addEdges

decompiled_code:
void __fastcall addEdges(char *a1, char *a2, int a3)
{
_DWORD *v5; // rsi
int v6; // eax
_DWORD *v7; // rsi
int v8; // eax

v5 = malloc(0x18uLL);
v6 = edgeid++;
*v5 = v6;
v5[1] = a3;
*((_QWORD *)v5 + 1) = a2;
*((_QWORD *)v5 + 2) = 0LL;
addToEdgeList(a1, (__int64)v5);
v7 = malloc(0x18uLL);
v8 = edgeid++;
*v7 = v8;
v7[1] = a3;
*((_QWORD *)v7 + 1) = a1;
*((_QWORD *)v7 + 2) = 0LL;
addToEdgeList(a2, (__int64)v7);
}

original_code:
void addEdges(node * endpoint1, node * endpoint2, int weight) {
 edge * e;
 e=(edge *)malloc(sizeof(edge));
 e->id = edgeid++;
 e->weight = weight;
 e->endpoint = endpoint2;
 e->next = ((void *)0);
 addToEdgeList(endpoint1, e);
 e=(edge *)malloc(sizeof(edge));
 e->id = edgeid++;
 e->weight = weight;
 e->endpoint = endpoint1;
 e->next = ((void *)0);
 addToEdgeList(endpoint2, e);
}

canonical_original_code:
void addEdges(struct struct_node *endpoint1, struct struct_node *endpoint2, int weight) {
 struct struct_edge *e;
 e=(struct struct_edge *)malloc(sizeof(edge));
 e->id = edgeid++;
 e->weight = weight;
 e->endpoint = endpoint2;
 e->next = ((void *)0);
 addToEdgeList(endpoint1, e);
 e=(struct struct_edge *)malloc(sizeof(edge));
 e->id = edgeid++;
 e->weight = weight;
 e->endpoint = endpoint1;
 e->next = ((void *)0);
 addToEdgeList(endpoint2, e);
}

variable_types: weight int

user_defined_types: struct struct_node { char id; int noEdges; struct struct_edge *edges; struct struct_node *next; }

user_defined_types: struct struct_edge { int id; int weight; struct struct_node *endpoint; struct struct_edge *next; }


listEdges

repo: FireArrow/traveling-salesman

