qtest

original_code:
long
qtest(void)
{
 int a, b, c1, c2, val;
 int eventind, eventmask;
 if (!vdevice.initialised)
  verror("qtest: vogl not initialised\n");
 if (vdevice.alreadyread)
  return((long)vdevice.devno);
 eventind = 0;
 eventmask = 0;
 val = c1 = (*vdevice.dev.Vcheckkey)();
 c2 = (*vdevice.dev.Vlocator)(&a, &b);
 if (c1 != 0) {
  eventind = c1 / 8;
  eventmask = 1 << (c1 & 0x7);
  if (vdevice.kbdmode) {
   vdevice.data = val;
   vdevice.devno = 257;
  } else {
   vdevice.data = 1;
   if (c1 >= 'a' && c1 <= 'z')
    vdevice.devno = c1 - 'a' + 'A';
   else
    vdevice.devno = c1;
  }
 } else {
  if (c2 & 0x01)
   c2 = 260;
  else if (c2 & 0x02)
   c2 = 259;
  else if (c2 & 0x04)
   c2 = 258;
  eventind = c2 / 8;
  eventmask = 1 << (c2 & 0x7);
  vdevice.data = 1;
  vdevice.devno = c2;
 }
 if (vdevice.enabled[eventind] & eventmask) {
  vdevice.alreadyread = 1;
  return(1L);
 }
 return(0L);
}

canonical_original_code:
long qtest()
{
 int a; int b; int c1; int c2; int val;
 int eventind; int eventmask;
 if (!vdevice.initialised)
  verror("qtest: vogl not initialised\n");
 if (vdevice.alreadyread)
  return((long)vdevice.devno);
 eventind = 0;
 eventmask = 0;
 val = c1 = (*vdevice.dev.Vcheckkey)();
 c2 = (*vdevice.dev.Vlocator)(&a, &b);
 if (c1 != 0) {
  eventind = c1 / 8;
  eventmask = 1 << (c1 & 0x7);
  if (vdevice.kbdmode) {
   vdevice.data = val;
   vdevice.devno = 257;
  } else {
   vdevice.data = 1;
   if (c1 >= 'a' && c1 <= 'z')
    vdevice.devno = c1 - 'a' + 'A';
   else
    vdevice.devno = c1;
  }
 } else {
  if (c2 & 0x01)
   c2 = 260;
  else if (c2 & 0x02)
   c2 = 259;
  else if (c2 & 0x04)
   c2 = 258;
  eventind = c2 / 8;
  eventmask = 1 << (c2 & 0x7);
  vdevice.data = 1;
  vdevice.devno = c2;
 }
 if (vdevice.enabled[eventind] & eventmask) {
  vdevice.alreadyread = 1;
  return(1L);
 }
 return(0L);
}


isqueued

decompiled_code:
unsigned __int64 __fastcall isqueued(unsigned __int16 a1)
{
return *(char *)(vdevice[64] + (a1 >> 3)) & (unsigned __int64)(1 << (a1 & 7));
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(unsigned __int16 a1)
{
return *(char *)(vdevice[64] + (a1 >> 3)) & (unsigned __int64)(1 << (a1 & 7));
}

original_code:
Boolean
isqueued(Device dev)
{
 return((long)vdevice.enabled[dev / 8] & (1 << (dev & 0x7)));
}

canonical_original_code:
long isqueued(unsigned short dev)
{
 return((long)vdevice.enabled[dev / 8] & (1 << (dev & 0x7)));
}

variable_types:
dev
unsigned short

return_type: long


qenter

decompiled_code:
void qenter()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void
qenter(Device dev, short int val)
{
}

canonical_original_code:
void qenter(unsigned short dev, short val)
{
}

variable_types: val short

return_type: void


charstr

decompiled_code:
__int64 __fastcall charstr(char *src)
{
size_t v2; // rax
int v3; // er12
int v4; // edx
char v5; // si
int v6; // eax
int v7; // ecx
__int64 v8; // r13
int v9; // ecx
__int64 result; // rax
int v11; // esi
float v12; // xmm0_4
__int64 v13; // rdi
char *v14; // rbp
__int64 v15; // rdx
__int64 v16; // rsi
__int64 v17; // rax

v2 = strlen(src);
if ( vdevice )
{
v3 = v2;
if ( *((_BYTE *)&vdevice + 2) )
{
v17 = newtokens((unsigned int)(v2 >> 2) + 2);
*(_DWORD *)v17 = 10;
result = (__int64)strcpy((char *)(v17 + 4), src);
}
else
{
v4 = *((char *)&vdevice + 6);
v5 = *((_BYTE *)&vdevice + 1);
sync = v4;
if ( v4 )
*((_BYTE *)&vdevice + 6) = 0;
v6 = sc_x;
v7 = sc_y;
v8 = *(_QWORD *)((char *)&vdevice + 140);
*((_DWORD *)&vdevice + 35) = sc_x;
*((_DWORD *)&vdevice + 36) = v7;
if ( v5
|| (v11 = *((_DWORD *)&vdevice + 28), v12 = *((float *)&vdevice + 13), v6 > v11)
&& *((_DWORD *)&vdevice + 29) > v7 - (int)*((float *)&vdevice + 12)
&& v7 > *((_DWORD *)&vdevice + 30)
&& *((_DWORD *)&vdevice + 27) > v6 + (int)(float)((float)(v3 + 1) * v12) )
{
(*((void (__fastcall **)(char *))&vdevice + 38))(src);
v9 = (int)*((float *)&vdevice + 13);
v6 = sc_x;
v4 = sync;
}
else
{
v13 = (unsigned int)*src;
v14 = src + 1;
if ( *src )
{
v15 = (unsigned int)(int)v12;
while ( 1 )
{
v9 = v15;
if ( v6 > v11 )
{
v16 = (unsigned int)(*((_DWORD *)&vdevice + 27) - v15);
if ( (int)v16 > v6 )
{
(*((void (__fastcall **)(__int64, __int64, __int64, _QWORD))&vdevice + 23))(
v13,
v16,
v15,
(unsigned int)v15);
v15 = (unsigned int)(int)*((float *)&vdevice + 13);
v6 = *((_DWORD *)&vdevice + 35);
v9 = (int)*((float *)&vdevice + 13);
}
}
v6 += v15;
++v14;
*((_DWORD *)&vdevice + 35) = v6;
v13 = (unsigned int)*(v14 - 1);
if ( !*(v14 - 1) )
break;
v11 = *((_DWORD *)&vdevice + 28);
}
v6 = sc_x;
v4 = sync;
}
else
{
v9 = (int)v12;
}
}
*(_QWORD *)((char *)&vdevice + 140) = v8;
result = (unsigned int)(v3 * v9 + v6);
sc_x = result;
if ( v4 )
{
*((_BYTE *)&vdevice + 6) = 1;
result = (*((__int64 (**)(void))&vdevice + 41))();
}
}
}
else
{
verror("charstr: vogl not initialized");
result = cmov();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src)
{
size_t v2; // rax
int v3; // er12
int v4; // edx
char v5; // si
int v6; // eax
int v7; // ecx
__int64 v8; // r13
int v9; // ecx
__int64 result; // rax
int v11; // esi
float v12; // xmm0_4
__int64 v13; // rdi
char *v14; // rbp
__int64 v15; // rdx
__int64 v16; // rsi
__int64 v17; // rax

v2 = strlen(src);
if ( vdevice )
{
v3 = v2;
if ( *((_BYTE *)&vdevice + 2) )
{
v17 = newtokens((unsigned int)(v2 >> 2) + 2);
*(_DWORD *)v17 = 10;
result = (__int64)strcpy((char *)(v17 + 4), src);
}
else
{
v4 = *((char *)&vdevice + 6);
v5 = *((_BYTE *)&vdevice + 1);
sync = v4;
if ( v4 )
*((_BYTE *)&vdevice + 6) = 0;
v6 = sc_x;
v7 = sc_y;
v8 = *(_QWORD *)((char *)&vdevice + 140);
*((_DWORD *)&vdevice + 35) = sc_x;
*((_DWORD *)&vdevice + 36) = v7;
if ( v5
|| (v11 = *((_DWORD *)&vdevice + 28), v12 = *((float *)&vdevice + 13), v6 > v11)
&& *((_DWORD *)&vdevice + 29) > v7 - (int)*((float *)&vdevice + 12)
&& v7 > *((_DWORD *)&vdevice + 30)
&& *((_DWORD *)&vdevice + 27) > v6 + (int)(float)((float)(v3 + 1) * v12) )
{
(*((void (__fastcall **)(char *))&vdevice + 38))(src);
v9 = (int)*((float *)&vdevice + 13);
v6 = sc_x;
v4 = sync;
}
else
{
v13 = (unsigned int)*src;
v14 = src + 1;
if ( *src )
{
v15 = (unsigned int)(int)v12;
while ( 1 )
{
v9 = v15;
if ( v6 > v11 )
{
v16 = (unsigned int)(*((_DWORD *)&vdevice + 27) - v15);
if ( (int)v16 > v6 )
{
(*((void (__fastcall **)(__int64, __int64, __int64, _QWORD))&vdevice + 23))(
v13,
v16,
v15,
(unsigned int)v15);
v15 = (unsigned int)(int)*((float *)&vdevice + 13);
v6 = *((_DWORD *)&vdevice + 35);
v9 = (int)*((float *)&vdevice + 13);
}
}
v6 += v15;
++v14;
*((_DWORD *)&vdevice + 35) = v6;
v13 = (unsigned int)*(v14 - 1);
if ( !*(v14 - 1) )
break;
v11 = *((_DWORD *)&vdevice + 28);
}
v6 = sc_x;
v4 = sync;
}
else
{
v9 = (int)v12;
}
}
*(_QWORD *)((char *)&vdevice + 140) = v8;
result = (unsigned int)(v3 * v9 + v6);
sc_x = result;
if ( v4 )
{
*((_BYTE *)&vdevice + 6) = 1;
result = (*((__int64 (**)(void))&vdevice + 41))();
}
}
}
else
{
verror("charstr: vogl not initialized");
result = func1();
}
return result;
}

original_code:
void
charstr(const char *str)
{
 int cx, cy;
 char c;
 Token *tok;
 int oldclipoff = vdevice.clipoff;
 int sl = strlen(str);
 if(!vdevice.initialised)
  verror("charstr: vogl not initialized");
 if (vdevice.inobject) {
  tok = newtokens(2 + strlen(str) / sizeof(Token));
  tok[0].i = 10;
  strcpy((char *)&tok[1], str);
  return;
 }
 if ((sync = vdevice.sync)!=0)
  vdevice.sync = 0;
 cx = vdevice.cpVx;
 cy = vdevice.cpVy;
 vdevice.cpVx = sc_x;
 vdevice.cpVy = sc_y;
 if (oldclipoff) {
  (*vdevice.dev.Vstring)(str);
 } else {
  int left_s = vdevice.cpVx;
  int bottom_s = vdevice.cpVy - (int)vdevice.hheight;
  int top_s = bottom_s + (int)vdevice.hheight;
  int right_s = left_s + (int)((sl + 1) * vdevice.hwidth);
  if (left_s > vdevice.minVx &&
      bottom_s < vdevice.maxVy &&
      top_s > vdevice.minVy &&
      right_s < vdevice.maxVx) {
   (*vdevice.dev.Vstring)(str);
  } else {
   while ((c = *str++)) {
    if (vdevice.cpVx > vdevice.minVx &&
        vdevice.cpVx < vdevice.maxVx - (int)vdevice.hwidth) {
     (*vdevice.dev.Vchar)(c);
    }
    vdevice.cpVx += (int)vdevice.hwidth;
   }
  }
 }
 sc_x += sl * (int)vdevice.hwidth;
 vdevice.cpVx = cx;
 vdevice.cpVy = cy;
 if (sync) {
  vdevice.sync = 1;
  (*vdevice.dev.Vsync)();
 }
}

canonical_original_code:
void charstr(char *str)
{
 int cx; int cy;
 char c;
 union tk *tok;
 int oldclipoff = vdevice.clipoff;
 int sl = strlen(str);
 if(!vdevice.initialised)
  verror("charstr: vogl not initialized");
 if (vdevice.inobject) {
  tok = newtokens(2 + strlen(str) / sizeof(Token));
  tok[0].i = 10;
  strcpy((char *)&tok[1], str);
  return;
 }
 if ((sync = vdevice.sync)!=0)
  vdevice.sync = 0;
 cx = vdevice.cpVx;
 cy = vdevice.cpVy;
 vdevice.cpVx = sc_x;
 vdevice.cpVy = sc_y;
 if (oldclipoff) {
  (*vdevice.dev.Vstring)(str);
 } else {
  int left_s = vdevice.cpVx;
  int bottom_s = vdevice.cpVy - (int)vdevice.hheight;
  int top_s = bottom_s + (int)vdevice.hheight;
  int right_s = left_s + (int)((sl + 1) * vdevice.hwidth);
  if (left_s > vdevice.minVx &&
      bottom_s < vdevice.maxVy &&
      top_s > vdevice.minVy &&
      right_s < vdevice.maxVx) {
   (*vdevice.dev.Vstring)(str);
  } else {
   while ((c = *str++)) {
    if (vdevice.cpVx > vdevice.minVx &&
        vdevice.cpVx < vdevice.maxVx - (int)vdevice.hwidth) {
     (*vdevice.dev.Vchar)(c);
    }
    vdevice.cpVx += (int)vdevice.hwidth;
   }
  }
 }
 sc_x += sl * (int)vdevice.hwidth;
 vdevice.cpVx = cx;
 vdevice.cpVy = cy;
 if (sync) {
  vdevice.sync = 1;
  (*vdevice.dev.Vsync)();
 }
}

variable_types:
str
char *

variable_types: cx int

variable_types: cy int

variable_types: c char

variable_types:
tok
union tk { int i; float f; } *

variable_types: oldclipoff int

variable_types: sl int


strwidth

decompiled_code:
__int64 __fastcall strwidth(const char *a1)
{
return (unsigned int)(int)(float)((float)(int)strlen(a1) * vdevice[13]);
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
return (unsigned int)(int)(float)((float)(int)strlen(a1) * vdevice[13]);
}

original_code:
long
strwidth(char *s)
{
 return((long)(strlen(s) * vdevice.hwidth));
}

variable_types:
s
char *


getheight

decompiled_code:
__int64 getheight()
{
if ( LOBYTE(vdevice[0]) )
return (unsigned int)(int)vdevice[12];
verror("getheight: vogl not initialized");
return getwidth();
}

canonical_decompiled_code:
__int64 func8()
{
if ( LOBYTE(vdevice[0]) )
return (unsigned int)(int)vdevice[12];
verror("getheight: vogl not initialized");
return func9();
}

original_code:
long
getheight(void)
{
 if (!vdevice.initialised)
  verror("getheight: vogl not initialized");
 return((long)vdevice.hheight);
}

canonical_original_code:
long getheight()
{
 if (!vdevice.initialised)
  verror("getheight: vogl not initialized");
 return((long)vdevice.hheight);
}


getwidth

decompiled_code:
__int64 getwidth()
{
if ( LOBYTE(vdevice[0]) )
return (unsigned int)(int)vdevice[13];
verror("getwidth: vogl not initialised");
return getcpos();
}

canonical_decompiled_code:
__int64 func9()
{
if ( LOBYTE(vdevice[0]) )
return (unsigned int)(int)vdevice[13];
verror("getwidth: vogl not initialised");
return func10();
}

original_code:
long
getwidth(void)
{
 if (!vdevice.initialised)
  verror("getwidth: vogl not initialised");
 return((long)vdevice.hwidth);
}

canonical_original_code:
long getwidth()
{
 if (!vdevice.initialised)
  verror("getwidth: vogl not initialised");
 return((long)vdevice.hwidth);
}


pnt

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

if ( vdevice )
{
move(a1, a2);
result = draw(a3, a4, a5);
}
else
{
verror("pnt: vogl not initialised");
result = pnts();
}
return result;
}

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

if ( vdevice )
{
move(a1, a2);
result = draw(a3, a4, a5);
}
else
{
verror("pnt: vogl not initialised");
result = func1();
}
return result;
}

original_code:
void
pnt(float x, float y, float z)
{
 if(!vdevice.initialised)
  verror("pnt: vogl not initialised");
 move(x, y, z);
 draw(x, y, z);
}

variable_types: x float

variable_types: y float

variable_types: z float


pnts

decompiled_code:
__int64 __fastcall pnts(__int16 a1, __int16 a2, int a3)
{
return pnt(a1, a2, (float)a1, (float)a2, (float)a3);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 a1, __int16 a2, int a3)
{
return func0(a1, a2, (float)a1, (float)a2, (float)a3);
}

