decompiled_code:
__int64 __fastcall R_SplitEntityOnNode(_QWORD *a1)
{
__int64 result; // rax
__int64 v2; // rdx
unsigned __int8 v3; // al
float v4; // xmm0_4
char v5; // bp

result = *(unsigned int *)a1;
if ( (_DWORD)result != -2 )
{
if ( (int)result >= 0 )
{
v2 = a1[5];
v3 = *(_BYTE *)(v2 + 16);
if ( v3 > 2u )
{
result = BoxOnPlaneSide(r_emins, r_emaxs);
v5 = result;
if ( (_DWORD)result != 3 )
{
if ( (result & 1) == 0 )
goto LABEL_15;
goto LABEL_18;
}
}
else
{
v4 = *(float *)(v2 + 12);
if ( r_emins[v3] >= v4 )
{
v5 = 1;
LABEL_18:
result = R_SplitEntityOnNode(a1[6]);
LABEL_15:
if ( (v5 & 2) == 0 )
return result;
return R_SplitEntityOnNode(a1[7]);
}
if ( v4 >= r_emaxs[v3] )
return R_SplitEntityOnNode(a1[7]);
}
v5 = 3;
if ( !r_pefragtopnode )
r_pefragtopnode = (__int64)a1;
goto LABEL_18;
}
if ( !r_pefragtopnode )
r_pefragtopnode = (__int64)a1;
result = unk_648[174257];
if ( result )
{
unk_648[174257] = *(_QWORD *)(result + 24);
*(_QWORD *)(result + 16) = r_addent;
*(_QWORD *)lastlink = result;
lastlink = result + 24;
*(_QWORD *)(result + 24) = 0LL;
*(_QWORD *)result = a1;
*(_QWORD *)(result + 8) = a1[6];
a1[6] = result;
}
else
{
result = Com_Printf("Too many efrags!\n");
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
__int64 result; // rax
__int64 v2; // rdx
unsigned __int8 v3; // al
float v4; // xmm0_4
char v5; // bp

result = *(unsigned int *)a1;
if ( (_DWORD)result != -2 )
{
if ( (int)result >= 0 )
{
v2 = a1[5];
v3 = *(_BYTE *)(v2 + 16);
if ( v3 > 2u )
{
result = BoxOnPlaneSide(r_emins, r_emaxs);
v5 = result;
if ( (_DWORD)result != 3 )
{
if ( (result & 1) == 0 )
goto LABEL_15;
goto LABEL_18;
}
}
else
{
v4 = *(float *)(v2 + 12);
if ( r_emins[v3] >= v4 )
{
v5 = 1;
LABEL_18:
result = func1(a1[6]);
LABEL_15:
if ( (v5 & 2) == 0 )
return result;
return func1(a1[7]);
}
if ( v4 >= r_emaxs[v3] )
return func1(a1[7]);
}
v5 = 3;
if ( !r_pefragtopnode )
r_pefragtopnode = (__int64)a1;
goto LABEL_18;
}
if ( !r_pefragtopnode )
r_pefragtopnode = (__int64)a1;
result = unk_648[174257];
if ( result )
{
unk_648[174257] = *(_QWORD *)(result + 24);
*(_QWORD *)(result + 16) = r_addent;
*(_QWORD *)lastlink = result;
lastlink = result + 24;
*(_QWORD *)(result + 24) = 0LL;
*(_QWORD *)result = a1;
*(_QWORD *)(result + 8) = a1[6];
a1[6] = result;
}
else
{
result = Com_Printf("Too many efrags!\n");
}
}
return result;
}

original_code:
void R_SplitEntityOnNode (mnode_t *node) {
 efrag_t *ef;
 mplane_t *splitplane;
 mleaf_t *leaf;
 int sides;
 if (node->contents == -2)
  return;
 if ( node->contents < 0) {
  if (!r_pefragtopnode)
   r_pefragtopnode = node;
  leaf = (mleaf_t *)node;
  if (!(ef = cl.free_efrags)) {
   Com_Printf ("Too many efrags!\n");
   return;
  }
  cl.free_efrags = cl.free_efrags->entnext;
  ef->entity = r_addent;
  *lastlink = ef;
  lastlink = &ef->entnext;
  ef->entnext = ((void *)0);
  ef->leaf = leaf;
  ef->leafnext = leaf->efrags;
  leaf->efrags = ef;
  return;
 }
 splitplane = node->plane;
 sides = (((splitplane)->type < 3) ? ( ((splitplane)->dist <= (r_emins)[(splitplane)->type]) ? 1 : ( ((splitplane)->dist >= (r_emaxs)[(splitplane)->type]) ? 2 : 3 ) ) : BoxOnPlaneSide((r_emins), (r_emaxs), (splitplane)));
 if (sides == 3) {
  if (!r_pefragtopnode)
   r_pefragtopnode = node;
 }
 if (sides & 1)
  R_SplitEntityOnNode (node->children[0]);
 if (sides & 2)
  R_SplitEntityOnNode (node->children[1]);
}

canonical_original_code:
void R_SplitEntityOnNode(struct mnode_s *node) {
 struct efrag_s *ef;
 struct mplane_s *splitplane;
 struct mleaf_s *leaf;
 int sides;
 if (node->contents == -2)
  return;
 if ( node->contents < 0) {
  if (!r_pefragtopnode)
   r_pefragtopnode = node;
  leaf = (struct mleaf_s *)node;
  if (!(ef = cl.free_efrags)) {
   Com_Printf ("Too many efrags!\n");
   return;
  }
  cl.free_efrags = cl.free_efrags->entnext;
  ef->entity = r_addent;
  *lastlink = ef;
  lastlink = &ef->entnext;
  ef->entnext = ((void *)0);
  ef->leaf = leaf;
  ef->leafnext = leaf->efrags;
  leaf->efrags = ef;
  return;
 }
 splitplane = node->plane;
 sides = (((splitplane)->type < 3) ? ( ((splitplane)->dist <= (r_emins)[(splitplane)->type]) ? 1 : ( ((splitplane)->dist >= (r_emaxs)[(splitplane)->type]) ? 2 : 3 ) ) : BoxOnPlaneSide((r_emins), (r_emaxs), (splitplane)));
 if (sides == 3) {
  if (!r_pefragtopnode)
   r_pefragtopnode = node;
 }
 if (sides & 1)
  R_SplitEntityOnNode (node->children[0]);
 if (sides & 2)
  R_SplitEntityOnNode (node->children[1]);
}

variable_types: struct efrag_s { 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 { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *plane; struct mnode_s *children[2]; unsigned short firstsurface; unsigned short numsurfaces; } *parent; unsigned char *compressed_vis; struct efrag_s *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; } *leaf; struct efrag_s *leafnext; struct entity_s { float origin[3]; float angles[3]; 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 *planes; int numleafs; struct mleaf_s *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 { void *data; } cache; } *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 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; } *

variable_types: 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 { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *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 { 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 *planes; int numleafs; struct mleaf_s *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 { float vecs[2][4]; struct texture_s { char name[16]; unsigned int width; int gl_texturenum; int fb_texturenum; 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 *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; } *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 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 { void *data; } cache; } *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 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 **firstmarksurface; int nummarksurfaces; } *

variable_types: sides int

user_defined_types: 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; }

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


repo: jite/jquake

decompiled_code:
void __fastcall R_AddEfrags(__int64 a1)
{
__int64 v1; // rdx
__int64 i; // rax

v1 = *(_QWORD *)(a1 + 24);
if ( v1 )
{
r_addent = a1;
lastlink = a1 + 80;
r_pefragtopnode = 0LL;
for ( i = 0LL; i != 3; ++i )
{
r_emins[i] = *(float *)(a1 + i * 4) + *(float *)(v1 + i * 4 + 112);
r_emaxs[i] = *(float *)(a1 + i * 4) + *(float *)(v1 + i * 4 + 124);
}
R_SplitEntityOnNode(*(_QWORD **)(unk_648[174256] + 232LL));
*(_QWORD *)(a1 + 112) = r_pefragtopnode;
}
}

original_code:
void R_AddEfrags (entity_t *ent) {
 model_t *entmodel;
 int i;
 if (!ent->model)
  return;
 r_addent = ent;
 lastlink = &ent->efrag;
 r_pefragtopnode = ((void *)0);
 entmodel = ent->model;
 for (i = 0; i < 3; i++) {
  r_emins[i] = ent->origin[i] + entmodel->mins[i];
  r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
 }
 R_SplitEntityOnNode (cl.worldmodel->nodes);
 ent->topnode = r_pefragtopnode;
}

canonical_original_code:
void R_AddEfrags(struct entity_s *ent) {
 struct model_s *entmodel;
 int i;
 if (!ent->model)
  return;
 r_addent = ent;
 lastlink = &ent->efrag;
 r_pefragtopnode = ((void *)0);
 entmodel = ent->model;
 for (i = 0; i < 3; i++) {
  r_emins[i] = ent->origin[i] + entmodel->mins[i];
  r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
 }
 R_SplitEntityOnNode (cl.worldmodel->nodes);
 ent->topnode = r_pefragtopnode;
}

variable_types: struct entity_s { float origin[3]; float angles[3]; 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 *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 { void *data; } cache; } *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 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; } *

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: i int

return_type: void

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 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 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 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 skin_t { char name[16]; enum qbool failedload; enum qbool warned; int width; int bpp; int texnum; struct cache_user_s cache; }

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 mtexinfo_s { float vecs[2][4]; struct texture_s *texture; int flags; }

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; }


decompiled_code:
void __fastcall R_StoreEfrags(__int64 *a1, double a2)
{
__int64 i; // rbx
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rsi

for ( i = *a1; i; i = *(_QWORD *)(i + 8) )
{
v3 = *(_QWORD *)(i + 16);
v4 = *(_QWORD *)(v3 + 24);
if ( *(_DWORD *)(v4 + 92) == 3 )
{
a2 = 0.0;
if ( r_drawflame[8] == 0.0 )
continue;
}
v5 = *(unsigned int *)(v4 + 96);
if ( (unsigned int)v5 > 1 && (unsigned int)(v5 - 3) > 1 )
{
Sys_Error("R_StoreEfrags: Bad entity type %d", v5);
}
else if ( *(_DWORD *)(v3 + 88) != r_framecount )
{
CL_AddEntity(*(_QWORD *)(i + 16), a2);
*(_DWORD *)(v3 + 88) = r_framecount;
}
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 *a1, double a2)
{
__int64 i; // rbx
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rsi

for ( i = *a1; i; i = *(_QWORD *)(i + 8) )
{
v3 = *(_QWORD *)(i + 16);
v4 = *(_QWORD *)(v3 + 24);
if ( *(_DWORD *)(v4 + 92) == 3 )
{
a2 = 0.0;
if ( r_drawflame[8] == 0.0 )
continue;
}
v5 = *(unsigned int *)(v4 + 96);
if ( (unsigned int)v5 > 1 && (unsigned int)(v5 - 3) > 1 )
{
Sys_Error("R_StoreEfrags: Bad entity type %d", v5);
}
else if ( *(_DWORD *)(v3 + 88) != r_framecount )
{
CL_AddEntity(*(_QWORD *)(i + 16), a2);
*(_DWORD *)(v3 + 88) = r_framecount;
}
}
}

original_code:
void R_StoreEfrags (efrag_t **ppefrag) {
 entity_t *pent;
 model_t *model;
 efrag_t *pefrag;
 for (pefrag = *ppefrag; pefrag; pefrag = pefrag->leafnext) {
  pent = pefrag->entity;
  model = pent->model;
  if (model->modhint == MOD_FLAME && !r_drawflame.value)
   continue;
  switch (model->type) {
  case mod_alias:
  case mod_alias3:
  case mod_brush:
  case mod_sprite:
   if (pent->visframe != r_framecount) {
    CL_AddEntity (pent);
    pent->visframe = r_framecount;
   }
   break;
  default:
   Sys_Error ("R_StoreEfrags: Bad entity type %d", model->type);
  }
 }
}

canonical_original_code:
void R_StoreEfrags(struct efrag_s **ppefrag) {
 struct entity_s *pent;
 struct model_s *model;
 struct efrag_s *pefrag;
 for (pefrag = *ppefrag; pefrag; pefrag = pefrag->leafnext) {
  pent = pefrag->entity;
  model = pent->model;
  if (model->modhint == MOD_FLAME && !r_drawflame.value)
   continue;
  switch (model->type) {
  case mod_alias:
  case mod_alias3:
  case mod_brush:
  case mod_sprite:
   if (pent->visframe != r_framecount) {
    CL_AddEntity (pent);
    pent->visframe = r_framecount;
   }
   break;
  default:
   Sys_Error ("R_StoreEfrags: Bad entity type %d", model->type);
  }
 }
}

variable_types: struct efrag_s { 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 { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *plane; struct mnode_s *children[2]; unsigned short firstsurface; unsigned short numsurfaces; } *parent; unsigned char *compressed_vis; struct efrag_s *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; } *leaf; struct efrag_s *leafnext; struct entity_s { float origin[3]; float angles[3]; 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 *planes; int numleafs; struct mleaf_s *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 { void *data; } cache; } *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 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; } **


