decompiled_code:
void __fastcall CTab_Free(_QWORD *a1)
{
void *v1; // r8

CTab_Clear(a1);
if ( v1 )
free(v1);
}

canonical_decompiled_code:
void __fastcall func4(_QWORD *a1)
{
void *v1; // r8

func2(a1);
if ( v1 )
free(v1);
}

original_code:
void CTab_Free(CTab_t *tab)
{
    CTab_Clear(tab);
    if(tab) { free(tab); tab = ((void *)0); };
}

canonical_original_code:
void CTab_Free(struct CTab_s *tab)
{
    CTab_Clear(tab);
    if(tab) { free(tab); tab = ((void *)0); };
}


repo: jite/jquake

decompiled_code:
__int64 __fastcall CTab_Key(_DWORD *a1, int a2, unsigned __int16 a3)
{
int v3; // eax
__int64 (__fastcall *v4)(_QWORD, _QWORD, _DWORD *); // rax
__int64 result; // rax
bool v6; // zf
int v7; // eax
int v8; // eax
int v9; // edx

v3 = a1[227];
if ( a2 == 200 && v3 >= 0 )
{
a1[225] = v3;
return 1LL;
}
v4 = *(__int64 (__fastcall **)(_QWORD, _QWORD, _DWORD *))&a1[14 * a1[225] + 8];
if ( !v4 || (result = v4((unsigned int)a2, a3, a1), !(_DWORD)result) )
{
if ( a2 != 159 )
{
if ( a2 <= 159 )
{
if ( a2 != 134 )
{
if ( a2 != 135 )
{
if ( a2 == 9 )
{
S_LocalSound("misc/menu1.wav");
v6 = (unsigned int)isShiftDown() == 0;
v7 = a1[225];
if ( v6 )
v8 = v7 + 1;
else
v8 = v7 - 1;
goto LABEL_12;
}
return 0LL;
}
goto LABEL_16;
}
LABEL_18:
S_LocalSound("misc/menu1.wav");
v8 = a1[225] - 1;
goto LABEL_12;
}
if ( a2 == 203 )
goto LABEL_18;
if ( a2 != 204 )
{
if ( a2 != 160 )
return 0LL;
goto LABEL_18;
}
}
LABEL_16:
S_LocalSound("misc/menu1.wav");
v8 = a1[225] + 1;
LABEL_12:
v9 = (a1[224] + v8) % a1[224];
result = 1LL;
a1[225] = v9;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1, int a2, unsigned __int16 a3)
{
int v3; // eax
__int64 (__fastcall *v4)(_QWORD, _QWORD, _DWORD *); // rax
__int64 result; // rax
bool v6; // zf
int v7; // eax
int v8; // eax
int v9; // edx

v3 = a1[227];
if ( a2 == 200 && v3 >= 0 )
{
a1[225] = v3;
return 1LL;
}
v4 = *(__int64 (__fastcall **)(_QWORD, _QWORD, _DWORD *))&a1[14 * a1[225] + 8];
if ( !v4 || (result = v4((unsigned int)a2, a3, a1), !(_DWORD)result) )
{
if ( a2 != 159 )
{
if ( a2 <= 159 )
{
if ( a2 != 134 )
{
if ( a2 != 135 )
{
if ( a2 == 9 )
{
S_LocalSound("misc/menu1.wav");
v6 = (unsigned int)isShiftDown() == 0;
v7 = a1[225];
if ( v6 )
v8 = v7 + 1;
else
v8 = v7 - 1;
goto LABEL_12;
}
return 0LL;
}
goto LABEL_16;
}
LABEL_18:
S_LocalSound("misc/menu1.wav");
v8 = a1[225] - 1;
goto LABEL_12;
}
if ( a2 == 203 )
goto LABEL_18;
if ( a2 != 204 )
{
if ( a2 != 160 )
return 0LL;
goto LABEL_18;
}
}
LABEL_16:
S_LocalSound("misc/menu1.wav");
v8 = a1[225] + 1;
LABEL_12:
v9 = (a1[224] + v8) % a1[224];
result = 1LL;
a1[225] = v9;
}
return result;
}

original_code:
int CTab_Key(CTab_t *tab, int key, unsigned short unichar)
{
    int handled;
 if (tab->hoveredPage >= 0 && key == K_MOUSE1)
 {
  tab->activePage = tab->hoveredPage;
  return true;
 }
    handled = false;
    if (tab->pages[tab->activePage].handlers.key != ((void *)0))
        handled = tab->pages[tab->activePage].handlers.key(key, unichar, tab, &tab->pages[tab->activePage]);
    if (!handled)
    {
            switch (key)
            {
   case K_PGUP:
   case K_MOUSE4:
    S_LocalSound ("misc/menu1.wav");
                tab->activePage--;
                handled = true;
                break;
   case K_PGDN:
   case K_MOUSE5:
    S_LocalSound ("misc/menu1.wav");
                tab->activePage++;
                handled = true;
                break;
   case K_LEFTARROW:
    S_LocalSound ("misc/menu1.wav");
    tab->activePage--;
    handled = true;
    break;
   case K_RIGHTARROW:
    S_LocalSound ("misc/menu1.wav");
    tab->activePage++;
    handled = true;
    break;
   case K_TAB:
    S_LocalSound ("misc/menu1.wav");
    if (isShiftDown()) tab->activePage--; else tab->activePage++;
    handled = true;
    break;
            }
            if (handled)
                tab->activePage = (tab->activePage + tab->nPages) % tab->nPages;
    }
    return handled;
}

canonical_original_code:
int CTab_Key(struct CTab_s *tab, int key, unsigned short unichar)
{
    int handled;
 if (tab->hoveredPage >= 0 && key == K_MOUSE1)
 {
  tab->activePage = tab->hoveredPage;
  return true;
 }
    handled = false;
    if (tab->pages[tab->activePage].handlers.key != ((void *)0))
        handled = tab->pages[tab->activePage].handlers.key(key, unichar, tab, &tab->pages[tab->activePage]);
    if (!handled)
    {
            switch (key)
            {
   case K_PGUP:
   case K_MOUSE4:
    S_LocalSound ("misc/menu1.wav");
                tab->activePage--;
                handled = true;
                break;
   case K_PGDN:
   case K_MOUSE5:
    S_LocalSound ("misc/menu1.wav");
                tab->activePage++;
                handled = true;
                break;
   case K_LEFTARROW:
    S_LocalSound ("misc/menu1.wav");
    tab->activePage--;
    handled = true;
    break;
   case K_RIGHTARROW:
    S_LocalSound ("misc/menu1.wav");
    tab->activePage++;
    handled = true;
    break;
   case K_TAB:
    S_LocalSound ("misc/menu1.wav");
    if (isShiftDown()) tab->activePage--; else tab->activePage++;
    handled = true;
    break;
            }
            if (handled)
                tab->activePage = (tab->activePage + tab->nPages) % tab->nPages;
    }
    return handled;
}

variable_types: struct CTab_s { struct CTabPage_s { char name[-1]; int id; struct CTabPage_Handlers_s { void (*draw)(int x, int y, int w, int h, struct CTab_s *, struct CTabPage_s *); int (*key)(int key, unsigned short unichar, struct CTab_s *, struct CTabPage_s *); void (*onshow)(); enum qbool { false=0, true=1 } (*mousemove)(struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool { false=0, true=1 } buttons[9]; int button_down; int button_up; } *ms); } handlers; } pages[16]; int nPages; int activePage; int lastViewedPage; int hoveredPage; int width; int height; struct { int x; } navi_boxes[16]; void *tag; } *

variable_types: key int

variable_types:
unichar
unsigned short

variable_types: handled int

return_type: int

user_defined_types: struct CTab_s { struct CTabPage_s pages[16]; int nPages; int activePage; int lastViewedPage; int hoveredPage; int width; int height; struct { int x; } navi_boxes[16]; void *tag; }

user_defined_types: struct CTabPage_s { char name[-1]; int id; struct CTabPage_Handlers_s handlers; }

user_defined_types: struct CTabPage_Handlers_s { void (*draw)(int x, int y, int w, int h, struct CTab_s *, struct CTabPage_s *); int (*key)(int key, unsigned short unichar, struct CTab_s *, struct CTabPage_s *); void (*onshow)(); enum qbool (*mousemove)(struct mouse_state_s *ms); }

user_defined_types: struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool buttons[9]; int button_down; int button_up; }


decompiled_code:
__int64 __fastcall CTab_Navi_Mouse_Event(_DWORD *a1, __int64 a2)
{
__int64 result; // rax
int v3; // edx
int v4; // ecx
double v5; // xmm1_8
int *v6; // rax
int v7; // edx
double v8; // xmm0_8

result = 0LL;
if ( a1[228] )
{
v3 = *(_DWORD *)(a2 + 72);
if ( v3 == 1 )
{
CTab_Key(a1, 200, 0);
result = 1LL;
}
else if ( v3 == 2 )
{
CTab_Key(a1, 201, 0);
result = 1LL;
}
else
{
v4 = a1[224];
if ( v4 > 0 )
{
v5 = *(double *)a2;
v6 = a1 + 230;
v7 = 0;
while ( 1 )
{
if ( (double)*v6 <= v5 )
{
v8 = *(double *)(a2 + 8);
if ( (double)v6[1] <= v8 && v5 <= (double)v6[2] && v8 <= (double)v6[3] )
break;
}
++v7;
v6 += 4;
if ( v7 == v4 )
return 0LL;
}
a1[227] = v7;
result = 1LL;
}
}
}
return result;
}

original_code:
static qbool CTab_Navi_Mouse_Event (CTab_t *tab, const mouse_state_t *ms)
{
    int i;
 if (!tab->width) return false;
    if (ms->button_up == 1) {
        CTab_Key(tab, K_MOUSE1, 0);
        return true;
    } else if (ms->button_up == 2) {
        CTab_Key(tab, K_MOUSE2, 0);
        return true;
    }
    for (i = 0; i < tab->nPages; i++)
    {
        if (!(tab->navi_boxes[i].x > ms->x || tab->navi_boxes[i].y > ms->y || tab->navi_boxes[i].x2 < ms->x || tab->navi_boxes[i].y2 < ms->y))
        {
            tab->hoveredPage = i;
            return true;
        }
    }
 return false;
}

canonical_original_code:
static enum qbool CTab_Navi_Mouse_Event(struct CTab_s *tab, struct mouse_state_s *ms)
{
    int i;
 if (!tab->width) return false;
    if (ms->button_up == 1) {
        CTab_Key(tab, K_MOUSE1, 0);
        return true;
    } else if (ms->button_up == 2) {
        CTab_Key(tab, K_MOUSE2, 0);
        return true;
    }
    for (i = 0; i < tab->nPages; i++)
    {
        if (!(tab->navi_boxes[i].x > ms->x || tab->navi_boxes[i].y > ms->y || tab->navi_boxes[i].x2 < ms->x || tab->navi_boxes[i].y2 < ms->y))
        {
            tab->hoveredPage = i;
            return true;
        }
    }
 return false;
}

variable_types:
ms
struct mouse_state_s *

variable_types: i int

return_type: enum qbool { false=0, true=1 }


original_code:
qbool CTab_Mouse_Event(CTab_t *tab, const mouse_state_t *ms)
{
    int nav_height = tab->navi_boxes[tab->nPages-1].y2;
    if (ms->x < 0 || ms->x > tab->width || ms->y < 0 || ms->y > tab->height)
        return false;
 if (ms->y <= nav_height)
    {
  return CTab_Navi_Mouse_Event(tab, ms);
 }
    else if (ms->y >= nav_height + 8)
    {
  CTabPage_MouseMoveType mmf;
  mouse_state_t lms = *ms;
        lms.y -= nav_height + 8;
  tab->hoveredPage = -1;
  mmf = tab->pages[tab->activePage].handlers.mousemove;
  if (mmf)
   return mmf(&lms);
 }
    return false;
}

canonical_original_code:
enum qbool CTab_Mouse_Event(struct CTab_s *tab, struct mouse_state_s *ms)
{
    int nav_height = tab->navi_boxes[tab->nPages-1].y2;
    if (ms->x < 0 || ms->x > tab->width || ms->y < 0 || ms->y > tab->height)
        return false;
 if (ms->y <= nav_height)
    {
  return CTab_Navi_Mouse_Event(tab, ms);
 }
    else if (ms->y >= nav_height + 8)
    {
  enum qbool (*mmf)(struct mouse_state_s *ms);
  struct mouse_state_s lms = *ms;
        lms.y -= nav_height + 8;
  tab->hoveredPage = -1;
  mmf = tab->pages[tab->activePage].handlers.mousemove;
  if (mmf)
   return mmf(&lms);
 }
    return false;
}

variable_types: enum qbool { false=0, true=1 } (*)(struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool { false=0, true=1 } buttons[9]; int button_down; int button_up; } *ms)


decompiled_code:
__int64 __fastcall CTab_GetCurrent(__int64 a1)
{
return a1 + 56LL * *(int *)(a1 + 900);
}

original_code:
CTabPage_t * CTab_GetCurrent(CTab_t *tab)
{
    return &tab->pages[tab->activePage];
}

canonical_original_code:
struct CTabPage_s *CTab_GetCurrent(struct CTab_s *tab)
{
    return &tab->pages[tab->activePage];
}

