original_code:
motionblur_t *CL_AllocBlur (void)
{
 int i;
 float time;
 int index;
 for (i=0 ; i<128 ; i++)
  if (!cl_blurs[i].model)
   return &cl_blurs[i];
 time = cl.time;
 index = 0;
 for (i=0 ; i<128 ; i++)
  if (cl_blurs[i].start < time)
  {
   time = cl_blurs[i].start;
   index = i;
  }
 return &cl_blurs[index];
}

canonical_original_code:
struct motionblur_t *CL_AllocBlur()
{
 int i;
 float time;
 int index;
 for (i=0 ; i<128 ; i++)
  if (!cl_blurs[i].model)
   return &cl_blurs[i];
 time = cl.time;
 index = 0;
 for (i=0 ; i<128 ; i++)
  if (cl_blurs[i].start < time)
  {
   time = cl_blurs[i].start;
   index = i;
  }
 return &cl_blurs[index];
}

variable_types: i int

variable_types: time float

variable_types: index int

return_type: struct motionblur_t { float origin[3]; float angles[3]; float alpha; float fade; 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; } *model; int frame; int oldframe; struct player_info_s *scoreboard; float start; int skinnum; } *

user_defined_types: struct motionblur_t { float origin[3]; float angles[3]; float alpha; float fade; struct model_s *model; int frame; int oldframe; struct player_info_s *scoreboard; float start; int skinnum; }

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 mleaf_s { int contents; int visframe; float minmaxs[6]; struct mnode_s *parent; unsigned char *compressed_vis; struct efrag_s *efrags; struct msurface_s **firstmarksurface; int nummarksurfaces; }

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

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

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

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

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

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

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


repo: jite/jquake

original_code:
void CL_CreateBlurs (vec3_t start, vec3_t end, entity_t *ent)
{
 vec3_t vec;
 float len, maxlen;
 motionblur_t *blur;
 if ((cl.paused || (!cl_demospeed.value && cls.demoplayback)))
  return;
 if (((start)[0] == (end)[0] && (start)[1] == (end)[1] && (start)[2] == (end)[2]))
 {
  blur = CL_AllocBlur();
  if (!blur)
   return;
  ((blur->origin)[0] = (start)[0], (blur->origin)[1] = (start)[1], (blur->origin)[2] = (start)[2]);
  ((blur->angles)[0] = (ent->angles)[0], (blur->angles)[1] = (ent->angles)[1], (blur->angles)[2] = (ent->angles)[2]);
  blur->model = ent->model;
  blur->frame = ent->frame;
  blur->oldframe = ent->oldframe;
  blur->scoreboard = ent->scoreboard;
  blur->start = cl.time;
  blur->alpha = 1;
  blur->fade = 4.5;
  blur->skinnum = ent->skinnum;
  return;
 }
 ((vec)[0] = (end)[0] - (start)[0], (vec)[1] = (end)[1] - (start)[1], (vec)[2] = (end)[2] - (start)[2]);
 len = VectorNormalize(vec);
 maxlen = len;
 while (len > 0)
 {
  blur = CL_AllocBlur();
  if (!blur)
   return;
  ((blur->origin)[0] = (start)[0], (blur->origin)[1] = (start)[1], (blur->origin)[2] = (start)[2]);
  ((blur->angles)[0] = (ent->angles)[0], (blur->angles)[1] = (ent->angles)[1], (blur->angles)[2] = (ent->angles)[2]);
  blur->model = ent->model;
  blur->frame = ent->frame;
  blur->oldframe = ent->oldframe;
  blur->scoreboard = ent->scoreboard;
  blur->start = cl.time;
  blur->alpha = len/maxlen;
  blur->fade = 6;
  blur->skinnum = ent->skinnum;
  len=-2;
  ((start)[0] = (start)[0] + (vec)[0], (start)[1] = (start)[1] + (vec)[1], (start)[2] = (start)[2] + (vec)[2]);
 }
}

canonical_original_code:
void CL_CreateBlurs(float start[3], float end[3], struct entity_s *ent)
{
 float vec[3];
 float len; float maxlen;
 struct motionblur_t *blur;
 if ((cl.paused || (!cl_demospeed.value && cls.demoplayback)))
  return;
 if (((start)[0] == (end)[0] && (start)[1] == (end)[1] && (start)[2] == (end)[2]))
 {
  blur = CL_AllocBlur();
  if (!blur)
   return;
  ((blur->origin)[0] = (start)[0], (blur->origin)[1] = (start)[1], (blur->origin)[2] = (start)[2]);
  ((blur->angles)[0] = (ent->angles)[0], (blur->angles)[1] = (ent->angles)[1], (blur->angles)[2] = (ent->angles)[2]);
  blur->model = ent->model;
  blur->frame = ent->frame;
  blur->oldframe = ent->oldframe;
  blur->scoreboard = ent->scoreboard;
  blur->start = cl.time;
  blur->alpha = 1;
  blur->fade = 4.5;
  blur->skinnum = ent->skinnum;
  return;
 }
 ((vec)[0] = (end)[0] - (start)[0], (vec)[1] = (end)[1] - (start)[1], (vec)[2] = (end)[2] - (start)[2]);
 len = VectorNormalize(vec);
 maxlen = len;
 while (len > 0)
 {
  blur = CL_AllocBlur();
  if (!blur)
   return;
  ((blur->origin)[0] = (start)[0], (blur->origin)[1] = (start)[1], (blur->origin)[2] = (start)[2]);
  ((blur->angles)[0] = (ent->angles)[0], (blur->angles)[1] = (ent->angles)[1], (blur->angles)[2] = (ent->angles)[2]);
  blur->model = ent->model;
  blur->frame = ent->frame;
  blur->oldframe = ent->oldframe;
  blur->scoreboard = ent->scoreboard;
  blur->start = cl.time;
  blur->alpha = len/maxlen;
  blur->fade = 6;
  blur->skinnum = ent->skinnum;
  len=-2;
  ((start)[0] = (start)[0] + (vec)[0], (start)[1] = (start)[1] + (vec)[1], (start)[2] = (start)[2] + (vec)[2]);
 }
}

variable_types:
start
float [3]

variable_types:
end
float [3]

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:
vec
float [3]

variable_types: len float

variable_types: maxlen float

variable_types: struct motionblur_t { float origin[3]; float angles[3]; float alpha; float fade; 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; } *model; int frame; int oldframe; struct player_info_s *scoreboard; float start; int skinnum; } *

return_type: void


TrailStats

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

result = a1;
if ( MotionBlurCount > MotionBlurCountHigh )
MotionBlurCountHigh = MotionBlurCount;
MotionBlurCount += a1;
return result;
}

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

result = a1;
if ( MotionBlurCount > MotionBlurCountHigh )
MotionBlurCountHigh = MotionBlurCount;
MotionBlurCount += a1;
return result;
}

original_code:
void TrailStats (int change)
{
 if (MotionBlurCount > MotionBlurCountHigh)
  MotionBlurCountHigh = MotionBlurCount;
 MotionBlurCount+=change;
}

canonical_original_code:
void TrailStats(int change)
{
 if (MotionBlurCount > MotionBlurCountHigh)
  MotionBlurCountHigh = MotionBlurCount;
 MotionBlurCount+=change;
}

variable_types: change int


original_code:
void CL_UpdateBlurs (void)
{
 int i;
 motionblur_t *blur;
 entity_t ent;
 memset (&ent, 0, sizeof(entity_t));
 TrailStats (-MotionBlurCount);
 MotionBlurCount = 0;
 for (i=0, blur=cl_blurs ; i< 128 ; i++, blur++)
 {
  if (!blur->model || blur->alpha <= 0)
   continue;
  if (blur->alpha <= 0)
  {
   blur->model = ((void *)0);
   continue;
  }
  TrailStats (1);
  ((ent.origin)[0] = (blur->origin)[0], (ent.origin)[1] = (blur->origin)[1], (ent.origin)[2] = (blur->origin)[2]);
  ent.model = blur->model;
  ent.frame = blur->frame;
  ent.alpha = blur->alpha;
  ent.oldframe = blur->oldframe;
  if (!(cl.paused || (!cl_demospeed.value && cls.demoplayback)))
   blur->alpha -= cls.frametime*blur->fade;
  ent.scoreboard = blur->scoreboard;
  ((ent.angles)[0] = (blur->angles)[0], (ent.angles)[1] = (blur->angles)[1], (ent.angles)[2] = (blur->angles)[2]);
  ent.skinnum = blur->skinnum;
  CL_AddEntity (&ent);
 }
}

canonical_original_code:
void CL_UpdateBlurs()
{
 int i;
 struct motionblur_t *blur;
 struct entity_s ent;
 memset (&ent, 0, sizeof(entity_t));
 TrailStats (-MotionBlurCount);
 MotionBlurCount = 0;
 for (i=0, blur=cl_blurs ; i< 128 ; i++, blur++)
 {
  if (!blur->model || blur->alpha <= 0)
   continue;
  if (blur->alpha <= 0)
  {
   blur->model = ((void *)0);
   continue;
  }
  TrailStats (1);
  ((ent.origin)[0] = (blur->origin)[0], (ent.origin)[1] = (blur->origin)[1], (ent.origin)[2] = (blur->origin)[2]);
  ent.model = blur->model;
  ent.frame = blur->frame;
  ent.alpha = blur->alpha;
  ent.oldframe = blur->oldframe;
  if (!(cl.paused || (!cl_demospeed.value && cls.demoplayback)))
   blur->alpha -= cls.frametime*blur->fade;
  ent.scoreboard = blur->scoreboard;
  ((ent.angles)[0] = (blur->angles)[0], (ent.angles)[1] = (blur->angles)[1], (ent.angles)[2] = (blur->angles)[2]);
  ent.skinnum = blur->skinnum;
  CL_AddEntity (&ent);
 }
}

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


decompiled_code:
__int64 *CL_ClearBlurs()
{
__int64 *result; // rax

MotionBlurCount = 0;
result = cl_blurs;
do
{
result[4] = 0LL;
*((_DWORD *)result + 3) = 0;
*((_DWORD *)result + 4) = 0;
*((_DWORD *)result + 5) = 0;
*((_DWORD *)result + 7) = 0;
*((_DWORD *)result + 10) = 0;
*((_DWORD *)result + 11) = 0;
*(_DWORD *)result = 0;
*((_DWORD *)result + 1) = 0;
*((_DWORD *)result + 2) = 0;
result[6] = 0LL;
*((_DWORD *)result + 15) = 0;
*((_DWORD *)result + 14) = 0;
result += 8;
}
while ( result != &cl_blurs[1024] );
return result;
}

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

