fillseed

decompiled_code:
void __fastcall fillseed(__int64 a1, unsigned int a2)
{
_QWORD *v2; // r12
_DWORD *v3; // rbp
_DWORD *v4; // rbx
int v5; // er13
int v6; // ebx
__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);
v3 = v2;
*v2 = a1;
*((_DWORD *)v2 + 2) = a2;
while ( 1 )
{
v5 = *v3;
v6 = v3[1];
HIDWORD(v7) = HIDWORD(*(_QWORD *)v3);
LODWORD(v7) = *v3 + 1;
v9 = v3[2];
if ( !(unsigned int)getred(v7, v9) )
v2 = creatpl((__int64)v2, v7, v9);
LODWORD(v7) = v5 - 1;
if ( !(unsigned int)getred(v7, v9) )
v2 = creatpl((__int64)v2, v7, v9);
LODWORD(v8) = v5;
HIDWORD(v8) = v6 + 1;
if ( !(unsigned int)getred(v8, v9) )
v2 = creatpl((__int64)v2, v8, v9);
HIDWORD(v8) = v6 - 1;
if ( !(unsigned int)getred(v8, v9) )
v2 = creatpl((__int64)v2, v8, v9);
v4 = (_DWORD *)*((_QWORD *)v3 + 2);
free(v3);
if ( !v4 )
break;
v3 = v4;
}
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, unsigned int a2)
{
_QWORD *v2; // r12
_DWORD *v3; // rbp
_DWORD *v4; // rbx
int v5; // er13
int v6; // ebx
__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);
v3 = v2;
*v2 = a1;
*((_DWORD *)v2 + 2) = a2;
while ( 1 )
{
v5 = *v3;
v6 = v3[1];
HIDWORD(v7) = HIDWORD(*(_QWORD *)v3);
LODWORD(v7) = *v3 + 1;
v9 = v3[2];
if ( !(unsigned int)getred(v7, v9) )
v2 = creatpl((__int64)v2, v7, v9);
LODWORD(v7) = v5 - 1;
if ( !(unsigned int)getred(v7, v9) )
v2 = creatpl((__int64)v2, v7, v9);
LODWORD(v8) = v5;
HIDWORD(v8) = v6 + 1;
if ( !(unsigned int)getred(v8, v9) )
v2 = creatpl((__int64)v2, v8, v9);
HIDWORD(v8) = v6 - 1;
if ( !(unsigned int)getred(v8, v9) )
v2 = creatpl((__int64)v2, v8, v9);
v4 = (_DWORD *)*((_QWORD *)v3 + 2);
free(v3);
if ( !v4 )
break;
v3 = 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

repo: kidxin/Graphics-Experiment

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 *

return_type: void


drawcircle

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

v5 = a3;
v6 = 2 * (1 - a3);
result = glColor3f(*(float *)&a4, *((float *)&a4 + 1), a5);
if ( v5 >= 0 )
{
v8 = 0;
while ( 1 )
{
draw8p(a1, a2, __PAIR64__(v5, v8), v10);
if ( v6 >= 0 )
break;
++v8;
result = (unsigned int)(v6 + 2 * v8);
if ( 2 * (v5 + v6) <= 1 )
{
v6 = result + 1;
LABEL_6:
if ( v8 > v5 )
return result;
}
else
{
--v5;
result = (unsigned int)(result - 2 * v5);
v6 = result + 2;
if ( v8 > v5 )
return result;
}
}
--v5;
if ( v6 )
{
v9 = 2 * v5;
result = (unsigned int)(2 * (v6 - v8));
if ( (int)result <= 1 )
{
++v8;
v6 = v6 + 2 * v8 - v9 + 2;
}
else
{
v6 = v6 - v9 + 1;
}
}
else
{
result = (unsigned int)(++v8 - v5);
v6 = 2 * result + 2;
}
goto LABEL_6;
}
return result;
}

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

v5 = a3;
v6 = 2 * (1 - a3);
result = glColor3f(*(float *)&a4, *((float *)&a4 + 1), a5);
if ( v5 >= 0 )
{
v8 = 0;
while ( 1 )
{
draw8p(a1, a2, __PAIR64__(v5, v8), v10);
if ( v6 >= 0 )
break;
++v8;
result = (unsigned int)(v6 + 2 * v8);
if ( 2 * (v5 + v6) <= 1 )
{
v6 = result + 1;
LABEL_6:
if ( v8 > v5 )
return result;
}
else
{
--v5;
result = (unsigned int)(result - 2 * v5);
v6 = result + 2;
if ( v8 > v5 )
return result;
}
}
--v5;
if ( v6 )
{
v9 = 2 * v5;
result = (unsigned int)(2 * (v6 - v8));
if ( (int)result <= 1 )
{
++v8;
v6 = v6 + 2 * v8 - v9 + 2;
}
else
{
v6 = v6 - v9 + 1;
}
}
else
{
result = (unsigned int)(++v8 - v5);
v6 = 2 * result + 2;
}
goto LABEL_6;
}
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:
c
struct colour { float r; }

variable_types:
now
struct point { int x; }

variable_types: diff int

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


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
__int64 v2; // rax
__int64 v3; // rbp
bool v4; // cc
int v5; // edx

readint(&con_num);
result = (unsigned int)con_num;
if ( con_num > 0 )
{
v1 = 0;
do
{
v2 = v1++;
v3 = 3 * v2;
result = readpoint();
v4 = con_num <= v1;
*(__int64 *)((char *)&control + 4 * v3) = result;
*((_DWORD *)&control + v3 + 2) = v5;
}
while ( !v4 );
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
int v1; // ebx
__int64 v2; // rax
__int64 v3; // rbp
bool v4; // cc
int v5; // edx

readint(&con_num);
result = (unsigned int)con_num;
if ( con_num > 0 )
{
v1 = 0;
do
{
v2 = v1++;
v3 = 3 * v2;
result = readpoint();
v4 = con_num <= v1;
*(__int64 *)((char *)&control + 4 * v3) = result;
*((_DWORD *)&control + v3 + 2) = v5;
}
while ( !v4 );
}
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()
{
int v0; // er14
__int64 result; // rax
int v2; // ebx
__int64 v3; // rax
__int64 v4; // rbp
bool v5; // cc
int v6; // edx

v0 = 0;
readint(&m);
result = readint(&n);
if ( m > 0 )
{
do
{
v2 = 0;
result = (unsigned int)n;
if ( n > 0 )
{
do
{
v3 = v2++;
v4 = 120LL * v0 + 12 * v3;
result = readpoint();
v5 = n <= v2;
*(__int64 *)((char *)&con2d + v4) = result;
*(_DWORD *)((char *)&con2d + v4 + 8) = v6;
}
while ( !v5 );
}
++v0;
}
while ( m > v0 );
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // er14
__int64 result; // rax
int v2; // ebx
__int64 v3; // rax
__int64 v4; // rbp
bool v5; // cc
int v6; // edx

v0 = 0;
readint(&m);
result = readint(&n);
if ( m > 0 )
{
do
{
v2 = 0;
result = (unsigned int)n;
if ( n > 0 )
{
do
{
v3 = v2++;
v4 = 120LL * v0 + 12 * v3;
result = readpoint();
v5 = n <= v2;
*(__int64 *)((char *)&con2d + v4) = result;
*(_DWORD *)((char *)&con2d + v4 + 8) = v6;
}
while ( !v5 );
}
++v0;
}
while ( m > v0 );
}
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
__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 += 2;
v3 += 12LL;
*(v1 - 2) = (double)*(int *)(v3 - 16);
*(v1 - 1) = (double)*(int *)(v3 - 12);
}
while ( v1 != v4 );
}
return separate(v2);
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // ebx
double *v1; // rax
double *v2; // rdi
__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 += 2;
v3 += 12LL;
*(v1 - 2) = (double)*(int *)(v3 - 16);
*(v1 - 1) = (double)*(int *)(v3 - 12);
}
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]

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