variable_types:
tab
struct CTab_s *

return_type: struct CTabPage_s { char name[-1]; int id; struct CTabPage_Handlers_s { void (*draw)(int x, int y, int w, int h, struct CTab_s { struct CTabPage_s pages[16]; int nPages; int activePage; int lastViewedPage; int hoveredPage; int width; int height; struct { int x; } navi_boxes[16]; void *tag; } *, struct CTabPage_s *); int (*key)(int key, unsigned short unichar, struct CTab_s *, struct CTabPage_s *); void (*onshow)(); enum qbool { false=0, true=1 } (*mousemove)(struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool { false=0, true=1 } buttons[9]; int button_down; int button_up; } *ms); } handlers; } *


decompiled_code:
__int64 __fastcall CTab_GetCurrentId(__int64 a1)
{
return *(unsigned int *)(a1 + 56LL * *(int *)(a1 + 900) + 16);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(unsigned int *)(a1 + 56LL * *(int *)(a1 + 900) + 16);
}

original_code:
int CTab_GetCurrentId(CTab_t *tab)
{
    return tab->pages[tab->activePage].id;
}

canonical_original_code:
int CTab_GetCurrentId(struct CTab_s *tab)
{
    return tab->pages[tab->activePage].id;
}


decompiled_code:
__int64 __fastcall CTab_GetCurrentPage(__int64 a1)
{
return a1 + 56LL * *(int *)(a1 + 900);
}

original_code:
char * CTab_GetCurrentPage(CTab_t *tab)
{
    return tab->pages[tab->activePage].name;
}

canonical_original_code:
char *CTab_GetCurrentPage(struct CTab_s *tab)
{
    return tab->pages[tab->activePage].name;
}

return_type: char *


decompiled_code:
__int64 __fastcall CTab_SetCurrentId(_DWORD *a1, int a2)
{
int v2; // ecx
_DWORD *v3; // rdx
__int64 result; // rax

v2 = a1[224];
if ( v2 <= 0 )
return Sys_Error("CTab_SetCurrentId: id not found");
v3 = a1 + 4;
result = 0LL;
while ( *v3 != a2 )
{
result = (unsigned int)(result + 1);
v3 += 14;
if ( (_DWORD)result == v2 )
return Sys_Error("CTab_SetCurrentId: id not found");
}
a1[225] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_DWORD *a1, int a2)
{
int v2; // ecx
_DWORD *v3; // rdx
__int64 result; // rax

v2 = a1[224];
if ( v2 <= 0 )
return Sys_Error("CTab_SetCurrentId: id not found");
v3 = a1 + 4;
result = 0LL;
while ( *v3 != a2 )
{
result = (unsigned int)(result + 1);
v3 += 14;
if ( (_DWORD)result == v2 )
return Sys_Error("CTab_SetCurrentId: id not found");
}
a1[225] = result;
return result;
}

original_code:
void CTab_SetCurrentId(CTab_t *tab, int id)
{
    int i;
    for (i=0; i < tab->nPages; i++)
    {
        if (tab->pages[i].id == id)
        {
            tab->activePage = i;
            return;
        }
    }
    Sys_Error("CTab_SetCurrentId: id not found");
}

canonical_original_code:
void CTab_SetCurrentId(struct CTab_s *tab, int id)
{
    int i;
    for (i=0; i < tab->nPages; i++)
    {
        if (tab->pages[i].id == id)
        {
            tab->activePage = i;
            return;
        }
    }
    Sys_Error("CTab_SetCurrentId: id not found");
}

variable_types: id int

return_type: void


SetCurrentPage

decompiled_code:
int __fastcall SetCurrentPage(char *s1, char *s2)
{
int v2; // er14
char *v3; // r12
char *v4; // rbp
int v5; // ebx
int result; // eax

v2 = *((_DWORD *)s1 + 224);
if ( v2 <= 0 )
return Sys_Error("CTab_SetCurrentName: name not found", s2);
v3 = s2;
v4 = s1;
v5 = 0;
while ( 1 )
{
s2 = v3;
result = strcmp(v4, v3);
if ( !result )
break;
++v5;
v4 += 56;
if ( v5 == v2 )
return Sys_Error("CTab_SetCurrentName: name not found", s2);
}
*((_DWORD *)s1 + 225) = v5;
return result;
}

canonical_decompiled_code:
int __fastcall func12(char *s1, char *s2)
{
int v2; // er14
char *v3; // r12
char *v4; // rbp
int v5; // ebx
int result; // eax

v2 = *((_DWORD *)s1 + 224);
if ( v2 <= 0 )
return Sys_Error("CTab_SetCurrentName: name not found", s2);
v3 = s2;
v4 = s1;
v5 = 0;
while ( 1 )
{
s2 = v3;
result = strcmp(v4, v3);
if ( !result )
break;
++v5;
v4 += 56;
if ( v5 == v2 )
return Sys_Error("CTab_SetCurrentName: name not found", s2);
}
*((_DWORD *)s1 + 225) = v5;
return result;
}

original_code:
void SetCurrentPage(CTab_t *tab, char *name)
{
    int i;
    for (i=0; i < tab->nPages; i++)
    {
        if (!strcmp(tab->pages[i].name, name))
        {
            tab->activePage = i;
            return;
        }
    }
    Sys_Error("CTab_SetCurrentName: name not found");
}

canonical_original_code:
void SetCurrentPage(struct CTab_s *tab, char *name)
{
    int i;
    for (i=0; i < tab->nPages; i++)
    {
        if (!strcmp(tab->pages[i].name, name))
        {
            tab->activePage = i;
            return;
        }
    }
    Sys_Error("CTab_SetCurrentName: name not found");
}

variable_types:
name
char *


StripLength

original_code:
int StripLength (int starttri, int startv)
{
 int m1, m2;
 int j;
 mtriangle_t *last, *check;
 int k;
 used[starttri] = 2;
 last = &triangles[starttri];
 stripverts[0] = last->vertindex[(startv)%3];
 stripverts[1] = last->vertindex[(startv+1)%3];
 stripverts[2] = last->vertindex[(startv+2)%3];
 striptris[0] = starttri;
 stripcount = 1;
 m1 = last->vertindex[(startv+2)%3];
 m2 = last->vertindex[(startv+1)%3];
nexttri:
 for (j=starttri+1, check=&triangles[starttri+1] ; j<pheader->numtris ; j++, check++)
 {
  if (check->facesfront != last->facesfront)
   continue;
  for (k=0 ; k<3 ; k++)
  {
   if (check->vertindex[k] != m1)
    continue;
   if (check->vertindex[ (k+1)%3 ] != m2)
    continue;
   if (used[j])
    goto done;
   if (stripcount & 1)
    m2 = check->vertindex[ (k+2)%3 ];
   else
    m1 = check->vertindex[ (k+2)%3 ];
   stripverts[stripcount+2] = check->vertindex[ (k+2)%3 ];
   striptris[stripcount] = j;
   stripcount++;
   used[j] = 2;
   goto nexttri;
  }
 }
done:
 for (j=starttri+1 ; j<pheader->numtris ; j++)
  if (used[j] == 2)
   used[j] = 0;
 return stripcount;
}

canonical_original_code:
int StripLength(int starttri, int startv)
{
 int m1; int m2;
 int j;
 struct mtriangle_s *last; struct mtriangle_s *check;
 int k;
 used[starttri] = 2;
 last = &triangles[starttri];
 stripverts[0] = last->vertindex[(startv)%3];
 stripverts[1] = last->vertindex[(startv+1)%3];
 stripverts[2] = last->vertindex[(startv+2)%3];
 striptris[0] = starttri;
 stripcount = 1;
 m1 = last->vertindex[(startv+2)%3];
 m2 = last->vertindex[(startv+1)%3];
nexttri:
 for (j=starttri+1, check=&triangles[starttri+1] ; j<pheader->numtris ; j++, check++)
 {
  if (check->facesfront != last->facesfront)
   continue;
  for (k=0 ; k<3 ; k++)
  {
   if (check->vertindex[k] != m1)
    continue;
   if (check->vertindex[ (k+1)%3 ] != m2)
    continue;
   if (used[j])
    goto done;
   if (stripcount & 1)
    m2 = check->vertindex[ (k+2)%3 ];
   else
    m1 = check->vertindex[ (k+2)%3 ];
   stripverts[stripcount+2] = check->vertindex[ (k+2)%3 ];
   striptris[stripcount] = j;
   stripcount++;
   used[j] = 2;
   goto nexttri;
  }
 }
done:
 for (j=starttri+1 ; j<pheader->numtris ; j++)
  if (used[j] == 2)
   used[j] = 0;
 return stripcount;
}

variable_types: starttri int

variable_types: startv int

variable_types: j int

variable_types: struct mtriangle_s { int facesfront; int vertindex[3]; } *

variable_types: k int


FanLength

original_code:
int FanLength (int starttri, int startv)
{
 int m1, m2;
 int j;
 mtriangle_t *last, *check;
 int k;
 used[starttri] = 2;
 last = &triangles[starttri];
 stripverts[0] = last->vertindex[(startv)%3];
 stripverts[1] = last->vertindex[(startv+1)%3];
 stripverts[2] = last->vertindex[(startv+2)%3];
 striptris[0] = starttri;
 stripcount = 1;
 m1 = last->vertindex[(startv+0)%3];
 m2 = last->vertindex[(startv+2)%3];
nexttri:
 for (j=starttri+1, check=&triangles[starttri+1] ; j<pheader->numtris ; j++, check++)
 {
  if (check->facesfront != last->facesfront)
   continue;
  for (k=0 ; k<3 ; k++)
  {
   if (check->vertindex[k] != m1)
    continue;
   if (check->vertindex[ (k+1)%3 ] != m2)
    continue;
   if (used[j])
    goto done;
   m2 = check->vertindex[ (k+2)%3 ];
   stripverts[stripcount+2] = m2;
   striptris[stripcount] = j;
   stripcount++;
   used[j] = 2;
   goto nexttri;
  }
 }
done:
 for (j=starttri+1 ; j<pheader->numtris ; j++)
  if (used[j] == 2)
   used[j] = 0;
 return stripcount;
}

canonical_original_code:
int FanLength(int starttri, int startv)
{
 int m1; int m2;
 int j;
 struct mtriangle_s *last; struct mtriangle_s *check;
 int k;
 used[starttri] = 2;
 last = &triangles[starttri];
 stripverts[0] = last->vertindex[(startv)%3];
 stripverts[1] = last->vertindex[(startv+1)%3];
 stripverts[2] = last->vertindex[(startv+2)%3];
 striptris[0] = starttri;
 stripcount = 1;
 m1 = last->vertindex[(startv+0)%3];
 m2 = last->vertindex[(startv+2)%3];
nexttri:
 for (j=starttri+1, check=&triangles[starttri+1] ; j<pheader->numtris ; j++, check++)
 {
  if (check->facesfront != last->facesfront)
   continue;
  for (k=0 ; k<3 ; k++)
  {
   if (check->vertindex[k] != m1)
    continue;
   if (check->vertindex[ (k+1)%3 ] != m2)
    continue;
   if (used[j])
    goto done;
   m2 = check->vertindex[ (k+2)%3 ];
   stripverts[stripcount+2] = m2;
   striptris[stripcount] = j;
   stripcount++;
   used[j] = 2;
   goto nexttri;
  }
 }
done:
 for (j=starttri+1 ; j<pheader->numtris ; j++)
  if (used[j] == 2)
   used[j] = 0;
 return stripcount;
}

user_defined_types: struct mtriangle_s { int facesfront; int vertindex[3]; }


BuildTris

