title

decompiled_code:
int __fastcall title(char *s, char a2, char a3, double a4)
{
unsigned int v4; // er14
int result; // eax
unsigned int v7; // er15
unsigned __int64 v8; // r13
int v9; // edx
int v10; // eax
double v11; // rbx

if ( Pltdev == 1 )
{
if ( (a2 & 3) == 2 )
{
v7 = (int)((*(double *)&Miny + *(double *)&Maxy) * 0.5);
v8 = 0xBFD0000000000000LL;
}
else if ( (a2 & 3u) > 2 )
{
v7 = (int)*(double *)&Miny;
v8 = 0x3FD0000000000000LL;
}
else
{
v7 = (int)*(double *)&Maxy;
v8 = 0xBFF0000000000000LL;
}
v9 = strlen(s);
v10 = a2 & 0xC;
if ( v10 == 8 )
{
v4 = (int)((*(double *)&Minx + *(double *)&Maxx) * 0.5);
v11 = -(double)v9 * 0.5;
}
else if ( (a2 & 0xCu) > 8 )
{
v11 = 0.0;
if ( v10 == 12 )
{
v4 = (int)*(double *)&Maxx;
v11 = -(double)v9;
if ( (Main_flags & 1) != 0 )
v11 = -(double)v9 - 0.5;
}
}
else if ( (a2 & 8) != 0 )
{
v11 = 0.0;
}
else
{
v4 = (int)*(double *)&Minx;
v11 = 0.0;
if ( (Main_flags & 1) != 0 )
v11 = 0.5;
}
if ( (a3 & 1) != 0 )
puts("SL.36;");
else
puts("SL0;");
printf("SI%1.2f,%1.2f;\n", a4 / 13.1579, a4 / 10.0);
printf("PU;PA%d,%d;CP%1.2f,%1.2f;LB%s%c;\n", v4, v7, v11, *(double *)&v8, s, 3LL);
result = printf("PU;PA%d,%d;\n", (unsigned int)(int)*(double *)&Xpos, (unsigned int)(int)*(double *)&Ypos);
}
else
{
result = Pltdev - 2;
if ( (unsigned int)(Pltdev - 2) > 2 )
result = fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
}
return result;
}

canonical_decompiled_code:
int __fastcall func11(char *s, char a2, char a3, double a4)
{
unsigned int v4; // er14
int result; // eax
unsigned int v7; // er15
unsigned __int64 v8; // r13
int v9; // edx
int v10; // eax
double v11; // rbx

if ( Pltdev == 1 )
{
if ( (a2 & 3) == 2 )
{
v7 = (int)((*(double *)&Miny + *(double *)&Maxy) * 0.5);
v8 = 0xBFD0000000000000LL;
}
else if ( (a2 & 3u) > 2 )
{
v7 = (int)*(double *)&Miny;
v8 = 0x3FD0000000000000LL;
}
else
{
v7 = (int)*(double *)&Maxy;
v8 = 0xBFF0000000000000LL;
}
v9 = strlen(s);
v10 = a2 & 0xC;
if ( v10 == 8 )
{
v4 = (int)((*(double *)&Minx + *(double *)&Maxx) * 0.5);
v11 = -(double)v9 * 0.5;
}
else if ( (a2 & 0xCu) > 8 )
{
v11 = 0.0;
if ( v10 == 12 )
{
v4 = (int)*(double *)&Maxx;
v11 = -(double)v9;
if ( (Main_flags & 1) != 0 )
v11 = -(double)v9 - 0.5;
}
}
else if ( (a2 & 8) != 0 )
{
v11 = 0.0;
}
else
{
v4 = (int)*(double *)&Minx;
v11 = 0.0;
if ( (Main_flags & 1) != 0 )
v11 = 0.5;
}
if ( (a3 & 1) != 0 )
puts("SL.36;");
else
puts("SL0;");
printf("SI%1.2f,%1.2f;\n", a4 / 13.1579, a4 / 10.0);
printf("PU;PA%d,%d;CP%1.2f,%1.2f;LB%s%c;\n", v4, v7, v11, *(double *)&v8, s, 3LL);
result = printf("PU;PA%d,%d;\n", (unsigned int)(int)*(double *)&Xpos, (unsigned int)(int)*(double *)&Ypos);
}
else
{
result = Pltdev - 2;
if ( (unsigned int)(Pltdev - 2) > 2 )
result = fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
}
return result;
}

original_code:
void title(const char str[], const double size, const int posn, const int flags)
{
   int x, y;
   double xc = 0.0;
   double yc = 0.0;
   const int len = strlen(str);
   switch (Pltdev) {
   case (1):
      switch (posn & 0x03) {
      case 0:
      case (1):
         y = (int)Maxy;
         yc = -1.0;
         break;
      case (2):
         y = (int)((Miny + Maxy) / 2.0);
         yc = -0.25;
         break;
      case (3):
         y = (int)Miny;
         yc = 0.25;
         break;
      }
      switch (posn & 0x0c) {
      case 0:
      case (4):
         x = (int)Minx;
         xc = 0.0;
         if (Main_flags & (1))
           xc += 0.5;
         break;
      case (8):
         x = (int)((Minx + Maxx) / 2.0);
         xc = -((double)len) / 2.0;
         break;
      case (12):
         x = (int)Maxx;
         xc = -((double)len);
         if (Main_flags & (1))
           xc -= 0.5;
         break;
      }
      if (flags & (1))
         printf("SL.36;\n");
      else
         printf("SL0;\n");
      printf("SI%1.2f,%1.2f;\n", size / 13.1579, size / 10.0);
      printf("PU;PA%d,%d;CP%1.2f,%1.2f;LB%s%c;\n", x, y, xc, yc, str, (0x03));
      printf("PU;PA%d,%d;\n", (int)Xpos, (int)Ypos);
      break;
   case (2):
      break;
   case (3):
      break;
   case (4):
      break;
   default:
      fprintf(stderr, "Turtle graphics not initialised\n");
      break;
   }
}

canonical_original_code:
void title(char str[], double size, int posn, int flags)
{
   int x; int y;
   double xc = 0.0;
   double yc = 0.0;
   int len = strlen(str);
   switch (Pltdev) {
   case (1):
      switch (posn & 0x03) {
      case 0:
      case (1):
         y = (int)Maxy;
         yc = -1.0;
         break;
      case (2):
         y = (int)((Miny + Maxy) / 2.0);
         yc = -0.25;
         break;
      case (3):
         y = (int)Miny;
         yc = 0.25;
         break;
      }
      switch (posn & 0x0c) {
      case 0:
      case (4):
         x = (int)Minx;
         xc = 0.0;
         if (Main_flags & (1))
           xc += 0.5;
         break;
      case (8):
         x = (int)((Minx + Maxx) / 2.0);
         xc = -((double)len) / 2.0;
         break;
      case (12):
         x = (int)Maxx;
         xc = -((double)len);
         if (Main_flags & (1))
           xc -= 0.5;
         break;
      }
      if (flags & (1))
         printf("SL.36;\n");
      else
         printf("SL0;\n");
      printf("SI%1.2f,%1.2f;\n", size / 13.1579, size / 10.0);
      printf("PU;PA%d,%d;CP%1.2f,%1.2f;LB%s%c;\n", x, y, xc, yc, str, (0x03));
      printf("PU;PA%d,%d;\n", (int)Xpos, (int)Ypos);
      break;
   case (2):
      break;
   case (3):
      break;
   case (4):
      break;
   default:
      fprintf(stderr, "Turtle graphics not initialised\n");
      break;
   }
}

variable_types:
str
char []

variable_types: size double

variable_types: posn int

variable_types: x int

variable_types: y int

variable_types: xc double

variable_types: yc double

variable_types: len int


repo: anachrocomputer/vec

decompiled_code:
int bottom_left()
{
int result; // eax

Xpos = Minx;
Ypos = Miny;
if ( Pltdev == 2 )
return printf("MA%d,%d\n", (unsigned int)(int)*(double *)&Minx, (unsigned int)(int)*(double *)&Miny);
if ( Pltdev <= 2 )
{
if ( Pltdev == 1 )
return printf("PU;PA%d,%d;\n", (unsigned int)(int)*(double *)&Minx, (unsigned int)(int)*(double *)&Miny);
return fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
}
result = Pltdev - 3;
if ( (unsigned int)(Pltdev - 3) > 1 )
return fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
return result;
}

canonical_decompiled_code:
int func12()
{
int result; // eax

Xpos = Minx;
Ypos = Miny;
if ( Pltdev == 2 )
return printf("MA%d,%d\n", (unsigned int)(int)*(double *)&Minx, (unsigned int)(int)*(double *)&Miny);
if ( Pltdev <= 2 )
{
if ( Pltdev == 1 )
return printf("PU;PA%d,%d;\n", (unsigned int)(int)*(double *)&Minx, (unsigned int)(int)*(double *)&Miny);
return fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
}
result = Pltdev - 3;
if ( (unsigned int)(Pltdev - 3) > 1 )
return fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
return result;
}

original_code:
void bottom_left(void)
{
   Xpos = Minx;
   Ypos = Miny;
   switch (Pltdev) {
   case (1):
      printf("PU;PA%d,%d;\n", (int)Xpos, (int)Ypos);
      break;
   case (2):
      printf("MA%d,%d\n", (int)Xpos, (int)Ypos);
      break;
   case (3):
      break;
   case (4):
      break;
   default:
      fprintf(stderr, "Turtle graphics not initialised\n");
      break;
   }
}

canonical_original_code:
void bottom_left()
{
   Xpos = Minx;
   Ypos = Miny;
   switch (Pltdev) {
   case (1):
      printf("PU;PA%d,%d;\n", (int)Xpos, (int)Ypos);
      break;
   case (2):
      printf("MA%d,%d\n", (int)Xpos, (int)Ypos);
      break;
   case (3):
      break;
   case (4):
      break;
   default:
      fprintf(stderr, "Turtle graphics not initialised\n");
      break;
   }
}

return_type: void


decompiled_code:
void __fastcall set_heading(double a1)
{
__int64 v1; // [rsp+0h] [rbp-18h] BYREF
double sinx[2]; // [rsp+8h] [rbp-10h] BYREF

Heading = *(_QWORD *)&a1;
sincos(a1 * 0.0174532925199433, sinx, (double *)&v1);
Xvec = v1;
Yvec = *(_QWORD *)&sinx[0];
}

canonical_decompiled_code:
void __fastcall func13(double a1)
{
__int64 v1; // [rsp+0h] [rbp-18h] BYREF
double sinx[2]; // [rsp+8h] [rbp-10h] BYREF

Heading = *(_QWORD *)&a1;
sincos(a1 * 0.0174532925199433, sinx, (double *)&v1);
Xvec = v1;
Yvec = *(_QWORD *)&sinx[0];
}

variable_types: deg double


forward

decompiled_code:
int __fastcall forward(double a1)
{
double v1; // xmm0_8
double v2; // xmm1_8
double v3; // xmm0_8
int result; // eax

v1 = a1 * *(double *)&Scale;
v2 = v1 * *(double *)&Xvec + *(double *)&Xpos;
v3 = v1 * *(double *)&Yvec + *(double *)&Ypos;
if ( Pltdev != 2 )
{
if ( Pltdev > 2 )
{
result = Pltdev - 3;
if ( (unsigned int)(Pltdev - 3) <= 1 )
goto LABEL_7;
}
else if ( Pltdev == 1 )
{
if ( Penstate == 1 )
result = printf("PD;PA%d,%d;\n", (unsigned int)(int)v2, (unsigned int)(int)v3);
else
result = printf("PU;PA%d,%d;\n", (unsigned int)(int)v2, (unsigned int)(int)v3);
goto LABEL_7;
}
result = fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
goto LABEL_7;
}
if ( Penstate == 1 )
result = printf("DA%d,%d\n", (unsigned int)(int)v2, (unsigned int)(int)v3);
else
result = printf("MA%d,%d\n", (unsigned int)(int)v2, (unsigned int)(int)v3);
LABEL_7:
Xpos = *(_QWORD *)&v2;
Ypos = *(_QWORD *)&v3;
return result;
}

canonical_decompiled_code:
int __fastcall func14(double a1)
{
double v1; // xmm0_8
double v2; // xmm1_8
double v3; // xmm0_8
int result; // eax

v1 = a1 * *(double *)&Scale;
v2 = v1 * *(double *)&Xvec + *(double *)&Xpos;
v3 = v1 * *(double *)&Yvec + *(double *)&Ypos;
if ( Pltdev != 2 )
{
if ( Pltdev > 2 )
{
result = Pltdev - 3;
if ( (unsigned int)(Pltdev - 3) <= 1 )
goto LABEL_7;
}
else if ( Pltdev == 1 )
{
if ( Penstate == 1 )
result = printf("PD;PA%d,%d;\n", (unsigned int)(int)v2, (unsigned int)(int)v3);
else
result = printf("PU;PA%d,%d;\n", (unsigned int)(int)v2, (unsigned int)(int)v3);
goto LABEL_7;
}
result = fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
goto LABEL_7;
}
if ( Penstate == 1 )
result = printf("DA%d,%d\n", (unsigned int)(int)v2, (unsigned int)(int)v3);
else
result = printf("MA%d,%d\n", (unsigned int)(int)v2, (unsigned int)(int)v3);
LABEL_7:
Xpos = *(_QWORD *)&v2;
Ypos = *(_QWORD *)&v3;
return result;
}