original_code:
void
pnts(Scoord x, Scoord y, int z)
{
 pnt((Coord)x, (Coord)y, (Coord)z);
}

canonical_original_code:
void pnts(short x, short y, int z)
{
 pnt((float)x, (float)y, (float)z);
}

variable_types: x short

variable_types: y short

variable_types: z int


pnti

decompiled_code:
__int64 __fastcall pnti(int a1, int a2, int a3)
{
return pnt(a1, a2, (float)a1, (float)a2, (float)a3);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, int a3)
{
return func0(a1, a2, (float)a1, (float)a2, (float)a3);
}

original_code:
void
pnti(Icoord x, Icoord y, Icoord z)
{
 pnt((Coord)x, (Coord)y, (Coord)z);
}

canonical_original_code:
void pnti(long x, long y, long z)
{
 pnt((float)x, (float)y, (float)z);
}

variable_types: x long

variable_types: y long

variable_types: z long


decompiled_code:
__int64 __fastcall pnt2(int a1, int a2, float a3, float a4)
{
move(a1, a2);
return draw(a3, a4, 0.0);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2, float a3, float a4)
{
move(a1, a2);
return draw(a3, a4, 0.0);
}

original_code:
void
pnt2(Coord x, Coord y)
{
 move(x, y, 0.0);
 draw(x, y, 0.0);
}

canonical_original_code:
void pnt2(float x, float y)
{
 move(x, y, 0.0);
 draw(x, y, 0.0);
}


