radixSorting

original_code:
void radixSorting(unsigned *org, int length)
{
 int max = 0;
 int i,j, k = 0, bucket_size = 10,exp = 1;
 for(i = 0; i<length; i++)
  if(org[i] > max)
   max = org[i];
 if(max <= 0)
  return;
 list_t **buckets = (list_t **)malloc(bucket_size * sizeof(list_t *));
 memset(buckets, 0, bucket_size* sizeof(list_t*));
 list_t *temp, *temp2;
 while(max / exp != 0)
 {
  for(i = 0; i < length; i++)
  {
   k = (org[i] / exp) % bucket_size;
   temp = (list_t *)malloc(sizeof(list_t));
   temp->item = org[i];
   temp->next = buckets[k];
   buckets[k] = temp;
  }
  for(i=j=0; i<bucket_size; i++)
  {
   temp = buckets[i];
   while(temp != ((void *)0))
   {
    temp = temp->next;
    j++;
   }
   k = 0;
   temp = buckets[i];
   while(temp != ((void *)0))
   {
    org[j-k-1] = temp->item;
    temp2 = temp;
    temp = temp->next;
    free(temp2);
    k++;
   }
   buckets[i] = ((void *)0);
  }
  exp *= 10;
 }
 free(buckets);
}

canonical_original_code:
void radixSorting(unsigned int *org, int length)
{
 int max = 0;
 int i; int j; int k = 0; int bucket_size = 10; int exp = 1;
 for(i = 0; i<length; i++)
  if(org[i] > max)
   max = org[i];
 if(max <= 0)
  return;
 struct _list **buckets = (list_t **)malloc(bucket_size * sizeof(list_t *));
 memset(buckets, 0, bucket_size* sizeof(struct _list *));
 struct _list *temp; struct _list *temp2;
 while(max / exp != 0)
 {
  for(i = 0; i < length; i++)
  {
   k = (org[i] / exp) % bucket_size;
   temp = (struct _list *)malloc(sizeof(list_t));
   temp->item = org[i];
   temp->next = buckets[k];
   buckets[k] = temp;
  }
  for(i=j=0; i<bucket_size; i++)
  {
   temp = buckets[i];
   while(temp != ((void *)0))
   {
    temp = temp->next;
    j++;
   }
   k = 0;
   temp = buckets[i];
   while(temp != ((void *)0))
   {
    org[j-k-1] = temp->item;
    temp2 = temp;
    temp = temp->next;
    free(temp2);
    k++;
   }
   buckets[i] = ((void *)0);
  }
  exp *= 10;
 }
 free(buckets);
}

variable_types: exp int

variable_types: struct _list { int item; struct _list *next; } *


bitSorting

repo: norlanliu/data-structure

original_code:
void bitSorting(unsigned *org, int length)
{
 int i,j;
 for(i = 31; i >= 1; i--)
 {
  int preCB = org[0] >> i;
  int theS = 0;
  int theI = theS - 1;
  int theBase = 1 << (i-1);
  int theAxBit = 0;
  for(j = 0; j < length; j++)
  {
   int temPreCB = org[j]>>i;
   if(temPreCB != preCB)
   {
    theS = j;
    theI = theS - 1;
    theAxBit = 0;
    preCB = temPreCB;
    j--;
    continue;
   }
   int theAJ = (org[j] & theBase) > 0 ? 1:0;
   if(theI < theS)
   {
    if(theAJ == 0)
     continue;
    theI = j;
    continue;
   }
   if(theAJ <= theAxBit)
   {
    int temp = org[j];
    org[j] = org[theI];
    org[theI]=temp;
    theI++;
   }
  }
 }
}

canonical_original_code:
void bitSorting(unsigned int *org, int length)
{
 int i; int j;
 for(i = 31; i >= 1; i--)
 {
  int preCB = org[0] >> i;
  int theS = 0;
  int theI = theS - 1;
  int theBase = 1 << (i-1);
  int theAxBit = 0;
  for(j = 0; j < length; j++)
  {
   int temPreCB = org[j]>>i;
   if(temPreCB != preCB)
   {
    theS = j;
    theI = theS - 1;
    theAxBit = 0;
    preCB = temPreCB;
    j--;
    continue;
   }
   int theAJ = (org[j] & theBase) > 0 ? 1:0;
   if(theI < theS)
   {
    if(theAJ == 0)
     continue;
    theI = j;
    continue;
   }
   if(theAJ <= theAxBit)
   {
    int temp = org[j];
    org[j] = org[theI];
    org[theI]=temp;
    theI++;
   }
  }
 }
}

variable_types:
org
unsigned int *

variable_types: length int

variable_types: i int

variable_types: j int

variable_types: preCB int

variable_types: theS int

variable_types: theI int

variable_types: theBase int

variable_types: theAxBit int

variable_types: temPreCB int

variable_types: theAJ int

variable_types: temp int

return_type: void


HeapSorting

decompiled_code:
__int64 __fastcall HeapSorting(__int64 a1, int a2)
{
__int64 result; // rax
int v3; // ebx
__int64 v4; // rbp

result = BuildHeap(a1, a2);
v3 = a2 - 1;
if ( a2 - 1 > 0 )
{
v4 = a1 + 4LL * v3;
do
{
Swap(a1, v4);
result = PerDown(a1, v3, 0);
v4 -= 4LL;
--v3;
}
while ( v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, int a2)
{
__int64 result; // rax
int v3; // ebx
__int64 v4; // rbp

result = func1(a1, a2);
v3 = a2 - 1;
if ( a2 - 1 > 0 )
{
v4 = a1 + 4LL * v3;
do
{
Swap(a1, v4);
result = func0(a1, v3, 0);
v4 -= 4LL;
--v3;
}
while ( v3 );
}
return result;
}

original_code:
void HeapSorting(int *org, int length)
{
 BuildHeap(org, length);
 int i;
 for(i = length-1; i > 0; --i)
 {
  Swap(&org[0], &org[i]);
  PerDown(org, i, 0);
 }
}

variable_types:
org
int *


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

result = a1;
if ( a1 )
{
if ( *(_QWORD *)(a1 + 16) )
result = find_min();
}
return result;
}

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

result = a1;
if ( a1 )
{
if ( *(_QWORD *)(a1 + 16) )
result = func7();
}
return result;
}

original_code:
BStree *find_min(BStree *tree)
{
 if(tree == ((void *)0))
  return ((void *)0);
 if(tree->left != ((void *)0))
  return find_min(tree->left);
 return
  tree;
}

canonical_original_code:
struct bstree *find_min(struct bstree *tree)
{
 if(tree == ((void *)0))
  return ((void *)0);
 if(tree->left != ((void *)0))
  return find_min(tree->left);
 return
  tree;
}

variable_types:
tree
struct bstree *

return_type: struct bstree { int element; struct bstree *parent; struct bstree *left; struct bstree *right; } *


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

result = a1;
if ( a1 )
{
if ( *(_QWORD *)(a1 + 24) )
result = find_max();
}
return result;
}

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

result = a1;
if ( a1 )
{
if ( *(_QWORD *)(a1 + 24) )
result = func8();
}
return result;
}

original_code:
BStree *find_max(BStree *tree)
{
 if(tree == ((void *)0))
  return ((void *)0);
 if(tree->right != ((void *)0))
  return find_max(tree->right);
 else
  return tree;
}

canonical_original_code:
struct bstree *find_max(struct bstree *tree)
{
 if(tree == ((void *)0))
  return ((void *)0);
 if(tree->right != ((void *)0))
  return find_max(tree->right);
 else
  return tree;
}

user_defined_types: struct bstree { int element; struct bstree *parent; struct bstree *left; struct bstree *right; }