VersionStringColored

decompiled_code:
char *VersionStringColored()
{
unsigned int v0; // eax

v0 = build_number();
snprintf(str_0, 0x40uLL, "&c2f2%s&r (%i)", "0.3-dev", v0);
return str_0;
}

canonical_decompiled_code:
char *func3()
{
unsigned int v0; // eax

v0 = func0();
snprintf(str_0, 0x40uLL, "&c2f2%s&r (%i)", "0.3-dev", v0);
return str_0;
}

original_code:
char *VersionStringColored (void)
{
 static char str[64];
 snprintf (str, sizeof(str), "&c2f2%s&r (%i)", "0.3-dev", build_number());
 return str;
}

canonical_original_code:
char *VersionStringColored()
{
 static char str[64];
 snprintf (str, sizeof(str), "&c2f2%s&r (%i)", "0.3-dev", build_number());
 return str;
}

variable_types:
str
char [64]

return_type: char *


original_code:
void CEditBox_Init(CEditBox *e, int width, int max)
{
 e->width = width;
 e->max = max;
 e->pos = 0;
 e->disp = 0;
 e->text[0] = 0;
}

canonical_original_code:
void CEditBox_Init(struct CEditBox_s *e, int width, int max)
{
 e->width = width;
 e->max = max;
 e->pos = 0;
 e->disp = 0;
 e->text[0] = 0;
}

variable_types: struct CEditBox_s { char text[-1]; unsigned int width; unsigned int max; unsigned int pos; unsigned int disp; } *

variable_types: width int

variable_types: max int


