main

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

v3 = CreateNode(100);
InsertNode(15, (__int64)v3);
InsertNode(140, (__int64)v3);
InsertNode(108, (__int64)v3);
InsertNode(63, (__int64)v3);
InsertNode(45, (__int64)v3);
InsertNode(75, (__int64)v3);
InsertNode(132, (__int64)v3);
InsertNode(30, (__int64)v3);
InsertNode(10, (__int64)v3);
InsertNode(8, (__int64)v3);
InsertNode(150, (__int64)v3);
InsertNode(24, (__int64)v3);
InsertNode(80, (__int64)v3);
InsertNode(102, (__int64)v3);
InsertNode(120, (__int64)v3);
InsertNode(99, (__int64)v3);
InsertNode(154, (__int64)v3);
PrintLine();
v4 = FindTreeDepth((__int64)v3);
printf("depth : %d", v4);
PrintLine();
puts("PostOrder");
PrintTreePostOrder((__int64)v3);
PrintLine();
puts("PreOrder");
PrintTreePreOrder((__int64)v3, 0);
PrintLine();
v5 = RemoveNode(140LL, v3);
puts("PreOrder after removal of 140");
PrintTreePreOrder((__int64)v5, 0);
PrintLine();
puts("InOrder");
PrintTreeInOrder((__int64)v5);
PrintLine();
PrintBFS((__int64)v5);
PrintLine();
PrintReverseBFS((__int64)v5);
return 0;
}

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

v3 = CreateNode(100);
InsertNode(15, (__int64)v3);
InsertNode(140, (__int64)v3);
InsertNode(108, (__int64)v3);
InsertNode(63, (__int64)v3);
InsertNode(45, (__int64)v3);
InsertNode(75, (__int64)v3);
InsertNode(132, (__int64)v3);
InsertNode(30, (__int64)v3);
InsertNode(10, (__int64)v3);
InsertNode(8, (__int64)v3);
InsertNode(150, (__int64)v3);
InsertNode(24, (__int64)v3);
InsertNode(80, (__int64)v3);
InsertNode(102, (__int64)v3);
InsertNode(120, (__int64)v3);
InsertNode(99, (__int64)v3);
InsertNode(154, (__int64)v3);
func8();
v4 = func13((__int64)v3);
printf("depth : %d", v4);
func8();
puts("PostOrder");
func12((__int64)v3);
func8();
puts("PreOrder");
func10((__int64)v3, 0);
func8();
v5 = RemoveNode(140LL, v3);
puts("PreOrder after removal of 140");
func10((__int64)v5, 0);
func8();
puts("InOrder");
func11((__int64)v5);
func8();
func14((__int64)v5);
func8();
func15((__int64)v5);
return 0;
}

original_code:
int main()
{
 node *root;
 root = CreateNode(100);
 InsertNode(15, root);
 InsertNode(140, root);
 InsertNode(108, root);
 InsertNode(63, root);
 InsertNode(45, root);
 InsertNode(75, root);
 InsertNode(132, root);
 InsertNode(30, root);
 InsertNode(10, root);
 InsertNode(8, root);
 InsertNode(150, root);
 InsertNode(24, root);
 InsertNode(80, root);
 InsertNode(102, root);
 InsertNode(120, root);
 InsertNode(99, root);
 InsertNode(154, root);
 PrintLine();
 printf("depth : %d",FindTreeDepth(root));
 PrintLine();
 printf("PostOrder\n");
 PrintTreePostOrder(root);
 PrintLine();
 printf("PreOrder\n");
 PrintTreePreOrder(root, 0);
 PrintLine();
 root = RemoveNode(140,root);
 printf("PreOrder after removal of 140\n");
 PrintTreePreOrder(root,0);
 PrintLine();
 printf("InOrder\n");
 PrintTreeInOrder(root);
 PrintLine();
 PrintBFS(root);
 PrintLine();
 PrintReverseBFS(root);
 return 0;
}

canonical_original_code:
int main()
{
 struct node *root;
 root = CreateNode(100);
 InsertNode(15, root);
 InsertNode(140, root);
 InsertNode(108, root);
 InsertNode(63, root);
 InsertNode(45, root);
 InsertNode(75, root);
 InsertNode(132, root);
 InsertNode(30, root);
 InsertNode(10, root);
 InsertNode(8, root);
 InsertNode(150, root);
 InsertNode(24, root);
 InsertNode(80, root);
 InsertNode(102, root);
 InsertNode(120, root);
 InsertNode(99, root);
 InsertNode(154, root);
 PrintLine();
 printf("depth : %d",FindTreeDepth(root));
 PrintLine();
 printf("PostOrder\n");
 PrintTreePostOrder(root);
 PrintLine();
 printf("PreOrder\n");
 PrintTreePreOrder(root, 0);
 PrintLine();
 root = RemoveNode(140,root);
 printf("PreOrder after removal of 140\n");
 PrintTreePreOrder(root,0);
 PrintLine();
 printf("InOrder\n");
 PrintTreeInOrder(root);
 PrintLine();
 PrintBFS(root);
 PrintLine();
 PrintReverseBFS(root);
 return 0;
}


decompiled_code:
void __fastcall hashList_DeleteTail(__int64 a1, int a2)
{
unsigned int v2; // ebx
__int64 v3; // rdx
_QWORD *v4; // rax
void *v5; // rdi

v2 = ht_HashFunction((_DWORD *)a1, a2);
puts("Deleting tail node. ");
v3 = *(_QWORD *)(a1 + 8) + 16LL * v2;
v4 = *(_QWORD **)(v3 + 8);
while ( 1 )
{
v5 = v4;
v4 = (_QWORD *)v4[1];
if ( !v4 )
break;
v3 = (__int64)v5;
}
*(_QWORD *)(v3 + 8) = 0LL;
free(v5);
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, int a2)
{
unsigned int v2; // ebx
__int64 v3; // rdx
_QWORD *v4; // rax
void *v5; // rdi

v2 = func0((_DWORD *)a1, a2);
puts("Deleting tail node. ");
v3 = *(_QWORD *)(a1 + 8) + 16LL * v2;
v4 = *(_QWORD **)(v3 + 8);
while ( 1 )
{
v5 = v4;
v4 = (_QWORD *)v4[1];
if ( !v4 )
break;
v3 = (__int64)v5;
}
*(_QWORD *)(v3 + 8) = 0LL;
free(v5);
}

original_code:
static void hashList_DeleteTail(HashTable* hashTable, DataType key)
{
 unsigned int index = ht_HashFunction(hashTable, key);
 printf("Deleting tail node. \n");
 HashNode* prev = (hashTable->htNodeHead+index);
    HashNode* p = prev->next;
    while(p->next){
             prev = p;
             p = p->next;
    }
    prev->next = ((void *)0);
    free(p);
}

canonical_original_code:
static void hashList_DeleteTail(struct hash_table *hashTable, int key)
{
 unsigned int index = ht_HashFunction(hashTable, key);
 printf("Deleting tail node. \n");
 struct hash_node *prev = (hashTable->htNodeHead+index);
    struct hash_node *p = prev->next;
    while(p->next){
             prev = p;
             p = p->next;
    }
    prev->next = ((void *)0);
    free(p);
}

variable_types: struct hash_table { int hashSize; struct hash_node { int key; int value; struct hash_node *next; } *htNodeHead; } *

variable_types: key int

variable_types:
index
unsigned int

return_type: void

user_defined_types: struct hash_table { int hashSize; struct hash_node *htNodeHead; }


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

result = (char *)malloc(0xCuLL);
*(_DWORD *)result = a1;
*(_QWORD *)(result + 4) = 0LL;
return result;
}

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

result = (char *)malloc(0xCuLL);
*(_DWORD *)result = a1;
*(_QWORD *)(result + 4) = 0LL;
return result;
}

original_code:
Node* list_CreateNode(DataType value)
{
 Node* node = malloc(sizeof(Node));
 node-> data = value;
 node-> next = ((void *)0);
 return node;
}

canonical_original_code:
struct node *list_CreateNode(int value)
{
 struct node *node = malloc(sizeof(Node));
 node-> data = value;
 node-> next = ((void *)0);
 return node;
}

variable_types: value int

variable_types: struct node { int data; struct node *next; } *


decompiled_code:
int __fastcall list_printList(unsigned int **a1)
{
unsigned int *v1; // rbx
unsigned int v2; // ebp
int result; // eax

v1 = *a1;
if ( *a1 )
{
v2 = 0;
do
{
printf("Node %d data: %d ", v2, *v1);
result = printf("---Node %d address: %p \n", v2, v1);
v1 = *(unsigned int **)(v1 + 1);
++v2;
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(unsigned int **a1)
{
unsigned int *v1; // rbx
unsigned int v2; // ebp
int result; // eax

v1 = *a1;
if ( *a1 )
{
v2 = 0;
do
{
printf("Node %d data: %d ", v2, *v1);
result = printf("---Node %d address: %p \n", v2, v1);
v1 = *(unsigned int **)(v1 + 1);
++v2;
}
while ( v1 );
}
return result;
}

original_code:
void list_printList(List* list)
{
 Node* p = list->listHead;
 int i = 0;
 while (p!=((void *)0)){
  printf("Node %d data: %d   ", i, p->data);
  printf("---Node %d address: %p \n", i, p);
  p = p->next;
  i++;
 }
}

canonical_original_code:
void list_printList(struct list *list)
{
 struct node *p = list->listHead;
 int i = 0;
 while (p!=((void *)0)){
  printf("Node %d data: %d   ", i, p->data);
  printf("---Node %d address: %p \n", i, p);
  p = p->next;
  i++;
 }
}

variable_types: struct list { struct node { int data; struct node *next; } *listHead; } *

variable_types: i int


decompiled_code:
__int64 __fastcall list_GetTail(__int64 *a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = *a1;
do
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 4);
}
while ( v1 );
return v2;
}

original_code:
Node* list_GetTail(List* list)
{
 Node* p = list->listHead;
 while (p->next!=((void *)0)){
  p = p->next;
 }
 return p;
}

canonical_original_code:
struct node *list_GetTail(struct list *list)
{
 struct node *p = list->listHead;
 while (p->next!=((void *)0)){
  p = p->next;
 }
 return p;
}

variable_types: struct list { struct node *listHead; } *

return_type: struct node { int data; struct node *next; } *


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

for ( result = *a1; result; result = *(_QWORD *)(result + 4) )
{
if ( *(_DWORD *)result == a2 )
break;
}
return result;
}

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

for ( result = *a1; result; result = *(_QWORD *)(result + 4) )
{
if ( *(_DWORD *)result == a2 )
break;
}
return result;
}

