RtlpLookupOrCreateLowBox

INT64 *__fastcall RtlpLookupOrCreateLowBox(INT64 a1, INT64 a2, CHAR a3){
  int LowBoxId; 
  INT64 **v6; 
  INT64 *result; 
  __int16 v8; 
  __int16 v9; 
  INT64 *v10; 
  __int16 v11; 
  if( (*(_DWORD *)(a1 + 24) & 1) != 0 )
    LowBoxId = 0;
  else
    LowBoxId = RtlpQueryLowBoxId();
  v6 = (INT64 **)(a2 + 16);
  if( !LowBoxId )
    return(INT64 *)(a2 + 16);
  for( result = *v6; result != (INT64 *)v6; result = (INT64 *)*result )
  {
    if( *((_DWORD *)result + 4) == LowBoxId )
    {
      if( a3 )
      {
        v8 = *((_WORD *)result + 11);
        if( (v8 & 4) == 0 )
        {
          v9 = *((_WORD *)result + 10);
          if( v9 == -1 )
            v8 |= 1u;
          else
            *((_WORD *)result + 10) = v9 + 1;
          *((_WORD *)result + 11) = v8 | 4;
        }
      }
      return result;
    }
  }
  result = (INT64 *)RtlpAllocateAtom(0x18ui64, 0x4C6D7441ui64);
  if( result )
  {
    v10 = *v6;
    if( (INT64 **)(*v6)[1] != v6 )
      __fastfail(3u);
    *result = (INT64)v10;
    result[1] = (INT64)v6;
    v10[1] = (INT64)result;
    *v6 = result;
    *((_DWORD *)result + 5) = 0;
    *((_DWORD *)result + 4) = LowBoxId;
    if( a3 )
    {
      *((_DWORD *)result + 5) = 262145;
      v11 = *(_WORD *)(a2 + 36);
      if( v11 == -1 )
        *(_WORD *)(a2 + 38) |= 1u;
      else
        *(_WORD *)(a2 + 36) = v11 + 1;
    }
  }
  return result;
}

Referenced by:

RtlpHashStringToAtom