original_code:
void Graphique_Dessin3DFull()
{
 SLTriangle *tmp;
 STriangle *t;
 SVecteur V1,V2,V;
 GLdouble col[3];
 tmp = tab.triangles->first;
 glEnable(0x0B57);
 glColorMaterial(0x0408,0x1602);
 glPolygonMode(0x0408, 0x1B02);
 glEnable(0x0B50);
 glEnable(0x4000);
 glEnable(0x0BA1);
 glBegin(0x0004);
 while(tmp!=((void *)0))
  {
  t=tmp->t;
  if((t->p1>3)&&(t->p2>3)&&(t->p3>3))
   {
   V1.x = tab.p[tmp->t->p2].x-tab.p[tmp->t->p1].x;
   V1.y = tab.p[tmp->t->p2].y-tab.p[tmp->t->p1].y;
   V1.z = tab.p[tmp->t->p2].z-tab.p[tmp->t->p1].z;
   V2.x = tab.p[tmp->t->p3].x-tab.p[tmp->t->p1].x;
   V2.y = tab.p[tmp->t->p3].y-tab.p[tmp->t->p1].y;
   V2.z = tab.p[tmp->t->p3].z-tab.p[tmp->t->p1].z;
   Vecteur_ProdVect(&V1,&V2,&V);
   glNormal3d(V.x, V.y, V.z) ;
   Graphique_GetColor(col,tab.p[t->p1].z);
   glColor3dv(col);
   glVertex3d(tab.p[t->p1].x,tab.p[t->p1].y,tab.p[t->p1].z);
   Graphique_GetColor(col,tab.p[t->p2].z);
   glColor3dv(col);
   glVertex3d(tab.p[t->p2].x,tab.p[t->p2].y,tab.p[t->p2].z);
   Graphique_GetColor(col,tab.p[t->p3].z);
   glColor3dv(col);
   glVertex3d(tab.p[t->p3].x,tab.p[t->p3].y,tab.p[t->p3].z);
   }
  tmp = tmp->next;
  }
 glEnd();
 glDisable(0x4000);
 glDisable(0x0B50);
 glDisable(0x0BA1);
}

canonical_original_code:
void Graphique_Dessin3DFull()
{
 struct sLTriangle *tmp;
 struct sTriangle *t;
 struct sVecteur V1; struct sVecteur V2; struct sVecteur V;
 double col[3];
 tmp = tab.triangles->first;
 glEnable(0x0B57);
 glColorMaterial(0x0408,0x1602);
 glPolygonMode(0x0408, 0x1B02);
 glEnable(0x0B50);
 glEnable(0x4000);
 glEnable(0x0BA1);
 glBegin(0x0004);
 while(tmp!=((void *)0))
  {
  t=tmp->t;
  if((t->p1>3)&&(t->p2>3)&&(t->p3>3))
   {
   V1.x = tab.p[tmp->t->p2].x-tab.p[tmp->t->p1].x;
   V1.y = tab.p[tmp->t->p2].y-tab.p[tmp->t->p1].y;
   V1.z = tab.p[tmp->t->p2].z-tab.p[tmp->t->p1].z;
   V2.x = tab.p[tmp->t->p3].x-tab.p[tmp->t->p1].x;
   V2.y = tab.p[tmp->t->p3].y-tab.p[tmp->t->p1].y;
   V2.z = tab.p[tmp->t->p3].z-tab.p[tmp->t->p1].z;
   Vecteur_ProdVect(&V1,&V2,&V);
   glNormal3d(V.x, V.y, V.z) ;
   Graphique_GetColor(col,tab.p[t->p1].z);
   glColor3dv(col);
   glVertex3d(tab.p[t->p1].x,tab.p[t->p1].y,tab.p[t->p1].z);
   Graphique_GetColor(col,tab.p[t->p2].z);
   glColor3dv(col);
   glVertex3d(tab.p[t->p2].x,tab.p[t->p2].y,tab.p[t->p2].z);
   Graphique_GetColor(col,tab.p[t->p3].z);
   glColor3dv(col);
   glVertex3d(tab.p[t->p3].x,tab.p[t->p3].y,tab.p[t->p3].z);
   }
  tmp = tmp->next;
  }
 glEnd();
 glDisable(0x4000);
 glDisable(0x0B50);
 glDisable(0x0BA1);
}

variable_types: struct sTriangle { int type; int flip_param; int p1; struct sTriangle *t1; struct sPoint { double x; } centre; double rayon; double critere; } *

variable_types:
V
struct sVecteur { double x; }

variable_types:
col
double [3]


repo: sbksba/Delaunay