decompiled_code:
int __fastcall listEdges(char a1)
{
_QWORD *v1; // rax
__int64 v2; // rbx

v1 = getNode(a1);
v2 = v1[1];
printf("Node %c:", (unsigned int)*(char *)v1);
for ( ; v2; v2 = *(_QWORD *)(v2 + 16) )
printf(" %c-%d", (unsigned int)**(char **)(v2 + 8), *(unsigned int *)(v2 + 4));
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func2(char a1)
{
_QWORD *v1; // rax
__int64 v2; // rbx

v1 = getNode(a1);
v2 = v1[1];
printf("Node %c:", (unsigned int)*(char *)v1);
for ( ; v2; v2 = *(_QWORD *)(v2 + 16) )
printf(" %c-%d", (unsigned int)**(char **)(v2 + 8), *(unsigned int *)(v2 + 4));
return putchar(10);
}

original_code:
void listEdges(char cNode) {
 node * n = getNode(cNode);
 edge * curr = n->edges;
 printf("Node %c:",n->id);
 while(curr != ((void *)0)) {
  printf(" %c-%d",curr->endpoint->id,curr->weight);
  curr = curr->next;
 }
 printf("\n");
}

canonical_original_code:
void listEdges(char cNode) {
 struct struct_node *n = getNode(cNode);
 struct struct_edge *curr = n->edges;
 printf("Node %c:",n->id);
 while(curr != ((void *)0)) {
  printf(" %c-%d",curr->endpoint->id,curr->weight);
  curr = curr->next;
 }
 printf("\n");
}

variable_types: cNode char

variable_types: struct struct_node { char id; int noEdges; struct struct_edge { int id; int weight; struct struct_node *endpoint; struct struct_edge *next; } *edges; struct struct_node *next; } *

variable_types: struct struct_edge { int id; int weight; struct struct_node { char id; int noEdges; struct struct_edge *edges; struct struct_node *next; } *endpoint; struct struct_edge *next; } *

return_type: void


removeNode

decompiled_code:
void __fastcall removeNode(void *ptr)
{
removeEdges(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
func3(*((void **)ptr + 1));
free(ptr);
}

original_code:
void removeNode(node * n) {
 removeEdges(n->edges);
 free(n);
}

canonical_original_code:
void removeNode(struct struct_node *n) {
 removeEdges(n->edges);
 free(n);
}


freeAllNodes

decompiled_code:
void __fastcall freeAllNodes(void *ptr)
{
char *v1; // rbx
char *v2; // rbp

v1 = (char *)ptr;
if ( ptr )
{
do
{
v2 = v1;
v1 = (char *)*((_QWORD *)v1 + 2);
if ( verbosity > 2 )
fprintf(stdout, "Freeing node %c - 0x%08x\n", (unsigned int)*v2, v2);
removeNode(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func5(void *ptr)
{
char *v1; // rbx
char *v2; // rbp

v1 = (char *)ptr;
if ( ptr )
{
do
{
v2 = v1;
v1 = (char *)*((_QWORD *)v1 + 2);
if ( verbosity > 2 )
fprintf(stdout, "Freeing node %c - 0x%08x\n", (unsigned int)*v2, v2);
func4(v2);
}
while ( v1 );
}
}

original_code:
void freeAllNodes(node * start) {
 node * curr = start;
 node * next;
 while(curr != ((void *)0)) {
  next = curr->next;
  if(verbosity >= 3) fprintf(stdout,"Freeing node %c - 0x%08x\n",curr->id, curr);
  removeNode(curr);
  curr = next;
 }
}

canonical_original_code:
void freeAllNodes(struct struct_node *start) {
 struct struct_node *curr = start;
 struct struct_node *next;
 while(curr != ((void *)0)) {
  next = curr->next;
  if(verbosity >= 3) fprintf(stdout,"Freeing node %c - 0x%08x\n",curr->id, curr);
  removeNode(curr);
  curr = next;
 }
}


visit

decompiled_code:
__int64 __fastcall visit(char *a1, __int64 a2, unsigned int *a3)
{
int v4; // eax
unsigned int v5; // edx
__int64 v6; // rbx

if ( verbosity > 2 )
fprintf(stdout, "Visit: currNode: %c, noVisited: %d, noNodes: %d\n", (unsigned int)*a1, *a3, (unsigned int)noNodes);
v4 = *a3;
v5 = 0;
if ( (int)*a3 <= noNodes )
{
if ( v4 == noNodes )
{
if ( verbosity > 2 )
{
fwrite("Last node... ", 1uLL, 0xDuLL, stdout);
if ( (char *)entrypoint != a1 )
{
if ( verbosity > 2 )
fprintf(stdout, "%c isn't the goal. Failing\n", (unsigned int)*a1);
return 0;
}
if ( verbosity > 2 )
fprintf(stdout, "%c is the goal. Ok\n", (unsigned int)*a1);
}
else if ( (char *)entrypoint != a1 )
{
return 0;
}
++*a3;
return 1;
}
v6 = 0LL;
if ( v4 > 0 )
{
while ( 1 )
{
if ( verbosity > 2 )
fprintf(stdout, "Comparing %c to %c... ", (unsigned int)*a1, (unsigned int)**(char **)(a2 + 8 * v6));
if ( *(char **)(a2 + 8 * v6) == a1 )
break;
if ( verbosity > 2 )
fwrite("no match\n", 1uLL, 9uLL, stdout);
v4 = *a3;
if ( (int)*a3 <= (int)++v6 )
goto LABEL_6;
}
v5 = 0;
if ( verbosity > 2 )
{
fwrite("match, can't visit again\n", 1uLL, 0x19uLL, stdout);
v5 = 0;
}
}
else
{
LABEL_6:
*(_QWORD *)(a2 + 8LL * v4) = a1;
++*a3;
v5 = 1;
if ( verbosity > 2 )
{
fprintf(stdout, "%c haven't been visited yet\n", (unsigned int)*a1);
v5 = 1;
}
}
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *a1, __int64 a2, unsigned int *a3)
{
int v4; // eax
unsigned int v5; // edx
__int64 v6; // rbx

if ( verbosity > 2 )
fprintf(stdout, "Visit: currNode: %c, noVisited: %d, noNodes: %d\n", (unsigned int)*a1, *a3, (unsigned int)noNodes);
v4 = *a3;
v5 = 0;
if ( (int)*a3 <= noNodes )
{
if ( v4 == noNodes )
{
if ( verbosity > 2 )
{
fwrite("Last node... ", 1uLL, 0xDuLL, stdout);
if ( (char *)entrypoint != a1 )
{
if ( verbosity > 2 )
fprintf(stdout, "%c isn't the goal. Failing\n", (unsigned int)*a1);
return 0;
}
if ( verbosity > 2 )
fprintf(stdout, "%c is the goal. Ok\n", (unsigned int)*a1);
}
else if ( (char *)entrypoint != a1 )
{
return 0;
}
++*a3;
return 1;
}
v6 = 0LL;
if ( v4 > 0 )
{
while ( 1 )
{
if ( verbosity > 2 )
fprintf(stdout, "Comparing %c to %c... ", (unsigned int)*a1, (unsigned int)**(char **)(a2 + 8 * v6));
if ( *(char **)(a2 + 8 * v6) == a1 )
break;
if ( verbosity > 2 )
fwrite("no match\n", 1uLL, 9uLL, stdout);
v4 = *a3;
if ( (int)*a3 <= (int)++v6 )
goto LABEL_6;
}
v5 = 0;
if ( verbosity > 2 )
{
fwrite("match, can't visit again\n", 1uLL, 0x19uLL, stdout);
v5 = 0;
}
}
else
{
LABEL_6:
*(_QWORD *)(a2 + 8LL * v4) = a1;
++*a3;
v5 = 1;
if ( verbosity > 2 )
{
fprintf(stdout, "%c haven't been visited yet\n", (unsigned int)*a1);
v5 = 1;
}
}
}
return v5;
}

original_code:
bool visit(node * currNode, node * visitedNodes[], int * noVisited) {
 if(verbosity >= 3) fprintf(stdout,"Visit: currNode: %c, noVisited: %d, noNodes: %d\n",currNode->id, *noVisited, noNodes);
 if(*noVisited > noNodes) {
  return 0;
 }
 if(*noVisited == noNodes) {
  if(verbosity >= 3) fprintf(stdout,"Last node... ");
  if(currNode == entrypoint) {
   if(verbosity >= 3) fprintf(stdout,"%c is the goal. Ok\n", currNode->id);
   (*noVisited)++;
   return 1;
  }
  else {
   if(verbosity >= 3) fprintf(stdout,"%c isn't the goal. Failing\n", currNode->id);
   return 0;
  }
 }
 else {
  for(int i=0;i<*noVisited;i++) {
   if(verbosity >= 3) fprintf(stdout,"Comparing %c to %c... ", currNode->id, visitedNodes[i]->id);
   if(currNode == visitedNodes[i]) {
    if(verbosity >= 3) fprintf(stdout,"match, can't visit again\n");
    return 0;
   }
   if(verbosity >= 3) fprintf(stdout,"no match\n");
  }
  visitedNodes[*noVisited] = currNode;
  (*noVisited)++;
  if(verbosity >= 3) fprintf(stdout,"%c haven't been visited yet\n",currNode->id);
  return 1;
 }
 if(verbosity >= 0) fprintf(stdout,"Reached end of visit(). This shouldn't be possible!\n");
 return 0;
}

canonical_original_code:
char visit(struct struct_node *currNode, struct struct_node *visitedNodes[], int *noVisited) {
 if(verbosity >= 3) fprintf(stdout,"Visit: currNode: %c, noVisited: %d, noNodes: %d\n",currNode->id, *noVisited, noNodes);
 if(*noVisited > noNodes) {
  return 0;
 }
 if(*noVisited == noNodes) {
  if(verbosity >= 3) fprintf(stdout,"Last node... ");
  if(currNode == entrypoint) {
   if(verbosity >= 3) fprintf(stdout,"%c is the goal. Ok\n", currNode->id);
   (*noVisited)++;
   return 1;
  }
  else {
   if(verbosity >= 3) fprintf(stdout,"%c isn't the goal. Failing\n", currNode->id);
   return 0;
  }
 }
 else {
  for(int i = 0;i<*noVisited;i++) {
   if(verbosity >= 3) fprintf(stdout,"Comparing %c to %c... ", currNode->id, visitedNodes[i]->id);
   if(currNode == visitedNodes[i]) {
    if(verbosity >= 3) fprintf(stdout,"match, can't visit again\n");
    return 0;
   }
   if(verbosity >= 3) fprintf(stdout,"no match\n");
  }
  visitedNodes[*noVisited] = currNode;
  (*noVisited)++;
  if(verbosity >= 3) fprintf(stdout,"%c haven't been visited yet\n",currNode->id);
  return 1;
 }
 if(verbosity >= 0) fprintf(stdout,"Reached end of visit(). This shouldn't be possible!\n");
 return 0;
}

variable_types:
visitedNodes
struct struct_node *[]

variable_types:
noVisited
int *

variable_types: i int

return_type: char


insideTravelGraph

decompiled_code:
__int64 __fastcall insideTravelGraph(__int64 a1, int a2, unsigned int a3, __int64 a4, __int64 a5)
{
__int64 result; // rax
__int64 v8; // rdx
int v9; // ecx
void *v10; // rsp
_QWORD *v11; // rax
_QWORD *v12; // rcx
__int64 v13; // rbx
__int64 v14; // r12
int v15; // eax
_QWORD v16[2]; // [rsp+0h] [rbp-60h] BYREF
__int64 v17; // [rsp+10h] [rbp-50h]
__int64 v18; // [rsp+18h] [rbp-48h]
__int64 v19; // [rsp+20h] [rbp-40h]
unsigned int v20[13]; // [rsp+2Ch] [rbp-34h] BYREF

v18 = a1;
v20[0] = a2;
v19 = a5;
if ( !(unsigned __int8)visit((char *)a4, a1, v20) )
return 0xFFFFFFFFLL;
result = a3;
if ( (int)v20[0] <= noNodes )
{
v16[1] = v16;
v8 = *(_QWORD *)(a4 + 8);
v9 = *(_DWORD *)(a4 + 4);
v10 = alloca(8LL * v9);
if ( v9 <= 0 )
goto LABEL_16;
v11 = v16;
v12 = &v16[v9];
do
{
*v11 = v8;
v8 = *(_QWORD *)(v8 + 16);
++v11;
}
while ( v12 != v11 );
v13 = 0LL;
v17 = 0LL;
do
{
v14 = v16[v13];
v15 = insideTravelGraph(v18, v20[0], *(_DWORD *)(v14 + 4) + a3, *(_QWORD *)(v14 + 8), v19);
if ( v15 >= 0 && (bestPathCost >= v15 || bestPathCost < 0) )
{
bestPathCost = v15;
v17 = v14;
}
++v13;
}
while ( *(_DWORD *)(a4 + 4) > (int)v13 );
if ( v17 )
{
*(_QWORD *)(v19 + 8LL * (int)v20[0]) = *(_QWORD *)(v17 + 8);
result = (unsigned int)bestPathCost;
}
else
{
LABEL_16:
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int insideTravelGraph(node * visitedNodes[], int noVisited, int costSoFar, node * currNode, node * solution[]) {
 if(visit(currNode, visitedNodes, &noVisited)) {
  if(noVisited > noNodes) {
   return costSoFar;
  }
  else {
   edge * bestPath = ((void *)0);
   edge * e = currNode->edges;
   edge * edges[currNode->noEdges];
   for(int i=0;i<currNode->noEdges;i++) {
    edges[i] = e;
    e=e->next;
   }
   for(int i=0;i<currNode->noEdges;i++) {
    int thisPathCost = insideTravelGraph(visitedNodes, noVisited, costSoFar+edges[i]->weight, edges[i]->endpoint, solution);
    if(thisPathCost >= 0) {
     if(bestPathCost < 0 || thisPathCost <= bestPathCost) {
      bestPathCost = thisPathCost;
      bestPath = edges[i];
     }
    }
   }
   if(bestPath != ((void *)0)) {
    solution[noVisited] = bestPath->endpoint;
    return bestPathCost;
   }
  }
 }
 return -1;
}

canonical_original_code:
int insideTravelGraph(struct struct_node *visitedNodes[], int noVisited, int costSoFar, struct struct_node *currNode, struct struct_node *solution[]) {
 if(visit(currNode, visitedNodes, &noVisited)) {
  if(noVisited > noNodes) {
   return costSoFar;
  }
  else {
   struct struct_edge *bestPath = ((void *)0);
   struct struct_edge *e = currNode->edges;
   struct struct_edge *edges[-1];
   for(int i = 0;i<currNode->noEdges;i++) {
    edges[i] = e;
    e=e->next;
   }
   for(int i = 0;i<currNode->noEdges;i++) {
    int thisPathCost = insideTravelGraph(visitedNodes, noVisited, costSoFar+edges[i]->weight, edges[i]->endpoint, solution);
    if(thisPathCost >= 0) {
     if(bestPathCost < 0 || thisPathCost <= bestPathCost) {
      bestPathCost = thisPathCost;
      bestPath = edges[i];
     }
    }
   }
   if(bestPath != ((void *)0)) {
    solution[noVisited] = bestPath->endpoint;
    return bestPathCost;
   }
  }
 }
 return -1;
}

variable_types: struct struct_node { char id; int noEdges; struct struct_edge { int id; int weight; struct struct_node *endpoint; struct struct_edge *next; } *edges; struct struct_node *next; } *[]

variable_types: noVisited int

variable_types: costSoFar int

variable_types:
currNode
struct struct_node *

variable_types:
solution
struct struct_node *[]

variable_types: struct struct_edge { int id; int weight; struct struct_node { char id; int noEdges; struct struct_edge *edges; struct struct_node *next; } *endpoint; struct struct_edge *next; } *[-1]

variable_types: thisPathCost int

return_type: int


travelGraph

decompiled_code:
__int64 travelGraph()
{
int v0; // esi
__int64 v1; // rcx
void *v2; // rsp
void *v3; // rsp
_BYTE *v4; // rax
int v5; // er13
__int64 v6; // rbx
_BYTE v8[7]; // [rsp+0h] [rbp-20h] BYREF
char v9; // [rsp+7h] [rbp-19h] BYREF

v0 = noNodes;
v1 = 8LL * (noNodes + 1);
v2 = alloca(16 * ((v1 + 15) / 0x10uLL));
v3 = alloca(16 * ((v1 + 7) / 0x10uLL));
if ( noNodes > 0 )
{
v4 = v8;
do
{
*(_QWORD *)v4 = 0LL;
v4 += 8;
}
while ( v4 != &v8[8 * v0] );
}
v5 = insideTravelGraph((__int64)v8, 0, 0, entrypoint, (__int64)v8);
if ( v5 < 0 )
{
if ( verbosity >= 0 )
fwrite("Graph unsolvable :(\n", 1uLL, 0x14uLL, stdout);
}
else
{
*(_QWORD *)(8 * ((unsigned __int64)&v9 >> 3)) = entrypoint;
if ( noNodes >= 0 )
{
v6 = 0LL;
do
{
if ( verbosity >= 0 )
fprintf(stdout, " %c", (unsigned int)**(char **)&v8[8 * v6]);
++v6;
}
while ( noNodes >= (int)v6 );
}
if ( verbosity >= 0 )
fprintf(stdout, ": %d\n", (unsigned int)v5);
}
return (unsigned int)v5;
}

canonical_decompiled_code:
__int64 func8()
{
int v0; // esi
__int64 v1; // rcx
void *v2; // rsp
void *v3; // rsp
_BYTE *v4; // rax
int v5; // er13
__int64 v6; // rbx
_BYTE v8[7]; // [rsp+0h] [rbp-20h] BYREF
char v9; // [rsp+7h] [rbp-19h] BYREF

v0 = noNodes;
v1 = 8LL * (noNodes + 1);
v2 = alloca(16 * ((v1 + 15) / 0x10uLL));
v3 = alloca(16 * ((v1 + 7) / 0x10uLL));
if ( noNodes > 0 )
{
v4 = v8;
do
{
*(_QWORD *)v4 = 0LL;
v4 += 8;
}
while ( v4 != &v8[8 * v0] );
}
v5 = func7((__int64)v8, 0, 0, entrypoint, (__int64)v8);
if ( v5 < 0 )
{
if ( verbosity >= 0 )
fwrite("Graph unsolvable :(\n", 1uLL, 0x14uLL, stdout);
}
else
{
*(_QWORD *)(8 * ((unsigned __int64)&v9 >> 3)) = entrypoint;
if ( noNodes >= 0 )
{
v6 = 0LL;
do
{
if ( verbosity >= 0 )
fprintf(stdout, " %c", (unsigned int)**(char **)&v8[8 * v6]);
++v6;
}
while ( noNodes >= (int)v6 );
}
if ( verbosity >= 0 )
fprintf(stdout, ": %d\n", (unsigned int)v5);
}
return (unsigned int)v5;
}

original_code:
int travelGraph() {
 node * solution[noNodes+1];
 node * visitedNodes[noNodes];
 int shortestPath = -1;
 for(int i=0;i<noNodes;i++) {
  visitedNodes[i] = 0;
 }
 shortestPath = insideTravelGraph(visitedNodes, 0, 0, entrypoint, solution);
 if(shortestPath >= 0) {
  solution[0] = entrypoint;
  for(int i=0;i<=noNodes;i++) {
   if(verbosity >= 0) fprintf(stdout," %c", solution[i]->id);
  }
  if(verbosity >= 0) fprintf(stdout,": %d\n",shortestPath);
 }
 else {
  if(verbosity >= 0) fprintf(stdout,"Graph unsolvable :(\n");
 }
 return shortestPath;
}

canonical_original_code:
int travelGraph() {
 struct struct_node *solution[-1];
 struct struct_node *visitedNodes[-1];
 int shortestPath = -1;
 for(int i = 0;i<noNodes;i++) {
  visitedNodes[i] = 0;
 }
 shortestPath = insideTravelGraph(visitedNodes, 0, 0, entrypoint, solution);
 if(shortestPath >= 0) {
  solution[0] = entrypoint;
  for(int i = 0;i<=noNodes;i++) {
   if(verbosity >= 0) fprintf(stdout," %c", solution[i]->id);
  }
  if(verbosity >= 0) fprintf(stdout,": %d\n",shortestPath);
 }
 else {
  if(verbosity >= 0) fprintf(stdout,"Graph unsolvable :(\n");
 }
 return shortestPath;
}

variable_types: struct struct_node { char id; int noEdges; struct struct_edge { int id; int weight; struct struct_node *endpoint; struct struct_edge *next; } *edges; struct struct_node *next; } *[-1]

variable_types: shortestPath int


printHelp

decompiled_code:
void __fastcall __noreturn printHelp(int status)
{
puts("Here be help some day, maybe");
exit(status);
}

canonical_decompiled_code:
void __fastcall __noreturn func10(int status)
{
puts("Here be help some day, maybe");
exit(status);
}

original_code:
void printHelp(int status) {
 printf("Here be help some day, maybe\n");
 exit(status);
}

variable_types: status int


setVerbosity

decompiled_code:
size_t __fastcall setVerbosity(int a1)
{
size_t result; // rax

result = (unsigned int)verbosity;
if ( verbosity == 1 )
{
verbosity = a1;
}
else if ( verbosity > 0 )
{
result = fwrite("Verbosity already set. Ignoring\n", 1uLL, 0x20uLL, stdout);
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func11(int a1)
{
size_t result; // rax

result = (unsigned int)verbosity;
if ( verbosity == 1 )
{
verbosity = a1;
}
else if ( verbosity > 0 )
{
result = fwrite("Verbosity already set. Ignoring\n", 1uLL, 0x20uLL, stdout);
}
return result;
}

original_code:
void setVerbosity(int level) {
 if(verbosity == 1)
  verbosity=level;
 else
  if(verbosity >= 1) fprintf(stdout,"Verbosity already set. Ignoring\n");
}

variable_types: level int


main

canonical_name: main

decompiled_code:
// local variable allocation has failed, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbp
const char **v4; // r14
char v5; // al
__int64 v6; // rbx
char v7; // r15
int *v8; // rax
int *v9; // rax
char *v10; // rax

if ( argc > 1 )
{
v3 = argv + 1;
v4 = &argv[(unsigned int)(argc - 2) + 2];
while ( 1 )
{
envp = (const char **)*v3;
if ( **v3 != 45 )
{
if ( first )
{
if ( verbosity > 0 )
{
argv = (const char **)"Only one file can be supplied per run.\n Ignoring %s\n";
*(_QWORD *)&argc = stdout;
fprintf(stdout, "Only one file can be supplied per run.\n Ignoring %s\n", (const char *)envp);
}
}
else
{
if ( verbosity > 1 )
fprintf(stdout, "Trying to read file %s... ", (const char *)envp);
argv = (const char **)"r";
graphFile = fopen(*v3, "r");
if ( !graphFile )
{
if ( verbosity > 1 )
fwrite("failed\n", 1uLL, 7uLL, stdout);
if ( verbosity >= 0 )
{
v9 = _errno_location();
v10 = strerror(*v9);
fprintf(stdout, "Failed to open %s: %s\n", *v3, v10);
}
v8 = _errno_location();
exit(*v8);
}
if ( verbosity > 1 )
{
argv = (const char **)&loc_1;
fwrite("done\n", 1uLL, 5uLL, stdout);
}
parseGraphFile(graphFile);
if ( verbosity > 2 )
{
argv = (const char **)&loc_1;
fwrite("Done parsing graph\n", 1uLL, 0x13uLL, stdout);
}
*(_QWORD *)&argc = graphFile;
fclose(graphFile);
}
goto LABEL_31;
}
v5 = *((_BYTE *)envp + 1);
if ( !v5 )
goto LABEL_31;
v6 = 2LL;
v7 = 1;
while ( 1 )
{
if ( v5 == 115 )
{
*(_QWORD *)&argc = 0LL;
setVerbosity(0);
goto LABEL_12;
}
if ( v5 <= 115 )
break;
if ( v5 == 118 )
{
*(_QWORD *)&argc = 2LL;
setVerbosity(2);
goto LABEL_12;
}
LABEL_6:
if ( verbosity >= 0 )
{
argv = (const char **)"Unknown parameter -%c\n";
fprintf(stdout, "Unknown parameter -%c\n", (unsigned int)*((char *)envp + v6));
}
envp = (const char **)*v3;
v5 = (*v3)[v6];
if ( !v5 )
goto LABEL_22;
v7 = 0;
LABEL_13:
++v6;
}
if ( v5 != 100 )
break;
*(_QWORD *)&argc = 3LL;
setVerbosity(3);
if ( verbosity > 2 )
{
argv = (const char **)&loc_1;
*(_QWORD *)&argc = "Setting verbosity to debug\n";
fwrite("Setting verbosity to debug\n", 1uLL, 0x1BuLL, stdout);
}
LABEL_12:
envp = (const char **)*v3;
v5 = (*v3)[v6];
if ( v5 )
goto LABEL_13;
if ( !v7 )
LABEL_22:
printHelp(1);
LABEL_31:
if ( ++v3 == v4 )
goto LABEL_41;
}
if ( v5 == 104 )
printHelp(0);
goto LABEL_6;
}
LABEL_41:
if ( !entrypoint )
{
if ( verbosity >= 0 )
fwrite("No graph file found (or reading it failed)\n", 1uLL, 0x2BuLL, stdout);
printHelp(2);
}
if ( verbosity > 1 )
{
argv = (const char **)"Traveling graph from %c:\n";
*(_QWORD *)&argc = stdout;
fprintf(stdout, "Traveling graph from %c:\n", (unsigned int)*(char *)entrypoint);
}
travelGraph(*(_QWORD *)&argc, argv, envp);
freeAllNodes(first);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbp
const char **v4; // r14
char v5; // al
__int64 v6; // rbx
char v7; // r15
int *v8; // rax
int *v9; // rax
char *v10; // rax

if ( argc > 1 )
{
v3 = argv + 1;
v4 = &argv[(unsigned int)(argc - 2) + 2];
while ( 1 )
{
envp = (const char **)*v3;
if ( **v3 != 45 )
{
if ( first )
{
if ( verbosity > 0 )
{
argv = (const char **)"Only one file can be supplied per run.\n Ignoring %s\n";
*(_QWORD *)&argc = stdout;
fprintf(stdout, "Only one file can be supplied per run.\n Ignoring %s\n", (const char *)envp);
}
}
else
{
if ( verbosity > 1 )
fprintf(stdout, "Trying to read file %s... ", (const char *)envp);
argv = (const char **)"r";
graphFile = fopen(*v3, "r");
if ( !graphFile )
{
if ( verbosity > 1 )
fwrite("failed\n", 1uLL, 7uLL, stdout);
if ( verbosity >= 0 )
{
v9 = _errno_location();
v10 = strerror(*v9);
fprintf(stdout, "Failed to open %s: %s\n", *v3, v10);
}
v8 = _errno_location();
exit(*v8);
}
if ( verbosity > 1 )
{
argv = (const char **)&loc_1;
fwrite("done\n", 1uLL, 5uLL, stdout);
}
func9(graphFile);
if ( verbosity > 2 )
{
argv = (const char **)&loc_1;
fwrite("Done parsing graph\n", 1uLL, 0x13uLL, stdout);
}
*(_QWORD *)&argc = graphFile;
fclose(graphFile);
}
goto LABEL_31;
}
v5 = *((_BYTE *)envp + 1);
if ( !v5 )
goto LABEL_31;
v6 = 2LL;
v7 = 1;
while ( 1 )
{
if ( v5 == 115 )
{
*(_QWORD *)&argc = 0LL;
func11(0);
goto LABEL_12;
}
if ( v5 <= 115 )
break;
if ( v5 == 118 )
{
*(_QWORD *)&argc = 2LL;
func11(2);
goto LABEL_12;
}
LABEL_6:
if ( verbosity >= 0 )
{
argv = (const char **)"Unknown parameter -%c\n";
fprintf(stdout, "Unknown parameter -%c\n", (unsigned int)*((char *)envp + v6));
}
envp = (const char **)*v3;
v5 = (*v3)[v6];
if ( !v5 )
goto LABEL_22;
v7 = 0;
LABEL_13:
++v6;
}
if ( v5 != 100 )
break;
*(_QWORD *)&argc = 3LL;
func11(3);
if ( verbosity > 2 )
{
argv = (const char **)&loc_1;
*(_QWORD *)&argc = "Setting verbosity to debug\n";
fwrite("Setting verbosity to debug\n", 1uLL, 0x1BuLL, stdout);
}
LABEL_12:
envp = (const char **)*v3;
v5 = (*v3)[v6];
if ( v5 )
goto LABEL_13;
if ( !v7 )
LABEL_22:
func10(1);
LABEL_31:
if ( ++v3 == v4 )
goto LABEL_41;
}
if ( v5 == 104 )
func10(0);
goto LABEL_6;
}
LABEL_41:
if ( !entrypoint )
{
if ( verbosity >= 0 )
fwrite("No graph file found (or reading it failed)\n", 1uLL, 0x2BuLL, stdout);
func10(2);
}
if ( verbosity > 1 )
{
argv = (const char **)"Traveling graph from %c:\n";
*(_QWORD *)&argc = stdout;
fprintf(stdout, "Traveling graph from %c:\n", (unsigned int)*(char *)entrypoint);
}
func8(*(_QWORD *)&argc, argv, envp);
func5(first);
return 0;
}

original_code:
int main(int argc, char* argv[]) {
 bool correctInput=1;
 for(int i=1;i<argc;++i) {
  if(argv[i][0] == '-') {
   int j=1;
   while(argv[i][j] != '\0') {
    switch(argv[i][j++]) {
     case 'h': printHelp(0);
         break;
     case 'v': setVerbosity(2);
         break;
     case 'd': setVerbosity(3);
         if(verbosity >= 3) fprintf(stdout,"Setting verbosity to debug\n");
         break;
     case 's': setVerbosity(0);
         break;
     default: correctInput = 0;
         if(verbosity >= 0) fprintf(stdout,"Unknown parameter -%c\n",argv[i][j]);
         break;
    }
   }
  }
  else {
   if(first == ((void *)0)) {
    if(verbosity >= 2) fprintf(stdout,"Trying to read file %s... ",argv[i]);
    graphFile = fopen(argv[i], "r");
    if(graphFile == ((void *)0)) {
     if(verbosity >= 2) fprintf(stdout,"failed\n");
     if(verbosity >= 0) fprintf(stdout,"Failed to open %s: %s\n",argv[i], strerror((*__errno_location ())));
     exit((*__errno_location ()));
    }
    else {
     if(verbosity >= 2) fprintf(stdout,"done\n");
     parseGraphFile(graphFile);
     if(verbosity >= 3) fprintf(stdout,"Done parsing graph\n");
     fclose(graphFile);
    }
   }
   else {
    if(verbosity >= 1) fprintf(stdout,"Only one file can be supplied per run.\n Ignoring %s\n",argv[i]);
   }
  }
  if(!correctInput) {
   printHelp(1);
  }
 }
 if(entrypoint != ((void *)0)) {
  if(verbosity >= 2) fprintf(stdout,"Traveling graph from %c:\n", entrypoint->id);
  travelGraph();
 }
 else {
  if(verbosity >= 0) fprintf(stdout,"No graph file found (or reading it failed)\n");
  printHelp(2);
 }
 freeAllNodes(first);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 char correctInput = 1;
 for(int i = 1;i<argc;++i) {
  if(argv[i][0] == '-') {
   int j = 1;
   while(argv[i][j] != '\0') {
    switch(argv[i][j++]) {
     case 'h': printHelp(0);
         break;
     case 'v': setVerbosity(2);
         break;
     case 'd': setVerbosity(3);
         if(verbosity >= 3) fprintf(stdout,"Setting verbosity to debug\n");
         break;
     case 's': setVerbosity(0);
         break;
     default: correctInput = 0;
         if(verbosity >= 0) fprintf(stdout,"Unknown parameter -%c\n",argv[i][j]);
         break;
    }
   }
  }
  else {
   if(first == ((void *)0)) {
    if(verbosity >= 2) fprintf(stdout,"Trying to read file %s... ",argv[i]);
    graphFile = fopen(argv[i], "r");
    if(graphFile == ((void *)0)) {
     if(verbosity >= 2) fprintf(stdout,"failed\n");
     if(verbosity >= 0) fprintf(stdout,"Failed to open %s: %s\n",argv[i], strerror((*__errno_location ())));
     exit((*__errno_location ()));
    }
    else {
     if(verbosity >= 2) fprintf(stdout,"done\n");
     parseGraphFile(graphFile);
     if(verbosity >= 3) fprintf(stdout,"Done parsing graph\n");
     fclose(graphFile);
    }
   }
   else {
    if(verbosity >= 1) fprintf(stdout,"Only one file can be supplied per run.\n Ignoring %s\n",argv[i]);
   }
  }
  if(!correctInput) {
   printHelp(1);
  }
 }
 if(entrypoint != ((void *)0)) {
  if(verbosity >= 2) fprintf(stdout,"Traveling graph from %c:\n", entrypoint->id);
  travelGraph();
 }
 else {
  if(verbosity >= 0) fprintf(stdout,"No graph file found (or reading it failed)\n");
  printHelp(2);
 }
 freeAllNodes(first);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: correctInput char

variable_types: j int


getObjectColorQuadratic

repo: Fireblend/Yet-Another-RayTracer

decompiled_code:
__int64 __fastcall getObjectColorQuadratic(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 96) + 160LL);
}

original_code:
rgb* getObjectColorQuadratic(struct object *quadratic){
 QuadraticData *data = (QuadraticData*)quadratic->data;
 return data->color;
}

canonical_original_code:
struct rgb *getObjectColorQuadratic(struct object *quadratic){
 struct QuadraticData *data = (QuadraticData*)quadratic->data;
 return data->color;
}

variable_types: struct object { long double position[3]; struct intDataNode { struct intData { long double t; long double *vector; struct object *obj; long double u; } *data; struct intDataNode *next; } *(*getIntersection)(long double *eye, long double *directionV, struct object *obj); struct rgb *(*getColorAt)(long double *eye, long double *directionV, struct intData *obj, struct lightNode { long double *data; long double c1; struct lightNode *next; } *lights, int rDepth, int tDepth); long double *(*getNormalV)(long double *intersection, struct object *obj); struct rgb *(*getObjectColor)(struct object *obj); struct rgb *(*getTexturesColor)(struct intData *inter); long double **(*getBumpmapVects)(struct intData *inter, struct object *sphere); void *data; long double ka; int texCount; struct objTexture { long double thRes; int mode; struct objTexture *next; } *textList; int planeCount; int *planes; int hasCutout; struct textureNode { struct rgb *data; int width; int height; int mode; struct textureNode *next; } *cutout; struct textureNode *bumpmap; int kn; long double kr; } *

variable_types: struct QuadraticData { long double A; struct rgb { float r; float g; float b; } *color; } *

user_defined_types: struct object { long double position[3]; struct intDataNode *(*getIntersection)(long double *eye, long double *directionV, struct object *obj); struct rgb *(*getColorAt)(long double *eye, long double *directionV, struct intData *obj, struct lightNode *lights, int rDepth, int tDepth); long double *(*getNormalV)(long double *intersection, struct object *obj); struct rgb *(*getObjectColor)(struct object *obj); struct rgb *(*getTexturesColor)(struct intData *inter); long double **(*getBumpmapVects)(struct intData *inter, struct object *sphere); void *data; long double ka; int texCount; struct objTexture *textList; int planeCount; int *planes; int hasCutout; struct textureNode *cutout; struct textureNode *bumpmap; int kn; long double kr; }

user_defined_types: struct QuadraticData { long double A; struct rgb *color; }

user_defined_types: struct intDataNode { struct intData *data; struct intDataNode *next; }


getIntersectionQuadratic

decompiled_code:
__int64 __fastcall getIntersectionQuadratic(long double *a1, long double *a2, __int64 a3)
{
long double *v4; // rax
long double v5; // fst6
long double v6; // fst5
long double v7; // fst3
long double v8; // rt0
double v9; // xmm0_8
long double v10; // fst3
long double v11; // fst2
long double v12; // fst3
long double v13; // fst6
long double v14; // fst5
__int64 v15; // rbp
__int64 v17; // r12
long double v18; // [rsp+70h] [rbp-D8h]
long double v19; // [rsp+80h] [rbp-C8h]
long double v20; // [rsp+90h] [rbp-B8h]
long double v21; // [rsp+A0h] [rbp-A8h]
long double v22; // [rsp+B0h] [rbp-98h]
double v23; // [rsp+B0h] [rbp-98h]
long double v24; // [rsp+C0h] [rbp-88h]
long double v25; // [rsp+D0h] [rbp-78h]
long double v26; // [rsp+F0h] [rbp-58h]

v4 = *(long double **)(a3 + 96);
v5 = v4[3];
v22 = v4[4];
v6 = *a2;
v7 = a2[2];
v21 = *a1;
v18 = a1[2];
v8 = a1[1];
v9 = v7;
v19 = a2[1];
v20 = v7;
v10 = v6 * v5 * v19 + v19 * v22 * v7 + v4[5] * v6 * v7;
v25 = v4[1];
v26 = *v4 * ((double)v6 * (double)v6) + v25 * ((double)v19 * (double)v19) + v4[2] * (v9 * v9) + v10 + v10;
v24 = v8 * v22;
v11 = v4[5] * v18;
v12 = *v4 * v21 * v6
+ v8 * v25 * v19
+ v4[2] * v18 * v20
+ v19 * (v21 * v5)
+ v5 * v8 * v6
+ v20 * v24
+ v18 * v22 * v19
+ v6 * v11
+ v21 * v4[5] * v20
+ v6 * v4[6]
+ v19 * v4[7]
+ v20 * v4[8];
v13 = v8 * v4[7] + v21 * v4[6] + v21 * v5 * v8 + v24 * v18 + v11 * v21 + v18 * v4[8];
v14 = (double)(v12 + v12) * (double)(v12 + v12)
- (v13
+ v13
+ *v4 * ((double)v21 * (double)v21)
+ v25 * ((double)v8 * (double)v8)
+ v4[2] * ((double)v18 * (double)v18)
+ v4[9])
* (v26
* 4.0);
if ( v14 > 0.0001 )
{
v23 = v14;
if ( (double)v14 < 0.0 )
{
sqrt(v23);
v15 = createDataNode(1LL, a3);
sqrt(v23);
}
else
{
v15 = createDataNode(1LL, a3);
}
v17 = createDataNode(1LL, a3);
if ( (unsigned int)checkCutPlanes(v15, a3) )
{
v15 = 0LL;
if ( !(unsigned int)checkCutPlanes(v17, a3) )
v15 = v17;
}
else if ( !(unsigned int)checkCutPlanes(v17, a3) )
{
*(_QWORD *)(v15 + 8) = v17;
}
}
else
{
v15 = 0LL;
if ( v14 < 0.0000001 )
{
v15 = 0LL;
if ( v14 > -0.0000001 )
{
v15 = createDataNode(1LL, a3);
if ( !(unsigned int)checkCutPlanes(v15, a3) )
v15 = 0LL;
}
}
}
return v15;
}

original_code:
intDataNode *getIntersectionQuadratic(long double *eye, long double *directionV, object *obj){
 QuadraticData *data = (QuadraticData*)obj->data;
 long double A, B, C, D, E, F, G, H, J, K, a, b, c, xd, yd, zd, xe, ye, ze;
 A = data->A;
 B = data->B;
 C = data->C;
 D = data->D;
 E = data->E;
 F = data->F;
 G = data->G;
 H = data->H;
 J = data->J;
 K = data->K;
 xd = directionV[0];
 yd = directionV[1];
 zd = directionV[2];
 xe = eye[0];
 ye = eye[1];
 ze = eye[2];
 a = (A * pow(xd, 2)) + (B * pow(yd, 2))+ (C * pow(zd, 2)) + (2*((D*xd*yd) + (E*yd*zd) + (F*xd*zd)));
 b = 2*((A*xe*xd)+(B*ye*yd)+(C*ze*zd)+(D*xe*yd)+(D*ye*xd)
 +(E*ye*zd)+(E*ze*yd)+(F*ze*xd)+(F*xe*zd)+(G*xd)+(H*yd)+(J*zd));
 c = (A*pow(xe, 2)) + (B*pow(ye, 2))+
   (C*pow(ze, 2)) + (2*((D*xe*ye) + (E*ye*ze) + (F*ze*xe)+
     (G*xe) + (H*ye) + (J*ze))) + K;
 long double disc = pow(b, 2)-(4*a*c);
 long double t;
 if(disc > 0.0001){
  t = ((-b) - sqrt(disc))/(2*a);
  intDataNode *newDataNode = createDataNode(t, xe, ye, ze, xd, yd, zd, 1, obj);
  t = ((-b) + sqrt(disc))/(2*a);
  intDataNode *newDataNode2 = createDataNode(t, xe, ye, ze, xd, yd, zd, 1, obj);
  if(checkCutPlanes(newDataNode, obj)){
   if(checkCutPlanes(newDataNode2, obj)){
    return ((void *)0);
   }
   else{
    return newDataNode2;
   }
  }
  else{
   if(checkCutPlanes(newDataNode2, obj)){
    return newDataNode;
   }
   else{
    newDataNode->next = newDataNode2;
    return newDataNode;
   }
  }
 }
 else if (disc < 0.0000001 && disc > -0.0000001){
  t = (-b)/(2*a);
  intDataNode *newDataNode = createDataNode(t, xe, ye, ze, xd, yd, zd, 1, obj);
  if(checkCutPlanes(newDataNode, obj)){
   return newDataNode;
  }
  else{
   return ((void *)0);
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct intDataNode *getIntersectionQuadratic(long double *eye, long double *directionV, struct object *obj){
 struct QuadraticData *data = (QuadraticData*)obj->data;
 long double A; long double B; long double C; long double D; long double E; long double F; long double G; long double H; long double J; long double K; long double a; long double b; long double c; long double xd; long double yd; long double zd; long double xe; long double ye; long double ze;
 A = data->A;
 B = data->B;
 C = data->C;
 D = data->D;
 E = data->E;
 F = data->F;
 G = data->G;
 H = data->H;
 J = data->J;
 K = data->K;
 xd = directionV[0];
 yd = directionV[1];
 zd = directionV[2];
 xe = eye[0];
 ye = eye[1];
 ze = eye[2];
 a = (A * pow(xd, 2)) + (B * pow(yd, 2))+ (C * pow(zd, 2)) + (2*((D*xd*yd) + (E*yd*zd) + (F*xd*zd)));
 b = 2*((A*xe*xd)+(B*ye*yd)+(C*ze*zd)+(D*xe*yd)+(D*ye*xd)
 +(E*ye*zd)+(E*ze*yd)+(F*ze*xd)+(F*xe*zd)+(G*xd)+(H*yd)+(J*zd));
 c = (A*pow(xe, 2)) + (B*pow(ye, 2))+
   (C*pow(ze, 2)) + (2*((D*xe*ye) + (E*ye*ze) + (F*ze*xe)+
     (G*xe) + (H*ye) + (J*ze))) + K;
 long double disc = pow(b, 2)-(4*a*c);
 long double t;
 if(disc > 0.0001){
  t = ((-b) - sqrt(disc))/(2*a);
  struct intDataNode *newDataNode = createDataNode(t, xe, ye, ze, xd, yd, zd, 1, obj);
  t = ((-b) + sqrt(disc))/(2*a);
  struct intDataNode *newDataNode2 = createDataNode(t, xe, ye, ze, xd, yd, zd, 1, obj);
  if(checkCutPlanes(newDataNode, obj)){
   if(checkCutPlanes(newDataNode2, obj)){
    return ((void *)0);
   }
   else{
    return newDataNode2;
   }
  }
  else{
   if(checkCutPlanes(newDataNode2, obj)){
    return newDataNode;
   }
   else{
    newDataNode->next = newDataNode2;
    return newDataNode;
   }
  }
 }
 else if (disc < 0.0000001 && disc > -0.0000001){
  t = (-b)/(2*a);
  struct intDataNode *newDataNode = createDataNode(t, xe, ye, ze, xd, yd, zd, 1, obj);
  if(checkCutPlanes(newDataNode, obj)){
   return newDataNode;
  }
  else{
   return ((void *)0);
  }
 }
 return ((void *)0);
}

variable_types:
eye
long double *

variable_types:
directionV
long double *

variable_types:
obj
struct object *

variable_types:
A
long double

variable_types:
B
long double

variable_types:
C
long double

variable_types:
D
long double

variable_types:
E
long double

variable_types:
F
long double

variable_types:
G
long double

variable_types:
H
long double

variable_types:
J
long double

variable_types:
K
long double

variable_types:
a
long double

variable_types:
b
long double

variable_types:
c
long double

variable_types:
xd
long double

variable_types:
yd
long double

variable_types:
zd
long double

variable_types:
xe
long double

variable_types:
ye
long double

variable_types:
ze
long double

variable_types:
disc
long double

variable_types:
t
long double

variable_types: struct intDataNode { struct intData { long double t; long double *vector; struct object { long double position[3]; struct intDataNode *(*getIntersection)(long double *eye, long double *directionV, struct object *obj); struct rgb { float r; float g; float b; } *(*getColorAt)(long double *eye, long double *directionV, struct intData *obj, struct lightNode { long double *data; long double c1; struct lightNode *next; } *lights, int rDepth, int tDepth); long double *(*getNormalV)(long double *intersection, struct object *obj); struct rgb *(*getObjectColor)(struct object *obj); struct rgb *(*getTexturesColor)(struct intData *inter); long double **(*getBumpmapVects)(struct intData *inter, struct object *sphere); void *data; long double ka; int texCount; struct objTexture { long double thRes; int mode; struct objTexture *next; } *textList; int planeCount; int *planes; int hasCutout; struct textureNode { struct rgb *data; int width; int height; int mode; struct textureNode *next; } *cutout; struct textureNode *bumpmap; int kn; long double kr; } *obj; long double u; } *data; struct intDataNode *next; } *

user_defined_types: struct intData { long double t; long double *vector; struct object *obj; long double u; }


getTexturesColorQuadratic

decompiled_code:
_DWORD *getTexturesColorQuadratic()
{
_DWORD *result; // rax

result = calloc(1uLL, 0xCuLL);
*result = LC6;
result[1] = LC6;
result[2] = LC6;
return result;
}

canonical_decompiled_code:
_DWORD *func2()
{
_DWORD *result; // rax

result = calloc(1uLL, 0xCuLL);
*result = LC6;
result[1] = LC6;
result[2] = LC6;
return result;
}

original_code:
rgb* getTexturesColorQuadratic(struct intData *inter){
 rgb *result = (rgb*) calloc (1, sizeof(rgb));
 result->r = 1; result->g = 1; result->b = 1;
 return result;
}

canonical_original_code:
struct rgb *getTexturesColorQuadratic(struct intData *inter){
 struct rgb *result = (rgb*) calloc (1, sizeof(rgb));
 result->r = 1; result->g = 1; result->b = 1;
 return result;
}

variable_types: struct intData { long double t; long double *vector; struct object { long double position[3]; struct intDataNode { struct intData *data; struct intDataNode *next; } *(*getIntersection)(long double *eye, long double *directionV, struct object *obj); struct rgb *(*getColorAt)(long double *eye, long double *directionV, struct intData *obj, struct lightNode { long double *data; long double c1; struct lightNode *next; } *lights, int rDepth, int tDepth); long double *(*getNormalV)(long double *intersection, struct object *obj); struct rgb *(*getObjectColor)(struct object *obj); struct rgb *(*getTexturesColor)(struct intData *inter); long double **(*getBumpmapVects)(struct intData *inter, struct object *sphere); void *data; long double ka; int texCount; struct objTexture { long double thRes; int mode; struct objTexture *next; } *textList; int planeCount; int *planes; int hasCutout; struct textureNode { struct rgb *data; int width; int height; int mode; struct textureNode *next; } *cutout; struct textureNode *bumpmap; int kn; long double kr; } *obj; long double u; } *

variable_types: struct rgb { float r; float g; float b; } *


getNormalVQuadratic

decompiled_code:
long double *__fastcall getNormalVQuadratic(long double *a1, __int64 a2)
{
long double *v2; // rbx
long double *v3; // rax
long double v4; // fst7
long double v5; // fst6
long double v6; // fst5
long double v7; // fst4
long double v8; // fst3
long double v9; // fst2
long double v10; // fst0
long double v11; // fst1
long double v12; // fst4
long double v13; // fst0
long double v14; // fst5
double v15; // xmm0_8
long double v16; // fst7
long double v18; // [rsp+0h] [rbp-58h]
long double v19; // [rsp+10h] [rbp-48h]
long double v20; // [rsp+20h] [rbp-38h]
long double v21; // [rsp+30h] [rbp-28h]

v2 = (long double *)calloc(3uLL, 0x10uLL);
v3 = *(long double **)(a2 + 96);
v4 = *a1;
v5 = a1[1];
v6 = a1[2];
v18 = v3[1];
v19 = v3[2];
v7 = v3[3];
v8 = v3[4];
v9 = v3[5];
v20 = v3[7];
v21 = v3[8];
v10 = *v3 * v4 + v5 * v7 + v6 * v9 + v3[6];
*v2 = v10;
v11 = v7;
v12 = v10;
v13 = v11 * v4 + v18 * v5 + v6 * v8 + v20;
v2[1] = v13;
v14 = v5 * v8 + v4 * v9 + v6 * v19 + v21;
v2[2] = v14;
v15 = (double)v14 * (double)v14 + (double)v13 * (double)v13 + (double)v12 * (double)v12;
if ( v15 < 0.0 )
v16 = sqrt(v15);
else
v16 = sqrt(v15);
*v2 = *v2 / v16;
v2[1] = v2[1] / v16;
v2[2] = v2[2] / v16;
return v2;
}

canonical_decompiled_code:
long double *__fastcall func3(long double *a1, __int64 a2)
{
long double *v2; // rbx
long double *v3; // rax
long double v4; // fst7
long double v5; // fst6
long double v6; // fst5
long double v7; // fst4
long double v8; // fst3
long double v9; // fst2
long double v10; // fst0
long double v11; // fst1
long double v12; // fst4
long double v13; // fst0
long double v14; // fst5
double v15; // xmm0_8
long double v16; // fst7
long double v18; // [rsp+0h] [rbp-58h]
long double v19; // [rsp+10h] [rbp-48h]
long double v20; // [rsp+20h] [rbp-38h]
long double v21; // [rsp+30h] [rbp-28h]

v2 = (long double *)calloc(3uLL, 0x10uLL);
v3 = *(long double **)(a2 + 96);
v4 = *a1;
v5 = a1[1];
v6 = a1[2];
v18 = v3[1];
v19 = v3[2];
v7 = v3[3];
v8 = v3[4];
v9 = v3[5];
v20 = v3[7];
v21 = v3[8];
v10 = *v3 * v4 + v5 * v7 + v6 * v9 + v3[6];
*v2 = v10;
v11 = v7;
v12 = v10;
v13 = v11 * v4 + v18 * v5 + v6 * v8 + v20;
v2[1] = v13;
v14 = v5 * v8 + v4 * v9 + v6 * v19 + v21;
v2[2] = v14;
v15 = (double)v14 * (double)v14 + (double)v13 * (double)v13 + (double)v12 * (double)v12;
if ( v15 < 0.0 )
v16 = sqrt(v15);
else
v16 = sqrt(v15);
*v2 = *v2 / v16;
v2[1] = v2[1] / v16;
v2[2] = v2[2] / v16;
return v2;
}

original_code:
long double *getNormalVQuadratic(long double *intersection, struct object* obj){
 long double *normal = (long double*) calloc(3, sizeof(long double));
 QuadraticData *data = (QuadraticData*)obj->data;
 long double xi, yi, zi, A, B, C, D, E, F, G, H, J, K;
 xi = intersection[0];
 yi = intersection[1];
 zi = intersection[2];
 A = data->A;
 B = data->B;
 C = data->C;
 D = data->D;
 E = data->E;
 F = data->F;
 G = data->G;
 H = data->H;
 J = data->J;
 K = data->K;
 normal[0] = (A*xi)+ (D*yi)+ (F*zi) + G;
 normal[1] = (D*xi) + (B*yi) + (E*zi) + H;
 normal[2] = (F*xi) + (E*yi) + (C*zi) + J;
 long double l = sqrt(pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2));
 normal[0] = normal[0]/l;
 normal[1] = normal[1]/l;
 normal[2] = normal[2]/l;
 return normal;
}

canonical_original_code:
long double *getNormalVQuadratic(long double *intersection, struct object *obj){
 long double *normal = (long double*) calloc(3, sizeof(long double));
 struct QuadraticData *data = (QuadraticData*)obj->data;
 long double xi; long double yi; long double zi; long double A; long double B; long double C; long double D; long double E; long double F; long double G; long double H; long double J; long double K;
 xi = intersection[0];
 yi = intersection[1];
 zi = intersection[2];
 A = data->A;
 B = data->B;
 C = data->C;
 D = data->D;
 E = data->E;
 F = data->F;
 G = data->G;
 H = data->H;
 J = data->J;
 K = data->K;
 normal[0] = (A*xi)+ (D*yi)+ (F*zi) + G;
 normal[1] = (D*xi) + (B*yi) + (E*zi) + H;
 normal[2] = (F*xi) + (E*yi) + (C*zi) + J;
 long double l = sqrt(pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2));
 normal[0] = normal[0]/l;
 normal[1] = normal[1]/l;
 normal[2] = normal[2]/l;
 return normal;
}

variable_types:
intersection
long double *

variable_types: struct object { long double position[3]; struct intDataNode { struct intData { long double t; long double *vector; struct object *obj; long double u; } *data; struct intDataNode *next; } *(*getIntersection)(long double *eye, long double *directionV, struct object *obj); struct rgb { float r; float g; float b; } *(*getColorAt)(long double *eye, long double *directionV, struct intData *obj, struct lightNode { long double *data; long double c1; struct lightNode *next; } *lights, int rDepth, int tDepth); long double *(*getNormalV)(long double *intersection, struct object *obj); struct rgb *(*getObjectColor)(struct object *obj); struct rgb *(*getTexturesColor)(struct intData *inter); long double **(*getBumpmapVects)(struct intData *inter, struct object *sphere); void *data; long double ka; int texCount; struct objTexture { long double thRes; int mode; struct objTexture *next; } *textList; int planeCount; int *planes; int hasCutout; struct textureNode { struct rgb *data; int width; int height; int mode; struct textureNode *next; } *cutout; struct textureNode *bumpmap; int kn; long double kr; } *

variable_types:
normal
long double *

variable_types: struct QuadraticData { long double A; struct rgb { float r; float g; float b; } *color; } *

variable_types:
xi
long double

variable_types:
yi
long double

variable_types:
zi
long double

variable_types:
A
long double

variable_types:
B
long double

variable_types:
C
long double

variable_types:
D
long double

variable_types:
E
long double

variable_types:
F
long double

variable_types:
G
long double

variable_types:
H
long double

variable_types:
l
long double

return_type: long double *


createQuadraticData

decompiled_code:
long double *__fastcall createQuadraticData(long double a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7, long double a8, long double a9, long double a10, long double a11, long double a12, long double a13)
{
long double *v19; // rbx
float *v20; // rax

v19 = (long double *)calloc(1uLL, 0xB0uLL);
*v19 = a1;
v19[1] = a2;
v19[2] = a3;
v19[3] = a4;
v19[4] = a5;
v19[5] = a6;
v19[6] = a7;
v19[7] = a8;
v19[8] = a9;
v19[9] = a10;
v20 = (float *)calloc(1uLL, 0xCuLL);
*v20 = a11;
v20[1] = a12;
v20[2] = a13;
*((_QWORD *)v19 + 20) = v20;
return v19;
}

canonical_decompiled_code:
long double *__fastcall func4(long double a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7, long double a8, long double a9, long double a10, long double a11, long double a12, long double a13)
{
long double *v19; // rbx
float *v20; // rax

v19 = (long double *)calloc(1uLL, 0xB0uLL);
*v19 = a1;
v19[1] = a2;
v19[2] = a3;
v19[3] = a4;
v19[4] = a5;
v19[5] = a6;
v19[6] = a7;
v19[7] = a8;
v19[8] = a9;
v19[9] = a10;
v20 = (float *)calloc(1uLL, 0xCuLL);
*v20 = a11;
v20[1] = a12;
v20[2] = a13;
*((_QWORD *)v19 + 20) = v20;
return v19;
}

original_code:
QuadraticData *createQuadraticData(long double A,long double B,long double C,
long double D,long double E,long double F,long double G,long double H, long double J,long double K, long double r, long double g, long double b){
 QuadraticData *data = (QuadraticData*) calloc(1, sizeof(QuadraticData));
 data->A = A;
 data->B = B;
 data->C = C;
 data->D = D;
 data->E = E;
 data->F = F;
 data->G = G;
 data->H = H;
 data->J = J;
 data->K = K;
 rgb *ncolor = (rgb*) calloc(1, sizeof(rgb));
 ncolor->r = r;
 ncolor->g = g;
 ncolor->b = b;
 data->color = ncolor;
 return data;
}

canonical_original_code:
struct QuadraticData *createQuadraticData(long double A, long double B, long double C, long double D, long double E, long double F, long double G, long double H, long double J, long double K, long double r, long double g, long double b){
 struct QuadraticData *data = (QuadraticData*) calloc(1, sizeof(QuadraticData));
 data->A = A;
 data->B = B;
 data->C = C;
 data->D = D;
 data->E = E;
 data->F = F;
 data->G = G;
 data->H = H;
 data->J = J;
 data->K = K;
 struct rgb *ncolor = (rgb*) calloc(1, sizeof(rgb));
 ncolor->r = r;
 ncolor->g = g;
 ncolor->b = b;
 data->color = ncolor;
 return data;
}

variable_types:
J
long double

variable_types:
K
long double

variable_types:
r
long double

variable_types:
g
long double

variable_types:
b
long double

return_type: struct QuadraticData { long double A; struct rgb { float r; float g; float b; } *color; } *


addLight

decompiled_code:
long double *__fastcall addLight(long double **a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7, long double a8, long double a9, long double a10, long double a11)
{
long double *v16; // rbx
long double *result; // rax

v16 = (long double *)calloc(4uLL, 0x10uLL);
result = (long double *)malloc(0x80uLL);
if ( result )
{
*v16 = a2;
v16[1] = a3;
v16[2] = a4;
v16[3] = a8;
*((_QWORD *)result + 14) = *a1;
*a1 = result;
*(_QWORD *)result = v16;
result[1] = a9;
result[2] = a10;
result[3] = a11;
result[6] = a7;
result[5] = a6;
result[4] = a5;
}
return result;
}

canonical_decompiled_code:
long double *__fastcall func1(long double **a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7, long double a8, long double a9, long double a10, long double a11)
{
long double *v16; // rbx
long double *result; // rax

v16 = (long double *)calloc(4uLL, 0x10uLL);
result = (long double *)malloc(0x80uLL);
if ( result )
{
*v16 = a2;
v16[1] = a3;
v16[2] = a4;
v16[3] = a8;
*((_QWORD *)result + 14) = *a1;
*a1 = result;
*(_QWORD *)result = v16;
result[1] = a9;
result[2] = a10;
result[3] = a11;
result[6] = a7;
result[5] = a6;
result[4] = a5;
}
return result;
}

original_code:
lightNode *addLight(lightNode **previous, long double x, long double y, long double z, long double r, long double g, long double b, long double i, long double c1, long double c2, long double c3)
{
 long double *newData = (long double*)calloc(4, sizeof(long double));
 lightNode *newNode = malloc(sizeof(lightNode));
 if (newNode == ((void *)0))
 return ((void *)0);
 newData[0] = x;
 newData[1] = y;
 newData[2] = z;
 newData[3] = i;
 newNode->next = *previous;
 *previous = newNode;
 newNode->data = newData;
 newNode->c1 = c1;
 newNode->c2 = c2;
 newNode->c3 = c3;
 newNode->b = b;
 newNode->g = g;
 newNode->r = r;
 return *previous;
}

canonical_original_code:
struct lightNode *addLight(struct lightNode **previous, long double x, long double y, long double z, long double r, long double g, long double b, long double i, long double c1, long double c2, long double c3)
{
 long double *newData = (long double*)calloc(4, sizeof(long double));
 struct lightNode *newNode = malloc(sizeof(lightNode));
 if (newNode == ((void *)0))
 return ((void *)0);
 newData[0] = x;
 newData[1] = y;
 newData[2] = z;
 newData[3] = i;
 newNode->next = *previous;
 *previous = newNode;
 newNode->data = newData;
 newNode->c1 = c1;
 newNode->c2 = c2;
 newNode->c3 = c3;
 newNode->b = b;
 newNode->g = g;
 newNode->r = r;
 return *previous;
}

variable_types:
previous
struct lightNode **

variable_types:
x
long double

variable_types:
y
long double

variable_types:
z
long double

variable_types:
i
long double

variable_types:
newData
long double *

variable_types: struct lightNode { long double *data; long double c1; struct lightNode *next; } *


get

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

for ( result = a2; a1; --a1 )
result = *(_QWORD *)(result + 24);
return result;
}

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

for ( result = a2; a1; --a1 )
result = *(_QWORD *)(result + 24);
return result;
}

original_code:
textureNode *get(int count, textureNode *txt){
 textureNode *hey = txt;
 while(count != 0){
  hey = hey->next;
  count--;
 }
 return hey;
}

canonical_original_code:
struct textureNode *get(int count, struct textureNode *txt){
 struct textureNode *hey = txt;
 while(count != 0){
  hey = hey->next;
  count--;
 }
 return hey;
}

variable_types: count int

variable_types:
txt
struct textureNode *

variable_types: struct textureNode { struct rgb { float r; float g; float b; } *data; int width; int height; int mode; struct textureNode *next; } *

user_defined_types: struct textureNode { struct rgb *data; int width; int height; int mode; struct textureNode *next; }


addCutPlane

decompiled_code:
long double *__fastcall addCutPlane(long double **a1, long double *a2)
{
long double *v2; // r15
long double *v3; // r14
long double *v4; // rbp
long double v5; // fst7
long double v6; // fst6
long double v7; // fst5
long double v8; // fst4
long double v9; // fst3
long double v10; // rt1
long double v11; // fst3
long double v12; // fst2
long double v13; // fst0
double v14; // xmm0_8
long double v15; // fst7
long double *v16; // rbx
long double v18; // [rsp+0h] [rbp-78h]
long double v19; // [rsp+0h] [rbp-78h]
long double v20; // [rsp+0h] [rbp-78h]
long double v21; // [rsp+10h] [rbp-68h]
long double v22; // [rsp+20h] [rbp-58h]
long double v23; // [rsp+20h] [rbp-58h]
long double v24; // [rsp+30h] [rbp-48h]
long double v25; // [rsp+30h] [rbp-48h]
long double v26; // [rsp+40h] [rbp-38h]

v2 = (long double *)calloc(3uLL, 0x10uLL);
v3 = (long double *)calloc(3uLL, 0x10uLL);
v4 = (long double *)calloc(3uLL, 0x10uLL);
v5 = *a2;
v6 = a2[3] - v5;
*v2 = v6;
v7 = a2[1];
v8 = a2[4] - v7;
v2[1] = v8;
v18 = a2[2];
v9 = a2[5] - v18;
v2[2] = v9;
v10 = v9;
v11 = a2[6] - v5;
*v3 = v11;
v12 = a2[7] - v7;
v3[1] = v12;
v13 = a2[8] - v18;
v3[2] = v13;
v24 = v8 * v13 - v10 * v12;
v26 = v10 * v11 - v13 * v6;
v22 = v12 * v6 - v11 * v8;
v19 = -(v7 * v26 + v5 * v24 + v22 * v18);
v14 = (double)v22 * (double)v22 + (double)v26 * (double)v26 + (double)v24 * (double)v24;
if ( v14 < 0.0 )
v15 = sqrt(v14);
else
v15 = sqrt(v14);
v21 = v24 / v15;
*v4 = v21;
v25 = v26 / v15;
v4[1] = v25;
v23 = v22 / v15;
v4[2] = v23;
v20 = v19 / v15;
v16 = (long double *)malloc(0x50uLL);
if ( v16 )
{
*((_QWORD *)v16 + 8) = *a1;
*a1 = v16;
*v16 = v21;
v16[1] = v25;
v16[2] = v23;
v16[3] = v20;
free(v2);
free(v3);
free(v4);
}
return v16;
}

canonical_decompiled_code:
long double *__fastcall func3(long double **a1, long double *a2)
{
long double *v2; // r15
long double *v3; // r14
long double *v4; // rbp
long double v5; // fst7
long double v6; // fst6
long double v7; // fst5
long double v8; // fst4
long double v9; // fst3
long double v10; // rt1
long double v11; // fst3
long double v12; // fst2
long double v13; // fst0
double v14; // xmm0_8
long double v15; // fst7
long double *v16; // rbx
long double v18; // [rsp+0h] [rbp-78h]
long double v19; // [rsp+0h] [rbp-78h]
long double v20; // [rsp+0h] [rbp-78h]
long double v21; // [rsp+10h] [rbp-68h]
long double v22; // [rsp+20h] [rbp-58h]
long double v23; // [rsp+20h] [rbp-58h]
long double v24; // [rsp+30h] [rbp-48h]
long double v25; // [rsp+30h] [rbp-48h]
long double v26; // [rsp+40h] [rbp-38h]

v2 = (long double *)calloc(3uLL, 0x10uLL);
v3 = (long double *)calloc(3uLL, 0x10uLL);
v4 = (long double *)calloc(3uLL, 0x10uLL);
v5 = *a2;
v6 = a2[3] - v5;
*v2 = v6;
v7 = a2[1];
v8 = a2[4] - v7;
v2[1] = v8;
v18 = a2[2];
v9 = a2[5] - v18;
v2[2] = v9;
v10 = v9;
v11 = a2[6] - v5;
*v3 = v11;
v12 = a2[7] - v7;
v3[1] = v12;
v13 = a2[8] - v18;
v3[2] = v13;
v24 = v8 * v13 - v10 * v12;
v26 = v10 * v11 - v13 * v6;
v22 = v12 * v6 - v11 * v8;
v19 = -(v7 * v26 + v5 * v24 + v22 * v18);
v14 = (double)v22 * (double)v22 + (double)v26 * (double)v26 + (double)v24 * (double)v24;
if ( v14 < 0.0 )
v15 = sqrt(v14);
else
v15 = sqrt(v14);
v21 = v24 / v15;
*v4 = v21;
v25 = v26 / v15;
v4[1] = v25;
v23 = v22 / v15;
v4[2] = v23;
v20 = v19 / v15;
v16 = (long double *)malloc(0x50uLL);
if ( v16 )
{
*((_QWORD *)v16 + 8) = *a1;
*a1 = v16;
*v16 = v21;
v16[1] = v25;
v16[2] = v23;
v16[3] = v20;
free(v2);
free(v3);
free(v4);
}
return v16;
}

original_code:
cutPlane *addCutPlane(cutPlane **previous, ptsNode *points)
{
 long double d;
 long double *vect1 = (long double*) calloc(3, sizeof(long double));
 long double *vect2 = (long double*) calloc(3, sizeof(long double));
 long double *norm = (long double*) calloc(3, sizeof(long double));
 vect1[0] = points[1].x - points[0].x;
 vect1[1] = points[1].y - points[0].y;
 vect1[2] = points[1].z - points[0].z;
 vect2[0] = points[2].x - points[0].x;
 vect2[1] = points[2].y - points[0].y;
 vect2[2] = points[2].z - points[0].z;
 norm[0] = (vect1[1] * vect2[2]) - (vect2[1] * vect1[2]);
 norm[1] = (vect2[0] * vect1[2]) - (vect1[0] * vect2[2]);
 norm[2] = (vect1[0] * vect2[1]) - (vect2[0] * vect1[1]);
 d = -(norm[0]*points[0].x + norm[1]*points[0].y + norm[2]*points[0].z);
 long double l = sqrt(pow(norm[0],2) + pow(norm[1],2) + pow(norm[2],2));
 norm[0] = norm[0]/l;
 norm[1] = norm[1]/l;
 norm[2] = norm[2]/l;
 d = d/l;
 cutPlane *newNode = malloc(sizeof(cutPlane));
 if (newNode == ((void *)0))
  return ((void *)0);
 newNode->next = *previous;
 *previous = newNode;
 newNode->a = norm[0];
 newNode->b = norm[1];
 newNode->c = norm[2];
 newNode->d = d;
 free(vect1);
 free(vect2);
 free(norm);
 return *previous;
}

canonical_original_code:
struct cutPlane *addCutPlane(struct cutPlane **previous, struct ptsNode *points)
{
 long double d;
 long double *vect1 = (long double*) calloc(3, sizeof(long double));
 long double *vect2 = (long double*) calloc(3, sizeof(long double));
 long double *norm = (long double*) calloc(3, sizeof(long double));
 vect1[0] = points[1].x - points[0].x;
 vect1[1] = points[1].y - points[0].y;
 vect1[2] = points[1].z - points[0].z;
 vect2[0] = points[2].x - points[0].x;
 vect2[1] = points[2].y - points[0].y;
 vect2[2] = points[2].z - points[0].z;
 norm[0] = (vect1[1] * vect2[2]) - (vect2[1] * vect1[2]);
 norm[1] = (vect2[0] * vect1[2]) - (vect1[0] * vect2[2]);
 norm[2] = (vect1[0] * vect2[1]) - (vect2[0] * vect1[1]);
 d = -(norm[0]*points[0].x + norm[1]*points[0].y + norm[2]*points[0].z);
 long double l = sqrt(pow(norm[0],2) + pow(norm[1],2) + pow(norm[2],2));
 norm[0] = norm[0]/l;
 norm[1] = norm[1]/l;
 norm[2] = norm[2]/l;
 d = d/l;
 struct cutPlane *newNode = malloc(sizeof(cutPlane));
 if (newNode == ((void *)0))
  return ((void *)0);
 newNode->next = *previous;
 *previous = newNode;
 newNode->a = norm[0];
 newNode->b = norm[1];
 newNode->c = norm[2];
 newNode->d = d;
 free(vect1);
 free(vect2);
 free(norm);
 return *previous;
}

variable_types:
previous
struct cutPlane **

variable_types:
points
struct ptsNode { long double x; } *

variable_types:
d
long double

variable_types:
norm
long double *

variable_types: struct cutPlane { long double a; struct cutPlane *next; } *


getCutPlane

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

for ( result = a2; a1; --a1 )
result = *(_QWORD *)(result + 64);
return result;
}

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

for ( result = a2; a1; --a1 )
result = *(_QWORD *)(result + 64);
return result;
}

original_code:
cutPlane *getCutPlane(int count, cutPlane *planes){
 cutPlane *current = planes;
 while(count != 0){
  count--;
  current = current->next;
 }
 return current;
}

canonical_original_code:
struct cutPlane *getCutPlane(int count, struct cutPlane *planes){
 struct cutPlane *current = planes;
 while(count != 0){
  count--;
  current = current->next;
 }
 return current;
}

variable_types:
planes
struct cutPlane *

return_type: struct cutPlane { long double a; struct cutPlane *next; } *


getObjectColorDisc

decompiled_code:
__int64 __fastcall getObjectColorDisc(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 96) + 152LL);
}

original_code:
rgb* getObjectColorDisc(struct object *disc){
 DiscData *data = (DiscData*)disc->data;
 return data->color;
}

canonical_original_code:
struct rgb *getObjectColorDisc(struct object *disc){
 struct DiscData *data = (DiscData*)disc->data;
 return data->color;
}

variable_types: struct object { long double position[3]; struct intDataNode { struct intData { long double t; long double *vector; struct object *obj; long double u; } *data; struct intDataNode *next; } *(*getIntersection)(long double *eye, long double *directionV, struct object *obj); struct rgb *(*getColorAt)(long double *eye, long double *directionV, struct intData *obj, struct lightNode { long double *data; long double c1; struct lightNode *next; } *lights, int rDepth, int tDepth); long double *(*getNormalV)(long double *intersection, struct object *obj); struct rgb *(*getObjectColor)(struct object *obj); struct rgb *(*getTexturesColor)(struct intData *inter); long double **(*getBumpmapVects)(struct intData *inter, struct object *sphere); void *data; long double ka; int texCount; struct objTexture { long double thRes; int mode; struct objTexture *next; } *textList; int planeCount; int *planes; int hasCutout; struct textureNode { struct rgb *data; int width; int height; int mode; struct textureNode *next; } *cutout; struct textureNode *bumpmap; int kn; long double kr; } *

variable_types: struct DiscData { long double a; long double *origin; long double *V; long double *U; struct rgb { float r; float g; float b; } *color; } *

user_defined_types: struct DiscData { long double a; long double *origin; long double *V; long double *U; struct rgb *color; }


getNormalVDisc

decompiled_code:
long double *__fastcall getNormalVDisc(__int64 a1, __int64 a2)
{
long double *result; // rax
long double *v3; // rdx

result = (long double *)calloc(3uLL, 0x10uLL);
v3 = *(long double **)(a2 + 96);
*result = *v3;
result[1] = v3[1];
result[2] = v3[2];
return result;
}

canonical_decompiled_code:
long double *__fastcall func1(__int64 a1, __int64 a2)
{
long double *result; // rax
long double *v3; // rdx

result = (long double *)calloc(3uLL, 0x10uLL);
v3 = *(long double **)(a2 + 96);
*result = *v3;
result[1] = v3[1];
result[2] = v3[2];
return result;
}

original_code:
long double *getNormalVDisc(long double *intersection, struct object * obj){
 long double *V = (long double*)calloc(3, sizeof(long double));
 DiscData *data = (DiscData*)obj->data;
 V[0] = data->a;
 V[1] = data->b;
 V[2] = data->c;
 return V;
}

canonical_original_code:
long double *getNormalVDisc(long double *intersection, struct object *obj){
 long double *V = (long double*)calloc(3, sizeof(long double));
 struct DiscData *data = (DiscData*)obj->data;
 V[0] = data->a;
 V[1] = data->b;
 V[2] = data->c;
 return V;
}

variable_types:
intersection
long double *

variable_types: struct object { long double position[3]; struct intDataNode { struct intData { long double t; long double *vector; struct object *obj; long double u; } *data; struct intDataNode *next; } *(*getIntersection)(long double *eye, long double *directionV, struct object *obj); struct rgb { float r; float g; float b; } *(*getColorAt)(long double *eye, long double *directionV, struct intData *obj, struct lightNode { long double *data; long double c1; struct lightNode *next; } *lights, int rDepth, int tDepth); long double *(*getNormalV)(long double *intersection, struct object *obj); struct rgb *(*getObjectColor)(struct object *obj); struct rgb *(*getTexturesColor)(struct intData *inter); long double **(*getBumpmapVects)(struct intData *inter, struct object *sphere); void *data; long double ka; int texCount; struct objTexture { long double thRes; int mode; struct objTexture *next; } *textList; int planeCount; int *planes; int hasCutout; struct textureNode { struct rgb *data; int width; int height; int mode; struct textureNode *next; } *cutout; struct textureNode *bumpmap; int kn; long double kr; } *

variable_types:
V
long double *


getUVDisc

decompiled_code:
long double *getUVDisc()
{
long double *result; // rax

result = (long double *)calloc(2uLL, 0x10uLL);
*result = 0.5;
result[1] = *result;
return result;
}

canonical_decompiled_code:
long double *func2()
{
long double *result; // rax

result = (long double *)calloc(2uLL, 0x10uLL);
*result = 0.5;
result[1] = *result;
return result;
}

original_code:
long double *getUVDisc(struct intData *inter){
 long double *result = (long double*) calloc(2, sizeof(long double));
 result[0] = 0.5;
 result[1] = 0.5;
 return result;
}

variable_types: struct intData { long double t; long double *vector; struct object { long double position[3]; struct intDataNode { struct intData *data; struct intDataNode *next; } *(*getIntersection)(long double *eye, long double *directionV, struct object *obj); struct rgb { float r; float g; float b; } *(*getColorAt)(long double *eye, long double *directionV, struct intData *obj, struct lightNode { long double *data; long double c1; struct lightNode *next; } *lights, int rDepth, int tDepth); long double *(*getNormalV)(long double *intersection, struct object *obj); struct rgb *(*getObjectColor)(struct object *obj); struct rgb *(*getTexturesColor)(struct intData *inter); long double **(*getBumpmapVects)(struct intData *inter, struct object *sphere); void *data; long double ka; int texCount; struct objTexture { long double thRes; int mode; struct objTexture *next; } *textList; int planeCount; int *planes; int hasCutout; struct textureNode { struct rgb *data; int width; int height; int mode; struct textureNode *next; } *cutout; struct textureNode *bumpmap; int kn; long double kr; } *obj; long double u; } *

variable_types:
result
long double *


setup

repo: Fireedud/Brainfuck

decompiled_code:
void *__fastcall setup(int a1)
{
return calloc(a1, 4uLL);
}

canonical_decompiled_code:
void *__fastcall func7(int a1)
{
return calloc(a1, 4uLL);
}

original_code:
char *setup(int size)
{
 char *ptr = calloc(size, sizeof(int));
 return ptr;
}

variable_types: size int

variable_types:
ptr
char *

return_type: char *


eval

decompiled_code:
__int64 __fastcall eval(unsigned __int8 *a1, _BYTE *a2, __int64 a3)
{
__int64 result; // rax
int v6; // ebx
int v7; // eax
__int64 v8; // rax

result = *a1;
if ( (unsigned __int8)(result + 1) > 1u )
{
v6 = 0;
do
{
switch ( (char)result )
{
case '+':
++*a2;
break;
case ',':
*a2 = getchar();
break;
case '-':
--*a2;
break;
case '.':
putchar((char)*a2);
break;
case '<':
--a2;
break;
case '>':
++a2;
break;
case '[':
if ( *a2 )
{
v7 = *(_DWORD *)(a3 + 400) + 1;
*(_DWORD *)(a3 + 400) = v7;
if ( *(_DWORD *)(a3 + 4LL * v7) != v6 )
*(_DWORD *)(a3 + 4LL * v7) = v6;
}
else if ( a1[v6] != 93 )
{
v8 = v6 + 1;
do
v6 = v8++;
while ( a1[v8 - 1] != 93 );
}
break;
case ']':
if ( *a2 )
v6 = *(_DWORD *)(a3 + 4LL * *(int *)(a3 + 400));
else
--*(_DWORD *)(a3 + 400);
break;
default:
break;
}
result = a1[++v6];
}
while ( (unsigned __int8)(result + 1) > 1u );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int8 *a1, _BYTE *a2, __int64 a3)
{
__int64 result; // rax
int v6; // ebx
int v7; // eax
__int64 v8; // rax

result = *a1;
if ( (unsigned __int8)(result + 1) > 1u )
{
v6 = 0;
do
{
switch ( (char)result )
{
case '+':
++*a2;
break;
case ',':
*a2 = getchar();
break;
case '-':
--*a2;
break;
case '.':
putchar((char)*a2);
break;
case '<':
--a2;
break;
case '>':
++a2;
break;
case '[':
if ( *a2 )
{
v7 = *(_DWORD *)(a3 + 400) + 1;
*(_DWORD *)(a3 + 400) = v7;
if ( *(_DWORD *)(a3 + 4LL * v7) != v6 )
*(_DWORD *)(a3 + 4LL * v7) = v6;
}
else if ( a1[v6] != 93 )
{
v8 = v6 + 1;
do
v6 = v8++;
while ( a1[v8 - 1] != 93 );
}
break;
case ']':
if ( *a2 )
v6 = *(_DWORD *)(a3 + 4LL * *(int *)(a3 + 400));
else
--*(_DWORD *)(a3 + 400);
break;
default:
break;
}
result = a1[++v6];
}
while ( (unsigned __int8)(result + 1) > 1u );
}
return result;
}

original_code:
void eval(char line[], char *ptr, struct LeftBrackets *list)
{
 int i = 0;
 for(i=0; line[i] != (-1) && line[i] != '\0'; i++) {
  switch(line[i]) {
   case '>':
    ptr++;
    break;
   case '<':
    ptr--;
    break;
   case '+':
    (*ptr)++;
    break;
   case '-':
    (*ptr)--;
    break;
   case '.':
    putchar(*ptr);
    break;
   case ',':
    *ptr = getchar();
    break;
   case '[':
    if(*ptr == '\0') {
     int j = i;
     while(line[j] != ']'){
      j++;
     }
     i = j;
    } else {
     (list->counter)++;
     if(list->loc[(list->counter)] != i) {
      list->loc[list->counter] = i;
     }
    }
    break;
   case ']':
    if(*ptr != '\0') {
     i = list->loc[list->counter];
    } else {
     (list->counter)--;
    }
    break;
   default:
    break;
  }
 }
}

variable_types:
line
char []

variable_types: struct LeftBrackets { int loc[100]; int counter; } *

variable_types: i int

variable_types: j int


repo: FlorianHe/spacewar

decompiled_code:
int __fastcall is_dead(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // er13

v4 = *(_DWORD *)(a2 + 24);
graph_mort();
deletenode(a1, *(unsigned int *)(a2 + 24));
*(_DWORD *)(a3 + 4LL * v4 + 16) = 0;
return close(v4);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // er13

v4 = *(_DWORD *)(a2 + 24);
graph_mort();
deletenode(a1, *(unsigned int *)(a2 + 24));
*(_DWORD *)(a3 + 4LL * v4 + 16) = 0;
return close(v4);
}

original_code:
void is_dead(t_player **list, t_player *pl, t_serv *serv)
{
  int fd;
  fd = pl->player_fd;
  graph_mort(list, pl);
  deletenode(list, pl->player_fd);
  serv->fd_type[fd] = 0;
  close(fd);
}

canonical_original_code:
void is_dead(struct s_player **list, struct s_player *pl, struct s_serv *serv)
{
  int fd;
  fd = pl->player_fd;
  graph_mort(list, pl);
  deletenode(list, pl->player_fd);
  serv->fd_type[fd] = 0;
  close(fd);
}

variable_types: struct s_player { int X; int Y; int time; int essence; int rotation; int player_id; int player_fd; int nb_missile; struct s_missile { int x; int y; int rotation; int nb_tir; int time; int time_grav; struct s_missile *next; } *missile; struct s_player *next; } **

variable_types:
pl
struct s_player *

variable_types: struct s_serv { int player; int game; int port; int id_player; int fd_type[512]; void (*fct_read[512])(); struct s_player *next; } *

variable_types: fd int

user_defined_types: struct s_player { int X; int Y; int time; int essence; int rotation; int player_id; int player_fd; int nb_missile; struct s_missile *missile; struct s_player *next; }


decompiled_code:
unsigned int __fastcall applique_mort(__int64 a1, _DWORD *a2, __int64 a3)
{
int v3; // eax
unsigned int result; // eax

if ( (unsigned int)(*a2 - 405) <= 0x1E )
return is_dead(a1, (__int64)a2, a3);
if ( (unsigned int)(*a2 - 365) <= 0x1E
|| (v3 = a2[1], (unsigned int)(v3 - 405) <= 0x1E)
|| (result = v3 - 365, result <= 0x1E) )
{
result = is_dead(a1, (__int64)a2, a3);
}
return result;
}

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

if ( (unsigned int)(*a2 - 405) <= 0x1E )
return func0(a1, (__int64)a2, a3);
if ( (unsigned int)(*a2 - 365) <= 0x1E
|| (v3 = a2[1], (unsigned int)(v3 - 405) <= 0x1E)
|| (result = v3 - 365, result <= 0x1E) )
{
result = func0(a1, (__int64)a2, a3);
}
return result;
}

original_code:
void applique_mort(t_player **list, t_player *pl, t_serv *serv)
{
  if (pl->X - 20 >= 385 && pl->X - 20 <= 415)
    is_dead(list, pl, serv);
  else if (pl->X + 20 >= 385 && pl->X + 20 <= 415)
    is_dead(list, pl, serv);
  else if (pl->Y - 20 >= 385 && pl->Y - 20 <= 415)
    is_dead(list, pl, serv);
  else if (pl->Y + 20 >= 385 && pl->Y + 20 <= 415)
    is_dead(list, pl, serv);
}

canonical_original_code:
void applique_mort(struct s_player **list, struct s_player *pl, struct s_serv *serv)
{
  if (pl->X - 20 >= 385 && pl->X - 20 <= 415)
    is_dead(list, pl, serv);
  else if (pl->X + 20 >= 385 && pl->X + 20 <= 415)
    is_dead(list, pl, serv);
  else if (pl->Y - 20 >= 385 && pl->Y - 20 <= 415)
    is_dead(list, pl, serv);
  else if (pl->Y + 20 >= 385 && pl->Y + 20 <= 415)
    is_dead(list, pl, serv);
}

user_defined_types: struct s_serv { int player; int game; int port; int id_player; int fd_type[512]; void (*fct_read[512])(); struct s_player *next; }

user_defined_types: struct s_missile { int x; int y; int rotation; int nb_tir; int time; int time_grav; struct s_missile *next; }


mort

decompiled_code:
unsigned int __fastcall mort(__int64 *a1, __int64 a2)
{
__int64 i; // rbx
unsigned int result; // eax

for ( i = *a1; i; i = *(_QWORD *)(i + 40) )
{
if ( *(_DWORD *)(i + 24) )
result = applique_mort((__int64)a1, (_DWORD *)i, a2);
}
return result;
}

canonical_decompiled_code:
unsigned int __fastcall func2(__int64 *a1, __int64 a2)
{
__int64 i; // rbx
unsigned int result; // eax

for ( i = *a1; i; i = *(_QWORD *)(i + 40) )
{
if ( *(_DWORD *)(i + 24) )
result = func1((__int64)a1, (_DWORD *)i, a2);
}
return result;
}

original_code:
void mort(t_player **list, t_serv *serv)
{
  t_player *tmp;
  tmp = *list;
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 applique_mort(list, tmp, serv);
      tmp = tmp->next;
    }
}

canonical_original_code:
void mort(struct s_player **list, struct s_serv *serv)
{
  struct s_player *tmp;
  tmp = *list;
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 applique_mort(list, tmp, serv);
      tmp = tmp->next;
    }
}

variable_types: struct s_player { int X; int Y; int time; int essence; int rotation; int player_id; int player_fd; int nb_missile; struct s_missile { int x; int y; int rotation; int nb_tir; int time; int time_grav; struct s_missile *next; } *missile; struct s_player *next; } *


decompiled_code:
__int64 __fastcall gravite_top_left(__int64 a1, _DWORD *a2)
{
++*a2;
++a2[1];
return graph_avance();
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _DWORD *a2)
{
++*a2;
++a2[1];
return graph_avance();
}

original_code:
void gravite_top_left(t_player **list, t_player *pl)
{
  pl->X += 1;
  pl->Y += 1;
  graph_avance(list, pl);
}

canonical_original_code:
void gravite_top_left(struct s_player **list, struct s_player *pl)
{
  pl->X += 1;
  pl->Y += 1;
  graph_avance(list, pl);
}


decompiled_code:
__int64 __fastcall gravite_top_right(__int64 a1, _DWORD *a2)
{
--*a2;
++a2[1];
return graph_avance();
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _DWORD *a2)
{
--*a2;
++a2[1];
return graph_avance();
}

original_code:
void gravite_top_right(t_player **list, t_player *pl)
{
  pl->X -= 1;
  pl->Y += 1;
  graph_avance(list, pl);
}

canonical_original_code:
void gravite_top_right(struct s_player **list, struct s_player *pl)
{
  pl->X -= 1;
  pl->Y += 1;
  graph_avance(list, pl);
}


decompiled_code:
__int64 __fastcall gravite_bot_left(__int64 a1, _DWORD *a2)
{
++*a2;
--a2[1];
return graph_avance();
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _DWORD *a2)
{
++*a2;
--a2[1];
return graph_avance();
}

original_code:
void gravite_bot_left(t_player **list, t_player *pl)
{
  pl->X += 1;
  pl->Y -= 1;
  graph_avance(list, pl);
}

canonical_original_code:
void gravite_bot_left(struct s_player **list, struct s_player *pl)
{
  pl->X += 1;
  pl->Y -= 1;
  graph_avance(list, pl);
}


decompiled_code:
__int64 __fastcall gravite_bot_right(__int64 a1, _DWORD *a2)
{
--*a2;
--a2[1];
return graph_avance();
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _DWORD *a2)
{
--*a2;
--a2[1];
return graph_avance();
}

original_code:
void gravite_bot_right(t_player **list, t_player *pl)
{
  pl->X -= 1;
  pl->Y -= 1;
  graph_avance(list, pl);
}

canonical_original_code:
void gravite_bot_right(struct s_player **list, struct s_player *pl)
{
  pl->X -= 1;
  pl->Y -= 1;
  graph_avance(list, pl);
}


decompiled_code:
__int64 __fastcall applique_gravite(__int64 a1, int *a2)
{
int v2; // eax
int v3; // eax
__int64 result; // rax

v2 = a2[2];
if ( v2 <= 9999 )
{
result = (unsigned int)(v2 + 1);
a2[2] = result;
return result;
}
v3 = *a2;
if ( (unsigned int)*a2 > 0x190 )
{
result = (unsigned int)(v3 - 400);
if ( (unsigned int)result <= 0x190 )
goto LABEL_11;
}
else
{
if ( (unsigned int)a2[1] > 0x190 )
{
if ( (unsigned int)(v3 - 400) > 0x190 )
{
result = (unsigned int)(a2[1] - 400);
if ( (unsigned int)result <= 0x190 )
result = gravite_bot_left(a1, a2);
goto LABEL_14;
}
LABEL_11:
result = (unsigned int)(a2[1] - 400);
if ( (unsigned int)result <= 0x190 )
{
result = gravite_bot_right(a1, a2);
}
else if ( (unsigned int)a2[1] <= 0x190 )
{
result = gravite_top_right(a1, a2);
}
goto LABEL_14;
}
result = gravite_top_left(a1, a2);
}
LABEL_14:
a2[2] = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int *a2)
{
int v2; // eax
int v3; // eax
__int64 result; // rax

v2 = a2[2];
if ( v2 <= 9999 )
{
result = (unsigned int)(v2 + 1);
a2[2] = result;
return result;
}
v3 = *a2;
if ( (unsigned int)*a2 > 0x190 )
{
result = (unsigned int)(v3 - 400);
if ( (unsigned int)result <= 0x190 )
goto LABEL_11;
}
else
{
if ( (unsigned int)a2[1] > 0x190 )
{
if ( (unsigned int)(v3 - 400) > 0x190 )
{
result = (unsigned int)(a2[1] - 400);
if ( (unsigned int)result <= 0x190 )
result = func2(a1, a2);
goto LABEL_14;
}
LABEL_11:
result = (unsigned int)(a2[1] - 400);
if ( (unsigned int)result <= 0x190 )
{
result = func3(a1, a2);
}
else if ( (unsigned int)a2[1] <= 0x190 )
{
result = func1(a1, a2);
}
goto LABEL_14;
}
result = func0(a1, a2);
}
LABEL_14:
a2[2] = 0;
return result;
}

original_code:
void applique_gravite(t_player **list, t_player *pl)
{
  if (pl->time >= 10000)
    {
      if (pl->X >= 0 && pl->X <= 400 && pl->Y >= 0 && pl->Y <= 400)
 gravite_top_left(list, pl);
      else if (pl->X >= 400 && pl->X <= 800 && pl->Y <= 800 && pl->Y >= 400)
 gravite_bot_right(list, pl);
      else if (pl->X >= 0 && pl->X <= 400 && pl->Y <= 800 && pl->Y >= 400)
 gravite_bot_left(list, pl);
      else if (pl->X >= 400 && pl->X <= 800 && pl->Y <= 400 && pl->Y >= 0)
 gravite_top_right(list, pl);
      pl->time = 0;
    }
  else
    pl->time++;
}

canonical_original_code:
void applique_gravite(struct s_player **list, struct s_player *pl)
{
  if (pl->time >= 10000)
    {
      if (pl->X >= 0 && pl->X <= 400 && pl->Y >= 0 && pl->Y <= 400)
 gravite_top_left(list, pl);
      else if (pl->X >= 400 && pl->X <= 800 && pl->Y <= 800 && pl->Y >= 400)
 gravite_bot_right(list, pl);
      else if (pl->X >= 0 && pl->X <= 400 && pl->Y <= 800 && pl->Y >= 400)
 gravite_bot_left(list, pl);
      else if (pl->X >= 400 && pl->X <= 800 && pl->Y <= 400 && pl->Y >= 0)
 gravite_top_right(list, pl);
      pl->time = 0;
    }
  else
    pl->time++;
}


original_code:
void init_player(t_serv *serv, int fd)
{
  char buff[254];
  t_player new;
  t_player *tmp;
  new.X = rand() % 800;
  new.Y = rand() % 800;
  if (new.X >= 300 && new.X <= 500)
    new.X = rand() % 300;
  if (new.Y >= 300 && new.Y <= 500)
    new.Y = rand() % 300;
  new.player_id = serv->id_player++;
  new.player_fd = fd;
  new.missile = ((void *)0);
  addnode(&(serv->next), &new);
  memset(buff, '\0', 254);
  sprintf(buff, "New %d %d %d 0\n", new.player_id, new.X,
   new.Y);
  tmp = serv->next;
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 write(tmp->player_fd, buff, strlen(buff));
      tmp = tmp->next;
    }
}

canonical_original_code:
void init_player(struct s_serv *serv, int fd)
{
  char buff[254];
  struct s_player new;
  struct s_player *tmp;
  new.X = rand() % 800;
  new.Y = rand() % 800;
  if (new.X >= 300 && new.X <= 500)
    new.X = rand() % 300;
  if (new.Y >= 300 && new.Y <= 500)
    new.Y = rand() % 300;
  new.player_id = serv->id_player++;
  new.player_fd = fd;
  new.missile = ((void *)0);
  addnode(&(serv->next), &new);
  memset(buff, '\0', 254);
  sprintf(buff, "New %d %d %d 0\n", new.player_id, new.X,
   new.Y);
  tmp = serv->next;
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 write(tmp->player_fd, buff, strlen(buff));
      tmp = tmp->next;
    }
}

variable_types: struct s_serv { int player; int game; int port; int id_player; int fd_type[512]; void (*fct_read[512])(); struct s_player { int X; int Y; int time; int essence; int rotation; int player_id; int player_fd; int nb_missile; struct s_missile { int x; int y; int rotation; int nb_tir; int time; int time_grav; struct s_missile *next; } *missile; struct s_player *next; } *next; } *

variable_types:
buff
char [254]


decompiled_code:
unsigned int __fastcall add_player(__int64 a1, int a2)
{
unsigned int result; // eax
unsigned int *i; // rbx
size_t v4; // rax
size_t v5; // rax
char v6[248]; // [rsp+0h] [rbp-118h] BYREF
int v7; // [rsp+F8h] [rbp-20h]
__int16 v8; // [rsp+FCh] [rbp-1Ch]

result = init_player(a1, a2);
for ( i = *(unsigned int **)(a1 + 6160); i; i = (unsigned int *)*((_QWORD *)i + 5) )
{
result = i[6];
if ( result != a2 )
{
if ( result )
{
memset(v6, 0, sizeof(v6));
v7 = 0;
v8 = 0;
sprintf(v6, "New %d %d %d %d\n", i[5], *i, i[1], i[4]);
v4 = strlen(v6);
write(1, v6, v4);
v5 = strlen(v6);
result = write(a2, v6, v5);
}
}
}
return result;
}

canonical_decompiled_code:
unsigned int __fastcall func1(__int64 a1, int a2)
{
unsigned int result; // eax
unsigned int *i; // rbx
size_t v4; // rax
size_t v5; // rax
char v6[248]; // [rsp+0h] [rbp-118h] BYREF
int v7; // [rsp+F8h] [rbp-20h]
__int16 v8; // [rsp+FCh] [rbp-1Ch]

result = func0(a1, a2);
for ( i = *(unsigned int **)(a1 + 6160); i; i = (unsigned int *)*((_QWORD *)i + 5) )
{
result = i[6];
if ( result != a2 )
{
if ( result )
{
memset(v6, 0, sizeof(v6));
v7 = 0;
v8 = 0;
sprintf(v6, "New %d %d %d %d\n", i[5], *i, i[1], i[4]);
v4 = strlen(v6);
write(1, v6, v4);
v5 = strlen(v6);
result = write(a2, v6, v5);
}
}
}
return result;
}

original_code:
void add_player(t_serv *serv, int fd)
{
  t_player *tmp;
  char buff[254];
  init_player(serv, fd);
  tmp = serv->next;
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0 && tmp->player_fd != fd)
 {
   memset(buff, '\0', 254);
   sprintf(buff, "New %d %d %d %d\n", tmp->player_id, tmp->X,
    tmp->Y, tmp->rotation);
   write(1, buff, strlen(buff));
   write(fd, buff, strlen(buff));
 }
      tmp = tmp->next;
    }
}