decompiled_code:
_BOOL8 __fastcall is_leaf(__int64 a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( !*(_QWORD *)(a1 + 16) )
result = *(_QWORD *)(a1 + 24) == 0LL;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(__int64 a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( !*(_QWORD *)(a1 + 16) )
result = *(_QWORD *)(a1 + 24) == 0LL;
return result;
}

original_code:
short is_leaf(BStree *tree)
{
 if(tree->left == ((void *)0) && tree->right == ((void *)0))
  return 1;
 return 0;
}

canonical_original_code:
short is_leaf(struct bstree *tree)
{
 if(tree->left == ((void *)0) && tree->right == ((void *)0))
  return 1;
 return 0;
}

variable_types: struct bstree { int element; struct bstree *parent; struct bstree *left; struct bstree *right; } *

return_type: short


decompiled_code:
__int64 __fastcall replace_with_max(__int64 a1)
{
__int16 v2; // dx
__int64 result; // rax
__int64 v4; // rdi
_DWORD *v5; // rax
_DWORD *v6; // rax

v2 = is_leaf(a1);
result = a1;
if ( !v2 )
{
v4 = *(_QWORD *)(a1 + 16);
if ( v4 )
{
v5 = (_DWORD *)find_max(v4);
*(_DWORD *)a1 = *v5;
result = replace_with_max(v5);
}
else
{
v6 = (_DWORD *)find_min(*(_QWORD *)(a1 + 24));
*(_DWORD *)a1 = *v6;
result = replace_with_max(v6);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int16 v2; // dx
__int64 result; // rax
__int64 v4; // rdi
_DWORD *v5; // rax
_DWORD *v6; // rax

v2 = func9(a1);
result = a1;
if ( !v2 )
{
v4 = *(_QWORD *)(a1 + 16);
if ( v4 )
{
v5 = (_DWORD *)func8(v4);
*(_DWORD *)a1 = *v5;
result = func10(v5);
}
else
{
v6 = (_DWORD *)func7(*(_QWORD *)(a1 + 24));
*(_DWORD *)a1 = *v6;
result = func10(v6);
}
}
return result;
}

original_code:
BStree *replace_with_max(BStree *tree)
{
 if(is_leaf(tree))
  return tree;
 else if(tree->left != ((void *)0))
 {
  BStree *tmp = find_max(tree->left);
  tree->element = tmp->element;
  return replace_with_max(tmp);
 }
 else
 {
  BStree *tmp = find_min(tree->right);
  tree->element = tmp->element;
  return replace_with_max(tmp);
 }
}

canonical_original_code:
struct bstree *replace_with_max(struct bstree *tree)
{
 if(is_leaf(tree))
  return tree;
 else if(tree->left != ((void *)0))
 {
  struct bstree *tmp = find_max(tree->left);
  tree->element = tmp->element;
  return replace_with_max(tmp);
 }
 else
 {
  struct bstree *tmp = find_min(tree->right);
  tree->element = tmp->element;
  return replace_with_max(tmp);
 }
}


original_code:
void delete_tree(BStree *tree, item_type element)
{
 if(tree == ((void *)0))
  return;
 else if(element == tree->element)
 {
  BStree *tmp = replace_with_max(tree);
  if(tmp != ((void *)0) && tmp->parent != ((void *)0))
  {
   if(tmp->parent->left == tmp)
    tmp->parent->left = ((void *)0);
   else
    tmp->parent->right = ((void *)0);
  }
  free(tmp);
  tmp = ((void *)0);
 }
 else if(element < tree->element)
  delete_tree(tree->left, element);
 else
  delete_tree(tree->right, element);
}

canonical_original_code:
void delete_tree(struct bstree *tree, int element)
{
 if(tree == ((void *)0))
  return;
 else if(element == tree->element)
 {
  struct bstree *tmp = replace_with_max(tree);
  if(tmp != ((void *)0) && tmp->parent != ((void *)0))
  {
   if(tmp->parent->left == tmp)
    tmp->parent->left = ((void *)0);
   else
    tmp->parent->right = ((void *)0);
  }
  free(tmp);
  tmp = ((void *)0);
 }
 else if(element < tree->element)
  delete_tree(tree->left, element);
 else
  delete_tree(tree->right, element);
}

variable_types: element int


decompiled_code:
__int64 __fastcall print_tree(unsigned int *a1)
{
__int64 result; // rax

if ( a1 )
{
printf("%d\n", *a1);
print_tree(*((_QWORD *)a1 + 2));
result = print_tree(*((_QWORD *)a1 + 3));
}
return result;
}

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

if ( a1 )
{
printf("%d\n", *a1);
func13(*((_QWORD *)a1 + 2));
result = func13(*((_QWORD *)a1 + 3));
}
return result;
}

original_code:
void print_tree(BStree *tree)
{
 if(tree == ((void *)0))
  return;
 else
  printf("%d\n", tree->element);
 print_tree(tree->left);
 print_tree(tree->right);
}

canonical_original_code:
void print_tree(struct bstree *tree)
{
 if(tree == ((void *)0))
  return;
 else
  printf("%d\n", tree->element);
 print_tree(tree->left);
 print_tree(tree->right);
}


clear

decompiled_code:
void __fastcall clear(void *ptr)
{
__int64 v1; // rax

if ( ptr )
{
if ( is_leaf((__int64)ptr) )
{
v1 = *((_QWORD *)ptr + 1);
if ( v1 )
{
if ( *(void **)(v1 + 16) == ptr )
*(_QWORD *)(v1 + 16) = 0LL;
else
*(_QWORD *)(v1 + 24) = 0LL;
}
free(ptr);
}
else
{
clear(*((void **)ptr + 2));
clear(*((void **)ptr + 3));
free(ptr);
}
}
}

original_code:
void clear(BStree *tree)
{
 if(tree == ((void *)0))
  return;
 else if(is_leaf(tree))
 {
  if(tree->parent == ((void *)0))
   ;
  else if(tree->parent->left == tree)
   tree->parent->left = ((void *)0);
  else
   tree->parent->right = ((void *)0);
  free(tree);
  tree = ((void *)0);
 }
 else
 {
  clear(tree->left);
  clear(tree->right);
  free(tree);
  tree = ((void *)0);
 }
}

canonical_original_code:
void clear(struct bstree *tree)
{
 if(tree == ((void *)0))
  return;
 else if(is_leaf(tree))
 {
  if(tree->parent == ((void *)0))
   ;
  else if(tree->parent->left == tree)
   tree->parent->left = ((void *)0);
  else
   tree->parent->right = ((void *)0);
  free(tree);
  tree = ((void *)0);
 }
 else
 {
  clear(tree->left);
  clear(tree->right);
  free(tree);
  tree = ((void *)0);
 }
}


hash

original_code:
static int hash(int hash_code, int hash_base)
{
 int answer = hash_base;
 answer ^= hash_code;
 answer ^= (answer >> 20) ^ (answer >> 12);
 answer ^= (answer >> 7) ^ (answer >> 4);
 return answer;
}

variable_types: answer int

return_type: int


indexForTable

decompiled_code:
__int64 __fastcall indexForTable(int a1, int a2)
{
return a1 & (unsigned int)(a2 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2)
{
return a1 & (unsigned int)(a2 - 1);
}

original_code:
static int indexForTable(int hash, int capability)
{
 return hash & (capability-1);
}

variable_types: hash int

variable_types: capability int


getHashBase

original_code:
static int getHashBase()
{
 int distance = sizeof(int)*8-15;
 int hash_base = 0;
 int data[2] = {time(((void *)0)), rand() >> 16};
 int i;
 for(i = 0; i < 2; i++)
 {
  data[i] *= 0xcc9e2d51;
  data[i] = (data[i]>>15) | (data[i]<<distance);
  data[i] *= 0x1b873593;
  hash_base ^= data[i];
  hash_base = (hash_base >> 15) | (hash_base << distance);
  hash_base = hash_base * 5 + 0xe6546b64;
 }
 hash_base ^= hash_base >> 16;
 hash_base *= 0x85ebca6b;
 hash_base ^= hash_base >> 13;
 hash_base *= 0xc2b2ae35;
 hash_base ^= hash_base >> 16;
 return hash_base;
}

variable_types: distance int

variable_types:
data
int [2]

variable_types: i int


resize

original_code:
static void resize(hashmap_t *map, int new_capability)
{
 if(map->table_capability >= MAX_CAPABILITY)
 {
  map->threshold = map->table_capability;
 }
 hashmap_list_t **new_table = (hashmap_list_t **)malloc(sizeof(hashmap_list_t *) * new_capability);
 memset(new_table, 0, sizeof(hashmap_list_t *)*new_capability);
 int i, index;
 hashmap_list_t *temp, *temp_while;
 for(i = 0; i < map->table_capability; i++)
 {
  temp = map->table[i];
  temp_while = map->table[i];
  while(temp_while != ((void *)0))
  {
   index = indexForTable(temp->hash, new_capability);
   temp_while = temp->next;
   temp->next = new_table[index];
   new_table[index] = temp;
   temp = temp_while;
  }
 }
 temp = temp_while = ((void *)0);
 free(map->table);
 map->table = new_table;
 map->table_capability = new_capability;
 map->threshold = new_capability * DEFAULT_LOAD_FACTOR;
}

canonical_original_code:
static void resize(struct _hashmap *map, int new_capability)
{
 if(map->table_capability >= MAX_CAPABILITY)
 {
  map->threshold = map->table_capability;
 }
 struct _linked_list **new_table = (hashmap_list_t **)malloc(sizeof(hashmap_list_t *) * new_capability);
 memset(new_table, 0, sizeof(struct _linked_list *)*new_capability);
 int i; int index;
 struct _linked_list *temp; struct _linked_list *temp_while;
 for(i = 0; i < map->table_capability; i++)
 {
  temp = map->table[i];
  temp_while = map->table[i];
  while(temp_while != ((void *)0))
  {
   index = indexForTable(temp->hash, new_capability);
   temp_while = temp->next;
   temp->next = new_table[index];
   new_table[index] = temp;
   temp = temp_while;
  }
 }
 temp = temp_while = ((void *)0);
 free(map->table);
 map->table = new_table;
 map->table_capability = new_capability;
 map->threshold = new_capability * DEFAULT_LOAD_FACTOR;
}

variable_types: struct _hashmap { int size; int threshold; int hash_base; int table_capability; int (*hash_code)(int); struct _linked_list { int hash; int key; int value; struct _linked_list *next; } **table; } *

variable_types: index int

user_defined_types: struct _hashmap { int size; int threshold; int hash_base; int table_capability; int (*hash_code)(int); struct _linked_list **table; }


original_code:
int hashmap_put(hashmap_t *map, int key, int value)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return -2;
 if(map->size >= (map->threshold-1))
  resize(map, 2*map->table_capability);
 int hash_num = hash((*(map->hash_code))(key), map->hash_base);
 int index = indexForTable(hash_num, map->table_capability);
 printf("key : %d, index : %d\n", key, index);
 if(map->table[index] != ((void *)0))
 {
  hashmap_list_t *temp;
  for(temp = map->table[index]; temp != ((void *)0); temp = temp->next)
  {
   if(temp->hash == hash_num && temp->key == key)
   {
    temp->value = value;
    return -1;
   }
  }
 }
 hashmap_list_t * newNode = (hashmap_list_t *)malloc(sizeof(hashmap_list_t));
 newNode->hash = hash_num;
 newNode->key = key;
 newNode->value = value;
 newNode->next = map->table[index];
 map->table[index] = newNode;
 map->size++;
 return index;
}

canonical_original_code:
int hashmap_put(struct _hashmap *map, int key, int value)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return -2;
 if(map->size >= (map->threshold-1))
  resize(map, 2*map->table_capability);
 int hash_num = hash((*(map->hash_code))(key), map->hash_base);
 int index = indexForTable(hash_num, map->table_capability);
 printf("key : %d, index : %d\n", key, index);
 if(map->table[index] != ((void *)0))
 {
  struct _linked_list *temp;
  for(temp = map->table[index]; temp != ((void *)0); temp = temp->next)
  {
   if(temp->hash == hash_num && temp->key == key)
   {
    temp->value = value;
    return -1;
   }
  }
 }
 struct _linked_list *newNode = (hashmap_list_t *)malloc(sizeof(hashmap_list_t));
 newNode->hash = hash_num;
 newNode->key = key;
 newNode->value = value;
 newNode->next = map->table[index];
 map->table[index] = newNode;
 map->size++;
 return index;
}

variable_types: key int

variable_types: value int

variable_types: struct _linked_list { int hash; int key; int value; struct _linked_list *next; } *


decompiled_code:
__int64 __fastcall hashmap_contains(__int64 a1, unsigned int a2, int a3)
{
int v4; // ebx
int v5; // eax
int v6; // ebx
__int64 v7; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !*(_QWORD *)(a1 + 24) )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 8);
v5 = (*(__int64 (__fastcall **)(_QWORD))(a1 + 16))(a2);
v6 = hash(v5, v4);
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * (int)indexForTable(v6, *(_DWORD *)(a1 + 12)));
if ( !v7 )
return 1LL;
do
{
if ( *(_DWORD *)v7 == v6 && *(_DWORD *)(v7 + 4) == a2 && *(_DWORD *)(v7 + 8) == a3 )
return 0LL;
v7 = *(_QWORD *)(v7 + 16);
}
while ( v7 );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, unsigned int a2, int a3)
{
int v4; // ebx
int v5; // eax
int v6; // ebx
__int64 v7; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !*(_QWORD *)(a1 + 24) )
return 0xFFFFFFFFLL;
v4 = *(_DWORD *)(a1 + 8);
v5 = (*(__int64 (__fastcall **)(_QWORD))(a1 + 16))(a2);
v6 = func6(v5, v4);
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * (int)func7(v6, *(_DWORD *)(a1 + 12)));
if ( !v7 )
return 1LL;
do
{
if ( *(_DWORD *)v7 == v6 && *(_DWORD *)(v7 + 4) == a2 && *(_DWORD *)(v7 + 8) == a3 )
return 0LL;
v7 = *(_QWORD *)(v7 + 16);
}
while ( v7 );
return 1LL;
}

original_code:
int hashmap_contains(hashmap_t *map, int key, int value)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return -1;
 int hash_num = hash((*(map->hash_code))(key), map->hash_base);
 int index = indexForTable(hash_num, map->table_capability);
 hashmap_list_t *temp;
 for(temp = map->table[index]; temp != ((void *)0); temp = temp->next)
  if(temp->hash == hash_num && temp->key == key && temp->value == value)
   return 0;
 return 1;
}

canonical_original_code:
int hashmap_contains(struct _hashmap *map, int key, int value)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return -1;
 int hash_num = hash((*(map->hash_code))(key), map->hash_base);
 int index = indexForTable(hash_num, map->table_capability);
 struct _linked_list *temp;
 for(temp = map->table[index]; temp != ((void *)0); temp = temp->next)
  if(temp->hash == hash_num && temp->key == key && temp->value == value)
   return 0;
 return 1;
}

user_defined_types: struct _linked_list { int hash; int key; int value; struct _linked_list *next; }


original_code:
void hashmap_remove(hashmap_t *map, int key)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return;
 int hash_num = hash((*(map->hash_code))(key), map->hash_base);
 int index = indexForTable(hash_num, map->table_capability);
 hashmap_list_t *temp = map->table[index], *prev = map->table[index];
 if(temp != ((void *)0) && temp->hash == hash_num && temp->key == key)
 {
  map->table[index] = temp->next;
  free(temp);
 }
 else
 {
  for(temp = map->table[index]->next; temp != ((void *)0); temp = temp->next)
  {
   if(temp->hash == hash_num && temp->key == key)
   {
    prev->next = temp->next;
    free(temp);
    break;
   }
   prev = prev->next;
  }
 }
}

canonical_original_code:
void hashmap_remove(struct _hashmap *map, int key)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return;
 int hash_num = hash((*(map->hash_code))(key), map->hash_base);
 int index = indexForTable(hash_num, map->table_capability);
 struct _linked_list *temp = map->table[index]; struct _linked_list *prev = map->table[index];
 if(temp != ((void *)0) && temp->hash == hash_num && temp->key == key)
 {
  map->table[index] = temp->next;
  free(temp);
 }
 else
 {
  for(temp = map->table[index]->next; temp != ((void *)0); temp = temp->next)
  {
   if(temp->hash == hash_num && temp->key == key)
   {
    prev->next = temp->next;
    free(temp);
    break;
   }
   prev = prev->next;
  }
 }
}


decompiled_code:
__int64 __fastcall hashmap_get(__int64 a1, unsigned int a2)
{
int v2; // ebx
int v3; // eax
int v4; // ebx
__int64 v5; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !*(_QWORD *)(a1 + 24) )
return 0xFFFFFFFFLL;
v2 = *(_DWORD *)(a1 + 8);
v3 = (*(__int64 (__fastcall **)(_QWORD))(a1 + 16))(a2);
v4 = hash(v3, v2);
v5 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * (int)indexForTable(v4, *(_DWORD *)(a1 + 12)));
if ( !v5 )
return 0xFFFFFFFFLL;
do
{
if ( *(_DWORD *)v5 == v4 && *(_DWORD *)(v5 + 4) == a2 )
return *(unsigned int *)(v5 + 8);
v5 = *(_QWORD *)(v5 + 16);
}
while ( v5 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, unsigned int a2)
{
int v2; // ebx
int v3; // eax
int v4; // ebx
__int64 v5; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !*(_QWORD *)(a1 + 24) )
return 0xFFFFFFFFLL;
v2 = *(_DWORD *)(a1 + 8);
v3 = (*(__int64 (__fastcall **)(_QWORD))(a1 + 16))(a2);
v4 = func6(v3, v2);
v5 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * (int)func7(v4, *(_DWORD *)(a1 + 12)));
if ( !v5 )
return 0xFFFFFFFFLL;
do
{
if ( *(_DWORD *)v5 == v4 && *(_DWORD *)(v5 + 4) == a2 )
return *(unsigned int *)(v5 + 8);
v5 = *(_QWORD *)(v5 + 16);
}
while ( v5 );
return 0xFFFFFFFFLL;
}

original_code:
int hashmap_get(hashmap_t *map, int key)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return -1;
 int hash_num = hash((*(map->hash_code))(key), map->hash_base);
 int index = indexForTable(hash_num, map->table_capability);
 if(map->table[index] != ((void *)0))
 {
  hashmap_list_t *temp;
  for(temp = map->table[index]; temp != ((void *)0); temp = temp->next)
   if(temp->hash == hash_num && temp->key == key)
    return temp->value;
 }
 return -1;
}