original_code:
Node* list_Search(List* list, DataType value)
{
 Node* p = list->listHead;
 while (p!=((void *)0)){
  if(p->data == value)
   return p;
  p = p->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct node *list_Search(struct list *list, int value)
{
 struct node *p = list->listHead;
 while (p!=((void *)0)){
  if(p->data == value)
   return p;
  p = p->next;
 }
 return ((void *)0);
}

user_defined_types: struct node { int data; struct node *next; }


decompiled_code:
char *__fastcall list_InsertValueToHead(char **a1, int a2)
{
char *result; // rax

result = list_CreateNode(a2);
*(_QWORD *)(result + 4) = *a1;
*a1 = result;
return result;
}

canonical_decompiled_code:
char *__fastcall func8(char **a1, int a2)
{
char *result; // rax

result = func4(a2);
*(_QWORD *)(result + 4) = *a1;
*a1 = result;
return result;
}

original_code:
void list_InsertValueToHead(List* list, DataType value)
{
 Node* newNode = list_CreateNode(value);
 newNode->next = list->listHead;
 list->listHead = newNode;
}

canonical_original_code:
void list_InsertValueToHead(struct list *list, int value)
{
 struct node *newNode = list_CreateNode(value);
 newNode->next = list->listHead;
 list->listHead = newNode;
}


decompiled_code:
__int64 __fastcall list_InsertValueToTail(__int64 *a1, int a2)
{
char *v2; // rbx
__int64 result; // rax

v2 = list_CreateNode(a2);
result = list_GetTail(a1);
*(_QWORD *)(result + 4) = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 *a1, int a2)
{
char *v2; // rbx
__int64 result; // rax

v2 = func4(a2);
result = func6(a1);
*(_QWORD *)(result + 4) = v2;
return result;
}

original_code:
void list_InsertValueToTail(List* list, DataType value)
{
 Node* newNode = list_CreateNode(value);
 Node* p = list_GetTail(list);
 p->next = newNode;
}

canonical_original_code:
void list_InsertValueToTail(struct list *list, int value)
{
 struct node *newNode = list_CreateNode(value);
 struct node *p = list_GetTail(list);
 p->next = newNode;
}


decompiled_code:
char *__fastcall list_InsertValueBeforeNode(char **a1, __int64 a2, int a3)
{
char *result; // rax

if ( *a1 == (char *)a2 )
return list_InsertValueToHead(a1, a3);
result = list_CreateNode(*(_DWORD *)a2);
*(_QWORD *)(result + 4) = *(_QWORD *)(a2 + 4);
*(_DWORD *)a2 = a3;
*(_QWORD *)(a2 + 4) = result;
return result;
}

canonical_decompiled_code:
char *__fastcall func10(char **a1, __int64 a2, int a3)
{
char *result; // rax

if ( *a1 == (char *)a2 )
return func8(a1, a3);
result = func4(*(_DWORD *)a2);
*(_QWORD *)(result + 4) = *(_QWORD *)(a2 + 4);
*(_DWORD *)a2 = a3;
*(_QWORD *)(a2 + 4) = result;
return result;
}

original_code:
void list_InsertValueBeforeNode(List* list, Node* node, DataType value)
{
 if (node == list->listHead) {
  list_InsertValueToHead(list, value);
 } else {
  Node* newNode = list_CreateNode(node->data);
  newNode->next = node->next;
  node->data = value;
  node->next = newNode;
 }
}

canonical_original_code:
void list_InsertValueBeforeNode(struct list *list, struct node *node, int value)
{
 if (node == list->listHead) {
  list_InsertValueToHead(list, value);
 } else {
  struct node *newNode = list_CreateNode(node->data);
  newNode->next = node->next;
  node->data = value;
  node->next = newNode;
 }
}

variable_types:
node
struct node *


decompiled_code:
char *__fastcall list_InsertValueAfterNode(__int64 *a1, __int64 a2, int a3)
{
char *result; // rax

if ( !*(_QWORD *)(a2 + 4) )
return (char *)list_InsertValueToTail(a1, a3);
result = list_CreateNode(a3);
*(_QWORD *)(result + 4) = *(_QWORD *)(a2 + 4);
*(_QWORD *)(a2 + 4) = result;
return result;
}

canonical_decompiled_code:
char *__fastcall func11(__int64 *a1, __int64 a2, int a3)
{
char *result; // rax

if ( !*(_QWORD *)(a2 + 4) )
return (char *)func9(a1, a3);
result = func4(a3);
*(_QWORD *)(result + 4) = *(_QWORD *)(a2 + 4);
*(_QWORD *)(a2 + 4) = result;
return result;
}

original_code:
void list_InsertValueAfterNode(List* list, Node* node, DataType value)
{
 if(node->next == ((void *)0)){
  list_InsertValueToTail(list, value);
 } else {
  Node* newNode = list_CreateNode(value);
  newNode->next = node->next;
  node->next = newNode;
 }
}

canonical_original_code:
void list_InsertValueAfterNode(struct list *list, struct node *node, int value)
{
 if(node->next == ((void *)0)){
  list_InsertValueToTail(list, value);
 } else {
  struct node *newNode = list_CreateNode(value);
  newNode->next = node->next;
  node->next = newNode;
 }
}


decompiled_code:
__int64 __fastcall list_InsertNodeToTail(__int64 *a1, __int64 a2)
{
__int64 result; // rax

result = list_GetTail(a1);
*(_QWORD *)(result + 4) = a2;
*(_QWORD *)(a2 + 4) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 *a1, __int64 a2)
{
__int64 result; // rax

result = func6(a1);
*(_QWORD *)(result + 4) = a2;
*(_QWORD *)(a2 + 4) = 0LL;
return result;
}

original_code:
void list_InsertNodeToTail(List* list, Node* newNode)
{
 Node* p = list_GetTail(list);
 p->next = newNode;
 newNode->next = ((void *)0);
}

canonical_original_code:
void list_InsertNodeToTail(struct list *list, struct node *newNode)
{
 struct node *p = list_GetTail(list);
 p->next = newNode;
 newNode->next = ((void *)0);
}

variable_types:
newNode
struct node *


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

result = *(_QWORD *)(a2 + 4);
if ( !result )
return list_InsertNodeToTail(a1, a3);
*(_QWORD *)(a3 + 4) = result;
*(_QWORD *)(a2 + 4) = a3;
return result;
}

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

result = *(_QWORD *)(a2 + 4);
if ( !result )
return func13(a1, a3);
*(_QWORD *)(a3 + 4) = result;
*(_QWORD *)(a2 + 4) = a3;
return result;
}

original_code:
void list_InsertNodeAfterNode(List* list, Node* nodeLocation, Node* newNode)
{
 if (nodeLocation->next == ((void *)0)) {
  list_InsertNodeToTail(list, newNode);
 } else {
  newNode->next = nodeLocation->next;
  nodeLocation->next = newNode;
 }
}

canonical_original_code:
void list_InsertNodeAfterNode(struct list *list, struct node *nodeLocation, struct node *newNode)
{
 if (nodeLocation->next == ((void *)0)) {
  list_InsertNodeToTail(list, newNode);
 } else {
  newNode->next = nodeLocation->next;
  nodeLocation->next = newNode;
 }
}

variable_types:
nodeLocation
struct node *


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

if ( (unsigned int *)*a1 == a2 )
return list_InsertNodeToHead(a1, (__int64)a3);
result = *a2;
*a2 = *a3;
*(_QWORD *)(a2 + 1) = a3;
*a3 = result;
return result;
}

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

if ( (unsigned int *)*a1 == a2 )
return func12(a1, (__int64)a3);
result = *a2;
*a2 = *a3;
*(_QWORD *)(a2 + 1) = a3;
*a3 = result;
return result;
}

original_code:
void list_InsertNodeBeforeNode(List* list, Node* nodeLocation, Node* newNode)
{
 if(nodeLocation == list->listHead) {
  list_InsertNodeToHead(list, newNode);
 } else {
  DataType temp = nodeLocation->data;
  nodeLocation->data = newNode->data;
  nodeLocation->next = newNode;
  newNode->data = temp;
 }
}

canonical_original_code:
void list_InsertNodeBeforeNode(struct list *list, struct node *nodeLocation, struct node *newNode)
{
 if(nodeLocation == list->listHead) {
  list_InsertNodeToHead(list, newNode);
 } else {
  int temp = nodeLocation->data;
  nodeLocation->data = newNode->data;
  nodeLocation->next = newNode;
  newNode->data = temp;
 }
}

variable_types: temp int


