myDisplay

decompiled_code:
__int64 myDisplay()
{
__int64 v0; // rdx
__int64 v1; // rcx
unsigned int v3; // edx
unsigned int v4; // edx
int v5; // eax
int v6; // eax
__int64 v7; // rdx
int v8; // eax
int v9; // eax
__int64 v10; // rdx
unsigned int v11; // [rsp+Ch] [rbp-2Ch] BYREF
unsigned int v12; // [rsp+10h] [rbp-28h] BYREF
unsigned int v13[4]; // [rsp+14h] [rbp-24h] BYREF
__int64 v14; // [rsp+24h] [rbp-14h]
unsigned int v15; // [rsp+2Ch] [rbp-Ch]

setcolour();
ChangeSize(600, 600);
if ( choice <= 15 )
glClear(0x4000LL);
glBegin(0LL);
switch ( choice )
{
case 1:
flag = 0;
choice = 18;
break;
case 2:
v14 = readpoint();
v15 = v3;
readint(v13);
readcolor();
drawcircle(v14, v15, v13[0]);
fclose(fin);
choice = 100;
break;
case 3:
v14 = readpoint();
v15 = v4;
readint(&v12);
readint(&v11);
readcolor();
drawellipse(v14, v15, v12, v11);
fclose(fin);
choice = 100;
break;
case 4:
flag = 0;
*((_DWORD *)&pol + 550) = 0;
choice = 22;
break;
case 5:
flag = 0;
choice = 24;
break;
case 6:
read_clip(&window, &pol_clip);
clipping(&window, &pol_clip);
fclose(fin);
choice = 100;
break;
case 7:
zbuffer();
fclose(fin);
choice = 100;
break;
case 9:
flag = 0;
con_num = 0;
choice = 20;
break;
case 10:
drawsurface();
fclose(fin);
choice = 100;
break;
case 11:
readpolygon(&pol);
drawpolygon(&pol, *(double *)&white, *((float *)&white + 2));
fclose(fin);
flag = 0;
choice = 17;
break;
case 17:
if ( flag )
fillseed(mousepoint, *((unsigned int *)&mousepoint + 2));
break;
case 18:
if ( flag )
{
majorline = mousepoint;
*((_DWORD *)&majorline + 2) = *((_DWORD *)&mousepoint + 2);
choice = 19;
}
break;
case 19:
if ( flag == 2 )
{
*(__int64 *)((char *)&majorline + 12) = mousepoint;
*((_DWORD *)&majorline + 5) = *((_DWORD *)&mousepoint + 2);
drawline(*(double *)&green, *((float *)&green + 2));
flag = 0;
choice = 18;
}
break;
case 20:
v5 = con_num;
if ( flag > con_num )
{
if ( (flag & 1) != 0 )
{
majorline = mousepoint;
*((_DWORD *)&majorline + 2) = *((_DWORD *)&mousepoint + 2);
}
else
{
*(__int64 *)((char *)&majorline + 12) = mousepoint;
*((_DWORD *)&majorline + 5) = *((_DWORD *)&mousepoint + 2);
}
if ( v5 )
drawline(*(double *)&yellow, *((float *)&yellow + 2));
v6 = con_num;
v7 = 12LL * con_num;
*(__int64 *)((char *)&control + v7) = mousepoint;
*(_DWORD *)((char *)&control + v7 + 8) = *((_DWORD *)&mousepoint + 2);
con_num = v6 + 1;
}
break;
case 21:
if ( flag == con_num )
drawcurve();
break;
case 22:
v8 = *((_DWORD *)&pol + 550);
if ( v8 < flag )
{
if ( (flag & 1) != 0 )
{
majorline = mousepoint;
*((_DWORD *)&majorline + 2) = *((_DWORD *)&mousepoint + 2);
}
else
{
*(__int64 *)((char *)&majorline + 12) = mousepoint;
*((_DWORD *)&majorline + 5) = *((_DWORD *)&mousepoint + 2);
}
if ( v8 )
drawline(*(double *)&white, *((float *)&white + 2));
v9 = *((_DWORD *)&pol + 550);
v10 = 12LL * v9;
*(__int64 *)((char *)&pol + v10) = mousepoint;
*(_DWORD *)((char *)&pol + v10 + 8) = *((_DWORD *)&mousepoint + 2);
*((_DWORD *)&pol + 550) = v9 + 1;
}
break;
case 23:
if ( *((_DWORD *)&pol + 550) == flag )
fillpolygon(&pol, *(double *)&white, *((float *)&white + 2), *(double *)&indigo, *((float *)&indigo + 2));
break;
case 24:
if ( flag )
{
liangx1 = mousepoint;
liangy1 = HIDWORD(mousepoint);
choice = 25;
}
break;
case 25:
if ( flag == 2 )
{
liangx2 = mousepoint;
liangy2 = HIDWORD(mousepoint);
if ( (int)mousepoint < liangx1 )
swap(&liangx1, &liangx2);
if ( liangy1 > liangy2 )
swap(&liangy1, &liangy2);
drawliangwindow();
flag = 0;
choice = 26;
}
break;
case 26:
if ( flag )
{
majorline = mousepoint;
*((_DWORD *)&majorline + 2) = *((_DWORD *)&mousepoint + 2);
choice = 27;
}
break;
case 27:
if ( flag == 2 )
{
*(__int64 *)((char *)&majorline + 12) = mousepoint;
*((_DWORD *)&majorline + 5) = *((_DWORD *)&mousepoint + 2);
liang(0LL, 600LL, v0, v1);
flag = 0;
choice = 26;
}
break;
default:
break;
}
glEnd();
return glFlush();
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rdx
__int64 v1; // rcx
unsigned int v3; // edx
unsigned int v4; // edx
int v5; // eax
int v6; // eax
__int64 v7; // rdx
int v8; // eax
int v9; // eax
__int64 v10; // rdx
unsigned int v11; // [rsp+Ch] [rbp-2Ch] BYREF
unsigned int v12; // [rsp+10h] [rbp-28h] BYREF
unsigned int v13[4]; // [rsp+14h] [rbp-24h] BYREF
__int64 v14; // [rsp+24h] [rbp-14h]
unsigned int v15; // [rsp+2Ch] [rbp-Ch]

setcolour();
func2(600, 600);
if ( choice <= 15 )
glClear(0x4000LL);
glBegin(0LL);
switch ( choice )
{
case 1:
flag = 0;
choice = 18;
break;
case 2:
v14 = readpoint();
v15 = v3;
readint(v13);
readcolor();
drawcircle(v14, v15, v13[0]);
fclose(fin);
choice = 100;
break;
case 3:
v14 = readpoint();
v15 = v4;
readint(&v12);
readint(&v11);
readcolor();
drawellipse(v14, v15, v12, v11);
fclose(fin);
choice = 100;
break;
case 4:
flag = 0;
*((_DWORD *)&pol + 550) = 0;
choice = 22;
break;
case 5:
flag = 0;
choice = 24;
break;
case 6:
read_clip(&window, &pol_clip);
clipping(&window, &pol_clip);
fclose(fin);
choice = 100;
break;
case 7:
zbuffer();
fclose(fin);
choice = 100;
break;
case 9:
flag = 0;
con_num = 0;
choice = 20;
break;
case 10:
drawsurface();
fclose(fin);
choice = 100;
break;
case 11:
readpolygon(&pol);
drawpolygon(&pol, *(double *)&white, *((float *)&white + 2));
fclose(fin);
flag = 0;
choice = 17;
break;
case 17:
if ( flag )
fillseed(mousepoint, *((unsigned int *)&mousepoint + 2));
break;
case 18:
if ( flag )
{
majorline = mousepoint;
*((_DWORD *)&majorline + 2) = *((_DWORD *)&mousepoint + 2);
choice = 19;
}
break;
case 19:
if ( flag == 2 )
{
*(__int64 *)((char *)&majorline + 12) = mousepoint;
*((_DWORD *)&majorline + 5) = *((_DWORD *)&mousepoint + 2);
drawline(*(double *)&green, *((float *)&green + 2));
flag = 0;
choice = 18;
}
break;
case 20:
v5 = con_num;
if ( flag > con_num )
{
if ( (flag & 1) != 0 )
{
majorline = mousepoint;
*((_DWORD *)&majorline + 2) = *((_DWORD *)&mousepoint + 2);
}
else
{
*(__int64 *)((char *)&majorline + 12) = mousepoint;
*((_DWORD *)&majorline + 5) = *((_DWORD *)&mousepoint + 2);
}
if ( v5 )
drawline(*(double *)&yellow, *((float *)&yellow + 2));
v6 = con_num;
v7 = 12LL * con_num;
*(__int64 *)((char *)&control + v7) = mousepoint;
*(_DWORD *)((char *)&control + v7 + 8) = *((_DWORD *)&mousepoint + 2);
con_num = v6 + 1;
}
break;
case 21:
if ( flag == con_num )
drawcurve();
break;
case 22:
v8 = *((_DWORD *)&pol + 550);
if ( v8 < flag )
{
if ( (flag & 1) != 0 )
{
majorline = mousepoint;
*((_DWORD *)&majorline + 2) = *((_DWORD *)&mousepoint + 2);
}
else
{
*(__int64 *)((char *)&majorline + 12) = mousepoint;
*((_DWORD *)&majorline + 5) = *((_DWORD *)&mousepoint + 2);
}
if ( v8 )
drawline(*(double *)&white, *((float *)&white + 2));
v9 = *((_DWORD *)&pol + 550);
v10 = 12LL * v9;
*(__int64 *)((char *)&pol + v10) = mousepoint;
*(_DWORD *)((char *)&pol + v10 + 8) = *((_DWORD *)&mousepoint + 2);
*((_DWORD *)&pol + 550) = v9 + 1;
}
break;
case 23:
if ( *((_DWORD *)&pol + 550) == flag )
fillpolygon(&pol, *(double *)&white, *((float *)&white + 2), *(double *)&indigo, *((float *)&indigo + 2));
break;
case 24:
if ( flag )
{
liangx1 = mousepoint;
liangy1 = HIDWORD(mousepoint);
choice = 25;
}
break;
case 25:
if ( flag == 2 )
{
liangx2 = mousepoint;
liangy2 = HIDWORD(mousepoint);
if ( (int)mousepoint < liangx1 )
swap(&liangx1, &liangx2);
if ( liangy1 > liangy2 )
swap(&liangy1, &liangy2);
drawliangwindow();
flag = 0;
choice = 26;
}
break;
case 26:
if ( flag )
{
majorline = mousepoint;
*((_DWORD *)&majorline + 2) = *((_DWORD *)&mousepoint + 2);
choice = 27;
}
break;
case 27:
if ( flag == 2 )
{
*(__int64 *)((char *)&majorline + 12) = mousepoint;
*((_DWORD *)&majorline + 5) = *((_DWORD *)&mousepoint + 2);
liang(0LL, 600LL, v0, v1);
flag = 0;
choice = 26;
}
break;
default:
break;
}
glEnd();
return glFlush();
}

original_code:
void myDisplay(void)
{
    struct point center;
    struct colour c;
    int r,a,b;
    setcolour();
 ChangeSize(600,600);
 if (choice < 16) glClear(0x00004000);
    glBegin(0x0000);
 switch (choice)
 {
  case 1: flag = 0; choice = 18; break;
        case 2: center = readpoint(); readint(&r); c = readcolor(); drawcircle(center,r,c);
          fclose(fin); choice = 100; break;
        case 3: center = readpoint(); readint(&a); readint(&b); c = readcolor(); drawellipse(center,a,b,c);
          fclose(fin); choice = 100; break;
        case 4: flag = 0; pol.ver_num = 0; choice = 22; break;
      case 5: flag = 0; choice =24; break;
      case 6: read_clip(&window,&pol_clip);
        clipping(&window,&pol_clip);
        fclose(fin); choice = 100; break;
      case 7: zbuffer();
        fclose(fin); choice = 100; break;
        case 9: flag = 0; con_num = 0; choice = 20; break;
        case 10: drawsurface();
    fclose (fin); choice = 100; break;
  case 11: readpolygon(&pol); drawpolygon(&pol,white);
    fclose(fin); flag = 0; choice = 17; break;
  case 17: if (flag) fillseed(mousepoint); break;
  case 18: if (flag)
     {
      majorline.p1 = mousepoint;
      choice = 19;
     }
    break;
  case 19: if (flag == 2)
     {
      majorline.p2 = mousepoint;
      drawline(majorline,green);
      flag = 0;
      choice = 18;
     }
     break;
  case 20: if (flag > con_num)
     {
      if (flag&1) majorline.p1 = mousepoint;
      else majorline.p2 = mousepoint;
      if (con_num) drawline(majorline,yellow);
      control[con_num] = mousepoint;
      ++con_num;
     }
    break;
  case 21: if (flag == con_num) drawcurve(); break;
  case 22: if (flag > pol.ver_num)
     {
      if (flag&1) majorline.p1 = mousepoint;
      else majorline.p2 = mousepoint;
      if (pol.ver_num) drawline(majorline,white);
      pol.vertex[pol.ver_num] = mousepoint;
      ++pol.ver_num;
     }
     break;
  case 23: if (flag == pol.ver_num) fillpolygon(&pol,white,indigo); break;
  case 24: if (flag)
     {
      liangx1 = mousepoint.x;
      liangy1 = mousepoint.y;
      choice = 25;
     }
     break;
  case 25: if (flag == 2)
     {
      liangx2 = mousepoint.x;
      liangy2 = mousepoint.y;
      if (liangx1 > liangx2) swap(&liangx1,&liangx2);
      if (liangy1 > liangy2) swap(&liangy1,&liangy2);
      drawliangwindow();
      flag = 0;
      choice = 26;
     }
     break;
        case 26: if (flag)
           {
            majorline.p1 = mousepoint;
            choice = 27;
           }
           break;
        case 27: if (flag == 2)
           {
            majorline.p2 = mousepoint;
            liang(majorline);
            flag = 0;
            choice = 26;
           }
           break;
        default: break;
    }
    glEnd();
    glFlush();
}