canonical_original_code:
void add_player(struct s_serv *serv, int fd)
{
  struct s_player *tmp;
  char buff[254];
  init_player(serv, fd);
  tmp = serv->next;
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0 && tmp->player_fd != fd)
 {
   memset(buff, '\0', 254);
   sprintf(buff, "New %d %d %d %d\n", tmp->player_id, tmp->X,
    tmp->Y, tmp->rotation);
   write(1, buff, strlen(buff));
   write(fd, buff, strlen(buff));
 }
      tmp = tmp->next;
    }
}


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

v2 = xaccept(a2);
*(_DWORD *)(a1 + 4LL * v2 + 16) = 2;
*(_QWORD *)(a1 + 8LL * v2 + 2064) = &client_read;
return add_player(a1, v2);
}

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

v2 = xaccept(a2);
*(_DWORD *)(a1 + 4LL * v2 + 16) = 2;
*(_QWORD *)(a1 + 8LL * v2 + 2064) = &client_read;
return func1(a1, v2);
}

original_code:
void add_client(t_serv *e, int fd)
{
  int client;
  client = xaccept(fd);
  e->fd_type[client] = 2;
  e->fct_read[client] = client_read;
  add_player(e, client);
}

canonical_original_code:
void add_client(struct s_serv *e, int fd)
{
  int client;
  client = xaccept(fd);
  e->fd_type[client] = 2;
  e->fct_read[client] = client_read;
  add_player(e, client);
}