decompiled_code:
__int64 __fastcall pnt2s(__int16 a1, __int16 a2)
{
return pnt2(a1, a2, (float)a1, (float)a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int16 a1, __int16 a2)
{
return func3(a1, a2, (float)a1, (float)a2);
}

original_code:
void
pnt2s(Scoord x, Scoord y)
{
 pnt2((Coord)x, (Coord)y);
}

canonical_original_code:
void pnt2s(short x, short y)
{
 pnt2((float)x, (float)y);
}


decompiled_code:
__int64 __fastcall pnt2i(int a1, int a2)
{
return pnt2(a1, a2, (float)a1, (float)a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2)
{
return func3(a1, a2, (float)a1, (float)a2);
}

original_code:
void
pnt2i(Icoord x, Icoord y)
{
 pnt2((Coord)x, (Coord)y);
}

canonical_original_code:
void pnt2i(long x, long y)
{
 pnt2((float)x, (float)y);
}


bgnpoint

decompiled_code:
void *bgnpoint()
{
void *result; // rax

result = &vdevice;
if ( *((_BYTE *)&vdevice + 348) )
{
verror("vogl: bgnpoint mode already belongs to some other bgn routine");
result = (void *)endpoint();
}
else
{
*((_BYTE *)&vdevice + 348) = 1;
*((_DWORD *)&vdevice + 88) = 0;
}
return result;
}

canonical_decompiled_code:
void *func6()
{
void *result; // rax

result = &vdevice;
if ( *((_BYTE *)&vdevice + 348) )
{
verror("vogl: bgnpoint mode already belongs to some other bgn routine");
result = (void *)func7();
}
else
{
*((_BYTE *)&vdevice + 348) = 1;
*((_DWORD *)&vdevice + 88) = 0;
}
return result;
}

original_code:
void
bgnpoint(void)
{
 if (vdevice.bgnmode != 0)
  verror("vogl: bgnpoint mode already belongs to some other bgn routine");
 vdevice.bgnmode = 1;
 vdevice.save = 0;
}

canonical_original_code:
void bgnpoint()
{
 if (vdevice.bgnmode != 0)
  verror("vogl: bgnpoint mode already belongs to some other bgn routine");
 vdevice.bgnmode = 1;
 vdevice.save = 0;
}


endpoint

decompiled_code:
void *endpoint()
{
void *result; // rax

result = &vdevice;
*((_BYTE *)&vdevice + 348) = 0;
*((_DWORD *)&vdevice + 88) = 0;
return result;
}

canonical_decompiled_code:
void *func7()
{
void *result; // rax

result = &vdevice;
*((_BYTE *)&vdevice + 348) = 0;
*((_DWORD *)&vdevice + 88) = 0;
return result;
}

original_code:
void
endpoint(void)
{
 vdevice.bgnmode = 0;
 vdevice.save = 0;
}

canonical_original_code:
void endpoint()
{
 vdevice.bgnmode = 0;
 vdevice.save = 0;
}


decompiled_code:
float hgetfontheight_()
{
return (float)(int)hgetfontheight();
}

canonical_decompiled_code:
float func15()
{
return (float)(int)hgetfontheight();
}

original_code:
float
hgetfontheight_()
{
 return(hgetfontheight());
}

return_type: float


decompiled_code:
float hgetfh_()
{
return hgetfontheight_();
}

canonical_decompiled_code:
float func16()
{
return func15();
}

original_code:
float
hgetfh_()
{
 return(hgetfontheight());
}


decompiled_code:
float hgetfontwidth_()
{
return (float)(int)hgetfontwidth();
}

canonical_decompiled_code:
float func17()
{
return (float)(int)hgetfontwidth();
}

original_code:
float
hgetfontwidth_()
{
 return(hgetfontwidth());
}


decompiled_code:
float hgetfw_()
{
return hgetfontwidth_();
}

canonical_decompiled_code:
float func18()
{
return func17();
}

original_code:
float
hgetfw_()
{
 return(hgetfontwidth());
}


decompiled_code:
float hgetdecender_()
{
return (float)(int)hgetdecender();
}

canonical_decompiled_code:
float func19()
{
return (float)(int)hgetdecender();
}

original_code:
float
hgetdecender_()
{
 return(hgetdecender());
}


decompiled_code:
float hgetde_()
{
return hgetdecender_();
}

canonical_decompiled_code:
float func20()
{
return func19();
}

original_code:
float
hgetde_()
{
 return(hgetdecender());
}


decompiled_code:
float hgetascender_()
{
return (float)(int)hgetascender();
}

canonical_decompiled_code:
float func21()
{
return (float)(int)hgetascender();
}

original_code:
float
hgetascender_()
{
 return(hgetascender());
}


decompiled_code:
float hgetas_()
{
return hgetascender_();
}

canonical_decompiled_code:
float func22()
{
return func21();
}

original_code:
float
hgetas_()
{
 return(hgetascender());
}


decompiled_code:
__int64 hnumchars_()
{
return hnumchars();
}

canonical_decompiled_code:
__int64 func35()
{
return hnumchars();
}

original_code:
int
hnumchars_()
{
 return(hnumchars());
}

return_type: int


decompiled_code:
__int64 hnumch_()
{
return hnumchars_();
}

canonical_decompiled_code:
__int64 func36()
{
return func35();
}

original_code:
int
hnumch_()
{
 return(hnumchars());
}

canonical_original_code:
int hnumch_()
{
 return(hnumchars());
}


curvebasis

decompiled_code:
__int64 __fastcall curvebasis(__int16 a1)
{
if ( vdevice )
return copymatrix((char *)&vdevice + 376, *((_QWORD *)&vdevice + 63) + ((__int64)a1 << 6));
verror("curvebasis: vogl not initialised");
return curveprecision();
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 a1)
{
if ( vdevice )
return copymatrix((char *)&vdevice + 376, *((_QWORD *)&vdevice + 63) + ((__int64)a1 << 6));
verror("curvebasis: vogl not initialised");
return func1();
}

original_code:
void
curvebasis(short int id)
{
 if(!vdevice.initialised)
  verror("curvebasis: vogl not initialised");
 copymatrix(vdevice.tbasis, vdevice.bases[id]);
}

canonical_original_code:
void curvebasis(short id)
{
 if(!vdevice.initialised)
  verror("curvebasis: vogl not initialised");
 copymatrix(vdevice.tbasis, vdevice.bases[id]);
}

variable_types: id short


curveprecision

decompiled_code:
__int64 __fastcall curveprecision(__int16 a1)
{
__int64 result; // rax
float v2; // xmm2_4
float v3; // xmm4_4

if ( a1 <= 0 )
{
verror("curveprecision: number of segments <= 0");
result = drcurve();
}
else
{
nsegs = a1;
identmatrix(&e);
result = (unsigned int)nsegs;
dword_61C = 0;
dword_608 = 0;
e = 0;
dword_5EC = LC2;
v2 = (float)(result * result);
v3 = (float)nsegs * v2;
*(float *)&dword_5F0 = 1.0 / v3;
*(float *)&dword_5F4 = 1.0 / v2;
*(float *)&dword_610 = 6.0 / v3;
*(float *)&dword_600 = 6.0 / v3;
*(float *)&dword_604 = 2.0 / v2;
*(float *)&dword_5F8 = 1.0 / (float)nsegs;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 a1)
{
__int64 result; // rax
float v2; // xmm2_4
float v3; // xmm4_4

if ( a1 <= 0 )
{
verror("curveprecision: number of segments <= 0");
result = func2();
}
else
{
nsegs = a1;
identmatrix(&e);
result = (unsigned int)nsegs;
dword_61C = 0;
dword_608 = 0;
e = 0;
dword_5EC = LC2;
v2 = (float)(result * result);
v3 = (float)nsegs * v2;
*(float *)&dword_5F0 = 1.0 / v3;
*(float *)&dword_5F4 = 1.0 / v2;
*(float *)&dword_610 = 6.0 / v3;
*(float *)&dword_600 = 6.0 / v3;
*(float *)&dword_604 = 2.0 / v2;
*(float *)&dword_5F8 = 1.0 / (float)nsegs;
}
return result;
}

original_code:
void
curveprecision(short int nsegments)
{
 float n2, n3;
 if (nsegments > 0)
  nsegs = nsegments;
 else
  verror("curveprecision: number of segments <= 0");
 identmatrix(e);
 n2 = (float)(nsegs * nsegs);
 n3 = (float)(nsegs * n2);
 e[0][0] = e[2][2] = e[3][3] = 0.0;
 e[1][0] = 1.0 / n3;
 e[1][1] = 1.0 / n2;
 e[2][0] = e[3][0] = 6.0 / n3;
 e[2][1] = 2.0 / n2;
 e[1][2] = 1.0 / (float)nsegs;
 e[0][3] = 1.0;
}

canonical_original_code:
void curveprecision(short nsegments)
{
 float n2; float n3;
 if (nsegments > 0)
  nsegs = nsegments;
 else
  verror("curveprecision: number of segments <= 0");
 identmatrix(e);
 n2 = (float)(nsegs * nsegs);
 n3 = (float)(nsegs * n2);
 e[0][0] = e[2][2] = e[3][3] = 0.0;
 e[1][0] = 1.0 / n3;
 e[1][1] = 1.0 / n2;
 e[2][0] = e[3][0] = 6.0 / n3;
 e[2][1] = 2.0 / n2;
 e[1][2] = 1.0 / (float)nsegs;
 e[0][3] = 1.0;
}

variable_types: nsegments short


drcurve

original_code:
void
drcurve(int n, float (*r)[4])
{
 int it, vx, vy, sync;
 if ((sync = vdevice.sync)!=0)
  vdevice.sync = 0;
 vdevice.cpVvalid = 0;
 if (vdevice.clipoff) {
  vdevice.cpVx = WtoVx(r[0]);
  vdevice.cpVy = WtoVy(r[0]);
 }
 for (it = 0; it < n; it++) {
  vdevice.cpWtrans[0] = r[0][0];
  vdevice.cpWtrans[1] = r[0][1];
  vdevice.cpWtrans[2] = r[0][2];
  vdevice.cpWtrans[3] = r[0][3];
  r[0][0] += r[1][0];
  r[1][0] += r[2][0];
  r[2][0] += r[3][0];
  r[0][1] += r[1][1];
  r[1][1] += r[2][1];
  r[2][1] += r[3][1];
  r[0][2] += r[1][2];
  r[1][2] += r[2][2];
  r[2][2] += r[3][2];
  r[0][3] += r[1][3];
  r[1][3] += r[2][3];
  r[2][3] += r[3][3];
  if (vdevice.clipoff) {
   vx = WtoVx(r[0]);
   vy = WtoVy(r[0]);
   (*vdevice.dev.Vdraw)(vx, vy);
   vdevice.cpVx = vx;
   vdevice.cpVy = vy;
   vdevice.cpVvalid = 0;
  } else {
   if (vdevice.cpVvalid)
    quickclip(vdevice.cpWtrans, r[0]);
   else
    clip(vdevice.cpWtrans, r[0]);
  }
 }
 vdevice.cpWtrans[0] = r[0][0];
 vdevice.cpWtrans[1] = r[0][1];
 vdevice.cpWtrans[2] = r[0][2];
 vdevice.cpWtrans[3] = r[0][3];
 if (sync) {
  vdevice.sync = 1;
  (*vdevice.dev.Vsync)();
 }
}

canonical_original_code:
void drcurve(int n, float (*r)[4])
{
 int it; int vx; int vy; int sync;
 if ((sync = vdevice.sync)!=0)
  vdevice.sync = 0;
 vdevice.cpVvalid = 0;
 if (vdevice.clipoff) {
  vdevice.cpVx = WtoVx(r[0]);
  vdevice.cpVy = WtoVy(r[0]);
 }
 for (it = 0; it < n; it++) {
  vdevice.cpWtrans[0] = r[0][0];
  vdevice.cpWtrans[1] = r[0][1];
  vdevice.cpWtrans[2] = r[0][2];
  vdevice.cpWtrans[3] = r[0][3];
  r[0][0] += r[1][0];
  r[1][0] += r[2][0];
  r[2][0] += r[3][0];
  r[0][1] += r[1][1];
  r[1][1] += r[2][1];
  r[2][1] += r[3][1];
  r[0][2] += r[1][2];
  r[1][2] += r[2][2];
  r[2][2] += r[3][2];
  r[0][3] += r[1][3];
  r[1][3] += r[2][3];
  r[2][3] += r[3][3];
  if (vdevice.clipoff) {
   vx = WtoVx(r[0]);
   vy = WtoVy(r[0]);
   (*vdevice.dev.Vdraw)(vx, vy);
   vdevice.cpVx = vx;
   vdevice.cpVy = vy;
   vdevice.cpVvalid = 0;
  } else {
   if (vdevice.cpVvalid)
    quickclip(vdevice.cpWtrans, r[0]);
   else
    clip(vdevice.cpWtrans, r[0]);
  }
 }
 vdevice.cpWtrans[0] = r[0][0];
 vdevice.cpWtrans[1] = r[0][1];
 vdevice.cpWtrans[2] = r[0][2];
 vdevice.cpWtrans[3] = r[0][3];
 if (sync) {
  vdevice.sync = 1;
  (*vdevice.dev.Vsync)();
 }
}

variable_types: n int

variable_types:
r
float (*)[4]

variable_types: it int

variable_types: vx int

variable_types: vy int

variable_types: sync int


rcrv

decompiled_code:
char *__fastcall rcrv(__int64 a1)
{
__m128i v1; // xmm0
int v2; // er14
__m128i v3; // xmm0
int v4; // er15
__m128i v5; // xmm0
int v6; // er13
char *result; // rax
_DWORD *v8; // rax
int v9; // edx
_DWORD *v10; // rdx
int v11; // xmm0_4
float v12; // [rsp+0h] [rbp-B8h] BYREF
float v13; // [rsp+4h] [rbp-B4h]
float v14; // [rsp+8h] [rbp-B0h]
float v15; // [rsp+10h] [rbp-A8h]
float v16; // [rsp+14h] [rbp-A4h]
float v17; // [rsp+18h] [rbp-A0h]
float v18; // [rsp+20h] [rbp-98h]
float v19; // [rsp+24h] [rbp-94h]
float v20; // [rsp+28h] [rbp-90h]
float v21; // [rsp+30h] [rbp-88h]
float v22; // [rsp+34h] [rbp-84h]
float v23; // [rsp+38h] [rbp-80h]
char v24[64]; // [rsp+40h] [rbp-78h] BYREF
char v25; // [rsp+80h] [rbp-38h] BYREF

if ( vdevice )
{
mult4x4(&v12, (char *)&vdevice + 376, a1);
v1 = (__m128i)LODWORD(v12);
*(float *)v1.m128i_i32 = (float)((float)(v12 + v15) + v18) + v21;
v2 = _mm_cvtsi128_si32(v1);
v3 = (__m128i)LODWORD(v13);
*(float *)v3.m128i_i32 = (float)((float)(v13 + v16) + v19) + v22;
v4 = _mm_cvtsi128_si32(v3);
v5 = (__m128i)LODWORD(v14);
*(float *)v5.m128i_i32 = (float)((float)(v14 + v17) + v20) + v23;
v6 = _mm_cvtsi128_si32(v5);
mult4x4(v24, &e, &v12);
if ( *((_BYTE *)&vdevice + 2) )
{
v8 = (_DWORD *)newtokens(21LL);
v9 = nsegs;
*v8 = 28;
v8[1] = v9;
v10 = v8 + 4;
v8[2] = v2;
v8[3] = v4;
v8[4] = v6;
result = v24;
do
{
v11 = *(_DWORD *)result;
result += 4;
*++v10 = v11;
}
while ( result != &v25 );
}
else
{
mult4x4(&v12, v24, *((_QWORD *)&vdevice + 3));
result = (char *)drcurve(nsegs, (__int64)&v12);
*((_DWORD *)&vdevice + 14) = v2;
*((_DWORD *)&vdevice + 15) = v4;
*((_DWORD *)&vdevice + 16) = v6;
}
}
else
{
verror("rcrv: vogl not initialised");
result = (char *)crv();
}
return result;
}

original_code:
void
rcrv(Coord (*geom)[4])
{
 Matrix d, tmp;
 float *m, xlast, ylast, zlast;
 Token *tok;
 int i;
 if (!vdevice.initialised)
  verror("rcrv: vogl not initialised");
 mult4x4(d, vdevice.tbasis, geom);
 xlast = d[0][0] + d[1][0] + d[2][0] + d[3][0];
 ylast = d[0][1] + d[1][1] + d[2][1] + d[3][1];
 zlast = d[0][2] + d[1][2] + d[2][2] + d[3][2];
 mult4x4(tmp, e, d);
 if (vdevice.inobject) {
  tok = newtokens(21);
  tok[0].i = 28;
  (++tok)->i = nsegs;
  (++tok)->f = xlast;
  (++tok)->f = ylast;
  (++tok)->f = zlast;
  m = (float *)tmp;
  for (i = 0; i < 16; i++)
   (++tok)->f = *m++;
  return;
 }
 mult4x4(d, tmp, vdevice.transmat->m);
 drcurve(nsegs, d);
 vdevice.cpW[0] = xlast;
 vdevice.cpW[1] = ylast;
 vdevice.cpW[2] = zlast;
}

canonical_original_code:
void rcrv(float (*geom)[4])
{
 float d[4][4]; float tmp[4][4];
 float *m; float xlast; float ylast; float zlast;
 union tk *tok;
 int i;
 if (!vdevice.initialised)
  verror("rcrv: vogl not initialised");
 mult4x4(d, vdevice.tbasis, geom);
 xlast = d[0][0] + d[1][0] + d[2][0] + d[3][0];
 ylast = d[0][1] + d[1][1] + d[2][1] + d[3][1];
 zlast = d[0][2] + d[1][2] + d[2][2] + d[3][2];
 mult4x4(tmp, e, d);
 if (vdevice.inobject) {
  tok = newtokens(21);
  tok[0].i = 28;
  (++tok)->i = nsegs;
  (++tok)->f = xlast;
  (++tok)->f = ylast;
  (++tok)->f = zlast;
  m = (float *)tmp;
  for (i = 0; i < 16; i++)
   (++tok)->f = *m++;
  return;
 }
 mult4x4(d, tmp, vdevice.transmat->m);
 drcurve(nsegs, d);
 vdevice.cpW[0] = xlast;
 vdevice.cpW[1] = ylast;
 vdevice.cpW[2] = zlast;
}

variable_types:
geom
float (*)[4]

variable_types:
d
float [4][4]

variable_types:
tmp
float [4][4]

variable_types:
m
float *

variable_types: xlast float

variable_types: ylast float

variable_types: zlast float

variable_types:
tok
union tk { int i; float f; } *

variable_types: i int


crv

decompiled_code:
char *__fastcall crv(_QWORD *a1)
{
char *v1; // rax
__int64 v2; // rdx
char *result; // rax
_BYTE v4[64]; // [rsp+0h] [rbp-48h] BYREF
char v5; // [rsp+40h] [rbp-8h] BYREF

if ( vdevice )
{
v1 = v4;
do
{
v2 = *a1;
*((_DWORD *)v1 + 3) = LC2;
v1 += 16;
a1 = (_QWORD *)((char *)a1 + 12);
*((_QWORD *)v1 - 2) = v2;
*((_DWORD *)v1 - 2) = *((_DWORD *)a1 - 1);
}
while ( &v5 != v1 );
result = rcrv((__int64)v4);
}
else
{
verror("crv: vogl not initialised");
result = (char *)crvn();
}
return result;
}

canonical_decompiled_code:
char *__fastcall func4(_QWORD *a1)
{
char *v1; // rax
__int64 v2; // rdx
char *result; // rax
_BYTE v4[64]; // [rsp+0h] [rbp-48h] BYREF
char v5; // [rsp+40h] [rbp-8h] BYREF

if ( vdevice )
{
v1 = v4;
do
{
v2 = *a1;
*((_DWORD *)v1 + 3) = LC2;
v1 += 16;
a1 = (_QWORD *)((char *)a1 + 12);
*((_QWORD *)v1 - 2) = v2;
*((_DWORD *)v1 - 2) = *((_DWORD *)a1 - 1);
}
while ( &v5 != v1 );
result = func3((__int64)v4);
}
else
{
verror("crv: vogl not initialised");
result = (char *)func5();
}
return result;
}

original_code:
void
crv(Coord (*geom)[3])
{
 Matrix tmp;
 int i, j;
 if (!vdevice.initialised)
  verror("crv: vogl not initialised");
 for (i = 0; i < 4; i++) {
  tmp[i][3] = 1.0;
  for (j = 0; j < 3; j++)
   tmp[i][j] = geom[i][j];
 }
 rcrv(tmp);
}

canonical_original_code:
void crv(float (*geom)[3])
{
 float tmp[4][4];
 int i; int j;
 if (!vdevice.initialised)
  verror("crv: vogl not initialised");
 for (i = 0; i < 4; i++) {
  tmp[i][3] = 1.0;
  for (j = 0; j < 3; j++)
   tmp[i][j] = geom[i][j];
 }
 rcrv(tmp);
}

variable_types:
geom
float (*)[3]

variable_types: j int


crvn

decompiled_code:
char *__fastcall crvn(__int64 a1, _QWORD *a2)
{
__int64 v3; // r12
__int64 v4; // rbp
_QWORD *v5; // rdi
char *result; // rax

if ( !vdevice )
{
verror("crvn: vogl not initialised");
goto LABEL_7;
}
if ( a1 <= 3 )
{
LABEL_7:
verror("crvn: not enough points in geometry matrix");
return (char *)rcrvn();
}
v3 = a1 - 3;
v4 = 0LL;
do
{
v5 = a2;
++v4;
a2 = (_QWORD *)((char *)a2 + 12);
result = crv(v5);
}
while ( v3 != v4 );
return result;
}

canonical_decompiled_code:
char *__fastcall func5(__int64 a1, _QWORD *a2)
{
__int64 v3; // r12
__int64 v4; // rbp
_QWORD *v5; // rdi
char *result; // rax

if ( !vdevice )
{
verror("crvn: vogl not initialised");
goto LABEL_7;
}
if ( a1 <= 3 )
{
LABEL_7:
verror("crvn: not enough points in geometry matrix");
return (char *)func6();
}
v3 = a1 - 3;
v4 = 0LL;
do
{
v5 = a2;
++v4;
a2 = (_QWORD *)((char *)a2 + 12);
result = func4(v5);
}
while ( v3 != v4 );
return result;
}

original_code:
void
crvn(long int n, Coord (*geom)[3])
{
 int i;
 if (!vdevice.initialised)
  verror("crvn: vogl not initialised");
 if (n < 4)
  verror("crvn: not enough points in geometry matrix");
 for (i = 0; i <= n - 4; i++)
  crv(&geom[i]);
}

canonical_original_code:
void crvn(long n, float (*geom)[3])
{
 int i;
 if (!vdevice.initialised)
  verror("crvn: vogl not initialised");
 if (n < 4)
  verror("crvn: not enough points in geometry matrix");
 for (i = 0; i <= n - 4; i++)
  crv(&geom[i]);
}

variable_types: n long


rcrvn

decompiled_code:
char *__fastcall rcrvn(__int64 a1, __int64 a2)
{
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // rdi
char *result; // rax

if ( !vdevice )
{
verror("rcrvn: vogl not initialised");
goto LABEL_7;
}
if ( a1 <= 3 )
{
LABEL_7:
verror("rcrvn: not enough points in geometry matrix");
return (char *)curveit();
}
v3 = a1 - 3;
v4 = 0LL;
do
{
v5 = a2;
++v4;
a2 += 16LL;
result = rcrv(v5);
}
while ( v3 != v4 );
return result;
}

canonical_decompiled_code:
char *__fastcall func6(__int64 a1, __int64 a2)
{
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // rdi
char *result; // rax

if ( !vdevice )
{
verror("rcrvn: vogl not initialised");
goto LABEL_7;
}
if ( a1 <= 3 )
{
LABEL_7:
verror("rcrvn: not enough points in geometry matrix");
return (char *)func7();
}
v3 = a1 - 3;
v4 = 0LL;
do
{
v5 = a2;
++v4;
a2 += 16LL;
result = func3(v5);
}
while ( v3 != v4 );
return result;
}

original_code:
void
rcrvn(long int n, Coord (*geom)[4])
{
 int i;
 if (!vdevice.initialised)
  verror("rcrvn: vogl not initialised");
 if (n < 4)
  verror("rcrvn: not enough points in geometry matrix");
 for (i = 0; i <= n - 4; i++)
  rcrv(&geom[i]);
}

canonical_original_code:
void rcrvn(long n, float (*geom)[4])
{
 int i;
 if (!vdevice.initialised)
  verror("rcrvn: vogl not initialised");
 if (n < 4)
  verror("rcrvn: not enough points in geometry matrix");
 for (i = 0; i <= n - 4; i++)
  rcrv(&geom[i]);
}


curveit

decompiled_code:
__int64 __fastcall curveit(__int16 a1)
{
return drcurve(a1, vdevice[3]);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int16 a1)
{
return func2(a1, vdevice[3]);
}

original_code:
void
curveit(short int n)
{
 drcurve((int)n, vdevice.transmat->m);
}

canonical_original_code:
void curveit(short n)
{
 drcurve((int)n, vdevice.transmat->m);
}

variable_types: n short


clip

variable_types: t float

variable_types: dx float

variable_types: dy float

variable_types: dz float

variable_types: dw float


decompiled_code:
__int64 swapbu_()
{
return swapbuffers__localalias();
}

canonical_decompiled_code:
__int64 func5()
{
return func4();
}

original_code:
void
swapbu_()
{
 swapbuffers();
}

canonical_original_code:
void swapbu_()
{
 swapbuffers();
}


decompiled_code:
__int64 double_()
{
return doublebuffer__localalias();
}

canonical_decompiled_code:
__int64 func7()
{
return func6();
}

original_code:
void
double_()
{
 doublebuffer();
}

canonical_original_code:
void double_()
{
 doublebuffer();
}


decompiled_code:
__int64 single_()
{
return singlebuffer__localalias();
}

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

original_code:
void
single_()
{
 singlebuffer();
}

canonical_original_code:
void single_()
{
 singlebuffer();
}


vcall

decompiled_code:
int __fastcall vcall(float *a1, int a2)
{
unsigned int v2; // esi
double v3; // xmm3_8
double v4; // xmm4_8
double v5; // xmm5_8
int v6; // edx
int *v7; // rax
float v9; // [rsp+0h] [rbp-14h]
float v10; // [rsp+0h] [rbp-14h]
float v11; // [rsp+4h] [rbp-10h]
float v12; // [rsp+4h] [rbp-10h]

v2 = a2 - 3;
v3 = 0.0;
*(_QWORD *)&v4 = *(unsigned int *)a1;
*(_QWORD *)&v5 = *((unsigned int *)a1 + 1);
if ( v2 <= 1 )
*(_QWORD *)&v3 = *((unsigned int *)a1 + 2);
v6 = *((_DWORD *)&vdevice + 88);
LODWORD(v7) = *((unsigned __int8 *)&vdevice + 348);
if ( v6 )
{
*((_DWORD *)&vdevice + 84) = LODWORD(v4);
*((_DWORD *)&vdevice + 85) = LODWORD(v5);
*((_DWORD *)&vdevice + 86) = LODWORD(v3);
switch ( (char)v7 )
{
case 1:
goto LABEL_9;
case 2:
case 3:
*((_DWORD *)&vdevice + 88) = 0;
goto LABEL_7;
case 4:
*((_DWORD *)&vdevice + 88) = 0;
LODWORD(v7) = pmv(v4, v5, v3);
return (int)v7;
case 5:
if ( v6 <= 1 )
goto LABEL_11;
v11 = *(float *)&v5;
v9 = *(float *)&v4;
pmv(
COERCE_DOUBLE((unsigned __int64)(unsigned int)tmesh_1[0]),
COERCE_DOUBLE((unsigned __int64)dword_674),
COERCE_DOUBLE((unsigned __int64)dword_678));
pdr(*(float *)&dword_67C, *(float *)&dword_680, COERCE_DOUBLE((unsigned __int64)dword_684));
pdr(v9, v11, COERCE_DOUBLE((unsigned __int64)LODWORD(v3)));
pclos();
v6 = *((_DWORD *)&vdevice + 88);
v7 = &tmesh_1[3 * (v6 % 2)];
*(float *)v7 = v9;
*((float *)v7 + 1) = v11;
v7[2] = LODWORD(v3);
goto LABEL_12;
case 6:
if ( v6 <= 2 )
goto LABEL_14;
if ( (v6 & 1) != 0 )
{
v12 = *(float *)&v5;
v10 = *(float *)&v4;
pmv(
COERCE_DOUBLE((unsigned __int64)(unsigned int)qstrip_0),
COERCE_DOUBLE((unsigned __int64)HIDWORD(qstrip_0)),
COERCE_DOUBLE((unsigned __int64)dword_648));
pdr(*(float *)&dword_64C, *(float *)&dword_650, COERCE_DOUBLE((unsigned __int64)dword_654));
pdr(v10, v12, COERCE_DOUBLE((unsigned __int64)LODWORD(v3)));
pdr(*(float *)&qword_658, *((float *)&qword_658 + 1), COERCE_DOUBLE((unsigned __int64)dword_660));
pclos();
LODWORD(v7) = qword_658;
qstrip_0 = qword_658;
v6 = *((_DWORD *)&vdevice + 88);
dword_648 = dword_660;
dword_64C = LODWORD(v10);
dword_650 = LODWORD(v12);
dword_654 = LODWORD(v3);
}
else
{
LODWORD(qword_658) = LODWORD(v4);
HIDWORD(qword_658) = LODWORD(v5);
dword_660 = LODWORD(v3);
}
goto LABEL_12;
default:
goto LABEL_7;
}
}
switch ( (char)v7 )
{
case 1:
LABEL_9:
LODWORD(v7) = pnt(v4, v5, v3);
break;
case 2:
case 3:
LODWORD(v7) = draw(v4, v5, v3);
break;
case 4:
LODWORD(v7) = pdr(*a1, a1[1], v3);
break;
case 5:
LABEL_11:
v7 = &tmesh_1[3 * v6];
*v7 = LODWORD(v4);
v7[1] = LODWORD(v5);
v7[2] = LODWORD(v3);
goto LABEL_12;
case 6:
LABEL_14:
v7 = (int *)&qstrip_0 + 3 * v6;
*v7 = LODWORD(v4);
v7[1] = LODWORD(v5);
v7[2] = LODWORD(v3);
LABEL_12:
*((_DWORD *)&vdevice + 88) = v6 + 1;
break;
default:
LABEL_7:
LODWORD(v7) = move((int)a1, v2);
break;
}
return (int)v7;
}

canonical_decompiled_code:
int __fastcall func0(float *a1, int a2)
{
unsigned int v2; // esi
double v3; // xmm3_8
double v4; // xmm4_8
double v5; // xmm5_8
int v6; // edx
int *v7; // rax
float v9; // [rsp+0h] [rbp-14h]
float v10; // [rsp+0h] [rbp-14h]
float v11; // [rsp+4h] [rbp-10h]
float v12; // [rsp+4h] [rbp-10h]

v2 = a2 - 3;
v3 = 0.0;
*(_QWORD *)&v4 = *(unsigned int *)a1;
*(_QWORD *)&v5 = *((unsigned int *)a1 + 1);
if ( v2 <= 1 )
*(_QWORD *)&v3 = *((unsigned int *)a1 + 2);
v6 = *((_DWORD *)&vdevice + 88);
LODWORD(v7) = *((unsigned __int8 *)&vdevice + 348);
if ( v6 )
{
*((_DWORD *)&vdevice + 84) = LODWORD(v4);
*((_DWORD *)&vdevice + 85) = LODWORD(v5);
*((_DWORD *)&vdevice + 86) = LODWORD(v3);
switch ( (char)v7 )
{
case 1:
goto LABEL_9;
case 2:
case 3:
*((_DWORD *)&vdevice + 88) = 0;
goto LABEL_7;
case 4:
*((_DWORD *)&vdevice + 88) = 0;
LODWORD(v7) = pmv(v4, v5, v3);
return (int)v7;
case 5:
if ( v6 <= 1 )
goto LABEL_11;
v11 = *(float *)&v5;
v9 = *(float *)&v4;
pmv(
COERCE_DOUBLE((unsigned __int64)(unsigned int)tmesh_1[0]),
COERCE_DOUBLE((unsigned __int64)dword_674),
COERCE_DOUBLE((unsigned __int64)dword_678));
pdr(*(float *)&dword_67C, *(float *)&dword_680, COERCE_DOUBLE((unsigned __int64)dword_684));
pdr(v9, v11, COERCE_DOUBLE((unsigned __int64)LODWORD(v3)));
pclos();
v6 = *((_DWORD *)&vdevice + 88);
v7 = &tmesh_1[3 * (v6 % 2)];
*(float *)v7 = v9;
*((float *)v7 + 1) = v11;
v7[2] = LODWORD(v3);
goto LABEL_12;
case 6:
if ( v6 <= 2 )
goto LABEL_14;
if ( (v6 & 1) != 0 )
{
v12 = *(float *)&v5;
v10 = *(float *)&v4;
pmv(
COERCE_DOUBLE((unsigned __int64)(unsigned int)qstrip_0),
COERCE_DOUBLE((unsigned __int64)HIDWORD(qstrip_0)),
COERCE_DOUBLE((unsigned __int64)dword_648));
pdr(*(float *)&dword_64C, *(float *)&dword_650, COERCE_DOUBLE((unsigned __int64)dword_654));
pdr(v10, v12, COERCE_DOUBLE((unsigned __int64)LODWORD(v3)));
pdr(*(float *)&qword_658, *((float *)&qword_658 + 1), COERCE_DOUBLE((unsigned __int64)dword_660));
pclos();
LODWORD(v7) = qword_658;
qstrip_0 = qword_658;
v6 = *((_DWORD *)&vdevice + 88);
dword_648 = dword_660;
dword_64C = LODWORD(v10);
dword_650 = LODWORD(v12);
dword_654 = LODWORD(v3);
}
else
{
LODWORD(qword_658) = LODWORD(v4);
HIDWORD(qword_658) = LODWORD(v5);
dword_660 = LODWORD(v3);
}
goto LABEL_12;
default:
goto LABEL_7;
}
}
switch ( (char)v7 )
{
case 1:
LABEL_9:
LODWORD(v7) = pnt(v4, v5, v3);
break;
case 2:
case 3:
LODWORD(v7) = draw(v4, v5, v3);
break;
case 4:
LODWORD(v7) = pdr(*a1, a1[1], v3);
break;
case 5:
LABEL_11:
v7 = &tmesh_1[3 * v6];
*v7 = LODWORD(v4);
v7[1] = LODWORD(v5);
v7[2] = LODWORD(v3);
goto LABEL_12;
case 6:
LABEL_14:
v7 = (int *)&qstrip_0 + 3 * v6;
*v7 = LODWORD(v4);
v7[1] = LODWORD(v5);
v7[2] = LODWORD(v3);
LABEL_12:
*((_DWORD *)&vdevice + 88) = v6 + 1;
break;
default:
LABEL_7:
LODWORD(v7) = move((int)a1, v2);
break;
}
return (int)v7;
}

original_code:
static void
vcall(float *vector, int len)
{
 Vector vec;
 static Coord tmesh[2][3];
        static Coord qstrip[3][3];
        int sjm;
 vec[0] = vector[0];
 vec[1] = vector[1];
 vec[2] = 0.0;
 vec[3] = 1.0;
 if (len == 3) {
  vec[2] = vector[2];
  vec[3] = 1.0;
 } else if (len == 4) {
  vec[2] = vector[2];
  vec[3] = vector[3];
 }
 if (vdevice.save) {
  vdevice.savex = vec[0];
  vdevice.savey = vec[1];
  vdevice.savez = vec[2];
 }
 switch (vdevice.bgnmode) {
 case 2:
  if (vdevice.save) {
   vdevice.save = 0;
   move(vec[0], vec[1], vec[2]);
   break;
  }
  draw(vec[0], vec[1], vec[2]);
  break;
 case 1:
  pnt(vec[0], vec[1], vec[2]);
  break;
 case 3:
  if (vdevice.save) {
   vdevice.save = 0;
   move(vec[0], vec[1], vec[2]);
   break;
  }
  draw(vec[0], vec[1], vec[2]);
  break;
 case 4:
  if (vdevice.save) {
   vdevice.save = 0;
   pmv(vec[0], vec[1], vec[2]);
   break;
  }
  pdr(vec[0], vec[1], vec[2]);
  break;
 case 5:
  if( vdevice.save < 2 ) {
   tmesh[vdevice.save][0] = vec[0];
   tmesh[vdevice.save][1] = vec[1];
   tmesh[vdevice.save][2] = vec[2];
  } else {
   pmv(tmesh[0][0], tmesh[0][1], tmesh[0][2]);
   pdr(tmesh[1][0], tmesh[1][1], tmesh[1][2]);
   pdr( vec[0], vec[1], vec[2]);
   pclos();
   sjm = vdevice.save % 2;
   tmesh[sjm][0] = vec[0];
   tmesh[sjm][1] = vec[1];
   tmesh[sjm][2] = vec[2];
  }
  vdevice.save++;
  break;
 case 6:
  if( vdevice.save < 3 ) {
   qstrip[vdevice.save][0] = vec[0];
   qstrip[vdevice.save][1] = vec[1];
   qstrip[vdevice.save][2] = vec[2];
  } else {
   sjm = vdevice.save % 2;
   if (sjm) {
    pmv(qstrip[0][0], qstrip[0][1], qstrip[0][2]);
    pdr(qstrip[1][0], qstrip[1][1], qstrip[1][2]);
    pdr( vec[0], vec[1], vec[2]);
    pdr(qstrip[2][0], qstrip[2][1], qstrip[2][2]);
    pclos();
    qstrip[0][0] = qstrip[2][0];
    qstrip[0][1] = qstrip[2][1];
    qstrip[0][2] = qstrip[2][2];
    qstrip[1][0] = vec[0];
    qstrip[1][1] = vec[1];
    qstrip[1][2] = vec[2];
   } else {
    qstrip[2][0] = vec[0];
    qstrip[2][1] = vec[1];
    qstrip[2][2] = vec[2];
   }
  }
  vdevice.save++;
  break;
 default:
  move(vec[0], vec[1], vec[2]);
 }
}

canonical_original_code:
static void vcall(float *vector, int len)
{
 float vec[4];
 static float tmesh[2][3];
        static float qstrip[3][3];
        int sjm;
 vec[0] = vector[0];
 vec[1] = vector[1];
 vec[2] = 0.0;
 vec[3] = 1.0;
 if (len == 3) {
  vec[2] = vector[2];
  vec[3] = 1.0;
 } else if (len == 4) {
  vec[2] = vector[2];
  vec[3] = vector[3];
 }
 if (vdevice.save) {
  vdevice.savex = vec[0];
  vdevice.savey = vec[1];
  vdevice.savez = vec[2];
 }
 switch (vdevice.bgnmode) {
 case 2:
  if (vdevice.save) {
   vdevice.save = 0;
   move(vec[0], vec[1], vec[2]);
   break;
  }
  draw(vec[0], vec[1], vec[2]);
  break;
 case 1:
  pnt(vec[0], vec[1], vec[2]);
  break;
 case 3:
  if (vdevice.save) {
   vdevice.save = 0;
   move(vec[0], vec[1], vec[2]);
   break;
  }
  draw(vec[0], vec[1], vec[2]);
  break;
 case 4:
  if (vdevice.save) {
   vdevice.save = 0;
   pmv(vec[0], vec[1], vec[2]);
   break;
  }
  pdr(vec[0], vec[1], vec[2]);
  break;
 case 5:
  if( vdevice.save < 2 ) {
   tmesh[vdevice.save][0] = vec[0];
   tmesh[vdevice.save][1] = vec[1];
   tmesh[vdevice.save][2] = vec[2];
  } else {
   pmv(tmesh[0][0], tmesh[0][1], tmesh[0][2]);
   pdr(tmesh[1][0], tmesh[1][1], tmesh[1][2]);
   pdr( vec[0], vec[1], vec[2]);
   pclos();
   sjm = vdevice.save % 2;
   tmesh[sjm][0] = vec[0];
   tmesh[sjm][1] = vec[1];
   tmesh[sjm][2] = vec[2];
  }
  vdevice.save++;
  break;
 case 6:
  if( vdevice.save < 3 ) {
   qstrip[vdevice.save][0] = vec[0];
   qstrip[vdevice.save][1] = vec[1];
   qstrip[vdevice.save][2] = vec[2];
  } else {
   sjm = vdevice.save % 2;
   if (sjm) {
    pmv(qstrip[0][0], qstrip[0][1], qstrip[0][2]);
    pdr(qstrip[1][0], qstrip[1][1], qstrip[1][2]);
    pdr( vec[0], vec[1], vec[2]);
    pdr(qstrip[2][0], qstrip[2][1], qstrip[2][2]);
    pclos();
    qstrip[0][0] = qstrip[2][0];
    qstrip[0][1] = qstrip[2][1];
    qstrip[0][2] = qstrip[2][2];
    qstrip[1][0] = vec[0];
    qstrip[1][1] = vec[1];
    qstrip[1][2] = vec[2];
   } else {
    qstrip[2][0] = vec[0];
    qstrip[2][1] = vec[1];
    qstrip[2][2] = vec[2];
   }
  }
  vdevice.save++;
  break;
 default:
  move(vec[0], vec[1], vec[2]);
 }
}

variable_types:
vector
float *

variable_types: len int

variable_types:
vec
float [4]

variable_types:
tmesh
float [2][3]

variable_types:
qstrip
float [3][3]

variable_types: sjm int


decompiled_code:
int __fastcall v4f(float *a1)
{
return vcall(a1, 4);
}

canonical_decompiled_code:
int __fastcall func1(float *a1)
{
return func0(a1, 4);
}

original_code:
void
v4f(float *vec)
{
 vcall(vec, 4);
}

canonical_original_code:
void v4f(float *vec)
{
 vcall(vec, 4);
}

variable_types:
vec
float *


decompiled_code:
int __fastcall v3f(float *a1)
{
return vcall(a1, 3);
}

canonical_decompiled_code:
int __fastcall func2(float *a1)
{
return func0(a1, 3);
}

original_code:
void
v3f(float *vec)
{
 vcall(vec, 3);
}

canonical_original_code:
void v3f(float *vec)
{
 vcall(vec, 3);
}


decompiled_code:
int __fastcall v2f(float *a1)
{
return vcall(a1, 2);
}

canonical_decompiled_code:
int __fastcall func3(float *a1)
{
return func0(a1, 2);
}

original_code:
void
v2f(float *vec)
{
 vcall(vec, 2);
}

canonical_original_code:
void v2f(float *vec)
{
 vcall(vec, 2);
}


original_code:
void
v3d(double *vec)
{
 float v[3];
 v[0] = vec[0];
 v[1] = vec[1];
 v[2] = vec[2];
 vcall(v, 3);
}

variable_types:
vec
double *

variable_types:
v
float [3]


decompiled_code:
int __fastcall v2d(double *a1)
{
float v1; // xmm0_4
int v2; // xmm0_4
int v4[4]; // [rsp+8h] [rbp-10h] BYREF

v1 = *a1;
*(float *)v4 = v1;
*(float *)&v2 = a1[1];
v4[1] = v2;
return vcall((float *)v4, 2);
}

canonical_decompiled_code:
int __fastcall func6(double *a1)
{
float v1; // xmm0_4
int v2; // xmm0_4
int v4[4]; // [rsp+8h] [rbp-10h] BYREF

v1 = *a1;
*(float *)v4 = v1;
*(float *)&v2 = a1[1];
v4[1] = v2;
return func0((float *)v4, 2);
}

original_code:
void
v2d(double *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}

variable_types:
v
float [2]


decompiled_code:
int __fastcall v4i(_QWORD *a1)
{
int v2[6]; // [rsp+0h] [rbp-18h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
*(float *)&v2[2] = (float)(int)a1[2];
*(float *)&v2[3] = (float)(int)a1[3];
return vcall((float *)v2, 4);
}

canonical_decompiled_code:
int __fastcall func7(_QWORD *a1)
{
int v2[6]; // [rsp+0h] [rbp-18h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
*(float *)&v2[2] = (float)(int)a1[2];
*(float *)&v2[3] = (float)(int)a1[3];
return func0((float *)v2, 4);
}

variable_types:
vec
long *

variable_types:
v
float [4]


decompiled_code:
int __fastcall v3i(_QWORD *a1)
{
int v2[5]; // [rsp+4h] [rbp-14h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
*(float *)&v2[2] = (float)(int)a1[2];
return vcall((float *)v2, 3);
}

canonical_decompiled_code:
int __fastcall func8(_QWORD *a1)
{
int v2[5]; // [rsp+4h] [rbp-14h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
*(float *)&v2[2] = (float)(int)a1[2];
return func0((float *)v2, 3);
}

original_code:
void
v3i(long int *vec)
{
 float v[3];
 v[0] = vec[0];
 v[1] = vec[1];
 v[2] = vec[2];
 vcall(v, 3);
}


decompiled_code:
int __fastcall v2i(_QWORD *a1)
{
int v2[4]; // [rsp+8h] [rbp-10h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
return vcall((float *)v2, 2);
}

canonical_decompiled_code:
int __fastcall func9(_QWORD *a1)
{
int v2[4]; // [rsp+8h] [rbp-10h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
return func0((float *)v2, 2);
}

original_code:
void
v2i(long int *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}

canonical_original_code:
void v2i(long *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}


decompiled_code:
int __fastcall v4s(__int16 *a1)
{
int v1; // eax
float v2; // xmm0_4
int v3; // eax
float v4; // xmm0_4
int v5; // eax
int v7[6]; // [rsp+0h] [rbp-18h] BYREF

v1 = a1[1];
*(float *)v7 = (float)*a1;
v2 = (float)v1;
v3 = a1[2];
*(float *)&v7[1] = v2;
v4 = (float)v3;
v5 = a1[3];
*(float *)&v7[2] = v4;
*(float *)&v7[3] = (float)v5;
return vcall((float *)v7, 4);
}

canonical_decompiled_code:
int __fastcall func10(__int16 *a1)
{
int v1; // eax
float v2; // xmm0_4
int v3; // eax
float v4; // xmm0_4
int v5; // eax
int v7[6]; // [rsp+0h] [rbp-18h] BYREF

v1 = a1[1];
*(float *)v7 = (float)*a1;
v2 = (float)v1;
v3 = a1[2];
*(float *)&v7[1] = v2;
v4 = (float)v3;
v5 = a1[3];
*(float *)&v7[2] = v4;
*(float *)&v7[3] = (float)v5;
return func0((float *)v7, 4);
}

variable_types:
vec
short *


decompiled_code:
int __fastcall v3s(__int16 *a1)
{
int v1; // eax
float v2; // xmm0_4
int v3; // eax
int v5[5]; // [rsp+4h] [rbp-14h] BYREF

v1 = a1[1];
*(float *)v5 = (float)*a1;
v2 = (float)v1;
v3 = a1[2];
*(float *)&v5[1] = v2;
*(float *)&v5[2] = (float)v3;
return vcall((float *)v5, 3);
}

canonical_decompiled_code:
int __fastcall func11(__int16 *a1)
{
int v1; // eax
float v2; // xmm0_4
int v3; // eax
int v5[5]; // [rsp+4h] [rbp-14h] BYREF

v1 = a1[1];
*(float *)v5 = (float)*a1;
v2 = (float)v1;
v3 = a1[2];
*(float *)&v5[1] = v2;
*(float *)&v5[2] = (float)v3;
return func0((float *)v5, 3);
}

original_code:
void
v3s(short int *vec)
{
 float v[3];
 v[0] = vec[0];
 v[1] = vec[1];
 v[2] = vec[2];
 vcall(v, 3);
}


decompiled_code:
int __fastcall v2s(__int16 *a1)
{
int v1; // eax
int v3[4]; // [rsp+8h] [rbp-10h] BYREF

v1 = a1[1];
*(float *)v3 = (float)*a1;
*(float *)&v3[1] = (float)v1;
return vcall((float *)v3, 2);
}

canonical_decompiled_code:
int __fastcall func12(__int16 *a1)
{
int v1; // eax
int v3[4]; // [rsp+8h] [rbp-10h] BYREF

v1 = a1[1];
*(float *)v3 = (float)*a1;
*(float *)&v3[1] = (float)v1;
return func0((float *)v3, 2);
}

original_code:
void
v2s(short int *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}

canonical_original_code:
void v2s(short *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}


original_code:
static void
out_bytes(int x, int y)
{
 int HiY, LoY, HiX, LoX;
 if (x < 0)
  x = 0;
 if (y < 0)
  y = 0;
 if (x > 1023)
  x = 1023;
 if (y > 1023)
  y = 1023;
 HiY = y / 32 + 32;
 LoY = y % 32 + 96;
 HiX = x / 32 + 32;
 LoX = x % 32 + 64;
 if (HiYold != HiY) {
  fprintf(fp, "%c", HiY);
  HiYold = HiY;
 }
 if ((LoYold != LoY) || (HiXold != HiX)) {
  fprintf(fp, "%c", LoY);
  LoYold = LoY;
  if (HiXold != HiX) {
   fprintf(fp, "%c", HiX);
   HiXold = HiX;
  }
 }
 fprintf(fp, "%c", LoX);
}

canonical_original_code:
static void out_bytes(int x, int y)
{
 int HiY; int LoY; int HiX; int LoX;
 if (x < 0)
  x = 0;
 if (y < 0)
  y = 0;
 if (x > 1023)
  x = 1023;
 if (y > 1023)
  y = 1023;
 HiY = y / 32 + 32;
 LoY = y % 32 + 96;
 HiX = x / 32 + 32;
 LoX = x % 32 + 64;
 if (HiYold != HiY) {
  fprintf(fp, "%c", HiY);
  HiYold = HiY;
 }
 if ((LoYold != LoY) || (HiXold != HiX)) {
  fprintf(fp, "%c", LoY);
  LoYold = LoY;
  if (HiXold != HiX) {
   fprintf(fp, "%c", HiX);
   HiXold = HiX;
  }
 }
 fprintf(fp, "%c", LoX);
}

variable_types: x int

variable_types: y int

variable_types: HiY int

variable_types: LoY int

variable_types: HiX int

variable_types: LoX int


decompiled_code:
__int64 __fastcall TEK_string(char *s)
{
int v2; // esi
int v3; // edi

if ( __PAIR64__(vdevice[35], vdevice[36]) != __PAIR64__(tlstx, tlsty) )
{
fputc(29, fp);
v2 = vdevice[36];
v3 = vdevice[35];
HiXold = -1;
HiYold = -1;
LoYold = -1;
out_bytes(v3, v2);
}
fputc(31, fp);
fputs(s, fp);
tlsty = -1;
tlstx = -1;
fflush(fp);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s)
{
int v2; // esi
int v3; // edi

if ( __PAIR64__(vdevice[35], vdevice[36]) != __PAIR64__(tlstx, tlsty) )
{
fputc(29, fp);
v2 = vdevice[36];
v3 = vdevice[35];
HiXold = -1;
HiYold = -1;
LoYold = -1;
func1(v3, v2);
}
fputc(31, fp);
fputs(s, fp);
tlsty = -1;
tlstx = -1;
fflush(fp);
return 0LL;
}

original_code:
static int
TEK_string(const char *s)
{
 if (tlstx != vdevice.cpVx || tlsty != vdevice.cpVy) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(vdevice.cpVx, vdevice.cpVy);
 }
 fputc('\037', fp);
 fputs(s, fp);
 tlstx = tlsty = -1;
 fflush(fp);
 return(0);
}

canonical_original_code:
static int TEK_string(char *s)
{
 if (tlstx != vdevice.cpVx || tlsty != vdevice.cpVy) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(vdevice.cpVx, vdevice.cpVy);
 }
 fputc('\037', fp);
 fputs(s, fp);
 tlstx = tlsty = -1;
 fflush(fp);
 return(0);
}

variable_types:
s
char *


decompiled_code:
__int64 __fastcall TEK_fill(int a1, int *a2, int *a3)
{
__int64 v5; // rbp
int v6; // esi
int v7; // edi
__int64 i; // rbx
int v9; // esi
int v10; // edi
__int64 v11; // rbp
int v12; // eax

v5 = a1;
if ( *a2 != tlstx || *a3 != tlsty )
{
fputc(29, fp);
v6 = *a3;
v7 = *a2;
HiXold = -1;
HiYold = -1;
LoYold = -1;
out_bytes(v7, v6);
}
if ( (int)v5 > 1 )
{
for ( i = 1LL; i != v5; ++i )
{
v9 = a3[i];
v10 = a2[i];
out_bytes(v10, v9);
}
}
v11 = v5;
out_bytes(*a2, *a3);
fflush(fp);
tlstx = a2[v11 - 1];
vdevice[35] = tlstx;
v12 = a3[v11 - 1];
vdevice[36] = v12;
tlsty = v12;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int *a2, int *a3)
{
__int64 v5; // rbp
int v6; // esi
int v7; // edi
__int64 i; // rbx
int v9; // esi
int v10; // edi
__int64 v11; // rbp
int v12; // eax

v5 = a1;
if ( *a2 != tlstx || *a3 != tlsty )
{
fputc(29, fp);
v6 = *a3;
v7 = *a2;
HiXold = -1;
HiYold = -1;
LoYold = -1;
func1(v7, v6);
}
if ( (int)v5 > 1 )
{
for ( i = 1LL; i != v5; ++i )
{
v9 = a3[i];
v10 = a2[i];
func1(v10, v9);
}
}
v11 = v5;
func1(*a2, *a3);
fflush(fp);
tlstx = a2[v11 - 1];
vdevice[35] = tlstx;
v12 = a3[v11 - 1];
vdevice[36] = v12;
tlsty = v12;
return 0LL;
}

original_code:
static int
TEK_fill(int n, int *x, int *y)
{
 int i;
 if (tlstx != x[0] || tlsty != y[0]) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(x[0], y[0]);
 }
 for (i = 1; i < n; i++)
  out_bytes(x[i], y[i]);
 out_bytes(x[0], y[0]);
 fflush(fp);
 tlstx = vdevice.cpVx = x[n - 1];
 tlsty = vdevice.cpVy = y[n - 1];
 return(0);
}