canonical_original_code:
int hashmap_get(struct _hashmap *map, int key)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return -1;
 int hash_num = hash((*(map->hash_code))(key), map->hash_base);
 int index = indexForTable(hash_num, map->table_capability);
 if(map->table[index] != ((void *)0))
 {
  struct _linked_list *temp;
  for(temp = map->table[index]; temp != ((void *)0); temp = temp->next)
   if(temp->hash == hash_num && temp->key == key)
    return temp->value;
 }
 return -1;
}


decompiled_code:
void __fastcall hashmap_free(void *ptr)
{
__int64 v2; // rbp
_QWORD *v3; // rbx
void *v4; // rdi

if ( ptr && *((_QWORD *)ptr + 3) )
{
if ( *((int *)ptr + 3) > 0 )
{
v2 = 0LL;
do
{
v3 = *(_QWORD **)(*((_QWORD *)ptr + 3) + 8 * v2);
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)v3[2];
free(v4);
}
*(_QWORD *)(*((_QWORD *)ptr + 3) + 8 * v2++) = 0LL;
}
while ( *((_DWORD *)ptr + 3) > (int)v2 );
}
free(ptr);
}
}

original_code:
void hashmap_free(hashmap_t *map)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return;
 int i;
 hashmap_list_t *temp1, *temp2;
 for(i = 0; i < map->table_capability; i++)
 {
  temp1 = map->table[i];
  temp2 = temp1;
  while(temp2 != ((void *)0))
  {
   temp2 = temp2->next;
   free(temp1);
   temp1 = temp2;
  }
  map->table[i] = ((void *)0);
 }
 free(map);
 map = ((void *)0);
}

canonical_original_code:
void hashmap_free(struct _hashmap *map)
{
 if(map == ((void *)0) || map->table == ((void *)0))
  return;
 int i;
 struct _linked_list *temp1; struct _linked_list *temp2;
 for(i = 0; i < map->table_capability; i++)
 {
  temp1 = map->table[i];
  temp2 = temp1;
  while(temp2 != ((void *)0))
  {
   temp2 = temp2->next;
   free(temp1);
   temp1 = temp2;
  }
  map->table[i] = ((void *)0);
 }
 free(map);
 map = ((void *)0);
}


hashCode

decompiled_code:
__int64 __fastcall hashCode(int a1)
{
return (unsigned int)(a1 + 31);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)(a1 + 31);
}

original_code:
static int hashCode(item_type item)
{
 return 31 + item;
}

canonical_original_code:
static int hashCode(int item)
{
 return 31 + item;
}

variable_types: item int


insert

decompiled_code:
void __fastcall insert(__int64 a1, int a2)
{
_QWORD *v2; // rax

if ( a1 )
{
v2 = malloc(0x10uLL);
*(_DWORD *)v2 = a2;
v2[1] = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 8) = v2;
}
}

original_code:
void insert(list *l, item_type item)
{
 if(l == ((void *)0))
  return;
 list * newItem = (list *)malloc(sizeof(list));
 newItem->item = item;
 newItem->next = l->next;
 l->next = newItem;
}

canonical_original_code:
void insert(struct _list *l, int item)
{
 if(l == ((void *)0))
  return;
 struct _list *newItem = (list *)malloc(sizeof(list));
 newItem->item = item;
 newItem->next = l->next;
 l->next = newItem;
}

variable_types: struct _list { int item; struct _list *next; } *


findItem

decompiled_code:
__int64 __fastcall findItem(__int64 a1, int a2)
{
if ( !a1 )
return 0LL;
while ( *(_DWORD *)a1 != a2 )
{
a1 = *(_QWORD *)(a1 + 8);
if ( !a1 )
return 0LL;
}
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
if ( !a1 )
return 0LL;
while ( *(_DWORD *)a1 != a2 )
{
a1 = *(_QWORD *)(a1 + 8);
if ( !a1 )
return 0LL;
}
return a1;
}