decompiled_code:
__int64 __fastcall CEditBox_Draw(char *s, unsigned int a2, unsigned int a3, int a4)
{
unsigned int v7; // esi
unsigned int v8; // ecx
unsigned int v9; // ebp
unsigned int v10; // eax
size_t v11; // rax
__int64 result; // rax

v7 = *((_DWORD *)s + 66);
v8 = *((_DWORD *)s + 67);
v9 = *((_DWORD *)s + 64);
if ( v7 > v9 + v8 - 1 )
{
v10 = v8 + 1;
do
v8 = v10++;
while ( v9 - 2 + v10 < v7 );
*((_DWORD *)s + 67) = v8;
}
if ( v7 < v8 )
*((_DWORD *)s + 67) = v7;
v11 = strlen(s);
if ( *((unsigned int *)s + 67) > v11 - v9 + 1 )
*((_DWORD *)s + 67) = v11 - v9 + 1;
if ( a4 )
{
snprintf(buf, 0x100uLL, "%-*.*s", v9, v9, &s[*((unsigned int *)s + 67)]);
Draw_String(a2, a3, buf);
result = Draw_Character(a2 + 8 * (*((_DWORD *)s + 66) - *((_DWORD *)s + 67)), a3, ((int)(4.0 * cls[1]) & 1u) + 10);
}
else
{
snprintf(buf, 0x100uLL, "%-*.*s", v9, v9, s);
result = Draw_String(a2, a3, buf);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s, unsigned int a2, unsigned int a3, int a4)
{
unsigned int v7; // esi
unsigned int v8; // ecx
unsigned int v9; // ebp
unsigned int v10; // eax
size_t v11; // rax
__int64 result; // rax

v7 = *((_DWORD *)s + 66);
v8 = *((_DWORD *)s + 67);
v9 = *((_DWORD *)s + 64);
if ( v7 > v9 + v8 - 1 )
{
v10 = v8 + 1;
do
v8 = v10++;
while ( v9 - 2 + v10 < v7 );
*((_DWORD *)s + 67) = v8;
}
if ( v7 < v8 )
*((_DWORD *)s + 67) = v7;
v11 = strlen(s);
if ( *((unsigned int *)s + 67) > v11 - v9 + 1 )
*((_DWORD *)s + 67) = v11 - v9 + 1;
if ( a4 )
{
snprintf(buf, 0x100uLL, "%-*.*s", v9, v9, &s[*((unsigned int *)s + 67)]);
Draw_String(a2, a3, buf);
result = Draw_Character(a2 + 8 * (*((_DWORD *)s + 66) - *((_DWORD *)s + 67)), a3, ((int)(4.0 * cls[1]) & 1u) + 10);
}
else
{
snprintf(buf, 0x100uLL, "%-*.*s", v9, v9, s);
result = Draw_String(a2, a3, buf);
}
return result;
}

original_code:
void CEditBox_Draw(CEditBox *e, int x, int y, qbool active)
{
 while (e->pos > e->disp + e->width - 1)
  e->disp ++;
 if (e->disp > e->pos)
  e->disp = e->pos;
 if (e->disp > strlen(e->text) - e->width + 1)
  e->disp = strlen(e->text) - e->width + 1;
 snprintf(buf, sizeof (buf), "%-*.*s", e->width, e->width, active ? e->text+e->disp : e->text);
 Draw_String(x, y, buf);
 if (active)
  Draw_Character(x+8*(e->pos-e->disp), y, 10+((int)(cls.realtime*4)&1));
}

canonical_original_code:
void CEditBox_Draw(struct CEditBox_s *e, int x, int y, enum qbool active)
{
 while (e->pos > e->disp + e->width - 1)
  e->disp ++;
 if (e->disp > e->pos)
  e->disp = e->pos;
 if (e->disp > strlen(e->text) - e->width + 1)
  e->disp = strlen(e->text) - e->width + 1;
 snprintf(buf, sizeof (buf), "%-*.*s", e->width, e->width, active ? e->text+e->disp : e->text);
 Draw_String(x, y, buf);
 if (active)
  Draw_Character(x+8*(e->pos-e->disp), y, 10+((int)(cls.realtime*4)&1));
}

variable_types: x int

variable_types: y int

variable_types:
active
enum qbool { false=0, true=1 }

user_defined_types: struct CEditBox_s { char text[-1]; unsigned int width; unsigned int max; unsigned int pos; unsigned int disp; }


decompiled_code:
unsigned __int64 __fastcall CEditBox_Key(char *s, const char *a2, char a3)
{
int v3; // ebp
unsigned int v5; // er14
size_t v6; // rcx
__int64 v7; // rdx
unsigned __int64 result; // rax
size_t v9; // rdx
const char *v10; // r14
size_t v11; // r15
unsigned int v12; // er13
size_t v13; // rax
size_t v14; // rdx
int v15; // er13
size_t v16; // rax
__int64 v17; // r14
size_t v18; // rax
__int64 v19; // rdx
size_t n; // [rsp+8h] [rbp-40h]

v3 = (int)a2;
if ( (_DWORD)a2 == 86 && (unsigned int)((__int64 (*)(void))isCtrlDown)() )
{
v10 = (const char *)ReadFromClipboard();
v11 = strlen(v10);
v12 = *((_DWORD *)s + 65);
v13 = strlen(s);
v14 = v12 - v13;
v15 = v12 - v13;
if ( v11 < v14 )
v15 = v11;
if ( v15 > 0 )
{
n = *((unsigned int *)s + 66);
v16 = strlen(&s[n]);
memmove(&s[v15 + n], &s[n], v16 + 1);
a2 = v10;
memcpy(&s[*((unsigned int *)s + 66)], v10, v15);
*((_DWORD *)s + 66) += v15;
}
}
v5 = *((_DWORD *)s + 66);
v6 = strlen(s);
v7 = v5;
if ( v5 >= v6 )
v5 = v6;
*((_DWORD *)s + 66) = v5;
result = isCtrlDown(s, a2, v7, v6);
if ( !(_DWORD)result && (unsigned int)(v3 - 32) <= 0x5D )
{
v9 = strlen(s);
result = *((unsigned int *)s + 65);
if ( v9 < result )
{
v17 = *((unsigned int *)s + 66);
v18 = strlen(&s[v17]);
memmove(&s[v17 + 1], &s[v17], v18 + 1);
v19 = *((unsigned int *)s + 66);
s[v19] = a3;
result = (unsigned int)(v19 + 1);
*((_DWORD *)s + 66) = result;
}
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(char *s, const char *a2, char a3)
{
int v3; // ebp
unsigned int v5; // er14
size_t v6; // rcx
__int64 v7; // rdx
unsigned __int64 result; // rax
size_t v9; // rdx
const char *v10; // r14
size_t v11; // r15
unsigned int v12; // er13
size_t v13; // rax
size_t v14; // rdx
int v15; // er13
size_t v16; // rax
__int64 v17; // r14
size_t v18; // rax
__int64 v19; // rdx
size_t n; // [rsp+8h] [rbp-40h]

v3 = (int)a2;
if ( (_DWORD)a2 == 86 && (unsigned int)((__int64 (*)(void))isCtrlDown)() )
{
v10 = (const char *)ReadFromClipboard();
v11 = strlen(v10);
v12 = *((_DWORD *)s + 65);
v13 = strlen(s);
v14 = v12 - v13;
v15 = v12 - v13;
if ( v11 < v14 )
v15 = v11;
if ( v15 > 0 )
{
n = *((unsigned int *)s + 66);
v16 = strlen(&s[n]);
memmove(&s[v15 + n], &s[n], v16 + 1);
a2 = v10;
memcpy(&s[*((unsigned int *)s + 66)], v10, v15);
*((_DWORD *)s + 66) += v15;
}
}
v5 = *((_DWORD *)s + 66);
v6 = strlen(s);
v7 = v5;
if ( v5 >= v6 )
v5 = v6;
*((_DWORD *)s + 66) = v5;
result = isCtrlDown(s, a2, v7, v6);
if ( !(_DWORD)result && (unsigned int)(v3 - 32) <= 0x5D )
{
v9 = strlen(s);
result = *((unsigned int *)s + 65);
if ( v9 < result )
{
v17 = *((unsigned int *)s + 66);
v18 = strlen(&s[v17]);
memmove(&s[v17 + 1], &s[v17], v18 + 1);
v19 = *((unsigned int *)s + 66);
s[v19] = a3;
result = (unsigned int)(v19 + 1);
*((_DWORD *)s + 66) = result;
}
}
return result;
}

original_code:
void CEditBox_Key(CEditBox *e, int key, unsigned short unichar)
{
 switch (key) {
   case K_LEFTARROW:
    e->pos--;
    break;
   case K_RIGHTARROW:
    e->pos++;
    break;
   case K_HOME:
    e->pos = 0;
    break;
   case K_END:
    e->pos = strlen(e->text);
    break;
   case K_DEL:
    if (e->pos < strlen(e->text))
     memmove(e->text + e->pos,
      e->text + e->pos + 1,
      strlen(e->text + e->pos + 1) + 1);
    break;
   case K_BACKSPACE:
    if (e->pos > 0) {
     memmove(e->text + e->pos - 1,
      e->text + e->pos,
      strlen(e->text + e->pos) + 1);
     e->pos --;
    }
   break;
   case 'v':
   case 'V':
    if (isCtrlDown()) {
     int len;
     char *clip = ReadFromClipboard();
     len = ((strlen(clip)) < (e->max - strlen(e->text)) ? (strlen(clip)) : (e->max - strlen(e->text)));
     if (len > 0) {
      memmove(e->text + e->pos + len,
       e->text + e->pos,
       strlen(e->text + e->pos) + 1);
      memcpy(e->text + e->pos, clip, len);
      e->pos += len;
     }
    }
   break;
 }
 e->pos = ((e->pos) > (0) ? (e->pos) : (0));
 e->pos = ((e->pos) < (strlen(e->text)) ? (e->pos) : (strlen(e->text)));
 if (!isCtrlDown() &&
  key >= ' ' && key <= '}' &&
  strlen(e->text) < e->max)
 {
  memmove(e->text + e->pos + 1,
   e->text + e->pos,
   strlen(e->text + e->pos) + 1);
  e->text[e->pos] = unichar;
  e->pos++;
 }
}

canonical_original_code:
void CEditBox_Key(struct CEditBox_s *e, int key, unsigned short unichar)
{
 switch (key) {
   case K_LEFTARROW:
    e->pos--;
    break;
   case K_RIGHTARROW:
    e->pos++;
    break;
   case K_HOME:
    e->pos = 0;
    break;
   case K_END:
    e->pos = strlen(e->text);
    break;
   case K_DEL:
    if (e->pos < strlen(e->text))
     memmove(e->text + e->pos,
      e->text + e->pos + 1,
      strlen(e->text + e->pos + 1) + 1);
    break;
   case K_BACKSPACE:
    if (e->pos > 0) {
     memmove(e->text + e->pos - 1,
      e->text + e->pos,
      strlen(e->text + e->pos) + 1);
     e->pos --;
    }
   break;
   case 'v':
   case 'V':
    if (isCtrlDown()) {
     int len;
     char *clip = ReadFromClipboard();
     len = ((strlen(clip)) < (e->max - strlen(e->text)) ? (strlen(clip)) : (e->max - strlen(e->text)));
     if (len > 0) {
      memmove(e->text + e->pos + len,
       e->text + e->pos,
       strlen(e->text + e->pos) + 1);
      memcpy(e->text + e->pos, clip, len);
      e->pos += len;
     }
    }
   break;
 }
 e->pos = ((e->pos) > (0) ? (e->pos) : (0));
 e->pos = ((e->pos) < (strlen(e->text)) ? (e->pos) : (strlen(e->text)));
 if (!isCtrlDown() &&
  key >= ' ' && key <= '}' &&
  strlen(e->text) < e->max)
 {
  memmove(e->text + e->pos + 1,
   e->text + e->pos,
   strlen(e->text + e->pos) + 1);
  e->text[e->pos] = unichar;
  e->pos++;
 }
}

variable_types: key int

variable_types:
unichar
unsigned short

variable_types: len int

variable_types:
clip
char *


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

if ( (unsigned __int16)a1 <= 0x7Fu )
return a1;
result = 63LL;
if ( (unsigned __int16)(a1 - 1024) <= 0x5Fu )
result = (unsigned int)(unsigned __int8)LC0[(unsigned __int16)a1 - 1024] - 128;
return result;
}

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

if ( (unsigned __int16)a1 <= 0x7Fu )
return a1;
result = 63LL;
if ( (unsigned __int16)(a1 - 1024) <= 0x5Fu )
result = (unsigned int)(unsigned __int8)LC0[(unsigned __int16)a1 - 1024] - 128;
return result;
}

original_code:
static char wc2koi (unsigned short wc) {
 if (wc <= 127)
  return (char)wc;
 if (wc >= 0x400 && wc <= 0x45f)
  return wc2koi_table[wc - 0x400] + 128;
 else
  return '?';
}

canonical_original_code:
static char wc2koi(unsigned short wc) {
 if (wc <= 127)
  return (char)wc;
 if (wc >= 0x400 && wc <= 0x45f)
  return wc2koi_table[wc - 0x400] + 128;
 else
  return '?';
}

variable_types:
wc
unsigned short

return_type: char


decompiled_code:
__int16 __fastcall koi2wc(unsigned __int8 a1)
{
__int16 result; // ax

if ( a1 > 0xBFu )
return (unsigned __int8)koi2wc_table[a1 - 192] + 1024;
switch ( a1 )
{
case 0xA3:
return 1105;
case 0xB3:
return 1025;
case 0xB4:
return 1028;
case 0xA4:
return 1108;
case 0xB6:
return 1030;
case 0xA6:
return 1110;
case 0xB7:
return 1031;
case 0xA7:
return 1111;
case 0xBE:
return 1038;
case 0xAE:
return 1118;
}
result = a1;
if ( a1 == 0xAF )
result = 1066;
return result;
}

canonical_decompiled_code:
__int16 __fastcall func1(unsigned __int8 a1)
{
__int16 result; // ax

if ( a1 > 0xBFu )
return (unsigned __int8)koi2wc_table[a1 - 192] + 1024;
switch ( a1 )
{
case 0xA3:
return 1105;
case 0xB3:
return 1025;
case 0xB4:
return 1028;
case 0xA4:
return 1108;
case 0xB6:
return 1030;
case 0xA6:
return 1110;
case 0xB7:
return 1031;
case 0xA7:
return 1111;
case 0xBE:
return 1038;
case 0xAE:
return 1118;
}
result = a1;
if ( a1 == 0xAF )
result = 1066;
return result;
}

original_code:
static unsigned short koi2wc (char c)
{
 unsigned char uc = c;
 if (uc >= 192 )
  return koi2wc_table[(unsigned char)c - 192] + 0x400;
 else if (uc == '#' + 128)
  return 0x0451;
 else if (uc == '3' + 128)
  return 0x0401;
 else if (uc == '4' + 128)
  return 0x0404;
 else if (uc == '$' + 128)
  return 0x0454;
 else if (uc == '6' + 128)
  return 0x0406;
 else if (uc == '&' + 128)
  return 0x0456;
 else if (uc == '7' + 128)
  return 0x0407;
 else if (uc == '\'' + 128)
  return 0x0457;
 else if (uc == '>' + 128)
  return 0x040e;
 else if (uc == '.' + 128)
  return 0x045e;
 else if (uc == '/' + 128)
  return 0x042a;
 else
  return (unsigned short)(unsigned char)c;
}

canonical_original_code:
static unsigned short koi2wc(char c)
{
 unsigned char uc = c;
 if (uc >= 192 )
  return koi2wc_table[(unsigned char)c - 192] + 0x400;
 else if (uc == '#' + 128)
  return 0x0451;
 else if (uc == '3' + 128)
  return 0x0401;
 else if (uc == '4' + 128)
  return 0x0404;
 else if (uc == '$' + 128)
  return 0x0454;
 else if (uc == '6' + 128)
  return 0x0406;
 else if (uc == '&' + 128)
  return 0x0456;
 else if (uc == '7' + 128)
  return 0x0407;
 else if (uc == '\'' + 128)
  return 0x0457;
 else if (uc == '>' + 128)
  return 0x040e;
 else if (uc == '.' + 128)
  return 0x045e;
 else if (uc == '/' + 128)
  return 0x042a;
 else
  return (unsigned short)(unsigned char)c;
}

variable_types: c char

variable_types:
uc
unsigned char

return_type: unsigned short


decompiled_code:
__int64 __fastcall cp1251towc(unsigned __int8 a1)
{
__int64 result; // rax

if ( a1 > 0xBFu )
return (unsigned int)a1 + 848;
switch ( a1 )
{
case 0xA8:
return 1025LL;
case 0xB8:
return 1105LL;
case 0xAA:
return 1028LL;
case 0xBA:
return 1108LL;
case 0xB2:
return 1030LL;
case 0xB3:
return 1110LL;
case 0xAF:
return 1031LL;
case 0xBF:
return 1111LL;
case 0xA1:
return 1038LL;
}
result = 1118LL;
if ( a1 != 0xA2 )
result = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 a1)
{
__int64 result; // rax

if ( a1 > 0xBFu )
return (unsigned int)a1 + 848;
switch ( a1 )
{
case 0xA8:
return 1025LL;
case 0xB8:
return 1105LL;
case 0xAA:
return 1028LL;
case 0xBA:
return 1108LL;
case 0xB2:
return 1030LL;
case 0xB3:
return 1110LL;
case 0xAF:
return 1031LL;
case 0xBF:
return 1111LL;
case 0xA1:
return 1038LL;
}
result = 1118LL;
if ( a1 != 0xA2 )
result = a1;
return result;
}

original_code:
static unsigned short cp1251towc (char c)
{
 unsigned char uc = c;
 if (uc >= 192)
  return 0x0410 + (uc - 192);
 else if (uc == 168)
  return 0x0401;
 else if (uc == 184)
  return 0x0451;
 else if (uc == 170)
  return 0x0404;
 else if (uc == 186)
  return 0x0454;
 else if (uc == 178)
  return 0x0406;
 else if (uc == 179)
  return 0x0456;
 else if (uc == 175)
  return 0x0407;
 else if (uc == 191)
  return 0x0457;
 else if (uc == 161)
  return 0x040e;
 else if (uc == 162)
  return 0x045e;
 return (unsigned short)uc;
}

canonical_original_code:
static unsigned short cp1251towc(char c)
{
 unsigned char uc = c;
 if (uc >= 192)
  return 0x0410 + (uc - 192);
 else if (uc == 168)
  return 0x0401;
 else if (uc == 184)
  return 0x0451;
 else if (uc == 170)
  return 0x0404;
 else if (uc == 186)
  return 0x0454;
 else if (uc == 178)
  return 0x0406;
 else if (uc == 179)
  return 0x0456;
 else if (uc == 175)
  return 0x0407;
 else if (uc == 191)
  return 0x0457;
 else if (uc == 161)
  return 0x040e;
 else if (uc == 162)
  return 0x045e;
 return (unsigned short)uc;
}


original_code:
char *encode_say (unsigned short *in)
{
 static char buf[1024];
 unsigned short *p;
 char *out;
 for (p = in; *p; p++)
  if (*p > 255)
   goto encode;
 strlcpy (buf, wcs2str(in), sizeof(buf));
 return buf;
encode:
 strlcpy (buf, wcs2str(in), ((p - in + 1) < (sizeof(buf)) ? (p - in + 1) : (sizeof(buf))));
 in = p;
 strlcat (buf, "=`k8:", sizeof(buf));
 out = buf + strlen(buf);
 while (*in && (out - buf < sizeof(buf)/sizeof(buf[0])))
 {
  if (*in <= 255)
   *out++ = *in;
  else {
   *out++ = wc2koi(*in);
  }
  in++;
 }
 *out++ = '`';
 *out++ = '=';
 *out++ = 0;
 return buf;
}

canonical_original_code:
char *encode_say(unsigned short *in)
{
 static char buf[1024];
 unsigned short *p;
 char *out;
 for (p = in; *p; p++)
  if (*p > 255)
   goto encode;
 strlcpy (buf, wcs2str(in), sizeof(buf));
 return buf;
encode:
 strlcpy (buf, wcs2str(in), ((p - in + 1) < (sizeof(buf)) ? (p - in + 1) : (sizeof(buf))));
 in = p;
 strlcat (buf, "=`k8:", sizeof(buf));
 out = buf + strlen(buf);
 while (*in && (out - buf < sizeof(buf)/sizeof(buf[0])))
 {
  if (*in <= 255)
   *out++ = *in;
  else {
   *out++ = wc2koi(*in);
  }
  in++;
 }
 *out++ = '`';
 *out++ = '=';
 *out++ = 0;
 return buf;
}

variable_types:
in
unsigned short *

variable_types:
buf
char [1024]

variable_types:
p
unsigned short *

variable_types:
out
char *


decompiled_code:
void *__fastcall maybe_transliterate(unsigned __int16 *a1)
{
unsigned __int16 *v1; // rbp
unsigned __int16 v2; // di
unsigned __int16 *v3; // rbx
__int16 *v4; // r14
unsigned __int64 v5; // rcx
int v6; // eax
size_t v7; // r12

v1 = a1;
v2 = *a1;
if ( v2 )
{
v3 = (unsigned __int16 *)&buf_0;
do
{
if ( (unsigned int)R_CharAvailable(v2) )
{
*v3++ = *v1;
}
else
{
v4 = transliterate_char(*v1);
v5 = qwcslen(v4);
v6 = &word_1B5E - v3;
if ( v5 < &word_1B5E - v3 )
v6 = qwcslen(v4);
v7 = 2LL * v6;
memcpy(v3, v4, v7);
v3 = (unsigned __int16 *)((char *)v3 + v7);
}
v2 = *++v1;
}
while ( v3 < &word_1B5E && v2 );
}
else
{
v3 = (unsigned __int16 *)&buf_0;
}
*v3 = 0;
return &buf_0;
}

canonical_decompiled_code:
void *__fastcall func6(unsigned __int16 *a1)
{
unsigned __int16 *v1; // rbp
unsigned __int16 v2; // di
unsigned __int16 *v3; // rbx
__int16 *v4; // r14
unsigned __int64 v5; // rcx
int v6; // eax
size_t v7; // r12

v1 = a1;
v2 = *a1;
if ( v2 )
{
v3 = (unsigned __int16 *)&buf_0;
do
{
if ( (unsigned int)R_CharAvailable(v2) )
{
*v3++ = *v1;
}
else
{
v4 = transliterate_char(*v1);
v5 = qwcslen(v4);
v6 = &word_1B5E - v3;
if ( v5 < &word_1B5E - v3 )
v6 = qwcslen(v4);
v7 = 2LL * v6;
memcpy(v3, v4, v7);
v3 = (unsigned __int16 *)((char *)v3 + v7);
}
v2 = *++v1;
}
while ( v3 < &word_1B5E && v2 );
}
else
{
v3 = (unsigned __int16 *)&buf_0;
}
*v3 = 0;
return &buf_0;
}

original_code:
unsigned short *maybe_transliterate (unsigned short *src)
{
 unsigned short *dst, *trans;
 static unsigned short buf[2048];
 int len;
 dst = buf;
 while (*src && dst < buf+(sizeof(buf)/sizeof(buf[0]))-1) {
  if (R_CharAvailable(*src))
   *dst++ = *src;
  else {
   trans = transliterate_char (*src);
   len = ((qwcslen(trans)) < (buf+(sizeof(buf)/sizeof(buf[0]))-1 - dst) ? (qwcslen(trans)) : (buf+(sizeof(buf)/sizeof(buf[0]))-1 - dst));
   memcpy (dst, trans, len*sizeof(unsigned short));
   dst += len;
  }
  src++;
 }
 *dst = 0;
 return buf;
}

canonical_original_code:
unsigned short *maybe_transliterate(unsigned short *src)
{
 unsigned short *dst; unsigned short *trans;
 static unsigned short buf[2048];
 int len;
 dst = buf;
 while (*src && dst < buf+(sizeof(buf)/sizeof(buf[0]))-1) {
  if (R_CharAvailable(*src))
   *dst++ = *src;
  else {
   trans = transliterate_char (*src);
   len = ((qwcslen(trans)) < (buf+(sizeof(buf)/sizeof(buf[0]))-1 - dst) ? (qwcslen(trans)) : (buf+(sizeof(buf)/sizeof(buf[0]))-1 - dst));
   memcpy (dst, trans, len*sizeof(unsigned short));
   dst += len;
  }
  src++;
 }
 *dst = 0;
 return buf;
}

variable_types:
src
unsigned short *

variable_types:
dst
unsigned short *

variable_types:
trans
unsigned short *

variable_types:
buf
unsigned short [2048]

return_type: unsigned short *


decompiled_code:
void *__fastcall decode_string(char *haystack)
{
char *v1; // r14
char *v2; // rbx
char *v3; // r12
__int64 v4; // rbx
__int64 v5; // rbp
__int64 v6; // rax
char *v7; // rbp
const unsigned __int16 *v8; // rsi
char *i; // rax
char v10; // dl
char *v11; // rax
char *v12; // rbp
unsigned __int64 v13; // rdx
__int64 v14; // rbx
const char *v15; // rsi
__int64 v16; // rax
void *v18; // rbx
char v19[1027]; // [rsp+0h] [rbp-438h] BYREF
char s1[53]; // [rsp+403h] [rbp-35h] BYREF

v1 = haystack;
buf_2[0] = 0;
v2 = haystack;
while ( 1 )
{
v3 = strstr(v2, "=`");
if ( !v3 )
break;
v4 = v3 - v1 + 1;
v5 = 2048LL;
if ( (unsigned __int64)(v4 + qwcslen(buf_2)) <= 0x7FF )
v5 = qwcslen(buf_2) + v4;
v6 = str2wcs(v1);
qwcslcat(buf_2, v6, v5);
v7 = v3 + 2;
v8 = *_ctype_b_loc();
for ( i = v3 + 2; ; ++i )
{
v10 = *i;
if ( (v8[(unsigned __int8)*i] & 8) == 0 || i - v7 > 11 )
break;
}
if ( !v10 )
{
v1 = v3;
break;
}
v2 = v3 + 4;
if ( v10 == 58 )
{
v2 = i + 1;
strlcpy(s1, v3 + 2, i + 1 - v7);
v11 = strstr(v2, "`=");
v12 = v11;
if ( v11 )
{
v13 = v11 - v2 + 1;
if ( v13 > 0x400 )
v13 = 1024LL;
strlcpy(v19, v2, v13);
v14 = 0LL;
v15 = "koi8q";
while ( strcasecmp(s1, v15) )
{
++v14;
v15 = (&decode_table)[2 * v14];
if ( !v15 )
{
v2 = v12 + 2;
goto LABEL_4;
}
}
v18 = (void *)((__int64 (__fastcall *)(const char *))*(&off_3048 + 2 * (int)v14))(v19);
qwcslcat(buf_2, v18, 2048LL);
if ( v18 )
free(v18);
v3 = v12 + 2;
v2 = v12 + 2;
}
}
LABEL_4:
v1 = v3;
}
v16 = str2wcs(v1);
qwcslcat(buf_2, v16, 2048LL);
return maybe_transliterate(buf_2);
}

original_code:
unsigned short *decode_string (const char *s)
{
 static unsigned short buf[2048];
 char encoding[13];
 char enc_str[1024];
 const char *p, *q, *r;
 unsigned short *decoded;
 int i;
 buf[0] = 0;
 p = s;
 while (1)
 {
  p = strstr(p, "=`");
  if (!p)
   break;
  qwcslcat (buf, str2wcs(s), ((p-s+qwcslen(buf)+1) < (sizeof(buf)/sizeof(buf[0])) ? (p-s+qwcslen(buf)+1) : (sizeof(buf)/sizeof(buf[0]))));
  s = p;
  p += 2;
  for (q = p; ((*__ctype_b_loc ())[(int) ((*q))] & (unsigned short int) _ISalnum) && q - p < 12; q++) {
   ;
  }
  if (!*q)
   break;
  if (*q != ':') {
   p += 2;
   continue;
  }
  q++;
  ((void) (0));
  strlcpy (encoding, p, q - p);
  r = strstr(q, "`=");
  if (!r) {
   p = q;
   continue;
  }
  strlcpy (enc_str, q, ((r - q + 1) < (sizeof(enc_str)) ? (r - q + 1) : (sizeof(enc_str))));
  for (i = 0; decode_table[i].name; i++) {
   if (!strcasecmp(encoding, decode_table[i].name))
    break;
  }
  if (!decode_table[i].name) {
   p = r + 2;
   continue;
  }
  decoded = decode_table[i].func(enc_str);
  qwcslcat (buf, decoded, sizeof(buf)/sizeof(buf[0]));
  if(decoded) { free(decoded); decoded = ((void *)0); };
  s = p = r + 2;
 }
 qwcslcat (buf, str2wcs(s), sizeof(buf)/sizeof(buf[0]));
 return maybe_transliterate(buf);
}

canonical_original_code:
unsigned short *decode_string(char *s)
{
 static unsigned short buf[2048];
 char encoding[13];
 char enc_str[1024];
 char *p; char *q; char *r;
 unsigned short *decoded;
 int i;
 buf[0] = 0;
 p = s;
 while (1)
 {
  p = strstr(p, "=`");
  if (!p)
   break;
  qwcslcat (buf, str2wcs(s), ((p-s+qwcslen(buf)+1) < (sizeof(buf)/sizeof(buf[0])) ? (p-s+qwcslen(buf)+1) : (sizeof(buf)/sizeof(buf[0]))));
  s = p;
  p += 2;
  for (q = p; ((*__ctype_b_loc ())[(int) ((*q))] & (unsigned short) _ISalnum) && q - p < 12; q++) {
   ;
  }
  if (!*q)
   break;
  if (*q != ':') {
   p += 2;
   continue;
  }
  q++;
  ((void) (0));
  strlcpy (encoding, p, q - p);
  r = strstr(q, "`=");
  if (!r) {
   p = q;
   continue;
  }
  strlcpy (enc_str, q, ((r - q + 1) < (sizeof(enc_str)) ? (r - q + 1) : (sizeof(enc_str))));
  for (i = 0; decode_table[i].name; i++) {
   if (!strcasecmp(encoding, decode_table[i].name))
    break;
  }
  if (!decode_table[i].name) {
   p = r + 2;
   continue;
  }
  decoded = decode_table[i].func(enc_str);
  qwcslcat (buf, decoded, sizeof(buf)/sizeof(buf[0]));
  if(decoded) { free(decoded); decoded = ((void *)0); };
  s = p = r + 2;
 }
 qwcslcat (buf, str2wcs(s), sizeof(buf)/sizeof(buf[0]));
 return maybe_transliterate(buf);
}

variable_types:
s
char *

variable_types:
encoding
char [13]

variable_types:
p
char *

variable_types:
q
char *

variable_types:
r
char *

variable_types:
decoded
unsigned short *

variable_types: i int


decompiled_code:
__int64 IRC_filter_register_cvars()
{
Cvar_Register(irc_filter_join_part_messages);
Cvar_Register(irc_filter_quit_messages);
Cvar_Register(irc_filter_private_messages);
return Cvar_Register(irc_filter_notice_messages);
}

canonical_decompiled_code:
__int64 func0()
{
Cvar_Register(irc_filter_join_part_messages);
Cvar_Register(irc_filter_quit_messages);
Cvar_Register(irc_filter_private_messages);
return Cvar_Register(irc_filter_notice_messages);
}

original_code:
void IRC_filter_register_cvars() {
  Cvar_Register(&irc_filter_join_part_messages);
  Cvar_Register(&irc_filter_quit_messages);
  Cvar_Register(&irc_filter_private_messages);
  Cvar_Register(&irc_filter_notice_messages);
}


decompiled_code:
_BOOL8 IRC_filter_show_chanop_messages()
{
return LODWORD(irc_filter_join_part_messages[8]) == 0;
}

canonical_decompiled_code:
_BOOL8 func1()
{
return LODWORD(irc_filter_join_part_messages[8]) == 0;
}

original_code:
int IRC_filter_show_chanop_messages() {
  return (irc_filter_join_part_messages.integer == 0);
}

return_type: int


decompiled_code:
_BOOL8 IRC_filter_show_connection_messages()
{
return LODWORD(irc_filter_quit_messages[8]) == 0;
}

canonical_decompiled_code:
_BOOL8 func2()
{
return LODWORD(irc_filter_quit_messages[8]) == 0;
}

original_code:
int IRC_filter_show_connection_messages() {
  return (irc_filter_quit_messages.integer == 0);
}


decompiled_code:
_BOOL8 IRC_filter_show_private_messages()
{
return LODWORD(irc_filter_private_messages[8]) == 0;
}

canonical_decompiled_code:
_BOOL8 func3()
{
return LODWORD(irc_filter_private_messages[8]) == 0;
}

original_code:
int IRC_filter_show_private_messages() {
  return (irc_filter_private_messages.integer == 0);
}


decompiled_code:
_BOOL8 IRC_filter_show_notice_messages()
{
return LODWORD(irc_filter_notice_messages[8]) == 0;
}

canonical_decompiled_code:
_BOOL8 func4()
{
return LODWORD(irc_filter_notice_messages[8]) == 0;
}

original_code:
int IRC_filter_show_notice_messages() {
  return (irc_filter_notice_messages.integer == 0);
}


original_code:
static void XSD_Variable_Init(xml_variable_t *document)
{
    memset(document, 0, sizeof(xml_variable_t));
}

canonical_original_code:
static void XSD_Variable_Init(struct xml_variable_s *document)
{
    memset(document, 0, sizeof(xml_variable_t));
}

variable_types: struct xml_variable_s { char *document_type; char *name; char *description; enum cvartype_t { t_boolean=0, t_enum=1, t_integer=2, t_float=3, t_string=4 } value_type; union { char *string_description; char *integer_description; char *float_description; struct { char *true_description; char *false_description; } boolean_value; struct variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; } *enum_value; } value; char *remarks; } *