original_code:
void forward(const double mm)
{
   const double len = mm * Scale;
   const double newx = Xpos + (Xvec * len);
   const double newy = Ypos + (Yvec * len);
   switch (Pltdev) {
   case (1):
      if (Penstate == (1))
         printf("PD;PA%d,%d;\n", (int)newx, (int)newy);
      else
         printf("PU;PA%d,%d;\n", (int)newx, (int)newy);
      break;
   case (2):
      if (Penstate == (1))
         printf("DA%d,%d\n", (int)newx, (int)newy);
      else
         printf("MA%d,%d\n", (int)newx, (int)newy);
      break;
   case (3):
      break;
   case (4):
      break;
   default:
      fprintf(stderr, "Turtle graphics not initialised\n");
      break;
   }
   Xpos = newx;
   Ypos = newy;
}

canonical_original_code:
void forward(double mm)
{
   double len = mm * Scale;
   double newx = Xpos + (Xvec * len);
   double newy = Ypos + (Yvec * len);
   switch (Pltdev) {
   case (1):
      if (Penstate == (1))
         printf("PD;PA%d,%d;\n", (int)newx, (int)newy);
      else
         printf("PU;PA%d,%d;\n", (int)newx, (int)newy);
      break;
   case (2):
      if (Penstate == (1))
         printf("DA%d,%d\n", (int)newx, (int)newy);
      else
         printf("MA%d,%d\n", (int)newx, (int)newy);
      break;
   case (3):
      break;
   case (4):
      break;
   default:
      fprintf(stderr, "Turtle graphics not initialised\n");
      break;
   }
   Xpos = newx;
   Ypos = newy;
}

variable_types: mm double

variable_types: len double

variable_types: newx double

variable_types: newy double


turn

decompiled_code:
void __fastcall turn(double a1)
{
double v1; // xmm0_8
__int64 v2; // [rsp+0h] [rbp-18h] BYREF
double sinx[2]; // [rsp+8h] [rbp-10h] BYREF

v1 = a1 + *(double *)&Heading;
if ( v1 > 360.0 )
v1 = v1 - 360.0;
Heading = *(_QWORD *)&v1;
if ( v1 < 0.0 )
*(double *)&Heading = v1 + 360.0;
sincos(0.0174532925199433 * *(double *)&Heading, sinx, (double *)&v2);
Xvec = v2;
Yvec = *(_QWORD *)&sinx[0];
}

canonical_decompiled_code:
void __fastcall func15(double a1)
{
double v1; // xmm0_8
__int64 v2; // [rsp+0h] [rbp-18h] BYREF
double sinx[2]; // [rsp+8h] [rbp-10h] BYREF

v1 = a1 + *(double *)&Heading;
if ( v1 > 360.0 )
v1 = v1 - 360.0;
Heading = *(_QWORD *)&v1;
if ( v1 < 0.0 )
*(double *)&Heading = v1 + 360.0;
sincos(0.0174532925199433 * *(double *)&Heading, sinx, (double *)&v2);
Xvec = v2;
Yvec = *(_QWORD *)&sinx[0];
}


pen

decompiled_code:
void __fastcall pen(int a1)
{
Penstate = a1;
}

canonical_decompiled_code:
void __fastcall func16(int a1)
{
Penstate = a1;
}

original_code:
void pen(const int flag)
{
   Penstate = flag;
}

canonical_original_code:
void pen(int flag)
{
   Penstate = flag;
}

variable_types: flag int


colour

decompiled_code:
void __fastcall colour(unsigned int a1)
{
if ( Pencol != a1 )
{
if ( Pltdev == 2 )
{
printf("PS%d;\n", a1);
goto LABEL_7;
}
if ( Pltdev > 2 )
{
if ( (unsigned int)(Pltdev - 3) <= 1 )
goto LABEL_7;
}
else if ( Pltdev == 1 )
{
printf("SP%d;\n", a1);
LABEL_7:
Pencol = a1;
return;
}
fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
goto LABEL_7;
}
}

canonical_decompiled_code:
void __fastcall func17(unsigned int a1)
{
if ( Pencol != a1 )
{
if ( Pltdev == 2 )
{
printf("PS%d;\n", a1);
goto LABEL_7;
}
if ( Pltdev > 2 )
{
if ( (unsigned int)(Pltdev - 3) <= 1 )
goto LABEL_7;
}
else if ( Pltdev == 1 )
{
printf("SP%d;\n", a1);
LABEL_7:
Pencol = a1;
return;
}
fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
goto LABEL_7;
}
}

original_code:
void colour(const int c)
{
   if (Pencol == c)
      return;
   switch (Pltdev) {
   case (1):
      printf("SP%d;\n", c);
      break;
   case (2):
      printf("PS%d;\n", c);
      break;
   case (3):
      break;
   case (4):
      break;
   default:
      fprintf(stderr, "Turtle graphics not initialised\n");
      break;
   }
   Pencol = c;
}

canonical_original_code:
void colour(int c)
{
   if (Pencol == c)
      return;
   switch (Pltdev) {
   case (1):
      printf("SP%d;\n", c);
      break;
   case (2):
      printf("PS%d;\n", c);
      break;
   case (3):
      break;
   case (4):
      break;
   default:
      fprintf(stderr, "Turtle graphics not initialised\n");
      break;
   }
   Pencol = c;
}

variable_types: c int


decompiled_code:
double page_width()
{
if ( Pltdev )
return (*(double *)&Maxx - *(double *)&Minx) / *(double *)&Scale;
fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
return 0.0;
}

canonical_decompiled_code:
double func18()
{
if ( Pltdev )
return (*(double *)&Maxx - *(double *)&Minx) / *(double *)&Scale;
fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
return 0.0;
}

original_code:
double page_width(void)
{
   if (Pltdev != (0))
      return ((Maxx - Minx) / Scale);
   else {
      fprintf(stderr, "Turtle graphics not initialised\n");
      return (0.0);
   }
}

canonical_original_code:
double page_width()
{
   if (Pltdev != (0))
      return ((Maxx - Minx) / Scale);
   else {
      fprintf(stderr, "Turtle graphics not initialised\n");
      return (0.0);
   }
}

return_type: double


decompiled_code:
double page_height()
{
if ( Pltdev )
return (*(double *)&Maxy - *(double *)&Miny) / *(double *)&Scale;
fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
return 0.0;
}

canonical_decompiled_code:
double func19()
{
if ( Pltdev )
return (*(double *)&Maxy - *(double *)&Miny) / *(double *)&Scale;
fwrite("Turtle graphics not initialised\n", 1uLL, 0x20uLL, stderr);
return 0.0;
}

original_code:
double page_height(void)
{
   if (Pltdev != (0))
      return ((Maxy - Miny) / Scale);
   else {
      fprintf(stderr, "Turtle graphics not initialised\n");
      return (0.0);
   }
}

canonical_original_code:
double page_height()
{
   if (Pltdev != (0))
      return ((Maxy - Miny) / Scale);
   else {
      fprintf(stderr, "Turtle graphics not initialised\n");
      return (0.0);
   }
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx

turtle(1LL, 3LL, 0LL, 1LL);
pen(0LL);
turn(90.0);
forward(37.0);
turn(-90.0);
pen(1LL);
colour(1LL);
v3 = 3;
do
{
penta(32.0);
turn(60.0);
forward(32.0);
turn(-60.0);
hexa(32.0);
turn(-60.0);
penta(32.0);
turn(-60.0);
hexa(32.0);
turn(-60.0);
forward(32.0);
turn(60.0);
--v3;
}
while ( v3 );
show();
return 0;
}