variable_types: client int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
const char *v4; // rdx
int v5; // [rsp+0h] [rbp-1838h] BYREF
int v6; // [rsp+4h] [rbp-1834h]
int v7; // [rsp+8h] [rbp-1830h]
int v8; // [rsp+Ch] [rbp-182Ch]
char v9[512]; // [rsp+10h] [rbp-1828h] BYREF
__int64 v10; // [rsp+1810h] [rbp-28h]

v6 = 5;
v5 = 2;
v7 = 4242;
v10 = 0LL;
v8 = 1;
v3 = time(0LL);
srand(v3);
checking(&v5, (unsigned int)argc, argv);
if ( (unsigned int)(v5 - 2) > 8 )
error((int)"Value must be between 2 and 10\n", argc, v4);
if ( (unsigned int)(v6 - 5) > 5 )
error((int)"Value must be between 5 and 10\n", argc, v4);
memset(v9, 0, sizeof(v9));
serveur(&v5);
while ( 1 )
run(&v5);
}

original_code:
int main(int ac, char **av)
{
  t_serv serv;
  serv.game = 5;
  serv.player = 2;
  serv.port = 4242;
  serv.next = ((void *)0);
  serv.id_player = 1;
  srand (time(((void *)0)));
  checking(&serv, ac, av);
  if (serv.player < 2 || serv.player > 10)
    error("Value must be between 2 and 10\n");
  if (serv.game < 5 || serv.game > 10)
    error("Value must be between 5 and 10\n");
  memset(serv.fd_type, 0, 512);
  serveur(&serv);
  while (1)
    run(&serv);
}