user_defined_types: struct xml_variable_s { char *document_type; char *name; char *description; enum cvartype_t value_type; union { char *string_description; char *integer_description; char *float_description; struct { char *true_description; char *false_description; } boolean_value; struct variable_enum_value_s *enum_value; } value; char *remarks; }


decompiled_code:
void __fastcall XSD_Variable_Free(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
_QWORD *i; // rbp
void *v6; // rdi
void *v7; // rdi
void *v8; // 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 + 6);
if ( v4 )
{
free(v4);
*((_QWORD *)ptr + 6) = 0LL;
}
switch ( *((_DWORD *)ptr + 6) )
{
case 0:
v7 = (void *)*((_QWORD *)ptr + 4);
if ( v7 )
{
free(v7);
*((_QWORD *)ptr + 4) = 0LL;
}
v8 = (void *)*((_QWORD *)ptr + 5);
if ( v8 )
goto LABEL_22;
break;
case 1:
for ( i = (_QWORD *)*((_QWORD *)ptr + 4); i; *((_QWORD *)ptr + 4) = i )
{
v6 = i;
i = (_QWORD *)i[2];
free(v6);
}
break;
case 2:
v8 = (void *)*((_QWORD *)ptr + 4);
if ( v8 )
goto LABEL_22;
break;
case 3:
v8 = (void *)*((_QWORD *)ptr + 4);
if ( v8 )
goto LABEL_22;
break;
case 4:
v8 = (void *)*((_QWORD *)ptr + 4);
if ( v8 )
LABEL_22:
free(v8);
break;
default:
break;
}
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
_QWORD *i; // rbp
void *v6; // rdi
void *v7; // rdi
void *v8; // 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 + 6);
if ( v4 )
{
free(v4);
*((_QWORD *)ptr + 6) = 0LL;
}
switch ( *((_DWORD *)ptr + 6) )
{
case 0:
v7 = (void *)*((_QWORD *)ptr + 4);
if ( v7 )
{
free(v7);
*((_QWORD *)ptr + 4) = 0LL;
}
v8 = (void *)*((_QWORD *)ptr + 5);
if ( v8 )
goto LABEL_22;
break;
case 1:
for ( i = (_QWORD *)*((_QWORD *)ptr + 4); i; *((_QWORD *)ptr + 4) = i )
{
v6 = i;
i = (_QWORD *)i[2];
free(v6);
}
break;
case 2:
v8 = (void *)*((_QWORD *)ptr + 4);
if ( v8 )
goto LABEL_22;
break;
case 3:
v8 = (void *)*((_QWORD *)ptr + 4);
if ( v8 )
goto LABEL_22;
break;
case 4:
v8 = (void *)*((_QWORD *)ptr + 4);
if ( v8 )
LABEL_22:
free(v8);
break;
default:
break;
}
if ( *(_QWORD *)ptr )
free(*(void **)ptr);
free(ptr);
}