MotionBlurCount = 0;
result = cl_blurs;
do
{
result[4] = 0LL;
*((_DWORD *)result + 3) = 0;
*((_DWORD *)result + 4) = 0;
*((_DWORD *)result + 5) = 0;
*((_DWORD *)result + 7) = 0;
*((_DWORD *)result + 10) = 0;
*((_DWORD *)result + 11) = 0;
*(_DWORD *)result = 0;
*((_DWORD *)result + 1) = 0;
*((_DWORD *)result + 2) = 0;
result[6] = 0LL;
*((_DWORD *)result + 15) = 0;
*((_DWORD *)result + 14) = 0;
result += 8;
}
while ( result != &cl_blurs[1024] );
return result;
}

original_code:
void CL_ClearBlurs (void)
{
 int i, j;
 motionblur_t *blur;
 MotionBlurCount = 0;
 for (i=0, blur=cl_blurs ; i< 128 ; i++, blur++)
 {
  blur->model = ((void *)0);
  for (j=0;j<3;j++)
   blur->angles[j] = 0;
  blur->fade = 0;
  blur->frame = 0;
  blur->oldframe = 0;
  for (j=0;j<3;j++)
   blur->origin[j] = 0;
  blur->scoreboard = 0;
  blur->skinnum = 0;
  blur->start = 0;
 }
}

canonical_original_code:
void CL_ClearBlurs()
{
 int i; int j;
 struct motionblur_t *blur;
 MotionBlurCount = 0;
 for (i=0, blur=cl_blurs ; i< 128 ; i++, blur++)
 {
  blur->model = ((void *)0);
  for (j=0;j<3;j++)
   blur->angles[j] = 0;
  blur->fade = 0;
  blur->frame = 0;
  blur->oldframe = 0;
  for (j=0;j<3;j++)
   blur->origin[j] = 0;
  blur->scoreboard = 0;
  blur->skinnum = 0;
  blur->start = 0;
 }
}

variable_types: j int

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

user_defined_types: enum modtype_t { mod_brush=0, mod_sprite=1, mod_spr32=2, mod_alias=3, mod_alias3=4 }

user_defined_types: enum synctype_t { ST_SYNC=0, ST_RAND=1 }

user_defined_types: struct dmodel_t { float mins[3]; float origin[3]; int headnode[4]; int visleafs; int firstface; }

user_defined_types: struct mplane_s { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; }

user_defined_types: struct medge_s { unsigned short v[2]; unsigned int cachededgeoffset; }

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


decompiled_code:
__int64 __fastcall Mod_ReadFlagsFromMD1(char *s1)
{
_DWORD *v1; // rax
unsigned int v2; // edx
char v4[72]; // [rsp+0h] [rbp-48h] BYREF

COM_StripExtension(s1, v4);
COM_DefaultExtension(v4, ".md3");
if ( !strcmp(s1, v4) )
{
COM_StripExtension(s1, v4);
COM_DefaultExtension(v4, ".md1");
}
else
{
COM_StripExtension(s1, v4);
COM_DefaultExtension(v4, ".mdl");
}
v1 = (_DWORD *)FS_LoadTempFile(v4, 0LL);
if ( !v1 )
return 0;
v2 = 0;
if ( *v1 == 1330660425 && v1[1] == 6 )
v2 = v1[19];
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1)
{
_DWORD *v1; // rax
unsigned int v2; // edx
char v4[72]; // [rsp+0h] [rbp-48h] BYREF

COM_StripExtension(s1, v4);
COM_DefaultExtension(v4, ".md3");
if ( !strcmp(s1, v4) )
{
COM_StripExtension(s1, v4);
COM_DefaultExtension(v4, ".md1");
}
else
{
COM_StripExtension(s1, v4);
COM_DefaultExtension(v4, ".mdl");
}
v1 = (_DWORD *)FS_LoadTempFile(v4, 0LL);
if ( !v1 )
return 0;
v2 = 0;
if ( *v1 == 1330660425 && v1[1] == 6 )
v2 = v1[19];
return v2;
}

original_code:
int Mod_ReadFlagsFromMD1(char *name, int md3version)
{
 mdl_t *pinmodel;
 char fname[64];
 COM_StripExtension(name, fname);
 COM_DefaultExtension(fname, ".md3");
 if (!strcmp(name, fname))
 {
  COM_StripExtension(name, fname);
  COM_DefaultExtension(fname, ".md1");
 }
 else
 {
  COM_StripExtension(name, fname);
  COM_DefaultExtension(fname, ".mdl");
 }
 pinmodel = (mdl_t *)FS_LoadTempFile(fname, ((void *)0));
 if (!pinmodel)
  return 0;
 if (pinmodel->ident != (('O'<<24)+('P'<<16)+('D'<<8)+'I'))
  return 0;
 if (pinmodel->version != 6)
  return 0;
 return pinmodel->flags;
}

canonical_original_code:
int Mod_ReadFlagsFromMD1(char *name, int md3version)
{
 struct mdl_t *pinmodel;
 char fname[64];
 COM_StripExtension(name, fname);
 COM_DefaultExtension(fname, ".md3");
 if (!strcmp(name, fname))
 {
  COM_StripExtension(name, fname);
  COM_DefaultExtension(fname, ".md1");
 }
 else
 {
  COM_StripExtension(name, fname);
  COM_DefaultExtension(fname, ".mdl");
 }
 pinmodel = (struct mdl_t *)FS_LoadTempFile(fname, ((void *)0));
 if (!pinmodel)
  return 0;
 if (pinmodel->ident != (('O'<<24)+('P'<<16)+('D'<<8)+'I'))
  return 0;
 if (pinmodel->version != 6)
  return 0;
 return pinmodel->flags;
}

variable_types:
name
char *

variable_types: struct mdl_t { int ident; int version; float scale[3]; float scale_origin[3]; float boundingradius; float eyeposition[3]; int numskins; int skinwidth; int skinheight; int numverts; int numtris; int numframes; enum synctype_t { ST_SYNC=0, ST_RAND=1 } synctype; int flags; float size; } *

variable_types:
fname
char [64]

return_type: int

user_defined_types: struct mdl_t { int ident; int version; float scale[3]; float scale_origin[3]; float boundingradius; float eyeposition[3]; int numskins; int skinwidth; int skinheight; int numverts; int numtris; int numframes; enum synctype_t synctype; int flags; float size; }


decompiled_code:
__int64 __fastcall Mod_LoadAlias3Model(__int64 a1, _DWORD *a2, unsigned int a3)
{
int v4; // ebx
int v5; // edx
int i; // eax
char *v7; // r12
char *v8; // r13
const char *v9; // rbp
size_t v10; // r15
char *v11; // rbx
int v12; // eax
int v13; // eax
int v14; // edx
int v15; // eax
int v16; // ecx
int j; // eax
int v18; // edx
int k; // eax
const char *v20; // rbx
char *v21; // rax
__int64 v22; // rbx
__int64 result; // rax
void *v24; // rdi
char *v26; // [rsp+10h] [rbp-1D8h]
int *src; // [rsp+18h] [rbp-1D0h]
_DWORD *v28; // [rsp+20h] [rbp-1C8h]
unsigned int v29; // [rsp+2Ch] [rbp-1BCh]
char v30[128]; // [rsp+30h] [rbp-1B8h] BYREF
char v31[128]; // [rsp+B0h] [rbp-138h] BYREF
char v32[184]; // [rsp+130h] [rbp-B8h] BYREF

v29 = Hunk_LowMark();
*(_DWORD *)(a1 + 96) = 4;
v4 = a2[21];
src = (int *)Hunk_Alloc((unsigned int)(68 * v4 + 20));
*src = 20;
v28 = (_DWORD *)Hunk_Alloc(a3);
src[1] = (_DWORD)v28 - (_DWORD)src;
memcpy(v28, a2, (int)a3);
src[4] = v28[19];
src[3] = v28[20];
src[2] = src[1] + v28[24];
v5 = v28[19];
if ( v5 > 0 )
{
for ( i = 0; i != v5; ++i )
;
}
v7 = (char *)src + *src;
v8 = (char *)v28 + (int)v28[25];
if ( v4 > 0 )
{
v26 = &v7[68 * v4];
do
{
v14 = *((_DWORD *)v8 + 20);
v15 = 0;
if ( v14 > 0 )
{
do
++v15;
while ( v15 != v14 );
}
v16 = *((_DWORD *)v8 + 21);
if ( v16 > 0 )
{
for ( j = 0; j != v16; ++j )
;
}
v18 = *((_DWORD *)v8 + 18) * v14;
if ( v18 > 0 )
{
for ( k = 0; k != v18; ++k )
;
}
v20 = &v8[*((int *)v8 + 23)];
v30[0] = 0;
v31[0] = 0;
v32[0] = 0;
strlcpy(v32, v20, 128LL);
if ( *v20 )
{
strlcpy(v30, a1, 128LL);
v21 = (char *)COM_SkipPathWritable(v30);
strcpy(v21, v20);
}
else
{
strlcpy(v7, a1, 64LL);
COM_StripExtension(v7, v7);
strlcat(v7, "_default.skin", 64LL);
v9 = (const char *)FS_LoadHunkFile(v7, 0LL);
strlcpy(v7, a1, 64LL);
COM_StripExtension(v7, v7);
strlcat(v7, "_skin.tga", 64LL);
if ( v9 && *v9 )
{
v10 = (int)strlen(v8 + 4);
while ( 1 )
{
v11 = strchr(v9, 10);
if ( !v11 )
v11 = (char *)&v9[strlen(v9)];
if ( v9[v10] == 44 && !strncasecmp(v8 + 4, v9, v10) )
break;
v9 = v11 + 1;
if ( !v11[1] )
goto LABEL_32;
}
strlcpy(v31, &v9[v10 + 1], v11 - &v9[v10] - 2);
}
}
LABEL_32:
if ( v31[0] && (v12 = GL_LoadTextureImage(v31, v31, 0LL, 0LL, 0LL), (*((_DWORD *)v7 + 16) = v12) != 0) )
{
strlcpy(v7, v31, 64LL);
}
else if ( v32[0] && (v13 = GL_LoadTextureImage(v32, v32, 0LL, 0LL, 0LL), (*((_DWORD *)v7 + 16) = v13) != 0) )
{
strlcpy(v7, v32, 64LL);
}
else if ( v30[0] )
{
*((_DWORD *)v7 + 16) = GL_LoadTextureImage(v30, v30, 0LL, 0LL, 0LL);
strlcpy(v7, v30, 64LL);
}
else if ( v31[0] )
{
*((_DWORD *)v7 + 16) = GL_LoadTextureImage(v31, v31, 0LL, 0LL, 0LL);
strlcpy(v7, v31, 64LL);
}
else
{
*((_DWORD *)v7 + 16) = GL_LoadTextureImage("dummy", "dummy", 0LL, 0LL, 0LL);
strlcpy(v7, "dummy", 64LL);
}
v8 += *((int *)v8 + 26);
v7 += 68;
}
while ( v7 != v26 );
}
v22 = (unsigned int)Hunk_LowMark() - v29;
result = Cache_Alloc(a1 + 344, v22, &loadname);
v24 = *(void **)(a1 + 344);
if ( v24 )
{
memcpy(v24, src, (int)v22);
*(_QWORD *)(a1 + 72) = 0LL;
*(_QWORD *)(a1 + 80) = 0LL;
*(_DWORD *)(a1 + 88) = 0;
*(_DWORD *)(a1 + 72) = Mod_LoadSimpleTexture(a1, 0LL);
Hunk_FreeToLowMark(v29);
result = Mod_ReadFlagsFromMD1((char *)a1);
*(_DWORD *)(a1 + 108) = result;
}
return result;
}