decompiled_code:
__int64 BuildTris()
{
_DWORD *v0; // r12
__int64 v1; // rbx
int i; // eax
int v3; // er14
int v4; // er13
int j; // ebp
int v6; // er12
int *v7; // rax
__int64 v8; // rdx
int v9; // er15
int v10; // er9
__int64 v11; // r8
int v12; // eax
int v13; // ecx
unsigned int v14; // er13
int v15; // er14
__int64 v16; // r10
int *v17; // rdi
__int64 v18; // rax
__int64 v19; // rsi
_WORD *v20; // rdx
int *v21; // rdi
float v22; // xmm0_4
float v23; // xmm1_4
int v24; // edi
double v25; // xmm1_8
int v26; // xmm0_4
__int64 v27; // rax
__int64 v28; // rdx
__int64 v29; // rcx
__int64 v30; // rsi
__int64 result; // rax
__int64 v32; // rax
__int64 v33; // rsi
__int64 v34; // r8
_WORD *v35; // rdi
__int64 v36; // rdx
__int64 v37; // r8
__int64 v38; // r9
int *v39; // r8
float v40; // xmm0_4
float v41; // xmm1_4
int v42; // er8
double v43; // xmm1_8
int v44; // xmm0_4
int v45; // [rsp+Ch] [rbp-204Ch]
int v46; // [rsp+10h] [rbp-2048h]
int v47; // [rsp+14h] [rbp-2044h]
__int64 v48; // [rsp+18h] [rbp-2040h]
_WORD src[2048]; // [rsp+20h] [rbp-2038h] BYREF
int dest[1038]; // [rsp+1020h] [rbp-1038h] BYREF

numorder = 0;
numcommands = 0;
memset(used, 0, sizeof(used));
v0 = (_DWORD *)pheader;
if ( *(int *)(pheader + 64LL) <= 0 )
{
v28 = 0LL;
v29 = 1LL;
v27 = 0LL;
goto LABEL_28;
}
v45 = 0;
v1 = 0LL;
for ( i = 0; ; i = used[v1] )
{
v0 = (_DWORD *)pheader;
if ( !i )
break;
if ( *(_DWORD *)(pheader + 64LL) <= (int)++v1 )
goto LABEL_27;
LABEL_4:
;
}
v3 = 0;
v4 = 0;
while ( 1 )
{
for ( j = 0; j != 3; ++j )
{
if ( v3 == 1 )
v6 = StripLength(v1, j);
else
v6 = FanLength(v1, j);
if ( v6 > v4 )
{
memcpy(src, stripverts, 4LL * v6 + 8);
v4 = v6;
memcpy(dest, striptris, 4LL * v6);
v45 = v3;
}
}
if ( v3 == 1 )
break;
v3 = 1;
}
if ( v4 )
{
v7 = dest;
do
{
v8 = *v7++;
used[v8] = 1;
}
while ( v7 != &dest[v4 - 1 + 1] );
}
v9 = numcommands;
v10 = numcommands + 1;
v11 = numcommands;
if ( v45 == 1 )
{
v12 = v4 + 2;
++numcommands;
}
else
{
++numcommands;
v12 = -2 - v4;
}
commands[v9] = v12;
v13 = numorder;
v14 = v4 + 1;
v0 = (_DWORD *)pheader;
v15 = triangles[4 * dest[0]];
v16 = numorder;
v17 = &vertexorder[v16];
if ( pheader + 52LL < (unsigned __int64)&vertexorder[(int)v14 + 1 + (__int64)numorder]
&& (unsigned __int64)v17 < pheader + 60LL )
{
v32 = v10;
v33 = v11 + 2LL * v14 + 3;
v34 = -v11;
v35 = &src[v34];
v36 = v16 * 4 + 2 * v34;
do
{
v37 = *(int *)&v35[v32 - 1];
v38 = 3 * v37;
*(int *)((char *)&vertexorder[-1] + 2 * v32 + v36 + 2) = v37;
v39 = (int *)((char *)&stverts + 12 * v37);
v40 = (float)v39[1];
v41 = (float)v39[2];
v42 = v0[13];
if ( !v15 && *((_DWORD *)&stverts + v38) )
v40 = v40 + (float)(v42 / 2);
v43 = (v41 + 0.5) / (double)(int)v0[14];
*(float *)&v44 = (v40 + 0.5) / (double)v42;
commands[v32] = v44;
*(float *)&v43 = v43;
commands[v32 + 1] = LODWORD(v43);
v32 += 2LL;
}
while ( v33 != v32 );
}
else
{
v48 = v11;
v46 = numorder;
v47 = v10;
memcpy(v17, src, 4LL * (int)v14 + 4);
v18 = v47;
v13 = v46;
v19 = v48 + 2LL * v14 + 3;
v20 = &src[-v48];
do
{
v21 = (int *)((char *)&stverts + 12 * *(int *)&v20[v18 - 1]);
v22 = (float)v21[1];
v23 = (float)v21[2];
v24 = v0[13];
if ( !v15 && *((_DWORD *)&stverts + 3 * *(int *)&v20[v18 - 1]) )
v22 = v22 + (float)(v24 / 2);
v25 = (v23 + 0.5) / (double)(int)v0[14];
*(float *)&v26 = (v22 + 0.5) / (double)v24;
commands[v18] = v26;
*(float *)&v25 = v25;
commands[v18 + 1] = LODWORD(v25);
v18 += 2LL;
}
while ( v18 != v19 );
}
++v1;
numorder = v13 + v14 + 1;
numcommands = v9 + 2 * v14 + 3;
if ( v0[16] > (int)v1 )
goto LABEL_4;
LABEL_27:
v27 = numcommands;
v28 = (unsigned int)numorder;
v29 = (unsigned int)(numcommands + 1);
LABEL_28:
commands[v27] = 0;
v30 = (unsigned int)v0[16];
numcommands = v29;
Com_DPrintf("%3i tri %3i vert %3i cmd\n", v30, v28, v29);
allverts += numorder;
result = *(unsigned int *)(pheader + 64LL);
alltris += result;
return result;
}

canonical_decompiled_code:
__int64 func2()
{
_DWORD *v0; // r12
__int64 v1; // rbx
int i; // eax
int v3; // er14
int v4; // er13
int j; // ebp
int v6; // er12
int *v7; // rax
__int64 v8; // rdx
int v9; // er15
int v10; // er9
__int64 v11; // r8
int v12; // eax
int v13; // ecx
unsigned int v14; // er13
int v15; // er14
__int64 v16; // r10
int *v17; // rdi
__int64 v18; // rax
__int64 v19; // rsi
_WORD *v20; // rdx
int *v21; // rdi
float v22; // xmm0_4
float v23; // xmm1_4
int v24; // edi
double v25; // xmm1_8
int v26; // xmm0_4
__int64 v27; // rax
__int64 v28; // rdx
__int64 v29; // rcx
__int64 v30; // rsi
__int64 result; // rax
__int64 v32; // rax
__int64 v33; // rsi
__int64 v34; // r8
_WORD *v35; // rdi
__int64 v36; // rdx
__int64 v37; // r8
__int64 v38; // r9
int *v39; // r8
float v40; // xmm0_4
float v41; // xmm1_4
int v42; // er8
double v43; // xmm1_8
int v44; // xmm0_4
int v45; // [rsp+Ch] [rbp-204Ch]
int v46; // [rsp+10h] [rbp-2048h]
int v47; // [rsp+14h] [rbp-2044h]
__int64 v48; // [rsp+18h] [rbp-2040h]
_WORD src[2048]; // [rsp+20h] [rbp-2038h] BYREF
int dest[1038]; // [rsp+1020h] [rbp-1038h] BYREF

numorder = 0;
numcommands = 0;
memset(used, 0, sizeof(used));
v0 = (_DWORD *)pheader;
if ( *(int *)(pheader + 64LL) <= 0 )
{
v28 = 0LL;
v29 = 1LL;
v27 = 0LL;
goto LABEL_28;
}
v45 = 0;
v1 = 0LL;
for ( i = 0; ; i = used[v1] )
{
v0 = (_DWORD *)pheader;
if ( !i )
break;
if ( *(_DWORD *)(pheader + 64LL) <= (int)++v1 )
goto LABEL_27;
LABEL_4:
;
}
v3 = 0;
v4 = 0;
while ( 1 )
{
for ( j = 0; j != 3; ++j )
{
if ( v3 == 1 )
v6 = func0(v1, j);
else
v6 = func1(v1, j);
if ( v6 > v4 )
{
memcpy(src, stripverts, 4LL * v6 + 8);
v4 = v6;
memcpy(dest, striptris, 4LL * v6);
v45 = v3;
}
}
if ( v3 == 1 )
break;
v3 = 1;
}
if ( v4 )
{
v7 = dest;
do
{
v8 = *v7++;
used[v8] = 1;
}
while ( v7 != &dest[v4 - 1 + 1] );
}
v9 = numcommands;
v10 = numcommands + 1;
v11 = numcommands;
if ( v45 == 1 )
{
v12 = v4 + 2;
++numcommands;
}
else
{
++numcommands;
v12 = -2 - v4;
}
commands[v9] = v12;
v13 = numorder;
v14 = v4 + 1;
v0 = (_DWORD *)pheader;
v15 = triangles[4 * dest[0]];
v16 = numorder;
v17 = &vertexorder[v16];
if ( pheader + 52LL < (unsigned __int64)&vertexorder[(int)v14 + 1 + (__int64)numorder]
&& (unsigned __int64)v17 < pheader + 60LL )
{
v32 = v10;
v33 = v11 + 2LL * v14 + 3;
v34 = -v11;
v35 = &src[v34];
v36 = v16 * 4 + 2 * v34;
do
{
v37 = *(int *)&v35[v32 - 1];
v38 = 3 * v37;
*(int *)((char *)&vertexorder[-1] + 2 * v32 + v36 + 2) = v37;
v39 = (int *)((char *)&stverts + 12 * v37);
v40 = (float)v39[1];
v41 = (float)v39[2];
v42 = v0[13];
if ( !v15 && *((_DWORD *)&stverts + v38) )
v40 = v40 + (float)(v42 / 2);
v43 = (v41 + 0.5) / (double)(int)v0[14];
*(float *)&v44 = (v40 + 0.5) / (double)v42;
commands[v32] = v44;
*(float *)&v43 = v43;
commands[v32 + 1] = LODWORD(v43);
v32 += 2LL;
}
while ( v33 != v32 );
}
else
{
v48 = v11;
v46 = numorder;
v47 = v10;
memcpy(v17, src, 4LL * (int)v14 + 4);
v18 = v47;
v13 = v46;
v19 = v48 + 2LL * v14 + 3;
v20 = &src[-v48];
do
{
v21 = (int *)((char *)&stverts + 12 * *(int *)&v20[v18 - 1]);
v22 = (float)v21[1];
v23 = (float)v21[2];
v24 = v0[13];
if ( !v15 && *((_DWORD *)&stverts + 3 * *(int *)&v20[v18 - 1]) )
v22 = v22 + (float)(v24 / 2);
v25 = (v23 + 0.5) / (double)(int)v0[14];
*(float *)&v26 = (v22 + 0.5) / (double)v24;
commands[v18] = v26;
*(float *)&v25 = v25;
commands[v18 + 1] = LODWORD(v25);
v18 += 2LL;
}
while ( v18 != v19 );
}
++v1;
numorder = v13 + v14 + 1;
numcommands = v9 + 2 * v14 + 3;
if ( v0[16] > (int)v1 )
goto LABEL_4;
LABEL_27:
v27 = numcommands;
v28 = (unsigned int)numorder;
v29 = (unsigned int)(numcommands + 1);
LABEL_28:
commands[v27] = 0;
v30 = (unsigned int)v0[16];
numcommands = v29;
Com_DPrintf("%3i tri %3i vert %3i cmd\n", v30, v28, v29);
allverts += numorder;
result = *(unsigned int *)(pheader + 64LL);
alltris += result;
return result;
}

original_code:
void BuildTris (void)
{
 int i, j, k;
 int startv;
 float s, t;
 int len, bestlen, besttype = 0;
 int bestverts[1024];
 int besttris[1024];
 int type;
 numorder = 0;
 numcommands = 0;
 memset (used, 0, sizeof(used));
 for (i=0 ; i<pheader->numtris ; i++)
 {
  if (used[i])
   continue;
  bestlen = 0;
  for (type = 0 ; type < 2 ; type++)
  {
   for (startv =0 ; startv < 3 ; startv++)
   {
    if (type == 1)
     len = StripLength (i, startv);
    else
     len = FanLength (i, startv);
    if (len > bestlen)
    {
     besttype = type;
     bestlen = len;
     for (j=0 ; j<bestlen+2 ; j++)
      bestverts[j] = stripverts[j];
     for (j=0 ; j<bestlen ; j++)
      besttris[j] = striptris[j];
    }
   }
  }
  for (j=0 ; j<bestlen ; j++)
   used[besttris[j]] = 1;
  if (besttype == 1)
   commands[numcommands++] = (bestlen+2);
  else
   commands[numcommands++] = -(bestlen+2);
  for (j=0 ; j<bestlen+2 ; j++)
  {
   k = bestverts[j];
   vertexorder[numorder++] = k;
   s = stverts[k].s;
   t = stverts[k].t;
   if (!triangles[besttris[0]].facesfront && stverts[k].onseam)
    s += pheader->skinwidth / 2;
   s = (s + 0.5) / pheader->skinwidth;
   t = (t + 0.5) / pheader->skinheight;
   *(float *)&commands[numcommands++] = s;
   *(float *)&commands[numcommands++] = t;
  }
 }
 commands[numcommands++] = 0;
 Com_DPrintf ("%3i tri %3i vert %3i cmd\n", pheader->numtris, numorder, numcommands);
 allverts += numorder;
 alltris += pheader->numtris;
}

canonical_original_code:
void BuildTris()
{
 int i; int j; int k;
 int startv;
 float s; float t;
 int len; int bestlen; int besttype = 0;
 int bestverts[1024];
 int besttris[1024];
 int type;
 numorder = 0;
 numcommands = 0;
 memset (used, 0, sizeof(used));
 for (i=0 ; i<pheader->numtris ; i++)
 {
  if (used[i])
   continue;
  bestlen = 0;
  for (type = 0 ; type < 2 ; type++)
  {
   for (startv =0 ; startv < 3 ; startv++)
   {
    if (type == 1)
     len = StripLength (i, startv);
    else
     len = FanLength (i, startv);
    if (len > bestlen)
    {
     besttype = type;
     bestlen = len;
     for (j=0 ; j<bestlen+2 ; j++)
      bestverts[j] = stripverts[j];
     for (j=0 ; j<bestlen ; j++)
      besttris[j] = striptris[j];
    }
   }
  }
  for (j=0 ; j<bestlen ; j++)
   used[besttris[j]] = 1;
  if (besttype == 1)
   commands[numcommands++] = (bestlen+2);
  else
   commands[numcommands++] = -(bestlen+2);
  for (j=0 ; j<bestlen+2 ; j++)
  {
   k = bestverts[j];
   vertexorder[numorder++] = k;
   s = stverts[k].s;
   t = stverts[k].t;
   if (!triangles[besttris[0]].facesfront && stverts[k].onseam)
    s += pheader->skinwidth / 2;
   s = (s + 0.5) / pheader->skinwidth;
   t = (t + 0.5) / pheader->skinheight;
   *(float *)&commands[numcommands++] = s;
   *(float *)&commands[numcommands++] = t;
  }
 }
 commands[numcommands++] = 0;
 Com_DPrintf ("%3i tri %3i vert %3i cmd\n", pheader->numtris, numorder, numcommands);
 allverts += numorder;
 alltris += pheader->numtris;
}