original_code:
void XSD_Variable_Free(xml_t *doc)
{
    xml_variable_t *document = (xml_variable_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); };
    switch (document->value_type)
    {
    case t_boolean:
        if (document->value.boolean_value.true_description)
            if(document->value.boolean_value.true_description) { free(document->value.boolean_value.true_description); document->value.boolean_value.true_description = ((void *)0); };
        if (document->value.boolean_value.false_description)
            if(document->value.boolean_value.false_description) { free(document->value.boolean_value.false_description); document->value.boolean_value.false_description = ((void *)0); };
        break;
    case t_integer:
        if (document->value.integer_description)
            if(document->value.integer_description) { free(document->value.integer_description); document->value.integer_description = ((void *)0); };
        break;
    case t_float:
        if (document->value.float_description)
            if(document->value.float_description) { free(document->value.float_description); document->value.float_description = ((void *)0); };
        break;
    case t_string:
        if (document->value.string_description)
            if(document->value.string_description) { free(document->value.string_description); document->value.string_description = ((void *)0); };
        break;
    case t_enum:
        while (document->value.enum_value)
        {
            variable_enum_value_t *next = document->value.enum_value->next;
            if(document->value.enum_value) { free(document->value.enum_value); document->value.enum_value = ((void *)0); };
            document->value.enum_value = next;
        }
        break;
    }
    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_Variable_Free(struct xml_s *doc)
{
    struct xml_variable_s *document = (xml_variable_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); };
    switch (document->value_type)
    {
    case t_boolean:
        if (document->value.boolean_value.true_description)
            if(document->value.boolean_value.true_description) { free(document->value.boolean_value.true_description); document->value.boolean_value.true_description = ((void *)0); };
        if (document->value.boolean_value.false_description)
            if(document->value.boolean_value.false_description) { free(document->value.boolean_value.false_description); document->value.boolean_value.false_description = ((void *)0); };
        break;
    case t_integer:
        if (document->value.integer_description)
            if(document->value.integer_description) { free(document->value.integer_description); document->value.integer_description = ((void *)0); };
        break;
    case t_float:
        if (document->value.float_description)
            if(document->value.float_description) { free(document->value.float_description); document->value.float_description = ((void *)0); };
        break;
    case t_string:
        if (document->value.string_description)
            if(document->value.string_description) { free(document->value.string_description); document->value.string_description = ((void *)0); };
        break;
    case t_enum:
        while (document->value.enum_value)
        {
            struct variable_enum_value_s *next = document->value.enum_value->next;
            if(document->value.enum_value) { free(document->value.enum_value); document->value.enum_value = ((void *)0); };
            document->value.enum_value = next;
        }
        break;
    }
    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 variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; } *

user_defined_types: enum cvartype_t { t_boolean=0, t_enum=1, t_integer=2, t_float=3, t_string=4 }


decompiled_code:
__int64 __fastcall XSD_Variable_Convert(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
_QWORD *v3; // rbx

v2 = XSD_Document_New();
*(_QWORD *)(v2 + 8) = Q_strdup(*(_QWORD *)(a1 + 8));
v3 = (_QWORD *)Q_malloc(24LL, a2);
*v3 = 0LL;
v3[1] = 0LL;
v3[2] = 0LL;
v3[2] = Q_strdup(*(_QWORD *)(a1 + 16));
*(_QWORD *)(v2 + 32) = v3;
return v2;
}

original_code:
xml_document_t * XSD_Variable_Convert(xml_t *doc)
{
    xml_document_t *ret;
    xml_variable_t *var = (xml_variable_t *) doc;
    ret = XSD_Document_New();
    ret->title = Q_strdup(var->name);
    {
        document_tag_text_t *text;
        text = (document_tag_text_t *) Q_malloc(sizeof(document_tag_text_t));
        memset(text, 0, sizeof(document_tag_text_t));
        text->type = tag_text;
        text->text = Q_strdup(var->description);
        ret->content = (document_tag_t *) text;
    }
    return ret;
}

canonical_original_code:
struct xml_document_s *XSD_Variable_Convert(struct xml_s *doc)
{
    struct xml_document_s *ret;
    struct xml_variable_s *var = (xml_variable_t *) doc;
    ret = XSD_Document_New();
    ret->title = Q_strdup(var->name);
    {
        struct document_tag_text_s *text;
        text = (struct document_tag_text_s *) Q_malloc(sizeof(document_tag_text_t));
        memset(text, 0, sizeof(document_tag_text_t));
        text->type = tag_text;
        text->text = Q_strdup(var->description);
        ret->content = (struct document_tag_s *) text;
    }
    return ret;
}

variable_types: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct xml_document_author_s *next; char *name; char *email; char *im; } *authors; struct document_tag_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s *next; } *content; } *

variable_types: struct document_tag_text_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s *next; } *next; char *text; } *

user_defined_types: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s *authors; struct document_tag_s *content; }

user_defined_types: struct document_tag_text_s { enum document_tag_type_t type; struct document_tag_s *next; char *text; }

user_defined_types: struct document_tag_s { enum document_tag_type_t type; struct document_tag_s *next; }

user_defined_types: struct xml_document_author_s { enum document_tag_type_t type; struct xml_document_author_s *next; char *name; char *email; char *im; }

user_defined_types: struct variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; }


