CmpSetValueDataNew

__int64 __fastcall CmpSetValueDataNew(__int64 Hive, VOID *Src, size_t Size, _HSTORAGE_TYPE Type, __int64 a5){
  size_t v5; 
  bool v6; 
  int v10; 
  _HV_GET_CELL_CONTEXT *p_CellAddressContext; 
  int v13; 
  _DWORD *v14; 
  unsigned int v15; 
  int v16; 
  _DWORD *v17; 
  size_t v18; 
  unsigned __int16 i; 
  ULONG_PTR v20; 
  ULONG_PTR v21; 
  _DWORD *v22; 
  _HV_GET_CELL_CONTEXT CellAddressContext; 
  _HV_GET_CELL_CONTEXT v24; 
  _HV_GET_CELL_CONTEXT v25; 
  VOID *v26; 
  VOID *v27; 
  VOID *CellAddress; 

  v5 = Size;
  CellAddress = 0i64;
  CellAddressContext.Cell = -1;
  v6 = *(_DWORD *)(Hive + 212) < 4u;
  *(_DWORD *)&CellAddressContext.BinContext._bf_0 = 0;
  if( v6 || Size - 16345 > 0x7FFFC026 )
  {
    v10 = HvAllocateCell(Hive, Size, Type, &CellAddress, &CellAddressContext);
    *(_DWORD *)a5 = v10;
    if( v10 != -1 )
    {
      memmove(CellAddress, Src, v5);
      p_CellAddressContext = &CellAddressContext;
LABEL_5:
      (*(void(__fastcall **)(__int64, _HV_GET_CELL_CONTEXT *))(Hive + 16))(Hive, p_CellAddressContext);
      return 0i64;
    }
  }
  else
  {
    v26 = 0i64;
    *(_DWORD *)&v25.BinContext._bf_0 = 0;
    *(_DWORD *)&v24.BinContext._bf_0 = 0;
    v25.Cell = -1;
    v27 = 0i64;
    v24.Cell = -1;
    v13 = HvAllocateCell(Hive, 8ui64, Type, &v26, &v25);
    *(_DWORD *)a5 = v13;
    if( v13 != -1 )
    {
      v14 = v26;
      *(_DWORD *)v26 = 25188;
      v14[1] = -1;
      v15 = (v5 + 16343) / 0x3FD8;
      v16 = HvAllocateCell(Hive, 4 * (unsigned int)(unsigned __int16)v15, Type, &v27, &v24);
      v17 = v27;
      v14[1] = v16;
      if( v16 != -1 )
      {
        if( *((_WORD *)v14 + 1) >= (unsigned __int16)v15 )
        {
LABEL_13:
          (*(void(__fastcall **)(__int64, _HV_GET_CELL_CONTEXT *))(Hive + 16))(Hive, &v24);
          p_CellAddressContext = &v25;
          goto LABEL_5;
        }
        while( 1 )
        {
          v17[*((unsigned __int16 *)v14 + 1)] = HvAllocateCell(
                                                  Hive,
                                                  0x3FD8ui64,
                                                  Type,
                                                  &CellAddress,
                                                  &CellAddressContext);
          if( v17[*((unsigned __int16 *)v14 + 1)] == -1 )
            break;
          v18 = v5;
          if( v5 > 0x3FD8 )
            v18 = 16344;
          memmove(CellAddress, Src, v18);
          (*(void(__fastcall **)(__int64, _HV_GET_CELL_CONTEXT *))(Hive + 16))(Hive, &CellAddressContext);
          CellAddress = 0i64;
          ++*((_WORD *)v14 + 1);
          Src = (char *)Src + 16344;
          v5 -= 16344;
          if( *((_WORD *)v14 + 1) >= (unsigned __int16)v15 )
            goto LABEL_13;
        }
      }
      if( v17 )
      {
        for( i = *((_WORD *)v14 + 1); i; *((_WORD *)v14 + 1) = i )
        {
          v20 = v17[i];
          if( v20 != -1 )
          {
            HvFreeCell(Hive, v20);
            i = *((_WORD *)v14 + 1);
          }
          --i;
        }
        (*(void(__fastcall **)(__int64, _HV_GET_CELL_CONTEXT *))(Hive + 16))(Hive, &v24);
      }
      v21 = v14[1];
      if( v21 != -1 )
        HvFreeCell(Hive, v21);
      (*(void(__fastcall **)(__int64, _HV_GET_CELL_CONTEXT *))(Hive + 16))(Hive, &v25);
      v22 = (_DWORD *)a5;
      HvFreeCell(Hive, *(_DWORD *)a5);
      *v22 = -1;
    }
  }
  return 3221225626i64;
}

Referenced by:

CmpAddValueKeyNew
CmpCopyValue
CmpSetValueKeyExisting