variable_types: s float

variable_types: t float

variable_types: len int

variable_types: bestlen int

variable_types: besttype int

variable_types:
bestverts
int [1024]

variable_types:
besttris
int [1024]

variable_types: type int


decompiled_code:
__int64 __fastcall GL_MakeAliasModelDisplayLists(__int64 a1, __int64 a2)
{
void *v2; // rax
__int64 v3; // rax
__int64 v4; // rcx
__int64 v5; // rdx
int v6; // edi
__int64 result; // rax
__int64 v8; // rdi
__int64 v9; // rsi

paliashdr = a2;
aliasmodel = a1;
BuildTris();
*(_DWORD *)(paliashdr + 88) = numorder;
v2 = (void *)Hunk_Alloc((unsigned int)(4 * numcommands));
*(_DWORD *)(paliashdr + 96) = (_DWORD)v2 - paliashdr;
memcpy(v2, commands, 4 * numcommands);
v3 = Hunk_Alloc((unsigned int)(4 * *(_DWORD *)(paliashdr + 88) * *(_DWORD *)(paliashdr + 84)));
v4 = paliashdr;
v5 = v3;
v6 = *(_DWORD *)(paliashdr + 84);
result = v3 - paliashdr;
*(_DWORD *)(paliashdr + 92) = result;
if ( v6 > 0 )
{
v8 = 0LL;
do
{
result = 0LL;
if ( numorder > 0 )
{
do
{
v9 = vertexorder[result];
v5 += 4LL;
++result;
*(_DWORD *)(v5 - 4) = *(_DWORD *)(*((_QWORD *)&poseverts + v8) + 4 * v9);
}
while ( numorder > (int)result );
v4 = paliashdr;
}
++v8;
}
while ( *(_DWORD *)(v4 + 84) > (int)v8 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
void *v2; // rax
__int64 v3; // rax
__int64 v4; // rcx
__int64 v5; // rdx
int v6; // edi
__int64 result; // rax
__int64 v8; // rdi
__int64 v9; // rsi

paliashdr = a2;
aliasmodel = a1;
func2();
*(_DWORD *)(paliashdr + 88) = numorder;
v2 = (void *)Hunk_Alloc((unsigned int)(4 * numcommands));
*(_DWORD *)(paliashdr + 96) = (_DWORD)v2 - paliashdr;
memcpy(v2, commands, 4 * numcommands);
v3 = Hunk_Alloc((unsigned int)(4 * *(_DWORD *)(paliashdr + 88) * *(_DWORD *)(paliashdr + 84)));
v4 = paliashdr;
v5 = v3;
v6 = *(_DWORD *)(paliashdr + 84);
result = v3 - paliashdr;
*(_DWORD *)(paliashdr + 92) = result;
if ( v6 > 0 )
{
v8 = 0LL;
do
{
result = 0LL;
if ( numorder > 0 )
{
do
{
v9 = vertexorder[result];
v5 += 4LL;
++result;
*(_DWORD *)(v5 - 4) = *(_DWORD *)(*((_QWORD *)&poseverts + v8) + 4 * v9);
}
while ( numorder > (int)result );
v4 = paliashdr;
}
++v8;
}
while ( *(_DWORD *)(v4 + 84) > (int)v8 );
}
return result;
}

original_code:
void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
{
 int i, j;
 int *cmds;
 trivertx_t *verts;
 aliasmodel = m;
 paliashdr = hdr;
 BuildTris ();
 paliashdr->poseverts = numorder;
 cmds = (int *) Hunk_Alloc (numcommands * 4);
 paliashdr->commands = (byte *)cmds - (byte *)paliashdr;
 memcpy (cmds, commands, numcommands * 4);
 verts = (trivertx_t *) Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
  * sizeof(trivertx_t) );
 paliashdr->posedata = (byte *)verts - (byte *)paliashdr;
 for (i=0 ; i<paliashdr->numposes ; i++)
  for (j=0 ; j<numorder ; j++)
   *verts++ = poseverts[i][vertexorder[j]];
}

canonical_original_code:
void GL_MakeAliasModelDisplayLists(struct model_s *m, struct aliashdr_s *hdr)
{
 int i; int j;
 int *cmds;
 struct trivertx_t *verts;
 aliasmodel = m;
 paliashdr = hdr;
 BuildTris ();
 paliashdr->poseverts = numorder;
 cmds = (int *) Hunk_Alloc (numcommands * 4);
 paliashdr->commands = (unsigned char *)cmds - (unsigned char *)paliashdr;
 memcpy (cmds, commands, numcommands * 4);
 verts = (struct trivertx_t *) Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
  * sizeof(trivertx_t) );
 paliashdr->posedata = (unsigned char *)verts - (unsigned char *)paliashdr;
 for (i=0 ; i<paliashdr->numposes ; i++)
  for (j=0 ; j<numorder ; j++)
   *verts++ = poseverts[i][vertexorder[j]];
}