original_code:
void Mod_LoadAlias3Model (model_t *mod, void *buffer, int filesize)
{
 char specifiedskinname[128];
 char skinfileskinname[128];
 char tenebraeskinname[128];
 extern char loadname[];
 int start, end, total;
 int numsurfs;
 int numskins;
 int surfn;
 md3model_t *pheader;
 md3Header_t *mem;
 surfinf_t *sinf;
 md3Surface_t *surf;
 md3Shader_t *sshad;
 md3Frame_t *mFrame;
 int fr, i, j;
 md3St_t *st;
 start = Hunk_LowMark ();
 mod->type = mod_alias3;
 numsurfs = (((md3Header_t *)buffer)->numSurfaces);
 numskins = 1;
 pheader = (md3model_t *) Hunk_Alloc(sizeof(md3model_t) +(numsurfs*numskins)*sizeof(surfinf_t));
 pheader->surfinf = sizeof(md3model_t);
 mem = (md3Header_t *) Hunk_Alloc(filesize);
 pheader->md3model = (char *)mem - (char *)pheader;
 memcpy(mem, buffer, filesize);
 mem->ident=(mem->ident);
 mem->version=(mem->version);
 mem->flags=(mem->flags);
 mem->numFrames=(mem->numFrames);
 mem->numTags=(mem->numTags);
 mem->numSurfaces=(mem->numSurfaces);
 mem->numSkins=(mem->numSkins);
 mem->ofsFrames=(mem->ofsFrames);
 mem->ofsTags=(mem->ofsTags);
 mem->ofsSurfaces=(mem->ofsSurfaces);
 mem->ofsEnd=(mem->ofsEnd);
 pheader->numframes = mem->numFrames;
 pheader->numtags = mem->numTags;
 pheader->ofstags = pheader->md3model + mem->ofsTags;
 for (fr = 0; fr < mem->numFrames; fr++)
 {
  mFrame = ((md3Frame_t *)((char *)mem + mem->ofsFrames)) + fr;
  for (j = 0; j < 3; j++)
  {
   mFrame->bounds[0][j]=(mFrame->bounds[0][j]);
   mFrame->bounds[1][j]=(mFrame->bounds[1][j]);
   mFrame->localOrigin[j]=(mFrame->localOrigin[j]);
  }
  mFrame->radius=(mFrame->radius);
 }
 sinf = (surfinf_t*)((char *)pheader + pheader->surfinf);
 {
  surf = (md3Surface_t *)((char *)mem + mem->ofsSurfaces);
  for (surfn = 0; surfn < numsurfs; surfn++)
  {
   md3Triangle_t *tris;
   md3XyzNormal_t *vert;
   surf->ident=(surf->ident);
   surf->flags=(surf->flags);
   surf->numFrames=(surf->numFrames);
   surf->numShaders=(surf->numShaders);
   surf->numVerts=(surf->numVerts);
   surf->numTriangles=(surf->numTriangles);
   surf->ofsTriangles=(surf->ofsTriangles);
   surf->ofsShaders=(surf->ofsShaders);
   surf->ofsSt=(surf->ofsSt);
   surf->ofsXyzNormals=(surf->ofsXyzNormals);
   surf->ofsEnd=(surf->ofsEnd);
   st = (md3St_t *)((char *)surf + surf->ofsSt);
   for (i = 0; i < surf->numVerts; i++)
   {
    st[i].s=(st[i].s);
    st[i].t=(st[i].t);
   }
   tris = (md3Triangle_t *)((char *)surf + surf->ofsTriangles);
   for (j=0 ; j<surf->numTriangles ; j++)
   {
    tris[j].indexes[0]=(tris[j].indexes[0]);
    tris[j].indexes[1]=(tris[j].indexes[1]);
    tris[j].indexes[2]=(tris[j].indexes[2]);
   }
   vert = (md3XyzNormal_t *)((char *)surf + surf->ofsXyzNormals);
   for (j=0 ; j < surf->numVerts * surf->numFrames ; j++)
   {
    vert[j].xyz[0] = (vert[j].xyz[0]);
    vert[j].xyz[1] = (vert[j].xyz[1]);
    vert[j].xyz[2] = (vert[j].xyz[2]);
    vert[j].normal = (vert[j].normal);
   }
   sshad = (md3Shader_t *)((char *)surf + surf->ofsShaders);
   sshad->shaderIndex=(sshad->shaderIndex);
   *specifiedskinname = *skinfileskinname = *tenebraeskinname = '\0';
   strlcpy (specifiedskinname, sshad->name, sizeof (specifiedskinname));
   if (*sshad->name)
   {
    strlcpy (tenebraeskinname, mod->name, sizeof (tenebraeskinname));
    strcpy (COM_SkipPathWritable(tenebraeskinname), sshad->name);
   }
   else
   {
    char *sfile, *sfilestart, *nl;
    int len;
    strlcpy (sinf->name, mod->name, sizeof (sinf->name));
    COM_StripExtension(sinf->name, sinf->name);
    strlcat (sinf->name, "_default.skin", sizeof (sinf->name));
    sfile = sfilestart = (char *) FS_LoadHunkFile(sinf->name, ((void *)0));
    strlcpy (sinf->name, mod->name, sizeof (sinf->name));
    COM_StripExtension(sinf->name, sinf->name);
    strlcat (sinf->name, "_skin.tga", sizeof (sinf->name));
    len = strlen(surf->name);
    if (sfilestart)
    {
     while(*sfile)
     {
      nl = strchr(sfile, '\n');
      if (!nl)
       nl = sfile + strlen(sfile);
      if (sfile[len] == ',' && !strncasecmp(surf->name, sfile, len))
      {
       strlcpy(skinfileskinname, sfile+len+1, nl - (sfile + len) -2);
       break;
      }
      sfile = nl+1;
     }
    }
   }
   if (*skinfileskinname && (sinf->texnum=GL_LoadTextureImage(skinfileskinname, skinfileskinname, 0, 0, 0)))
    strlcpy (sinf->name, skinfileskinname, sizeof (sinf->name));
   else if (*specifiedskinname && (sinf->texnum=GL_LoadTextureImage(specifiedskinname, specifiedskinname, 0, 0, 0)))
    strlcpy (sinf->name, specifiedskinname, sizeof (sinf->name));
   else if (*tenebraeskinname)
   {
    sinf->texnum=GL_LoadTextureImage(tenebraeskinname, tenebraeskinname, 0, 0, 0);
    strlcpy (sinf->name, tenebraeskinname, sizeof (sinf->name));
   }
   else if (*skinfileskinname)
   {
    sinf->texnum=GL_LoadTextureImage(skinfileskinname, skinfileskinname, 0, 0, 0);
    strlcpy (sinf->name, skinfileskinname, sizeof (sinf->name));
   }
   else
   {
    sinf->texnum=GL_LoadTextureImage("dummy", "dummy", 0, 0, 0);
    strlcpy (sinf->name, "dummy", sizeof (sinf->name));
   }
   surf = (md3Surface_t *)((char *)surf + surf->ofsEnd);
   sinf++;
  }
 }
 end = Hunk_LowMark ();
 total = end - start;
 Cache_Alloc (&mod->cache, total, loadname);
 if (!mod->cache.data)
  return;
 memcpy (mod->cache.data, pheader, total);
 memset(mod->simpletexture, 0, sizeof(mod->simpletexture));
 mod->simpletexture[0] = Mod_LoadSimpleTexture(mod, 0);
 Hunk_FreeToLowMark (start);
 mod->flags = Mod_ReadFlagsFromMD1(mod->name, mem->flags);
}