variable_types: n int

variable_types:
x
int *

variable_types:
y
int *

variable_types: i int


decompiled_code:
__int64 __fastcall TEK_draw(int a1, int a2)
{
int v4; // esi
int v5; // edi

if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
v4 = vdevice[36];
v5 = vdevice[35];
HiXold = -1;
HiYold = -1;
LoYold = -1;
out_bytes(v5, v4);
}
out_bytes(a1, a2);
tlstx = a1;
tlsty = a2;
fflush(fp);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2)
{
int v4; // esi
int v5; // edi

if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
v4 = vdevice[36];
v5 = vdevice[35];
HiXold = -1;
HiYold = -1;
LoYold = -1;
func1(v5, v4);
}
func1(a1, a2);
tlstx = a1;
tlsty = a2;
fflush(fp);
return 0LL;
}

original_code:
static int
TEK_draw(int x, int y)
{
 if (tlstx != vdevice.cpVx || tlsty != vdevice.cpVy) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(vdevice.cpVx, vdevice.cpVy);
 }
 out_bytes(x, y);
 tlstx = x;
 tlsty = y;
 fflush(fp);
 return(0);
}


decompiled_code:
__int64 __fastcall TEK_char(char a1)
{
int v2; // esi
int v3; // edi

if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
v2 = vdevice[36];
v3 = vdevice[35];
HiXold = -1;
HiYold = -1;
LoYold = -1;
out_bytes(v3, v2);
}
fputc(31, fp);
fputc(a1, fp);
tlsty = -1;
tlstx = -1;
fflush(fp);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(char a1)
{
int v2; // esi
int v3; // edi

if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
v2 = vdevice[36];
v3 = vdevice[35];
HiXold = -1;
HiYold = -1;
LoYold = -1;
func1(v3, v2);
}
fputc(31, fp);
fputc(a1, fp);
tlsty = -1;
tlstx = -1;
fflush(fp);
return 0LL;
}