canonical_original_code:
int main(int ac, char **av)
{
  struct s_serv serv;
  serv.game = 5;
  serv.player = 2;
  serv.port = 4242;
  serv.next = ((void *)0);
  serv.id_player = 1;
  srand (time(((void *)0)));
  checking(&serv, ac, av);
  if (serv.player < 2 || serv.player > 10)
    error("Value must be between 2 and 10\n");
  if (serv.game < 5 || serv.game > 10)
    error("Value must be between 5 and 10\n");
  memset(serv.fd_type, 0, 512);
  serveur(&serv);
  while (1)
    run(&serv);
}

variable_types: ac int

variable_types:
av
char **

variable_types: struct s_serv { int player; int game; int port; int id_player; int fd_type[512]; void (*fct_read[512])(); struct s_player { int X; int Y; int time; int essence; int rotation; int player_id; int player_fd; int nb_missile; struct s_missile { int x; int y; int rotation; int nb_tir; int time; int time_grav; struct s_missile *next; } *missile; struct s_player *next; } *next; }


xaccept

decompiled_code:
__int64 __fastcall xaccept(int a1)
{
int v1; // eax
unsigned int v2; // ebp
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF

addr_len = 16;
v1 = accept(a1, &addr, &addr_len);
if ( a1 == -1 )
{
write(2, "ACCEPT ERROR\n", 0xDuLL);
if ( close(-1) == -1 )
{
write(2, "ERROR: close\n", 0xDuLL);
exit(0);
}
exit(1);
}
v2 = v1;
write(1, "NEW CONNECTION SUCCESS\n", 0x17uLL);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
int v1; // eax
unsigned int v2; // ebp
socklen_t addr_len; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-28h] BYREF