original_code:
list *findItem(list *l, item_type item)
{
 if(l == ((void *)0))
  return ((void *)0);
 list *p = l;
 while(p != ((void *)0))
 {
  if(p->item == item)
   return p;
  else
   p = p->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct _list *findItem(struct _list *l, int item)
{
 if(l == ((void *)0))
  return ((void *)0);
 struct _list *p = l;
 while(p != ((void *)0))
 {
  if(p->item == item)
   return p;
  else
   p = p->next;
 }
 return ((void *)0);
}

variable_types:
l
struct _list *

return_type: struct _list { int item; struct _list *next; } *


findPredecessor

decompiled_code:
__int64 __fastcall findPredecessor(__int64 a1, int a2)
{
__int64 result; // rax

if ( !a1 )
return 0LL;
while ( 1 )
{
result = a1;
a1 = *(_QWORD *)(a1 + 8);
if ( !a1 )
break;
if ( *(_DWORD *)a1 == a2 )
return result;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
__int64 result; // rax

if ( !a1 )
return 0LL;
while ( 1 )
{
result = a1;
a1 = *(_QWORD *)(a1 + 8);
if ( !a1 )
break;
if ( *(_DWORD *)a1 == a2 )
return result;
}
return 0LL;
}

original_code:
list *findPredecessor(list *l, item_type x)
{
 if(l == ((void *)0))
  return ((void *)0);
 list * p = l;
 while(p->next != ((void *)0))
 {
  if(p->next->item == x)
   return p;
  else
   p = p->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct _list *findPredecessor(struct _list *l, int x)
{
 if(l == ((void *)0))
  return ((void *)0);
 struct _list *p = l;
 while(p->next != ((void *)0))
 {
  if(p->next->item == x)
   return p;
  else
   p = p->next;
 }
 return ((void *)0);
}

variable_types: x int

user_defined_types: struct _list { int item; struct _list *next; }


deleteItem

decompiled_code:
void __fastcall deleteItem(__int64 a1, int a2)
{
__int64 v2; // rax
_QWORD *v3; // rdi

if ( a1 )
{
v2 = findPredecessor(a1, a2);
if ( v2 )
{
v3 = *(_QWORD **)(v2 + 8);
*(_QWORD *)(v2 + 8) = v3[1];
free(v3);
}
}
}

original_code:
void deleteItem(list *l, item_type x)
{
 if(l == ((void *)0))
  return;
 list *p = findPredecessor(l,x);
 if(p != ((void *)0))
 {
  list *old = p->next;
  p->next = old->next;
  free(old);
  old = ((void *)0);
 }
}

canonical_original_code:
void deleteItem(struct _list *l, int x)
{
 if(l == ((void *)0))
  return;
 struct _list *p = findPredecessor(l,x);
 if(p != ((void *)0))
 {
  struct _list *old = p->next;
  p->next = old->next;
  free(old);
  old = ((void *)0);
 }
}


freeList

original_code:
void freeList(list *l)
{
 if(l != ((void *)0))
 {
  list *temp = ((void *)0);
  while(l->next != ((void *)0))
  {
   temp = l->next;
   l->next = temp->next;
   free(temp);
   temp = ((void *)0);
  }
 }
}

canonical_original_code:
void freeList(struct _list *l)
{
 if(l != ((void *)0))
 {
  struct _list *temp = ((void *)0);
  while(l->next != ((void *)0))
  {
   temp = l->next;
   l->next = temp->next;
   free(temp);
   temp = ((void *)0);
  }
 }
}


printList

decompiled_code:
void __fastcall printList(__int64 a1)
{
unsigned int *v1; // rax

if ( a1 )
{
v1 = *(unsigned int **)(a1 + 8);
if ( v1 )
{
printf("%d\n", *v1);
printList(*(_QWORD *)(a1 + 8));
}
}
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
unsigned int *v1; // rax

if ( a1 )
{
v1 = *(unsigned int **)(a1 + 8);
if ( v1 )
{
printf("%d\n", *v1);
func6(*(_QWORD *)(a1 + 8));
}
}
}

original_code:
void printList(list *l)
{
 if(l == ((void *)0) || l->next == ((void *)0))
  return;
 printf("%d\n", l->next->item);
 printList(l->next);
}

canonical_original_code:
void printList(struct _list *l)
{
 if(l == ((void *)0) || l->next == ((void *)0))
  return;
 printf("%d\n", l->next->item);
 printList(l->next);
}


reverseList

original_code:
void reverseList(list *l)
{
 if(l == ((void *)0))
  return;
 list *p1 = l->next;
 list *p2 = p1->next;
 p1->next = ((void *)0);
 list *pTemp = p2;
 while(pTemp != ((void *)0))
 {
  pTemp = p2->next;
  p2->next = p1;
  p1 = p2;
  p2 = pTemp;
 }
 l->next = p1;
}

canonical_original_code:
void reverseList(struct _list *l)
{
 if(l == ((void *)0))
  return;
 struct _list *p1 = l->next;
 struct _list *p2 = p1->next;
 p1->next = ((void *)0);
 struct _list *pTemp = p2;
 while(pTemp != ((void *)0))
 {
  pTemp = p2->next;
  p2->next = p1;
  p1 = p2;
  p2 = pTemp;
 }
 l->next = p1;
}


decompiled_code:
int __fastcall remove_duplication(__int64 a1)
{
__int64 v1; // rbx
int v2; // er12
__int64 v3; // rbp
unsigned int *i; // rax
int v5; // eax

v1 = a1;
v2 = clock();
v3 = hashmap_initialize(13LL, hashCode);
for ( i = *(unsigned int **)(a1 + 8); i; i = *(unsigned int **)(v1 + 8) )
{
if ( (int)hashmap_put(v3, *i, 0LL) < 0 )
deleteItem(v1, **(_DWORD **)(v1 + 8));
else
v1 = *(_QWORD *)(v1 + 8);
}
v5 = clock();
return printf("Total time taken by CPU is %f\n", (double)(v5 - v2) / 1000000.0);
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
__int64 v1; // rbx
int v2; // er12
__int64 v3; // rbp
unsigned int *i; // rax
int v5; // eax

v1 = a1;
v2 = clock();
v3 = hashmap_initialize(13LL, hashCode);
for ( i = *(unsigned int **)(a1 + 8); i; i = *(unsigned int **)(v1 + 8) )
{
if ( (int)hashmap_put(v3, *i, 0LL) < 0 )
func4(v1, **(_DWORD **)(v1 + 8));
else
v1 = *(_QWORD *)(v1 + 8);
}
v5 = clock();
return printf("Total time taken by CPU is %f\n", (double)(v5 - v2) / 1000000.0);
}

original_code:
void remove_duplication(list *l)
{
 clock_t start = clock();
 hashmap_t *map = hashmap_initialize(13, &hashCode);
 while(l->next != ((void *)0))
 {
  if(hashmap_put(map, l->next->item, 0) < 0 )
   deleteItem(l, l->next->item);
  else
   l = l->next;
 }
 clock_t end = clock();
 printf("Total time taken by CPU is %f\n", (double)(end-start)/((__clock_t) 1000000));
}

canonical_original_code:
void remove_duplication(struct _list *l)
{
 long start = clock();
 struct _hashmap *map = hashmap_initialize(13, &hashCode);
 while(l->next != ((void *)0))
 {
  if(hashmap_put(map, l->next->item, 0) < 0 )
   deleteItem(l, l->next->item);
  else
   l = l->next;
 }
 long end = clock();
 printf("Total time taken by CPU is %f\n", (double)(end-start)/((long) 1000000));
}

variable_types: start long

variable_types: end long


decompiled_code:
void __fastcall free_queue(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

original_code:
void free_queue(priority_queue *queue)
{
 free(queue->item);
 free(queue);
 queue = ((void *)0);
}

canonical_original_code:
void free_queue(struct priority_queue *queue)
{
 free(queue->item);
 free(queue);
 queue = ((void *)0);
}

variable_types: struct priority_queue { int *item; int length; int capability; } *


dequeue

decompiled_code:
__int64 __fastcall dequeue(__int64 *a1)
{
int v1; // eax
__int64 v2; // rdx
unsigned int v3; // ebx

v1 = *((_DWORD *)a1 + 2);
if ( !v1 )
return (unsigned int)-1;
v2 = *a1;
v3 = *(_DWORD *)(*a1 + 4);
*((_DWORD *)a1 + 2) = v1 - 1;
*(_DWORD *)(v2 + 4) = *(_DWORD *)(v2 + 4LL * v1);
percolate_down(a1, 1);
return v3;
}

original_code:
item_type dequeue(priority_queue *queue)
{
 if(queue->length == 0)
  return -1;
 int answer = queue->item[1];
 queue->item[1] = queue->item[queue->length--];
 percolate_down(queue, 1);
 return answer;
}

canonical_original_code:
int dequeue(struct priority_queue *queue)
{
 if(queue->length == 0)
  return -1;
 int answer = queue->item[1];
 queue->item[1] = queue->item[queue->length--];
 percolate_down(queue, 1);
 return answer;
}

variable_types: answer int

user_defined_types: struct priority_queue { int *item; int length; int capability; }


subFindByName

repo: norly/centaur

decompiled_code:
__int64 __fastcall subFindByName(__int64 a1, __int64 a2, const char *a3)
{
__int64 result; // rax
const char *v5; // rax
bool v6; // zf

result = ((__int64 (*)(void))elfu_mScnName)();
if ( result )
{
v5 = (const char *)elfu_mScnName(a1, a2);
v6 = strcmp(v5, a3) == 0;
result = 0LL;
if ( v6 )
result = a2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, const char *a3)
{
__int64 result; // rax
const char *v5; // rax
bool v6; // zf

result = ((__int64 (*)(void))elfu_mScnName)();
if ( result )
{
v5 = (const char *)elfu_mScnName(a1, a2);
v6 = strcmp(v5, a3) == 0;
result = 0LL;
if ( v6 )
result = a2;
}
return result;
}

original_code:
static void* subFindByName(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
  char *name = (char*)aux1;
  (void)aux2;
  if (elfu_mScnName(me, ms)) {
    if (!strcmp(elfu_mScnName(me, ms), name)) {
      return ms;
    }
  }
  return ((void *)0);
}

canonical_original_code:
static void *subFindByName(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)
{
  char *name = (char*)aux1;
  (void)aux2;
  if (elfu_mScnName(me, ms)) {
    if (!strcmp(elfu_mScnName(me, ms), name)) {
      return ms;
    }
  }
  return ((void *)0);
}

variable_types: struct ElfuElf { int elfclass; struct Elf64_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } ehdr; struct PhdrList { struct ElfuPhdr { struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; } phdr; struct ChildScnList { struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *cqh_first; struct ElfuScn *cqh_last; } childScnList; struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; } childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; } *cqh_first; struct ElfuPhdr *cqh_last; } phdrList; struct OrphanScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; } orphanScnList; struct ElfuScn *shstrtab; struct ElfuScn *symtab; } *

variable_types:
ms
struct ElfuScn *

variable_types:
name
char *

return_type: void *

user_defined_types: struct ElfuElf { int elfclass; struct Elf64_Ehdr ehdr; struct PhdrList phdrList; struct OrphanScnList orphanScnList; struct ElfuScn *shstrtab; struct ElfuScn *symtab; }

user_defined_types: struct PhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; }

user_defined_types: struct ElfuPhdr { struct Elf64_Phdr phdr; struct ChildScnList childScnList; struct ChildPhdrList childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; }

user_defined_types: struct ChildScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; }

user_defined_types: struct ElfuScn { struct Elf64_Shdr shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab symtab; struct ElfuReltab reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; }

user_defined_types: struct Syms { struct ElfuSym *cqh_first; struct ElfuSym *cqh_last; }

user_defined_types: struct Rels { struct ElfuRel *cqh_first; struct ElfuRel *cqh_last; }


decompiled_code:
__int64 __fastcall elfu_mDynLookupPltAddrByName(_DWORD *a1, const char *a2, _QWORD *a3)
{
__int64 v3; // r13
__int64 v4; // r15
__int64 v5; // rbx
__int64 v6; // r13
unsigned int v7; // er14
unsigned int v8; // er12
unsigned int v9; // ebp
unsigned int *v10; // rdx
unsigned int v11; // ecx
int i; // eax
__int64 v13; // rbx
__int64 v15; // [rsp+10h] [rbp-48h]

v3 = elfu_mScnForall(a1, subFindByName, ".rel.plt", 0LL);
if ( v3 || (v3 = elfu_mScnForall(a1, subFindByName, ".rela.plt", 0LL)) != 0 )
{
v15 = elfu_mScnForall(a1, subFindByName, ".plt", 0LL);
if ( v15 )
{
v4 = *(_QWORD *)(v3 + 72);
if ( !v4 )
_assert_fail("relplt->linkptr", "src/libelfu/modelops/dynlookup.c", 0x43u, "elfu_mDynLookupPltAddrByName");
v5 = *(_QWORD *)(v3 + 112);
v6 = v3 + 112;
if ( v5 == v6 )
{
LABEL_19:
fprintf(stderr, "elfu_mDynLookupPltAddr: Could not find symbol '%s' in destination ELF.\n", a2);
v9 = -1;
}
else
{
v7 = *a1 - 1;
v8 = 0;
while ( 1 )
{
++v8;
if ( v7 > 1 || *(_BYTE *)(v5 + 12) == 7 )
{
v10 = *(unsigned int **)(v4 + 96);
v11 = *(_DWORD *)(v5 + 8);
if ( v11 > 1 )
{
for ( i = 1; i != v11; ++i )
v10 = (unsigned int *)*((_QWORD *)v10 + 5);
}
v9 = strcmp((const char *)(*(_QWORD *)(*(_QWORD *)(v4 + 72) + 64LL) + *v10), a2);
if ( !v9 )
break;
}
v5 = *(_QWORD *)(v5 + 24);
if ( v5 == v6 )
goto LABEL_19;
}
v13 = *(_QWORD *)(v15 + 16) + 16 * v8;
fprintf(
stdout,
"elfu_mDynLookupPltAddr: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n",
a2,
(unsigned int)v13,
v8);
*a3 = v13;
}
}
else
{
fwrite("elfu_mDynLookupPltAddr: Could not find .plt section in destination ELF.\n", 1uLL, 0x48uLL, stderr);
v9 = -1;
}
}
else
{
fwrite("elfu_mDynLookupPltAddr: Could not find .rel.plt section in destination ELF.\n", 1uLL, 0x4CuLL, stderr);
v9 = -1;
}
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, const char *a2, _QWORD *a3)
{
__int64 v3; // r13
__int64 v4; // r15
__int64 v5; // rbx
__int64 v6; // r13
unsigned int v7; // er14
unsigned int v8; // er12
unsigned int v9; // ebp
unsigned int *v10; // rdx
unsigned int v11; // ecx
int i; // eax
__int64 v13; // rbx
__int64 v15; // [rsp+10h] [rbp-48h]

v3 = elfu_mScnForall(a1, subFindByName, ".rel.plt", 0LL);
if ( v3 || (v3 = elfu_mScnForall(a1, subFindByName, ".rela.plt", 0LL)) != 0 )
{
v15 = elfu_mScnForall(a1, subFindByName, ".plt", 0LL);
if ( v15 )
{
v4 = *(_QWORD *)(v3 + 72);
if ( !v4 )
_assert_fail("relplt->linkptr", "src/libelfu/modelops/dynlookup.c", 0x43u, "elfu_mDynLookupPltAddrByName");
v5 = *(_QWORD *)(v3 + 112);
v6 = v3 + 112;
if ( v5 == v6 )
{
LABEL_19:
fprintf(stderr, "elfu_mDynLookupPltAddr: Could not find symbol '%s' in destination ELF.\n", a2);
v9 = -1;
}
else
{
v7 = *a1 - 1;
v8 = 0;
while ( 1 )
{
++v8;
if ( v7 > 1 || *(_BYTE *)(v5 + 12) == 7 )
{
v10 = *(unsigned int **)(v4 + 96);
v11 = *(_DWORD *)(v5 + 8);
if ( v11 > 1 )
{
for ( i = 1; i != v11; ++i )
v10 = (unsigned int *)*((_QWORD *)v10 + 5);
}
v9 = strcmp((const char *)(*(_QWORD *)(*(_QWORD *)(v4 + 72) + 64LL) + *v10), a2);
if ( !v9 )
break;
}
v5 = *(_QWORD *)(v5 + 24);
if ( v5 == v6 )
goto LABEL_19;
}
v13 = *(_QWORD *)(v15 + 16) + 16 * v8;
fprintf(
stdout,
"elfu_mDynLookupPltAddr: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n",
a2,
(unsigned int)v13,
v8);
*a3 = v13;
}
}
else
{
fwrite("elfu_mDynLookupPltAddr: Could not find .plt section in destination ELF.\n", 1uLL, 0x48uLL, stderr);
v9 = -1;
}
}
else
{
fwrite("elfu_mDynLookupPltAddr: Could not find .rel.plt section in destination ELF.\n", 1uLL, 0x4CuLL, stderr);
v9 = -1;
}
return v9;
}

original_code:
int elfu_mDynLookupPltAddrByName(ElfuElf *me, char *name, GElf_Addr *result)
{
  ElfuScn *relplt;
  ElfuScn *plt;
  ElfuRel *rel;
  GElf_Word j;
  relplt = elfu_mScnForall(me, subFindByName, ".rel.plt", ((void *)0));
  if (!relplt) {
    relplt = elfu_mScnForall(me, subFindByName, ".rela.plt", ((void *)0));
  }
  if (!relplt) {
    do { fprintf(stderr, "elfu_mDynLookupPltAddr: Could not find .rel.plt section in destination ELF.\n"); } while(0);
    return -1;
  }
  plt = elfu_mScnForall(me, subFindByName, ".plt", ((void *)0));
  if (!plt) {
    do { fprintf(stderr, "elfu_mDynLookupPltAddr: Could not find .plt section in destination ELF.\n"); } while(0);
    return -1;
  }
  ((void) sizeof ((relplt->linkptr) ? 1 : 0), __extension__ ({ if (relplt->linkptr) ; else __assert_fail ("relplt->linkptr", "src/libelfu/modelops/dynlookup.c", 67, __extension__ __PRETTY_FUNCTION__); }));
  j = 0;
  for ((rel) = ((&relplt->reltab.rels)->cqh_first); (rel) != (const void *)(&relplt->reltab.rels); (rel) = ((rel)->elem.cqe_next)) {
    GElf_Word i;
    ElfuSym *sym;
    char *symname;
    j++;
    if ((me->elfclass == 1 && rel->type != 7)
        || (me->elfclass == 2 && rel->type != 7)) {
      continue;
    }
    sym = ((&relplt->linkptr->symtab.syms)->cqh_first);
    for (i = 1; i < rel->sym; i++) {
      sym = ((sym)->elem.cqe_next);
    }
    symname = ((relplt->linkptr)->linkptr->databuf + (sym->name));
    if (!strcmp(symname, name)) {
      GElf_Addr addr = plt->shdr.sh_addr + (16 * j);
      do { fprintf(stdout, "elfu_mDynLookupPltAddr: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n", name, (unsigned)addr, j); } while(0);
      *result = addr;
      return 0;
    }
  }
  do { fprintf(stderr, "elfu_mDynLookupPltAddr: Could not find symbol '%s' in destination ELF.\n", name); } while(0);
  return -1;
}

canonical_original_code:
int elfu_mDynLookupPltAddrByName(struct ElfuElf *me, char *name, unsigned long *result)
{
  struct ElfuScn *relplt;
  struct ElfuScn *plt;
  struct ElfuRel *rel;
  unsigned int j;
  relplt = elfu_mScnForall(me, subFindByName, ".rel.plt", ((void *)0));
  if (!relplt) {
    relplt = elfu_mScnForall(me, subFindByName, ".rela.plt", ((void *)0));
  }
  if (!relplt) {
    do { fprintf(stderr, "elfu_mDynLookupPltAddr: Could not find .rel.plt section in destination ELF.\n"); } while(0);
    return -1;
  }
  plt = elfu_mScnForall(me, subFindByName, ".plt", ((void *)0));
  if (!plt) {
    do { fprintf(stderr, "elfu_mDynLookupPltAddr: Could not find .plt section in destination ELF.\n"); } while(0);
    return -1;
  }
  ((void) sizeof ((relplt->linkptr) ? 1 : 0), __extension__ ({ if (relplt->linkptr) ; else __assert_fail ("relplt->linkptr", "src/libelfu/modelops/dynlookup.c", 67, __extension__ __PRETTY_FUNCTION__); }));
  j = 0;
  for ((rel) = ((&relplt->reltab.rels)->cqh_first); (rel) != (void *)(&relplt->reltab.rels); (rel) = ((rel)->elem.cqe_next)) {
    unsigned int i;
    struct ElfuSym *sym;
    char *symname;
    j++;
    if ((me->elfclass == 1 && rel->type != 7)
        || (me->elfclass == 2 && rel->type != 7)) {
      continue;
    }
    sym = ((&relplt->linkptr->symtab.syms)->cqh_first);
    for (i = 1; i < rel->sym; i++) {
      sym = ((sym)->elem.cqe_next);
    }
    symname = ((relplt->linkptr)->linkptr->databuf + (sym->name));
    if (!strcmp(symname, name)) {
      unsigned long addr = plt->shdr.sh_addr + (16 * j);
      do { fprintf(stdout, "elfu_mDynLookupPltAddr: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n", name, (unsigned int)addr, j); } while(0);
      *result = addr;
      return 0;
    }
  }
  do { fprintf(stderr, "elfu_mDynLookupPltAddr: Could not find symbol '%s' in destination ELF.\n", name); } while(0);
  return -1;
}

variable_types:
result
unsigned long *

variable_types: struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *

variable_types:
j
unsigned int

variable_types:
i
unsigned int

variable_types: struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *

variable_types:
symname
char *

variable_types:
addr
unsigned long

user_defined_types: struct Elf64_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; }

user_defined_types: struct OrphanScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; }

user_defined_types: struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; }

user_defined_types: struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; }