original_code:
static int
TEK_char(char c)
{
 if (tlstx != vdevice.cpVx || tlsty != vdevice.cpVy) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(vdevice.cpVx, vdevice.cpVy);
 }
 fputc('\037', fp);
 fputc(c, fp);
 tlstx = tlsty = -1;
 fflush(fp);
 return(0);
}

variable_types: c char


original_code:
static int
TEK_locator(int *x, int *y)
{
 char buf[5];
 int i;
 struct termio oldtty, newtty;
 if (click) {
  click = 0;
  return(0);
 }
 click = 1;
 if (fp == stdout) {
  ioctl(0, 0x5405, &oldtty);
  newtty = oldtty;
  newtty.c_iflag = 0000002 | 0002000 | 0000040;
  newtty.c_lflag = 0;
  newtty.c_cc[4] = 1;
  ioctl(0, 0x5406, &newtty);
 } else
  return(0);
 fputs("\037\033\032", fp);
 fflush(fp);
 for (i = 0; i < 5; i++)
  buf[i] = getchar();
 ioctl(0, 0x540B, (char *)((void *)0));
 *x = ((buf[1] & 037) << 5) | (buf[2] & 037);
 *y = ((buf[3] & 037) << 5) | (buf[4] & 037);
 ioctl(0, 0x5406, &oldtty);
 tlstx = tlsty = -1;
 return(1 << ((int)buf[0] - '1'));
}

canonical_original_code:
static int TEK_locator(int *x, int *y)
{
 char buf[5];
 int i;
 struct termio oldtty; struct termio newtty;
 if (click) {
  click = 0;
  return(0);
 }
 click = 1;
 if (fp == stdout) {
  ioctl(0, 0x5405, &oldtty);
  newtty = oldtty;
  newtty.c_iflag = 0000002 | 0002000 | 0000040;
  newtty.c_lflag = 0;
  newtty.c_cc[4] = 1;
  ioctl(0, 0x5406, &newtty);
 } else
  return(0);
 fputs("\037\033\032", fp);
 fflush(fp);
 for (i = 0; i < 5; i++)
  buf[i] = getchar();
 ioctl(0, 0x540B, (char *)((void *)0));
 *x = ((buf[1] & 037) << 5) | (buf[2] & 037);
 *y = ((buf[3] & 037) << 5) | (buf[4] & 037);
 ioctl(0, 0x5406, &oldtty);
 tlstx = tlsty = -1;
 return(1 << ((int)buf[0] - '1'));
}

variable_types:
buf
char [5]

variable_types: struct termio { unsigned short c_iflag; unsigned short c_oflag; unsigned short c_cflag; unsigned short c_lflag; unsigned char c_line; unsigned char c_cc[8]; }


decompiled_code:
__int64 TEK_init()
{
__int64 result; // rax

vdevice[26] = 1;
fp = (FILE *)voutfile();
fputc(29, fp);
tlsty = -1;
*(_QWORD *)&vdevice[31] = 0x2FF000002FFLL;
*(_QWORD *)&vdevice[33] = 0x2FF000003FFLL;
result = 1LL;
tlstx = -1;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax

vdevice[26] = 1;
fp = (FILE *)voutfile();
fputc(29, fp);
tlsty = -1;
*(_QWORD *)&vdevice[31] = 0x2FF000002FFLL;
*(_QWORD *)&vdevice[33] = 0x2FF000003FFLL;
result = 1LL;
tlstx = -1;
return result;
}

original_code:
static int
TEK_init(void)
{
 vdevice.depth = 1;
 fp = _voutfile();
 fputc('\035', fp);
 vdevice.sizeX = vdevice.sizeY = 767;
 vdevice.sizeSx = 1023;
 vdevice.sizeSy = 767;
 tlstx = tlsty = -1;
        return(1);
}

canonical_original_code:
static int TEK_init()
{
 vdevice.depth = 1;
 fp = _voutfile();
 fputc('\035', fp);
 vdevice.sizeX = vdevice.sizeY = 767;
 vdevice.sizeSx = 1023;
 vdevice.sizeSy = 767;
 tlstx = tlsty = -1;
        return(1);
}


original_code:
static int
TEK_getkey(void)
{
 struct termio oldtty, newtty;
 char c;
 ioctl(0, 0x5405, &oldtty);
 newtty = oldtty;
 newtty.c_iflag = 0000002 | 0002000 | 0000040;
 newtty.c_lflag = 0;
 newtty.c_cc[4] = 1;
 ioctl(0, 0x5406, &newtty);
 read(0, &c, 1);
 ioctl(0, 0x5406, &oldtty);
 return(c);
}

canonical_original_code:
static int TEK_getkey()
{
 struct termio oldtty; struct termio newtty;
 char c;
 ioctl(0, 0x5405, &oldtty);
 newtty = oldtty;
 newtty.c_iflag = 0000002 | 0002000 | 0000040;
 newtty.c_lflag = 0;
 newtty.c_cc[4] = 1;
 ioctl(0, 0x5406, &newtty);
 read(0, &c, 1);
 ioctl(0, 0x5406, &oldtty);
 return(c);
}

user_defined_types: struct termio { unsigned short c_iflag; unsigned short c_oflag; unsigned short c_cflag; unsigned short c_lflag; unsigned char c_line; unsigned char c_cc[8]; }


decompiled_code:
__int64 __fastcall TEK_font(const char *a1)
{
if ( !strcmp(a1, "small") )
{
fwrite("\x1B:", 1uLL, 2uLL, fp);
vdevice[6] = 0x4100000041700000LL;
}
else
{
if ( strcmp(a1, "large") )
return 0LL;
fwrite("\x1B8", 1uLL, 2uLL, fp);
vdevice[6] = 0x4160000041880000LL;
}
tlsty = -1;
tlstx = -1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1)
{
if ( !strcmp(a1, "small") )
{
fwrite("\x1B:", 1uLL, 2uLL, fp);
vdevice[6] = 0x4100000041700000LL;
}
else
{
if ( strcmp(a1, "large") )
return 0LL;
fwrite("\x1B8", 1uLL, 2uLL, fp);
vdevice[6] = 0x4160000041880000LL;
}
tlsty = -1;
tlstx = -1;
return 1LL;
}

original_code:
static int
TEK_font(char *tekfont)
{
 if (strcmp(tekfont, "small") == 0) {
  fprintf(fp, "\033:");
  vdevice.hwidth = 8.0;
  vdevice.hheight = 15.0;
 } else if (strcmp(tekfont, "large") == 0) {
  fprintf(fp, "\0338");
  vdevice.hwidth = 14.0;
  vdevice.hheight = 17.0;
 } else
  return(0);
 tlstx = tlsty = -1;
 return(1);
}

variable_types:
tekfont
char *


decompiled_code:
__int64 TEK_exit()
{
fputc(31, fp);
fputc(24, fp);
if ( fp != stdout )
fclose(fp);
return 0LL;
}

canonical_decompiled_code:
__int64 func10()
{
fputc(31, fp);
fputc(24, fp);
if ( fp != stdout )
fclose(fp);
return 0LL;
}

original_code:
static int
TEK_exit(void)
{
 fputc('\037', fp);
 fputc('\030', fp);
 if (fp != stdout)
  fclose(fp);
 return(0);
}

canonical_original_code:
static int TEK_exit()
{
 fputc('\037', fp);
 fputc('\030', fp);
 if (fp != stdout)
  fclose(fp);
 return(0);
}