addr_len = 16;
v1 = accept(a1, &addr, &addr_len);
if ( a1 == -1 )
{
write(2, "ACCEPT ERROR\n", 0xDuLL);
if ( close(-1) == -1 )
{
write(2, "ERROR: close\n", 0xDuLL);
exit(0);
}
exit(1);
}
v2 = v1;
write(1, "NEW CONNECTION SUCCESS\n", 0x17uLL);
return v2;
}

original_code:
int xaccept(int fd)
{
  struct sockaddr_in sin;
  int sin_size;
  int client;
  sin_size = sizeof(sin);
  client = accept(fd, (struct sockaddr *)&sin, (socklen_t *)&sin_size);
  if (fd == -1)
    {
      write(2, "ACCEPT ERROR\n", 13);
      if (close(fd) == -1)
 {
   write (2, "ERROR: close\n", 13);
   exit(0);
 }
      exit(1);
    }
  write(1, "NEW CONNECTION SUCCESS\n", 23);
  return (client);
}

canonical_original_code:
int xaccept(int fd)
{
  struct sockaddr_in sin;
  int sin_size;
  int client;
  sin_size = sizeof(sin);
  client = accept(fd, (struct sockaddr *)&sin, (unsigned int *)&sin_size);
  if (fd == -1)
    {
      write(2, "ACCEPT ERROR\n", 13);
      if (close(fd) == -1)
 {
   write (2, "ERROR: close\n", 13);
   exit(0);
 }
      exit(1);
    }
  write(1, "NEW CONNECTION SUCCESS\n", 23);
  return (client);
}

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]; }

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]; }


