decompiled_code:
float __fastcall gi_OffencePlay_ComputeBase(__int64 a1, int a2, __int64 a3)
{
__int64 v4; // rbx
unsigned __int64 v5; // rbp
float v7; // [rsp+8h] [rbp-30h]
float v8; // [rsp+Ch] [rbp-2Ch]

if ( !*(_QWORD *)(a1 + 4560) )
return 0.0;
v4 = a1 + 528;
v7 = 0.0;
v5 = 0LL;
do
{
if ( (unsigned int)gi_PositionValue_GetBasePosition(v4) == a2 && !(unsigned int)gi_PositionValue_GetValueType(v4) )
{
v8 = *(float *)(a3 + 4LL * (unsigned int)gi_PositionValue_GetQST(v4));
v7 = (float)(gi_PositionValue_GetFloatValue(v4) * v8) + v7;
}
++v5;
v4 += 32LL;
}
while ( *(_QWORD *)(a1 + 4560) > v5 );
return v7;
}

canonical_decompiled_code:
float __fastcall func4(__int64 a1, int a2, __int64 a3)
{
__int64 v4; // rbx
unsigned __int64 v5; // rbp
float v7; // [rsp+8h] [rbp-30h]
float v8; // [rsp+Ch] [rbp-2Ch]

if ( !*(_QWORD *)(a1 + 4560) )
return 0.0;
v4 = a1 + 528;
v7 = 0.0;
v5 = 0LL;
do
{
if ( (unsigned int)gi_PositionValue_GetBasePosition(v4) == a2 && !(unsigned int)gi_PositionValue_GetValueType(v4) )
{
v8 = *(float *)(a3 + 4LL * (unsigned int)gi_PositionValue_GetQST(v4));
v7 = (float)(gi_PositionValue_GetFloatValue(v4) * v8) + v7;
}
++v5;
v4 += 32LL;
}
while ( *(_QWORD *)(a1 + 4560) > v5 );
return v7;
}

original_code:
float gi_OffencePlay_ComputeBase(const gi_OffencePlay* const pThis, const GI_POSITION playerPosition, const float* const playerQST)
{
 size_t i;
 float baseValue = 0.0f;
 for (i = 0; i < pThis->m_numBase; i++)
 {
  const gi_PositionValue* const pPositionValue = &pThis->m_base[i];
  if (gi_PositionValue_GetBasePosition(pPositionValue) == playerPosition)
  {
   if (gi_PositionValue_GetValueType(pPositionValue) == GI_TYPE_FLOAT)
   {
    const GI_QST playQST = gi_PositionValue_GetQST(pPositionValue);
    const float playerStat = playerQST[playQST] * gi_PositionValue_GetFloatValue(pPositionValue);
    baseValue += playerStat;
   }
  }
 }
 return baseValue;
}

canonical_original_code:
float gi_OffencePlay_ComputeBase(struct gi_OffencePlay *pThis, enum GI_POSITION playerPosition, float *playerQST)
{
 unsigned long i;
 float baseValue = 0.0f;
 for (i = 0; i < pThis->m_numBase; i++)
 {
  struct gi_PositionValue *pPositionValue = &pThis->m_base[i];
  if (gi_PositionValue_GetBasePosition(pPositionValue) == playerPosition)
  {
   if (gi_PositionValue_GetValueType(pPositionValue) == GI_TYPE_FLOAT)
   {
    enum GI_QST playQST = gi_PositionValue_GetQST(pPositionValue);
    float playerStat = playerQST[playQST] * gi_PositionValue_GetFloatValue(pPositionValue);
    baseValue += playerStat;
   }
  }
 }
 return baseValue;
}

variable_types: enum GI_POSITION { GI_POSITION_QB=0, GI_POSITION_RB=1, GI_POSITION_WR=2, GI_POSITION_TE=3, GI_POSITION_OC=4, GI_POSITION_OG=5, GI_POSITION_OT=6, GI_POSITION_DE=7, GI_POSITION_DT=8, GI_POSITION_IB=9, GI_POSITION_OB=10, GI_POSITION_CB=11, GI_POSITION_SF=12, GI_POSITION_R=13, GI_POSITION_K=14, GI_POSITION_P=15, GI_POSITION_SE=16, GI_POSITION_FL=17, GI_POSITION_RB1=18, GI_POSITION_RB2=19, GI_POSITION_TE1=20, GI_POSITION_TE2=21, GI_POSITION_LG=22, GI_POSITION_RG=23, GI_POSITION_LT=24, GI_POSITION_RT=25, GI_POSITION_HB=26, GI_POSITION_FB=27, GI_POSITION_FS=28, GI_POSITION_SS=29, GI_POSITION_C=30, GI_POSITION_NT=31, GI_POSITION_LE=32, GI_POSITION_RE=33, GI_POSITION_LILB=34, GI_POSITION_MILB=35, GI_POSITION_RILB=36, GI_POSITION_LOLB=37, GI_POSITION_ROLB=38, GI_POSITION_LCB=39, GI_POSITION_RCB=40, GI_POSITION_UNKNOWN=41, GI_POSITION_NUM=expr }

variable_types:
playerQST
float *

variable_types: baseValue float

variable_types: enum GI_QST { GI_QST_Q=0, GI_QST_S=1, GI_QST_T=2, GI_QST_NONE=3, GI_QST_UNKNOWN=4, GI_QST_NUM=expr }

variable_types: playerStat float


decompiled_code:
__int64 __fastcall gi_OffencePlay_GetName(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return a1;
}

original_code:
const char* gi_OffencePlay_GetName(const gi_OffencePlay* const pThis)
{
 return pThis->m_name;
}

canonical_original_code:
char *gi_OffencePlay_GetName(struct gi_OffencePlay *pThis)
{
 return pThis->m_name;
}

variable_types: struct gi_OffencePlay { char m_name[-1]; char m_defence[-1][-1]; struct gi_PositionValue { char m_positionName[-1]; enum GI_POSITION { GI_POSITION_QB=0, GI_POSITION_RB=1, GI_POSITION_WR=2, GI_POSITION_TE=3, GI_POSITION_OC=4, GI_POSITION_OG=5, GI_POSITION_OT=6, GI_POSITION_DE=7, GI_POSITION_DT=8, GI_POSITION_IB=9, GI_POSITION_OB=10, GI_POSITION_CB=11, GI_POSITION_SF=12, GI_POSITION_R=13, GI_POSITION_K=14, GI_POSITION_P=15, GI_POSITION_SE=16, GI_POSITION_FL=17, GI_POSITION_RB1=18, GI_POSITION_RB2=19, GI_POSITION_TE1=20, GI_POSITION_TE2=21, GI_POSITION_LG=22, GI_POSITION_RG=23, GI_POSITION_LT=24, GI_POSITION_RT=25, GI_POSITION_HB=26, GI_POSITION_FB=27, GI_POSITION_FS=28, GI_POSITION_SS=29, GI_POSITION_C=30, GI_POSITION_NT=31, GI_POSITION_LE=32, GI_POSITION_RE=33, GI_POSITION_LILB=34, GI_POSITION_MILB=35, GI_POSITION_RILB=36, GI_POSITION_LOLB=37, GI_POSITION_ROLB=38, GI_POSITION_LCB=39, GI_POSITION_RCB=40, GI_POSITION_UNKNOWN=41, GI_POSITION_NUM=expr } m_position; enum GI_POSITION { GI_POSITION_QB=0, GI_POSITION_RB=1, GI_POSITION_WR=2, GI_POSITION_TE=3, GI_POSITION_OC=4, GI_POSITION_OG=5, GI_POSITION_OT=6, GI_POSITION_DE=7, GI_POSITION_DT=8, GI_POSITION_IB=9, GI_POSITION_OB=10, GI_POSITION_CB=11, GI_POSITION_SF=12, GI_POSITION_R=13, GI_POSITION_K=14, GI_POSITION_P=15, GI_POSITION_SE=16, GI_POSITION_FL=17, GI_POSITION_RB1=18, GI_POSITION_RB2=19, GI_POSITION_TE1=20, GI_POSITION_TE2=21, GI_POSITION_LG=22, GI_POSITION_RG=23, GI_POSITION_LT=24, GI_POSITION_RT=25, GI_POSITION_HB=26, GI_POSITION_FB=27, GI_POSITION_FS=28, GI_POSITION_SS=29, GI_POSITION_C=30, GI_POSITION_NT=31, GI_POSITION_LE=32, GI_POSITION_RE=33, GI_POSITION_LILB=34, GI_POSITION_MILB=35, GI_POSITION_RILB=36, GI_POSITION_LOLB=37, GI_POSITION_ROLB=38, GI_POSITION_LCB=39, GI_POSITION_RCB=40, GI_POSITION_UNKNOWN=41, GI_POSITION_NUM=expr } m_basePosition; union PositionValue_Value { float f; unsigned long i; } m_value; enum GI_QST { GI_QST_Q=0, GI_QST_S=1, GI_QST_T=2, GI_QST_NONE=3, GI_QST_UNKNOWN=4, GI_QST_NUM=expr } m_qst; enum GI_TYPE { GI_TYPE_FLOAT=0, GI_TYPE_INT=1, GI_TYPE_UNKNOWN=2 } m_valueType; } m_base[-1]; struct gi_PositionValue m_bc[-1]; struct gi_PositionValue m_weighting[-1]; unsigned long m_numBase; unsigned long m_numBC; unsigned long m_numWeighting; } *

return_type: char *

user_defined_types: struct gi_OffencePlay { char m_name[-1]; char m_defence[-1][-1]; struct gi_PositionValue m_base[-1]; struct gi_PositionValue m_bc[-1]; struct gi_PositionValue m_weighting[-1]; unsigned long m_numBase; unsigned long m_numBC; unsigned long m_numWeighting; }

user_defined_types: struct gi_PositionValue { char m_positionName[-1]; enum GI_POSITION m_position; enum GI_POSITION m_basePosition; union PositionValue_Value m_value; enum GI_QST m_qst; enum GI_TYPE m_valueType; }


decompiled_code:
__int64 __fastcall gi_OffencePlay_GetDefence(__int64 a1, __int64 a2)
{
return a1 + 16 * (a2 + 1);
}

original_code:
const char* gi_OffencePlay_GetDefence(const gi_OffencePlay* const pThis, const size_t defenceIndex)
{
 return pThis->m_defence[defenceIndex];
}

canonical_original_code:
char *gi_OffencePlay_GetDefence(struct gi_OffencePlay *pThis, unsigned long defenceIndex)
{
 return pThis->m_defence[defenceIndex];
}

variable_types:
defenceIndex
unsigned long

user_defined_types: enum GI_POSITION { GI_POSITION_QB=0, GI_POSITION_RB=1, GI_POSITION_WR=2, GI_POSITION_TE=3, GI_POSITION_OC=4, GI_POSITION_OG=5, GI_POSITION_OT=6, GI_POSITION_DE=7, GI_POSITION_DT=8, GI_POSITION_IB=9, GI_POSITION_OB=10, GI_POSITION_CB=11, GI_POSITION_SF=12, GI_POSITION_R=13, GI_POSITION_K=14, GI_POSITION_P=15, GI_POSITION_SE=16, GI_POSITION_FL=17, GI_POSITION_RB1=18, GI_POSITION_RB2=19, GI_POSITION_TE1=20, GI_POSITION_TE2=21, GI_POSITION_LG=22, GI_POSITION_RG=23, GI_POSITION_LT=24, GI_POSITION_RT=25, GI_POSITION_HB=26, GI_POSITION_FB=27, GI_POSITION_FS=28, GI_POSITION_SS=29, GI_POSITION_C=30, GI_POSITION_NT=31, GI_POSITION_LE=32, GI_POSITION_RE=33, GI_POSITION_LILB=34, GI_POSITION_MILB=35, GI_POSITION_RILB=36, GI_POSITION_LOLB=37, GI_POSITION_ROLB=38, GI_POSITION_LCB=39, GI_POSITION_RCB=40, GI_POSITION_UNKNOWN=41, GI_POSITION_NUM=expr }

user_defined_types: union PositionValue_Value { float f; unsigned long i; }

user_defined_types: enum GI_QST { GI_QST_Q=0, GI_QST_S=1, GI_QST_T=2, GI_QST_NONE=3, GI_QST_UNKNOWN=4, GI_QST_NUM=expr }

user_defined_types: enum GI_TYPE { GI_TYPE_FLOAT=0, GI_TYPE_INT=1, GI_TYPE_UNKNOWN=2 }