decompiled_code:
__int64 TEK_clear()
{
FILE *v0; // rsi
int v1; // ebx
__int64 result; // rax

fputc(31, fp);
fputc(27, fp);
fputc(12, fp);
fflush(fp);
tlsty = -1;
tlstx = -1;
v0 = fp;
if ( fp == stdout )
{
sleep(2u);
result = 0LL;
}
else
{
v1 = 960;
while ( 1 )
{
fputc(0, v0);
if ( !--v1 )
break;
v0 = fp;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
FILE *v0; // rsi
int v1; // ebx
__int64 result; // rax

fputc(31, fp);
fputc(27, fp);
fputc(12, fp);
fflush(fp);
tlsty = -1;
tlstx = -1;
v0 = fp;
if ( fp == stdout )
{
sleep(2u);
result = 0LL;
}
else
{
v1 = 960;
while ( 1 )
{
fputc(0, v0);
if ( !--v1 )
break;
v0 = fp;
}
result = 0LL;
}
return result;
}

original_code:
static int
TEK_clear(void)
{
 fputc('\037', fp);
 fputc('\033', fp);
 fputc('\014', fp);
 fflush(fp);
 tlstx = tlsty = -1;
 if (fp != stdout) {
  int i;
  for (i = 0; i < 960; i++)
   fputc(0, fp);
 } else
  sleep(2);
 return(0);
}

canonical_original_code:
static int TEK_clear()
{
 fputc('\037', fp);
 fputc('\033', fp);
 fputc('\014', fp);
 fflush(fp);
 tlstx = tlsty = -1;
 if (fp != stdout) {
  int i;
  for (i = 0; i < 960; i++)
   fputc(0, fp);
 } else
  sleep(2);
 return(0);
}


noop

decompiled_code:
__int64 noop()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0xFFFFFFFFLL;
}

original_code:
static int
noop()
{
 return(-1);
}

canonical_original_code:
static int noop()
{
 return(-1);
}


decompiled_code:
__int64 popdev_()
{
return popdev();
}

canonical_decompiled_code:
__int64 func7()
{
return popdev();
}

original_code:
void
popdev_()
{
 popdev();
}

canonical_original_code:
void popdev_()
{
 popdev();
}


decompiled_code:
// attributes: thunk
__int64 gexit_()
{
return gexit();
}

canonical_decompiled_code:
__int64 func10()
{
return gexit();
}

original_code:
void
gexit_()
{
 gexit();
}

canonical_original_code:
void gexit_()
{
 gexit();
}


decompiled_code:
// attributes: thunk
int clear_(void)
{
return clear();
}

canonical_decompiled_code:
int func11(void)
{
return clear();
}

original_code:
void
clear_()
{
 clear();
}

canonical_original_code:
void clear_()
{
 clear();
}


decompiled_code:
__int64 getpla_()
{
return getplanes__localalias();
}

canonical_decompiled_code:
__int64 func17()
{
return func16();
}

original_code:
int
getpla_()
{
 return((int)getplanes());
}


decompiled_code:
void gconfi_()
{
gconfig__localalias();
}

canonical_decompiled_code:
void func23()
{
func22();
}

original_code:
int
gconfi_()
{ }

canonical_original_code:
int gconfi_()
{ }


decompiled_code:
__int64 reshap_()
{
return reshapeviewport__localalias();
}

canonical_decompiled_code:
__int64 func25()
{
return func24();
}

original_code:
int
reshap_()
{
 reshapeviewport();
}

canonical_original_code:
int reshap_()
{
 reshapeviewport();
}


decompiled_code:
void wincon_()
{
;
}

canonical_decompiled_code:
void func27()
{
;
}

original_code:
void
wincon_()
{ }

canonical_original_code:
void wincon_()
{ }


decompiled_code:
void foreground_()
{
;
}

canonical_decompiled_code:
void func34()
{
;
}

original_code:
void
foreground_()
{
}

canonical_original_code:
void foreground_()
{
}


decompiled_code:
void foregr_()
{
;
}

canonical_decompiled_code:
void func35()
{
;
}

original_code:
void
foregr_()
{
}

canonical_original_code:
void foregr_()
{
}


decompiled_code:
__int64 vflush_()
{
return vdevice[41]();
}

canonical_decompiled_code:
__int64 func36()
{
return vdevice[41]();
}

original_code:
void
vflush_()
{
 (*vdevice.dev.Vsync)();
}


rect

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

if ( vdevice )
{
move2();
draw2(a3, a2);
draw2(a3, a4);
draw2(a1, a4);
result = draw2(a1, a2);
}
else
{
verror("rect: vogl not initialised");
result = recti();
}
return result;
}

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

if ( vdevice )
{
move2();
draw2(a3, a2);
draw2(a3, a4);
draw2(a1, a4);
result = draw2(a1, a2);
}
else
{
verror("rect: vogl not initialised");
result = func1();
}
return result;
}

original_code:
void
rect(Coord x1, Coord y1, Coord x2, Coord y2)
{
 if (!vdevice.initialised)
  verror("rect: vogl not initialised");
 move2(x1, y1);
 draw2(x2, y1);
 draw2(x2, y2);
 draw2(x1, y2);
 draw2(x1, y1);
}

canonical_original_code:
void rect(float x1, float y1, float x2, float y2)
{
 if (!vdevice.initialised)
  verror("rect: vogl not initialised");
 move2(x1, y1);
 draw2(x2, y1);
 draw2(x2, y2);
 draw2(x1, y2);
 draw2(x1, y1);
}


recti

decompiled_code:
__int64 __fastcall recti(int a1, int a2, int a3, int a4)
{
return rect((float)a1, (float)a2, (float)a3, (float)a4);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2, int a3, int a4)
{
return func0((float)a1, (float)a2, (float)a3, (float)a4);
}

original_code:
void
recti(Icoord x1, Icoord y1, Icoord x2, Icoord y2)
{
 rect((Coord)x1, (Coord)y1, (Coord)x2, (Coord)y2);
}

canonical_original_code:
void recti(long x1, long y1, long x2, long y2)
{
 rect((float)x1, (float)y1, (float)x2, (float)y2);
}


rects

decompiled_code:
__int64 __fastcall rects(__int16 a1, __int16 a2, __int16 a3, __int16 a4)
{
return rect((float)a1, (float)a2, (float)a3, (float)a4);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int16 a1, __int16 a2, __int16 a3, __int16 a4)
{
return func0((float)a1, (float)a2, (float)a3, (float)a4);
}

original_code:
void
rects(Scoord x1, Scoord y1, Scoord x2, Scoord y2)
{
 rect((Coord)x1, (Coord)y1, (Coord)x2, (Coord)y2);
}

canonical_original_code:
void rects(short x1, short y1, short x2, short y2)
{
 rect((float)x1, (float)y1, (float)x2, (float)y2);
}


frontbuffer

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

if ( vdevice )
{
if ( *((_BYTE *)&vdevice + 2) )
{
result = newtokens(2LL);
*(_DWORD *)result = 35;
*(_DWORD *)(result + 4) = a1;
}
else
{
result = *((_QWORD *)&vdevice + 4);
if ( *(_BYTE *)(result + 1) != 1 )
{
if ( a1 )
{
(*((void (**)(void))&vdevice + 31))();
result = (unsigned int)sync;
*((_WORD *)&vdevice + 3) = (unsigned __int8)sync;
}
else
{
result = backbuffer(1);
}
}
}
}
else
{
verror("frontbuffer: vogl not initialised.");
result = swapbuffers();
}
return result;
}

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

if ( vdevice )
{
if ( *((_BYTE *)&vdevice + 2) )
{
result = newtokens(2LL);
*(_DWORD *)result = 35;
*(_DWORD *)(result + 4) = a1;
}
else
{
result = *((_QWORD *)&vdevice + 4);
if ( *(_BYTE *)(result + 1) != 1 )
{
if ( a1 )
{
(*((void (**)(void))&vdevice + 31))();
result = (unsigned int)sync;
*((_WORD *)&vdevice + 3) = (unsigned __int8)sync;
}
else
{
result = func0(1);
}
}
}
}
else
{
verror("frontbuffer: vogl not initialised.");
result = func2();
}
return result;
}

original_code:
void
frontbuffer(int yes)
{
 Token *tok;
 if (!vdevice.initialised)
  verror("frontbuffer: vogl not initialised.");
 if (vdevice.inobject) {
  tok = newtokens(2);
  tok[0].i = 35;
  tok[1].i = yes;
  return;
 }
 if (vdevice.attr->a.mode == 1)
  return;
 if (yes) {
  (*vdevice.dev.Vfrontb)();
  vdevice.inbackbuffer = 0;
  vdevice.sync = sync;
 } else
  backbuffer(1);
}

canonical_original_code:
void frontbuffer(int yes)
{
 union tk *tok;
 if (!vdevice.initialised)
  verror("frontbuffer: vogl not initialised.");
 if (vdevice.inobject) {
  tok = newtokens(2);
  tok[0].i = 35;
  tok[1].i = yes;
  return;
 }
 if (vdevice.attr->a.mode == 1)
  return;
 if (yes) {
  (*vdevice.dev.Vfrontb)();
  vdevice.inbackbuffer = 0;
  vdevice.sync = sync;
 } else
  backbuffer(1);
}

variable_types: yes int

variable_types:
tok
union tk { int i; float f; } *


swapbuffers

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

if ( *((_BYTE *)&vdevice + 2) )
{
result = (_DWORD *)newtokens(1LL);
*result = 36;
}
else if ( vdevice )
{
result = (_DWORD *)(*((__int64 (**)(void))&vdevice + 39))();
}
else
{
verror("swapbuffers: vogl not initialised.");
result = (_DWORD *)doublebuffer();
}
return result;
}

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

if ( *((_BYTE *)&vdevice + 2) )
{
result = (_DWORD *)newtokens(1LL);
*result = 36;
}
else if ( vdevice )
{
result = (_DWORD *)(*((__int64 (**)(void))&vdevice + 39))();
}
else
{
verror("swapbuffers: vogl not initialised.");
result = (_DWORD *)func3();
}
return result;
}

original_code:
void
swapbuffers(void)
{
 Token *tok;
 if (vdevice.inobject) {
  tok = newtokens(1);
  tok[0].i = 36;
  return;
 }
 if (!vdevice.initialised)
  verror("swapbuffers: vogl not initialised.");
 (*vdevice.dev.Vswapb)();
}

canonical_original_code:
void swapbuffers()
{
 union tk *tok;
 if (vdevice.inobject) {
  tok = newtokens(1);
  tok[0].i = 36;
  return;
 }
 if (!vdevice.initialised)
  verror("swapbuffers: vogl not initialised.");
 (*vdevice.dev.Vswapb)();
}


doublebuffer

decompiled_code:
__int64 doublebuffer()
{
__int64 result; // rax

if ( vdevice )
{
result = (*((__int64 (**)(void))&vdevice + 22))();
if ( (int)result >= 0 )
{
sync = *((char *)&vdevice + 6);
result = 256LL;
*((_WORD *)&vdevice + 3) = 256;
}
}
else
{
verror("doublebuffer: vogl not initialised.");
result = singlebuffer();
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax

if ( vdevice )
{
result = (*((__int64 (**)(void))&vdevice + 22))();
if ( (int)result >= 0 )
{
sync = *((char *)&vdevice + 6);
result = 256LL;
*((_WORD *)&vdevice + 3) = 256;
}
}
else
{
verror("doublebuffer: vogl not initialised.");
result = func4();
}
return result;
}

original_code:
void
doublebuffer(void)
{
 if (!vdevice.initialised)
  verror("doublebuffer: vogl not initialised.");
 if ((*vdevice.dev.Vbackb)() >= 0) {
  vdevice.inbackbuffer = 1;
  sync = vdevice.sync;
  vdevice.sync = 0;
 }
}

canonical_original_code:
void doublebuffer()
{
 if (!vdevice.initialised)
  verror("doublebuffer: vogl not initialised.");
 if ((*vdevice.dev.Vbackb)() >= 0) {
  vdevice.inbackbuffer = 1;
  sync = vdevice.sync;
  vdevice.sync = 0;
 }
}


singlebuffer

decompiled_code:
__int64 singlebuffer()
{
__int64 result; // rax

result = *((_QWORD *)&vdevice + 4);
if ( *(_BYTE *)(result + 1) != 1 )
{
(*((void (**)(void))&vdevice + 31))();
result = (unsigned int)sync;
*((_BYTE *)&vdevice + 7) = 0;
if ( (_DWORD)result )
*((_BYTE *)&vdevice + 6) = 1;
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax

result = *((_QWORD *)&vdevice + 4);
if ( *(_BYTE *)(result + 1) != 1 )
{
(*((void (**)(void))&vdevice + 31))();
result = (unsigned int)sync;
*((_BYTE *)&vdevice + 7) = 0;
if ( (_DWORD)result )
*((_BYTE *)&vdevice + 6) = 1;
}
return result;
}

original_code:
void
singlebuffer(void)
{
 if (vdevice.attr->a.mode == 1)
  return;
 (*vdevice.dev.Vfrontb)();
 vdevice.inbackbuffer = 0;
 if (sync)
  vdevice.sync = 1;
}

canonical_original_code:
void singlebuffer()
{
 if (vdevice.attr->a.mode == 1)
  return;
 (*vdevice.dev.Vfrontb)();
 vdevice.inbackbuffer = 0;
 if (sync)
  vdevice.sync = 1;
}


pushattributes

decompiled_code:
void pushattributes()
{
__int64 v0; // rdi
__int64 v1; // rax
__int64 v2; // rdx
int v3; // ecx
__int16 v4; // r9
__int16 v5; // r8
char v6; // si
__int64 v7; // rdi
__int64 v8; // rax
int v9; // ecx
int v10; // edx

if ( vdevice )
{
if ( *((_BYTE *)&vdevice + 2) )
{
*(_DWORD *)newtokens(1LL) = 25;
}
else
{
v0 = asfree;
if ( asfree )
{
v1 = *((_QWORD *)&vdevice + 4);
v2 = *(_QWORD *)(asfree + 16);
*((_QWORD *)&vdevice + 4) = asfree;
v3 = *(_DWORD *)(v1 + 8);
v4 = *(_WORD *)(v1 + 14);
*(_QWORD *)(v0 + 16) = v1;
v5 = *(_WORD *)(v1 + 12);
v6 = *(_BYTE *)v1;
asfree = v2;
copyattributes_isra_0(v0, v6, *(_DWORD *)(v1 + 4), v3, v5, v4);
}
else
{
v7 = vallocate(24LL);
v8 = *((_QWORD *)&vdevice + 4);
v9 = *(_DWORD *)(v8 + 8);
v10 = *(_DWORD *)(v8 + 4);
*(_QWORD *)(v7 + 16) = v8;
copyattributes_isra_0(v7, *(_BYTE *)v8, v10, v9, *(_WORD *)(v8 + 12), *(_WORD *)(v8 + 14));
*((_QWORD *)&vdevice + 4) = v7;
}
}
}
else
{
verror("pushattributes: vogl not initialised");
popattributes();
}
}

original_code:
void
pushattributes(void)
{
 Astack *nattr;
 Token *p;
 if (!vdevice.initialised)
  verror("pushattributes:  vogl not initialised");
 if (vdevice.inobject) {
  p = newtokens(1);
  p[0].i = 25;
  return;
 }
 if (asfree != (Astack *)((void *)0)) {
  nattr = vdevice.attr;
  vdevice.attr = asfree;
  asfree = asfree->back;
  vdevice.attr->back = nattr;
  copyattributes(&vdevice.attr->a, &nattr->a);
 } else {
  nattr = (Astack *)vallocate(sizeof(Astack));
  nattr->back = vdevice.attr;
  copyattributes(&nattr->a, &vdevice.attr->a);
  vdevice.attr = nattr;
 }
}

canonical_original_code:
void pushattributes()
{
 struct as *nattr;
 union tk *p;
 if (!vdevice.initialised)
  verror("pushattributes:  vogl not initialised");
 if (vdevice.inobject) {
  p = newtokens(1);
  p[0].i = 25;
  return;
 }
 if (asfree != (struct as *)((void *)0)) {
  nattr = vdevice.attr;
  vdevice.attr = asfree;
  asfree = asfree->back;
  vdevice.attr->back = nattr;
  copyattributes(&vdevice.attr->a, &nattr->a);
 } else {
  nattr = (struct as *)vallocate(sizeof(Astack));
  nattr->back = vdevice.attr;
  copyattributes(&nattr->a, &vdevice.attr->a);
  vdevice.attr = nattr;
 }
}

variable_types: struct as { struct Attribute { char backface; int color; int fontnum; unsigned short ls; short lw; } a; struct as *back; } *

variable_types:
p
union tk { int i; float f; } *

user_defined_types: struct as { struct Attribute a; struct as *back; }


popattributes

decompiled_code:
_DWORD *popattributes()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rcx
__int64 v3; // rdx
__int64 v4; // rdi
_DWORD *result; // rax

if ( !vdevice )
{
verror("popattributes: vogl not initialised");
goto LABEL_7;
}
if ( !*((_BYTE *)&vdevice + 2) )
{
v0 = *(_QWORD *)(*((_QWORD *)&vdevice + 4) + 16LL);
if ( v0 )
{
font((unsigned int)*(__int16 *)(v0 + 8));
v1 = *((_QWORD *)&vdevice + 4);
v2 = asfree;
v3 = *(_QWORD *)(v1 + 16);
asfree = v1;
*((_QWORD *)&vdevice + 4) = v3;
v4 = *(unsigned __int16 *)(v3 + 12);
*(_QWORD *)(v1 + 16) = v2;
(*((void (__fastcall **)(__int64))&vdevice + 36))(v4);
(*((void (__fastcall **)(_QWORD))&vdevice + 37))((unsigned int)*(__int16 *)(*((_QWORD *)&vdevice + 4) + 14LL));
return (_DWORD *)color(*(unsigned int *)(*((_QWORD *)&vdevice + 4) + 4LL));
}
LABEL_7:
verror("popattributes: attribute stack is empty");
JUMPOUT(0x16ALL);
}
result = (_DWORD *)newtokens(1LL);
*result = 22;
return result;
}

canonical_decompiled_code:
_DWORD *func2()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rcx
__int64 v3; // rdx
__int64 v4; // rdi
_DWORD *result; // rax

if ( !vdevice )
{
verror("popattributes: vogl not initialised");
goto LABEL_7;
}
if ( !*((_BYTE *)&vdevice + 2) )
{
v0 = *(_QWORD *)(*((_QWORD *)&vdevice + 4) + 16LL);
if ( v0 )
{
font((unsigned int)*(__int16 *)(v0 + 8));
v1 = *((_QWORD *)&vdevice + 4);
v2 = asfree;
v3 = *(_QWORD *)(v1 + 16);
asfree = v1;
*((_QWORD *)&vdevice + 4) = v3;
v4 = *(unsigned __int16 *)(v3 + 12);
*(_QWORD *)(v1 + 16) = v2;
(*((void (__fastcall **)(__int64))&vdevice + 36))(v4);
(*((void (__fastcall **)(_QWORD))&vdevice + 37))((unsigned int)*(__int16 *)(*((_QWORD *)&vdevice + 4) + 14LL));
return (_DWORD *)color(*(unsigned int *)(*((_QWORD *)&vdevice + 4) + 4LL));
}
LABEL_7:
verror("popattributes: attribute stack is empty");
JUMPOUT(0x16ALL);
}
result = (_DWORD *)newtokens(1LL);
*result = 22;
return result;
}