variable_types: struct model_s { char name[64]; enum qbool { false=0, true=1 } needload; unsigned short crc; int simpletexture[5]; enum modhint_t { MOD_NORMAL=0, MOD_PLAYER=1, MOD_EYES=2, MOD_FLAME=3, MOD_THUNDERBOLT=4, MOD_BACKPACK=5, MOD_FLAG=6, MOD_SPIKE=7, MOD_TF_TRAIL=8, MOD_GRENADE=9, MOD_TESLA=10, MOD_SENTRYGUN=11, MOD_DETPACK=12, MOD_LASER=13, MOD_DEMON=14, MOD_SOLDIER=15, MOD_OGRE=16, MOD_ENFORCER=17, MOD_VOORSPIKE=18, MOD_LAVABALL=19, MOD_RAIL=20, MOD_RAIL2=21, MOD_BUILDINGGIBS=22, MOD_CLUSTER=23, MOD_SHAMBLER=24, MOD_TELEPORTDESTINATION=25, MOD_GIB=26, MOD_VMODEL=27 } modhint; enum modtype_t { mod_brush=0, mod_sprite=1, mod_spr32=2, mod_alias=3, mod_alias3=4 } type; int numframes; enum synctype_t { ST_SYNC=0, ST_RAND=1 } synctype; int flags; float mins[3]; float radius; int firstmodelsurface; int numsubmodels; struct dmodel_t { float mins[3]; float origin[3]; int headnode[4]; int visleafs; int firstface; } *submodels; int numplanes; struct mplane_s { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *planes; int numleafs; struct mleaf_s { int contents; int visframe; float minmaxs[6]; struct mnode_s { int contents; int visframe; float minmaxs[6]; struct mnode_s *parent; struct mplane_s *plane; struct mnode_s *children[2]; unsigned short firstsurface; unsigned short numsurfaces; } *parent; unsigned char *compressed_vis; struct efrag_s { struct mleaf_s *leaf; struct efrag_s *leafnext; struct entity_s { float origin[3]; float angles[3]; struct model_s *model; unsigned char *colormap; int skinnum; struct player_info_s { int userid; char userinfo[1024]; char name[16]; float entertime; int frags; int ping; unsigned char pl; int topcolor; int bottomcolor; int _topcolor; int _bottomcolor; int real_topcolor; int real_bottomcolor; char team[1024]; char _team[1024]; int fps_msec; int last_fps; int fps; int fps_frames; double fps_measure_time; enum qbool { false=0, true=1 } isnear; int spectator; unsigned char translations[-1]; struct skin_t { char name[16]; enum qbool { false=0, true=1 } failedload; enum qbool { false=0, true=1 } warned; int width; int bpp; int texnum; struct cache_user_s { void *data; } cache; } *skin; int stats[32]; enum qbool { false=0, true=1 } skin_refresh; enum qbool { false=0, true=1 } ignored; enum qbool { false=0, true=1 } validated; char f_server[16]; enum qbool { false=0, true=1 } dead; } *scoreboard; int renderfx; int effects; int oldframe; int frame; float framelerp; struct efrag_s *efrag; int visframe; int dlightframe; int dlightbits; float alpha; int trivial_accept; struct mnode_s *topnode; } *entity; struct efrag_s *entnext; } *efrags; struct msurface_s { int visframe; struct mplane_s *plane; int flags; int firstedge; int numedges; short texturemins[2]; short extents[2]; int light_s; struct glpoly_s { struct glpoly_s *next; struct glpoly_s *chain; struct glpoly_s *fb_chain; struct glpoly_s *luma_chain; struct glpoly_s *caustics_chain; struct glpoly_s *detail_chain; int numverts; float verts[4][9]; } *polys; struct msurface_s *texturechain; struct mtexinfo_s { float vecs[2][4]; struct texture_s { char name[16]; unsigned int width; int gl_texturenum; int fb_texturenum; struct msurface_s *texturechain[2]; struct msurface_s **texturechain_tail[2]; int anim_total; int anim_min; struct texture_s *anim_next; struct texture_s *alternate_anims; unsigned int offsets[4]; unsigned int flatcolor3ub; enum qbool { false=0, true=1 } loaded; int isLumaTexture; } *texture; int flags; } *texinfo; int dlightframe; int dlightbits; int lightmaptexturenum; unsigned char styles[4]; int cached_light[4]; enum qbool { false=0, true=1 } cached_dlight; unsigned char *samples; } **firstmarksurface; int nummarksurfaces; } *leafs; int numvertexes; struct mvertex_s { float position[3]; } *vertexes; int numedges; struct medge_s { unsigned short v[2]; unsigned int cachededgeoffset; } *edges; int numnodes; int firstnode; struct mnode_s *nodes; int numtexinfo; struct mtexinfo_s *texinfo; int numsurfaces; struct msurface_s *surfaces; int numsurfedges; int *surfedges; int nummarksurfaces; struct msurface_s **marksurfaces; int numtextures; struct texture_s **textures; unsigned char *visdata; unsigned char *lightdata; int bspversion; enum qbool { false=0, true=1 } isworldmodel; struct cache_user_s cache; } *

variable_types: struct aliashdr_s { int ident; int version; float scale[3]; float scale_origin[3]; float boundingradius; float eyeposition[3]; int numskins; int skinwidth; int skinheight; int numverts; int numtris; int numframes; enum synctype_t { ST_SYNC=0, ST_RAND=1 } synctype; int flags; float size; int numposes; int poseverts; int posedata; int commands; int gl_texturenum[32][4]; int fb_texturenum[32][4]; struct maliasframedesc_s { int firstpose; int numposes; float interval; float bboxmin[3]; float bboxmax[3]; float radius; int frame; char name[16]; } frames[1]; } *

variable_types: i int

variable_types:
cmds
int *

variable_types: struct trivertx_t { unsigned char v[3]; unsigned char lightnormalindex; } *

user_defined_types: struct model_s { char name[64]; enum qbool needload; unsigned short crc; int simpletexture[5]; enum modhint_t modhint; enum modtype_t type; int numframes; enum synctype_t synctype; int flags; float mins[3]; float radius; int firstmodelsurface; int numsubmodels; struct dmodel_t *submodels; int numplanes; struct mplane_s *planes; int numleafs; struct mleaf_s *leafs; int numvertexes; struct mvertex_s *vertexes; int numedges; struct medge_s *edges; int numnodes; int firstnode; struct mnode_s *nodes; int numtexinfo; struct mtexinfo_s *texinfo; int numsurfaces; struct msurface_s *surfaces; int numsurfedges; int *surfedges; int nummarksurfaces; struct msurface_s **marksurfaces; int numtextures; struct texture_s **textures; unsigned char *visdata; unsigned char *lightdata; int bspversion; enum qbool isworldmodel; struct cache_user_s cache; }

user_defined_types: struct aliashdr_s { int ident; int version; float scale[3]; float scale_origin[3]; float boundingradius; float eyeposition[3]; int numskins; int skinwidth; int skinheight; int numverts; int numtris; int numframes; enum synctype_t synctype; int flags; float size; int numposes; int poseverts; int posedata; int commands; int gl_texturenum[32][4]; int fb_texturenum[32][4]; struct maliasframedesc_s frames[1]; }

user_defined_types: struct mleaf_s { int contents; int visframe; float minmaxs[6]; struct mnode_s *parent; unsigned char *compressed_vis; struct efrag_s *efrags; struct msurface_s **firstmarksurface; int nummarksurfaces; }

user_defined_types: struct efrag_s { struct mleaf_s *leaf; struct efrag_s *leafnext; struct entity_s *entity; struct efrag_s *entnext; }

user_defined_types: struct msurface_s { int visframe; struct mplane_s *plane; int flags; int firstedge; int numedges; short texturemins[2]; short extents[2]; int light_s; struct glpoly_s *polys; struct msurface_s *texturechain; struct mtexinfo_s *texinfo; int dlightframe; int dlightbits; int lightmaptexturenum; unsigned char styles[4]; int cached_light[4]; enum qbool cached_dlight; unsigned char *samples; }

user_defined_types: struct entity_s { float origin[3]; float angles[3]; struct model_s *model; unsigned char *colormap; int skinnum; struct player_info_s *scoreboard; int renderfx; int effects; int oldframe; int frame; float framelerp; struct efrag_s *efrag; int visframe; int dlightframe; int dlightbits; float alpha; int trivial_accept; struct mnode_s *topnode; }

user_defined_types: struct mtexinfo_s { float vecs[2][4]; struct texture_s *texture; int flags; }

user_defined_types: struct player_info_s { int userid; char userinfo[1024]; char name[16]; float entertime; int frags; int ping; unsigned char pl; int topcolor; int bottomcolor; int _topcolor; int _bottomcolor; int real_topcolor; int real_bottomcolor; char team[1024]; char _team[1024]; int fps_msec; int last_fps; int fps; int fps_frames; double fps_measure_time; enum qbool isnear; int spectator; unsigned char translations[-1]; struct skin_t *skin; int stats[32]; enum qbool skin_refresh; enum qbool ignored; enum qbool validated; char f_server[16]; enum qbool dead; }

user_defined_types: struct texture_s { char name[16]; unsigned int width; int gl_texturenum; int fb_texturenum; struct msurface_s *texturechain[2]; struct msurface_s **texturechain_tail[2]; int anim_total; int anim_min; struct texture_s *anim_next; struct texture_s *alternate_anims; unsigned int offsets[4]; unsigned int flatcolor3ub; enum qbool loaded; int isLumaTexture; }

user_defined_types: struct skin_t { char name[16]; enum qbool failedload; enum qbool warned; int width; int bpp; int texnum; struct cache_user_s cache; }


GetFileLocalTime

decompiled_code:
__int64 __fastcall GetFileLocalTime(const char *a1, _DWORD *a2)
{
int v2; // er8
__int64 result; // rax
struct tm *v4; // rax
struct stat v5; // [rsp+0h] [rbp-98h] BYREF

v2 = stat(a1, &v5);
result = 0LL;
if ( !v2 )
{
v4 = localtime(&v5.st_mtim.tv_sec);
UnixtimeToWintime(a2, (unsigned int *)v4);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, _DWORD *a2)
{
int v2; // er8
__int64 result; // rax
struct tm *v4; // rax
struct stat v5; // [rsp+0h] [rbp-98h] BYREF

v2 = stat(a1, &v5);
result = 0LL;
if ( !v2 )
{
v4 = localtime(&v5.st_mtim.tv_sec);
func0(a2, (unsigned int *)v4);
result = 1LL;
}
return result;
}

original_code:
int GetFileLocalTime(char *path, SYSTEMTIME *wintime)
{
    struct stat statbuf;
    struct tm * lintime;
    if (stat(path, &statbuf) != 0)
        return 0;
    lintime = localtime(&statbuf.st_mtim.tv_sec);
    UnixtimeToWintime(wintime, lintime);
    return 1;
}

canonical_original_code:
int GetFileLocalTime(char *path, struct SYSTEMTIME_s *wintime)
{
    struct stat statbuf;
    struct tm *lintime;
    if (stat(path, &statbuf) != 0)
        return 0;
    lintime = localtime(&statbuf.st_mtim.tv_sec);
    UnixtimeToWintime(wintime, lintime);
    return 1;
}

variable_types:
path
char *

variable_types: struct SYSTEMTIME_s { int wYear; int wMonth; int wDay; int wDayOfWeek; int wHour; int wMinute; int wSecond; int wMilliseconds; } *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


SYSTEMTIMEcmp

original_code:
int SYSTEMTIMEcmp(const SYSTEMTIME *t1, const SYSTEMTIME *t2)
{
    return intcmp( t1->wSecond, t2->wSecond )
    + intcmp( t1->wMinute, t2->wMinute ) * 2
    + intcmp( t1->wHour, t2->wHour ) * 4
    + intcmp( t1->wDay, t2->wDay ) * 8
    + intcmp( t1->wMonth, t2->wMonth ) * 16
    + intcmp( t1->wYear, t2->wYear ) * 32;
}

canonical_original_code:
int SYSTEMTIMEcmp(struct SYSTEMTIME_s *t1, struct SYSTEMTIME_s *t2)
{
    return intcmp( t1->wSecond, t2->wSecond )
    + intcmp( t1->wMinute, t2->wMinute ) * 2
    + intcmp( t1->wHour, t2->wHour ) * 4
    + intcmp( t1->wDay, t2->wDay ) * 8
    + intcmp( t1->wMonth, t2->wMonth ) * 16
    + intcmp( t1->wYear, t2->wYear ) * 32;
}

user_defined_types: struct SYSTEMTIME_s { int wYear; int wMonth; int wDay; int wDayOfWeek; int wHour; int wMinute; int wSecond; int wMilliseconds; }


intcmp

decompiled_code:
__int64 __fastcall intcmp(int a1, int a2)
{
__int64 result; // rax

result = (unsigned int)-(a1 < a2);
if ( a1 > a2 )
result = 1LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2)
{
__int64 result; // rax

result = (unsigned int)-(a1 < a2);
if ( a1 > a2 )
result = 1LL;
return result;
}

original_code:
int intcmp(int i1, int i2)
{
    if (i1 > i2)
    return 1;
    if (i1 < i2)
    return -1;
    return 0;
}


decompiled_code:
void __fastcall XSD_Command_Init(_OWORD *a1)
{
*a1 = 0LL;
a1[1] = 0LL;
a1[2] = 0LL;
}

canonical_decompiled_code:
void __fastcall func2(_OWORD *a1)
{
*a1 = 0LL;
a1[1] = 0LL;
a1[2] = 0LL;
}

original_code:
static void XSD_Command_Init(xml_command_t *document)
{
    memset(document, 0, sizeof(xml_command_t));
}

canonical_original_code:
static void XSD_Command_Init(struct xml_command_s *document)
{
    memset(document, 0, sizeof(xml_command_t));
}

variable_types: struct xml_command_s { char *document_type; char *name; char *description; char *syntax; struct command_argument_s { char *name; char *description; struct command_argument_s *next; } *arguments; char *remarks; } *

user_defined_types: struct xml_command_s { char *document_type; char *name; char *description; char *syntax; struct command_argument_s *arguments; char *remarks; }


decompiled_code:
void __fastcall XSD_Command_Free(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi
_QWORD *i; // rbx
void *v7; // rdi

v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
{
free(v2);
*((_QWORD *)ptr + 1) = 0LL;
}
v3 = (void *)*((_QWORD *)ptr + 2);
if ( v3 )
{
free(v3);
*((_QWORD *)ptr + 2) = 0LL;
}
v4 = (void *)*((_QWORD *)ptr + 5);
if ( v4 )
{
free(v4);
*((_QWORD *)ptr + 5) = 0LL;
}
v5 = (void *)*((_QWORD *)ptr + 3);
if ( v5 )
{
free(v5);
*((_QWORD *)ptr + 3) = 0LL;
}
for ( i = (_QWORD *)*((_QWORD *)ptr + 4); i; *((_QWORD *)ptr + 4) = i )
{
v7 = i;
i = (_QWORD *)i[2];
free(v7);
}
if ( *(_QWORD *)ptr )
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi
_QWORD *i; // rbx
void *v7; // rdi

v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
{
free(v2);
*((_QWORD *)ptr + 1) = 0LL;
}
v3 = (void *)*((_QWORD *)ptr + 2);
if ( v3 )
{
free(v3);
*((_QWORD *)ptr + 2) = 0LL;
}
v4 = (void *)*((_QWORD *)ptr + 5);
if ( v4 )
{
free(v4);
*((_QWORD *)ptr + 5) = 0LL;
}
v5 = (void *)*((_QWORD *)ptr + 3);
if ( v5 )
{
free(v5);
*((_QWORD *)ptr + 3) = 0LL;
}
for ( i = (_QWORD *)*((_QWORD *)ptr + 4); i; *((_QWORD *)ptr + 4) = i )
{
v7 = i;
i = (_QWORD *)i[2];
free(v7);
}
if ( *(_QWORD *)ptr )
free(*(void **)ptr);
free(ptr);
}

original_code:
void XSD_Command_Free(xml_t *doc)
{
    xml_command_t *document = (xml_command_t *) doc;
    if (document->name)
        if(document->name) { free(document->name); document->name = ((void *)0); };
    if (document->description)
        if(document->description) { free(document->description); document->description = ((void *)0); };
    if (document->remarks)
        if(document->remarks) { free(document->remarks); document->remarks = ((void *)0); };
    if (document->syntax)
        if(document->syntax) { free(document->syntax); document->syntax = ((void *)0); };
    while (document->arguments)
    {
        command_argument_t *next = document->arguments->next;
        if(document->arguments) { free(document->arguments); document->arguments = ((void *)0); };
        document->arguments = next;
    }
    if (document->document_type)
        if(document->document_type) { free(document->document_type); document->document_type = ((void *)0); };
    if(document) { free(document); document = ((void *)0); };
}

canonical_original_code:
void XSD_Command_Free(struct xml_s *doc)
{
    struct xml_command_s *document = (xml_command_t *) doc;
    if (document->name)
        if(document->name) { free(document->name); document->name = ((void *)0); };
    if (document->description)
        if(document->description) { free(document->description); document->description = ((void *)0); };
    if (document->remarks)
        if(document->remarks) { free(document->remarks); document->remarks = ((void *)0); };
    if (document->syntax)
        if(document->syntax) { free(document->syntax); document->syntax = ((void *)0); };
    while (document->arguments)
    {
        struct command_argument_s *next = document->arguments->next;
        if(document->arguments) { free(document->arguments); document->arguments = ((void *)0); };
        document->arguments = next;
    }
    if (document->document_type)
        if(document->document_type) { free(document->document_type); document->document_type = ((void *)0); };
    if(document) { free(document); document = ((void *)0); };
}

variable_types:
doc
struct xml_s { char *document_type; } *

variable_types: struct command_argument_s { char *name; char *description; struct command_argument_s *next; } *


decompiled_code:
__int64 __fastcall EZ_window_Init(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10)
{
int v12; // ebp
unsigned int v13; // er14
__int64 v14; // rax
__int64 v15; // rbp
__int64 v16; // r12
__int64 v17; // rax
int v18; // edx
int v19; // esi
__int64 v20; // r12
__int64 v21; // rax
__int64 v22; // rdi
unsigned int v24; // [rsp+Ch] [rbp-3Ch]

EZ_control_Init(a1, a2, a3, a4);
v12 = *(_DWORD *)(a1 + 176) | a10;
*(_DWORD *)a1 = 6;
v13 = *(_DWORD *)(a1 + 164);
*(_DWORD *)(a1 + 176) = v12 | 0x64;
EZ_control_SetBackgroundImage(a1, "gfx/ui/ez_window");
EZ_control_SetBackgroundImageOpacity(a1, 1.0);
EZ_control_SetBackgroundImageEdgePercentage(a1, 20LL);
v14 = EZ_control_Create(a2, a1, "Window titlebar", 0LL, v13, v13, *(unsigned int *)(a1 + 56), 15LL, 3111LL);
*(_QWORD *)(a1 + 1128) = v14;
v15 = v14;
EZ_control_SetBackgroundImage(v14, "gfx/ui/ez_titlebar");
EZ_control_SetSize(v15, *(_DWORD *)(a1 + 56) - 2 * v13, 15LL);
EZ_control_SetAnchor(v15, 14LL);
EZ_control_SetDrawOrder(v15, (unsigned int)(*(_DWORD *)(a1 + 168) + 1), 1LL);
v16 = EZ_button_Create(a2, v15, "Close button", 0LL, 0LL, 0LL, 10LL, 10LL, 1LL);
*(_QWORD *)(a1 + 1136) = v16;
v24 = *(_DWORD *)(v15 + 60) - 4;
EZ_control_SetPosition(v16, 4294967294LL, 2LL);
EZ_control_SetSize(v16, v24, v24);
EZ_control_SetAnchor(v16, 12LL);
v17 = EZ_scrollpane_Create(a2, a1, "Window scrollpane", 0LL, v13, v13 + *(_DWORD *)(v15 + 60), 10LL, 10LL, 0LL);
v18 = *(_DWORD *)(a1 + 60);
v19 = *(_DWORD *)(a1 + 56);
v20 = v17;
*(_QWORD *)(a1 + 1112) = v17;
EZ_control_SetSize(v17, v19 - 2 * v13, v18 - (2 * v13 + *(_DWORD *)(v15 + 60)));
EZ_control_SetAnchor(v20, 30LL);
v21 = EZ_control_Create(a2, v20, "Window area", 0LL, 0LL, 0LL, 10LL, 10LL, 289LL);
v22 = *(_QWORD *)(a1 + 1112);
*(_QWORD *)(a1 + 1120) = v21;
EZ_scrollpane_SetTarget(v22, v21);
return EZ_control_SetDrawOrder(*(_QWORD *)(a1 + 1120), (unsigned int)(*(_DWORD *)(v20 + 168) + 1), 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10)
{
int v12; // ebp
unsigned int v13; // er14
__int64 v14; // rax
__int64 v15; // rbp
__int64 v16; // r12
__int64 v17; // rax
int v18; // edx
int v19; // esi
__int64 v20; // r12
__int64 v21; // rax
__int64 v22; // rdi
unsigned int v24; // [rsp+Ch] [rbp-3Ch]

EZ_control_Init(a1, a2, a3, a4);
v12 = *(_DWORD *)(a1 + 176) | a10;
*(_DWORD *)a1 = 6;
v13 = *(_DWORD *)(a1 + 164);
*(_DWORD *)(a1 + 176) = v12 | 0x64;
EZ_control_SetBackgroundImage(a1, "gfx/ui/ez_window");
EZ_control_SetBackgroundImageOpacity(a1, 1.0);
EZ_control_SetBackgroundImageEdgePercentage(a1, 20LL);
v14 = EZ_control_Create(a2, a1, "Window titlebar", 0LL, v13, v13, *(unsigned int *)(a1 + 56), 15LL, 3111LL);
*(_QWORD *)(a1 + 1128) = v14;
v15 = v14;
EZ_control_SetBackgroundImage(v14, "gfx/ui/ez_titlebar");
EZ_control_SetSize(v15, *(_DWORD *)(a1 + 56) - 2 * v13, 15LL);
EZ_control_SetAnchor(v15, 14LL);
EZ_control_SetDrawOrder(v15, (unsigned int)(*(_DWORD *)(a1 + 168) + 1), 1LL);
v16 = EZ_button_Create(a2, v15, "Close button", 0LL, 0LL, 0LL, 10LL, 10LL, 1LL);
*(_QWORD *)(a1 + 1136) = v16;
v24 = *(_DWORD *)(v15 + 60) - 4;
EZ_control_SetPosition(v16, 4294967294LL, 2LL);
EZ_control_SetSize(v16, v24, v24);
EZ_control_SetAnchor(v16, 12LL);
v17 = EZ_scrollpane_Create(a2, a1, "Window scrollpane", 0LL, v13, v13 + *(_DWORD *)(v15 + 60), 10LL, 10LL, 0LL);
v18 = *(_DWORD *)(a1 + 60);
v19 = *(_DWORD *)(a1 + 56);
v20 = v17;
*(_QWORD *)(a1 + 1112) = v17;
EZ_control_SetSize(v17, v19 - 2 * v13, v18 - (2 * v13 + *(_DWORD *)(v15 + 60)));
EZ_control_SetAnchor(v20, 30LL);
v21 = EZ_control_Create(a2, v20, "Window area", 0LL, 0LL, 0LL, 10LL, 10LL, 289LL);
v22 = *(_QWORD *)(a1 + 1112);
*(_QWORD *)(a1 + 1120) = v21;
EZ_scrollpane_SetTarget(v22, v21);
return EZ_control_SetDrawOrder(*(_QWORD *)(a1 + 1120), (unsigned int)(*(_DWORD *)(v20 + 168) + 1), 1LL);
}

original_code:
void EZ_window_Init(ez_window_t *window, ez_tree_t *tree, ez_control_t *parent,
         char *name, char *description,
         int x, int y, int width, int height,
         ez_control_flags_t flags)
{
 ez_control_t *window_ctrl = (ez_control_t *)window;
 ez_control_t *titlebar_ctrl = ((void *)0);
 ez_control_t *scrollpane_ctrl = ((void *)0);
 int rh_size = 0;
 EZ_control_Init(&window->super, tree, parent, name, description, x, y, width, height, flags);
 ((ez_control_t *)window)->CLASS_ID = EZ_WINDOW_ID;
 ((ez_control_t *)window)->ext_flags |= (flags | control_focusable | control_contained | control_resizeable);
 rh_size = window_ctrl->resize_handle_thickness;
 EZ_control_SetBackgroundImage(window_ctrl, "gfx/ui/ez_window");
 EZ_control_SetBackgroundImageOpacity(window_ctrl, 1.0);
 EZ_control_SetBackgroundImageEdgePercentage(window_ctrl, 20);
 {
  window->titlebar = EZ_control_Create(tree, window_ctrl, "Window titlebar", ((void *)0), rh_size, rh_size, window_ctrl->width, 15,
   (control_focusable | control_move_parent | control_movable | control_resizeable | control_enabled | control_anchor_viewport));
  titlebar_ctrl = (ez_control_t *)window->titlebar;
  EZ_control_SetBackgroundImage(titlebar_ctrl, "gfx/ui/ez_titlebar");
  EZ_control_SetSize(titlebar_ctrl, (window_ctrl->width - (2 * rh_size)), 15);
  EZ_control_SetAnchor(titlebar_ctrl, (anchor_left | anchor_top | anchor_right));
  EZ_control_SetDrawOrder(titlebar_ctrl, window_ctrl->draw_order + 1, true);
  {
   int cb_sidelength = 0;
   ez_control_t *close_ctrl = ((void *)0);
   window->close_button = EZ_button_Create(tree, titlebar_ctrl, "Close button", ((void *)0),
             0, 0, 10, 10, control_enabled);
   close_ctrl = (ez_control_t *)window->close_button;
   cb_sidelength = (titlebar_ctrl->height - (2 * 2));
   EZ_control_SetPosition(close_ctrl, -2, 2);
   EZ_control_SetSize(close_ctrl, cb_sidelength, cb_sidelength);
   EZ_control_SetAnchor(close_ctrl, (anchor_top | anchor_right));
  }
 }
 {
  window->scrollpane = EZ_scrollpane_Create(tree, window_ctrl, "Window scrollpane", ((void *)0), rh_size, (rh_size + titlebar_ctrl->height), 10, 10, 0);
  scrollpane_ctrl = (ez_control_t *)window->scrollpane;
  EZ_control_SetSize(scrollpane_ctrl,
   (window_ctrl->width - (2 * rh_size)),
   (window_ctrl->height - (titlebar_ctrl->height + (2 * rh_size))));
  EZ_control_SetAnchor(scrollpane_ctrl, (anchor_left | anchor_right | anchor_bottom | anchor_top));
  {
   window->window_area = EZ_control_Create(tree, scrollpane_ctrl, "Window area", ((void *)0), 0, 0, 10, 10, (control_scrollable | control_enabled | control_resizeable));
   EZ_scrollpane_SetTarget(window->scrollpane, window->window_area);
   EZ_control_SetDrawOrder(window->window_area, scrollpane_ctrl->draw_order + 1, true);
  }
 }
}

canonical_original_code:
void EZ_window_Init(struct ez_window_s *window, struct ez_tree_s *tree, struct ez_control_s *parent, char *name, char *description, int x, int y, int width, int height, enum ez_control_flags_e flags)
{
 struct ez_control_s *window_ctrl = (ez_control_t *)window;
 struct ez_control_s *titlebar_ctrl = ((void *)0);
 struct ez_control_s *scrollpane_ctrl = ((void *)0);
 int rh_size = 0;
 EZ_control_Init(&window->super, tree, parent, name, description, x, y, width, height, flags);
 ((struct ez_control_s *)window)->CLASS_ID = EZ_WINDOW_ID;
 ((struct ez_control_s *)window)->ext_flags |= (flags | control_focusable | control_contained | control_resizeable);
 rh_size = window_ctrl->resize_handle_thickness;
 EZ_control_SetBackgroundImage(window_ctrl, "gfx/ui/ez_window");
 EZ_control_SetBackgroundImageOpacity(window_ctrl, 1.0);
 EZ_control_SetBackgroundImageEdgePercentage(window_ctrl, 20);
 {
  window->titlebar = EZ_control_Create(tree, window_ctrl, "Window titlebar", ((void *)0), rh_size, rh_size, window_ctrl->width, 15,
   (control_focusable | control_move_parent | control_movable | control_resizeable | control_enabled | control_anchor_viewport));
  titlebar_ctrl = (struct ez_control_s *)window->titlebar;
  EZ_control_SetBackgroundImage(titlebar_ctrl, "gfx/ui/ez_titlebar");
  EZ_control_SetSize(titlebar_ctrl, (window_ctrl->width - (2 * rh_size)), 15);
  EZ_control_SetAnchor(titlebar_ctrl, (anchor_left | anchor_top | anchor_right));
  EZ_control_SetDrawOrder(titlebar_ctrl, window_ctrl->draw_order + 1, true);
  {
   int cb_sidelength = 0;
   struct ez_control_s *close_ctrl = ((void *)0);
   window->close_button = EZ_button_Create(tree, titlebar_ctrl, "Close button", ((void *)0),
             0, 0, 10, 10, control_enabled);
   close_ctrl = (struct ez_control_s *)window->close_button;
   cb_sidelength = (titlebar_ctrl->height - (2 * 2));
   EZ_control_SetPosition(close_ctrl, -2, 2);
   EZ_control_SetSize(close_ctrl, cb_sidelength, cb_sidelength);
   EZ_control_SetAnchor(close_ctrl, (anchor_top | anchor_right));
  }
 }
 {
  window->scrollpane = EZ_scrollpane_Create(tree, window_ctrl, "Window scrollpane", ((void *)0), rh_size, (rh_size + titlebar_ctrl->height), 10, 10, 0);
  scrollpane_ctrl = (struct ez_control_s *)window->scrollpane;
  EZ_control_SetSize(scrollpane_ctrl,
   (window_ctrl->width - (2 * rh_size)),
   (window_ctrl->height - (titlebar_ctrl->height + (2 * rh_size))));
  EZ_control_SetAnchor(scrollpane_ctrl, (anchor_left | anchor_right | anchor_bottom | anchor_top));
  {
   window->window_area = EZ_control_Create(tree, scrollpane_ctrl, "Window area", ((void *)0), 0, 0, 10, 10, (control_scrollable | control_enabled | control_resizeable));
   EZ_scrollpane_SetTarget(window->scrollpane, window->window_area);
   EZ_control_SetDrawOrder(window->window_area, scrollpane_ctrl->draw_order + 1, true);
  }
 }
}

variable_types: struct ez_window_s { struct ez_control_s { enum ez_control_id_e { EZ_CONTROL_ID=0, EZ_BUTTON_ID=1, EZ_LABEL_ID=2, EZ_SLIDER_ID=3, EZ_SCROLLBAR_ID=4, EZ_SCROLLPANE_ID=5, EZ_WINDOW_ID=6, EZ_LISTVIEW_ID=7, EZ_LISTVIEWITEM_ID=8 } CLASS_ID; char *name; char *description; int x; int y; int prev_x; int prev_y; int absolute_x; int absolute_y; int prev_absolute_x; int prev_absolute_y; int width; int height; int prev_width; int prev_height; int virtual_x; int virtual_y; int absolute_virtual_x; int absolute_virtual_y; int virtual_width; int virtual_height; int prev_virtual_width; int prev_virtual_height; int virtual_width_min; int virtual_height_min; int width_max; int width_min; int height_max; int height_min; int bound_top; int bound_left; int bound_right; int bound_bottom; int left_edge_gap; int right_edge_gap; int top_edge_gap; int bottom_edge_gap; enum ez_anchor_e { anchor_none=expr, anchor_left=expr, anchor_right=expr, anchor_top=expr, anchor_bottom=expr } anchor_flags; int resize_handle_thickness; int draw_order; int tab_order; enum ez_control_flags_e { control_enabled=expr, control_movable=expr, control_focusable=expr, control_resize_h=expr, control_resize_v=expr, control_resizeable=expr, control_contained=expr, control_visible=expr, control_scrollable=expr, control_ignore_mouse=expr, control_anchor_viewport=expr, control_move_parent=expr, control_listen_repeat_mouse=expr, control_bg_tile_center=expr, control_bg_tile_edges=expr } ext_flags; enum ez_control_iflags_e { control_focused=expr, control_moving=expr, control_resizing_left=expr, control_resizing_right=expr, control_resizing_top=expr, control_resizing_bottom=expr, control_clicked=expr, control_mouse_over=expr, control_update_anchorgap=expr, control_hidden_by_parent=expr } int_flags; unsigned char background_color[4]; struct mpic_t { int width; int texnum; float sl; } *background; float bg_edge_size_ratio; float bg_opacity; float opacity; float overall_opacity; float x_percent; float y_percent; void *payload; struct ez_control_events_s { int (*OnMouseEvent)(struct ez_control_s *self, struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool { false=0, true=1 } buttons[9]; int button_down; int button_up; } *mouse_state); int (*OnMouseClick)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUp)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUpOutside)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseDown)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseHover)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseEnter)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseLeave)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnKeyEvent)(struct ez_control_s *self, int key, int unichar, enum qbool { false=0, true=1 } down); int (*OnKeyDown)(struct ez_control_s *self, int key, int unichar); int (*OnKeyUp)(struct ez_control_s *self, int key, int unichar); int (*OnLayoutChildren)(struct ez_control_s *self, void *ext_event_info); int (*OnDraw)(struct ez_control_s *self, void *ext_event_info); int (*OnDestroy)(struct ez_control_s *self, enum qbool { false=0, true=1 } destroy_children); int (*OnMove)(struct ez_control_s *self, void *ext_event_info); int (*OnScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnParentScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnResize)(struct ez_control_s *self, void *ext_event_info); int (*OnParentResize)(struct ez_control_s *self, void *ext_event_info); int (*OnGotFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnLostFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnMinVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnFlagsChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnResizeHandleThicknessChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnEventHandlerChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnAnchorChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnVisibilityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnOpacityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnChildMoved)(struct ez_control_s *self, struct ez_control_s *child); int (*OnChildResize)(struct ez_control_s *self, struct ez_control_s *child); } events; struct ez_control_eventhandlers_s { struct ez_eventhandler_s { int function_type; union ez_eventhandlerfunction_u { int (*normal)(struct ez_control_s *self, void *payload, void *ext_info); int (*mouse)(struct ez_control_s *self, void *payload, struct mouse_state_s *mouse_state); int (*key)(struct ez_control_s *self, void *payload, int key, int unichar, enum qbool { false=0, true=1 } down); int (*key_sp)(struct ez_control_s *self, void *payload, int key, int unichar); int (*destroy)(struct ez_control_s *self, void *payload, enum qbool { false=0, true=1 } destroy_children); int (*child)(struct ez_control_s *self, void *payload, struct ez_control_s *child); } function; void *payload; struct ez_eventhandler_s *next; } *OnMouseEvent; struct ez_eventhandler_s *OnMouseClick; struct ez_eventhandler_s *OnMouseUp; struct ez_eventhandler_s *OnMouseUpOutside; struct ez_eventhandler_s *OnMouseDown; struct ez_eventhandler_s *OnMouseHover; struct ez_eventhandler_s *OnMouseEnter; struct ez_eventhandler_s *OnMouseLeave; struct ez_eventhandler_s *OnKeyEvent; struct ez_eventhandler_s *OnKeyDown; struct ez_eventhandler_s *OnKeyUp; struct ez_eventhandler_s *OnLayoutChildren; struct ez_eventhandler_s *OnDraw; struct ez_eventhandler_s *OnDestroy; struct ez_eventhandler_s *OnMove; struct ez_eventhandler_s *OnScroll; struct ez_eventhandler_s *OnParentScroll; struct ez_eventhandler_s *OnResize; struct ez_eventhandler_s *OnParentResize; struct ez_eventhandler_s *OnGotFocus; struct ez_eventhandler_s *OnLostFocus; struct ez_eventhandler_s *OnVirtualResize; struct ez_eventhandler_s *OnMinVirtualResize; struct ez_eventhandler_s *OnFlagsChanged; struct ez_eventhandler_s *OnResizeHandleThicknessChanged; struct ez_eventhandler_s *OnEventHandlerChanged; struct ez_eventhandler_s *OnAnchorChanged; struct ez_eventhandler_s *OnVisibilityChanged; struct ez_eventhandler_s *OnOpacityChanged; struct ez_eventhandler_s *OnChildMoved; struct ez_eventhandler_s *OnChildResize; } event_handlers; struct ez_control_eventcount_s { int OnMouseEvent; int OnMouseClick; int OnMouseUp; int OnMouseUpOutside; int OnMouseDown; int OnMouseHover; int OnMouseEnter; int OnMouseLeave; int OnKeyEvent; int OnKeyDown; int OnKeyUp; int OnLayoutChildren; int OnDraw; int OnDestroy; int OnMove; int OnScroll; int OnParentScroll; int OnResize; int OnParentResize; int OnGotFocus; int OnLostFocus; int OnVirtualResize; int OnMinVirtualResize; int OnFlagsChanged; int OnResizeHandleThicknessChanged; int OnEventHandlerChanged; int OnAnchorChanged; int OnVisibilityChanged; int OnOpacityChanged; int OnChildMoved; int OnChildResize; } inherit_levels; struct ez_control_eventcount_s override_counts; enum qbool { false=0, true=1 } initializing; struct ez_control_s *parent; struct ez_double_linked_list_s { int count; struct ez_dllist_node_s { struct ez_dllist_node_s *next; struct ez_dllist_node_s *previous; void *payload; } *head; struct ez_dllist_node_s *tail; } children; struct ez_tree_s { struct ez_control_s *root; enum qbool { false=0, true=1 } destroying; struct ez_dllist_node_s *focused_node; struct ez_double_linked_list_s drawlist; struct ez_double_linked_list_s tablist; struct mouse_state_s prev_mouse_state; double mouse_pressed_time[9]; } *control_tree; struct mouse_state_s prev_mouse_state; double mouse_repeat_delay; } super; struct ez_scrollpane_s { struct ez_control_s super; struct ez_scrollpane_events_s { int (*OnTargetChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnTargetResize)(struct ez_control_s *self, void *ext_event_info); int (*OnTargetScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnScrollbarThicknessChanged)(struct ez_control_s *self, void *ext_event_info); } events; struct ez_scrollpane_eventhandlers_s { struct ez_eventhandler_s *OnTargetChanged; struct ez_eventhandler_s *OnTargetResize; struct ez_eventhandler_s *OnTargetScroll; struct ez_eventhandler_s *OnScrollbarThicknessChanged; } event_handlers; struct ez_scrollpane_eventcount_s { int OnTargetChanged; int OnScrollbarThicknessChanged; } inherit_levels; struct ez_scrollpane_eventcount_s override_counts; struct ez_control_s *target; struct ez_control_s *prev_target; struct ez_scrollbar_s { struct ez_control_s super; struct ez_scrollbar_events_s { int (*OnTargetChanged)(struct ez_control_s *self, void *ext_event_info); } events; struct ez_scrollbar_eventhandlers_s { struct ez_eventhandler_s *OnTargetChanged; } event_handlers; struct ez_scrollbar_eventcount_s { int OnTargetChanged; } inherit_levels; struct ez_scrollbar_eventcount_s override_counts; struct ez_button_s { struct ez_control_s super; struct ez_button_events_s { int (*OnAction)(struct ez_control_s *self, void *ext_event_info); int (*OnTextAlignmentChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnToggled)(struct ez_control_s *self, void *ext_event_info); } events; struct ez_button_eventhandlers_s { struct ez_eventhandler_s *OnAction; struct ez_eventhandler_s *OnTextAlignmentChanged; struct ez_eventhandler_s *OnToggled; } event_handlers; struct ez_button_eventcount_s { int OnAction; int OnTextAlignmentChanged; int OnToggled; } inherit_levels; struct ez_button_eventcount_s override_counts; struct ez_label_s { struct ez_control_s super; struct ez_label_events_s { int (*OnTextChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnCaretMoved)(struct ez_control_s *self, void *ext_event_info); int (*OnTextScaleChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnTextFlagsChanged)(struct ez_control_s *self, void *ext_event_info); } events; struct ez_label_eventhandlers_s { struct ez_eventhandler_s *OnTextChanged; struct ez_eventhandler_s *OnCaretMoved; struct ez_eventhandler_s *OnTextScaleChanged; struct ez_eventhandler_s *OnTextFlagsChanged; } event_handlers; struct ez_label_eventcount_s { int OnTextChanged; int OnCaretMoved; int OnTextScaleChanged; int OnTextFlagsChanged; } inherit_levels; struct ez_label_eventcount_s override_counts; char *text; int text_length; enum ez_label_flags_e { label_largefont=expr, label_autosize=expr, label_autoellipsis=expr, label_wraptext=expr, label_selectable=expr, label_readonly=expr } ext_flags; enum ez_label_iflags_e { label_selecting=expr } int_flags; struct ez_label_textpos_s { int index; int row; int col; } wordwraps[512]; struct clrinfo_s { int c; int i; } color; float scale; int scaled_char_size; int select_start; int select_end; struct ez_label_textpos_s caret_pos; int num_rows; int num_cols; } *text_label; struct mpic_t *focused_image; struct mpic_t *normal_image; struct mpic_t *hover_image; struct mpic_t *pressed_image; struct mpic_t *toggled_hover_image; unsigned char color_focused[4]; unsigned char color_normal[4]; unsigned char color_hover[4]; unsigned char color_pressed[4]; unsigned char color_toggled_hover[4]; enum ez_button_iflags_e { button_toggled=expr } int_flags; enum ez_button_flags_e { button_use_images=expr, button_is_toggleable=expr } ext_flags; int padding_top; int padding_left; int padding_right; int padding_bottom; enum ez_textalign_e { top_left=0, top_center=1, top_right=2, middle_left=3, middle_center=4, middle_right=5, bottom_left=6, bottom_center=7, bottom_right=8 } text_alignment; struct clrinfo_s focused_text_color; struct clrinfo_s normal_text_color; struct clrinfo_s hover_text_color; struct clrinfo_s pressed_text_color; int override_count; int inheritance_level; } *back; struct ez_button_s *slider; struct ez_button_s *forward; enum ez_orientation_s { vertical=0, horizontal=1 } orientation; int scroll_area; int slider_minsize; int scroll_delta_x; int scroll_delta_y; struct ez_control_s *target; enum ez_scrollbar_flags_e { target_parent=expr } ext_flags; enum ez_scrollbar_iflags_e { sliding=expr, scrolling=expr } int_flags; } *v_scrollbar; struct ez_scrollbar_s *h_scrollbar; int scrollbar_thickness; enum ez_scrollpane_flags_e { always_v_scrollbar=expr, always_h_scrollbar=expr } ext_flags; enum ez_scrollpane_iflags_e { show_v_scrollbar=expr, show_h_scrollbar=expr, resizing_target=expr } int_flags; } *scrollpane; struct ez_control_s *window_area; struct ez_control_s *titlebar; struct ez_button_s *close_button; } *

