decompiled_code:
__int64 __fastcall slabset_contain_slab(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rdi
_QWORD *v4; // rsi

v2 = *(_QWORD **)(a1 + 16);
v3 = (_QWORD *)(a1 + 16);
if ( v2 == v3 )
return 0LL;
v4 = (_QWORD *)(a2 + 16);
if ( v2 != v4 )
{
while ( 1 )
{
v2 = (_QWORD *)*v2;
if ( v2 == v3 )
break;
if ( v2 == v4 )
return 1LL;
}
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rdi
_QWORD *v4; // rsi

v2 = *(_QWORD **)(a1 + 16);
v3 = (_QWORD *)(a1 + 16);
if ( v2 == v3 )
return 0LL;
v4 = (_QWORD *)(a2 + 16);
if ( v2 != v4 )
{
while ( 1 )
{
v2 = (_QWORD *)*v2;
if ( v2 == v3 )
break;
if ( v2 == v4 )
return 1LL;
}
return 0LL;
}
return 1LL;
}

original_code:
static bool slabset_contain_slab(struct slabset* set, struct page* slab) {
  struct list_head* current = set->slabs.next;
  while(&set->slabs != current) {
 if (&slab->manage == current) {
   return true;
 }
 current = current->next;
  }
  return false;
}

canonical_original_code:
static int slabset_contain_slab(struct slabset *set, struct page *slab) {
  struct list_head *current = set->slabs.next;
  while(&set->slabs != current) {
 if (&slab->manage == current) {
   return true;
 }
 current = current->next;
  }
  return false;
}

variable_types: struct slabset { struct kcache { int object_size; int slab_size; int objects_per_slab; unsigned long align; struct slabset full_set; struct slabset partial_set; struct slabset empty_set; } *parent; int slab_count; int objects_free; struct list_head { struct list_head *next; } slabs; } *

variable_types: struct page { unsigned long virtual; char allocated; char order; struct list_head manage; struct list_head list; } *

variable_types: struct list_head { struct list_head *next; } *


decompiled_code:
__int64 __fastcall slab_alloc_object(__int64 *a1, int a2, int a3, int a4)
{
__int64 v4; // r12
__int64 v6; // r13
__int64 v7; // rax

v4 = a4;
v6 = *a1;
printk(1LL, 36LL, "slab_alloc_object(): slab = %x, order = %x\n", a1, (unsigned int)*((char *)a1 + 9));
if ( a3 <= 0 )
return 0LL;
v7 = 0LL;
while ( *(_BYTE *)(v6 + v7) )
{
if ( ++v7 == a3 )
return 0LL;
}
*(_BYTE *)(v6 + v7) = -1;
return v6 + v4 + a2 * (int)v7;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 *a1, int a2, int a3, int a4)
{
__int64 v4; // r12
__int64 v6; // r13
__int64 v7; // rax

v4 = a4;
v6 = *a1;
printk(1LL, 36LL, "slab_alloc_object(): slab = %x, order = %x\n", a1, (unsigned int)*((char *)a1 + 9));
if ( a3 <= 0 )
return 0LL;
v7 = 0LL;
while ( *(_BYTE *)(v6 + v7) )
{
if ( ++v7 == a3 )
return 0LL;
}
*(_BYTE *)(v6 + v7) = -1;
return v6 + v4 + a2 * (int)v7;
}

original_code:
static void* slab_alloc_object(struct page* slab, int object_size, int objects_per_slab, int align) {
  unsigned char* map = (unsigned char*)slab->virtual;
  int i;
  void * result = ((void *)0);
  printk(0x01, 0x24, "slab_alloc_object(): slab = %x, order = %x\n", slab, slab->order);
  for (i = 0; i < objects_per_slab; i++) {
 if ((unsigned char)0 == map[i]) {
   map[i] = (unsigned char)0xff;
   result = (void *)((map + align) + object_size * i);
   break;
 }
  }
  return result;
}

canonical_original_code:
static void *slab_alloc_object(struct page *slab, int object_size, int objects_per_slab, int align) {
  unsigned char *map = (unsigned char*)slab->virtual;
  int i;
  void *result = ((void *)0);
  printk(0x01, 0x24, "slab_alloc_object(): slab = %x, order = %x\n", slab, slab->order);
  for (i = 0; i < objects_per_slab; i++) {
 if ((unsigned char)0 == map[i]) {
   map[i] = (unsigned char)0xff;
   result = (void *)((map + align) + object_size * i);
   break;
 }
  }
  return result;
}

variable_types: struct page { unsigned long virtual; char allocated; char order; struct list_head { struct list_head *next; } manage; struct list_head list; } *

variable_types: align int

variable_types:
map
unsigned char *

variable_types: i int

variable_types:
result
void *

return_type: void *

user_defined_types: struct page { unsigned long virtual; char allocated; char order; struct list_head manage; struct list_head list; }


original_code:
static void slabset_remove_slab(struct page* slab, struct slabset* set) {
  struct list_head* current = &set->slabs;
  while(&slab->manage != current->next) {
 printk(0x01, 0x25, "slab = %x, &slab->manage = %x, current->next = %x\n", slab, &slab->manage, current->next);
 current = current->next;
  }
  current->next = current->next->next;
  if (slab->manage.next == &set->slabs) {
 set->slabs.prev = current;
  }
  set->slab_count --;
}

canonical_original_code:
static void slabset_remove_slab(struct page *slab, struct slabset *set) {
  struct list_head *current = &set->slabs;
  while(&slab->manage != current->next) {
 printk(0x01, 0x25, "slab = %x, &slab->manage = %x, current->next = %x\n", slab, &slab->manage, current->next);
 current = current->next;
  }
  current->next = current->next->next;
  if (slab->manage.next == &set->slabs) {
 set->slabs.prev = current;
  }
  set->slab_count --;
}

variable_types: struct slabset { struct kcache { int object_size; int slab_size; int objects_per_slab; unsigned long align; struct slabset full_set; struct slabset partial_set; struct slabset empty_set; } *parent; int slab_count; int objects_free; struct list_head slabs; } *

return_type: void

user_defined_types: struct slabset { struct kcache *parent; int slab_count; int objects_free; struct list_head slabs; }

user_defined_types: struct list_head { struct list_head *next; }


decompiled_code:
__int64 __fastcall slab_free_object(_QWORD *a1, int a2, int a3, int a4, _BYTE *a5)
{
_BYTE *v8; // r13
__int64 v9; // rcx
_BYTE *i; // rax
_BYTE *v12; // rbx

v8 = (_BYTE *)*a1;
printk(1LL, 37LL, "slab_free_object(): slab = %x\n", a1);
if ( a3 <= 0 )
{
LABEL_7:
printk(1LL, 16LL, "returned memory %x is not a valid address\n", (unsigned int)a5);
return 0LL;
}
if ( a5 != &v8[a4] )
{
LODWORD(v9) = 0;
for ( i = &v8[a2 + (__int64)a4]; ; i += a2 )
{
v9 = (unsigned int)(v9 + 1);
if ( a3 == (_DWORD)v9 )
break;
if ( a5 == i )
{
v12 = &v8[(int)v9];
goto LABEL_9;
}
}
goto LABEL_7;
}
v12 = v8;
v9 = 0LL;
LABEL_9:
printk(1LL, 37LL, "objects index found: %x\n", v9);
printk(1LL, 37LL, "map = %x\n", v8);
if ( !*v12 )
printk(1LL, 16LL, "returned memory %x was not allocated\n", (unsigned int)a5);
*v12 = 0;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, int a2, int a3, int a4, _BYTE *a5)
{
_BYTE *v8; // r13
__int64 v9; // rcx
_BYTE *i; // rax
_BYTE *v12; // rbx

v8 = (_BYTE *)*a1;
printk(1LL, 37LL, "slab_free_object(): slab = %x\n", a1);
if ( a3 <= 0 )
{
LABEL_7:
printk(1LL, 16LL, "returned memory %x is not a valid address\n", (unsigned int)a5);
return 0LL;
}
if ( a5 != &v8[a4] )
{
LODWORD(v9) = 0;
for ( i = &v8[a2 + (__int64)a4]; ; i += a2 )
{
v9 = (unsigned int)(v9 + 1);
if ( a3 == (_DWORD)v9 )
break;
if ( a5 == i )
{
v12 = &v8[(int)v9];
goto LABEL_9;
}
}
goto LABEL_7;
}
v12 = v8;
v9 = 0LL;
LABEL_9:
printk(1LL, 37LL, "objects index found: %x\n", v9);
printk(1LL, 37LL, "map = %x\n", v8);
if ( !*v12 )
printk(1LL, 16LL, "returned memory %x was not allocated\n", (unsigned int)a5);
*v12 = 0;
return 1LL;
}

original_code:
static bool slab_free_object(struct page* slab, int object_size, int objects_per_slab, int align, void* object) {
  unsigned char* map = (unsigned char*)slab->virtual;
  int i;
  printk(0x01, 0x25, "slab_free_object(): slab = %x\n", slab);
  for (i = 0; i < objects_per_slab; i++) {
 if (object == (map + align + object_size * i)) {
   printk(0x01, 0x25, "objects index found: %x\n", i);
   printk(0x01, 0x25, "map = %x\n", map);
   if ((unsigned char)0 == map[i])
  printk(0x01, 0x10, "returned memory %x was not allocated\n", (unsigned int)object);
   map[i] = (unsigned char)0;
   return true;
 }
  }
  printk(0x01, 0x10, "returned memory %x is not a valid address\n", (unsigned int)object);
  return false;
}

canonical_original_code:
static int slab_free_object(struct page *slab, int object_size, int objects_per_slab, int align, void *object) {
  unsigned char *map = (unsigned char*)slab->virtual;
  int i;
  printk(0x01, 0x25, "slab_free_object(): slab = %x\n", slab);
  for (i = 0; i < objects_per_slab; i++) {
 if (object == (map + align + object_size * i)) {
   printk(0x01, 0x25, "objects index found: %x\n", i);
   printk(0x01, 0x25, "map = %x\n", map);
   if ((unsigned char)0 == map[i])
  printk(0x01, 0x10, "returned memory %x was not allocated\n", (unsigned int)object);
   map[i] = (unsigned char)0;
   return true;
 }
  }
  printk(0x01, 0x10, "returned memory %x is not a valid address\n", (unsigned int)object);
  return false;
}

variable_types:
object
void *

return_type: int


decompiled_code:
__int64 __fastcall slabset_grow(__int64 a1)
{
__int64 v2; // rbp
__int64 result; // rax
_QWORD *v4; // rdx
void *v5; // rdi

printk(1LL, 36LL, "slabset_grow()\n");
printk(1LL, 36LL, "need to alloc %x pages\n", *(unsigned int *)(*(_QWORD *)a1 + 4LL));
v2 = pages_alloc(*(unsigned int *)(*(_QWORD *)a1 + 4LL));
printk(1LL, 36LL, "slab allocated : %x\n", v2);
result = 0LL;
if ( v2 )
{
v4 = *(_QWORD **)(a1 + 24);
++*(_DWORD *)(a1 + 8);
v5 = *(void **)v2;
*v4 = v2 + 16;
*(_QWORD *)(a1 + 24) = v2 + 16;
*(_QWORD *)(v2 + 16) = a1 + 16;
*(_QWORD *)(v2 + 24) = a1 + 16;
slab_init_isra_0(v5, *(_DWORD *)(*(_QWORD *)a1 + 8LL));
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 v2; // rbp
__int64 result; // rax
_QWORD *v4; // rdx
void *v5; // rdi

printk(1LL, 36LL, "slabset_grow()\n");
printk(1LL, 36LL, "need to alloc %x pages\n", *(unsigned int *)(*(_QWORD *)a1 + 4LL));
v2 = pages_alloc(*(unsigned int *)(*(_QWORD *)a1 + 4LL));
printk(1LL, 36LL, "slab allocated : %x\n", v2);
result = 0LL;
if ( v2 )
{
v4 = *(_QWORD **)(a1 + 24);
++*(_DWORD *)(a1 + 8);
v5 = *(void **)v2;
*v4 = v2 + 16;
*(_QWORD *)(a1 + 24) = v2 + 16;
*(_QWORD *)(v2 + 16) = a1 + 16;
*(_QWORD *)(v2 + 24) = a1 + 16;
func10(v5, *(_DWORD *)(*(_QWORD *)a1 + 8LL));
result = 1LL;
}
return result;
}

original_code:
static bool slabset_grow(struct slabset* set) {
  struct page* pg = ((void *)0);
  printk(0x01, 0x24, "slabset_grow()\n");
  printk(0x01, 0x24, "need to alloc %x pages\n", set->parent->slab_size);
  pg = pages_alloc(set->parent->slab_size);
  printk(0x01, 0x24, "slab allocated : %x\n", pg);
  if (((void *)0) == pg)
 return false;
  set->slab_count ++;
  set->slabs.prev->next = &pg->manage;
  set->slabs.prev = &pg->manage;
  pg->manage.next = &set->slabs;
  pg->manage.prev = &set->slabs;
  slab_init(pg, set->parent->objects_per_slab);
  return true;
}

canonical_original_code:
static int slabset_grow(struct slabset *set) {
  struct page *pg = ((void *)0);
  printk(0x01, 0x24, "slabset_grow()\n");
  printk(0x01, 0x24, "need to alloc %x pages\n", set->parent->slab_size);
  pg = pages_alloc(set->parent->slab_size);
  printk(0x01, 0x24, "slab allocated : %x\n", pg);
  if (((void *)0) == pg)
 return false;
  set->slab_count ++;
  set->slabs.prev->next = &pg->manage;
  set->slabs.prev = &pg->manage;
  pg->manage.next = &set->slabs;
  pg->manage.prev = &set->slabs;
  slab_init(pg, set->parent->objects_per_slab);
  return true;
}

user_defined_types: struct kcache { int object_size; int slab_size; int objects_per_slab; unsigned long align; struct slabset full_set; struct slabset partial_set; struct slabset empty_set; }


decompiled_code:
__int64 __fastcall kcache_alloc(int *a1)
{
__int64 v1; // r13
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rbp
__int64 *v5; // rax
__int64 *v6; // rbp
__int64 v7; // r12

v1 = (__int64)(a1 + 14);
if ( !a1[16] )
{
v2 = (__int64)(a1 + 22);
if ( !a1[24] && !(unsigned int)slabset_grow((__int64)(a1 + 22)) )
{
printk(1LL, 16LL, "why can't empty slab grow?\n");
while ( 1 )
;
}
v3 = slabset_get_first_slab(v2);
v4 = v3;
if ( !v3 )
{
printk(1LL, 16LL, "empty slab shouldn't be empty\n");
while ( 1 )
;
}
v1 = (__int64)(a1 + 14);
slabset_remove_slab(v3, v2);
slabset_add_slab(v4, (__int64)(a1 + 14));
}
v5 = (__int64 *)slabset_get_first_slab(v1);
v6 = v5;
if ( !v5 )
{
printk(1LL, 16LL, "partial set can't be empty\n");
while ( 1 )
;
}
v7 = slab_alloc_object(v5, *a1, a1[2], a1[4]);
if ( (unsigned int)is_slab_full_isra_0(*v6, (unsigned int)a1[2]) )
{
slabset_remove_slab((__int64)v6, v1);
slabset_add_slab((__int64)v6, (__int64)(a1 + 6));
}
return v7;
}

original_code:
static void* kcache_alloc(struct kcache* cache) {
  struct page* slab;
  void* result = ((void *)0);
  if (0 == cache->partial_set.slab_count) {
 if (0 == cache->empty_set.slab_count) {
   bool grow = false;
   grow = slabset_grow(&(cache->empty_set));
   if (false == grow) {
  printk(0x01, 0x10, "why can't empty slab grow?\n");
  while(1);
  return ((void *)0);
   }
 }
 slab = slabset_get_first_slab(&(cache->empty_set));
 if (((void *)0) == slab) {
   printk(0x01, 0x10, "empty slab shouldn't be empty\n");
   while(1);
   return ((void *)0);
 }
 slabset_remove_slab(slab, &(cache->empty_set));
 slabset_add_slab(slab, &(cache->partial_set));
  }
  slab = slabset_get_first_slab(&(cache->partial_set));
  if (((void *)0) == slab) {
 printk(0x01, 0x10, "partial set can't be empty\n");
 while(1);
 return ((void *)0);
  }
  result = slab_alloc_object(slab, cache->object_size, cache->objects_per_slab, cache->align);
  if (is_slab_full(slab, cache->objects_per_slab)) {
 slabset_remove_slab(slab, &(cache->partial_set));
 slabset_add_slab(slab, &(cache->full_set));
  }
  return result;
}

canonical_original_code:
static void *kcache_alloc(struct kcache *cache) {
  struct page *slab;
  void *result = ((void *)0);
  if (0 == cache->partial_set.slab_count) {
 if (0 == cache->empty_set.slab_count) {
   int grow = false;
   grow = slabset_grow(&(cache->empty_set));
   if (false == grow) {
  printk(0x01, 0x10, "why can't empty slab grow?\n");
  while(1);
  return ((void *)0);
   }
 }
 slab = slabset_get_first_slab(&(cache->empty_set));
 if (((void *)0) == slab) {
   printk(0x01, 0x10, "empty slab shouldn't be empty\n");
   while(1);
   return ((void *)0);
 }
 slabset_remove_slab(slab, &(cache->empty_set));
 slabset_add_slab(slab, &(cache->partial_set));
  }
  slab = slabset_get_first_slab(&(cache->partial_set));
  if (((void *)0) == slab) {
 printk(0x01, 0x10, "partial set can't be empty\n");
 while(1);
 return ((void *)0);
  }
  result = slab_alloc_object(slab, cache->object_size, cache->objects_per_slab, cache->align);
  if (is_slab_full(slab, cache->objects_per_slab)) {
 slabset_remove_slab(slab, &(cache->partial_set));
 slabset_add_slab(slab, &(cache->full_set));
  }
  return result;
}

variable_types: struct kcache { int object_size; int slab_size; int objects_per_slab; unsigned long align; struct slabset { struct kcache *parent; int slab_count; int objects_free; struct list_head { struct list_head *next; } slabs; } full_set; struct slabset partial_set; struct slabset empty_set; } *

variable_types: grow int


decompiled_code:
char *__fastcall get_kcache(int a1)
{
char *result; // rax

result = 0LL;
if ( a1 <= 10 )
result = (char *)&kcache_array + 120 * a1;
return result;
}

canonical_decompiled_code:
char *__fastcall func13(int a1)
{
char *result; // rax

result = 0LL;
if ( a1 <= 10 )
result = (char *)&kcache_array + 120 * a1;
return result;
}

original_code:
struct kcache* get_kcache(int index) {
  if (index < 11)
 return &kcache_array[index];
  else
 return ((void *)0);
}

canonical_original_code:
struct kcache *get_kcache(int index) {
  if (index < 11)
 return &kcache_array[index];
  else
 return ((void *)0);
}

variable_types: index int

return_type: struct kcache { int object_size; int slab_size; int objects_per_slab; unsigned long align; struct slabset { struct kcache *parent; int slab_count; int objects_free; struct list_head { struct list_head *next; } slabs; } full_set; struct slabset partial_set; struct slabset empty_set; } *


original_code:
void slab_alloc_init() {
  int i;
  int wasted_bytes;
  for(i = 0; i < 11; i++) {
 kcache_array[i].object_size = object_size_array[i];
 kcache_array[i].slab_size = slab_size_array[i];
 kcache_array[i].objects_per_slab = (kcache_array[i].slab_size * (1UL<<12))/(kcache_array[i].object_size + 1);
 wasted_bytes = (kcache_array[i].slab_size * (1UL<<12)) % kcache_array[i].object_size;
 kcache_array[i].align = kcache_array[i].slab_size * (1UL<<12) - kcache_array[i].objects_per_slab * kcache_array[i].object_size - wasted_bytes;
 kcache_array[i].full_set.parent = &kcache_array[i];
 kcache_array[i].full_set.slab_count = 0;
 kcache_array[i].full_set.objects_free = 0;
 INIT_LIST_HEAD(&(kcache_array[i].full_set.slabs));
 kcache_array[i].partial_set.parent = &kcache_array[i];
 kcache_array[i].partial_set.slab_count = 0;
 kcache_array[i].partial_set.objects_free = 0;
 INIT_LIST_HEAD(&(kcache_array[i].partial_set.slabs));
 kcache_array[i].empty_set.parent = &kcache_array[i];
 kcache_array[i].empty_set.slab_count = 0;
 kcache_array[i].empty_set.objects_free = 0;
 INIT_LIST_HEAD(&(kcache_array[i].empty_set.slabs));
  }
}


decompiled_code:
__int64 __fastcall slab_alloc(int a1)
{
__int64 v1; // rax
int i; // edx
__int64 v3; // rcx
__int64 v4; // rbx

if ( (unsigned int)(a1 - 1) > 0x7FF )
return 0LL;
v1 = 0LL;
for ( i = 8; ; i = object_size_array[v1] )
{
v3 = (unsigned int)v1;
if ( a1 <= i )
break;
if ( ++v1 == 11 )
{
v4 = 1320LL;
v3 = 11LL;
goto LABEL_7;
}
}
v4 = 120LL * (int)v1;
LABEL_7:
printk(1LL, 36LL, "slab_alloc(): cache_index = %x\n", v3);
return kcache_alloc((int *)((char *)&kcache_array + v4));
}

canonical_decompiled_code:
__int64 __fastcall func15(int a1)
{
__int64 v1; // rax
int i; // edx
__int64 v3; // rcx
__int64 v4; // rbx

if ( (unsigned int)(a1 - 1) > 0x7FF )
return 0LL;
v1 = 0LL;
for ( i = 8; ; i = object_size_array[v1] )
{
v3 = (unsigned int)v1;
if ( a1 <= i )
break;
if ( ++v1 == 11 )
{
v4 = 1320LL;
v3 = 11LL;
goto LABEL_7;
}
}
v4 = 120LL * (int)v1;
LABEL_7:
printk(1LL, 36LL, "slab_alloc(): cache_index = %x\n", v3);
return func12((int *)((char *)&kcache_array + v4));
}

original_code:
void* slab_alloc(int size) {
  int cache_index;
  if((size > 2048) || (size <= 0))
 return ((void *)0);
  for(cache_index = 0; cache_index < 11; cache_index++)
 if (object_size_array[cache_index] >= size)
   break;
  printk(0x01, 0x24, "slab_alloc(): cache_index = %x\n", cache_index);
  return kcache_alloc(&kcache_array[cache_index]);
}

canonical_original_code:
void *slab_alloc(int size) {
  int cache_index;
  if((size > 2048) || (size <= 0))
 return ((void *)0);
  for(cache_index = 0; cache_index < 11; cache_index++)
 if (object_size_array[cache_index] >= size)
   break;
  printk(0x01, 0x24, "slab_alloc(): cache_index = %x\n", cache_index);
  return kcache_alloc(&kcache_array[cache_index]);
}

variable_types: size int


decompiled_code:
void *bootmem_initialize()
{
unsigned __int64 v0; // rbx
__int64 v1; // rbp
void *result; // rax
size_t v3; // rdx

v0 = ((unsigned __int64)(unsigned int)(kernel_end + 0x40000000) + 4095) >> 12;
printk(
1LL,
32LL,
"_kernel_end = %x, kernel_end_pages = %d, BOOTMEM_MAP_SIZE = %d\n",
(unsigned int)kernel_end,
(unsigned int)v0,
0x4000LL);
MEMORY[0xC0000000] = v0;
if ( v0 <= 1 )
{
v1 = 1LL;
}
else
{
v1 = (int)v0;
result = memset((void *)0xC0000001LL, 255, (unsigned int)(v0 - 1));
if ( (int)v0 > 0x3FFF )
return result;
}
v3 = (unsigned int)(0x4000 - v1);
if ( (int)v1 > 0x3FFF )
v3 = 1LL;
return memset((void *)(v1 + 3221225472LL), 0, v3);
}

canonical_decompiled_code:
void *func0()
{
unsigned __int64 v0; // rbx
__int64 v1; // rbp
void *result; // rax
size_t v3; // rdx

v0 = ((unsigned __int64)(unsigned int)(kernel_end + 0x40000000) + 4095) >> 12;
printk(
1LL,
32LL,
"_kernel_end = %x, kernel_end_pages = %d, BOOTMEM_MAP_SIZE = %d\n",
(unsigned int)kernel_end,
(unsigned int)v0,
0x4000LL);
MEMORY[0xC0000000] = v0;
if ( v0 <= 1 )
{
v1 = 1LL;
}
else
{
v1 = (int)v0;
result = memset((void *)0xC0000001LL, 255, (unsigned int)(v0 - 1));
if ( (int)v0 > 0x3FFF )
return result;
}
v3 = (unsigned int)(0x4000 - v1);
if ( (int)v1 > 0x3FFF )
v3 = 1LL;
return memset((void *)(v1 + 3221225472LL), 0, v3);
}

original_code:
void bootmem_initialize() {
  int kernel_end_pages = (_kernel_end - 0xc0000000 + (1UL<<12) - 1)/(1UL<<12);
  int i;
  unsigned char *map_item = (unsigned char *)0xc0000000;
  printk(0x01, 0x20, "_kernel_end = %x, kernel_end_pages = %d, BOOTMEM_MAP_SIZE = %d\n", _kernel_end, kernel_end_pages, (0x4000000 >> 12));
  i = 0;
  map_item[i++] = (unsigned char)kernel_end_pages;
  for (; i < kernel_end_pages; i++) {
 map_item[i] = (unsigned char)0xff;
  }
  for (; i < ((0x4000000 >> 12)); i++) {
 map_item[i] = (unsigned char)0x00;
  }
}


original_code:
void *bootmem_alloc(int pages) {
  int i, cont = 0;
  unsigned char *map_item = (unsigned char *)0xc0000000;
  if (0 == pages)
 return ((void *)0);
  for (i=0; i<(0x4000000 >> 12); i++) {
    if (0x00 == (unsigned char)map_item[i]) {
      cont ++;
    } else {
      cont = 0;
    }
    if (cont == pages) {
      printk(0x01, 0x20, "i = %d, cont = %d\n", i ,cont);
      for (; cont>0; cont--) {
 map_item[i - pages + cont] = (unsigned char)0xff;
      }
      map_item[i - pages + 1] = (unsigned char)(0xff & pages);
      return (void*)(0xc0000000 + (i - (pages - 1)) * (1UL<<12));
    }
  }
  return ((void *)0);
}

canonical_original_code:
void *bootmem_alloc(int pages) {
  int i; int cont = 0;
  unsigned char *map_item = (unsigned char *)0xc0000000;
  if (0 == pages)
 return ((void *)0);
  for (i=0; i<(0x4000000 >> 12); i++) {
    if (0x00 == (unsigned char)map_item[i]) {
      cont ++;
    } else {
      cont = 0;
    }
    if (cont == pages) {
      printk(0x01, 0x20, "i = %d, cont = %d\n", i ,cont);
      for (; cont>0; cont--) {
 map_item[i - pages + cont] = (unsigned char)0xff;
      }
      map_item[i - pages + 1] = (unsigned char)(0xff & pages);
      return (void *)(0xc0000000 + (i - (pages - 1)) * (1UL<<12));
    }
  }
  return ((void *)0);
}

variable_types: pages int

variable_types: cont int


original_code:
void bootmem_free(void *addr) {
  int page_index = ((unsigned long)addr - 0xc0000000)/(1UL<<12);
  unsigned char *map_item = (unsigned char *)0xc0000000;
  int pages = map_item[page_index];
  for (; pages>0; pages--) {
 map_item[page_index + pages - 1] = 0x00;
  }
}

variable_types:
addr
void *


decompiled_code:
void *bootmem_finalize()
{
return memset((void *)0xC0000000LL, 0, 0x4000uLL);
}

canonical_decompiled_code:
void *func3()
{
return memset((void *)0xC0000000LL, 0, 0x4000uLL);
}

original_code:
void bootmem_finalize() {
  int i;
  unsigned char *map_item = (unsigned char *)0xc0000000;
  for (i = 0; i < (0x4000000 >> 12); i++) {
 map_item[i] = (unsigned char)0x00;
  }
}


decompiled_code:
void ring_buffer_test_initialize()
{
int v0; // ebp
const __m128i *v1; // rax

v0 = get_ring_buffer_test_cases_count();
v1 = (const __m128i *)get_ring_buffer_test_cases_array();
add_test_cases_isra_0(v1, v0);
}

canonical_decompiled_code:
void func3()
{
int v0; // ebp
const __m128i *v1; // rax

v0 = get_ring_buffer_test_cases_count();
v1 = (const __m128i *)get_ring_buffer_test_cases_array();
func2(v1, v0);
}

original_code:
void ring_buffer_test_initialize() {
  _add_test_cases(get_ring_buffer_test_cases_array(), get_ring_buffer_test_cases_count());
}


decompiled_code:
void ring_buffer_test_finalize()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void ring_buffer_test_finalize() {
}

canonical_original_code:
void ring_buffer_test_finalize() {
}


decompiled_code:
__int64 test_suite_clean()
{
free(*(void **)kernel_ring_buffer);
free(kernel_ring_buffer);
free(*(void **)user_ring_buffer);
free(user_ring_buffer);
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
free(*(void **)kernel_ring_buffer);
free(kernel_ring_buffer);
free(*(void **)user_ring_buffer);
free(user_ring_buffer);
return 0LL;
}

original_code:
static int test_suite_clean(void) {
  free(kernel_ring_buffer->upper);
  free(kernel_ring_buffer);
  free(user_ring_buffer->upper);
  free(user_ring_buffer);
  return 0;
}

canonical_original_code:
static int test_suite_clean() {
  free(kernel_ring_buffer->upper);
  free(kernel_ring_buffer);
  free(user_ring_buffer->upper);
  free(user_ring_buffer);
  return 0;
}


decompiled_code:
__int64 test_suite_init()
{
kernel_ring_buffer = (void *)create_ring_buffer();
user_ring_buffer = (void *)create_ring_buffer();
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
kernel_ring_buffer = (void *)create_ring_buffer();
user_ring_buffer = (void *)create_ring_buffer();
return 0LL;
}

original_code:
static int test_suite_init(void) {
  kernel_ring_buffer = create_ring_buffer();
  user_ring_buffer = create_ring_buffer();
  return 0;
}

canonical_original_code:
static int test_suite_init() {
  kernel_ring_buffer = create_ring_buffer();
  user_ring_buffer = create_ring_buffer();
  return 0;
}


decompiled_code:
__int64 __fastcall register_file_system(char *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
registered_file_systems = a1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
registered_file_systems = a1;
return 0LL;
}

original_code:
int register_file_system(struct file_system_type *type) {
  if (((void *)0) == type)
 return -1;
  else {
 registered_file_systems = type;
 return 0;
  }
}

variable_types: struct file_system_type { char name[16]; struct fs_node_operations { int (*create)(struct _vfs_node { char name[16]; struct _date_t { int year; int month; int day; int hour; int minute; int second; } date; enum vfs_node_type { VFS_NODE_TYPE_FILE=0, VFS_NODE_TYPE_DIR=1 } type; struct _vfs_node *parent; struct list_head { struct list_head *next; } list; union { struct _vfs_file { enum vfs_file_type { FILE_TYPE_REGULAR=0, FILE_TYPE_EXE=1 } type; void *addr; int size; } file; struct _vfs_dir { struct list_head nodes; } dir; }; } *, enum vfs_node_type { VFS_NODE_TYPE_FILE=0, VFS_NODE_TYPE_DIR=1 }); int (*remove)(struct _vfs_node *); int (*rename)(struct _vfs_node *, char *, int); int (*move)(struct _vfs_node *, struct _vfs_node *, struct _vfs_node *); } *node_operations; struct fs_file_operations { int (*read)(struct _vfs_node *, char *, int, int); int (*write)(struct _vfs_node *, char *, int, int); } *file_operations; struct fs_mount_operations { struct _vfs_node *(*file_system_mount)(); void (*file_system_unmount)(); } *mount_operations; } *

user_defined_types: struct file_system_type { char name[16]; struct fs_node_operations *node_operations; struct fs_file_operations *file_operations; struct fs_mount_operations *mount_operations; }

user_defined_types: struct fs_node_operations { int (*create)(struct _vfs_node *, enum vfs_node_type); int (*remove)(struct _vfs_node *); int (*rename)(struct _vfs_node *, char *, int); int (*move)(struct _vfs_node *, struct _vfs_node *, struct _vfs_node *); }

user_defined_types: struct _vfs_node { char name[16]; struct _date_t date; enum vfs_node_type type; struct _vfs_node *parent; struct list_head list; union { struct _vfs_file file; struct _vfs_dir dir; }; }

user_defined_types: struct _vfs_file { enum vfs_file_type type; void *addr; int size; }


decompiled_code:
__int64 unregister_file_system()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 0LL;
}

original_code:
int unregister_file_system(struct file_system_type *type) {
 return 0;
}

user_defined_types: struct fs_file_operations { int (*read)(struct _vfs_node *, char *, int, int); int (*write)(struct _vfs_node *, char *, int, int); }

user_defined_types: struct fs_mount_operations { struct _vfs_node *(*file_system_mount)(); void (*file_system_unmount)(); }

user_defined_types: enum vfs_node_type { VFS_NODE_TYPE_FILE=0, VFS_NODE_TYPE_DIR=1 }

user_defined_types: struct _date_t { int year; int month; int day; int hour; int minute; int second; }

user_defined_types: struct _vfs_dir { struct list_head nodes; }

user_defined_types: enum vfs_file_type { FILE_TYPE_REGULAR=0, FILE_TYPE_EXE=1 }


decompiled_code:
__int64 __fastcall mount_file_system(const char *a1)
{
char *v1; // rbx
unsigned int v2; // er12

v1 = registered_file_systems;
if ( !registered_file_systems )
return (unsigned int)-1;
v2 = strcmp(a1, registered_file_systems);
if ( v2 )
return (unsigned int)-2;
root_vfs_node = (**((__int64 (***)(void))v1 + 4))();
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
char *v1; // rbx
unsigned int v2; // er12

v1 = registered_file_systems;
if ( !registered_file_systems )
return (unsigned int)-1;
v2 = strcmp(a1, registered_file_systems);
if ( v2 )
return (unsigned int)-2;
root_vfs_node = (**((__int64 (***)(void))v1 + 4))();
return v2;
}

original_code:
int mount_file_system(char *name) {
  if (((void *)0) == registered_file_systems) {
 return -1;
  } else {
 if (strcmp(name, registered_file_systems->name) == 0) {
   root_vfs_node = registered_file_systems->mount_operations->file_system_mount();
 } else {
   return -2;
 }
  }
  return 0;
}

variable_types:
name
char *


decompiled_code:
__int64 unmount_file_system()
{
if ( !registered_file_systems )
return 0xFFFFFFFFLL;
(*(void (**)(void))(*((_QWORD *)registered_file_systems + 4) + 8LL))();
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
if ( !registered_file_systems )
return 0xFFFFFFFFLL;
(*(void (**)(void))(*((_QWORD *)registered_file_systems + 4) + 8LL))();
return 0LL;
}

original_code:
int unmount_file_system() {
  if (((void *)0) == registered_file_systems) {
 return -1;
  } else {
 registered_file_systems->mount_operations->file_system_unmount();
 return 0;
  }
}


decompiled_code:
__int64 *get_fs_listfs_test_cases_array()
{
return test_cases_array;
}

canonical_decompiled_code:
__int64 *func1()
{
return test_cases_array;
}

original_code:
CU_TestInfo* get_fs_listfs_test_cases_array() {
  return test_cases_array;
}

canonical_original_code:
struct CU_TestInfo *get_fs_listfs_test_cases_array() {
  return test_cases_array;
}

return_type: struct CU_TestInfo { char *pName; void (*pTestFunc)(); } *


decompiled_code:
__int64 get_fs_listfs_test_cases_count()
{
return 20LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 20LL;
}

original_code:
int get_fs_listfs_test_cases_count() {
  return sizeof(test_cases_array)/sizeof(CU_TestInfo);
}


decompiled_code:
void fs_listfs_test_initialize()
{
int v0; // ebp
const __m128i *v1; // rax

v0 = get_fs_listfs_parser_test_cases_count();
v1 = (const __m128i *)get_fs_listfs_parser_test_cases_array();
add_test_cases_isra_0(v1, v0);
}

canonical_decompiled_code:
void func3()
{
int v0; // ebp
const __m128i *v1; // rax

v0 = get_fs_listfs_parser_test_cases_count();
v1 = (const __m128i *)get_fs_listfs_parser_test_cases_array();
func0(v1, v0);
}

original_code:
void fs_listfs_test_initialize() {
  _add_test_cases(get_fs_listfs_parser_test_cases_array(), get_fs_listfs_parser_test_cases_count());
}


decompiled_code:
void fs_listfs_test_finalize()
{
;
}

original_code:
void fs_listfs_test_finalize() {
}

canonical_original_code:
void fs_listfs_test_finalize() {
}


kmalloc

decompiled_code:
__int64 __fastcall kmalloc(int a1)
{
__int64 result; // rax
unsigned __int64 v2; // rbp

if ( a1 <= 0 )
return 0LL;
if ( boot_alloc_ready != 1 || __PAIR64__(page_alloc_ready, slab_alloc_ready) )
{
if ( a1 > 2048 )
{
v2 = (unsigned __int64)(a1 + 4095LL) >> 12;
printk(1LL, 34LL, "page allocator is choosen to allocate %d pages\n", (unsigned int)v2);
result = *(_QWORD *)pages_alloc((unsigned int)v2);
}
else
{
printk(1LL, 36LL, "slab allocator is choosen to allocate %d bytes\n", (unsigned int)a1);
result = slab_alloc((unsigned int)a1);
}
}
else
{
printk(1LL, 36LL, "boot allocator is choosen to allocate %d bytes\n", (unsigned int)a1);
result = bootmem_alloc((unsigned __int64)(a1 + 4095LL) >> 12);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 result; // rax
unsigned __int64 v2; // rbp

if ( a1 <= 0 )
return 0LL;
if ( boot_alloc_ready != 1 || __PAIR64__(page_alloc_ready, slab_alloc_ready) )
{
if ( a1 > 2048 )
{
v2 = (unsigned __int64)(a1 + 4095LL) >> 12;
printk(1LL, 34LL, "page allocator is choosen to allocate %d pages\n", (unsigned int)v2);
result = *(_QWORD *)pages_alloc((unsigned int)v2);
}
else
{
printk(1LL, 36LL, "slab allocator is choosen to allocate %d bytes\n", (unsigned int)a1);
result = slab_alloc((unsigned int)a1);
}
}
else
{
printk(1LL, 36LL, "boot allocator is choosen to allocate %d bytes\n", (unsigned int)a1);
result = bootmem_alloc((unsigned __int64)(a1 + 4095LL) >> 12);
}
return result;
}

original_code:
void* kmalloc(int size) {
  if (size <= 0)
 return ((void *)0);
  else if ((boot_alloc_ready == true) && (page_alloc_ready == false) && (slab_alloc_ready ==false)) {
 printk(0x01, 0x24, "boot allocator is choosen to allocate %d bytes\n", size);
 int n = (size + (1UL<<12) - 1)/(1UL<<12);
 return bootmem_alloc(n);
  } else if (size <= ((1UL<<12)/2)) {
 printk(0x01, 0x24, "slab allocator is choosen to allocate %d bytes\n", size);
 return (void*)slab_alloc(size);
  } else {
 struct page* pages;
 int n = (size + (1UL<<12) - 1)/(1UL<<12);
 printk(0x01, 0x22, "page allocator is choosen to allocate %d pages\n", n);
 pages = pages_alloc(n);
 return (void*)pages->virtual;
  }
}

canonical_original_code:
void *kmalloc(int size) {
  if (size <= 0)
 return ((void *)0);
  else if ((boot_alloc_ready == true) && (page_alloc_ready == false) && (slab_alloc_ready ==false)) {
 printk(0x01, 0x24, "boot allocator is choosen to allocate %d bytes\n", size);
 int n = (size + (1UL<<12) - 1)/(1UL<<12);
 return bootmem_alloc(n);
  } else if (size <= ((1UL<<12)/2)) {
 printk(0x01, 0x24, "slab allocator is choosen to allocate %d bytes\n", size);
 return (void *)slab_alloc(size);
  } else {
 struct page *pages;
 int n = (size + (1UL<<12) - 1)/(1UL<<12);
 printk(0x01, 0x22, "page allocator is choosen to allocate %d pages\n", n);
 pages = pages_alloc(n);
 return (void *)pages->virtual;
  }
}

variable_types: n int


kfree

decompiled_code:
__int64 __fastcall kfree(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // r12
__int64 result; // rax

if ( test_page_offset > (unsigned int)a1 || (unsigned int)a1 > 0xC4000000 )
return printk(1LL, 16LL, "returned memory %x is out of area\n", (unsigned int)a1);
if ( boot_alloc_ready == 1 && !__PAIR64__(page_alloc_ready, slab_alloc_ready) )
return bootmem_free();
v1 = virtual_to_page();
v2 = page_to_buddy(v1);
v3 = v2;
if ( *(_QWORD *)(v2 + 24) || *(_QWORD *)(v2 + 16) )
{
printk(1LL, 37LL, "returned memory %x was allocated by slab allocator\n", (unsigned int)a1);
result = slab_free(a1);
}
else
{
printk(1LL, 35LL, "returned memory %x was allocated by page allocator\n", (unsigned int)a1);
result = pages_free(v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // r12
__int64 result; // rax

if ( test_page_offset > (unsigned int)a1 || (unsigned int)a1 > 0xC4000000 )
return printk(1LL, 16LL, "returned memory %x is out of area\n", (unsigned int)a1);
if ( boot_alloc_ready == 1 && !__PAIR64__(page_alloc_ready, slab_alloc_ready) )
return bootmem_free();
v1 = virtual_to_page();
v2 = page_to_buddy(v1);
v3 = v2;
if ( *(_QWORD *)(v2 + 24) || *(_QWORD *)(v2 + 16) )
{
printk(1LL, 37LL, "returned memory %x was allocated by slab allocator\n", (unsigned int)a1);
result = slab_free(a1);
}
else
{
printk(1LL, 35LL, "returned memory %x was allocated by page allocator\n", (unsigned int)a1);
result = pages_free(v3);
}
return result;
}

original_code:
void kfree(void *p) {
  if (((unsigned int)p < (unsigned int)test_page_offset) || ((unsigned int)p > (unsigned int)(0xc0000000 + 0x4000000))) {
 printk(0x01, 0x10, "returned memory %x is out of area\n", (unsigned int)p);
 return;
  }
  else {
 if ((boot_alloc_ready == true) && (page_alloc_ready == false) && (slab_alloc_ready ==false)) {
   bootmem_free(p);
 } else {
   struct page *pg, *buddy;
   pg = (struct page*)virtual_to_page(p);
   buddy = (struct page*)page_to_buddy(pg);
   if ((((void *)0) == buddy->manage.prev) && (((void *)0) == buddy->manage.next)) {
  printk(0x01, 0x23, "returned memory %x was allocated by page allocator\n", (unsigned int)p);
  pages_free(buddy);
   } else {
  printk(0x01, 0x25, "returned memory %x was allocated by slab allocator\n", (unsigned int)p);
  slab_free(p);
   }
 }
  }
}

canonical_original_code:
void kfree(void *p) {
  if (((unsigned int)p < (unsigned int)test_page_offset) || ((unsigned int)p > (unsigned int)(0xc0000000 + 0x4000000))) {
 printk(0x01, 0x10, "returned memory %x is out of area\n", (unsigned int)p);
 return;
  }
  else {
 if ((boot_alloc_ready == true) && (page_alloc_ready == false) && (slab_alloc_ready ==false)) {
   bootmem_free(p);
 } else {
   struct page *pg; struct page *buddy;
   pg = (struct page *)virtual_to_page(p);
   buddy = (struct page *)page_to_buddy(pg);
   if ((((void *)0) == buddy->manage.prev) && (((void *)0) == buddy->manage.next)) {
  printk(0x01, 0x23, "returned memory %x was allocated by page allocator\n", (unsigned int)p);
  pages_free(buddy);
   } else {
  printk(0x01, 0x25, "returned memory %x was allocated by slab allocator\n", (unsigned int)p);
  slab_free(p);
   }
 }
  }
}

variable_types:
p
void *

variable_types: struct page { unsigned long virtual; char allocated; char order; struct list_head { struct list_head *next; } manage; struct list_head list; } *


original_code:
static int find_command_id(char *cmd) {
  int ret = -1;
  if (0 == cmd)
 ret = 0;
  else {
 if (0 == strcmp(cmd, "elf"))
   ret = 1;
 else if (0 == strcmp(cmd, "elfs"))
   ret = 2;
 else if (0 == strcmp(cmd, "elfa"))
   ret = 3;
 else if (0 == strcmp(cmd, "ls"))
   ret = 4;
 else if (0 == strcmp(cmd, "tree"))
   ret = 5;
 else if (0 == strcmp(cmd, "jiffies"))
   ret = 6;
 else if (0 == strcmp(cmd, "cat"))
   ret = 7;
 else if (0 == strcmp(cmd, "kmsg"))
   ret = 8;
 else if (0 == strcmp(cmd, "ps"))
   ret = 9;
 else if (0 == strcmp(cmd, "kill"))
   ret = 10;
 else if (0 == strcmp(cmd, "log"))
   ret = 11;
 else if (0 == strcmp(cmd, "reset"))
   ret = 12;
 else if (0 == strcmp(cmd, "help"))
   ret = 13;
 else
   ret = -1;
  }
  return ret;
}

variable_types:
cmd
char *

variable_types: ret int


decompiled_code:
__int64 kernel_shell()
{
__int64 v0; // rbp
char v1; // r12
char *v2; // rbp
const char *v3; // rcx
__int64 v4; // rbx
__int64 v5; // rbx
const char *v7; // [rsp+0h] [rbp-158h] BYREF
const char *v8; // [rsp+8h] [rbp-150h] BYREF
const char *v9; // [rsp+10h] [rbp-148h] BYREF
const char *v10; // [rsp+18h] [rbp-140h]
const char *v11; // [rsp+20h] [rbp-138h]
const char *v12; // [rsp+28h] [rbp-130h]
__int128 v13[18]; // [rsp+30h] [rbp-128h] BYREF

v0 = 1LL;
v13[0] = 0LL;
v13[1] = 0LL;
v13[2] = 0LL;
v13[3] = 0LL;
v13[4] = 0LL;
v13[5] = 0LL;
v13[6] = 0LL;
v13[7] = 0LL;
v13[8] = 0LL;
v13[9] = 0LL;
v13[10] = 0LL;
v13[11] = 0LL;
v13[12] = 0LL;
v13[13] = 0LL;
v13[14] = 0LL;
v13[15] = 0LL;
printk(0LL, 37LL, "%s: kernel shell started\n", "kernel_shell");
memset(v13, 0, 0x100uLL);
v1 = inputc();
printk(0LL, 37LL, "%s: char %c was received\n", "kernel_shell", (unsigned int)v1);
LOBYTE(v13[0]) = v1;
while ( v1 != 10 )
{
v1 = inputc();
printk(0LL, 37LL, "%s: char %c was received\n", "kernel_shell", (unsigned int)v1);
*((_BYTE *)v13 + v0++) = v1;
if ( v0 == 256 )
{
printk(0LL, 37LL, "%s: received command line: %s\n", "kernel_shell", (const char *)v13);
printk(0LL, 37LL, "%s: received command line length: %d\n", "kernel_shell", 256LL);
return 0LL;
}
}
printk(0LL, 37LL, "%s: received command line: %s\n", "kernel_shell", (const char *)v13);
printk(0LL, 37LL, "%s: received command line length: %d\n", "kernel_shell", (unsigned int)v0);
v2 = cmd_line_stripe_constprop_0((char *)v13);
printk(0LL, 37LL, "%s: command line after striping:\n%s\n", v3, v2);
v4 = (unsigned int)cmd_line_parse_isra_0(v2, &v7, &v8, &v9);
printk(0LL, 37LL, "%s: cmd_line_parse = %d\n", "kernel_shell", v4);
printk(0LL, 37LL, "%s: separated command line:\n", "kernel_shell");
printk(0LL, 37LL, "%s: command = %s\n", "kernel_shell", v7);
if ( v8 )
printk(0LL, 37LL, "%s: primary_parameter = %s\n", "kernel_shell", v8);
if ( v9 )
printk(0LL, 37LL, "%s: secondary_parameters[0] = %s\n", "kernel_shell", v9);
if ( v10 )
printk(0LL, 37LL, "%s: secondary_parameters[1] = %s\n", "kernel_shell", v10);
if ( v11 )
printk(0LL, 37LL, "%s: secondary_parameters[2] = %s\n", "kernel_shell", v11);
if ( v12 )
printk(0LL, 37LL, "%s: secondary_parameters[3] = %s\n", "kernel_shell", v12);
if ( (_DWORD)v4 != -1 )
{
v5 = (unsigned int)find_command_id(v7);
printk(0LL, 37LL, "%s: cmd_id = %d\n", "kernel_shell", v5);
switch ( (int)v5 )
{
case 1:
handle_cmd_elf(v8, &v9);
break;
case 2:
handle_cmd_elfs(v8, &v9);
break;
case 3:
handle_cmd_elfa(v8, &v9);
break;
case 4:
handle_cmd_ls(v8, &v9);
break;
case 5:
handle_cmd_tree(v8, &v9);
break;
case 6:
handle_cmd_jiffies(v8, &v9);
break;
case 7:
handle_cmd_cat(v8, &v9);
break;
case 8:
handle_cmd_kmsg(v8, &v9);
break;
case 9:
handle_cmd_ps(v8, &v9);
break;
case 10:
handle_cmd_kill(v8, &v9);
break;
case 11:
handle_cmd_log(v8, &v9);
break;
case 12:
handle_cmd_reset(v8, &v9);
break;
case 13:
handle_cmd_help(v8, &v9);
break;
default:
return 0LL;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbp
char v1; // r12
char *v2; // rbp
const char *v3; // rcx
__int64 v4; // rbx
__int64 v5; // rbx
const char *v7; // [rsp+0h] [rbp-158h] BYREF
const char *v8; // [rsp+8h] [rbp-150h] BYREF
const char *v9; // [rsp+10h] [rbp-148h] BYREF
const char *v10; // [rsp+18h] [rbp-140h]
const char *v11; // [rsp+20h] [rbp-138h]
const char *v12; // [rsp+28h] [rbp-130h]
__int128 v13[18]; // [rsp+30h] [rbp-128h] BYREF

v0 = 1LL;
v13[0] = 0LL;
v13[1] = 0LL;
v13[2] = 0LL;
v13[3] = 0LL;
v13[4] = 0LL;
v13[5] = 0LL;
v13[6] = 0LL;
v13[7] = 0LL;
v13[8] = 0LL;
v13[9] = 0LL;
v13[10] = 0LL;
v13[11] = 0LL;
v13[12] = 0LL;
v13[13] = 0LL;
v13[14] = 0LL;
v13[15] = 0LL;
printk(0LL, 37LL, "%s: kernel shell started\n", "kernel_shell");
memset(v13, 0, 0x100uLL);
v1 = inputc();
printk(0LL, 37LL, "%s: char %c was received\n", "kernel_shell", (unsigned int)v1);
LOBYTE(v13[0]) = v1;
while ( v1 != 10 )
{
v1 = inputc();
printk(0LL, 37LL, "%s: char %c was received\n", "kernel_shell", (unsigned int)v1);
*((_BYTE *)v13 + v0++) = v1;
if ( v0 == 256 )
{
printk(0LL, 37LL, "%s: received command line: %s\n", "kernel_shell", (const char *)v13);
printk(0LL, 37LL, "%s: received command line length: %d\n", "kernel_shell", 256LL);
return 0LL;
}
}
printk(0LL, 37LL, "%s: received command line: %s\n", "kernel_shell", (const char *)v13);
printk(0LL, 37LL, "%s: received command line length: %d\n", "kernel_shell", (unsigned int)v0);
v2 = func1((char *)v13);
printk(0LL, 37LL, "%s: command line after striping:\n%s\n", v3, v2);
v4 = (unsigned int)func2(v2, &v7, &v8, &v9);
printk(0LL, 37LL, "%s: cmd_line_parse = %d\n", "kernel_shell", v4);
printk(0LL, 37LL, "%s: separated command line:\n", "kernel_shell");
printk(0LL, 37LL, "%s: command = %s\n", "kernel_shell", v7);
if ( v8 )
printk(0LL, 37LL, "%s: primary_parameter = %s\n", "kernel_shell", v8);
if ( v9 )
printk(0LL, 37LL, "%s: secondary_parameters[0] = %s\n", "kernel_shell", v9);
if ( v10 )
printk(0LL, 37LL, "%s: secondary_parameters[1] = %s\n", "kernel_shell", v10);
if ( v11 )
printk(0LL, 37LL, "%s: secondary_parameters[2] = %s\n", "kernel_shell", v11);
if ( v12 )
printk(0LL, 37LL, "%s: secondary_parameters[3] = %s\n", "kernel_shell", v12);
if ( (_DWORD)v4 != -1 )
{
v5 = (unsigned int)func0(v7);
printk(0LL, 37LL, "%s: cmd_id = %d\n", "kernel_shell", v5);
switch ( (int)v5 )
{
case 1:
handle_cmd_elf(v8, &v9);
break;
case 2:
handle_cmd_elfs(v8, &v9);
break;
case 3:
handle_cmd_elfa(v8, &v9);
break;
case 4:
handle_cmd_ls(v8, &v9);
break;
case 5:
handle_cmd_tree(v8, &v9);
break;
case 6:
handle_cmd_jiffies(v8, &v9);
break;
case 7:
handle_cmd_cat(v8, &v9);
break;
case 8:
handle_cmd_kmsg(v8, &v9);
break;
case 9:
handle_cmd_ps(v8, &v9);
break;
case 10:
handle_cmd_kill(v8, &v9);
break;
case 11:
handle_cmd_log(v8, &v9);
break;
case 12:
handle_cmd_reset(v8, &v9);
break;
case 13:
handle_cmd_help(v8, &v9);
break;
default:
return 0LL;
}
}
return 0LL;
}

original_code:
int __attribute__ ((__section__(".init.text"))) kernel_shell(void *unused) {
  char ch = 0;
  char cmd_line[256] = {0};
  int i = 0, cmd_id, error;
  char *cmd_p;
  char *command, *primary_parameter, *secondary_parameters[4];
  printk(0x00, 0x25, "%s: kernel shell started\n", __func__);
  ("\n");
  ("********************************************************************************\n");
  ("                        Sparrow OS default shell\n");
  ("********************************************************************************\n");
  ("\n");
  do {
 for (i = 0; i < 256; i++)
   cmd_line[i] = 0;
 i = 0;
 ("[sparrow] $: ");
 do {
   ch = inputc();
   printk(0x00, 0x25, "%s: char %c was received\n", __func__, ch);
   cmd_line[i] = ch;
   i++;
   ("%c", ch);
   if (i >= 256)
  break;
 } while('\n' != ch);
 printk(0x00, 0x25, "%s: received command line: %s\n", __func__, cmd_line);
 printk(0x00, 0x25, "%s: received command line length: %d\n", __func__, i);
 if (i >= 256)
   continue;
 cmd_p = cmd_line_stripe(cmd_line, 256);
 printk(0x00, 0x25, "%s: command line after striping:\n%s\n", __func__, cmd_p);
 error = cmd_line_parse(&cmd_p, &command, &primary_parameter, secondary_parameters);
 printk(0x00, 0x25, "%s: cmd_line_parse = %d\n", __func__, error);
 printk(0x00, 0x25, "%s: separated command line:\n", __func__);
 printk(0x00, 0x25, "%s: command = %s\n", __func__, command);
 if (primary_parameter)
   printk(0x00, 0x25, "%s: primary_parameter = %s\n", __func__, primary_parameter);
 if (secondary_parameters[0])
   printk(0x00, 0x25, "%s: secondary_parameters[0] = %s\n", __func__, secondary_parameters[0]);
 if (secondary_parameters[1])
   printk(0x00, 0x25, "%s: secondary_parameters[1] = %s\n", __func__, secondary_parameters[1]);
 if (secondary_parameters[2])
   printk(0x00, 0x25, "%s: secondary_parameters[2] = %s\n", __func__, secondary_parameters[2]);
 if (secondary_parameters[3])
   printk(0x00, 0x25, "%s: secondary_parameters[3] = %s\n", __func__, secondary_parameters[3]);
 if (-1 == error) {
   ("invalid command\n");
   continue;
 }
 cmd_id = find_command_id(command);
 printk(0x00, 0x25, "%s: cmd_id = %d\n", __func__, cmd_id);
 switch (cmd_id) {
 case 0:
   break;
 case 1:
   handle_cmd_elf(primary_parameter, secondary_parameters);
   break;
 case 2:
   handle_cmd_elfs(primary_parameter, secondary_parameters);
   break;
 case 3:
   handle_cmd_elfa(primary_parameter, secondary_parameters);
   break;
 case 4:
   handle_cmd_ls(primary_parameter, secondary_parameters);
   break;
 case 5:
   handle_cmd_tree(primary_parameter, secondary_parameters);
   break;
 case 6:
   handle_cmd_jiffies(primary_parameter, secondary_parameters);
   break;
 case 7:
   handle_cmd_cat(primary_parameter, secondary_parameters);
   break;
 case 8:
   handle_cmd_kmsg(primary_parameter, secondary_parameters);
   break;
 case 9:
   handle_cmd_ps(primary_parameter, secondary_parameters);
   break;
 case 10:
   handle_cmd_kill(primary_parameter, secondary_parameters);
   break;
 case 11:
   handle_cmd_log(primary_parameter, secondary_parameters);
   break;
 case 12:
   handle_cmd_reset(primary_parameter, secondary_parameters);
   break;
 case 13:
   handle_cmd_help(primary_parameter, secondary_parameters);
   break;
 default:
   ("command '%s' is not known\n", cmd_p);
   continue;
 }
  } while(0);
  return 0;
}

canonical_original_code:
int kernel_shell(void *unused) {
  char ch = 0;
  char cmd_line[256] = {0};
  int i = 0; int cmd_id; int error;
  char *cmd_p;
  char *command; char *primary_parameter; char *secondary_parameters[4];
  printk(0x00, 0x25, "%s: kernel shell started\n", __func__);
  ("\n");
  ("********************************************************************************\n");
  ("                        Sparrow OS default shell\n");
  ("********************************************************************************\n");
  ("\n");
  do {
 for (i = 0; i < 256; i++)
   cmd_line[i] = 0;
 i = 0;
 ("[sparrow] $: ");
 do {
   ch = inputc();
   printk(0x00, 0x25, "%s: char %c was received\n", __func__, ch);
   cmd_line[i] = ch;
   i++;
   ("%c", ch);
   if (i >= 256)
  break;
 } while('\n' != ch);
 printk(0x00, 0x25, "%s: received command line: %s\n", __func__, cmd_line);
 printk(0x00, 0x25, "%s: received command line length: %d\n", __func__, i);
 if (i >= 256)
   continue;
 cmd_p = cmd_line_stripe(cmd_line, 256);
 printk(0x00, 0x25, "%s: command line after striping:\n%s\n", __func__, cmd_p);
 error = cmd_line_parse(&cmd_p, &command, &primary_parameter, secondary_parameters);
 printk(0x00, 0x25, "%s: cmd_line_parse = %d\n", __func__, error);
 printk(0x00, 0x25, "%s: separated command line:\n", __func__);
 printk(0x00, 0x25, "%s: command = %s\n", __func__, command);
 if (primary_parameter)
   printk(0x00, 0x25, "%s: primary_parameter = %s\n", __func__, primary_parameter);
 if (secondary_parameters[0])
   printk(0x00, 0x25, "%s: secondary_parameters[0] = %s\n", __func__, secondary_parameters[0]);
 if (secondary_parameters[1])
   printk(0x00, 0x25, "%s: secondary_parameters[1] = %s\n", __func__, secondary_parameters[1]);
 if (secondary_parameters[2])
   printk(0x00, 0x25, "%s: secondary_parameters[2] = %s\n", __func__, secondary_parameters[2]);
 if (secondary_parameters[3])
   printk(0x00, 0x25, "%s: secondary_parameters[3] = %s\n", __func__, secondary_parameters[3]);
 if (-1 == error) {
   ("invalid command\n");
   continue;
 }
 cmd_id = find_command_id(command);
 printk(0x00, 0x25, "%s: cmd_id = %d\n", __func__, cmd_id);
 switch (cmd_id) {
 case 0:
   break;
 case 1:
   handle_cmd_elf(primary_parameter, secondary_parameters);
   break;
 case 2:
   handle_cmd_elfs(primary_parameter, secondary_parameters);
   break;
 case 3:
   handle_cmd_elfa(primary_parameter, secondary_parameters);
   break;
 case 4:
   handle_cmd_ls(primary_parameter, secondary_parameters);
   break;
 case 5:
   handle_cmd_tree(primary_parameter, secondary_parameters);
   break;
 case 6:
   handle_cmd_jiffies(primary_parameter, secondary_parameters);
   break;
 case 7:
   handle_cmd_cat(primary_parameter, secondary_parameters);
   break;
 case 8:
   handle_cmd_kmsg(primary_parameter, secondary_parameters);
   break;
 case 9:
   handle_cmd_ps(primary_parameter, secondary_parameters);
   break;
 case 10:
   handle_cmd_kill(primary_parameter, secondary_parameters);
   break;
 case 11:
   handle_cmd_log(primary_parameter, secondary_parameters);
   break;
 case 12:
   handle_cmd_reset(primary_parameter, secondary_parameters);
   break;
 case 13:
   handle_cmd_help(primary_parameter, secondary_parameters);
   break;
 default:
   ("command '%s' is not known\n", cmd_p);
   continue;
 }
  } while(0);
  return 0;
}

variable_types:
unused
void *

variable_types: ch char

variable_types: i int

variable_types: error int

variable_types:
command
char *


decompiled_code:
__int64 __fastcall test_case_common(int a1)
{
test_id = a1;
char_index = 0;
return kernel_shell();
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
test_id = a1;
char_index = 0;
return kernel_shell();
}

original_code:
static void test_case_common(int id) {
  test_id = id;
  char_index = 0;
  kernel_shell();
}

variable_types: id int


decompiled_code:
__int64 test_case_15()
{
return test_case_common(14);
}

canonical_decompiled_code:
__int64 func1()
{
return func0(14);
}

original_code:
static void test_case_15(void) {
  test_case_common(14);
  return;
}

canonical_original_code:
static void test_case_15() {
  test_case_common(14);
  return;
}


decompiled_code:
__int64 test_case_14()
{
return test_case_common(13);
}

canonical_decompiled_code:
__int64 func2()
{
return func0(13);
}

original_code:
static void test_case_14(void) {
  test_case_common(13);
  return;
}

canonical_original_code:
static void test_case_14() {
  test_case_common(13);
  return;
}


inputc

decompiled_code:
__int64 inputc()
{
char *v0; // rdx
__int64 v1; // rax

v0 = (&test_cmds)[test_id];
v1 = char_index++;
return (unsigned __int8)v0[v1];
}

canonical_decompiled_code:
__int64 func16()
{
char *v0; // rdx
__int64 v1; // rax

v0 = (&test_cmds)[test_id];
v1 = char_index++;
return (unsigned __int8)v0[v1];
}

original_code:
char inputc() {
  return test_cmds[test_id][char_index++];
}

return_type: char


decompiled_code:
char **get_shell_test_cases_array()
{
return &test_cases_array;
}

canonical_decompiled_code:
char **func17()
{
return &test_cases_array;
}

original_code:
CU_TestInfo* get_shell_test_cases_array() {
  return test_cases_array;
}

canonical_original_code:
struct CU_TestInfo *get_shell_test_cases_array() {
  return test_cases_array;
}

user_defined_types: struct CU_TestInfo { char *pName; void (*pTestFunc)(); }


decompiled_code:
__int64 get_shell_test_cases_count()
{
return 15LL;
}

canonical_decompiled_code:
__int64 func18()
{
return 15LL;
}

original_code:
int get_shell_test_cases_count() {
  return sizeof(test_cases_array)/sizeof(CU_TestInfo);
}


decompiled_code:
__int64 test_case_13()
{
return test_case_common(12);
}

canonical_decompiled_code:
__int64 func3()
{
return func0(12);
}

original_code:
static void test_case_13(void) {
  test_case_common(12);
  return;
}

canonical_original_code:
static void test_case_13() {
  test_case_common(12);
  return;
}


decompiled_code:
__int64 test_case_12()
{
return test_case_common(11);
}

canonical_decompiled_code:
__int64 func4()
{
return func0(11);
}

original_code:
static void test_case_12(void) {
  test_case_common(11);
  return;
}

canonical_original_code:
static void test_case_12() {
  test_case_common(11);
  return;
}


decompiled_code:
__int64 test_case_11()
{
return test_case_common(10);
}

canonical_decompiled_code:
__int64 func5()
{
return func0(10);
}

original_code:
static void test_case_11(void) {
  test_case_common(10);
  return;
}

canonical_original_code:
static void test_case_11() {
  test_case_common(10);
  return;
}


decompiled_code:
__int64 test_case_10()
{
return test_case_common(9);
}

canonical_decompiled_code:
__int64 func6()
{
return func0(9);
}

original_code:
static void test_case_10(void) {
  test_case_common(9);
  return;
}

canonical_original_code:
static void test_case_10() {
  test_case_common(9);
  return;
}


decompiled_code:
__int64 test_case_09()
{
return test_case_common(8);
}

canonical_decompiled_code:
__int64 func7()
{
return func0(8);
}

original_code:
static void test_case_09(void) {
  test_case_common(8);
  return;
}

canonical_original_code:
static void test_case_09() {
  test_case_common(8);
  return;
}


decompiled_code:
__int64 test_case_08()
{
return test_case_common(7);
}

canonical_decompiled_code:
__int64 func8()
{
return func0(7);
}

original_code:
static void test_case_08(void) {
  test_case_common(7);
  return;
}

canonical_original_code:
static void test_case_08() {
  test_case_common(7);
  return;
}


decompiled_code:
__int64 test_case_07()
{
return test_case_common(6);
}

canonical_decompiled_code:
__int64 func9()
{
return func0(6);
}

original_code:
static void test_case_07(void) {
  test_case_common(6);
  return;
}

canonical_original_code:
static void test_case_07() {
  test_case_common(6);
  return;
}


decompiled_code:
__int64 test_case_06()
{
return test_case_common(5);
}

canonical_decompiled_code:
__int64 func10()
{
return func0(5);
}

original_code:
static void test_case_06(void) {
  test_case_common(5);
  return;
}

canonical_original_code:
static void test_case_06() {
  test_case_common(5);
  return;
}


decompiled_code:
__int64 test_case_05()
{
return test_case_common(4);
}

canonical_decompiled_code:
__int64 func11()
{
return func0(4);
}

original_code:
static void test_case_05(void) {
  test_case_common(4);
  return;
}

canonical_original_code:
static void test_case_05() {
  test_case_common(4);
  return;
}


decompiled_code:
__int64 test_case_04()
{
return test_case_common(3);
}

canonical_decompiled_code:
__int64 func12()
{
return func0(3);
}

original_code:
static void test_case_04(void) {
  test_case_common(3);
  return;
}

canonical_original_code:
static void test_case_04() {
  test_case_common(3);
  return;
}


decompiled_code:
__int64 test_case_03()
{
return test_case_common(2);
}

canonical_decompiled_code:
__int64 func13()
{
return func0(2);
}

original_code:
static void test_case_03(void) {
  test_case_common(2);
  return;
}

canonical_original_code:
static void test_case_03() {
  test_case_common(2);
  return;
}


decompiled_code:
__int64 test_case_02()
{
return test_case_common(1);
}

canonical_decompiled_code:
__int64 func14()
{
return func0(1);
}

original_code:
static void test_case_02(void) {
  test_case_common(1);
  return;
}

canonical_original_code:
static void test_case_02() {
  test_case_common(1);
  return;
}


decompiled_code:
__int64 test_case_01()
{
return test_case_common(0);
}

canonical_decompiled_code:
__int64 func15()
{
return func0(0);
}

original_code:
static void test_case_01(void) {
  test_case_common(0);
  return;
}

canonical_original_code:
static void test_case_01() {
  test_case_common(0);
  return;
}


decompiled_code:
void shell_test_initialize()
{
int v0; // ebp
const __m128i *v1; // rax

v0 = get_shell_test_cases_count();
v1 = (const __m128i *)get_shell_test_cases_array();
add_test_cases_isra_0(v1, v0);
}

canonical_decompiled_code:
void func3()
{
int v0; // ebp
const __m128i *v1; // rax

v0 = get_shell_test_cases_count();
v1 = (const __m128i *)get_shell_test_cases_array();
func2(v1, v0);
}

original_code:
void shell_test_initialize() {
  _add_test_cases(get_shell_test_cases_array(), get_shell_test_cases_count());
}


decompiled_code:
void shell_test_finalize()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void shell_test_finalize() {
}

canonical_original_code:
void shell_test_finalize() {
}


decompiled_code:
__int64 test_suite_init()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
static int test_suite_init(void) {
  return 0;
}

canonical_original_code:
static int test_suite_init() {
  return 0;
}


decompiled_code:
// attributes: thunk
__int64 test_suite_clean()
{
return test_suite_init();
}

canonical_decompiled_code:
__int64 func1()
{
return func0();
}

original_code:
static int test_suite_clean(void) {
  return 0;
}

canonical_original_code:
static int test_suite_clean() {
  return 0;
}


decompiled_code:
__int64 test_initialize()
{
fs_test_initialize();
mm_test_initialize();
glibc_test_initialize();
shell_test_initialize();
return ring_buffer_test_initialize();
}

canonical_decompiled_code:
__int64 func0()
{
fs_test_initialize();
mm_test_initialize();
glibc_test_initialize();
shell_test_initialize();
return ring_buffer_test_initialize();
}

original_code:
void test_initialize() {
  fs_test_initialize();
  mm_test_initialize();
  glibc_test_initialize();
  shell_test_initialize();
  ring_buffer_test_initialize();
}


decompiled_code:
__int64 test_finalize()
{
fs_test_finalize();
mm_test_finalize();
glibc_test_finalize();
shell_test_finalize();
return ring_buffer_test_finalize();
}

canonical_decompiled_code:
__int64 func1()
{
fs_test_finalize();
mm_test_finalize();
glibc_test_finalize();
shell_test_finalize();
return ring_buffer_test_finalize();
}

original_code:
void test_finalize() {
  fs_test_finalize();
  mm_test_finalize();
  glibc_test_finalize();
  shell_test_finalize();
  ring_buffer_test_finalize();
}


main

canonical_name: main

original_code:
int main() {
  int i = 0;
  CU_ErrorCode error;
  test_initialize();
  CU_SuiteInfo all_test_suites[5 + 1];
  all_test_suites[i++] = fs_test_suite;
  all_test_suites[i++] = mm_test_suite;
  all_test_suites[i++] = glibc_test_suite;
  all_test_suites[i++] = shell_test_suite;
  all_test_suites[i++] = ring_buffer_test_suite;
  all_test_suites[i++] = (CU_SuiteInfo){ ((void *)0), ((void *)0), ((void *)0), ((void *)0), ((void *)0), ((void *)0) };
  if (CUE_SUCCESS != CU_initialize_registry())
 return CU_get_error();
  error = CU_register_suites(all_test_suites);
  CU_basic_set_mode(CU_BRM_VERBOSE);
  CU_basic_run_tests();
  CU_cleanup_registry();
  error = CU_get_error();
  test_finalize();
  return error;
}

canonical_original_code:
int main() {
  int i = 0;
  enum CU_ErrorCode error;
  test_initialize();
  struct CU_SuiteInfo all_test_suites[-1];
  all_test_suites[i++] = fs_test_suite;
  all_test_suites[i++] = mm_test_suite;
  all_test_suites[i++] = glibc_test_suite;
  all_test_suites[i++] = shell_test_suite;
  all_test_suites[i++] = ring_buffer_test_suite;
  all_test_suites[i++] = (struct CU_SuiteInfo){ ((void *)0), ((void *)0), ((void *)0), ((void *)0), ((void *)0), ((void *)0) };
  if (CUE_SUCCESS != CU_initialize_registry())
 return CU_get_error();
  error = CU_register_suites(all_test_suites);
  CU_basic_set_mode(CU_BRM_VERBOSE);
  CU_basic_run_tests();
  CU_cleanup_registry();
  error = CU_get_error();
  test_finalize();
  return error;
}

variable_types: enum CU_ErrorCode { CUE_SUCCESS=0, CUE_NOMEMORY=1, CUE_NOREGISTRY=10, CUE_REGISTRY_EXISTS=11, CUE_NOSUITE=20, CUE_NO_SUITENAME=21, CUE_SINIT_FAILED=22, CUE_SCLEAN_FAILED=23, CUE_DUP_SUITE=24, CUE_SUITE_INACTIVE=25, CUE_NOTEST=30, CUE_NO_TESTNAME=31, CUE_DUP_TEST=32, CUE_TEST_NOT_IN_SUITE=33, CUE_TEST_INACTIVE=34, CUE_FOPEN_FAILED=40, CUE_FCLOSE_FAILED=41, CUE_BAD_FILENAME=42, CUE_WRITE_ERROR=43 }

variable_types: struct CU_SuiteInfo { char *pName; int (*pInitFunc)(); int (*pCleanupFunc)(); void (*pSetUpFunc)(); void (*pTearDownFunc)(); struct CU_TestInfo { char *pName; void (*pTestFunc)(); } *pTests; } [-1]

user_defined_types: struct CU_SuiteInfo { char *pName; int (*pInitFunc)(); int (*pCleanupFunc)(); void (*pSetUpFunc)(); void (*pTearDownFunc)(); struct CU_TestInfo *pTests; }


strim

decompiled_code:
char *__fastcall strim(char *a1)
{
int v1; // eax
char *i; // rax

v1 = strlen(a1);
if ( !v1 )
return a1;
for ( i = &a1[v1 - 1]; a1 <= i; --i )
{
if ( *i != 32 )
break;
}
i[1] = 0;
return skip_spaces(a1);
}

canonical_decompiled_code:
char *__fastcall func0(char *a1)
{
int v1; // eax
char *i; // rax

v1 = strlen(a1);
if ( !v1 )
return a1;
for ( i = &a1[v1 - 1]; a1 <= i; --i )
{
if ( *i != 32 )
break;
}
i[1] = 0;
return skip_spaces(a1);
}

original_code:
char *strim(char *s)
{
 unsigned int size;
 char *end;
 size = strlen(s);
 if (!size)
  return s;
 end = s + size - 1;
 while (end >= s && ((unsigned char)(*end)==(unsigned char)0x20))
  end--;
 *(end + 1) = '\0';
 return skip_spaces(s);
}

variable_types:
s
char *

variable_types:
size
unsigned int

variable_types:
end
char *

return_type: char *


decompiled_code:
void fs_test_initialize()
{
int v0; // ebp
const __m128i *v1; // rax
int v2; // ebp
const __m128i *v3; // rdi
int v4; // ebp
const __m128i *v5; // rax

fs_listfs_test_initialize();
v0 = get_fs_node_test_cases_count();
v1 = (const __m128i *)get_fs_node_test_cases_array();
add_test_cases_isra_0(v1, v0);
v2 = get_fs_listfs_test_cases_count();
v3 = (const __m128i *)get_fs_listfs_test_cases_array();
add_test_cases_isra_0(v3, v2);
v4 = get_fs_vfs_test_cases_count();
v5 = (const __m128i *)get_fs_vfs_test_cases_array();
add_test_cases_isra_0(v5, v4);
}

canonical_decompiled_code:
void func3()
{
int v0; // ebp
const __m128i *v1; // rax
int v2; // ebp
const __m128i *v3; // rdi
int v4; // ebp
const __m128i *v5; // rax

fs_listfs_test_initialize();
v0 = get_fs_node_test_cases_count();
v1 = (const __m128i *)get_fs_node_test_cases_array();
func2(v1, v0);
v2 = get_fs_listfs_test_cases_count();
v3 = (const __m128i *)get_fs_listfs_test_cases_array();
func2(v3, v2);
v4 = get_fs_vfs_test_cases_count();
v5 = (const __m128i *)get_fs_vfs_test_cases_array();
func2(v5, v4);
}

original_code:
void fs_test_initialize() {
  fs_listfs_test_initialize();
  _add_test_cases(get_fs_node_test_cases_array(), get_fs_node_test_cases_count());
  _add_test_cases(get_fs_listfs_test_cases_array(), get_fs_listfs_test_cases_count());
  _add_test_cases(get_fs_vfs_test_cases_array(), get_fs_vfs_test_cases_count());
}


decompiled_code:
__int64 fs_test_finalize()
{
return fs_listfs_test_finalize();
}

canonical_decompiled_code:
__int64 func4()
{
return fs_listfs_test_finalize();
}

original_code:
void fs_test_finalize() {
  fs_listfs_test_finalize();
}


decompiled_code:
__int64 __fastcall get_next_mcb(__int64 a1)
{
return *(int *)(a1 + 4) + a1 + 12;
}

original_code:
static struct memory_control_block *get_next_mcb(struct memory_control_block *mcb) {
  return (struct memory_control_block *)((unsigned long)mcb + 8 + mcb->size + 4);
}

variable_types:
mcb
struct memory_control_block *

return_type: struct memory_control_block { int allocated; int size; } *


decompiled_code:
int __fastcall my_free(__int64 a1)
{
_DWORD *v1; // rbx
_DWORD *v2; // rax
unsigned __int64 v3; // rdx

v1 = heap_start;
v2 = (_DWORD *)(a1 - 8);
if ( a1 - 8 >= (unsigned __int64)heap_start && (unsigned __int64)v2 < heap_end )
{
*(_DWORD *)(a1 - 8) = 0;
v2 = (_DWORD *)get_next_mcb((__int64)v1);
if ( v3 <= (unsigned __int64)v2 )
goto LABEL_9;
while ( !*v2 )
{
v1[1] += whole_buffer_size_isra_0(v2[1]);
v2 = (_DWORD *)get_next_mcb((__int64)v1);
if ( v3 <= (unsigned __int64)v2 )
goto LABEL_9;
}
if ( v3 <= (unsigned __int64)v2 )
{
LABEL_9:
LODWORD(v2) = brk(v1);
heap_end = (int)v2;
if ( (int)v2 >= (unsigned __int64)(v1 + 4) )
{
LODWORD(v2) = (_DWORD)v2 - (_DWORD)v1 - 12;
v1[1] = (_DWORD)v2;
}
}
}
return (int)v2;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
_DWORD *v1; // rbx
_DWORD *v2; // rax
unsigned __int64 v3; // rdx

v1 = heap_start;
v2 = (_DWORD *)(a1 - 8);
if ( a1 - 8 >= (unsigned __int64)heap_start && (unsigned __int64)v2 < heap_end )
{
*(_DWORD *)(a1 - 8) = 0;
v2 = (_DWORD *)func0((__int64)v1);
if ( v3 <= (unsigned __int64)v2 )
goto LABEL_9;
while ( !*v2 )
{
v1[1] += func1(v2[1]);
v2 = (_DWORD *)func0((__int64)v1);
if ( v3 <= (unsigned __int64)v2 )
goto LABEL_9;
}
if ( v3 <= (unsigned __int64)v2 )
{
LABEL_9:
LODWORD(v2) = brk(v1);
heap_end = (int)v2;
if ( (int)v2 >= (unsigned __int64)(v1 + 4) )
{
LODWORD(v2) = (_DWORD)v2 - (_DWORD)v1 - 12;
v1[1] = (_DWORD)v2;
}
}
}
return (int)v2;
}

original_code:
void my_free(void *ptr)
{
  struct memory_control_block *current_mcb, *next_mcb;
  current_mcb = (struct memory_control_block *)((unsigned long)ptr - 8);
  ("%s: ptr = %x, mcb = %x, allocated = %x, size = %x\n", __func__, (unsigned int)ptr, (unsigned int)current_mcb, current_mcb->allocated, current_mcb->size);
  ("%s: heap_start = %x, heap_end = %x\n", __func__, (unsigned int)heap_start, (unsigned int)heap_end);
  if (((unsigned long)current_mcb < heap_start) || ((unsigned long)current_mcb >= heap_end)) {
 ("%s: invalid address\n", __func__);
 return;
  }
  current_mcb->allocated = 0;
  current_mcb = (struct memory_control_block *)heap_start;
  next_mcb = get_next_mcb(current_mcb);
  while (((unsigned long)next_mcb < heap_end) && (0 == next_mcb->allocated)) {
   current_mcb->size += whole_buffer_size(next_mcb);
   next_mcb = get_next_mcb(current_mcb);
  }
  if ((unsigned long)next_mcb >= heap_end) {
 heap_end = _brk((unsigned long)current_mcb);
 ("%s: after brk: heap_start = %x, heap_end = %x\n", __func__, (unsigned int)heap_start, (unsigned int)heap_end);
 if (heap_end >= ((unsigned long)current_mcb + (8 + 4 + 4)))
   current_mcb->size = heap_end - (unsigned long)current_mcb - 8 - 4;
 else if (heap_end < (unsigned long)current_mcb) {
   ("%s: this should never happen\n", __func__);
   return;
 }
  }
  return;
}

canonical_original_code:
void my_free(void *ptr)
{
  struct memory_control_block *current_mcb; struct memory_control_block *next_mcb;
  current_mcb = (struct memory_control_block *)((unsigned long)ptr - 8);
  ("%s: ptr = %x, mcb = %x, allocated = %x, size = %x\n", __func__, (unsigned int)ptr, (unsigned int)current_mcb, current_mcb->allocated, current_mcb->size);
  ("%s: heap_start = %x, heap_end = %x\n", __func__, (unsigned int)heap_start, (unsigned int)heap_end);
  if (((unsigned long)current_mcb < heap_start) || ((unsigned long)current_mcb >= heap_end)) {
 ("%s: invalid address\n", __func__);
 return;
  }
  current_mcb->allocated = 0;
  current_mcb = (struct memory_control_block *)heap_start;
  next_mcb = get_next_mcb(current_mcb);
  while (((unsigned long)next_mcb < heap_end) && (0 == next_mcb->allocated)) {
   current_mcb->size += whole_buffer_size(next_mcb);
   next_mcb = get_next_mcb(current_mcb);
  }
  if ((unsigned long)next_mcb >= heap_end) {
 heap_end = _brk((unsigned long)current_mcb);
 ("%s: after brk: heap_start = %x, heap_end = %x\n", __func__, (unsigned int)heap_start, (unsigned int)heap_end);
 if (heap_end >= ((unsigned long)current_mcb + (8 + 4 + 4)))
   current_mcb->size = heap_end - (unsigned long)current_mcb - 8 - 4;
 else if (heap_end < (unsigned long)current_mcb) {
   ("%s: this should never happen\n", __func__);
   return;
 }
  }
  return;
}

variable_types:
ptr
void *

variable_types: struct memory_control_block { int allocated; int size; } *


decompiled_code:
char **get_glibc_malloc_test_cases_array()
{
return &test_cases_array;
}

canonical_decompiled_code:
char **func11()
{
return &test_cases_array;
}

original_code:
CU_TestInfo* get_glibc_malloc_test_cases_array() {
  return test_cases_array;
}

canonical_original_code:
struct CU_TestInfo *get_glibc_malloc_test_cases_array() {
  return test_cases_array;
}


decompiled_code:
__int64 get_glibc_malloc_test_cases_count()
{
return 10LL;
}

canonical_decompiled_code:
__int64 func12()
{
return 10LL;
}

original_code:
int get_glibc_malloc_test_cases_count() {
  return sizeof(test_cases_array)/sizeof(CU_TestInfo);
}


decompiled_code:
__int64 test_case_10()
{
unsigned __int64 v0; // rbp
int v1; // ebx
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // rdx
char *v6; // rbx
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10[4096]; // [rsp+0h] [rbp-8018h] BYREF
char v11; // [rsp+8000h] [rbp-18h] BYREF

memset(v10, 0, sizeof(v10));
heap_start = 0LL;
sim_heap_end = sim_heap_start;
v0 = (sim_heap_start + 4095) & 0xFFFFFFFFFFFFF000LL;
v1 = 128;
heap_end = 0LL;
LABEL_2:
while ( 2 )
{
v2 = random();
v3 = my_malloc((unsigned int)(v2 % 128) + 1);
if ( v3 )
{
v4 = random() % 4096;
if ( (v4 & 1) != 0 )
{
v5 = (int)v4;
if ( v4 < 0 )
goto LABEL_7;
do
{
if ( !v10[v5] )
{
v10[(int)v5] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
--v5;
}
while ( (int)v5 >= 0 );
LABEL_7:
while ( v10[v4] )
{
if ( (_DWORD)++v4 == 4096 )
goto LABEL_9;
}
v10[(int)v4] = v3;
if ( --v1 )
continue;
}
else
{
v8 = v4;
v9 = v4;
do
{
if ( !v10[v9] )
{
v10[(int)v9] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
++v9;
}
while ( (_DWORD)v9 != 4096 );
if ( v4 >= 0 )
{
while ( v10[v8] )
{
if ( (int)--v8 < 0 )
goto LABEL_9;
}
v10[(int)v8] = v3;
if ( --v1 )
continue;
}
else
{
LABEL_9:
if ( --v1 )
continue;
}
}
}
break;
}
LABEL_10:
v6 = (char *)v10;
do
{
if ( *(_QWORD *)v6 )
{
my_free();
*(_QWORD *)v6 = 0LL;
}
v6 += 8;
}
while ( v6 != &v11 );
return CU_assertImplementation(
sim_heap_end == v0,
368LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

canonical_decompiled_code:
__int64 func0()
{
unsigned __int64 v0; // rbp
int v1; // ebx
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // rdx
char *v6; // rbx
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10[4096]; // [rsp+0h] [rbp-8018h] BYREF
char v11; // [rsp+8000h] [rbp-18h] BYREF

memset(v10, 0, sizeof(v10));
heap_start = 0LL;
sim_heap_end = sim_heap_start;
v0 = (sim_heap_start + 4095) & 0xFFFFFFFFFFFFF000LL;
v1 = 128;
heap_end = 0LL;
LABEL_2:
while ( 2 )
{
v2 = random();
v3 = my_malloc((unsigned int)(v2 % 128) + 1);
if ( v3 )
{
v4 = random() % 4096;
if ( (v4 & 1) != 0 )
{
v5 = (int)v4;
if ( v4 < 0 )
goto LABEL_7;
do
{
if ( !v10[v5] )
{
v10[(int)v5] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
--v5;
}
while ( (int)v5 >= 0 );
LABEL_7:
while ( v10[v4] )
{
if ( (_DWORD)++v4 == 4096 )
goto LABEL_9;
}
v10[(int)v4] = v3;
if ( --v1 )
continue;
}
else
{
v8 = v4;
v9 = v4;
do
{
if ( !v10[v9] )
{
v10[(int)v9] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
++v9;
}
while ( (_DWORD)v9 != 4096 );
if ( v4 >= 0 )
{
while ( v10[v8] )
{
if ( (int)--v8 < 0 )
goto LABEL_9;
}
v10[(int)v8] = v3;
if ( --v1 )
continue;
}
else
{
LABEL_9:
if ( --v1 )
continue;
}
}
}
break;
}
LABEL_10:
v6 = (char *)v10;
do
{
if ( *(_QWORD *)v6 )
{
my_free();
*(_QWORD *)v6 = 0LL;
}
v6 += 8;
}
while ( v6 != &v11 );
return CU_assertImplementation(
sim_heap_end == v0,
368LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

original_code:
static void test_case_10(void) {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *buff[4096] = {((void *)0)};
  int buff_cnt[4096] = {0};
  void *p = ((void *)0);
  int size, loc, j, m;
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  for (j = 0; j < 128; j++) {
 size = random()%128 + 1;
 p = my_malloc(size);
 if (((void *)0) == p)
   break;
 loc = random()%4096;
 if (loc%2 == 0) {
   int loc_found = 0, i;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 } else {
   int loc_found = 0, i;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 }
  }
  for (j = 0; j < 4096; j++) {
 if (buff[j] != ((void *)0)) {
   my_free(buff[j]);
   buff[j] = ((void *)0);
 }
  }
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 368, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

canonical_original_code:
static void test_case_10() {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *buff[4096] = {((void *)0)};
  int buff_cnt[4096] = {0};
  void *p = ((void *)0);
  int size; int loc; int j; int m;
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  for (j = 0; j < 128; j++) {
 size = random()%128 + 1;
 p = my_malloc(size);
 if (((void *)0) == p)
   break;
 loc = random()%4096;
 if (loc%2 == 0) {
   int loc_found = 0; int i;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 } else {
   int loc_found = 0; int i;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 }
  }
  for (j = 0; j < 4096; j++) {
 if (buff[j] != ((void *)0)) {
   my_free(buff[j]);
   buff[j] = ((void *)0);
 }
  }
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 368, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

variable_types:
buff
void *[4096]

variable_types:
p
void *

variable_types: size int

variable_types: loc int

variable_types: j int

variable_types: m int


decompiled_code:
__int64 test_case_09()
{
unsigned __int64 v0; // rbp
int v1; // ebx
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // rdx
char *v6; // rbx
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10[4096]; // [rsp+0h] [rbp-8018h] BYREF
char v11; // [rsp+8000h] [rbp-18h] BYREF

memset(v10, 0, sizeof(v10));
heap_start = 0LL;
sim_heap_end = sim_heap_start;
v0 = (sim_heap_start + 4095) & 0xFFFFFFFFFFFFF000LL;
v1 = 32;
heap_end = 0LL;
LABEL_2:
while ( 2 )
{
v2 = random();
v3 = my_malloc((unsigned int)(v2 % 128) + 1);
if ( v3 )
{
v4 = random() % 4096;
if ( (v4 & 1) != 0 )
{
v5 = (int)v4;
if ( v4 < 0 )
goto LABEL_7;
do
{
if ( !v10[v5] )
{
v10[(int)v5] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
--v5;
}
while ( (int)v5 >= 0 );
LABEL_7:
while ( v10[v4] )
{
if ( (_DWORD)++v4 == 4096 )
goto LABEL_9;
}
v10[(int)v4] = v3;
if ( --v1 )
continue;
}
else
{
v8 = v4;
v9 = v4;
do
{
if ( !v10[v9] )
{
v10[(int)v9] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
++v9;
}
while ( (_DWORD)v9 != 4096 );
if ( v4 >= 0 )
{
while ( v10[v8] )
{
if ( (int)--v8 < 0 )
goto LABEL_9;
}
v10[(int)v8] = v3;
if ( --v1 )
continue;
}
else
{
LABEL_9:
if ( --v1 )
continue;
}
}
}
break;
}
LABEL_10:
v6 = (char *)v10;
do
{
if ( *(_QWORD *)v6 )
{
my_free();
*(_QWORD *)v6 = 0LL;
}
v6 += 8;
}
while ( v6 != &v11 );
return CU_assertImplementation(
sim_heap_end == v0,
298LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

canonical_decompiled_code:
__int64 func1()
{
unsigned __int64 v0; // rbp
int v1; // ebx
__int64 v2; // rax
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // rdx
char *v6; // rbx
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10[4096]; // [rsp+0h] [rbp-8018h] BYREF
char v11; // [rsp+8000h] [rbp-18h] BYREF

memset(v10, 0, sizeof(v10));
heap_start = 0LL;
sim_heap_end = sim_heap_start;
v0 = (sim_heap_start + 4095) & 0xFFFFFFFFFFFFF000LL;
v1 = 32;
heap_end = 0LL;
LABEL_2:
while ( 2 )
{
v2 = random();
v3 = my_malloc((unsigned int)(v2 % 128) + 1);
if ( v3 )
{
v4 = random() % 4096;
if ( (v4 & 1) != 0 )
{
v5 = (int)v4;
if ( v4 < 0 )
goto LABEL_7;
do
{
if ( !v10[v5] )
{
v10[(int)v5] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
--v5;
}
while ( (int)v5 >= 0 );
LABEL_7:
while ( v10[v4] )
{
if ( (_DWORD)++v4 == 4096 )
goto LABEL_9;
}
v10[(int)v4] = v3;
if ( --v1 )
continue;
}
else
{
v8 = v4;
v9 = v4;
do
{
if ( !v10[v9] )
{
v10[(int)v9] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
++v9;
}
while ( (_DWORD)v9 != 4096 );
if ( v4 >= 0 )
{
while ( v10[v8] )
{
if ( (int)--v8 < 0 )
goto LABEL_9;
}
v10[(int)v8] = v3;
if ( --v1 )
continue;
}
else
{
LABEL_9:
if ( --v1 )
continue;
}
}
}
break;
}
LABEL_10:
v6 = (char *)v10;
do
{
if ( *(_QWORD *)v6 )
{
my_free();
*(_QWORD *)v6 = 0LL;
}
v6 += 8;
}
while ( v6 != &v11 );
return CU_assertImplementation(
sim_heap_end == v0,
298LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

original_code:
static void test_case_09(void) {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *buff[4096] = {((void *)0)};
  int buff_cnt[4096] = {0};
  void *p = ((void *)0);
  int size, loc, j, m;
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  for (j = 0; j < 32; j++) {
 size = random()%128 + 1;
 p = my_malloc(size);
 if (((void *)0) == p)
   break;
 loc = random()%4096;
 if (loc%2 == 0) {
   int loc_found = 0, i;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 } else {
   int loc_found = 0, i;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 }
  }
  for (j = 0; j < 4096; j++) {
 if (buff[j] != ((void *)0)) {
   my_free(buff[j]);
   buff[j] = ((void *)0);
 }
  }
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 298, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

canonical_original_code:
static void test_case_09() {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *buff[4096] = {((void *)0)};
  int buff_cnt[4096] = {0};
  void *p = ((void *)0);
  int size; int loc; int j; int m;
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  for (j = 0; j < 32; j++) {
 size = random()%128 + 1;
 p = my_malloc(size);
 if (((void *)0) == p)
   break;
 loc = random()%4096;
 if (loc%2 == 0) {
   int loc_found = 0; int i;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 } else {
   int loc_found = 0; int i;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 }
  }
  for (j = 0; j < 4096; j++) {
 if (buff[j] != ((void *)0)) {
   my_free(buff[j]);
   buff[j] = ((void *)0);
 }
  }
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 298, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

variable_types: i int


decompiled_code:
__int64 test_case_08()
{
unsigned __int64 v0; // r12
int v1; // ebx
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rdx
char *v6; // rbx
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10[4096]; // [rsp+0h] [rbp-8018h] BYREF
char v11; // [rsp+8000h] [rbp-18h] BYREF

memset(v10, 0, sizeof(v10));
heap_start = 0LL;
sim_heap_end = sim_heap_start;
v0 = (sim_heap_start + 4095) & 0xFFFFFFFFFFFFF000LL;
v1 = 8;
heap_end = 0LL;
LABEL_2:
while ( 2 )
{
v2 = random();
v3 = my_malloc((unsigned int)(v2 % 128) + 1);
if ( v3 )
{
v4 = random() % 4096;
if ( (v4 & 1) != 0 )
{
v5 = (int)v4;
if ( v4 < 0 )
goto LABEL_7;
do
{
if ( !v10[v5] )
{
v10[(int)v5] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
--v5;
}
while ( (int)v5 >= 0 );
LABEL_7:
while ( v10[v4] )
{
if ( (_DWORD)++v4 == 4096 )
goto LABEL_9;
}
v10[(int)v4] = v3;
if ( --v1 )
continue;
}
else
{
v8 = v4;
v9 = v4;
do
{
if ( !v10[v9] )
{
v10[(int)v9] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
++v9;
}
while ( (_DWORD)v9 != 4096 );
if ( v4 >= 0 )
{
while ( v10[v8] )
{
if ( (int)--v8 < 0 )
goto LABEL_9;
}
v10[(int)v8] = v3;
if ( --v1 )
continue;
}
else
{
LABEL_9:
if ( --v1 )
continue;
}
}
}
break;
}
LABEL_10:
v6 = (char *)v10;
do
{
if ( *(_QWORD *)v6 )
{
my_free();
*(_QWORD *)v6 = 0LL;
}
v6 += 8;
}
while ( v6 != &v11 );
return CU_assertImplementation(
sim_heap_end == v0,
228LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

canonical_decompiled_code:
__int64 func2()
{
unsigned __int64 v0; // r12
int v1; // ebx
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rdx
char *v6; // rbx
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10[4096]; // [rsp+0h] [rbp-8018h] BYREF
char v11; // [rsp+8000h] [rbp-18h] BYREF

memset(v10, 0, sizeof(v10));
heap_start = 0LL;
sim_heap_end = sim_heap_start;
v0 = (sim_heap_start + 4095) & 0xFFFFFFFFFFFFF000LL;
v1 = 8;
heap_end = 0LL;
LABEL_2:
while ( 2 )
{
v2 = random();
v3 = my_malloc((unsigned int)(v2 % 128) + 1);
if ( v3 )
{
v4 = random() % 4096;
if ( (v4 & 1) != 0 )
{
v5 = (int)v4;
if ( v4 < 0 )
goto LABEL_7;
do
{
if ( !v10[v5] )
{
v10[(int)v5] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
--v5;
}
while ( (int)v5 >= 0 );
LABEL_7:
while ( v10[v4] )
{
if ( (_DWORD)++v4 == 4096 )
goto LABEL_9;
}
v10[(int)v4] = v3;
if ( --v1 )
continue;
}
else
{
v8 = v4;
v9 = v4;
do
{
if ( !v10[v9] )
{
v10[(int)v9] = v3;
if ( --v1 )
goto LABEL_2;
goto LABEL_10;
}
++v9;
}
while ( (_DWORD)v9 != 4096 );
if ( v4 >= 0 )
{
while ( v10[v8] )
{
if ( (int)--v8 < 0 )
goto LABEL_9;
}
v10[(int)v8] = v3;
if ( --v1 )
continue;
}
else
{
LABEL_9:
if ( --v1 )
continue;
}
}
}
break;
}
LABEL_10:
v6 = (char *)v10;
do
{
if ( *(_QWORD *)v6 )
{
my_free();
*(_QWORD *)v6 = 0LL;
}
v6 += 8;
}
while ( v6 != &v11 );
return CU_assertImplementation(
sim_heap_end == v0,
228LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

original_code:
static void test_case_08(void) {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *buff[4096] = {((void *)0)};
  int buff_cnt[4096] = {0};
  void *p = ((void *)0);
  int size, loc, j, m;
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  ("\n");
  for (j = 0; j < 8; j++) {
 size = random()%128 + 1;
 ("%s: j = %d, size = 0x%x\n", __func__, j, size);
 p = my_malloc(size);
 ("%s: j = %d, p = 0x%x\n", __func__, j, (unsigned int)p);
 if (((void *)0) == p)
   break;
 loc = random()%4096;
 if (loc%2 == 0) {
   int loc_found = 0, i;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 } else {
   int loc_found = 0, i;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 }
  }
  for (j = 0; j < 4096; j++) {
 if (buff[j] != ((void *)0)) {
   my_free(buff[j]);
   buff[j] = ((void *)0);
 }
  }
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 228, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

canonical_original_code:
static void test_case_08() {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *buff[4096] = {((void *)0)};
  int buff_cnt[4096] = {0};
  void *p = ((void *)0);
  int size; int loc; int j; int m;
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  ("\n");
  for (j = 0; j < 8; j++) {
 size = random()%128 + 1;
 ("%s: j = %d, size = 0x%x\n", __func__, j, size);
 p = my_malloc(size);
 ("%s: j = %d, p = 0x%x\n", __func__, j, (unsigned int)p);
 if (((void *)0) == p)
   break;
 loc = random()%4096;
 if (loc%2 == 0) {
   int loc_found = 0; int i;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 } else {
   int loc_found = 0; int i;
   for (i = loc; i >= 0; i--)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    loc_found = 1;
    break;
  }
   if (loc_found)
  continue;
   for (i = loc; i < 4096; i++)
  if (((void *)0) == buff[i]) {
    buff[i] = p;
    buff_cnt[i] = size;
    break;
  }
 }
  }
  for (j = 0; j < 4096; j++) {
 if (buff[j] != ((void *)0)) {
   my_free(buff[j]);
   buff[j] = ((void *)0);
 }
  }
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 228, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}


decompiled_code:
__int64 test_case_07()
{
__int64 v0; // rbx
__int64 v1; // rbp
__int64 v2; // r12

v0 = sim_heap_start;
heap_start = 0LL;
sim_heap_end = sim_heap_start;
heap_end = 0LL;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 142LL, "NULL != p1", "malloc-test.c", &unk_BB0, 0LL);
v2 = my_malloc(96LL);
CU_assertImplementation(v2 != 0, 145LL, "NULL != p2", "malloc-test.c", &unk_BB0, 0LL);
my_free(v2);
my_free(v1);
return CU_assertImplementation(
((v0 + 4095) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
153LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx
__int64 v1; // rbp
__int64 v2; // r12

v0 = sim_heap_start;
heap_start = 0LL;
sim_heap_end = sim_heap_start;
heap_end = 0LL;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 142LL, "NULL != p1", "malloc-test.c", &unk_BB0, 0LL);
v2 = my_malloc(96LL);
CU_assertImplementation(v2 != 0, 145LL, "NULL != p2", "malloc-test.c", &unk_BB0, 0LL);
my_free(v2);
my_free(v1);
return CU_assertImplementation(
((v0 + 4095) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
153LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

original_code:
static void test_case_07(void) {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p1 = ((void *)0), *p2 = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p1 = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p1), 142, "NULL != p1", "malloc-test.c", "", 0); };
  p2 = my_malloc(96);
  { CU_assertImplementation((((void *)0) != p2), 145, "NULL != p2", "malloc-test.c", "", 0); };
  my_free(p2);
  my_free(p1);
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 153, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

canonical_original_code:
static void test_case_07() {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p1 = ((void *)0); void *p2 = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p1 = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p1), 142, "NULL != p1", "malloc-test.c", "", 0); };
  p2 = my_malloc(96);
  { CU_assertImplementation((((void *)0) != p2), 145, "NULL != p2", "malloc-test.c", "", 0); };
  my_free(p2);
  my_free(p1);
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 153, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}


decompiled_code:
__int64 test_case_06()
{
__int64 v0; // rbx
__int64 v1; // r12
__int64 v2; // rbp

v0 = sim_heap_start;
heap_start = 0LL;
sim_heap_end = sim_heap_start;
heap_end = 0LL;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 120LL, "NULL != p1", "malloc-test.c", &unk_BB0, 0LL);
v2 = my_malloc(96LL);
CU_assertImplementation(v2 != 0, 123LL, "NULL != p2", "malloc-test.c", &unk_BB0, 0LL);
my_free(v1);
my_free(v2);
return CU_assertImplementation(
((v0 + 4095) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
132LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbx
__int64 v1; // r12
__int64 v2; // rbp

v0 = sim_heap_start;
heap_start = 0LL;
sim_heap_end = sim_heap_start;
heap_end = 0LL;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 120LL, "NULL != p1", "malloc-test.c", &unk_BB0, 0LL);
v2 = my_malloc(96LL);
CU_assertImplementation(v2 != 0, 123LL, "NULL != p2", "malloc-test.c", &unk_BB0, 0LL);
my_free(v1);
my_free(v2);
return CU_assertImplementation(
((v0 + 4095) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
132LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

original_code:
static void test_case_06(void) {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p1 = ((void *)0), *p2 = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p1 = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p1), 120, "NULL != p1", "malloc-test.c", "", 0); };
  p2 = my_malloc(96);
  { CU_assertImplementation((((void *)0) != p2), 123, "NULL != p2", "malloc-test.c", "", 0); };
  my_free(p1);
  my_free(p2);
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 132, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

canonical_original_code:
static void test_case_06() {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p1 = ((void *)0); void *p2 = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p1 = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p1), 120, "NULL != p1", "malloc-test.c", "", 0); };
  p2 = my_malloc(96);
  { CU_assertImplementation((((void *)0) != p2), 123, "NULL != p2", "malloc-test.c", "", 0); };
  my_free(p1);
  my_free(p2);
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 132, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}


decompiled_code:
__int64 test_case_05()
{
__int64 v0; // rbx
__int64 v1; // rbp
__int64 v2; // rbp

v0 = sim_heap_start;
heap_start = 0LL;
heap_end = 0LL;
sim_heap_end = sim_heap_start;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 98LL, "NULL != p1", "malloc-test.c", &unk_BB0, 0LL);
my_free(v1);
v2 = my_malloc(96LL);
CU_assertImplementation(v2 != 0, 103LL, "NULL != p2", "malloc-test.c", &unk_BB0, 0LL);
my_free(v2);
return CU_assertImplementation(
((v0 + 4095) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
110LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rbx
__int64 v1; // rbp
__int64 v2; // rbp

v0 = sim_heap_start;
heap_start = 0LL;
heap_end = 0LL;
sim_heap_end = sim_heap_start;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 98LL, "NULL != p1", "malloc-test.c", &unk_BB0, 0LL);
my_free(v1);
v2 = my_malloc(96LL);
CU_assertImplementation(v2 != 0, 103LL, "NULL != p2", "malloc-test.c", &unk_BB0, 0LL);
my_free(v2);
return CU_assertImplementation(
((v0 + 4095) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
110LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

original_code:
static void test_case_05(void) {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p1 = ((void *)0), *p2 = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p1 = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p1), 98, "NULL != p1", "malloc-test.c", "", 0); };
  my_free(p1);
  p2 = my_malloc(96);
  { CU_assertImplementation((((void *)0) != p2), 103, "NULL != p2", "malloc-test.c", "", 0); };
  my_free(p2);
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 110, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

canonical_original_code:
static void test_case_05() {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p1 = ((void *)0); void *p2 = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p1 = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p1), 98, "NULL != p1", "malloc-test.c", "", 0); };
  my_free(p1);
  p2 = my_malloc(96);
  { CU_assertImplementation((((void *)0) != p2), 103, "NULL != p2", "malloc-test.c", "", 0); };
  my_free(p2);
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 110, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}


decompiled_code:
__int64 test_case_04()
{
__int64 v0; // rbx
__int64 v1; // rbp

v0 = sim_heap_start;
heap_start = 0LL;
heap_end = 0LL;
sim_heap_end = sim_heap_start;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 82LL, "NULL != p", "malloc-test.c", &unk_BB0, 0LL);
my_free(v1);
return CU_assertImplementation(
((v0 + 4095) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
88LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // rbx
__int64 v1; // rbp

v0 = sim_heap_start;
heap_start = 0LL;
heap_end = 0LL;
sim_heap_end = sim_heap_start;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 82LL, "NULL != p", "malloc-test.c", &unk_BB0, 0LL);
my_free(v1);
return CU_assertImplementation(
((v0 + 4095) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
88LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

original_code:
static void test_case_04(void) {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p), 82, "NULL != p", "malloc-test.c", "", 0); };
  my_free(p);
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 88, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

canonical_original_code:
static void test_case_04() {
  unsigned long expected_heap_end = (((sim_heap_start) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p), 82, "NULL != p", "malloc-test.c", "", 0); };
  my_free(p);
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 88, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}


decompiled_code:
__int64 test_case_03()
{
__int64 v0; // rbx
__int64 v1; // rax

v0 = sim_heap_start;
heap_start = 0LL;
sim_heap_end = sim_heap_start;
heap_end = 0LL;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 69LL, "NULL != p", "malloc-test.c", &unk_BB0, 0LL);
return CU_assertImplementation(
((v0 + 4159) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
72LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rbx
__int64 v1; // rax

v0 = sim_heap_start;
heap_start = 0LL;
sim_heap_end = sim_heap_start;
heap_end = 0LL;
v1 = my_malloc(52LL);
CU_assertImplementation(v1 != 0, 69LL, "NULL != p", "malloc-test.c", &unk_BB0, 0LL);
return CU_assertImplementation(
((v0 + 4159) & 0xFFFFFFFFFFFFF000LL) == sim_heap_end,
72LL,
"sim_heap_end == expected_heap_end",
"malloc-test.c",
&unk_BB0,
0LL);
}

original_code:
static void test_case_03(void) {
  unsigned long expected_heap_end = (((sim_heap_start + ((52 + 3) & 0xfffffffc) + 8 + 4) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p), 69, "NULL != p", "malloc-test.c", "", 0); };
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 72, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}

canonical_original_code:
static void test_case_03() {
  unsigned long expected_heap_end = (((sim_heap_start + ((52 + 3) & 0xfffffffc) + 8 + 4) + (~(~((1UL<<12)-1)))) & (~((1UL<<12)-1)));
  void *p = ((void *)0);
  heap_end = heap_start = 0;
  sim_heap_end = sim_heap_start;
  p = my_malloc(52);
  { CU_assertImplementation((((void *)0) != p), 69, "NULL != p", "malloc-test.c", "", 0); };
  ("%s: expected_heap_end = 0x%x\n", __func__, (unsigned int)expected_heap_end);
  { CU_assertImplementation((sim_heap_end == expected_heap_end), 72, "sim_heap_end == expected_heap_end", "malloc-test.c", "", 0); };
}