decompiled_code:
__int64 __fastcall R_MQW_NetGraph(char a1, __int64 a2, __int64 a3, int a4, __int64 a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14)
{
int v16; // er12
int v17; // er14
__int64 result; // rax
float v19; // xmm2_4
unsigned int v20; // er15
__int64 v21; // r8
size_t v22; // rbx
size_t v23; // rax
int v24; // eax
int v25; // eax
unsigned int v26; // er12
int v27; // er15
int v28; // ebx
int v29; // eax
char *v30; // rdi
unsigned int v31; // ebp
int v32; // ebp
int v33; // er13
double v34; // xmm0_8
double v35; // xmm3_8
__m128i v36; // xmm5
unsigned int v37; // ebp
__m128i v38; // xmm7
float v39; // xmm1_4
unsigned int v40; // [rsp+4h] [rbp-134h]
unsigned int v41; // [rsp+8h] [rbp-130h]
float v42; // [rsp+Ch] [rbp-12Ch]
int v43; // [rsp+10h] [rbp-128h]
int v46; // [rsp+20h] [rbp-118h]
unsigned int v47; // [rsp+24h] [rbp-114h]
unsigned int v48; // [rsp+2Ch] [rbp-10Ch]
char s[128]; // [rsp+30h] [rbp-108h] BYREF
char v50[136]; // [rsp+B0h] [rbp-88h] BYREF

v16 = a11;
v17 = a12;
if ( !hud_5 )
{
hud_5 = HUD_Find("netgraph");
par_alpha_4 = HUD_FindVar(hud_5, "alpha");
par_full_3 = HUD_FindVar(hud_5, "full");
par_inframes_2 = HUD_FindVar(hud_5, "inframes");
par_maxping_1 = HUD_FindVar(hud_5, "scale");
par_dropheight_0 = HUD_FindVar(hud_5, "lostscale");
}
result = CL_CalcNet();
if ( v16 < 0 )
{
v41 = 256;
}
else
{
if ( v16 <= 15 )
return result;
result = 256LL;
if ( v16 <= 256 )
result = (unsigned int)v16;
v41 = result;
}
if ( v17 < 0 )
{
v17 = 32;
}
else if ( v17 > 256 )
{
v17 = 256;
}
else if ( !v17 )
{
return result;
}
v19 = *(float *)(par_alpha_4 + 32);
v42 = v19;
if ( v19 < 0.0 )
{
v42 = *(float *)&LC0;
}
else if ( v19 > 1.0 )
{
v42 = *(float *)&LC0;
}
v43 = a9;
v20 = a10;
if ( a9 >= 0 && a10 >= 0 )
{
if ( a4 >= 0 )
{
LABEL_22:
if ( a6 < 0 )
{
snprintf(v50, 0x50uLL, " %3i%% packet loss", (unsigned int)a4);
v24 = v41 + 6;
if ( (int)(v41 - 1) >= 0 )
v24 = v41 - 1;
v50[v24 >> 3] = 0;
Draw_String((unsigned int)(v43 + 3), v20, v50);
}
else
{
strlcpy(v50, &unk_9A8, 80LL);
v21 = 99LL;
if ( a4 <= 99 )
v21 = (unsigned int)a4;
snprintf(s, 0x80uLL, format, (unsigned int)a6, v21);
v22 = strlen(s);
v23 = strlen(v50);
strlcpy(&v50[v23 - v22 - 3], s, v22 + 83 - v23);
Draw_String((unsigned int)(v43 + 4), v20, v50);
}
v20 += 8;
}
LABEL_27:
if ( v42 < 1.0 )
{
glDisable(3008LL);
glEnable(3042LL);
}
glTexEnvf(8960LL, 8704LL, 8448.0);
if ( *(float *)(par_full_3 + 32) == 0.0 )
GL_Bind((unsigned int)netgraphtexture);
else
GL_Bind(whitetexture);
v25 = v17 + v20;
v47 = v17 + v20;
if ( a14 )
v25 = v20;
v46 = v25;
v26 = v41 - 1;
v48 = v20;
v27 = a14;
while ( 1 )
{
v31 = v41 - 1 - v26;
v28 = *(_DWORD *)(a3 + 4LL * (unsigned __int8)(v26 + a1 - v41));
switch ( v28 )
{
case 10000:
v29 = 111;
break;
case 9999:
v29 = 79;
break;
case 9998:
v29 = 208;
break;
case 10001:
v29 = 4;
break;
default:
if ( v28 <= 8999 )
{
if ( *(float *)(par_inframes_2 + 32) == 0.0 )
v28 = (int)(float)((float)(v17 * v28) / *(float *)(par_maxping_1 + 32));
v29 = 254;
goto LABEL_45;
}
v29 = 254;
break;
}
v39 = (float)v17 * *(float *)(par_dropheight_0 + 32);
if ( v39 <= (float)v17 )
v28 = (int)v39;
else
v28 = (int)(float)v17;
LABEL_45:
if ( v28 < 0 )
v28 = 0;
if ( v28 > v17 )
v28 = v17;
v30 = (char *)&d_8to24table + 4 * v29;
if ( v42 < 1.0 )
glColor4ub(
*((unsigned __int8 *)&d_8to24table + 4 * v29),
(unsigned __int8)v30[1],
(unsigned __int8)v30[2],
(unsigned __int8)(int)(float)(v42 * 255.0));
else
glColor4ubv(v30);
if ( !a13 )
v31 = v26;
v32 = v43 + v31;
v33 = v47 - v28;
if ( v27 )
v33 = v28 + v48;
glBegin(7LL);
glTexCoord2f(0.0);
HIDWORD(v34) = 0;
*(float *)&v34 = (float)v46;
HIDWORD(v35) = 0;
*(float *)&v35 = (float)v32;
*(float *)&v40 = (float)v32;
glVertex2f(v35, v34);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC0));
v36 = 0LL;
*(float *)v36.m128i_i32 = (float)(v32 + 1);
v37 = _mm_cvtsi128_si32(v36);
glVertex2f(*(double *)v36.m128i_i64, COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)v46)));
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC0));
v38 = 0LL;
*(float *)v38.m128i_i32 = (float)v33;
glVertex2f(*(double *)_mm_cvtsi32_si128(v37).m128i_i64, *(double *)v38.m128i_i64);
glTexCoord2f(0.0);
glVertex2f(COERCE_DOUBLE((unsigned __int64)v40), *(double *)_mm_cvtsi32_si128(_mm_cvtsi128_si32(v38)).m128i_i64);
glEnd();
if ( --v26 == -1 )
{
glColor3f(1.0, 1.0);
glTexEnvf(8960LL, 8704LL, 7681.0);
glEnable(3008LL);
glDisable(3042LL);
return glEnable(3553LL);
}
}
}
if ( a4 >= 0 )
{
result = HUD_PrepareDraw(hud_5, v41, (unsigned int)(v17 + 8), &a9, &a10);
if ( !(_DWORD)result )
return result;
v43 = a9;
v20 = a10;
goto LABEL_22;
}
result = HUD_PrepareDraw(hud_5, v41, (unsigned int)v17, &a9, &a10);
if ( (_DWORD)result )
{
v43 = a9;
v20 = a10;
goto LABEL_27;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1, __int64 a2, __int64 a3, int a4, __int64 a5, int a6, int a7, int a8, int a9, int a10, int a11, int a12, int a13, int a14)
{
int v16; // er12
int v17; // er14
__int64 result; // rax
float v19; // xmm2_4
unsigned int v20; // er15
__int64 v21; // r8
size_t v22; // rbx
size_t v23; // rax
int v24; // eax
int v25; // eax
unsigned int v26; // er12
int v27; // er15
int v28; // ebx
int v29; // eax
char *v30; // rdi
unsigned int v31; // ebp
int v32; // ebp
int v33; // er13
double v34; // xmm0_8
double v35; // xmm3_8
__m128i v36; // xmm5
unsigned int v37; // ebp
__m128i v38; // xmm7
float v39; // xmm1_4
unsigned int v40; // [rsp+4h] [rbp-134h]
unsigned int v41; // [rsp+8h] [rbp-130h]
float v42; // [rsp+Ch] [rbp-12Ch]
int v43; // [rsp+10h] [rbp-128h]
int v46; // [rsp+20h] [rbp-118h]
unsigned int v47; // [rsp+24h] [rbp-114h]
unsigned int v48; // [rsp+2Ch] [rbp-10Ch]
char s[128]; // [rsp+30h] [rbp-108h] BYREF
char v50[136]; // [rsp+B0h] [rbp-88h] BYREF

v16 = a11;
v17 = a12;
if ( !hud_5 )
{
hud_5 = HUD_Find("netgraph");
par_alpha_4 = HUD_FindVar(hud_5, "alpha");
par_full_3 = HUD_FindVar(hud_5, "full");
par_inframes_2 = HUD_FindVar(hud_5, "inframes");
par_maxping_1 = HUD_FindVar(hud_5, "scale");
par_dropheight_0 = HUD_FindVar(hud_5, "lostscale");
}
result = CL_CalcNet();
if ( v16 < 0 )
{
v41 = 256;
}
else
{
if ( v16 <= 15 )
return result;
result = 256LL;
if ( v16 <= 256 )
result = (unsigned int)v16;
v41 = result;
}
if ( v17 < 0 )
{
v17 = 32;
}
else if ( v17 > 256 )
{
v17 = 256;
}
else if ( !v17 )
{
return result;
}
v19 = *(float *)(par_alpha_4 + 32);
v42 = v19;
if ( v19 < 0.0 )
{
v42 = *(float *)&LC0;
}
else if ( v19 > 1.0 )
{
v42 = *(float *)&LC0;
}
v43 = a9;
v20 = a10;
if ( a9 >= 0 && a10 >= 0 )
{
if ( a4 >= 0 )
{
LABEL_22:
if ( a6 < 0 )
{
snprintf(v50, 0x50uLL, " %3i%% packet loss", (unsigned int)a4);
v24 = v41 + 6;
if ( (int)(v41 - 1) >= 0 )
v24 = v41 - 1;
v50[v24 >> 3] = 0;
Draw_String((unsigned int)(v43 + 3), v20, v50);
}
else
{
strlcpy(v50, &unk_9A8, 80LL);
v21 = 99LL;
if ( a4 <= 99 )
v21 = (unsigned int)a4;
snprintf(s, 0x80uLL, format, (unsigned int)a6, v21);
v22 = strlen(s);
v23 = strlen(v50);
strlcpy(&v50[v23 - v22 - 3], s, v22 + 83 - v23);
Draw_String((unsigned int)(v43 + 4), v20, v50);
}
v20 += 8;
}
LABEL_27:
if ( v42 < 1.0 )
{
glDisable(3008LL);
glEnable(3042LL);
}
glTexEnvf(8960LL, 8704LL, 8448.0);
if ( *(float *)(par_full_3 + 32) == 0.0 )
GL_Bind((unsigned int)netgraphtexture);
else
GL_Bind(whitetexture);
v25 = v17 + v20;
v47 = v17 + v20;
if ( a14 )
v25 = v20;
v46 = v25;
v26 = v41 - 1;
v48 = v20;
v27 = a14;
while ( 1 )
{
v31 = v41 - 1 - v26;
v28 = *(_DWORD *)(a3 + 4LL * (unsigned __int8)(v26 + a1 - v41));
switch ( v28 )
{
case 10000:
v29 = 111;
break;
case 9999:
v29 = 79;
break;
case 9998:
v29 = 208;
break;
case 10001:
v29 = 4;
break;
default:
if ( v28 <= 8999 )
{
if ( *(float *)(par_inframes_2 + 32) == 0.0 )
v28 = (int)(float)((float)(v17 * v28) / *(float *)(par_maxping_1 + 32));
v29 = 254;
goto LABEL_45;
}
v29 = 254;
break;
}
v39 = (float)v17 * *(float *)(par_dropheight_0 + 32);
if ( v39 <= (float)v17 )
v28 = (int)v39;
else
v28 = (int)(float)v17;
LABEL_45:
if ( v28 < 0 )
v28 = 0;
if ( v28 > v17 )
v28 = v17;
v30 = (char *)&d_8to24table + 4 * v29;
if ( v42 < 1.0 )
glColor4ub(
*((unsigned __int8 *)&d_8to24table + 4 * v29),
(unsigned __int8)v30[1],
(unsigned __int8)v30[2],
(unsigned __int8)(int)(float)(v42 * 255.0));
else
glColor4ubv(v30);
if ( !a13 )
v31 = v26;
v32 = v43 + v31;
v33 = v47 - v28;
if ( v27 )
v33 = v28 + v48;
glBegin(7LL);
glTexCoord2f(0.0);
HIDWORD(v34) = 0;
*(float *)&v34 = (float)v46;
HIDWORD(v35) = 0;
*(float *)&v35 = (float)v32;
*(float *)&v40 = (float)v32;
glVertex2f(v35, v34);
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC0));
v36 = 0LL;
*(float *)v36.m128i_i32 = (float)(v32 + 1);
v37 = _mm_cvtsi128_si32(v36);
glVertex2f(*(double *)v36.m128i_i64, COERCE_DOUBLE((unsigned __int64)COERCE_UNSIGNED_INT((float)v46)));
glTexCoord2f(COERCE_DOUBLE((unsigned __int64)LC0));
v38 = 0LL;
*(float *)v38.m128i_i32 = (float)v33;
glVertex2f(*(double *)_mm_cvtsi32_si128(v37).m128i_i64, *(double *)v38.m128i_i64);
glTexCoord2f(0.0);
glVertex2f(COERCE_DOUBLE((unsigned __int64)v40), *(double *)_mm_cvtsi32_si128(_mm_cvtsi128_si32(v38)).m128i_i64);
glEnd();
if ( --v26 == -1 )
{
glColor3f(1.0, 1.0);
glTexEnvf(8960LL, 8704LL, 7681.0);
glEnable(3008LL);
glDisable(3042LL);
return glEnable(3553LL);
}
}
}
if ( a4 >= 0 )
{
result = HUD_PrepareDraw(hud_5, v41, (unsigned int)(v17 + 8), &a9, &a10);
if ( !(_DWORD)result )
return result;
v43 = a9;
v20 = a10;
goto LABEL_22;
}
result = HUD_PrepareDraw(hud_5, v41, (unsigned int)v17, &a9, &a10);
if ( (_DWORD)result )
{
v43 = a9;
v20 = a10;
goto LABEL_27;
}
return result;
}