canonical_original_code:
void Mod_LoadAlias3Model(struct model_s *mod, void *buffer, int filesize)
{
 char specifiedskinname[128];
 char skinfileskinname[128];
 char tenebraeskinname[128];
 extern char loadname[];
 int start; int end; int total;
 int numsurfs;
 int numskins;
 int surfn;
 struct md3model_t *pheader;
 struct md3Header_t *mem;
 struct surfinf_t *sinf;
 struct md3Surface_t *surf;
 struct md3Shader_t *sshad;
 struct md3Frame_s *mFrame;
 int fr; int i; int j;
 struct md3St_t *st;
 start = Hunk_LowMark ();
 mod->type = mod_alias3;
 numsurfs = (((struct md3Header_t *)buffer)->numSurfaces);
 numskins = 1;
 pheader = (struct md3model_t *) Hunk_Alloc(sizeof(md3model_t) +(numsurfs*numskins)*sizeof(surfinf_t));
 pheader->surfinf = sizeof(md3model_t);
 mem = (struct md3Header_t *) Hunk_Alloc(filesize);
 pheader->md3model = (char *)mem - (char *)pheader;
 memcpy(mem, buffer, filesize);
 mem->ident=(mem->ident);
 mem->version=(mem->version);
 mem->flags=(mem->flags);
 mem->numFrames=(mem->numFrames);
 mem->numTags=(mem->numTags);
 mem->numSurfaces=(mem->numSurfaces);
 mem->numSkins=(mem->numSkins);
 mem->ofsFrames=(mem->ofsFrames);
 mem->ofsTags=(mem->ofsTags);
 mem->ofsSurfaces=(mem->ofsSurfaces);
 mem->ofsEnd=(mem->ofsEnd);
 pheader->numframes = mem->numFrames;
 pheader->numtags = mem->numTags;
 pheader->ofstags = pheader->md3model + mem->ofsTags;
 for (fr = 0; fr < mem->numFrames; fr++)
 {
  mFrame = ((struct md3Frame_s *)((char *)mem + mem->ofsFrames)) + fr;
  for (j = 0; j < 3; j++)
  {
   mFrame->bounds[0][j]=(mFrame->bounds[0][j]);
   mFrame->bounds[1][j]=(mFrame->bounds[1][j]);
   mFrame->localOrigin[j]=(mFrame->localOrigin[j]);
  }
  mFrame->radius=(mFrame->radius);
 }
 sinf = (struct surfinf_t *)((char *)pheader + pheader->surfinf);
 {
  surf = (struct md3Surface_t *)((char *)mem + mem->ofsSurfaces);
  for (surfn = 0; surfn < numsurfs; surfn++)
  {
   struct md3Triangle_t *tris;
   struct md3XyzNormal_t *vert;
   surf->ident=(surf->ident);
   surf->flags=(surf->flags);
   surf->numFrames=(surf->numFrames);
   surf->numShaders=(surf->numShaders);
   surf->numVerts=(surf->numVerts);
   surf->numTriangles=(surf->numTriangles);
   surf->ofsTriangles=(surf->ofsTriangles);
   surf->ofsShaders=(surf->ofsShaders);
   surf->ofsSt=(surf->ofsSt);
   surf->ofsXyzNormals=(surf->ofsXyzNormals);
   surf->ofsEnd=(surf->ofsEnd);
   st = (struct md3St_t *)((char *)surf + surf->ofsSt);
   for (i = 0; i < surf->numVerts; i++)
   {
    st[i].s=(st[i].s);
    st[i].t=(st[i].t);
   }
   tris = (struct md3Triangle_t *)((char *)surf + surf->ofsTriangles);
   for (j=0 ; j<surf->numTriangles ; j++)
   {
    tris[j].indexes[0]=(tris[j].indexes[0]);
    tris[j].indexes[1]=(tris[j].indexes[1]);
    tris[j].indexes[2]=(tris[j].indexes[2]);
   }
   vert = (struct md3XyzNormal_t *)((char *)surf + surf->ofsXyzNormals);
   for (j=0 ; j < surf->numVerts * surf->numFrames ; j++)
   {
    vert[j].xyz[0] = (vert[j].xyz[0]);
    vert[j].xyz[1] = (vert[j].xyz[1]);
    vert[j].xyz[2] = (vert[j].xyz[2]);
    vert[j].normal = (vert[j].normal);
   }
   sshad = (struct md3Shader_t *)((char *)surf + surf->ofsShaders);
   sshad->shaderIndex=(sshad->shaderIndex);
   *specifiedskinname = *skinfileskinname = *tenebraeskinname = '\0';
   strlcpy (specifiedskinname, sshad->name, sizeof (specifiedskinname));
   if (*sshad->name)
   {
    strlcpy (tenebraeskinname, mod->name, sizeof (tenebraeskinname));
    strcpy (COM_SkipPathWritable(tenebraeskinname), sshad->name);
   }
   else
   {
    char *sfile; char *sfilestart; char *nl;
    int len;
    strlcpy (sinf->name, mod->name, sizeof (sinf->name));
    COM_StripExtension(sinf->name, sinf->name);
    strlcat (sinf->name, "_default.skin", sizeof (sinf->name));
    sfile = sfilestart = (char *) FS_LoadHunkFile(sinf->name, ((void *)0));
    strlcpy (sinf->name, mod->name, sizeof (sinf->name));
    COM_StripExtension(sinf->name, sinf->name);
    strlcat (sinf->name, "_skin.tga", sizeof (sinf->name));
    len = strlen(surf->name);
    if (sfilestart)
    {
     while(*sfile)
     {
      nl = strchr(sfile, '\n');
      if (!nl)
       nl = sfile + strlen(sfile);
      if (sfile[len] == ',' && !strncasecmp(surf->name, sfile, len))
      {
       strlcpy(skinfileskinname, sfile+len+1, nl - (sfile + len) -2);
       break;
      }
      sfile = nl+1;
     }
    }
   }
   if (*skinfileskinname && (sinf->texnum=GL_LoadTextureImage(skinfileskinname, skinfileskinname, 0, 0, 0)))
    strlcpy (sinf->name, skinfileskinname, sizeof (sinf->name));
   else if (*specifiedskinname && (sinf->texnum=GL_LoadTextureImage(specifiedskinname, specifiedskinname, 0, 0, 0)))
    strlcpy (sinf->name, specifiedskinname, sizeof (sinf->name));
   else if (*tenebraeskinname)
   {
    sinf->texnum=GL_LoadTextureImage(tenebraeskinname, tenebraeskinname, 0, 0, 0);
    strlcpy (sinf->name, tenebraeskinname, sizeof (sinf->name));
   }
   else if (*skinfileskinname)
   {
    sinf->texnum=GL_LoadTextureImage(skinfileskinname, skinfileskinname, 0, 0, 0);
    strlcpy (sinf->name, skinfileskinname, sizeof (sinf->name));
   }
   else
   {
    sinf->texnum=GL_LoadTextureImage("dummy", "dummy", 0, 0, 0);
    strlcpy (sinf->name, "dummy", sizeof (sinf->name));
   }
   surf = (struct md3Surface_t *)((char *)surf + surf->ofsEnd);
   sinf++;
  }
 }
 end = Hunk_LowMark ();
 total = end - start;
 Cache_Alloc (&mod->cache, total, loadname);
 if (!mod->cache.data)
  return;
 memcpy (mod->cache.data, pheader, total);
 memset(mod->simpletexture, 0, sizeof(mod->simpletexture));
 mod->simpletexture[0] = Mod_LoadSimpleTexture(mod, 0);
 Hunk_FreeToLowMark (start);
 mod->flags = Mod_ReadFlagsFromMD1(mod->name, mem->flags);
}

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:
buffer
void *

variable_types: filesize int

variable_types:
specifiedskinname
char [128]

variable_types:
skinfileskinname
char [128]

variable_types:
tenebraeskinname
char [128]

variable_types:
loadname
char []

variable_types: start int

variable_types: end int

variable_types: total int

variable_types: numsurfs int

variable_types: numskins int

variable_types: surfn int

variable_types: struct md3model_t { int surfinf; int md3model; int ofstags; int numtags; int numframes; } *

variable_types: struct md3Header_t { int ident; int version; char name[64]; int flags; int numFrames; int numTags; int numSurfaces; int numSkins; int ofsFrames; int ofsTags; int ofsSurfaces; int ofsEnd; } *

variable_types: struct surfinf_t { char name[64]; int texnum; } *

variable_types: struct md3Surface_t { int ident; char name[64]; int flags; int numFrames; int numShaders; int numVerts; int numTriangles; int ofsTriangles; int ofsShaders; int ofsSt; int ofsXyzNormals; int ofsEnd; } *

variable_types: struct md3Shader_t { char name[64]; int shaderIndex; } *

variable_types: struct md3Frame_s { float bounds[2][3]; float localOrigin[3]; float radius; char name[16]; } *

variable_types: fr int

variable_types:
st
struct md3St_t { float s; float t; } *

variable_types: struct md3Triangle_t { int indexes[3]; } *

variable_types: struct md3XyzNormal_t { short xyz[3]; unsigned short normal; } *

variable_types:
sfile
char *

variable_types:
sfilestart
char *

variable_types:
nl
char *

variable_types: len int

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


GetTag

original_code:
int GetTag(model_t *mod, char *tagname, int frame, float **org, m3by3_t **ang)
{
 md3model_t *mhead;
 md3tag_t *tag;
 int tnum;
 float bad[3]={0};
 m3by3_t badm= {{0}};
 *org = bad;
 *ang = &badm;
 if (mod->type != mod_alias3)
  return false;
 mhead = (md3model_t *)Mod_Extradata (mod);
 if (frame > mhead->numframes)
  frame = 0;
 tag = (md3tag_t *)((char *)mhead + mhead->ofstags);
 tag += frame*mhead->numtags;
 for(tnum=0;tnum<mhead->numtags; tnum++)
 {
  if (!strcasecmp(tag->name, tagname))
  {
   *org = tag->org;
   *ang = &tag->ang;
   return true;
  }
  tag++;
 }
 return false;
}

canonical_original_code:
int GetTag(struct model_s *mod, char *tagname, int frame, float **org, float (**ang)[3][3])
{
 struct md3model_t *mhead;
 struct md3tag_t *tag;
 int tnum;
 float bad[3] = {0};
 float badm[3][3] = {{0}};
 *org = bad;
 *ang = &badm;
 if (mod->type != mod_alias3)
  return false;
 mhead = (struct md3model_t *)Mod_Extradata (mod);
 if (frame > mhead->numframes)
  frame = 0;
 tag = (struct md3tag_t *)((char *)mhead + mhead->ofstags);
 tag += frame*mhead->numtags;
 for(tnum=0;tnum<mhead->numtags; tnum++)
 {
  if (!strcasecmp(tag->name, tagname))
  {
   *org = tag->org;
   *ang = &tag->ang;
   return true;
  }
  tag++;
 }
 return false;
}

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:
tagname
char *

variable_types: frame int

variable_types:
org
float **

variable_types: struct md3tag_t { char name[64]; float org[3]; float ang[3][3]; } *

variable_types: tnum int

variable_types:
bad
float [3]

variable_types:
badm
float [3][3]

user_defined_types: struct md3model_t { int surfinf; int md3model; int ofstags; int numtags; int numframes; }

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

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