decompiled_code:
void __fastcall list_DeleteHead(void *ptr)
{
__int64 v2; // rdi
__int64 v3; // rax

v2 = *(_QWORD *)ptr;
v3 = *(_QWORD *)(v2 + 4);
if ( v3 )
{
*(_QWORD *)ptr = v3;
free((void *)v2);
}
else
{
puts("List is empty after deletion! ");
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func16(void *ptr)
{
__int64 v2; // rdi
__int64 v3; // rax

v2 = *(_QWORD *)ptr;
v3 = *(_QWORD *)(v2 + 4);
if ( v3 )
{
*(_QWORD *)ptr = v3;
free((void *)v2);
}
else
{
puts("List is empty after deletion! ");
free(ptr);
}
}

original_code:
void list_DeleteHead(List* list)
{
 if (list->listHead->next ==((void *)0)){
  printf("List is empty after deletion! \n");
  free(list);
  return;
 }
 Node* node = list->listHead;
 list->listHead = list->listHead->next;
 free(node);
}

canonical_original_code:
void list_DeleteHead(struct list *list)
{
 if (list->listHead->next ==((void *)0)){
  printf("List is empty after deletion! \n");
  free(list);
  return;
 }
 struct node *node = list->listHead;
 list->listHead = list->listHead->next;
 free(node);
}


decompiled_code:
void __fastcall list_DeleteTail(void *ptr)
{
__int64 v2; // rbx
__int64 v3; // rdi
__int64 i; // rax

v2 = *(_QWORD *)ptr;
v3 = *(_QWORD *)(*(_QWORD *)ptr + 4LL);
if ( v3 )
{
for ( i = *(_QWORD *)(v3 + 4); i; i = *(_QWORD *)(i + 4) )
{
v2 = *(_QWORD *)(v2 + 4);
v3 = i;
}
free((void *)v3);
*(_QWORD *)(v2 + 4) = 0LL;
}
else
{
puts("List is empty after deletion! ");
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func17(void *ptr)
{
__int64 v2; // rbx
__int64 v3; // rdi
__int64 i; // rax

v2 = *(_QWORD *)ptr;
v3 = *(_QWORD *)(*(_QWORD *)ptr + 4LL);
if ( v3 )
{
for ( i = *(_QWORD *)(v3 + 4); i; i = *(_QWORD *)(i + 4) )
{
v2 = *(_QWORD *)(v2 + 4);
v3 = i;
}
free((void *)v3);
*(_QWORD *)(v2 + 4) = 0LL;
}
else
{
puts("List is empty after deletion! ");
free(ptr);
}
}

original_code:
void list_DeleteTail(List* list)
{
 Node* p1 = list->listHead;
 Node* p2 = list->listHead->next;
 if (p2 == ((void *)0)){
  printf("List is empty after deletion! \n");
  free(list);
  return;
 }
 while(p2->next!=((void *)0)){
  p1 = p1->next;
  p2 = p2->next;
 }
 free(p2);
 p1->next = ((void *)0);
}

canonical_original_code:
void list_DeleteTail(struct list *list)
{
 struct node *p1 = list->listHead;
 struct node *p2 = list->listHead->next;
 if (p2 == ((void *)0)){
  printf("List is empty after deletion! \n");
  free(list);
  return;
 }
 while(p2->next!=((void *)0)){
  p1 = p1->next;
  p2 = p2->next;
 }
 free(p2);
 p1->next = ((void *)0);
}


decompiled_code:
void __fastcall list_Delete(void *ptr, __int64 a2)
{
char *v2; // rdi

if ( *(_QWORD *)ptr == a2 )
{
list_DeleteHead(ptr);
}
else if ( a2 == list_GetTail((__int64 *)ptr) )
{
list_DeleteTail(ptr);
}
else
{
v2 = *(char **)(a2 + 4);
*(_DWORD *)a2 = *(_DWORD *)v2;
*(_QWORD *)(a2 + 4) = *(_QWORD *)(v2 + 4);
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func18(void *ptr, __int64 a2)
{
char *v2; // rdi

if ( *(_QWORD *)ptr == a2 )
{
func16(ptr);
}
else if ( a2 == func6((__int64 *)ptr) )
{
func17(ptr);
}
else
{
v2 = *(char **)(a2 + 4);
*(_DWORD *)a2 = *(_DWORD *)v2;
*(_QWORD *)(a2 + 4) = *(_QWORD *)(v2 + 4);
free(v2);
}
}

original_code:
void list_Delete(List* list, Node* node)
{
 if (node == list->listHead){
  list_DeleteHead(list);
  return;
 }
 Node* p = list_GetTail(list);
 if(node == p){
  list_DeleteTail(list);
  return;
 }
 p = node->next;
 node->data = node->next->data;
 node->next = node->next->next;
 free(p);
}

canonical_original_code:
void list_Delete(struct list *list, struct node *node)
{
 if (node == list->listHead){
  list_DeleteHead(list);
  return;
 }
 struct node *p = list_GetTail(list);
 if(node == p){
  list_DeleteTail(list);
  return;
 }
 p = node->next;
 node->data = node->next->data;
 node->next = node->next->next;
 free(p);
}


decompiled_code:
__int64 __fastcall hashList_Add(__int64 *a1, int a2, int a3)
{
_DWORD *v3; // rbx
__int64 result; // rax

v3 = ht_CreateNode(a2, a3);
result = hashList_GetTail(a1);
*(_QWORD *)(result + 8) = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 *a1, int a2, int a3)
{
_DWORD *v3; // rbx
__int64 result; // rax

v3 = ht_CreateNode(a2, a3);
result = func1(a1);
*(_QWORD *)(result + 8) = v3;
return result;
}

original_code:
static void hashList_Add(HashList* hashList, DataType key, DataType value)
{
 HashNode* newNode = ht_CreateNode(key, value);
 HashNode* p = hashList_GetTail(hashList);
 p->next = newNode;
}

canonical_original_code:
static void hashList_Add(struct hash_list *hashList, int key, int value)
{
 struct hash_node *newNode = ht_CreateNode(key, value);
 struct hash_node *p = hashList_GetTail(hashList);
 p->next = newNode;
}

variable_types: struct hash_list { struct hash_node { int key; int value; struct hash_node *next; } *listHead; } *

user_defined_types: struct hash_list { struct hash_node *listHead; }


decompiled_code:
int __fastcall ht_Create(__int64 a1, int a2)
{
void *v2; // rbx
int result; // eax
__int64 i; // rbx
_DWORD *v5; // rdx

v2 = malloc(16LL * a2);
printf("HashTable allocated at %p \n", v2);
result = printf("Size_HashNode %d = size_NodePtr %d + 2*size_Data %d \n", 16LL, 8LL, 8LL);
*(_DWORD *)a1 = a2;
*(_QWORD *)(a1 + 8) = v2;
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; result = printf("Initializing node %d at %p \n", (unsigned int)i++, v5) )
{
v5 = (_DWORD *)(*(_QWORD *)(a1 + 8) + 16 * i);
*((_QWORD *)v5 + 1) = 0LL;
*v5 = 0;
v5[1] = 0;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func20(__int64 a1, int a2)
{
void *v2; // rbx
int result; // eax
__int64 i; // rbx
_DWORD *v5; // rdx

v2 = malloc(16LL * a2);
printf("HashTable allocated at %p \n", v2);
result = printf("Size_HashNode %d = size_NodePtr %d + 2*size_Data %d \n", 16LL, 8LL, 8LL);
*(_DWORD *)a1 = a2;
*(_QWORD *)(a1 + 8) = v2;
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; result = printf("Initializing node %d at %p \n", (unsigned int)i++, v5) )
{
v5 = (_DWORD *)(*(_QWORD *)(a1 + 8) + 16 * i);
*((_QWORD *)v5 + 1) = 0LL;
*v5 = 0;
v5[1] = 0;
}
}
return result;
}

original_code:
void ht_Create(HashTable* hashTable, int hashSize)
{
 int i;
 HashNode* p = malloc(hashSize*sizeof(HashNode));
 printf("HashTable allocated at %p \n", p);
 printf("Size_HashNode %d = size_NodePtr %d + 2*size_Data %d \n",
  sizeof(HashNode), sizeof(HashNode*), 2*sizeof(DataType) );
 hashTable->hashSize = hashSize;
 hashTable->htNodeHead = p;
 for(i = 0; i<hashSize; i++){
  p = (HashNode*)(hashTable->htNodeHead+i);
  p->next = ((void *)0);
  p->key = 0;
  p->value = 0;
  printf("Initializing node %d at %p \n", i, p);
 }
}

canonical_original_code:
void ht_Create(struct hash_table *hashTable, int hashSize)
{
 int i;
 struct hash_node *p = malloc(hashSize*sizeof(HashNode));
 printf("HashTable allocated at %p \n", p);
 printf("Size_HashNode %d = size_NodePtr %d + 2*size_Data %d \n",
  sizeof(HashNode), sizeof(struct hash_node *), 2*sizeof(DataType) );
 hashTable->hashSize = hashSize;
 hashTable->htNodeHead = p;
 for(i = 0; i<hashSize; i++){
  p = (struct hash_node *)(hashTable->htNodeHead+i);
  p->next = ((void *)0);
  p->key = 0;
  p->value = 0;
  printf("Initializing node %d at %p \n", i, p);
 }
}

variable_types: hashSize int

variable_types: struct hash_node { int key; int value; struct hash_node *next; } *


decompiled_code:
int __fastcall ht_Insert(__int64 a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // r12
__int64 *v5; // r13

v4 = (unsigned int)ht_HashFunction((_DWORD *)a1, a2);
v5 = hashList_CreateList(*(_QWORD *)(a1 + 8) + 16 * v4);
hashList_Add(v5, a2, a3);
printf("\nData with <key, val> <%d, %d> is inserted to %dth list. \n", a2, a3, (unsigned int)v4);
return hashList_PrintList((unsigned int **)v5);
}

canonical_decompiled_code:
int __fastcall func21(__int64 a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // r12
__int64 *v5; // r13

v4 = (unsigned int)func0((_DWORD *)a1, a2);
v5 = hashList_CreateList(*(_QWORD *)(a1 + 8) + 16 * v4);
func19(v5, a2, a3);
printf("\nData with <key, val> <%d, %d> is inserted to %dth list. \n", a2, a3, (unsigned int)v4);
return func2((unsigned int **)v5);
}

original_code:
void ht_Insert(HashTable* hashTable, DataType key, DataType value)
{
 unsigned int index = ht_HashFunction(hashTable, key);
 HashNode* p = (hashTable->htNodeHead+index);
 HashList* hashList = hashList_CreateList(p);
 hashList_Add(hashList, key, value);
 printf("\nData with <key, val> <%d, %d> is inserted to %dth list. \n",
                   key, value, index);
 hashList_PrintList(hashList);
}

canonical_original_code:
void ht_Insert(struct hash_table *hashTable, int key, int value)
{
 unsigned int index = ht_HashFunction(hashTable, key);
 struct hash_node *p = (hashTable->htNodeHead+index);
 struct hash_list *hashList = hashList_CreateList(p);
 hashList_Add(hashList, key, value);
 printf("\nData with <key, val> <%d, %d> is inserted to %dth list. \n",
                   key, value, index);
 hashList_PrintList(hashList);
}

user_defined_types: struct hash_node { int key; int value; struct hash_node *next; }


decompiled_code:
__int64 __fastcall ht_Search(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx

v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 16LL * (unsigned int)ht_HashFunction((_DWORD *)a1, a2) + 8);
if ( v2 )
{
while ( *(_DWORD *)v2 != a2 )
{
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
goto LABEL_4;
}
printf("Data with key %d is found with value %d. \n", a2, *(unsigned int *)(v2 + 4));
}
else
{
LABEL_4:
printf("Key %d not found. \n", a2);
v2 = 0LL;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx

v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 16LL * (unsigned int)func0((_DWORD *)a1, a2) + 8);
if ( v2 )
{
while ( *(_DWORD *)v2 != a2 )
{
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
goto LABEL_4;
}
printf("Data with key %d is found with value %d. \n", a2, *(unsigned int *)(v2 + 4));
}
else
{
LABEL_4:
printf("Key %d not found. \n", a2);
v2 = 0LL;
}
return v2;
}

original_code:
HashNode* ht_Search(HashTable* hashTable, DataType key)
{
 unsigned int index = ht_HashFunction(hashTable, key);
 HashNode* p = (hashTable->htNodeHead+index);
 HashNode* result = ((void *)0);
    p = p->next;
    while(p){
        if(p->key==key) {
            result = p;
            break;
        }
        p = p->next;
    }
    if(result)
        printf("Data with key %d is found with value %d. \n",
                   key, result->value);
    else printf("Key %d not found. \n", key);
    return result;
}

canonical_original_code:
struct hash_node *ht_Search(struct hash_table *hashTable, int key)
{
 unsigned int index = ht_HashFunction(hashTable, key);
 struct hash_node *p = (hashTable->htNodeHead+index);
 struct hash_node *result = ((void *)0);
    p = p->next;
    while(p){
        if(p->key==key) {
            result = p;
            break;
        }
        p = p->next;
    }
    if(result)
        printf("Data with key %d is found with value %d. \n",
                   key, result->value);
    else printf("Key %d not found. \n", key);
    return result;
}

variable_types: struct hash_table { int hashSize; struct hash_node *htNodeHead; } *

return_type: struct hash_node { int key; int value; struct hash_node *next; } *


decompiled_code:
__int64 __fastcall ht_Delete(__int64 a1, unsigned int a2)
{
__int64 v3; // rax
_DWORD *v4; // rdi
__int64 result; // rax

v3 = ht_Search(a1, a2);
if ( v3 )
{
v4 = *(_DWORD **)(v3 + 8);
if ( v4 )
{
*(_DWORD *)v3 = *v4;
*(_DWORD *)(v3 + 4) = v4[1];
*(_QWORD *)(v3 + 8) = *((_QWORD *)v4 + 1);
free(v4);
}
else
{
hashList_DeleteTail(a1, a2);
}
printf("Node with key %d deleted.\n", a2);
result = 1LL;
}
else
{
printf("Key %d not found. \n", a2);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1, unsigned int a2)
{
__int64 v3; // rax
_DWORD *v4; // rdi
__int64 result; // rax

v3 = func22(a1, a2);
if ( v3 )
{
v4 = *(_DWORD **)(v3 + 8);
if ( v4 )
{
*(_DWORD *)v3 = *v4;
*(_DWORD *)(v3 + 4) = v4[1];
*(_QWORD *)(v3 + 8) = *((_QWORD *)v4 + 1);
free(v4);
}
else
{
func3(a1, a2);
}
printf("Node with key %d deleted.\n", a2);
result = 1LL;
}
else
{
printf("Key %d not found. \n", a2);
result = 0LL;
}
return result;
}

original_code:
int ht_Delete(HashTable* hashTable, DataType key)
{
 HashNode* p;
    HashNode* q;
    q = ht_Search(hashTable, key);
    if(q) {
     p = q->next;
     if(p){
           q->key = p->key;
           q->value = p->value;
           q->next = p->next;
           free(p);
        } else{
              hashList_DeleteTail(hashTable, key);
        }
        printf("Node with key %d deleted.\n", key);
        return 1;
    } else {
         printf("Key %d not found. \n", key);
         return 0;
    }
}

canonical_original_code:
int ht_Delete(struct hash_table *hashTable, int key)
{
 struct hash_node *p;
    struct hash_node *q;
    q = ht_Search(hashTable, key);
    if(q) {
     p = q->next;
     if(p){
           q->key = p->key;
           q->value = p->value;
           q->next = p->next;
           free(p);
        } else{
              hashList_DeleteTail(hashTable, key);
        }
        printf("Node with key %d deleted.\n", key);
        return 1;
    } else {
         printf("Key %d not found. \n", key);
         return 0;
    }
}

return_type: int


decompiled_code:
int __fastcall ht_PrintTable(__int64 a1, unsigned int a2)
{
unsigned int *v2; // rbx

v2 = (unsigned int *)(*(_QWORD *)(a1 + 8) + 16LL * (unsigned int)ht_HashFunction((_DWORD *)a1, a2));
printf("List correspoding to key %d", a2);
for ( ; v2; v2 = (unsigned int *)*((_QWORD *)v2 + 1) )
printf("-<%d, %d>-", *v2, v2[1]);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func24(__int64 a1, unsigned int a2)
{
unsigned int *v2; // rbx

v2 = (unsigned int *)(*(_QWORD *)(a1 + 8) + 16LL * (unsigned int)func0((_DWORD *)a1, a2));
printf("List correspoding to key %d", a2);
for ( ; v2; v2 = (unsigned int *)*((_QWORD *)v2 + 1) )
printf("-<%d, %d>-", *v2, v2[1]);
return putchar(10);
}

original_code:
void ht_PrintTable(HashTable* hashTable, DataType key)
{
    unsigned int index = ht_HashFunction(hashTable, key);
 HashNode* p = (hashTable->htNodeHead+index);
    printf("List correspoding to key %d", key);
    while(p){
        printf("-<%d, %d>-", p->key, p->value);
        p = p->next;
    }
    printf("\n");
}

canonical_original_code:
void ht_PrintTable(struct hash_table *hashTable, int key)
{
    unsigned int index = ht_HashFunction(hashTable, key);
 struct hash_node *p = (hashTable->htNodeHead+index);
    printf("List correspoding to key %d", key);
    while(p){
        printf("-<%d, %d>-", p->key, p->value);
        p = p->next;
    }
    printf("\n");
}


decompiled_code:
int test_LinkedList()
{
char *v0; // rax
unsigned int **v1; // rbx
char *v2; // rbp
char *v3; // rbp
__int64 v4; // rbp
const void *v5; // rax
__int64 v6; // rsi
__int64 v7; // rax

puts("Linked list implementation test: \n");
v0 = list_CreateNode(0);
v1 = (unsigned int **)list_CreateList((__int64)v0);
printf("New list node created at %p \n", v1);
list_printList(v1);
puts("Inserting new value -1 to head: ");
list_InsertValueToHead((char **)v1, -1);
puts("New list is: ");
list_printList(v1);
v2 = list_CreateNode(-3);
puts("Inserting new node (-3) to head: ");
list_InsertNodeToHead((__int64 *)v1, (__int64)v2);
puts("New list is: ");
list_printList(v1);
puts("Inserting new value 1 to tail: ");
list_InsertValueToTail((__int64 *)v1, 1);
puts("New list is: ");
list_printList(v1);
v3 = list_CreateNode(3);
puts("Inserting new node (3) to tail: ");
list_InsertNodeToTail((__int64 *)v1, (__int64)v3);
puts("New list is: ");
list_printList(v1);
puts("Searching for -1 ... ");
v4 = list_Search((__int64 *)v1, -1);
puts("Insert -2 before -1. ");
list_InsertValueBeforeNode((char **)v1, v4, -2);
puts("New list is: ");
list_printList(v1);
puts("Searching for 2 ... ");
v5 = (const void *)list_Search((__int64 *)v1, 2);
printf(" %p \n", v5);
puts("Insert 2 after 1. ");
v6 = list_Search((__int64 *)v1, 1);
list_InsertValueAfterNode((__int64 *)v1, v6, 2);
puts("New list is: ");
list_printList(v1);
printf("Delete head: ");
list_DeleteHead(v1);
puts("New list is: ");
list_printList(v1);
printf("Delete tail: ");
list_DeleteTail(v1);
puts("New list is: ");
list_printList(v1);
puts("Find 0 and delete ");
v7 = list_Search((__int64 *)v1, 0);
list_Delete(v1, v7);
puts("New list is: ");
return list_printList(v1);
}

canonical_decompiled_code:
int func25()
{
char *v0; // rax
unsigned int **v1; // rbx
char *v2; // rbp
char *v3; // rbp
__int64 v4; // rbp
const void *v5; // rax
__int64 v6; // rsi
__int64 v7; // rax

puts("Linked list implementation test: \n");
v0 = func4(0);
v1 = (unsigned int **)list_CreateList((__int64)v0);
printf("New list node created at %p \n", v1);
func5(v1);
puts("Inserting new value -1 to head: ");
func8((char **)v1, -1);
puts("New list is: ");
func5(v1);
v2 = func4(-3);
puts("Inserting new node (-3) to head: ");
func12((__int64 *)v1, (__int64)v2);
puts("New list is: ");
func5(v1);
puts("Inserting new value 1 to tail: ");
func9((__int64 *)v1, 1);
puts("New list is: ");
func5(v1);
v3 = func4(3);
puts("Inserting new node (3) to tail: ");
func13((__int64 *)v1, (__int64)v3);
puts("New list is: ");
func5(v1);
puts("Searching for -1 ... ");
v4 = func7((__int64 *)v1, -1);
puts("Insert -2 before -1. ");
func10((char **)v1, v4, -2);
puts("New list is: ");
func5(v1);
puts("Searching for 2 ... ");
v5 = (const void *)func7((__int64 *)v1, 2);
printf(" %p \n", v5);
puts("Insert 2 after 1. ");
v6 = func7((__int64 *)v1, 1);
func11((__int64 *)v1, v6, 2);
puts("New list is: ");
func5(v1);
printf("Delete head: ");
func16(v1);
puts("New list is: ");
func5(v1);
printf("Delete tail: ");
func17(v1);
puts("New list is: ");
func5(v1);
puts("Find 0 and delete ");
v7 = func7((__int64 *)v1, 0);
func18(v1, v7);
puts("New list is: ");
return func5(v1);
}

original_code:
void test_LinkedList(void)
{
 printf("Linked list implementation test: \n\n");
 Node* node;
 node = list_CreateNode(0);
 List * list = list_CreateList(node);
 printf("New list node created at %p \n", list);
 list_printList(list);
 printf("Inserting new value -1 to head: \n");
 list_InsertValueToHead(list, -1);
 printf("New list is: \n");
 list_printList(list);
 node = list_CreateNode(-3);
 printf("Inserting new node (-3) to head: \n");
 list_InsertNodeToHead(list, node);
 printf("New list is: \n");
 list_printList(list);
 printf("Inserting new value 1 to tail: \n");
 list_InsertValueToTail(list, 1);
 printf("New list is: \n");
 list_printList(list);
 node = list_CreateNode(3);
 printf("Inserting new node (3) to tail: \n");
 list_InsertNodeToTail(list, node);
 printf("New list is: \n");
 list_printList(list);
 printf("Searching for -1 ... \n");
 node = list_Search(list, -1);
 printf("Insert -2 before -1. \n");
 list_InsertValueBeforeNode(list, node, -2);
 printf("New list is: \n");
 list_printList(list);
 printf("Searching for 2 ... \n");
 printf(" %p \n", list_Search(list, 2));
 printf("Insert 2 after 1. \n");
 node = list_Search(list, 1);
 list_InsertValueAfterNode(list, node, 2);
 printf("New list is: \n");
 list_printList(list);
 printf("Delete head: ");
 list_DeleteHead(list);
 printf("New list is: \n");
 list_printList(list);
 printf("Delete tail: ");
 list_DeleteTail(list);
 printf("New list is: \n");
 list_printList(list);
 printf("Find 0 and delete \n");
 node = list_Search(list, 0);
 list_Delete(list, node);
 printf("New list is: \n");
 list_printList(list);
}

canonical_original_code:
void test_LinkedList()
{
 printf("Linked list implementation test: \n\n");
 struct node *node;
 node = list_CreateNode(0);
 struct list *list = list_CreateList(node);
 printf("New list node created at %p \n", list);
 list_printList(list);
 printf("Inserting new value -1 to head: \n");
 list_InsertValueToHead(list, -1);
 printf("New list is: \n");
 list_printList(list);
 node = list_CreateNode(-3);
 printf("Inserting new node (-3) to head: \n");
 list_InsertNodeToHead(list, node);
 printf("New list is: \n");
 list_printList(list);
 printf("Inserting new value 1 to tail: \n");
 list_InsertValueToTail(list, 1);
 printf("New list is: \n");
 list_printList(list);
 node = list_CreateNode(3);
 printf("Inserting new node (3) to tail: \n");
 list_InsertNodeToTail(list, node);
 printf("New list is: \n");
 list_printList(list);
 printf("Searching for -1 ... \n");
 node = list_Search(list, -1);
 printf("Insert -2 before -1. \n");
 list_InsertValueBeforeNode(list, node, -2);
 printf("New list is: \n");
 list_printList(list);
 printf("Searching for 2 ... \n");
 printf(" %p \n", list_Search(list, 2));
 printf("Insert 2 after 1. \n");
 node = list_Search(list, 1);
 list_InsertValueAfterNode(list, node, 2);
 printf("New list is: \n");
 list_printList(list);
 printf("Delete head: ");
 list_DeleteHead(list);
 printf("New list is: \n");
 list_printList(list);
 printf("Delete tail: ");
 list_DeleteTail(list);
 printf("New list is: \n");
 list_printList(list);
 printf("Find 0 and delete \n");
 node = list_Search(list, 0);
 list_Delete(list, node);
 printf("New list is: \n");
 list_printList(list);
}


canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rbp
__int64 i; // rbx
unsigned int j; // ebx

test_LinkedList();
puts("Hash Table test: ");
printf("Creating Hash Table of size %d \n", 10LL);
v3 = malloc(0x10uLL);
ht_Create((__int64)v3, 10);
for ( i = 0LL; i != 10; ++i )
printf(
"<Key, Val> of node head %d is <%d, %d> \n",
(unsigned int)i,
*(unsigned int *)(v3[1] + 16 * i),
*(unsigned int *)(v3[1] + 16 * i + 4));
for ( j = 0; j != 20; ++j )
ht_Insert((__int64)v3, j, j + 100);
ht_Search((__int64)v3, 0xCu);
ht_Search((__int64)v3, 0x20u);
ht_PrintTable((__int64)v3, 7u);
ht_Delete((__int64)v3, 7u);
ht_PrintTable((__int64)v3, 7u);
ht_PrintTable((__int64)v3, 0x10u);
ht_Delete((__int64)v3, 0x10u);
ht_PrintTable((__int64)v3, 0x10u);
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rbp
__int64 i; // rbx
unsigned int j; // ebx

func25();
puts("Hash Table test: ");
printf("Creating Hash Table of size %d \n", 10LL);
v3 = malloc(0x10uLL);
func20((__int64)v3, 10);
for ( i = 0LL; i != 10; ++i )
printf(
"<Key, Val> of node head %d is <%d, %d> \n",
(unsigned int)i,
*(unsigned int *)(v3[1] + 16 * i),
*(unsigned int *)(v3[1] + 16 * i + 4));
for ( j = 0; j != 20; ++j )
func21((__int64)v3, j, j + 100);
func22((__int64)v3, 0xCu);
func22((__int64)v3, 0x20u);
func24((__int64)v3, 7u);
func23((__int64)v3, 7u);
func24((__int64)v3, 7u);
func24((__int64)v3, 0x10u);
func23((__int64)v3, 0x10u);
func24((__int64)v3, 0x10u);
return 1;
}

original_code:
int main()
{
 test_LinkedList();
 printf("Hash Table test: \n");
 int i = 0;
 int hashSize = 10;
 printf("Creating Hash Table of size %d \n", hashSize);
 HashTable* hashTable = malloc(sizeof(HashTable));
 ht_Create(hashTable, hashSize);
 for (i=0; i<hashSize; i++){
  printf("<Key, Val> of node head %d is <%d, %d> \n", i,
   (hashTable->htNodeHead+i)->key,
   (hashTable->htNodeHead+i)->value);
 }
 for (i=0; i<hashSize*2; i++){
  ht_Insert(hashTable, i, 100+i);
 }
 ht_Search(hashTable, 12);
 ht_Search(hashTable, 32);
    ht_PrintTable(hashTable, 7);
 ht_Delete(hashTable, 7);
    ht_PrintTable(hashTable, 7);
    ht_PrintTable(hashTable, 16);
 ht_Delete(hashTable, 16);
    ht_PrintTable(hashTable, 16);
 return 1;
}

canonical_original_code:
int main()
{
 test_LinkedList();
 printf("Hash Table test: \n");
 int i = 0;
 int hashSize = 10;
 printf("Creating Hash Table of size %d \n", hashSize);
 struct hash_table *hashTable = malloc(sizeof(HashTable));
 ht_Create(hashTable, hashSize);
 for (i=0; i<hashSize; i++){
  printf("<Key, Val> of node head %d is <%d, %d> \n", i,
   (hashTable->htNodeHead+i)->key,
   (hashTable->htNodeHead+i)->value);
 }
 for (i=0; i<hashSize*2; i++){
  ht_Insert(hashTable, i, 100+i);
 }
 ht_Search(hashTable, 12);
 ht_Search(hashTable, 32);
    ht_PrintTable(hashTable, 7);
 ht_Delete(hashTable, 7);
    ht_PrintTable(hashTable, 7);
    ht_PrintTable(hashTable, 16);
 ht_Delete(hashTable, 16);
    ht_PrintTable(hashTable, 16);
 return 1;
}


repo: fredericmarchand/CommandLineChat

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
size_t v3; // rax
__int64 v4; // rcx
char v6[124]; // [rsp+0h] [rbp-B8h] BYREF
char n[12]; // [rsp+7Ch] [rbp-3Ch] BYREF
int fd; // [rsp+88h] [rbp-30h] BYREF
char v9[6]; // [rsp+8Ch] [rbp-2Ch] BYREF
char dest[38]; // [rsp+92h] [rbp-26h] BYREF

if ( argc > 1 )
{
strcpy(dest, argv[1]);
*(_DWORD *)n = 120;
puts("\n\nWelcome!\nYou are a Client.\nWaiting for connection...\n");
establishConnection(&fd, dest, 62210LL);
}
else
{
*(_DWORD *)n = 120;
puts("\n\nWelcome!\nYou are a Server.\nWaiting for connection...\n");
setupConnection(v9, &fd, 62210LL);
}
if ( fork() )
{
while ( 1 )
{
memset(v6, 0, 0x78uLL);
*(_QWORD *)&n[4] = malloc(4uLL);
getline((char **)&n[4], (size_t *)n, _bss_start);
strcpy(v6, *(const char **)&n[4]);
v3 = strlen(v6);
send(fd, v6, v3, 0);
v4 = *(_QWORD *)&n[4];
**(_QWORD **)&n[4] = 0LL;
*(_QWORD *)(v4 + 112) = 0LL;
memset(
(void *)((v4 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v4 - (((_DWORD)v4 + 8) & 0xFFFFFFF8) + 120) >> 3));
free(*(void **)&n[4]);
}
}
while ( 1 )
{
memset(v6, 0, 0x78uLL);
recv(fd, v6, 0x78uLL, 0);
if ( !strcmp(v6, "exit") )
break;
printf("\nReceived: %s\n", v6);
}
puts("\nYour chat partner has exited the conversation");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
size_t v3; // rax
__int64 v4; // rcx
char v6[124]; // [rsp+0h] [rbp-B8h] BYREF
char n[12]; // [rsp+7Ch] [rbp-3Ch] BYREF
int fd; // [rsp+88h] [rbp-30h] BYREF
char v9[6]; // [rsp+8Ch] [rbp-2Ch] BYREF
char dest[38]; // [rsp+92h] [rbp-26h] BYREF

if ( argc > 1 )
{
strcpy(dest, argv[1]);
*(_DWORD *)n = 120;
puts("\n\nWelcome!\nYou are a Client.\nWaiting for connection...\n");
func11(&fd, dest, 62210LL);
}
else
{
*(_DWORD *)n = 120;
puts("\n\nWelcome!\nYou are a Server.\nWaiting for connection...\n");
func9(v9, &fd, 62210LL);
}
if ( fork() )
{
while ( 1 )
{
memset(v6, 0, 0x78uLL);
*(_QWORD *)&n[4] = malloc(4uLL);
getline((char **)&n[4], (size_t *)n, _bss_start);
strcpy(v6, *(const char **)&n[4]);
v3 = strlen(v6);
send(fd, v6, v3, 0);
v4 = *(_QWORD *)&n[4];
**(_QWORD **)&n[4] = 0LL;
*(_QWORD *)(v4 + 112) = 0LL;
memset(
(void *)((v4 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v4 - (((_DWORD)v4 + 8) & 0xFFFFFFF8) + 120) >> 3));
free(*(void **)&n[4]);
}
}
while ( 1 )
{
memset(v6, 0, 0x78uLL);
recv(fd, v6, 0x78uLL, 0);
if ( !strcmp(v6, "exit") )
break;
printf("\nReceived: %s\n", v6);
}
puts("\nYour chat partner has exited the conversation");
return 0;
}

original_code:
int main (int argc, char * argv[]){
    char SERVER_IP[14];
    if (argc>1)
        strcpy(SERVER_IP, argv[1]);
    int myPort = 62210;
    int cors;
    int myListenSocket, clientSocket;
    int bytesRcv;
    char * inStr;
    int p = 120;
    char buffer[120];
    if (argc > 1) {
        printf("\n\nWelcome!\nYou are a Client.\nWaiting for connection...\n\n");
        establishConnection(&clientSocket, SERVER_IP, myPort);
        cors = 0;
    }
    else {
        printf("\n\nWelcome!\nYou are a Server.\nWaiting for connection...\n\n");
        setupConnection(&myListenSocket, &clientSocket, myPort);
        cors = 1;
    }
    int i;
    i = fork();
    if(i == 0) {
        while (1) {
            memset(buffer, '\0', sizeof(buffer));
            bytesRcv = recv(clientSocket, buffer, sizeof(buffer), 0);
            if(strcmp (buffer, "exit") == 0) {
                    printf("\nYour chat partner has exited the conversation\n");
                    break;
            }
            printf("\nReceived: %s\n", buffer);
            memset(buffer, '\0', sizeof(buffer));
        }
    }
    else {
        while (1) {
            memset(buffer, '\0', sizeof(buffer));
            inStr = (char*)malloc(sizeof(p));
            getline(&inStr, &p, stdin);
            strcpy(buffer, inStr);
            send(clientSocket, buffer, strlen(buffer), 0);
            memset(buffer, '\0', sizeof(buffer));
            memset(inStr, '\0', sizeof(buffer));
            free(inStr);
        }
    }
}

canonical_original_code:
int main(int argc, char *argv[]){
    char SERVER_IP[14];
    if (argc>1)
        strcpy(SERVER_IP, argv[1]);
    int myPort = 62210;
    int cors;
    int myListenSocket; int clientSocket;
    int bytesRcv;
    char *inStr;
    int p = 120;
    char buffer[120];
    if (argc > 1) {
        printf("\n\nWelcome!\nYou are a Client.\nWaiting for connection...\n\n");
        establishConnection(&clientSocket, SERVER_IP, myPort);
        cors = 0;
    }
    else {
        printf("\n\nWelcome!\nYou are a Server.\nWaiting for connection...\n\n");
        setupConnection(&myListenSocket, &clientSocket, myPort);
        cors = 1;
    }
    int i;
    i = fork();
    if(i == 0) {
        while (1) {
            memset(buffer, '\0', sizeof(buffer));
            bytesRcv = recv(clientSocket, buffer, sizeof(buffer), 0);
            if(strcmp (buffer, "exit") == 0) {
                    printf("\nYour chat partner has exited the conversation\n");
                    break;
            }
            printf("\nReceived: %s\n", buffer);
            memset(buffer, '\0', sizeof(buffer));
        }
    }
    else {
        while (1) {
            memset(buffer, '\0', sizeof(buffer));
            inStr = (char *)malloc(sizeof(p));
            getline(&inStr, &p, stdin);
            strcpy(buffer, inStr);
            send(clientSocket, buffer, strlen(buffer), 0);
            memset(buffer, '\0', sizeof(buffer));
            memset(inStr, '\0', sizeof(buffer));
            free(inStr);
        }
    }
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: myPort int

variable_types: cors int

variable_types: myListenSocket int

variable_types: clientSocket int

variable_types: bytesRcv int

variable_types:
inStr
char *

variable_types: p int

variable_types:
buffer
char [120]


setupConnection

decompiled_code:
int __fastcall setupConnection(int *a1, int *a2, __int16 a3)
{
int v4; // eax
int v5; // ebx
int result; // eax
socklen_t addr_len; // [rsp+Ch] [rbp-4Ch] BYREF
struct sockaddr v8; // [rsp+10h] [rbp-48h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-38h] BYREF

v4 = socket(2, 1, 6);
*a1 = v4;
if ( v4 < 0 )
{
puts("Couldn't open socket");
exit(-1);
}
v5 = v4;
*(_DWORD *)&addr.sa_data[10] = 0;
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[2] = (unsigned int)_bswap_32(0);
*(_WORD *)addr.sa_data = _bswap_16(a3);
if ( bind(v5, &addr, 0x10u) < 0 )
{
puts("Couldn't bind socket");
exit(-1);
}
if ( listen(*a1, 5) < 0 )
{
puts("Couldn't listen");
exit(-1);
}
addr_len = 16;
result = accept(*a1, &v8, &addr_len);
*a2 = result;
if ( result < 0 )
{
puts("Couldn't accept the connection");
exit(-1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(int *a1, int *a2, __int16 a3)
{
int v4; // eax
int v5; // ebx
int result; // eax
socklen_t addr_len; // [rsp+Ch] [rbp-4Ch] BYREF
struct sockaddr v8; // [rsp+10h] [rbp-48h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-38h] BYREF

v4 = socket(2, 1, 6);
*a1 = v4;
if ( v4 < 0 )
{
puts("Couldn't open socket");
exit(-1);
}
v5 = v4;
*(_DWORD *)&addr.sa_data[10] = 0;
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[2] = (unsigned int)func7(0);
*(_WORD *)addr.sa_data = func8(a3);
if ( bind(v5, &addr, 0x10u) < 0 )
{
puts("Couldn't bind socket");
exit(-1);
}
if ( listen(*a1, 5) < 0 )
{
puts("Couldn't listen");
exit(-1);
}
addr_len = 16;
result = accept(*a1, &v8, &addr_len);
*a2 = result;
if ( result < 0 )
{
puts("Couldn't accept the connection");
exit(-1);
}
return result;
}

original_code:
void setupConnection(int *myListenSocket, int *clientSocket, int myPort){
    struct sockaddr_in myAddr, clientAddr;
    int i, addrSize;
    *myListenSocket = socket(2, SOCK_STREAM, IPPROTO_TCP);
    if (*myListenSocket < 0) {
        printf("Couldn't open socket\n");
        exit(-1);
    }
    memset(&myAddr, 0, sizeof(myAddr));
    myAddr.sin_family = 2;
    myAddr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
    myAddr.sin_port = htons((unsigned short) myPort);
    i = bind(*myListenSocket,
             (struct sockaddr *) &myAddr,
             sizeof(myAddr));
    if (i < 0) {
        printf("Couldn't bind socket\n");
        exit(-1);
    }
    i = listen(*myListenSocket, 5);
    if (i < 0) {
        printf("Couldn't listen\n");
        exit(-1);
    }
    addrSize = sizeof(clientAddr);
    *clientSocket = accept(*myListenSocket,
                          (struct sockaddr *) &clientAddr,
                          &addrSize);
    if (*clientSocket < 0) {
        printf("Couldn't accept the connection\n");
        exit(-1);
    }
}

canonical_original_code:
void setupConnection(int *myListenSocket, int *clientSocket, int myPort){
    struct sockaddr_in myAddr; struct sockaddr_in clientAddr;
    int i; int addrSize;
    *myListenSocket = socket(2, SOCK_STREAM, IPPROTO_TCP);
    if (*myListenSocket < 0) {
        printf("Couldn't open socket\n");
        exit(-1);
    }
    memset(&myAddr, 0, sizeof(myAddr));
    myAddr.sin_family = 2;
    myAddr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
    myAddr.sin_port = htons((unsigned short) myPort);
    i = bind(*myListenSocket,
             (struct sockaddr *) &myAddr,
             sizeof(myAddr));
    if (i < 0) {
        printf("Couldn't bind socket\n");
        exit(-1);
    }
    i = listen(*myListenSocket, 5);
    if (i < 0) {
        printf("Couldn't listen\n");
        exit(-1);
    }
    addrSize = sizeof(clientAddr);
    *clientSocket = accept(*myListenSocket,
                          (struct sockaddr *) &clientAddr,
                          &addrSize);
    if (*clientSocket < 0) {
        printf("Couldn't accept the connection\n");
        exit(-1);
    }
}

variable_types:
myListenSocket
int *

variable_types:
clientSocket
int *

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types: i int

variable_types: addrSize int

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


establishConnection

decompiled_code:
int __fastcall establishConnection(int *a1, const char *a2, __int16 a3)
{
int v4; // eax
int result; // eax
struct sockaddr v6; // [rsp+0h] [rbp-28h] BYREF

v4 = socket(2, 1, 6);
*a1 = v4;
if ( v4 < 0 )
{
puts("Couldn't open socket");
exit(-1);
}
v6.sa_family = 2;
*(_QWORD *)&v6.sa_data[6] = 0LL;
*(_DWORD *)&v6.sa_data[2] = inet_addr(a2);
*(_WORD *)v6.sa_data = _bswap_16_0(a3);
result = connect(*a1, &v6, 0x10u);
if ( result < 0 )
{
puts("Client could not connect!");
exit(-1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func11(int *a1, const char *a2, __int16 a3)
{
int v4; // eax
int result; // eax
struct sockaddr v6; // [rsp+0h] [rbp-28h] BYREF

v4 = socket(2, 1, 6);
*a1 = v4;
if ( v4 < 0 )
{
puts("Couldn't open socket");
exit(-1);
}
v6.sa_family = 2;
*(_QWORD *)&v6.sa_data[6] = 0LL;
*(_DWORD *)&v6.sa_data[2] = inet_addr(a2);
*(_WORD *)v6.sa_data = func10(a3);
result = connect(*a1, &v6, 0x10u);
if ( result < 0 )
{
puts("Client could not connect!");
exit(-1);
}
return result;
}

original_code:
void establishConnection(int *mySocket, char* SERVER_IP, int myPort){
    struct sockaddr_in addr;
    int i;
    *mySocket = socket(2, SOCK_STREAM, IPPROTO_TCP);
    if (*mySocket < 0) {
        printf("Couldn't open socket\n");
        exit(-1);
    }
    memset(&addr, 0, sizeof(addr));
    addr.sin_family = 2;
    addr.sin_addr.s_addr = inet_addr(SERVER_IP);
    addr.sin_port = htons((unsigned short) myPort);
    i = connect(*mySocket,
                (struct sockaddr *) &addr,
                sizeof(addr));
    if (i<0) {
        printf("Client could not connect!\n");
        exit(-1);
    }
}

canonical_original_code:
void establishConnection(int *mySocket, char *SERVER_IP, int myPort){
    struct sockaddr_in addr;
    int i;
    *mySocket = socket(2, SOCK_STREAM, IPPROTO_TCP);
    if (*mySocket < 0) {
        printf("Couldn't open socket\n");
        exit(-1);
    }
    memset(&addr, 0, sizeof(addr));
    addr.sin_family = 2;
    addr.sin_addr.s_addr = inet_addr(SERVER_IP);
    addr.sin_port = htons((unsigned short) myPort);
    i = connect(*mySocket,
                (struct sockaddr *) &addr,
                sizeof(addr));
    if (i<0) {
        printf("Client could not connect!\n");
        exit(-1);
    }
}

variable_types:
mySocket
int *


checkLetter

decompiled_code:
__int64 __fastcall checkLetter(const char *a1, const char *a2, int a3)
{
size_t v5; // rax
unsigned int v6; // edx
size_t v8; // rsi
const char *v9; // rax
const char *v10; // rbp

v5 = strlen(a1);
if ( v5 == 1 )
{
v8 = strlen(a2);
v9 = a2;
v10 = &a2[v8];
while ( v9 != v10 )
{
if ( *a1 == *v9++ )
{
puts("This letter has already been checked");
return (unsigned int)-1;
}
}
v6 = 0;
}
else
{
v6 = 1;
if ( v5 <= 1 )
{
a2[a3] = *a1;
v6 = 0;
}
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func12(const char *a1, const char *a2, int a3)
{
size_t v5; // rax
unsigned int v6; // edx
size_t v8; // rsi
const char *v9; // rax
const char *v10; // rbp

v5 = strlen(a1);
if ( v5 == 1 )
{
v8 = strlen(a2);
v9 = a2;
v10 = &a2[v8];
while ( v9 != v10 )
{
if ( *a1 == *v9++ )
{
puts("This letter has already been checked");
return (unsigned int)-1;
}
}
v6 = 0;
}
else
{
v6 = 1;
if ( v5 <= 1 )
{
a2[a3] = *a1;
v6 = 0;
}
}
return v6;
}

original_code:
int checkLetter(char *letter, char *checkedLetters, int position){
    int r=0;
    if(strlen(letter)==1){
        int i;
        for (i=0; i<strlen(checkedLetters); i++){
            if(letter[0] == checkedLetters[i]){
                printf("This letter has already been checked\n");
                r = (-1);
                break;
            }
        }
    }
    else if(strlen(letter)>1){
        r=1;
    }
    else{
        checkedLetters[position] = letter[0];
    }
    return(r);
}

canonical_original_code:
int checkLetter(char *letter, char *checkedLetters, int position){
    int r = 0;
    if(strlen(letter)==1){
        int i;
        for (i=0; i<strlen(checkedLetters); i++){
            if(letter[0] == checkedLetters[i]){
                printf("This letter has already been checked\n");
                r = (-1);
                break;
            }
        }
    }
    else if(strlen(letter)>1){
        r=1;
    }
    else{
        checkedLetters[position] = letter[0];
    }
    return(r);
}

variable_types:
letter
char *

variable_types:
checkedLetters
char *

variable_types: position int

variable_types: r int


repo: fredericmarchand/WebsitePingerDaemon

decompiled_code:
void daemon_setup()
{
__pid_t v0; // eax
__pid_t v1; // eax
int v2; // ebx

v0 = fork();
if ( v0 < 0 )
exit(1);
if ( v0 > 0 )
exit(0);
if ( setsid() < 0 )
exit(1);
signal(17, (__sighandler_t)1);
signal(1, (__sighandler_t)1);
v1 = fork();
if ( v1 < 0 )
exit(1);
if ( v1 > 0 )
exit(0);
umask(0);
chdir("/home/4user4/fredericmarchand/websitePinger/");
v2 = sysconf(4);
if ( v2 > 0 )
{
do
close(v2--);
while ( v2 );
}
openlog("firstdaemon", 1, 24);
}

canonical_decompiled_code:
void func7()
{
__pid_t v0; // eax
__pid_t v1; // eax
int v2; // ebx

v0 = fork();
if ( v0 < 0 )
exit(1);
if ( v0 > 0 )
exit(0);
if ( setsid() < 0 )
exit(1);
signal(17, (__sighandler_t)1);
signal(1, (__sighandler_t)1);
v1 = fork();
if ( v1 < 0 )
exit(1);
if ( v1 > 0 )
exit(0);
umask(0);
chdir("/home/4user4/fredericmarchand/websitePinger/");
v2 = sysconf(4);
if ( v2 > 0 )
{
do
close(v2--);
while ( v2 );
}
openlog("firstdaemon", 1, 24);
}

original_code:
static void daemon_setup()
{
  pid_t pid;
  pid = fork();
  if (pid < 0)
    exit(1);
  if (pid > 0)
    exit(0);
  if (setsid() < 0)
    exit(1);
  signal(17, ((__sighandler_t) 1));
  signal(1, ((__sighandler_t) 1));
  pid = fork();
  if (pid < 0)
    exit(1);
  if (pid > 0)
    exit(0);
  umask(0);
  chdir("/home/4user4/fredericmarchand/websitePinger/");
  int x;
  for (x = sysconf(_SC_OPEN_MAX); x>0; x--)
  {
    close (x);
  }
  openlog ("firstdaemon", 0x01, (3<<3));
}

canonical_original_code:
static void daemon_setup()
{
  int pid;
  pid = fork();
  if (pid < 0)
    exit(1);
  if (pid > 0)
    exit(0);
  if (setsid() < 0)
    exit(1);
  signal(17, ((void (*)(int)) 1));
  signal(1, ((void (*)(int)) 1));
  pid = fork();
  if (pid < 0)
    exit(1);
  if (pid > 0)
    exit(0);
  umask(0);
  chdir("/home/4user4/fredericmarchand/websitePinger/");
  int x;
  for (x = sysconf(_SC_OPEN_MAX); x>0; x--)
  {
    close (x);
  }
  openlog ("firstdaemon", 0x01, (3<<3));
}

variable_types: pid int

variable_types: x int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
daemon_setup();
while ( 1 )
{
system("/home/4user4/fredericmarchand/websitePinger/websitePinger.sh");
sleep(0x3Cu);
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
func7();
while ( 1 )
{
system("/home/4user4/fredericmarchand/websitePinger/websitePinger.sh");
sleep(0x3Cu);
}
}

original_code:
int main()
{
  daemon_setup();
  while (1)
  {
    system("/home/4user4/fredericmarchand/websitePinger/websitePinger.sh");
    sleep (60);
  }
  closelog();
  return 0;
}


repo: fredokun/libpiccolort

decompiled_code:
void __fastcall PICC_free_knownset(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 1));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 1));
free(ptr);
}
}

original_code:
void PICC_free_knownset(PICC_KnownSet *knownset)
{
    if (knownset != ((void *)0)) {
        free(knownset->content);
        free(knownset);
    }
}

canonical_original_code:
void PICC_free_knownset(struct _PICC_KnownSet *knownset)
{
    if (knownset != ((void *)0)) {
        free(knownset->content);
        free(knownset);
    }
}

variable_types: struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement { enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 } state; struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle { int global_rc; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *error); } *handle; } value; } *content; } *

user_defined_types: struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement *content; }

user_defined_types: struct _PICC_KnownElement { enum _PICC_KnownState state; struct _PICC_KnownValue value; }

user_defined_types: struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle *handle; }

user_defined_types: struct _PICC_Handle { int global_rc; union pthread_mutex_t *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error *error); }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct _PICC_Error { enum _PICC_ErrorId id; char *file; int line; struct _PICC_Error *prev; }


decompiled_code:
void __fastcall PICC_KnownSet_inv(int *a1)
{
int v1; // eax

if ( a1 )
{
v1 = a1[1];
if ( v1 < 0 )
_assert_fail("0 <= set->current_size", "src/knownset.c", 0x1F7u, "PICC_KnownSet_inv");
if ( v1 > *a1 )
_assert_fail("set->current_size <= set->max_size", "src/knownset.c", 0x1F8u, "PICC_KnownSet_inv");
}
}

canonical_decompiled_code:
void __fastcall func1(int *a1)
{
int v1; // eax

if ( a1 )
{
v1 = a1[1];
if ( v1 < 0 )
_assert_fail("0 <= set->current_size", "src/knownset.c", 0x1F7u, "PICC_KnownSet_inv");
if ( v1 > *a1 )
_assert_fail("set->current_size <= set->max_size", "src/knownset.c", 0x1F8u, "PICC_KnownSet_inv");
}
}

original_code:
void PICC_KnownSet_inv(PICC_KnownSet *set)
{
    if (set) {
        ((0 <= set->current_size) ? (void) (0) : __assert_fail ("0 <= set->current_size", "src/knownset.c", 503, __extension__ __PRETTY_FUNCTION__));;
        ((set->current_size <= set->max_size) ? (void) (0) : __assert_fail ("set->current_size <= set->max_size", "src/knownset.c", 504, __extension__ __PRETTY_FUNCTION__));
    }
}

canonical_original_code:
void PICC_KnownSet_inv(struct _PICC_KnownSet *set)
{
    if (set) {
        ((0 <= set->current_size) ? (void) (0) : __assert_fail ("0 <= set->current_size", "src/knownset.c", 503, __extension__ __PRETTY_FUNCTION__));;
        ((set->current_size <= set->max_size) ? (void) (0) : __assert_fail ("set->current_size <= set->max_size", "src/knownset.c", 504, __extension__ __PRETTY_FUNCTION__));
    }
}

user_defined_types: enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

user_defined_types: enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 }