original_code:
void R_MQW_NetGraph(int outgoing_sequence, int incoming_sequence, int *packet_latency,
                int lost, int minping, int avgping, int maxping, int devping,
                int posx, int posy, int width, int height, int revx, int revy)
{
    int a, x, i, y;
    char st[80];
    float alpha;
    static hud_t *hud = ((void *)0);
    static cvar_t
        *par_alpha, *par_full, *par_inframes, *par_maxping, *par_dropheight;
    if (hud == ((void *)0))
    {
        hud = HUD_Find("netgraph");
        par_alpha = HUD_FindVar(hud, "alpha");
        par_full = HUD_FindVar(hud, "full");
        par_inframes = HUD_FindVar(hud, "inframes");
        par_maxping = HUD_FindVar(hud, "scale");
        par_dropheight = HUD_FindVar(hud, "lostscale");
    }
    CL_CalcNet();
    alpha = par_alpha->value;
    if (width < 0)
        width = 256;
    width = ((width) < (256) ? (width) : (256));
    if (width < 16)
        return;
    if (height < 0)
        height = 32;
    if (height > 256)
        height = 256;
    if (height < 1)
        return;
    if (alpha < 0 || alpha > 1)
        alpha = 1;
    if (posx < 0 || posy < 0)
    {
        int w, h;
        w = width;
        h = height;
        if (lost >= 0)
            h += 8;
        if (!HUD_PrepareDraw(hud, w, h, &posx, &posy))
            return;
    }
    x = posx;
    y = posy;
    if (lost >= 0)
    {
        if (avgping < 0)
        {
            snprintf(st, sizeof (st)," %3i%% packet loss", lost);
            st[(width-1)/8] = 0;
            Draw_String(x+3, y, st);
        }
        else
        {
            char buf[128];
            if (lost > 99)
                lost = 99;
            strlcpy(st, "\x1D\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1F", sizeof (st));
            snprintf (buf, sizeof (buf), " %i \xf %i%% ", avgping, lost);
            strlcpy (st + strlen(st) - strlen(buf) - 3, buf, sizeof (st) - strlen (st) + strlen (buf) + 3);
            Draw_String(x+4, y, st);
        }
        y += 8;
    }
    if (alpha < 1)
    {
        glDisable(0x0BC0);
        glEnable (0x0BE2);
    }
    glTexEnvf(0x2300, 0x2200, 0x2100);
    if (par_full->value)
        GL_Bind(whitetexture);
    else
        GL_Bind(netgraphtexture);
    for (a=0; a < width; a++)
    {
        int px, py1, py2;
        unsigned char *pColor;
        int h, color;
        i = (outgoing_sequence-a-1) & 255;
        h = packet_latency[i];
        if (h == 10000)
            color = 0x6f;
        else if (h == 9999)
            color = 0x4f;
        else if (h == 9998)
            color = 0xd0;
        else if (h == 10001)
            color = 4;
        else
            color = 0xfe;
        if (h < 9000)
        {
            if (!par_inframes->value)
                h = h*height/par_maxping->value;
        }
        else
            h = ((height) < (height*par_dropheight->value) ? (height) : (height*par_dropheight->value));
        (h = ((((h) > (0) ? (h) : (0))) < (height) ? (((h) > (0) ? (h) : (0))) : (height)));
        pColor = (unsigned char *) &d_8to24table[(byte) color];
        if (alpha < 1)
            glColor4ub (pColor[0], pColor[1], pColor[2], (byte)(alpha*255));
        else
            glColor4ubv ( pColor );
        px = x + (revx ? a : width-a-1);
        if (revy)
        {
            py1 = y + 0;
            py2 = y + h;
        }
        else
        {
            py1 = y + height;
            py2 = y + height-h;
        }
        glBegin (0x0007);
        glTexCoord2f (0, 0);
        glVertex2f (px, py1);
        glTexCoord2f (1, 0);
        glVertex2f (px+1, py1);
        glTexCoord2f (1, h/2.0);
        glVertex2f (px+1, py2);
        glTexCoord2f (0, h/2.0);
        glVertex2f (px, py2);
        glEnd ();
    }
    glColor3f(1,1,1);
    glTexEnvf ( 0x2300, 0x2200, 0x1E01 );
    glEnable(0x0BC0);
    glDisable(0x0BE2);
    glEnable(0x0DE1);
}

canonical_original_code:
void R_MQW_NetGraph(int outgoing_sequence, int incoming_sequence, int *packet_latency, int lost, int minping, int avgping, int maxping, int devping, int posx, int posy, int width, int height, int revx, int revy)
{
    int a; int x; int i; int y;
    char st[80];
    float alpha;
    static struct hud_s *hud = ((void *)0);
    static struct cvar_s *par_alpha; static struct cvar_s *par_full; static struct cvar_s *par_inframes; static struct cvar_s *par_maxping; static struct cvar_s *par_dropheight;
    if (hud == ((void *)0))
    {
        hud = HUD_Find("netgraph");
        par_alpha = HUD_FindVar(hud, "alpha");
        par_full = HUD_FindVar(hud, "full");
        par_inframes = HUD_FindVar(hud, "inframes");
        par_maxping = HUD_FindVar(hud, "scale");
        par_dropheight = HUD_FindVar(hud, "lostscale");
    }
    CL_CalcNet();
    alpha = par_alpha->value;
    if (width < 0)
        width = 256;
    width = ((width) < (256) ? (width) : (256));
    if (width < 16)
        return;
    if (height < 0)
        height = 32;
    if (height > 256)
        height = 256;
    if (height < 1)
        return;
    if (alpha < 0 || alpha > 1)
        alpha = 1;
    if (posx < 0 || posy < 0)
    {
        int w; int h;
        w = width;
        h = height;
        if (lost >= 0)
            h += 8;
        if (!HUD_PrepareDraw(hud, w, h, &posx, &posy))
            return;
    }
    x = posx;
    y = posy;
    if (lost >= 0)
    {
        if (avgping < 0)
        {
            snprintf(st, sizeof (st)," %3i%% packet loss", lost);
            st[(width-1)/8] = 0;
            Draw_String(x+3, y, st);
        }
        else
        {
            char buf[128];
            if (lost > 99)
                lost = 99;
            strlcpy(st, "\x1D\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1E\x1F", sizeof (st));
            snprintf (buf, sizeof (buf), " %i \xf %i%% ", avgping, lost);
            strlcpy (st + strlen(st) - strlen(buf) - 3, buf, sizeof (st) - strlen (st) + strlen (buf) + 3);
            Draw_String(x+4, y, st);
        }
        y += 8;
    }
    if (alpha < 1)
    {
        glDisable(0x0BC0);
        glEnable (0x0BE2);
    }
    glTexEnvf(0x2300, 0x2200, 0x2100);
    if (par_full->value)
        GL_Bind(whitetexture);
    else
        GL_Bind(netgraphtexture);
    for (a=0; a < width; a++)
    {
        int px; int py1; int py2;
        unsigned char *pColor;
        int h; int color;
        i = (outgoing_sequence-a-1) & 255;
        h = packet_latency[i];
        if (h == 10000)
            color = 0x6f;
        else if (h == 9999)
            color = 0x4f;
        else if (h == 9998)
            color = 0xd0;
        else if (h == 10001)
            color = 4;
        else
            color = 0xfe;
        if (h < 9000)
        {
            if (!par_inframes->value)
                h = h*height/par_maxping->value;
        }
        else
            h = ((height) < (height*par_dropheight->value) ? (height) : (height*par_dropheight->value));
        (h = ((((h) > (0) ? (h) : (0))) < (height) ? (((h) > (0) ? (h) : (0))) : (height)));
        pColor = (unsigned char *) &d_8to24table[(unsigned char) color];
        if (alpha < 1)
            glColor4ub (pColor[0], pColor[1], pColor[2], (byte)(alpha*255));
        else
            glColor4ubv ( pColor );
        px = x + (revx ? a : width-a-1);
        if (revy)
        {
            py1 = y + 0;
            py2 = y + h;
        }
        else
        {
            py1 = y + height;
            py2 = y + height-h;
        }
        glBegin (0x0007);
        glTexCoord2f (0, 0);
        glVertex2f (px, py1);
        glTexCoord2f (1, 0);
        glVertex2f (px+1, py1);
        glTexCoord2f (1, h/2.0);
        glVertex2f (px+1, py2);
        glTexCoord2f (0, h/2.0);
        glVertex2f (px, py2);
        glEnd ();
    }
    glColor3f(1,1,1);
    glTexEnvf ( 0x2300, 0x2200, 0x1E01 );
    glEnable(0x0BC0);
    glDisable(0x0BE2);
    glEnable(0x0DE1);
}

variable_types: lost int

variable_types: minping int

variable_types: avgping int

variable_types: maxping int

variable_types: devping int

variable_types: posx int

variable_types: posy int

variable_types: width int

variable_types: height int

variable_types: revx int

variable_types: revy int

variable_types: a int

variable_types: x int

variable_types: y int

variable_types:
st
char [80]

variable_types: alpha float