readshadow

decompiled_code:
void __fastcall readshadow(double a1, float a2)
{
__int64 v2; // r12
int v3; // ebp
__int64 v4; // rbx
__int64 v5; // rdi
__int64 v6; // rdx
double v7; // xmm0_8
bool v8; // cc

readint(&pla_num);
if ( pla_num > 0 )
{
v2 = (unsigned int)((_DWORD)&proj_list + 16);
v3 = 0;
do
{
v4 = v3++;
v4 *= 2232LL;
v5 = v2;
v2 += 2232LL;
*(__int64 *)((char *)&proj_list + v4) = readplane();
*(__int64 *)((char *)&proj_list + v4 + 8) = v6;
readpolygon(v5);
v7 = readcolor();
v8 = pla_num <= v3;
*(double *)((char *)&proj_list + v4 + 2220) = v7;
*(float *)((char *)&proj_list + v4 + 2228) = a2;
}
while ( !v8 );
}
}

canonical_decompiled_code:
void __fastcall func0(double a1, float a2)
{
__int64 v2; // r12
int v3; // ebp
__int64 v4; // rbx
__int64 v5; // rdi
__int64 v6; // rdx
double v7; // xmm0_8
bool v8; // cc

readint(&pla_num);
if ( pla_num > 0 )
{
v2 = (unsigned int)((_DWORD)&proj_list + 16);
v3 = 0;
do
{
v4 = v3++;
v4 *= 2232LL;
v5 = v2;
v2 += 2232LL;
*(__int64 *)((char *)&proj_list + v4) = readplane();
*(__int64 *)((char *)&proj_list + v4 + 8) = v6;
readpolygon(v5);
v7 = readcolor();
v8 = pla_num <= v3;
*(double *)((char *)&proj_list + v4 + 2220) = v7;
*(float *)((char *)&proj_list + v4 + 2228) = a2;
}
while ( !v8 );
}
}

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 v2; // er12
unsigned int i; // ebp
double v4; // xmm1_8
double v5; // xmm2_8
unsigned int v6; // er14
unsigned __int64 v7; // rbx
int v8; // er13
double v9; // r15
double v10; // xmm3_8
int v11; // eax
double v12; // xmm0_8
__int64 v13; // rsi
__int64 result; // rax
unsigned int v15; // [rsp+1Ch] [rbp-3Ch]

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