original_code:
int main(int argc, char * const argv[])
{
   int i;
   const double size = 32.0;
   turtle((1), (3), (0), (1));
   pen((0));
   turn(90.0);
   forward(size + 5.0);
   turn(-90.0);
   pen((1));
   colour((1));
   for (i = 0; i < 3; i++) {
      penta(size);
      turn(60.0);
      forward(size);
      turn(-60.0);
      hexa(size);
      turn(-60.0);
      penta(size);
      turn(-60.0);
      hexa(size);
      turn(-60.0);
      forward(size);
      turn(60.0);
   }
   show();
   return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int i;
   double size = 32.0;
   turtle((1), (3), (0), (1));
   pen((0));
   turn(90.0);
   forward(size + 5.0);
   turn(-90.0);
   pen((1));
   colour((1));
   for (i = 0; i < 3; i++) {
      penta(size);
      turn(60.0);
      forward(size);
      turn(-60.0);
      hexa(size);
      turn(-60.0);
      penta(size);
      turn(-60.0);
      hexa(size);
      turn(-60.0);
      forward(size);
      turn(60.0);
   }
   show();
   return (0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: i int

return_type: int


circulararch

decompiled_code:
__int64 __fastcall circulararch(double a1, double a2, double a3, double a4)
{
moveto(a1 - a4);
lineto(a1 - a4, a3);
arc(a1, a3, -180.0);
return lineto(a1 + a4, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(double a1, double a2, double a3, double a4)
{
moveto(a1 - a4);
lineto(a1 - a4, a3);
arc(a1, a3, -180.0);
return lineto(a1 + a4, a2);
}

original_code:
void circulararch(const double xc, const double y0, const double yc, const double r)
{
   moveto(xc - r, y0);
   lineto(xc - r, yc);
   arc(xc, yc, -180.0);
   lineto(xc + r, y0);
}

canonical_original_code:
void circulararch(double xc, double y0, double yc, double r)
{
   moveto(xc - r, y0);
   lineto(xc - r, yc);
   arc(xc, yc, -180.0);
   lineto(xc + r, y0);
}

variable_types: r double


threecentredarch

decompiled_code:
__int64 __fastcall threecentredarch(double a1, double a2, double a3, double a4, double a5)
{
double v5; // r14
double v7; // [rsp+18h] [rbp-20h]

v7 = a5 + a4;
v5 = a1 - (a5 + a4);
moveto(v5);
lineto(v5, a3);
arc(a1 - a4, a3, -45.0);
arc(a1, a3 - a4, -90.0);
arc(a4 + a1, a3, -45.0);
return lineto(v7 + a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(double a1, double a2, double a3, double a4, double a5)
{
double v5; // r14
double v7; // [rsp+18h] [rbp-20h]

v7 = a5 + a4;
v5 = a1 - (a5 + a4);
moveto(v5);
lineto(v5, a3);
arc(a1 - a4, a3, -45.0);
arc(a1, a3 - a4, -90.0);
arc(a4 + a1, a3, -45.0);
return lineto(v7 + a1, a2);
}

original_code:
void threecentredarch(const double xc, const double y0, const double yc, const double d, const double r)
{
   moveto(xc - (d + r), y0);
   lineto(xc - (d + r), yc);
   arc(xc - d, yc, -45.0);
   arc(xc, yc - d, -90.0);
   arc(xc + d, yc, -45.0);
   lineto(xc + (d + r), y0);
}

canonical_original_code:
void threecentredarch(double xc, double y0, double yc, double d, double r)
{
   moveto(xc - (d + r), y0);
   lineto(xc - (d + r), yc);
   arc(xc - d, yc, -45.0);
   arc(xc, yc - d, -90.0);
   arc(xc + d, yc, -45.0);
   lineto(xc + (d + r), y0);
}

variable_types: d double


decompiled_code:
__int64 __fastcall half_ellipse(double a1, double a2, double a3, double a4, double a5)
{
int v5; // ebp
int i; // ebx
double v7; // xmm0_8
__int64 result; // rax
double v9; // [rsp+0h] [rbp-58h]
double v10; // [rsp+8h] [rbp-50h]
double cosx; // [rsp+20h] [rbp-38h] BYREF
double sinx[6]; // [rsp+28h] [rbp-30h] BYREF

sincos(a5, sinx, &cosx);
v9 = cosx;
v10 = sinx[0];
v5 = 1;
for ( i = 0; ; ++i )
{
sincos((double)i * 0.08726646259971647, sinx, &cosx);
v7 = v9 * (a3 * cosx) - v10 * (a4 * sinx[0]);
if ( !i )
{
moveto(v7 + a1);
goto LABEL_3;
}
result = lineto(v7 + a1, a3 * cosx * v10 + a4 * sinx[0] * v9 + a2);
if ( v5 > 36 )
break;
LABEL_3:
++v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(double a1, double a2, double a3, double a4, double a5)
{
int v5; // ebp
int i; // ebx
double v7; // xmm0_8
__int64 result; // rax
double v9; // [rsp+0h] [rbp-58h]
double v10; // [rsp+8h] [rbp-50h]
double cosx; // [rsp+20h] [rbp-38h] BYREF
double sinx[6]; // [rsp+28h] [rbp-30h] BYREF

sincos(a5, sinx, &cosx);
v9 = cosx;
v10 = sinx[0];
v5 = 1;
for ( i = 0; ; ++i )
{
sincos((double)i * 0.08726646259971647, sinx, &cosx);
v7 = v9 * (a3 * cosx) - v10 * (a4 * sinx[0]);
if ( !i )
{
moveto(v7 + a1);
goto LABEL_3;
}
result = lineto(v7 + a1, a3 * cosx * v10 + a4 * sinx[0] * v9 + a2);
if ( v5 > 36 )
break;
LABEL_3:
++v5;
}
return result;
}

original_code:
void half_ellipse(const double x0, const double y0, const double a, const double b, const double theta)
{
   const int npts = 36;
   const double delta = 3.14159265358979323846 / (double)npts;
   const double sintheta = sin(theta);
   const double costheta = cos(theta);
   int i;
   for (i = 0; i <= npts; i++) {
      const double t = (double)i * delta;
      const double x = (a * cos(t) * costheta) - (b * sin(t) * sintheta);
      const double y = (a * cos(t) * sintheta) + (b * sin(t) * costheta);
      if (i == 0)
         moveto(x0 + x, y0 + y);
      else
         lineto(x0 + x, y0 + y);
   }
}

canonical_original_code:
void half_ellipse(double x0, double y0, double a, double b, double theta)
{
   int npts = 36;
   double delta = 3.14159265358979323846 / (double)npts;
   double sintheta = sin(theta);
   double costheta = cos(theta);
   int i;
   for (i = 0; i <= npts; i++) {
      double t = (double)i * delta;
      double x = (a * cos(t) * costheta) - (b * sin(t) * sintheta);
      double y = (a * cos(t) * sintheta) + (b * sin(t) * costheta);
      if (i == 0)
         moveto(x0 + x, y0 + y);
      else
         lineto(x0 + x, y0 + y);
   }
}

variable_types: a double

variable_types: b double

variable_types: theta double

variable_types: npts int

variable_types: delta double

variable_types: sintheta double

variable_types: costheta double

variable_types: t double

variable_types: x double

variable_types: y double


ellipticalarch

decompiled_code:
__int64 __fastcall ellipticalarch(double a1, double a2, double a3, double a4, double a5)
{
moveto(a1 + a4);
lineto(a1 + a4, a3);
half_ellipse(a1, a3, a4, a5, 0.0);
return lineto(a1 - a4, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(double a1, double a2, double a3, double a4, double a5)
{
moveto(a1 + a4);
lineto(a1 + a4, a3);
func4(a1, a3, a4, a5, 0.0);
return lineto(a1 - a4, a2);
}

original_code:
void ellipticalarch(const double xc, const double y0, const double yc, const double a, const double b)
{
   moveto(xc + a, y0);
   lineto(xc + a, yc);
   half_ellipse(xc, yc, a, b, 0.0);
   lineto(xc - a, y0);
}

canonical_original_code:
void ellipticalarch(double xc, double y0, double yc, double a, double b)
{
   moveto(xc + a, y0);
   lineto(xc + a, yc);
   half_ellipse(xc, yc, a, b, 0.0);
   lineto(xc - a, y0);
}

variable_types: xc double

variable_types: yc double


pointedarch

decompiled_code:
__int64 __fastcall pointedarch(double a1, double a2, double a3, double a4, double a5)
{
double v6; // rbx
double v7; // xmm2_8

v6 = acos(a5 / (a4 + a5));
moveto(a1 - a4);
lineto(a1 - a4, a3);
*(_QWORD *)&v7 = COERCE_UNSIGNED_INT64(v6 * 57.29577951308232) ^ LC12;
arc(a5 + a1, a3, v7);
arc(a1 - a5, a3, v7);
return lineto(a4 + a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(double a1, double a2, double a3, double a4, double a5)
{
double v6; // rbx
double v7; // xmm2_8

v6 = acos(a5 / (a4 + a5));
moveto(a1 - a4);
lineto(a1 - a4, a3);
*(_QWORD *)&v7 = COERCE_UNSIGNED_INT64(v6 * 57.29577951308232) ^ LC12;
arc(a5 + a1, a3, v7);
arc(a1 - a5, a3, v7);
return lineto(a4 + a1, a2);
}

original_code:
void pointedarch(const double xc, const double y0, const double yc, const double d1, const double d2)
{
   const double degrees = acos(d2 / (d1 + d2)) * (180.0 / 3.14159265358979323846);
   moveto(xc - d1, y0);
   lineto(xc - d1, yc);
   arc(xc + d2, yc, -degrees);
   arc(xc - d2, yc, -degrees);
   lineto(xc + d1, y0);
}

canonical_original_code:
void pointedarch(double xc, double y0, double yc, double d1, double d2)
{
   double degrees = acos(d2 / (d1 + d2)) * (180.0 / 3.14159265358979323846);
   moveto(xc - d1, y0);
   lineto(xc - d1, yc);
   arc(xc + d2, yc, -degrees);
   arc(xc - d2, yc, -degrees);
   lineto(xc + d1, y0);
}

variable_types: degrees double


original_code:
void draw_oval(const struct Point *const p1, const struct Point *const p2, const struct Point *const vec90)
{
   moveto(p1->x + vec90->x, p1->y + vec90->y);
   arc(p1->x, p1->y, 180.0);
   lineto(p2->x - vec90->x, p2->y - vec90->y);
   arc(p2->x, p2->y, 180.0);
   lineto(p1->x + vec90->x, p1->y + vec90->y);
}

canonical_original_code:
void draw_oval(struct Point *p1, struct Point *p2, struct Point *vec90)
{
   moveto(p1->x + vec90->x, p1->y + vec90->y);
   arc(p1->x, p1->y, 180.0);
   lineto(p2->x - vec90->x, p2->y - vec90->y);
   arc(p2->x, p2->y, 180.0);
   lineto(p1->x + vec90->x, p1->y + vec90->y);
}


decompiled_code:
__int64 __fastcall multi_oval(double *a1, double *a2, int a3, double a4, double a5)
{
double v6; // xmm0_8
double v7; // xmm0_8
__int64 result; // rax
double v9; // xmm1_8
int v10; // ebx
double v11; // xmm0_8
double v13; // [rsp+8h] [rbp-50h]
double v14; // [rsp+8h] [rbp-50h]
double v15; // [rsp+10h] [rbp-48h]
double v16; // [rsp+18h] [rbp-40h]
__int64 v17[7]; // [rsp+20h] [rbp-38h] BYREF

v13 = *a1 - *a2;
v16 = a1[1] - a2[1];
v6 = v13 * v13 + v16 * v16;
if ( v6 < 0.0 )
v7 = sqrt(v6);
else
v7 = sqrt(v6);
result = (unsigned int)(a3 - 1);
v15 = (a5 - a4) / (double)(int)result;
v9 = v13 / v7;
v14 = v16 / v7;
if ( a3 > 0 )
{
v10 = 0;
do
{
v11 = (double)v10 * v15 + a4;
*(double *)v17 = v14 * v11;
*(double *)&v17[1] = v11 * COERCE_DOUBLE(*(_QWORD *)&v9 ^ LC2);
result = draw_oval(a1, a2, (double *)v17);
++v10;
}
while ( a3 != v10 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(double *a1, double *a2, int a3, double a4, double a5)
{
double v6; // xmm0_8
double v7; // xmm0_8
__int64 result; // rax
double v9; // xmm1_8
int v10; // ebx
double v11; // xmm0_8
double v13; // [rsp+8h] [rbp-50h]
double v14; // [rsp+8h] [rbp-50h]
double v15; // [rsp+10h] [rbp-48h]
double v16; // [rsp+18h] [rbp-40h]
__int64 v17[7]; // [rsp+20h] [rbp-38h] BYREF

v13 = *a1 - *a2;
v16 = a1[1] - a2[1];
v6 = v13 * v13 + v16 * v16;
if ( v6 < 0.0 )
v7 = sqrt(v6);
else
v7 = sqrt(v6);
result = (unsigned int)(a3 - 1);
v15 = (a5 - a4) / (double)(int)result;
v9 = v13 / v7;
v14 = v16 / v7;
if ( a3 > 0 )
{
v10 = 0;
do
{
v11 = (double)v10 * v15 + a4;
*(double *)v17 = v14 * v11;
*(double *)&v17[1] = v11 * COERCE_DOUBLE(*(_QWORD *)&v9 ^ LC2);
result = func0(a1, a2, (double *)v17);
++v10;
}
while ( a3 != v10 );
}
return result;
}

original_code:
void multi_oval(struct Point *p1, struct Point *p2, const double inner, const double outer, const int n)
{
   int i;
   struct Point vec;
   struct Point vec90;
   const double dx = p1->x - p2->x;
   const double dy = p1->y - p2->y;
   const double mag = sqrt((dx * dx) + (dy * dy));
   const double delta_r = (outer - inner) / (double)(n - 1);
   vec.x = dx / mag;
   vec.y = dy / mag;
   for (i = 0; i < n; i++) {
      const double r = inner + (i * delta_r);
      vec90.x = vec.y * r;
      vec90.y = -vec.x * r;
      draw_oval(p1, p2, &vec90);
   }
}

canonical_original_code:
void multi_oval(struct Point *p1, struct Point *p2, double inner, double outer, int n)
{
   int i;
   struct Point vec;
   struct Point vec90;
   double dx = p1->x - p2->x;
   double dy = p1->y - p2->y;
   double mag = sqrt((dx * dx) + (dy * dy));
   double delta_r = (outer - inner) / (double)(n - 1);
   vec.x = dx / mag;
   vec.y = dy / mag;
   for (i = 0; i < n; i++) {
      double r = inner + (i * delta_r);
      vec90.x = vec.y * r;
      vec90.y = -vec.x * r;
      draw_oval(p1, p2, &vec90);
   }
}

variable_types: inner double

variable_types: outer double

variable_types: n int

variable_types:
vec
struct Point { double x; double y; }

variable_types: dx double

variable_types: dy double

variable_types: mag double


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
double *v4; // rbp
double *v5; // r12
int i; // ebx
double v7; // xmm0_8
int v8; // ebx
double v10; // [rsp+8h] [rbp-150h]
double v11; // [rsp+10h] [rbp-148h]
double v12; // [rsp+18h] [rbp-140h]
double cosx; // [rsp+20h] [rbp-138h] BYREF
double sinx; // [rsp+28h] [rbp-130h] BYREF
double v15[32]; // [rsp+30h] [rbp-128h] BYREF
double v16; // [rsp+130h] [rbp-28h] BYREF
double v17[4]; // [rsp+138h] [rbp-20h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
if ( (int)plotbegin(1LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v17, &v16);
v10 = 0.5 * v17[0];
v11 = 0.5 * v16;
v12 = 0.5 * v16 - 1600.0;
v4 = v15;
v5 = v15;
for ( i = 0; i != 5; ++i )
{
sincos((double)i * 1.256637061435917, &sinx, &cosx);
v7 = sinx;
*v5 = v12 * cosx + v10;
v5[1] = v7 * v12 + v11;
v5 += 2;
}
v8 = 0;
do
{
multi_oval(v4, &v15[2 * (++v8 % 5)], 12, 600.0, 1600.0);
v4 += 2;
}
while ( v8 != 5 );
plotend();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
double *v4; // rbp
double *v5; // r12
int i; // ebx
double v7; // xmm0_8
int v8; // ebx
double v10; // [rsp+8h] [rbp-150h]
double v11; // [rsp+10h] [rbp-148h]
double v12; // [rsp+18h] [rbp-140h]
double cosx; // [rsp+20h] [rbp-138h] BYREF
double sinx; // [rsp+28h] [rbp-130h] BYREF
double v15[32]; // [rsp+30h] [rbp-128h] BYREF
double v16; // [rsp+130h] [rbp-28h] BYREF
double v17[4]; // [rsp+138h] [rbp-20h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
if ( (int)plotbegin(1LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v17, &v16);
v10 = 0.5 * v17[0];
v11 = 0.5 * v16;
v12 = 0.5 * v16 - 1600.0;
v4 = v15;
v5 = v15;
for ( i = 0; i != 5; ++i )
{
sincos((double)i * 1.256637061435917, &sinx, &cosx);
v7 = sinx;
*v5 = v12 * cosx + v10;
v5[1] = v7 * v12 + v11;
v5 += 2;
}
v8 = 0;
do
{
func1(v4, &v15[2 * (++v8 % 5)], 12, 600.0, 1600.0);
v4 += 2;
}
while ( v8 != 5 );
plotend();
return 0;
}

original_code:
int main(int argc, char * const argv[])
{
   int opt;
   int i, j;
   double xc, yc;
   double maxx, maxy;
   double delta;
   int nsides = 5;
   double outer = 40.0;
   double inner = 15.0;
   struct Point pt[16];
   double radius;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(1) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   xc = maxx / 2.0;
   yc = maxy / 2.0;
   delta = (2.0 * 3.14159265358979323846) / (double)nsides;
   radius = (maxy / 2.0) - (outer * 40.0);
   for (i = 0; i < nsides; i++) {
      const double theta = (double)i * delta;
      pt[i].x = xc + (radius * cos(theta));
      pt[i].y = yc + (radius * sin(theta));
   }
   for (i = 0; i < nsides; i++) {
      j = (i + 1) % nsides;
      multi_oval(&pt[i], &pt[j], inner * 40.0, outer * 40.0, 12);
   }
   plotend();
   return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int opt;
   int i; int j;
   double xc; double yc;
   double maxx; double maxy;
   double delta;
   int nsides = 5;
   double outer = 40.0;
   double inner = 15.0;
   struct Point pt[16];
   double radius;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(1) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   xc = maxx / 2.0;
   yc = maxy / 2.0;
   delta = (2.0 * 3.14159265358979323846) / (double)nsides;
   radius = (maxy / 2.0) - (outer * 40.0);
   for (i = 0; i < nsides; i++) {
      double theta = (double)i * delta;
      pt[i].x = xc + (radius * cos(theta));
      pt[i].y = yc + (radius * sin(theta));
   }
   for (i = 0; i < nsides; i++) {
      j = (i + 1) % nsides;
      multi_oval(&pt[i], &pt[j], inner * 40.0, outer * 40.0, 12);
   }
   plotend();
   return (0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: opt int

variable_types: i int

variable_types: j int

variable_types: maxx double

variable_types: maxy double

variable_types: nsides int

variable_types: struct Point { double x; double y; } [16]

variable_types: radius double

variable_types: theta double


decompiled_code:
__int64 __fastcall square_triangle(double a1, double a2, double a3, double a4)
{
double v4; // r14
double v5; // r15

rectangle(a1, a2, a3 + a1, a3 + a2);
moveto(a1, a2);
v4 = a3 * 0.5 + a2;
lineto(a1 - a4, v4);
lineto(a1, a3 + a2);
v5 = a3 * 0.5 + a1;
lineto(v5, a2 + a4 + a3);
lineto(a3 + a1, a3 + a2);
lineto(a3 + a1 + a4, v4);
lineto(a3 + a1, a2);
lineto(v5, a2 - a4);
return lineto(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(double a1, double a2, double a3, double a4)
{
double v4; // r14
double v5; // r15

rectangle(a1, a2, a3 + a1, a3 + a2);
moveto(a1, a2);
v4 = a3 * 0.5 + a2;
lineto(a1 - a4, v4);
lineto(a1, a3 + a2);
v5 = a3 * 0.5 + a1;
lineto(v5, a2 + a4 + a3);
lineto(a3 + a1, a3 + a2);
lineto(a3 + a1 + a4, v4);
lineto(a3 + a1, a2);
lineto(v5, a2 - a4);
return lineto(a1, a2);
}

original_code:
void square_triangle(const double x, const double y, const double side, const double ht)
{
   const double hside = side / 2.0;
   rectangle(x, y, x + side, y + side);
   moveto(x, y);
   lineto(x - ht, y + hside);
   lineto(x, y + side);
   lineto(x + hside, y + ht + side);
   lineto(x + side, y + side);
   lineto(x + side + ht, y + hside);
   lineto(x + side, y);
   lineto(x + hside, y - ht);
   lineto(x, y);
}

canonical_original_code:
void square_triangle(double x, double y, double side, double ht)
{
   double hside = side / 2.0;
   rectangle(x, y, x + side, y + side);
   moveto(x, y);
   lineto(x - ht, y + hside);
   lineto(x, y + side);
   lineto(x + hside, y + ht + side);
   lineto(x + side, y + side);
   lineto(x + side + ht, y + hside);
   lineto(x + side, y);
   lineto(x + hside, y - ht);
   lineto(x, y);
}

variable_types: x double

variable_types: y double

variable_types: side double

variable_types: ht double

variable_types: hside double


original_code:
void draw_module(const double x, const double y, const double side, const int firstx, const int lastx, const int firsty, const int lasty)
{
   int i;
   double trueside;
   const double step = 5.5 * Scale;
   const double radius = sqrt ((step * step) + (step * step));
   double hside = side / 2.0;
   double offset = 3.0 * step;
   moveto(x + offset, y + hside);
   lineto(x + side - offset, y + hside);
   moveto(x + hside, y + offset);
   lineto(x + hside, y + side - offset);
   for (i = 0; i < 3; i++) {
      offset = (double)(i + 1) * step;
      trueside = side - (2.0 * step * (double)(i + 1));
      square_triangle(x + offset, y + offset, trueside, step);
   }
   if (firsty) {
      moveto(x + radius, y);
      if (firstx)
         arc(x, y, 90.0);
      else
         arc(x, y, 180.0);
   }
   else if (firstx) {
      moveto(x, y - radius);
      arc(x, y, 180.0);
   }
   else
      circle(x, y, radius);
   if (lastx) {
      moveto(x + side, y + radius);
      if (firsty)
         arc(x + side, y, 90.0);
      else
         arc(x + side, y, 180.0);
   }
   if (lasty) {
      if (firstx) {
         moveto(x, y + side - radius);
         arc(x, y + side, 90.0);
      }
      else {
         moveto(x - radius, y + side);
         arc(x, y + side, 180.0);
      }
   }
   if (lastx && lasty) {
      moveto(x + side - radius, y + side);
      arc(x + side, y + side, 90.0);
   }
}

canonical_original_code:
void draw_module(double x, double y, double side, int firstx, int lastx, int firsty, int lasty)
{
   int i;
   double trueside;
   double step = 5.5 * Scale;
   double radius = sqrt ((step * step) + (step * step));
   double hside = side / 2.0;
   double offset = 3.0 * step;
   moveto(x + offset, y + hside);
   lineto(x + side - offset, y + hside);
   moveto(x + hside, y + offset);
   lineto(x + hside, y + side - offset);
   for (i = 0; i < 3; i++) {
      offset = (double)(i + 1) * step;
      trueside = side - (2.0 * step * (double)(i + 1));
      square_triangle(x + offset, y + offset, trueside, step);
   }
   if (firsty) {
      moveto(x + radius, y);
      if (firstx)
         arc(x, y, 90.0);
      else
         arc(x, y, 180.0);
   }
   else if (firstx) {
      moveto(x, y - radius);
      arc(x, y, 180.0);
   }
   else
      circle(x, y, radius);
   if (lastx) {
      moveto(x + side, y + radius);
      if (firsty)
         arc(x + side, y, 90.0);
      else
         arc(x + side, y, 180.0);
   }
   if (lasty) {
      if (firstx) {
         moveto(x, y + side - radius);
         arc(x, y + side, 90.0);
      }
      else {
         moveto(x - radius, y + side);
         arc(x, y + side, 180.0);
      }
   }
   if (lastx && lasty) {
      moveto(x + side - radius, y + side);
      arc(x + side, y + side, 90.0);
   }
}

variable_types: firstx int

variable_types: lastx int

variable_types: firsty int

variable_types: lasty int

variable_types: trueside double

variable_types: step double

variable_types: offset double


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int i; // ebp
int j; // ebx
double v7; // [rsp+0h] [rbp-38h]
double v8; // [rsp+8h] [rbp-30h]
double v9; // [rsp+10h] [rbp-28h] BYREF
double v10[4]; // [rsp+18h] [rbp-20h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
Scale = LC9;
if ( (int)plotbegin(0LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v10, &v9);
v8 = (v10[0] - 14400.0) * 0.5;
v7 = (v9 - 10800.0) * 0.5;
rectangle(v8, v7, v8 + 14400.0, v7 + 10800.0);
for ( i = 0; i != 8; ++i )
{
for ( j = 0; j != 6; ++j )
draw_module(i == 0, i == 7, j == 0, j == 5, (double)i * 1800.0 + v8, (double)j * 1800.0 + v7, 1800.0);
}
plotend();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int i; // ebp
int j; // ebx
double v7; // [rsp+0h] [rbp-38h]
double v8; // [rsp+8h] [rbp-30h]
double v9; // [rsp+10h] [rbp-28h] BYREF
double v10[4]; // [rsp+18h] [rbp-20h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
Scale = LC9;
if ( (int)plotbegin(0LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v10, &v9);
v8 = (v10[0] - 14400.0) * 0.5;
v7 = (v9 - 10800.0) * 0.5;
rectangle(v8, v7, v8 + 14400.0, v7 + 10800.0);
for ( i = 0; i != 8; ++i )
{
for ( j = 0; j != 6; ++j )
func1(i == 0, i == 7, j == 0, j == 5, (double)i * 1800.0 + v8, (double)j * 1800.0 + v7, 1800.0);
}
plotend();
return 0;
}

original_code:
int main(int argc, char * const argv[])
{
   int opt;
   int ix, iy;
   int nx, ny;
   double pitch;
   double x0, y0;
   double width, height;
   double xoffset, yoffset;
   double maxx, maxy;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 'n':
      case 'o':
      case 'p':
      case 's':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   nx = 8;
   ny = 6;
   Scale = 40.0;
   pitch = 45.0 * Scale;
   if (plotbegin(0) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   width = nx * pitch;
   height = ny * pitch;
   xoffset = (maxx - width) / 2.0;
   yoffset = (maxy - height) / 2.0;
   rectangle(xoffset, yoffset, xoffset + width, yoffset + height);
   for (ix = 0; ix < nx; ix++) {
      for (iy = 0; iy < ny; iy++) {
         x0 = xoffset + ((double)ix * pitch);
         y0 = yoffset + ((double)iy * pitch);
         draw_module(x0, y0, pitch, ix == 0, ix == nx - 1, iy == 0, iy == ny - 1);
      }
   }
   plotend();
   return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int opt;
   int ix; int iy;
   int nx; int ny;
   double pitch;
   double x0; double y0;
   double width; double height;
   double xoffset; double yoffset;
   double maxx; double maxy;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 'n':
      case 'o':
      case 'p':
      case 's':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   nx = 8;
   ny = 6;
   Scale = 40.0;
   pitch = 45.0 * Scale;
   if (plotbegin(0) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   width = nx * pitch;
   height = ny * pitch;
   xoffset = (maxx - width) / 2.0;
   yoffset = (maxy - height) / 2.0;
   rectangle(xoffset, yoffset, xoffset + width, yoffset + height);
   for (ix = 0; ix < nx; ix++) {
      for (iy = 0; iy < ny; iy++) {
         x0 = xoffset + ((double)ix * pitch);
         y0 = yoffset + ((double)iy * pitch);
         draw_module(x0, y0, pitch, ix == 0, ix == nx - 1, iy == 0, iy == ny - 1);
      }
   }
   plotend();
   return (0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: opt int

variable_types: ix int

variable_types: iy int

variable_types: nx int

variable_types: ny int

variable_types: pitch double

variable_types: width double

variable_types: height double

variable_types: xoffset double

variable_types: yoffset double

variable_types: maxx double

variable_types: maxy double


sutpoly

original_code:
void sutpoly(const int nsides, const struct Vertex vertex[], const int level, const double ratio)
{
   int i;
   int i1;
   int opp, opp1;
   double dx, dy;
   double x1, y1;
   double x2, y2;
   struct Vertex newv[32];
   drawpoly(nsides, vertex);
   for (i = 0; i < nsides; i++) {
      i1 = (i + 1) % nsides;
      x1 = (vertex[i].x + vertex[i1].x) / 2.0;
      y1 = (vertex[i].y + vertex[i1].y) / 2.0;
      if (nsides & 1) {
         opp = (i + (nsides / 2) + 1) % nsides;
         x2 = vertex[opp].x;
         y2 = vertex[opp].y;
      }
      else {
         opp = (i + (nsides / 2)) % nsides;
         opp1 = (opp + 1) % nsides;
         x2 = (vertex[opp].x + vertex[opp1].x) / 2.0;
         y2 = (vertex[opp].y + vertex[opp1].y) / 2.0;
      }
      dx = (x2 - x1) * ratio;
      dy = (y2 - y1) * ratio;
      x2 = x1 + dx;
      y2 = y1 + dy;
      moveto(x1, y1);
      lineto(x2, y2);
      newv[i].x = x2;
      newv[i].y = y2;
   }
   if (level > 0)
      sutpoly(nsides, newv, level - 1, ratio);
   else
      drawpoly(nsides, newv);
}

canonical_original_code:
void sutpoly(int nsides, struct Vertex vertex[], int level, double ratio)
{
   int i;
   int i1;
   int opp; int opp1;
   double dx; double dy;
   double x1; double y1;
   double x2; double y2;
   struct Vertex newv[32];
   drawpoly(nsides, vertex);
   for (i = 0; i < nsides; i++) {
      i1 = (i + 1) % nsides;
      x1 = (vertex[i].x + vertex[i1].x) / 2.0;
      y1 = (vertex[i].y + vertex[i1].y) / 2.0;
      if (nsides & 1) {
         opp = (i + (nsides / 2) + 1) % nsides;
         x2 = vertex[opp].x;
         y2 = vertex[opp].y;
      }
      else {
         opp = (i + (nsides / 2)) % nsides;
         opp1 = (opp + 1) % nsides;
         x2 = (vertex[opp].x + vertex[opp1].x) / 2.0;
         y2 = (vertex[opp].y + vertex[opp1].y) / 2.0;
      }
      dx = (x2 - x1) * ratio;
      dy = (y2 - y1) * ratio;
      x2 = x1 + dx;
      y2 = y1 + dy;
      moveto(x1, y1);
      lineto(x2, y2);
      newv[i].x = x2;
      newv[i].y = y2;
   }
   if (level > 0)
      sutpoly(nsides, newv, level - 1, ratio);
   else
      drawpoly(nsides, newv);
}

variable_types: nsides int

variable_types: struct Vertex { double x; double y; } []

variable_types: level int

variable_types: ratio double

variable_types: i int

variable_types: opp int

variable_types: dx double

variable_types: dy double

variable_types: struct Vertex { double x; double y; } [32]


sutcliffepolygon

decompiled_code:
__int64 __fastcall sutcliffepolygon(int a1, int a2, double a3, double a4, double a5, double a6)
{
__int64 i; // rbx
double v7; // xmm0_8
__int64 v8; // rax
double cosx; // [rsp+20h] [rbp-238h] BYREF
double sinx; // [rsp+28h] [rbp-230h] BYREF
__int64 v13[69]; // [rsp+30h] [rbp-228h] BYREF

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; ++i )
{
sincos((double)(int)i * (6.283185307179586 / (double)a1), &sinx, &cosx);
v7 = sinx;
v8 = 2 * i;
*(double *)&v13[v8] = a5 * cosx + a3;
*(double *)&v13[v8 + 1] = v7 * a5 + a4;
}
}
return sutpoly(a1, (double *)v13, a2, a6);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, double a3, double a4, double a5, double a6)
{
__int64 i; // rbx
double v7; // xmm0_8
__int64 v8; // rax
double cosx; // [rsp+20h] [rbp-238h] BYREF
double sinx; // [rsp+28h] [rbp-230h] BYREF
__int64 v13[69]; // [rsp+30h] [rbp-228h] BYREF

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; ++i )
{
sincos((double)(int)i * (6.283185307179586 / (double)a1), &sinx, &cosx);
v7 = sinx;
v8 = 2 * i;
*(double *)&v13[v8] = a5 * cosx + a3;
*(double *)&v13[v8 + 1] = v7 * a5 + a4;
}
}
return func1(a1, (double *)v13, a2, a6);
}

original_code:
void sutcliffepolygon(const double xc, const double yc, const double radius, const int nsides, const int levels, const double ratio)
{
   const double delta = (2.0 * 3.14159265358979323846) / (double)nsides;
   double theta;
   struct Vertex vertex[32];
   int i;
   for (i = 0; i < nsides; i++) {
      theta = (double)i * delta;
      vertex[i].x = xc + (cos(theta) * radius);
      vertex[i].y = yc + (sin(theta) * radius);
   }
   sutpoly(nsides, vertex, levels, ratio);
}

canonical_original_code:
void sutcliffepolygon(double xc, double yc, double radius, int nsides, int levels, double ratio)
{
   double delta = (2.0 * 3.14159265358979323846) / (double)nsides;
   double theta;
   struct Vertex vertex[32];
   int i;
   for (i = 0; i < nsides; i++) {
      theta = (double)i * delta;
      vertex[i].x = xc + (cos(theta) * radius);
      vertex[i].y = yc + (sin(theta) * radius);
   }
   sutpoly(nsides, vertex, levels, ratio);
}

variable_types: xc double

variable_types: yc double

variable_types: radius double

variable_types: levels int

variable_types: delta double

variable_types: theta double


drawpoly

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

moveto(*a2, a2[1]);
if ( a1 > 1 )
{
v2 = a2 + 2;
do
{
lineto(*v2, v2[1]);
v2 += 2;
}
while ( v2 != &a2[2 * (unsigned int)(a1 - 2) + 4] );
}
return lineto(*a2, a2[1]);
}

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

moveto(*a2, a2[1]);
if ( a1 > 1 )
{
v2 = a2 + 2;
do
{
lineto(*v2, v2[1]);
v2 += 2;
}
while ( v2 != &a2[2 * (unsigned int)(a1 - 2) + 4] );
}
return lineto(*a2, a2[1]);
}

original_code:
void drawpoly(const int nsides, const struct Vertex vertex[])
{
   int i;
   moveto(vertex[0].x, vertex[0].y);
   for (i = 1; i < nsides; i++)
      lineto(vertex[i].x, vertex[i].y);
   lineto(vertex[0].x, vertex[0].y);
}

canonical_original_code:
void drawpoly(int nsides, struct Vertex vertex[])
{
   int i;
   moveto(vertex[0].x, vertex[0].y);
   for (i = 1; i < nsides; i++)
      lineto(vertex[i].x, vertex[i].y);
   lineto(vertex[0].x, vertex[0].y);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
double v4; // xmm4_8
double v5; // xmm0_8
double v6; // xmm0_8
double v7; // rbx
double v9; // [rsp+8h] [rbp-40h]
double v10; // [rsp+10h] [rbp-38h]
double v11; // [rsp+10h] [rbp-38h]
double v12; // [rsp+18h] [rbp-30h]
double v13; // [rsp+20h] [rbp-28h] BYREF
double v14[4]; // [rsp+28h] [rbp-20h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
if ( (int)plotbegin(1LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v14, &v13);
v10 = 0.25 * v14[0];
v4 = 0.25 * v13;
v9 = 0.25 * v13;
v12 = v4 + v4;
v5 = (v4 + v4) * (v4 + v4) - v4 * v4;
if ( v5 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
v7 = v10 + v10;
v11 = v10 + v10 - v6;
sutcliffepolygon(5, 6, v14[0] - v11, v9 * 3.0, v9, 0.15);
sutcliffepolygon(6, 7, v11, v9 * 3.0, v9, 0.15);
sutcliffepolygon(7, 7, v14[0] - v11, v9, v9, 0.15);
sutcliffepolygon(8, 7, v11, v9, v9, 0.15);
sutcliffepolygon(9, 7, v7, v12, v9, 0.15);
plotend();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
double v4; // xmm4_8
double v5; // xmm0_8
double v6; // xmm0_8
double v7; // rbx
double v9; // [rsp+8h] [rbp-40h]
double v10; // [rsp+10h] [rbp-38h]
double v11; // [rsp+10h] [rbp-38h]
double v12; // [rsp+18h] [rbp-30h]
double v13; // [rsp+20h] [rbp-28h] BYREF
double v14[4]; // [rsp+28h] [rbp-20h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
if ( (int)plotbegin(1LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v14, &v13);
v10 = 0.25 * v14[0];
v4 = 0.25 * v13;
v9 = 0.25 * v13;
v12 = v4 + v4;
v5 = (v4 + v4) * (v4 + v4) - v4 * v4;
if ( v5 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
v7 = v10 + v10;
v11 = v10 + v10 - v6;
func2(5, 6, v14[0] - v11, v9 * 3.0, v9, 0.15);
func2(6, 7, v11, v9 * 3.0, v9, 0.15);
func2(7, 7, v14[0] - v11, v9, v9, 0.15);
func2(8, 7, v11, v9, v9, 0.15);
func2(9, 7, v7, v12, v9, 0.15);
plotend();
return 0;
}

original_code:
int main(int argc, char * const argv[])
{
   int opt;
   double w4, h4;
   double xc;
   double maxx, maxy;
   double radius;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(1) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   w4 = maxx / 4.0;
   h4 = maxy / 4.0;
   radius = maxy / 4.0;
   xc = sqrt(((2.0 * radius) * (2.0 * radius)) - (h4 * h4));
   xc = (2.0 * w4) - xc;
   sutcliffepolygon(maxx - xc, h4 * 3.0, radius, 5, 6, 0.15);
   sutcliffepolygon(xc, h4 * 3.0, radius, 6, 7, 0.15);
   sutcliffepolygon(maxx - xc, h4, radius, 7, 7, 0.15);
   sutcliffepolygon(xc, h4, radius, 8, 7, 0.15);
   sutcliffepolygon(w4 * 2.0, h4 * 2.0, radius, 9, 7, 0.15);
   plotend();
   return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int opt;
   double w4; double h4;
   double xc;
   double maxx; double maxy;
   double radius;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(1) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   w4 = maxx / 4.0;
   h4 = maxy / 4.0;
   radius = maxy / 4.0;
   xc = sqrt(((2.0 * radius) * (2.0 * radius)) - (h4 * h4));
   xc = (2.0 * w4) - xc;
   sutcliffepolygon(maxx - xc, h4 * 3.0, radius, 5, 6, 0.15);
   sutcliffepolygon(xc, h4 * 3.0, radius, 6, 7, 0.15);
   sutcliffepolygon(maxx - xc, h4, radius, 7, 7, 0.15);
   sutcliffepolygon(xc, h4, radius, 8, 7, 0.15);
   sutcliffepolygon(w4 * 2.0, h4 * 2.0, radius, 9, 7, 0.15);
   plotend();
   return (0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: opt int

variable_types: maxx double


decompiled_code:
__int64 __fastcall draw3lines(int a1, double a2, double a3, double a4, double a5, double a6)
{
double v7; // r14
double v8; // xmm1_8
double v9; // rbp

if ( a1 )
{
v7 = a3 + a5;
v8 = a3 - a5;
}
else
{
v7 = a3 - a5;
v8 = a3 + a5;
}
moveto(a6, v7);
if ( a6 <= a2 )
v9 = a2 - a4;
else
v9 = a2 + a4;
lineto(v9, v7);
lineto(v9, v8);
return lineto(a6, v8);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, double a2, double a3, double a4, double a5, double a6)
{
double v7; // r14
double v8; // xmm1_8
double v9; // rbp

if ( a1 )
{
v7 = a3 + a5;
v8 = a3 - a5;
}
else
{
v7 = a3 - a5;
v8 = a3 + a5;
}
moveto(a6, v7);
if ( a6 <= a2 )
v9 = a2 - a4;
else
v9 = a2 + a4;
lineto(v9, v7);
lineto(v9, v8);
return lineto(a6, v8);
}

original_code:
void draw3lines(const double xc, const double yc, const double x, const double y, const int up, const double maxx)
{
   double top, bottom;
   if (up) {
      top = yc + y;
      bottom = yc - y;
   }
   else {
      top = yc - y;
      bottom = yc + y;
   }
   moveto(maxx, top);
   if (maxx > xc) {
      lineto(xc + x, top);
      lineto(xc + x, bottom);
   }
   else {
      lineto(xc - x, top);
      lineto(xc - x, bottom);
   }
   lineto(maxx, bottom);
}

canonical_original_code:
void draw3lines(double xc, double yc, double x, double y, int up, double maxx)
{
   double top; double bottom;
   if (up) {
      top = yc + y;
      bottom = yc - y;
   }
   else {
      top = yc - y;
      bottom = yc + y;
   }
   moveto(maxx, top);
   if (maxx > xc) {
      lineto(xc + x, top);
      lineto(xc + x, bottom);
   }
   else {
      lineto(xc - x, top);
      lineto(xc - x, bottom);
   }
   lineto(maxx, bottom);
}

variable_types: x double

variable_types: y double

variable_types: up int

variable_types: top double

variable_types: bottom double


decompiled_code:
__int64 __fastcall draw_side(int a1, double a2, double a3, double a4, double a5)
{
int v5; // ebx
int v6; // ebp
__int64 result; // rax
double cosx; // [rsp+10h] [rbp-48h] BYREF
double sinx[8]; // [rsp+18h] [rbp-40h] BYREF

if ( a1 > 1 )
{
v5 = 1;
v6 = 0;
do
{
sincos((double)v5 * (1.570796326794897 / (double)a1), sinx, &cosx);
result = draw3lines(v6, a2, a3, a4 * cosx, a4 * sinx[0], a5);
v6 ^= 1u;
++v5;
}
while ( a1 != v5 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, double a2, double a3, double a4, double a5)
{
int v5; // ebx
int v6; // ebp
__int64 result; // rax
double cosx; // [rsp+10h] [rbp-48h] BYREF
double sinx[8]; // [rsp+18h] [rbp-40h] BYREF

if ( a1 > 1 )
{
v5 = 1;
v6 = 0;
do
{
sincos((double)v5 * (1.570796326794897 / (double)a1), sinx, &cosx);
result = func0(v6, a2, a3, a4 * cosx, a4 * sinx[0], a5);
v6 ^= 1u;
++v5;
}
while ( a1 != v5 );
}
return result;
}

original_code:
void draw_side(const double xc, const double yc, const double radius, const double maxx, const int n)
{
   int up;
   int i;
   const double delta = (3.14159265358979323846 / 2.0) / (double)n;
   double x, y;
   up = 0;
   for (i = 1; i < n; i++) {
      const double theta = i * delta;
      x = cos(theta) * radius;
      y = sin(theta) * radius;
      draw3lines(xc, yc, x, y, up, maxx);
      up = !up;
   }
}

canonical_original_code:
void draw_side(double xc, double yc, double radius, double maxx, int n)
{
   int up;
   int i;
   double delta = (3.14159265358979323846 / 2.0) / (double)n;
   double x; double y;
   up = 0;
   for (i = 1; i < n; i++) {
      double theta = i * delta;
      x = cos(theta) * radius;
      y = sin(theta) * radius;
      draw3lines(xc, yc, x, y, up, maxx);
      up = !up;
   }
}

variable_types: n int

variable_types: i int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er13
int v4; // ebx
char *v5; // r15
double v6; // rbp
double v7; // r12
int i; // ebx
double v10; // [rsp+0h] [rbp-58h]
double v11; // [rsp+8h] [rbp-50h]
double v12; // [rsp+10h] [rbp-48h] BYREF
double v13[8]; // [rsp+18h] [rbp-40h] BYREF

v3 = 64;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v4 == -1 )
break;
if ( v4 == 115 )
{
v5 = optarg;
if ( strchr(optarg, 49) )
{
v3 = 128;
}
else if ( strchr(v5, 50) )
{
v3 = 96;
}
else if ( strchr(v5, 52) )
{
v3 = 48;
}
else if ( strchr(v5, 53) )
{
v3 = 32;
}
}
else if ( v4 <= 115 )
{
if ( (unsigned int)(v4 - 110) > 2 )
goto LABEL_8;
}
else if ( (v4 & 0xFFFFFFFD) != 116 )
{
LABEL_8:
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt((unsigned int)v4, optarg);
}
if ( (int)plotbegin(0LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v13, &v12);
v11 = 0.5 * v12;
v6 = 0.5 * v13[0] - 0.5 * v12;
v10 = 0.5 * v13[0];
v7 = 0.5 * v13[0] + 0.5 * v12;
rectangle(v6, 0.0, v7);
moveto(v10, 0.0);
lineto(v10, v12);
for ( i = 1; ; ++i )
{
if ( i == 1 )
{
draw_side(v3, v10, v11, v11, v7);
continue;
}
draw_side(v3, v10, v11, v11, v6);
if ( i > 1 )
break;
}
plotend();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er13
int v4; // ebx
char *v5; // r15
double v6; // rbp
double v7; // r12
int i; // ebx
double v10; // [rsp+0h] [rbp-58h]
double v11; // [rsp+8h] [rbp-50h]
double v12; // [rsp+10h] [rbp-48h] BYREF
double v13[8]; // [rsp+18h] [rbp-40h] BYREF

v3 = 64;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v4 == -1 )
break;
if ( v4 == 115 )
{
v5 = optarg;
if ( strchr(optarg, 49) )
{
v3 = 128;
}
else if ( strchr(v5, 50) )
{
v3 = 96;
}
else if ( strchr(v5, 52) )
{
v3 = 48;
}
else if ( strchr(v5, 53) )
{
v3 = 32;
}
}
else if ( v4 <= 115 )
{
if ( (unsigned int)(v4 - 110) > 2 )
goto LABEL_8;
}
else if ( (v4 & 0xFFFFFFFD) != 116 )
{
LABEL_8:
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt((unsigned int)v4, optarg);
}
if ( (int)plotbegin(0LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v13, &v12);
v11 = 0.5 * v12;
v6 = 0.5 * v13[0] - 0.5 * v12;
v10 = 0.5 * v13[0];
v7 = 0.5 * v13[0] + 0.5 * v12;
rectangle(v6, 0.0, v7);
moveto(v10, 0.0);
lineto(v10, v12);
for ( i = 1; ; ++i )
{
if ( i == 1 )
{
func1(v3, v10, v11, v11, v7);
continue;
}
func1(v3, v10, v11, v11, v6);
if ( i > 1 )
break;
}
plotend();
return 0;
}

original_code:
int main(int argc, char * const argv[])
{
   int opt;
   int side;
   int lines;
   double height;
   double xc, yc;
   double maxx, maxy;
   double left, right;
   double radius;
   lines = 64;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
         if (strchr(optarg, '1'))
            lines = 128;
         else if (strchr(optarg, '2'))
            lines = 96;
         else if (strchr(optarg, '4'))
            lines = 48;
         else if (strchr(optarg, '5'))
            lines = 32;
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(0) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   xc = maxx / 2.0;
   yc = maxy / 2.0;
   height = maxy;
   radius = maxy / 2.0;
   left = xc - (height / 2.0);
   right = xc + (height / 2.0);
   rectangle(left, 0.0, right, maxy);
   moveto(xc, 0.0);
   lineto(xc, maxy);
   for (side = 0; side < 2; side++)
      draw_side(xc, yc, radius, side ? left : right, lines);
   plotend();
   return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int opt;
   int side;
   int lines;
   double height;
   double xc; double yc;
   double maxx; double maxy;
   double left; double right;
   double radius;
   lines = 64;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
         if (strchr(optarg, '1'))
            lines = 128;
         else if (strchr(optarg, '2'))
            lines = 96;
         else if (strchr(optarg, '4'))
            lines = 48;
         else if (strchr(optarg, '5'))
            lines = 32;
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(0) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   xc = maxx / 2.0;
   yc = maxy / 2.0;
   height = maxy;
   radius = maxy / 2.0;
   left = xc - (height / 2.0);
   right = xc + (height / 2.0);
   rectangle(left, 0.0, right, maxy);
   moveto(xc, 0.0);
   lineto(xc, maxy);
   for (side = 0; side < 2; side++)
      draw_side(xc, yc, radius, side ? left : right, lines);
   plotend();
   return (0);
}

variable_types: side int

variable_types: lines int

variable_types: height double

variable_types: xc double

variable_types: maxy double

variable_types: left double

variable_types: right double


straightbox

decompiled_code:
int __fastcall straightbox(double a1, double a2, double a3, double a4)
{
__int64 v4; // rbp
__int64 v5; // rbx

v4 = (unsigned int)(int)(a1 + 0.5);
v5 = (unsigned int)(int)(a2 + 0.5);
printf("PU;PA%d,%d;", v4, v5);
return printf(
"PD;PA%d,%d,%d,%d,%d,%d,%d,%d\n",
(unsigned int)(int)(a3 + 0.5),
(unsigned int)v5,
(unsigned int)(int)(a3 + 0.5),
(unsigned int)(int)(a4 + 0.5),
(unsigned int)v4,
(unsigned int)(int)(a4 + 0.5),
v4,
v5);
}

canonical_decompiled_code:
int __fastcall func7(double a1, double a2, double a3, double a4)
{
__int64 v4; // rbp
__int64 v5; // rbx

v4 = (unsigned int)(int)(a1 + 0.5);
v5 = (unsigned int)(int)(a2 + 0.5);
printf("PU;PA%d,%d;", v4, v5);
return printf(
"PD;PA%d,%d,%d,%d,%d,%d,%d,%d\n",
(unsigned int)(int)(a3 + 0.5),
(unsigned int)v5,
(unsigned int)(int)(a3 + 0.5),
(unsigned int)(int)(a4 + 0.5),
(unsigned int)v4,
(unsigned int)(int)(a4 + 0.5),
v4,
v5);
}

original_code:
void straightbox(const double x0, const double y0, const double x1, const double y1)
{
   int ix0, iy0, ix1, iy1;
   ix0 = (int)(x0 + 0.5);
   iy0 = (int)(y0 + 0.5);
   ix1 = (int)(x1 + 0.5);
   iy1 = (int)(y1 + 0.5);
   printf("PU;PA%d,%d;", ix0, iy0);
   printf("PD;PA%d,%d,%d,%d,%d,%d,%d,%d\n", ix1, iy0, ix1, iy1, ix0, iy1, ix0, iy0);
}

canonical_original_code:
void straightbox(double x0, double y0, double x1, double y1)
{
   int ix0; int iy0; int ix1; int iy1;
   ix0 = (int)(x0 + 0.5);
   iy0 = (int)(y0 + 0.5);
   ix1 = (int)(x1 + 0.5);
   iy1 = (int)(y1 + 0.5);
   printf("PU;PA%d,%d;", ix0, iy0);
   printf("PD;PA%d,%d,%d,%d,%d,%d,%d,%d\n", ix1, iy0, ix1, iy1, ix0, iy1, ix0, iy0);
}


gencurve

decompiled_code:
void __fastcall gencurve(double *a1, __int64 a2, int a3, double a4, double a5, double a6)
{
__int64 v6; // r15
__int64 v7; // rbx
double v8; // [rsp+0h] [rbp-40h]

v8 = 1.0 / (double)a3;
if ( a3 >= 0 )
{
v6 = (unsigned int)(a3 + 1);
v7 = 0LL;
do
{
*(double *)(a2 + 8 * v7) = quadfunc(a1, a4, a5, a6, (double)(int)v7 * v8);
++v7;
}
while ( v7 != v6 );
}
}

canonical_decompiled_code:
void __fastcall func9(double *a1, __int64 a2, int a3, double a4, double a5, double a6)
{
__int64 v6; // r15
__int64 v7; // rbx
double v8; // [rsp+0h] [rbp-40h]

v8 = 1.0 / (double)a3;
if ( a3 >= 0 )
{
v6 = (unsigned int)(a3 + 1);
v7 = 0LL;
do
{
*(double *)(a2 + 8 * v7) = func8(a1, a4, a5, a6, (double)(int)v7 * v8);
++v7;
}
while ( v7 != v6 );
}
}

original_code:
void gencurve (struct Weights *wp, double x0, double x1, double x2,
               double x[], int n)
{
   double t;
   double step;
   int i;
   step = 1.0 / (double)n;
   for (i = 0; i <= n; i++) {
      t = i * step;
      x[i] = quadfunc (wp, x0, x1, x2, t);
   }
}

canonical_original_code:
void gencurve(struct Weights *wp, double x0, double x1, double x2, double x[], int n)
{
   double t;
   double step;
   int i;
   step = 1.0 / (double)n;
   for (i = 0; i <= n; i++) {
      t = i * step;
      x[i] = quadfunc (wp, x0, x1, x2, t);
   }
}

variable_types: struct Weights { double w0; double w1; double w2; } *

variable_types:
x
double []

variable_types: t double

variable_types: step double


drawbox

original_code:
void drawbox(const double x0, const double y0, const double width, const double height)
{
   double xpts[(16) + 1], ypts[(16) + 1], wpts[(16) + 1];
   struct Point p0, p1, p2, p3, p4, p5, p6, p7;
   double w0 = 1.0;
   double w1 = 3.0;
   double w2 = 1.0;
   double xmin, ymin;
   double xmax, ymax;
   double xstep = 240.0;
   double ystep = 240.0;
   int i;
   static double controls[8] = {
      0.0,
      32.0, 16.0, 8.0, 4.0, 2.0, 1.0, 0.5
   };
   straightbox(x0, y0, x0 + width, y0 + height);
   for (i = 1; i <= 6; i++) {
      xmin = x0 + (i * xstep);
      xmax = (x0 + width) - (i * xstep);
      ymin = y0 + (i * ystep);
      ymax = (y0 + height) - (i * ystep);
      p0.x = x0 + (width / 2.0);
      p0.y = ymax;
      p1.x = xmin;
      p1.y = ymax;
      p2.x = xmin;
      p2.y = y0 + (height / 2.0);
      p3.x = xmin;
      p3.y = ymin;
      p4.x = x0 + (width / 2.0);
      p4.y = ymin;
      p5.x = xmax;
      p5.y = ymin;
      p6.x = xmax;
      p6.y = y0 + (height / 2.0);
      p7.x = xmax;
      p7.y = ymax;
      w1 = controls[i];
      genconic(p0, p1, p2, w0, w1, w2, xpts, ypts, wpts, (16));
      showcurve(1, xpts, ypts, wpts, (16), 1);
      genconic(p2, p3, p4, w0, w1, w2, xpts, ypts, wpts, (16));
      showcurve(1, xpts, ypts, wpts, (16), 0);
      genconic(p4, p5, p6, w0, w1, w2, xpts, ypts, wpts, (16));
      showcurve(1, xpts, ypts, wpts, (16), 0);
      genconic(p6, p7, p0, w0, w1, w2, xpts, ypts, wpts, (16));
      showcurve(1, xpts, ypts, wpts, (16), 0);
   }
   printf("PU;PA%d,%d;CI%d;\n", (int)p4.x, (int)p6.y, (int)((width - (14.0 * xstep)) / 2.0));
}

canonical_original_code:
void drawbox(double x0, double y0, double width, double height)
{
   double xpts[-1]; double ypts[-1]; double wpts[-1];
   struct Point p0; struct Point p1; struct Point p2; struct Point p3; struct Point p4; struct Point p5; struct Point p6; struct Point p7;
   double w0 = 1.0;
   double w1 = 3.0;
   double w2 = 1.0;
   double xmin; double ymin;
   double xmax; double ymax;
   double xstep = 240.0;
   double ystep = 240.0;
   int i;
   static double controls[8] = {
      0.0,
      32.0, 16.0, 8.0, 4.0, 2.0, 1.0, 0.5
   };
   straightbox(x0, y0, x0 + width, y0 + height);
   for (i = 1; i <= 6; i++) {
      xmin = x0 + (i * xstep);
      xmax = (x0 + width) - (i * xstep);
      ymin = y0 + (i * ystep);
      ymax = (y0 + height) - (i * ystep);
      p0.x = x0 + (width / 2.0);
      p0.y = ymax;
      p1.x = xmin;
      p1.y = ymax;
      p2.x = xmin;
      p2.y = y0 + (height / 2.0);
      p3.x = xmin;
      p3.y = ymin;
      p4.x = x0 + (width / 2.0);
      p4.y = ymin;
      p5.x = xmax;
      p5.y = ymin;
      p6.x = xmax;
      p6.y = y0 + (height / 2.0);
      p7.x = xmax;
      p7.y = ymax;
      w1 = controls[i];
      genconic(p0, p1, p2, w0, w1, w2, xpts, ypts, wpts, (16));
      showcurve(1, xpts, ypts, wpts, (16), 1);
      genconic(p2, p3, p4, w0, w1, w2, xpts, ypts, wpts, (16));
      showcurve(1, xpts, ypts, wpts, (16), 0);
      genconic(p4, p5, p6, w0, w1, w2, xpts, ypts, wpts, (16));
      showcurve(1, xpts, ypts, wpts, (16), 0);
      genconic(p6, p7, p0, w0, w1, w2, xpts, ypts, wpts, (16));
      showcurve(1, xpts, ypts, wpts, (16), 0);
   }
   printf("PU;PA%d,%d;CI%d;\n", (int)p4.x, (int)p6.y, (int)((width - (14.0 * xstep)) / 2.0));
}

variable_types: width double

variable_types:
xpts
double [-1]

variable_types:
ypts
double [-1]

variable_types:
wpts
double [-1]

variable_types: xmin double

variable_types: ymin double

variable_types: xmax double

variable_types: ymax double

variable_types: xstep double

variable_types: ystep double

variable_types:
controls
double [8]


splitside

decompiled_code:
void __fastcall splitside(int a1, double *a2, double a3, double a4, double a5, double a6)
{
int v7; // eax
double v8; // xmm0_8

if ( a1 >= 0 )
{
v7 = 0;
do
{
v8 = (double)v7 / (double)a1;
*a2 = a3 * v8 + a5 * (1.0 - v8);
a2[1] = v8 * a4 + (1.0 - v8) * a6;
++v7;
a2 += 2;
}
while ( v7 != a1 + 1 );
}
}

canonical_decompiled_code:
void __fastcall func0(int a1, double *a2, double a3, double a4, double a5, double a6)
{
int v7; // eax
double v8; // xmm0_8

if ( a1 >= 0 )
{
v7 = 0;
do
{
v8 = (double)v7 / (double)a1;
*a2 = a3 * v8 + a5 * (1.0 - v8);
a2[1] = v8 * a4 + (1.0 - v8) * a6;
++v7;
a2 += 2;
}
while ( v7 != a1 + 1 );
}
}

original_code:
void splitside(const struct Vertex v1, const struct Vertex v2, const int nsubdiv, struct Vertex *result)
{
   int i;
   for (i = 0; i <= nsubdiv; i++) {
      const double p1 = i / (double)nsubdiv;
      const double p2 = 1.0 - p1;
      result[i].x = (v1.x * p1) + (v2.x * p2);
      result[i].y = (v1.y * p1) + (v2.y * p2);
   }
}

canonical_original_code:
void splitside(struct Vertex v1, struct Vertex v2, int nsubdiv, struct Vertex *result)
{
   int i;
   for (i = 0; i <= nsubdiv; i++) {
      double p1 = i / (double)nsubdiv;
      double p2 = 1.0 - p1;
      result[i].x = (v1.x * p1) + (v2.x * p2);
      result[i].y = (v1.y * p1) + (v2.y * p2);
   }
}

variable_types: nsubdiv int

variable_types:
result
struct Vertex *

variable_types: i int


original_code:
int generate2polygons(const double radius, const double angle, const int nsides,
                      const int nsubdiv, struct Vertex outer[],
                      struct Vertex inner[])
{
   const double rad = radius * 0.2;
   int i;
   const double delta = (2.0 * 3.14159265358979323846) / (double)nsides;
   struct Vertex vertex[64];
   struct Vertex jiggle;
   for (i = 0; i < nsides; i++) {
      const double theta = (double)i * delta;
      vertex[i].x = cos(theta + angle) * radius;
      vertex[i].y = sin(theta + angle) * radius;
   }
   for (i = 0; i < nsides; i++) {
      const int i1 = (i + 1) % nsides;
      splitside(vertex[i1], vertex[i], nsubdiv, &outer[i * (nsubdiv + 1)]);
   }
   for (i = 0; i < (nsides * (nsubdiv + 1)); i++) {
      jiggle.x = (((double)rand() / (double)2147483647) * rad) - (rad / 2.0);
      jiggle.y = (((double)rand() / (double)2147483647) * rad) - (rad / 2.0);
      inner[i].x = (outer[i].x / 3.0) + jiggle.x;
      inner[i].y = (outer[i].y / 3.0) + jiggle.y;
   }
   return (nsides * (nsubdiv + 1));
}

canonical_original_code:
int generate2polygons(double radius, double angle, int nsides, int nsubdiv, struct Vertex outer[], struct Vertex inner[])
{
   double rad = radius * 0.2;
   int i;
   double delta = (2.0 * 3.14159265358979323846) / (double)nsides;
   struct Vertex vertex[64];
   struct Vertex jiggle;
   for (i = 0; i < nsides; i++) {
      double theta = (double)i * delta;
      vertex[i].x = cos(theta + angle) * radius;
      vertex[i].y = sin(theta + angle) * radius;
   }
   for (i = 0; i < nsides; i++) {
      int i1 = (i + 1) % nsides;
      splitside(vertex[i1], vertex[i], nsubdiv, &outer[i * (nsubdiv + 1)]);
   }
   for (i = 0; i < (nsides * (nsubdiv + 1)); i++) {
      jiggle.x = (((double)rand() / (double)2147483647) * rad) - (rad / 2.0);
      jiggle.y = (((double)rand() / (double)2147483647) * rad) - (rad / 2.0);
      inner[i].x = (outer[i].x / 3.0) + jiggle.x;
      inner[i].y = (outer[i].y / 3.0) + jiggle.y;
   }
   return (nsides * (nsubdiv + 1));
}

variable_types: radius double

variable_types: angle double

variable_types: nsides int

variable_types: struct Vertex { double x; double y; } []

variable_types:
inner
struct Vertex []

variable_types: rad double

variable_types: delta double

variable_types: struct Vertex { double x; double y; } [64]

variable_types:
jiggle
struct Vertex { double x; double y; }

variable_types: theta double


morphpolygon

original_code:
void morphpolygon(const double xc, const double yc, const int nsides, const struct Vertex outer[], const struct Vertex inner[], const int nsteps)
{
   int i, j;
   const double delta = 1.0 / nsteps;
   struct Vertex vertex[64];
   drawpoly(nsides, xc, yc, outer);
   for (i = 1; i < nsteps; i++) {
      const double innerportion = delta * i;
      const double outerportion = delta * (nsteps - i);
      for (j = 0; j < nsides; j++) {
         vertex[j].x = (outer[j].x * outerportion) + (inner[j].x * innerportion);
         vertex[j].y = (outer[j].y * outerportion) + (inner[j].y * innerportion);
      }
      drawpoly(nsides, xc, yc, vertex);
   }
   drawpoly(nsides, xc, yc, inner);
}

canonical_original_code:
void morphpolygon(double xc, double yc, int nsides, struct Vertex outer[], struct Vertex inner[], int nsteps)
{
   int i; int j;
   double delta = 1.0 / nsteps;
   struct Vertex vertex[64];
   drawpoly(nsides, xc, yc, outer);
   for (i = 1; i < nsteps; i++) {
      double innerportion = delta * i;
      double outerportion = delta * (nsteps - i);
      for (j = 0; j < nsides; j++) {
         vertex[j].x = (outer[j].x * outerportion) + (inner[j].x * innerportion);
         vertex[j].y = (outer[j].y * outerportion) + (inner[j].y * innerportion);
      }
      drawpoly(nsides, xc, yc, vertex);
   }
   drawpoly(nsides, xc, yc, inner);
}

variable_types: xc double

variable_types: yc double

variable_types: nsteps int

variable_types: j int

variable_types: innerportion double

variable_types: outerportion double


drawpoly

decompiled_code:
__int64 __fastcall drawpoly(int a1, double *a2, double a3, double a4)
{
double *v4; // rbx

moveto(a3 + *a2, a4 + a2[1]);
if ( a1 > 1 )
{
v4 = a2 + 2;
do
{
lineto(a3 + *v4, a4 + v4[1]);
v4 += 2;
}
while ( v4 != &a2[2 * (unsigned int)(a1 - 2) + 4] );
}
return lineto(a3 + *a2, a4 + a2[1]);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, double *a2, double a3, double a4)
{
double *v4; // rbx

moveto(a3 + *a2, a4 + a2[1]);
if ( a1 > 1 )
{
v4 = a2 + 2;
do
{
lineto(a3 + *v4, a4 + v4[1]);
v4 += 2;
}
while ( v4 != &a2[2 * (unsigned int)(a1 - 2) + 4] );
}
return lineto(a3 + *a2, a4 + a2[1]);
}

original_code:
void drawpoly(const int nsides, const double xc, const double yc, const struct Vertex vertex[])
{
   int i;
   moveto(xc + vertex[0].x, yc + vertex[0].y);
   for (i = 1; i < nsides; i++) {
      lineto(xc + vertex[i].x, yc + vertex[i].y);
   }
   lineto(xc + vertex[0].x, yc + vertex[0].y);
}

canonical_original_code:
void drawpoly(int nsides, double xc, double yc, struct Vertex vertex[])
{
   int i;
   moveto(xc + vertex[0].x, yc + vertex[0].y);
   for (i = 1; i < nsides; i++) {
      lineto(xc + vertex[i].x, yc + vertex[i].y);
   }
   lineto(xc + vertex[0].x, yc + vertex[0].y);
}

variable_types: i int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
unsigned int v4; // eax
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
double v10; // [rsp+0h] [rbp-838h]
double v11; // [rsp+8h] [rbp-830h]
double v12[128]; // [rsp+10h] [rbp-828h] BYREF
double v13[128]; // [rsp+410h] [rbp-428h] BYREF
double v14; // [rsp+810h] [rbp-28h] BYREF
double v15[4]; // [rsp+818h] [rbp-20h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
v4 = time(0LL);
srand(v4);
if ( (int)plotbegin(1LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v15, &v14);
v11 = 0.25 * v15[0];
v10 = 0.25 * v14;
v5 = generate2polygons(4, 4, v12, (__int64)v13, 0.25 * v14, 0.0);
morphpolygon(v5, v12, v13, 12, 3.0 * v11, v10 * 3.0);
v6 = generate2polygons(5, 4, v12, (__int64)v13, v10, 0.0);
morphpolygon(v6, v12, v13, 12, v11, v10 * 3.0);
v7 = generate2polygons(6, 4, v12, (__int64)v13, v10, 0.0);
morphpolygon(v7, v12, v13, 12, 3.0 * v11, v10);
v8 = generate2polygons(7, 4, v12, (__int64)v13, v10, 0.0);
morphpolygon(v8, v12, v13, 12, v11, v10);
plotend();
return 0;
}

original_code:
int main(int argc, char * const argv[])
{
   int opt;
   int nsides;
   double radius;
   double w4, h4;
   double maxx, maxy;
   struct Vertex inner[64], outer[64];
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   srand((unsigned int)time(((void *)0)));
   if (plotbegin(1) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   radius = maxy / 4.0;
   w4 = maxx / 4.0;
   h4 = maxy / 4.0;
   nsides = generate2polygons(radius, 0.0, 4, 4, outer, inner);
   morphpolygon(w4 * 3.0, h4 * 3.0, nsides, outer, inner, 12);
   nsides = generate2polygons(radius, 0.0, 5, 4, outer, inner);
   morphpolygon(w4, h4 * 3.0, nsides, outer, inner, 12);
   nsides = generate2polygons(radius, 0.0, 6, 4, outer, inner);
   morphpolygon(w4 * 3.0, h4, nsides, outer, inner, 12);
   nsides = generate2polygons(radius, 0.0, 7, 4, outer, inner);
   morphpolygon(w4, h4, nsides, outer, inner, 12);
   plotend();
   return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int opt;
   int nsides;
   double radius;
   double w4; double h4;
   double maxx; double maxy;
   struct Vertex inner[64]; struct Vertex outer[64];
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   srand((unsigned int)time(((void *)0)));
   if (plotbegin(1) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   radius = maxy / 4.0;
   w4 = maxx / 4.0;
   h4 = maxy / 4.0;
   nsides = generate2polygons(radius, 0.0, 4, 4, outer, inner);
   morphpolygon(w4 * 3.0, h4 * 3.0, nsides, outer, inner, 12);
   nsides = generate2polygons(radius, 0.0, 5, 4, outer, inner);
   morphpolygon(w4, h4 * 3.0, nsides, outer, inner, 12);
   nsides = generate2polygons(radius, 0.0, 6, 4, outer, inner);
   morphpolygon(w4 * 3.0, h4, nsides, outer, inner, 12);
   nsides = generate2polygons(radius, 0.0, 7, 4, outer, inner);
   morphpolygon(w4, h4, nsides, outer, inner, 12);
   plotend();
   return (0);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: opt int

variable_types: radius double

variable_types: maxx double

variable_types: maxy double


reuleaux

original_code:
void reuleaux(const double xc, const double yc, const double r, const int n, const _Bool drawSides)
{
   int i;
   const double delta = (2.0 * 3.14159265358979323846) / (double)n;
   const double degrees = 180.0 / (double)n;
   double x[32];
   double y[32];
   for (i = 0; i <= n; i++) {
      const double theta = (delta * (double)i) + (3.14159265358979323846 / 2.0);
      x[i] = xc + (r * cos(theta));
      y[i] = yc + (r * sin(theta));
   }
   for (i = 0; i < n; i++) {
      const int j = (i + (n / 2)) % n;
      moveto(x[i], y[i]);
      arc(x[j], y[j], -degrees);
   }
   if (drawSides) {
      for (i = 0; i <= n; i++) {
         if (i == 0)
            moveto(x[i], y[i]);
         else
            lineto(x[i], y[i]);
      }
   }
}

canonical_original_code:
void reuleaux(double xc, double yc, double r, int n, _Bool drawSides)
{
   int i;
   double delta = (2.0 * 3.14159265358979323846) / (double)n;
   double degrees = 180.0 / (double)n;
   double x[32];
   double y[32];
   for (i = 0; i <= n; i++) {
      double theta = (delta * (double)i) + (3.14159265358979323846 / 2.0);
      x[i] = xc + (r * cos(theta));
      y[i] = yc + (r * sin(theta));
   }
   for (i = 0; i < n; i++) {
      int j = (i + (n / 2)) % n;
      moveto(x[i], y[i]);
      arc(x[j], y[j], -degrees);
   }
   if (drawSides) {
      for (i = 0; i <= n; i++) {
         if (i == 0)
            moveto(x[i], y[i]);
         else
            lineto(x[i], y[i]);
      }
   }
}

variable_types: r double

variable_types: n int

variable_types: delta double

variable_types: degrees double

variable_types:
x
double [32]

variable_types:
y
double [32]


decompiled_code:
__int64 __fastcall draw_diagonals(int a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
int i; // ebx
__int64 result; // rax
double v10; // [rsp+0h] [rbp-58h]

if ( a1 > 0 )
{
v10 = 0.0;
for ( i = 0; i != a1; ++i )
{
if ( (i & 1) != 0 )
{
moveto(a3, a5 + v10);
result = lineto(a4, a7 + v10);
}
else
{
moveto(a4, a7 + v10);
result = lineto(a3, a5 + v10);
}
a5 = a5 + a6;
a7 = a7 + a8;
v10 = v10 + a2;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
int i; // ebx
__int64 result; // rax
double v10; // [rsp+0h] [rbp-58h]

if ( a1 > 0 )
{
v10 = 0.0;
for ( i = 0; i != a1; ++i )
{
if ( (i & 1) != 0 )
{
moveto(a3, a5 + v10);
result = lineto(a4, a7 + v10);
}
else
{
moveto(a4, a7 + v10);
result = lineto(a3, a5 + v10);
}
a5 = a5 + a6;
a7 = a7 + a8;
v10 = v10 + a2;
}
}
return result;
}

original_code:
void draw_diagonals(int nlines, double pitch, double xl, double xr,
                    double yoff1, double dyoff1, double yoff2, double dyoff2)
{
   int i;
   double y;
   for (y = 0.0, i = 0; i < nlines; y += pitch, i++) {
      if (i & 1) {
         moveto(xl, y + yoff1);
         lineto(xr, y + yoff2);
      }
      else {
         moveto(xr, y + yoff2);
         lineto(xl, y + yoff1);
      }
      yoff1 += dyoff1;
      yoff2 += dyoff2;
   }
}

variable_types: nlines int

variable_types: pitch double

variable_types: xl double

variable_types: xr double

variable_types: y double


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
double v4; // r14
double v5; // rbx
int v6; // er12
double v7; // rbp
double v9; // [rsp+0h] [rbp-38h] BYREF
double v10[6]; // [rsp+8h] [rbp-30h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
if ( (int)plotbegin(0LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v10, &v9);
v4 = 0.5 * v10[0] - 0.5 * v9;
v5 = 0.5 * v9 + 0.5 * v10[0];
v6 = (int)((v9 - 600.0) / 80.0 + 1.0);
v7 = 200.0 / (double)v6;
rectangle(v4, 0.0, v5);
draw_diagonals(v6, 80.0, v4, v5, 400.0, v7, 0.0, 0.0);
draw_diagonals(v6, 80.0, v4, v5, 0.0, 0.0, 400.0, v7);
plotend();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
double v4; // r14
double v5; // rbx
int v6; // er12
double v7; // rbp
double v9; // [rsp+0h] [rbp-38h] BYREF
double v10[6]; // [rsp+8h] [rbp-30h] BYREF

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
if ( (int)plotbegin(0LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
getplotsize(v10, &v9);
v4 = 0.5 * v10[0] - 0.5 * v9;
v5 = 0.5 * v9 + 0.5 * v10[0];
v6 = (int)((v9 - 600.0) / 80.0 + 1.0);
v7 = 200.0 / (double)v6;
rectangle(v4, 0.0, v5);
func0(v6, 80.0, v4, v5, 400.0, v7, 0.0, 0.0);
func0(v6, 80.0, v4, v5, 0.0, 0.0, 400.0, v7);
plotend();
return 0;
}

original_code:
int main(int argc, char * const argv[])
{
   int opt;
   int nlines;
   double xc;
   double scale = 40.0;
   double maxx, maxy;
   double xl, xr;
   double height;
   const double yoff = 10.0 * scale;
   const double pitch = 2.0 * scale;
   double dyoff;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(0) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   xc = maxx / 2.0;
   height = maxy;
   xl = xc - height / 2.0;
   xr = xc + height / 2.0;
   nlines = ((height - (yoff + (5.0 * scale))) / pitch) + 1;
   dyoff = (5.0 * scale) / (double)nlines;
   rectangle(xc - (height / 2.0), 0.0, xc + (height / 2.0), maxy);
   draw_diagonals(nlines, pitch, xl, xr, yoff, dyoff, 0.0, 0.0);
   draw_diagonals(nlines, pitch, xl, xr, 0.0, 0.0, yoff, dyoff);
   plotend();
   return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int opt;
   int nlines;
   double xc;
   double scale = 40.0;
   double maxx; double maxy;
   double xl; double xr;
   double height;
   double yoff = 10.0 * scale;
   double pitch = 2.0 * scale;
   double dyoff;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(0) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&maxx, &maxy);
   xc = maxx / 2.0;
   height = maxy;
   xl = xc - height / 2.0;
   xr = xc + height / 2.0;
   nlines = ((height - (yoff + (5.0 * scale))) / pitch) + 1;
   dyoff = (5.0 * scale) / (double)nlines;
   rectangle(xc - (height / 2.0), 0.0, xc + (height / 2.0), maxy);
   draw_diagonals(nlines, pitch, xl, xr, yoff, dyoff, 0.0, 0.0);
   draw_diagonals(nlines, pitch, xl, xr, 0.0, 0.0, yoff, dyoff);
   plotend();
   return (0);
}

variable_types: argc int

variable_types: xc double

variable_types: scale double

variable_types: height double

variable_types: yoff double

variable_types: dyoff double


infline

decompiled_code:
__int64 __fastcall infline(int a1, double a2, double a3)
{
double v4; // xmm1_8
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

if ( a1 )
{
sincos((a2 + a3 * 0.5) * 0.0174532925199433, sinx, &cosx);
moveto(*(double *)&Rad * cosx + *(double *)&X0, *(double *)&Rad * sinx[0] + *(double *)&Y0);
}
sincos(a2 * 0.0174532925199433, sinx, &cosx);
v4 = cos(0.0174532925199433 * (a3 * 0.5));
return arc(*(double *)&Rad / v4 * cosx + *(double *)&X0, *(double *)&Rad / v4 * sinx[0] + *(double *)&Y0, 180.0 - a3);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, double a2, double a3)
{
double v4; // xmm1_8
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

if ( a1 )
{
sincos((a2 + a3 * 0.5) * 0.0174532925199433, sinx, &cosx);
moveto(*(double *)&Rad * cosx + *(double *)&X0, *(double *)&Rad * sinx[0] + *(double *)&Y0);
}
sincos(a2 * 0.0174532925199433, sinx, &cosx);
v4 = cos(0.0174532925199433 * (a3 * 0.5));
return arc(*(double *)&Rad / v4 * cosx + *(double *)&X0, *(double *)&Rad / v4 * sinx[0] + *(double *)&Y0, 180.0 - a3);
}

original_code:
void infline(const double ctrang, const double incang, const int move)
{
   double a;
   double b;
   double c;
   double d;
   double x, y;
   a = (ctrang + (incang / 2.0)) * (3.14159265358979323846 / 180.0);
   if (move)
      moveto(X0 + (Rad * cos(a)), Y0 + (Rad * sin(a)));
   b = ctrang * (3.14159265358979323846 / 180.0);
   c = 180.0 - incang;
   d = Rad / cos((incang / 2.0) * (3.14159265358979323846 / 180.0));
   x = d * cos(b);
   y = d * sin(b);
   arc(X0 + x, Y0 + y, c);
}

variable_types: ctrang double

variable_types: incang double

variable_types: move int

variable_types: a double

variable_types: b double

variable_types: c double

variable_types: d double

variable_types: x double


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
__int64 *v4; // rdi
int v5; // er14
double v6; // rbp
int v7; // er12
double v8; // xmm5_8
int i; // ebx
double v11; // [rsp+0h] [rbp-48h]
double v12; // [rsp+8h] [rbp-40h]

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
if ( (int)plotbegin(0LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
v4 = &X0;
getplotsize(&X0, &Y0);
*(double *)&X0 = 0.5 * *(double *)&X0;
*(double *)&Y0 = 0.5 * *(double *)&Y0;
Rad = Y0;
moveto(*(double *)&X0 + 200.0, *(double *)&Y0);
lineto(*(double *)&X0 - 200.0, *(double *)&Y0);
moveto(*(double *)&X0, *(double *)&Y0 + 200.0);
lineto(*(double *)&X0, *(double *)&Y0 - 200.0);
circle(*(double *)&X0, *(double *)&Y0, *(double *)&Rad);
v5 = 6;
v6 = *(double *)&LC3;
v7 = 3;
do
{
v12 = v6;
v8 = v6 * 0.5;
v6 = v6 * 0.5;
if ( v7 > 0 )
{
v11 = v8;
LODWORD(v4) = 1;
for ( i = 0; i != v7; ++i )
{
infline((int)v4, v11, v12);
v11 = v11 - v12;
v4 = 0LL;
}
}
v7 *= 2;
--v5;
}
while ( v5 );
plotend(v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
__int64 *v4; // rdi
int v5; // er14
double v6; // rbp
int v7; // er12
double v8; // xmm5_8
int i; // ebx
double v11; // [rsp+0h] [rbp-48h]
double v12; // [rsp+8h] [rbp-40h]

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "no:p:s:t:v:");
if ( v3 == -1 )
break;
if ( v3 - 110 > 8 || ((1LL << ((unsigned __int8)v3 - 110)) & 0x167) == 0 )
{
fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", *argv);
fwrite(" <size> ::= A1 | A2 | A3 | A4 | A5\n", 1uLL, 0x29uLL, stderr);
exit(1);
}
plotopt(v3, optarg);
}
if ( (int)plotbegin(0LL) < 0 )
{
fwrite("Failed to initialise HPGL library\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
v4 = &X0;
getplotsize(&X0, &Y0);
*(double *)&X0 = 0.5 * *(double *)&X0;
*(double *)&Y0 = 0.5 * *(double *)&Y0;
Rad = Y0;
moveto(*(double *)&X0 + 200.0, *(double *)&Y0);
lineto(*(double *)&X0 - 200.0, *(double *)&Y0);
moveto(*(double *)&X0, *(double *)&Y0 + 200.0);
lineto(*(double *)&X0, *(double *)&Y0 - 200.0);
circle(*(double *)&X0, *(double *)&Y0, *(double *)&Rad);
v5 = 6;
v6 = *(double *)&LC3;
v7 = 3;
do
{
v12 = v6;
v8 = v6 * 0.5;
v6 = v6 * 0.5;
if ( v7 > 0 )
{
v11 = v8;
LODWORD(v4) = 1;
for ( i = 0; i != v7; ++i )
{
func0((int)v4, v11, v12);
v11 = v11 - v12;
v4 = 0LL;
}
}
v7 *= 2;
--v5;
}
while ( v5 );
plotend(v4);
return 0;
}

original_code:
int main(int argc, char *const argv[])
{
   int opt;
   int i;
   int level;
   int num;
   int first;
   double theta, phi;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(0) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&X0, &Y0);
   X0 /= 2.0;
   Y0 /= 2.0;
   Rad = Y0;
   moveto(X0 + 200.0, Y0);
   lineto(X0 - 200.0, Y0);
   moveto(X0, Y0 + 200.0);
   lineto(X0, Y0 - 200.0);
   circle(X0, Y0, Rad);
   num = 3;
   phi = 120.0;
   for (level = 0; level < 6; level++) {
      theta = phi / 2.0;
      first = 1;
      for (i = 0; i < num; i++) {
         infline(theta, phi, first);
         first = 0;
         theta -= phi;
      }
      phi /= 2.0;
      num *= 2;
   }
   plotend();
   return (0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int opt;
   int i;
   int level;
   int num;
   int first;
   double theta; double phi;
   while ((opt = getopt(argc, argv, "no:p:s:t:v:")) != -1) {
      switch (opt) {
      case 's':
      case 'n':
      case 'o':
      case 'p':
      case 't':
      case 'v':
         plotopt(opt, optarg);
         break;
      default:
         fprintf(stderr, "Usage: %s [-p pen] [-s <size>] [-t title]\n", argv[0]);
         fprintf(stderr, "       <size> ::= A1 | A2 | A3 | A4 | A5\n");
         exit(1);
      }
   }
   if (plotbegin(0) < 0) {
      fputs("Failed to initialise HPGL library\n", stderr);
      exit(1);
   }
   getplotsize(&X0, &Y0);
   X0 /= 2.0;
   Y0 /= 2.0;
   Rad = Y0;
   moveto(X0 + 200.0, Y0);
   lineto(X0 - 200.0, Y0);
   moveto(X0, Y0 + 200.0);
   lineto(X0, Y0 - 200.0);
   circle(X0, Y0, Rad);
   num = 3;
   phi = 120.0;
   for (level = 0; level < 6; level++) {
      theta = phi / 2.0;
      first = 1;
      for (i = 0; i < num; i++) {
         infline(theta, phi, first);
         first = 0;
         theta -= phi;
      }
      phi /= 2.0;
      num *= 2;
   }
   plotend();
   return (0);
}

variable_types:
argv
char *[]

variable_types: opt int

variable_types: i int

variable_types: level int

variable_types: num int

variable_types: first int

variable_types: theta double

variable_types: phi double