variable_types:
tree
struct ez_tree_s *

variable_types:
parent
struct ez_control_s *

variable_types:
name
char *

variable_types:
description
char *

variable_types: x int

variable_types: y int

variable_types: width int

variable_types: height int

variable_types: struct ez_control_s { enum ez_control_id_e { EZ_CONTROL_ID=0, EZ_BUTTON_ID=1, EZ_LABEL_ID=2, EZ_SLIDER_ID=3, EZ_SCROLLBAR_ID=4, EZ_SCROLLPANE_ID=5, EZ_WINDOW_ID=6, EZ_LISTVIEW_ID=7, EZ_LISTVIEWITEM_ID=8 } CLASS_ID; char *name; char *description; int x; int y; int prev_x; int prev_y; int absolute_x; int absolute_y; int prev_absolute_x; int prev_absolute_y; int width; int height; int prev_width; int prev_height; int virtual_x; int virtual_y; int absolute_virtual_x; int absolute_virtual_y; int virtual_width; int virtual_height; int prev_virtual_width; int prev_virtual_height; int virtual_width_min; int virtual_height_min; int width_max; int width_min; int height_max; int height_min; int bound_top; int bound_left; int bound_right; int bound_bottom; int left_edge_gap; int right_edge_gap; int top_edge_gap; int bottom_edge_gap; enum ez_anchor_e { anchor_none=expr, anchor_left=expr, anchor_right=expr, anchor_top=expr, anchor_bottom=expr } anchor_flags; int resize_handle_thickness; int draw_order; int tab_order; enum ez_control_flags_e { control_enabled=expr, control_movable=expr, control_focusable=expr, control_resize_h=expr, control_resize_v=expr, control_resizeable=expr, control_contained=expr, control_visible=expr, control_scrollable=expr, control_ignore_mouse=expr, control_anchor_viewport=expr, control_move_parent=expr, control_listen_repeat_mouse=expr, control_bg_tile_center=expr, control_bg_tile_edges=expr } ext_flags; enum ez_control_iflags_e { control_focused=expr, control_moving=expr, control_resizing_left=expr, control_resizing_right=expr, control_resizing_top=expr, control_resizing_bottom=expr, control_clicked=expr, control_mouse_over=expr, control_update_anchorgap=expr, control_hidden_by_parent=expr } int_flags; unsigned char background_color[4]; struct mpic_t { int width; int texnum; float sl; } *background; float bg_edge_size_ratio; float bg_opacity; float opacity; float overall_opacity; float x_percent; float y_percent; void *payload; struct ez_control_events_s { int (*OnMouseEvent)(struct ez_control_s *self, struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool { false=0, true=1 } buttons[9]; int button_down; int button_up; } *mouse_state); int (*OnMouseClick)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUp)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUpOutside)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseDown)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseHover)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseEnter)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseLeave)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnKeyEvent)(struct ez_control_s *self, int key, int unichar, enum qbool { false=0, true=1 } down); int (*OnKeyDown)(struct ez_control_s *self, int key, int unichar); int (*OnKeyUp)(struct ez_control_s *self, int key, int unichar); int (*OnLayoutChildren)(struct ez_control_s *self, void *ext_event_info); int (*OnDraw)(struct ez_control_s *self, void *ext_event_info); int (*OnDestroy)(struct ez_control_s *self, enum qbool { false=0, true=1 } destroy_children); int (*OnMove)(struct ez_control_s *self, void *ext_event_info); int (*OnScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnParentScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnResize)(struct ez_control_s *self, void *ext_event_info); int (*OnParentResize)(struct ez_control_s *self, void *ext_event_info); int (*OnGotFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnLostFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnMinVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnFlagsChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnResizeHandleThicknessChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnEventHandlerChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnAnchorChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnVisibilityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnOpacityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnChildMoved)(struct ez_control_s *self, struct ez_control_s *child); int (*OnChildResize)(struct ez_control_s *self, struct ez_control_s *child); } events; struct ez_control_eventhandlers_s { struct ez_eventhandler_s { int function_type; union ez_eventhandlerfunction_u { int (*normal)(struct ez_control_s *self, void *payload, void *ext_info); int (*mouse)(struct ez_control_s *self, void *payload, struct mouse_state_s *mouse_state); int (*key)(struct ez_control_s *self, void *payload, int key, int unichar, enum qbool { false=0, true=1 } down); int (*key_sp)(struct ez_control_s *self, void *payload, int key, int unichar); int (*destroy)(struct ez_control_s *self, void *payload, enum qbool { false=0, true=1 } destroy_children); int (*child)(struct ez_control_s *self, void *payload, struct ez_control_s *child); } function; void *payload; struct ez_eventhandler_s *next; } *OnMouseEvent; struct ez_eventhandler_s *OnMouseClick; struct ez_eventhandler_s *OnMouseUp; struct ez_eventhandler_s *OnMouseUpOutside; struct ez_eventhandler_s *OnMouseDown; struct ez_eventhandler_s *OnMouseHover; struct ez_eventhandler_s *OnMouseEnter; struct ez_eventhandler_s *OnMouseLeave; struct ez_eventhandler_s *OnKeyEvent; struct ez_eventhandler_s *OnKeyDown; struct ez_eventhandler_s *OnKeyUp; struct ez_eventhandler_s *OnLayoutChildren; struct ez_eventhandler_s *OnDraw; struct ez_eventhandler_s *OnDestroy; struct ez_eventhandler_s *OnMove; struct ez_eventhandler_s *OnScroll; struct ez_eventhandler_s *OnParentScroll; struct ez_eventhandler_s *OnResize; struct ez_eventhandler_s *OnParentResize; struct ez_eventhandler_s *OnGotFocus; struct ez_eventhandler_s *OnLostFocus; struct ez_eventhandler_s *OnVirtualResize; struct ez_eventhandler_s *OnMinVirtualResize; struct ez_eventhandler_s *OnFlagsChanged; struct ez_eventhandler_s *OnResizeHandleThicknessChanged; struct ez_eventhandler_s *OnEventHandlerChanged; struct ez_eventhandler_s *OnAnchorChanged; struct ez_eventhandler_s *OnVisibilityChanged; struct ez_eventhandler_s *OnOpacityChanged; struct ez_eventhandler_s *OnChildMoved; struct ez_eventhandler_s *OnChildResize; } event_handlers; struct ez_control_eventcount_s { int OnMouseEvent; int OnMouseClick; int OnMouseUp; int OnMouseUpOutside; int OnMouseDown; int OnMouseHover; int OnMouseEnter; int OnMouseLeave; int OnKeyEvent; int OnKeyDown; int OnKeyUp; int OnLayoutChildren; int OnDraw; int OnDestroy; int OnMove; int OnScroll; int OnParentScroll; int OnResize; int OnParentResize; int OnGotFocus; int OnLostFocus; int OnVirtualResize; int OnMinVirtualResize; int OnFlagsChanged; int OnResizeHandleThicknessChanged; int OnEventHandlerChanged; int OnAnchorChanged; int OnVisibilityChanged; int OnOpacityChanged; int OnChildMoved; int OnChildResize; } inherit_levels; struct ez_control_eventcount_s override_counts; enum qbool { false=0, true=1 } initializing; struct ez_control_s *parent; struct ez_double_linked_list_s { int count; struct ez_dllist_node_s { struct ez_dllist_node_s *next; struct ez_dllist_node_s *previous; void *payload; } *head; struct ez_dllist_node_s *tail; } children; struct ez_tree_s { struct ez_control_s *root; enum qbool { false=0, true=1 } destroying; struct ez_dllist_node_s *focused_node; struct ez_double_linked_list_s drawlist; struct ez_double_linked_list_s tablist; struct mouse_state_s prev_mouse_state; double mouse_pressed_time[9]; } *control_tree; struct mouse_state_s prev_mouse_state; double mouse_repeat_delay; } *