canonical_original_code:
void myDisplay()
{
    struct point center;
    struct colour c;
    int r; int a; int b;
    setcolour();
 ChangeSize(600,600);
 if (choice < 16) glClear(0x00004000);
    glBegin(0x0000);
 switch (choice)
 {
  case 1: flag = 0; choice = 18; break;
        case 2: center = readpoint(); readint(&r); c = readcolor(); drawcircle(center,r,c);
          fclose(fin); choice = 100; break;
        case 3: center = readpoint(); readint(&a); readint(&b); c = readcolor(); drawellipse(center,a,b,c);
          fclose(fin); choice = 100; break;
        case 4: flag = 0; pol.ver_num = 0; choice = 22; break;
      case 5: flag = 0; choice =24; break;
      case 6: read_clip(&window,&pol_clip);
        clipping(&window,&pol_clip);
        fclose(fin); choice = 100; break;
      case 7: zbuffer();
        fclose(fin); choice = 100; break;
        case 9: flag = 0; con_num = 0; choice = 20; break;
        case 10: drawsurface();
    fclose (fin); choice = 100; break;
  case 11: readpolygon(&pol); drawpolygon(&pol,white);
    fclose(fin); flag = 0; choice = 17; break;
  case 17: if (flag) fillseed(mousepoint); break;
  case 18: if (flag)
     {
      majorline.p1 = mousepoint;
      choice = 19;
     }
    break;
  case 19: if (flag == 2)
     {
      majorline.p2 = mousepoint;
      drawline(majorline,green);
      flag = 0;
      choice = 18;
     }
     break;
  case 20: if (flag > con_num)
     {
      if (flag&1) majorline.p1 = mousepoint;
      else majorline.p2 = mousepoint;
      if (con_num) drawline(majorline,yellow);
      control[con_num] = mousepoint;
      ++con_num;
     }
    break;
  case 21: if (flag == con_num) drawcurve(); break;
  case 22: if (flag > pol.ver_num)
     {
      if (flag&1) majorline.p1 = mousepoint;
      else majorline.p2 = mousepoint;
      if (pol.ver_num) drawline(majorline,white);
      pol.vertex[pol.ver_num] = mousepoint;
      ++pol.ver_num;
     }
     break;
  case 23: if (flag == pol.ver_num) fillpolygon(&pol,white,indigo); break;
  case 24: if (flag)
     {
      liangx1 = mousepoint.x;
      liangy1 = mousepoint.y;
      choice = 25;
     }
     break;
  case 25: if (flag == 2)
     {
      liangx2 = mousepoint.x;
      liangy2 = mousepoint.y;
      if (liangx1 > liangx2) swap(&liangx1,&liangx2);
      if (liangy1 > liangy2) swap(&liangy1,&liangy2);
      drawliangwindow();
      flag = 0;
      choice = 26;
     }
     break;
        case 26: if (flag)
           {
            majorline.p1 = mousepoint;
            choice = 27;
           }
           break;
        case 27: if (flag == 2)
           {
            majorline.p2 = mousepoint;
            liang(majorline);
            flag = 0;
            choice = 26;
           }
           break;
        default: break;
    }
    glEnd();
    glFlush();
}

variable_types: r int

variable_types: a int

variable_types: b int

user_defined_types:
struct point { int x; }
struct colour { float r; }


basicgeometry

repo: kidxin/Graphics-Experiment

decompiled_code:
__int64 __fastcall basicgeometry(int a1)
{
switch ( a1 )
{
case 2:
fin = fopen("test/circle", "r");
choice = 2;
break;
case 3:
fin = fopen("test/ellipse", "r");
choice = 3;
break;
case 1:
choice = 1;
break;
}
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
switch ( a1 )
{
case 2:
fin = fopen("test/circle", "r");
choice = 2;
break;
case 3:
fin = fopen("test/ellipse", "r");
choice = 3;
break;
case 1:
choice = 1;
break;
}
return glutPostRedisplay();
}

original_code:
void basicgeometry(GLint option)
{
 switch (option)
 {
  case 1: choice = 1; break;
  case 2: fin = fopen("test/circle", "r"); choice = 2; break;
  case 3: fin = fopen("test/ellipse", "r"); choice = 3; break;
 }
 glutPostRedisplay ();
}

canonical_original_code:
void basicgeometry(int option)
{
 switch (option)
 {
  case 1: choice = 1; break;
  case 2: fin = fopen("test/circle", "r"); choice = 2; break;
  case 3: fin = fopen("test/ellipse", "r"); choice = 3; break;
 }
 glutPostRedisplay ();
}

variable_types: option int

return_type: void


clip

decompiled_code:
__int64 __fastcall clip(int a1)
{
if ( a1 == 1 )
{
choice = 5;
}
else if ( a1 == 2 )
{
fin = fopen("test/clipping", "r");
choice = 6;
}
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
if ( a1 == 1 )
{
choice = 5;
}
else if ( a1 == 2 )
{
fin = fopen("test/clipping", "r");
choice = 6;
}
return glutPostRedisplay();
}

original_code:
void clip(GLint option)
{
 switch (option)
 {
  case 1: choice = 5; break;
  case 2: fin = fopen("test/clipping", "r"); choice = 6; break;
 }
 glutPostRedisplay ();
}

canonical_original_code:
void clip(int option)
{
 switch (option)
 {
  case 1: choice = 5; break;
  case 2: fin = fopen("test/clipping", "r"); choice = 6; break;
 }
 glutPostRedisplay ();
}


curve

decompiled_code:
__int64 __fastcall curve(int a1)
{
if ( a1 == 1 )
{
choice = 9;
}
else if ( a1 == 2 )
{
fin = fopen("test/surface", "r");
choice = 10;
}
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
if ( a1 == 1 )
{
choice = 9;
}
else if ( a1 == 2 )
{
fin = fopen("test/surface", "r");
choice = 10;
}
return glutPostRedisplay();
}

original_code:
void curve(GLint option)
{
 switch (option)
 {
  case 1: choice = 9; break;
  case 2: fin = fopen("test/surface", "r"); choice = 10; break;
 }
 glutPostRedisplay ();
}

canonical_original_code:
void curve(int option)
{
 switch (option)
 {
  case 1: choice = 9; break;
  case 2: fin = fopen("test/surface", "r"); choice = 10; break;
 }
 glutPostRedisplay ();
}


fillpol

decompiled_code:
__int64 __fastcall fillpol(int a1)
{
if ( a1 == 1 )
{
choice = 4;
}
else if ( a1 == 2 )
{
fin = fopen("test/seed", "r");
choice = 11;
}
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
if ( a1 == 1 )
{
choice = 4;
}
else if ( a1 == 2 )
{
fin = fopen("test/seed", "r");
choice = 11;
}
return glutPostRedisplay();
}

original_code:
void fillpol(GLint option)
{
 switch (option)
 {
  case 1: choice = 4; break;
  case 2: fin = fopen("test/seed","r"); choice = 11; break;
 }
 glutPostRedisplay ();
}

canonical_original_code:
void fillpol(int option)
{
 switch (option)
 {
  case 1: choice = 4; break;
  case 2: fin = fopen("test/seed","r"); choice = 11; break;
 }
 glutPostRedisplay ();
}


mousedeal

