PopEnableSystemSleepCheckpoint

INT64 __fastcall PopEnableSystemSleepCheckpoint(){
  char v0; 
  int v1; 
  __int32 v3; 
  __int32 v4; 
  UINT64 v5; 
  unsigned __int64 v6; 
  UINT64 RemainingStorageSize; 
  UINT64 QpcTimeStamp; 
  UINT64 MaximumVariableSize; 
  UINT64 MaxStorageSize; 
  MaximumVariableSize = 0i64;
  MaxStorageSize = 0i64;
  RemainingStorageSize = 0i64;
  QpcTimeStamp = 0i64;
  PopSleepReliabilityDetailedDiagEnabled = (unsigned int)Feature_SleepReliabilityDetailedDiagnostics__private_IsEnabled() != 0;
  PopCheckpointSystemSleepEnabled = 0;
  v0 = 0;
  _InterlockedExchange(&PopSleepCheckpointStatus, 0);
  if( PopCheckpointSystemSleepEnabledReg )
    goto LABEL_7;
  if( PopSleepReliabilityDetailedDiagEnabled )
  {
    v0 = 1;
LABEL_7:
    v3 = 4;
    goto LABEL_10;
  }
  if( !byte_140C23E54 || (*(_BYTE *)(&PopBsdPowerTransitionAtBoot + 1) & 0xF0) == 0 )
    return(unsigned int)-1073741271;
  v3 = 1;
LABEL_10:
  _InterlockedExchange(&PopSleepCheckpointStatus, v3);
  if( dword_140C19650 != 2 )
  {
    v1 = -1073741822;
    v4 = 8;
LABEL_13:
    _InterlockedExchange(&PopSleepCheckpointStatus, v4);
LABEL_23:
    PopTraceSleepCheckpointInitFailure();
    return(unsigned int)v1;
  }
  v1 = NtQueryEnvironmentVariableInfoEx(1ui64, &MaxStorageSize, &RemainingStorageSize, &MaximumVariableSize);
  if( v1 < 0 )
    goto LABEL_20;
  if( RemainingStorageSize <= 0x400 )
  {
    v1 = -1073740716;
    v4 = 9;
    goto LABEL_13;
  }
  v5 = KeQueryInterruptTimePrecise(&QpcTimeStamp);
  v1 = PopCheckpointSystemSleepUnsafe(PopSleepCheckpointInvalid);
  if( v1 < 0 )
  {
LABEL_20:
    _InterlockedExchange(&PopSleepCheckpointStatus, 15);
  }
  else
  {
    v6 = KeQueryInterruptTimePrecise(&QpcTimeStamp) - v5;
    if( v0 && v6 > 0x186A0 )
    {
      v1 = 258;
      _InterlockedExchange(&PopSleepCheckpointStatus, 10);
      return(unsigned int)v1;
    }
    PopCheckpointSystemSleepEnabled = 1;
    v1 = 0;
  }
  if( v1 < 0 )
    goto LABEL_23;
  return(unsigned int)v1;
}

Referenced by:

PopIssueActionRequest