decompiled_code:
int __fastcall graph_droite(__int64 *a1, __int64 a2)
{
__int64 v2; // rbx
int result; // eax
size_t v4; // rax
size_t v5; // rax
char v6[248]; // [rsp+0h] [rbp-108h] BYREF
int v7; // [rsp+F8h] [rbp-10h]
__int16 v8; // [rsp+FCh] [rbp-Ch]

v2 = *a1;
memset(v6, 0, sizeof(v6));
v7 = 0;
v8 = 0;
for ( result = sprintf(v6, "Dro %d %d\n", *(unsigned int *)(a2 + 20), *(unsigned int *)(a2 + 16));
v2;
v2 = *(_QWORD *)(v2 + 40) )
{
if ( *(_DWORD *)(v2 + 24) )
{
v4 = strlen(v6);
write(1, v6, v4);
v5 = strlen(v6);
result = write(*(_DWORD *)(v2 + 24), v6, v5);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 *a1, __int64 a2)
{
__int64 v2; // rbx
int result; // eax
size_t v4; // rax
size_t v5; // rax
char v6[248]; // [rsp+0h] [rbp-108h] BYREF
int v7; // [rsp+F8h] [rbp-10h]
__int16 v8; // [rsp+FCh] [rbp-Ch]

v2 = *a1;
memset(v6, 0, sizeof(v6));
v7 = 0;
v8 = 0;
for ( result = sprintf(v6, "Dro %d %d\n", *(unsigned int *)(a2 + 20), *(unsigned int *)(a2 + 16));
v2;
v2 = *(_QWORD *)(v2 + 40) )
{
if ( *(_DWORD *)(v2 + 24) )
{
v4 = strlen(v6);
write(1, v6, v4);
v5 = strlen(v6);
result = write(*(_DWORD *)(v2 + 24), v6, v5);
}
}
return result;
}

original_code:
void graph_droite(t_player **list, t_player *perso)
{
  t_player *tmp;
  char buff[254];
  tmp = *list;
  memset(buff, '\0', 254);
  sprintf(buff, "Dro %d %d\n", perso->player_id, perso->rotation);
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 {
   write(1, buff, strlen(buff));
   write(tmp->player_fd, buff, strlen(buff));
 }
      tmp = tmp->next;
    }
}

canonical_original_code:
void graph_droite(struct s_player **list, struct s_player *perso)
{
  struct s_player *tmp;
  char buff[254];
  tmp = *list;
  memset(buff, '\0', 254);
  sprintf(buff, "Dro %d %d\n", perso->player_id, perso->rotation);
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 {
   write(1, buff, strlen(buff));
   write(tmp->player_fd, buff, strlen(buff));
 }
      tmp = tmp->next;
    }
}