decompiled_code:
char *__fastcall Skin_AsNameOrId(unsigned int *a1)
{
unsigned int *v1; // rbp
int v2; // eax
char *v3; // rdx
unsigned int v5; // ebx
int v6; // eax
const char *v7; // rdx

v1 = a1 + 271;
v2 = Skin_ForcingType((__int64)(a1 + 271));
if ( v2 == 2 )
{
snprintf(name_1, 0x80uLL, "%d", *a1);
v3 = name_1;
}
else if ( v2 == 3 )
{
v5 = TP_PlayersNumber(*a1, v1);
v3 = 0LL;
if ( v5 )
{
v6 = TP_ThisPOV_IsHisTeam(v1);
v7 = (const char *)&unk_2C40;
if ( !v6 )
v7 = "e%d";
snprintf(name_1, 0x80uLL, v7, v5);
v3 = name_1;
}
}
else
{
v3 = 0LL;
if ( v2 == 1 )
{
Util_ToValidFileName(a1 + 257, name_1, 128LL);
v3 = name_1;
}
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func1(unsigned int *a1)
{
unsigned int *v1; // rbp
int v2; // eax
char *v3; // rdx
unsigned int v5; // ebx
int v6; // eax
const char *v7; // rdx

v1 = a1 + 271;
v2 = func0((__int64)(a1 + 271));
if ( v2 == 2 )
{
snprintf(name_1, 0x80uLL, "%d", *a1);
v3 = name_1;
}
else if ( v2 == 3 )
{
v5 = TP_PlayersNumber(*a1, v1);
v3 = 0LL;
if ( v5 )
{
v6 = TP_ThisPOV_IsHisTeam(v1);
v7 = (const char *)&unk_2C40;
if ( !v6 )
v7 = "e%d";
snprintf(name_1, 0x80uLL, v7, v5);
v3 = name_1;
}
}
else
{
v3 = 0LL;
if ( v2 == 1 )
{
Util_ToValidFileName(a1 + 257, name_1, 128LL);
v3 = name_1;
}
}
return v3;
}

original_code:
char *Skin_AsNameOrId (player_info_t *sc) {
 static char name[128];
 int pn;
 char* mask;
 switch (Skin_ForcingType(sc->team)) {
 case 1:
  Util_ToValidFileName(sc->name, name, sizeof(name));
  return name;
 break;
 case 2:
  snprintf(name, sizeof(name), "%d", sc->userid);
  return name;
 break;
 case 3:
  pn = TP_PlayersNumber(sc->userid, sc->team);
  if (pn) {
   mask = TP_ThisPOV_IsHisTeam(sc->team) ? "t%d" : "e%d";
   snprintf(name, sizeof(name), mask, pn);
   return name;
  }
 break;
 }
 return ((void *)0);
}

canonical_original_code:
char *Skin_AsNameOrId(struct player_info_s *sc) {
 static char name[128];
 int pn;
 char *mask;
 switch (Skin_ForcingType(sc->team)) {
 case 1:
  Util_ToValidFileName(sc->name, name, sizeof(name));
  return name;
 break;
 case 2:
  snprintf(name, sizeof(name), "%d", sc->userid);
  return name;
 break;
 case 3:
  pn = TP_PlayersNumber(sc->userid, sc->team);
  if (pn) {
   mask = TP_ThisPOV_IsHisTeam(sc->team) ? "t%d" : "e%d";
   snprintf(name, sizeof(name), mask, pn);
   return name;
  }
 break;
 }
 return ((void *)0);
}

variable_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 { 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; } *

variable_types:
name
char [128]

variable_types: pn int

variable_types:
mask
char *

return_type: char *

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


decompiled_code:
char *__fastcall Skin_FindName(__int64 a1)
{
const char *v1; // rax
char *v2; // rdx
int v3; // ecx
int v4; // eax
_BYTE *v5; // rsi
char *v6; // rax

if ( allskins )
{
strlcpy(&name_0, &allskins, 128LL);
}
else
{
v6 = Skin_AsNameOrId((unsigned int *)a1);
if ( v6 && *v6 || (v6 = (char *)Info_ValueForKey(a1 + 4, "skin")) != 0LL && *v6 )
strlcpy(&name_0, v6, 128LL);
else
strlcpy(&name_0, baseskin[1], 128LL);
}
v1 = (const char *)TP_SkinForcingTeam();
skinforcing_team = v1;
if ( !(*((_DWORD *)&s + 133) | *((_DWORD *)&s + 134) & 0x100) )
{
if ( *((_DWORD *)&s + 131) && !strcmp((const char *)(a1 + 1084), v1) )
{
if ( !*((_DWORD *)&s + 145) )
goto LABEL_35;
v2 = &s
+ 0x77F3899B42FC5D78LL * ((a1 - (__int64)(&s + 1394296)) >> 3)
+ 20704 * (*((_DWORD *)&s + 143) & 0x3F)
+ 656;
if ( *((_DWORD *)&s + 143) != *(_DWORD *)v2 )
goto LABEL_35;
v3 = 1;
}
else
{
if ( !*((_DWORD *)&s + 145) )
goto LABEL_22;
v2 = &s
+ 0x77F3899B42FC5D78LL * ((a1 - (__int64)(&s + 1394296)) >> 3)
+ 20704 * (*((_DWORD *)&s + 143) & 0x3F)
+ 656;
if ( *((_DWORD *)&s + 143) != *(_DWORD *)v2 )
goto LABEL_22;
v3 = 0;
}
v4 = *((_DWORD *)v2 + 23);
if ( (v4 & 0xC0) == 192 )
{
v5 = (_BYTE *)cl_teambothskin[1];
if ( v3 )
goto LABEL_29;
v5 = (_BYTE *)cl_enemybothskin[1];
}
else
{
if ( (v4 & 0x40) != 0 )
{
v5 = (_BYTE *)cl_teamquadskin[1];
if ( !v3 )
{
v5 = (_BYTE *)cl_enemyquadskin[1];
goto LABEL_21;
}
LABEL_29:
if ( !v5 )
goto LABEL_35;
goto LABEL_30;
}
if ( (v4 & 0x80u) == 0 )
goto LABEL_31;
v5 = (_BYTE *)cl_teampentskin[1];
if ( v3 )
goto LABEL_29;
v5 = (_BYTE *)cl_enemypentskin[1];
}
LABEL_21:
if ( !v5 )
{
LABEL_22:
v5 = (_BYTE *)cl_enemyskin[1];
goto LABEL_36;
}
LABEL_30:
if ( *v5 )
{
LABEL_26:
strlcpy(&name_0, v5, 128LL);
goto LABEL_37;
}
LABEL_31:
if ( !v3 )
goto LABEL_22;
LABEL_35:
v5 = (_BYTE *)cl_teamskin[1];
LABEL_36:
if ( !*v5 )
goto LABEL_37;
goto LABEL_26;
}
LABEL_37:
if ( strstr(&name_0, "..") || name_0 == 46 )
strlcpy(&name_0, baseskin[1], 128LL);
return &name_0;
}

canonical_decompiled_code:
char *__fastcall func2(__int64 a1)
{
const char *v1; // rax
char *v2; // rdx
int v3; // ecx
int v4; // eax
_BYTE *v5; // rsi
char *v6; // rax

if ( allskins )
{
strlcpy(&name_0, &allskins, 128LL);
}
else
{
v6 = func1((unsigned int *)a1);
if ( v6 && *v6 || (v6 = (char *)Info_ValueForKey(a1 + 4, "skin")) != 0LL && *v6 )
strlcpy(&name_0, v6, 128LL);
else
strlcpy(&name_0, baseskin[1], 128LL);
}
v1 = (const char *)TP_SkinForcingTeam();
skinforcing_team = v1;
if ( !(*((_DWORD *)&s + 133) | *((_DWORD *)&s + 134) & 0x100) )
{
if ( *((_DWORD *)&s + 131) && !strcmp((const char *)(a1 + 1084), v1) )
{
if ( !*((_DWORD *)&s + 145) )
goto LABEL_35;
v2 = &s
+ 0x77F3899B42FC5D78LL * ((a1 - (__int64)(&s + 1394296)) >> 3)
+ 20704 * (*((_DWORD *)&s + 143) & 0x3F)
+ 656;
if ( *((_DWORD *)&s + 143) != *(_DWORD *)v2 )
goto LABEL_35;
v3 = 1;
}
else
{
if ( !*((_DWORD *)&s + 145) )
goto LABEL_22;
v2 = &s
+ 0x77F3899B42FC5D78LL * ((a1 - (__int64)(&s + 1394296)) >> 3)
+ 20704 * (*((_DWORD *)&s + 143) & 0x3F)
+ 656;
if ( *((_DWORD *)&s + 143) != *(_DWORD *)v2 )
goto LABEL_22;
v3 = 0;
}
v4 = *((_DWORD *)v2 + 23);
if ( (v4 & 0xC0) == 192 )
{
v5 = (_BYTE *)cl_teambothskin[1];
if ( v3 )
goto LABEL_29;
v5 = (_BYTE *)cl_enemybothskin[1];
}
else
{
if ( (v4 & 0x40) != 0 )
{
v5 = (_BYTE *)cl_teamquadskin[1];
if ( !v3 )
{
v5 = (_BYTE *)cl_enemyquadskin[1];
goto LABEL_21;
}
LABEL_29:
if ( !v5 )
goto LABEL_35;
goto LABEL_30;
}
if ( (v4 & 0x80u) == 0 )
goto LABEL_31;
v5 = (_BYTE *)cl_teampentskin[1];
if ( v3 )
goto LABEL_29;
v5 = (_BYTE *)cl_enemypentskin[1];
}
LABEL_21:
if ( !v5 )
{
LABEL_22:
v5 = (_BYTE *)cl_enemyskin[1];
goto LABEL_36;
}
LABEL_30:
if ( *v5 )
{
LABEL_26:
strlcpy(&name_0, v5, 128LL);
goto LABEL_37;
}
LABEL_31:
if ( !v3 )
goto LABEL_22;
LABEL_35:
v5 = (_BYTE *)cl_teamskin[1];
LABEL_36:
if ( !*v5 )
goto LABEL_37;
goto LABEL_26;
}
LABEL_37:
if ( strstr(&name_0, "..") || name_0 == 46 )
strlcpy(&name_0, baseskin[1], 128LL);
return &name_0;
}

original_code:
char *Skin_FindName (player_info_t *sc) {
 static char name[128];
 if (allskins[0]) {
  strlcpy(name, allskins, sizeof(name));
 } else {
  char *s = Skin_AsNameOrId(sc);
  if (!s || !s[0])
   s = Info_ValueForKey(sc->userinfo, "skin");
  if (s && s[0])
   strlcpy(name, s, sizeof(name));
  else
   strlcpy(name, baseskin.string, sizeof(name));
 }
 skinforcing_team = TP_SkinForcingTeam();
 if (!cl.teamfortress && !(cl.fpd & 256)) {
  char *skinname = ((void *)0);
  player_state_t *state;
  qbool teammate;
  teammate = (cl.teamplay && !strcmp(sc->team, skinforcing_team)) ? true : false;
  if (!cl.validsequence)
   goto nopowerups;
  state = cl.frames[cl.parsecount & (64 - 1)].playerstate + (sc - cl.players);
  if (state->messagenum != cl.parsecount)
   goto nopowerups;
  if ((state->effects & (64 | 128)) == (64 | 128) )
   skinname = teammate ? cl_teambothskin.string : cl_enemybothskin.string;
  else if (state->effects & 64)
   skinname = teammate ? cl_teamquadskin.string : cl_enemyquadskin.string;
  else if (state->effects & 128)
   skinname = teammate ? cl_teampentskin.string : cl_enemypentskin.string;
 nopowerups:
  if (!skinname || !skinname[0])
   skinname = teammate ? cl_teamskin.string : cl_enemyskin.string;
  if (skinname[0])
   strlcpy(name, skinname, sizeof(name));
 }
 if (strstr(name, "..") || *name == '.')
  strlcpy(name, baseskin.string, sizeof(name));
 return name;
}

canonical_original_code:
char *Skin_FindName(struct player_info_s *sc) {
 static char name[128];
 if (allskins[0]) {
  strlcpy(name, allskins, sizeof(name));
 } else {
  char *s = Skin_AsNameOrId(sc);
  if (!s || !s[0])
   s = Info_ValueForKey(sc->userinfo, "skin");
  if (s && s[0])
   strlcpy(name, s, sizeof(name));
  else
   strlcpy(name, baseskin.string, sizeof(name));
 }
 skinforcing_team = TP_SkinForcingTeam();
 if (!cl.teamfortress && !(cl.fpd & 256)) {
  char *skinname = ((void *)0);
  struct player_state_t *state;
  enum qbool teammate;
  teammate = (cl.teamplay && !strcmp(sc->team, skinforcing_team)) ? true : false;
  if (!cl.validsequence)
   goto nopowerups;
  state = cl.frames[cl.parsecount & (64 - 1)].playerstate + (sc - cl.players);
  if (state->messagenum != cl.parsecount)
   goto nopowerups;
  if ((state->effects & (64 | 128)) == (64 | 128) )
   skinname = teammate ? cl_teambothskin.string : cl_enemybothskin.string;
  else if (state->effects & 64)
   skinname = teammate ? cl_teamquadskin.string : cl_enemyquadskin.string;
  else if (state->effects & 128)
   skinname = teammate ? cl_teampentskin.string : cl_enemypentskin.string;
 nopowerups:
  if (!skinname || !skinname[0])
   skinname = teammate ? cl_teamskin.string : cl_enemyskin.string;
  if (skinname[0])
   strlcpy(name, skinname, sizeof(name));
 }
 if (strstr(name, "..") || *name == '.')
  strlcpy(name, baseskin.string, sizeof(name));
 return name;
}

variable_types:
s
char *

variable_types:
skinname
char *

variable_types: struct player_state_t { int messagenum; double state_time; struct usercmd_s { unsigned char msec; float angles[3]; short forwardmove; unsigned char buttons; unsigned char impulse; } command; float origin[3]; float viewangles[3]; float velocity[3]; int weaponframe; int modelindex; int frame; int skinnum; int effects; int flags; unsigned char alpha; unsigned char vw_index; unsigned char pm_type; float waterjumptime; enum qbool { false=0, true=1 } onground; enum qbool { false=0, true=1 } jump_held; int jump_msec; } *

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

user_defined_types: struct player_state_t { int messagenum; double state_time; struct usercmd_s command; float origin[3]; float viewangles[3]; float velocity[3]; int weaponframe; int modelindex; int frame; int skinnum; int effects; int flags; unsigned char alpha; unsigned char vw_index; unsigned char pm_type; float waterjumptime; enum qbool onground; enum qbool jump_held; int jump_msec; }


decompiled_code:
__int64 __fastcall Skin_PixelsLoad(__int64 a1, _DWORD *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5, _DWORD *a6)
{
__int64 result; // rax

*a4 = 0;
*a3 = 0;
*a2 = 0;
result = GL_LoadImagePixels(a1, 0LL, 0LL, 256LL);
if ( result )
{
*a2 = *a5;
*a3 = *a6;
*a4 = 4;
}
else
{
result = Image_LoadPCX(0LL, a1, 0LL, 0LL, a5, a6);
if ( result )
{
*a2 = 320;
*a3 = 200;
*a4 = 1;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _DWORD *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5, _DWORD *a6)
{
__int64 result; // rax

*a4 = 0;
*a3 = 0;
*a2 = 0;
result = GL_LoadImagePixels(a1, 0LL, 0LL, 256LL);
if ( result )
{
*a2 = *a5;
*a3 = *a6;
*a4 = 4;
}
else
{
result = Image_LoadPCX(0LL, a1, 0LL, 0LL, a5, a6);
if ( result )
{
*a2 = 320;
*a3 = 200;
*a4 = 1;
}
}
return result;
}

original_code:
byte *Skin_PixelsLoad(char *name, int *max_w, int *max_h, int *bpp, int *real_width, int *real_height)
{
 byte *pic;
 *max_w = *max_h = *bpp = 0;
 if ((pic = GL_LoadImagePixels (name, 0, 0, (1<<8), real_width, real_height))) {
  *max_w = *real_width;
  *max_h = *real_height;
  *bpp = 4;
  return pic;
 }
 if ((pic = Image_LoadPCX (((void *)0), name, 0, 0, real_width, real_height)))
 {
  *max_w = 320;
  *max_h = 200;
  *bpp = 1;
  return pic;
 }
 return ((void *)0);
}

canonical_original_code:
unsigned char *Skin_PixelsLoad(char *name, int *max_w, int *max_h, int *bpp, int *real_width, int *real_height)
{
 unsigned char *pic;
 *max_w = *max_h = *bpp = 0;
 if ((pic = GL_LoadImagePixels (name, 0, 0, (1<<8), real_width, real_height))) {
  *max_w = *real_width;
  *max_h = *real_height;
  *bpp = 4;
  return pic;
 }
 if ((pic = Image_LoadPCX (((void *)0), name, 0, 0, real_width, real_height)))
 {
  *max_w = 320;
  *max_h = 200;
  *bpp = 1;
  return pic;
 }
 return ((void *)0);
}

variable_types:
name
char *

variable_types:
bpp
int *

variable_types:
pic
unsigned char *

return_type: unsigned char *


original_code:
byte *Skin_Cache (skin_t *skin, qbool no_baseskin)
{
 int y, max_w, max_h, bpp, real_width = -1, real_height = -1;
 byte *pic = ((void *)0), *out, *pix;
 char name[128];
 if (noskins.value == 1)
  return ((void *)0);
 if (skin->failedload)
  return ((void *)0);
 if ((out = (byte *) Cache_Check (&skin->cache)))
  return out;
 snprintf (name, sizeof(name), "skins/%s.pcx", skin->name);
 if (!(pic = Skin_PixelsLoad(name, &max_w, &max_h, &bpp, &real_width, &real_height)) || real_width > max_w || real_height > max_h)
 {
  if(pic) { free(pic); pic = ((void *)0); };
  if (no_baseskin)
  {
   skin->warned = true;
   return ((void *)0);
  }
  else if (!skin->warned)
  {
   Com_Printf ("&cf22Couldn't load skin:&r %s\n", name);
  }
  skin->warned = true;
 }
 if (!pic)
 {
  snprintf (name, sizeof(name), "skins/%s.pcx", baseskin.string);
  if (!(pic = Skin_PixelsLoad(name, &max_w, &max_h, &bpp, &real_width, &real_height)) || real_width > max_w || real_height > max_h)
  {
   if(pic) { free(pic); pic = ((void *)0); };
   skin->failedload = true;
   return ((void *)0);
  }
 }
 if (!(out = pix = (byte *) Cache_Alloc (&skin->cache, max_w * max_h * bpp, skin->name)))
  Sys_Error ("Skin_Cache: couldn't allocate");
 memset (out, 0, max_w * max_h * bpp);
 for (y = 0; y < real_height; y++, pix += (max_w * bpp))
 {
  memcpy (pix, pic + y * real_width * bpp, real_width * bpp);
 }
 if(pic) { free(pic); pic = ((void *)0); };
 skin->bpp = bpp;
 skin->width = real_width;
 skin->height = real_height;
 skin->texnum = 0;
 skin->failedload = false;
 return out;
}

canonical_original_code:
unsigned char *Skin_Cache(struct skin_t *skin, enum qbool no_baseskin)
{
 int y; int max_w; int max_h; int bpp; int real_width = -1; int real_height = -1;
 unsigned char *pic = ((void *)0); unsigned char *out; unsigned char *pix;
 char name[128];
 if (noskins.value == 1)
  return ((void *)0);
 if (skin->failedload)
  return ((void *)0);
 if ((out = (unsigned char *) Cache_Check (&skin->cache)))
  return out;
 snprintf (name, sizeof(name), "skins/%s.pcx", skin->name);
 if (!(pic = Skin_PixelsLoad(name, &max_w, &max_h, &bpp, &real_width, &real_height)) || real_width > max_w || real_height > max_h)
 {
  if(pic) { free(pic); pic = ((void *)0); };
  if (no_baseskin)
  {
   skin->warned = true;
   return ((void *)0);
  }
  else if (!skin->warned)
  {
   Com_Printf ("&cf22Couldn't load skin:&r %s\n", name);
  }
  skin->warned = true;
 }
 if (!pic)
 {
  snprintf (name, sizeof(name), "skins/%s.pcx", baseskin.string);
  if (!(pic = Skin_PixelsLoad(name, &max_w, &max_h, &bpp, &real_width, &real_height)) || real_width > max_w || real_height > max_h)
  {
   if(pic) { free(pic); pic = ((void *)0); };
   skin->failedload = true;
   return ((void *)0);
  }
 }
 if (!(out = pix = (unsigned char *) Cache_Alloc (&skin->cache, max_w * max_h * bpp, skin->name)))
  Sys_Error ("Skin_Cache: couldn't allocate");
 memset (out, 0, max_w * max_h * bpp);
 for (y = 0; y < real_height; y++, pix += (max_w * bpp))
 {
  memcpy (pix, pic + y * real_width * bpp, real_width * bpp);
 }
 if(pic) { free(pic); pic = ((void *)0); };
 skin->bpp = bpp;
 skin->width = real_width;
 skin->height = real_height;
 skin->texnum = 0;
 skin->failedload = false;
 return out;
}

variable_types: 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; } *

variable_types: y int

variable_types: bpp int

variable_types:
out
unsigned char *

variable_types:
pix
unsigned char *

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


decompiled_code:
int __fastcall Skin_Find_Ex(__int64 a1, const char *a2)
{
int v3; // er13
const char *v4; // rbx
int result; // eax
int v6; // edx
__int64 v7; // rax
char *v8; // rdi
char v9[168]; // [rsp+0h] [rbp-A8h] BYREF

if ( !a2 || !*a2 )
{
a2 = baseskin[1];
if ( !*a2 )
a2 = "base";
}
strlcpy(v9, a2, 128LL);
COM_StripExtension(v9, v9);
v3 = numskins;
if ( numskins <= 0 )
{
LABEL_9:
if ( v3 == 128 )
{
Com_Printf("MAX_CACHED_SKINS reached, flushing skins\n");
Skin_Skins_f();
}
v6 = numskins;
v7 = 48LL * numskins;
v8 = &skins[v7];
if ( a1 )
*(_QWORD *)(a1 + 19552) = v8;
numskins = v6 + 1;
*(_QWORD *)&skins[v7] = 0LL;
*(_QWORD *)&skins[v7 + 8] = 0LL;
*((_QWORD *)v8 + 2) = 0LL;
*((_QWORD *)v8 + 3) = 0LL;
*((_QWORD *)v8 + 4) = 0LL;
*((_QWORD *)v8 + 5) = 0LL;
result = strlcpy(v8, v9, 16LL);
}
else
{
v4 = skins;
while ( 1 )
{
result = strcmp(v9, v4);
if ( !result )
break;
v4 += 48;
if ( v4 == &skins[48 * (v3 - 1) + 48] )
goto LABEL_9;
}
if ( a1 )
*(_QWORD *)(a1 + 19552) = v4;
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1, const char *a2)
{
int v3; // er13
const char *v4; // rbx
int result; // eax
int v6; // edx
__int64 v7; // rax
char *v8; // rdi
char v9[168]; // [rsp+0h] [rbp-A8h] BYREF

if ( !a2 || !*a2 )
{
a2 = baseskin[1];
if ( !*a2 )
a2 = "base";
}
strlcpy(v9, a2, 128LL);
COM_StripExtension(v9, v9);
v3 = numskins;
if ( numskins <= 0 )
{
LABEL_9:
if ( v3 == 128 )
{
Com_Printf("MAX_CACHED_SKINS reached, flushing skins\n");
func5();
}
v6 = numskins;
v7 = 48LL * numskins;
v8 = &skins[v7];
if ( a1 )
*(_QWORD *)(a1 + 19552) = v8;
numskins = v6 + 1;
*(_QWORD *)&skins[v7] = 0LL;
*(_QWORD *)&skins[v7 + 8] = 0LL;
*((_QWORD *)v8 + 2) = 0LL;
*((_QWORD *)v8 + 3) = 0LL;
*((_QWORD *)v8 + 4) = 0LL;
*((_QWORD *)v8 + 5) = 0LL;
result = strlcpy(v8, v9, 16LL);
}
else
{
v4 = skins;
while ( 1 )
{
result = strcmp(v9, v4);
if ( !result )
break;
v4 += 48;
if ( v4 == &skins[48 * (v3 - 1) + 48] )
goto LABEL_9;
}
if ( a1 )
*(_QWORD *)(a1 + 19552) = v4;
}
return result;
}

original_code:
void Skin_Find_Ex (player_info_t *sc, char *skin_name) {
 skin_t *skin;
 int i;
 char name[128];
 if (!skin_name || !skin_name[0])
 {
  skin_name = baseskin.string;
  if (!skin_name[0])
   skin_name = "base";
 }
 strlcpy(name, skin_name, sizeof(name));
 COM_StripExtension(name, name);
 for (i = 0; i < numskins; i++)
 {
  if (!strcmp(name, skins[i].name))
  {
   if (sc)
    sc->skin = &skins[i];
   return;
  }
 }
 if (numskins == 128)
 {
  Com_Printf ("MAX_CACHED_SKINS reached, flushing skins\n");
  Skin_Skins_f();
 }
 skin = &skins[numskins];
 if (sc)
  sc->skin = skin;
 numskins++;
 memset (skin, 0, sizeof(*skin));
 strlcpy(skin->name, name, sizeof(skin->name));
}

canonical_original_code:
void Skin_Find_Ex(struct player_info_s *sc, char *skin_name) {
 struct skin_t *skin;
 int i;
 char name[128];
 if (!skin_name || !skin_name[0])
 {
  skin_name = baseskin.string;
  if (!skin_name[0])
   skin_name = "base";
 }
 strlcpy(name, skin_name, sizeof(name));
 COM_StripExtension(name, name);
 for (i = 0; i < numskins; i++)
 {
  if (!strcmp(name, skins[i].name))
  {
   if (sc)
    sc->skin = &skins[i];
   return;
  }
 }
 if (numskins == 128)
 {
  Com_Printf ("MAX_CACHED_SKINS reached, flushing skins\n");
  Skin_Skins_f();
 }
 skin = &skins[numskins];
 if (sc)
  sc->skin = skin;
 numskins++;
 memset (skin, 0, sizeof(*skin));
 strlcpy(skin->name, name, sizeof(skin->name));
}

variable_types: i int


decompiled_code:
int __fastcall Skin_Find(__int64 a1)
{
char *v1; // rax

v1 = Skin_FindName(a1);
return Skin_Find_Ex(a1, v1);
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1)
{
char *v1; // rax

v1 = func2(a1);
return func6(a1, v1);
}

original_code:
void Skin_Find (player_info_t *sc)
{
 Skin_Find_Ex(sc, Skin_FindName(sc));
}

canonical_original_code:
void Skin_Find(struct player_info_s *sc)
{
 Skin_Find_Ex(sc, Skin_FindName(sc));
}

variable_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 { 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; } *


original_code:
void Skin_NextDownload (void) {
 player_info_t *sc;
 int i;
 if (cls.downloadnumber == 0)
  if (!com_serveractive || developer.value)
   Com_Printf ("Checking skins...\n");
 cls.downloadtype = dl_skin;
 for ( ; cls.downloadnumber >= 0 && cls.downloadnumber < 32; cls.downloadnumber++) {
  sc = &cl.players[cls.downloadnumber];
  if (!sc->name[0])
   continue;
  Skin_Find (sc);
  if (noskins.value)
   continue;
  if (Skin_Cache (sc->skin, true))
   continue;
  if (!CL_CheckOrDownloadFile(va("skins/%s.pcx", sc->skin->name)))
   return;
 }
 cls.downloadtype = dl_none;
 for (i = 0; i < 32; i++) {
  sc = &cl.players[i];
  if (!sc->name[0])
   continue;
  if (!sc->skin)
   Skin_Find (sc);
  Skin_Cache (sc->skin, false);
  sc->skin = ((void *)0);
 }
 if (cls.state == ca_onserver ) {
  MSG_WriteByte (&cls.netchan.message, 4);
  MSG_WriteString (&cls.netchan.message, va("begin %i", cl.servercount));
 }
}

canonical_original_code:
void Skin_NextDownload() {
 struct player_info_s *sc;
 int i;
 if (cls.downloadnumber == 0)
  if (!com_serveractive || developer.value)
   Com_Printf ("Checking skins...\n");
 cls.downloadtype = dl_skin;
 for ( ; cls.downloadnumber >= 0 && cls.downloadnumber < 32; cls.downloadnumber++) {
  sc = &cl.players[cls.downloadnumber];
  if (!sc->name[0])
   continue;
  Skin_Find (sc);
  if (noskins.value)
   continue;
  if (Skin_Cache (sc->skin, true))
   continue;
  if (!CL_CheckOrDownloadFile(va("skins/%s.pcx", sc->skin->name)))
   return;
 }
 cls.downloadtype = dl_none;
 for (i = 0; i < 32; i++) {
  sc = &cl.players[i];
  if (!sc->name[0])
   continue;
  if (!sc->skin)
   Skin_Find (sc);
  Skin_Cache (sc->skin, false);
  sc->skin = ((void *)0);
 }
 if (cls.state == ca_onserver ) {
  MSG_WriteByte (&cls.netchan.message, 4);
  MSG_WriteString (&cls.netchan.message, va("begin %i", cl.servercount));
 }
}


decompiled_code:
void Skins_PreCache()
{
char *v0; // rbx
int v1; // ebp
char *v2; // rcx
unsigned int v3; // eax

if ( skins_need_preache )
{
skins_need_preache = 0;
Skin_Find_Ex(0LL, (const char *)cl_teamskin[1]);
Skin_Find_Ex(0LL, (const char *)cl_enemyskin[1]);
Skin_Find_Ex(0LL, (const char *)cl_teamquadskin[1]);
Skin_Find_Ex(0LL, (const char *)cl_enemyquadskin[1]);
Skin_Find_Ex(0LL, (const char *)cl_teampentskin[1]);
Skin_Find_Ex(0LL, (const char *)cl_enemypentskin[1]);
Skin_Find_Ex(0LL, (const char *)cl_teambothskin[1]);
Skin_Find_Ex(0LL, (const char *)cl_enemybothskin[1]);
Skin_Find_Ex(0LL, baseskin[1]);
Skin_Find_Ex(0LL, "base");
if ( numskins > 0 )
{
v0 = skins;
v1 = 0;
do
{
v2 = Skin_Cache((__int64)v0, 0);
if ( v2 && *((_DWORD *)v0 + 8) == 4 && !*((_DWORD *)v0 + 9) )
{
v3 = GL_LoadTexture(
v0,
*((unsigned int *)v0 + 6),
*((unsigned int *)v0 + 7),
v2,
gl_playermip[16] == 0 ? 32 : 34,
4LL);
*((_DWORD *)v0 + 9) = v3;
Com_DPrintf("skin precache: %s, texnum %d\n", v0, v3);
}
++v1;
v0 += 48;
}
while ( numskins > v1 );
}
}
}

canonical_decompiled_code:
void func9()
{
char *v0; // rbx
int v1; // ebp
char *v2; // rcx
unsigned int v3; // eax

if ( skins_need_preache )
{
skins_need_preache = 0;
func6(0LL, (const char *)cl_teamskin[1]);
func6(0LL, (const char *)cl_enemyskin[1]);
func6(0LL, (const char *)cl_teamquadskin[1]);
func6(0LL, (const char *)cl_enemyquadskin[1]);
func6(0LL, (const char *)cl_teampentskin[1]);
func6(0LL, (const char *)cl_enemypentskin[1]);
func6(0LL, (const char *)cl_teambothskin[1]);
func6(0LL, (const char *)cl_enemybothskin[1]);
func6(0LL, baseskin[1]);
func6(0LL, "base");
if ( numskins > 0 )
{
v0 = skins;
v1 = 0;
do
{
v2 = func4((__int64)v0, 0);
if ( v2 && *((_DWORD *)v0 + 8) == 4 && !*((_DWORD *)v0 + 9) )
{
v3 = GL_LoadTexture(
v0,
*((unsigned int *)v0 + 6),
*((unsigned int *)v0 + 7),
v2,
gl_playermip[16] == 0 ? 32 : 34,
4LL);
*((_DWORD *)v0 + 9) = v3;
Com_DPrintf("skin precache: %s, texnum %d\n", v0, v3);
}
++v1;
v0 += 48;
}
while ( numskins > v1 );
}
}
}

original_code:
void Skins_PreCache(void)
{
 int i;
 byte *tex;
 if (!skins_need_preache)
  return;
 skins_need_preache = false;
 Skin_Find_Ex(((void *)0), cl_teamskin.string);
 Skin_Find_Ex(((void *)0), cl_enemyskin.string);
 Skin_Find_Ex(((void *)0), cl_teamquadskin.string);
 Skin_Find_Ex(((void *)0), cl_enemyquadskin.string);
 Skin_Find_Ex(((void *)0), cl_teampentskin.string);
 Skin_Find_Ex(((void *)0), cl_enemypentskin.string);
 Skin_Find_Ex(((void *)0), cl_teambothskin.string);
 Skin_Find_Ex(((void *)0), cl_enemybothskin.string);
 Skin_Find_Ex(((void *)0), baseskin.string);
 Skin_Find_Ex(((void *)0), "base");
 for (i = 0; i < numskins; i++)
 {
  tex = Skin_Cache (&skins[i], false);
  if (!tex)
   continue;
  if (skins[i].bpp != 4)
   continue;
  if (skins[i].texnum)
   continue;
  skins[i].texnum = GL_LoadTexture (skins[i].name, skins[i].width, skins[i].height, tex, (gl_playermip.integer ? (1<<1) : 0) | (1<<5), 4);
  Com_DPrintf("skin precache: %s, texnum %d\n", skins[i].name, skins[i].texnum);
 }
}

canonical_original_code:
void Skins_PreCache()
{
 int i;
 unsigned char *tex;
 if (!skins_need_preache)
  return;
 skins_need_preache = false;
 Skin_Find_Ex(((void *)0), cl_teamskin.string);
 Skin_Find_Ex(((void *)0), cl_enemyskin.string);
 Skin_Find_Ex(((void *)0), cl_teamquadskin.string);
 Skin_Find_Ex(((void *)0), cl_enemyquadskin.string);
 Skin_Find_Ex(((void *)0), cl_teampentskin.string);
 Skin_Find_Ex(((void *)0), cl_enemypentskin.string);
 Skin_Find_Ex(((void *)0), cl_teambothskin.string);
 Skin_Find_Ex(((void *)0), cl_enemybothskin.string);
 Skin_Find_Ex(((void *)0), baseskin.string);
 Skin_Find_Ex(((void *)0), "base");
 for (i = 0; i < numskins; i++)
 {
  tex = Skin_Cache (&skins[i], false);
  if (!tex)
   continue;
  if (skins[i].bpp != 4)
   continue;
  if (skins[i].texnum)
   continue;
  skins[i].texnum = GL_LoadTexture (skins[i].name, skins[i].width, skins[i].height, tex, (gl_playermip.integer ? (1<<1) : 0) | (1<<5), 4);
  Com_DPrintf("skin precache: %s, texnum %d\n", skins[i].name, skins[i].texnum);
 }
}

variable_types:
tex
unsigned char *


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

if ( LODWORD(teamforceskins[8]) && (unsigned int)((__int64 (*)(void))TP_ThisPOV_IsHisTeam)() )
return LODWORD(teamforceskins[8]);
if ( !LODWORD(enemyforceskins[8]) || (unsigned int)TP_ThisPOV_IsHisTeam(a1) )
{
result = LODWORD(cl_name_as_skin[8]);
if ( (_DWORD)result )
{
if ( !(cls[2427] | *((_DWORD *)&s + 148)) )
result = 0LL;
}
}
else
{
result = (unsigned int)(cls[2427] | *((_DWORD *)&s + 148));
if ( cls[2427] | *((_DWORD *)&s + 148) )
{
result = LODWORD(enemyforceskins[8]);
}
else if ( (*((_DWORD *)&s + 134) & 0x300) == 0 )
{
result = LODWORD(enemyforceskins[8]);
}
}
return result;
}

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

if ( LODWORD(teamforceskins[8]) && (unsigned int)((__int64 (*)(void))TP_ThisPOV_IsHisTeam)() )
return LODWORD(teamforceskins[8]);
if ( !LODWORD(enemyforceskins[8]) || (unsigned int)TP_ThisPOV_IsHisTeam(a1) )
{
result = LODWORD(cl_name_as_skin[8]);
if ( (_DWORD)result )
{
if ( !(cls[2427] | *((_DWORD *)&s + 148)) )
result = 0LL;
}
}
else
{
result = (unsigned int)(cls[2427] | *((_DWORD *)&s + 148));
if ( cls[2427] | *((_DWORD *)&s + 148) )
{
result = LODWORD(enemyforceskins[8]);
}
else if ( (*((_DWORD *)&s + 134) & 0x300) == 0 )
{
result = LODWORD(enemyforceskins[8]);
}
}
return result;
}

original_code:
static int Skin_ForcingType(const char *team)
{
 if (teamforceskins.integer && TP_ThisPOV_IsHisTeam(team))
  return teamforceskins.integer;
 if (enemyforceskins.integer && !TP_ThisPOV_IsHisTeam(team)) {
  if (cls.demoplayback || cl.spectator) {
   return enemyforceskins.integer;
  } else {
   if (!(cl.fpd & 256) && !(cl.fpd & 512))
    return enemyforceskins.integer;
   else
    return 0;
  }
 }
 if (cl_name_as_skin.integer && (cls.demoplayback || cl.spectator)) {
  return cl_name_as_skin.integer;
 }
 return 0;
}

canonical_original_code:
static int Skin_ForcingType(char *team)
{
 if (teamforceskins.integer && TP_ThisPOV_IsHisTeam(team))
  return teamforceskins.integer;
 if (enemyforceskins.integer && !TP_ThisPOV_IsHisTeam(team)) {
  if (cls.demoplayback || cl.spectator) {
   return enemyforceskins.integer;
  } else {
   if (!(cl.fpd & 256) && !(cl.fpd & 512))
    return enemyforceskins.integer;
   else
    return 0;
  }
 }
 if (cl_name_as_skin.integer && (cls.demoplayback || cl.spectator)) {
  return cl_name_as_skin.integer;
 }
 return 0;
}

variable_types:
team
char *


decompiled_code:
__int64 Skin_Skins_f()
{
unsigned __int64 v0; // rbx
int v1; // ebp
__int64 result; // rax

if ( numskins > 0 )
{
v0 = (unsigned int)((_DWORD)skins + 40);
v1 = 0;
do
{
if ( *(_QWORD *)v0 )
Cache_Free(v0);
++v1;
v0 += 48LL;
}
while ( numskins > v1 );
}
numskins = 0;
skins_need_preache = 1;
cls[2374] = 0;
cls[2375] = 4;
result = Skin_NextDownload();
if ( cls[3434] == 2 && (_UNKNOWN *)cbuf_current != &cbuf_main )
cls[3437] = 0;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
unsigned __int64 v0; // rbx
int v1; // ebp
__int64 result; // rax

if ( numskins > 0 )
{
v0 = (unsigned int)((_DWORD)skins + 40);
v1 = 0;
do
{
if ( *(_QWORD *)v0 )
Cache_Free(v0);
++v1;
v0 += 48LL;
}
while ( numskins > v1 );
}
numskins = 0;
skins_need_preache = 1;
cls[2374] = 0;
cls[2375] = 4;
result = func8();
if ( cls[3434] == 2 && (_UNKNOWN *)cbuf_current != &cbuf_main )
cls[3437] = 0;
return result;
}

original_code:
void Skin_Skins_f (void) {
 int i;
 for (i = 0; i < numskins; i++) {
  if (skins[i].cache.data)
   Cache_Free (&skins[i].cache);
 }
 numskins = 0;
 skins_need_preache = true;
 cls.downloadnumber = 0;
 cls.downloadtype = dl_skin;
 Skin_NextDownload ();
 if (cls.mvdplayback == 2 && cbuf_current != &cbuf_main)
 {
  cls.qtv_donotbuffer = false;
 }
}

canonical_original_code:
void Skin_Skins_f() {
 int i;
 for (i = 0; i < numskins; i++) {
  if (skins[i].cache.data)
   Cache_Free (&skins[i].cache);
 }
 numskins = 0;
 skins_need_preache = true;
 cls.downloadnumber = 0;
 cls.downloadtype = dl_skin;
 Skin_NextDownload ();
 if (cls.mvdplayback == 2 && cbuf_current != &cbuf_main)
 {
  cls.qtv_donotbuffer = false;
 }
}


decompiled_code:
__int64 Skin_AllSkins_f()
{
const char *v0; // rax
__int64 result; // rax
__int64 v2; // rsi

if ( (unsigned int)Cmd_Argc() == 1 )
return Com_Printf("allskins set to \"%s\"\n", &allskins);
if ( (unsigned int)Cmd_Argc() == 2 )
{
v2 = Cmd_Argv(1LL);
strlcpy(&allskins, v2, 128LL);
result = Skin_Skins_f();
}
else
{
v0 = (const char *)Cmd_Argv(0LL);
result = Com_Printf("Usage: %s [skin]\n", v0);
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
const char *v0; // rax
__int64 result; // rax
__int64 v2; // rsi

if ( (unsigned int)Cmd_Argc() == 1 )
return Com_Printf("allskins set to \"%s\"\n", &allskins);
if ( (unsigned int)Cmd_Argc() == 2 )
{
v2 = Cmd_Argv(1LL);
strlcpy(&allskins, v2, 128LL);
result = func5();
}
else
{
v0 = (const char *)Cmd_Argv(0LL);
result = Com_Printf("Usage: %s [skin]\n", v0);
}
return result;
}

original_code:
void Skin_AllSkins_f (void) {
 if (Cmd_Argc() == 1) {
  Com_Printf("allskins set to \"%s\"\n", allskins);
  return;
 }
 if (Cmd_Argc() != 2) {
  Com_Printf("Usage: %s [skin]\n", Cmd_Argv(0));
  return;
 }
 strlcpy (allskins, Cmd_Argv(1), sizeof(allskins));
 Skin_Skins_f();
}

canonical_original_code:
void Skin_AllSkins_f() {
 if (Cmd_Argc() == 1) {
  Com_Printf("allskins set to \"%s\"\n", allskins);
  return;
 }
 if (Cmd_Argc() != 2) {
  Com_Printf("Usage: %s [skin]\n", Cmd_Argv(0));
  return;
 }
 strlcpy (allskins, Cmd_Argv(1), sizeof(allskins));
 Skin_Skins_f();
}


original_code:
void Skin_ShowSkins_f (void) {
 int i, count, maxlen;
 maxlen = sizeof("name") - 1;
 for (i = 0; i < 32; i++)
  if (cl.players[i].name[0] && !cl.players[i].spectator)
   maxlen = ((maxlen) >= (17) ? (maxlen) : (strlen(cl.players[i].name)) < (maxlen) ? (maxlen) : (strlen(cl.players[i].name)) > (17) ? (17) : (strlen(cl.players[i].name)));
 for (i = count = 0; i < 32; i++)
  if (cl.players[i].name[0] && !cl.players[i].spectator) {
   if (!count)
    Com_Printf("\x02%-*.*s %s\n", maxlen, maxlen, "name", "skin");
   Com_Printf("%-*.*s %s\n", maxlen, maxlen, cl.players[i].name, Skin_FindName(&cl.players[i]));
   count++;
  }
}

canonical_original_code:
void Skin_ShowSkins_f() {
 int i; int count; int maxlen;
 maxlen = sizeof("name") - 1;
 for (i = 0; i < 32; i++)
  if (cl.players[i].name[0] && !cl.players[i].spectator)
   maxlen = ((maxlen) >= (17) ? (maxlen) : (strlen(cl.players[i].name)) < (maxlen) ? (maxlen) : (strlen(cl.players[i].name)) > (17) ? (17) : (strlen(cl.players[i].name)));
 for (i = count = 0; i < 32; i++)
  if (cl.players[i].name[0] && !cl.players[i].spectator) {
   if (!count)
    Com_Printf("\x02%-*.*s %s\n", maxlen, maxlen, "name", "skin");
   Com_Printf("%-*.*s %s\n", maxlen, maxlen, cl.players[i].name, Skin_FindName(&cl.players[i]));
   count++;
  }
}

variable_types: count int

variable_types: maxlen int