decompiled_code:
int *PICC_create_empty_knownset()
{
int *v0; // rbx
int v2; // [rsp+0h] [rbp-28h] BYREF
__int64 v3; // [rsp+8h] [rbp-20h]
int v4; // [rsp+10h] [rbp-18h]
__int64 v5; // [rsp+18h] [rbp-10h]

v2 = 0;
v3 = 0LL;
v4 = 0;
v5 = 0LL;
v0 = PICC_create_knownset(10, (__int64)&v2);
if ( v2 )
PICC_crash(&v2, "src/knownset.c", "PICC_create_empty_knownset");
PICC_KnownSet_inv(v0);
return v0;
}

canonical_decompiled_code:
int *func2()
{
int *v0; // rbx
int v2; // [rsp+0h] [rbp-28h] BYREF
__int64 v3; // [rsp+8h] [rbp-20h]
int v4; // [rsp+10h] [rbp-18h]
__int64 v5; // [rsp+18h] [rbp-10h]

v2 = 0;
v3 = 0LL;
v4 = 0;
v5 = 0LL;
v0 = PICC_create_knownset(10, (__int64)&v2);
if ( v2 )
PICC_crash(&v2, "src/knownset.c", "PICC_create_empty_knownset");
func1(v0);
return v0;
}

original_code:
PICC_KnownSet *PICC_create_empty_knownset()
{
    PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)};
    PICC_KnownSet *set = PICC_create_knownset(10, &error);
    if (error.id > 0)
        PICC_crash(&error, "src/knownset.c", __FUNCTION__);
        PICC_KnownSet_inv(set);
    return set;
}