user_defined_types: struct ez_window_s { struct ez_control_s super; struct ez_scrollpane_s *scrollpane; struct ez_control_s *window_area; struct ez_control_s *titlebar; struct ez_button_s *close_button; }

user_defined_types: struct ez_control_s { enum ez_control_id_e CLASS_ID; char *name; char *description; int x; int y; int prev_x; int prev_y; int absolute_x; int absolute_y; int prev_absolute_x; int prev_absolute_y; int width; int height; int prev_width; int prev_height; int virtual_x; int virtual_y; int absolute_virtual_x; int absolute_virtual_y; int virtual_width; int virtual_height; int prev_virtual_width; int prev_virtual_height; int virtual_width_min; int virtual_height_min; int width_max; int width_min; int height_max; int height_min; int bound_top; int bound_left; int bound_right; int bound_bottom; int left_edge_gap; int right_edge_gap; int top_edge_gap; int bottom_edge_gap; enum ez_anchor_e anchor_flags; int resize_handle_thickness; int draw_order; int tab_order; enum ez_control_flags_e ext_flags; enum ez_control_iflags_e int_flags; unsigned char background_color[4]; struct mpic_t *background; float bg_edge_size_ratio; float bg_opacity; float opacity; float overall_opacity; float x_percent; float y_percent; void *payload; struct ez_control_events_s events; struct ez_control_eventhandlers_s event_handlers; struct ez_control_eventcount_s inherit_levels; struct ez_control_eventcount_s override_counts; enum qbool initializing; struct ez_control_s *parent; struct ez_double_linked_list_s children; struct ez_tree_s *control_tree; struct mouse_state_s prev_mouse_state; double mouse_repeat_delay; }