decompiled_code:
__int64 __fastcall Graphique_RenderBitmapString(__int64 a1, _BYTE *a2, float a3, float a4)
{
__int64 result; // rax
_BYTE *v5; // rbx

result = HIDWORD(param[0]);
if ( (_DWORD)result )
{
v5 = a2;
glPushMatrix();
glColor3f(0.0, 1.0);
Graphique_SetOrthographicProjection();
glLoadIdentity();
glRasterPos2f(a3, a4);
if ( *a2 )
{
do
{
++v5;
glutBitmapCharacter(a1);
}
while ( *v5 );
}
Graphique_ResetPerspectiveProjection();
glPopMatrix();
result = glPopMatrix();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _BYTE *a2, float a3, float a4)
{
__int64 result; // rax
_BYTE *v5; // rbx

result = HIDWORD(param[0]);
if ( (_DWORD)result )
{
v5 = a2;
glPushMatrix();
glColor3f(0.0, 1.0);
func1();
glLoadIdentity();
glRasterPos2f(a3, a4);
if ( *a2 )
{
do
{
++v5;
glutBitmapCharacter(a1);
}
while ( *v5 );
}
func0();
glPopMatrix();
result = glPopMatrix();
}
return result;
}

original_code:
void Graphique_RenderBitmapString(float x, float y, void *font,char *string)
{
  char *c;
  if(param.texte)
 {
 glPushMatrix();
 glColor3f(0.0f,1.0f,1.0f);
 Graphique_SetOrthographicProjection();
 glLoadIdentity();
 glRasterPos2f(x, y);
 for (c=string; *c != '\0'; c++)
  {
      glutBitmapCharacter(font, *c);
  }
 Graphique_ResetPerspectiveProjection();
 glPopMatrix();
 glPopMatrix();
 }
}

canonical_original_code:
void Graphique_RenderBitmapString(float x, float y, void *font, char *string)
{
  char *c;
  if(param.texte)
 {
 glPushMatrix();
 glColor3f(0.0f,1.0f,1.0f);
 Graphique_SetOrthographicProjection();
 glLoadIdentity();
 glRasterPos2f(x, y);
 for (c=string; *c != '\0'; c++)
  {
      glutBitmapCharacter(font, *c);
  }
 Graphique_ResetPerspectiveProjection();
 glPopMatrix();
 glPopMatrix();
 }
}

variable_types: x float

variable_types: y float

variable_types:
font
void *

variable_types:
string
char *

variable_types:
c
char *

return_type: void


decompiled_code:
__int64 __fastcall Main_redimFenetre(int a1, int a2)
{
glViewport(0LL, 0LL, (unsigned int)a1, (unsigned int)a2);
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(40.0, (float)((float)a1 / (float)a2), 1.0, 25.0);
glMatrixMode(5888LL);
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
glViewport(0LL, 0LL, (unsigned int)a1, (unsigned int)a2);
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(40.0, (float)((float)a1 / (float)a2), 1.0, 25.0);
glMatrixMode(5888LL);
return glutPostRedisplay();
}

original_code:
void Main_redimFenetre(int largeur, int hauteur)
{
  GLfloat rapport = ((float)(largeur))/((float)(hauteur));
  glViewport(0,0,largeur,hauteur);
  glMatrixMode(0x1701);
  glLoadIdentity();
  gluPerspective(40,rapport,1.0,25.0);
  glMatrixMode(0x1700);
  glutPostRedisplay();
}

canonical_original_code:
void Main_redimFenetre(int largeur, int hauteur)
{
  float rapport = ((float)(largeur))/((float)(hauteur));
  glViewport(0,0,largeur,hauteur);
  glMatrixMode(0x1701);
  glLoadIdentity();
  gluPerspective(40,rapport,1.0,25.0);
  glMatrixMode(0x1700);
  glutPostRedisplay();
}

variable_types: largeur int

variable_types: hauteur int

variable_types: rapport float


decompiled_code:
__int64 Main_inserePoint()
{
__int64 result; // rax
double *v1; // rbx
double v2; // xmm0_8

if ( !param[0] )
{
DestCons_InserePoint();
result = (unsigned int)param[16];
if ( (result & 4) == 0 )
goto LABEL_3;
LABEL_10:
v1 = (double *)&tab[6 * tab[4] - 6];
v2 = TerrainImpl_CalcHeight(terrainimpl, v1[3], v1[4]);
result = (unsigned int)param[16];
v1[5] = v2;
goto LABEL_3;
}
FlipAlgo_InserePoint();
result = (unsigned int)param[16];
if ( (result & 4) != 0 )
goto LABEL_10;
LABEL_3:
if ( (result & 2) != 0 && __ROR4__(-286331153 * tab[0] + 143165576, 1) <= 0x8888888u )
{
Terran_VieilMont(0LL, **(_QWORD **)(*(_QWORD *)(**(_QWORD **)&tab[2] + 8LL) + 8LL), 20LL, 20LL, 1.0);
result = (unsigned int)param[16];
}
if ( (result & 1) != 0 )
{
result = (unsigned int)__ROR4__(-1030792151 * tab[0] + 85899344, 2);
if ( (unsigned int)result <= 0x28F5C28 )
result = Terran_JeuneMont(0LL, ***(_QWORD ***)&tab[2], 7LL, 0.5);
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
double *v1; // rbx
double v2; // xmm0_8

if ( !param[0] )
{
DestCons_InserePoint();
result = (unsigned int)param[16];
if ( (result & 4) == 0 )
goto LABEL_3;
LABEL_10:
v1 = (double *)&tab[6 * tab[4] - 6];
v2 = TerrainImpl_CalcHeight(terrainimpl, v1[3], v1[4]);
result = (unsigned int)param[16];
v1[5] = v2;
goto LABEL_3;
}
FlipAlgo_InserePoint();
result = (unsigned int)param[16];
if ( (result & 4) != 0 )
goto LABEL_10;
LABEL_3:
if ( (result & 2) != 0 && __ROR4__(-286331153 * tab[0] + 143165576, 1) <= 0x8888888u )
{
Terran_VieilMont(0LL, **(_QWORD **)(*(_QWORD *)(**(_QWORD **)&tab[2] + 8LL) + 8LL), 20LL, 20LL, 1.0);
result = (unsigned int)param[16];
}
if ( (result & 1) != 0 )
{
result = (unsigned int)__ROR4__(-1030792151 * tab[0] + 85899344, 2);
if ( (unsigned int)result <= 0x28F5C28 )
result = Terran_JeuneMont(0LL, ***(_QWORD ***)&tab[2], 7LL, 0.5);
}
return result;
}

original_code:
void Main_inserePoint()
{
  if(param.flip_algo)
    FlipAlgo_InserePoint();
  else
    DestCons_InserePoint();
  if(param.gentype&4)
    tab.p[tab.np-1].z = TerrainImpl_CalcHeight(terrainimpl,tab.p[tab.np-1].x,tab.p[tab.np-1].y);
  if(param.gentype&2)
    if (tab.nt%30==0) Terran_VieilMont(((void *)0),(tab.triangles->first->next->next->t),1.0,20,20);
  if(param.gentype&1)
    if(tab.nt%100==0) Terran_JeuneMont(((void *)0),(tab.triangles->first->t),0.5,7);
}


decompiled_code:
__int64 Main_timer()
{
if ( param[13] && !param[14] )
Main_inserePoint();
Main_affichage();
return glutTimerFunc((unsigned int)param[12], Main_timer, 0LL);
}

canonical_decompiled_code:
__int64 func3()
{
if ( param[13] && !param[14] )
func1();
func2();
return glutTimerFunc((unsigned int)param[12], Main_timer, 0LL);
}

original_code:
void Main_timer(int value)
{
  if((param.auto_insert)&&!param.stop_insert)
    Main_inserePoint();
  Main_affichage();
  glutTimerFunc(param.timer_wait,Main_timer, 0);
  (void) value;
}

variable_types: value int


decompiled_code:
__int64 Main_nextGeneration()
{
int v0; // eax
__int64 result; // rax

v0 = param[16] + 1;
if ( v0 > 7 )
{
param[16] = 1;
result = 0LL;
param[4] = 0;
}
else
{
param[16] = v0;
result = v0 & 4;
param[4] = result;
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // eax
__int64 result; // rax

v0 = param[16] + 1;
if ( v0 > 7 )
{
param[16] = 1;
result = 0LL;
param[4] = 0;
}
else
{
param[16] = v0;
result = v0 & 4;
param[4] = result;
}
return result;
}

original_code:
void Main_nextGeneration()
{
  param.gentype++;
  if(param.gentype>=8)
    param.gentype=1;
  param.show_impl = (param.gentype&4);
}


decompiled_code:
__int64 __fastcall Main_touchesSpeciales(int a1)
{
__int64 result; // rax
void *v2; // rdi

if ( a1 > 105 )
return glutPostRedisplay();
if ( a1 <= 99 )
{
if ( a1 <= 8 )
{
if ( a1 > 4 )
{
v2 = terrainimpl;
if ( !terrainimpl )
goto LABEL_19;
}
else
{
if ( a1 != 2 )
{
if ( a1 == 3 )
Main_nextGeneration();
return glutPostRedisplay();
}
v2 = terrainimpl;
if ( !terrainimpl )
{
LABEL_19:
terrainimpl = (void *)TerrainImpl_Init(-10.0, 10.0, -10.0, 10.0);
DestCons_ResetTab();
return glutPostRedisplay();
}
}
free(v2);
goto LABEL_19;
}
if ( a1 == 10 )
{
param[1] = param[1] == 0;
return glutPostRedisplay();
}
return glutPostRedisplay();
}
switch ( a1 )
{
case 'e':
*(double *)&param[10] = *(double *)&param[10] + 0.2;
result = glutPostRedisplay();
break;
case 'f':
*(double *)&param[6] = *(double *)&param[6] - 2.0;
result = glutPostRedisplay();
break;
case 'g':
*(double *)&param[10] = *(double *)&param[10] - 0.2;
result = glutPostRedisplay();
break;
case 'h':
*(double *)&param[8] = *(double *)&param[8] + 2.0;
result = glutPostRedisplay();
break;
case 'i':
*(double *)&param[8] = *(double *)&param[8] - 2.0;
result = glutPostRedisplay();
break;
default:
*(double *)&param[6] = *(double *)&param[6] + 2.0;
result = glutPostRedisplay();
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
__int64 result; // rax
void *v2; // rdi

if ( a1 > 105 )
return glutPostRedisplay();
if ( a1 <= 99 )
{
if ( a1 <= 8 )
{
if ( a1 > 4 )
{
v2 = terrainimpl;
if ( !terrainimpl )
goto LABEL_19;
}
else
{
if ( a1 != 2 )
{
if ( a1 == 3 )
func4();
return glutPostRedisplay();
}
v2 = terrainimpl;
if ( !terrainimpl )
{
LABEL_19:
terrainimpl = (void *)TerrainImpl_Init(-10.0, 10.0, -10.0, 10.0);
DestCons_ResetTab();
return glutPostRedisplay();
}
}
free(v2);
goto LABEL_19;
}
if ( a1 == 10 )
{
param[1] = param[1] == 0;
return glutPostRedisplay();
}
return glutPostRedisplay();
}
switch ( a1 )
{
case 'e':
*(double *)&param[10] = *(double *)&param[10] + 0.2;
result = glutPostRedisplay();
break;
case 'f':
*(double *)&param[6] = *(double *)&param[6] - 2.0;
result = glutPostRedisplay();
break;
case 'g':
*(double *)&param[10] = *(double *)&param[10] - 0.2;
result = glutPostRedisplay();
break;
case 'h':
*(double *)&param[8] = *(double *)&param[8] + 2.0;
result = glutPostRedisplay();
break;
case 'i':
*(double *)&param[8] = *(double *)&param[8] - 2.0;
result = glutPostRedisplay();
break;
default:
*(double *)&param[6] = *(double *)&param[6] + 2.0;
result = glutPostRedisplay();
break;
}
return result;
}

original_code:
void Main_touchesSpeciales(int touche, int x, int y)
{
  int tmp1,tmp2,tmp3;
  switch(touche)
    {
    case 0x0003:
      Main_nextGeneration();
      break;
    case 0x0002:
    case 0x0005:
    case 0x0006:
    case 0x0007:
    case 0x0008:
      if(terrainimpl!=((void *)0))
 {
   tmp1=terrainimpl->nb_montagnes;
   tmp2=terrainimpl->nb_centre-tmp1;
   free(terrainimpl);
 }
      else
 {tmp1=4;tmp2=4;}
      if(touche==0x0005)
 tmp1--;
      if(touche==0x0006)
 tmp1++;
      if(touche==0x0007)
 tmp2--;
      if(touche==0x0008)
 tmp2++;
      if(tmp1<0)
 tmp1=0;
      if(tmp2<0)
 tmp2=0;
      if(tmp1+tmp2>=200)
 {
   tmp3 = tmp1;
   tmp1 = (tmp1>tmp2)?tmp1-(tmp1+tmp2-200 +1):tmp1;
   tmp2 = (tmp3<tmp2)?tmp2-(tmp3+tmp2-200 +1):tmp2;
 }
      terrainimpl = TerrainImpl_Init(tmp1,tmp2,-10,10,-10,10);
      DestCons_ResetTab();
      break;
    case 0x000A:
      param.texte = ! param.texte;
      break;
    case 0x0065 :
      param.trans+=0.2;
      break;
    case 0x0067 :
      param.trans-=0.2;
      break;
    case 0x0066 :
      param.angle-=2.0;
      break;
    case 0x0064 :
      param.angle+=2.0;
      break;
    case 0x0068:
      param.angle2+= 2.0;
      break;
    case 0x0069:
      param.angle2-= 2.0;
      break;
    }
  glutPostRedisplay();
  (void) x;
  (void) y;
}

canonical_original_code:
void Main_touchesSpeciales(int touche, int x, int y)
{
  int tmp1; int tmp2; int tmp3;
  switch(touche)
    {
    case 0x0003:
      Main_nextGeneration();
      break;
    case 0x0002:
    case 0x0005:
    case 0x0006:
    case 0x0007:
    case 0x0008:
      if(terrainimpl!=((void *)0))
 {
   tmp1=terrainimpl->nb_montagnes;
   tmp2=terrainimpl->nb_centre-tmp1;
   free(terrainimpl);
 }
      else
 {tmp1=4;tmp2=4;}
      if(touche==0x0005)
 tmp1--;
      if(touche==0x0006)
 tmp1++;
      if(touche==0x0007)
 tmp2--;
      if(touche==0x0008)
 tmp2++;
      if(tmp1<0)
 tmp1=0;
      if(tmp2<0)
 tmp2=0;
      if(tmp1+tmp2>=200)
 {
   tmp3 = tmp1;
   tmp1 = (tmp1>tmp2)?tmp1-(tmp1+tmp2-200 +1):tmp1;
   tmp2 = (tmp3<tmp2)?tmp2-(tmp3+tmp2-200 +1):tmp2;
 }
      terrainimpl = TerrainImpl_Init(tmp1,tmp2,-10,10,-10,10);
      DestCons_ResetTab();
      break;
    case 0x000A:
      param.texte = ! param.texte;
      break;
    case 0x0065 :
      param.trans+=0.2;
      break;
    case 0x0067 :
      param.trans-=0.2;
      break;
    case 0x0066 :
      param.angle-=2.0;
      break;
    case 0x0064 :
      param.angle+=2.0;
      break;
    case 0x0068:
      param.angle2+= 2.0;
      break;
    case 0x0069:
      param.angle2-= 2.0;
      break;
    }
  glutPostRedisplay();
  (void) x;
  (void) y;
}

variable_types: touche int

variable_types: x int

variable_types: y int


decompiled_code:
__int64 __fastcall Main_clavier(char a1)
{
double v2; // xmm0_8
int v3; // edi
int v4; // eax
int v5; // eax
int v6; // ecx

switch ( a1 )
{
case '+':
*(double *)&param[34] = fmin(1.0, *(double *)&param[34] + 0.05);
break;
case '-':
*(double *)&param[34] = fmax(-1.0, *(double *)&param[34] - 0.05);
break;
case 'a':
v3 = param[13];
param[13] = v3 == 0;
if ( !v3 )
glutTimerFunc((unsigned int)param[12], Main_timer, 0LL);
break;
case 'b':
param[15] = param[15] == 0;
break;
case 'c':
param[3] = param[3] == 0;
break;
case 'd':
param[5] = (param[5] + 1) % 3;
break;
case 'f':
param[2] = param[2] == 0;
break;
case 'i':
if ( !param[13] )
Main_inserePoint();
break;
case 'j':
param[0] = param[0] == 0;
break;
case 'm':
if ( terrainimpl && param[17] )
param[22] = param[22] == 0;
break;
case 'n':
if ( terrainimpl )
{
param[17] = param[17] == 0;
Main_touchesSpeciales(2);
printf("Min: %f Max:%f\n", *(double *)&param[18], *(double *)&param[20]);
}
break;
case 'o':
v4 = param[12] + 10;
if ( v4 > 1000 )
v4 = 1000;
param[12] = v4;
break;
case 'p':
v5 = param[12] - 10;
if ( v5 < 10 )
v5 = 1;
param[12] = v5;
break;
case 'q':
exit(0);
case 't':
param[4] = param[4] == 0;
break;
case 'w':
v6 = param[24];
*(_QWORD *)&param[28] = *(_QWORD *)&param[26];
param[24] = v6 == 0;
break;
case 'x':
if ( param[24] )
{
*(double *)&param[26] = *(double *)&param[26] - 0.1;
*(double *)&param[28] = *(double *)&param[28] - 0.1;
}
break;
case 'z':
if ( param[24] )
{
v2 = *(double *)&param[28] + 0.1;
*(double *)&param[26] = *(double *)&param[26] + 0.1;
*(double *)&param[28] = v2;
}
break;
default:
return glutPostRedisplay();
}
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func6(char a1)
{
double v2; // xmm0_8
int v3; // edi
int v4; // eax
int v5; // eax
int v6; // ecx

switch ( a1 )
{
case '+':
*(double *)&param[34] = fmin(1.0, *(double *)&param[34] + 0.05);
break;
case '-':
*(double *)&param[34] = fmax(-1.0, *(double *)&param[34] - 0.05);
break;
case 'a':
v3 = param[13];
param[13] = v3 == 0;
if ( !v3 )
glutTimerFunc((unsigned int)param[12], Main_timer, 0LL);
break;
case 'b':
param[15] = param[15] == 0;
break;
case 'c':
param[3] = param[3] == 0;
break;
case 'd':
param[5] = (param[5] + 1) % 3;
break;
case 'f':
param[2] = param[2] == 0;
break;
case 'i':
if ( !param[13] )
func1();
break;
case 'j':
param[0] = param[0] == 0;
break;
case 'm':
if ( terrainimpl && param[17] )
param[22] = param[22] == 0;
break;
case 'n':
if ( terrainimpl )
{
param[17] = param[17] == 0;
func5(2);
printf("Min: %f Max:%f\n", *(double *)&param[18], *(double *)&param[20]);
}
break;
case 'o':
v4 = param[12] + 10;
if ( v4 > 1000 )
v4 = 1000;
param[12] = v4;
break;
case 'p':
v5 = param[12] - 10;
if ( v5 < 10 )
v5 = 1;
param[12] = v5;
break;
case 'q':
exit(0);
case 't':
param[4] = param[4] == 0;
break;
case 'w':
v6 = param[24];
*(_QWORD *)&param[28] = *(_QWORD *)&param[26];
param[24] = v6 == 0;
break;
case 'x':
if ( param[24] )
{
*(double *)&param[26] = *(double *)&param[26] - 0.1;
*(double *)&param[28] = *(double *)&param[28] - 0.1;
}
break;
case 'z':
if ( param[24] )
{
v2 = *(double *)&param[28] + 0.1;
*(double *)&param[26] = *(double *)&param[26] + 0.1;
*(double *)&param[28] = v2;
}
break;
default:
return glutPostRedisplay();
}
return glutPostRedisplay();
}

original_code:
void Main_clavier(unsigned char touche, int x, int y)
{
  SLTriangle *tmp = ((void *)0);
  switch(touche)
    {
    case 'a':
      param.auto_insert = !param.auto_insert;
      if(param.auto_insert)
 glutTimerFunc(param.timer_wait,Main_timer, 0);
      break;
    case 'b':
      param.barycentre = !param.barycentre;
      break;
    case 'c':
      param.circle = !param.circle;
      break;
    case 'd':
      param.draw = (param.draw+1)%3;
      break;
    case 'f' :
      param.filaire = !param.filaire;
      break;
    case 'i':
      if(!param.auto_insert)
 {
   Main_inserePoint();
   if(0==1){
     printf("Triangles are\n");
     tmp = tab.triangles->first;
     while(tmp!=((void *)0))
       {
  printf("\t Points are: %d %d %d\n",tmp->t->p1,tmp->t->p2,tmp->t->p3);
  printf("\t(%f,%f) (%f,%f) (%f,%f)\n",tab.p[tmp->t->p1].x,tab.p[tmp->t->p1].y,
         tab.p[tmp->t->p2].x,tab.p[tmp->t->p2].y,tab.p[tmp->t->p3].x,tab.p[tmp->t->p3].y);
  printf("Critere is %f\n",tmp->t->critere);
  tmp = tmp -> next;
       }
   }
 }
      break;
    case 'j':
      param.flip_algo = !param.flip_algo;
      break;
    case 'm':
      if((terrainimpl!=((void *)0))&&(param.norm_v2))
 param.flat = !param.flat;
      break;
    case 'n':
      if(terrainimpl!=((void *)0))
 {
   param.norm_v2 = !param.norm_v2;
   Main_touchesSpeciales(0x0002,0,0);
   printf("Min: %f Max:%f\n",param.min,param.max);
 }
      break;
    case 'o':
      param.timer_wait += 10;
      if(param.timer_wait>1000)
 param.timer_wait = 1000;
      break;
    case 'p':
      param.timer_wait -= 10;
      if(param.timer_wait<10)
 param.timer_wait = 1;
      break;
    case 'q' :
      exit(0);
      break;
    case 't':
      param.show_impl = !param.show_impl;
      break;
    case 'w':
      param.water = !param.water;
      param.w_cur = param.w_lvl;
      break;
    case 'x':
      if(param.water)
 {
   param.w_lvl -= 0.1;
   param.w_cur -= 0.1;
 }
      break;
    case 'z':
      if(param.water)
 {
   param.w_lvl += 0.1;
   param.w_cur += 0.1;
 }
      break;
    case '+':
      param.light+=0.05;
      if(param.light>1.0)
 param.light=1.0;
      break;
    case '-':
      param.light-=0.05;
      if(param.light<-1.0)
 param.light=-1.0;
      break;
    }
  glutPostRedisplay();
  (void) x;
  (void) y;
}

canonical_original_code:
void Main_clavier(unsigned char touche, int x, int y)
{
  struct sLTriangle *tmp = ((void *)0);
  switch(touche)
    {
    case 'a':
      param.auto_insert = !param.auto_insert;
      if(param.auto_insert)
 glutTimerFunc(param.timer_wait,Main_timer, 0);
      break;
    case 'b':
      param.barycentre = !param.barycentre;
      break;
    case 'c':
      param.circle = !param.circle;
      break;
    case 'd':
      param.draw = (param.draw+1)%3;
      break;
    case 'f' :
      param.filaire = !param.filaire;
      break;
    case 'i':
      if(!param.auto_insert)
 {
   Main_inserePoint();
   if(0==1){
     printf("Triangles are\n");
     tmp = tab.triangles->first;
     while(tmp!=((void *)0))
       {
  printf("\t Points are: %d %d %d\n",tmp->t->p1,tmp->t->p2,tmp->t->p3);
  printf("\t(%f,%f) (%f,%f) (%f,%f)\n",tab.p[tmp->t->p1].x,tab.p[tmp->t->p1].y,
         tab.p[tmp->t->p2].x,tab.p[tmp->t->p2].y,tab.p[tmp->t->p3].x,tab.p[tmp->t->p3].y);
  printf("Critere is %f\n",tmp->t->critere);
  tmp = tmp -> next;
       }
   }
 }
      break;
    case 'j':
      param.flip_algo = !param.flip_algo;
      break;
    case 'm':
      if((terrainimpl!=((void *)0))&&(param.norm_v2))
 param.flat = !param.flat;
      break;
    case 'n':
      if(terrainimpl!=((void *)0))
 {
   param.norm_v2 = !param.norm_v2;
   Main_touchesSpeciales(0x0002,0,0);
   printf("Min: %f Max:%f\n",param.min,param.max);
 }
      break;
    case 'o':
      param.timer_wait += 10;
      if(param.timer_wait>1000)
 param.timer_wait = 1000;
      break;
    case 'p':
      param.timer_wait -= 10;
      if(param.timer_wait<10)
 param.timer_wait = 1;
      break;
    case 'q' :
      exit(0);
      break;
    case 't':
      param.show_impl = !param.show_impl;
      break;
    case 'w':
      param.water = !param.water;
      param.w_cur = param.w_lvl;
      break;
    case 'x':
      if(param.water)
 {
   param.w_lvl -= 0.1;
   param.w_cur -= 0.1;
 }
      break;
    case 'z':
      if(param.water)
 {
   param.w_lvl += 0.1;
   param.w_cur += 0.1;
 }
      break;
    case '+':
      param.light+=0.05;
      if(param.light>1.0)
 param.light=1.0;
      break;
    case '-':
      param.light-=0.05;
      if(param.light<-1.0)
 param.light=-1.0;
      break;
    }
  glutPostRedisplay();
  (void) x;
  (void) y;
}

variable_types:
touche
unsigned char

variable_types: struct sLTriangle { struct sTriangle { int type; int flip_param; int p1; struct sTriangle *t1; struct sPoint { double x; } centre; double rayon; double critere; } *t; struct sLTriangle *next; } *

user_defined_types: struct sLTriangle { struct sTriangle *t; struct sLTriangle *next; }

user_defined_types: struct sTriangle { int type; int flip_param; int p1; struct sTriangle *t1; struct sPoint centre; double rayon; double critere; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
void *v4; // rax
__int64 v5; // rdx
__int64 v6; // rcx
int v7; // er8
int v9; // [rsp+Ch] [rbp-2Ch] BYREF
__int64 v10[2]; // [rsp+10h] [rbp-28h] BYREF
__int64 v11[3]; // [rsp+20h] [rbp-18h] BYREF

v9 = argc;
glutInit(&v9, argv, envp);
v3 = time(0LL);
srand(v3);
DestCons_InitTab();
glutInitDisplayMode(18LL);
glutInitWindowSize(640LL, 480LL);
glutCreateWindow("Delaunay");
glClearColor(0.0, 0.0, 0.0);
glEnable(2929LL);
glViewport(0LL, 0LL, 640LL, 480LL);
glMatrixMode(5889LL);
glLoadIdentity();
gluPerspective(40.0, 1.333333373069763, 1.0, 25.0);
glMatrixMode(5888LL);
v10[0] = 0x3F8000003F800000LL;
v11[0] = 0x3F8000003F800000LL;
v11[1] = 0x3F8000003F800000LL;
v10[1] = 0LL;
glLightfv(0x4000LL, 4611LL, v10);
glLightfv(0x4000LL, 4609LL, v11);
glLightfv(0x4000LL, 4610LL, v11);
glutReshapeFunc(Main_redimFenetre);
glutDisplayFunc(Main_affichage);
glutKeyboardFunc(Main_clavier);
glutSpecialFunc(Main_touchesSpeciales);
v4 = (void *)TerrainImpl_Init(-10.0, 10.0, -10.0, 10.0);
v7 = 1;
terrainimpl = v4;
if ( v4 )
{
glutMainLoop(4LL, 4LL, v5, v6, 1LL);
v7 = 0;
}
return v7;
}

original_code:
int main( int argc, char *argv[])
{
  glutInit(&argc,argv);
  srand(time(((void *)0)));
  DestCons_InitTab();
  glutInitDisplayMode(0x0000
        | 0x0002
        | 0x0010);
  glutInitWindowSize(640,480);
  glutCreateWindow("Delaunay");
  glClearColor(0.0,0.0,0.0,0.0);
  glEnable(0x0B71);
  GLfloat rapport = ((float)(640))/((float)(480));
  glViewport(0,0,640,480);
  glMatrixMode(0x1701);
  glLoadIdentity();
  gluPerspective(40,rapport,1.0,25.0);
  glMatrixMode(0x1700);
  GLfloat positionLumiere[] = {1.0,1.0,0.0,0.0};
  GLfloat couleurLumiere[] = {1.0,1.0,1.0,1.0};
  glLightfv(0x4000, 0x1203, positionLumiere);
  glLightfv(0x4000, 0x1201, couleurLumiere);
  glLightfv(0x4000, 0x1202, couleurLumiere);
  glutReshapeFunc(Main_redimFenetre);
  glutDisplayFunc(Main_affichage);
  glutKeyboardFunc(Main_clavier);
  glutSpecialFunc(Main_touchesSpeciales);
  terrainimpl = TerrainImpl_Init(4,4,-10,10,-10,10);
  if(terrainimpl==((void *)0))
    return 1;
  glutMainLoop();
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  glutInit(&argc,argv);
  srand(time(((void *)0)));
  DestCons_InitTab();
  glutInitDisplayMode(0x0000
        | 0x0002
        | 0x0010);
  glutInitWindowSize(640,480);
  glutCreateWindow("Delaunay");
  glClearColor(0.0,0.0,0.0,0.0);
  glEnable(0x0B71);
  float rapport = ((float)(640))/((float)(480));
  glViewport(0,0,640,480);
  glMatrixMode(0x1701);
  glLoadIdentity();
  gluPerspective(40,rapport,1.0,25.0);
  glMatrixMode(0x1700);
  float positionLumiere[] = {1.0,1.0,0.0,0.0};
  float couleurLumiere[] = {1.0,1.0,1.0,1.0};
  glLightfv(0x4000, 0x1203, positionLumiere);
  glLightfv(0x4000, 0x1201, couleurLumiere);
  glLightfv(0x4000, 0x1202, couleurLumiere);
  glutReshapeFunc(Main_redimFenetre);
  glutDisplayFunc(Main_affichage);
  glutKeyboardFunc(Main_clavier);
  glutSpecialFunc(Main_touchesSpeciales);
  terrainimpl = TerrainImpl_Init(4,4,-10,10,-10,10);
  if(terrainimpl==((void *)0))
    return 1;
  glutMainLoop();
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
positionLumiere
float []

variable_types:
couleurLumiere
float []

return_type: int


decompiled_code:
_BOOL8 __fastcall Liste_TriangleIsIn(__int64 a1, __int64 **a2)
{
__int64 *v2; // rax
__int64 v3; // rdx

v2 = *a2;
if ( !a1 || !v2 )
return 0LL;
do
{
v3 = *v2;
v2 = (__int64 *)v2[1];
}
while ( v2 && v3 != a1 );
return v3 == a1;
}

original_code:
int Liste_TriangleIsIn(STriangle *t1, SStartT *t2)
{
 int res=0;
 if((t2->first!=((void *)0))&&(t1!=((void *)0)))
 {
  SLTriangle *tmp=t2->first;
  while( (!res) && (tmp!=((void *)0)) )
  {
   res=( (res) || (tmp->t==t1)) ;
   tmp=tmp->next;
  }
 }
 return res;
}

canonical_original_code:
int Liste_TriangleIsIn(struct sTriangle *t1, struct sStartT *t2)
{
 int res = 0;
 if((t2->first!=((void *)0))&&(t1!=((void *)0)))
 {
  struct sLTriangle *tmp = t2->first;
  while( (!res) && (tmp!=((void *)0)) )
  {
   res=( (res) || (tmp->t==t1)) ;
   tmp=tmp->next;
  }
 }
 return res;
}

variable_types: struct sTriangle { int type; int flip_param; int p1; struct sTriangle *t1; struct sPoint { double x; } centre; double rayon; double critere; } *

variable_types: struct sStartT { struct sLTriangle { struct sTriangle *t; struct sLTriangle *next; } *first; } *

variable_types: res int

user_defined_types: struct sStartT { struct sLTriangle *first; }


decompiled_code:
__int64 __fastcall Global_AddPoint(double a1, double a2, double a3)
{
__int64 result; // rax
double *v4; // rdx

result = tab[4];
v4 = (double *)&tab[6 * result];
v4[3] = a1;
v4[4] = a2;
v4[5] = a3;
tab[4] = result + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(double a1, double a2, double a3)
{
__int64 result; // rax
double *v4; // rdx

result = tab[4];
v4 = (double *)&tab[6 * result];
v4[3] = a1;
v4[4] = a2;
v4[5] = a3;
tab[4] = result + 1;
return result;
}

original_code:
int Global_AddPoint(double x,double y,double z)
{
 tab.p[tab.np].x=x;
 tab.p[tab.np].y=y;
 tab.p[tab.np].z=z;
 return tab.np++;
}

canonical_original_code:
int Global_AddPoint(double x, double y, double z)
{
 tab.p[tab.np].x=x;
 tab.p[tab.np].y=y;
 tab.p[tab.np].z=z;
 return tab.np++;
}

variable_types: x double

variable_types: y double

variable_types: z double


decompiled_code:
__int64 __fastcall Global_EffTriangleListe(__int64 a1)
{
__int64 v1; // rsi
__int64 result; // rax

v1 = *(_QWORD *)&tab[2];
--tab[0];
result = Liste_EffTriangle(a1, v1);
if ( !tab[0] )
**(_QWORD **)&tab[2] = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 v1; // rsi
__int64 result; // rax

v1 = *(_QWORD *)&tab[2];
--tab[0];
result = func5(a1, v1);
if ( !tab[0] )
**(_QWORD **)&tab[2] = 0LL;
return result;
}

original_code:
int Global_EffTriangleListe(STriangle *t)
{
 int res;
 tab.nt--;
 res = Liste_EffTriangle(t,tab.triangles);
 if(tab.nt==0)
  tab.triangles->first = ((void *)0);
 return res;
}

canonical_original_code:
int Global_EffTriangleListe(struct sTriangle *t)
{
 int res;
 tab.nt--;
 res = Liste_EffTriangle(t,tab.triangles);
 if(tab.nt==0)
  tab.triangles->first = ((void *)0);
 return res;
}


decompiled_code:
__int64 __fastcall Liste_EffTriangle(_DWORD *a1, _QWORD **a2)
{
__int64 result; // rax
_QWORD *v3; // rbp
_QWORD *v4; // rax
int v5; // edx

result = 1LL;
if ( a1 )
{
v3 = *a2;
if ( *a2 )
{
if ( (_DWORD *)*v3 == a1 )
{
v5 = a1[1];
*a2 = (_QWORD *)v3[1];
if ( !v5 )
goto LABEL_12;
}
else
{
do
{
v4 = v3;
v3 = (_QWORD *)v3[1];
if ( !v3 )
return 0LL;
}
while ( (_DWORD *)*v3 != a1 );
v4[1] = v3[1];
if ( !a1[1] )
goto LABEL_12;
}
if ( *(_QWORD ***)&tab[2] != a2 )
{
Global_EffTriangleListe((__int64)a1);
LABEL_9:
free(v3);
return 1LL;
}
LABEL_12:
free(a1);
goto LABEL_9;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1, _QWORD **a2)
{
__int64 result; // rax
_QWORD *v3; // rbp
_QWORD *v4; // rax
int v5; // edx

result = 1LL;
if ( a1 )
{
v3 = *a2;
if ( *a2 )
{
if ( (_DWORD *)*v3 == a1 )
{
v5 = a1[1];
*a2 = (_QWORD *)v3[1];
if ( !v5 )
goto LABEL_12;
}
else
{
do
{
v4 = v3;
v3 = (_QWORD *)v3[1];
if ( !v3 )
return 0LL;
}
while ( (_DWORD *)*v3 != a1 );
v4[1] = v3[1];
if ( !a1[1] )
goto LABEL_12;
}
if ( *(_QWORD ***)&tab[2] != a2 )
{
func4((__int64)a1);
LABEL_9:
free(v3);
return 1LL;
}
LABEL_12:
free(a1);
goto LABEL_9;
}
}
return result;
}

original_code:
int Liste_EffTriangle(STriangle *t1, SStartT *t2)
{
 if (t1!=((void *)0))
 if(t2->first!=((void *)0))
 {
  int res=0;
  SLTriangle *tmp=t2->first, *tmp2=tmp;
  if (tmp->t==t1)
  {
   t2->first=tmp->next;
   if( (t1->flip_param)&&(t2!=tab.triangles))
     Global_EffTriangleListe(t1);
    else
     free(tmp->t);
   free(tmp);
  }
  else
  while(!res)
  {
   if (tmp==((void *)0))
    return 0;
   else
   if(tmp->t==t1)
   {
    tmp2->next=tmp->next;
    if( (t1->flip_param)&&(t2!=tab.triangles))
     Global_EffTriangleListe(t1);
    else
     free(tmp->t);
    free(tmp);
    res=1;
   }
   else
   {
    tmp2=tmp;
    tmp=tmp->next;
   }
  }
 }
 return 1;
}

canonical_original_code:
int Liste_EffTriangle(struct sTriangle *t1, struct sStartT *t2)
{
 if (t1!=((void *)0))
 if(t2->first!=((void *)0))
 {
  int res = 0;
  struct sLTriangle *tmp = t2->first; struct sLTriangle *tmp2 = tmp;
  if (tmp->t==t1)
  {
   t2->first=tmp->next;
   if( (t1->flip_param)&&(t2!=tab.triangles))
     Global_EffTriangleListe(t1);
    else
     free(tmp->t);
   free(tmp);
  }
  else
  while(!res)
  {
   if (tmp==((void *)0))
    return 0;
   else
   if(tmp->t==t1)
   {
    tmp2->next=tmp->next;
    if( (t1->flip_param)&&(t2!=tab.triangles))
     Global_EffTriangleListe(t1);
    else
     free(tmp->t);
    free(tmp);
    res=1;
   }
   else
   {
    tmp2=tmp;
    tmp=tmp->next;
   }
  }
 }
 return 1;
}


decompiled_code:
void __fastcall Global_DestructionListe(__int64 *a1)
{
__int64 v1; // rbp
__int64 v2; // rbx

v1 = *a1;
if ( *a1 )
{
while ( 1 )
{
if ( *(_QWORD *)v1 )
free(*(void **)v1);
v2 = *(_QWORD *)(v1 + 8);
free((void *)v1);
if ( !v2 )
break;
v1 = v2;
}
}
}

original_code:
void Global_DestructionListe(SStartT *t)
{
 SLTriangle *tmp=t->first,*tmp2=t->first;
 while(tmp!=((void *)0))
 {
  if(tmp->t!=((void *)0))
   free(tmp->t);
  tmp=tmp->next;
  free(tmp2);
  tmp2=tmp;
 }
}

canonical_original_code:
void Global_DestructionListe(struct sStartT *t)
{
 struct sLTriangle *tmp = t->first; struct sLTriangle *tmp2 = t->first;
 while(tmp!=((void *)0))
 {
  if(tmp->t!=((void *)0))
   free(tmp->t);
  tmp=tmp->next;
  free(tmp2);
  tmp2=tmp;
 }
}

variable_types: struct sStartT { struct sLTriangle { struct sTriangle { int type; int flip_param; int p1; struct sTriangle *t1; struct sPoint { double x; } centre; double rayon; double critere; } *t; struct sLTriangle *next; } *first; } *


original_code:
void FlipAlgo_InserePoint()
{
 int i;
 int p;
 SStartT list;
 SLTriangle *l,*l2;
 STriangle *t1,*t2,*t3,*t,*tmp,*tmp2;
 list.first=((void *)0);
 if(param.stop_insert)
  return;
 if((tab.np>=10000)||(tab.nt>=9999))
 {
  param.stop_insert=1;
  return;
 }
 p = Delaunay_ChoisitPoint();
 t = tab.triangles->first->t;
 t1 = Triangle_Cree(p,t->p1,t->p2);
 t2 = Triangle_Cree(p,t->p2,t->p3);
 t3 = Triangle_Cree(p,t->p3,t->p1);
 t1->t1 = t3;
 t1->t2 = t->t1;
 t1->t3 = t2;
 t2->t1 = t1;
 t2->t2 = t->t2;
 t2->t3 = t3;
 t3->t1 = t2;
 t3->t2 = t->t3;
 t3->t3 = t1;
 for(i=0;i<3;i++)
 {
  switch(i)
  {
  case 0: tmp = t->t1;
   tmp2 = t1;
   break;
  case 1: tmp = t->t2;
   tmp2 = t2;
   break;
  case 2: tmp = t->t3;
   tmp2 = t3;
   break;
  }
  if(tmp!=((void *)0))
  {
   if(tmp->t1==t)
    tmp->t1=tmp2;
   if(tmp->t2==t)
    tmp->t2=tmp2;
   if(tmp->t3==t)
    tmp->t3=tmp2;
  }
 }
 Global_EffTriangleListe(t);
 Liste_AddTriangle(t1,&list);
 Liste_AddTriangle(t2,&list);
 Liste_AddTriangle(t3,&list);
 Liste_AddTriangle(t1->t2,&list);
 Liste_AddTriangle(t2->t2,&list);
 Liste_AddTriangle(t3->t2,&list);
 int p1 = t1->p2, p2 = t1->p3, p3 = t2->p2, p4 = t2->p3,
  p5 = t3->p2, p6 = t3->p3;
 FlipAlgo_CoteIllegal(p1,p2,&list);
 FlipAlgo_CoteIllegal(p3,p4,&list);
 FlipAlgo_CoteIllegal(p5,p6,&list);
 l = list.first;
 while(l!=((void *)0))
 {
  Global_AddTriangleListe(l->t);
  l2 = l->next;
  free(l);
  l = l2;
 }
}

canonical_original_code:
void FlipAlgo_InserePoint()
{
 int i;
 int p;
 struct sStartT list;
 struct sLTriangle *l; struct sLTriangle *l2;
 struct sTriangle *t1; struct sTriangle *t2; struct sTriangle *t3; struct sTriangle *t; struct sTriangle *tmp; struct sTriangle *tmp2;
 list.first=((void *)0);
 if(param.stop_insert)
  return;
 if((tab.np>=10000)||(tab.nt>=9999))
 {
  param.stop_insert=1;
  return;
 }
 p = Delaunay_ChoisitPoint();
 t = tab.triangles->first->t;
 t1 = Triangle_Cree(p,t->p1,t->p2);
 t2 = Triangle_Cree(p,t->p2,t->p3);
 t3 = Triangle_Cree(p,t->p3,t->p1);
 t1->t1 = t3;
 t1->t2 = t->t1;
 t1->t3 = t2;
 t2->t1 = t1;
 t2->t2 = t->t2;
 t2->t3 = t3;
 t3->t1 = t2;
 t3->t2 = t->t3;
 t3->t3 = t1;
 for(i=0;i<3;i++)
 {
  switch(i)
  {
  case 0: tmp = t->t1;
   tmp2 = t1;
   break;
  case 1: tmp = t->t2;
   tmp2 = t2;
   break;
  case 2: tmp = t->t3;
   tmp2 = t3;
   break;
  }
  if(tmp!=((void *)0))
  {
   if(tmp->t1==t)
    tmp->t1=tmp2;
   if(tmp->t2==t)
    tmp->t2=tmp2;
   if(tmp->t3==t)
    tmp->t3=tmp2;
  }
 }
 Global_EffTriangleListe(t);
 Liste_AddTriangle(t1,&list);
 Liste_AddTriangle(t2,&list);
 Liste_AddTriangle(t3,&list);
 Liste_AddTriangle(t1->t2,&list);
 Liste_AddTriangle(t2->t2,&list);
 Liste_AddTriangle(t3->t2,&list);
 int p1 = t1->p2; int p2 = t1->p3; int p3 = t2->p2; int p4 = t2->p3; int p5 = t3->p2; int p6 = t3->p3;
 FlipAlgo_CoteIllegal(p1,p2,&list);
 FlipAlgo_CoteIllegal(p3,p4,&list);
 FlipAlgo_CoteIllegal(p5,p6,&list);
 l = list.first;
 while(l!=((void *)0))
 {
  Global_AddTriangleListe(l->t);
  l2 = l->next;
  free(l);
  l = l2;
 }
}

variable_types: i int

variable_types: p int

variable_types: struct sStartT { struct sLTriangle { struct sTriangle { int type; int flip_param; int p1; struct sTriangle *t1; struct sPoint { double x; } centre; double rayon; double critere; } *t; struct sLTriangle *next; } *first; }


decompiled_code:
__int64 __fastcall DestCons_DeterminerTAD(_QWORD *a1, __int64 a2, unsigned int a3)
{
unsigned int v4; // ebx
__int64 result; // rax
__int64 v6; // rbp

v4 = 1;
Liste_AddTriangle(a1, a2);
result = 0LL;
while ( 1 )
{
if ( (_DWORD)result == 2 )
{
v6 = a1[5];
if ( !v6 )
return result;
}
else
{
v6 = a1[3];
if ( !v6 )
break;
}
result = Liste_TriangleIsIn(v6, a2);
if ( (_DWORD)result )
break;
LABEL_9:
result = Delaunay_PointInCercle(a3, v6);
if ( !(_DWORD)result )
break;
result = DestCons_DeterminerTAD(v6, a2, a3);
if ( v4 == 3 )
return result;
LABEL_6:
while ( 1 )
{
result = v4++;
if ( v4 != 2 )
break;
v6 = a1[4];
if ( v6 )
{
result = Liste_TriangleIsIn(a1[4], a2);
if ( (_DWORD)result )
goto LABEL_5;
goto LABEL_9;
}
}
}
LABEL_5:
if ( v4 != 3 )
goto LABEL_6;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, __int64 a2, unsigned int a3)
{
unsigned int v4; // ebx
__int64 result; // rax
__int64 v6; // rbp

v4 = 1;
Liste_AddTriangle(a1, a2);
result = 0LL;
while ( 1 )
{
if ( (_DWORD)result == 2 )
{
v6 = a1[5];
if ( !v6 )
return result;
}
else
{
v6 = a1[3];
if ( !v6 )
break;
}
result = Liste_TriangleIsIn(v6, a2);
if ( (_DWORD)result )
break;
LABEL_9:
result = Delaunay_PointInCercle(a3, v6);
if ( !(_DWORD)result )
break;
result = func2(v6, a2, a3);
if ( v4 == 3 )
return result;
LABEL_6:
while ( 1 )
{
result = v4++;
if ( v4 != 2 )
break;
v6 = a1[4];
if ( v6 )
{
result = Liste_TriangleIsIn(a1[4], a2);
if ( (_DWORD)result )
goto LABEL_5;
goto LABEL_9;
}
}
}
LABEL_5:
if ( v4 != 3 )
goto LABEL_6;
return result;
}

original_code:
void DestCons_DeterminerTAD(STriangle *t, SStartT *lt,int p)
{
 int i;
 STriangle* tmp;
 Liste_AddTriangle(t,lt);
 for(i=0;i<3;i++)
  {
  switch(i)
   {
   case 0:
    tmp = t->t1;
    break;
   case 1:
    tmp = t->t2;
    break;
   case 2:
    tmp = t->t3;
    break;
   default: break;
   }
  if(tmp!=((void *)0))
   {
   if(!Liste_TriangleIsIn(tmp, lt))
    {
    if(Delaunay_PointInCercle(p,tmp))
     {
     DestCons_DeterminerTAD(tmp,lt,p);
     }
    }
   }
  }
}

canonical_original_code:
void DestCons_DeterminerTAD(struct sTriangle *t, struct sStartT *lt, int p)
{
 int i;
 struct sTriangle *tmp;
 Liste_AddTriangle(t,lt);
 for(i=0;i<3;i++)
  {
  switch(i)
   {
   case 0:
    tmp = t->t1;
    break;
   case 1:
    tmp = t->t2;
    break;
   case 2:
    tmp = t->t3;
    break;
   default: break;
   }
  if(tmp!=((void *)0))
   {
   if(!Liste_TriangleIsIn(tmp, lt))
    {
    if(Delaunay_PointInCercle(p,tmp))
     {
     DestCons_DeterminerTAD(tmp,lt,p);
     }
    }
   }
  }
}


decompiled_code:
__int64 DestCons_InitTab()
{
_QWORD *v0; // rax
_QWORD *v1; // rbp
_QWORD *v2; // rax

v0 = malloc(8uLL);
*((_QWORD *)&tab + 1) = v0;
if ( !v0 )
{
puts("Erreur d'allocation de malloc dans DestCons_InitTab");
exit(1);
}
*v0 = 0LL;
*((_DWORD *)&tab + 4) = 4;
*((_QWORD *)&tab + 5) = 0LL;
*((_QWORD *)&tab + 3) = LC2;
*((_QWORD *)&tab + 4) = LC3;
*((_QWORD *)&tab + 6) = LC3;
*((_QWORD *)&tab + 7) = LC3;
*((_QWORD *)&tab + 9) = LC3;
*((_QWORD *)&tab + 10) = LC2;
*((_QWORD *)&tab + 12) = LC2;
*((_QWORD *)&tab + 13) = LC2;
*((_QWORD *)&tab + 8) = 0LL;
*((_QWORD *)&tab + 11) = 0LL;
*((_QWORD *)&tab + 14) = 0LL;
v1 = (_QWORD *)Triangle_Cree(2LL, 1LL, 0LL);
v2 = (_QWORD *)Triangle_Cree(2LL, 0LL, 3LL);
v1[3] = 0LL;
v1[4] = 0LL;
v1[5] = v2;
v2[3] = v1;
v2[4] = 0LL;
v2[5] = 0LL;
tab = 0;
Global_AddTriangleListe(v2);
return Global_AddTriangleListe(v1);
}

canonical_decompiled_code:
__int64 func3()
{
_QWORD *v0; // rax
_QWORD *v1; // rbp
_QWORD *v2; // rax

v0 = malloc(8uLL);
*((_QWORD *)&tab + 1) = v0;
if ( !v0 )
{
puts("Erreur d'allocation de malloc dans DestCons_InitTab");
exit(1);
}
*v0 = 0LL;
*((_DWORD *)&tab + 4) = 4;
*((_QWORD *)&tab + 5) = 0LL;
*((_QWORD *)&tab + 3) = LC2;
*((_QWORD *)&tab + 4) = LC3;
*((_QWORD *)&tab + 6) = LC3;
*((_QWORD *)&tab + 7) = LC3;
*((_QWORD *)&tab + 9) = LC3;
*((_QWORD *)&tab + 10) = LC2;
*((_QWORD *)&tab + 12) = LC2;
*((_QWORD *)&tab + 13) = LC2;
*((_QWORD *)&tab + 8) = 0LL;
*((_QWORD *)&tab + 11) = 0LL;
*((_QWORD *)&tab + 14) = 0LL;
v1 = (_QWORD *)Triangle_Cree(2LL, 1LL, 0LL);
v2 = (_QWORD *)Triangle_Cree(2LL, 0LL, 3LL);
v1[3] = 0LL;
v1[4] = 0LL;
v1[5] = v2;
v2[3] = v1;
v2[4] = 0LL;
v2[5] = 0LL;
tab = 0;
Global_AddTriangleListe(v2);
return Global_AddTriangleListe(v1);
}

original_code:
void DestCons_InitTab()
{
 STriangle *tmp,*tmp2;
 tab.triangles = malloc(sizeof(SStartT));
 if(tab.triangles==((void *)0))
  {
  printf("Erreur d'allocation de malloc dans DestCons_InitTab\n");
  exit(1);
  }
 tab.np=4;
 tab.p[0].x = -10.0f;
 tab.p[0].y = 10.0f;
 tab.p[0].z = 0.0f;
 tab.p[1].x = 10.0f;
 tab.p[1].y = 10.0f;
 tab.p[1].z = 0.0f;
 tab.p[2].x = 10.0f;
 tab.p[2].y = -10.0f;
 tab.p[2].z = 0.0f;
 tab.p[3].x = -10.0f;
 tab.p[3].y = -10.0f;
 tab.p[3].z = 0.0f;
 tab.triangles->first=((void *)0);
 tmp = Triangle_Cree(2,1,0);
 tmp2 = Triangle_Cree(2,0,3);
 tmp->t1 = ((void *)0);
 tmp->t2 = ((void *)0);
 tmp->t3 = tmp2;
 tmp2->t1 = tmp;
 tmp2->t2 = ((void *)0);
 tmp2->t3 = ((void *)0);
 tab.nt=0;
 Global_AddTriangleListe(tmp2);
 Global_AddTriangleListe(tmp);
}

canonical_original_code:
void DestCons_InitTab()
{
 struct sTriangle *tmp; struct sTriangle *tmp2;
 tab.triangles = malloc(sizeof(SStartT));
 if(tab.triangles==((void *)0))
  {
  printf("Erreur d'allocation de malloc dans DestCons_InitTab\n");
  exit(1);
  }
 tab.np=4;
 tab.p[0].x = -10.0f;
 tab.p[0].y = 10.0f;
 tab.p[0].z = 0.0f;
 tab.p[1].x = 10.0f;
 tab.p[1].y = 10.0f;
 tab.p[1].z = 0.0f;
 tab.p[2].x = 10.0f;
 tab.p[2].y = -10.0f;
 tab.p[2].z = 0.0f;
 tab.p[3].x = -10.0f;
 tab.p[3].y = -10.0f;
 tab.p[3].z = 0.0f;
 tab.triangles->first=((void *)0);
 tmp = Triangle_Cree(2,1,0);
 tmp2 = Triangle_Cree(2,0,3);
 tmp->t1 = ((void *)0);
 tmp->t2 = ((void *)0);
 tmp->t3 = tmp2;
 tmp2->t1 = tmp;
 tmp2->t2 = ((void *)0);
 tmp2->t3 = ((void *)0);
 tab.nt=0;
 Global_AddTriangleListe(tmp2);
 Global_AddTriangleListe(tmp);
}


decompiled_code:
__int64 DestCons_ResetTab()
{
unsigned int v0; // eax
__int64 result; // rax

Global_DestructionListe(tab[1]);
DestCons_InitTab();
v0 = param[16];
param[14] = 0;
result = (v0 >> 2) & 1;
param[4] = result;
return result;
}

canonical_decompiled_code:
__int64 func4()
{
unsigned int v0; // eax
__int64 result; // rax

Global_DestructionListe(tab[1]);
func3();
v0 = param[16];
param[14] = 0;
result = (v0 >> 2) & 1;
param[4] = result;
return result;
}

original_code:
void DestCons_ResetTab()
{
 Global_DestructionListe(tab.triangles);
 DestCons_InitTab();
 param.stop_insert = 0;
 if(param.gentype&4)
  param.show_impl = 1;
 else
  param.show_impl = 0;
}


decompiled_code:
void DestCons_InserePoint()
{
int v0; // eax
unsigned int v1; // er12
_QWORD *v2; // rbx
_QWORD *v3; // rbp
void *v4; // rdi
void *v5; // rdi
void *ptr; // [rsp+0h] [rbp-28h] BYREF
void *v7; // [rsp+8h] [rbp-20h] BYREF

v0 = param[14];
v7 = 0LL;
ptr = 0LL;
if ( !v0 )
{
if ( SLODWORD(tab[2]) <= 9999
&& SLODWORD(tab[0]) <= 9998
&& (v1 = Delaunay_ChoisitPoint(),
DestCons_DeterminerTAD(**(_QWORD ***)tab[1], (__int64)&ptr, v1),
DestCons_DeterminerTAC((__int64 **)&ptr, &v7, v1),
(v2 = v7) != 0LL) )
{
v3 = ptr;
if ( !ptr )
goto LABEL_13;
do
{
Global_EffTriangleListe(*v3);
v4 = v3;
v3 = (_QWORD *)v3[1];
free(v4);
}
while ( v3 );
v2 = v7;
if ( v7 )
{
LABEL_13:
do
{
Global_AddTriangleListe(*v2);
v5 = v2;
v2 = (_QWORD *)v2[1];
free(v5);
}
while ( v2 );
}
}
else
{
param[14] = 1;
}
}
}

canonical_decompiled_code:
void func5()
{
int v0; // eax
unsigned int v1; // er12
_QWORD *v2; // rbx
_QWORD *v3; // rbp
void *v4; // rdi
void *v5; // rdi
void *ptr; // [rsp+0h] [rbp-28h] BYREF
void *v7; // [rsp+8h] [rbp-20h] BYREF

v0 = param[14];
v7 = 0LL;
ptr = 0LL;
if ( !v0 )
{
if ( SLODWORD(tab[2]) <= 9999
&& SLODWORD(tab[0]) <= 9998
&& (v1 = Delaunay_ChoisitPoint(),
func2(**(_QWORD ***)tab[1], (__int64)&ptr, v1),
func1((__int64 **)&ptr, &v7, v1),
(v2 = v7) != 0LL) )
{
v3 = ptr;
if ( !ptr )
goto LABEL_13;
do
{
Global_EffTriangleListe(*v3);
v4 = v3;
v3 = (_QWORD *)v3[1];
free(v4);
}
while ( v3 );
v2 = v7;
if ( v7 )
{
LABEL_13:
do
{
Global_AddTriangleListe(*v2);
v5 = v2;
v2 = (_QWORD *)v2[1];
free(v5);
}
while ( v2 );
}
}
else
{
param[14] = 1;
}
}
}

original_code:
void DestCons_InserePoint()
{
 int p;
 SStartT Tad,Tac;
 SLTriangle* tmp,*tmp2;
 Tac.first = ((void *)0);
 Tad.first = ((void *)0);
 if(param.stop_insert)
  return;
 if((tab.np>=10000)||(tab.nt>=9999))
 {
  param.stop_insert=1;
  return;
 }
 p = Delaunay_ChoisitPoint();
 DestCons_DeterminerTAD(tab.triangles->first->t,&Tad,p);
 DestCons_DeterminerTAC(&Tad,&Tac,p);
 if(Tac.first==((void *)0))
 {
  param.stop_insert=1;
  return;
 }
 tmp = Tad.first;
 while(tmp!=((void *)0))
  {
  Global_EffTriangleListe(tmp->t);
  tmp2 = tmp;
  tmp = tmp -> next;
  free(tmp2);
  }
 tmp = Tac.first;
 while(tmp!=((void *)0))
  {
  Global_AddTriangleListe(tmp->t);
  tmp2 = tmp;
  tmp = tmp -> next;
  free(tmp2);
  }
}

canonical_original_code:
void DestCons_InserePoint()
{
 int p;
 struct sStartT Tad; struct sStartT Tac;
 struct sLTriangle *tmp; struct sLTriangle *tmp2;
 Tac.first = ((void *)0);
 Tad.first = ((void *)0);
 if(param.stop_insert)
  return;
 if((tab.np>=10000)||(tab.nt>=9999))
 {
  param.stop_insert=1;
  return;
 }
 p = Delaunay_ChoisitPoint();
 DestCons_DeterminerTAD(tab.triangles->first->t,&Tad,p);
 DestCons_DeterminerTAC(&Tad,&Tac,p);
 if(Tac.first==((void *)0))
 {
  param.stop_insert=1;
  return;
 }
 tmp = Tad.first;
 while(tmp!=((void *)0))
  {
  Global_EffTriangleListe(tmp->t);
  tmp2 = tmp;
  tmp = tmp -> next;
  free(tmp2);
  }
 tmp = Tac.first;
 while(tmp!=((void *)0))
  {
  Global_AddTriangleListe(tmp->t);
  tmp2 = tmp;
  tmp = tmp -> next;
  free(tmp2);
  }
}


decompiled_code:
double __fastcall TerrainImpl_SimpleCalcHeight(int *a1, double a2, double a3)
{
double *v3; // rbx
double v4; // xmm3_8
__int64 v5; // rbp
double v6; // xmm0_8
double v8; // [rsp+0h] [rbp-38h]

if ( *a1 <= 0 )
return 0.0;
v3 = (double *)(a1 + 2);
v4 = 0.0;
v5 = 0LL;
do
{
v8 = *(double *)&a1[2 * v5 + 1602];
v6 = exp(
COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*v3 - a2) ^ LC1) * (*v3 - a2) / v3[400]
- (v3[1] - a3) * (v3[1] - a3) / v3[401])
* v8;
if ( !a1[v5 + 2002] )
*(_QWORD *)&v6 ^= LC1;
v4 = v4 + v6;
++v5;
v3 += 2;
}
while ( *a1 > (int)v5 );
return v4;
}

original_code:
double TerrainImpl_SimpleCalcHeight(STerrainImpl* t,double x, double y)
{
  int i=0;
  double res = 0.0,tmp;
  for(i=0;i<t->nb_centre;i++)
    {
      tmp = t->hauteur[i]*exp( -(t->centre[i][0]-x)*(t->centre[i][0]-x)/t->etal[i][0]-(t->centre[i][1]-y)*(t->centre[i][1]-y)/ t->etal[i][1]);
      res += (t->montagne[i])?tmp:-tmp;
    }
  return res;
}

canonical_original_code:
double TerrainImpl_SimpleCalcHeight(struct sTerrainImpl *t, double x, double y)
{
  int i = 0;
  double res = 0.0; double tmp;
  for(i=0;i<t->nb_centre;i++)
    {
      tmp = t->hauteur[i]*exp( -(t->centre[i][0]-x)*(t->centre[i][0]-x)/t->etal[i][0]-(t->centre[i][1]-y)*(t->centre[i][1]-y)/ t->etal[i][1]);
      res += (t->montagne[i])?tmp:-tmp;
    }
  return res;
}

variable_types: struct sTerrainImpl { int nb_centre; double centre[200][2]; double etal[200][2]; double hauteur[200]; int montagne[200]; int nb_montagnes; } *

variable_types: res double

variable_types: tmp double

return_type: double


decompiled_code:
double __fastcall TerrainImpl_CalcHeight(int *a1, double a2, double a3)
{
double result; // xmm0_8
double v4; // xmm0_8

result = TerrainImpl_SimpleCalcHeight(a1, a2, a3);
if ( *((_DWORD *)&param + 17) )
{
v4 = (result - *((double *)&param + 9)) / (*((double *)&param + 10) - *((double *)&param + 9));
if ( *((_DWORD *)&param + 22) )
v4 = pow(v4, (double)*((int *)&param + 23));
result = v4 * 10.0;
}
return result;
}

canonical_decompiled_code:
double __fastcall func2(int *a1, double a2, double a3)
{
double result; // xmm0_8
double v4; // xmm0_8

result = func0(a1, a2, a3);
if ( *((_DWORD *)&param + 17) )
{
v4 = (result - *((double *)&param + 9)) / (*((double *)&param + 10) - *((double *)&param + 9));
if ( *((_DWORD *)&param + 22) )
v4 = pow(v4, (double)*((int *)&param + 23));
result = v4 * 10.0;
}
return result;
}

original_code:
double TerrainImpl_CalcHeight(STerrainImpl* t,double x, double y)
{
  double res = TerrainImpl_SimpleCalcHeight(t,x,y);
  if(param.norm_v2)
    {
      res = (res-param.min)/(param.max-param.min);
      if(param.flat)
 res = pow(res,param.power);
      res *= 10.0;
      return res;
    }
  return res;
}

canonical_original_code:
double TerrainImpl_CalcHeight(struct sTerrainImpl *t, double x, double y)
{
  double res = TerrainImpl_SimpleCalcHeight(t,x,y);
  if(param.norm_v2)
    {
      res = (res-param.min)/(param.max-param.min);
      if(param.flat)
 res = pow(res,param.power);
      res *= 10.0;
      return res;
    }
  return res;
}

user_defined_types: struct sTerrainImpl { int nb_centre; double centre[200][2]; double etal[200][2]; double hauteur[200]; int montagne[200]; int nb_montagnes; }


canonical_original_code:
int Triangle_CalcCritere(struct sTriangle *t)
{
 double h; double l1; double l2; double l3;
 l1 = sqrt((tab.p[t->p1].x - tab.p[t->p2].x)*(tab.p[t->p1].x - tab.p[t->p2].x)+(tab.p[t->p1].y - tab.p[t->p2].y)*(tab.p[t->p1].y - tab.p[t->p2].y));
 l2 = sqrt((tab.p[t->p1].x - tab.p[t->p3].x)*(tab.p[t->p1].x - tab.p[t->p3].x)+(tab.p[t->p1].y - tab.p[t->p3].y)*(tab.p[t->p1].y - tab.p[t->p3].y));
 l3 = sqrt((tab.p[t->p2].x - tab.p[t->p3].x)*(tab.p[t->p2].x - tab.p[t->p3].x)+(tab.p[t->p2].y - tab.p[t->p3].y)*(tab.p[t->p2].y - tab.p[t->p3].y));
 h = l1/(2.0*t->rayon);
 h *= l2;
 t->critere = h*l3/2.0;
 return 1;
}

variable_types: h double


original_code:
STriangle* Triangle_Cree(int x, int y, int z)
{
 STriangle *t = malloc(sizeof(*t));
 SVecteur v1, v2;
 if(t==((void *)0))
  {
  printf("Malloc failed in cree_t\n");
  return ((void *)0);
  }
 t->p1 = x;
 t->p2 = y;
 t->p3 = z;
 v1.x = tab.p[x].x - tab.p[y].x;
 v1.y = tab.p[x].y - tab.p[y].y;
 v1.z = tab.p[x].z - tab.p[y].z;
 v2.x = tab.p[x].x - tab.p[z].x;
 v2.y = tab.p[x].y - tab.p[z].y;
 v2.z = tab.p[x].z - tab.p[z].z;
 if(!Vecteur_Zup(&v1,&v2))
  {t->p1 = y; t->p2 = x;}
 Triangle_CalcParam(t);
 t->flip_param = 0;
 t->t1 = ((void *)0);
 t->t2 = ((void *)0);
 t->t3 = ((void *)0);
 return t;
}

canonical_original_code:
struct sTriangle *Triangle_Cree(int x, int y, int z)
{
 struct sTriangle *t = malloc(sizeof(*t));
 struct sVecteur v1; struct sVecteur v2;
 if(t==((void *)0))
  {
  printf("Malloc failed in cree_t\n");
  return ((void *)0);
  }
 t->p1 = x;
 t->p2 = y;
 t->p3 = z;
 v1.x = tab.p[x].x - tab.p[y].x;
 v1.y = tab.p[x].y - tab.p[y].y;
 v1.z = tab.p[x].z - tab.p[y].z;
 v2.x = tab.p[x].x - tab.p[z].x;
 v2.y = tab.p[x].y - tab.p[z].y;
 v2.z = tab.p[x].z - tab.p[z].z;
 if(!Vecteur_Zup(&v1,&v2))
  {t->p1 = y; t->p2 = x;}
 Triangle_CalcParam(t);
 t->flip_param = 0;
 t->t1 = ((void *)0);
 t->t2 = ((void *)0);
 t->t3 = ((void *)0);
 return t;
}

variable_types: x int

variable_types: y int

variable_types: z int

return_type: struct sTriangle { int type; int flip_param; int p1; struct sTriangle *t1; struct sPoint { double x; } centre; double rayon; double critere; } *


decompiled_code:
double *__fastcall Terran_AddHaut(int a1, double a2)
{
double *result; // rax

result = (double *)((char *)&tab + 24 * a1);
result[5] = a2 + result[5];
return result;
}

canonical_decompiled_code:
double *__fastcall func0(int a1, double a2)
{
double *result; // rax

result = (double *)((char *)&tab + 24 * a1);
result[5] = a2 + result[5];
return result;
}

original_code:
void Terran_AddHaut(int indice,double hauteur)
{
 tab.p[indice].z+=hauteur;
}

canonical_original_code:
void Terran_AddHaut(int indice, double hauteur)
{
 tab.p[indice].z+=hauteur;
}

variable_types: indice int

variable_types: hauteur double


decompiled_code:
void __fastcall Terran_JeuneMont(__int64 a1, __int64 a2, int a3, double a4)
{
__int64 v6; // rbx
__int64 v7; // r13
__int64 v8; // rsi
int v9; // edi

if ( a2 )
{
v6 = a2;
while ( a1 )
{
v8 = *(_QWORD *)(v6 + 24);
if ( v8 == a1 )
{
v9 = *(_DWORD *)(v6 + 16);
v8 = *(_QWORD *)(v6 + 32);
if ( v9 != -1 )
goto LABEL_15;
}
else
{
if ( *(_QWORD *)(v6 + 32) != a1 )
return;
v9 = *(_DWORD *)(v6 + 8);
a1 = *(_QWORD *)(v6 + 40);
if ( v9 != -1 )
{
LABEL_15:
if ( a3 > 2 )
{
v7 = 0LL;
Terran_AddHaut(v9, a4);
goto LABEL_5;
}
v7 = 0LL;
Terran_AddHaut(v9, a4 * 0.5);
a4 = a4 * 0.5;
goto LABEL_4;
}
}
v7 = 0LL;
if ( a3 <= 1 )
return;
LABEL_5:
if ( v8 )
Terran_JeuneMont(v6, v8, (unsigned int)(a3 - 1));
if ( a1 )
Terran_JeuneMont(v6, a1, (unsigned int)(a3 - 1));
if ( !v7 )
return;
a1 = v6;
--a3;
v6 = v7;
}
Terran_AddHaut(*(_DWORD *)(v6 + 8), a4);
Terran_AddHaut(*(_DWORD *)(v6 + 12), a4);
Terran_AddHaut(*(_DWORD *)(v6 + 16), a4);
v8 = *(_QWORD *)(v6 + 24);
a1 = *(_QWORD *)(v6 + 32);
v7 = *(_QWORD *)(v6 + 40);
LABEL_4:
if ( a3 <= 1 )
return;
goto LABEL_5;
}
}

original_code:
void Terran_JeuneMont(STriangle* orig,STriangle* t,double h,int p)
{
 int point=-1;
 STriangle* t1=((void *)0),*t2=((void *)0),*t3=((void *)0);
 if(t!=((void *)0))
 {
  if(orig==((void *)0))
  {
   Terran_AddHaut(t->p1,h);
   Terran_AddHaut(t->p2,h);
   Terran_AddHaut(t->p3,h);
   t1=t->t1;
   t2=t->t2;
   t3=t->t3;
  }
  else if(orig==t->t1)
  {
   point =t->p3;
   t1=t->t2;
   t2=t->t1;
  }
  else if(orig==t->t2)
  {
   point =t->p1;
   t1=t->t1;
   t2=t->t3;
  }
  else if(orig==t->t1)
  {
   point =t->p2;
   t1=t->t3;
   t2=t->t2;
  }
  if (point!=-1)
  {
   if (p<3)
   {
    h/=2;
    Terran_AddHaut(point,h);
   }
   else
   {
    Terran_AddHaut(point,h);
   }
  }
  if (p>1)
  {
   if(t1!=((void *)0)) Terran_JeuneMont(t,t1,h,p-1);
   if(t2!=((void *)0)) Terran_JeuneMont(t,t2,h,p-1);
   if(t3!=((void *)0)) Terran_JeuneMont(t,t3,h,p-1);
  }
 }
}

canonical_original_code:
void Terran_JeuneMont(struct sTriangle *orig, struct sTriangle *t, double h, int p)
{
 int point = -1;
 struct sTriangle *t1 = ((void *)0); struct sTriangle *t2 = ((void *)0); struct sTriangle *t3 = ((void *)0);
 if(t!=((void *)0))
 {
  if(orig==((void *)0))
  {
   Terran_AddHaut(t->p1,h);
   Terran_AddHaut(t->p2,h);
   Terran_AddHaut(t->p3,h);
   t1=t->t1;
   t2=t->t2;
   t3=t->t3;
  }
  else if(orig==t->t1)
  {
   point =t->p3;
   t1=t->t2;
   t2=t->t1;
  }
  else if(orig==t->t2)
  {
   point =t->p1;
   t1=t->t1;
   t2=t->t3;
  }
  else if(orig==t->t1)
  {
   point =t->p2;
   t1=t->t3;
   t2=t->t2;
  }
  if (point!=-1)
  {
   if (p<3)
   {
    h/=2;
    Terran_AddHaut(point,h);
   }
   else
   {
    Terran_AddHaut(point,h);
   }
  }
  if (p>1)
  {
   if(t1!=((void *)0)) Terran_JeuneMont(t,t1,h,p-1);
   if(t2!=((void *)0)) Terran_JeuneMont(t,t2,h,p-1);
   if(t3!=((void *)0)) Terran_JeuneMont(t,t3,h,p-1);
  }
 }
}

variable_types: struct sTriangle { int type; int flip_param; int p1; struct sTriangle *t1; struct sPoint { double x; } centre; double rayon; double critere; } *

variable_types:
t
struct sTriangle *

variable_types: point int


original_code:
void Terran_VieilMont(STriangle* orig,STriangle* t,double h,int p,int max)
{
 int point=-1;
 STriangle* t1=((void *)0),*t2=((void *)0),*t3=((void *)0);
 if(t!=((void *)0))
 {
  if(orig==((void *)0))
  {
   Terran_Set(2,t,p);
   Terran_AddHaut(t->p1,h/3);
   Terran_AddHaut(t->p2,h/3);
   Terran_AddHaut(t->p3,h/3);
   t1=t->t1;
   t2=t->t2;
   t3=t->t3;
   t->type=0;
  }
 else
 if(t->type==2)
 {
  t->type=0;
  if(orig==t->t1)
  {
   point =t->p3;
   t1=t->t2;
   t2=t->t1;
  }
  else if(orig==t->t2)
  {
   point =t->p1;
   t1=t->t1;
   t2=t->t3;
  }
  else if(orig==t->t1)
  {
   point =t->p2;
   t1=t->t3;
   t2=t->t2;
  }
  if (point!=-1)
  {
   if ((p>(max/10))&&(p<(3*max/10)))
   {
    h*=0.90;
    Terran_AddHaut(point,h);
   }
   else
   {
    h*=0.95;
    Terran_AddHaut(point,h);
   }
  }
  if (p>1)
  {
   if(t1!=((void *)0)) Terran_VieilMont(t,t1,h,p-1,max);
   if(t2!=((void *)0)) Terran_VieilMont(t,t2,h,p-1,max);
   if(t3!=((void *)0)) Terran_VieilMont(t,t3,h,p-1,max);
  }
 }
 }
}

canonical_original_code:
void Terran_VieilMont(struct sTriangle *orig, struct sTriangle *t, double h, int p, int max)
{
 int point = -1;
 struct sTriangle *t1 = ((void *)0); struct sTriangle *t2 = ((void *)0); struct sTriangle *t3 = ((void *)0);
 if(t!=((void *)0))
 {
  if(orig==((void *)0))
  {
   Terran_Set(2,t,p);
   Terran_AddHaut(t->p1,h/3);
   Terran_AddHaut(t->p2,h/3);
   Terran_AddHaut(t->p3,h/3);
   t1=t->t1;
   t2=t->t2;
   t3=t->t3;
   t->type=0;
  }
 else
 if(t->type==2)
 {
  t->type=0;
  if(orig==t->t1)
  {
   point =t->p3;
   t1=t->t2;
   t2=t->t1;
  }
  else if(orig==t->t2)
  {
   point =t->p1;
   t1=t->t1;
   t2=t->t3;
  }
  else if(orig==t->t1)
  {
   point =t->p2;
   t1=t->t3;
   t2=t->t2;
  }
  if (point!=-1)
  {
   if ((p>(max/10))&&(p<(3*max/10)))
   {
    h*=0.90;
    Terran_AddHaut(point,h);
   }
   else
   {
    h*=0.95;
    Terran_AddHaut(point,h);
   }
  }
  if (p>1)
  {
   if(t1!=((void *)0)) Terran_VieilMont(t,t1,h,p-1,max);
   if(t2!=((void *)0)) Terran_VieilMont(t,t2,h,p-1,max);
   if(t3!=((void *)0)) Terran_VieilMont(t,t3,h,p-1,max);
  }
 }
 }
}

variable_types: max int


original_code:
void Vecteur_ProdVect(SVecteur *V1, SVecteur *V2, SVecteur *V3)
{
 V3->x=V1->y*V2->z-V1->z*V2->y;
 V3->y=V1->z*V2->x-V1->x*V2->z;
 V3->z=V1->x*V2->y-V1->y*V2->x;
}

canonical_original_code:
void Vecteur_ProdVect(struct sVecteur *V1, struct sVecteur *V2, struct sVecteur *V3)
{
 V3->x=V1->y*V2->z-V1->z*V2->y;
 V3->y=V1->z*V2->x-V1->x*V2->z;
 V3->z=V1->x*V2->y-V1->y*V2->x;
}


decompiled_code:
_BOOL8 __fastcall Vecteur_Zup(double *a1, double *a2)
{
return *a1 * a2[1] - a1[1] * *a2 > 0.0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(double *a1, double *a2)
{
return *a1 * a2[1] - a1[1] * *a2 > 0.0;
}

original_code:
int Vecteur_Zup(SVecteur *V1, SVecteur *V2)
{
return ((V1->x*V2->y-V1->y*V2->x)>0.0);
}

canonical_original_code:
int Vecteur_Zup(struct sVecteur *V1, struct sVecteur *V2)
{
return ((V1->x*V2->y-V1->y*V2->x)>0.0);
}


original_code:
int Delaunay_ChoisitPoint()
{
 STriangle *t;
 double coef1,coef2,coef3;
 double sum;
 t = tab.triangles->first->t;
 if(param.barycentre)
  {coef1=coef2=coef3=1;}
 else
  {
  coef1 = rand()%5+1;
  coef2 = rand()%5+1;
  coef3 = rand()%5+1;
  }
 sum = coef1 + coef2 + coef3;
 return Global_AddPoint( (tab.p[t->p1].x*coef1 + tab.p[t->p2].x*coef2 + tab.p[t->p3].x*coef3)/sum,
      (tab.p[t->p1].y*coef1 + tab.p[t->p2].y*coef2 + tab.p[t->p3].y*coef3)/sum,
      (tab.p[t->p1].z*coef1 + tab.p[t->p2].z*coef2 + tab.p[t->p3].z*coef3)/sum);
}

canonical_original_code:
int Delaunay_ChoisitPoint()
{
 struct sTriangle *t;
 double coef1; double coef2; double coef3;
 double sum;
 t = tab.triangles->first->t;
 if(param.barycentre)
  {coef1=coef2=coef3=1;}
 else
  {
  coef1 = rand()%5+1;
  coef2 = rand()%5+1;
  coef3 = rand()%5+1;
  }
 sum = coef1 + coef2 + coef3;
 return Global_AddPoint( (tab.p[t->p1].x*coef1 + tab.p[t->p2].x*coef2 + tab.p[t->p3].x*coef3)/sum,
      (tab.p[t->p1].y*coef1 + tab.p[t->p2].y*coef2 + tab.p[t->p3].y*coef3)/sum,
      (tab.p[t->p1].z*coef1 + tab.p[t->p2].z*coef2 + tab.p[t->p3].z*coef3)/sum);
}

variable_types: sum double


decompiled_code:
_BOOL8 __fastcall Delaunay_PointInCercle(int a1, double *a2)
{
double *v2; // rax
double v3; // xmm1_8
double v4; // xmm0_8
_BOOL8 result; // rax

v2 = (double *)((char *)&tab + 24 * a1);
v3 = v2[3] - a2[6];
v4 = (v2[4] - a2[7]) * (v2[4] - a2[7]) + v3 * v3;
if ( v4 < 0.0 )
result = a2[9] > sqrt(v4);
else
result = a2[9] > sqrt(v4);
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(int a1, double *a2)
{
double *v2; // rax
double v3; // xmm1_8
double v4; // xmm0_8
_BOOL8 result; // rax

v2 = (double *)((char *)&tab + 24 * a1);
v3 = v2[3] - a2[6];
v4 = (v2[4] - a2[7]) * (v2[4] - a2[7]) + v3 * v3;
if ( v4 < 0.0 )
result = a2[9] > sqrt(v4);
else
result = a2[9] > sqrt(v4);
return result;
}

original_code:
int Delaunay_PointInCercle(int p, STriangle *t)
{
 double dist = (tab.p[p].x-t->centre.x)*(tab.p[p].x-t->centre.x)+(tab.p[p].y-t->centre.y)*(tab.p[p].y-t->centre.y);
 dist = sqrt(dist);
 return (dist<t->rayon);
}

canonical_original_code:
int Delaunay_PointInCercle(int p, struct sTriangle *t)
{
 double dist = (tab.p[p].x-t->centre.x)*(tab.p[p].x-t->centre.x)+(tab.p[p].y-t->centre.y)*(tab.p[p].y-t->centre.y);
 dist = sqrt(dist);
 return (dist<t->rayon);
}

variable_types: dist double


achieveDestruction

decompiled_code:
__int64 __fastcall achieveDestruction(int a1)
{
unsigned int v1; // er8
_BYTE *v2; // rax

v1 = -4 * players - a1;
if ( numNodes > 0 )
{
v2 = (_BYTE *)(nodes + 4LL);
do
{
if ( !*v2 )
{
if ( !v1 )
return v1;
++v1;
}
v2 += 88;
}
while ( v2 != (_BYTE *)(nodes + 88LL * (unsigned int)(numNodes - 1) + 92) );
}
return 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
unsigned int v1; // er8
_BYTE *v2; // rax

v1 = -4 * players - a1;
if ( numNodes > 0 )
{
v2 = (_BYTE *)(nodes + 4LL);
do
{
if ( !*v2 )
{
if ( !v1 )
return v1;
++v1;
}
v2 += 88;
}
while ( v2 != (_BYTE *)(nodes + 88LL * (unsigned int)(numNodes - 1) + 92) );
}
return 1;
}

original_code:
static int achieveDestruction(int numAcceptable)
{
 int alive = -4 * players - numAcceptable;
 int i = 0;
 for (; i < numNodes; i++) {
  if (!nodes[i].dead)
   if (0 == alive++)
    return 0;
 }
 return 1;
}

variable_types: numAcceptable int

variable_types: alive int

variable_types: i int


achieveRosetteHelper

decompiled_code:
__int64 __fastcall achieveRosetteHelper(int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx
int v4; // er15
int v5; // er13
int v6; // er14
__int64 v7; // rbx
__int64 v8; // rdi
double v9; // xmm0_8
double v10; // xmm0_8
double v11; // xmm0_8

*(_BYTE *)(a2 + a1) = 1;
result = nodes;
v3 = nodes + 88LL * a1;
v4 = (int)*(double *)(v3 + 56);
v5 = *(_DWORD *)(v3 + 8);
v6 = *(_DWORD *)(v3 + 16);
if ( numNodes > 0 )
{
v7 = 0LL;
while ( 1 )
{
v8 = (unsigned int)v7;
result += 88 * v7;
if ( !*(_BYTE *)(result + 4) && !*(_BYTE *)(a2 + v7) )
{
v9 = (double)(int)(*(_QWORD *)(result + 8) - v5);
v10 = v9 * v9 + (double)(*(_DWORD *)(result + 16) - v6) * (double)(*(_DWORD *)(result + 16) - v6);
if ( v10 < 0.0 )
{
v11 = sqrt(v10);
v8 = (unsigned int)v7;
result = 88 * v7 + nodes;
}
else
{
v11 = sqrt(v10);
}
if ( v11 - *(double *)(result + 56) - (double)v4 < 10.0 )
result = achieveRosetteHelper(v8, a2);
}
if ( numNodes <= (int)++v7 )
break;
result = nodes;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx
int v4; // er15
int v5; // er13
int v6; // er14
__int64 v7; // rbx
__int64 v8; // rdi
double v9; // xmm0_8
double v10; // xmm0_8
double v11; // xmm0_8

*(_BYTE *)(a2 + a1) = 1;
result = nodes;
v3 = nodes + 88LL * a1;
v4 = (int)*(double *)(v3 + 56);
v5 = *(_DWORD *)(v3 + 8);
v6 = *(_DWORD *)(v3 + 16);
if ( numNodes > 0 )
{
v7 = 0LL;
while ( 1 )
{
v8 = (unsigned int)v7;
result += 88 * v7;
if ( !*(_BYTE *)(result + 4) && !*(_BYTE *)(a2 + v7) )
{
v9 = (double)(int)(*(_QWORD *)(result + 8) - v5);
v10 = v9 * v9 + (double)(*(_DWORD *)(result + 16) - v6) * (double)(*(_DWORD *)(result + 16) - v6);
if ( v10 < 0.0 )
{
v11 = sqrt(v10);
v8 = (unsigned int)v7;
result = 88 * v7 + nodes;
}
else
{
v11 = sqrt(v10);
}
if ( v11 - *(double *)(result + 56) - (double)v4 < 10.0 )
result = func1(v8, a2);
}
if ( numNodes <= (int)++v7 )
break;
result = nodes;
}
}
return result;
}

original_code:
static void achieveRosetteHelper(int ix, char *touching)
{
 touching[ix] = 1;
 int x = nodes[ix].x;
 int y = nodes[ix].y;
 int r = nodes[ix].size;
 int i = 0;
 for (; i < numNodes; i++) {
  if (nodes[i].dead || touching[i])
   continue;
  double dx = nodes[i].x - x;
  double dy = nodes[i].y - y;
  if (sqrt(dx * dx + dy * dy) - nodes[i].size - r < 10)
   achieveRosetteHelper(i, touching);
 }
}

variable_types: ix int

variable_types:
touching
char *

variable_types: r int

variable_types: dx double

variable_types: dy double


achieveLazy

decompiled_code:
__int64 achieveLazy()
{
return 1LL;
}

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

original_code:
int achieveLazy()
{
 return 1;
}

canonical_original_code:
int achieveLazy()
{
 return 1;
}


achieveFlawless

decompiled_code:
__int64 achieveFlawless()
{
_BYTE *v0; // rax

if ( players <= 0 )
return 2LL;
v0 = (_BYTE *)(guyDatas + 73LL);
while ( !*v0 && v0[1] )
{
v0 += 152;
if ( v0 == (_BYTE *)(guyDatas + 152LL * (unsigned int)(players - 1) + 225) )
return 2LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
_BYTE *v0; // rax

if ( players <= 0 )
return 2LL;
v0 = (_BYTE *)(guyDatas + 73LL);
while ( !*v0 && v0[1] )
{
v0 += 152;
if ( v0 == (_BYTE *)(guyDatas + 152LL * (unsigned int)(players - 1) + 225) )
return 2LL;
}
return 1LL;
}

original_code:
int achieveFlawless()
{
 int i = 0;
 for (; i < players; i++) {
  if (guyDatas[i].injured || !guyDatas[i].firstLife)
   return 1;
 }
 return 2;
}


achieveGardens

decompiled_code:
__int64 achieveGardens()
{
_DWORD *v0; // rax

if ( players <= 0 )
return 0LL;
v0 = (_DWORD *)(guyDatas + 16LL);
while ( *v0 != 70 )
{
v0 += 38;
if ( v0 == (_DWORD *)(guyDatas + 152LL * (unsigned int)(players - 1) + 168) )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 func4()
{
_DWORD *v0; // rax

if ( players <= 0 )
return 0LL;
v0 = (_DWORD *)(guyDatas + 16LL);
while ( *v0 != 70 )
{
v0 += 38;
if ( v0 == (_DWORD *)(guyDatas + 152LL * (unsigned int)(players - 1) + 168) )
return 0LL;
}
return 1LL;
}

original_code:
int achieveGardens()
{
 int i = 0;
 for (; i < players; i++) {
  if (guyDatas[i].controlType == 70)
   return 1;
 }
 return 0;
}


achieveCave

decompiled_code:
__int64 achieveCave()
{
_DWORD *v0; // rax

if ( players <= 0 )
return 0LL;
v0 = (_DWORD *)(guyDatas + 144LL);
while ( (unsigned int)(*v0 + 49) > 0x62 || (int)v0[1] >= -50 )
{
v0 += 38;
if ( v0 == (_DWORD *)(guyDatas + 152LL * (unsigned int)(players - 1) + 296) )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 func5()
{
_DWORD *v0; // rax

if ( players <= 0 )
return 0LL;
v0 = (_DWORD *)(guyDatas + 144LL);
while ( (unsigned int)(*v0 + 49) > 0x62 || (int)v0[1] >= -50 )
{
v0 += 38;
if ( v0 == (_DWORD *)(guyDatas + 152LL * (unsigned int)(players - 1) + 296) )
return 0LL;
}
return 1LL;
}

original_code:
int achieveCave()
{
 int i = 0;
 for (; i < players; i++) {
  if (abs(guyDatas[i].centerX) < 50
      && guyDatas[i].centerY < -50)
   return 1;
 }
 return 0;
}


achieveBuilding

decompiled_code:
__int64 achieveBuilding()
{
int *v0; // rax

if ( players <= 0 )
return 0LL;
v0 = (int *)(guyDatas + 148LL);
while ( *v0 >= -325 )
{
v0 += 38;
if ( v0 == (int *)(guyDatas + 152LL * (unsigned int)(players - 1) + 300) )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 func6()
{
int *v0; // rax

if ( players <= 0 )
return 0LL;
v0 = (int *)(guyDatas + 148LL);
while ( *v0 >= -325 )
{
v0 += 38;
if ( v0 == (int *)(guyDatas + 152LL * (unsigned int)(players - 1) + 300) )
return 0LL;
}
return 1LL;
}

original_code:
int achieveBuilding()
{
 int i = 0;
 for (; i < players; i++) {
  if (guyDatas[i].centerY < -325)
   return 1;
 }
 return 0;
}


achieveSumo

decompiled_code:
__int64 achieveSumo()
{
return achieveDestruction(70);
}

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

original_code:
int achieveSumo()
{
 return achieveDestruction(70);
}


achieveDrop

decompiled_code:
__int64 achieveDrop()
{
return achieveDestruction(20);
}

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

original_code:
int achieveDrop()
{
 return achieveDestruction(20);
}


achieveWalled

decompiled_code:
__int64 achieveWalled()
{
return achieveDrop();
}

canonical_decompiled_code:
__int64 func9()
{
return func8();
}

original_code:
int achieveWalled()
{
 return achieveDestruction(20);
}


achieveBoulder

decompiled_code:
__int64 achieveBoulder()
{
__int64 v0; // rax

if ( numNodes <= 0 )
return 1LL;
v0 = nodes + 4LL;
while ( *(_BYTE *)v0 || 3.0 != *(double *)(v0 + 60) )
{
v0 += 88LL;
if ( v0 == nodes + 88LL * (unsigned int)(numNodes - 1) + 92 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 v0; // rax

if ( numNodes <= 0 )
return 1LL;
v0 = nodes + 4LL;
while ( *(_BYTE *)v0 || 3.0 != *(double *)(v0 + 60) )
{
v0 += 88LL;
if ( v0 == nodes + 88LL * (unsigned int)(numNodes - 1) + 92 )
return 1LL;
}
return 0LL;
}

original_code:
int achieveBoulder()
{
 int i = 0;
 for (; i < numNodes; i++) {
  if (!nodes[i].dead && 3 == nodes[i].mass)
   return 0;
 }
 return 1;
}


achievePlain

decompiled_code:
__int64 achievePlain()
{
__int64 v0; // rax

if ( numNodes <= 0 )
return 1LL;
v0 = nodes + 4LL;
while ( *(_BYTE *)v0 || 1.0 != *(double *)(v0 + 60) )
{
v0 += 88LL;
if ( v0 == nodes + 88LL * (unsigned int)(numNodes - 1) + 92 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 v0; // rax

if ( numNodes <= 0 )
return 1LL;
v0 = nodes + 4LL;
while ( *(_BYTE *)v0 || 1.0 != *(double *)(v0 + 60) )
{
v0 += 88LL;
if ( v0 == nodes + 88LL * (unsigned int)(numNodes - 1) + 92 )
return 1LL;
}
return 0LL;
}

original_code:
int achievePlain()
{
 int i = 0;
 for (; i < numNodes; i++) {
  if (!nodes[i].dead && 1 == nodes[i].mass)
   return 0;
 }
 return 1;
}


achieveManMech

original_code:
int achieveManMech()
{
 int count = 0;
 int result = 0;
 int i = 0;
 int j;
 for (; i < numNodes; i++) {
  if (nodes[i].dead || 14 != nodes[i].mass)
   continue;
  count++;
  for (j = 0; j < nodes[i].numConnections; j++) {
   if (nodes[i].connections[j].dead) {
    result = 1;
    break;
   }
  }
 }
 if (count < 5)
  return 0;
 return result;
}

variable_types: count int

variable_types: result int

variable_types: j int


achieveGunMech

decompiled_code:
__int64 achieveGunMech()
{
__int64 v0; // rax
double v1; // xmm0_8

if ( numNodes <= 0 )
return 1LL;
v0 = nodes + 4LL;
while ( 1 )
{
if ( !*(_BYTE *)v0 )
{
v1 = *(double *)(v0 + 60);
if ( v1 == 1.0 || v1 == 14.0 )
break;
}
v0 += 88LL;
if ( v0 == nodes + 88LL * (unsigned int)(numNodes - 1) + 92 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 v0; // rax
double v1; // xmm0_8

if ( numNodes <= 0 )
return 1LL;
v0 = nodes + 4LL;
while ( 1 )
{
if ( !*(_BYTE *)v0 )
{
v1 = *(double *)(v0 + 60);
if ( v1 == 1.0 || v1 == 14.0 )
break;
}
v0 += 88LL;
if ( v0 == nodes + 88LL * (unsigned int)(numNodes - 1) + 92 )
return 1LL;
}
return 0LL;
}

original_code:
int achieveGunMech()
{
 int i = 0;
 for (; i < numNodes; i++) {
  if (!nodes[i].dead
      && (14 == nodes[i].mass || 1 == nodes[i].mass))
   return 0;
 }
 return 1;
}


achieveMechMech

original_code:
int achieveMechMech()
{
 unsigned char stage = 0;
 int pos[2] = { -1000, 1000 };;
 int i = 0;
 int j, k, l;
 for (; i < numNodes; i++) {
  if (nodes[i].dead || nodes[i].mass != 14
      || nodes[i].size != 6)
   continue;
  for (j = nodes[i].numConnections - 1; j >= 0; j--) {
   if (nodes[i].connections[j].dead)
    return 0;
   k = nodes[i].connections[j].id;
   if (nodes[k].dead)
    return 0;
   for (l = nodes[k].numConnections - 1; l >= 0; l--)
    if (nodes[k].connections[l].dead)
     return 0;
   if (stage ^ (nodes[k].x > pos[stage]))
    pos[stage] = nodes[k].x;
  }
  if (stage)
   return pos[0] < pos[1];
  else
   stage++;
 }
 return 0;
}

canonical_original_code:
int achieveMechMech()
{
 unsigned char stage = 0;
 int pos[2] = { -1000, 1000 };;
 int i = 0;
 int j; int k; int l;
 for (; i < numNodes; i++) {
  if (nodes[i].dead || nodes[i].mass != 14
      || nodes[i].size != 6)
   continue;
  for (j = nodes[i].numConnections - 1; j >= 0; j--) {
   if (nodes[i].connections[j].dead)
    return 0;
   k = nodes[i].connections[j].id;
   if (nodes[k].dead)
    return 0;
   for (l = nodes[k].numConnections - 1; l >= 0; l--)
    if (nodes[k].connections[l].dead)
     return 0;
   if (stage ^ (nodes[k].x > pos[stage]))
    pos[stage] = nodes[k].x;
  }
  if (stage)
   return pos[0] < pos[1];
  else
   stage++;
 }
 return 0;
}

variable_types:
stage
unsigned char

variable_types:
pos
int [2]

variable_types: k int

variable_types: l int


achieveAsteroids

decompiled_code:
__int64 achieveAsteroids()
{
__int64 v0; // rcx
_DWORD *v1; // rax
__int64 v2; // rdx

if ( numNodes <= 0 )
return 0LL;
v0 = nodes + 4LL;
while ( *(_BYTE *)v0 || 10.0 != *(double *)(v0 + 52) || players <= 0 )
{
LABEL_3:
v0 += 88LL;
if ( nodes + 88LL * (unsigned int)(numNodes - 1) + 92 == v0 )
return 0LL;
}
v1 = (_DWORD *)(guyDatas + 144LL);
while ( 1 )
{
v2 = (int)v1[1] - *(_QWORD *)(v0 + 12);
if ( (double)(int)(*v1 - *(_QWORD *)(v0 + 4)) * (double)(int)(*v1 - *(_QWORD *)(v0 + 4))
+ (double)(int)v2 * (double)(int)v2 <= 100.0 )
return 1LL;
v1 += 38;
if ( (_DWORD *)(guyDatas + 152LL * (unsigned int)(players - 1) + 296) == v1 )
goto LABEL_3;
}
}

canonical_decompiled_code:
__int64 func15()
{
__int64 v0; // rcx
_DWORD *v1; // rax
__int64 v2; // rdx

if ( numNodes <= 0 )
return 0LL;
v0 = nodes + 4LL;
while ( *(_BYTE *)v0 || 10.0 != *(double *)(v0 + 52) || players <= 0 )
{
LABEL_3:
v0 += 88LL;
if ( nodes + 88LL * (unsigned int)(numNodes - 1) + 92 == v0 )
return 0LL;
}
v1 = (_DWORD *)(guyDatas + 144LL);
while ( 1 )
{
v2 = (int)v1[1] - *(_QWORD *)(v0 + 12);
if ( (double)(int)(*v1 - *(_QWORD *)(v0 + 4)) * (double)(int)(*v1 - *(_QWORD *)(v0 + 4))
+ (double)(int)v2 * (double)(int)v2 <= 100.0 )
return 1LL;
v1 += 38;
if ( (_DWORD *)(guyDatas + 152LL * (unsigned int)(players - 1) + 296) == v1 )
goto LABEL_3;
}
}

original_code:
int achieveAsteroids()
{
 int i = 0, j;
 for (; i < numNodes; i++) {
  if (nodes[i].dead || nodes[i].size != 10)
   continue;
  for (j = 0; j < players; j++) {
   double dx = guyDatas[j].centerX - nodes[i].x;
   double dy = guyDatas[j].centerY - nodes[i].y;
   if (dx * dx + dy * dy <= 100)
    return 1;
  }
 }
 return 0;
}

canonical_original_code:
int achieveAsteroids()
{
 int i = 0; int j;
 for (; i < numNodes; i++) {
  if (nodes[i].dead || nodes[i].size != 10)
   continue;
  for (j = 0; j < players; j++) {
   double dx = guyDatas[j].centerX - nodes[i].x;
   double dy = guyDatas[j].centerY - nodes[i].y;
   if (dx * dx + dy * dy <= 100)
    return 1;
  }
 }
 return 0;
}


achievePlanet

decompiled_code:
__int64 achievePlanet()
{
int v0; // ebp
__int64 v1; // rbx
double v2; // xmm2_8
double v3; // xmm0_8
double v4; // xmm0_8

if ( players <= 0 )
return 0LL;
v0 = 0;
v1 = 0LL;
v2 = *(double *)&LC7;
do
{
v3 = (double)*(int *)(v1 + guyDatas + 144) * (double)*(int *)(v1 + guyDatas + 144)
+ (double)*(int *)(v1 + guyDatas + 148) * (double)*(int *)(v1 + guyDatas + 148);
if ( v3 < 0.0 )
{
v4 = sqrt(v3);
v2 = *(double *)&LC7;
}
else
{
v4 = sqrt(v3);
}
if ( v4 > v2 )
return 1LL;
++v0;
v1 += 152LL;
}
while ( players > v0 );
return 0LL;
}

canonical_decompiled_code:
__int64 func16()
{
int v0; // ebp
__int64 v1; // rbx
double v2; // xmm2_8
double v3; // xmm0_8
double v4; // xmm0_8

if ( players <= 0 )
return 0LL;
v0 = 0;
v1 = 0LL;
v2 = *(double *)&LC7;
do
{
v3 = (double)*(int *)(v1 + guyDatas + 144) * (double)*(int *)(v1 + guyDatas + 144)
+ (double)*(int *)(v1 + guyDatas + 148) * (double)*(int *)(v1 + guyDatas + 148);
if ( v3 < 0.0 )
{
v4 = sqrt(v3);
v2 = *(double *)&LC7;
}
else
{
v4 = sqrt(v3);
}
if ( v4 > v2 )
return 1LL;
++v0;
v1 += 152LL;
}
while ( players > v0 );
return 0LL;
}

original_code:
int achievePlanet()
{
 int i = 0;
 for (; i < players; i++) {
  double x = guyDatas[i].centerX;
  double y = guyDatas[i].centerY;
  if (sqrt(x * x + y * y) > 390)
   return 1;
 }
 return 0;
}

variable_types: x double

variable_types: y double


achieveRosette

decompiled_code:
__int64 achieveRosette()
{
int v0; // ebp
__int64 v1; // rax
__int64 result; // rax
char *v3; // r12
char *v4; // rdx
double *v5; // rax

if ( numNodes <= 0 )
{
if ( !numNodes )
{
LABEL_6:
puts("WTF HOW\nPlz contact me!\n-Simon");
return 1LL;
}
v0 = 0;
}
else
{
v0 = 0;
v1 = nodes + 4LL;
while ( *(_BYTE *)v1 || 6.0 == *(double *)(v1 + 52) )
{
++v0;
v1 += 88LL;
if ( v0 == numNodes )
goto LABEL_6;
}
}
v3 = (char *)calloc(numNodes, 1uLL);
achieveRosetteHelper(v0, (__int64)v3);
if ( numNodes <= 0 )
{
LABEL_15:
free(v3);
result = 1LL;
}
else
{
v4 = v3;
v5 = (double *)(nodes + 56LL);
while ( *((_BYTE *)v5 - 52) || *v4 || 6.0 == *v5 )
{
++v4;
v5 += 11;
if ( v4 == &v3[numNodes] )
goto LABEL_15;
}
free(v3);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func17()
{
int v0; // ebp
__int64 v1; // rax
__int64 result; // rax
char *v3; // r12
char *v4; // rdx
double *v5; // rax

if ( numNodes <= 0 )
{
if ( !numNodes )
{
LABEL_6:
puts("WTF HOW\nPlz contact me!\n-Simon");
return 1LL;
}
v0 = 0;
}
else
{
v0 = 0;
v1 = nodes + 4LL;
while ( *(_BYTE *)v1 || 6.0 == *(double *)(v1 + 52) )
{
++v0;
v1 += 88LL;
if ( v0 == numNodes )
goto LABEL_6;
}
}
v3 = (char *)calloc(numNodes, 1uLL);
func1(v0, (__int64)v3);
if ( numNodes <= 0 )
{
LABEL_15:
free(v3);
result = 1LL;
}
else
{
v4 = v3;
v5 = (double *)(nodes + 56LL);
while ( *((_BYTE *)v5 - 52) || *v4 || 6.0 == *v5 )
{
++v4;
v5 += 11;
if ( v4 == &v3[numNodes] )
goto LABEL_15;
}
free(v3);
result = 0LL;
}
return result;
}

original_code:
int achieveRosette()
{
 int i;
 for (i = 0; i < numNodes && (nodes[i].dead || nodes[i].size == 6);
      i++);
 if (i == numNodes) {
  puts("WTF HOW\nPlz contact me!\n-Simon");
  return 1;
 }
 char *touching = calloc(numNodes, 1);
 achieveRosetteHelper(i, touching);
 for (i = 0; i < numNodes; i++)
  if (nodes[i].dead == 0 && touching[i] == 0
      && nodes[i].size != 6) {
   free(touching);
   return 0;
  }
 free(touching);
 return 1;
}


achieveBigPlanet

decompiled_code:
__int64 achieveBigPlanet()
{
unsigned int *v0; // rax
unsigned int v1; // er8

if ( numTools <= 0 )
return 1;
v0 = (unsigned int *)tools;
while ( 1 )
{
v1 = *v0;
if ( !*v0 && v0[1] != -1 )
break;
v0 += 3;
if ( v0 == (unsigned int *)(tools + 12LL * (unsigned int)(numTools - 1) + 12) )
return 1;
}
return v1;
}

canonical_decompiled_code:
__int64 func18()
{
unsigned int *v0; // rax
unsigned int v1; // er8

if ( numTools <= 0 )
return 1;
v0 = (unsigned int *)tools;
while ( 1 )
{
v1 = *v0;
if ( !*v0 && v0[1] != -1 )
break;
v0 += 3;
if ( v0 == (unsigned int *)(tools + 12LL * (unsigned int)(numTools - 1) + 12) )
return 1;
}
return v1;
}

original_code:
int achieveBigPlanet()
{
 int i = 0;
 for (; i < numTools; i++) {
  if (tools[i].type == 0 && tools[i].where != -1)
   return 0;
 }
 return 1;
}


achieveTutorial

decompiled_code:
__int64 achieveTutorial()
{
__int64 v0; // rax
int v1; // ecx

if ( numNodes <= 0 )
return 1LL;
v0 = nodes + 4LL;
v1 = 0;
while ( *(_BYTE *)v0 || 8.0 != *(double *)(v0 + 52) || ++v1 != 9 )
{
v0 += 88LL;
if ( v0 == nodes + 88LL * (unsigned int)(numNodes - 1) + 92 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func19()
{
__int64 v0; // rax
int v1; // ecx

if ( numNodes <= 0 )
return 1LL;
v0 = nodes + 4LL;
v1 = 0;
while ( *(_BYTE *)v0 || 8.0 != *(double *)(v0 + 52) || ++v1 != 9 )
{
v0 += 88LL;
if ( v0 == nodes + 88LL * (unsigned int)(numNodes - 1) + 92 )
return 1LL;
}
return 0LL;
}

original_code:
int achieveTutorial()
{
 int count = 0;
 int i = 0;
 for (; i < numNodes; i++) {
  if (nodes[i].dead == 0 && nodes[i].size == 8) {
   if (++count == 9)
    return 0;
  }
 }
 return 1;
}


quitGfx

decompiled_code:
__int64 quitGfx()
{
return _glewBindBuffer(34962LL, 0LL);
}

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

original_code:
void quitGfx()
{
 __glewBindBuffer(0x8892, 0);
}


setColorFromHue

variable_types:
hue
unsigned short

variable_types: r float

variable_types: g float

variable_types: b float


getColorFromHue

return_type: unsigned int


setColorWhite

decompiled_code:
__int64 setColorWhite()
{
return _glewUniform3f((unsigned int)uniColorId, COERCE_DOUBLE((unsigned __int64)LC13), 0.5, 0.5);
}

canonical_decompiled_code:
__int64 func4()
{
return _glewUniform3f((unsigned int)uniColorId, COERCE_DOUBLE((unsigned __int64)LC13), 0.5, 0.5);
}

original_code:
void setColorWhite()
{
 __glewUniform3f(uniColorId, 0.5, 0.5, 0.5);
}


setColorFromHex

decompiled_code:
__int64 __fastcall setColorFromHex(int a1)
{
double v1; // xmm0_8
__int64 result; // rax

if ( (cheats & 0x10) == 0 )
{
HIDWORD(v1) = 0;
*(float *)&v1 = (float)(int)(a1 & 0xFF000000) / 4278190100.0;
result = _glewUniform3f(
(unsigned int)uniColorId,
v1,
(float)(a1 & 0xFF0000) / 16711680.0,
(float)(a1 & 0xFF00) / 65280.0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
double v1; // xmm0_8
__int64 result; // rax

if ( (cheats & 0x10) == 0 )
{
HIDWORD(v1) = 0;
*(float *)&v1 = (float)(int)(a1 & 0xFF000000) / 4278190100.0;
result = _glewUniform3f(
(unsigned int)uniColorId,
v1,
(float)(a1 & 0xFF0000) / 16711680.0,
(float)(a1 & 0xFF00) / 65280.0);
}
return result;
}

original_code:
void setColorFromHex(uint32_t color)
{
 if (cheats & 16)
  return;
 __glewUniform3f(uniColorId, (float) (color & 0xFF000000) / 0xFF000000,
      (float) (color & 0xFF0000) / 0xFF0000,
      (float) (color & 0xFF00) / 0xFF00);
}

canonical_original_code:
void setColorFromHex(unsigned int color)
{
 if (cheats & 16)
  return;
 __glewUniform3f(uniColorId, (float) (color & 0xFF000000) / 0xFF000000,
      (float) (color & 0xFF0000) / 0xFF0000,
      (float) (color & 0xFF00) / 0xFF00);
}

variable_types:
color
unsigned int


drawBox

decompiled_code:
__int64 __fastcall drawBox(float a1, float a2, float a3, float a4)
{
int v5[10]; // [rsp+0h] [rbp-28h] BYREF

*(float *)v5 = a1;
*(float *)&v5[1] = a2;
*(float *)&v5[2] = a3;
*(float *)&v5[3] = a2;
*(float *)&v5[4] = a3;
*(float *)&v5[5] = a4;
*(float *)&v5[6] = a1;
*(float *)&v5[7] = a4;
_glewBufferData(34962LL, 32LL, v5, 35040LL);
glDrawArrays(7LL, 0LL, 4LL);
_glewMapBufferRange(34962LL, 0LL, 0LL, 42LL);
return _glewUnmapBuffer(34962LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(float a1, float a2, float a3, float a4)
{
int v5[10]; // [rsp+0h] [rbp-28h] BYREF

*(float *)v5 = a1;
*(float *)&v5[1] = a2;
*(float *)&v5[2] = a3;
*(float *)&v5[3] = a2;
*(float *)&v5[4] = a3;
*(float *)&v5[5] = a4;
*(float *)&v5[6] = a1;
*(float *)&v5[7] = a4;
_glewBufferData(34962LL, 32LL, v5, 35040LL);
glDrawArrays(7LL, 0LL, 4LL);
_glewMapBufferRange(34962LL, 0LL, 0LL, 42LL);
return _glewUnmapBuffer(34962LL);
}

original_code:
void drawBox(float x1, float y1, float x2, float y2)
{
 float points[] = {
  x1, y1,
  x2, y1,
  x2, y2,
  x1, y2
 };
 __glewBufferData(0x8892, sizeof(points), points,
       0x88E0);
 glDrawArrays(0x0007, 0, 4);
 __glewMapBufferRange(0x8892, 0, 0,
    0x0002 | 0x0020 |
    0x0008);
 __glewUnmapBuffer(0x8892);
}

variable_types:
points
float []


drawRectangle

decompiled_code:
__int64 __fastcall drawRectangle(float a1, float a2, float a3, float a4)
{
int v5[10]; // [rsp+0h] [rbp-28h] BYREF

*(float *)v5 = a1;
*(float *)&v5[1] = a2;
*(float *)&v5[2] = a3;
*(float *)&v5[3] = a2;
*(float *)&v5[4] = a3;
*(float *)&v5[5] = a4;
*(float *)&v5[6] = a1;
*(float *)&v5[7] = a4;
_glewBufferData(34962LL, 32LL, v5, 35040LL);
glDrawArrays(2LL, 0LL, 4LL);
_glewMapBufferRange(34962LL, 0LL, 0LL, 42LL);
return _glewUnmapBuffer(34962LL);
}

canonical_decompiled_code:
__int64 __fastcall func7(float a1, float a2, float a3, float a4)
{
int v5[10]; // [rsp+0h] [rbp-28h] BYREF

*(float *)v5 = a1;
*(float *)&v5[1] = a2;
*(float *)&v5[2] = a3;
*(float *)&v5[3] = a2;
*(float *)&v5[4] = a3;
*(float *)&v5[5] = a4;
*(float *)&v5[6] = a1;
*(float *)&v5[7] = a4;
_glewBufferData(34962LL, 32LL, v5, 35040LL);
glDrawArrays(2LL, 0LL, 4LL);
_glewMapBufferRange(34962LL, 0LL, 0LL, 42LL);
return _glewUnmapBuffer(34962LL);
}

original_code:
void drawRectangle(float x1, float y1, float x2, float y2)
{
 float points[] = {
  x1, y1,
  x2, y1,
  x2, y2,
  x1, y2
 };
 __glewBufferData(0x8892, sizeof(points), points,
       0x88E0);
 glDrawArrays(0x0002, 0, 4);
 __glewMapBufferRange(0x8892, 0, 0,
    0x0002 | 0x0020 |
    0x0008);
 __glewUnmapBuffer(0x8892);
}


drawLine

decompiled_code:
__int64 __fastcall drawLine(float a1, float a2, float a3, float a4)
{
int v5[6]; // [rsp+0h] [rbp-18h] BYREF

*(float *)v5 = a1;
*(float *)&v5[1] = a2;
*(float *)&v5[2] = a3;
*(float *)&v5[3] = a4;
_glewBufferData(34962LL, 16LL, v5, 35040LL);
glDrawArrays(1LL, 0LL, 2LL);
_glewMapBufferRange(34962LL, 0LL, 0LL, 42LL);
return _glewUnmapBuffer(34962LL);
}

canonical_decompiled_code:
__int64 __fastcall func8(float a1, float a2, float a3, float a4)
{
int v5[6]; // [rsp+0h] [rbp-18h] BYREF

*(float *)v5 = a1;
*(float *)&v5[1] = a2;
*(float *)&v5[2] = a3;
*(float *)&v5[3] = a4;
_glewBufferData(34962LL, 16LL, v5, 35040LL);
glDrawArrays(1LL, 0LL, 2LL);
_glewMapBufferRange(34962LL, 0LL, 0LL, 42LL);
return _glewUnmapBuffer(34962LL);
}

original_code:
void drawLine(float x1, float y1, float x2, float y2)
{
 float points[] = { x1, y1, x2, y2 };
 __glewBufferData(0x8892, sizeof(points), points,
       0x88E0);
 glDrawArrays(0x0001, 0, 2);
 __glewMapBufferRange(0x8892, 0, 0,
    0x0002 | 0x0020 |
    0x0008);
 __glewUnmapBuffer(0x8892);
}


drawCircle

decompiled_code:
float __fastcall drawCircle(float a1, float a2, float a3)
{
float result; // xmm0_4
float v5; // xmm0_4
int v6; // er12
float *v7; // rbp
float v8; // xmm0_4
float v9; // xmm5_4
float v10; // xmm4_4
float *v11; // rax
float v12; // xmm3_4
float cosx; // [rsp+Ch] [rbp-20h] BYREF
float sinx[7]; // [rsp+10h] [rbp-1Ch] BYREF

if ( a1 <= 0.0 )
{
result = -1.0 - a3;
if ( (float)(-1.0 - a3) > a1 )
return result;
if ( a2 > 0.0 )
goto LABEL_4;
}
else
{
result = a3 + 1.0;
if ( a1 > (float)(a3 + 1.0) )
return result;
if ( a2 > 0.0 )
{
LABEL_4:
result = a3 + 1.0;
if ( a2 > (float)(a3 + 1.0) )
return result;
goto LABEL_5;
}
}
result = -1.0 - a3;
if ( (float)(-1.0 - a3) > a2 )
return result;
LABEL_5:
if ( a3 < 0.0 )
v5 = sqrtf(a3);
else
v5 = fsqrt(a3);
v6 = (int)(float)(v5 * 60.0);
if ( v6 < 4 )
v6 = 4;
v7 = (float *)malloc(8LL * v6);
v8 = 6.283185307179586 / (double)v6;
sincosf(v8, sinx, &cosx);
v9 = cosx;
v10 = sinx[0];
result = 0.0;
v11 = v7;
do
{
v11 += 2;
*(v11 - 2) = a1 + a3;
*(v11 - 1) = a2 + result;
v12 = a3;
a3 = (float)(v10 * result) + (float)(v9 * a3);
result = (float)(result * v9) - (float)(v12 * v10);
}
while ( v11 != &v7[2 * v6] );
_glewBufferData(34962LL, 8LL * v6, v7, 35040LL);
glDrawArrays(2LL, 0LL, (unsigned int)v6);
free(v7);
_glewMapBufferRange(34962LL, 0LL, 0LL, 42LL);
_glewUnmapBuffer(34962LL);
return result;
}

canonical_decompiled_code:
float __fastcall func9(float a1, float a2, float a3)
{
float result; // xmm0_4
float v5; // xmm0_4
int v6; // er12
float *v7; // rbp
float v8; // xmm0_4
float v9; // xmm5_4
float v10; // xmm4_4
float *v11; // rax
float v12; // xmm3_4
float cosx; // [rsp+Ch] [rbp-20h] BYREF
float sinx[7]; // [rsp+10h] [rbp-1Ch] BYREF

if ( a1 <= 0.0 )
{
result = -1.0 - a3;
if ( (float)(-1.0 - a3) > a1 )
return result;
if ( a2 > 0.0 )
goto LABEL_4;
}
else
{
result = a3 + 1.0;
if ( a1 > (float)(a3 + 1.0) )
return result;
if ( a2 > 0.0 )
{
LABEL_4:
result = a3 + 1.0;
if ( a2 > (float)(a3 + 1.0) )
return result;
goto LABEL_5;
}
}
result = -1.0 - a3;
if ( (float)(-1.0 - a3) > a2 )
return result;
LABEL_5:
if ( a3 < 0.0 )
v5 = sqrtf(a3);
else
v5 = fsqrt(a3);
v6 = (int)(float)(v5 * 60.0);
if ( v6 < 4 )
v6 = 4;
v7 = (float *)malloc(8LL * v6);
v8 = 6.283185307179586 / (double)v6;
sincosf(v8, sinx, &cosx);
v9 = cosx;
v10 = sinx[0];
result = 0.0;
v11 = v7;
do
{
v11 += 2;
*(v11 - 2) = a1 + a3;
*(v11 - 1) = a2 + result;
v12 = a3;
a3 = (float)(v10 * result) + (float)(v9 * a3);
result = (float)(result * v9) - (float)(v12 * v10);
}
while ( v11 != &v7[2 * v6] );
_glewBufferData(34962LL, 8LL * v6, v7, 35040LL);
glDrawArrays(2LL, 0LL, (unsigned int)v6);
free(v7);
_glewMapBufferRange(34962LL, 0LL, 0LL, 42LL);
_glewUnmapBuffer(34962LL);
return result;
}

original_code:
void drawCircle(float cx, float cy, float r)
{
 if (cx > 0) {
  if (cx > 1 + r)
   return;
 } else {
  if (cx < -1 - r)
   return;
 }
 if (cy > 0) {
  if (cy > 1 + r)
   return;
 } else {
  if (cy < -1 - r)
   return;
 }
 int numSegments = (int) (60 * sqrtf(r));
 if (numSegments < 4)
  numSegments = 4;
 float *points = malloc(numSegments * 2 * sizeof(float));
 float *current = points;
 float t = 2 * 3.14159265358979323846 / numSegments;
 float myCos = cosf(t);
 float mySin = sinf(t);
 float x = r;
 float y = 0;
 int count = numSegments;
 for (; count > 0; count--) {
  *(current++) = cx + x;
  *(current++) = cy + y;
  t = x;
  x = myCos * x + mySin * y;
  y = myCos * y - mySin * t;
 }
 __glewBufferData(0x8892, sizeof(float) * 2 * numSegments,
       points, 0x88E0);
 glDrawArrays(0x0002, 0, numSegments);
 free(points);
 __glewMapBufferRange(0x8892, 0, 0,
    0x0002 | 0x0020 |
    0x0008);
 __glewUnmapBuffer(0x8892);
}

variable_types: cx float

variable_types: cy float

variable_types: numSegments int

variable_types:
points
float *

variable_types:
current
float *

variable_types: t float

variable_types: myCos float

variable_types: mySin float

variable_types: x float

variable_types: y float


newConnectionLong

decompiled_code:
void __fastcall newConnectionLong(int a1, int a2, int a3, double a4, double a5, double a6, double a7, double a8)
{
__int64 v8; // rbx

v8 = *(_QWORD *)(nodes + 88LL * a1 + 72) + 56LL * a2;
*(_BYTE *)v8 = 0;
*(_DWORD *)(v8 + 4) = a3;
*(double *)(v8 + 8) = a5;
*(double *)(v8 + 16) = a6;
*(double *)(v8 + 24) = a7;
*(double *)(v8 + 32) = pow(a4, 0.7) - 1.0;
*(double *)(v8 + 40) = 0.7 * a8;
}

original_code:
void newConnectionLong(int node, int con, int id, double fric,
         double prefLen, double mid, double tol,
         double force)
{
 connection *who = nodes[node].connections + con;
 who->dead = 0;
 who->id = id;
 who->preflength = prefLen;
 who->midlength = mid;
 who->tolerance = tol;
 who->friction = pow(fric, 0.7) - 1;
 who->force = force * 0.7;
}

canonical_original_code:
void newConnectionLong(int node, int con, int id, double fric, double prefLen, double mid, double tol, double force)
{
 struct connection *who = nodes[node].connections + con;
 who->dead = 0;
 who->id = id;
 who->preflength = prefLen;
 who->midlength = mid;
 who->tolerance = tol;
 who->friction = pow(fric, 0.7) - 1;
 who->force = force * 0.7;
}

variable_types: node int

variable_types: con int

variable_types: id int

variable_types: fric double

variable_types: prefLen double

variable_types: mid double

variable_types: tol double

variable_types: force double

variable_types: struct connection { char dead; int id; double preflength; double midlength; double tolerance; double friction; double force; unsigned char hue; } *


newConnection

decompiled_code:
void __fastcall newConnection(int a1, int a2, int a3, double a4, double a5, double a6, double a7)
{
newConnectionLong(a1, a2, a3, a4, a5, a5, a6, a7);
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2, int a3, double a4, double a5, double a6, double a7)
{
func0(a1, a2, a3, a4, a5, a5, a6, a7);
}

original_code:
void newConnection(int node, int con, int id, double fric, double len,
     double tol, double force)
{
 newConnectionLong(node, con, id, fric, len, len, tol, force);
}

variable_types: len double


newNodeLong

original_code:
int newNodeLong(long X, long Y, double Px, double Py, double Xm, double Ym,
  double S, double M, int array)
{
 int ret = addNode();
 node *who = nodes + ret;
 who->dead = 0;
 who->x = X;
 who->y = Y;
 who->px = Px;
 who->py = Py;
 who->xmom = Xm;
 who->ymom = Ym;
 who->size = S;
 who->mass = M;
 who->numConnections = array;
 who->connections =
     (connection *) malloc(array * sizeof(connection));
 return ret;
}

canonical_original_code:
int newNodeLong(long X, long Y, double Px, double Py, double Xm, double Ym, double S, double M, int array)
{
 int ret = addNode();
 struct node *who = nodes + ret;
 who->dead = 0;
 who->x = X;
 who->y = Y;
 who->px = Px;
 who->py = Py;
 who->xmom = Xm;
 who->ymom = Ym;
 who->size = S;
 who->mass = M;
 who->numConnections = array;
 who->connections =
     (struct connection *) malloc(array * sizeof(connection));
 return ret;
}

variable_types: X long

variable_types: Y long

variable_types: Px double

variable_types: Py double

variable_types: Xm double

variable_types: Ym double

variable_types: S double

variable_types: M double

variable_types: array int

variable_types: ret int

variable_types: struct node { int netIndex; char dead; long x; long y; double px; double py; double xmom; double ymom; double size; double mass; struct connection { char dead; int id; double preflength; double midlength; double tolerance; double friction; double force; unsigned char hue; } *connections; int numConnections; } *

user_defined_types: struct node { int netIndex; char dead; long x; long y; double px; double py; double xmom; double ymom; double size; double mass; struct connection *connections; int numConnections; }


newNode

decompiled_code:
__int64 __fastcall newNode(int a1, int a2, int a3, double a4, double a5)
{
return newNodeLong(a1, a2, a3, 0.0, 0.0, 0.0, 0.0, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2, int a3, double a4, double a5)
{
return func2(a1, a2, a3, 0.0, 0.0, 0.0, 0.0, a4, a5);
}

original_code:
int newNode(int x, int y, double size, double mass, int array)
{
 return newNodeLong((long) x, (long) y, (double) 0, (double) 0, 0,
      0, size, mass, array);
}

variable_types: x int

variable_types: y int

variable_types: size double

variable_types: mass double


createConnection

decompiled_code:
__int64 __fastcall createConnection(int a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
void *v3; // rdi
int v4; // eax

v1 = 88LL * a1;
v2 = v1 + nodes;
v3 = *(void **)(v1 + nodes + 72);
v4 = *(_DWORD *)(v1 + nodes + 80) + 1;
*(_DWORD *)(v1 + nodes + 80) = v4;
*(_QWORD *)(v2 + 72) = realloc(v3, 56LL * v4);
return (unsigned int)(*(_DWORD *)(nodes + v1 + 80) - 1);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
__int64 v1; // rbx
__int64 v2; // rbp
void *v3; // rdi
int v4; // eax

v1 = 88LL * a1;
v2 = v1 + nodes;
v3 = *(void **)(v1 + nodes + 72);
v4 = *(_DWORD *)(v1 + nodes + 80) + 1;
*(_DWORD *)(v1 + nodes + 80) = v4;
*(_QWORD *)(v2 + 72) = realloc(v3, 56LL * v4);
return (unsigned int)(*(_DWORD *)(nodes + v1 + 80) - 1);
}

original_code:
int createConnection(int who)
{
 nodes[who].connections =
     (connection *) realloc(nodes[who].connections,
       (++nodes[who].numConnections) *
       sizeof(connection));
 return nodes[who].numConnections - 1;
}

canonical_original_code:
int createConnection(int who)
{
 nodes[who].connections =
     (struct connection *) realloc(nodes[who].connections,
       (++nodes[who].numConnections) *
       sizeof(connection));
 return nodes[who].numConnections - 1;
}

variable_types: who int

user_defined_types: struct connection { char dead; int id; double preflength; double midlength; double tolerance; double friction; double force; unsigned char hue; }


positioncleanup

original_code:
void positioncleanup(node * who)
{
 who->px += who->xmom;
 int n = floor(who->px);
 who->x += n;
 who->px -= n;
 who->py += who->ymom;
 n = floor(who->py);
 who->y += n;
 who->py -= n;
}

canonical_original_code:
void positioncleanup(struct node *who)
{
 who->px += who->xmom;
 int n = floor(who->px);
 who->x += n;
 who->px -= n;
 who->py += who->ymom;
 n = floor(who->py);
 who->y += n;
 who->py -= n;
}

variable_types: n int