canonical_original_code:
struct _PICC_KnownSet *PICC_create_empty_knownset()
{
    struct _PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)};
    struct _PICC_KnownSet *set = PICC_create_knownset(10, &error);
    if (error.id > 0)
        PICC_crash(&error, "src/knownset.c", __FUNCTION__);
        PICC_KnownSet_inv(set);
    return set;
}

return_type: struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement { enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 } state; struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle { int global_rc; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *error); } *handle; } value; } *content; } *


decompiled_code:
__int64 __fastcall PICC_knownset_size(__int64 a1)
{
PICC_KnownSet_inv((int *)a1);
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
func1((int *)a1);
return *(unsigned int *)(a1 + 4);
}

original_code:
int PICC_knownset_size(PICC_KnownSet *knownset)
{
        PICC_KnownSet_inv(knownset);
    return knownset->current_size;
}

canonical_original_code:
int PICC_knownset_size(struct _PICC_KnownSet *knownset)
{
        PICC_KnownSet_inv(knownset);
    return knownset->current_size;
}


decompiled_code:
void __fastcall PICC_knownset_forget_all(__int64 a1)
{
_DWORD *v1; // rax
__int64 v2; // rcx
int i; // edx

PICC_KnownSet_inv((int *)a1);
if ( !a1 )
_assert_fail("ks != ((void *)0)", "src/knownset.c", 0x1DDu, "PICC_knownset_forget_all");
if ( *(int *)(a1 + 4) > 0 )
{
v1 = *(_DWORD **)(a1 + 8);
v2 = 24LL;
for ( i = 0; v1; v2 += 24LL )
{
if ( *v1 == 1 )
*v1 = 2;
if ( *(_DWORD *)(a1 + 4) <= ++i )
break;
v1 = (_DWORD *)(*(_QWORD *)(a1 + 8) + v2);
}
}
PICC_KnownSet_inv((int *)a1);
}