canonical_decompiled_code:
__int64 __fastcall func1(double a1, float a2)
{
unsigned int v2; // er12
unsigned int i; // ebp
double v4; // xmm1_8
double v5; // xmm2_8
unsigned int v6; // er14
unsigned __int64 v7; // rbx
int v8; // er13
double v9; // r15
double v10; // xmm3_8
int v11; // eax
double v12; // xmm0_8
__int64 v13; // rsi
__int64 result; // rax
unsigned int v15; // [rsp+1Ch] [rbp-3Ch]

v2 = -300;
func0(a1, a2);
do
{
for ( i = -300; i != 301; ++i )
{
*(_QWORD *)&v4 = (unsigned int)black[1];
*(_QWORD *)&v5 = (unsigned int)black[2];
v6 = _mm_cvtsi128_si32((__m128i)(unsigned int)black[0]);
if ( pla_num > 0 )
{
v7 = (unsigned int)((_DWORD)&proj_list + 16);
v8 = 0;
v9 = *(double *)&LC0;
do
{
if ( *(_DWORD *)(v7 - 8) )
{
*(_QWORD *)&v4 = LODWORD(v4);
*(_QWORD *)&v5 = LODWORD(v5);
if ( (unsigned int)in_poly(v7, __PAIR64__(i, v2), v15) )
{
v10 = (double)*(int *)(v7 - 8);
v11 = *(_DWORD *)(v7 - 4) - v2 * *(_DWORD *)(v7 - 16) - i * *(_DWORD *)(v7 - 12);
v12 = (double)v11 / v10;
if ( v12 >= 0.0 && v9 > v12 )
{
*(_QWORD *)&v4 = *(unsigned int *)(v7 + 2208);
v9 = (double)v11 / v10;
*(_QWORD *)&v5 = *(unsigned int *)(v7 + 2212);
v6 = _mm_cvtsi128_si32((__m128i)*(unsigned int *)(v7 + 2204));
}
}
}
++v8;
v7 += 2232LL;
}
while ( pla_num > v8 );
}
glColor3f(*(double *)_mm_cvtsi32_si128(v6).m128i_i64, v4, v5);
v13 = i;
result = glVertex2i(v2, v13);
}
++v2;
}
while ( v2 != 301 );
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
int *v2; // rbx
int *v3; // rbp
unsigned int v4; // ebx
int v5; // ebp
int v7; // [rsp+4h] [rbp-44h] BYREF
int v8; // [rsp+8h] [rbp-40h] BYREF
int v9[15]; // [rsp+Ch] [rbp-3Ch] BYREF

v7 = 10;
v8 = 20;
v9[0] = 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, &v8);
if ( (unsigned int)vector_size(v1) != 2 )
_assert_fail("vector_size(v) == 2 && \"insert element FAILED\"", "test.c", 0x16u, "test_vector");
v2 = (int *)vector_get_element_at(v1, 0LL);
if ( v2 != &v7 )
_assert_fail("vector_get_element_at(v, 0) == &a && \"insert element FAILED\"", "test.c", 0x17u, "test_vector");
v3 = (int *)vector_get_element_at(v1, 1LL);
if ( v3 != &v8 )
_assert_fail("vector_get_element_at(v, 1) == &b && \"insert element FAILED\"", "test.c", 0x18u, "test_vector");
vector_push_front(v1, v2);
vector_push_front(v1, v3);
vector_push_front(v1, v9);
if ( (unsigned int)vector_size(v1) != 5 )
_assert_fail("vector_size(v) == 5", "test.c", 0x1Eu, "test_vector");
if ( v9 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x1Fu, "test_vector");
if ( v3 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x20u, "test_vector");
if ( v2 != (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 ( &v8 != (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, v9, 2LL);
if ( (unsigned int)vector_size(v1) != 6 )
_assert_fail("vector_size(v) == 6", "test.c", 0x27u, "test_vector");
if ( v9 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x28u, "test_vector");
if ( &v8 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x29u, "test_vector");
if ( v9 != (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 ( &v8 != (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);
v4 = vector_size(v1);
if ( v4 != 5 )
_assert_fail("vector_size(v) == 5", "test.c", 0x31u, "test_vector");
if ( v9 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x32u, "test_vector");
if ( &v8 != (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 ( &v8 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &b", "test.c", 0x36u, "test_vector");
v5 = 100;
do
{
vector_push_back(v1, &v7);
--v5;
}
while ( v5 );
if ( (unsigned int)vector_size(v1) != 105 )
_assert_fail("vector_size(v) == 105", "test.c", 0x3Cu, "test_vector");
if ( v9 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x3Du, "test_vector");
if ( &v8 != (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 ( &v8 != (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, v4) )
_assert_fail("vector_get_element_at(v, i) == &a", "test.c", 0x43u, "test_vector");
++v4;
}
while ( v4 != 105 );
if ( &v7 != (int *)vector_top_back(v1) )
_assert_fail("vector_top_back(v) == &a", "test.c", 0x47u, "test_vector");
if ( v9 != (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
int *v2; // rbx
int *v3; // rbp
unsigned int v4; // ebx
int v5; // ebp
int v7; // [rsp+4h] [rbp-44h] BYREF
int v8; // [rsp+8h] [rbp-40h] BYREF
int v9[15]; // [rsp+Ch] [rbp-3Ch] BYREF

v7 = 10;
v8 = 20;
v9[0] = 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, &v8);
if ( (unsigned int)vector_size(v1) != 2 )
_assert_fail("vector_size(v) == 2 && \"insert element FAILED\"", "test.c", 0x16u, "test_vector");
v2 = (int *)vector_get_element_at(v1, 0LL);
if ( v2 != &v7 )
_assert_fail("vector_get_element_at(v, 0) == &a && \"insert element FAILED\"", "test.c", 0x17u, "test_vector");
v3 = (int *)vector_get_element_at(v1, 1LL);
if ( v3 != &v8 )
_assert_fail("vector_get_element_at(v, 1) == &b && \"insert element FAILED\"", "test.c", 0x18u, "test_vector");
vector_push_front(v1, v2);
vector_push_front(v1, v3);
vector_push_front(v1, v9);
if ( (unsigned int)vector_size(v1) != 5 )
_assert_fail("vector_size(v) == 5", "test.c", 0x1Eu, "test_vector");
if ( v9 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x1Fu, "test_vector");
if ( v3 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x20u, "test_vector");
if ( v2 != (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 ( &v8 != (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, v9, 2LL);
if ( (unsigned int)vector_size(v1) != 6 )
_assert_fail("vector_size(v) == 6", "test.c", 0x27u, "test_vector");
if ( v9 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x28u, "test_vector");
if ( &v8 != (int *)vector_get_element_at(v1, 1LL) )
_assert_fail("vector_get_element_at(v, 1) == &b", "test.c", 0x29u, "test_vector");
if ( v9 != (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 ( &v8 != (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);
v4 = vector_size(v1);
if ( v4 != 5 )
_assert_fail("vector_size(v) == 5", "test.c", 0x31u, "test_vector");
if ( v9 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x32u, "test_vector");
if ( &v8 != (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 ( &v8 != (int *)vector_get_element_at(v1, 4LL) )
_assert_fail("vector_get_element_at(v, 4) == &b", "test.c", 0x36u, "test_vector");
v5 = 100;
do
{
vector_push_back(v1, &v7);
--v5;
}
while ( v5 );
if ( (unsigned int)vector_size(v1) != 105 )
_assert_fail("vector_size(v) == 105", "test.c", 0x3Cu, "test_vector");
if ( v9 != (int *)vector_get_element_at(v1, 0LL) )
_assert_fail("vector_get_element_at(v, 0) == &c", "test.c", 0x3Du, "test_vector");
if ( &v8 != (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 ( &v8 != (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, v4) )
_assert_fail("vector_get_element_at(v, i) == &a", "test.c", 0x43u, "test_vector");
++v4;
}
while ( v4 != 105 );
if ( &v7 != (int *)vector_top_back(v1) )
_assert_fail("vector_top_back(v) == &a", "test.c", 0x47u, "test_vector");
if ( v9 != (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
unsigned int v1; // ebx
__int64 v2; // r13
char *v3; // r12
char *v4; // r14
__int64 v5; // rdx
unsigned int i; // ebx
char *v7; // r12
char *v8; // rbp
const char **v9; // r14
int j; // ebx
__int64 v11; // rsi
__int64 v12; // rax

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

canonical_decompiled_code:
int __fastcall func1()
{
__int64 v0; // rbp
unsigned int v1; // ebx
__int64 v2; // r13
char *v3; // r12
char *v4; // r14
__int64 v5; // rdx
unsigned int i; // ebx
char *v7; // r12
char *v8; // rbp
const char **v9; // r14
int j; // ebx
__int64 v11; // rsi
__int64 v12; // rax

v1 = 0;
v2 = vector_create(0LL);
do
{
v3 = (char *)malloc(0x1EuLL);
v4 = (char *)malloc(0x1EuLL);
sprintf(v3, "tag %d", v1);
v5 = v1++;
sprintf(v4, "value %d", v5);
v0 = XMLElement_create(v0, v3, v4);
vector_push_back(v2, v0);
}
while ( v1 != 100000 );
for ( i = 0; (int)vector_size(v2) > (int)i; ++i )
{
v7 = (char *)malloc(0x1EuLL);
v8 = (char *)malloc(0x1EuLL);
sprintf(v7, "tag %d", i);
sprintf(v8, "value %d", i);
v9 = (const char **)vector_get_element_at(v2, i);
if ( strcmp(*v9, v7) )
_assert_fail("strcmp(e->tag_name, tag_name) == 0", "test.c", 0x6Cu, "test_vector2");
if ( strcmp(v9[1], v8) )
_assert_fail("strcmp(e->value, value) == 0", "test.c", 0x6Du, "test_vector2");
free(v7);
free(v8);
}
for ( j = 0; (int)vector_size(v2) > j; ++j )
{
v11 = (unsigned int)j;
v12 = vector_get_element_at(v2, v11);
XMLElement_release(v12);
}
vector_release(v2);
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()
{
int v0; // eax
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rbx
const char **v7; // rbp
char *s2[13]; // [rsp+0h] [rbp-68h]

v0 = parse_xml_from_text(
"<programmer> <name>Kien Nguyen Trung</name> <languages> <language>C</language> <language>C++</langu"
"age> <language>Python</language> <language>Ruby</language> <language>Objective C</language> <langua"
"ge>Java</language> <language>Javascript</language> <language>Lua</language> <language>C#</language> "
" <language>PHP</language> </languages> </programmer>");
v1 = v0;
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 *)((char *)&loc_12 + v0 + 6)) != 2 )
_assert_fail("vector_size(elem->children) == 2", "test.c", 0x93u, "test_xml");
v2 = vector_get_element_at(*(_QWORD *)(v1 + 24), 0LL);
v3 = v2;
if ( strcmp(*(const char **)v2, "name") )
_assert_fail("strcmp(child1->tag_name, \"name\") == 0", "test.c", 0x96u, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v2 + 24)) )
_assert_fail("vector_size(child1->children) == 0", "test.c", 0x97u, "test_xml");
if ( strcmp(*(const char **)(v3 + 8), "Kien Nguyen Trung") )
_assert_fail("strcmp(child1->value, \"Kien Nguyen Trung\") == 0", "test.c", 0x98u, "test_xml");
v4 = vector_get_element_at(*(_QWORD *)(v1 + 24), 1LL);
v5 = v4;
if ( strcmp(*(const char **)v4, "languages") )
_assert_fail("strcmp(child2->tag_name, \"languages\") == 0", "test.c", 0x9Bu, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v4 + 24)) != 10 )
_assert_fail("vector_size(child2->children) == 10", "test.c", 0x9Cu, "test_xml");
s2[0] = "C";
v6 = 0LL;
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";
do
{
v7 = (const char **)vector_get_element_at(*(_QWORD *)(v5 + 24), (unsigned int)v6);
if ( strcmp(v7[1], s2[v6]) )
_assert_fail("strcmp(child->value, list_languages[i]) == 0", "test.c", 0xA4u, "test_xml");
if ( strcmp(*v7, "language") )
_assert_fail("strcmp(child->tag_name, \"language\") == 0", "test.c", 0xA5u, "test_xml");
++v6;
}
while ( v6 != 10 );
return puts("PASSED Test parser xml");
}

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

v0 = parse_xml_from_text(
"<programmer> <name>Kien Nguyen Trung</name> <languages> <language>C</language> <language>C++</langu"
"age> <language>Python</language> <language>Ruby</language> <language>Objective C</language> <langua"
"ge>Java</language> <language>Javascript</language> <language>Lua</language> <language>C#</language> "
" <language>PHP</language> </languages> </programmer>");
v1 = v0;
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 *)((char *)&loc_12 + v0 + 6)) != 2 )
_assert_fail("vector_size(elem->children) == 2", "test.c", 0x93u, "test_xml");
v2 = vector_get_element_at(*(_QWORD *)(v1 + 24), 0LL);
v3 = v2;
if ( strcmp(*(const char **)v2, "name") )
_assert_fail("strcmp(child1->tag_name, \"name\") == 0", "test.c", 0x96u, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v2 + 24)) )
_assert_fail("vector_size(child1->children) == 0", "test.c", 0x97u, "test_xml");
if ( strcmp(*(const char **)(v3 + 8), "Kien Nguyen Trung") )
_assert_fail("strcmp(child1->value, \"Kien Nguyen Trung\") == 0", "test.c", 0x98u, "test_xml");
v4 = vector_get_element_at(*(_QWORD *)(v1 + 24), 1LL);
v5 = v4;
if ( strcmp(*(const char **)v4, "languages") )
_assert_fail("strcmp(child2->tag_name, \"languages\") == 0", "test.c", 0x9Bu, "test_xml");
if ( (unsigned int)vector_size(*(_QWORD *)(v4 + 24)) != 10 )
_assert_fail("vector_size(child2->children) == 10", "test.c", 0x9Cu, "test_xml");
s2[0] = "C";
v6 = 0LL;
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";
do
{
v7 = (const char **)vector_get_element_at(*(_QWORD *)(v5 + 24), (unsigned int)v6);
if ( strcmp(v7[1], s2[v6]) )
_assert_fail("strcmp(child->value, list_languages[i]) == 0", "test.c", 0xA4u, "test_xml");
if ( strcmp(*v7, "language") )
_assert_fail("strcmp(child->tag_name, \"language\") == 0", "test.c", 0xA5u, "test_xml");
++v6;
}
while ( v6 != 10 );
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

canonical_name: 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 **

return_type: int


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:
_QWORD *vector_create()
{
_QWORD *v0; // rax
_QWORD *v1; // r12

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

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *v0; // rax
_QWORD *v1; // r12

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

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 *


decompiled_code:
__int64 __fastcall vector_top_back(__int64 a1)
{
int v1; // eax

if ( !*(_DWORD *)(a1 + 4) )
return 0LL;
v1 = vector_size(a1);
return vector_get_element_at(a1, v1 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v1; // eax

if ( !*(_DWORD *)(a1 + 4) )
return 0LL;
v1 = func3(a1);
return func4(a1, v1 - 1);
}

original_code:
void* vector_top_back(Vector *v) {
  if (v->_size == 0)
    return ((void *)0);
  return vector_get_element_at(v, vector_size(v) - 1);
}

canonical_original_code:
void *vector_top_back(struct Vector *v) {
  if (v->_size == 0)
    return ((void *)0);
  return vector_get_element_at(v, vector_size(v) - 1);
}


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

if ( *(_DWORD *)(a1 + 4) )
result = vector_get_element_at(a1, 0);
else
result = 0LL;
return result;
}

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

if ( *(_DWORD *)(a1 + 4) )
result = func4(a1, 0);
else
result = 0LL;
return result;
}

original_code:
void* vector_top_front(Vector *v) {
  if (v->_size == 0)
    return ((void *)0);
  return vector_get_element_at(v, 0);
}

canonical_original_code:
void *vector_top_front(struct Vector *v) {
  if (v->_size == 0)
    return ((void *)0);
  return vector_get_element_at(v, 0);
}


original_code:
int vector_insert_at_index(Vector *v, void* elem, 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", 107, __extension__ __PRETTY_FUNCTION__); }));
  int i;
  if (v->_size == v->_capacity) {
    v->_capacity = v->_capacity * 2;
    void** old_data = v->_data;
    v->_data = calloc(v->_capacity, sizeof(void*));
    for (i = 0; i < v->_size; ++i)
      v->_data[i] = old_data[i];
    free(old_data);
  }
  v->_size++;
  for (i = v->_size; i > index; --i) {
    v->_data[i] = v->_data[i - 1];
  }
  v->_data[index] = elem;
  return 1;
}

canonical_original_code:
int vector_insert_at_index(struct Vector *v, void *elem, 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", 107, __extension__ __PRETTY_FUNCTION__); }));
  int i;
  if (v->_size == v->_capacity) {
    v->_capacity = v->_capacity * 2;
    void **old_data = v->_data;
    v->_data = calloc(v->_capacity, sizeof(void *));
    for (i = 0; i < v->_size; ++i)
      v->_data[i] = old_data[i];
    free(old_data);
  }
  v->_size++;
  for (i = v->_size; i > index; --i) {
    v->_data[i] = v->_data[i - 1];
  }
  v->_data[index] = elem;
  return 1;
}

variable_types:
elem
void *


decompiled_code:
__int64 __fastcall vector_push_back(__int64 a1, __int64 a2)
{
return vector_insert_at_index(a1, a2, *(_DWORD *)(a1 + 4));
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
return func7(a1, a2, *(_DWORD *)(a1 + 4));
}

original_code:
int vector_push_back(Vector *v, void* elem) {
  return vector_insert_at_index(v, elem, v->_size);
}

canonical_original_code:
int vector_push_back(struct Vector *v, void *elem) {
  return vector_insert_at_index(v, elem, v->_size);
}


decompiled_code:
__int64 __fastcall vector_push_front(__int64 a1, __int64 a2)
{
return vector_insert_at_index(a1, a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
return func7(a1, a2, 0);
}

original_code:
int vector_push_front(Vector *v, void* elem) {
  return vector_insert_at_index(v, elem, 0);
}

canonical_original_code:
int vector_push_front(struct Vector *v, void *elem) {
  return vector_insert_at_index(v, elem, 0);
}


decompiled_code:
__int64 __fastcall vector_remove_element_at_index(__int64 a1, int a2)
{
int v2; // er8
__int64 v3; // rdx
__int64 v4; // rax
__int64 v5; // r9
__int64 result; // rax

vector_validated(a1);
if ( a2 < 0 || (v2 = *(_DWORD *)(a1 + 4), v2 <= a2) )
_assert_fail(
"index >= 0 && index < v->_size && \"index of out range\"",
"simple_vector.c",
0x86u,
"vector_remove_element_at_index");
v3 = *(_QWORD *)(a1 + 8);
v4 = 8LL * a2;
v5 = *(_QWORD *)(v3 + v4);
while ( 1 )
{
*(_QWORD *)(v3 + v4) = *(_QWORD *)(v3 + v4 + 8);
if ( v4 == 8 * (a2 + (unsigned __int64)(unsigned int)(~a2 + v2)) )
break;
v3 = *(_QWORD *)(a1 + 8);
v4 += 8LL;
}
result = v5;
*(_DWORD *)(a1 + 4) = v2 - 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2)
{
int v2; // er8
__int64 v3; // rdx
__int64 v4; // rax
__int64 v5; // r9
__int64 result; // rax

func0(a1);
if ( a2 < 0 || (v2 = *(_DWORD *)(a1 + 4), v2 <= a2) )
_assert_fail(
"index >= 0 && index < v->_size && \"index of out range\"",
"simple_vector.c",
0x86u,
"vector_remove_element_at_index");
v3 = *(_QWORD *)(a1 + 8);
v4 = 8LL * a2;
v5 = *(_QWORD *)(v3 + v4);
while ( 1 )
{
*(_QWORD *)(v3 + v4) = *(_QWORD *)(v3 + v4 + 8);
if ( v4 == 8 * (a2 + (unsigned __int64)(unsigned int)(~a2 + v2)) )
break;
v3 = *(_QWORD *)(a1 + 8);
v4 += 8LL;
}
result = v5;
*(_DWORD *)(a1 + 4) = v2 - 1;
return result;
}

original_code:
void* vector_remove_element_at_index(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", 134, __extension__ __PRETTY_FUNCTION__); }));
  int i;
  void* elem;
  elem = v->_data[index];
  for (i = index; i < v->_size; ++i) {
    v->_data[i] = v->_data[i + 1];
  }
  v->_size--;
  return elem;
}

canonical_original_code:
void *vector_remove_element_at_index(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", 134, __extension__ __PRETTY_FUNCTION__); }));
  int i;
  void *elem;
  elem = v->_data[index];
  for (i = index; i < v->_size; ++i) {
    v->_data[i] = v->_data[i + 1];
  }
  v->_size--;
  return elem;
}


decompiled_code:
__int64 __fastcall vector_pop_back(__int64 a1)
{
return vector_remove_element_at_index(a1, *(_DWORD *)(a1 + 4) - 1);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return func10(a1, *(_DWORD *)(a1 + 4) - 1);
}

original_code:
void* vector_pop_back(Vector *v) {
  return vector_remove_element_at_index(v, v->_size - 1);
}

canonical_original_code:
void *vector_pop_back(struct Vector *v) {
  return vector_remove_element_at_index(v, v->_size - 1);
}


decompiled_code:
__int64 __fastcall vector_pop_front(__int64 a1)
{
return vector_remove_element_at_index(a1, 0);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return func10(a1, 0);
}

original_code:
void* vector_pop_front(Vector *v) {
  return vector_remove_element_at_index(v, 0);
}

canonical_original_code:
void *vector_pop_front(struct Vector *v) {
  return vector_remove_element_at_index(v, 0);
}


decompiled_code:
__int64 __fastcall vector_index_of_with_start(__int64 a1, __int64 a2, int a3)
{
int v4; // eax
__int64 v5; // rdx

vector_validated(a1);
v4 = *(_DWORD *)(a1 + 4);
if ( a3 >= v4 )
return 0xFFFFFFFFLL;
v5 = a3;
while ( *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v5) != a2 )
{
if ( v4 <= (int)++v5 )
return 0xFFFFFFFFLL;
}
return (unsigned int)v5;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, int a3)
{
int v4; // eax
__int64 v5; // rdx

func0(a1);
v4 = *(_DWORD *)(a1 + 4);
if ( a3 >= v4 )
return 0xFFFFFFFFLL;
v5 = a3;
while ( *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v5) != a2 )
{
if ( v4 <= (int)++v5 )
return 0xFFFFFFFFLL;
}
return (unsigned int)v5;
}

original_code:
int vector_index_of_with_start(Vector *v, void *elem, int start) {
  vector_validated(v);
  int i;
  for (i = start; i < v->_size; ++i) {
    if (v->_data[i] == elem) {
      return i;
    }
  }
  return -1;
}

canonical_original_code:
int vector_index_of_with_start(struct Vector *v, void *elem, int start) {
  vector_validated(v);
  int i;
  for (i = start; i < v->_size; ++i) {
    if (v->_data[i] == elem) {
      return i;
    }
  }
  return -1;
}

variable_types: start int


decompiled_code:
__int64 __fastcall vector_index_of(__int64 a1, __int64 a2)
{
return vector_index_of_with_start(a1, a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2)
{
return func13(a1, a2, 0);
}

original_code:
int vector_index_of(Vector *v, void *elem) {
  return vector_index_of_with_start(v, elem, 0);
}

canonical_original_code:
int vector_index_of(struct Vector *v, void *elem) {
  return vector_index_of_with_start(v, elem, 0);
}


decompiled_code:
// attributes: thunk
void StackElement_release(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func0(void *ptr)
{
free(ptr);
}

original_code:
static void StackElement_release(StackElement *se) {
  free(se);
  se = ((void *)0);
}

canonical_original_code:
static void StackElement_release(struct StackElement *se) {
  free(se);
  se = ((void *)0);
}

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

user_defined_types: struct StackElement { struct XMLElement *element; int depth; }


decompiled_code:
void __fastcall XMLParser_release(void *ptr)
{
vector_release(*((_QWORD *)ptr + 5));
vector_release(*((_QWORD *)ptr + 3));
vector_release(*((_QWORD *)ptr + 4));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
vector_release(*((_QWORD *)ptr + 5));
vector_release(*((_QWORD *)ptr + 3));
vector_release(*((_QWORD *)ptr + 4));
free(ptr);
}

original_code:
static void XMLParser_release(XMLParser *p) {
  vector_release(p->element_stack);
  vector_release(p->value_stack);
  vector_release(p->tag_stack);
  free(p);
  p = ((void *)0);
}

canonical_original_code:
static void XMLParser_release(struct XMLParser *p) {
  vector_release(p->element_stack);
  vector_release(p->value_stack);
  vector_release(p->tag_stack);
  free(p);
  p = ((void *)0);
}

variable_types: struct XMLParser { char *_input; int _pos; int _depth; enum ParseState { STATE1=0, STATE2=1, STATE3=2, STATE4=3, STATE5=4, STATE6=5, STATE7=6, STATE8=7, STATE_ERROR=8 } state; struct Vector { int _capacity; int _size; void **_data; } *value_stack; struct Vector *tag_stack; struct Vector *element_stack; } *

user_defined_types: struct XMLParser { char *_input; int _pos; int _depth; enum ParseState state; struct Vector *value_stack; struct Vector *tag_stack; struct Vector *element_stack; }


decompiled_code:
void __fastcall XMLElement_release(void *ptr)
{
*((_QWORD *)ptr + 2) = 0LL;
free(*(void **)ptr);
free(*((void **)ptr + 1));
vector_release(*((_QWORD *)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
*((_QWORD *)ptr + 2) = 0LL;
free(*(void **)ptr);
free(*((void **)ptr + 1));
vector_release(*((_QWORD *)ptr + 3));
free(ptr);
}

original_code:
void XMLElement_release(XMLElement *e) {
  e->parent = ((void *)0);
  free(e->tag_name);
  free(e->value);
  vector_release(e->children);
  free(e);
  e = ((void *)0);
}

canonical_original_code:
void XMLElement_release(struct XMLElement *e) {
  e->parent = ((void *)0);
  free(e->tag_name);
  free(e->value);
  vector_release(e->children);
  free(e);
  e = ((void *)0);
}


decompiled_code:
__int64 __fastcall parse_xml_from_text(__int64 a1)
{
_QWORD *v1; // r14
_QWORD *v2; // rax
__int64 v3; // r15
__int64 v4; // rsi
int v5; // ebx
const char **v6; // rax
const char **v7; // rbp
unsigned int v8; // ecx
__int64 v9; // r12
__int64 v10; // r13
int v11; // eax
_DWORD *v12; // rax
_DWORD *v13; // r13
int i; // er12
__int64 v15; // rax
const char *v16; // rsi
__int64 *v17; // rax
__int64 v18; // r12
int v20; // [rsp+Ch] [rbp-3Ch]

v2 = XMLParser_create_constprop_0();
*v2 = a1;
v3 = (__int64)v2;
*((_DWORD *)v2 + 2) = 0;
*((_DWORD *)v2 + 4) = 0;
while ( 1 )
{
v6 = (const char **)parser_get_next_token(v3);
v7 = v6;
if ( !v6 )
break;
v8 = *(_DWORD *)v6;
if ( *(_DWORD *)v6 != 3 || v6[1] )
{
v4 = *(unsigned int *)(v3 + 16);
v5 = state_translate[4 * v4 + v8];
if ( v5 == 8 )
{
free(v6);
_assert_fail("state != STATE_ERROR && \"error while parsing\"", "simple_xml.c", 0x139u, "parse_xml_from_text");
}
if ( (_DWORD)v4 == 5 )
{
if ( v8 == 3 )
{
v16 = (const char *)vector_top_back(*(_QWORD *)(v3 + 32));
if ( strcmp(v7[1], v16) )
_assert_fail(
"strcmp(token->data, vector_top_back(parser->tag_stack)) == 0",
"simple_xml.c",
0x109u,
"parse_xml_from_text");
}
}
else if ( (unsigned int)v4 > 5 )
{
if ( (_DWORD)v4 == 6 && v8 == 2 )
{
v9 = vector_top_back(*(_QWORD *)(v3 + 32));
v10 = vector_top_back(*(_QWORD *)(v3 + 24));
v11 = vector_size(*(_QWORD *)(v3 + 40));
--*(_DWORD *)(v3 + 12);
v20 = v11;
v1 = XMLElement_create((__int64)v1, v9, v10);
v12 = StackElement_create_constprop_0();
*(_QWORD *)v12 = v1;
v13 = v12;
v12[2] = *(_DWORD *)(v3 + 12);
if ( v20 > 0 )
{
for ( i = 0; i != v20; ++i )
{
v15 = vector_top_back(*(_QWORD *)(v3 + 40));
if ( *(_DWORD *)(v15 + 8) <= v13[2] )
break;
vector_push_front(v1[3], *(_QWORD *)v15);
vector_pop_back(*(_QWORD *)(v3 + 40));
}
}
vector_push_back(*(_QWORD *)(v3 + 40), v13);
vector_pop_back(*(_QWORD *)(v3 + 32));
vector_pop_back(*(_QWORD *)(v3 + 24));
}
}
else if ( (_DWORD)v4 == 1 )
{
if ( v8 == 3 )
{
vector_push_back(*(_QWORD *)(v3 + 32), v6[1]);
++*(_DWORD *)(v3 + 12);
}
}
else if ( (_DWORD)v4 == 3 )
{
vector_push_back(*(_QWORD *)(v3 + 24), v6[1]);
}
free(v7);
*(_DWORD *)(v3 + 16) = v5;
}
}
v17 = (__int64 *)vector_top_back(*(_QWORD *)(v3 + 40));
v18 = *v17;
StackElement_release(v17);
XMLParser_release((void *)v3);
return v18;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
_QWORD *v1; // r14
_QWORD *v2; // rax
__int64 v3; // r15
__int64 v4; // rsi
int v5; // ebx
const char **v6; // rax
const char **v7; // rbp
unsigned int v8; // ecx
__int64 v9; // r12
__int64 v10; // r13
int v11; // eax
_DWORD *v12; // rax
_DWORD *v13; // r13
int i; // er12
__int64 v15; // rax
const char *v16; // rsi
__int64 *v17; // rax
__int64 v18; // r12
int v20; // [rsp+Ch] [rbp-3Ch]

v2 = func3();
*v2 = a1;
v3 = (__int64)v2;
*((_DWORD *)v2 + 2) = 0;
*((_DWORD *)v2 + 4) = 0;
while ( 1 )
{
v6 = (const char **)parser_get_next_token(v3);
v7 = v6;
if ( !v6 )
break;
v8 = *(_DWORD *)v6;
if ( *(_DWORD *)v6 != 3 || v6[1] )
{
v4 = *(unsigned int *)(v3 + 16);
v5 = state_translate[4 * v4 + v8];
if ( v5 == 8 )
{
free(v6);
_assert_fail("state != STATE_ERROR && \"error while parsing\"", "simple_xml.c", 0x139u, "parse_xml_from_text");
}
if ( (_DWORD)v4 == 5 )
{
if ( v8 == 3 )
{
v16 = (const char *)vector_top_back(*(_QWORD *)(v3 + 32));
if ( strcmp(v7[1], v16) )
_assert_fail(
"strcmp(token->data, vector_top_back(parser->tag_stack)) == 0",
"simple_xml.c",
0x109u,
"parse_xml_from_text");
}
}
else if ( (unsigned int)v4 > 5 )
{
if ( (_DWORD)v4 == 6 && v8 == 2 )
{
v9 = vector_top_back(*(_QWORD *)(v3 + 32));
v10 = vector_top_back(*(_QWORD *)(v3 + 24));
v11 = vector_size(*(_QWORD *)(v3 + 40));
--*(_DWORD *)(v3 + 12);
v20 = v11;
v1 = XMLElement_create((__int64)v1, v9, v10);
v12 = func2();
*(_QWORD *)v12 = v1;
v13 = v12;
v12[2] = *(_DWORD *)(v3 + 12);
if ( v20 > 0 )
{
for ( i = 0; i != v20; ++i )
{
v15 = vector_top_back(*(_QWORD *)(v3 + 40));
if ( *(_DWORD *)(v15 + 8) <= v13[2] )
break;
vector_push_front(v1[3], *(_QWORD *)v15);
vector_pop_back(*(_QWORD *)(v3 + 40));
}
}
vector_push_back(*(_QWORD *)(v3 + 40), v13);
vector_pop_back(*(_QWORD *)(v3 + 32));
vector_pop_back(*(_QWORD *)(v3 + 24));
}
}
else if ( (_DWORD)v4 == 1 )
{
if ( v8 == 3 )
{
vector_push_back(*(_QWORD *)(v3 + 32), v6[1]);
++*(_DWORD *)(v3 + 12);
}
}
else if ( (_DWORD)v4 == 3 )
{
vector_push_back(*(_QWORD *)(v3 + 24), v6[1]);
}
free(v7);
*(_DWORD *)(v3 + 16) = v5;
}
}
v17 = (__int64 *)vector_top_back(*(_QWORD *)(v3 + 40));
v18 = *v17;
func0(v17);
func1((void *)v3);
return v18;
}

original_code:
XMLElement* parse_xml_from_text(char *text) {
  XMLToken *token;
  XMLParser *parser;
  parser = XMLParser_create(parser);
  parser->_input = text;
  parser->_pos = 0;
  parser->state = STATE1;
  while (1) {
    ParseState state;
    token = parser_get_next_token(parser);
    if (token == ((void *)0)) break;
    if (token->type == TEXT && token->data == ((void *)0))
      continue;
    state = state_translate[parser->state][token->type];
    if (state != STATE_ERROR) {
      switch (parser->state) {
        case STATE1:
          break;
        case STATE2:
          if (token->type == TEXT) {
            vector_push_back(parser->tag_stack, token->data);
            parser->_depth++;
          }
          break;
        case STATE3:
          break;
        case STATE4:
          vector_push_back(parser->value_stack, token->data);
          break;
        case STATE5:
          break;
        case STATE6:
          if (token->type == TEXT) {
            ((void) sizeof ((strcmp(token->data, vector_top_back(parser->tag_stack)) == 0) ? 1 : 0), __extension__ ({ if (strcmp(token->data, vector_top_back(parser->tag_stack)) == 0) ; else __assert_fail ("strcmp(token->data, vector_top_back(parser->tag_stack)) == 0", "simple_xml.c", 265, __extension__ __PRETTY_FUNCTION__); }));
          }
          break;
        case STATE7:
          if (token->type == END_TAG) {
            char *current_tag, *current_value;
            int i, length;
            XMLElement *top;
            XMLElement *current;
            StackElement *se;
            current_tag = vector_top_back(parser->tag_stack);
            current_value = vector_top_back(parser->value_stack);
            length = vector_size(parser->element_stack);
            parser->_depth--;
            current = XMLElement_create(current, current_tag, current_value);
            se = StackElement_create(se);
            se->element = current;
            se->depth = parser->_depth;
            for (i = 0; i < length; ++i) {
              StackElement *elem = (StackElement *)vector_top_back(parser->element_stack);
              if (elem->depth <= se->depth) break;
              vector_push_front(current->children, elem->element);
              vector_pop_back(parser->element_stack);
            }
            vector_push_back(parser->element_stack, se);
            vector_pop_back(parser->tag_stack);
            vector_pop_back(parser->value_stack);
          }
          break;
        case STATE8:
          break;
        default:
          break;
      }
    }
    free(token);
    if (state == STATE_ERROR)
      ((void) sizeof ((state != STATE_ERROR && "error while parsing") ? 1 : 0), __extension__ ({ if (state != STATE_ERROR && "error while parsing") ; else __assert_fail ("state != STATE_ERROR && \"error while parsing\"", "simple_xml.c", 313, __extension__ __PRETTY_FUNCTION__); }));
    parser->state = state;
  }
  StackElement* stackElem = (StackElement *) vector_top_back(parser->element_stack);
  XMLElement *xmlElem = stackElem->element;
  StackElement_release(stackElem);
  XMLParser_release(parser);
  return xmlElem;
}

canonical_original_code:
struct XMLElement *parse_xml_from_text(char *text) {
  struct XMLToken *token;
  struct XMLParser *parser;
  parser = XMLParser_create(parser);
  parser->_input = text;
  parser->_pos = 0;
  parser->state = STATE1;
  while (1) {
    enum ParseState state;
    token = parser_get_next_token(parser);
    if (token == ((void *)0)) break;
    if (token->type == TEXT && token->data == ((void *)0))
      continue;
    state = state_translate[parser->state][token->type];
    if (state != STATE_ERROR) {
      switch (parser->state) {
        case STATE1:
          break;
        case STATE2:
          if (token->type == TEXT) {
            vector_push_back(parser->tag_stack, token->data);
            parser->_depth++;
          }
          break;
        case STATE3:
          break;
        case STATE4:
          vector_push_back(parser->value_stack, token->data);
          break;
        case STATE5:
          break;
        case STATE6:
          if (token->type == TEXT) {
            ((void) sizeof ((strcmp(token->data, vector_top_back(parser->tag_stack)) == 0) ? 1 : 0), __extension__ ({ if (strcmp(token->data, vector_top_back(parser->tag_stack)) == 0) ; else __assert_fail ("strcmp(token->data, vector_top_back(parser->tag_stack)) == 0", "simple_xml.c", 265, __extension__ __PRETTY_FUNCTION__); }));
          }
          break;
        case STATE7:
          if (token->type == END_TAG) {
            char *current_tag; char *current_value;
            int i; int length;
            struct XMLElement *top;
            struct XMLElement *current;
            struct StackElement *se;
            current_tag = vector_top_back(parser->tag_stack);
            current_value = vector_top_back(parser->value_stack);
            length = vector_size(parser->element_stack);
            parser->_depth--;
            current = XMLElement_create(current, current_tag, current_value);
            se = StackElement_create(se);
            se->element = current;
            se->depth = parser->_depth;
            for (i = 0; i < length; ++i) {
              struct StackElement *elem = (StackElement *)vector_top_back(parser->element_stack);
              if (elem->depth <= se->depth) break;
              vector_push_front(current->children, elem->element);
              vector_pop_back(parser->element_stack);
            }
            vector_push_back(parser->element_stack, se);
            vector_pop_back(parser->tag_stack);
            vector_pop_back(parser->value_stack);
          }
          break;
        case STATE8:
          break;
        default:
          break;
      }
    }
    free(token);
    if (state == STATE_ERROR)
      ((void) sizeof ((state != STATE_ERROR && "error while parsing") ? 1 : 0), __extension__ ({ if (state != STATE_ERROR && "error while parsing") ; else __assert_fail ("state != STATE_ERROR && \"error while parsing\"", "simple_xml.c", 313, __extension__ __PRETTY_FUNCTION__); }));
    parser->state = state;
  }
  struct StackElement *stackElem = (StackElement *) vector_top_back(parser->element_stack);
  struct XMLElement *xmlElem = stackElem->element;
  StackElement_release(stackElem);
  XMLParser_release(parser);
  return xmlElem;
}

variable_types:
text
char *

variable_types: struct XMLToken { enum XMLTokenType { BEGIN_OPEN_TAG=0, BEGIN_CLOSE_TAG=1, END_TAG=2, TEXT=3 } type; char *data; } *

variable_types: enum ParseState { STATE1=0, STATE2=1, STATE3=2, STATE4=3, STATE5=4, STATE6=5, STATE7=6, STATE8=7, STATE_ERROR=8 }

variable_types: length int

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

user_defined_types: struct XMLToken { enum XMLTokenType type; char *data; }


repo: kimito/libcr

decompiled_code:
char *__fastcall create_context_for(void (*a1)(void))
{
void *v2; // rax
char *ptr; // [rsp+8h] [rbp-20h]

if ( !a1 )
return 0LL;
ptr = (char *)malloc(0x798uLL);
*(_QWORD *)ptr = now_context;
if ( getcontext((ucontext_t *)(ptr + 976)) )
return ptr;
v2 = malloc(0x4000uLL);
*((_QWORD *)ptr + 124) = v2;
if ( !v2 )
{
free(ptr);
return ptr;
}
*((_QWORD *)ptr + 126) = 0x4000LL;
*((_QWORD *)ptr + 123) = ptr + 8;
makecontext((ucontext_t *)(ptr + 976), a1, 0);
return ptr;
}

canonical_decompiled_code:
char *__fastcall func6(void (*a1)(void))
{
void *v2; // rax
char *ptr; // [rsp+8h] [rbp-20h]

if ( !a1 )
return 0LL;
ptr = (char *)malloc(0x798uLL);
*(_QWORD *)ptr = now_context;
if ( getcontext((ucontext_t *)(ptr + 976)) )
return ptr;
v2 = malloc(0x4000uLL);
*((_QWORD *)ptr + 124) = v2;
if ( !v2 )
{
free(ptr);
return ptr;
}
*((_QWORD *)ptr + 126) = 0x4000LL;
*((_QWORD *)ptr + 123) = ptr + 8;
makecontext((ucontext_t *)(ptr + 976), a1, 0);
return ptr;
}

original_code:
cr_context* create_context_for( void (*func)(void) )
{
  cr_context *ret = ((void *)0);
  if( func == ((void *)0) ){
    return ((void *)0);
  }
  ret = (cr_context*)malloc( sizeof(cr_context) );
  ret->parent = now_context;
  if( ret != ((void *)0) && getcontext( &(ret->to) ) == 0 ){
    ucontext_t *to = &(ret->to);
    if( (to->uc_stack.ss_sp = malloc( STACK_SIZE )) != ((void *)0) ){
      to->uc_stack.ss_size = STACK_SIZE;
      to->uc_link = &(ret->from);
      makecontext(to, func, 0);
    }
    else{
      free(ret);
    }
  }
  return ret;
}

canonical_original_code:
struct tag_cr_context *create_context_for(void (*func)())
{
  struct tag_cr_context *ret = ((void *)0);
  if( func == ((void *)0) ){
    return ((void *)0);
  }
  ret = (struct tag_cr_context *)malloc( sizeof(cr_context) );
  ret->parent = now_context;
  if( ret != ((void *)0) && getcontext( &(ret->to) ) == 0 ){
    struct ucontext_t *to = &(ret->to);
    if( (to->uc_stack.ss_sp = malloc( STACK_SIZE )) != ((void *)0) ){
      to->uc_stack.ss_size = STACK_SIZE;
      to->uc_link = &(ret->from);
      makecontext(to, func, 0);
    }
    else{
      free(ret);
    }
  }
  return ret;
}

variable_types:
func
void (*)()

variable_types: struct tag_cr_context { struct tag_cr_context *parent; struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } from; struct ucontext_t to; } *

variable_types: struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t { void *ss_sp; int ss_flags; unsigned long ss_size; } uc_stack; struct mcontext_t { long long gregs[23]; struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg { unsigned short significand[4]; unsigned short exponent; unsigned short __glibc_reserved1[3]; } _st[8]; struct _libc_xmmreg { unsigned int element[4]; } _xmm[16]; unsigned int __glibc_reserved1[24]; } *fpregs; unsigned long long __reserved1[8]; } uc_mcontext; struct __sigset_t { unsigned long __val[-1]; } uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; } *

user_defined_types: struct tag_cr_context { struct tag_cr_context *parent; struct ucontext_t from; struct ucontext_t to; }

user_defined_types: struct ucontext_t { unsigned long uc_flags; struct ucontext_t *uc_link; struct stack_t uc_stack; struct mcontext_t uc_mcontext; struct __sigset_t uc_sigmask; struct _libc_fpstate __fpregs_mem; unsigned long long __ssp[4]; }

user_defined_types: struct mcontext_t { long long gregs[23]; struct _libc_fpstate *fpregs; unsigned long long __reserved1[8]; }

user_defined_types: struct _libc_fpstate { unsigned short cwd; unsigned short swd; unsigned short ftw; unsigned short fop; unsigned long rip; unsigned long rdp; unsigned int mxcsr; unsigned int mxcr_mask; struct _libc_fpxreg _st[8]; struct _libc_xmmreg _xmm[16]; unsigned int __glibc_reserved1[24]; }