variable_types: struct hud_s { char *name; char *description; void (*draw_func)(struct hud_s *); struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool { false=0, true=1 } *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool { false=0, true=1 } modified; enum qbool { false=0, true=1 } teamplay; struct cvar_group_s { char name[65]; int count; struct cvar_s *head; struct cvar_group_s *next; } *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; } *order; struct cvar_s *show; struct cvar_s *frame; struct cvar_s *frame_color; unsigned char frame_color_cache[4]; struct cvar_s *opacity; struct cvar_s *place; struct hud_s *place_hud; enum qbool { false=0, true=1 } place_outside; int place_num; struct cvar_s *align_x; struct cvar_s *align_y; int align_x_num; int align_y_num; struct cvar_s *pos_x; struct cvar_s *pos_y; struct cvar_s **params; int num_params; enum cactive_t { ca_disconnected=0, ca_demostart=1, ca_connected=2, ca_onserver=3, ca_active=4 } min_state; unsigned int flags; int lx; int al; int last_try_sequence; int last_draw_sequence; struct hud_s *next; } *

variable_types: w int

variable_types: h int

variable_types:
buf
char [128]

variable_types: px int

variable_types:
pColor
unsigned char *

variable_types: color int

user_defined_types: struct hud_s { char *name; char *description; void (*draw_func)(struct hud_s *); struct cvar_s *order; struct cvar_s *show; struct cvar_s *frame; struct cvar_s *frame_color; unsigned char frame_color_cache[4]; struct cvar_s *opacity; struct cvar_s *place; struct hud_s *place_hud; enum qbool place_outside; int place_num; struct cvar_s *align_x; struct cvar_s *align_y; int align_x_num; int align_y_num; struct cvar_s *pos_x; struct cvar_s *pos_y; struct cvar_s **params; int num_params; enum cactive_t min_state; unsigned int flags; int lx; int al; int last_try_sequence; int last_draw_sequence; struct hud_s *next; }

user_defined_types: struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool modified; enum qbool teamplay; struct cvar_group_s *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; }


decompiled_code:
__int64 __fastcall thread_func(_DWORD *a1)
{
int v1; // eax
size_t v2; // rax
int v3; // eax
size_t v4; // rax

*a1 += 50;
_mythread_debug_futex_init();
futex_down(&debug_futex);
v1 = mythread_self();
sprintf(&debug_msg, "Thread %ld: Incremented count by 50 and will now yield\n", v1);
v2 = strlen(&debug_msg);
write(1, &debug_msg, v2);
futex_up(&debug_futex);
mythread_yield();
*a1 += 50;
_mythread_debug_futex_init();
futex_down(&debug_futex);
v3 = mythread_self();
sprintf(&debug_msg, "Thread %ld: Incremented count by 50 and will now exit\n", v3);
v4 = strlen(&debug_msg);
write(1, &debug_msg, v4);
futex_up(&debug_futex);
mythread_exit(0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1)
{
int v1; // eax
size_t v2; // rax
int v3; // eax
size_t v4; // rax

*a1 += 50;
_mythread_debug_futex_init();
func3(&debug_futex);
v1 = mythread_self();
sprintf(&debug_msg, "Thread %ld: Incremented count by 50 and will now yield\n", v1);
v2 = strlen(&debug_msg);
write(1, &debug_msg, v2);
func4(&debug_futex);
mythread_yield();
*a1 += 50;
_mythread_debug_futex_init();
func3(&debug_futex);
v3 = mythread_self();
sprintf(&debug_msg, "Thread %ld: Incremented count by 50 and will now exit\n", v3);
v4 = strlen(&debug_msg);
write(1, &debug_msg, v4);
func4(&debug_futex);
mythread_exit(0LL);
return 0LL;
}

original_code:
void *thread_func(void *arg)
{
 int *count = (int *)arg;
 *count = *count + 50;
 __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Thread %ld: Incremented count by 50 and will now yield\n", (unsigned long)mythread_self().tid); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 mythread_yield();
 *count = *count + 50;
 __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Thread %ld: Incremented count by 50 and will now exit\n", (unsigned long)mythread_self().tid); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 mythread_exit(((void *)0));
 return ((void *)0);
}

variable_types:
arg
void *

variable_types:
count
int *

return_type: void *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
int i; // ebp
__int64 j; // rbx
size_t v6; // rax
size_t v7; // rax
size_t v8; // rax
char v10[96]; // [rsp+8h] [rbp-60h] BYREF

v3 = 0LL;
for ( i = 0; i != 8; ++i )
{
*(_DWORD *)&v10[v3 + 8] = i;
mythread_create(&v10[v3 + 40], 0LL, thread_func, &v10[v3 + 8]);
v3 += 4LL;
}
for ( j = 0LL; j != 8; ++j )
{
_mythread_debug_futex_init();
futex_down(&debug_futex);
sprintf(&debug_msg, "Main: Will now wait for thread %ld. Yielding..\n", *(int *)&v10[4 * j + 40]);
v6 = strlen(&debug_msg);
write(1, &debug_msg, v6);
futex_up(&debug_futex);
mythread_join(*(unsigned int *)&v10[4 * (int)j + 40], v10);
_mythread_debug_futex_init();
futex_down(&debug_futex);
sprintf(
&debug_msg,
"Main: Thread %ld exited and increment count to %d\n",
*(int *)&v10[4 * j + 40],
*(unsigned int *)&v10[4 * j + 8]);
v7 = strlen(&debug_msg);
write(1, &debug_msg, v7);
futex_up(&debug_futex);
}
_mythread_debug_futex_init();
futex_down(&debug_futex);
*(_QWORD *)&debug_msg = 0x6C41203A6E69614DLL;
*((_QWORD *)&debug_msg + 1) = 0x646165726874206CLL;
*((_QWORD *)&debug_msg + 2) = 0x656C706D6F632073LL;
*((_QWORD *)&debug_msg + 3) = 0x6365786520646574LL;
*((_QWORD *)&debug_msg + 4) = 0x57202E6E6F697475LL;
*((_QWORD *)&debug_msg + 5) = 0x20776F6E206C6C69LL;
*((_QWORD *)&debug_msg + 6) = 0xA2E2E74697865LL;
v8 = strlen(&debug_msg);
write(1, &debug_msg, v8);
futex_up(&debug_futex);
mythread_exit(0LL);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
int i; // ebp
__int64 j; // rbx
size_t v6; // rax
size_t v7; // rax
size_t v8; // rax
char v10[96]; // [rsp+8h] [rbp-60h] BYREF

v3 = 0LL;
for ( i = 0; i != 8; ++i )
{
*(_DWORD *)&v10[v3 + 8] = i;
mythread_create(&v10[v3 + 40], 0LL, thread_func, &v10[v3 + 8]);
v3 += 4LL;
}
for ( j = 0LL; j != 8; ++j )
{
_mythread_debug_futex_init();
func3(&debug_futex);
sprintf(&debug_msg, "Main: Will now wait for thread %ld. Yielding..\n", *(int *)&v10[4 * j + 40]);
v6 = strlen(&debug_msg);
write(1, &debug_msg, v6);
func4(&debug_futex);
mythread_join(*(unsigned int *)&v10[4 * (int)j + 40], v10);
_mythread_debug_futex_init();
func3(&debug_futex);
sprintf(
&debug_msg,
"Main: Thread %ld exited and increment count to %d\n",
*(int *)&v10[4 * j + 40],
*(unsigned int *)&v10[4 * j + 8]);
v7 = strlen(&debug_msg);
write(1, &debug_msg, v7);
func4(&debug_futex);
}
_mythread_debug_futex_init();
func3(&debug_futex);
*(_QWORD *)&debug_msg = 0x6C41203A6E69614DLL;
*((_QWORD *)&debug_msg + 1) = 0x646165726874206CLL;
*((_QWORD *)&debug_msg + 2) = 0x656C706D6F632073LL;
*((_QWORD *)&debug_msg + 3) = 0x6365786520646574LL;
*((_QWORD *)&debug_msg + 4) = 0x57202E6E6F697475LL;
*((_QWORD *)&debug_msg + 5) = 0x20776F6E206C6C69LL;
*((_QWORD *)&debug_msg + 6) = 0xA2E2E74697865LL;
v8 = strlen(&debug_msg);
write(1, &debug_msg, v8);
func4(&debug_futex);
mythread_exit(0LL);
return 0;
}

original_code:
int main()
{
 mythread_t threads[8];
 int count[8];
 int i;
 char *status;
 for (i = 0; i < 8; i++) {
  count[i] = i;
  mythread_create(&threads[i], ((void *)0), thread_func, &count[i]);
 }
 for (i = 0; i < 8; i++) {
  __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: Will now wait for thread %ld. Yielding..\n", (unsigned long)threads[i].tid); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
  mythread_join(threads[i], (void **)&status);
  __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: Thread %ld exited and increment count to %d\n", (unsigned long)threads[i].tid, count[i]); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 }
 __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: All threads completed execution. Will now exit..\n"); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 mythread_exit(((void *)0));
 return 0;
}

canonical_original_code:
int main()
{
 struct mythread threads[8];
 int count[8];
 int i;
 char *status;
 for (i = 0; i < 8; i++) {
  count[i] = i;
  mythread_create(&threads[i], ((void *)0), thread_func, &count[i]);
 }
 for (i = 0; i < 8; i++) {
  __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: Will now wait for thread %ld. Yielding..\n", (unsigned long)threads[i].tid); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
  mythread_join(threads[i], (void **)&status);
  __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: Thread %ld exited and increment count to %d\n", (unsigned long)threads[i].tid, count[i]); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 }
 __mythread_debug_futex_init(); futex_down(&debug_futex); sprintf(debug_msg, "Main: All threads completed execution. Will now exit..\n"); write(1, debug_msg, strlen(debug_msg)); futex_up(&debug_futex);;
 mythread_exit(((void *)0));
 return 0;
}

variable_types:
threads
struct mythread { int tid; } [8]

variable_types:
count
int [8]

variable_types: i int

variable_types:
status
char *


decompiled_code:
__int64 __fastcall sys_futex(__int64 a1, unsigned int a2, unsigned int a3, __int64 a4)
{
return syscall(202LL, a1, a2, a3, a4, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2, unsigned int a3, __int64 a4)
{
return syscall(202LL, a1, a2, a3, a4, 0LL, 0LL);
}

original_code:
int sys_futex(int *uaddr, int op, int val, const struct timespec *timeout)
{
  return syscall(202, uaddr, op, val, timeout, ((void *)0), 0);
}

canonical_original_code:
int sys_futex(int *uaddr, int op, int val, struct timespec *timeout)
{
  return syscall(202, uaddr, op, val, timeout, ((void *)0), 0);
}

variable_types:
uaddr
int *

variable_types: op int

variable_types: val int

variable_types: struct timespec { long tv_sec; long tv_nsec; } *


decompiled_code:
__int64 __fastcall futex_await(__int64 a1, unsigned int a2)
{
return sys_futex(a1, 2u, a2, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2)
{
return func0(a1, 2u, a2, 0LL);
}

original_code:
int futex_await(struct futex *futx, int signal)
{
 return sys_futex(&futx->count, 2, signal, ((void *)0));
}

variable_types:
futx
struct futex { int count; } *

variable_types: signal int


decompiled_code:
void __fastcall futex_init(_DWORD *a1, int a2)
{
*a1 = a2;
}

canonical_decompiled_code:
void __fastcall func4(_DWORD *a1, int a2)
{
*a1 = a2;
}

original_code:
void futex_init(struct futex *futx, int val)
{
 futx->count = val;
 __futex_commit();
}