original_code:
void PICC_knownset_forget_all(PICC_KnownSet *ks)
{
        PICC_KnownSet_inv(ks);
        ((ks != ((void *)0)) ? (void) (0) : __assert_fail ("ks != ((void *)0)", "src/knownset.c", 477, __extension__ __PRETTY_FUNCTION__));;
    PICC_KnownElement *elem;
    for(int i = 0; i < (ks)->current_size && (elem = &((ks)->content[i])); i++) {
        if (elem->state == PICC_KNOWN)
         elem->state = PICC_FORGET;
    }
        PICC_KnownSet_inv(ks);
}

canonical_original_code:
void PICC_knownset_forget_all(struct _PICC_KnownSet *ks)
{
        PICC_KnownSet_inv(ks);
        ((ks != ((void *)0)) ? (void) (0) : __assert_fail ("ks != ((void *)0)", "src/knownset.c", 477, __extension__ __PRETTY_FUNCTION__));;
    struct _PICC_KnownElement *elem;
    for(int i = 0; i < (ks)->current_size && (elem = &((ks)->content[i])); i++) {
        if (elem->state == PICC_KNOWN)
         elem->state = PICC_FORGET;
    }
        PICC_KnownSet_inv(ks);
}

variable_types: struct _PICC_KnownElement { enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 } state; struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle { int global_rc; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *error); } *handle; } value; } *


decompiled_code:
void PICC_KnownElement_inv()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void PICC_KnownElement_inv(PICC_KnownElement *elem)
{
}

canonical_original_code:
void PICC_KnownElement_inv(struct _PICC_KnownElement *elem)
{
}


decompiled_code:
void __fastcall PICC_KnownValue_inv(__int64 a1)
{
if ( !a1 )
_assert_fail("val != ((void *)0)", "src/knownset.c", 0x202u, "PICC_KnownValue_inv");
if ( !*(_QWORD *)(a1 + 8) )
_assert_fail("val->handle != ((void *)0)", "src/knownset.c", 0x203u, "PICC_KnownValue_inv");
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
if ( !a1 )
_assert_fail("val != ((void *)0)", "src/knownset.c", 0x202u, "PICC_KnownValue_inv");
if ( !*(_QWORD *)(a1 + 8) )
_assert_fail("val->handle != ((void *)0)", "src/knownset.c", 0x203u, "PICC_KnownValue_inv");
}

original_code:
void PICC_KnownValue_inv(PICC_KnownValue *val)
{
    ((val != ((void *)0)) ? (void) (0) : __assert_fail ("val != ((void *)0)", "src/knownset.c", 514, __extension__ __PRETTY_FUNCTION__));;
    ((val->handle != ((void *)0)) ? (void) (0) : __assert_fail ("val->handle != ((void *)0)", "src/knownset.c", 515, __extension__ __PRETTY_FUNCTION__));;
}

canonical_original_code:
void PICC_KnownValue_inv(struct _PICC_KnownValue *val)
{
    ((val != ((void *)0)) ? (void) (0) : __assert_fail ("val != ((void *)0)", "src/knownset.c", 514, __extension__ __PRETTY_FUNCTION__));;
    ((val->handle != ((void *)0)) ? (void) (0) : __assert_fail ("val->handle != ((void *)0)", "src/knownset.c", 515, __extension__ __PRETTY_FUNCTION__));;
}

variable_types: struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle { int global_rc; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *error); } *handle; } *