decompiled_code:
void __fastcall BlockAllocator_Destroy(_QWORD *a1)
{
_QWORD *v1; // rbx
void *v3; // rdi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v3 = v1;
v1 = (_QWORD *)v1[3];
free(v3);
*a1 = v1;
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func1(_QWORD *a1)
{
_QWORD *v1; // rbx
void *v3; // rdi

v1 = (_QWORD *)*a1;
if ( *a1 )
{
do
{
v3 = v1;
v1 = (_QWORD *)v1[3];
free(v3);
*a1 = v1;
}
while ( v1 );
}
}

original_code:
void BlockAllocator_Destroy(BlockAllocator* const pThis)
{
 while (pThis->m_head)
 {
  Block* const temp = pThis->m_head->m_next;
  free(pThis->m_head);
  pThis->m_head = temp;
 }
}

canonical_original_code:
void BlockAllocator_Destroy(struct BlockAllocator *pThis)
{
 while (pThis->m_head)
 {
  struct Block *temp = pThis->m_head->m_next;
  free(pThis->m_head);
  pThis->m_head = temp;
 }
}

variable_types: struct BlockAllocator { struct Block { unsigned long m_size; unsigned long m_used; char *m_buffer; struct Block *m_next; } *m_head; unsigned long m_blocksize; } *

return_type: void

user_defined_types: struct BlockAllocator { struct Block *m_head; unsigned long m_blocksize; }


decompiled_code:
void __fastcall BlockAllocator_Free(__int64 *a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3[3]; // [rsp+0h] [rbp-18h] BYREF

v1 = a1[1];
a1[1] = 0LL;
v3[1] = v1;
v2 = *a1;
*a1 = 0LL;
v3[0] = v2;
BlockAllocator_Destroy(v3);
}

original_code:
void BlockAllocator_Free(BlockAllocator* const pThis)
{
 BlockAllocator temp;
 temp.m_blocksize = pThis->m_blocksize;
 temp.m_head = pThis->m_head;
 pThis->m_blocksize = 0;
 pThis->m_head = ((void *)0);
 BlockAllocator_Destroy(&temp);
}

canonical_original_code:
void BlockAllocator_Free(struct BlockAllocator *pThis)
{
 struct BlockAllocator temp;
 temp.m_blocksize = pThis->m_blocksize;
 temp.m_head = pThis->m_head;
 pThis->m_blocksize = 0;
 pThis->m_head = ((void *)0);
 BlockAllocator_Destroy(&temp);
}

variable_types: struct BlockAllocator { struct Block { unsigned long m_size; unsigned long m_used; char *m_buffer; struct Block *m_next; } *m_head; unsigned long m_blocksize; }


original_code:
void* BlockAllocator_Malloc(BlockAllocator* const pThis, const size_t size)
{
 void* ptr;
 if ((pThis->m_head && pThis->m_head->m_used + size > pThis->m_head->m_size) || !pThis->m_head)
 {
  size_t alloc_size = ((sizeof(Block) + size) > pThis->m_blocksize) ? (sizeof(Block) + size) : pThis->m_blocksize;
  char* buffer = (char*)malloc(alloc_size);
  Block* b = (Block*)(buffer);
  b->m_size = alloc_size;
  b->m_used = sizeof(Block);
  b->m_buffer = buffer;
  b->m_next = pThis->m_head;
  pThis->m_head = b;
 }
 ptr = pThis->m_head->m_buffer + pThis->m_head->m_used;
 pThis->m_head->m_used += size;
 return ptr;
}

canonical_original_code:
void *BlockAllocator_Malloc(struct BlockAllocator *pThis, unsigned long size)
{
 void *ptr;
 if ((pThis->m_head && pThis->m_head->m_used + size > pThis->m_head->m_size) || !pThis->m_head)
 {
  unsigned long alloc_size = ((sizeof(Block) + size) > pThis->m_blocksize) ? (sizeof(Block) + size) : pThis->m_blocksize;
  char *buffer = (char*)malloc(alloc_size);
  struct Block *b = (Block*)(buffer);
  b->m_size = alloc_size;
  b->m_used = sizeof(Block);
  b->m_buffer = buffer;
  b->m_next = pThis->m_head;
  pThis->m_head = b;
 }
 ptr = pThis->m_head->m_buffer + pThis->m_head->m_used;
 pThis->m_head->m_used += size;
 return ptr;
}

variable_types:
size
unsigned long

variable_types:
ptr
void *

variable_types:
buffer
char *

variable_types: struct Block { unsigned long m_size; unsigned long m_used; char *m_buffer; struct Block *m_next; } *

return_type: void *


decompiled_code:
_BOOL8 __fastcall SizetItem_CompareSmaller(_QWORD *a1, _QWORD *a2)
{
return *a1 < *a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_QWORD *a1, _QWORD *a2)
{
return *a1 < *a2;
}

original_code:
int SizetItem_CompareSmaller(const void* a, const void* b)
{
 const size_t valueA = ((const SizetItem*)a)->m_value;
 const size_t valueB = ((const SizetItem*)b)->m_value;
 return (valueA < valueB);
}

canonical_original_code:
int SizetItem_CompareSmaller(void *a, void *b)
{
 unsigned long valueA = ((const SizetItem*)a)->m_value;
 unsigned long valueB = ((const SizetItem*)b)->m_value;
 return (valueA < valueB);
}

variable_types:
a
void *

variable_types:
b
void *

variable_types:
valueA
unsigned long

variable_types:
valueB
unsigned long

return_type: int


decompiled_code:
_BOOL8 __fastcall SizetItem_CompareBigger(_QWORD *a1, _QWORD *a2)
{
return *a1 > *a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(_QWORD *a1, _QWORD *a2)
{
return *a1 > *a2;
}

original_code:
int SizetItem_CompareBigger(const void* a, const void* b)
{
 const size_t valueA = ((const SizetItem*)a)->m_value;
 const size_t valueB = ((const SizetItem*)b)->m_value;
 return (valueA > valueB);
}

canonical_original_code:
int SizetItem_CompareBigger(void *a, void *b)
{
 unsigned long valueA = ((const SizetItem*)a)->m_value;
 unsigned long valueB = ((const SizetItem*)b)->m_value;
 return (valueA > valueB);
}


decompiled_code:
_BOOL8 __fastcall FloatItem_CompareSmaller(float *a1, float *a2)
{
return *a2 > *a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(float *a1, float *a2)
{
return *a2 > *a1;
}

original_code:
int FloatItem_CompareSmaller(const void* a, const void* b)
{
 const float valueA = ((const FloatItem*)a)->m_value;
 const float valueB = ((const FloatItem*)b)->m_value;
 return (valueA < valueB);
}

canonical_original_code:
int FloatItem_CompareSmaller(void *a, void *b)
{
 float valueA = ((const FloatItem*)a)->m_value;
 float valueB = ((const FloatItem*)b)->m_value;
 return (valueA < valueB);
}

variable_types: valueA float

variable_types: valueB float


decompiled_code:
_BOOL8 __fastcall FloatItem_CompareBigger(float *a1, float *a2)
{
return *a1 > *a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(float *a1, float *a2)
{
return *a1 > *a2;
}

original_code:
int FloatItem_CompareBigger(const void* a, const void* b)
{
 const float valueA = ((const FloatItem*)a)->m_value;
 const float valueB = ((const FloatItem*)b)->m_value;
 return (valueA > valueB);
}

canonical_original_code:
int FloatItem_CompareBigger(void *a, void *b)
{
 float valueA = ((const FloatItem*)a)->m_value;
 float valueB = ((const FloatItem*)b)->m_value;
 return (valueA > valueB);
}


decompiled_code:
float __fastcall gi_SpecialTeamsValues_GetProtector(__int64 a1)
{
return *(float *)a1;
}

canonical_decompiled_code:
float __fastcall func2(__int64 a1)
{
return *(float *)a1;
}

original_code:
float gi_SpecialTeamsValues_GetProtector(const gi_SpecialTeamsValues* const pThis)
{
 return pThis->m_protector;
}

canonical_original_code:
float gi_SpecialTeamsValues_GetProtector(struct gi_SpecialTeamsValues *pThis)
{
 return pThis->m_protector;
}

variable_types: struct gi_SpecialTeamsValues { float m_protector; float m_blocker; float m_runner; float m_gunner; } *

return_type: float


decompiled_code:
float __fastcall gi_SpecialTeamsValues_GetBlocker(__int64 a1)
{
return *(float *)(a1 + 4);
}

canonical_decompiled_code:
float __fastcall func3(__int64 a1)
{
return *(float *)(a1 + 4);
}

original_code:
float gi_SpecialTeamsValues_GetBlocker(const gi_SpecialTeamsValues* const pThis)
{
 return pThis->m_blocker;
}

canonical_original_code:
float gi_SpecialTeamsValues_GetBlocker(struct gi_SpecialTeamsValues *pThis)
{
 return pThis->m_blocker;
}

user_defined_types: struct gi_SpecialTeamsValues { float m_protector; float m_blocker; float m_runner; float m_gunner; }


decompiled_code:
float __fastcall gi_SpecialTeamsValues_GetRunner(__int64 a1)
{
return *(float *)(a1 + 8);
}

canonical_decompiled_code:
float __fastcall func4(__int64 a1)
{
return *(float *)(a1 + 8);
}

original_code:
float gi_SpecialTeamsValues_GetRunner(const gi_SpecialTeamsValues* const pThis)
{
 return pThis->m_runner;
}

canonical_original_code:
float gi_SpecialTeamsValues_GetRunner(struct gi_SpecialTeamsValues *pThis)
{
 return pThis->m_runner;
}


decompiled_code:
float __fastcall gi_SpecialTeamsValues_GetGunner(__int64 a1)
{
return *(float *)(a1 + 12);
}

canonical_decompiled_code:
float __fastcall func5(__int64 a1)
{
return *(float *)(a1 + 12);
}

original_code:
float gi_SpecialTeamsValues_GetGunner(const gi_SpecialTeamsValues* const pThis)
{
 return pThis->m_gunner;
}

canonical_original_code:
float gi_SpecialTeamsValues_GetGunner(struct gi_SpecialTeamsValues *pThis)
{
 return pThis->m_gunner;
}


matrixFree

original_code:
void matrixFree(NtscMatrix* const ntscMatrix)
{
 unsigned int i;
 const unsigned int numRows = ntscMatrix->m_numRows;
 float** const matrix = ntscMatrix->m_matrix;
 for (i = 0; i < numRows; i++)
 {
  free(matrix[i]);
 }
 free(matrix);
 ntscMatrix->m_matrix = ((void *)0);
 ntscMatrix->m_numRows = 0;
 ntscMatrix->m_numCols = 0;
}

canonical_original_code:
void matrixFree(struct NtscMatrix *ntscMatrix)
{
 unsigned int i;
 unsigned int numRows = ntscMatrix->m_numRows;
 float **matrix = ntscMatrix->m_matrix;
 for (i = 0; i < numRows; i++)
 {
  free(matrix[i]);
 }
 free(matrix);
 ntscMatrix->m_matrix = ((void *)0);
 ntscMatrix->m_numRows = 0;
 ntscMatrix->m_numCols = 0;
}

variable_types: struct NtscMatrix { float **m_matrix; unsigned int m_numRows; unsigned int m_numCols; char *m_name; } *

variable_types:
i
unsigned int

variable_types:
numRows
unsigned int

variable_types:
matrix
float **


matrixMultiply

decompiled_code:
__int64 __fastcall matrixMultiply(__int64 *a1, __int64 a2, __int64 *a3)
{
__int64 result; // rax
unsigned int v4; // esi
__int64 v5; // r8
int v6; // ebx
unsigned int v7; // er12
__int64 v8; // rbp
__int64 v9; // r10
__int64 v10; // r14
__int64 v11; // r9
__int64 v12; // r9
__int64 v13; // r9
__int64 v14; // r13
float *v15; // rdx
__int64 v16; // rcx
float *v17; // r11
__int64 v18; // rsi
float v19; // xmm1_4
float v20; // xmm0_4

result = a2;
v4 = *(_DWORD *)(a2 + 8);
v5 = *((unsigned int *)a1 + 2);
v6 = *(_DWORD *)(result + 12);
v7 = *((_DWORD *)a3 + 3);
v8 = *(_QWORD *)result;
v9 = *a3;
v10 = *a1;
if ( (_DWORD)v5 != v4 )
{
fprintf(
stderr,
"ERROR: matrixMultiply: left:'%s' result:'%s' numRowsLeft != numRowsResult %d != %d\n",
*(_QWORD *)(result + 16),
a1[2],
v4,
(unsigned int)v5);
goto LABEL_15;
}
v11 = *((unsigned int *)a1 + 3);
if ( (_DWORD)v11 != v7 )
{
fprintf(
stderr,
"ERROR: matrixMultiply: right:'%s' result:'%s' numColsRight != numColsResult %d != %d\n",
a3[2],
a1[2],
v7,
v11);
LABEL_15:
exit(-1);
}
v12 = *((unsigned int *)a3 + 2);
if ( (_DWORD)v12 != v6 )
{
fprintf(
stderr,
"ERROR: matrixMultiply: left:'%s' right:'%s' numColsLeft != numRowsRight %d != %d\n",
*(_QWORD *)(result + 16),
a3[2],
v5,
v12);
goto LABEL_15;
}
if ( (_DWORD)v5 )
{
result = v7 - 1;
v13 = 0LL;
v14 = 4 * result + 4;
do
{
if ( v7 )
{
v15 = *(float **)(v10 + 8 * v13);
v16 = 0LL;
v17 = (float *)((char *)v15 + v14);
do
{
*v15 = 0.0;
if ( v6 )
{
v18 = *(_QWORD *)(v8 + 8 * v13);
result = 0LL;
v19 = 0.0;
do
{
v20 = *(float *)(*(_QWORD *)(v9 + 8 * result) + v16) * *(float *)(v18 + 4 * result);
++result;
v19 = v19 + v20;
*v15 = v19;
}
while ( result != v6 );
}
++v15;
v16 += 4LL;
}
while ( v17 != v15 );
}
++v13;
}
while ( v13 != v5 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, __int64 a2, __int64 *a3)
{
__int64 result; // rax
unsigned int v4; // esi
__int64 v5; // r8
int v6; // ebx
unsigned int v7; // er12
__int64 v8; // rbp
__int64 v9; // r10
__int64 v10; // r14
__int64 v11; // r9
__int64 v12; // r9
__int64 v13; // r9
__int64 v14; // r13
float *v15; // rdx
__int64 v16; // rcx
float *v17; // r11
__int64 v18; // rsi
float v19; // xmm1_4
float v20; // xmm0_4

result = a2;
v4 = *(_DWORD *)(a2 + 8);
v5 = *((unsigned int *)a1 + 2);
v6 = *(_DWORD *)(result + 12);
v7 = *((_DWORD *)a3 + 3);
v8 = *(_QWORD *)result;
v9 = *a3;
v10 = *a1;
if ( (_DWORD)v5 != v4 )
{
fprintf(
stderr,
"ERROR: matrixMultiply: left:'%s' result:'%s' numRowsLeft != numRowsResult %d != %d\n",
*(_QWORD *)(result + 16),
a1[2],
v4,
(unsigned int)v5);
goto LABEL_15;
}
v11 = *((unsigned int *)a1 + 3);
if ( (_DWORD)v11 != v7 )
{
fprintf(
stderr,
"ERROR: matrixMultiply: right:'%s' result:'%s' numColsRight != numColsResult %d != %d\n",
a3[2],
a1[2],
v7,
v11);
LABEL_15:
exit(-1);
}
v12 = *((unsigned int *)a3 + 2);
if ( (_DWORD)v12 != v6 )
{
fprintf(
stderr,
"ERROR: matrixMultiply: left:'%s' right:'%s' numColsLeft != numRowsRight %d != %d\n",
*(_QWORD *)(result + 16),
a3[2],
v5,
v12);
goto LABEL_15;
}
if ( (_DWORD)v5 )
{
result = v7 - 1;
v13 = 0LL;
v14 = 4 * result + 4;
do
{
if ( v7 )
{
v15 = *(float **)(v10 + 8 * v13);
v16 = 0LL;
v17 = (float *)((char *)v15 + v14);
do
{
*v15 = 0.0;
if ( v6 )
{
v18 = *(_QWORD *)(v8 + 8 * v13);
result = 0LL;
v19 = 0.0;
do
{
v20 = *(float *)(*(_QWORD *)(v9 + 8 * result) + v16) * *(float *)(v18 + 4 * result);
++result;
v19 = v19 + v20;
*v15 = v19;
}
while ( result != v6 );
}
++v15;
v16 += 4LL;
}
while ( v17 != v15 );
}
++v13;
}
while ( v13 != v5 );
}
return result;
}

original_code:
void matrixMultiply(NtscMatrix* const ntscResult, const NtscMatrix* const ntscLeft, const NtscMatrix* const ntscRight)
{
 unsigned int i;
 const unsigned int numRowsLeft = ntscLeft->m_numRows;
 const unsigned int numColsLeft = ntscLeft->m_numCols;
 const unsigned int numColsRight = ntscRight->m_numCols;
 const float** const left = (const float** const)ntscLeft->m_matrix;
 const float** const right = (const float** const)ntscRight->m_matrix;
 float** const result = ntscResult->m_matrix;
 if (numRowsLeft != ntscResult->m_numRows)
 {
  fprintf(stderr,"ERROR: matrixMultiply: left:'%s' result:'%s' numRowsLeft != numRowsResult %d != %d\n",
      ntscLeft->m_name, ntscResult->m_name, numRowsLeft, ntscResult->m_numRows);
  exit(-1);
 }
 if (numColsRight != ntscResult->m_numCols)
 {
  fprintf(stderr,"ERROR: matrixMultiply: right:'%s' result:'%s' numColsRight != numColsResult %d != %d\n",
      ntscRight->m_name, ntscResult->m_name, numColsRight, ntscResult->m_numCols);
  exit(-1);
 }
 if (numColsLeft != ntscRight->m_numRows)
 {
  fprintf(stderr,"ERROR: matrixMultiply: left:'%s' right:'%s' numColsLeft != numRowsRight %d != %d\n",
      ntscLeft->m_name, ntscRight->m_name, numRowsLeft, ntscRight->m_numRows);
  exit(-1);
 }
 for (i = 0; i < numRowsLeft; i++)
 {
  unsigned int j;
  for (j = 0; j < numColsRight; j++)
  {
   unsigned int k;
   result[i][j] = 0.0f;
   for (k = 0; k < numColsLeft; k++)
   {
    result[i][j] += left[i][k] * right[k][j];
   }
  }
 }
}

canonical_original_code:
void matrixMultiply(struct NtscMatrix *ntscResult, struct NtscMatrix *ntscLeft, struct NtscMatrix *ntscRight)
{
 unsigned int i;
 unsigned int numRowsLeft = ntscLeft->m_numRows;
 unsigned int numColsLeft = ntscLeft->m_numCols;
 unsigned int numColsRight = ntscRight->m_numCols;
 float **left = (const float** const)ntscLeft->m_matrix;
 float **right = (const float** const)ntscRight->m_matrix;
 float **result = ntscResult->m_matrix;
 if (numRowsLeft != ntscResult->m_numRows)
 {
  fprintf(stderr,"ERROR: matrixMultiply: left:'%s' result:'%s' numRowsLeft != numRowsResult %d != %d\n",
      ntscLeft->m_name, ntscResult->m_name, numRowsLeft, ntscResult->m_numRows);
  exit(-1);
 }
 if (numColsRight != ntscResult->m_numCols)
 {
  fprintf(stderr,"ERROR: matrixMultiply: right:'%s' result:'%s' numColsRight != numColsResult %d != %d\n",
      ntscRight->m_name, ntscResult->m_name, numColsRight, ntscResult->m_numCols);
  exit(-1);
 }
 if (numColsLeft != ntscRight->m_numRows)
 {
  fprintf(stderr,"ERROR: matrixMultiply: left:'%s' right:'%s' numColsLeft != numRowsRight %d != %d\n",
      ntscLeft->m_name, ntscRight->m_name, numRowsLeft, ntscRight->m_numRows);
  exit(-1);
 }
 for (i = 0; i < numRowsLeft; i++)
 {
  unsigned int j;
  for (j = 0; j < numColsRight; j++)
  {
   unsigned int k;
   result[i][j] = 0.0f;
   for (k = 0; k < numColsLeft; k++)
   {
    result[i][j] += left[i][k] * right[k][j];
   }
  }
 }
}

variable_types:
ntscLeft
struct NtscMatrix *

variable_types:
ntscRight
struct NtscMatrix *

variable_types:
numRowsLeft
unsigned int

variable_types:
numColsLeft
unsigned int

variable_types:
numColsRight
unsigned int

variable_types:
left
float **

variable_types:
right
float **

variable_types:
result
float **

variable_types:
j
unsigned int

variable_types:
k
unsigned int

user_defined_types: struct NtscMatrix { float **m_matrix; unsigned int m_numRows; unsigned int m_numCols; char *m_name; }


main

canonical_name: main

repo: Zuckonit/callmewash

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rax
char v4; // bl
int v5; // eax

welcome(argc, argv, envp);
init();
v3 = (const char *)read_file(f_record);
printf("%s days after your last washing!\n", v3);
if ( !(unsigned int)update_date() )
{
printf("You have checked today!");
exit(1);
}
printf("Have you washed your clothes? (Y/N)/(y/n): ");
v4 = getchar();
getchar();
v5 = input((unsigned int)v4);
if ( v5 )
{
if ( v5 == 1 )
{
puts(&byte_402146);
plus_day();
update_date();
}
else
{
puts("Error input, only (Y/N)/(y/n) admitted!");
}
}
else
{
puts("=3");
write_file(f_record, "1");
update_date();
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rax
char v4; // bl
int v5; // eax

func11(argc, argv, envp);
func14();
v3 = (const char *)func7(f_record);
printf("%s days after your last washing!\n", v3);
if ( !(unsigned int)func13() )
{
printf("You have checked today!");
exit(1);
}
printf("Have you washed your clothes? (Y/N)/(y/n): ");
v4 = getchar();
getchar();
v5 = func10((unsigned int)v4);
if ( v5 )
{
if ( v5 == 1 )
{
puts(&byte_402146);
func12();
func13();
}
else
{
puts("Error input, only (Y/N)/(y/n) admitted!");
}
}
else
{
puts("=3");
func8(f_record, "1");
func13();
}
return 0;
}

original_code:
int main(int argc, const char *argv[])
{
    char ch;
    int res;
    welcome();
    init();
    printf("%s days after your last washing!\n",read_file(f_record));
    if(!update_date()) {
        printf("You have checked today!");
        exit(1);
    }
    printf("Have you washed your clothes? (Y/N)/(y/n): ");
    ch = getchar();
    getchar();
    res = input(ch);
    if(res == 0) {
        printf("=3\n");
        write_file(f_record, "1");
        update_date();
    }
    else if(res == 1) {
        printf("╭(╯^╰)╮\n");
        plus_day();
        update_date();
    }
    else
        printf("Error input, only (Y/N)/(y/n) admitted!\n");
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    char ch;
    int res;
    welcome();
    init();
    printf("%s days after your last washing!\n",read_file(f_record));
    if(!update_date()) {
        printf("You have checked today!");
        exit(1);
    }
    printf("Have you washed your clothes? (Y/N)/(y/n): ");
    ch = getchar();
    getchar();
    res = input(ch);
    if(res == 0) {
        printf("=3\n");
        write_file(f_record, "1");
        update_date();
    }
    else if(res == 1) {
        printf("╭(╯^╰)╮\n");
        plus_day();
        update_date();
    }
    else
        printf("Error input, only (Y/N)/(y/n) admitted!\n");
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: ch char

variable_types: res int


decompiled_code:
_BOOL8 __fastcall file_exist(const char *a1)
{
return access(a1, 0) != -1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(const char *a1)
{
return access(a1, 0) != -1;
}

original_code:
int file_exist(const char *p)
{
    return (access(p, 0) == -1) ? 0 : 1;
}

canonical_original_code:
int file_exist(char *p)
{
    return (access(p, 0) == -1) ? 0 : 1;
}

variable_types:
p
char *


input

decompiled_code:
__int64 __fastcall input(char a1)
{
__int64 result; // rax

if ( a1 == 110 )
return 1LL;
if ( a1 > 110 )
return 2 * (unsigned int)(a1 != 121);
result = 1LL;
if ( a1 != 78 )
result = 2 * (unsigned int)(a1 != 89);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(char a1)
{
__int64 result; // rax

if ( a1 == 110 )
return 1LL;
if ( a1 > 110 )
return 2 * (unsigned int)(a1 != 121);
result = 1LL;
if ( a1 != 78 )
result = 2 * (unsigned int)(a1 != 89);
return result;
}

original_code:
int input(char ch)
{
    switch(ch) {
    case 'y':
    case 'Y':
        return 0;
    case 'n':
    case 'N':
        return 1;
    default:
        return 2;
    }
}


decompiled_code:
__int64 plus_day()
{
char *v0; // r12
int v1; // ebx
char *v2; // rax
char *v3; // rbp
int v4; // ebx
unsigned int v5; // eax
int v6; // er12

v0 = read_file(f_date);
v1 = atoi(v0);
v2 = (char *)malloc(0xAuLL);
if ( !v1 )
{
printf("Error data (integer instead) have been existed in %s", f_record);
exit(1);
}
v3 = v2;
v4 = v1 + 1;
v5 = get_current_time();
v6 = diff_day(v0, v5);
if ( v6 < 2 )
v6 = v4;
sprintf(v3, "%d", (unsigned int)v6);
write_file(f_record, v3);
free(v3);
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 func12()
{
char *v0; // r12
int v1; // ebx
char *v2; // rax
char *v3; // rbp
int v4; // ebx
unsigned int v5; // eax
int v6; // er12

v0 = func7(f_date);
v1 = atoi(v0);
v2 = (char *)malloc(0xAuLL);
if ( !v1 )
{
printf("Error data (integer instead) have been existed in %s", f_record);
exit(1);
}
v3 = v2;
v4 = v1 + 1;
v5 = func15();
v6 = func17(v0, v5);
if ( v6 < 2 )
v6 = v4;
sprintf(v3, "%d", (unsigned int)v6);
func8(f_record, v3);
free(v3);
return (unsigned int)v6;
}

original_code:
int plus_day()
{
    char *buf = read_file(f_date);
    int day = atoi(buf);
    char *str = (char*)malloc(sizeof(char)*10);
    int _day;
    if (day == 0) {
        printf("Error data (integer instead) have been existed in %s", f_record);
        exit(1);
    }
    _day = diff_day(buf, get_current_time());
    if (_day > 1)
        day = _day;
    else
        day++;
    sprintf(str, "%d", day);
    write_file(f_record, str);
    free(str);
    return day;
}

variable_types:
buf
char *

variable_types: day int

variable_types:
str
char *


decompiled_code:
__int64 update_date()
{
void *v0; // rbp
char *v1; // rax
__int64 result; // rax

v0 = (void *)(int)get_current_time();
if ( file_exist(f_date) && (v1 = read_file(f_date), !strcmp((const char *)v0, v1)) )
{
free(v0);
result = 0LL;
}
else
{
write_file(f_date, (const char *)v0);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func13()
{
void *v0; // rbp
char *v1; // rax
__int64 result; // rax

v0 = (void *)(int)func15();
if ( func9(f_date) && (v1 = func7(f_date), !strcmp((const char *)v0, v1)) )
{
free(v0);
result = 0LL;
}
else
{
func8(f_date, (const char *)v0);
result = 1LL;
}
return result;
}

original_code:
int update_date()
{
    char *c_date = get_current_time();
    if (!file_exist(f_date)) {
        write_file(f_date, c_date);
        return 1;
    }
    char *r_date = read_file(f_date);
    if(strcmp(c_date, r_date) != 0) {
        write_file(f_date, c_date);
        return 1;
    }
    free(c_date);
    return 0;
}


init

decompiled_code:
int init()
{
int result; // eax

result = file_exist(f_record);
if ( !result )
result = write_file(f_record, "1");
return result;
}

canonical_decompiled_code:
int func14()
{
int result; // eax

result = func9(f_record);
if ( !result )
result = func8(f_record, "1");
return result;
}

original_code:
void init()
{
    if(!file_exist(f_record)) {
        write_file(f_record, "1");
    }
}


decompiled_code:
char *get_current_time()
{
struct tm *v0; // rbx
char *v1; // rax
__int64 v2; // rdx
char *v3; // r12
__int64 v4; // rdx
char dest[3]; // [rsp+2h] [rbp-36h] BYREF
char s[3]; // [rsp+5h] [rbp-33h] BYREF
time_t timer; // [rsp+8h] [rbp-30h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
v1 = (char *)malloc(0xAuLL);
v2 = v0->tm_mday;
v3 = v1;
if ( (int)v2 > 9 )
{
sprintf(dest, "%d", v2);
v4 = (unsigned int)v0->tm_mon;
if ( (int)v4 <= 8 )
goto LABEL_3;
LABEL_6:
sprintf(s, "%d", v4);
goto LABEL_4;
}
strcpy(dest, (&CONVERT_DAY_OR_MONTH)[v2]);
v4 = (unsigned int)v0->tm_mon;
if ( (int)v4 > 8 )
goto LABEL_6;
LABEL_3:
strcpy(s, (&CONVERT_DAY_OR_MONTH)[(int)v4 + 1]);
LABEL_4:
sprintf(v3, "%d%s%s", (unsigned int)(v0->tm_year + 1900), s, dest);
return v3;
}

canonical_decompiled_code:
char *func15()
{
struct tm *v0; // rbx
char *v1; // rax
__int64 v2; // rdx
char *v3; // r12
__int64 v4; // rdx
char dest[3]; // [rsp+2h] [rbp-36h] BYREF
char s[3]; // [rsp+5h] [rbp-33h] BYREF
time_t timer; // [rsp+8h] [rbp-30h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
v1 = (char *)malloc(0xAuLL);
v2 = v0->tm_mday;
v3 = v1;
if ( (int)v2 > 9 )
{
sprintf(dest, "%d", v2);
v4 = (unsigned int)v0->tm_mon;
if ( (int)v4 <= 8 )
goto LABEL_3;
LABEL_6:
sprintf(s, "%d", v4);
goto LABEL_4;
}
strcpy(dest, (&CONVERT_DAY_OR_MONTH)[v2]);
v4 = (unsigned int)v0->tm_mon;
if ( (int)v4 > 8 )
goto LABEL_6;
LABEL_3:
strcpy(s, (&CONVERT_DAY_OR_MONTH)[(int)v4 + 1]);
LABEL_4:
sprintf(v3, "%d%s%s", (unsigned int)(v0->tm_year + 1900), s, dest);
return v3;
}

original_code:
char *get_current_time()
{
    time_t t = time(((void *)0));
    struct tm *n_time = localtime(&t);
    char *tstr = (char *)malloc(sizeof(char) * 10);
    char day[3];
    char month[3];
    if(n_time->tm_mday < 10)
        strcpy(day, CONVERT_DAY_OR_MONTH[n_time->tm_mday]);
    else
        sprintf(day,"%d",n_time->tm_mday);
    if(n_time->tm_mon+1 < 10)
        strcpy(month, CONVERT_DAY_OR_MONTH[n_time->tm_mon+1]);
    else
        sprintf(month,"%d",n_time->tm_mon);
    sprintf(tstr,"%d%s%s",n_time->tm_year+1900,month,day);
    return tstr;
}

canonical_original_code:
char *get_current_time()
{
    long t = time(((void *)0));
    struct tm *n_time = localtime(&t);
    char *tstr = (char *)malloc(sizeof(char) * 10);
    char day[3];
    char month[3];
    if(n_time->tm_mday < 10)
        strcpy(day, CONVERT_DAY_OR_MONTH[n_time->tm_mday]);
    else
        sprintf(day,"%d",n_time->tm_mday);
    if(n_time->tm_mon+1 < 10)
        strcpy(month, CONVERT_DAY_OR_MONTH[n_time->tm_mon+1]);
    else
        sprintf(month,"%d",n_time->tm_mon);
    sprintf(tstr,"%d%s%s",n_time->tm_year+1900,month,day);
    return tstr;
}

variable_types: t long

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long __tm_gmtoff; char *__tm_zone; } *

variable_types:
tstr
char *

variable_types:
day
char [3]

variable_types:
month
char [3]


original_code:
int diff_day(const char *day1, const char *day2)
{
    long t;
    Date tm1,tm2;
    tm1 = pack_date(day1);
    tm2 = pack_date(day2);
    t=(long)difftime(mktime(&tm1), mktime(&tm2));
    return(abs(t/24/3600));
}

canonical_original_code:
int diff_day(char *day1, char *day2)
{
    long t;
    struct tm tm1; struct tm tm2;
    tm1 = pack_date(day1);
    tm2 = pack_date(day2);
    t=(long)difftime(mktime(&tm1), mktime(&tm2));
    return(abs(t/24/3600));
}

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long __tm_gmtoff; char *__tm_zone; }


repo: Zwitty/FileSystem

decompiled_code:
__int64 __fastcall sfs_gettype(char *s)
{
size_t v1; // rbx
_BYTE *v2; // r13
void *v3; // r12
__int64 v4; // rsi
int v5; // eax
__int64 result; // rax
size_t v7; // rbx
void *v8; // r13
void *v9; // r12
__int64 v10; // rsi
__int64 v11; // rdi

v1 = 0LL;
v2 = malloc(0x80uLL);
v3 = malloc(0x80uLL);
append(v3, 49LL);
while ( strlen(s) > v1 )
{
v4 = (unsigned int)s[v1++];
append(v3, v4);
}
v5 = inodeSearch(v3);
if ( v5 > 0 )
get_block((unsigned int)v5, v2);
result = 1LL;
if ( *v2 != 49 )
{
v7 = 0LL;
v8 = malloc(0x80uLL);
v9 = malloc(0x80uLL);
append(v9, 48LL);
while ( strlen(s) > v7 )
{
v10 = (unsigned int)s[v7++];
append(v9, v10);
}
v11 = (unsigned int)inodeSearch(v9);
result = 0xFFFFFFFFLL;
if ( (int)v11 > 0 )
{
get_block(v11, v8);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s)
{
size_t v1; // rbx
_BYTE *v2; // r13
void *v3; // r12
__int64 v4; // rsi
int v5; // eax
__int64 result; // rax
size_t v7; // rbx
void *v8; // r13
void *v9; // r12
__int64 v10; // rsi
__int64 v11; // rdi

v1 = 0LL;
v2 = malloc(0x80uLL);
v3 = malloc(0x80uLL);
append(v3, 49LL);
while ( strlen(s) > v1 )
{
v4 = (unsigned int)s[v1++];
append(v3, v4);
}
v5 = inodeSearch(v3);
if ( v5 > 0 )
get_block((unsigned int)v5, v2);
result = 1LL;
if ( *v2 != 49 )
{
v7 = 0LL;
v8 = malloc(0x80uLL);
v9 = malloc(0x80uLL);
append(v9, 48LL);
while ( strlen(s) > v7 )
{
v10 = (unsigned int)s[v7++];
append(v9, v10);
}
v11 = (unsigned int)inodeSearch(v9);
result = 0xFFFFFFFFLL;
if ( (int)v11 > 0 )
{
get_block(v11, v8);
result = 0LL;
}
}
return result;
}

original_code:
int
sfs_gettype(char *pathname){
 char* buf2;
 buf2 = malloc(128);
 char* path3;
 path3 = malloc(128);
 append(path3, '1');
 int w;
 for(w =0; w <strlen(pathname); w++){
  append(path3, pathname[w]);
 }
 int index2 = inodeSearch(path3);
 if(index2 > 0){
  get_block(index2, buf2);
 }
 if(buf2[0] == '1'){
  return 1;
 }
 char* buf1;
 buf1 = malloc(128);
 char* path2;
 path2 = malloc(128);
 append(path2, '0');
 int q;
 for(q =0; q <strlen(pathname); q++){
  append(path2, pathname[q]);
 }
 int index = inodeSearch(path2);
 if(index > 0){
  get_block(index, buf1);
  if(buf1[0] == '0'){
   return 0;
  }
 }else{
  return -1;
 }
}

canonical_original_code:
int sfs_gettype(char *pathname){
 char *buf2;
 buf2 = malloc(128);
 char *path3;
 path3 = malloc(128);
 append(path3, '1');
 int w;
 for(w =0; w <strlen(pathname); w++){
  append(path3, pathname[w]);
 }
 int index2 = inodeSearch(path3);
 if(index2 > 0){
  get_block(index2, buf2);
 }
 if(buf2[0] == '1'){
  return 1;
 }
 char *buf1;
 buf1 = malloc(128);
 char *path2;
 path2 = malloc(128);
 append(path2, '0');
 int q;
 for(q =0; q <strlen(pathname); q++){
  append(path2, pathname[q]);
 }
 int index = inodeSearch(path2);
 if(index > 0){
  get_block(index, buf1);
  if(buf1[0] == '0'){
   return 0;
  }
 }else{
  return -1;
 }
}

variable_types:
pathname
char *

variable_types: w int

variable_types: q int

variable_types: index int


decompiled_code:
__int64 __fastcall sfs_readdir(int a1, char *a2)
{
__int64 v2; // rbx
const char *v3; // r12
const char *v4; // rbp
unsigned int v5; // er15
int v6; // er12
const char *v7; // rbx
const char *v8; // r14
size_t v9; // rax
__int64 i; // rbp

v2 = 0LL;
v3 = (const char *)(int)getDirSuperBlock();
v4 = (const char *)malloc(0x80uLL);
append(v4, 48LL);
while ( strlen(v3) > ++v2 )
append(v4, (unsigned int)v3[v2]);
v5 = 11;
v6 = 0;
v7 = (const char *)malloc(0x80uLL);
v8 = (const char *)malloc(0x80uLL);
while ( 1 )
{
get_block(v5, v7);
v9 = strlen(v4);
if ( !strncmp(v7, v4, v9) && ++v6 == a1 )
break;
if ( ++v5 == 512 )
return 0LL;
}
for ( i = 0LL; strlen(v7) > ++i; append(v8, (unsigned int)v7[i]) )
;
strcpy(a2, v8);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, char *a2)
{
__int64 v2; // rbx
const char *v3; // r12
const char *v4; // rbp
unsigned int v5; // er15
int v6; // er12
const char *v7; // rbx
const char *v8; // r14
size_t v9; // rax
__int64 i; // rbp

v2 = 0LL;
v3 = (const char *)(int)getDirSuperBlock();
v4 = (const char *)malloc(0x80uLL);
append(v4, 48LL);
while ( strlen(v3) > ++v2 )
append(v4, (unsigned int)v3[v2]);
v5 = 11;
v6 = 0;
v7 = (const char *)malloc(0x80uLL);
v8 = (const char *)malloc(0x80uLL);
while ( 1 )
{
get_block(v5, v7);
v9 = strlen(v4);
if ( !strncmp(v7, v4, v9) && ++v6 == a1 )
break;
if ( ++v5 == 512 )
return 0LL;
}
for ( i = 0LL; strlen(v7) > ++i; append(v8, (unsigned int)v7[i]) )
;
strcpy(a2, v8);
return 1LL;
}

original_code:
int
sfs_readdir(int fd, char *mem_pointer){
 char* openDir;
 openDir = malloc(128);
 openDir = getDirSuperBlock();
 char* buf;
 buf = malloc(128);
 append(buf, '0');
 int i;
 for(i = 1; i < strlen(openDir); i++){
  append(buf, openDir[i]);
 }
 char* temp;
 temp = malloc(128);
 char* temp2;
 temp2 = malloc(128);
 int check = 0;
 int j;
 for (j = 11; j < 512; j++){
  get_block(j,temp);
  if(strncmp(temp, buf, strlen(buf)) == 0){
   check = check + 1;
   if(check == fd){
    int k;
    for(k =1; k <strlen(temp); k++){
     append(temp2, temp[k]);
    }
    strcpy(mem_pointer, temp2);
    return 1;
   }
  }
 }
 return 0;
}

canonical_original_code:
int sfs_readdir(int fd, char *mem_pointer){
 char *openDir;
 openDir = malloc(128);
 openDir = getDirSuperBlock();
 char *buf;
 buf = malloc(128);
 append(buf, '0');
 int i;
 for(i = 1; i < strlen(openDir); i++){
  append(buf, openDir[i]);
 }
 char *temp;
 temp = malloc(128);
 char *temp2;
 temp2 = malloc(128);
 int check = 0;
 int j;
 for (j = 11; j < 512; j++){
  get_block(j,temp);
  if(strncmp(temp, buf, strlen(buf)) == 0){
   check = check + 1;
   if(check == fd){
    int k;
    for(k =1; k <strlen(temp); k++){
     append(temp2, temp[k]);
    }
    strcpy(mem_pointer, temp2);
    return 1;
   }
  }
 }
 return 0;
}

variable_types: fd int

variable_types:
openDir
char *

variable_types: i int

variable_types:
temp
char *

variable_types: check int

variable_types: j int

variable_types: k int


decompiled_code:
__int64 init_disk()
{
int v0; // eax
int v1; // ebp
__int64 result; // rax
char buf[9]; // [rsp+Fh] [rbp-9h] BYREF

v0 = open("simdisk.data", 66, 440LL);
diskfd = v0;
if ( v0 < 0 )
{
perror("opening disk data file");
result = 0xFFFFFFFFLL;
}
else
{
v1 = v0;
if ( lseek(v0, 0x10000LL, 0) < 0 )
{
perror("disk data file seek");
result = 0xFFFFFFFFLL;
}
else if ( write(v1, buf, 1uLL) < 0 )
{
perror("disk data file write");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // eax
int v1; // ebp
__int64 result; // rax
char buf[9]; // [rsp+Fh] [rbp-9h] BYREF

v0 = open("simdisk.data", 66, 440LL);
diskfd = v0;
if ( v0 < 0 )
{
perror("opening disk data file");
result = 0xFFFFFFFFLL;
}
else
{
v1 = v0;
if ( lseek(v0, 0x10000LL, 0) < 0 )
{
perror("disk data file seek");
result = 0xFFFFFFFFLL;
}
else if ( write(v1, buf, 1uLL) < 0 )
{
perror("disk data file write");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
static int
init_disk()
{
  char garbage;
  if ((diskfd = open("simdisk.data",02|0100,0400|0200|((0400|0200|0100) >> 3))) < 0) {
    perror("opening disk data file");
    return(-1);
  }
  if (lseek(diskfd,128*512,0) < 0) {
    perror("disk data file seek");
    return(-1);
  }
  if (write(diskfd,&garbage,1) < 0) {
    perror("disk data file write");
    return(-1);
  }
  return(0);
}

variable_types: garbage char


decompiled_code:
__int64 __fastcall get_block(unsigned int a1, void *a2)
{
int v2; // ebp

if ( a1 > 0x1FF )
{
fprintf(stderr, "get_block: invalid block number: %d\n", a1);
return 0xFFFFFFFFLL;
}
v2 = diskfd;
if ( diskfd < 0 )
{
if ( (unsigned int)init_disk() )
return 0xFFFFFFFFLL;
v2 = diskfd;
}
if ( lseek(v2, (int)(a1 << 7), 0) >= 0 && read(v2, a2, 0x80uLL) >= 0 )
return 0LL;
perror("get_block");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, void *a2)
{
int v2; // ebp

if ( a1 > 0x1FF )
{
fprintf(stderr, "get_block: invalid block number: %d\n", a1);
return 0xFFFFFFFFLL;
}
v2 = diskfd;
if ( diskfd < 0 )
{
if ( (unsigned int)func0() )
return 0xFFFFFFFFLL;
v2 = diskfd;
}
if ( lseek(v2, (int)(a1 << 7), 0) >= 0 && read(v2, a2, 0x80uLL) >= 0 )
return 0LL;
perror("get_block");
return 0xFFFFFFFFLL;
}

original_code:
int
get_block(int blknum,
   char *buf)
{
  if (blknum >= 512 || blknum < 0) {
    fprintf(stderr,"get_block: invalid block number: %d\n",blknum);
    return(-1);
  }
  if (diskfd < 0) {
    if (init_disk() != 0) return(-1);
  }
  if (lseek(diskfd,blknum*128,0) < 0) {
    perror("get_block");
    return(-1);
  }
  if (read(diskfd,buf,128) < 0) {
    perror("get_block");
    return(-1);
  }
  return(0);
}

variable_types: blknum int

variable_types:
buf
char *


decompiled_code:
__int64 __fastcall put_block(unsigned int a1, const void *a2)
{
int v2; // ebp

if ( a1 > 0x1FF )
{
fprintf(stderr, "put_block: invalid block number: %d\n", a1);
return 0xFFFFFFFFLL;
}
v2 = diskfd;
if ( diskfd < 0 )
{
if ( (unsigned int)init_disk() )
return 0xFFFFFFFFLL;
v2 = diskfd;
}
if ( lseek(v2, (int)(a1 << 7), 0) >= 0 && write(v2, a2, 0x80uLL) >= 0 )
return 0LL;
perror("put_block");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, const void *a2)
{
int v2; // ebp

if ( a1 > 0x1FF )
{
fprintf(stderr, "put_block: invalid block number: %d\n", a1);
return 0xFFFFFFFFLL;
}
v2 = diskfd;
if ( diskfd < 0 )
{
if ( (unsigned int)func0() )
return 0xFFFFFFFFLL;
v2 = diskfd;
}
if ( lseek(v2, (int)(a1 << 7), 0) >= 0 && write(v2, a2, 0x80uLL) >= 0 )
return 0LL;
perror("put_block");
return 0xFFFFFFFFLL;
}

original_code:
int
put_block(int blknum,
   char *buf)
{
  if (blknum >= 512 || blknum < 0) {
    fprintf(stderr,"put_block: invalid block number: %d\n",blknum);
    return(-1);
  }
  if (diskfd < 0) {
    if (init_disk() != 0) return(-1);
  }
  if (lseek(diskfd,blknum*128,0) < 0) {
    perror("put_block");
    return(-1);
  }
  if (write(diskfd,buf,128) < 0) {
    perror("put_block");
    return(-1);
  }
  return(0);
}


decompiled_code:
__int64 __fastcall sfs_close(int a1)
{
if ( a1 > 4 )
return 0xFFFFFFFFLL;
*(_WORD *)malloc(0x80uLL) = 48;
put_block((unsigned int)(a1 - 1));
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
if ( a1 > 4 )
return 0xFFFFFFFFLL;
*(_WORD *)malloc(0x80uLL) = 48;
put_block((unsigned int)(a1 - 1));
return 1LL;
}

original_code:
int sfs_close(int fd){
 if (fd <= 4){
  char* buf;
  buf = malloc(128);
  strcpy(buf, "0");
  put_block(fd-1,buf);
  return 1;
 }else{
  return -1;
 }
}

canonical_original_code:
int sfs_close(int fd){
 if (fd <= 4){
  char *buf;
  buf = malloc(128);
  strcpy(buf, "0");
  put_block(fd-1,buf);
  return 1;
 }else{
  return -1;
 }
}


inodeSearch

decompiled_code:
__int64 __fastcall inodeSearch(char *s2)
{
unsigned int v1; // er12
const char *v2; // rbx
size_t v3; // rax

v1 = 11;
v2 = (const char *)malloc(0x80uLL);
while ( 1 )
{
get_block(v1, v2);
if ( *v2 )
{
v3 = strlen(s2);
if ( !strncmp(v2, s2, v3) )
break;
}
if ( ++v1 == 512 )
return (unsigned int)-1;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s2)
{
unsigned int v1; // er12
const char *v2; // rbx
size_t v3; // rax

v1 = 11;
v2 = (const char *)malloc(0x80uLL);
while ( 1 )
{
get_block(v1, v2);
if ( *v2 )
{
v3 = strlen(s2);
if ( !strncmp(v2, s2, v3) )
break;
}
if ( ++v1 == 512 )
return (unsigned int)-1;
}
return v1;
}

original_code:
int inodeSearch(char* path){
 int i, j;
 int index = -1;
 char* temp, temp2;
 char* A;
 temp = malloc(128);
 for (i=11; i<512; i++){
  get_block(i, temp);
  if (temp[0] != '\0'){
   if(strncmp(temp, path, strlen(path)) == 0){
     index = i;
     break;
    }else{
     continue;
    }
  }
 }
 return index;
}

canonical_original_code:
int inodeSearch(char *path){
 int i; int j;
 int index = -1;
 char *temp; char temp2;
 char *A;
 temp = malloc(128);
 for (i=11; i<512; i++){
  get_block(i, temp);
  if (temp[0] != '\0'){
   if(strncmp(temp, path, strlen(path)) == 0){
     index = i;
     break;
    }else{
     continue;
    }
  }
 }
 return index;
}

variable_types:
path
char *

variable_types:
A
char *


inodeReadTable

decompiled_code:
__int64 inodeReadTable()
{
__int64 *v0; // rbx
void *v1; // rbp
void *v2; // rbp
__int64 *v3; // r13
int v4; // er14
__int64 i; // rbx
__int64 v6; // rax

v0 = inode;
v1 = malloc(0x80uLL);
inodeBlocks = (__int64)v1;
*(&inodeBlocks + 1) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 2) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 3) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 4) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 5) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 6) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 7) = (__int64)malloc(0x80uLL);
get_block(2LL, v1);
get_block(3LL, *(&inodeBlocks + 1));
get_block(4LL, *(&inodeBlocks + 2));
get_block(5LL, *(&inodeBlocks + 3));
get_block(6LL, *(&inodeBlocks + 4));
get_block(7LL, *(&inodeBlocks + 5));
get_block(8LL, *(&inodeBlocks + 6));
get_block(9LL, *(&inodeBlocks + 7));
v2 = malloc(0x80uLL);
do
*v0++ = (__int64)malloc(0x14uLL);
while ( (__int64 *)(unsigned int)((_DWORD)inode + 4096) != v0 );
v3 = &inodeBlocks;
v4 = 0;
do
{
for ( i = 0LL; i != 128; ++i )
{
while ( 1 )
{
if ( *(_BYTE *)(*v3 + i) != 33 )
{
if ( *(_BYTE *)(*v3 + i) )
append(v2);
goto LABEL_7;
}
if ( v4 <= 511 )
break;
LABEL_7:
if ( ++i == 128 )
goto LABEL_11;
}
v6 = v4++;
inode[v6] = (__int64)v2;
}
LABEL_11:
++v3;
}
while ( (__int64 *)(unsigned int)((_DWORD)&inodeBlocks + 64) != v3 );
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 *v0; // rbx
void *v1; // rbp
void *v2; // rbp
__int64 *v3; // r13
int v4; // er14
__int64 i; // rbx
__int64 v6; // rax

v0 = inode;
v1 = malloc(0x80uLL);
inodeBlocks = (__int64)v1;
*(&inodeBlocks + 1) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 2) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 3) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 4) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 5) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 6) = (__int64)malloc(0x80uLL);
*(&inodeBlocks + 7) = (__int64)malloc(0x80uLL);
get_block(2LL, v1);
get_block(3LL, *(&inodeBlocks + 1));
get_block(4LL, *(&inodeBlocks + 2));
get_block(5LL, *(&inodeBlocks + 3));
get_block(6LL, *(&inodeBlocks + 4));
get_block(7LL, *(&inodeBlocks + 5));
get_block(8LL, *(&inodeBlocks + 6));
get_block(9LL, *(&inodeBlocks + 7));
v2 = malloc(0x80uLL);
do
*v0++ = (__int64)malloc(0x14uLL);
while ( (__int64 *)(unsigned int)((_DWORD)inode + 4096) != v0 );
v3 = &inodeBlocks;
v4 = 0;
do
{
for ( i = 0LL; i != 128; ++i )
{
while ( 1 )
{
if ( *(_BYTE *)(*v3 + i) != 33 )
{
if ( *(_BYTE *)(*v3 + i) )
append(v2);
goto LABEL_7;
}
if ( v4 <= 511 )
break;
LABEL_7:
if ( ++i == 128 )
goto LABEL_11;
}
v6 = v4++;
inode[v6] = (__int64)v2;
}
LABEL_11:
++v3;
}
while ( (__int64 *)(unsigned int)((_DWORD)&inodeBlocks + 64) != v3 );
return 0LL;
}

original_code:
int inodeReadTable(){
 inodeBlocks[0] = malloc(128);
 inodeBlocks[1] = malloc(128);
 inodeBlocks[2] = malloc(128);
 inodeBlocks[3] = malloc(128);
 inodeBlocks[4] = malloc(128);
 inodeBlocks[5] = malloc(128);
 inodeBlocks[6] = malloc(128);
 inodeBlocks[7] = malloc(128);
 get_block(2, inodeBlocks[0]);
 get_block(3, inodeBlocks[1]);
 get_block(4, inodeBlocks[2]);
 get_block(5, inodeBlocks[3]);
 get_block(6, inodeBlocks[4]);
 get_block(7, inodeBlocks[5]);
 get_block(8, inodeBlocks[6]);
 get_block(9, inodeBlocks[7]);
 int j, k;
 int i = 0;
 char* temp;
 temp = malloc(128);
 int g;
 for(g=0; g<512; g++){
  inode[g] = malloc(20);
 }
 for (j = 0; j < 8; j++) {
  for (k =0; k < 128; k++){
   if(inodeBlocks[j][k] == '!'){
    if(i < 512){
     inode[i] = temp;
     i = i + 1;
    }
   }else if(inodeBlocks[j][k] != '\0') {
    append(temp, inodeBlocks[j][k]);
   }else{
    continue;
   }
  }
 }
 return 0;
}

canonical_original_code:
int inodeReadTable(){
 inodeBlocks[0] = malloc(128);
 inodeBlocks[1] = malloc(128);
 inodeBlocks[2] = malloc(128);
 inodeBlocks[3] = malloc(128);
 inodeBlocks[4] = malloc(128);
 inodeBlocks[5] = malloc(128);
 inodeBlocks[6] = malloc(128);
 inodeBlocks[7] = malloc(128);
 get_block(2, inodeBlocks[0]);
 get_block(3, inodeBlocks[1]);
 get_block(4, inodeBlocks[2]);
 get_block(5, inodeBlocks[3]);
 get_block(6, inodeBlocks[4]);
 get_block(7, inodeBlocks[5]);
 get_block(8, inodeBlocks[6]);
 get_block(9, inodeBlocks[7]);
 int j; int k;
 int i = 0;
 char *temp;
 temp = malloc(128);
 int g;
 for(g=0; g<512; g++){
  inode[g] = malloc(20);
 }
 for (j = 0; j < 8; j++) {
  for (k =0; k < 128; k++){
   if(inodeBlocks[j][k] == '!'){
    if(i < 512){
     inode[i] = temp;
     i = i + 1;
    }
   }else if(inodeBlocks[j][k] != '\0') {
    append(temp, inodeBlocks[j][k]);
   }else{
    continue;
   }
  }
 }
 return 0;
}

variable_types: g int


inodeAdd

decompiled_code:
__int64 inodeAdd()
{
unsigned int v0; // er12
_BYTE *v1; // rbx

v0 = 11;
inodeReadTable();
v1 = malloc(0x80uLL);
do
{
get_block(v0, v1);
if ( !*v1 )
{
inode[v0] = (char)v0;
return v0;
}
++v0;
}
while ( v0 != 512 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func2()
{
unsigned int v0; // er12
_BYTE *v1; // rbx

v0 = 11;
func1();
v1 = malloc(0x80uLL);
do
{
get_block(v0, v1);
if ( !*v1 )
{
inode[v0] = (char)v0;
return v0;
}
++v0;
}
while ( v0 != 512 );
return 0xFFFFFFFFLL;
}

original_code:
int inodeAdd(int type, char* path){
 inodeReadTable();
 int i;
 int index = -1;
 char* chartype = (char)type;
 char* temp, temp2;
 temp = malloc(128);
 for (i=11; i<512; i++){
  get_block(i, temp);
  if (temp[0] == '\0'){
   index = i;
   temp2 = (char)index;
   inode[i] = temp2;
   break;
  }
 }
 return index;
}

canonical_original_code:
int inodeAdd(int type, char *path){
 inodeReadTable();
 int i;
 int index = -1;
 char *chartype = (char)type;
 char *temp; char temp2;
 temp = malloc(128);
 for (i=11; i<512; i++){
  get_block(i, temp);
  if (temp[0] == '\0'){
   index = i;
   temp2 = (char)index;
   inode[i] = temp2;
   break;
  }
 }
 return index;
}

variable_types: type int

variable_types:
chartype
char *


append

decompiled_code:
__int64 __fastcall append(const char *a1, char a2)
{
__int64 result; // rax

result = (int)strlen(a1);
a1[(int)result] = a2;
a1[(int)result + 1] = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, char a2)
{
__int64 result; // rax

result = (int)strlen(a1);
a1[(int)result] = a2;
a1[(int)result + 1] = 0;
return result;
}

original_code:
void append(char* s, char c)
{
        int len = strlen(s);
        s[len] = c;
        s[len+1] = '\0';
}

canonical_original_code:
void append(char *s, char c)
{
        int len = strlen(s);
        s[len] = c;
        s[len+1] = '\0';
}

variable_types:
s
char *

variable_types: c char

variable_types: len int


decompiled_code:
__int64 __fastcall sfs_write(unsigned int a1, int a2, int a3, const void *a4)
{
char *v6; // rbp
__int64 result; // rax
unsigned int v8; // er14

v6 = (char *)malloc(0x80uLL);
result = getSuperBlock(a1);
if ( (_DWORD)result != -1 )
{
v8 = result + 1;
get_block((unsigned int)(result + 1), v6);
if ( a2 < a2 + a3 )
memcpy(&v6[a2], a4, (unsigned int)(a3 - 1) + 1LL);
put_block(v8, v6);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, int a2, int a3, const void *a4)
{
char *v6; // rbp
__int64 result; // rax
unsigned int v8; // er14

v6 = (char *)malloc(0x80uLL);
result = getSuperBlock(a1);
if ( (_DWORD)result != -1 )
{
v8 = result + 1;
get_block((unsigned int)(result + 1), v6);
if ( a2 < a2 + a3 )
memcpy(&v6[a2], a4, (unsigned int)(a3 - 1) + 1LL);
put_block(v8, v6);
result = 1LL;
}
return result;
}

original_code:
int sfs_write(int fd, int start, int length, char *mem_pointer){
 char* buf;
 buf = malloc(128);
 int index;
 index = getSuperBlock(fd);
 if(index == -1){
  return -1;
 }
 get_block(index+1, buf);
 int i;
 int space = start+length;
 for(i = start; i < space; i++){
  buf[i] = mem_pointer[i-start];
 }
 put_block(index+1, buf);
 return 1;
}

canonical_original_code:
int sfs_write(int fd, int start, int length, char *mem_pointer){
 char *buf;
 buf = malloc(128);
 int index;
 index = getSuperBlock(fd);
 if(index == -1){
  return -1;
 }
 get_block(index+1, buf);
 int i;
 int space = start+length;
 for(i = start; i < space; i++){
  buf[i] = mem_pointer[i-start];
 }
 put_block(index+1, buf);
 return 1;
}

variable_types: fd int

variable_types: start int

variable_types: length int

variable_types: index int

variable_types: space int


putSuperBlock

decompiled_code:
__int64 __fastcall putSuperBlock(unsigned int a1)
{
unsigned int v1; // er12
char *v2; // rbp
_BYTE *v3; // rbx

v1 = 0;
v2 = (char *)malloc(0x80uLL);
snprintf(v2, 0x7FuLL, "%d", a1);
v3 = malloc(0x80uLL);
while ( 1 )
{
get_block(v1, v3);
if ( *v3 == 48 )
break;
if ( ++v1 == 4 )
return 0xFFFFFFFFLL;
}
put_block(v1, v2);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
unsigned int v1; // er12
char *v2; // rbp
_BYTE *v3; // rbx

v1 = 0;
v2 = (char *)malloc(0x80uLL);
snprintf(v2, 0x7FuLL, "%d", a1);
v3 = malloc(0x80uLL);
while ( 1 )
{
get_block(v1, v3);
if ( *v3 == 48 )
break;
if ( ++v1 == 4 )
return 0xFFFFFFFFLL;
}
put_block(v1, v2);
return v1;
}

original_code:
int putSuperBlock(int FileLoc){
 char* buf;
 buf = malloc(128);
 char* fileChar;
 fileChar = malloc(128);
 snprintf(fileChar, 127, "%d",FileLoc);
 int i;
 char* temp;
 temp = malloc(128);
 for(i = 0; i< 4; i++){
  get_block(i,temp);
  if(temp[0] == '0'){
   put_block(i, fileChar);
   return i;
  }
 }
 return -1;
}

canonical_original_code:
int putSuperBlock(int FileLoc){
 char *buf;
 buf = malloc(128);
 char *fileChar;
 fileChar = malloc(128);
 snprintf(fileChar, 127, "%d",FileLoc);
 int i;
 char *temp;
 temp = malloc(128);
 for(i = 0; i< 4; i++){
  get_block(i,temp);
  if(temp[0] == '0'){
   put_block(i, fileChar);
   return i;
  }
 }
 return -1;
}

variable_types: FileLoc int

variable_types:
fileChar
char *

variable_types: i int

variable_types:
temp
char *


getSuperBlock

decompiled_code:
int __fastcall getSuperBlock(int a1)
{
const char *v1; // rbp

v1 = (const char *)malloc(0x80uLL);
get_block((unsigned int)(a1 - 1), v1);
return atoi(v1);
}

canonical_decompiled_code:
int __fastcall func1(int a1)
{
const char *v1; // rbp

v1 = (const char *)malloc(0x80uLL);
get_block((unsigned int)(a1 - 1), v1);
return atoi(v1);
}

original_code:
int getSuperBlock(int fd){
 char* buf;
 buf = malloc(128);
 get_block(fd-1, buf);
 int openFile =atoi(buf);
 return openFile;
}

canonical_original_code:
int getSuperBlock(int fd){
 char *buf;
 buf = malloc(128);
 get_block(fd-1, buf);
 int openFile = atoi(buf);
 return openFile;
}

variable_types:
buf
char *

variable_types: openFile int


putDirSuperBlock

decompiled_code:
__int64 __fastcall putDirSuperBlock(char *s)
{
size_t v1; // rbx
void *v2; // r12
__int64 v3; // rsi

v1 = 0LL;
v2 = malloc(0x80uLL);
while ( strlen(s) > v1 )
{
v3 = (unsigned int)s[v1++];
append(v2, v3);
}
put_block(4LL, v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s)
{
size_t v1; // rbx
void *v2; // r12
__int64 v3; // rsi

v1 = 0LL;
v2 = malloc(0x80uLL);
while ( strlen(s) > v1 )
{
v3 = (unsigned int)s[v1++];
append(v2, v3);
}
put_block(4LL, v2);
return 0LL;
}

original_code:
int putDirSuperBlock(char* openDir){
 char* buf;
 buf = malloc(128);
 int i;
 for(i=0; i< strlen(openDir); i++){
  append(buf, openDir[i]);
 }
 put_block(4, buf);
 return 0;
}

canonical_original_code:
int putDirSuperBlock(char *openDir){
 char *buf;
 buf = malloc(128);
 int i;
 for(i=0; i< strlen(openDir); i++){
  append(buf, openDir[i]);
 }
 put_block(4, buf);
 return 0;
}

variable_types:
openDir
char *


getDirSuperBlock

decompiled_code:
void *getDirSuperBlock()
{
void *v0; // r12

v0 = malloc(0x80uLL);
get_block(4LL, v0);
return v0;
}

canonical_decompiled_code:
void *func3()
{
void *v0; // r12

v0 = malloc(0x80uLL);
get_block(4LL, v0);
return v0;
}

original_code:
char* getDirSuperBlock(){
 char* dir;
 dir = malloc(128);
 int i;
 get_block(4, dir);
 return dir;
}

canonical_original_code:
char *getDirSuperBlock(){
 char *dir;
 dir = malloc(128);
 int i;
 get_block(4, dir);
 return dir;
}

variable_types:
dir
char *


decompiled_code:
__int64 __fastcall sfs_create(char *s, unsigned int a2)
{
unsigned int v3; // eax
unsigned int v4; // er13
size_t v5; // rax
int v6; // edx
unsigned __int64 v7; // rcx
unsigned __int64 i; // rax
unsigned int v9; // er14
size_t v11; // rbp
void *v12; // r14
__int64 v13; // rsi
void *v14; // rsi
void *v15; // rbp

v3 = inodeAdd(a2, s);
if ( *s != 47 )
return (unsigned int)-1;
v4 = v3;
if ( v3 == -1 )
return (unsigned int)-1;
v5 = strlen(s);
v6 = 0;
v7 = v5;
for ( i = 1LL; v7 > i; ++i )
{
if ( s[i] == 47 )
{
v6 = 0;
}
else if ( ++v6 > 6 )
{
return (unsigned int)-1;
}
}
v11 = 0LL;
v12 = malloc(0x80uLL);
append(v12, (char)(a2 + 48));
while ( strlen(s) > v11 )
{
v13 = (unsigned int)s[v11++];
append(v12, v13);
}
v14 = v12;
v9 = 1;
put_block(v4, v14);
if ( !a2 )
{
v15 = malloc(0x80uLL);
append(v15, 33LL);
put_block(v4 + 1, v15);
}
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s, unsigned int a2)
{
unsigned int v3; // eax
unsigned int v4; // er13
size_t v5; // rax
int v6; // edx
unsigned __int64 v7; // rcx
unsigned __int64 i; // rax
unsigned int v9; // er14
size_t v11; // rbp
void *v12; // r14
__int64 v13; // rsi
void *v14; // rsi
void *v15; // rbp

v3 = inodeAdd(a2, s);
if ( *s != 47 )
return (unsigned int)-1;
v4 = v3;
if ( v3 == -1 )
return (unsigned int)-1;
v5 = strlen(s);
v6 = 0;
v7 = v5;
for ( i = 1LL; v7 > i; ++i )
{
if ( s[i] == 47 )
{
v6 = 0;
}
else if ( ++v6 > 6 )
{
return (unsigned int)-1;
}
}
v11 = 0LL;
v12 = malloc(0x80uLL);
append(v12, (char)(a2 + 48));
while ( strlen(s) > v11 )
{
v13 = (unsigned int)s[v11++];
append(v12, v13);
}
v14 = v12;
v9 = 1;
put_block(v4, v14);
if ( !a2 )
{
v15 = malloc(0x80uLL);
append(v15, 33LL);
put_block(v4 + 1, v15);
}
return v9;
}

original_code:
int sfs_create(char *pathname, int type){
 int index;
 index = inodeAdd(type, pathname);
 if(pathname[0] != '/')
 {
  return -1;
 }
 if(index == -1){
  return -1;
 }
 int p;
 int count = 0;
 for(p=1; p<strlen(pathname);p++){
  if(pathname[p] != '/'){
   count = count + 1;
  }
  if(pathname[p] == '/'){
   count = 0;
  }
  if(count > 6){
   return -1;
  }
 }
 char* addToBlock;
 addToBlock = malloc(128);
 char* chartype = (char)(((int)'0')+type);
 append(addToBlock, chartype);
 int i;
 for(i=0; i<strlen(pathname); i++){
  append(addToBlock, pathname[i]);
 }
 put_block(index, addToBlock);
 if(type == 0){
  char* dataBuf;
  dataBuf = malloc(128);
  append(dataBuf, '!');
  put_block(index+1, dataBuf);
 }
 return 1;
}

canonical_original_code:
int sfs_create(char *pathname, int type){
 int index;
 index = inodeAdd(type, pathname);
 if(pathname[0] != '/')
 {
  return -1;
 }
 if(index == -1){
  return -1;
 }
 int p;
 int count = 0;
 for(p=1; p<strlen(pathname);p++){
  if(pathname[p] != '/'){
   count = count + 1;
  }
  if(pathname[p] == '/'){
   count = 0;
  }
  if(count > 6){
   return -1;
  }
 }
 char *addToBlock;
 addToBlock = malloc(128);
 char *chartype = (char)(((int)'0')+type);
 append(addToBlock, chartype);
 int i;
 for(i=0; i<strlen(pathname); i++){
  append(addToBlock, pathname[i]);
 }
 put_block(index, addToBlock);
 if(type == 0){
  char *dataBuf;
  dataBuf = malloc(128);
  append(dataBuf, '!');
  put_block(index+1, dataBuf);
 }
 return 1;
}

variable_types:
pathname
char *

variable_types: type int

variable_types: p int

variable_types: count int

variable_types:
addToBlock
char *

variable_types:
chartype
char *

variable_types:
dataBuf
char *


decompiled_code:
__int64 __fastcall sfs_read(unsigned int a1, int a2, int a3, void *a4)
{
char *v6; // rbp
__int64 result; // rax

v6 = (char *)malloc(0x80uLL);
result = getSuperBlock(a1);
if ( (_DWORD)result != -1 )
{
get_block((unsigned int)(result + 1), v6);
if ( a2 < a2 + a3 )
memcpy(a4, &v6[a2], (unsigned int)(a3 - 1) + 1LL);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, int a2, int a3, void *a4)
{
char *v6; // rbp
__int64 result; // rax

v6 = (char *)malloc(0x80uLL);
result = getSuperBlock(a1);
if ( (_DWORD)result != -1 )
{
get_block((unsigned int)(result + 1), v6);
if ( a2 < a2 + a3 )
memcpy(a4, &v6[a2], (unsigned int)(a3 - 1) + 1LL);
result = 1LL;
}
return result;
}

original_code:
int sfs_read(int fd, int start, int length, char *mem_pointer){
 char* buf;
 buf = malloc(128);
 int index = getSuperBlock(fd);
 if(index == -1){
  return -1;
 }else
  get_block(index+1, buf);
  int i;
  int space = start+length;
  for(i = start; i < space; i++){
   mem_pointer[i-start] = buf[i];
  }
 return 1;
}

canonical_original_code:
int sfs_read(int fd, int start, int length, char *mem_pointer){
 char *buf;
 buf = malloc(128);
 int index = getSuperBlock(fd);
 if(index == -1){
  return -1;
 }else
  get_block(index+1, buf);
  int i;
  int space = start+length;
  for(i = start; i < space; i++){
   mem_pointer[i-start] = buf[i];
  }
 return 1;
}

variable_types: fd int

variable_types: start int

variable_types: length int

variable_types: index int


decompiled_code:
__int64 __fastcall sfs_delete(char *s)
{
size_t v1; // rbx
void *v2; // r12
__int64 v3; // rsi
int v4; // ebp
__int64 result; // rax
void *v6; // rax

v1 = 0LL;
v2 = malloc(0x80uLL);
append(v2, 48LL);
while ( strlen(s) > v1 )
{
v3 = (unsigned int)s[v1++];
append(v2, v3);
}
v4 = inodeSearch(v2);
result = 0LL;
if ( v4 >= 0 )
{
v6 = malloc(0x80uLL);
put_block((unsigned int)v4, v6);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s)
{
size_t v1; // rbx
void *v2; // r12
__int64 v3; // rsi
int v4; // ebp
__int64 result; // rax
void *v6; // rax

v1 = 0LL;
v2 = malloc(0x80uLL);
append(v2, 48LL);
while ( strlen(s) > v1 )
{
v3 = (unsigned int)s[v1++];
append(v2, v3);
}
v4 = inodeSearch(v2);
result = 0LL;
if ( v4 >= 0 )
{
v6 = malloc(0x80uLL);
put_block((unsigned int)v4, v6);
result = 1LL;
}
return result;
}

original_code:
int sfs_delete(char *pathname){
 char* path2;
 path2 = malloc(128);
 append(path2, '0');
 int q;
 for(q =0; q <strlen(pathname); q++){
  append(path2, pathname[q]);
 }
 int index = inodeSearch(path2);
 if(index < 0){
  return 0;
 }
 char* buf = malloc(128);
 put_block(index, buf);
 return 1;
}

canonical_original_code:
int sfs_delete(char *pathname){
 char *path2;
 path2 = malloc(128);
 append(path2, '0');
 int q;
 for(q =0; q <strlen(pathname); q++){
  append(path2, pathname[q]);
 }
 int index = inodeSearch(path2);
 if(index < 0){
  return 0;
 }
 char *buf = malloc(128);
 put_block(index, buf);
 return 1;
}

variable_types: q int


decompiled_code:
__int64 __fastcall sfs_open(char *s)
{
size_t v1; // rbx
unsigned int v2; // er13
void *v3; // r12
__int64 v4; // rsi
__int64 result; // rax

v1 = 0LL;
v2 = sfs_gettype();
v3 = malloc(0x80uLL);
append(v3, (unsigned int)(char)(v2 + 48));
while ( strlen(s) > v1 )
{
v4 = (unsigned int)s[v1++];
append(v3, v4);
}
LODWORD(result) = inodeSearch(v3);
if ( (int)result < 0 )
return (unsigned int)result;
if ( !v2 )
return (unsigned int)putSuperBlock((unsigned int)result) + 1;
if ( v2 != 1 )
return v2;
putDirSuperBlock(v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s)
{
size_t v1; // rbx
unsigned int v2; // er13
void *v3; // r12
__int64 v4; // rsi
__int64 result; // rax

v1 = 0LL;
v2 = sfs_gettype();
v3 = malloc(0x80uLL);
append(v3, (unsigned int)(char)(v2 + 48));
while ( strlen(s) > v1 )
{
v4 = (unsigned int)s[v1++];
append(v3, v4);
}
LODWORD(result) = inodeSearch(v3);
if ( (int)result < 0 )
return (unsigned int)result;
if ( !v2 )
return (unsigned int)putSuperBlock((unsigned int)result) + 1;
if ( v2 != 1 )
return v2;
putDirSuperBlock(v3);
return 1LL;
}

original_code:
int sfs_open(char *pathname){
 int type = sfs_gettype(pathname);
 char chartype = (char)(((int)'0')+type);
 char* path2;
 path2 = malloc(128);
 append(path2, chartype);
 int q;
 for(q =0; q <strlen(pathname); q++){
  append(path2, pathname[q]);
 }
 int index = inodeSearch(path2);
 if(index < 0){
  return index;
 }
 if(type == 0){
  return putSuperBlock(index) + 1;
 }
 if(type == 1){
  putDirSuperBlock(path2);
 }
 return type;
}

canonical_original_code:
int sfs_open(char *pathname){
 int type = sfs_gettype(pathname);
 char chartype = (char)(((int)'0')+type);
 char *path2;
 path2 = malloc(128);
 append(path2, chartype);
 int q;
 for(q =0; q <strlen(pathname); q++){
  append(path2, pathname[q]);
 }
 int index = inodeSearch(path2);
 if(index < 0){
  return index;
 }
 if(type == 0){
  return putSuperBlock(index) + 1;
 }
 if(type == 1){
  putDirSuperBlock(path2);
 }
 return type;
}

variable_types: chartype char


decompiled_code:
__int64 __fastcall sfs_initialize(int a1)
{
_WORD *v1; // rax
_WORD *v2; // rax
_WORD *v3; // r13
_WORD *v4; // rax
_WORD *v5; // r12
_WORD *v6; // rax
_WORD *v7; // rbp
char *v8; // rax
char *v9; // r14
char *v10; // rbx
char *v11; // rax
_WORD *v12; // rsi
__int64 result; // rax
unsigned int v14; // ebx
void *v15; // rbp
__int64 v16; // rdi
_WORD *v17; // [rsp+8h] [rbp-60h]
char *v18; // [rsp+8h] [rbp-60h]
void *v19; // [rsp+10h] [rbp-58h]
void *v20; // [rsp+18h] [rbp-50h]
void *v21; // [rsp+20h] [rbp-48h]
void *v22; // [rsp+28h] [rbp-40h]

v1 = malloc(0x80uLL);
*v1 = 48;
v17 = v1;
v2 = malloc(0x80uLL);
*v2 = 48;
v3 = v2;
v4 = malloc(0x80uLL);
*v4 = 48;
v5 = v4;
v6 = malloc(0x80uLL);
*v6 = 48;
v7 = v6;
v8 = (char *)malloc(0x80uLL);
strcpy(v8, "1/");
v9 = v8;
v10 = (char *)malloc(0x80uLL);
strcpy(v10, "101/!");
v19 = malloc(0x80uLL);
v20 = malloc(0x80uLL);
v21 = malloc(0x80uLL);
v22 = malloc(0x80uLL);
v11 = (char *)malloc(0x80uLL);
v12 = v17;
strcpy(v11, "1/");
if ( a1 > 0 )
{
v14 = 0;
v15 = malloc(0x80uLL);
do
{
v16 = v14++;
put_block(v16, v15);
}
while ( v14 != 512 );
result = 2LL;
}
else
{
v18 = v11;
put_block(0LL, v12);
put_block(1LL, v3);
put_block(2LL, v5);
put_block(3LL, v7);
put_block(4LL, v9);
put_block(5LL, v10);
put_block(6LL, v19);
put_block(7LL, v20);
put_block(8LL, v21);
put_block(9LL, v22);
put_block(10LL, v18);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
_WORD *v1; // rax
_WORD *v2; // rax
_WORD *v3; // r13
_WORD *v4; // rax
_WORD *v5; // r12
_WORD *v6; // rax
_WORD *v7; // rbp
char *v8; // rax
char *v9; // r14
char *v10; // rbx
char *v11; // rax
_WORD *v12; // rsi
__int64 result; // rax
unsigned int v14; // ebx
void *v15; // rbp
__int64 v16; // rdi
_WORD *v17; // [rsp+8h] [rbp-60h]
char *v18; // [rsp+8h] [rbp-60h]
void *v19; // [rsp+10h] [rbp-58h]
void *v20; // [rsp+18h] [rbp-50h]
void *v21; // [rsp+20h] [rbp-48h]
void *v22; // [rsp+28h] [rbp-40h]

v1 = malloc(0x80uLL);
*v1 = 48;
v17 = v1;
v2 = malloc(0x80uLL);
*v2 = 48;
v3 = v2;
v4 = malloc(0x80uLL);
*v4 = 48;
v5 = v4;
v6 = malloc(0x80uLL);
*v6 = 48;
v7 = v6;
v8 = (char *)malloc(0x80uLL);
strcpy(v8, "1/");
v9 = v8;
v10 = (char *)malloc(0x80uLL);
strcpy(v10, "101/!");
v19 = malloc(0x80uLL);
v20 = malloc(0x80uLL);
v21 = malloc(0x80uLL);
v22 = malloc(0x80uLL);
v11 = (char *)malloc(0x80uLL);
v12 = v17;
strcpy(v11, "1/");
if ( a1 > 0 )
{
v14 = 0;
v15 = malloc(0x80uLL);
do
{
v16 = v14++;
put_block(v16, v15);
}
while ( v14 != 512 );
result = 2LL;
}
else
{
v18 = v11;
put_block(0LL, v12);
put_block(1LL, v3);
put_block(2LL, v5);
put_block(3LL, v7);
put_block(4LL, v9);
put_block(5LL, v10);
put_block(6LL, v19);
put_block(7LL, v20);
put_block(8LL, v21);
put_block(9LL, v22);
put_block(10LL, v18);
result = 1LL;
}
return result;
}

original_code:
int sfs_initialize(int erase){
 char * superblock_0 = ((void *)0);
 char * superblock_1 = ((void *)0);
 char * superblock_2 = ((void *)0);
 char * superblock_3 = ((void *)0);
 char * superblock_4 = ((void *)0);
 char* inodein[512];
 superblock_0 = malloc(128);
 strcpy(superblock_0, "0");
 superblock_1 = malloc(128);
 strcpy(superblock_1, "0");
 superblock_2 = malloc(128);
 strcpy(superblock_2, "0");
 superblock_3 = malloc(128);
 strcpy(superblock_3, "0");
 superblock_4 = malloc(128);
 strcpy(superblock_4, "1/");
 inodein[0] = malloc(128);
 inodein[0] = ((void *)0);
 inodein[1] = malloc(128);
 inodein[1] = ((void *)0);
 inodein[2] = malloc(128);
 inodein[3] = malloc(128);
 inodein[4] = malloc(128);
 inodein[5] = malloc(128);
 strcpy(inodein[5], "101/!");
 inodein[6] = malloc(128);
 inodein[7] = malloc(128);
 inodein[8] = malloc(128);
 inodein[9] = malloc(128);
 inodein[10] = malloc(128);
 strcpy(inodein[10], "1/");
 if(erase >= 1){
  char* buf;
  buf = malloc(128);
  int i;
  for(i=0; i<512; i++){
   put_block(i, buf);
  }
  return 2;
 }else{
  put_block(0, superblock_0);
  put_block(1, superblock_1);
  put_block(2, superblock_2);
  put_block(3, superblock_3);
  put_block(4, superblock_4);
  put_block(5, inodein[5]);
  put_block(6, inodein[6]);
  put_block(7, inodein[7]);
  put_block(8, inodein[8]);
  put_block(9, inodein[9]);
  put_block(10, inodein[10]);
  return 1;
 }
}

canonical_original_code:
int sfs_initialize(int erase){
 char *superblock_0 = ((void *)0);
 char *superblock_1 = ((void *)0);
 char *superblock_2 = ((void *)0);
 char *superblock_3 = ((void *)0);
 char *superblock_4 = ((void *)0);
 char *inodein[512];
 superblock_0 = malloc(128);
 strcpy(superblock_0, "0");
 superblock_1 = malloc(128);
 strcpy(superblock_1, "0");
 superblock_2 = malloc(128);
 strcpy(superblock_2, "0");
 superblock_3 = malloc(128);
 strcpy(superblock_3, "0");
 superblock_4 = malloc(128);
 strcpy(superblock_4, "1/");
 inodein[0] = malloc(128);
 inodein[0] = ((void *)0);
 inodein[1] = malloc(128);
 inodein[1] = ((void *)0);
 inodein[2] = malloc(128);
 inodein[3] = malloc(128);
 inodein[4] = malloc(128);
 inodein[5] = malloc(128);
 strcpy(inodein[5], "101/!");
 inodein[6] = malloc(128);
 inodein[7] = malloc(128);
 inodein[8] = malloc(128);
 inodein[9] = malloc(128);
 inodein[10] = malloc(128);
 strcpy(inodein[10], "1/");
 if(erase >= 1){
  char *buf;
  buf = malloc(128);
  int i;
  for(i=0; i<512; i++){
   put_block(i, buf);
  }
  return 2;
 }else{
  put_block(0, superblock_0);
  put_block(1, superblock_1);
  put_block(2, superblock_2);
  put_block(3, superblock_3);
  put_block(4, superblock_4);
  put_block(5, inodein[5]);
  put_block(6, inodein[6]);
  put_block(7, inodein[7]);
  put_block(8, inodein[8]);
  put_block(9, inodein[9]);
  put_block(10, inodein[10]);
  return 1;
 }
}

variable_types: erase int

variable_types:
inodein
char *[512]

variable_types:
buf
char *

variable_types: i int


repo: a-darwish/cuteOS

decompiled_code:
__int64 __fastcall bit_is_set(unsigned __int8 a1, char a2)
{
return (a1 >> a2) & 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 a1, char a2)
{
return (a1 >> a2) & 1;
}

original_code:
static _Bool bit_is_set(uint8_t val, int bit)
{
 if ((val & (1U << bit)) == 0)
  return ((_Bool)0);
 return ((_Bool)1);
}

canonical_original_code:
static _Bool bit_is_set(unsigned char val, int bit)
{
 if ((val & (1U << bit)) == 0)
  return ((_Bool)0);
 return ((_Bool)1);
}

variable_types:
val
unsigned char

variable_types: bit int


decompiled_code:
__int64 __fastcall set_offsets(unsigned int a1, _DWORD *a2, unsigned int *a3, int a4)
{
__int64 result; // rax

if ( 8 * a4 <= a1 )
{
panic("%s:%d - !(bit < len * 8)\n", "lib/bitmap.c", 59LL);
result = bitmap_first_set_bit();
}
else
{
result = a1 >> 3;
*a2 = result;
*a3 = a1 & 7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, _DWORD *a2, unsigned int *a3, int a4)
{
__int64 result; // rax

if ( 8 * a4 <= a1 )
{
panic("%s:%d - !(bit < len * 8)\n", "lib/bitmap.c", 59LL);
result = func2();
}
else
{
result = a1 >> 3;
*a2 = result;
*a3 = a1 & 7;
}
return result;
}

original_code:
static void set_offsets(uint bit, uint *byte_offset, uint *bit_offset, uint len)
{
 do { if (__builtin_expect((!(bit < len * 8)), 0)) panic("%s:%d - !(" "bit < len * 8" ")\n", "lib/bitmap.c", 59); } while (0);;
 *byte_offset = bit / 8;
 *bit_offset = bit % 8;
}

canonical_original_code:
static void set_offsets(unsigned int bit, unsigned int *byte_offset, unsigned int *bit_offset, unsigned int len)
{
 do { if (__builtin_expect((!(bit < len * 8)), 0)) panic("%s:%d - !(" "bit < len * 8" ")\n", "lib/bitmap.c", 59); } while (0);;
 *byte_offset = bit / 8;
 *bit_offset = bit % 8;
}

variable_types:
bit
unsigned int

variable_types:
len
unsigned int


decompiled_code:
__int64 __fastcall bitmap_first_set_bit(__int64 a1, int a2)
{
__int64 v3; // r8
unsigned __int8 v4; // di
int v5; // edx
int v6; // edx
__int64 v7; // r8
__int64 v8; // r9
int v9; // er11

if ( a2 )
{
v3 = 0LL;
while ( 2 )
{
v4 = *(_BYTE *)(a1 + v3);
LOBYTE(v5) = 0;
do
{
if ( (unsigned __int8)bit_is_set(v4, v5) )
return (unsigned int)(v6 + 8 * v9);
v5 = v6 + 1;
}
while ( v5 != 8 );
v3 = v7 + 1;
if ( v8 != v3 )
continue;
break;
}
}
return -1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
__int64 v3; // r8
unsigned __int8 v4; // di
int v5; // edx
int v6; // edx
__int64 v7; // r8
__int64 v8; // r9
int v9; // er11

if ( a2 )
{
v3 = 0LL;
while ( 2 )
{
v4 = *(_BYTE *)(a1 + v3);
LOBYTE(v5) = 0;
do
{
if ( (unsigned __int8)func0(v4, v5) )
return (unsigned int)(v6 + 8 * v9);
v5 = v6 + 1;
}
while ( v5 != 8 );
v3 = v7 + 1;
if ( v8 != v3 )
continue;
break;
}
}
return -1LL;
}

original_code: int64_t bitmap_first_set_bit(char *buf, uint len) { uint bits_per_byte = 8; for (uint i = 0; i < len; i++) for (uint j = 0; j < bits_per_byte; j++) if (bit_is_set(buf[i], j)) return (i * 8) + j; return -1; }

canonical_original_code: long bitmap_first_set_bit(char *buf, unsigned int len) { unsigned int bits_per_byte = 8; for (unsigned int i = 0; i < len; i++) for (unsigned int j = 0; j < bits_per_byte; j++) if (bit_is_set(buf[i], j)) return (i * 8) + j; return -1; }

variable_types:
i
unsigned int

variable_types:
j
unsigned int

return_type: long


decompiled_code:
__int64 __fastcall bitmap_first_zero_bit(__int64 a1, int a2)
{
__int64 v3; // r8
unsigned __int8 v4; // di
int v5; // edx
int v6; // edx
__int64 v7; // r8
__int64 v8; // r9
int v9; // er11

if ( a2 )
{
v3 = 0LL;
while ( 2 )
{
v4 = *(_BYTE *)(a1 + v3);
LOBYTE(v5) = 0;
do
{
if ( !(unsigned __int8)bit_is_set(v4, v5) )
return (unsigned int)(v6 + 8 * v9);
v5 = v6 + 1;
}
while ( v5 != 8 );
v3 = v7 + 1;
if ( v8 != v3 )
continue;
break;
}
}
return -1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
__int64 v3; // r8
unsigned __int8 v4; // di
int v5; // edx
int v6; // edx
__int64 v7; // r8
__int64 v8; // r9
int v9; // er11

if ( a2 )
{
v3 = 0LL;
while ( 2 )
{
v4 = *(_BYTE *)(a1 + v3);
LOBYTE(v5) = 0;
do
{
if ( !(unsigned __int8)func0(v4, v5) )
return (unsigned int)(v6 + 8 * v9);
v5 = v6 + 1;
}
while ( v5 != 8 );
v3 = v7 + 1;
if ( v8 != v3 )
continue;
break;
}
}
return -1LL;
}

original_code: int64_t bitmap_first_zero_bit(char *buf, uint len) { uint bits_per_byte = 8; for (uint i = 0; i < len; i++) for (uint j = 0; j < bits_per_byte; j++) if (!bit_is_set(buf[i], j)) return (i * 8) + j; return -1; }

canonical_original_code: long bitmap_first_zero_bit(char *buf, unsigned int len) { unsigned int bits_per_byte = 8; for (unsigned int i = 0; i < len; i++) for (unsigned int j = 0; j < bits_per_byte; j++) if (!bit_is_set(buf[i], j)) return (i * 8) + j; return -1; }


decompiled_code:
__int64 __fastcall bitmap_bit_is_set(__int64 a1, unsigned int a2, int a3)
{
unsigned int v4; // [rsp+8h] [rbp-10h] BYREF
unsigned int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

set_offsets(a2, &v4, v5, a3);
return bit_is_set(*(_BYTE *)(a1 + v4), v5[0]);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned int a2, int a3)
{
unsigned int v4; // [rsp+8h] [rbp-10h] BYREF
unsigned int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

func1(a2, &v4, v5, a3);
return func0(*(_BYTE *)(a1 + v4), v5[0]);
}

original_code:
_Bool bitmap_bit_is_set(char *buf, uint bit, uint len)
{
 uint byte_offset, bit_offset;
 set_offsets(bit, &byte_offset, &bit_offset, len);
 buf += byte_offset;
 return bit_is_set(*buf, bit_offset);
}

canonical_original_code:
_Bool bitmap_bit_is_set(char *buf, unsigned int bit, unsigned int len)
{
 unsigned int byte_offset; unsigned int bit_offset;
 set_offsets(bit, &byte_offset, &bit_offset, len);
 buf += byte_offset;
 return bit_is_set(*buf, bit_offset);
}


decompiled_code:
__int64 __fastcall bitmap_bit_is_clear(__int64 a1, unsigned int a2, int a3)
{
return (unsigned int)bitmap_bit_is_set(a1, a2, a3) ^ 1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, int a3)
{
return (unsigned int)func6(a1, a2, a3) ^ 1;
}

original_code:
_Bool bitmap_bit_is_clear(char *buf, uint bit, uint len)
{
 return !bitmap_bit_is_set(buf, bit, len);
}

canonical_original_code:
_Bool bitmap_bit_is_clear(char *buf, unsigned int bit, unsigned int len)
{
 return !bitmap_bit_is_set(buf, bit, len);
}


decompiled_code:
char *__fastcall memcpy_forward(char *a1, char *a2, unsigned __int64 a3)
{
char *v4; // rcx
char *v5; // rdx

if ( a1 + 8 > a2 && &a2[a3] > a1 )
{
v4 = a1;
v5 = a2;
a2 = "memcpy_forward";
a1 = "%s: badly-overlapped regions, src=0x%lx, dst=0x%lx, len=0x%lx";
panic("%s: badly-overlapped regions, src=0x%lx, dst=0x%lx, len=0x%lx", "memcpy_forward", v5, v4, a3);
}
return _memcpy_forward(a1, a2, a3);
}

canonical_decompiled_code:
char *__fastcall func1(char *a1, char *a2, unsigned __int64 a3)
{
char *v4; // rcx
char *v5; // rdx

if ( a1 + 8 > a2 && &a2[a3] > a1 )
{
v4 = a1;
v5 = a2;
a2 = "memcpy_forward";
a1 = "%s: badly-overlapped regions, src=0x%lx, dst=0x%lx, len=0x%lx";
panic("%s: badly-overlapped regions, src=0x%lx, dst=0x%lx, len=0x%lx", "memcpy_forward", v5, v4, a3);
}
return func0(a1, a2, a3);
}

original_code:
void *memcpy_forward(void *dst, const void *src, size_t len)
{
 uintptr_t udst, usrc;
 _Bool bad_overlap;
 udst = (uintptr_t)dst;
 usrc = (uintptr_t)src;
 bad_overlap = (udst + 8 > usrc) && (usrc + len > udst);
 if (__builtin_expect((bad_overlap), 0))
  panic("%s: badly-overlapped regions, src=0x%lx, dst"
        "=0x%lx, len=0x%lx", __func__, src, dst, len);
 return __memcpy_forward(dst, src, len);
}

canonical_original_code:
void *memcpy_forward(void *dst, void *src, unsigned long len)
{
 unsigned long udst; unsigned long usrc;
 _Bool bad_overlap;
 udst = (unsigned long)dst;
 usrc = (unsigned long)src;
 bad_overlap = (udst + 8 > usrc) && (usrc + len > udst);
 if (__builtin_expect((bad_overlap), 0))
  panic("%s: badly-overlapped regions, src=0x%lx, dst"
        "=0x%lx, len=0x%lx", __func__, src, dst, len);
 return __memcpy_forward(dst, src, len);
}

variable_types:
dst
void *

variable_types:
src
void *

variable_types:
len
unsigned long

variable_types:
udst
unsigned long

variable_types:
usrc
unsigned long


memcpy

decompiled_code:
char *__fastcall memcpy(char *a1, char *a2, unsigned __int64 a3)
{
char *v4; // rcx
char *v5; // rdx

if ( &a1[a3] > a2 && &a2[a3] > a1 )
{
v4 = a1;
v5 = a2;
a2 = "memcpy";
a1 = "%s: overlapped regions, src=0x%lx, dst=0x%lx, len=0x%lx";
panic("%s: overlapped regions, src=0x%lx, dst=0x%lx, len=0x%lx", "memcpy", v5, v4, a3);
}
return _memcpy_forward(a1, a2, a3);
}

canonical_decompiled_code:
char *__fastcall func2(char *a1, char *a2, unsigned __int64 a3)
{
char *v4; // rcx
char *v5; // rdx

if ( &a1[a3] > a2 && &a2[a3] > a1 )
{
v4 = a1;
v5 = a2;
a2 = "memcpy";
a1 = "%s: overlapped regions, src=0x%lx, dst=0x%lx, len=0x%lx";
panic("%s: overlapped regions, src=0x%lx, dst=0x%lx, len=0x%lx", "memcpy", v5, v4, a3);
}
return func0(a1, a2, a3);
}

original_code:
void *memcpy(void * restrict dst, const void * restrict src, size_t len)
{
 uintptr_t udst, usrc;
 _Bool overlap;
 udst = (uintptr_t)dst;
 usrc = (uintptr_t)src;
 overlap = (udst + len > usrc) && (usrc + len > udst);
 if (__builtin_expect((overlap), 0))
  panic("%s: overlapped regions, src=0x%lx, dst=0x"
        "%lx, len=0x%lx", __func__, src, dst, len);
 return __memcpy_forward(dst, src, len);
}

canonical_original_code:
void *memcpy(void *dst, void *src, unsigned long len)
{
 unsigned long udst; unsigned long usrc;
 _Bool overlap;
 udst = (unsigned long)dst;
 usrc = (unsigned long)src;
 overlap = (udst + len > usrc) && (usrc + len > udst);
 if (__builtin_expect((overlap), 0))
  panic("%s: overlapped regions, src=0x%lx, dst=0x"
        "%lx, len=0x%lx", __func__, src, dst, len);
 return __memcpy_forward(dst, src, len);
}


decompiled_code:
// attributes: thunk
char *__fastcall memcpy_forward_nocheck(char *a1, char *a2, unsigned __int64 a3)
{
return _memcpy_forward(a1, a2, a3);
}

canonical_decompiled_code:
char *__fastcall func3(char *a1, char *a2, unsigned __int64 a3)
{
return func0(a1, a2, a3);
}

original_code:
void *memcpy_forward_nocheck(void *dst, const void *src, size_t len)
{
 return __memcpy_forward(dst, src, len);
}

canonical_original_code:
void *memcpy_forward_nocheck(void *dst, void *src, unsigned long len)
{
 return __memcpy_forward(dst, src, len);
}


decompiled_code:
// attributes: thunk
char *__fastcall memcpy_nocheck(char *a1, char *a2, unsigned __int64 a3)
{
return _memcpy_forward(a1, a2, a3);
}

canonical_decompiled_code:
char *__fastcall func4(char *a1, char *a2, unsigned __int64 a3)
{
return func0(a1, a2, a3);
}

original_code:
void *memcpy_nocheck(void * restrict dst, const void * restrict src, size_t len)
{
 return __memcpy_forward(dst, src, len);
}

canonical_original_code:
void *memcpy_nocheck(void *dst, void *src, unsigned long len)
{
 return __memcpy_forward(dst, src, len);
}


memset

decompiled_code:
char *__fastcall memset(char *a1, unsigned __int8 a2, unsigned __int64 a3)
{
memset(a1, a2, a3 & 7);
memset64(&a1[a3 & 7], 0x101010101010101LL * a2, a3 >> 3);
return a1;
}

canonical_decompiled_code:
char *__fastcall func5(char *a1, unsigned __int8 a2, unsigned __int64 a3)
{
func5(a1, a2, a3 & 7);
func7(&a1[a3 & 7], 0x101010101010101LL * a2, a3 >> 3);
return a1;
}

original_code:
void *memset(void *dst, uint8_t ch, size_t len)
{
 uint64_t uch;
 uintptr_t d0;
 uch = ch;
 asm volatile (
  "mov  %3, %%rcx;"
  "rep  stosb;"
  "mov  %4, %%rcx;"
  "rep  stosq;"
  :"=&D" (d0)
  :"0" (dst), "a" (uch * 0x0101010101010101),
   "ir" (len & 7), "ir" (len >> 3)
  :"rcx", "memory");
 return dst;
}

canonical_original_code:
void *memset(void *dst, unsigned char ch, unsigned long len)
{
 unsigned long uch;
 unsigned long d0;
 uch = ch;
 asm volatile (
  "mov  %3, %%rcx;"
  "rep  stosb;"
  "mov  %4, %%rcx;"
  "rep  stosq;"
  :"=&D" (d0)
  :"0" (dst), "a" (uch * 0x0101010101010101),
   "ir" (len & 7), "ir" (len >> 3)
  :"rcx", "memory");
 return dst;
}

variable_types:
ch
unsigned char

variable_types:
uch
unsigned long


decompiled_code:
__int64 __fastcall memset32(void *a1, __int64 a2, unsigned __int64 a3)
{
__int64 result; // rax

if ( (a3 & 7) != 0 )
{
panic("%s:%d - !((len % 8) == 0)\n", "lib/string.c", 152LL);
result = memset64();
}
else
{
memset64(a1, (a2 << 32) + (unsigned int)a2, a3 >> 3);
result = (__int64)a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(void *a1, __int64 a2, unsigned __int64 a3)
{
__int64 result; // rax

if ( (a3 & 7) != 0 )
{
panic("%s:%d - !((len % 8) == 0)\n", "lib/string.c", 152LL);
result = func7();
}
else
{
func7(a1, (a2 << 32) + (unsigned int)a2, a3 >> 3);
result = (__int64)a1;
}
return result;
}

original_code:
void *memset32(void *dst, uint32_t val, uint64_t len)
{
 uint64_t uval;
 uintptr_t d0;
 do { if (__builtin_expect((!((len % 8) == 0)), 0)) panic("%s:%d - !(" "(len % 8) == 0" ")\n", "lib/string.c", 152); } while (0);;
 len = len / 8;
 uval = ((uint64_t)val << 32) + val;
 asm volatile (
  "rep stosq"
  :"=&D" (d0), "+&c" (len)
  :"0" (dst), "a" (uval)
  :"memory");
 return dst;
}

canonical_original_code:
void *memset32(void *dst, unsigned int val, unsigned long len)
{
 unsigned long uval;
 unsigned long d0;
 do { if (__builtin_expect((!((len % 8) == 0)), 0)) panic("%s:%d - !(" "(len % 8) == 0" ")\n", "lib/string.c", 152); } while (0);;
 len = len / 8;
 uval = ((unsigned long)val << 32) + val;
 asm volatile (
  "rep stosq"
  :"=&D" (d0), "+&c" (len)
  :"0" (dst), "a" (uval)
  :"memory");
 return dst;
}

variable_types:
val
unsigned int

variable_types:
uval
unsigned long


decompiled_code:
__int64 __fastcall memset64(void *a1, unsigned __int64 a2, unsigned __int64 a3)
{
__int64 result; // rax

if ( (a3 & 7) != 0 )
{
panic("%s:%d - !((len % 8) == 0)\n", "lib/string.c", 173LL);
result = strlen();
}
else
{
memset64(a1, a2, a3 >> 3);
result = (__int64)a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(void *a1, unsigned __int64 a2, unsigned __int64 a3)
{
__int64 result; // rax

if ( (a3 & 7) != 0 )
{
panic("%s:%d - !((len % 8) == 0)\n", "lib/string.c", 173LL);
result = func8();
}
else
{
func7(a1, a2, a3 >> 3);
result = (__int64)a1;
}
return result;
}

original_code:
void *memset64(void *dst, uint64_t val, uint64_t len)
{
 uintptr_t d0;
 do { if (__builtin_expect((!((len % 8) == 0)), 0)) panic("%s:%d - !(" "(len % 8) == 0" ")\n", "lib/string.c", 173); } while (0);;
 len = len / 8;
 asm volatile (
  "rep stosq"
  :"=&D" (d0), "+&c" (len)
  :"0" (dst), "a" (val)
  :"memory");
 return dst;
}

canonical_original_code:
void *memset64(void *dst, unsigned long val, unsigned long len)
{
 unsigned long d0;
 do { if (__builtin_expect((!((len % 8) == 0)), 0)) panic("%s:%d - !(" "(len % 8) == 0" ")\n", "lib/string.c", 173); } while (0);;
 len = len / 8;
 asm volatile (
  "rep stosq"
  :"=&D" (d0), "+&c" (len)
  :"0" (dst), "a" (val)
  :"memory");
 return dst;
}

variable_types:
val
unsigned long


strncmp

decompiled_code:
__int64 __fastcall strncmp(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax
unsigned __int8 v4; // r8

if ( !a3 )
return 0LL;
v3 = 0LL;
while ( 1 )
{
v4 = *(_BYTE *)(a1 + v3) - *(_BYTE *)(a2 + v3);
if ( v4 || !*(_BYTE *)(a1 + v3) )
break;
if ( a3 == ++v3 )
return 0LL;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax
unsigned __int8 v4; // r8

if ( !a3 )
return 0LL;
v3 = 0LL;
while ( 1 )
{
v4 = *(_BYTE *)(a1 + v3) - *(_BYTE *)(a2 + v3);
if ( v4 || !*(_BYTE *)(a1 + v3) )
break;
if ( a3 == ++v3 )
return 0LL;
}
return v4;
}

original_code:
int strncmp(const char *c1, const char *c2, int n)
{
 uint8_t s1, s2, res;
 res = 0;
 while (n) {
  s1 = *c1++;
  s2 = *c2++;
  res = s1 - s2;
  if (res != 0 || s1 == 0)
   break;
  n--;
 }
 return res;
}

canonical_original_code:
int strncmp(char *c1, char *c2, int n)
{
 unsigned char s1; unsigned char s2; unsigned char res;
 res = 0;
 while (n) {
  s1 = *c1++;
  s2 = *c2++;
  res = s1 - s2;
  if (res != 0 || s1 == 0)
   break;
  n--;
 }
 return res;
}

variable_types: n int

variable_types:
res
unsigned char


memcmp

decompiled_code:
__int64 __fastcall memcmp(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v3; // rcx
__int64 v4; // rax
unsigned __int8 v5; // dl

v3 = a3;
v4 = 0LL;
do
{
if ( v4 == v3 )
return 0LL;
v5 = *(_BYTE *)(a1 + v4) - *(_BYTE *)(a2 + v4);
++v4;
}
while ( !v5 );
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v3; // rcx
__int64 v4; // rax
unsigned __int8 v5; // dl

v3 = a3;
v4 = 0LL;
do
{
if ( v4 == v3 )
return 0LL;
v5 = *(_BYTE *)(a1 + v4) - *(_BYTE *)(a2 + v4);
++v4;
}
while ( !v5 );
return v5;
}

original_code:
int memcmp(const void *s1, const void *s2, uint32_t n)
{
 const uint8_t *v1, *v2;
 uint8_t res;
 v1 = s1;
 v2 = s2;
 res = 0;
 while (n--) {
  res = *v1++ - *v2++;
  if (res != 0)
   break;
 }
 return res;
}

canonical_original_code:
int memcmp(void *s1, void *s2, unsigned int n)
{
 unsigned char *v1; unsigned char *v2;
 unsigned char res;
 v1 = s1;
 v2 = s2;
 res = 0;
 while (n--) {
  res = *v1++ - *v2++;
  if (res != 0)
   break;
 }
 return res;
}

variable_types:
n
unsigned int


decompiled_code:
void local_irq_enable()
{
_enable();
}

canonical_decompiled_code:
void func0()
{
_enable();
}

original_code:
static inline void local_irq_enable(void)
{
 asm volatile ("sti"
        ::
        :"cc", "memory");
}

canonical_original_code:
static inline void local_irq_enable()
{
 asm volatile ("sti"
        ::
        :"cc", "memory");
}


decompiled_code:
void *clear_bss()
{
return memset(&_bss_start, 0, &_bss_end - &_bss_start);
}

canonical_decompiled_code:
void *func1()
{
return memset(&_bss_start, 0, &_bss_end - &_bss_start);
}

original_code:
static void clear_bss(void)
{
 memset(__bss_start , 0, __bss_end - __bss_start);
}

canonical_original_code:
static void clear_bss()
{
 memset(__bss_start , 0, __bss_end - __bss_start);
}


decompiled_code:
__int64 print_info()
{
printk("Cute 0.0\n\n");
printk("Text start = 0x%lx\n", &_text_start);
printk("Text end = 0x%lx\n", &_text_end);
printk("Text size = %d bytes\n\n", &_text_end - &_text_start);
printk("Data start = 0x%lx\n", &_data_start);
printk("Data end = 0x%lx\n", &_data_end);
printk("Data size = %d bytes\n\n", &_data_end - &_data_start);
printk("BSS start = 0x%lx\n", &_bss_start);
printk("BSS end = 0x%lx\n", &_bss_end);
return printk("BSS size = %d bytes\n\n", &_bss_end - &_bss_start);
}

canonical_decompiled_code:
__int64 func2()
{
printk("Cute 0.0\n\n");
printk("Text start = 0x%lx\n", &_text_start);
printk("Text end = 0x%lx\n", &_text_end);
printk("Text size = %d bytes\n\n", &_text_end - &_text_start);
printk("Data start = 0x%lx\n", &_data_start);
printk("Data end = 0x%lx\n", &_data_end);
printk("Data size = %d bytes\n\n", &_data_end - &_data_start);
printk("BSS start = 0x%lx\n", &_bss_start);
printk("BSS end = 0x%lx\n", &_bss_end);
return printk("BSS size = %d bytes\n\n", &_bss_end - &_bss_start);
}

original_code:
static void print_info(void)
{
 printk("Cute 0.0\n\n");
 printk("Text start = 0x%lx\n", __text_start);
 printk("Text end   = 0x%lx\n", __text_end);
 printk("Text size  = %d bytes\n\n", __text_end - __text_start);
 printk("Data start = 0x%lx\n", __data_start);
 printk("Data end   = 0x%lx\n", __data_end);
 printk("Data size  = %d bytes\n\n", __data_end - __data_start);
 printk("BSS start  = 0x%lx\n", __bss_start);
 printk("BSS end    = 0x%lx\n", __bss_end);
 printk("BSS size   = %d bytes\n\n", __bss_end - __bss_start);
}

canonical_original_code:
static void print_info()
{
 printk("Cute 0.0\n\n");
 printk("Text start = 0x%lx\n", __text_start);
 printk("Text end   = 0x%lx\n", __text_end);
 printk("Text size  = %d bytes\n\n", __text_end - __text_start);
 printk("Data start = 0x%lx\n", __data_start);
 printk("Data end   = 0x%lx\n", __data_end);
 printk("Data size  = %d bytes\n\n", __data_end - __data_start);
 printk("BSS start  = 0x%lx\n", __bss_start);
 printk("BSS end    = 0x%lx\n", __bss_end);
 printk("BSS size   = %d bytes\n\n", __bss_end - __bss_start);
}


decompiled_code:
__int64 __fastcall set_intr_gate(__int64 a1, unsigned __int64 a2)
{
unsigned int v2; // er8
__int64 v4[2]; // [rsp+0h] [rbp-10h] BYREF

pack_idt_gate_constprop_0((__int64)v4, a2);
return write_idt_gate_constprop_0(v4, v2);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, unsigned __int64 a2)
{
unsigned int v2; // er8
__int64 v4[2]; // [rsp+0h] [rbp-10h] BYREF

func5((__int64)v4, a2);
return func4(v4, v2);
}

original_code:
static inline void set_intr_gate(unsigned int n, void *addr)
{
 struct idt_gate gate;
 pack_idt_gate(&gate, 0xe, addr);
 write_idt_gate(&gate, idt, n);
}

variable_types:
addr
void *

variable_types: struct idt_gate { unsigned short offset_low; unsigned short selector; unsigned short ist; unsigned short offset_middle; unsigned int offset_high; unsigned int reserved0_2; }


decompiled_code:
void setup_idt()
{
void *v0; // r9
unsigned int i; // ecx

v0 = &idt_exception_stubs;
for ( i = 0; i != 32; set_intr_gate(i, (unsigned __int64)v0) )
;
set_intr_gate(241LL, (unsigned __int64)&halt_cpu_ipi_handler);
load_idt_constprop_0();
}

canonical_decompiled_code:
void func7()
{
void *v0; // r9
unsigned int i; // ecx

v0 = &idt_exception_stubs;
for ( i = 0; i != 32; func6(i, (unsigned __int64)v0) )
;
func6(241LL, (unsigned __int64)&halt_cpu_ipi_handler);
func3();
}

original_code:
static void setup_idt(void)
{
 for (int i = 0; i < (0x1F + 1); i ++)
  set_intr_gate(i, &idt_exception_stubs[i]);
 set_intr_gate(0xf1, halt_cpu_ipi_handler);
 load_idt(&idtdesc);
}

canonical_original_code:
static void setup_idt()
{
 for (int i = 0; i < (0x1F + 1); i ++)
  set_intr_gate(i, &idt_exception_stubs[i]);
 set_intr_gate(0xf1, halt_cpu_ipi_handler);
 load_idt(&idtdesc);
}

variable_types: i int


decompiled_code:
void __noreturn kernel_start()
{
clear_bss();
setup_idt();
schedulify_this_code_path(0LL);
print_info();
ramdisk_init();
e820_init();
pagealloc_init();
vm_init();
kmalloc_init();
mptables_init();
serial_init();
pic_init();
apic_init();
ioapic_init();
smpboot_init();
keyboard_init();
sched_init();
local_irq_enable();
ext2_init();
smpboot_trigger_secondary_cores_testcases();
__halt();
}

canonical_decompiled_code:
void __noreturn func8()
{
func1();
func7();
schedulify_this_code_path(0LL);
func2();
ramdisk_init();
e820_init();
pagealloc_init();
vm_init();
kmalloc_init();
mptables_init();
serial_init();
pic_init();
apic_init();
ioapic_init();
smpboot_init();
keyboard_init();
sched_init();
func0();
ext2_init();
smpboot_trigger_secondary_cores_testcases();
__halt();
}

original_code:
void __attribute__((noreturn)) kernel_start(void)
{
 clear_bss();
 setup_idt();
 schedulify_this_code_path(BOOTSTRAP);
 print_info();
 ramdisk_init();
 e820_init();
 pagealloc_init();
 vm_init();
 kmalloc_init();
 mptables_init();
 serial_init();
 pic_init();
 apic_init();
 ioapic_init();
 smpboot_init();
 keyboard_init();
 sched_init();
 local_irq_enable();
 ext2_init();
 smpboot_trigger_secondary_cores_testcases();
 run_test_cases();
 do { while (((_Bool)1)) asm volatile ("hlt":::"memory"); } while (0);;
}

canonical_original_code:
void kernel_start()
{
 clear_bss();
 setup_idt();
 schedulify_this_code_path(BOOTSTRAP);
 print_info();
 ramdisk_init();
 e820_init();
 pagealloc_init();
 vm_init();
 kmalloc_init();
 mptables_init();
 serial_init();
 pic_init();
 apic_init();
 ioapic_init();
 smpboot_init();
 keyboard_init();
 sched_init();
 local_irq_enable();
 ext2_init();
 smpboot_trigger_secondary_cores_testcases();
 run_test_cases();
 do { while (((_Bool)1)) asm volatile ("hlt":::"memory"); } while (0);;
}


decompiled_code:
void null_printer()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void null_printer(__attribute__((__unused__)) const char *fmt, ...)
{
}

canonical_original_code:
void null_printer(char *fmt, ...)
{
}

variable_types:
fmt
char *