CmpLightWeightPrepareAddKeyUoW

__int64 __fastcall CmpLightWeightPrepareAddKeyUoW(__int64 a1, __int64 a2, __int64 a3, struct _LOOKASIDE_LIST_EX *a4){
  unsigned int v5; 
  __int64 v6; 
  HSTORAGE_TYPE v7; 
  VOID *v8; 
  UINT64 v9; 
  __int64 v10; 
  UINT64 *v11; 
  int ModificationData; 
  unsigned int v13; 
  __int64 v14; 
  __int64(__fastcall *v15)(UINT64, _QWORD, int *); 
  char *v16; 
  unsigned int v17; 
  int v18; 
  _WORD *v19; 
  unsigned int v20; 
  __int64 v21; 
  CHAR v23; 
  UINT64 v24; 
  int v25[2]; 
  __int64 v26; 
  HSTORAGE_TYPE Type; 
  _HV_GET_CELL_CONTEXT CellAddressContext; 
  UINT64 *v29; 
  VOID *CellAddress; 
  v25[1] = 0;
  *(_DWORD *)&CellAddressContext.BinContext = 0;
  v5 = -1;
  v25[0] = -1;
  v6 = *(_QWORD *)(a1 + 48);
  v7 = *(_DWORD *)(a1 + 72);
  CellAddressContext.Cell = -1;
  Type = v7;
  v8 = 0i64;
  v9 = *(_QWORD *)(v6 + 32);
  v10 = *(_QWORD *)(a1 + 80);
  CellAddress = 0i64;
  v11 = *(UINT64 **)(v10 + 104);
  v29 = v11;
  if( v11 )
  {
    ++*(_DWORD *)v11;
  }
  else
  {
    ModificationData = CmpLightWeightCreateModificationData(a1, (unsigned int **)&v29, a3, a4);
    v11 = v29;
    v13 = ModificationData;
    if( ModificationData < 0 )
      goto LABEL_23;
    v7 = Type;
  }
  v14 = *(_QWORD *)(*(_QWORD *)(a1 + 48) + 72i64);
  v15 = *(__int64(__fastcall **)(UINT64, _QWORD, int *))(v9 + 8);
  v26 = v14;
  v29 = (UINT64 *)v15(v9, *(unsigned int *)(v14 + 40), v25);
  if( !v29 )
  {
    v13 = -1073741670;
    goto LABEL_23;
  }
  if( !HvMarkCellDirty(v9, *(unsigned int *)(*(_QWORD *)(a1 + 48) + 40i64), 1)
    || !HvMarkCellDirty(v9, *(unsigned int *)(v14 + 40), 1)
    || !HvMarkCellDirty(v9, *((unsigned int *)v29 + v7 + 7), 1) )
  {
    v13 = -1073741443;
    goto LABEL_19;
  }
  v16 = (char *)v11 + 4 * v7;
  if( *((_DWORD *)v16 + 3) != -1 )
  {
LABEL_14:
    LODWORD(v24) = Type;
    v20 = CmpCopyKeyPartial(
            v9,
            *(unsigned int *)(*(_QWORD *)(a1 + 48) + 40i64),
            v9,
            *(unsigned int *)(v26 + 40),
            38,
            v23,
            v24);
    v5 = v20;
    if( v20 == -1 || !CmpAddSubKeyToList(v9, (UINT64 *)(v16 + 12), v20) )
    {
      v13 = -1073741670;
    }
    else
    {
      ++*((_DWORD *)v11 + v7 + 1);
      v13 = 0;
      v21 = *(_QWORD *)(a1 + 48);
      *(_DWORD *)(a1 + 88) = *(_DWORD *)(v21 + 40);
      *(_DWORD *)(v21 + 40) = v5;
      v5 = -1;
      *(_QWORD *)(a1 + 104) = v11;
      v11 = 0i64;
    }
    goto LABEL_19;
  }
  v17 = *(_DWORD *)(v9 + 212);
  v18 = HvAllocateCell((_HHIVE *)v9, 0xCui64, Type, &CellAddress, &CellAddressContext);
  if( v18 != -1 )
  {
    v19 = CellAddress;
    *(_WORD *)CellAddress = v17 < 5 ? 26220 : 26732;
    v19[1] = 0;
    *((_DWORD *)v16 + 3) = v18;
    *((_DWORD *)v11 + v7 + 1) = 0;
    (*(void(__fastcall **)(UINT64, _HV_GET_CELL_CONTEXT *))(v9 + 16))(v9, &CellAddressContext);
    v8 = 0i64;
    goto LABEL_14;
  }
  v8 = CellAddress;
  v13 = -1073741670;
LABEL_19:
  (*(void(__fastcall **)(UINT64, int *))(v9 + 16))(v9, v25);
  if( v8 )
    (*(void(__fastcall **)(UINT64, _HV_GET_CELL_CONTEXT *))(v9 + 16))(v9, &CellAddressContext);
  if( v5 != -1 )
    CmpFreeKeyByCell((_HHIVE *)v9, v5, 0);
LABEL_23:
  if( v11 )
  {
    CmpLightWeightCleanupModifyKeyDataUoW(v9, v11);
    *(_QWORD *)(a1 + 104) = 0i64;
  }
  return v13;
}

Referenced by:

CmpProcessLightWeightUOW