decompiled_code:
__int64 __fastcall PICC_knownset_get_element(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rbx
__int64 v4; // rdx
__int64 v5; // rcx

PICC_KnownSet_inv((int *)a1);
PICC_KnownValue_inv(a2);
if ( !a1 )
_assert_fail("knownset != ((void *)0)", "src/knownset.c", 0x8Eu, "PICC_knownset_get_element");
if ( !a2 )
_assert_fail("val != ((void *)0)", "src/knownset.c", 0x8Fu, "PICC_knownset_get_element");
v2 = *(_DWORD *)(a1 + 4);
if ( v2 <= 0 )
{
v3 = 0LL;
}
else
{
v3 = *(_QWORD *)(a1 + 8);
if ( v3 )
{
v4 = *(_QWORD *)(a2 + 8);
v5 = v3 + 24LL * (unsigned int)(v2 - 1);
while ( *(_QWORD *)(v3 + 16) != v4 )
{
if ( v5 == v3 )
{
v3 = 0LL;
goto LABEL_17;
}
if ( v3 == -24 )
{
v3 = 0LL;
goto LABEL_17;
}
v3 += 24LL;
}
if ( v4 != *(_QWORD *)(v3 + 16) )
_assert_fail("elem->value.handle == val->handle", "src/knownset.c", 0xA0u, "PICC_knownset_get_element");
}
}
LABEL_17:
PICC_KnownSet_inv((int *)a1);
PICC_KnownValue_inv(a2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rbx
__int64 v4; // rdx
__int64 v5; // rcx

func1((int *)a1);
func6(a2);
if ( !a1 )
_assert_fail("knownset != ((void *)0)", "src/knownset.c", 0x8Eu, "PICC_knownset_get_element");
if ( !a2 )
_assert_fail("val != ((void *)0)", "src/knownset.c", 0x8Fu, "PICC_knownset_get_element");
v2 = *(_DWORD *)(a1 + 4);
if ( v2 <= 0 )
{
v3 = 0LL;
}
else
{
v3 = *(_QWORD *)(a1 + 8);
if ( v3 )
{
v4 = *(_QWORD *)(a2 + 8);
v5 = v3 + 24LL * (unsigned int)(v2 - 1);
while ( *(_QWORD *)(v3 + 16) != v4 )
{
if ( v5 == v3 )
{
v3 = 0LL;
goto LABEL_17;
}
if ( v3 == -24 )
{
v3 = 0LL;
goto LABEL_17;
}
v3 += 24LL;
}
if ( v4 != *(_QWORD *)(v3 + 16) )
_assert_fail("elem->value.handle == val->handle", "src/knownset.c", 0xA0u, "PICC_knownset_get_element");
}
}
LABEL_17:
func1((int *)a1);
func6(a2);
return v3;
}

original_code:
PICC_KnownElement *PICC_knownset_get_element(PICC_KnownSet *knownset, PICC_KnownValue *val)
{
        PICC_KnownSet_inv(knownset);
        PICC_KnownValue_inv(val);
        ((knownset != ((void *)0)) ? (void) (0) : __assert_fail ("knownset != ((void *)0)", "src/knownset.c", 142, __extension__ __PRETTY_FUNCTION__));;
        ((val != ((void *)0)) ? (void) (0) : __assert_fail ("val != ((void *)0)", "src/knownset.c", 143, __extension__ __PRETTY_FUNCTION__));;
    PICC_KnownElement *elem;
    _Bool found = 0;
    for(int i = 0; i < (knownset)->current_size && (elem = &((knownset)->content[i])); i++) {
        if (elem->value.handle == val->handle) {
            found = 1;
            break;
        }
    }
    if (!found)
        elem = ((void *)0);
        if (found) {
            ((elem->value.handle == val->handle) ? (void) (0) : __assert_fail ("elem->value.handle == val->handle", "src/knownset.c", 160, __extension__ __PRETTY_FUNCTION__));;
        } else {
            ((elem == ((void *)0)) ? (void) (0) : __assert_fail ("elem == ((void *)0)", "src/knownset.c", 162, __extension__ __PRETTY_FUNCTION__));;
        }
        PICC_KnownSet_inv(knownset);
        PICC_KnownValue_inv(val);
    return elem;
}

canonical_original_code:
struct _PICC_KnownElement *PICC_knownset_get_element(struct _PICC_KnownSet *knownset, struct _PICC_KnownValue *val)
{
        PICC_KnownSet_inv(knownset);
        PICC_KnownValue_inv(val);
        ((knownset != ((void *)0)) ? (void) (0) : __assert_fail ("knownset != ((void *)0)", "src/knownset.c", 142, __extension__ __PRETTY_FUNCTION__));;
        ((val != ((void *)0)) ? (void) (0) : __assert_fail ("val != ((void *)0)", "src/knownset.c", 143, __extension__ __PRETTY_FUNCTION__));;
    struct _PICC_KnownElement *elem;
    _Bool found = 0;
    for(int i = 0; i < (knownset)->current_size && (elem = &((knownset)->content[i])); i++) {
        if (elem->value.handle == val->handle) {
            found = 1;
            break;
        }
    }
    if (!found)
        elem = ((void *)0);
        if (found) {
            ((elem->value.handle == val->handle) ? (void) (0) : __assert_fail ("elem->value.handle == val->handle", "src/knownset.c", 160, __extension__ __PRETTY_FUNCTION__));;
        } else {
            ((elem == ((void *)0)) ? (void) (0) : __assert_fail ("elem == ((void *)0)", "src/knownset.c", 162, __extension__ __PRETTY_FUNCTION__));;
        }
        PICC_KnownSet_inv(knownset);
        PICC_KnownValue_inv(val);
    return elem;
}

variable_types: struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement *content; } *

variable_types:
val
struct _PICC_KnownValue *

return_type: struct _PICC_KnownElement { enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 } state; struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle { int global_rc; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *error); } *handle; } value; } *


decompiled_code:
__int64 __fastcall PICC_knownset_add(__int64 a1, const __m128i *a2)
{
unsigned int v2; // er12
int v4; // eax
int v5; // er12
char *v6; // r13
int v7; // edx
char *v8; // rax
int v9; // [rsp+0h] [rbp-48h] BYREF
__int64 v10; // [rsp+8h] [rbp-40h]
int v11; // [rsp+10h] [rbp-38h]
__int64 v12; // [rsp+18h] [rbp-30h]

PICC_KnownSet_inv((int *)a1);
PICC_KnownValue_inv((__int64)a2);
if ( !a1 )
_assert_fail("ks != ((void *)0)", "src/knownset.c", 0x109u, "PICC_knownset_add");
if ( !a2 )
_assert_fail("val != ((void *)0)", "src/knownset.c", 0x10Au, "PICC_knownset_add");
v2 = 0;
if ( !PICC_knownset_get_element(a1, (__int64)a2) )
{
v4 = *(_DWORD *)(a1 + 4);
if ( v4 == *(_DWORD *)a1 )
{
v5 = v4 + 10;
v6 = (char *)realloc(*(void **)(a1 + 8), 24LL * (v4 + 10));
if ( !v6 )
{
v9 = 0;
v10 = 0LL;
v11 = 0;
v12 = 0LL;
PICC_init_error(&v9, 9LL, "src/knownset.c", 278LL);
PICC_crash(&v9, "src/knownset.c", "PICC_knownset_add");
}
v7 = *(_DWORD *)(a1 + 4);
if ( v7 < *(_DWORD *)a1 )
{
v8 = &v6[24 * v7];
do
{
*(_DWORD *)v8 = 0;
*((_DWORD *)v8 + 2) = 0x1000000;
*((_QWORD *)v8 + 2) = 0LL;
++v7;
v8 += 24;
}
while ( *(_DWORD *)a1 > v7 );
}
*(_DWORD *)a1 = v5;
*(_QWORD *)(a1 + 8) = v6;
}
*(__m128i *)(*(_QWORD *)(a1 + 8) + 24LL * (int)(*(_DWORD *)(a1 + 4))++ + 8) = _mm_loadu_si128(a2);
v2 = 1;
}
if ( !PICC_knownset_get_element(a1, (__int64)a2) )
_assert_fail("PICC_knownset_get_element(ks, val) != ((void *)0)", "src/knownset.c", 0x129u, "PICC_knownset_add");
PICC_KnownSet_inv((int *)a1);
PICC_KnownValue_inv((__int64)a2);
return v2;
}

original_code:
_Bool PICC_knownset_add(PICC_KnownSet *ks, PICC_KnownValue *val)
{
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
        ((ks != ((void *)0)) ? (void) (0) : __assert_fail ("ks != ((void *)0)", "src/knownset.c", 265, __extension__ __PRETTY_FUNCTION__));;
        ((val != ((void *)0)) ? (void) (0) : __assert_fail ("val != ((void *)0)", "src/knownset.c", 266, __extension__ __PRETTY_FUNCTION__));;
    PICC_KnownElement *elem;
    _Bool new_add = 0;
    elem = PICC_knownset_get_element(ks, val);
    if (elem == ((void *)0)) {
        if (ks->current_size == ks->max_size) {
     int new_max_size = ks->current_size + 10;
     PICC_KnownElement *new_elts = realloc(ks->content, sizeof(PICC_KnownElement) * new_max_size);
     if (new_elts == ((void *)0)) {
  PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)}; PICC_init_error(&error, ERR_OUT_OF_MEMORY, "src/knownset.c", 278); PICC_crash(&error, "src/knownset.c", __FUNCTION__);;
     }
     for (int i = ks->current_size; i < ks->max_size; i++) {
                new_elts[i].state = PICC_UNKNOWN;
                new_elts[i].value.header = ((unsigned int) (((TAG_NOVALUE) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) )))));
  new_elts[i].value.handle = ((void *)0);
          }
            ks->max_size = new_max_size;
     ks->content = new_elts;
        }
        ks->content[ks->current_size].value = *val;
        ks->current_size ++;
        new_add= 1;
    }
        ((PICC_knownset_get_element(ks, val) != ((void *)0)) ? (void) (0) : __assert_fail ("PICC_knownset_get_element(ks, val) != ((void *)0)", "src/knownset.c", 297, __extension__ __PRETTY_FUNCTION__));;
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
    return new_add;
}

canonical_original_code:
_Bool PICC_knownset_add(struct _PICC_KnownSet *ks, struct _PICC_KnownValue *val)
{
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
        ((ks != ((void *)0)) ? (void) (0) : __assert_fail ("ks != ((void *)0)", "src/knownset.c", 265, __extension__ __PRETTY_FUNCTION__));;
        ((val != ((void *)0)) ? (void) (0) : __assert_fail ("val != ((void *)0)", "src/knownset.c", 266, __extension__ __PRETTY_FUNCTION__));;
    struct _PICC_KnownElement *elem;
    _Bool new_add = 0;
    elem = PICC_knownset_get_element(ks, val);
    if (elem == ((void *)0)) {
        if (ks->current_size == ks->max_size) {
     int new_max_size = ks->current_size + 10;
     struct _PICC_KnownElement *new_elts = realloc(ks->content, sizeof(PICC_KnownElement) * new_max_size);
     if (new_elts == ((void *)0)) {
  struct _PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)}; PICC_init_error(&error, ERR_OUT_OF_MEMORY, "src/knownset.c", 278); PICC_crash(&error, "src/knownset.c", __FUNCTION__);;
     }
     for (int i = ks->current_size; i < ks->max_size; i++) {
                new_elts[i].state = PICC_UNKNOWN;
                new_elts[i].value.header = ((unsigned int) (((TAG_NOVALUE) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) )))));
  new_elts[i].value.handle = ((void *)0);
          }
            ks->max_size = new_max_size;
     ks->content = new_elts;
        }
        ks->content[ks->current_size].value = *val;
        ks->current_size ++;
        new_add= 1;
    }
        ((PICC_knownset_get_element(ks, val) != ((void *)0)) ? (void) (0) : __assert_fail ("PICC_knownset_get_element(ks, val) != ((void *)0)", "src/knownset.c", 297, __extension__ __PRETTY_FUNCTION__));;
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
    return new_add;
}

variable_types: struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; }


