RtlpRunOnceWaitForInit

UINT64 __stdcall RtlpRunOnceWaitForInit(UINT64 PreviousState, RTL_RUN_ONCE *RunOnce){
  UINT64 v3; 
  __int64 v5[4]; 
  __int128 v6; 
  v5[1] = 0i64;
  v5[2] = 0i64;
  v6 = 0i64;
  v5[3] = (__int64)KeGetCurrentThread();
  do
  {
    v5[0] = PreviousState & 0xFFFFFFFFFFFFFFFCui64;
    v3 = _InterlockedCompareExchange64((volatile signed __int64 *)RunOnce, (signed __int64)v5 + 1, PreviousState);
    if( PreviousState == v3 )
      break;
    PreviousState = v3;
  }
  while( (v3 & 3) == 1 );
  if( (PreviousState & 3) == 1 )
  {
    do
    {
      KeWaitForAlertByThreadId(0, 0i64, RunOnce);
      PreviousState = RunOnce->Value;
    }
    while( (BYTE4(v6) & 4) == 0 );
  }
  return PreviousState;
}

Referenced by:

RtlRunOnceBeginInitialize