decompiled_code:
__int64 __fastcall elfu_mDynLookupReldynAddrByName(_DWORD *a1, const char *a2, _QWORD *a3)
{
__int64 v3; // r13
__int64 *v4; // rbx
unsigned int v5; // er12
unsigned int v6; // ebp
__int64 v7; // rsi
const char *v8; // rax
__int64 v9; // rbx

v3 = elfu_mScnForall(a1, subFindByName, ".rel.dyn", 0LL);
if ( v3 || (v3 = elfu_mScnForall(a1, subFindByName, ".rela.dyn", 0LL)) != 0 )
{
if ( !*(_QWORD *)(v3 + 72) )
_assert_fail("reldyn->linkptr", "src/libelfu/modelops/dynlookup.c", 0x83u, "elfu_mDynLookupReldynAddrByName");
v4 = *(__int64 **)(v3 + 112);
if ( v4 == (__int64 *)(v3 + 112) )
{
LABEL_16:
fprintf(stderr, "elfu_mDynLookupReldynAddrByName: Could not find or use symbol '%s' in destination ELF.\n", a2);
fwrite(" NOTE: Only R_*_COPY relocations are resolved to global variables.\n", 1uLL, 0x48uLL, stderr);
v6 = -1;
}
else
{
v5 = 0;
while ( 1 )
{
++v5;
if ( (unsigned int)(*a1 - 1) > 1 || *((_BYTE *)v4 + 12) == 5 )
{
v7 = elfu_mSymtabIndexToSym(*(_QWORD *)(v3 + 72), *((unsigned int *)v4 + 2));
if ( !v7 )
_assert_fail("sym", "src/libelfu/modelops/dynlookup.c", 0x96u, "elfu_mDynLookupReldynAddrByName");
v8 = (const char *)elfu_mSymtabSymToName(*(_QWORD *)(v3 + 72), v7);
v6 = strcmp(v8, a2);
if ( !v6 )
break;
}
v4 = (__int64 *)v4[3];
if ( v4 == (__int64 *)(v3 + 112) )
goto LABEL_16;
}
v9 = *v4;
fprintf(
stdout,
"elfu_mDynLookupReldynAddrByName: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n",
a2,
(unsigned int)v9,
v5);
*a3 = v9;
}
}
else
{
fwrite(
"elfu_mDynLookupReldynAddrByName: Could not find .rel.dyn section in destination ELF.\n",
1uLL,
0x55uLL,
stderr);
v6 = -1;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1, const char *a2, _QWORD *a3)
{
__int64 v3; // r13
__int64 *v4; // rbx
unsigned int v5; // er12
unsigned int v6; // ebp
__int64 v7; // rsi
const char *v8; // rax
__int64 v9; // rbx

v3 = elfu_mScnForall(a1, subFindByName, ".rel.dyn", 0LL);
if ( v3 || (v3 = elfu_mScnForall(a1, subFindByName, ".rela.dyn", 0LL)) != 0 )
{
if ( !*(_QWORD *)(v3 + 72) )
_assert_fail("reldyn->linkptr", "src/libelfu/modelops/dynlookup.c", 0x83u, "elfu_mDynLookupReldynAddrByName");
v4 = *(__int64 **)(v3 + 112);
if ( v4 == (__int64 *)(v3 + 112) )
{
LABEL_16:
fprintf(stderr, "elfu_mDynLookupReldynAddrByName: Could not find or use symbol '%s' in destination ELF.\n", a2);
fwrite(" NOTE: Only R_*_COPY relocations are resolved to global variables.\n", 1uLL, 0x48uLL, stderr);
v6 = -1;
}
else
{
v5 = 0;
while ( 1 )
{
++v5;
if ( (unsigned int)(*a1 - 1) > 1 || *((_BYTE *)v4 + 12) == 5 )
{
v7 = elfu_mSymtabIndexToSym(*(_QWORD *)(v3 + 72), *((unsigned int *)v4 + 2));
if ( !v7 )
_assert_fail("sym", "src/libelfu/modelops/dynlookup.c", 0x96u, "elfu_mDynLookupReldynAddrByName");
v8 = (const char *)elfu_mSymtabSymToName(*(_QWORD *)(v3 + 72), v7);
v6 = strcmp(v8, a2);
if ( !v6 )
break;
}
v4 = (__int64 *)v4[3];
if ( v4 == (__int64 *)(v3 + 112) )
goto LABEL_16;
}
v9 = *v4;
fprintf(
stdout,
"elfu_mDynLookupReldynAddrByName: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n",
a2,
(unsigned int)v9,
v5);
*a3 = v9;
}
}
else
{
fwrite(
"elfu_mDynLookupReldynAddrByName: Could not find .rel.dyn section in destination ELF.\n",
1uLL,
0x55uLL,
stderr);
v6 = -1;
}
return v6;
}

original_code:
int elfu_mDynLookupReldynAddrByName(ElfuElf *me, char *name, GElf_Addr *result)
{
  ElfuScn *reldyn;
  ElfuRel *rel;
  GElf_Word j;
  reldyn = elfu_mScnForall(me, subFindByName, ".rel.dyn", ((void *)0));
  if (!reldyn) {
    reldyn = elfu_mScnForall(me, subFindByName, ".rela.dyn", ((void *)0));
  }
  if (!reldyn) {
    do { fprintf(stderr, "elfu_mDynLookupReldynAddrByName: Could not find .rel.dyn section in destination ELF.\n"); } while(0);
    return -1;
  }
  ((void) sizeof ((reldyn->linkptr) ? 1 : 0), __extension__ ({ if (reldyn->linkptr) ; else __assert_fail ("reldyn->linkptr", "src/libelfu/modelops/dynlookup.c", 131, __extension__ __PRETTY_FUNCTION__); }));
  j = 0;
  for ((rel) = ((&reldyn->reltab.rels)->cqh_first); (rel) != (const void *)(&reldyn->reltab.rels); (rel) = ((rel)->elem.cqe_next)) {
    ElfuSym *sym;
    char *symname;
    j++;
    if ((me->elfclass == 1 && rel->type != 5)
        || (me->elfclass == 2 && rel->type != 5)) {
      continue;
    }
    sym = elfu_mSymtabIndexToSym(reldyn->linkptr, rel->sym);
    ((void) sizeof ((sym) ? 1 : 0), __extension__ ({ if (sym) ; else __assert_fail ("sym", "src/libelfu/modelops/dynlookup.c", 150, __extension__ __PRETTY_FUNCTION__); }));
    symname = elfu_mSymtabSymToName(reldyn->linkptr, sym);
    if (!strcmp(symname, name)) {
      GElf_Addr addr = rel->offset;
      do { fprintf(stdout, "elfu_mDynLookupReldynAddrByName: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n", name, (unsigned)addr, j); } while(0);
      *result = addr;
      return 0;
    }
  }
  do { fprintf(stderr, "elfu_mDynLookupReldynAddrByName: Could not find or use symbol '%s' in destination ELF.\n", name); } while(0);
  do { fprintf(stderr, "      NOTE: Only R_*_COPY relocations are resolved to global variables.\n"); } while(0);
  return -1;
}

canonical_original_code:
int elfu_mDynLookupReldynAddrByName(struct ElfuElf *me, char *name, unsigned long *result)
{
  struct ElfuScn *reldyn;
  struct ElfuRel *rel;
  unsigned int j;
  reldyn = elfu_mScnForall(me, subFindByName, ".rel.dyn", ((void *)0));
  if (!reldyn) {
    reldyn = elfu_mScnForall(me, subFindByName, ".rela.dyn", ((void *)0));
  }
  if (!reldyn) {
    do { fprintf(stderr, "elfu_mDynLookupReldynAddrByName: Could not find .rel.dyn section in destination ELF.\n"); } while(0);
    return -1;
  }
  ((void) sizeof ((reldyn->linkptr) ? 1 : 0), __extension__ ({ if (reldyn->linkptr) ; else __assert_fail ("reldyn->linkptr", "src/libelfu/modelops/dynlookup.c", 131, __extension__ __PRETTY_FUNCTION__); }));
  j = 0;
  for ((rel) = ((&reldyn->reltab.rels)->cqh_first); (rel) != (void *)(&reldyn->reltab.rels); (rel) = ((rel)->elem.cqe_next)) {
    struct ElfuSym *sym;
    char *symname;
    j++;
    if ((me->elfclass == 1 && rel->type != 5)
        || (me->elfclass == 2 && rel->type != 5)) {
      continue;
    }
    sym = elfu_mSymtabIndexToSym(reldyn->linkptr, rel->sym);
    ((void) sizeof ((sym) ? 1 : 0), __extension__ ({ if (sym) ; else __assert_fail ("sym", "src/libelfu/modelops/dynlookup.c", 150, __extension__ __PRETTY_FUNCTION__); }));
    symname = elfu_mSymtabSymToName(reldyn->linkptr, sym);
    if (!strcmp(symname, name)) {
      unsigned long addr = rel->offset;
      do { fprintf(stdout, "elfu_mDynLookupReldynAddrByName: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n", name, (unsigned int)addr, j); } while(0);
      *result = addr;
      return 0;
    }
  }
  do { fprintf(stderr, "elfu_mDynLookupReldynAddrByName: Could not find or use symbol '%s' in destination ELF.\n", name); } while(0);
  do { fprintf(stderr, "      NOTE: Only R_*_COPY relocations are resolved to global variables.\n"); } while(0);
  return -1;
}

variable_types: struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *

user_defined_types: struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; }

user_defined_types: struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; }