decompiled_code:
__int64 __fastcall PICC_knownset_register(int *a1, const __m128i *a2)
{
_DWORD *v2; // rax
unsigned int v3; // er12
_DWORD *v5; // rax

PICC_KnownSet_inv(a1);
PICC_KnownValue_inv((__int64)a2);
if ( !a1 )
_assert_fail("ks != ((void *)0)", "src/knownset.c", 0xC6u, "PICC_knownset_register");
if ( !a2 )
_assert_fail("val != ((void *)0)", "src/knownset.c", 0xC7u, "PICC_knownset_register");
v2 = (_DWORD *)PICC_knownset_get_element((__int64)a1, (__int64)a2);
if ( v2 )
{
if ( *v2 == 2 )
*v2 = 1;
v3 = 0;
}
else
{
PICC_knownset_add((__int64)a1, a2);
*(_DWORD *)PICC_knownset_get_element((__int64)a1, (__int64)a2) = 1;
v5 = (_DWORD *)PICC_knownset_get_element((__int64)a1, (__int64)a2);
if ( !v5 )
_assert_fail("elem != ((void *)0)", "src/knownset.c", 0xE9u, "PICC_knownset_register");
if ( *v5 != 1 )
_assert_fail("elem->state == PICC_KNOWN", "src/knownset.c", 0xEAu, "PICC_knownset_register");
v3 = 1;
}
PICC_KnownSet_inv(a1);
PICC_KnownValue_inv((__int64)a2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func11(int *a1, const __m128i *a2)
{
_DWORD *v2; // rax
unsigned int v3; // er12
_DWORD *v5; // rax

func1(a1);
func6((__int64)a2);
if ( !a1 )
_assert_fail("ks != ((void *)0)", "src/knownset.c", 0xC6u, "PICC_knownset_register");
if ( !a2 )
_assert_fail("val != ((void *)0)", "src/knownset.c", 0xC7u, "PICC_knownset_register");
v2 = (_DWORD *)func7((__int64)a1, (__int64)a2);
if ( v2 )
{
if ( *v2 == 2 )
*v2 = 1;
v3 = 0;
}
else
{
func8((__int64)a1, a2);
*(_DWORD *)func7((__int64)a1, (__int64)a2) = 1;
v5 = (_DWORD *)func7((__int64)a1, (__int64)a2);
if ( !v5 )
_assert_fail("elem != ((void *)0)", "src/knownset.c", 0xE9u, "PICC_knownset_register");
if ( *v5 != 1 )
_assert_fail("elem->state == PICC_KNOWN", "src/knownset.c", 0xEAu, "PICC_knownset_register");
v3 = 1;
}
func1(a1);
func6((__int64)a2);
return v3;
}

original_code:
_Bool PICC_knownset_register(PICC_KnownSet *ks, PICC_KnownValue *val)
{
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
        ((ks != ((void *)0)) ? (void) (0) : __assert_fail ("ks != ((void *)0)", "src/knownset.c", 198, __extension__ __PRETTY_FUNCTION__));;
        ((val != ((void *)0)) ? (void) (0) : __assert_fail ("val != ((void *)0)", "src/knownset.c", 199, __extension__ __PRETTY_FUNCTION__));;
        PICC_KnownElement *val_at_pre = PICC_knownset_get_element(ks, val);
        _Bool val_in_ks_at_pre = (val_at_pre != ((void *)0));
    _Bool channel_added_to_knownset = 0;
    PICC_KnownElement *elem = PICC_knownset_get_element(ks, val);
    if (elem != ((void *)0)) {
        if (elem->state == PICC_FORGET)
            elem->state = PICC_KNOWN;
    } else {
        channel_added_to_knownset = 1;
        PICC_knownset_add(ks, val);
        elem = PICC_knownset_get_element(ks, val);
        elem->state = PICC_KNOWN;
    }
        if (val_in_ks_at_pre) {
            if (val_at_pre->state == PICC_FORGET)
                ((PICC_knownset_get_element(ks, val)->state == PICC_KNOWN) ? (void) (0) : __assert_fail ("PICC_knownset_get_element(ks, val)->state == PICC_KNOWN", "src/knownset.c", 227, __extension__ __PRETTY_FUNCTION__));;
            ((channel_added_to_knownset == 0) ? (void) (0) : __assert_fail ("channel_added_to_knownset == 0", "src/knownset.c", 228, __extension__ __PRETTY_FUNCTION__));;
        } else {
            PICC_KnownElement *elem = PICC_knownset_get_element(ks, val);
            ((elem != ((void *)0)) ? (void) (0) : __assert_fail ("elem != ((void *)0)", "src/knownset.c", 233, __extension__ __PRETTY_FUNCTION__));;
            ((elem->state == PICC_KNOWN) ? (void) (0) : __assert_fail ("elem->state == PICC_KNOWN", "src/knownset.c", 234, __extension__ __PRETTY_FUNCTION__));;
            ((channel_added_to_knownset == 1) ? (void) (0) : __assert_fail ("channel_added_to_knownset == 1", "src/knownset.c", 235, __extension__ __PRETTY_FUNCTION__));;
        }
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
    return channel_added_to_knownset;
}

canonical_original_code:
_Bool PICC_knownset_register(struct _PICC_KnownSet *ks, struct _PICC_KnownValue *val)
{
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
        ((ks != ((void *)0)) ? (void) (0) : __assert_fail ("ks != ((void *)0)", "src/knownset.c", 198, __extension__ __PRETTY_FUNCTION__));;
        ((val != ((void *)0)) ? (void) (0) : __assert_fail ("val != ((void *)0)", "src/knownset.c", 199, __extension__ __PRETTY_FUNCTION__));;
        struct _PICC_KnownElement *val_at_pre = PICC_knownset_get_element(ks, val);
        _Bool val_in_ks_at_pre = (val_at_pre != ((void *)0));
    _Bool channel_added_to_knownset = 0;
    struct _PICC_KnownElement *elem = PICC_knownset_get_element(ks, val);
    if (elem != ((void *)0)) {
        if (elem->state == PICC_FORGET)
            elem->state = PICC_KNOWN;
    } else {
        channel_added_to_knownset = 1;
        PICC_knownset_add(ks, val);
        elem = PICC_knownset_get_element(ks, val);
        elem->state = PICC_KNOWN;
    }
        if (val_in_ks_at_pre) {
            if (val_at_pre->state == PICC_FORGET)
                ((PICC_knownset_get_element(ks, val)->state == PICC_KNOWN) ? (void) (0) : __assert_fail ("PICC_knownset_get_element(ks, val)->state == PICC_KNOWN", "src/knownset.c", 227, __extension__ __PRETTY_FUNCTION__));;
            ((channel_added_to_knownset == 0) ? (void) (0) : __assert_fail ("channel_added_to_knownset == 0", "src/knownset.c", 228, __extension__ __PRETTY_FUNCTION__));;
        } else {
            struct _PICC_KnownElement *elem = PICC_knownset_get_element(ks, val);
            ((elem != ((void *)0)) ? (void) (0) : __assert_fail ("elem != ((void *)0)", "src/knownset.c", 233, __extension__ __PRETTY_FUNCTION__));;
            ((elem->state == PICC_KNOWN) ? (void) (0) : __assert_fail ("elem->state == PICC_KNOWN", "src/knownset.c", 234, __extension__ __PRETTY_FUNCTION__));;
            ((channel_added_to_knownset == 1) ? (void) (0) : __assert_fail ("channel_added_to_knownset == 1", "src/knownset.c", 235, __extension__ __PRETTY_FUNCTION__));;
        }
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
    return channel_added_to_knownset;
}


decompiled_code:
void __fastcall PICC_knownset_forget_to_unknown(__int64 a1, __int64 a2)
{
int v2; // er13
int *v3; // rax
bool v4; // r12
__int64 v5; // rax
__int64 v6; // rcx
int v7; // edx
_DWORD *v8; // rax

PICC_KnownSet_inv((int *)a1);
PICC_KnownValue_inv(a2);
if ( !a1 )
_assert_fail("ks != ((void *)0)", "src/knownset.c", 0x1AFu, "PICC_knownset_forget_to_unknown");
v3 = (int *)PICC_knownset_get_element(a1, a2);
v4 = v3 != 0LL;
if ( !v3 )
{
if ( *(int *)(a1 + 4) <= 0 || (v5 = *(_QWORD *)(a1 + 8)) == 0 )
{
PICC_knownset_get_element(a1, a2);
goto LABEL_15;
}
goto LABEL_5;
}
v2 = *v3;
if ( *(int *)(a1 + 4) > 0 )
{
v5 = *(_QWORD *)(a1 + 8);
if ( v5 )
{
LABEL_5:
v6 = 24LL;
v7 = 0;
do
{
if ( *(_QWORD *)(v5 + 16) == *(_QWORD *)(a2 + 8) && *(_DWORD *)v5 == 2 )
*(_DWORD *)v5 = 0;
if ( *(_DWORD *)(a1 + 4) <= ++v7 )
break;
v5 = *(_QWORD *)(a1 + 8) + v6;
v6 += 24LL;
}
while ( v5 );
goto LABEL_12;
}
}
LABEL_12:
v8 = (_DWORD *)PICC_knownset_get_element(a1, a2);
if ( v2 == 2 && v4 && *v8 )
_assert_fail("elem2->state == PICC_UNKNOWN", "src/knownset.c", 0x1C5u, "PICC_knownset_forget_to_unknown");
LABEL_15:
PICC_KnownSet_inv((int *)a1);
PICC_KnownValue_inv(a2);
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1, __int64 a2)
{
int v2; // er13
int *v3; // rax
bool v4; // r12
__int64 v5; // rax
__int64 v6; // rcx
int v7; // edx
_DWORD *v8; // rax

func1((int *)a1);
func6(a2);
if ( !a1 )
_assert_fail("ks != ((void *)0)", "src/knownset.c", 0x1AFu, "PICC_knownset_forget_to_unknown");
v3 = (int *)func7(a1, a2);
v4 = v3 != 0LL;
if ( !v3 )
{
if ( *(int *)(a1 + 4) <= 0 || (v5 = *(_QWORD *)(a1 + 8)) == 0 )
{
func7(a1, a2);
goto LABEL_15;
}
goto LABEL_5;
}
v2 = *v3;
if ( *(int *)(a1 + 4) > 0 )
{
v5 = *(_QWORD *)(a1 + 8);
if ( v5 )
{
LABEL_5:
v6 = 24LL;
v7 = 0;
do
{
if ( *(_QWORD *)(v5 + 16) == *(_QWORD *)(a2 + 8) && *(_DWORD *)v5 == 2 )
*(_DWORD *)v5 = 0;
if ( *(_DWORD *)(a1 + 4) <= ++v7 )
break;
v5 = *(_QWORD *)(a1 + 8) + v6;
v6 += 24LL;
}
while ( v5 );
goto LABEL_12;
}
}
LABEL_12:
v8 = (_DWORD *)func7(a1, a2);
if ( v2 == 2 && v4 && *v8 )
_assert_fail("elem2->state == PICC_UNKNOWN", "src/knownset.c", 0x1C5u, "PICC_knownset_forget_to_unknown");
LABEL_15:
func1((int *)a1);
func6(a2);
}

original_code:
void PICC_knownset_forget_to_unknown(PICC_KnownSet *ks, PICC_KnownValue *val)
{
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
        ((ks != ((void *)0)) ? (void) (0) : __assert_fail ("ks != ((void *)0)", "src/knownset.c", 431, __extension__ __PRETTY_FUNCTION__));;
        PICC_KnownElement *elem1 = PICC_knownset_get_element(ks, val);
        _Bool val_in_ks_at_pre = (elem1 != ((void *)0));
        PICC_KnownState state_at_pre;
        if (val_in_ks_at_pre)
            state_at_pre = elem1->state;
    PICC_KnownElement *elem;
    for(int i = 0; i < (ks)->current_size && (elem = &((ks)->content[i])); i++) {
        if (elem->value.handle == val->handle
     && elem->state == PICC_FORGET)
            elem->state = PICC_UNKNOWN;
    }
        PICC_KnownElement *elem2 = PICC_knownset_get_element(ks, val);
        if (val_in_ks_at_pre && state_at_pre == PICC_FORGET) {
            ((elem2->state == PICC_UNKNOWN) ? (void) (0) : __assert_fail ("elem2->state == PICC_UNKNOWN", "src/knownset.c", 453, __extension__ __PRETTY_FUNCTION__));;
        }
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
}

canonical_original_code:
void PICC_knownset_forget_to_unknown(struct _PICC_KnownSet *ks, struct _PICC_KnownValue *val)
{
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
        ((ks != ((void *)0)) ? (void) (0) : __assert_fail ("ks != ((void *)0)", "src/knownset.c", 431, __extension__ __PRETTY_FUNCTION__));;
        struct _PICC_KnownElement *elem1 = PICC_knownset_get_element(ks, val);
        _Bool val_in_ks_at_pre = (elem1 != ((void *)0));
        enum _PICC_KnownState state_at_pre;
        if (val_in_ks_at_pre)
            state_at_pre = elem1->state;
    struct _PICC_KnownElement *elem;
    for(int i = 0; i < (ks)->current_size && (elem = &((ks)->content[i])); i++) {
        if (elem->value.handle == val->handle
     && elem->state == PICC_FORGET)
            elem->state = PICC_UNKNOWN;
    }
        struct _PICC_KnownElement *elem2 = PICC_knownset_get_element(ks, val);
        if (val_in_ks_at_pre && state_at_pre == PICC_FORGET) {
            ((elem2->state == PICC_UNKNOWN) ? (void) (0) : __assert_fail ("elem2->state == PICC_UNKNOWN", "src/knownset.c", 453, __extension__ __PRETTY_FUNCTION__));;
        }
        PICC_KnownSet_inv(ks);
        PICC_KnownValue_inv(val);
}

variable_types: enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 }


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
puts("== Run unit tests suite ==\n");
puts("Run pi_thread tests...");
PICC_test_pithread("Run pi_thread tests...", argv);
puts("Run queue tests...");
PICC_test_queue();
puts("Run channel tests...");
PICC_test_channel();
puts("Run commit tests...");
PICC_test_commit();
puts("Run atomic tests...");
PICC_test_atomic();
puts("Run value tests...");
PICC_test_value();
puts("Run known set tests...");
PICC_test_knownset();
return 0;
}

original_code:
int main(int argc, char **argv)
{
    printf("== Run unit tests suite ==\n\n");
    printf("Run pi_thread tests...\n");
    PICC_test_pithread();
    printf("Run queue tests...\n");
    PICC_test_queue();
    printf("Run channel tests...\n");
    PICC_test_channel();
    printf("Run commit tests...\n");
    PICC_test_commit();
    printf("Run atomic tests...\n");
    PICC_test_atomic();
    printf("Run value tests...\n");
    PICC_test_value();
    printf("Run known set tests...\n");
    PICC_test_knownset();
    return 0;
}

variable_types: argc int

variable_types:
argv
char **