original_code:
void
popattributes(void)
{
 Astack *nattr;
 Token *p;
 if (!vdevice.initialised)
  verror("popattributes: vogl not initialised");
 if (vdevice.inobject) {
  p = newtokens(1);
  p[0].i = 22;
  return;
 }
 if (vdevice.attr->back == (Astack *)((void *)0))
  verror("popattributes: attribute stack is empty");
 else {
  font(vdevice.attr->back->a.fontnum);
  nattr = vdevice.attr;
  vdevice.attr = vdevice.attr->back;
  nattr->back = asfree;
  asfree = nattr;
 }
 (*vdevice.dev.Vsetls)(vdevice.attr->a.ls);
 (*vdevice.dev.Vsetlw)(vdevice.attr->a.lw);
 color(vdevice.attr->a.color);
}

canonical_original_code:
void popattributes()
{
 struct as *nattr;
 union tk *p;
 if (!vdevice.initialised)
  verror("popattributes: vogl not initialised");
 if (vdevice.inobject) {
  p = newtokens(1);
  p[0].i = 22;
  return;
 }
 if (vdevice.attr->back == (struct as *)((void *)0))
  verror("popattributes: attribute stack is empty");
 else {
  font(vdevice.attr->back->a.fontnum);
  nattr = vdevice.attr;
  vdevice.attr = vdevice.attr->back;
  nattr->back = asfree;
  asfree = nattr;
 }
 (*vdevice.dev.Vsetls)(vdevice.attr->a.ls);
 (*vdevice.dev.Vsetlw)(vdevice.attr->a.lw);
 color(vdevice.attr->a.color);
}

user_defined_types: struct Attribute { char backface; int color; int fontnum; unsigned short ls; short lw; }


decompiled_code:
__int64 CalcW2Vcoeffs()
{
int v0; // edx
int v1; // esi
int v2; // eax
int v3; // ecx
int v4; // edi
__int64 result; // rax

v0 = vdevice[27];
v1 = vdevice[28];
v2 = vdevice[29];
v3 = vdevice[30];
v4 = v2 + v3;
result = (unsigned int)(v2 - v3);
*(float *)&Vcx = (float)(v0 + v1) * 0.5;
*(float *)&Vcy = (float)v4 * 0.5;
*(float *)&Vsx = (float)(v0 - v1) * 0.5;
*(float *)&Vsy = 0.5 * (float)(int)result;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // edx
int v1; // esi
int v2; // eax
int v3; // ecx
int v4; // edi
__int64 result; // rax

v0 = vdevice[27];
v1 = vdevice[28];
v2 = vdevice[29];
v3 = vdevice[30];
v4 = v2 + v3;
result = (unsigned int)(v2 - v3);
*(float *)&Vcx = (float)(v0 + v1) * 0.5;
*(float *)&Vcy = (float)v4 * 0.5;
*(float *)&Vsx = (float)(v0 - v1) * 0.5;
*(float *)&Vsy = 0.5 * (float)(int)result;
return result;
}

original_code:
void
CalcW2Vcoeffs(void)
{
 Vcx = (float)(vdevice.maxVx + vdevice.minVx) * 0.5;
 Vcy = (float)(vdevice.maxVy + vdevice.minVy) * 0.5;
 Vsx = (float)(vdevice.maxVx - vdevice.minVx) * 0.5;
 Vsy = (float)(vdevice.maxVy - vdevice.minVy) * 0.5;
}

canonical_original_code:
void CalcW2Vcoeffs()
{
 Vcx = (float)(vdevice.maxVx + vdevice.minVx) * 0.5;
 Vcy = (float)(vdevice.maxVy + vdevice.minVy) * 0.5;
 Vsx = (float)(vdevice.maxVx - vdevice.minVx) * 0.5;
 Vsy = (float)(vdevice.maxVy - vdevice.minVy) * 0.5;
}


WtoVx

decompiled_code:
__int64 __fastcall WtoVx(float *a1)
{
return (unsigned int)(int)((float)((float)((float)(*a1 * *(float *)&Vsx) / a1[3]) + *(float *)&Vcx) + 0.5);
}

canonical_decompiled_code:
__int64 __fastcall func1(float *a1)
{
return (unsigned int)(int)((float)((float)((float)(*a1 * *(float *)&Vsx) / a1[3]) + *(float *)&Vcx) + 0.5);
}

original_code:
int
WtoVx(float *p)
{
 return((int)(p[0] * Vsx / p[3] + Vcx + 0.5));
}

variable_types:
p
float *


WtoVy

decompiled_code:
__int64 __fastcall WtoVy(__int64 a1)
{
return (unsigned int)(int)((float)((float)((float)(*(float *)(a1 + 4) * *(float *)&Vsy) / *(float *)(a1 + 12))
+ *(float *)&Vcy)
+ 0.5);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return (unsigned int)(int)((float)((float)((float)(*(float *)(a1 + 4) * *(float *)&Vsy) / *(float *)(a1 + 12))
+ *(float *)&Vcy)
+ 0.5);
}

original_code:
int
WtoVy(float *p)
{
 return((int)(p[1] * Vsy / p[3] + Vcy + 0.5));
}


decompiled_code:
__int64 pushat_()
{
return pushattributes__localalias();
}

canonical_decompiled_code:
__int64 func1()
{
return func0();
}

original_code:
void
pushat_()
{
 pushattributes();
}

canonical_original_code:
void pushat_()
{
 pushattributes();
}


decompiled_code:
__int64 popatt_()
{
return popattributes__localalias();
}

canonical_decompiled_code:
__int64 func3()
{
return func2();
}

original_code:
void
popatt_()
{
 popattributes();
}

canonical_original_code:
void popatt_()
{
 popattributes();
}


hnumchars

decompiled_code:
__int64 hnumchars()
{
check_loaded("hnumchars");
return (unsigned int)nchars;
}

canonical_decompiled_code:
__int64 func3()
{
check_loaded("hnumchars");
return (unsigned int)nchars;
}

original_code:
int
hnumchars()
{
 check_loaded("hnumchars");
 return((int)nchars);
}


hgetfontwidth

decompiled_code:
float hgetfontwidth()
{
float result; // xmm0_4

check_loaded("hgetfontwidth");
if ( dword_DA8 >= ftab - dword_DA4 )
result = (float)dword_DA8 * *(float *)&SCSIZEX;
else
result = (float)(ftab - dword_DA4) * *(float *)&SCSIZEX;
return result;
}

canonical_decompiled_code:
float func8()
{
float result; // xmm0_4

check_loaded("hgetfontwidth");
if ( dword_DA8 >= ftab - dword_DA4 )
result = (float)dword_DA8 * *(float *)&SCSIZEX;
else
result = (float)(ftab - dword_DA4) * *(float *)&SCSIZEX;
return result;
}

original_code:
float
hgetfontwidth()
{
 check_loaded("hgetfontwidth");
 return((float)(SCSIZEX * (((int)ftab.mw) < ((int)(ftab.as - ftab.dec)) ? ((int)(ftab.as - ftab.dec)) : ((int)ftab.mw))));
}


hgetfontheight

decompiled_code:
float hgetfontheight()
{
float result; // xmm0_4

check_loaded("hgetfontheight");
if ( dword_DA8 >= ftab - dword_DA4 )
result = (float)dword_DA8 * *(float *)&SCSIZEY;
else
result = (float)(ftab - dword_DA4) * *(float *)&SCSIZEY;
return result;
}

canonical_decompiled_code:
float func9()
{
float result; // xmm0_4

check_loaded("hgetfontheight");
if ( dword_DA8 >= ftab - dword_DA4 )
result = (float)dword_DA8 * *(float *)&SCSIZEY;
else
result = (float)(ftab - dword_DA4) * *(float *)&SCSIZEY;
return result;
}

original_code:
float
hgetfontheight()
{
 check_loaded("hgetfontheight");
 return((float)(SCSIZEY * (((int)ftab.mw) < ((int)(ftab.as - ftab.dec)) ? ((int)(ftab.as - ftab.dec)) : ((int)ftab.mw))));
}


hgetdecender

decompiled_code:
float hgetdecender()
{
check_loaded("hgetdecender");
return (float)dword_DA4 * *(float *)&SCSIZEY;
}

canonical_decompiled_code:
float func11()
{
check_loaded("hgetdecender");
return (float)dword_DA4 * *(float *)&SCSIZEY;
}

original_code:
float
hgetdecender()
{
 check_loaded("hgetdecender");
 return((float)ftab.dec * SCSIZEY);
}


hgetascender

decompiled_code:
float hgetascender()
{
check_loaded("hgetascender");
return (float)ftab * *(float *)&SCSIZEY;
}

canonical_decompiled_code:
float func12()
{
check_loaded("hgetascender");
return (float)ftab * *(float *)&SCSIZEY;
}

original_code:
float
hgetascender()
{
 check_loaded("hgetascender");
 return((float)ftab.as * SCSIZEY);
}


pushmatrix

decompiled_code:
_DWORD *pushmatrix()
{
__int64 v0; // rdi
__int64 v1; // rsi
__int64 v2; // rax
_DWORD *result; // rax
__int64 v4; // rax
__int64 v5; // rsi
__int64 v6; // rbp

if ( BYTE2(vdevice[0]) )
{
result = (_DWORD *)newtokens(1LL);
*result = 26;
}
else
{
v0 = msfree;
if ( msfree )
{
v1 = vdevice[3];
v2 = *(_QWORD *)(msfree + 64);
vdevice[3] = msfree;
*(_QWORD *)(v0 + 64) = v1;
msfree = v2;
result = (_DWORD *)copymatrix(v0, v1);
}
else
{
v4 = vallocate(72LL);
v5 = vdevice[3];
v6 = v4;
*(_QWORD *)(v4 + 64) = v5;
result = (_DWORD *)copymatrix(v4, v5);
vdevice[3] = v6;
}
}
return result;
}

canonical_decompiled_code:
_DWORD *func4()
{
__int64 v0; // rdi
__int64 v1; // rsi
__int64 v2; // rax
_DWORD *result; // rax
__int64 v4; // rax
__int64 v5; // rsi
__int64 v6; // rbp

if ( BYTE2(vdevice[0]) )
{
result = (_DWORD *)newtokens(1LL);
*result = 26;
}
else
{
v0 = msfree;
if ( msfree )
{
v1 = vdevice[3];
v2 = *(_QWORD *)(msfree + 64);
vdevice[3] = msfree;
*(_QWORD *)(v0 + 64) = v1;
msfree = v2;
result = (_DWORD *)func1(v0, v1);
}
else
{
v4 = vallocate(72LL);
v5 = vdevice[3];
v6 = v4;
*(_QWORD *)(v4 + 64) = v5;
result = (_DWORD *)func1(v4, v5);
vdevice[3] = v6;
}
}
return result;
}

original_code:
void
pushmatrix(void)
{
 Mstack *tmpmat;
 Token *p;
 if (vdevice.inobject) {
  p = newtokens(1);
  p->i = 26;
  return;
 }
 if (msfree != (Mstack *)((void *)0)) {
  tmpmat = vdevice.transmat;
  vdevice.transmat = msfree;
  msfree = msfree->back;
  vdevice.transmat->back = tmpmat;
  copymatrix(vdevice.transmat->m, tmpmat->m);
 } else {
  tmpmat = (Mstack *)vallocate(sizeof(Mstack));
  tmpmat->back = vdevice.transmat;
  copymatrix(tmpmat->m, vdevice.transmat->m);
  vdevice.transmat = tmpmat;
 }
}

canonical_original_code:
void pushmatrix()
{
 struct ms *tmpmat;
 union tk *p;
 if (vdevice.inobject) {
  p = newtokens(1);
  p->i = 26;
  return;
 }
 if (msfree != (struct ms *)((void *)0)) {
  tmpmat = vdevice.transmat;
  vdevice.transmat = msfree;
  msfree = msfree->back;
  vdevice.transmat->back = tmpmat;
  copymatrix(vdevice.transmat->m, tmpmat->m);
 } else {
  tmpmat = (struct ms *)vallocate(sizeof(Mstack));
  tmpmat->back = vdevice.transmat;
  copymatrix(tmpmat->m, vdevice.transmat->m);
  vdevice.transmat = tmpmat;
 }
}

variable_types: struct ms { float m[4][4]; struct ms *back; } *


popmatrix

decompiled_code:
_DWORD *popmatrix()
{
_DWORD *result; // rax
__int64 v1; // rdx
__int64 v2; // rcx
__int64 v3; // rcx

result = vdevice;
if ( BYTE2(vdevice[0]) )
{
result = (_DWORD *)newtokens(1LL);
*result = 23;
}
else
{
v1 = vdevice[3];
v2 = *(_QWORD *)(v1 + 64);
if ( v2 )
{
vdevice[3] = v2;
v3 = msfree;
BYTE5(vdevice[0]) = 0;
*(_QWORD *)(v1 + 64) = v3;
msfree = v1;
}
else
{
verror("popmatrix: matrix stack empty");
result = (_DWORD *)loadmatrix();
}
}
return result;
}

canonical_decompiled_code:
_DWORD *func5()
{
_DWORD *result; // rax
__int64 v1; // rdx
__int64 v2; // rcx
__int64 v3; // rcx

result = vdevice;
if ( BYTE2(vdevice[0]) )
{
result = (_DWORD *)newtokens(1LL);
*result = 23;
}
else
{
v1 = vdevice[3];
v2 = *(_QWORD *)(v1 + 64);
if ( v2 )
{
vdevice[3] = v2;
v3 = msfree;
BYTE5(vdevice[0]) = 0;
*(_QWORD *)(v1 + 64) = v3;
msfree = v1;
}
else
{
verror("popmatrix: matrix stack empty");
result = (_DWORD *)func6();
}
}
return result;
}

original_code:
void
popmatrix(void)
{
 Token *p;
 Mstack *oldtop;
 if (vdevice.inobject) {
  p = newtokens(1);
  p->i = 23;
  return;
 }
 if (vdevice.transmat->back == (Mstack *)((void *)0))
  verror("popmatrix: matrix stack empty");
 else {
  oldtop = vdevice.transmat;
  vdevice.transmat = vdevice.transmat->back;
  oldtop->back = msfree;
  msfree = oldtop;
 }
 vdevice.cpVvalid = 0;
}