decompiled_code:
__int64 __fastcall elfu_mSymtabLookupSymToAddr(__int64 a1, __int64 a2, unsigned int *a3, _QWORD *a4)
{
unsigned __int8 v6; // dl
__int64 result; // rax
unsigned int v8; // eax
__int64 v9; // rsi
__int64 v10; // rax

v6 = *((_BYTE *)a3 + 21);
if ( v6 == 3 )
{
if ( !*((_QWORD *)a3 + 3) )
_assert_fail("sym->scnptr", "src/libelfu/model/symtab.c", 0x30u, "elfu_mSymtabLookupSymToAddr");
if ( !((__int64 (*)(void))elfu_mScnByOldscn)() )
_assert_fail(
"elfu_mScnByOldscn(me, sym->scnptr)",
"src/libelfu/model/symtab.c",
0x31u,
"elfu_mSymtabLookupSymToAddr");
*a4 = *(_QWORD *)(elfu_mScnByOldscn(a1, *((_QWORD *)a3 + 3)) + 16);
result = 0LL;
}
else if ( v6 <= 3u )
{
v8 = a3[8];
if ( v8 )
{
if ( v8 == 65521 )
{
*a4 = *((_QWORD *)a3 + 1);
result = 0LL;
}
else if ( v8 == 65522 )
{
result = 0xFFFFFFFFLL;
}
else
{
v9 = *((_QWORD *)a3 + 3);
if ( !v9 )
_assert_fail("sym->scnptr", "src/libelfu/model/symtab.c", 0x28u, "elfu_mSymtabLookupSymToAddr");
v10 = elfu_mScnByOldscn(a1, v9);
if ( !v10 )
_assert_fail("newscn", "src/libelfu/model/symtab.c", 0x2Au, "elfu_mSymtabLookupSymToAddr");
*a4 = *(_QWORD *)(v10 + 16) + *((_QWORD *)a3 + 1);
result = 0LL;
}
}
else
{
result = 0xFFFFFFFFLL;
}
}
else
{
if ( v6 == 4 )
fwrite("elfu_mSymtabLookupSymToAddr: Symbol type FILE is not supported.\n", 1uLL, 0x40uLL, stderr);
else
fprintf(
stderr,
"elfu_mSymtabLookupSymToAddr: Unknown symbol type %d for %s.\n",
v6,
(const char *)(*(_QWORD *)(*(_QWORD *)(a2 + 72) + 64LL) + *a3));
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, unsigned int *a3, _QWORD *a4)
{
unsigned __int8 v6; // dl
__int64 result; // rax
unsigned int v8; // eax
__int64 v9; // rsi
__int64 v10; // rax

v6 = *((_BYTE *)a3 + 21);
if ( v6 == 3 )
{
if ( !*((_QWORD *)a3 + 3) )
_assert_fail("sym->scnptr", "src/libelfu/model/symtab.c", 0x30u, "elfu_mSymtabLookupSymToAddr");
if ( !((__int64 (*)(void))elfu_mScnByOldscn)() )
_assert_fail(
"elfu_mScnByOldscn(me, sym->scnptr)",
"src/libelfu/model/symtab.c",
0x31u,
"elfu_mSymtabLookupSymToAddr");
*a4 = *(_QWORD *)(elfu_mScnByOldscn(a1, *((_QWORD *)a3 + 3)) + 16);
result = 0LL;
}
else if ( v6 <= 3u )
{
v8 = a3[8];
if ( v8 )
{
if ( v8 == 65521 )
{
*a4 = *((_QWORD *)a3 + 1);
result = 0LL;
}
else if ( v8 == 65522 )
{
result = 0xFFFFFFFFLL;
}
else
{
v9 = *((_QWORD *)a3 + 3);
if ( !v9 )
_assert_fail("sym->scnptr", "src/libelfu/model/symtab.c", 0x28u, "elfu_mSymtabLookupSymToAddr");
v10 = elfu_mScnByOldscn(a1, v9);
if ( !v10 )
_assert_fail("newscn", "src/libelfu/model/symtab.c", 0x2Au, "elfu_mSymtabLookupSymToAddr");
*a4 = *(_QWORD *)(v10 + 16) + *((_QWORD *)a3 + 1);
result = 0LL;
}
}
else
{
result = 0xFFFFFFFFLL;
}
}
else
{
if ( v6 == 4 )
fwrite("elfu_mSymtabLookupSymToAddr: Symbol type FILE is not supported.\n", 1uLL, 0x40uLL, stderr);
else
fprintf(
stderr,
"elfu_mSymtabLookupSymToAddr: Unknown symbol type %d for %s.\n",
v6,
(const char *)(*(_QWORD *)(*(_QWORD *)(a2 + 72) + 64LL) + *a3));
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int elfu_mSymtabLookupSymToAddr(ElfuElf *me, ElfuScn *msst, ElfuSym *sym, GElf_Addr *result)
{
  char *symname = ((msst)->linkptr->databuf + (sym->name));
  switch (sym->type) {
    case 0:
    case 1:
    case 2:
      if (sym->shndx == 0) {
        return -1;
      } else if (sym->shndx == 0xfff1) {
        *result = sym->value;
        return 0;
      } else if (sym->shndx == 0xfff2) {
        return -1;
      } else {
        ElfuScn *newscn;
        ((void) sizeof ((sym->scnptr) ? 1 : 0), __extension__ ({ if (sym->scnptr) ; else __assert_fail ("sym->scnptr", "src/libelfu/model/symtab.c", 40, __extension__ __PRETTY_FUNCTION__); }));
        newscn = elfu_mScnByOldscn(me, sym->scnptr);
        ((void) sizeof ((newscn) ? 1 : 0), __extension__ ({ if (newscn) ; else __assert_fail ("newscn", "src/libelfu/model/symtab.c", 42, __extension__ __PRETTY_FUNCTION__); }));
        *result = newscn->shdr.sh_addr + sym->value;
        return 0;
      }
      break;
    case 3:
      ((void) sizeof ((sym->scnptr) ? 1 : 0), __extension__ ({ if (sym->scnptr) ; else __assert_fail ("sym->scnptr", "src/libelfu/model/symtab.c", 48, __extension__ __PRETTY_FUNCTION__); }));
      ((void) sizeof ((elfu_mScnByOldscn(me, sym->scnptr)) ? 1 : 0), __extension__ ({ if (elfu_mScnByOldscn(me, sym->scnptr)) ; else __assert_fail ("elfu_mScnByOldscn(me, sym->scnptr)", "src/libelfu/model/symtab.c", 49, __extension__ __PRETTY_FUNCTION__); }));
      *result = elfu_mScnByOldscn(me, sym->scnptr)->shdr.sh_addr;
      return 0;
    case 4:
      do { fprintf(stderr, "elfu_mSymtabLookupSymToAddr: Symbol type FILE is not supported.\n"); } while(0);
      return -1;
    default:
      do { fprintf(stderr, "elfu_mSymtabLookupSymToAddr: Unknown symbol type %d for %s.\n", sym->type, symname); } while(0);
      return -1;
  }
}

canonical_original_code:
int elfu_mSymtabLookupSymToAddr(struct ElfuElf *me, struct ElfuScn *msst, struct ElfuSym *sym, unsigned long *result)
{
  char *symname = ((msst)->linkptr->databuf + (sym->name));
  switch (sym->type) {
    case 0:
    case 1:
    case 2:
      if (sym->shndx == 0) {
        return -1;
      } else if (sym->shndx == 0xfff1) {
        *result = sym->value;
        return 0;
      } else if (sym->shndx == 0xfff2) {
        return -1;
      } else {
        struct ElfuScn *newscn;
        ((void) sizeof ((sym->scnptr) ? 1 : 0), __extension__ ({ if (sym->scnptr) ; else __assert_fail ("sym->scnptr", "src/libelfu/model/symtab.c", 40, __extension__ __PRETTY_FUNCTION__); }));
        newscn = elfu_mScnByOldscn(me, sym->scnptr);
        ((void) sizeof ((newscn) ? 1 : 0), __extension__ ({ if (newscn) ; else __assert_fail ("newscn", "src/libelfu/model/symtab.c", 42, __extension__ __PRETTY_FUNCTION__); }));
        *result = newscn->shdr.sh_addr + sym->value;
        return 0;
      }
      break;
    case 3:
      ((void) sizeof ((sym->scnptr) ? 1 : 0), __extension__ ({ if (sym->scnptr) ; else __assert_fail ("sym->scnptr", "src/libelfu/model/symtab.c", 48, __extension__ __PRETTY_FUNCTION__); }));
      ((void) sizeof ((elfu_mScnByOldscn(me, sym->scnptr)) ? 1 : 0), __extension__ ({ if (elfu_mScnByOldscn(me, sym->scnptr)) ; else __assert_fail ("elfu_mScnByOldscn(me, sym->scnptr)", "src/libelfu/model/symtab.c", 49, __extension__ __PRETTY_FUNCTION__); }));
      *result = elfu_mScnByOldscn(me, sym->scnptr)->shdr.sh_addr;
      return 0;
    case 4:
      do { fprintf(stderr, "elfu_mSymtabLookupSymToAddr: Symbol type FILE is not supported.\n"); } while(0);
      return -1;
    default:
      do { fprintf(stderr, "elfu_mSymtabLookupSymToAddr: Unknown symbol type %d for %s.\n", sym->type, symname); } while(0);
      return -1;
  }
}

variable_types:
msst
struct ElfuScn *

variable_types:
sym
struct ElfuSym *

user_defined_types: struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; }


decompiled_code:
__int64 __fastcall elfu_mSymtabSymToName(__int64 a1, unsigned int *a2)
{
if ( !a1 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x41u, "elfu_mSymtabSymToName");
if ( !a2 )
_assert_fail("sym", "src/libelfu/model/symtab.c", 0x42u, "elfu_mSymtabSymToName");
return *(_QWORD *)(*(_QWORD *)(a1 + 72) + 64LL) + *a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int *a2)
{
if ( !a1 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x41u, "elfu_mSymtabSymToName");
if ( !a2 )
_assert_fail("sym", "src/libelfu/model/symtab.c", 0x42u, "elfu_mSymtabSymToName");
return *(_QWORD *)(*(_QWORD *)(a1 + 72) + 64LL) + *a2;
}

original_code:
char* elfu_mSymtabSymToName(ElfuScn *msst, ElfuSym *sym)
{
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 65, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((sym) ? 1 : 0), __extension__ ({ if (sym) ; else __assert_fail ("sym", "src/libelfu/model/symtab.c", 66, __extension__ __PRETTY_FUNCTION__); }));
  return ((msst)->linkptr->databuf + (sym->name));
}

canonical_original_code:
char *elfu_mSymtabSymToName(struct ElfuScn *msst, struct ElfuSym *sym)
{
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 65, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((sym) ? 1 : 0), __extension__ ({ if (sym) ; else __assert_fail ("sym", "src/libelfu/model/symtab.c", 66, __extension__ __PRETTY_FUNCTION__); }));
  return ((msst)->linkptr->databuf + (sym->name));
}

return_type: char *