decompiled_code:
__int64 __fastcall mousedeal(int a1, int a2, int a3, int a4)
{
__int64 result; // rax

LODWORD(mousepoint) = a3 - 300;
result = (unsigned int)(300 - a4);
HIDWORD(mousepoint) = result;
if ( a1 == 2 && !a2 )
{
result = (unsigned int)(choice - 17);
if ( (unsigned int)result <= 0xA )
{
++flag;
result = glutPostRedisplay();
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2, int a3, int a4)
{
__int64 result; // rax

LODWORD(mousepoint) = a3 - 300;
result = (unsigned int)(300 - a4);
HIDWORD(mousepoint) = result;
if ( a1 == 2 && !a2 )
{
result = (unsigned int)(choice - 17);
if ( (unsigned int)result <= 0xA )
{
++flag;
result = glutPostRedisplay();
}
}
return result;
}

original_code:
void mousedeal(GLint button, GLint action,GLint xMouse,GLint yMouse)
{
 mousepoint.x = xMouse - 300; mousepoint.y = 300 -yMouse;
 if (button == 0x0002 && action == 0x0000)
 {
  switch (choice)
  {
   case 17:
   case 18:
   case 19:
   case 20:
   case 21:
   case 22:
   case 23:
   case 24:
   case 25:
   case 26:
   case 27: ++flag; break;
   default: return;
  }
  glutPostRedisplay ();
 }
}

canonical_original_code:
void mousedeal(int button, int action, int xMouse, int yMouse)
{
 mousepoint.x = xMouse - 300; mousepoint.y = 300 -yMouse;
 if (button == 0x0002 && action == 0x0000)
 {
  switch (choice)
  {
   case 17:
   case 18:
   case 19:
   case 20:
   case 21:
   case 22:
   case 23:
   case 24:
   case 25:
   case 26:
   case 27: ++flag; break;
   default: return;
  }
  glutPostRedisplay ();
 }
}

variable_types: button int

variable_types: action int

variable_types: xMouse int

variable_types: yMouse int


keyfun

decompiled_code:
void __fastcall keyfun(char a1)
{
if ( a1 != 13 )
{
if ( a1 != 27 )
return;
if ( choice != 100 )
{
if ( choice > 23 )
{
choice = 5;
goto LABEL_8;
}
if ( choice > 21 )
{
choice = 4;
goto LABEL_8;
}
if ( choice > 19 )
{
choice = 9;
goto LABEL_8;
}
if ( choice > 17 )
{
choice = 1;
goto LABEL_8;
}
}
choice = 0;
goto LABEL_8;
}
if ( choice == 20 )
{
choice = 21;
goto LABEL_8;
}
if ( choice == 22 )
{
choice = 23;
LABEL_8:
glutPostRedisplay();
}
}

canonical_decompiled_code:
void __fastcall func9(char a1)
{
if ( a1 != 13 )
{
if ( a1 != 27 )
return;
if ( choice != 100 )
{
if ( choice > 23 )
{
choice = 5;
goto LABEL_8;
}
if ( choice > 21 )
{
choice = 4;
goto LABEL_8;
}
if ( choice > 19 )
{
choice = 9;
goto LABEL_8;
}
if ( choice > 17 )
{
choice = 1;
goto LABEL_8;
}
}
choice = 0;
goto LABEL_8;
}
if ( choice == 20 )
{
choice = 21;
goto LABEL_8;
}
if ( choice == 22 )
{
choice = 23;
LABEL_8:
glutPostRedisplay();
}
}

original_code:
void keyfun(GLubyte key, GLint xMouse, GLint yMouse)
{
 if (key == 13)
 {
  switch (choice)
  {
   case 20: choice = 21; break;
   case 22: choice = 23; break;
   default: return;
  }
  glutPostRedisplay ();
 }
 else if (key == 27)
 {
  if (choice == 100) choice = 0;
  if (choice > 23) choice = 5;
  else if (choice > 21) choice = 4;
  else if (choice > 19) choice = 9;
  else if (choice > 17) choice = 1;
  else choice = 0;
  glutPostRedisplay ();
 }
}

canonical_original_code:
void keyfun(unsigned char key, int xMouse, int yMouse)
{
 if (key == 13)
 {
  switch (choice)
  {
   case 20: choice = 21; break;
   case 22: choice = 23; break;
   default: return;
  }
  glutPostRedisplay ();
 }
 else if (key == 27)
 {
  if (choice == 100) choice = 0;
  if (choice > 23) choice = 5;
  else if (choice > 21) choice = 4;
  else if (choice > 19) choice = 9;
  else if (choice > 17) choice = 1;
  else choice = 0;
  glutPostRedisplay ();
 }
}

variable_types:
key
unsigned char


shadow

decompiled_code:
void __fastcall shadow(int a1)
{
if ( a1 == 1 )
{
fin = fopen("test/shadow", "r");
choice = 7;
}
if ( fin )
glutPostRedisplay();
else
perror("File Does Not Exist\n");
}

canonical_decompiled_code:
void __fastcall func10(int a1)
{
if ( a1 == 1 )
{
fin = fopen("test/shadow", "r");
choice = 7;
}
if ( fin )
glutPostRedisplay();
else
perror("File Does Not Exist\n");
}

original_code:
void shadow(GLint option)
{
 switch (option)
 {
  case 1: fin = fopen("test/shadow", "r"); choice = 7; break;
 }
 if (!fin) {
     perror("File Does Not Exist\n");
     return ;
    }
 glutPostRedisplay ();
}

canonical_original_code:
void shadow(int option)
{
 switch (option)
 {
  case 1: fin = fopen("test/shadow", "r"); choice = 7; break;
 }
 if (!fin) {
     perror("File Does Not Exist\n");
     return ;
    }
 glutPostRedisplay ();
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er14
unsigned int v4; // er13
unsigned int v5; // er12
unsigned int v6; // ebp
unsigned int v7; // ebx
int v9[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v9[0] = argc;
glutInit(v9, argv, envp);
glutInitDisplayMode(16LL);
glutInitWindowSize(600LL, 600LL);
glutInitWindowPosition(300LL, 300LL);
glutCreateWindow("Graphic Experiment");
choice = 0;
glutReshapeFunc(ChangeSize);
glutDisplayFunc(myDisplay);
glutCreateMenu(blank);
v3 = glutCreateMenu(basicgeometry);
glutAddMenuEntry("Line", 1LL);
glutAddMenuEntry("Circle", 2LL);
glutAddMenuEntry("Ellipse", 3LL);
v4 = glutCreateMenu(fillpol);
glutAddMenuEntry("Scan line", 1LL);
glutAddMenuEntry("Seed", 2LL);
v5 = glutCreateMenu(clip);
glutAddMenuEntry("Liang", 1LL);
glutAddMenuEntry("Weiler Atherton", 2LL);
v6 = glutCreateMenu(shadow);
glutAddMenuEntry("Zbuffer", 1LL);
v7 = glutCreateMenu(curve);
glutAddMenuEntry("Bezier Curve", 1LL);
glutAddMenuEntry("Bezier Surface", 2LL);
glutCreateMenu(mainmenu);
glutAddSubMenu("Element", v3);
glutAddSubMenu("Fill", v4);
glutAddSubMenu("Clipping", v5);
glutAddSubMenu("Shadow", v6);
glutAddSubMenu("Curve", v7);
glutAttachMenu(0LL);
glutMouseFunc(mousedeal);
glutKeyboardFunc(keyfun);
glutMainLoop();
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(0x0000 | 0x0000| 0x0010);
    glutInitWindowSize(600, 600);
    glutInitWindowPosition(300, 300);
    glutCreateWindow("Graphic Experiment");
    choice = 0;
    glutReshapeFunc(ChangeSize);
    glutDisplayFunc(&myDisplay);
    GLint Basic, Clipping, Curve, Shadow, Fill;
    Basic = glutCreateMenu(blank);
    Basic = glutCreateMenu(basicgeometry);
     glutAddMenuEntry ("Line", 1);
     glutAddMenuEntry ("Circle", 2);
     glutAddMenuEntry ("Ellipse", 3);
    Fill = glutCreateMenu(fillpol);
     glutAddMenuEntry ("Scan line", 1);
     glutAddMenuEntry ("Seed", 2);
    Clipping = glutCreateMenu(clip);
     glutAddMenuEntry ("Liang", 1);
     glutAddMenuEntry ("Weiler Atherton", 2);
    Shadow = glutCreateMenu(shadow);
     glutAddMenuEntry ("Zbuffer", 1);
    Curve = glutCreateMenu(curve);
     glutAddMenuEntry ("Bezier Curve", 1);
     glutAddMenuEntry ("Bezier Surface", 2);
    glutCreateMenu(mainmenu);
     glutAddSubMenu ("Element", Basic);
     glutAddSubMenu ("Fill", Fill);
     glutAddSubMenu ("Clipping", Clipping);
     glutAddSubMenu ("Shadow", Shadow);
     glutAddSubMenu ("Curve", Curve);
    glutAttachMenu (0x0000);
    glutMouseFunc (mousedeal);
    glutKeyboardFunc (keyfun);
    glutMainLoop();
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(0x0000 | 0x0000| 0x0010);
    glutInitWindowSize(600, 600);
    glutInitWindowPosition(300, 300);
    glutCreateWindow("Graphic Experiment");
    choice = 0;
    glutReshapeFunc(ChangeSize);
    glutDisplayFunc(&myDisplay);
    int Basic; int Clipping; int Curve; int Shadow; int Fill;
    Basic = glutCreateMenu(blank);
    Basic = glutCreateMenu(basicgeometry);
     glutAddMenuEntry ("Line", 1);
     glutAddMenuEntry ("Circle", 2);
     glutAddMenuEntry ("Ellipse", 3);
    Fill = glutCreateMenu(fillpol);
     glutAddMenuEntry ("Scan line", 1);
     glutAddMenuEntry ("Seed", 2);
    Clipping = glutCreateMenu(clip);
     glutAddMenuEntry ("Liang", 1);
     glutAddMenuEntry ("Weiler Atherton", 2);
    Shadow = glutCreateMenu(shadow);
     glutAddMenuEntry ("Zbuffer", 1);
    Curve = glutCreateMenu(curve);
     glutAddMenuEntry ("Bezier Curve", 1);
     glutAddMenuEntry ("Bezier Surface", 2);
    glutCreateMenu(mainmenu);
     glutAddSubMenu ("Element", Basic);
     glutAddSubMenu ("Fill", Fill);
     glutAddSubMenu ("Clipping", Clipping);
     glutAddSubMenu ("Shadow", Shadow);
     glutAddSubMenu ("Curve", Curve);
    glutAttachMenu (0x0000);
    glutMouseFunc (mousedeal);
    glutKeyboardFunc (keyfun);
    glutMainLoop();
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: Basic int

variable_types: Clipping int

variable_types: Curve int

variable_types: Shadow int

variable_types: Fill int

return_type: int


decompiled_code:
__int64 __fastcall comp_slope(int *a1, int *a2)
{
int v2; // eax
int v3; // edx

v2 = *a1;
v3 = *a2;
if ( *a2 * *a1 > 0 )
{
v2 *= a2[1];
v3 *= a1[1];
}
return (unsigned int)(v2 - v3);
}

original_code:
int comp_slope(const void *a,const void *b)
{
 int t1 = ((struct slope *)a)->dx * ((struct slope *)b)->dy;
 int t2 = ((struct slope *)a)->dy * ((struct slope *)b)->dx;
 int t3 = ((struct slope *)a)->dx * ((struct slope *)b)->dx;
 if (t3 <= 0) return ((struct slope *)a)->dx - ((struct slope *)b)->dx;
 else return t1-t2;
}

canonical_original_code:
int comp_slope(void *a, void *b)
{
 int t1 = ((struct slope *)a)->dx * ((struct slope *)b)->dy;
 int t2 = ((struct slope *)a)->dy * ((struct slope *)b)->dx;
 int t3 = ((struct slope *)a)->dx * ((struct slope *)b)->dx;
 if (t3 <= 0) return ((struct slope *)a)->dx - ((struct slope *)b)->dx;
 else return t1-t2;
}

variable_types:
a
void *

variable_types:
b
void *


decompiled_code:
__int64 __fastcall comp_line(const void *a1, const void *a2)
{
__int64 result; // rax

result = (unsigned int)(*((_DWORD *)a1 + 1) - *((_DWORD *)a2 + 1));
if ( !(_DWORD)result )
{
result = (unsigned int)(*(_DWORD *)a1 - *(_DWORD *)a2);
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
result = comp_slope((int *)a1 + 6, (int *)a2 + 6);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const void *a1, const void *a2)
{
__int64 result; // rax

result = (unsigned int)(*((_DWORD *)a1 + 1) - *((_DWORD *)a2 + 1));
if ( !(_DWORD)result )
{
result = (unsigned int)(*(_DWORD *)a1 - *(_DWORD *)a2);
if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
result = func0((int *)a1 + 6, (int *)a2 + 6);
}
return result;
}

original_code:
int comp_line(const void *a,const void *b)
{
 int t1 = ((struct line *)a)->p1.y-((struct line *)b)->p1.y;
 int t2 = ((struct line *)a)->p1.x-((struct line *)b)->p1.x;
 if (t1 != 0) return t1;
 else if (t2 != 0) return t2;
 else return comp_slope(&((struct line *)a)->sl,&((struct line *)b)->sl);
}

canonical_original_code:
int comp_line(void *a, void *b)
{
 int t1 = ((struct line *)a)->p1.y-((struct line *)b)->p1.y;
 int t2 = ((struct line *)a)->p1.x-((struct line *)b)->p1.x;
 if (t1 != 0) return t1;
 else if (t2 != 0) return t2;
 else return comp_slope(&((struct line *)a)->sl,&((struct line *)b)->sl);
}

user_defined_types: struct line { struct point p1; struct slope sl; }


makeline

original_code:
void makeline(struct poly *pol)
{
 int i;
 for (i=0;i < pol->ver_num;++i)
 {
  pol->edge[i].p1 = pol->vertex[i];
  pol->edge[i].p2 = pol->vertex[(i+1)%pol->ver_num];
 }
}

variable_types: struct poly { struct point { int x; } vertex[50]; struct line { struct point p1; struct slope { int dx; } sl; } edge[50]; int ver_num; } *

variable_types: i int

user_defined_types: struct poly { struct point vertex[50]; struct line edge[50]; int ver_num; }


nomalize

decompiled_code:
__int64 __fastcall nomalize(_DWORD *a1)
{
int v1; // edx
int v2; // eax

v1 = a1[1];
v2 = a1[4];
if ( v1 > v2 || v1 == v2 && *a1 > a1[3] )
swap_poi(a1, a1 + 3);
return cal_sl(a1);
}

original_code:
void nomalize(struct line *l)
{
 if (l->p1.y > l->p2.y || (l->p1.y == l->p2.y && l->p1.x > l->p2.x))
   swap_poi(&l->p1,&l->p2);
  cal_sl(l);
}

variable_types: struct line { struct point { int x; } p1; struct slope { int dx; } sl; } *


readpolygon

original_code:
void readpolygon(struct poly *pol)
{
 readint(&pol->ver_num);
 int i;
 for (i=0;i < pol->ver_num;++i) pol->vertex[i]=readpoint();
 makeline(pol);
}


drawpolygon

decompiled_code:
__int64 __fastcall drawpolygon(__int64 a1, double a2, float a3)
{
int v3; // ebx
__int64 result; // rax

if ( *(int *)(a1 + 2200) > 0 )
{
v3 = 0;
do
{
result = drawline(a2, a3);
++v3;
}
while ( *(_DWORD *)(a1 + 2200) > v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, double a2, float a3)
{
int v3; // ebx
__int64 result; // rax

if ( *(int *)(a1 + 2200) > 0 )
{
v3 = 0;
do
{
result = drawline(a2, a3);
++v3;
}
while ( *(_DWORD *)(a1 + 2200) > v3 );
}
return result;
}

original_code:
void drawpolygon(struct poly *pol,struct colour c)
{
 int i;
 for (i=0;i < pol->ver_num; ++i)
 {
  drawline(pol->edge[i],c);
 }
}

canonical_original_code:
void drawpolygon(struct poly *pol, struct colour c)
{
 int i;
 for (i=0;i < pol->ver_num; ++i)
 {
  drawline(pol->edge[i],c);
 }
}

variable_types:
c
struct colour { float r; }


original_code:
int in_poly(struct poly *pol,struct point p)
{
 struct line l;
 l.p1 = p; l.p2 = p;
 l.p2.x += 601;
 l.p2.y += 1;
 int i,j = 0;
 for (i = 0;i < pol->ver_num; ++i)
  if (interset(l, pol->edge[i]) > 1) return 1;
  else if (interset(l, pol->edge[i]) == 1) ++j;
 return j&1;
}

canonical_original_code:
int in_poly(struct poly *pol, struct point p)
{
 struct line l;
 l.p1 = p; l.p2 = p;
 l.p2.x += 601;
 l.p2.y += 1;
 int i; int j = 0;
 for (i = 0;i < pol->ver_num; ++i)
  if (interset(l, pol->edge[i]) > 1) return 1;
  else if (interset(l, pol->edge[i]) == 1) ++j;
 return j&1;
}

variable_types:
p
struct point

variable_types: struct line { struct point { int x; } p1; struct slope { int dx; } sl; }

variable_types: j int


fillseed

decompiled_code:
void __fastcall fillseed(__int64 a1, unsigned int a2)
{
_DWORD *v2; // rbx
_DWORD *v3; // rbp
_DWORD *v4; // r12
int v5; // er13
int v6; // er12
__int64 v7; // [rsp+14h] [rbp-34h]
__int64 v8; // [rsp+14h] [rbp-34h]
unsigned int v9; // [rsp+1Ch] [rbp-2Ch]

glEnd();
if ( !(unsigned int)getred(a1, a2) )
{
glColor3f(1.0, 0.0);
v2 = malloc(0x18uLL);
*(_QWORD *)v2 = a1;
v2[2] = a2;
v3 = v2;
while ( 1 )
{
v7 = *(_QWORD *)v2;
v9 = v2[2];
v5 = *v2;
v6 = v2[1];
LODWORD(v7) = *v2 + 1;
if ( !(unsigned int)getred(v7, v9) )
v3 = creatpl((__int64)v3, v7, v9);
LODWORD(v7) = v5 - 1;
if ( !(unsigned int)getred(v7, v9) )
v3 = creatpl((__int64)v3, v7, v9);
LODWORD(v8) = v5;
HIDWORD(v8) = v6 + 1;
if ( !(unsigned int)getred(v8, v9) )
v3 = creatpl((__int64)v3, v8, v9);
HIDWORD(v8) = v6 - 1;
if ( !(unsigned int)getred(v8, v9) )
v3 = creatpl((__int64)v3, v8, v9);
v4 = (_DWORD *)*((_QWORD *)v2 + 2);
free(v2);
if ( !v4 )
break;
v2 = v4;
}
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, unsigned int a2)
{
_DWORD *v2; // rbx
_DWORD *v3; // rbp
_DWORD *v4; // r12
int v5; // er13
int v6; // er12
__int64 v7; // [rsp+14h] [rbp-34h]
__int64 v8; // [rsp+14h] [rbp-34h]
unsigned int v9; // [rsp+1Ch] [rbp-2Ch]

glEnd();
if ( !(unsigned int)getred(a1, a2) )
{
glColor3f(1.0, 0.0);
v2 = malloc(0x18uLL);
*(_QWORD *)v2 = a1;
v2[2] = a2;
v3 = v2;
while ( 1 )
{
v7 = *(_QWORD *)v2;
v9 = v2[2];
v5 = *v2;
v6 = v2[1];
LODWORD(v7) = *v2 + 1;
if ( !(unsigned int)getred(v7, v9) )
v3 = creatpl((__int64)v3, v7, v9);
LODWORD(v7) = v5 - 1;
if ( !(unsigned int)getred(v7, v9) )
v3 = creatpl((__int64)v3, v7, v9);
LODWORD(v8) = v5;
HIDWORD(v8) = v6 + 1;
if ( !(unsigned int)getred(v8, v9) )
v3 = creatpl((__int64)v3, v8, v9);
HIDWORD(v8) = v6 - 1;
if ( !(unsigned int)getred(v8, v9) )
v3 = creatpl((__int64)v3, v8, v9);
v4 = (_DWORD *)*((_QWORD *)v2 + 2);
free(v2);
if ( !v4 )
break;
v2 = v4;
}
}
}

original_code:
void fillseed(struct point seed)
{
 glEnd();
 if (getred(seed)) return;
 glColor3f(1,0,0);
 struct plist *head = (struct plist *)malloc(sizeof(struct plist));
 head->p = seed;
 struct plist *tail;
 tail = head;
 int s = 0;
 while (head != ((void *)0))
 {
  struct point p;
  p = head->p;
  ++p.x;
  if (getred(p) == 0) tail = creatpl(tail,p);
  p.x -= 2;
  if (getred(p) == 0) tail = creatpl(tail,p);
  ++p.x; ++p.y;
  if (getred(p) == 0) tail = creatpl(tail,p);
  p.y-=2;
  if (getred(p) == 0) tail = creatpl(tail,p);
  struct plist *t;
  t = head;
  head = head->next;
  free(t);
 }
}

variable_types:
seed
struct point { int x; }

variable_types: struct plist { struct point { int x; } p; struct plist *next; } *

variable_types: s int

variable_types:
p
struct point { int x; }

user_defined_types: struct plist { struct point p; struct plist *next; }


moved

decompiled_code:
void __fastcall moved(_DWORD *a1)
{
++*a1;
--a1[1];
}

canonical_decompiled_code:
void __fastcall func0(_DWORD *a1)
{
++*a1;
--a1[1];
}

original_code:
void moved(struct point *now,int *diff)
{
    now->x=now->x+1;
    now->y=now->y-1;
    diff=diff+2*now->x-2*now->y+2;
}

canonical_original_code:
void moved(struct point *now, int *diff)
{
    now->x=now->x+1;
    now->y=now->y-1;
    diff=diff+2*now->x-2*now->y+2;
}

variable_types:
now
struct point { int x; } *

variable_types:
diff
int *


drawcircle

decompiled_code:
__int64 __fastcall drawcircle(__int64 a1, unsigned int a2, int a3, double a4, double a5)
{
__int64 result; // rax
int v7; // ebx
signed int v8; // er12
unsigned int v9; // [rsp+2Ch] [rbp-1Ch]

result = glColor3f(*(float *)&a4, *((float *)&a4 + 1), a5);
v7 = 2 * (1 - a3);
if ( a3 >= 0 )
{
v8 = 0;
do
{
draw8p(a1, a2, __PAIR64__(a3, v8), v9);
if ( v7 < 0 )
{
result = (unsigned int)(2 * (v7 + a3));
++v8;
if ( (int)result <= 1 )
{
v7 += 2 * v8 + 1;
}
else
{
--a3;
result = (unsigned int)(2 * a3);
v7 = v7 + 2 * v8 - result + 2;
}
}
else if ( v7 <= 0 )
{
++v8;
--a3;
result = (unsigned int)(v8 - a3);
v7 = 2 * result + 2;
}
else if ( 2 * (v7 - v8) <= 1 )
{
++v8;
--a3;
result = (unsigned int)(2 * a3);
v7 = v7 + 2 * v8 - result + 2;
}
else
{
--a3;
result = (unsigned int)(2 * a3);
v7 = v7 - result + 1;
}
}
while ( v8 <= a3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2, int a3, double a4, double a5)
{
__int64 result; // rax
int v7; // ebx
signed int v8; // er12
unsigned int v9; // [rsp+2Ch] [rbp-1Ch]

result = glColor3f(*(float *)&a4, *((float *)&a4 + 1), a5);
v7 = 2 * (1 - a3);
if ( a3 >= 0 )
{
v8 = 0;
do
{
draw8p(a1, a2, __PAIR64__(a3, v8), v9);
if ( v7 < 0 )
{
result = (unsigned int)(2 * (v7 + a3));
++v8;
if ( (int)result <= 1 )
{
v7 += 2 * v8 + 1;
}
else
{
--a3;
result = (unsigned int)(2 * a3);
v7 = v7 + 2 * v8 - result + 2;
}
}
else if ( v7 <= 0 )
{
++v8;
--a3;
result = (unsigned int)(v8 - a3);
v7 = 2 * result + 2;
}
else if ( 2 * (v7 - v8) <= 1 )
{
++v8;
--a3;
result = (unsigned int)(2 * a3);
v7 = v7 + 2 * v8 - result + 2;
}
else
{
--a3;
result = (unsigned int)(2 * a3);
v7 = v7 - result + 1;
}
}
while ( v8 <= a3 );
}
return result;
}

original_code:
void drawcircle(struct point center,int rad,struct colour c)
{
    struct point now;
    int diff;
    glColor3f(c.r,c.g,c.b);
    now.x=0;
    now.y=rad;
    diff=2*(1-rad);
    while (now.y>=now.x)
    {
  draw8p(center,now);
  if (diff<0)
   if (2*diff+2*now.y-1<=0)
   {
    now.x=now.x+1;
    diff=diff+2*now.x+1;
   }
   else
   {
    now.x=now.x+1;
    now.y=now.y-1;
    diff=diff+2*now.x-2*now.y+2;
   }
  else
  if (diff>0)
   if (2*diff-2*now.x-1<=0)
   {
    now.x=now.x+1;
    now.y=now.y-1;
    diff=diff+2*now.x-2*now.y+2;
   }
   else
   {
    now.y=now.y-1;
    diff=diff-2*now.y+1;
   }
  else
  {
   now.x=now.x+1;
   now.y=now.y-1;
   diff=diff+2*now.x-2*now.y+2;
  }
    }
}

canonical_original_code:
void drawcircle(struct point center, int rad, struct colour c)
{
    struct point now;
    int diff;
    glColor3f(c.r,c.g,c.b);
    now.x=0;
    now.y=rad;
    diff=2*(1-rad);
    while (now.y>=now.x)
    {
  draw8p(center,now);
  if (diff<0)
   if (2*diff+2*now.y-1<=0)
   {
    now.x=now.x+1;
    diff=diff+2*now.x+1;
   }
   else
   {
    now.x=now.x+1;
    now.y=now.y-1;
    diff=diff+2*now.x-2*now.y+2;
   }
  else
  if (diff>0)
   if (2*diff-2*now.x-1<=0)
   {
    now.x=now.x+1;
    now.y=now.y-1;
    diff=diff+2*now.x-2*now.y+2;
   }
   else
   {
    now.y=now.y-1;
    diff=diff-2*now.y+1;
   }
  else
  {
   now.x=now.x+1;
   now.y=now.y-1;
   diff=diff+2*now.x-2*now.y+2;
  }
    }
}

variable_types:
center
struct point { int x; }

variable_types: rad int

variable_types:
now
struct point { int x; }

variable_types: diff int


drawellipse

original_code:
void drawellipse(struct point center,int a,int b,struct colour c)
{
    int aa=a*a,bb=b*b;
    float diff;
    struct point now;
    glColor3f(c.r,c.g,c.b);
    now.x=a; now.y=0;
    diff=aa-a*bb+(float)bb/4;
    while (bb*now.x>aa*now.y)
    {
 draw4p(center,now);
 now.y++;
 if (diff<0)
     diff+=2*aa*now.y+aa;
 else
 {
     now.x--;
     diff=diff-2*bb*now.x+2*aa*now.y+aa;
 }
    }
    diff=bb*sqr(now.x-1)+aa*sqr(now.y+0.5)-aa*bb;
    while (now.x>=0)
    {
 draw4p(center,now);
 now.x--;
 if (diff<0)
 {
     now.y++;
     diff+=2*aa*now.y-2*bb*now.x+bb;
 }
 else
     diff=diff-2*bb*now.x+bb;
    }
}

canonical_original_code:
void drawellipse(struct point center, int a, int b, struct colour c)
{
    int aa = a*a; int bb = b*b;
    float diff;
    struct point now;
    glColor3f(c.r,c.g,c.b);
    now.x=a; now.y=0;
    diff=aa-a*bb+(float)bb/4;
    while (bb*now.x>aa*now.y)
    {
 draw4p(center,now);
 now.y++;
 if (diff<0)
     diff+=2*aa*now.y+aa;
 else
 {
     now.x--;
     diff=diff-2*bb*now.x+2*aa*now.y+aa;
 }
    }
    diff=bb*sqr(now.x-1)+aa*sqr(now.y+0.5)-aa*bb;
    while (now.x>=0)
    {
 draw4p(center,now);
 now.x--;
 if (diff<0)
 {
     now.y++;
     diff+=2*aa*now.y-2*bb*now.x+bb;
 }
 else
     diff=diff-2*bb*now.x+bb;
    }
}

variable_types: a int

variable_types: b int

variable_types: aa int

variable_types: bb int

variable_types: diff float


readcontrol

decompiled_code:
__int64 readcontrol()
{
__int64 result; // rax
int v1; // ebx
int v2; // edx

result = readint(&con_num);
if ( con_num > 0 )
{
v1 = 0;
do
{
result = readpoint();
*(__int64 *)((char *)&control + 12 * v1) = result;
*((_DWORD *)&control + 3 * v1++ + 2) = v2;
}
while ( con_num > v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
int v1; // ebx
int v2; // edx

result = readint(&con_num);
if ( con_num > 0 )
{
v1 = 0;
do
{
result = readpoint();
*(__int64 *)((char *)&control + 12 * v1) = result;
*((_DWORD *)&control + 3 * v1++ + 2) = v2;
}
while ( con_num > v1 );
}
return result;
}

original_code:
void readcontrol()
{
 readint(&con_num);
 int i;
 for (i = 0;i < con_num;++i)
  control[i]=readpoint();
}

variable_types: i int


decompiled_code:
__int64 read2d()
{
__int64 result; // rax
int i; // er14
__int64 v2; // rbp
int v3; // edx
int j; // ebx

readint(&m);
result = readint(&n);
for ( i = 0; m > i; ++i )
{
for ( j = 0; n > j; ++j )
{
v2 = 120LL * i + 12LL * j;
result = readpoint();
*(__int64 *)((char *)&con2d + v2) = result;
*(_DWORD *)((char *)&con2d + v2 + 8) = v3;
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
int i; // er14
__int64 v2; // rbp
int v3; // edx
int j; // ebx

readint(&m);
result = readint(&n);
for ( i = 0; m > i; ++i )
{
for ( j = 0; n > j; ++j )
{
v2 = 120LL * i + 12LL * j;
result = readpoint();
*(__int64 *)((char *)&con2d + v2) = result;
*(_DWORD *)((char *)&con2d + v2 + 8) = v3;
}
}
return result;
}

original_code:
void read2d()
{
 readint(&m);
 readint(&n);
 int i,j;
 for (i = 0;i < m; ++i)
  for (j = 0;j < n;++j)
   con2d[i][j] = readpoint();
}

canonical_original_code:
void read2d()
{
 readint(&m);
 readint(&n);
 int i; int j;
 for (i = 0;i < m; ++i)
  for (j = 0;j < n;++j)
   con2d[i][j] = readpoint();
}

variable_types: j int


separate

original_code:
void separate(struct pointd *origin)
{
 int i,j = 0;
 for (i = 1;i < con_num;++i)
  if (abs((origin+i)->x-(origin+i-1)->x) > 0.4 ||abs((origin+i)->y-(origin+i-1)->y) > 0.4 )
  {
   j = 1;
   break;
  }
 if (j == 0)
 {
  for (i = 0;i < con_num; ++i) glVertex2i((int)((origin+i)->x+0.5),(int)((origin+i)->y+0.5));
  glEnd();
  glFlush();
  usleep(50000);
  glBegin(0x0000);
  return;
 }
 struct pointd *left = (struct pointd *)malloc(sizeof(struct pointd)*con_num);
 struct pointd *right = (struct pointd *)malloc(sizeof(struct pointd)*con_num);
 for (i = 0;i < con_num; ++i)
 {
  *(left+i) = *origin;
  *(right+i) = *(origin+con_num-i-1);
  for (j = 0;j < con_num-i-1;++j)
  {
   (origin+j)->x = ((origin+j)->x + (origin+j+1)->x)/2;
   (origin+j)->y = ((origin+j)->y + (origin+j+1)->y)/2;
  }
 }
 separate(left);
 separate(right);
}

canonical_original_code:
void separate(struct pointd *origin)
{
 int i; int j = 0;
 for (i = 1;i < con_num;++i)
  if (abs((origin+i)->x-(origin+i-1)->x) > 0.4 ||abs((origin+i)->y-(origin+i-1)->y) > 0.4 )
  {
   j = 1;
   break;
  }
 if (j == 0)
 {
  for (i = 0;i < con_num; ++i) glVertex2i((int)((origin+i)->x+0.5),(int)((origin+i)->y+0.5));
  glEnd();
  glFlush();
  usleep(50000);
  glBegin(0x0000);
  return;
 }
 struct pointd *left = (struct pointd *)malloc(sizeof(struct pointd)*con_num);
 struct pointd *right = (struct pointd *)malloc(sizeof(struct pointd)*con_num);
 for (i = 0;i < con_num; ++i)
 {
  *(left+i) = *origin;
  *(right+i) = *(origin+con_num-i-1);
  for (j = 0;j < con_num-i-1;++j)
  {
   (origin+j)->x = ((origin+j)->x + (origin+j+1)->x)/2;
   (origin+j)->y = ((origin+j)->y + (origin+j+1)->y)/2;
  }
 }
 separate(left);
 separate(right);
}

variable_types:
origin
struct pointd { double x; } *

variable_types:
left
struct pointd { double x; } *

variable_types:
right
struct pointd { double x; } *


drawcurve

decompiled_code:
__int64 drawcurve()
{
int v0; // ebx
double *v1; // rax
double *v2; // rdi
unsigned __int64 v3; // rdx
double *v4; // rcx

glColor3f(*(float *)&red, *((float *)&red + 1), *((float *)&red + 2));
v0 = con_num;
v1 = (double *)malloc(16LL * con_num);
v2 = v1;
if ( v0 > 0 )
{
v3 = (unsigned int)((_DWORD)&control + 4);
v4 = &v1[2 * (unsigned int)v0];
do
{
*v1 = (double)*(int *)(v3 - 4);
v1[1] = (double)*(int *)v3;
v1 += 2;
v3 += 12LL;
}
while ( v1 != v4 );
}
return separate(v2);
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebx
double *v1; // rax
double *v2; // rdi
unsigned __int64 v3; // rdx
double *v4; // rcx

glColor3f(*(float *)&red, *((float *)&red + 1), *((float *)&red + 2));
v0 = con_num;
v1 = (double *)malloc(16LL * con_num);
v2 = v1;
if ( v0 > 0 )
{
v3 = (unsigned int)((_DWORD)&control + 4);
v4 = &v1[2 * (unsigned int)v0];
do
{
*v1 = (double)*(int *)(v3 - 4);
v1[1] = (double)*(int *)v3;
v1 += 2;
v3 += 12LL;
}
while ( v1 != v4 );
}
return func2(v2);
}

original_code:
void drawcurve()
{
 int i;
 glColor3f(red.r,red.g,red.b);
 struct pointd *origin = (struct pointd *)malloc(sizeof(struct pointd)*con_num);
 for (i = 0;i < con_num;++i)
 {
  (origin+i)->x = control[i].x;
  (origin+i)->y = control[i].y;
 }
 separate(origin);
}


recur

canonical_original_code:
struct point recur(double u, double v)
{
 int i; int j; int k;
 struct point p;
 for (i = 0;i < m;++i)
 {
  for (j = 0;j < n;++j)
  {
   temp1[j].x = con2d[i][j].x;
   temp1[j].y = con2d[i][j].y;
  }
  for (j = 0;j < n;++j)
   for (k = 0;k < n-j-1;++k)
   {
    temp1[k].x = v*temp1[k].x+(1-v)*temp1[k+1].x;
    temp1[k].y = v*temp1[k].y+(1-v)*temp1[k+1].y;
   }
  temp2[i] = temp1[0];
 }
 for (i = 0;i < m;++i)
 {
  for (k = 0;k < m-i-1;++k)
   {
    temp2[k].x = u*temp2[k].x+(1-u)*temp2[k+1].x;
    temp2[k].y = u*temp2[k].y+(1-u)*temp2[k+1].y;
   }
 }
 p.x = (int)(temp2[0].x + 0.5);
 p.y = (int)(temp2[0].y + 0.5);
 return p;
}

variable_types: u double

variable_types: v double

variable_types: k int

variable_types:
p
struct point { int x; }

return_type: struct point { int x; }


drawsurface

original_code:
void drawsurface()
{
 read2d();
 int i,j;
 for (i = 0;i < m;++i)
 {
  struct line l;
  for (j = 1;j < n;++j)
  {
   l.p1 = con2d[i][j];
   l.p2 = con2d[i][j-1];
   drawline(l,yellow);
  }
 }
 for (j = 0;j < n;++j)
 {
  struct line l;
  for (i = 1;i < m;++i)
  {
   l.p1 = con2d[i][j];
   l.p2 = con2d[i-1][j];
   drawline(l,yellow);
  }
 }
 struct pointd origin[m][n];
 for (i = 0;i < m;++i)
 {
  for (j = 0;j < n;++j)
  {
   origin[i][j].x = con2d[i][j].x;
   origin[i][j].y = con2d[i][j].y;
  }
 }
 glColor3f(red.r,red.g,red.b);
 double u,v;
 for (u = 0;u <= 1; u+=0.005)
  for (v = 0;v <= 1; v+=0.005)
  {
   struct point p = recur(u,v);
   glVertex2i(p.x,p.y);
  }
}

canonical_original_code:
void drawsurface()
{
 read2d();
 int i; int j;
 for (i = 0;i < m;++i)
 {
  struct line l;
  for (j = 1;j < n;++j)
  {
   l.p1 = con2d[i][j];
   l.p2 = con2d[i][j-1];
   drawline(l,yellow);
  }
 }
 for (j = 0;j < n;++j)
 {
  struct line l;
  for (i = 1;i < m;++i)
  {
   l.p1 = con2d[i][j];
   l.p2 = con2d[i-1][j];
   drawline(l,yellow);
  }
 }
 struct pointd origin[-1][-1];
 for (i = 0;i < m;++i)
 {
  for (j = 0;j < n;++j)
  {
   origin[i][j].x = con2d[i][j].x;
   origin[i][j].y = con2d[i][j].y;
  }
 }
 glColor3f(red.r,red.g,red.b);
 double u; double v;
 for (u = 0;u <= 1; u+=0.005)
  for (v = 0;v <= 1; v+=0.005)
  {
   struct point p = recur(u,v);
   glVertex2i(p.x,p.y);
  }
}

variable_types: struct line { struct point { int x; } p1; struct slope { int dx; } sl; }

variable_types:
origin
struct pointd { double x; } [-1][-1]


readshadow

decompiled_code:
void __fastcall readshadow(double a1, float a2)
{
__int64 v2; // r12
int v3; // ebp
__int64 v4; // rdx

readint(&pla_num);
if ( pla_num > 0 )
{
v2 = (unsigned int)((_DWORD)proj_list + 16);
v3 = 0;
do
{
proj_list[279 * v3] = readplane();
proj_list[279 * v3 + 1] = v4;
readpolygon(v2);
*(double *)((char *)&proj_list[279 * v3 + 277] + 4) = readcolor();
*((float *)&proj_list[279 * v3++ + 278] + 1) = a2;
v2 += 2232LL;
}
while ( pla_num > v3 );
}
}

canonical_decompiled_code:
void __fastcall func0(double a1, float a2)
{
__int64 v2; // r12
int v3; // ebp
__int64 v4; // rdx

readint(&pla_num);
if ( pla_num > 0 )
{
v2 = (unsigned int)((_DWORD)proj_list + 16);
v3 = 0;
do
{
proj_list[279 * v3] = readplane();
proj_list[279 * v3 + 1] = v4;
readpolygon(v2);
*(double *)((char *)&proj_list[279 * v3 + 277] + 4) = readcolor();
*((float *)&proj_list[279 * v3++ + 278] + 1) = a2;
v2 += 2232LL;
}
while ( pla_num > v3 );
}
}

original_code:
void readshadow()
{
 readint(&pla_num);
 int i;
 for (i = 0;i < pla_num;++i)
 {
  proj_list[i].plan=readplane();
  readpolygon(&proj_list[i].proj);
  proj_list[i].c=readcolor();
 }
}


zbuffer

decompiled_code:
__int64 __fastcall zbuffer(double a1, float a2)
{
unsigned int i; // er14
int v3; // ebp
unsigned __int64 v4; // rbx
int v5; // eax
double v6; // xmm1_8
double v7; // xmm0_8
unsigned int v8; // er15
__int64 result; // rax
unsigned int j; // er13
float v11; // [rsp+0h] [rbp-58h]
float v12; // [rsp+4h] [rbp-54h]
double v13; // [rsp+8h] [rbp-50h]
unsigned int v14; // [rsp+1Ch] [rbp-3Ch]

readshadow(a1, a2);
for ( i = -300; i != 301; ++i )
{
for ( j = -300; j != 301; ++j )
{
v11 = black[0];
v12 = black[1];
v8 = LODWORD(black[2]);
if ( pla_num > 0 )
{
v4 = (unsigned int)((_DWORD)proj_list + 16);
v13 = *(double *)&LC0;
v3 = 0;
do
{
if ( *(_DWORD *)(v4 - 8) )
{
if ( (unsigned int)in_poly(v4, __PAIR64__(j, i), v14) )
{
v5 = *(_DWORD *)(v4 - 4) - *(_DWORD *)(v4 - 16) * i - *(_DWORD *)(v4 - 12) * j;
v6 = (double)*(int *)(v4 - 8);
v7 = (double)v5 / v6;
if ( v7 >= 0.0 && v13 > v7 )
{
v11 = *(float *)(v4 + 2204);
v12 = *(float *)(v4 + 2208);
v8 = *(_DWORD *)(v4 + 2212);
v13 = (double)v5 / v6;
}
}
}
++v3;
v4 += 2232LL;
}
while ( pla_num > v3 );
}
glColor3f(v11, v12, *(double *)_mm_cvtsi32_si128(v8).m128i_i64);
result = glVertex2i(i, j);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(double a1, float a2)
{
unsigned int i; // er14
int v3; // ebp
unsigned __int64 v4; // rbx
int v5; // eax
double v6; // xmm1_8
double v7; // xmm0_8
unsigned int v8; // er15
__int64 result; // rax
unsigned int j; // er13
float v11; // [rsp+0h] [rbp-58h]
float v12; // [rsp+4h] [rbp-54h]
double v13; // [rsp+8h] [rbp-50h]
unsigned int v14; // [rsp+1Ch] [rbp-3Ch]

func0(a1, a2);
for ( i = -300; i != 301; ++i )
{
for ( j = -300; j != 301; ++j )
{
v11 = black[0];
v12 = black[1];
v8 = LODWORD(black[2]);
if ( pla_num > 0 )
{
v4 = (unsigned int)((_DWORD)proj_list + 16);
v13 = *(double *)&LC0;
v3 = 0;
do
{
if ( *(_DWORD *)(v4 - 8) )
{
if ( (unsigned int)in_poly(v4, __PAIR64__(j, i), v14) )
{
v5 = *(_DWORD *)(v4 - 4) - *(_DWORD *)(v4 - 16) * i - *(_DWORD *)(v4 - 12) * j;
v6 = (double)*(int *)(v4 - 8);
v7 = (double)v5 / v6;
if ( v7 >= 0.0 && v13 > v7 )
{
v11 = *(float *)(v4 + 2204);
v12 = *(float *)(v4 + 2208);
v8 = *(_DWORD *)(v4 + 2212);
v13 = (double)v5 / v6;
}
}
}
++v3;
v4 += 2232LL;
}
while ( pla_num > v3 );
}
glColor3f(v11, v12, *(double *)_mm_cvtsi32_si128(v8).m128i_i64);
result = glVertex2i(i, j);
}
}
return result;
}

original_code:
void zbuffer()
{
 readshadow();
 int i,j,k;
 for (i = -300;i <= 300;++i)
  for (j = -300;j <= 300;++j)
  {
   double z = 1e11;
   struct point p;
   struct colour c = black;
   p.x = i;
   p.y = j;
   for (k = 0;k < pla_num;++k)
   {
    if (proj_list[k].plan.z != 0)
     if (in_poly(&proj_list[k].proj,p))
     {
      struct plane pl = proj_list[k].plan;
      double t = (pl.d-pl.x*i-pl.y*j)/(double)pl.z;
      if (t >=0 && t < z)
      {
       z = t;
       c = proj_list[k].c;
      }
     }
   }
   glColor3f(c.r,c.g,c.b);
   glVertex2i(i,j);
  }
}

canonical_original_code:
void zbuffer()
{
 readshadow();
 int i; int j; int k;
 for (i = -300;i <= 300;++i)
  for (j = -300;j <= 300;++j)
  {
   double z = 1e11;
   struct point p;
   struct colour c = black;
   p.x = i;
   p.y = j;
   for (k = 0;k < pla_num;++k)
   {
    if (proj_list[k].plan.z != 0)
     if (in_poly(&proj_list[k].proj,p))
     {
      struct plane pl = proj_list[k].plan;
      double t = (pl.d-pl.x*i-pl.y*j)/(double)pl.z;
      if (t >=0 && t < z)
      {
       z = t;
       c = proj_list[k].c;
      }
     }
   }
   glColor3f(c.r,c.g,c.b);
   glVertex2i(i,j);
  }
}

variable_types: z double

variable_types:
c
struct colour { float r; }

variable_types:
pl
struct plane { int x; }

variable_types: t double

user_defined_types:
struct point { int x; }
struct colour { float r; }
struct plane { int x; }


repo: kiennt/SimpleXML

decompiled_code:
int test_vector()
{
_DWORD *v0; // rax
_DWORD *v1; // r12
unsigned int v2; // ebx
int v3; // ebp
int v5; // [rsp+4h] [rbp-24h] BYREF
int v6; // [rsp+8h] [rbp-20h] BYREF
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v7[0] = 10;
v6 = 20;
v5 = 30;
v0 = (_DWORD *)vector_create(0LL);
if ( v0[1] )
_assert_fail("v->_size == 0 && \"create size FAILED\"", "test.c", 0x10u, "test_vector");
v1 = v0;
if ( *v0 != 8 )
_assert_fail("v->_capacity == 8 && \"create capacity FAILED\"", "test.c", 0x11u, "test_vector");
vector_push_back(v0, v7);
vector_push_back(v1, &v6);
if ( (unsigned int)vector_size(v1) != 2 )
_assert_fail("vector_size(v) == 2 && \"insert element FAILED\"", "test.c", 0x16u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &a && \"insert element FAILED\"", "test.c", 0x17u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b && \"insert element FAILED\"", "test.c", 0x18u, "test_vector");
vector_push_front(v1, v7);
vector_push_front(v1, &v6);
vector_push_front(v1, &v5);
if ( (unsigned int)vector_size(v1) != 5 )
_assert_fail("vector_size(v) == 5", "test.c", 0x1Eu, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x1Fu, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x20u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 2LL) )
_assert_fail("vector_get_element_at(v, 2) == &a", "test.c", 0x21u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 3LL) )
_assert_fail("vector_get_element_at(v, 3) == &a", "test.c", 0x22u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &b", "test.c", 0x23u, "test_vector");
vector_insert_at_index(v1, &v5, 2LL);
if ( (unsigned int)vector_size(v1) != 6 )
_assert_fail("vector_size(v) == 6", "test.c", 0x27u, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x28u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x29u, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 2LL) )
_assert_fail("vector_get_element_at(v, 2) == &c", "test.c", 0x2Au, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 3LL) )
_assert_fail("vector_get_element_at(v, 3) == &a", "test.c", 0x2Bu, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &a", "test.c", 0x2Cu, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 5LL) )
_assert_fail("vector_get_element_at(v, 5) == &b", "test.c", 0x2Du, "test_vector");
vector_remove_element_at_index(v1, 2LL);
v2 = vector_size(v1);
if ( v2 != 5 )
_assert_fail("vector_size(v) == 5", "test.c", 0x31u, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x32u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x33u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 2LL) )
_assert_fail("vector_get_element_at(v, 2) == &a", "test.c", 0x34u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 3LL) )
_assert_fail("vector_get_element_at(v, 3) == &a", "test.c", 0x35u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &b", "test.c", 0x36u, "test_vector");
v3 = 100;
do
{
vector_push_back(v1, v7);
--v3;
}
while ( v3 );
if ( (unsigned int)vector_size(v1) != 105 )
_assert_fail("vector_size(v) == 105", "test.c", 0x3Cu, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x3Du, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x3Eu, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 2LL) )
_assert_fail("vector_get_element_at(v, 2) == &a", "test.c", 0x3Fu, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 3LL) )
_assert_fail("vector_get_element_at(v, 3) == &a", "test.c", 0x40u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &b", "test.c", 0x41u, "test_vector");
do
{
if ( v7 != (int *)vector_get_element_at(v1, v2) )
_assert_fail("vector_get_element_at(v, i) == &a", "test.c", 0x43u, "test_vector");
++v2;
}
while ( v2 != 105 );
if ( v7 != (int *)vector_top_back(v1) )
_assert_fail("vector_top_back(v) == &a", "test.c", 0x47u, "test_vector");
if ( &v5 != (int *)vector_top_front(v1) )
_assert_fail("vector_top_front(v) == &c", "test.c", 0x48u, "test_vector");
if ( (unsigned int)vector_size(v1) != 105 )
_assert_fail("vector_size(v) == 105", "test.c", 0x49u, "test_vector");
vector_release(v1);
return puts("PASSED Test vector1");
}

canonical_decompiled_code:
int func0()
{
_DWORD *v0; // rax
_DWORD *v1; // r12
unsigned int v2; // ebx
int v3; // ebp
int v5; // [rsp+4h] [rbp-24h] BYREF
int v6; // [rsp+8h] [rbp-20h] BYREF
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v7[0] = 10;
v6 = 20;
v5 = 30;
v0 = (_DWORD *)vector_create(0LL);
if ( v0[1] )
_assert_fail("v->_size == 0 && \"create size FAILED\"", "test.c", 0x10u, "test_vector");
v1 = v0;
if ( *v0 != 8 )
_assert_fail("v->_capacity == 8 && \"create capacity FAILED\"", "test.c", 0x11u, "test_vector");
vector_push_back(v0, v7);
vector_push_back(v1, &v6);
if ( (unsigned int)vector_size(v1) != 2 )
_assert_fail("vector_size(v) == 2 && \"insert element FAILED\"", "test.c", 0x16u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &a && \"insert element FAILED\"", "test.c", 0x17u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b && \"insert element FAILED\"", "test.c", 0x18u, "test_vector");
vector_push_front(v1, v7);
vector_push_front(v1, &v6);
vector_push_front(v1, &v5);
if ( (unsigned int)vector_size(v1) != 5 )
_assert_fail("vector_size(v) == 5", "test.c", 0x1Eu, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x1Fu, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x20u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 2LL) )
_assert_fail("vector_get_element_at(v, 2) == &a", "test.c", 0x21u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 3LL) )
_assert_fail("vector_get_element_at(v, 3) == &a", "test.c", 0x22u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &b", "test.c", 0x23u, "test_vector");
vector_insert_at_index(v1, &v5, 2LL);
if ( (unsigned int)vector_size(v1) != 6 )
_assert_fail("vector_size(v) == 6", "test.c", 0x27u, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x28u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x29u, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 2LL) )
_assert_fail("vector_get_element_at(v, 2) == &c", "test.c", 0x2Au, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 3LL) )
_assert_fail("vector_get_element_at(v, 3) == &a", "test.c", 0x2Bu, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &a", "test.c", 0x2Cu, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 5LL) )
_assert_fail("vector_get_element_at(v, 5) == &b", "test.c", 0x2Du, "test_vector");
vector_remove_element_at_index(v1, 2LL);
v2 = vector_size(v1);
if ( v2 != 5 )
_assert_fail("vector_size(v) == 5", "test.c", 0x31u, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x32u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x33u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 2LL) )
_assert_fail("vector_get_element_at(v, 2) == &a", "test.c", 0x34u, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 3LL) )
_assert_fail("vector_get_element_at(v, 3) == &a", "test.c", 0x35u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &b", "test.c", 0x36u, "test_vector");
v3 = 100;
do
{
vector_push_back(v1, v7);
--v3;
}
while ( v3 );
if ( (unsigned int)vector_size(v1) != 105 )
_assert_fail("vector_size(v) == 105", "test.c", 0x3Cu, "test_vector");
if ( &v5 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x3Du, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x3Eu, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 2LL) )
_assert_fail("vector_get_element_at(v, 2) == &a", "test.c", 0x3Fu, "test_vector");
if ( v7 != (int *)vector_get_element_at(v1, 3LL) )
_assert_fail("vector_get_element_at(v, 3) == &a", "test.c", 0x40u, "test_vector");
if ( &v6 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &b", "test.c", 0x41u, "test_vector");
do
{
if ( v7 != (int *)vector_get_element_at(v1, v2) )
_assert_fail("vector_get_element_at(v, i) == &a", "test.c", 0x43u, "test_vector");
++v2;
}
while ( v2 != 105 );
if ( v7 != (int *)vector_top_back(v1) )
_assert_fail("vector_top_back(v) == &a", "test.c", 0x47u, "test_vector");
if ( &v5 != (int *)vector_top_front(v1) )
_assert_fail("vector_top_front(v) == &c", "test.c", 0x48u, "test_vector");
if ( (unsigned int)vector_size(v1) != 105 )
_assert_fail("vector_size(v) == 105", "test.c", 0x49u, "test_vector");
vector_release(v1);
return puts("PASSED Test vector1");
}

original_code:
void test_vector() {
  Vector *v;
  int a, b, c, i;
  a = 10;
  b = 20;
  c = 30;
  v = vector_create(v);
  ((void) sizeof ((v->_size == 0 && "create size FAILED") ? 1 : 0), __extension__ ({ if (v->_size == 0 && "create size FAILED") ; else __assert_fail ("v->_size == 0 && \"create size FAILED\"", "test.c", 16, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((v->_capacity == 8 && "create capacity FAILED") ? 1 : 0), __extension__ ({ if (v->_capacity == 8 && "create capacity FAILED") ; else __assert_fail ("v->_capacity == 8 && \"create capacity FAILED\"", "test.c", 17, __extension__ __PRETTY_FUNCTION__); }));
  vector_push_back(v, &a);
  vector_push_back(v, &b);
  ((void) sizeof ((vector_size(v) == 2 && "insert element FAILED") ? 1 : 0), __extension__ ({ if (vector_size(v) == 2 && "insert element FAILED") ; else __assert_fail ("vector_size(v) == 2 && \"insert element FAILED\"", "test.c", 22, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &a && "insert element FAILED") ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &a && "insert element FAILED") ; else __assert_fail ("vector_get_element_at(v, 0) == &a && \"insert element FAILED\"", "test.c", 23, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b && "insert element FAILED") ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b && "insert element FAILED") ; else __assert_fail ("vector_get_element_at(v, 1) == &b && \"insert element FAILED\"", "test.c", 24, __extension__ __PRETTY_FUNCTION__); }));
  vector_push_front(v, &a);
  vector_push_front(v, &b);
  vector_push_front(v, &c);
  ((void) sizeof ((vector_size(v) == 5) ? 1 : 0), __extension__ ({ if (vector_size(v) == 5) ; else __assert_fail ("vector_size(v) == 5", "test.c", 30, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &c) ; else __assert_fail ("vector_get_element_at(v, 0) == &c", "test.c", 31, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b) ; else __assert_fail ("vector_get_element_at(v, 1) == &b", "test.c", 32, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 2) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 2) == &a) ; else __assert_fail ("vector_get_element_at(v, 2) == &a", "test.c", 33, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 3) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 3) == &a) ; else __assert_fail ("vector_get_element_at(v, 3) == &a", "test.c", 34, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 4) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 4) == &b) ; else __assert_fail ("vector_get_element_at(v, 4) == &b", "test.c", 35, __extension__ __PRETTY_FUNCTION__); }));
  vector_insert_at_index(v, &c, 2);
  ((void) sizeof ((vector_size(v) == 6) ? 1 : 0), __extension__ ({ if (vector_size(v) == 6) ; else __assert_fail ("vector_size(v) == 6", "test.c", 39, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &c) ; else __assert_fail ("vector_get_element_at(v, 0) == &c", "test.c", 40, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b) ; else __assert_fail ("vector_get_element_at(v, 1) == &b", "test.c", 41, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 2) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 2) == &c) ; else __assert_fail ("vector_get_element_at(v, 2) == &c", "test.c", 42, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 3) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 3) == &a) ; else __assert_fail ("vector_get_element_at(v, 3) == &a", "test.c", 43, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 4) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 4) == &a) ; else __assert_fail ("vector_get_element_at(v, 4) == &a", "test.c", 44, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 5) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 5) == &b) ; else __assert_fail ("vector_get_element_at(v, 5) == &b", "test.c", 45, __extension__ __PRETTY_FUNCTION__); }));
  vector_remove_element_at_index(v, 2);
  ((void) sizeof ((vector_size(v) == 5) ? 1 : 0), __extension__ ({ if (vector_size(v) == 5) ; else __assert_fail ("vector_size(v) == 5", "test.c", 49, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &c) ; else __assert_fail ("vector_get_element_at(v, 0) == &c", "test.c", 50, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b) ; else __assert_fail ("vector_get_element_at(v, 1) == &b", "test.c", 51, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 2) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 2) == &a) ; else __assert_fail ("vector_get_element_at(v, 2) == &a", "test.c", 52, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 3) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 3) == &a) ; else __assert_fail ("vector_get_element_at(v, 3) == &a", "test.c", 53, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 4) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 4) == &b) ; else __assert_fail ("vector_get_element_at(v, 4) == &b", "test.c", 54, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 0; i < 100; ++i) {
    vector_push_back(v, &a);
  }
  ((void) sizeof ((vector_size(v) == 105) ? 1 : 0), __extension__ ({ if (vector_size(v) == 105) ; else __assert_fail ("vector_size(v) == 105", "test.c", 60, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &c) ; else __assert_fail ("vector_get_element_at(v, 0) == &c", "test.c", 61, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b) ; else __assert_fail ("vector_get_element_at(v, 1) == &b", "test.c", 62, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 2) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 2) == &a) ; else __assert_fail ("vector_get_element_at(v, 2) == &a", "test.c", 63, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 3) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 3) == &a) ; else __assert_fail ("vector_get_element_at(v, 3) == &a", "test.c", 64, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 4) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 4) == &b) ; else __assert_fail ("vector_get_element_at(v, 4) == &b", "test.c", 65, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 5; i < 105; ++i) {
    ((void) sizeof ((vector_get_element_at(v, i) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, i) == &a) ; else __assert_fail ("vector_get_element_at(v, i) == &a", "test.c", 67, __extension__ __PRETTY_FUNCTION__); }));
  }
  ((void) sizeof ((vector_top_back(v) == &a) ? 1 : 0), __extension__ ({ if (vector_top_back(v) == &a) ; else __assert_fail ("vector_top_back(v) == &a", "test.c", 71, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_top_front(v) == &c) ? 1 : 0), __extension__ ({ if (vector_top_front(v) == &c) ; else __assert_fail ("vector_top_front(v) == &c", "test.c", 72, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_size(v) == 105) ? 1 : 0), __extension__ ({ if (vector_size(v) == 105) ; else __assert_fail ("vector_size(v) == 105", "test.c", 73, __extension__ __PRETTY_FUNCTION__); }));
  vector_release(v);
  printf("PASSED Test vector1\n");
}

canonical_original_code:
void test_vector() {
  struct Vector *v;
  int a; int b; int c; int i;
  a = 10;
  b = 20;
  c = 30;
  v = vector_create(v);
  ((void) sizeof ((v->_size == 0 && "create size FAILED") ? 1 : 0), __extension__ ({ if (v->_size == 0 && "create size FAILED") ; else __assert_fail ("v->_size == 0 && \"create size FAILED\"", "test.c", 16, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((v->_capacity == 8 && "create capacity FAILED") ? 1 : 0), __extension__ ({ if (v->_capacity == 8 && "create capacity FAILED") ; else __assert_fail ("v->_capacity == 8 && \"create capacity FAILED\"", "test.c", 17, __extension__ __PRETTY_FUNCTION__); }));
  vector_push_back(v, &a);
  vector_push_back(v, &b);
  ((void) sizeof ((vector_size(v) == 2 && "insert element FAILED") ? 1 : 0), __extension__ ({ if (vector_size(v) == 2 && "insert element FAILED") ; else __assert_fail ("vector_size(v) == 2 && \"insert element FAILED\"", "test.c", 22, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &a && "insert element FAILED") ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &a && "insert element FAILED") ; else __assert_fail ("vector_get_element_at(v, 0) == &a && \"insert element FAILED\"", "test.c", 23, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b && "insert element FAILED") ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b && "insert element FAILED") ; else __assert_fail ("vector_get_element_at(v, 1) == &b && \"insert element FAILED\"", "test.c", 24, __extension__ __PRETTY_FUNCTION__); }));
  vector_push_front(v, &a);
  vector_push_front(v, &b);
  vector_push_front(v, &c);
  ((void) sizeof ((vector_size(v) == 5) ? 1 : 0), __extension__ ({ if (vector_size(v) == 5) ; else __assert_fail ("vector_size(v) == 5", "test.c", 30, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &c) ; else __assert_fail ("vector_get_element_at(v, 0) == &c", "test.c", 31, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b) ; else __assert_fail ("vector_get_element_at(v, 1) == &b", "test.c", 32, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 2) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 2) == &a) ; else __assert_fail ("vector_get_element_at(v, 2) == &a", "test.c", 33, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 3) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 3) == &a) ; else __assert_fail ("vector_get_element_at(v, 3) == &a", "test.c", 34, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 4) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 4) == &b) ; else __assert_fail ("vector_get_element_at(v, 4) == &b", "test.c", 35, __extension__ __PRETTY_FUNCTION__); }));
  vector_insert_at_index(v, &c, 2);
  ((void) sizeof ((vector_size(v) == 6) ? 1 : 0), __extension__ ({ if (vector_size(v) == 6) ; else __assert_fail ("vector_size(v) == 6", "test.c", 39, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &c) ; else __assert_fail ("vector_get_element_at(v, 0) == &c", "test.c", 40, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b) ; else __assert_fail ("vector_get_element_at(v, 1) == &b", "test.c", 41, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 2) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 2) == &c) ; else __assert_fail ("vector_get_element_at(v, 2) == &c", "test.c", 42, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 3) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 3) == &a) ; else __assert_fail ("vector_get_element_at(v, 3) == &a", "test.c", 43, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 4) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 4) == &a) ; else __assert_fail ("vector_get_element_at(v, 4) == &a", "test.c", 44, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 5) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 5) == &b) ; else __assert_fail ("vector_get_element_at(v, 5) == &b", "test.c", 45, __extension__ __PRETTY_FUNCTION__); }));
  vector_remove_element_at_index(v, 2);
  ((void) sizeof ((vector_size(v) == 5) ? 1 : 0), __extension__ ({ if (vector_size(v) == 5) ; else __assert_fail ("vector_size(v) == 5", "test.c", 49, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &c) ; else __assert_fail ("vector_get_element_at(v, 0) == &c", "test.c", 50, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b) ; else __assert_fail ("vector_get_element_at(v, 1) == &b", "test.c", 51, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 2) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 2) == &a) ; else __assert_fail ("vector_get_element_at(v, 2) == &a", "test.c", 52, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 3) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 3) == &a) ; else __assert_fail ("vector_get_element_at(v, 3) == &a", "test.c", 53, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 4) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 4) == &b) ; else __assert_fail ("vector_get_element_at(v, 4) == &b", "test.c", 54, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 0; i < 100; ++i) {
    vector_push_back(v, &a);
  }
  ((void) sizeof ((vector_size(v) == 105) ? 1 : 0), __extension__ ({ if (vector_size(v) == 105) ; else __assert_fail ("vector_size(v) == 105", "test.c", 60, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 0) == &c) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 0) == &c) ; else __assert_fail ("vector_get_element_at(v, 0) == &c", "test.c", 61, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 1) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 1) == &b) ; else __assert_fail ("vector_get_element_at(v, 1) == &b", "test.c", 62, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 2) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 2) == &a) ; else __assert_fail ("vector_get_element_at(v, 2) == &a", "test.c", 63, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 3) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 3) == &a) ; else __assert_fail ("vector_get_element_at(v, 3) == &a", "test.c", 64, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_get_element_at(v, 4) == &b) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, 4) == &b) ; else __assert_fail ("vector_get_element_at(v, 4) == &b", "test.c", 65, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 5; i < 105; ++i) {
    ((void) sizeof ((vector_get_element_at(v, i) == &a) ? 1 : 0), __extension__ ({ if (vector_get_element_at(v, i) == &a) ; else __assert_fail ("vector_get_element_at(v, i) == &a", "test.c", 67, __extension__ __PRETTY_FUNCTION__); }));
  }
  ((void) sizeof ((vector_top_back(v) == &a) ? 1 : 0), __extension__ ({ if (vector_top_back(v) == &a) ; else __assert_fail ("vector_top_back(v) == &a", "test.c", 71, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_top_front(v) == &c) ? 1 : 0), __extension__ ({ if (vector_top_front(v) == &c) ; else __assert_fail ("vector_top_front(v) == &c", "test.c", 72, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_size(v) == 105) ? 1 : 0), __extension__ ({ if (vector_size(v) == 105) ; else __assert_fail ("vector_size(v) == 105", "test.c", 73, __extension__ __PRETTY_FUNCTION__); }));
  vector_release(v);
  printf("PASSED Test vector1\n");
}

variable_types: struct Vector { int _capacity; int _size; void **_data; } *

variable_types: a int

variable_types: b int

variable_types: c int


decompiled_code:
int __fastcall test_vector2()
{
__int64 v0; // rbp
__int64 v1; // r14
unsigned int i; // ebx
char *v3; // r12
char *v4; // r13
unsigned int j; // ebx
char *v6; // r12
char *v7; // rbp
const char **v8; // r13
int k; // ebx
__int64 v10; // rax

v1 = vector_create(0LL);
for ( i = 0; i != 100000; ++i )
{
v3 = (char *)malloc(0x1EuLL);
v4 = (char *)malloc(0x1EuLL);
sprintf(v3, "tag %d", i);
sprintf(v4, "value %d", i);
v0 = XMLElement_create(v0, v3, v4);
vector_push_back(v1, v0);
}
for ( j = 0; (int)vector_size(v1) > (int)j; ++j )
{
v6 = (char *)malloc(0x1EuLL);
v7 = (char *)malloc(0x1EuLL);
sprintf(v6, "tag %d", j);
sprintf(v7, "value %d", j);
v8 = (const char **)vector_get_element_at(v1, j);
if ( strcmp(*v8, v6) )
_assert_fail("strcmp(e->tag_name, tag_name) == 0", "test.c", 0x6Cu, "test_vector2");
if ( strcmp(v8[1], v7) )
_assert_fail("strcmp(e->value, value) == 0", "test.c", 0x6Du, "test_vector2");
free(v6);
free(v7);
}
for ( k = 0; (int)vector_size(v1) > k; ++k )
{
v10 = vector_get_element_at(v1, (unsigned int)k);
XMLElement_release(v10);
}
vector_release(v1);
return puts("PASSED Test vector2");
}

canonical_decompiled_code:
int __fastcall func1()
{
__int64 v0; // rbp
__int64 v1; // r14
unsigned int i; // ebx
char *v3; // r12
char *v4; // r13
unsigned int j; // ebx
char *v6; // r12
char *v7; // rbp
const char **v8; // r13
int k; // ebx
__int64 v10; // rax

v1 = vector_create(0LL);
for ( i = 0; i != 100000; ++i )
{
v3 = (char *)malloc(0x1EuLL);
v4 = (char *)malloc(0x1EuLL);
sprintf(v3, "tag %d", i);
sprintf(v4, "value %d", i);
v0 = XMLElement_create(v0, v3, v4);
vector_push_back(v1, v0);
}
for ( j = 0; (int)vector_size(v1) > (int)j; ++j )
{
v6 = (char *)malloc(0x1EuLL);
v7 = (char *)malloc(0x1EuLL);
sprintf(v6, "tag %d", j);
sprintf(v7, "value %d", j);
v8 = (const char **)vector_get_element_at(v1, j);
if ( strcmp(*v8, v6) )
_assert_fail("strcmp(e->tag_name, tag_name) == 0", "test.c", 0x6Cu, "test_vector2");
if ( strcmp(v8[1], v7) )
_assert_fail("strcmp(e->value, value) == 0", "test.c", 0x6Du, "test_vector2");
free(v6);
free(v7);
}
for ( k = 0; (int)vector_size(v1) > k; ++k )
{
v10 = vector_get_element_at(v1, (unsigned int)k);
XMLElement_release(v10);
}
vector_release(v1);
return puts("PASSED Test vector2");
}

original_code:
void test_vector2() {
  int i;
  Vector *v;
  v = vector_create(v);
  for (i = 0; i < 100000; ++i) {
    XMLElement *e;
    char *tag_name, *value;
    tag_name = malloc(30 * sizeof(char));
    value = malloc(30 * sizeof(char));
    sprintf(tag_name, "tag %d", i);
    sprintf(value, "value %d", i);
    e = XMLElement_create(e, tag_name, value);
    vector_push_back(v, e);
  }
  for (i = 0; i < vector_size(v); ++i) {
    XMLElement *e;
    char *tag_name, *value;
    tag_name = malloc(30 * sizeof(char));
    value = malloc(30 * sizeof(char));
    sprintf(tag_name, "tag %d", i);
    sprintf(value, "value %d", i);
    e = (XMLElement *) vector_get_element_at(v, i);
    ((void) sizeof ((strcmp(e->tag_name, tag_name) == 0) ? 1 : 0), __extension__ ({ if (strcmp(e->tag_name, tag_name) == 0) ; else __assert_fail ("strcmp(e->tag_name, tag_name) == 0", "test.c", 108, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((strcmp(e->value, value) == 0) ? 1 : 0), __extension__ ({ if (strcmp(e->value, value) == 0) ; else __assert_fail ("strcmp(e->value, value) == 0", "test.c", 109, __extension__ __PRETTY_FUNCTION__); }));
    free(tag_name);
    free(value);
  }
  for (i = 0; i < vector_size(v); ++i) {
    XMLElement *e;
    e = vector_get_element_at(v, i);
    XMLElement_release(e);
  }
  vector_release(v);
  printf("PASSED Test vector2\n");
}

canonical_original_code:
void test_vector2() {
  int i;
  struct Vector *v;
  v = vector_create(v);
  for (i = 0; i < 100000; ++i) {
    struct XMLElement *e;
    char *tag_name; char *value;
    tag_name = malloc(30 * sizeof(char));
    value = malloc(30 * sizeof(char));
    sprintf(tag_name, "tag %d", i);
    sprintf(value, "value %d", i);
    e = XMLElement_create(e, tag_name, value);
    vector_push_back(v, e);
  }
  for (i = 0; i < vector_size(v); ++i) {
    struct XMLElement *e;
    char *tag_name; char *value;
    tag_name = malloc(30 * sizeof(char));
    value = malloc(30 * sizeof(char));
    sprintf(tag_name, "tag %d", i);
    sprintf(value, "value %d", i);
    e = (struct XMLElement *) vector_get_element_at(v, i);
    ((void) sizeof ((strcmp(e->tag_name, tag_name) == 0) ? 1 : 0), __extension__ ({ if (strcmp(e->tag_name, tag_name) == 0) ; else __assert_fail ("strcmp(e->tag_name, tag_name) == 0", "test.c", 108, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((strcmp(e->value, value) == 0) ? 1 : 0), __extension__ ({ if (strcmp(e->value, value) == 0) ; else __assert_fail ("strcmp(e->value, value) == 0", "test.c", 109, __extension__ __PRETTY_FUNCTION__); }));
    free(tag_name);
    free(value);
  }
  for (i = 0; i < vector_size(v); ++i) {
    struct XMLElement *e;
    e = vector_get_element_at(v, i);
    XMLElement_release(e);
  }
  vector_release(v);
  printf("PASSED Test vector2\n");
}

variable_types: i int

variable_types: struct XMLElement { char *tag_name; char *value; struct XMLElement *parent; struct Vector { int _capacity; int _size; void **_data; } *children; } *

variable_types:
value
char *

user_defined_types: struct XMLElement { char *tag_name; char *value; struct XMLElement *parent; struct Vector *children; }


decompiled_code:
int test_xml()
{
__int64 v0; // rbx
__int64 v1; // rbp
__int64 v2; // r12
__int64 i; // rbx
const char **v4; // rbp
char *s2[13]; // [rsp+0h] [rbp-68h]

v0 = (int)parse_xml_from_text(
"<programmer> <name>Kien Nguyen Trung</name> <languages> <language>C</language> <language>C++</"
"language> <language>Python</language> <language>Ruby</language> <language>Objective C</language> "
" <language>Java</language> <language>Javascript</language> <language>Lua</language> <language>C"
"#</language> <language>PHP</language> </languages> </programmer>");
if ( strcmp(*(const char **)v0, "programmer") )
_assert_fail("strcmp(elem->tag_name, \"programmer\") == 0", "test.c", 0x92u, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v0 + 24)) != 2 )
_assert_fail("vector_size(elem->children) == 2", "test.c", 0x93u, "test_xml");
v1 = vector_get_element_at(*(_QWORD *)(v0 + 24), 0LL);
if ( strcmp(*(const char **)v1, "name") )
_assert_fail("strcmp(child1->tag_name, \"name\") == 0", "test.c", 0x96u, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v1 + 24)) )
_assert_fail("vector_size(child1->children) == 0", "test.c", 0x97u, "test_xml");
if ( strcmp(*(const char **)(v1 + 8), "Kien Nguyen Trung") )
_assert_fail("strcmp(child1->value, \"Kien Nguyen Trung\") == 0", "test.c", 0x98u, "test_xml");
v2 = vector_get_element_at(*(_QWORD *)(v0 + 24), 1LL);
if ( strcmp(*(const char **)v2, "languages") )
_assert_fail("strcmp(child2->tag_name, \"languages\") == 0", "test.c", 0x9Bu, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v2 + 24)) != 10 )
_assert_fail("vector_size(child2->children) == 10", "test.c", 0x9Cu, "test_xml");
s2[0] = "C";
s2[1] = "C++";
s2[2] = "Python";
s2[3] = "Ruby";
s2[4] = "Objective C";
s2[5] = "Java";
s2[6] = "Javascript";
s2[7] = "Lua";
s2[8] = "C#";
s2[9] = "PHP";
for ( i = 0LL; i != 10; ++i )
{
v4 = (const char **)vector_get_element_at(*(_QWORD *)(v2 + 24), (unsigned int)i);
if ( strcmp(v4[1], s2[i]) )
_assert_fail("strcmp(child->value, list_languages[i]) == 0", "test.c", 0xA4u, "test_xml");
if ( strcmp(*v4, "language") )
_assert_fail("strcmp(child->tag_name, \"language\") == 0", "test.c", 0xA5u, "test_xml");
}
return puts("PASSED Test parser xml");
}

canonical_decompiled_code:
int func2()
{
__int64 v0; // rbx
__int64 v1; // rbp
__int64 v2; // r12
__int64 i; // rbx
const char **v4; // rbp
char *s2[13]; // [rsp+0h] [rbp-68h]

v0 = (int)parse_xml_from_text(
"<programmer> <name>Kien Nguyen Trung</name> <languages> <language>C</language> <language>C++</"
"language> <language>Python</language> <language>Ruby</language> <language>Objective C</language> "
" <language>Java</language> <language>Javascript</language> <language>Lua</language> <language>C"
"#</language> <language>PHP</language> </languages> </programmer>");
if ( strcmp(*(const char **)v0, "programmer") )
_assert_fail("strcmp(elem->tag_name, \"programmer\") == 0", "test.c", 0x92u, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v0 + 24)) != 2 )
_assert_fail("vector_size(elem->children) == 2", "test.c", 0x93u, "test_xml");
v1 = vector_get_element_at(*(_QWORD *)(v0 + 24), 0LL);
if ( strcmp(*(const char **)v1, "name") )
_assert_fail("strcmp(child1->tag_name, \"name\") == 0", "test.c", 0x96u, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v1 + 24)) )
_assert_fail("vector_size(child1->children) == 0", "test.c", 0x97u, "test_xml");
if ( strcmp(*(const char **)(v1 + 8), "Kien Nguyen Trung") )
_assert_fail("strcmp(child1->value, \"Kien Nguyen Trung\") == 0", "test.c", 0x98u, "test_xml");
v2 = vector_get_element_at(*(_QWORD *)(v0 + 24), 1LL);
if ( strcmp(*(const char **)v2, "languages") )
_assert_fail("strcmp(child2->tag_name, \"languages\") == 0", "test.c", 0x9Bu, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v2 + 24)) != 10 )
_assert_fail("vector_size(child2->children) == 10", "test.c", 0x9Cu, "test_xml");
s2[0] = "C";
s2[1] = "C++";
s2[2] = "Python";
s2[3] = "Ruby";
s2[4] = "Objective C";
s2[5] = "Java";
s2[6] = "Javascript";
s2[7] = "Lua";
s2[8] = "C#";
s2[9] = "PHP";
for ( i = 0LL; i != 10; ++i )
{
v4 = (const char **)vector_get_element_at(*(_QWORD *)(v2 + 24), (unsigned int)i);
if ( strcmp(v4[1], s2[i]) )
_assert_fail("strcmp(child->value, list_languages[i]) == 0", "test.c", 0xA4u, "test_xml");
if ( strcmp(*v4, "language") )
_assert_fail("strcmp(child->tag_name, \"language\") == 0", "test.c", 0xA5u, "test_xml");
}
return puts("PASSED Test parser xml");
}