variable_types:
perso
struct s_player *


decompiled_code:
__int64 __fastcall gravite_top_left_tir(__int64 a1, _DWORD *a2)
{
++*a2;
++a2[1];
return graph_tir();
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _DWORD *a2)
{
++*a2;
++a2[1];
return graph_tir();
}

original_code:
void gravite_top_left_tir(t_player **list, t_missile *tir)
{
  tir->x += 1;
  tir->y += 1;
  graph_tir(list, tir);
}

canonical_original_code:
void gravite_top_left_tir(struct s_player **list, struct s_missile *tir)
{
  tir->x += 1;
  tir->y += 1;
  graph_tir(list, tir);
}

variable_types:
tir
struct s_missile *


decompiled_code:
__int64 __fastcall gravite_top_right_tir(__int64 a1, _DWORD *a2)
{
--*a2;
++a2[1];
return graph_tir();
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _DWORD *a2)
{
--*a2;
++a2[1];
return graph_tir();
}

original_code:
void gravite_top_right_tir(t_player **list, t_missile *tir)
{
  tir->x -= 1;
  tir->y += 1;
  graph_tir(list, tir);
}

canonical_original_code:
void gravite_top_right_tir(struct s_player **list, struct s_missile *tir)
{
  tir->x -= 1;
  tir->y += 1;
  graph_tir(list, tir);
}


decompiled_code:
__int64 __fastcall gravite_bot_left_tir(__int64 a1, _DWORD *a2)
{
++*a2;
--a2[1];
return graph_tir();
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _DWORD *a2)
{
++*a2;
--a2[1];
return graph_tir();
}

original_code:
void gravite_bot_left_tir(t_player **list, t_missile *tir)
{
  tir->x += 1;
  tir->y -= 1;
  graph_tir(list, tir);
}

canonical_original_code:
void gravite_bot_left_tir(struct s_player **list, struct s_missile *tir)
{
  tir->x += 1;
  tir->y -= 1;
  graph_tir(list, tir);
}


decompiled_code:
__int64 __fastcall gravite_bot_right_tir(__int64 a1, _DWORD *a2)
{
--*a2;
--a2[1];
return graph_tir();
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _DWORD *a2)
{
--*a2;
--a2[1];
return graph_tir();
}

original_code:
void gravite_bot_right_tir(t_player **list, t_missile *tir)
{
  tir->x -= 1;
  tir->y -= 1;
  graph_tir(list, tir);
}

canonical_original_code:
void gravite_bot_right_tir(struct s_player **list, struct s_missile *tir)
{
  tir->x -= 1;
  tir->y -= 1;
  graph_tir(list, tir);
}


decompiled_code:
__int64 __fastcall gravite_tir(__int64 a1, int *a2)
{
int v2; // eax
int v3; // eax
__int64 result; // rax

v2 = a2[5];
if ( v2 <= 2 )
{
result = (unsigned int)(v2 + 1);
a2[5] = result;
return result;
}
v3 = *a2;
if ( (unsigned int)*a2 > 0x190 )
{
result = (unsigned int)(v3 - 400);
if ( (unsigned int)result <= 0x190 )
goto LABEL_11;
}
else
{
if ( (unsigned int)a2[1] > 0x190 )
{
if ( (unsigned int)(v3 - 400) > 0x190 )
{
result = (unsigned int)(a2[1] - 400);
if ( (unsigned int)result <= 0x190 )
result = gravite_bot_left_tir(a1, a2);
goto LABEL_14;
}
LABEL_11:
result = (unsigned int)(a2[1] - 400);
if ( (unsigned int)result <= 0x190 )
{
result = gravite_bot_right_tir(a1, a2);
}
else if ( (unsigned int)a2[1] <= 0x190 )
{
result = gravite_top_right_tir(a1, a2);
}
goto LABEL_14;
}
result = gravite_top_left_tir(a1, a2);
}
LABEL_14:
a2[5] = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int *a2)
{
int v2; // eax
int v3; // eax
__int64 result; // rax

v2 = a2[5];
if ( v2 <= 2 )
{
result = (unsigned int)(v2 + 1);
a2[5] = result;
return result;
}
v3 = *a2;
if ( (unsigned int)*a2 > 0x190 )
{
result = (unsigned int)(v3 - 400);
if ( (unsigned int)result <= 0x190 )
goto LABEL_11;
}
else
{
if ( (unsigned int)a2[1] > 0x190 )
{
if ( (unsigned int)(v3 - 400) > 0x190 )
{
result = (unsigned int)(a2[1] - 400);
if ( (unsigned int)result <= 0x190 )
result = func2(a1, a2);
goto LABEL_14;
}
LABEL_11:
result = (unsigned int)(a2[1] - 400);
if ( (unsigned int)result <= 0x190 )
{
result = func3(a1, a2);
}
else if ( (unsigned int)a2[1] <= 0x190 )
{
result = func1(a1, a2);
}
goto LABEL_14;
}
result = func0(a1, a2);
}
LABEL_14:
a2[5] = 0;
return result;
}

original_code:
void gravite_tir(t_player **list, t_missile *tir)
{
  if (tir->time_grav >= 3)
    {
      if (tir->x >= 0 && tir->x <= 400 && tir->y >= 0 && tir->y <= 400)
 gravite_top_left_tir(list, tir);
      else if (tir->x >= 400 && tir->x <= 800 && tir->y <= 800 &&
        tir->y >= 400)
 gravite_bot_right_tir(list, tir);
      else if (tir->x >= 0 && tir->x <= 400 && tir->y <= 800 && tir->y >= 400)
 gravite_bot_left_tir(list, tir);
      else if (tir->x >= 400 && tir->x <= 800 && tir->y <= 400 && tir->y >= 0)
 gravite_top_right_tir(list, tir);
      tir->time_grav = 0;
    }
  else
    tir->time_grav++;
}

canonical_original_code:
void gravite_tir(struct s_player **list, struct s_missile *tir)
{
  if (tir->time_grav >= 3)
    {
      if (tir->x >= 0 && tir->x <= 400 && tir->y >= 0 && tir->y <= 400)
 gravite_top_left_tir(list, tir);
      else if (tir->x >= 400 && tir->x <= 800 && tir->y <= 800 &&
        tir->y >= 400)
 gravite_bot_right_tir(list, tir);
      else if (tir->x >= 0 && tir->x <= 400 && tir->y <= 800 && tir->y >= 400)
 gravite_bot_left_tir(list, tir);
      else if (tir->x >= 400 && tir->x <= 800 && tir->y <= 400 && tir->y >= 0)
 gravite_top_right_tir(list, tir);
      tir->time_grav = 0;
    }
  else
    tir->time_grav++;
}


decompiled_code:
int __fastcall graph_tir(__int64 *a1, unsigned int *a2)
{
__int64 v2; // rbx
int result; // eax
size_t v4; // rax
size_t v5; // rax
char v6[248]; // [rsp+0h] [rbp-108h] BYREF
int v7; // [rsp+F8h] [rbp-10h]
__int16 v8; // [rsp+FCh] [rbp-Ch]

v2 = *a1;
memset(v6, 0, sizeof(v6));
v7 = 0;
v8 = 0;
for ( result = sprintf(v6, "Tir %d %d %d\n", a2[3], *a2, a2[1]); v2; v2 = *(_QWORD *)(v2 + 40) )
{
if ( *(_DWORD *)(v2 + 24) )
{
v4 = strlen(v6);
write(1, v6, v4);
v5 = strlen(v6);
result = write(*(_DWORD *)(v2 + 24), v6, v5);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 *a1, unsigned int *a2)
{
__int64 v2; // rbx
int result; // eax
size_t v4; // rax
size_t v5; // rax
char v6[248]; // [rsp+0h] [rbp-108h] BYREF
int v7; // [rsp+F8h] [rbp-10h]
__int16 v8; // [rsp+FCh] [rbp-Ch]

v2 = *a1;
memset(v6, 0, sizeof(v6));
v7 = 0;
v8 = 0;
for ( result = sprintf(v6, "Tir %d %d %d\n", a2[3], *a2, a2[1]); v2; v2 = *(_QWORD *)(v2 + 40) )
{
if ( *(_DWORD *)(v2 + 24) )
{
v4 = strlen(v6);
write(1, v6, v4);
v5 = strlen(v6);
result = write(*(_DWORD *)(v2 + 24), v6, v5);
}
}
return result;
}

original_code:
void graph_tir(t_player **list, t_missile *tir)
{
  t_player *tmp;
  char buff[254];
  tmp = *list;
  memset(buff, '\0', 254);
  sprintf(buff, "Tir %d %d %d\n", tir->nb_tir, tir->x, tir->y);
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 {
   write(1, buff, strlen(buff));
   write(tmp->player_fd, buff, strlen(buff));
 }
      tmp = tmp->next;
    }
}

canonical_original_code:
void graph_tir(struct s_player **list, struct s_missile *tir)
{
  struct s_player *tmp;
  char buff[254];
  tmp = *list;
  memset(buff, '\0', 254);
  sprintf(buff, "Tir %d %d %d\n", tir->nb_tir, tir->x, tir->y);
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 {
   write(1, buff, strlen(buff));
   write(tmp->player_fd, buff, strlen(buff));
 }
      tmp = tmp->next;
    }
}


decompiled_code:
int __fastcall graph_tir_suppr(__int64 *a1, __int64 a2)
{
__int64 v2; // rbx
int result; // eax
size_t v4; // rax
size_t v5; // rax
char v6[248]; // [rsp+0h] [rbp-108h] BYREF
int v7; // [rsp+F8h] [rbp-10h]
__int16 v8; // [rsp+FCh] [rbp-Ch]

v2 = *a1;
memset(v6, 0, sizeof(v6));
v7 = 0;
v8 = 0;
for ( result = sprintf(v6, "MoT %d\n", *(unsigned int *)(a2 + 12)); v2; v2 = *(_QWORD *)(v2 + 40) )
{
if ( *(_DWORD *)(v2 + 24) )
{
v4 = strlen(v6);
write(1, v6, v4);
v5 = strlen(v6);
result = write(*(_DWORD *)(v2 + 24), v6, v5);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 *a1, __int64 a2)
{
__int64 v2; // rbx
int result; // eax
size_t v4; // rax
size_t v5; // rax
char v6[248]; // [rsp+0h] [rbp-108h] BYREF
int v7; // [rsp+F8h] [rbp-10h]
__int16 v8; // [rsp+FCh] [rbp-Ch]

v2 = *a1;
memset(v6, 0, sizeof(v6));
v7 = 0;
v8 = 0;
for ( result = sprintf(v6, "MoT %d\n", *(unsigned int *)(a2 + 12)); v2; v2 = *(_QWORD *)(v2 + 40) )
{
if ( *(_DWORD *)(v2 + 24) )
{
v4 = strlen(v6);
write(1, v6, v4);
v5 = strlen(v6);
result = write(*(_DWORD *)(v2 + 24), v6, v5);
}
}
return result;
}

original_code:
void graph_tir_suppr(t_player **list, t_missile *tir)
{
  t_player *tmp;
  char buff[254];
  tmp = *list;
  memset(buff, '\0', 254);
  sprintf(buff, "MoT %d\n", tir->nb_tir);
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 {
   write(1, buff, strlen(buff));
   write(tmp->player_fd, buff, strlen(buff));
 }
      tmp = tmp->next;
    }
}

canonical_original_code:
void graph_tir_suppr(struct s_player **list, struct s_missile *tir)
{
  struct s_player *tmp;
  char buff[254];
  tmp = *list;
  memset(buff, '\0', 254);
  sprintf(buff, "MoT %d\n", tir->nb_tir);
  while (tmp != ((void *)0))
    {
      if (tmp->player_fd != 0)
 {
   write(1, buff, strlen(buff));
   write(tmp->player_fd, buff, strlen(buff));
 }
      tmp = tmp->next;
    }
}


decompiled_code:
int __fastcall connection_close(__int64 a1, __int64 a2)
{
printf("%d: Connection closed\n", a2);
graph_close(a1 + 6160, (unsigned int)a2);
deletenode(a1 + 6160, (unsigned int)a2);
*(_DWORD *)(a1 + 4LL * (int)a2 + 16) = 0;
return close(a2);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2)
{
printf("%d: Connection closed\n", a2);
graph_close(a1 + 6160, (unsigned int)a2);
deletenode(a1 + 6160, (unsigned int)a2);
*(_DWORD *)(a1 + 4LL * (int)a2 + 16) = 0;
return close(a2);
}

original_code:
void connection_close(t_serv *serv, int fd)
{
  printf("%d: Connection closed\n", fd);
  graph_close(&(serv->next), fd);
  deletenode(&(serv->next), fd);
  serv->fd_type[fd] = 0;
  close(fd);
}

canonical_original_code:
void connection_close(struct s_serv *serv, int fd)
{
  printf("%d: Connection closed\n", fd);
  graph_close(&(serv->next), fd);
  deletenode(&(serv->next), fd);
  serv->fd_type[fd] = 0;
  close(fd);
}