decompiled_code:
__int64 __fastcall elfu_mSymtabIndexToSym(__int64 a1, unsigned int a2)
{
__int64 v2; // rdx
int v3; // eax

if ( !a1 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x4Eu, "elfu_mSymtabIndexToSym");
if ( !a2 )
_assert_fail("entry > 0", "src/libelfu/model/symtab.c", 0x4Fu, "elfu_mSymtabIndexToSym");
v2 = *(_QWORD *)(a1 + 96);
if ( v2 == a1 + 96 )
_assert_fail("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 0x50u, "elfu_mSymtabIndexToSym");
v3 = 1;
if ( a2 > 1 )
{
do
{
v2 = *(_QWORD *)(v2 + 40);
++v3;
}
while ( a2 != v3 );
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2)
{
__int64 v2; // rdx
int v3; // eax

if ( !a1 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x4Eu, "elfu_mSymtabIndexToSym");
if ( !a2 )
_assert_fail("entry > 0", "src/libelfu/model/symtab.c", 0x4Fu, "elfu_mSymtabIndexToSym");
v2 = *(_QWORD *)(a1 + 96);
if ( v2 == a1 + 96 )
_assert_fail("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 0x50u, "elfu_mSymtabIndexToSym");
v3 = 1;
if ( a2 > 1 )
{
do
{
v2 = *(_QWORD *)(v2 + 40);
++v3;
}
while ( a2 != v3 );
}
return v2;
}

original_code:
ElfuSym* elfu_mSymtabIndexToSym(ElfuScn *msst, GElf_Word entry)
{
  GElf_Word i;
  ElfuSym *sym;
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 78, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((entry > 0) ? 1 : 0), __extension__ ({ if (entry > 0) ; else __assert_fail ("entry > 0", "src/libelfu/model/symtab.c", 79, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ? 1 : 0), __extension__ ({ if (!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ; else __assert_fail ("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  sym = ((&msst->symtab.syms)->cqh_first);
  for (i = 1; i < entry; i++) {
    sym = ((sym)->elem.cqe_next);
  }
  return sym;
}

canonical_original_code:
struct ElfuSym *elfu_mSymtabIndexToSym(struct ElfuScn *msst, unsigned int entry)
{
  unsigned int i;
  struct ElfuSym *sym;
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 78, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((entry > 0) ? 1 : 0), __extension__ ({ if (entry > 0) ; else __assert_fail ("entry > 0", "src/libelfu/model/symtab.c", 79, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ? 1 : 0), __extension__ ({ if (!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ; else __assert_fail ("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  sym = ((&msst->symtab.syms)->cqh_first);
  for (i = 1; i < entry; i++) {
    sym = ((sym)->elem.cqe_next);
  }
  return sym;
}

variable_types:
entry
unsigned int

return_type: struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *


decompiled_code:
__int64 __fastcall elfu_mSymtabLookupAddrByName(__int64 a1, __int64 a2, const char *a3)
{
unsigned int *v4; // rbx
__int64 v5; // r13
__int64 result; // rax
__int64 v7; // rdx
__int64 v8; // rax
unsigned int v9; // edx

if ( !a1 )
_assert_fail("me", "src/libelfu/model/symtab.c", 0x61u, "elfu_mSymtabLookupAddrByName");
if ( !a2 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x62u, "elfu_mSymtabLookupAddrByName");
if ( !a3 )
_assert_fail("name", "src/libelfu/model/symtab.c", 0x63u, "elfu_mSymtabLookupAddrByName");
if ( !*a3 )
_assert_fail("strlen(name) > 0", "src/libelfu/model/symtab.c", 0x64u, "elfu_mSymtabLookupAddrByName");
v4 = *(unsigned int **)(a2 + 96);
if ( v4 == (unsigned int *)(a2 + 96) )
_assert_fail(
"!CIRCLEQ_EMPTY(&msst->symtab.syms)",
"src/libelfu/model/symtab.c",
0x65u,
"elfu_mSymtabLookupAddrByName");
v5 = *(_QWORD *)(*(_QWORD *)(a2 + 72) + 64LL);
while ( strcmp((const char *)(v5 + *v4), a3) )
{
v4 = (unsigned int *)*((_QWORD *)v4 + 5);
if ( (unsigned int *)(a2 + 96) == v4 )
return 0LL;
}
result = 0LL;
if ( *((_BYTE *)v4 + 21) <= 2u )
{
v7 = *((_QWORD *)v4 + 3);
if ( v7 )
{
v8 = 0LL;
if ( *(_WORD *)(a1 + 24) == 1 )
v8 = *(_QWORD *)(v7 + 16);
result = *((_QWORD *)v4 + 1) + v8;
}
else
{
v9 = v4[8];
result = 0LL;
if ( v9 )
{
if ( v9 == 65521 )
{
result = *((_QWORD *)v4 + 1);
}
else
{
fwrite(
"elfu_mSymtabLookupAddrByName: Symbol binding COMMON is not supported, using 0.\n",
1uLL,
0x4FuLL,
stderr);
result = 0LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, const char *a3)
{
unsigned int *v4; // rbx
__int64 v5; // r13
__int64 result; // rax
__int64 v7; // rdx
__int64 v8; // rax
unsigned int v9; // edx

if ( !a1 )
_assert_fail("me", "src/libelfu/model/symtab.c", 0x61u, "elfu_mSymtabLookupAddrByName");
if ( !a2 )
_assert_fail("msst", "src/libelfu/model/symtab.c", 0x62u, "elfu_mSymtabLookupAddrByName");
if ( !a3 )
_assert_fail("name", "src/libelfu/model/symtab.c", 0x63u, "elfu_mSymtabLookupAddrByName");
if ( !*a3 )
_assert_fail("strlen(name) > 0", "src/libelfu/model/symtab.c", 0x64u, "elfu_mSymtabLookupAddrByName");
v4 = *(unsigned int **)(a2 + 96);
if ( v4 == (unsigned int *)(a2 + 96) )
_assert_fail(
"!CIRCLEQ_EMPTY(&msst->symtab.syms)",
"src/libelfu/model/symtab.c",
0x65u,
"elfu_mSymtabLookupAddrByName");
v5 = *(_QWORD *)(*(_QWORD *)(a2 + 72) + 64LL);
while ( strcmp((const char *)(v5 + *v4), a3) )
{
v4 = (unsigned int *)*((_QWORD *)v4 + 5);
if ( (unsigned int *)(a2 + 96) == v4 )
return 0LL;
}
result = 0LL;
if ( *((_BYTE *)v4 + 21) <= 2u )
{
v7 = *((_QWORD *)v4 + 3);
if ( v7 )
{
v8 = 0LL;
if ( *(_WORD *)(a1 + 24) == 1 )
v8 = *(_QWORD *)(v7 + 16);
result = *((_QWORD *)v4 + 1) + v8;
}
else
{
v9 = v4[8];
result = 0LL;
if ( v9 )
{
if ( v9 == 65521 )
{
result = *((_QWORD *)v4 + 1);
}
else
{
fwrite(
"elfu_mSymtabLookupAddrByName: Symbol binding COMMON is not supported, using 0.\n",
1uLL,
0x4FuLL,
stderr);
result = 0LL;
}
}
}
}
return result;
}

original_code:
GElf_Addr elfu_mSymtabLookupAddrByName(ElfuElf *me, ElfuScn *msst, char *name)
{
  ElfuSym *sym;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/symtab.c", 97, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 98, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((name) ? 1 : 0), __extension__ ({ if (name) ; else __assert_fail ("name", "src/libelfu/model/symtab.c", 99, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((strlen(name) > 0) ? 1 : 0), __extension__ ({ if (strlen(name) > 0) ; else __assert_fail ("strlen(name) > 0", "src/libelfu/model/symtab.c", 100, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ? 1 : 0), __extension__ ({ if (!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ; else __assert_fail ("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 101, __extension__ __PRETTY_FUNCTION__); }));
  for ((sym) = ((&msst->symtab.syms)->cqh_first); (sym) != (const void *)(&msst->symtab.syms); (sym) = ((sym)->elem.cqe_next)) {
    char *symname = ((msst)->linkptr->databuf + (sym->name));
    if (!strcmp(symname, name)) {
      goto SYMBOL_FOUND;
    }
  }
  return 0;
  SYMBOL_FOUND:
  switch (sym->type) {
    case 0:
    case 1:
    case 2:
      if (sym->scnptr) {
        GElf_Addr a = sym->value;
        a += me->ehdr.e_type == 1 ? sym->scnptr->shdr.sh_addr : 0;
        return a;
      } else if (sym->shndx == 0) {
        return 0;
      } else if (sym->shndx == 0xfff1) {
        return sym->value;
      } else {
        do { fprintf(stderr, "elfu_mSymtabLookupAddrByName: Symbol binding COMMON is not supported, using 0.\n"); } while(0);
        return 0;
      }
      break;
    default:
      return 0;
  }
}

canonical_original_code:
unsigned long elfu_mSymtabLookupAddrByName(struct ElfuElf *me, struct ElfuScn *msst, char *name)
{
  struct ElfuSym *sym;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/symtab.c", 97, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((msst) ? 1 : 0), __extension__ ({ if (msst) ; else __assert_fail ("msst", "src/libelfu/model/symtab.c", 98, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((name) ? 1 : 0), __extension__ ({ if (name) ; else __assert_fail ("name", "src/libelfu/model/symtab.c", 99, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((strlen(name) > 0) ? 1 : 0), __extension__ ({ if (strlen(name) > 0) ; else __assert_fail ("strlen(name) > 0", "src/libelfu/model/symtab.c", 100, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ? 1 : 0), __extension__ ({ if (!((&msst->symtab.syms)->cqh_first == (void *)(&msst->symtab.syms))) ; else __assert_fail ("!CIRCLEQ_EMPTY(&msst->symtab.syms)", "src/libelfu/model/symtab.c", 101, __extension__ __PRETTY_FUNCTION__); }));
  for ((sym) = ((&msst->symtab.syms)->cqh_first); (sym) != (void *)(&msst->symtab.syms); (sym) = ((sym)->elem.cqe_next)) {
    char *symname = ((msst)->linkptr->databuf + (sym->name));
    if (!strcmp(symname, name)) {
      goto SYMBOL_FOUND;
    }
  }
  return 0;
  SYMBOL_FOUND:
  switch (sym->type) {
    case 0:
    case 1:
    case 2:
      if (sym->scnptr) {
        unsigned long a = sym->value;
        a += me->ehdr.e_type == 1 ? sym->scnptr->shdr.sh_addr : 0;
        return a;
      } else if (sym->shndx == 0) {
        return 0;
      } else if (sym->shndx == 0xfff1) {
        return sym->value;
      } else {
        do { fprintf(stderr, "elfu_mSymtabLookupAddrByName: Symbol binding COMMON is not supported, using 0.\n"); } while(0);
        return 0;
      }
      break;
    default:
      return 0;
  }
}

variable_types:
a
unsigned long

return_type: unsigned long


decompiled_code:
void __fastcall elfu_mSymtabAddGlobalDymtabIfNotPresent(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rax
__int64 v3; // rbp
_BYTE *v4; // rax
__int64 v5; // rax
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rax

if ( !a1 )
_assert_fail("me", "src/libelfu/model/symtab.c", 0xDDu, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
if ( !*(_QWORD *)(a1 + 112) )
{
v1 = elfu_mScnAlloc();
if ( !v1 )
_assert_fail("symtab", "src/libelfu/model/symtab.c", 0xE4u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
v2 = elfu_mScnAlloc();
v3 = v2;
if ( !v2 )
_assert_fail("strtab", "src/libelfu/model/symtab.c", 0xE6u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
*(_QWORD *)(v1 + 72) = v2;
*(_QWORD *)(v1 + 56) = 8LL * (*(_DWORD *)a1 != 1) + 16;
*(_QWORD *)(v1 + 48) = 4LL;
*(_QWORD *)(v2 + 48) = 1LL;
*(_DWORD *)(v1 + 4) = 2;
*(_DWORD *)(v2 + 4) = 3;
v4 = malloc(1uLL);
*(_QWORD *)(v3 + 64) = v4;
if ( !v4 )
_assert_fail("strtab->databuf", "src/libelfu/model/symtab.c", 0xF0u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
*v4 = 0;
v5 = a1 + 88;
*(_QWORD *)(v1 + 128) = a1 + 88;
v6 = *(_QWORD *)(a1 + 96);
*(_QWORD *)(v1 + 136) = v6;
if ( a1 + 88 == *(_QWORD *)(a1 + 88) )
*(_QWORD *)(a1 + 88) = v1;
else
*(_QWORD *)(v6 + 128) = v1;
*(_QWORD *)(a1 + 96) = v1;
*(_QWORD *)(v3 + 128) = v5;
v7 = *(_QWORD *)(a1 + 96);
*(_QWORD *)(v3 + 136) = v7;
if ( v5 == *(_QWORD *)(a1 + 88) )
*(_QWORD *)(a1 + 88) = v3;
else
*(_QWORD *)(v7 + 128) = v3;
*(_QWORD *)(a1 + 96) = v3;
*(_QWORD *)(a1 + 112) = v1;
v8 = *(_QWORD *)(a1 + 104);
if ( v8 )
{
*(_DWORD *)v1 = *(_QWORD *)(v8 + 32);
if ( (unsigned int)elfu_mScnAppendData(*(_QWORD *)(a1 + 104), ".symtab", 8LL) )
*(_DWORD *)v1 = 0;
*(_DWORD *)v3 = *(_QWORD *)(*(_QWORD *)(a1 + 104) + 32LL);
if ( (unsigned int)elfu_mScnAppendData(*(_QWORD *)(a1 + 104), ".strtab", 8LL) )
*(_DWORD *)v3 = 0;
}
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rax
__int64 v3; // rbp
_BYTE *v4; // rax
__int64 v5; // rax
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rax

if ( !a1 )
_assert_fail("me", "src/libelfu/model/symtab.c", 0xDDu, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
if ( !*(_QWORD *)(a1 + 112) )
{
v1 = elfu_mScnAlloc();
if ( !v1 )
_assert_fail("symtab", "src/libelfu/model/symtab.c", 0xE4u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
v2 = elfu_mScnAlloc();
v3 = v2;
if ( !v2 )
_assert_fail("strtab", "src/libelfu/model/symtab.c", 0xE6u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
*(_QWORD *)(v1 + 72) = v2;
*(_QWORD *)(v1 + 56) = 8LL * (*(_DWORD *)a1 != 1) + 16;
*(_QWORD *)(v1 + 48) = 4LL;
*(_QWORD *)(v2 + 48) = 1LL;
*(_DWORD *)(v1 + 4) = 2;
*(_DWORD *)(v2 + 4) = 3;
v4 = malloc(1uLL);
*(_QWORD *)(v3 + 64) = v4;
if ( !v4 )
_assert_fail("strtab->databuf", "src/libelfu/model/symtab.c", 0xF0u, "elfu_mSymtabAddGlobalDymtabIfNotPresent");
*v4 = 0;
v5 = a1 + 88;
*(_QWORD *)(v1 + 128) = a1 + 88;
v6 = *(_QWORD *)(a1 + 96);
*(_QWORD *)(v1 + 136) = v6;
if ( a1 + 88 == *(_QWORD *)(a1 + 88) )
*(_QWORD *)(a1 + 88) = v1;
else
*(_QWORD *)(v6 + 128) = v1;
*(_QWORD *)(a1 + 96) = v1;
*(_QWORD *)(v3 + 128) = v5;
v7 = *(_QWORD *)(a1 + 96);
*(_QWORD *)(v3 + 136) = v7;
if ( v5 == *(_QWORD *)(a1 + 88) )
*(_QWORD *)(a1 + 88) = v3;
else
*(_QWORD *)(v7 + 128) = v3;
*(_QWORD *)(a1 + 96) = v3;
*(_QWORD *)(a1 + 112) = v1;
v8 = *(_QWORD *)(a1 + 104);
if ( v8 )
{
*(_DWORD *)v1 = *(_QWORD *)(v8 + 32);
if ( (unsigned int)elfu_mScnAppendData(*(_QWORD *)(a1 + 104), ".symtab", 8LL) )
*(_DWORD *)v1 = 0;
*(_DWORD *)v3 = *(_QWORD *)(*(_QWORD *)(a1 + 104) + 32LL);
if ( (unsigned int)elfu_mScnAppendData(*(_QWORD *)(a1 + 104), ".strtab", 8LL) )
*(_DWORD *)v3 = 0;
}
}
}

original_code:
void elfu_mSymtabAddGlobalDymtabIfNotPresent(ElfuElf *me)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/symtab.c", 221, __extension__ __PRETTY_FUNCTION__); }));
  if (!me->symtab) {
    ElfuScn *symtab;
    ElfuScn *strtab;
    symtab = elfu_mScnAlloc();
    ((void) sizeof ((symtab) ? 1 : 0), __extension__ ({ if (symtab) ; else __assert_fail ("symtab", "src/libelfu/model/symtab.c", 228, __extension__ __PRETTY_FUNCTION__); }));
    strtab = elfu_mScnAlloc();
    ((void) sizeof ((strtab) ? 1 : 0), __extension__ ({ if (strtab) ; else __assert_fail ("strtab", "src/libelfu/model/symtab.c", 230, __extension__ __PRETTY_FUNCTION__); }));
    symtab->linkptr = strtab;
    symtab->shdr.sh_entsize = me->elfclass == 1 ? sizeof(Elf32_Sym) : sizeof(Elf64_Sym);
    symtab->shdr.sh_addralign = 4;
    strtab->shdr.sh_addralign = 1;
    symtab->shdr.sh_type = 2;
    strtab->shdr.sh_type = 3;
    strtab->databuf = malloc(1);
    ((void) sizeof ((strtab->databuf) ? 1 : 0), __extension__ ({ if (strtab->databuf) ; else __assert_fail ("strtab->databuf", "src/libelfu/model/symtab.c", 240, __extension__ __PRETTY_FUNCTION__); }));
    strtab->databuf[0] = 0;
    do { (symtab)->elemChildScn.cqe_next = (void *)(&me->orphanScnList); (symtab)->elemChildScn.cqe_prev = (&me->orphanScnList)->cqh_last; if ((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (symtab); else (&me->orphanScnList)->cqh_last->elemChildScn.cqe_next = (symtab); (&me->orphanScnList)->cqh_last = (symtab); } while ( 0);
    do { (strtab)->elemChildScn.cqe_next = (void *)(&me->orphanScnList); (strtab)->elemChildScn.cqe_prev = (&me->orphanScnList)->cqh_last; if ((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (strtab); else (&me->orphanScnList)->cqh_last->elemChildScn.cqe_next = (strtab); (&me->orphanScnList)->cqh_last = (strtab); } while ( 0);
    me->symtab = symtab;
    if (me->shstrtab) {
      symtab->shdr.sh_name = me->shstrtab->shdr.sh_size;
      if (elfu_mScnAppendData(me->shstrtab, ".symtab", 8)) {
        symtab->shdr.sh_name = 0;
      }
      strtab->shdr.sh_name = me->shstrtab->shdr.sh_size;
      if (elfu_mScnAppendData(me->shstrtab, ".strtab", 8)) {
        strtab->shdr.sh_name = 0;
      }
    }
  }
}

canonical_original_code:
void elfu_mSymtabAddGlobalDymtabIfNotPresent(struct ElfuElf *me)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/symtab.c", 221, __extension__ __PRETTY_FUNCTION__); }));
  if (!me->symtab) {
    struct ElfuScn *symtab;
    struct ElfuScn *strtab;
    symtab = elfu_mScnAlloc();
    ((void) sizeof ((symtab) ? 1 : 0), __extension__ ({ if (symtab) ; else __assert_fail ("symtab", "src/libelfu/model/symtab.c", 228, __extension__ __PRETTY_FUNCTION__); }));
    strtab = elfu_mScnAlloc();
    ((void) sizeof ((strtab) ? 1 : 0), __extension__ ({ if (strtab) ; else __assert_fail ("strtab", "src/libelfu/model/symtab.c", 230, __extension__ __PRETTY_FUNCTION__); }));
    symtab->linkptr = strtab;
    symtab->shdr.sh_entsize = me->elfclass == 1 ? sizeof(Elf32_Sym) : sizeof(Elf64_Sym);
    symtab->shdr.sh_addralign = 4;
    strtab->shdr.sh_addralign = 1;
    symtab->shdr.sh_type = 2;
    strtab->shdr.sh_type = 3;
    strtab->databuf = malloc(1);
    ((void) sizeof ((strtab->databuf) ? 1 : 0), __extension__ ({ if (strtab->databuf) ; else __assert_fail ("strtab->databuf", "src/libelfu/model/symtab.c", 240, __extension__ __PRETTY_FUNCTION__); }));
    strtab->databuf[0] = 0;
    do { (symtab)->elemChildScn.cqe_next = (void *)(&me->orphanScnList); (symtab)->elemChildScn.cqe_prev = (&me->orphanScnList)->cqh_last; if ((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (symtab); else (&me->orphanScnList)->cqh_last->elemChildScn.cqe_next = (symtab); (&me->orphanScnList)->cqh_last = (symtab); } while ( 0);
    do { (strtab)->elemChildScn.cqe_next = (void *)(&me->orphanScnList); (strtab)->elemChildScn.cqe_prev = (&me->orphanScnList)->cqh_last; if ((&me->orphanScnList)->cqh_first == (void *)(&me->orphanScnList)) (&me->orphanScnList)->cqh_first = (strtab); else (&me->orphanScnList)->cqh_last->elemChildScn.cqe_next = (strtab); (&me->orphanScnList)->cqh_last = (strtab); } while ( 0);
    me->symtab = symtab;
    if (me->shstrtab) {
      symtab->shdr.sh_name = me->shstrtab->shdr.sh_size;
      if (elfu_mScnAppendData(me->shstrtab, ".symtab", 8)) {
        symtab->shdr.sh_name = 0;
      }
      strtab->shdr.sh_name = me->shstrtab->shdr.sh_size;
      if (elfu_mScnAppendData(me->shstrtab, ".strtab", 8)) {
        strtab->shdr.sh_name = 0;
      }
    }
  }
}


subOldscn

decompiled_code:
__int64 __fastcall subOldscn(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = 0LL;
if ( *(_QWORD *)(a2 + 88) == a3 )
result = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = 0LL;
if ( *(_QWORD *)(a2 + 88) == a3 )
result = a2;
return result;
}

original_code:
static void* subOldscn(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
  ElfuScn *otherScn = (ElfuScn*)aux1;
  (void)aux2;
  if (ms->oldptr == otherScn) {
    return ms;
  }
  return ((void *)0);
}

canonical_original_code:
static void *subOldscn(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)
{
  struct ElfuScn *otherScn = (ElfuScn*)aux1;
  (void)aux2;
  if (ms->oldptr == otherScn) {
    return ms;
  }
  return ((void *)0);
}


subScnsToArray

decompiled_code:
__int64 __fastcall subScnsToArray(__int64 a1, __int64 a2, __int64 a3, _QWORD *a4)
{
*(_QWORD *)(a3 + 8LL * (*a4)++) = a2;
return 0LL;
}

original_code:
static void* subScnsToArray(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
{
  ElfuScn **arr = (ElfuScn**)aux1;
  size_t *i = (size_t*)aux2;
  arr[(*i)] = ms;
  *i += 1;
  return ((void *)0);
}

canonical_original_code:
static void *subScnsToArray(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)
{
  struct ElfuScn **arr = (ElfuScn**)aux1;
  unsigned long *i = (size_t*)aux2;
  arr[(*i)] = ms;
  *i += 1;
  return ((void *)0);
}

variable_types: struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } **

variable_types:
i
unsigned long *


original_code:
void* elfu_mScnForall(ElfuElf *me, SectionHandlerFunc f, void *aux1, void *aux2)
{
  ElfuPhdr *mp;
  ElfuScn *ms;
  for ((mp) = ((&me->phdrList)->cqh_first); (mp) != (const void *)(&me->phdrList); (mp) = ((mp)->elem.cqe_next)) {
    if (mp->phdr.p_type != 1) {
      continue;
    }
    for ((ms) = ((&mp->childScnList)->cqh_first); (ms) != (const void *)(&mp->childScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
      void *rv = f(me, ms, aux1, aux2);
      if (rv) {
        return rv;
      }
    }
  }
  for ((ms) = ((&me->orphanScnList)->cqh_first); (ms) != (const void *)(&me->orphanScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
    void *rv = f(me, ms, aux1, aux2);
    if (rv) {
      return rv;
    }
  }
  return ((void *)0);
}

canonical_original_code:
void *elfu_mScnForall(struct ElfuElf *me, void *f(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2), void *aux1, void *aux2)
{
  struct ElfuPhdr *mp;
  struct ElfuScn *ms;
  for ((mp) = ((&me->phdrList)->cqh_first); (mp) != (void *)(&me->phdrList); (mp) = ((mp)->elem.cqe_next)) {
    if (mp->phdr.p_type != 1) {
      continue;
    }
    for ((ms) = ((&mp->childScnList)->cqh_first); (ms) != (void *)(&mp->childScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
      void *rv = f(me, ms, aux1, aux2);
      if (rv) {
        return rv;
      }
    }
  }
  for ((ms) = ((&me->orphanScnList)->cqh_first); (ms) != (void *)(&me->orphanScnList); (ms) = ((ms)->elemChildScn.cqe_next)) {
    void *rv = f(me, ms, aux1, aux2);
    if (rv) {
      return rv;
    }
  }
  return ((void *)0);
}

variable_types: struct ElfuElf { int elfclass; struct Elf64_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } ehdr; struct PhdrList { struct ElfuPhdr { struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; } phdr; struct ChildScnList { struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *cqh_first; struct ElfuScn *cqh_last; } childScnList; struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; } childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; } *cqh_first; struct ElfuPhdr *cqh_last; } phdrList; struct OrphanScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; } orphanScnList; struct ElfuScn *shstrtab; struct ElfuScn *symtab; } *

variable_types: void *(struct ElfuElf *me, struct ElfuScn *ms, void *aux1, void *aux2)

variable_types:
rv
void *


decompiled_code:
__int64 __fastcall elfu_mScnCount(__int64 a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

v2 = 0LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x50u, "elfu_mScnCount");
elfu_mScnForall(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v2, 0LL);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

v2 = 0LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x50u, "elfu_mScnCount");
func4(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v2, 0LL);
return v2;
}

original_code:
size_t elfu_mScnCount(ElfuElf *me)
{
  size_t i = 0;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mScnForall(me, subCounter, &i, ((void *)0));
  return i;
}

canonical_original_code:
unsigned long elfu_mScnCount(struct ElfuElf *me)
{
  unsigned long i = 0;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mScnForall(me, subCounter, &i, ((void *)0));
  return i;
}

variable_types:
i
unsigned long


decompiled_code:
unsigned __int64 __fastcall elfu_mScnIndex(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rdx
unsigned __int64 result; // rax
unsigned __int64 v4; // [rsp+8h] [rbp-10h] BYREF

v4 = 1LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x5Eu, "elfu_mScnIndex");
if ( !a2 )
_assert_fail("ms", "src/libelfu/model/section.c", 0x5Fu, "elfu_mScnIndex");
elfu_mScnForall(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v4, a2);
v2 = elfu_mScnCount(a1);
result = v4;
if ( v2 < v4 )
_assert_fail("i <= elfu_mScnCount(me)", "src/libelfu/model/section.c", 0x64u, "elfu_mScnIndex");
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rdx
unsigned __int64 result; // rax
unsigned __int64 v4; // [rsp+8h] [rbp-10h] BYREF

v4 = 1LL;
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x5Eu, "elfu_mScnIndex");
if ( !a2 )
_assert_fail("ms", "src/libelfu/model/section.c", 0x5Fu, "elfu_mScnIndex");
func4(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subCounter, (__int64)&v4, a2);
v2 = func5(a1);
result = v4;
if ( v2 < v4 )
_assert_fail("i <= elfu_mScnCount(me)", "src/libelfu/model/section.c", 0x64u, "elfu_mScnIndex");
return result;
}

original_code:
size_t elfu_mScnIndex(ElfuElf *me, ElfuScn *ms)
{
  size_t i = 1;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 94, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 95, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mScnForall(me, subCounter, &i, ms);
  ((void) sizeof ((i <= elfu_mScnCount(me)) ? 1 : 0), __extension__ ({ if (i <= elfu_mScnCount(me)) ; else __assert_fail ("i <= elfu_mScnCount(me)", "src/libelfu/model/section.c", 100, __extension__ __PRETTY_FUNCTION__); }));
  return i;
}

canonical_original_code:
unsigned long elfu_mScnIndex(struct ElfuElf *me, struct ElfuScn *ms)
{
  unsigned long i = 1;
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 94, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ms) ? 1 : 0), __extension__ ({ if (ms) ; else __assert_fail ("ms", "src/libelfu/model/section.c", 95, __extension__ __PRETTY_FUNCTION__); }));
  elfu_mScnForall(me, subCounter, &i, ms);
  ((void) sizeof ((i <= elfu_mScnCount(me)) ? 1 : 0), __extension__ ({ if (i <= elfu_mScnCount(me)) ; else __assert_fail ("i <= elfu_mScnCount(me)", "src/libelfu/model/section.c", 100, __extension__ __PRETTY_FUNCTION__); }));
  return i;
}

variable_types:
ms
struct ElfuScn *


decompiled_code:
__int64 __fastcall elfu_mScnByOldscn(__int64 a1, __int64 a2)
{
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x79u, "elfu_mScnByOldscn");
if ( !a2 )
_assert_fail("oldscn", "src/libelfu/model/section.c", 0x7Au, "elfu_mScnByOldscn");
return elfu_mScnForall(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subOldscn, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
if ( !a1 )
_assert_fail("me", "src/libelfu/model/section.c", 0x79u, "elfu_mScnByOldscn");
if ( !a2 )
_assert_fail("oldscn", "src/libelfu/model/section.c", 0x7Au, "elfu_mScnByOldscn");
return func4(a1, (__int64 (__fastcall *)(__int64, __int64, __int64, __int64))subOldscn, a2, 0LL);
}

original_code:
ElfuScn* elfu_mScnByOldscn(ElfuElf *me, ElfuScn *oldscn)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 121, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((oldscn) ? 1 : 0), __extension__ ({ if (oldscn) ; else __assert_fail ("oldscn", "src/libelfu/model/section.c", 122, __extension__ __PRETTY_FUNCTION__); }));
  return elfu_mScnForall(me, subOldscn, oldscn, ((void *)0));
}

canonical_original_code:
struct ElfuScn *elfu_mScnByOldscn(struct ElfuElf *me, struct ElfuScn *oldscn)
{
  ((void) sizeof ((me) ? 1 : 0), __extension__ ({ if (me) ; else __assert_fail ("me", "src/libelfu/model/section.c", 121, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((oldscn) ? 1 : 0), __extension__ ({ if (oldscn) ; else __assert_fail ("oldscn", "src/libelfu/model/section.c", 122, __extension__ __PRETTY_FUNCTION__); }));
  return elfu_mScnForall(me, subOldscn, oldscn, ((void *)0));
}

variable_types: struct ElfuElf { int elfclass; struct Elf64_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } ehdr; struct PhdrList { struct ElfuPhdr { struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; } phdr; struct ChildScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; } childScnList; struct ChildPhdrList { struct ElfuPhdr *cqh_first; struct ElfuPhdr *cqh_last; } childPhdrList; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elemChildPhdr; struct { struct ElfuPhdr *cqe_next; struct ElfuPhdr *cqe_prev; } elem; } *cqh_first; struct ElfuPhdr *cqh_last; } phdrList; struct OrphanScnList { struct ElfuScn *cqh_first; struct ElfuScn *cqh_last; } orphanScnList; struct ElfuScn *shstrtab; struct ElfuScn *symtab; } *

variable_types:
oldscn
struct ElfuScn *

return_type: struct ElfuScn { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } shdr; char *databuf; struct ElfuScn *linkptr; struct ElfuScn *infoptr; struct ElfuScn *oldptr; struct ElfuSymtab { struct Syms { struct ElfuSym { unsigned int name; unsigned long value; unsigned int size; unsigned char bind; unsigned char type; unsigned char other; struct ElfuScn *scnptr; int shndx; struct { struct ElfuSym *cqe_next; struct ElfuSym *cqe_prev; } elem; } *cqh_first; struct ElfuSym *cqh_last; } syms; } symtab; struct ElfuReltab { struct Rels { struct ElfuRel { unsigned long offset; unsigned int sym; unsigned char type; int addendUsed; int addend; struct { struct ElfuRel *cqe_next; struct ElfuRel *cqe_prev; } elem; } *cqh_first; struct ElfuRel *cqh_last; } rels; } reltab; struct { struct ElfuScn *cqe_next; struct ElfuScn *cqe_prev; } elemChildScn; } *