original_code:
void test_xml() {
  int i;
  char* s =
    "<programmer>    <name>Kien Nguyen Trung</name>    <languages>    <language>C</language>    <language>C++</language>    <language>Python</language>    <language>Ruby</language>    <language>Objective C</language>    <language>Java</language>    <language>Javascript</language>    <language>Lua</language>    <language>C#</language>    <language>PHP</language>    </languages>     </programmer>";
  XMLElement *elem, *child1, *child2;
  elem = (XMLElement *)parse_xml_from_text(s);
  ((void) sizeof ((strcmp(elem->tag_name, "programmer") == 0) ? 1 : 0), __extension__ ({ if (strcmp(elem->tag_name, "programmer") == 0) ; else __assert_fail ("strcmp(elem->tag_name, \"programmer\") == 0", "test.c", 146, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_size(elem->children) == 2) ? 1 : 0), __extension__ ({ if (vector_size(elem->children) == 2) ; else __assert_fail ("vector_size(elem->children) == 2", "test.c", 147, __extension__ __PRETTY_FUNCTION__); }));
  child1 = (XMLElement *)vector_get_element_at(elem->children, 0);
  ((void) sizeof ((strcmp(child1->tag_name, "name") == 0) ? 1 : 0), __extension__ ({ if (strcmp(child1->tag_name, "name") == 0) ; else __assert_fail ("strcmp(child1->tag_name, \"name\") == 0", "test.c", 150, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_size(child1->children) == 0) ? 1 : 0), __extension__ ({ if (vector_size(child1->children) == 0) ; else __assert_fail ("vector_size(child1->children) == 0", "test.c", 151, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((strcmp(child1->value, "Kien Nguyen Trung") == 0) ? 1 : 0), __extension__ ({ if (strcmp(child1->value, "Kien Nguyen Trung") == 0) ; else __assert_fail ("strcmp(child1->value, \"Kien Nguyen Trung\") == 0", "test.c", 152, __extension__ __PRETTY_FUNCTION__); }));
  child2 = (XMLElement *)vector_get_element_at(elem->children, 1);
  ((void) sizeof ((strcmp(child2->tag_name, "languages") == 0) ? 1 : 0), __extension__ ({ if (strcmp(child2->tag_name, "languages") == 0) ; else __assert_fail ("strcmp(child2->tag_name, \"languages\") == 0", "test.c", 155, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_size(child2->children) == 10) ? 1 : 0), __extension__ ({ if (vector_size(child2->children) == 10) ; else __assert_fail ("vector_size(child2->children) == 10", "test.c", 156, __extension__ __PRETTY_FUNCTION__); }));
  char* list_languages[10] = {
    "C", "C++", "Python", "Ruby", "Objective C", "Java", "Javascript", "Lua", "C#", "PHP"
  };
  for (i = 0; i < 10; i++) {
    XMLElement *child;
    child = (XMLElement *) vector_get_element_at(child2->children, i);
    ((void) sizeof ((strcmp(child->value, list_languages[i]) == 0) ? 1 : 0), __extension__ ({ if (strcmp(child->value, list_languages[i]) == 0) ; else __assert_fail ("strcmp(child->value, list_languages[i]) == 0", "test.c", 164, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((strcmp(child->tag_name, "language") == 0) ? 1 : 0), __extension__ ({ if (strcmp(child->tag_name, "language") == 0) ; else __assert_fail ("strcmp(child->tag_name, \"language\") == 0", "test.c", 165, __extension__ __PRETTY_FUNCTION__); }));
  }
  printf("PASSED Test parser xml\n");
}

canonical_original_code:
void test_xml() {
  int i;
  char *s = "<programmer>    <name>Kien Nguyen Trung</name>    <languages>    <language>C</language>    <language>C++</language>    <language>Python</language>    <language>Ruby</language>    <language>Objective C</language>    <language>Java</language>    <language>Javascript</language>    <language>Lua</language>    <language>C#</language>    <language>PHP</language>    </languages>     </programmer>";
  struct XMLElement *elem; struct XMLElement *child1; struct XMLElement *child2;
  elem = (struct XMLElement *)parse_xml_from_text(s);
  ((void) sizeof ((strcmp(elem->tag_name, "programmer") == 0) ? 1 : 0), __extension__ ({ if (strcmp(elem->tag_name, "programmer") == 0) ; else __assert_fail ("strcmp(elem->tag_name, \"programmer\") == 0", "test.c", 146, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_size(elem->children) == 2) ? 1 : 0), __extension__ ({ if (vector_size(elem->children) == 2) ; else __assert_fail ("vector_size(elem->children) == 2", "test.c", 147, __extension__ __PRETTY_FUNCTION__); }));
  child1 = (struct XMLElement *)vector_get_element_at(elem->children, 0);
  ((void) sizeof ((strcmp(child1->tag_name, "name") == 0) ? 1 : 0), __extension__ ({ if (strcmp(child1->tag_name, "name") == 0) ; else __assert_fail ("strcmp(child1->tag_name, \"name\") == 0", "test.c", 150, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_size(child1->children) == 0) ? 1 : 0), __extension__ ({ if (vector_size(child1->children) == 0) ; else __assert_fail ("vector_size(child1->children) == 0", "test.c", 151, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((strcmp(child1->value, "Kien Nguyen Trung") == 0) ? 1 : 0), __extension__ ({ if (strcmp(child1->value, "Kien Nguyen Trung") == 0) ; else __assert_fail ("strcmp(child1->value, \"Kien Nguyen Trung\") == 0", "test.c", 152, __extension__ __PRETTY_FUNCTION__); }));
  child2 = (struct XMLElement *)vector_get_element_at(elem->children, 1);
  ((void) sizeof ((strcmp(child2->tag_name, "languages") == 0) ? 1 : 0), __extension__ ({ if (strcmp(child2->tag_name, "languages") == 0) ; else __assert_fail ("strcmp(child2->tag_name, \"languages\") == 0", "test.c", 155, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((vector_size(child2->children) == 10) ? 1 : 0), __extension__ ({ if (vector_size(child2->children) == 10) ; else __assert_fail ("vector_size(child2->children) == 10", "test.c", 156, __extension__ __PRETTY_FUNCTION__); }));
  char *list_languages[10] = {
    "C", "C++", "Python", "Ruby", "Objective C", "Java", "Javascript", "Lua", "C#", "PHP"
  };
  for (i = 0; i < 10; i++) {
    struct XMLElement *child;
    child = (struct XMLElement *) vector_get_element_at(child2->children, i);
    ((void) sizeof ((strcmp(child->value, list_languages[i]) == 0) ? 1 : 0), __extension__ ({ if (strcmp(child->value, list_languages[i]) == 0) ; else __assert_fail ("strcmp(child->value, list_languages[i]) == 0", "test.c", 164, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((strcmp(child->tag_name, "language") == 0) ? 1 : 0), __extension__ ({ if (strcmp(child->tag_name, "language") == 0) ; else __assert_fail ("strcmp(child->tag_name, \"language\") == 0", "test.c", 165, __extension__ __PRETTY_FUNCTION__); }));
  }
  printf("PASSED Test parser xml\n");
}

variable_types:
s
char *

user_defined_types: struct Vector { int _capacity; int _size; void **_data; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
test_vector();
test_vector2();
test_xml();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func0();
func1();
func2();
return 0;
}

original_code:
int main(int argc, char** argv) {
  test_vector();
  test_vector2();
  test_xml();
  return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
  test_vector();
  test_vector2();
  test_xml();
  return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
void __fastcall vector_validated(__int64 a1)
{
if ( !a1 )
_assert_fail("v != NULL && \"vector is NULL\"", "simple_vector.c", 7u, "vector_validated");
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
if ( !a1 )
_assert_fail("v != NULL && \"vector is NULL\"", "simple_vector.c", 7u, "vector_validated");
}

original_code:
static void vector_validated(Vector *v) {
  ((void) sizeof ((v != ((void *)0) && "vector is NULL") ? 1 : 0), __extension__ ({ if (v != ((void *)0) && "vector is NULL") ; else __assert_fail ("v != NULL && \"vector is NULL\"", "simple_vector.c", 7, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
static void vector_validated(struct Vector *v) {
  ((void) sizeof ((v != ((void *)0) && "vector is NULL") ? 1 : 0), __extension__ ({ if (v != ((void *)0) && "vector is NULL") ; else __assert_fail ("v != NULL && \"vector is NULL\"", "simple_vector.c", 7, __extension__ __PRETTY_FUNCTION__); }));
}


decompiled_code:
_DWORD *vector_create()
{
_DWORD *v0; // rbx

v0 = malloc(0x10uLL);
*v0 = 8;
v0[1] = 0;
*((_QWORD *)v0 + 1) = calloc(8uLL, 8uLL);
return v0;
}

canonical_decompiled_code:
_DWORD *func1()
{
_DWORD *v0; // rbx

v0 = malloc(0x10uLL);
*v0 = 8;
v0[1] = 0;
*((_QWORD *)v0 + 1) = calloc(8uLL, 8uLL);
return v0;
}

original_code:
Vector* vector_create(Vector *v) {
  v = malloc(sizeof(Vector));
  v->_capacity = 8;
  v->_size = 0;
  v->_data = calloc(v->_capacity, sizeof(void*));
  return v;
}

canonical_original_code:
struct Vector *vector_create(struct Vector *v) {
  v = malloc(sizeof(Vector));
  v->_capacity = 8;
  v->_size = 0;
  v->_data = calloc(v->_capacity, sizeof(void *));
  return v;
}

variable_types:
v
struct Vector *

return_type: struct Vector { int _capacity; int _size; void **_data; } *


decompiled_code:
void __fastcall vector_release(void *ptr)
{
vector_validated((__int64)ptr);
free(*((void **)ptr + 1));
free(ptr);
}

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

original_code:
void vector_release(Vector *v) {
  vector_validated(v);
  free(v->_data);
  free(v);
}

canonical_original_code:
void vector_release(struct Vector *v) {
  vector_validated(v);
  free(v->_data);
  free(v);
}


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

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

original_code:
int vector_size(Vector *v) {
  vector_validated(v);
  return v->_size;
}

canonical_original_code:
int vector_size(struct Vector *v) {
  vector_validated(v);
  return v->_size;
}


decompiled_code:
__int64 __fastcall vector_get_element_at(__int64 a1, int a2)
{
vector_validated(a1);
if ( a2 < 0 || *(_DWORD *)(a1 + 4) <= a2 )
_assert_fail(
"index >= 0 && index < v->_size && \"index of out range\"",
"simple_vector.c",
0x32u,
"vector_get_element_at");
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
func0(a1);
if ( a2 < 0 || *(_DWORD *)(a1 + 4) <= a2 )
_assert_fail(
"index >= 0 && index < v->_size && \"index of out range\"",
"simple_vector.c",
0x32u,
"vector_get_element_at");
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2);
}

original_code:
void* vector_get_element_at(Vector *v, int index) {
  vector_validated(v);
  ((void) sizeof ((index >= 0 && index < v->_size && "index of out range") ? 1 : 0), __extension__ ({ if (index >= 0 && index < v->_size && "index of out range") ; else __assert_fail ("index >= 0 && index < v->_size && \"index of out range\"", "simple_vector.c", 50, __extension__ __PRETTY_FUNCTION__); }));
  return (void*) v->_data[index];
}

canonical_original_code:
void *vector_get_element_at(struct Vector *v, int index) {
  vector_validated(v);
  ((void) sizeof ((index >= 0 && index < v->_size && "index of out range") ? 1 : 0), __extension__ ({ if (index >= 0 && index < v->_size && "index of out range") ; else __assert_fail ("index >= 0 && index < v->_size && \"index of out range\"", "simple_vector.c", 50, __extension__ __PRETTY_FUNCTION__); }));
  return (void *) v->_data[index];
}

variable_types: index int

return_type: void *