user_defined_types: struct ez_control_events_s { int (*OnMouseEvent)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseClick)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUp)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseUpOutside)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseDown)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseHover)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseEnter)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnMouseLeave)(struct ez_control_s *self, struct mouse_state_s *mouse_state); int (*OnKeyEvent)(struct ez_control_s *self, int key, int unichar, enum qbool down); int (*OnKeyDown)(struct ez_control_s *self, int key, int unichar); int (*OnKeyUp)(struct ez_control_s *self, int key, int unichar); int (*OnLayoutChildren)(struct ez_control_s *self, void *ext_event_info); int (*OnDraw)(struct ez_control_s *self, void *ext_event_info); int (*OnDestroy)(struct ez_control_s *self, enum qbool destroy_children); int (*OnMove)(struct ez_control_s *self, void *ext_event_info); int (*OnScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnParentScroll)(struct ez_control_s *self, void *ext_event_info); int (*OnResize)(struct ez_control_s *self, void *ext_event_info); int (*OnParentResize)(struct ez_control_s *self, void *ext_event_info); int (*OnGotFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnLostFocus)(struct ez_control_s *self, void *ext_event_info); int (*OnVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnMinVirtualResize)(struct ez_control_s *self, void *ext_event_info); int (*OnFlagsChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnResizeHandleThicknessChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnEventHandlerChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnAnchorChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnVisibilityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnOpacityChanged)(struct ez_control_s *self, void *ext_event_info); int (*OnChildMoved)(struct ez_control_s *self, struct ez_control_s *child); int (*OnChildResize)(struct ez_control_s *self, struct ez_control_s *child); }

user_defined_types: struct ez_control_eventhandlers_s { struct ez_eventhandler_s *OnMouseEvent; struct ez_eventhandler_s *OnMouseClick; struct ez_eventhandler_s *OnMouseUp; struct ez_eventhandler_s *OnMouseUpOutside; struct ez_eventhandler_s *OnMouseDown; struct ez_eventhandler_s *OnMouseHover; struct ez_eventhandler_s *OnMouseEnter; struct ez_eventhandler_s *OnMouseLeave; struct ez_eventhandler_s *OnKeyEvent; struct ez_eventhandler_s *OnKeyDown; struct ez_eventhandler_s *OnKeyUp; struct ez_eventhandler_s *OnLayoutChildren; struct ez_eventhandler_s *OnDraw; struct ez_eventhandler_s *OnDestroy; struct ez_eventhandler_s *OnMove; struct ez_eventhandler_s *OnScroll; struct ez_eventhandler_s *OnParentScroll; struct ez_eventhandler_s *OnResize; struct ez_eventhandler_s *OnParentResize; struct ez_eventhandler_s *OnGotFocus; struct ez_eventhandler_s *OnLostFocus; struct ez_eventhandler_s *OnVirtualResize; struct ez_eventhandler_s *OnMinVirtualResize; struct ez_eventhandler_s *OnFlagsChanged; struct ez_eventhandler_s *OnResizeHandleThicknessChanged; struct ez_eventhandler_s *OnEventHandlerChanged; struct ez_eventhandler_s *OnAnchorChanged; struct ez_eventhandler_s *OnVisibilityChanged; struct ez_eventhandler_s *OnOpacityChanged; struct ez_eventhandler_s *OnChildMoved; struct ez_eventhandler_s *OnChildResize; }

user_defined_types: struct ez_double_linked_list_s { int count; struct ez_dllist_node_s *head; struct ez_dllist_node_s *tail; }

user_defined_types: struct ez_scrollpane_s { struct ez_control_s super; struct ez_scrollpane_events_s events; struct ez_scrollpane_eventhandlers_s event_handlers; struct ez_scrollpane_eventcount_s inherit_levels; struct ez_scrollpane_eventcount_s override_counts; struct ez_control_s *target; struct ez_control_s *prev_target; struct ez_scrollbar_s *v_scrollbar; struct ez_scrollbar_s *h_scrollbar; int scrollbar_thickness; enum ez_scrollpane_flags_e ext_flags; enum ez_scrollpane_iflags_e int_flags; }

user_defined_types: struct ez_tree_s { struct ez_control_s *root; enum qbool destroying; struct ez_dllist_node_s *focused_node; struct ez_double_linked_list_s drawlist; struct ez_double_linked_list_s tablist; struct mouse_state_s prev_mouse_state; double mouse_pressed_time[9]; }

user_defined_types: struct ez_eventhandler_s { int function_type; union ez_eventhandlerfunction_u function; void *payload; struct ez_eventhandler_s *next; }

user_defined_types: struct ez_scrollbar_s { struct ez_control_s super; struct ez_scrollbar_events_s events; struct ez_scrollbar_eventhandlers_s event_handlers; struct ez_scrollbar_eventcount_s inherit_levels; struct ez_scrollbar_eventcount_s override_counts; struct ez_button_s *back; struct ez_button_s *slider; struct ez_button_s *forward; enum ez_orientation_s orientation; int scroll_area; int slider_minsize; int scroll_delta_x; int scroll_delta_y; struct ez_control_s *target; enum ez_scrollbar_flags_e ext_flags; enum ez_scrollbar_iflags_e int_flags; }

user_defined_types: union ez_eventhandlerfunction_u { int (*normal)(struct ez_control_s *self, void *payload, void *ext_info); int (*mouse)(struct ez_control_s *self, void *payload, struct mouse_state_s *mouse_state); int (*key)(struct ez_control_s *self, void *payload, int key, int unichar, enum qbool down); int (*key_sp)(struct ez_control_s *self, void *payload, int key, int unichar); int (*destroy)(struct ez_control_s *self, void *payload, enum qbool destroy_children); int (*child)(struct ez_control_s *self, void *payload, struct ez_control_s *child); }

user_defined_types: struct ez_button_s { struct ez_control_s super; struct ez_button_events_s events; struct ez_button_eventhandlers_s event_handlers; struct ez_button_eventcount_s inherit_levels; struct ez_button_eventcount_s override_counts; struct ez_label_s *text_label; struct mpic_t *focused_image; struct mpic_t *normal_image; struct mpic_t *hover_image; struct mpic_t *pressed_image; struct mpic_t *toggled_hover_image; unsigned char color_focused[4]; unsigned char color_normal[4]; unsigned char color_hover[4]; unsigned char color_pressed[4]; unsigned char color_toggled_hover[4]; enum ez_button_iflags_e int_flags; enum ez_button_flags_e ext_flags; int padding_top; int padding_left; int padding_right; int padding_bottom; enum ez_textalign_e text_alignment; struct clrinfo_s focused_text_color; struct clrinfo_s normal_text_color; struct clrinfo_s hover_text_color; struct clrinfo_s pressed_text_color; int override_count; int inheritance_level; }

user_defined_types: struct ez_label_s { struct ez_control_s super; struct ez_label_events_s events; struct ez_label_eventhandlers_s event_handlers; struct ez_label_eventcount_s inherit_levels; struct ez_label_eventcount_s override_counts; char *text; int text_length; enum ez_label_flags_e ext_flags; enum ez_label_iflags_e int_flags; struct ez_label_textpos_s wordwraps[512]; struct clrinfo_s color; float scale; int scaled_char_size; int select_start; int select_end; struct ez_label_textpos_s caret_pos; int num_rows; int num_cols; }