canonical_original_code:
void popmatrix()
{
 union tk *p;
 struct ms *oldtop;
 if (vdevice.inobject) {
  p = newtokens(1);
  p->i = 23;
  return;
 }
 if (vdevice.transmat->back == (struct ms *)((void *)0))
  verror("popmatrix: matrix stack empty");
 else {
  oldtop = vdevice.transmat;
  vdevice.transmat = vdevice.transmat->back;
  oldtop->back = msfree;
  msfree = oldtop;
 }
 vdevice.cpVvalid = 0;
}

user_defined_types: struct ms { float m[4][4]; struct ms *back; }


variable_types:
a
float (*)[4]

variable_types:
b
float (*)[4]

variable_types:
c
float (*)[4]


decompiled_code:
// attributes: thunk
__int64 pclos_()
{
return pclos();
}

canonical_decompiled_code:
__int64 func38()
{
return pclos();
}

original_code:
void
pclos_()
{
 pclos();
}

canonical_original_code:
void pclos_()
{
 pclos();
}


deflinestyle

decompiled_code:
__int64 __fastcall deflinestyle(__int16 a1, unsigned __int16 a2)
{
__int64 v2; // r12
__int64 result; // rax
__int64 v4; // rdx

v2 = a1 % 11;
result = ls_table[v2];
if ( result )
{
while ( *(_WORD *)result != a1 )
{
result = *(_QWORD *)(result + 8);
if ( !result )
goto LABEL_7;
}
if ( a1 )
{
*(_DWORD *)(result + 4) = a2;
}
else
{
verror("vogl: deflinestyle can't redefine 0");
result = setlinestyle();
}
}
else
{
LABEL_7:
result = vallocate(16LL);
v4 = ls_table[v2];
*(_WORD *)result = a1;
*(_DWORD *)(result + 4) = a2;
*(_QWORD *)(result + 8) = v4;
ls_table[v2] = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 a1, unsigned __int16 a2)
{
__int64 v2; // r12
__int64 result; // rax
__int64 v4; // rdx

v2 = a1 % 11;
result = ls_table[v2];
if ( result )
{
while ( *(_WORD *)result != a1 )
{
result = *(_QWORD *)(result + 8);
if ( !result )
goto LABEL_7;
}
if ( a1 )
{
*(_DWORD *)(result + 4) = a2;
}
else
{
verror("vogl: deflinestyle can't redefine 0");
result = setlinestyle();
}
}
else
{
LABEL_7:
result = vallocate(16LL);
v4 = ls_table[v2];
*(_WORD *)result = a1;
*(_DWORD *)(result + 4) = a2;
*(_QWORD *)(result + 8) = v4;
ls_table[v2] = result;
}
return result;
}

original_code:
void
deflinestyle(short int n, Linestyle ls)
{
 LT *l;
 for (l = ls_table[n % 11]; l != (LT *)((void *)0); l = l->next)
  if (l->n == n) {
   if (n == 0)
    verror("vogl: deflinestyle can't redefine 0");
   l->ls = ls;
   return;
  }
 l = (LT *)vallocate(sizeof(LT));
 l->n = n;
 l->ls = ls;
 l->next = ls_table[n % 11];
 ls_table[n % 11] = l;
}

canonical_original_code:
void deflinestyle(short n, unsigned short ls)
{
 struct l *l;
 for (l = ls_table[n % 11]; l != (struct l *)((void *)0); l = l->next)
  if (l->n == n) {
   if (n == 0)
    verror("vogl: deflinestyle can't redefine 0");
   l->ls = ls;
   return;
  }
 l = (struct l *)vallocate(sizeof(LT));
 l->n = n;
 l->ls = ls;
 l->next = ls_table[n % 11];
 ls_table[n % 11] = l;
}

variable_types: n short

variable_types:
ls
unsigned short

variable_types: struct l { short n; unsigned int ls; struct l *next; } *


decompiled_code:
__int64 gethei_()
{
return getheight__localalias();
}

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

original_code:
int
gethei_()
{
 return((int)getheight());
}


decompiled_code:
__int64 pushma_()
{
return pushmatrix__localalias();
}

original_code:
void
pushma_()
{
 pushmatrix();
}

canonical_original_code:
void pushma_()
{
 pushmatrix();
}


decompiled_code:
__int64 popmat_()
{
return popmatrix__localalias();
}

original_code:
void
popmat_()
{
 popmatrix();
}

canonical_original_code:
void popmat_()
{
 popmatrix();
}


decompiled_code:
__int64 qtest_()
{
return qtest();
}

canonical_decompiled_code:
__int64 func5()
{
return qtest();
}

original_code:
int
qtest_()
{
 int ret = qtest();
 return(ret);
}

variable_types: ret int


decompiled_code:
// attributes: thunk
__int64 qreset_()
{
return qreset();
}

canonical_decompiled_code:
__int64 func6()
{
return qreset();
}

original_code:
void
qreset_()
{
 qreset();
}

canonical_original_code:
void qreset_()
{
 qreset();
}


vallocate

decompiled_code:
void *__fastcall vallocate(size_t size)
{
void *result; // rax
char v2[88]; // [rsp+0h] [rbp-58h] BYREF

result = malloc((unsigned int)size);
if ( !result )
{
sprintf(v2, "vallocate: request for %d bytes returned NULL", (unsigned int)size);
verror(v2);
JUMPOUT(0x3BLL);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(size_t size)
{
void *result; // rax
char v2[88]; // [rsp+0h] [rbp-58h] BYREF

result = malloc((unsigned int)size);
if ( !result )
{
sprintf(v2, "vallocate: request for %d bytes returned NULL", (unsigned int)size);
verror(v2);
JUMPOUT(0x3BLL);
}
return result;
}

original_code:
char *
vallocate(unsigned int size)
{
 char *p, buf[60];
 if ((p = (char *)malloc(size)) == (char *)0) {
  sprintf(buf,"vallocate: request for %d bytes returned NULL", size);
  verror(buf);
 }
 return (p);
}

canonical_original_code:
char *vallocate(unsigned int size)
{
 char *p; char buf[60];
 if ((p = (char *)malloc(size)) == (char *)0) {
  sprintf(buf,"vallocate: request for %d bytes returned NULL", size);
  verror(buf);
 }
 return (p);
}

variable_types:
size
unsigned int

variable_types:
p
char *

variable_types:
buf
char [60]

return_type: char *


decompiled_code:
__int64 closeo_()
{
return closeobj__localalias();
}

original_code:
void
closeo_()
{
 closeobj();
}

canonical_original_code:
void closeo_()
{
 closeobj();
}


decompiled_code:
__int64 genobj_()
{
return genobj();
}

canonical_decompiled_code:
__int64 func5()
{
return genobj();
}

original_code:
int
genobj_()
{
 return(genobj());
}

canonical_original_code:
int genobj_()
{
 return(genobj());
}


decompiled_code:
__int64 getope_()
{
return getopenobj__localalias();
}

canonical_decompiled_code:
__int64 func7()
{
return func6();
}

original_code:
int
getope_()
{
 return(getopenobj());
}

canonical_original_code:
int getope_()
{
 return(getopenobj());
}


repo: bert/fped

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

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

original_code:
void bitset_free(struct bitset *set)
{
 free(set->v);
 free(set);
}

variable_types: struct bitset { int v_n; unsigned int *v; } *


decompiled_code:
unsigned __int64 __fastcall bitset_set(int *a1, int a2)
{
unsigned __int64 result; // rax

if ( a2 >= (unsigned __int64)(32LL * *a1) )
_assert_fail("n < set->v_n*BITS", "bitset.c", 0x41u, "bitset_set");
result = (unsigned __int64)a2 >> 5;
*(_DWORD *)(*((_QWORD *)a1 + 1) + 4 * result) |= 1 << a2;
return result;
}

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

if ( a2 >= (unsigned __int64)(32LL * *a1) )
_assert_fail("n < set->v_n*BITS", "bitset.c", 0x41u, "bitset_set");
result = (unsigned __int64)a2 >> 5;
*(_DWORD *)(*((_QWORD *)a1 + 1) + 4 * result) |= 1 << a2;
return result;
}

original_code:
void bitset_set(struct bitset *set, int n)
{
 ((void) sizeof ((n < set->v_n*(sizeof(unsigned)*8)) ? 1 : 0), __extension__ ({ if (n < set->v_n*(sizeof(unsigned)*8)) ; else __assert_fail ("n < set->v_n*BITS", "bitset.c", 65, __extension__ __PRETTY_FUNCTION__); }));
 set->v[n/(sizeof(unsigned)*8)] |= 1U << (n % (sizeof(unsigned)*8));
}

canonical_original_code:
void bitset_set(struct bitset *set, int n)
{
 ((void) sizeof ((n < set->v_n*(sizeof(unsigned int)*8)) ? 1 : 0), __extension__ ({ if (n < set->v_n*(sizeof(unsigned int)*8)) ; else __assert_fail ("n < set->v_n*BITS", "bitset.c", 65, __extension__ __PRETTY_FUNCTION__); }));
 set->v[n/(sizeof(unsigned int)*8)] |= 1U << (n % (sizeof(unsigned int)*8));
}

variable_types: n int

user_defined_types: struct bitset { int v_n; unsigned int *v; }


decompiled_code:
unsigned __int64 __fastcall bitset_clear(int *a1, int a2)
{
unsigned __int64 result; // rax

if ( a2 >= (unsigned __int64)(32LL * *a1) )
_assert_fail("n < set->v_n*BITS", "bitset.c", 0x48u, "bitset_clear");
result = (unsigned __int64)a2 >> 5;
*(_DWORD *)(*((_QWORD *)a1 + 1) + 4 * result) &= ~(1 << a2);
return result;
}

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

if ( a2 >= (unsigned __int64)(32LL * *a1) )
_assert_fail("n < set->v_n*BITS", "bitset.c", 0x48u, "bitset_clear");
result = (unsigned __int64)a2 >> 5;
*(_DWORD *)(*((_QWORD *)a1 + 1) + 4 * result) &= ~(1 << a2);
return result;
}

original_code:
void bitset_clear(struct bitset *set, int n)
{
 ((void) sizeof ((n < set->v_n*(sizeof(unsigned)*8)) ? 1 : 0), __extension__ ({ if (n < set->v_n*(sizeof(unsigned)*8)) ; else __assert_fail ("n < set->v_n*BITS", "bitset.c", 72, __extension__ __PRETTY_FUNCTION__); }));
 set->v[n/(sizeof(unsigned)*8)] &= ~(1U << (n % (sizeof(unsigned)*8)));
}

canonical_original_code:
void bitset_clear(struct bitset *set, int n)
{
 ((void) sizeof ((n < set->v_n*(sizeof(unsigned int)*8)) ? 1 : 0), __extension__ ({ if (n < set->v_n*(sizeof(unsigned int)*8)) ; else __assert_fail ("n < set->v_n*BITS", "bitset.c", 72, __extension__ __PRETTY_FUNCTION__); }));
 set->v[n/(sizeof(unsigned int)*8)] &= ~(1U << (n % (sizeof(unsigned int)*8)));
}


decompiled_code:
__int64 __fastcall bitset_pick(int *a1, int a2)
{
if ( a2 >= (unsigned __int64)(32LL * *a1) )
_assert_fail("n < set->v_n*BITS", "bitset.c", 0x4Fu, "bitset_pick");
return (*(_DWORD *)(*((_QWORD *)a1 + 1) + 4 * ((unsigned __int64)a2 >> 5)) >> a2) & 1;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, int a2)
{
if ( a2 >= (unsigned __int64)(32LL * *a1) )
_assert_fail("n < set->v_n*BITS", "bitset.c", 0x4Fu, "bitset_pick");
return (*(_DWORD *)(*((_QWORD *)a1 + 1) + 4 * ((unsigned __int64)a2 >> 5)) >> a2) & 1;
}

original_code:
int bitset_pick(const struct bitset *set, int n)
{
 ((void) sizeof ((n < set->v_n*(sizeof(unsigned)*8)) ? 1 : 0), __extension__ ({ if (n < set->v_n*(sizeof(unsigned)*8)) ; else __assert_fail ("n < set->v_n*BITS", "bitset.c", 79, __extension__ __PRETTY_FUNCTION__); }));
 return !!(set->v[n/(sizeof(unsigned)*8)] & (1U << (n % (sizeof(unsigned)*8))));
}

canonical_original_code:
int bitset_pick(struct bitset *set, int n)
{
 ((void) sizeof ((n < set->v_n*(sizeof(unsigned int)*8)) ? 1 : 0), __extension__ ({ if (n < set->v_n*(sizeof(unsigned int)*8)) ; else __assert_fail ("n < set->v_n*BITS", "bitset.c", 79, __extension__ __PRETTY_FUNCTION__); }));
 return !!(set->v[n/(sizeof(unsigned int)*8)] & (1U << (n % (sizeof(unsigned int)*8))));
}


decompiled_code:
__int64 __fastcall bitset_is_empty(__int64 a1)
{
_DWORD *v1; // rax
__int64 v2; // rdx

if ( !*(_DWORD *)a1 )
return 1LL;
v1 = *(_DWORD **)(a1 + 8);
v2 = (__int64)&v1[*(_DWORD *)a1 - 1 + 1];
while ( !*v1 )
{
if ( ++v1 == (_DWORD *)v2 )
return 1LL;
}
return 0LL;
}

original_code:
int bitset_is_empty(const struct bitset *set)
{
 int i;
 for (i = 0; i != set->v_n; i++)
  if (set->v[i])
   return 0;
 return 1;
}

canonical_original_code:
int bitset_is_empty(struct bitset *set)
{
 int i;
 for (i = 0; i != set->v_n; i++)
  if (set->v[i])
   return 0;
 return 1;
}

variable_types: i int


decompiled_code:
__int64 __fastcall bitset_zero(unsigned int *a1)
{
__int64 result; // rax
__int64 v2; // rdx

result = *a1;
if ( (_DWORD)result )
{
v2 = *((_QWORD *)a1 + 1);
result = 0LL;
do
*(_DWORD *)(v2 + 4 * result++) = 0;
while ( *a1 != (_DWORD)result );
}
return result;
}

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

result = *a1;
if ( (_DWORD)result )
{
v2 = *((_QWORD *)a1 + 1);
result = 0LL;
do
*(_DWORD *)(v2 + 4 * result++) = 0;
while ( *a1 != (_DWORD)result );
}
return result;
}

original_code:
void bitset_zero(struct bitset *a)
{
 int i;
 for (i = 0; i != a->v_n; i++)
  a->v[i] = 0;
}


decompiled_code:
__int64 __fastcall bitset_and(unsigned int *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx
__int64 v4; // rsi

result = *a1;
if ( (_DWORD)result != *(_DWORD *)a2 )
_assert_fail("a->v_n == b->v_n", "bitset.c", 0x6Cu, "bitset_and");
if ( (_DWORD)result )
{
v3 = *((_QWORD *)a1 + 1);
v4 = *(_QWORD *)(a2 + 8);
result = 0LL;
do
{
*(_DWORD *)(v3 + 4 * result) &= *(_DWORD *)(v4 + 4 * result);
++result;
}
while ( *a1 != (_DWORD)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx
__int64 v4; // rsi

result = *a1;
if ( (_DWORD)result != *(_DWORD *)a2 )
_assert_fail("a->v_n == b->v_n", "bitset.c", 0x6Cu, "bitset_and");
if ( (_DWORD)result )
{
v3 = *((_QWORD *)a1 + 1);
v4 = *(_QWORD *)(a2 + 8);
result = 0LL;
do
{
*(_DWORD *)(v3 + 4 * result) &= *(_DWORD *)(v4 + 4 * result);
++result;
}
while ( *a1 != (_DWORD)result );
}
return result;
}

original_code:
void bitset_and(struct bitset *a, const struct bitset *b)
{
 int i;
 ((void) sizeof ((a->v_n == b->v_n) ? 1 : 0), __extension__ ({ if (a->v_n == b->v_n) ; else __assert_fail ("a->v_n == b->v_n", "bitset.c", 108, __extension__ __PRETTY_FUNCTION__); }));
 for (i = 0; i != a->v_n; i++)
  a->v[i] &= b->v[i];
}

canonical_original_code:
void bitset_and(struct bitset *a, struct bitset *b)
{
 int i;
 ((void) sizeof ((a->v_n == b->v_n) ? 1 : 0), __extension__ ({ if (a->v_n == b->v_n) ; else __assert_fail ("a->v_n == b->v_n", "bitset.c", 108, __extension__ __PRETTY_FUNCTION__); }));
 for (i = 0; i != a->v_n; i++)
  a->v[i] &= b->v[i];
}

variable_types:
b
struct bitset *