decompiled_code:
__int64 __fastcall do_heal(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
unsigned int v4; // er13
const char *v5; // r15
void *v6; // r14
int v7; // er12
__int16 v8; // ax
__int16 v9; // ax
__int64 v10; // rax
__int64 v11[39]; // [rsp+0h] [rbp-138h] BYREF

v11[0] = 0LL;
v11[1] = 0LL;
v11[2] = 0LL;
v11[3] = 0LL;
v11[4] = 0LL;
v11[5] = 0LL;
v11[6] = 0LL;
v11[7] = 0LL;
v11[8] = 0LL;
v11[9] = 0LL;
v11[10] = 0LL;
v11[11] = 0LL;
v11[12] = 0LL;
v11[13] = 0LL;
v11[14] = 0LL;
v11[15] = 0LL;
v11[16] = 0LL;
v11[17] = 0LL;
v11[18] = 0LL;
v11[19] = 0LL;
v11[20] = 0LL;
v11[21] = 0LL;
v11[22] = 0LL;
v11[23] = 0LL;
v11[24] = 0LL;
v11[25] = 0LL;
v11[26] = 0LL;
v11[27] = 0LL;
v11[28] = 0LL;
v11[29] = 0LL;
v11[30] = 0LL;
v11[31] = 0LL;
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 128) + 8LL);
if ( !v2 )
return send_to_char("You can't do that here.\n\r", a1);
while ( (*(_QWORD *)(v2 + 320) & 0x4000001LL) != 67108865 )
{
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
return send_to_char("You can't do that here.\n\r", a1);
}
one_argument(a2, v11);
if ( LOBYTE(v11[0]) )
{
if ( (unsigned __int8)str_prefix(v11, "light") )
{
if ( (unsigned __int8)str_prefix(v11, "serious") )
{
if ( (unsigned __int8)str_prefix(v11, "critical") )
{
if ( (unsigned __int8)str_prefix(v11, "heal") )
{
if ( (unsigned __int8)str_prefix(v11, "blindness") )
{
if ( (unsigned __int8)str_prefix(v11, "disease") )
{
if ( (unsigned __int8)str_prefix(v11, "poison") )
{
if ( (unsigned __int8)str_prefix(v11, "uncurse") && (unsigned __int8)str_prefix(v11, "curse") )
{
if ( (unsigned __int8)str_prefix(v11, "mana") )
{
if ( (unsigned __int8)str_prefix(v11, "energize") )
{
if ( (unsigned __int8)str_prefix(v11, "refresh") && (unsigned __int8)str_prefix(v11, "moves") )
return act_new("$N says 'Type 'heal' for a list of spells.'", a1, 0LL, v2, 3LL, 5LL);
v4 = skill_lookup("refresh");
v5 = "candusima";
v6 = &spell_refresh;
v7 = 500;
}
else
{
v5 = "energizer";
v6 = 0LL;
v4 = -1;
v7 = 1000;
}
}
else
{
v5 = "energizer";
v6 = 0LL;
v4 = -1;
v7 = 1000;
}
}
else
{
v4 = skill_lookup("remove curse");
v5 = "candussido judifgz";
v6 = &spell_remove_curse;
v7 = 5000;
}
}
else
{
v4 = skill_lookup("cure poison");
v5 = "judicandus sausabru";
v6 = &spell_cure_poison;
v7 = 2500;
}
}
else
{
v4 = skill_lookup("cure disease");
v5 = "judicandus eugzagz";
v6 = &spell_cure_disease;
v7 = 1500;
}
}
else
{
v4 = skill_lookup("cure blindness");
v5 = "judicandus noselacri";
v6 = &spell_cure_blindness;
v7 = 2000;
}
}
else
{
v4 = skill_lookup("heal");
v5 = "pzar";
v6 = &spell_heal;
v7 = 5000;
}
}
else
{
v4 = skill_lookup("cure critical");
v5 = "judicandus qfuhuqar";
v6 = &spell_cure_critical;
v7 = 2500;
}
}
else
{
v4 = skill_lookup("cure serious");
v5 = "judicandus gzfuajg";
v6 = &spell_cure_serious;
v7 = 1600;
}
}
else
{
v4 = skill_lookup("cure light");
v5 = "judicandus dies";
v6 = &spell_cure_light;
v7 = 1000;
}
if ( v7 > *(_QWORD *)(a1 + 304) + 100LL * *(_QWORD *)(a1 + 296) )
{
result = act_new("$N says 'You do not have enough gold for my services.'", a1, 0LL, v2, 3LL, 5LL);
}
else
{
if ( (int)get_trust(a1) <= 51 )
{
v9 = 12;
if ( *(__int16 *)(a1 + 274) >= 12 )
v9 = *(_WORD *)(a1 + 274);
*(_WORD *)(a1 + 274) = v9;
}
deduct_cost(a1, (unsigned int)v7);
v10 = (1374389535LL * v7) >> 37;
*(_QWORD *)(v2 + 296) += (int)v10;
*(_QWORD *)(v2 + 304) += v7 - 100 * (int)v10;
result = act_new("$n utters the words '$T'.", v2, 0LL, v5, 0LL, 5LL);
if ( v6 )
{
if ( v4 != -1 )
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, __int64, __int64, _QWORD))v6)(
v4,
(unsigned int)*(__int16 *)(v2 + 250),
v2,
a1,
0LL);
}
else
{
v8 = dice(2LL, 8LL) + *(_WORD *)(a1 + 282) + *(__int16 *)(v2 + 250) / 3;
if ( v8 > *(__int16 *)(a1 + 284) )
v8 = *(_WORD *)(a1 + 284);
*(_WORD *)(a1 + 282) = v8;
result = send_to_char("A warm glow passes through you.\n\r", a1);
}
}
}
else
{
act_new("$N says 'I offer the following spells:'", a1, 0LL, v2, 3LL, 5LL);
send_to_char(" light: cure light wounds 10 gold\n\r", a1);
send_to_char(" serious: cure serious wounds 15 gold\n\r", a1);
send_to_char(" critic: cure critical wounds 25 gold\n\r", a1);
send_to_char(" heal: healing spell\t 50 gold\n\r", a1);
send_to_char(" blind: cure blindness 20 gold\n\r", a1);
send_to_char(" disease: cure disease 15 gold\n\r", a1);
send_to_char(" poison: cure poison\t 25 gold\n\r", a1);
send_to_char(" uncurse: remove curse\t 50 gold\n\r", a1);
send_to_char(" refresh: restore movement 5 gold\n\r", a1);
send_to_char(" mana: restore mana\t 10 gold\n\r", a1);
result = send_to_char(" Type heal <type> to be healed.\n\r", a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
unsigned int v4; // er13
const char *v5; // r15
void *v6; // r14
int v7; // er12
__int16 v8; // ax
__int16 v9; // ax
__int64 v10; // rax
__int64 v11[39]; // [rsp+0h] [rbp-138h] BYREF

v11[0] = 0LL;
v11[1] = 0LL;
v11[2] = 0LL;
v11[3] = 0LL;
v11[4] = 0LL;
v11[5] = 0LL;
v11[6] = 0LL;
v11[7] = 0LL;
v11[8] = 0LL;
v11[9] = 0LL;
v11[10] = 0LL;
v11[11] = 0LL;
v11[12] = 0LL;
v11[13] = 0LL;
v11[14] = 0LL;
v11[15] = 0LL;
v11[16] = 0LL;
v11[17] = 0LL;
v11[18] = 0LL;
v11[19] = 0LL;
v11[20] = 0LL;
v11[21] = 0LL;
v11[22] = 0LL;
v11[23] = 0LL;
v11[24] = 0LL;
v11[25] = 0LL;
v11[26] = 0LL;
v11[27] = 0LL;
v11[28] = 0LL;
v11[29] = 0LL;
v11[30] = 0LL;
v11[31] = 0LL;
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 128) + 8LL);
if ( !v2 )
return send_to_char("You can't do that here.\n\r", a1);
while ( (*(_QWORD *)(v2 + 320) & 0x4000001LL) != 67108865 )
{
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
return send_to_char("You can't do that here.\n\r", a1);
}
one_argument(a2, v11);
if ( LOBYTE(v11[0]) )
{
if ( (unsigned __int8)str_prefix(v11, "light") )
{
if ( (unsigned __int8)str_prefix(v11, "serious") )
{
if ( (unsigned __int8)str_prefix(v11, "critical") )
{
if ( (unsigned __int8)str_prefix(v11, "heal") )
{
if ( (unsigned __int8)str_prefix(v11, "blindness") )
{
if ( (unsigned __int8)str_prefix(v11, "disease") )
{
if ( (unsigned __int8)str_prefix(v11, "poison") )
{
if ( (unsigned __int8)str_prefix(v11, "uncurse") && (unsigned __int8)str_prefix(v11, "curse") )
{
if ( (unsigned __int8)str_prefix(v11, "mana") )
{
if ( (unsigned __int8)str_prefix(v11, "energize") )
{
if ( (unsigned __int8)str_prefix(v11, "refresh") && (unsigned __int8)str_prefix(v11, "moves") )
return act_new("$N says 'Type 'heal' for a list of spells.'", a1, 0LL, v2, 3LL, 5LL);
v4 = skill_lookup("refresh");
v5 = "candusima";
v6 = &spell_refresh;
v7 = 500;
}
else
{
v5 = "energizer";
v6 = 0LL;
v4 = -1;
v7 = 1000;
}
}
else
{
v5 = "energizer";
v6 = 0LL;
v4 = -1;
v7 = 1000;
}
}
else
{
v4 = skill_lookup("remove curse");
v5 = "candussido judifgz";
v6 = &spell_remove_curse;
v7 = 5000;
}
}
else
{
v4 = skill_lookup("cure poison");
v5 = "judicandus sausabru";
v6 = &spell_cure_poison;
v7 = 2500;
}
}
else
{
v4 = skill_lookup("cure disease");
v5 = "judicandus eugzagz";
v6 = &spell_cure_disease;
v7 = 1500;
}
}
else
{
v4 = skill_lookup("cure blindness");
v5 = "judicandus noselacri";
v6 = &spell_cure_blindness;
v7 = 2000;
}
}
else
{
v4 = skill_lookup("heal");
v5 = "pzar";
v6 = &spell_heal;
v7 = 5000;
}
}
else
{
v4 = skill_lookup("cure critical");
v5 = "judicandus qfuhuqar";
v6 = &spell_cure_critical;
v7 = 2500;
}
}
else
{
v4 = skill_lookup("cure serious");
v5 = "judicandus gzfuajg";
v6 = &spell_cure_serious;
v7 = 1600;
}
}
else
{
v4 = skill_lookup("cure light");
v5 = "judicandus dies";
v6 = &spell_cure_light;
v7 = 1000;
}
if ( v7 > *(_QWORD *)(a1 + 304) + 100LL * *(_QWORD *)(a1 + 296) )
{
result = act_new("$N says 'You do not have enough gold for my services.'", a1, 0LL, v2, 3LL, 5LL);
}
else
{
if ( (int)get_trust(a1) <= 51 )
{
v9 = 12;
if ( *(__int16 *)(a1 + 274) >= 12 )
v9 = *(_WORD *)(a1 + 274);
*(_WORD *)(a1 + 274) = v9;
}
deduct_cost(a1, (unsigned int)v7);
v10 = (1374389535LL * v7) >> 37;
*(_QWORD *)(v2 + 296) += (int)v10;
*(_QWORD *)(v2 + 304) += v7 - 100 * (int)v10;
result = act_new("$n utters the words '$T'.", v2, 0LL, v5, 0LL, 5LL);
if ( v6 )
{
if ( v4 != -1 )
result = ((__int64 (__fastcall *)(_QWORD, _QWORD, __int64, __int64, _QWORD))v6)(
v4,
(unsigned int)*(__int16 *)(v2 + 250),
v2,
a1,
0LL);
}
else
{
v8 = dice(2LL, 8LL) + *(_WORD *)(a1 + 282) + *(__int16 *)(v2 + 250) / 3;
if ( v8 > *(__int16 *)(a1 + 284) )
v8 = *(_WORD *)(a1 + 284);
*(_WORD *)(a1 + 282) = v8;
result = send_to_char("A warm glow passes through you.\n\r", a1);
}
}
}
else
{
act_new("$N says 'I offer the following spells:'", a1, 0LL, v2, 3LL, 5LL);
send_to_char(" light: cure light wounds 10 gold\n\r", a1);
send_to_char(" serious: cure serious wounds 15 gold\n\r", a1);
send_to_char(" critic: cure critical wounds 25 gold\n\r", a1);
send_to_char(" heal: healing spell\t 50 gold\n\r", a1);
send_to_char(" blind: cure blindness 20 gold\n\r", a1);
send_to_char(" disease: cure disease 15 gold\n\r", a1);
send_to_char(" poison: cure poison\t 25 gold\n\r", a1);
send_to_char(" uncurse: remove curse\t 50 gold\n\r", a1);
send_to_char(" refresh: restore movement 5 gold\n\r", a1);
send_to_char(" mana: restore mana\t 10 gold\n\r", a1);
result = send_to_char(" Type heal <type> to be healed.\n\r", a1);
}
return result;
}

original_code:
void do_heal(CHAR_DATA *ch, char *argument)
{
 CHAR_DATA *mob;
 char arg[256]={'\0'};
 int cost = 0;
 int sn = 0;
 SPELL_FUN *spell;
 char *words;
 for ( mob = ch->in_room->people; mob; mob = mob->next_in_room )
 {
  if ( ((((mob)->act) & ((1)))) && ((mob->act) & ((67108864))) )
   break;
 }
 if ( mob == ((void *)0) )
 {
  send_to_char( "You can't do that here.\n\r", ch );
  return;
 }
 one_argument(argument,arg);
 if (((arg) == ((void *)0) || (arg)[0] == '\0'))
 {
  act_new(("$N says 'I offer the following spells:'"),(ch),(((void *)0)),(mob),(3),5);
  send_to_char("  light: cure light wounds      10 gold\n\r",ch);
  send_to_char("  serious: cure serious wounds  15 gold\n\r",ch);
  send_to_char("  critic: cure critical wounds  25 gold\n\r",ch);
  send_to_char("  heal: healing spell	      50 gold\n\r",ch);
  send_to_char("  blind: cure blindness         20 gold\n\r",ch);
  send_to_char("  disease: cure disease         15 gold\n\r",ch);
  send_to_char("  poison:  cure poison	      25 gold\n\r",ch);
  send_to_char("  uncurse: remove curse	      50 gold\n\r",ch);
  send_to_char("  refresh: restore movement      5 gold\n\r",ch);
  send_to_char("  mana:  restore mana	      10 gold\n\r",ch);
  send_to_char(" Type heal <type> to be healed.\n\r",ch);
  return;
 }
 if (!str_prefix(arg,"light"))
 {
  spell = spell_cure_light;
  sn = skill_lookup("cure light");
  words = "judicandus dies";
  cost = 1000;
 }
 else if (!str_prefix(arg,"serious"))
 {
  spell = spell_cure_serious;
  sn = skill_lookup("cure serious");
  words = "judicandus gzfuajg";
  cost = 1600;
 }
 else if (!str_prefix(arg,"critical"))
 {
  spell = spell_cure_critical;
  sn = skill_lookup("cure critical");
  words = "judicandus qfuhuqar";
  cost = 2500;
 }
 else if (!str_prefix(arg,"heal"))
 {
  spell = spell_heal;
  sn = skill_lookup("heal");
  words = "pzar";
  cost = 5000;
 }
 else if (!str_prefix(arg,"blindness"))
 {
  spell = spell_cure_blindness;
  sn = skill_lookup("cure blindness");
  words = "judicandus noselacri";
  cost = 2000;
 }
 else if (!str_prefix(arg,"disease"))
 {
  spell = spell_cure_disease;
  sn = skill_lookup("cure disease");
  words = "judicandus eugzagz";
  cost = 1500;
 }
 else if (!str_prefix(arg,"poison"))
 {
  spell = spell_cure_poison;
  sn = skill_lookup("cure poison");
  words = "judicandus sausabru";
  cost = 2500;
 }
 else if (!str_prefix(arg,"uncurse") || !str_prefix(arg,"curse"))
 {
  spell = spell_remove_curse;
  sn = skill_lookup("remove curse");
  words = "candussido judifgz";
  cost = 5000;
 }
 else if (!str_prefix(arg,"mana") || !str_prefix(arg,"energize"))
 {
  spell = ((void *)0);
  sn = -1;
  words = "energizer";
  cost = 1000;
 }
 else if (!str_prefix(arg,"refresh") || !str_prefix(arg,"moves"))
 {
  spell = spell_refresh;
  sn = skill_lookup("refresh");
  words = "candusima";
  cost = 500;
 }
 else
 {
  act_new(("$N says 'Type 'heal' for a list of spells.'"),(ch),(((void *)0)),(mob),(3),5);
  return;
 }
 if (cost > (ch->gold * 100 + ch->silver))
 {
  act_new(("$N says 'You do not have enough gold for my services.'"),(ch),(((void *)0)),(mob),(3),5);
  return;
 }
 { if(!(get_trust((ch)) >= (60 - 8))) { ((ch)->wait = (((ch)->wait) > ((( 3 * 4))) ? ((ch)->wait) : ((( 3 * 4))))); } } while(0);
 deduct_cost(ch,cost);
 mob->gold += cost / 100;
 mob->silver += cost % 100;
 act_new(("$n utters the words '$T'."),(mob),(((void *)0)),(words),(0),5);
 if (spell == ((void *)0))
 {
  ch->mana += dice(2,8) + mob->level / 3;
  ch->mana = ((ch->mana) < (ch->max_mana) ? (ch->mana) : (ch->max_mana));
  send_to_char("A warm glow passes through you.\n\r",ch);
  return;
 }
 if (sn == -1)
  return;
 spell(sn,mob->level,mob,ch,0);
}

canonical_original_code:
void do_heal(struct char_data *ch, char *argument)
{
 struct char_data *mob;
 char arg[256] = {'\0'};
 int cost = 0;
 int sn = 0;
 void (*spell)(int sn, int level, struct char_data *ch, void *vo, int target);
 char *words;
 for ( mob = ch->in_room->people; mob; mob = mob->next_in_room )
 {
  if ( ((((mob)->act) & ((1)))) && ((mob->act) & ((67108864))) )
   break;
 }
 if ( mob == ((void *)0) )
 {
  send_to_char( "You can't do that here.\n\r", ch );
  return;
 }
 one_argument(argument,arg);
 if (((arg) == ((void *)0) || (arg)[0] == '\0'))
 {
  act_new(("$N says 'I offer the following spells:'"),(ch),(((void *)0)),(mob),(3),5);
  send_to_char("  light: cure light wounds      10 gold\n\r",ch);
  send_to_char("  serious: cure serious wounds  15 gold\n\r",ch);
  send_to_char("  critic: cure critical wounds  25 gold\n\r",ch);
  send_to_char("  heal: healing spell	      50 gold\n\r",ch);
  send_to_char("  blind: cure blindness         20 gold\n\r",ch);
  send_to_char("  disease: cure disease         15 gold\n\r",ch);
  send_to_char("  poison:  cure poison	      25 gold\n\r",ch);
  send_to_char("  uncurse: remove curse	      50 gold\n\r",ch);
  send_to_char("  refresh: restore movement      5 gold\n\r",ch);
  send_to_char("  mana:  restore mana	      10 gold\n\r",ch);
  send_to_char(" Type heal <type> to be healed.\n\r",ch);
  return;
 }
 if (!str_prefix(arg,"light"))
 {
  spell = spell_cure_light;
  sn = skill_lookup("cure light");
  words = "judicandus dies";
  cost = 1000;
 }
 else if (!str_prefix(arg,"serious"))
 {
  spell = spell_cure_serious;
  sn = skill_lookup("cure serious");
  words = "judicandus gzfuajg";
  cost = 1600;
 }
 else if (!str_prefix(arg,"critical"))
 {
  spell = spell_cure_critical;
  sn = skill_lookup("cure critical");
  words = "judicandus qfuhuqar";
  cost = 2500;
 }
 else if (!str_prefix(arg,"heal"))
 {
  spell = spell_heal;
  sn = skill_lookup("heal");
  words = "pzar";
  cost = 5000;
 }
 else if (!str_prefix(arg,"blindness"))
 {
  spell = spell_cure_blindness;
  sn = skill_lookup("cure blindness");
  words = "judicandus noselacri";
  cost = 2000;
 }
 else if (!str_prefix(arg,"disease"))
 {
  spell = spell_cure_disease;
  sn = skill_lookup("cure disease");
  words = "judicandus eugzagz";
  cost = 1500;
 }
 else if (!str_prefix(arg,"poison"))
 {
  spell = spell_cure_poison;
  sn = skill_lookup("cure poison");
  words = "judicandus sausabru";
  cost = 2500;
 }
 else if (!str_prefix(arg,"uncurse") || !str_prefix(arg,"curse"))
 {
  spell = spell_remove_curse;
  sn = skill_lookup("remove curse");
  words = "candussido judifgz";
  cost = 5000;
 }
 else if (!str_prefix(arg,"mana") || !str_prefix(arg,"energize"))
 {
  spell = ((void *)0);
  sn = -1;
  words = "energizer";
  cost = 1000;
 }
 else if (!str_prefix(arg,"refresh") || !str_prefix(arg,"moves"))
 {
  spell = spell_refresh;
  sn = skill_lookup("refresh");
  words = "candusima";
  cost = 500;
 }
 else
 {
  act_new(("$N says 'Type 'heal' for a list of spells.'"),(ch),(((void *)0)),(mob),(3),5);
  return;
 }
 if (cost > (ch->gold * 100 + ch->silver))
 {
  act_new(("$N says 'You do not have enough gold for my services.'"),(ch),(((void *)0)),(mob),(3),5);
  return;
 }
 { if(!(get_trust((ch)) >= (60 - 8))) { ((ch)->wait = (((ch)->wait) > ((( 3 * 4))) ? ((ch)->wait) : ((( 3 * 4))))); } } while(0);
 deduct_cost(ch,cost);
 mob->gold += cost / 100;
 mob->silver += cost % 100;
 act_new(("$n utters the words '$T'."),(mob),(((void *)0)),(words),(0),5);
 if (spell == ((void *)0))
 {
  ch->mana += dice(2,8) + mob->level / 3;
  ch->mana = ((ch->mana) < (ch->max_mana) ? (ch->mana) : (ch->max_mana));
  send_to_char("A warm glow passes through you.\n\r",ch);
  return;
 }
 if (sn == -1)
  return;
 spell(sn,mob->level,mob,ch,0);
}

variable_types:
argument
char *

variable_types: cost int

variable_types: sn int

variable_types: void (*)(int sn, int level, struct char_data { struct char_data *next; struct char_data *next_in_room; struct char_data *master; struct char_data *leader; struct char_data *fighting; struct char_data *reply; struct char_data *pet; struct char_data *mprog_target; struct mem_data { struct mem_data *next; unsigned char valid; int id; int reaction; long when; } *memory; unsigned char (*spec_fun)(struct char_data *ch); struct mob_index_data { struct mob_index_data *next; unsigned char (*spec_fun)(struct char_data *ch); struct shop_data { struct shop_data *next; short keeper; short buy_type[5]; short profit_buy; short profit_sell; short open_hour; short close_hour; } *pShop; struct mprog_list { int trig_type; char *trig_phrase; short vnum; char *code; struct mprog_list *next; unsigned char valid; } *mprogs; struct area_data { struct area_data *next; struct help_area_data { struct help_area_data *next; struct help_data { struct help_data *next; struct help_data *next_area; short level; char *keyword; char *text; } *first; struct help_data *last; struct area_data *area; char *filename; unsigned char changed; } *helps; char *file_name; char *name; char *credits; short age; short nplayer; short low_range; short high_range; short min_vnum; short max_vnum; unsigned char empty; char *builders; int vnum; int area_flags; int security; } *area; short vnum; short group; unsigned char new_format; short count; short killed; char *player_name; char *short_descr; char *long_descr; char *description; long act; long affected_by; short alignment; short level; short hitroll; short hit[3]; short mana[3]; short damage[3]; short ac[4]; short dam_type; long off_flags; long imm_flags; long res_flags; long vuln_flags; short start_pos; short default_pos; short sex; short race; long wealth; long form; long parts; short size; char *material; long mprog_flags; } *pIndexData; struct descriptor_data { struct descriptor_data *next; struct descriptor_data *snoop_by; struct char_data *character; struct char_data *original; unsigned char valid; char *host; short descriptor; short connected; unsigned char fcommand; char inbuf[-1]; char incomm[256]; char inlast[256]; int repeat; char *outbuf; int outsize; int outtop; char *showstr_head; char *showstr_point; void *pEdit; char **pString; int editor; struct protocol_t { int WriteOOB; enum bool_t { false=0, true=1 } Negotiated[-1]; enum bool_t { false=0, true=1 } bIACMode; enum bool_t { false=0, true=1 } bNegotiated; enum bool_t { false=0, true=1 } bRenegotiate; enum bool_t { false=0, true=1 } bNeedMXPVersion; enum bool_t { false=0, true=1 } bBlockMXP; enum bool_t { false=0, true=1 } bTTYPE; enum bool_t { false=0, true=1 } bECHO; enum bool_t { false=0, true=1 } bNAWS; enum bool_t { false=0, true=1 } bCHARSET; enum bool_t { false=0, true=1 } bMSDP; enum bool_t { false=0, true=1 } bMSSP; enum bool_t { false=0, true=1 } bATCP; enum bool_t { false=0, true=1 } bMSP; enum bool_t { false=0, true=1 } bMXP; enum bool_t { false=0, true=1 } bMCCP; enum support_t { eUNKNOWN=0, eNO=1, eSOMETIMES=2, eYES=3 } b256Support; int ScreenWidth; int ScreenHeight; char *pMXPVersion; char *pLastTTYPE; struct MSDP_t { enum bool_t { false=0, true=1 } bReport; enum bool_t { false=0, true=1 } bDirty; int ValueInt; char *pValueString; } **pVariables; } *pProtocol; } *desc; struct affect_data { struct affect_data *next; unsigned char valid; short where; short type; short level; short duration; short location; short modifier; int bitvector; } *affected; struct note_data { struct note_data *next; unsigned char valid; short type; char *sender; char *date; char *to_list; char *subject; char *text; long date_stamp; } *pnote; struct obj_data { struct obj_data *next; struct obj_data *next_content; struct obj_data *contains; struct obj_data *in_obj; struct obj_data *on; struct char_data *carried_by; struct extra_descr_data { struct extra_descr_data *next; unsigned char valid; char *keyword; char *description; } *extra_descr; struct affect_data *affected; struct obj_index_data { struct obj_index_data *next; struct extra_descr_data *extra_descr; struct affect_data *affected; struct area_data *area; unsigned char new_format; char *name; char *short_descr; char *description; short vnum; short reset_num; char *material; short item_type; int extra_flags; int wear_flags; short level; short condition; short count; short weight; int cost; int value[5]; } *pIndexData; struct room_index_data { struct room_index_data *next; struct char_data *people; struct obj_data *contents; struct extra_descr_data *extra_descr; struct area_data *area; struct exit_data { union { struct room_index_data *to_room; short vnum; } u1; int exit_info; short key; char *keyword; char *description; struct exit_data *next; int rs_flags; int orig_door; } *exit[6]; struct reset_data { struct reset_data *next; char command; short arg1; short arg2; short arg3; short arg4; } *reset_first; struct reset_data *reset_last; char *name; char *description; char *owner; short vnum; int room_flags; short light; short sector_type; short heal_rate; short mana_rate; short clan; } *in_room; unsigned char valid; unsigned char enchanted; char *owner; char *name; char *short_descr; char *description; short item_type; int extra_flags; int wear_flags; short wear_loc; short weight; int cost; short level; short condition; char *material; short timer; int value[5]; } *carrying; struct obj_data *on; struct room_index_data *in_room; struct room_index_data *was_in_room; struct area_data *zone; struct pc_data { struct pc_data *next; struct buf_type { struct buf_type *next; unsigned char valid; short state; short size; char *string; char *file; char *function; int line; } *buffer; unsigned char valid; char *pwd; char *bamfin; char *bamfout; char *title; long last_note; long last_idea; long last_penalty; long last_news; long last_changes; short perm_hit; short perm_mana; short perm_move; short true_sex; int last_level; short condition[4]; short learned[151]; unsigned char group_known[30]; short points; unsigned char confirm_delete; char *alias[5]; char *alias_sub[5]; int security; } *pcdata; struct gen_data { struct gen_data *next; unsigned char valid; unsigned char skill_chosen[151]; unsigned char group_chosen[30]; int points_chosen; } *gen_data; unsigned char valid; char *name; long id; short version; char *short_descr; char *long_descr; char *description; char *prompt; char *prefix; short group; short clan; short sex; short iclass; short race; short level; short trust; int played; int lines; long logon; short timer; short wait; short daze; short hit; short max_hit; short mana; short max_mana; short move; short max_move; long gold; long silver; int exp; long act; long comm; long wiznet; long imm_flags; long res_flags; long vuln_flags; short invis_level; short incog_level; long affected_by; short position; short practice; short train; short carry_weight; short carry_number; short saving_throw; short alignment; short hitroll; short damroll; short armor[4]; short wimpy; short perm_stat[5]; short mod_stat[5]; long form; long parts; short size; char *material; long off_flags; short damage[3]; short dam_type; short start_pos; short default_pos; short mprog_delay; } *ch, void *vo, int target)

variable_types:
words
char *

user_defined_types: struct char_data { struct char_data *next; struct char_data *next_in_room; struct char_data *master; struct char_data *leader; struct char_data *fighting; struct char_data *reply; struct char_data *pet; struct char_data *mprog_target; struct mem_data *memory; unsigned char (*spec_fun)(struct char_data *ch); struct mob_index_data *pIndexData; struct descriptor_data *desc; struct affect_data *affected; struct note_data *pnote; struct obj_data *carrying; struct obj_data *on; struct room_index_data *in_room; struct room_index_data *was_in_room; struct area_data *zone; struct pc_data *pcdata; struct gen_data *gen_data; unsigned char valid; char *name; long id; short version; char *short_descr; char *long_descr; char *description; char *prompt; char *prefix; short group; short clan; short sex; short iclass; short race; short level; short trust; int played; int lines; long logon; short timer; short wait; short daze; short hit; short max_hit; short mana; short max_mana; short move; short max_move; long gold; long silver; int exp; long act; long comm; long wiznet; long imm_flags; long res_flags; long vuln_flags; short invis_level; short incog_level; long affected_by; short position; short practice; short train; short carry_weight; short carry_number; short saving_throw; short alignment; short hitroll; short damroll; short armor[4]; short wimpy; short perm_stat[5]; short mod_stat[5]; long form; long parts; short size; char *material; long off_flags; short damage[3]; short dam_type; short start_pos; short default_pos; short mprog_delay; }

user_defined_types: struct mob_index_data { struct mob_index_data *next; unsigned char (*spec_fun)(struct char_data *ch); struct shop_data *pShop; struct mprog_list *mprogs; struct area_data *area; short vnum; short group; unsigned char new_format; short count; short killed; char *player_name; char *short_descr; char *long_descr; char *description; long act; long affected_by; short alignment; short level; short hitroll; short hit[3]; short mana[3]; short damage[3]; short ac[4]; short dam_type; long off_flags; long imm_flags; long res_flags; long vuln_flags; short start_pos; short default_pos; short sex; short race; long wealth; long form; long parts; short size; char *material; long mprog_flags; }

user_defined_types: struct descriptor_data { struct descriptor_data *next; struct descriptor_data *snoop_by; struct char_data *character; struct char_data *original; unsigned char valid; char *host; short descriptor; short connected; unsigned char fcommand; char inbuf[-1]; char incomm[256]; char inlast[256]; int repeat; char *outbuf; int outsize; int outtop; char *showstr_head; char *showstr_point; void *pEdit; char **pString; int editor; struct protocol_t *pProtocol; }

user_defined_types: struct obj_data { struct obj_data *next; struct obj_data *next_content; struct obj_data *contains; struct obj_data *in_obj; struct obj_data *on; struct char_data *carried_by; struct extra_descr_data *extra_descr; struct affect_data *affected; struct obj_index_data *pIndexData; struct room_index_data *in_room; unsigned char valid; unsigned char enchanted; char *owner; char *name; char *short_descr; char *description; short item_type; int extra_flags; int wear_flags; short wear_loc; short weight; int cost; short level; short condition; char *material; short timer; int value[5]; }

user_defined_types: struct pc_data { struct pc_data *next; struct buf_type *buffer; unsigned char valid; char *pwd; char *bamfin; char *bamfout; char *title; long last_note; long last_idea; long last_penalty; long last_news; long last_changes; short perm_hit; short perm_mana; short perm_move; short true_sex; int last_level; short condition[4]; short learned[151]; unsigned char group_known[30]; short points; unsigned char confirm_delete; char *alias[5]; char *alias_sub[5]; int security; }

user_defined_types: struct room_index_data { struct room_index_data *next; struct char_data *people; struct obj_data *contents; struct extra_descr_data *extra_descr; struct area_data *area; struct exit_data *exit[6]; struct reset_data *reset_first; struct reset_data *reset_last; char *name; char *description; char *owner; short vnum; int room_flags; short light; short sector_type; short heal_rate; short mana_rate; short clan; }


now

repo: punkave/sanity-benchmark

decompiled_code:
double now()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return (double)SLODWORD(v1.tv_usec) / 1000000.0 + (double)SLODWORD(v1.tv_sec);
}

canonical_decompiled_code:
double func7()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return (double)SLODWORD(v1.tv_usec) / 1000000.0 + (double)SLODWORD(v1.tv_sec);
}

original_code:
static double now() {
  struct timeval tv;
  gettimeofday(&tv, 0);
  return tv.tv_sec + ((double) tv.tv_usec) / 1000000.0;
}

variable_types: struct timeval { long tv_sec; long tv_usec; }

return_type: double


cpu

decompiled_code:
int cpu()
{
double v0; // rbx
int v1; // eax
double v2; // xmm0_8

v0 = now();
v1 = 1000000;
do
--v1;
while ( v1 );
puts("Printing result of CPU test computation so the compiler cannot optimize it away:\r");
printf("%f\r\n", -0.9773520315382229);
v2 = now();
return printf("CPU benchmark time: %.04f\r\n", v2 - v0);
}

canonical_decompiled_code:
int func9()
{
double v0; // rbx
int v1; // eax
double v2; // xmm0_8

v0 = func7();
v1 = 1000000;
do
--v1;
while ( v1 );
puts("Printing result of CPU test computation so the compiler cannot optimize it away:\r");
printf("%f\r\n", -0.9773520315382229);
v2 = func7();
return printf("CPU benchmark time: %.04f\r\n", v2 - v0);
}

original_code:
static void cpu() {
  double start = now();
  double s = 1.0;
  int i;
  for (i = 0; (i < 1000000); i++) {
    s = sin(i);
  }
  printf("Printing result of CPU test computation so the compiler cannot optimize it away:\r\n");
  printf("%f\r\n", s);
  double end = now();
  printf("CPU benchmark time: %.04f\r\n", end - start);
}

variable_types: start double

variable_types: s double

variable_types: i int

variable_types: end double

return_type: void


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
io();
cpu();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func8();
func9();
return 0;
}

original_code:
int main(int argc, char *argv[]) {
  io();
  cpu();
}

variable_types: argc int

variable_types:
argv
char *[]

return_type: int


repo: put-poznan/mls

decompiled_code:
__int64 __fastcall parse_opts(int argc, char **argv, __int64 a3)
{
int v4; // eax

*(_QWORD *)a3 = 0LL;
*(_QWORD *)(a3 + 8) = 0LL;
*(_QWORD *)(a3 + 16) = 0LL;
while ( 1 )
{
v4 = getopt(argc, argv, "alr");
if ( v4 == -1 )
break;
switch ( v4 )
{
case 'l':
*(_DWORD *)(a3 + 4) = 1;
break;
case 'r':
*(_DWORD *)(a3 + 8) = 1;
break;
case 'a':
*(_DWORD *)a3 = 1;
break;
default:
printf("Usage: %s [-alr] [directory]\n", *argv);
exit(1);
}
}
return (unsigned int)_bss_start;
}

canonical_decompiled_code:
__int64 __fastcall func7(int argc, char **argv, __int64 a3)
{
int v4; // eax

*(_QWORD *)a3 = 0LL;
*(_QWORD *)(a3 + 8) = 0LL;
*(_QWORD *)(a3 + 16) = 0LL;
while ( 1 )
{
v4 = getopt(argc, argv, "alr");
if ( v4 == -1 )
break;
switch ( v4 )
{
case 'l':
*(_DWORD *)(a3 + 4) = 1;
break;
case 'r':
*(_DWORD *)(a3 + 8) = 1;
break;
case 'a':
*(_DWORD *)a3 = 1;
break;
default:
printf("Usage: %s [-alr] [directory]\n", *argv);
exit(1);
}
}
return (unsigned int)_bss_start;
}

original_code:
int parse_opts(int argc, char *argv[], options* opts) {
  int c = 0;
  memset(opts, 0, sizeof(*opts));
  while ((c = getopt(argc, argv, "alr")) != -1) {
    switch (c) {
      case 'a':
        opts->all = 1;
        break;
      case 'l':
        opts->long_format = 1;
        break;
      case 'r':
        opts->reverse = 1;
        break;
      default:
        printf("Usage: %s [-alr] [directory]\n", argv[0]);
        exit(1);
    }
  }
  return optind;
}

canonical_original_code:
int parse_opts(int argc, char *argv[], struct options *opts) {
  int c = 0;
  memset(opts, 0, sizeof(*opts));
  while ((c = getopt(argc, argv, "alr")) != -1) {
    switch (c) {
      case 'a':
        opts->all = 1;
        break;
      case 'l':
        opts->long_format = 1;
        break;
      case 'r':
        opts->reverse = 1;
        break;
      default:
        printf("Usage: %s [-alr] [directory]\n", argv[0]);
        exit(1);
    }
  }
  return optind;
}

variable_types: struct options { int all; int long_format; int reverse; char *path; } *

variable_types: c int


normal

decompiled_code:
void __fastcall normal(void **a1, int a2, void (__fastcall *a3)(void *))
{
void **v4; // rbx

if ( a2 > 0 )
{
v4 = a1;
do
{
a3(*v4);
free(*v4++);
}
while ( v4 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

canonical_decompiled_code:
void __fastcall func8(void **a1, int a2, void (__fastcall *a3)(void *))
{
void **v4; // rbx

if ( a2 > 0 )
{
v4 = a1;
do
{
a3(*v4);
free(*v4++);
}
while ( v4 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

original_code:
void normal(struct dirent **namelist, int count, formatter_t f, options o) {
  int i;
  for (i = 0; i < count; i++) {
    f(namelist[i], o);
    free(namelist[i]);
  }
}

canonical_original_code:
void normal(struct dirent **namelist, int count, void (*f)(struct dirent *, struct options), struct options o) {
  int i;
  for (i = 0; i < count; i++) {
    f(namelist[i], o);
    free(namelist[i]);
  }
}

variable_types: struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; } **

variable_types: count int

variable_types: void (*)(struct dirent *, struct options { int all; int long_format; int reverse; char *path; })

variable_types:
o
struct options


reverse

original_code:
void reverse(struct dirent **namelist, int count, formatter_t f, options o) {
  int i;
  for (i = count - 1; i >= 0; i--) {
    f(namelist[i], o);
    free(namelist[i]);
  }
}

canonical_original_code:
void reverse(struct dirent **namelist, int count, void (*f)(struct dirent *, struct options), struct options o) {
  int i;
  for (i = count - 1; i >= 0; i--) {
    f(namelist[i], o);
    free(namelist[i]);
  }
}

user_defined_types: struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; }

user_defined_types: struct options { int all; int long_format; int reverse; char *path; }


decompiled_code:
_BOOL8 __fastcall skip_dotfiles(__int64 a1)
{
return *(_BYTE *)(a1 + 19) != 46;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(__int64 a1)
{
return *(_BYTE *)(a1 + 19) != 46;
}

original_code:
int skip_dotfiles(const struct dirent * node) {
  return node->d_name[0] != '.';
}

canonical_original_code:
int skip_dotfiles(struct dirent *node) {
  return node->d_name[0] != '.';
}

variable_types: struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; } *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // eax
int result; // eax
int (*selector[2])(const struct dirent *); // [rsp+0h] [rbp-68h]
__int64 v7[2]; // [rsp+10h] [rbp-58h]
__int64 v8[2]; // [rsp+20h] [rbp-48h]
__int64 v9; // [rsp+30h] [rbp-38h] BYREF
__int64 v10; // [rsp+38h] [rbp-30h]
char *dir; // [rsp+40h] [rbp-28h]
struct dirent **namelist; // [rsp+48h] [rbp-20h] BYREF

v8[0] = (__int64)default_format;
v8[1] = (__int64)long_format;
v7[0] = (__int64)normal;
v7[1] = (__int64)reverse;
selector[0] = (int (*)(const struct dirent *))skip_dotfiles;
selector[1] = 0LL;
v3 = parse_opts(argc, (char **)argv, (__int64)&v9);
dir = ".";
if ( argc > v3 )
dir = (char *)argv[v3];
v4 = scandir(dir, &namelist, selector[(int)v9], alphasort);
if ( v4 < 0 )
{
perror("mls");
result = 1;
}
else
{
((void (__fastcall *)(struct dirent **, _QWORD, __int64))v7[(int)v10])(namelist, (unsigned int)v4, v8[SHIDWORD(v9)]);
free(namelist);
result = 0;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // eax
int result; // eax
int (*selector[2])(const struct dirent *); // [rsp+0h] [rbp-68h]
__int64 v7[2]; // [rsp+10h] [rbp-58h]
__int64 v8[2]; // [rsp+20h] [rbp-48h]
__int64 v9; // [rsp+30h] [rbp-38h] BYREF
__int64 v10; // [rsp+38h] [rbp-30h]
char *dir; // [rsp+40h] [rbp-28h]
struct dirent **namelist; // [rsp+48h] [rbp-20h] BYREF

v8[0] = (__int64)default_format;
v8[1] = (__int64)long_format;
v7[0] = (__int64)normal;
v7[1] = (__int64)reverse;
selector[0] = (int (*)(const struct dirent *))skip_dotfiles;
selector[1] = 0LL;
v3 = func7(argc, (char **)argv, (__int64)&v9);
dir = ".";
if ( argc > v3 )
dir = (char *)argv[v3];
v4 = scandir(dir, &namelist, selector[(int)v9], alphasort);
if ( v4 < 0 )
{
perror("mls");
result = 1;
}
else
{
((void (__fastcall *)(struct dirent **, _QWORD, __int64))v7[(int)v10])(namelist, (unsigned int)v4, v8[SHIDWORD(v9)]);
free(namelist);
result = 0;
}
return result;
}

original_code:
int main(int argc, char* argv[]) {
  struct dirent **namelist;
  int dirs_count, opts_count;
  options opts;
  formatter_t formatters[] = {
    default_format,
    long_format
  };
  lister_t listers[] = {
    normal,
    reverse
  };
  filter_t filters[] = {
    skip_dotfiles,
    ((void *)0)
  };
  opts_count = parse_opts(argc, argv, &opts);
  opts.path = ".";
  if (opts_count < argc) {
    opts.path = argv[opts_count];
  }
  dirs_count = scandir(opts.path, &namelist, filters[opts.all], alphasort);
  if (dirs_count < 0) {
    perror("mls");
    return 1;
  } else {
    listers[opts.reverse](
        namelist,
        dirs_count,
        formatters[opts.long_format],
        opts
        );
    free(namelist);
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
  struct dirent **namelist;
  int dirs_count; int opts_count;
  struct options opts;
  void (*formatters[])(struct dirent *, struct options) = {
    default_format,
    long_format
  };
  void (*listers[])(struct dirent **, int, void (*)(struct dirent *, struct options), struct options) = {
    normal,
    reverse
  };
  int (*filters[])(struct dirent *) = {
    skip_dotfiles,
    ((void *)0)
  };
  opts_count = parse_opts(argc, argv, &opts);
  opts.path = ".";
  if (opts_count < argc) {
    opts.path = argv[opts_count];
  }
  dirs_count = scandir(opts.path, &namelist, filters[opts.all], alphasort);
  if (dirs_count < 0) {
    perror("mls");
    return 1;
  } else {
    listers[opts.reverse](
        namelist,
        dirs_count,
        formatters[opts.long_format],
        opts
        );
    free(namelist);
  }
  return 0;
}

variable_types: void (*[])(struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; } *, struct options { int all; int long_format; int reverse; char *path; })

variable_types: void (*[])(struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; } **, int, void (*)(struct dirent *, struct options { int all; int long_format; int reverse; char *path; }), struct options)

variable_types: int (*[])(struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; } *)


filetype

decompiled_code:
__int64 __fastcall filetype(__int16 a1)
{
unsigned int v1; // edi
__int64 result; // rax

v1 = a1 & 0xF000;
if ( v1 == 24576 )
return 98LL;
if ( v1 > 0x6000 )
{
result = 108LL;
if ( v1 != 40960 )
{
result = 45LL;
if ( v1 == 49152 )
result = 115LL;
}
}
else
{
result = 99LL;
if ( v1 != 0x2000 )
{
result = 100LL;
if ( v1 != 0x4000 )
{
result = 45LL;
if ( v1 == 4096 )
result = 102LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int16 a1)
{
unsigned int v1; // edi
__int64 result; // rax

v1 = a1 & 0xF000;
if ( v1 == 24576 )
return 98LL;
if ( v1 > 0x6000 )
{
result = 108LL;
if ( v1 != 40960 )
{
result = 45LL;
if ( v1 == 49152 )
result = 115LL;
}
}
else
{
result = 99LL;
if ( v1 != 0x2000 )
{
result = 100LL;
if ( v1 != 0x4000 )
{
result = 45LL;
if ( v1 == 4096 )
result = 102LL;
}
}
}
return result;
}

original_code:
char filetype(mode_t mode) {
  switch (mode & 0170000) {
    case 0140000: return 's';
    case 0120000: return 'l';
    case 0060000: return 'b';
    case 0040000: return 'd';
    case 0020000: return 'c';
    case 0010000: return 'f';
  }
  return '-';
}

canonical_original_code:
char filetype(unsigned int mode) {
  switch (mode & 0170000) {
    case 0140000: return 's';
    case 0120000: return 'l';
    case 0060000: return 'b';
    case 0040000: return 'd';
    case 0020000: return 'c';
    case 0010000: return 'f';
  }
  return '-';
}

variable_types:
mode
unsigned int

return_type: char


decompiled_code:
int __fastcall default_format(__int64 a1)
{
return puts((const char *)(a1 + 19));
}

canonical_decompiled_code:
int __fastcall func13(__int64 a1)
{
return puts((const char *)(a1 + 19));
}

original_code:
void default_format(struct dirent *name, options _) {
  puts(name->d_name);
}

canonical_original_code:
void default_format(struct dirent *name, struct options _) {
  puts(name->d_name);
}

variable_types: struct options { int all; int long_format; int reverse; char *path; }


decompiled_code:
int __fastcall long_format(__int64 a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, char *s)
{
int v9; // ebp
int v10; // eax
char *v11; // rbp
struct passwd *v12; // r12
struct group *v13; // r13
struct tm *v14; // rax
__off_t v15; // r15
const char *v16; // r14
const char *v17; // r13
__nlink_t v18; // r12
char v19; // al
const char *v21; // [rsp+8h] [rbp-140h]
char v22[102]; // [rsp+10h] [rbp-138h] BYREF
__int64 v23; // [rsp+76h] [rbp-D2h] BYREF
__int16 v24; // [rsp+7Eh] [rbp-CAh]
struct stat stat_buf; // [rsp+80h] [rbp-C8h] BYREF

v23 = 0LL;
v24 = 0;
v9 = strlen((const char *)(a1 + 19));
v10 = strlen(s);
v11 = (char *)malloc(v9 + v10 + 10);
strcpy(v11, s);
*(_WORD *)&v11[strlen(v11)] = 47;
strcat(v11, (const char *)(a1 + 19));
lstat(v11, &stat_buf);
v12 = getpwuid(stat_buf.st_uid);
v13 = getgrgid(stat_buf.st_gid);
v14 = localtime(&stat_buf.st_ctim.tv_sec);
strftime(v22, 0x63uLL, "%m-%d %R", v14);
v15 = stat_buf.st_size;
v16 = v13->gr_name;
v17 = v12->pw_name;
v18 = stat_buf.st_nlink;
v21 = (const char *)filemode(stat_buf.st_mode, (__int64)&v23);
v19 = filetype(stat_buf.st_mode);
return printf(
"%c%s %3d %s %s %5lld %s %s\n",
(unsigned int)v19,
v21,
v18,
v17,
v16,
v15,
v22,
(const char *)(a1 + 19));
}

canonical_decompiled_code:
int __fastcall func14(__int64 a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, char *s)
{
int v9; // ebp
int v10; // eax
char *v11; // rbp
struct passwd *v12; // r12
struct group *v13; // r13
struct tm *v14; // rax
__off_t v15; // r15
const char *v16; // r14
const char *v17; // r13
__nlink_t v18; // r12
char v19; // al
const char *v21; // [rsp+8h] [rbp-140h]
char v22[102]; // [rsp+10h] [rbp-138h] BYREF
__int64 v23; // [rsp+76h] [rbp-D2h] BYREF
__int16 v24; // [rsp+7Eh] [rbp-CAh]
struct stat stat_buf; // [rsp+80h] [rbp-C8h] BYREF

v23 = 0LL;
v24 = 0;
v9 = strlen((const char *)(a1 + 19));
v10 = strlen(s);
v11 = (char *)malloc(v9 + v10 + 10);
strcpy(v11, s);
*(_WORD *)&v11[strlen(v11)] = 47;
strcat(v11, (const char *)(a1 + 19));
func17(v11, &stat_buf);
v12 = getpwuid(stat_buf.st_uid);
v13 = getgrgid(stat_buf.st_gid);
v14 = localtime(&stat_buf.st_ctim.tv_sec);
strftime(v22, 0x63uLL, "%m-%d %R", v14);
v15 = stat_buf.st_size;
v16 = v13->gr_name;
v17 = v12->pw_name;
v18 = stat_buf.st_nlink;
v21 = (const char *)func12(stat_buf.st_mode, (__int64)&v23);
v19 = func11(stat_buf.st_mode);
return printf(
"%c%s %3d %s %s %5lld %s %s\n",
(unsigned int)v19,
v21,
v18,
v17,
v16,
v15,
v22,
(const char *)(a1 + 19));
}

original_code:
void long_format(struct dirent *name, options opts) {
  struct stat stats;
  struct passwd *user;
  struct group *group;
  char perm[10] = {0}, time[100], *filepath;
  int filepath_l = 0;
  filepath_l = strlen(name->d_name) + strlen(opts.path);
  filepath = (char*)malloc(filepath_l + 10);
  strcpy(filepath, opts.path);
  strcat(filepath, "/");
  strcat(filepath, name->d_name);
  lstat(filepath, &stats);
  user = getpwuid(stats.st_uid);
  group = getgrgid(stats.st_gid);
  strftime(time, 99, "%m-%d %R", localtime(&stats.st_ctim.tv_sec));
  printf("%c%s %3d %s %s %5lld %s %s\n",
      filetype(stats.st_mode),
      filemode(stats.st_mode, perm),
      stats.st_nlink,
      user->pw_name,
      group->gr_name,
      stats.st_size,
      time,
      name->d_name
      );
}

canonical_original_code:
void long_format(struct dirent *name, struct options opts) {
  struct stat stats;
  struct passwd *user;
  struct group *group;
  char perm[10] = {0}; char time[100]; char *filepath;
  int filepath_l = 0;
  filepath_l = strlen(name->d_name) + strlen(opts.path);
  filepath = (char *)malloc(filepath_l + 10);
  strcpy(filepath, opts.path);
  strcat(filepath, "/");
  strcat(filepath, name->d_name);
  lstat(filepath, &stats);
  user = getpwuid(stats.st_uid);
  group = getgrgid(stats.st_gid);
  strftime(time, 99, "%m-%d %R", localtime(&stats.st_ctim.tv_sec));
  printf("%c%s %3d %s %s %5lld %s %s\n",
      filetype(stats.st_mode),
      filemode(stats.st_mode, perm),
      stats.st_nlink,
      user->pw_name,
      group->gr_name,
      stats.st_size,
      time,
      name->d_name
      );
}

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

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *

variable_types: struct group { char *gr_name; char *gr_passwd; unsigned int gr_gid; char **gr_mem; } *

variable_types:
perm
char [10]

variable_types:
time
char [100]

variable_types:
filepath
char *

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


swap

repo: put-poznan/sorts

decompiled_code:
__int64 __fastcall swap(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = (unsigned int)*a1;
*a1 = *a2;
*a2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = (unsigned int)*a1;
*a1 = *a2;
*a2 = result;
return result;
}

original_code:
void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

variable_types:
a
int *

variable_types:
b
int *

variable_types: tmp int


decompiled_code:
__int64 __fastcall shell_sort(_DWORD *a1, int a2)
{
int v2; // ebx
__int64 result; // rax

v2 = a2 / 2;
if ( a2 > 1 )
{
do
{
insertion_sort(a1, v2, a2);
result = (unsigned int)v2;
v2 /= 2;
}
while ( (int)result > 1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_DWORD *a1, int a2)
{
int v2; // ebx
__int64 result; // rax

v2 = a2 / 2;
if ( a2 > 1 )
{
do
{
insertion_sort(a1, v2, a2);
result = (unsigned int)v2;
v2 /= 2;
}
while ( (int)result > 1 );
}
return result;
}

original_code:
void shell_sort(int arr[], int size) {
  int step = size / 2;
  for (; step > 0; step /= 2)
    insertion_sort(arr, step, size);
}

variable_types:
arr
int []

variable_types: size int

variable_types: step int


canonical_original_code:
void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}


heapify

decompiled_code:
__int64 __fastcall heapify(__int64 a1, int a2, int a3)
{
__int64 result; // rax
unsigned int v5; // er12

result = (unsigned int)(2 * a2);
v5 = result + 1;
if ( (int)result + 1 < a3 && *(_DWORD *)(a1 + 4LL * (int)result + 4) < *(_DWORD *)(a1 + 4LL * a2) )
{
if ( (int)result + 2 < a3 )
{
result = (int)result;
if ( *(_DWORD *)(a1 + 4LL * (int)result + 8) < *(_DWORD *)(a1 + 4LL * (int)v5) )
v5 = result + 2;
}
goto LABEL_9;
}
v5 = result + 2;
if ( a3 > (int)result + 2 )
{
result = (int)result;
if ( *(_DWORD *)(a1 + 4LL * (int)result + 8) < *(_DWORD *)(a1 + 4LL * a2) )
{
LABEL_9:
if ( v5 != a2 )
{
swap((_DWORD *)(a1 + 4LL * a2), (_DWORD *)(a1 + 4LL * (int)v5));
result = heapify(a1, v5, (unsigned int)a3);
}
return result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2, int a3)
{
__int64 result; // rax
unsigned int v5; // er12

result = (unsigned int)(2 * a2);
v5 = result + 1;
if ( (int)result + 1 < a3 && *(_DWORD *)(a1 + 4LL * (int)result + 4) < *(_DWORD *)(a1 + 4LL * a2) )
{
if ( (int)result + 2 < a3 )
{
result = (int)result;
if ( *(_DWORD *)(a1 + 4LL * (int)result + 8) < *(_DWORD *)(a1 + 4LL * (int)v5) )
v5 = result + 2;
}
goto LABEL_9;
}
v5 = result + 2;
if ( a3 > (int)result + 2 )
{
result = (int)result;
if ( *(_DWORD *)(a1 + 4LL * (int)result + 8) < *(_DWORD *)(a1 + 4LL * a2) )
{
LABEL_9:
if ( v5 != a2 )
{
func7((_DWORD *)(a1 + 4LL * a2), (_DWORD *)(a1 + 4LL * (int)v5));
result = func8(a1, v5, (unsigned int)a3);
}
return result;
}
}
return result;
}

original_code:
void heapify(int arr[], int item, int size) {
  int min = item;
  if (((item) * 2 + 1) < size && arr[((item) * 2 + 1)] < arr[min]) min = ((item) * 2 + 1);
  if (((item) * 2 + 2) < size && arr[((item) * 2 + 2)] < arr[min]) min = ((item) * 2 + 2);
  if (item != min) {
    swap(arr + item, arr + min);
    heapify(arr, min, size);
  }
}

variable_types: item int

variable_types: min int


decompiled_code:
__int64 __fastcall heap_sort(_DWORD *a1, int a2)
{
int v2; // ebp
__int64 result; // rax
int v4; // ebx
_DWORD *v5; // rbp

v2 = a2 / 2;
if ( a2 >= -1 )
{
do
result = heapify((__int64)a1, v2--, a2);
while ( v2 >= 0 );
}
v4 = a2 - 1;
if ( a2 - 1 > 0 )
{
v5 = &a1[v4];
do
{
swap(a1, v5);
result = heapify((__int64)a1, 0, --v4);
--v5;
}
while ( v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(_DWORD *a1, int a2)
{
int v2; // ebp
__int64 result; // rax
int v4; // ebx
_DWORD *v5; // rbp

v2 = a2 / 2;
if ( a2 >= -1 )
{
do
result = func8((__int64)a1, v2--, a2);
while ( v2 >= 0 );
}
v4 = a2 - 1;
if ( a2 - 1 > 0 )
{
v5 = &a1[v4];
do
{
func7(a1, v5);
result = func8((__int64)a1, 0, --v4);
--v5;
}
while ( v4 );
}
return result;
}

original_code:
void heap_sort(int arr[], int size) {
  for (int i = size / 2; i >= 0; i--)
    heapify(arr, i, size);
  for (int i = size - 1; i > 0; i--) {
    swap(arr, arr + i);
    heapify(arr, 0, i - 1);
  }
}

variable_types: i int


original_code:
int selection_sort(int arr[], int size) {
  for (int i = 0; i < size - i; i++) {
    int min_idx = i + 1;
    for (int j = min_idx; j < size; j++)
      if (arr[min_idx] > arr[j]) min_idx = j;
    if (arr[i] > arr[min_idx]) swap(arr + i, arr + min_idx);
  }
}

variable_types: j int


repo: pvachon/libghetto

decompiled_code:
__int16 __fastcall tiff_swap_word(__int16 a1)
{
return __ROL2__(a1, 8);
}

canonical_decompiled_code:
__int16 __fastcall func0(__int16 a1)
{
return __ROL2__(a1, 8);
}

original_code:
static inline uint16_t tiff_swap_word(uint16_t word)
{
    return (uint16_t)((((word) >> 8) & 0xff) | ((word) & 0xff) << 8);
}

canonical_original_code:
static inline unsigned short tiff_swap_word(unsigned short word)
{
    return (unsigned short)((((word) >> 8) & 0xff) | ((word) & 0xff) << 8);
}

variable_types:
word
unsigned short

return_type: unsigned short


decompiled_code:
__int64 __fastcall tiff_swap_dword(unsigned int a1)
{
return (a1 << 8) & 0xFF0000 | (a1 >> 8) & 0xFF00 | (a1 << 24) | HIBYTE(a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
return (a1 << 8) & 0xFF0000 | (a1 >> 8) & 0xFF00 | (a1 << 24) | HIBYTE(a1);
}

original_code:
static inline uint32_t tiff_swap_dword(uint32_t word)
{
    return (uint32_t)(((uint32_t)((word >> 24) & 0xff)) |
           ((uint32_t)((word >> 8) & 0xff00)) |
           ((uint32_t)((word & 0xff) << 24)) |
           ((uint32_t)((word & 0xff00) << 8)));
}

canonical_original_code:
static inline unsigned int tiff_swap_dword(unsigned int word)
{
    return (unsigned int)(((unsigned int)((word >> 24) & 0xff)) |
           ((unsigned int)((word >> 8) & 0xff00)) |
           ((unsigned int)((word & 0xff) << 24)) |
           ((unsigned int)((word & 0xff00) << 8)));
}

variable_types:
word
unsigned int

return_type: unsigned int


decompiled_code:
void __fastcall tiff_swap_dword_buffer(unsigned int *a1, __int64 a2, int a3)
{
unsigned int *v3; // rbx

if ( a3 != 1 && a2 )
{
v3 = a1;
do
{
*v3 = tiff_swap_dword(*v3);
++v3;
}
while ( v3 != &a1[a2] );
}
}

canonical_decompiled_code:
void __fastcall func2(unsigned int *a1, __int64 a2, int a3)
{
unsigned int *v3; // rbx

if ( a3 != 1 && a2 )
{
v3 = a1;
do
{
*v3 = func1(*v3);
++v3;
}
while ( v3 != &a1[a2] );
}
}

original_code:
static void tiff_swap_dword_buffer(void *buf, size_t count, int endianess)
{
    size_t i;
    uint32_t *dwbuf = (uint32_t *)buf;
    if (endianess == 1) return;
    for (i = 0; i < count; i++) {
        dwbuf[i] = tiff_swap_dword(dwbuf[i]);
    }
}

canonical_original_code:
static void tiff_swap_dword_buffer(void *buf, unsigned long count, int endianess)
{
    unsigned long i;
    unsigned int *dwbuf = (uint32_t *)buf;
    if (endianess == 1) return;
    for (i = 0; i < count; i++) {
        dwbuf[i] = tiff_swap_dword(dwbuf[i]);
    }
}

variable_types:
buf
void *

variable_types:
count
unsigned long

variable_types: endianess int

variable_types:
i
unsigned long

variable_types:
dwbuf
unsigned int *


decompiled_code:
void __fastcall tiff_swap_word_buffer(__int16 *a1, __int64 a2, int a3)
{
__int16 *v3; // rbx

if ( a3 != 1 && a2 )
{
v3 = a1;
do
{
*v3 = tiff_swap_word(*v3);
++v3;
}
while ( v3 != &a1[a2] );
}
}

original_code:
static void tiff_swap_word_buffer(void *buf, size_t count, int endianess)
{
    size_t i;
    uint16_t *wbuf = (uint16_t *)buf;
    if (endianess == 1) return;
    for (i = 0; i < count; i++) {
        wbuf[i] = tiff_swap_word(wbuf[i]);
    }
}

canonical_original_code:
static void tiff_swap_word_buffer(void *buf, unsigned long count, int endianess)
{
    unsigned long i;
    unsigned short *wbuf = (uint16_t *)buf;
    if (endianess == 1) return;
    for (i = 0; i < count; i++) {
        wbuf[i] = tiff_swap_word(wbuf[i]);
    }
}

variable_types:
wbuf
unsigned short *


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

result = 0LL;
if ( (unsigned int)(a1 - 1) <= 0xB )
result = tiff_type_sizes[a1];
return result;
}

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

result = 0LL;
if ( (unsigned int)(a1 - 1) <= 0xB )
result = tiff_type_sizes[a1];
return result;
}

original_code:
size_t tiff_get_type_size(int type)
{
    if (type < 1 || type > 12) {
        return 0;
    }
    return tiff_type_sizes[type];
}

canonical_original_code:
unsigned long tiff_get_type_size(int type)
{
    if (type < 1 || type > 12) {
        return 0;
    }
    return tiff_type_sizes[type];
}

variable_types: type int

return_type: unsigned long


canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
return (a1 << 8) & 0xFF0000 | (a1 >> 8) & 0xFF00 | (a1 << 24) | HIBYTE(a1);
}


repo: pwaller/gooda

decompiled_code:
unsigned __int64 __fastcall init_order_def()
{
int j; // ebx
_DWORD *v1; // rax
__int64 v2; // rdx
_DWORD *v3; // rax
_DWORD *v4; // r15
int v5; // ebp
__int64 v6; // rdx
__int64 i; // r14
_DWORD *v8; // rax
int v9; // ebp
int v10; // er12
unsigned __int64 result; // rax
__int64 v12; // rdx
__int64 v13; // rbp
const char *v14; // r13
const char *v15; // r12

column_name[0] = (__int64)cycles;
column_name[1] = (__int64)stalls;
column_name[2] = (__int64)inst;
column_name[3] = (__int64)uops;
num_primary_elements = 4;
num_elements = 4;
if ( num_events > 0 )
{
v1 = (_DWORD *)(event_list + 36LL);
v2 = event_list + 40LL * (unsigned int)(num_events - 1) + 76;
do
{
*v1 = 0;
v1 += 10;
}
while ( (_DWORD *)v2 != v1 );
}
v3 = malloc(0x20uLL);
v4 = v3;
if ( !v3 )
{
fwrite("failed to create event_order_struc\n", 1uLL, 0x23uLL, stderr);
err(1, "failed to malloc event order struc");
}
v5 = v3[2] + 4;
*((_QWORD *)v3 + 1) = (unsigned int)v5;
fixed_index = (__int64)malloc(4LL * v5);
if ( !fixed_index )
{
fwrite("failed to malloc fixed_index array\n", 1uLL, 0x23uLL, stderr);
err(1, "failed to malloc fixed_index");
}
v6 = 0LL;
if ( v5 > 0 )
{
do
*(_DWORD *)(fixed_index + 4 * v6++) = num_events * (num_cores + num_sockets + 1);
while ( v4[2] > (int)v6 );
}
for ( i = 0LL; num_elements > (int)i; ++i )
{
v13 = 0LL;
for ( j = 0; num_events > j; v13 += 40LL )
{
v14 = *(const char **)(event_list + v13);
v15 = (const char *)column_name[i];
if ( !strcasecmp(v15, v14) )
{
fprintf(
stderr,
" column name[%d][%d] = %s, event_list[%d].name = %s ",
0LL,
(unsigned int)i,
v15,
(unsigned int)j,
v14);
fwrite(" found to be matched\n", 1uLL, 0x15uLL, stderr);
*(_DWORD *)(fixed_index + 4 * i) = j + num_events * (num_cores + num_sockets);
*(_DWORD *)(event_list + v13 + 36) = 1;
}
else
{
fputc(10, stderr);
}
++j;
}
}
if ( num_events <= 0 )
{
v9 = 0;
}
else
{
v8 = (_DWORD *)(event_list + 36LL);
v9 = 0;
do
{
v9 += *v8 == 0;
v8 += 10;
}
while ( (_DWORD *)(event_list + 40LL * (unsigned int)(num_events - 1) + 76) != v8 );
}
v4[3] = v9;
v4[4] = 0;
v4[5] = 0;
v10 = v4[2] + v9;
result = (unsigned __int64)malloc(88LL * v10);
*(_QWORD *)v4 = result;
if ( !result )
{
fwrite("failed to malloc order_data array\n", 1uLL, 0x22uLL, stderr);
err(1, "failed to malloc order array");
}
if ( v10 > 0 )
{
v12 = 88LL * j;
LODWORD(result) = 0;
do
{
*(_DWORD *)(*(_QWORD *)v4 + v12 + 48) = 0;
*(_DWORD *)(*(_QWORD *)v4 + v12 + 52) = 0;
result = (unsigned int)(result + 1);
}
while ( v4[2] + v9 > (int)result );
}
global_event_order = v4;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0()
{
int j; // ebx
_DWORD *v1; // rax
__int64 v2; // rdx
_DWORD *v3; // rax
_DWORD *v4; // r15
int v5; // ebp
__int64 v6; // rdx
__int64 i; // r14
_DWORD *v8; // rax
int v9; // ebp
int v10; // er12
unsigned __int64 result; // rax
__int64 v12; // rdx
__int64 v13; // rbp
const char *v14; // r13
const char *v15; // r12

column_name[0] = (__int64)cycles;
column_name[1] = (__int64)stalls;
column_name[2] = (__int64)inst;
column_name[3] = (__int64)uops;
num_primary_elements = 4;
num_elements = 4;
if ( num_events > 0 )
{
v1 = (_DWORD *)(event_list + 36LL);
v2 = event_list + 40LL * (unsigned int)(num_events - 1) + 76;
do
{
*v1 = 0;
v1 += 10;
}
while ( (_DWORD *)v2 != v1 );
}
v3 = malloc(0x20uLL);
v4 = v3;
if ( !v3 )
{
fwrite("failed to create event_order_struc\n", 1uLL, 0x23uLL, stderr);
err(1, "failed to malloc event order struc");
}
v5 = v3[2] + 4;
*((_QWORD *)v3 + 1) = (unsigned int)v5;
fixed_index = (__int64)malloc(4LL * v5);
if ( !fixed_index )
{
fwrite("failed to malloc fixed_index array\n", 1uLL, 0x23uLL, stderr);
err(1, "failed to malloc fixed_index");
}
v6 = 0LL;
if ( v5 > 0 )
{
do
*(_DWORD *)(fixed_index + 4 * v6++) = num_events * (num_cores + num_sockets + 1);
while ( v4[2] > (int)v6 );
}
for ( i = 0LL; num_elements > (int)i; ++i )
{
v13 = 0LL;
for ( j = 0; num_events > j; v13 += 40LL )
{
v14 = *(const char **)(event_list + v13);
v15 = (const char *)column_name[i];
if ( !strcasecmp(v15, v14) )
{
fprintf(
stderr,
" column name[%d][%d] = %s, event_list[%d].name = %s ",
0LL,
(unsigned int)i,
v15,
(unsigned int)j,
v14);
fwrite(" found to be matched\n", 1uLL, 0x15uLL, stderr);
*(_DWORD *)(fixed_index + 4 * i) = j + num_events * (num_cores + num_sockets);
*(_DWORD *)(event_list + v13 + 36) = 1;
}
else
{
fputc(10, stderr);
}
++j;
}
}
if ( num_events <= 0 )
{
v9 = 0;
}
else
{
v8 = (_DWORD *)(event_list + 36LL);
v9 = 0;
do
{
v9 += *v8 == 0;
v8 += 10;
}
while ( (_DWORD *)(event_list + 40LL * (unsigned int)(num_events - 1) + 76) != v8 );
}
v4[3] = v9;
v4[4] = 0;
v4[5] = 0;
v10 = v4[2] + v9;
result = (unsigned __int64)malloc(88LL * v10);
*(_QWORD *)v4 = result;
if ( !result )
{
fwrite("failed to malloc order_data array\n", 1uLL, 0x22uLL, stderr);
err(1, "failed to malloc order array");
}
if ( v10 > 0 )
{
v12 = 88LL * j;
LODWORD(result) = 0;
do
{
*(_DWORD *)(*(_QWORD *)v4 + v12 + 48) = 0;
*(_DWORD *)(*(_QWORD *)v4 + v12 + 52) = 0;
result = (unsigned int)(result + 1);
}
while ( v4[2] + v9 > (int)result );
}
global_event_order = v4;
return result;
}

original_code:
void
init_order_def()
{
 event_order_struc_ptr this_event_order;
 int i,j,k,l,len, found_fixed_events, found_ordered_events;
 column_name[0][0] = cycles;
 column_name[0][1] = stalls;
 column_name[0][2] = inst;
 column_name[0][3] = uops;
 num_primary_elements[0] = 4;
 num_elements[0] = 4;
 for(i=0; i< num_events; i++)event_list[i].fixed = 0;
 this_event_order = (event_order_struc_ptr)malloc(sizeof(event_order_data));
 if(this_event_order == ((void *)0))
  {
  fprintf(stderr,"failed to create event_order_struc\n");
  err(1,"failed to malloc event order struc");
  }
 for(i=0; i< 0 +1; i++)this_event_order->num_fixed += num_elements[i];
 this_event_order->num_ordered = 0;
 fixed_index = (int *)malloc(this_event_order->num_fixed*sizeof(int));
 if(fixed_index == ((void *)0))
  {
  fprintf(stderr,"failed to malloc fixed_index array\n");
  err(1,"failed to malloc fixed_index");
  }
 for(i=0; i < this_event_order->num_fixed; i++)fixed_index[i] = num_events*(num_cores + num_sockets + 1);
 l = 0;
 for(i=0; i<0 +1; i++)
  {
  j = 0;
  while(j < num_elements[i])
   {
   for(k=0; k < num_events; k++)
    {
    if(strcasecmp(column_name[i][j],event_list[k].name) != 0)
     {
     fprintf(stderr,"\n");
     continue;
     }
    fprintf(stderr," column name[%d][%d] = %s, event_list[%d].name = %s ",i,j,column_name[i][j],k,event_list[k].name);
    fprintf(stderr," found to be matched\n");
    fixed_index[l]=num_events*(num_cores + num_sockets) + k;
    event_list[k].fixed = 1;
    }
   j++;
   l++;
   }
  }
 found_ordered_events = 0;
 for(i=0; i< num_events; i++)if(event_list[i].fixed == 0)found_ordered_events++;
 this_event_order->num_ordered = found_ordered_events;
 this_event_order->num_branch = 0;
 this_event_order->num_sub_branch = 0;
 this_event_order->order = (order_data *)malloc((this_event_order->num_fixed + found_ordered_events )*sizeof(order_data));
 if(this_event_order->order == ((void *)0))
  {
  fprintf(stderr,"failed to malloc order_data array\n");
  err(1,"failed to malloc order array");
  }
 for(i=0; i < this_event_order->num_fixed + found_ordered_events; i++)
  {
  this_event_order->order[k].penalty = 0;
  this_event_order->order[k].cycle = 0;
  }
 global_event_order = this_event_order;
}

canonical_original_code:
void init_order_def()
{
 struct event_order_struc *this_event_order;
 int i; int j; int k; int l; int len; int found_fixed_events; int found_ordered_events;
 column_name[0][0] = cycles;
 column_name[0][1] = stalls;
 column_name[0][2] = inst;
 column_name[0][3] = uops;
 num_primary_elements[0] = 4;
 num_elements[0] = 4;
 for(i=0; i< num_events; i++)event_list[i].fixed = 0;
 this_event_order = (struct event_order_struc *)malloc(sizeof(event_order_data));
 if(this_event_order == ((void *)0))
  {
  fprintf(stderr,"failed to create event_order_struc\n");
  err(1,"failed to malloc event order struc");
  }
 for(i=0; i< 0 +1; i++)this_event_order->num_fixed += num_elements[i];
 this_event_order->num_ordered = 0;
 fixed_index = (int *)malloc(this_event_order->num_fixed*sizeof(int));
 if(fixed_index == ((void *)0))
  {
  fprintf(stderr,"failed to malloc fixed_index array\n");
  err(1,"failed to malloc fixed_index");
  }
 for(i=0; i < this_event_order->num_fixed; i++)fixed_index[i] = num_events*(num_cores + num_sockets + 1);
 l = 0;
 for(i=0; i<0 +1; i++)
  {
  j = 0;
  while(j < num_elements[i])
   {
   for(k=0; k < num_events; k++)
    {
    if(strcasecmp(column_name[i][j],event_list[k].name) != 0)
     {
     fprintf(stderr,"\n");
     continue;
     }
    fprintf(stderr," column name[%d][%d] = %s, event_list[%d].name = %s ",i,j,column_name[i][j],k,event_list[k].name);
    fprintf(stderr," found to be matched\n");
    fixed_index[l]=num_events*(num_cores + num_sockets) + k;
    event_list[k].fixed = 1;
    }
   j++;
   l++;
   }
  }
 found_ordered_events = 0;
 for(i=0; i< num_events; i++)if(event_list[i].fixed == 0)found_ordered_events++;
 this_event_order->num_ordered = found_ordered_events;
 this_event_order->num_branch = 0;
 this_event_order->num_sub_branch = 0;
 this_event_order->order = (struct order_struc *)malloc((this_event_order->num_fixed + found_ordered_events )*sizeof(order_data));
 if(this_event_order->order == ((void *)0))
  {
  fprintf(stderr,"failed to malloc order_data array\n");
  err(1,"failed to malloc order array");
  }
 for(i=0; i < this_event_order->num_fixed + found_ordered_events; i++)
  {
  this_event_order->order[k].penalty = 0;
  this_event_order->order[k].cycle = 0;
  }
 global_event_order = this_event_order;
}

variable_types: struct event_order_struc { struct order_struc { char *name; char *ctrl_string; unsigned long config; unsigned long Period; double multiplex; int index; int base_col; int penalty; int cycle; int branch; int sub_branch; int derived; int sum; int sub_branch_sum; int ratio; int num_branch; } *order; int num_fixed; int num_ordered; int num_branch; int num_sub_branch; int num_derived; } *

variable_types: k int

variable_types: l int

variable_types: len int

user_defined_types: struct event_order_struc { struct order_struc *order; int num_fixed; int num_ordered; int num_branch; int num_sub_branch; int num_derived; }


decompiled_code:
void branch_eval_def()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void
branch_eval_def(int* sample_count)
{
 int i,j,k,kk,l,len, branch_order_index, order_index, sub_branch_order_index, num_col,first_event_index;
 event_order_struc_ptr this_event_order;
 order_data * order;
 uint64_t cycle_norm;
 this_event_order = global_event_order;
 order = this_event_order->order;
 first_event_index = num_events*(num_cores + num_sockets);
 branch_order_index = num_events*(num_cores + num_sockets + 1) + 1 ;
 sub_branch_order_index = branch_order_index + 0;
 order_index = 4;
 cycle_norm = order[0].Period*order[0].multiplex;
}

canonical_original_code:
void branch_eval_def(int *sample_count)
{
 int i; int j; int k; int kk; int l; int len; int branch_order_index; int order_index; int sub_branch_order_index; int num_col; int first_event_index;
 struct event_order_struc *this_event_order;
 struct order_struc *order;
 unsigned long cycle_norm;
 this_event_order = global_event_order;
 order = this_event_order->order;
 first_event_index = num_events*(num_cores + num_sockets);
 branch_order_index = num_events*(num_cores + num_sockets + 1) + 1 ;
 sub_branch_order_index = branch_order_index + 0;
 order_index = 4;
 cycle_norm = order[0].Period*order[0].multiplex;
}

variable_types: kk int

variable_types: struct order_struc { char *name; char *ctrl_string; unsigned long config; unsigned long Period; double multiplex; int index; int base_col; int penalty; int cycle; int branch; int sub_branch; int derived; int sum; int sub_branch_sum; int ratio; int num_branch; } *


decompiled_code:
__int64 get_count()
{
return (unsigned int)(num_derived + num_sub_branch + num_branch + num_events * (num_cores + num_sockets + 1) + 1);
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)(num_derived + num_sub_branch + num_branch + num_events * (num_cores + num_sockets + 1) + 1);
}

original_code:
static inline int
get_count(void)
{
 return num_events*(num_cores+num_sockets+1) + num_branch + num_sub_branch + num_derived + 1;
}

canonical_original_code:
static inline int get_count()
{
 return num_events*(num_cores+num_sockets+1) + num_branch + num_sub_branch + num_derived + 1;
}


decompiled_code:
_QWORD *function_struc_create()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
int v2; // eax
void *v3; // rbp

v0 = calloc(1uLL, 0xB8uLL);
v1 = v0;
if ( v0 )
{
*((_DWORD *)v0 + 44) = -1;
v2 = get_count();
v3 = calloc(v2, 4uLL);
v1[16] = v3;
if ( !v3 )
{
free(v1);
v1 = 0LL;
}
}
return v1;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
int v2; // eax
void *v3; // rbp

v0 = calloc(1uLL, 0xB8uLL);
v1 = v0;
if ( v0 )
{
*((_DWORD *)v0 + 44) = -1;
v2 = func0();
v3 = calloc(v2, 4uLL);
v1[16] = v3;
if ( !v3 )
{
free(v1);
v1 = 0LL;
}
}
return v1;
}

original_code:
function_struc_ptr
function_struc_create(void)
{
 function_struc_ptr this_struc;
 this_struc = calloc(1, sizeof(function_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->funclist_index = -1;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
 return this_struc;
}

canonical_original_code:
struct function_struc *function_struc_create()
{
 struct function_struc *this_struc;
 this_struc = calloc(1, sizeof(function_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->funclist_index = -1;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
 return this_struc;
}

variable_types: struct function_struc { struct function_struc *next; struct function_struc *previous; struct func_branch_struc { struct func_branch_struc *next; struct branch_struc { struct branch_struc *next; struct branch_struc *previous; unsigned long address; char *module_name; char *function_name; struct module_struc { struct module_struc *next; struct module_struc *previous; struct rva_hash_struc { int size; int entries; struct hash_struc { struct sample_struc { struct sample_struc *next; struct sample_struc *previous; unsigned long rva; struct process_struc { struct process_struc *next; struct process_struc *previous; struct process_struc *principal_next; struct process_struc *principal_previous; struct process_struc *principal_process; struct process_struc *parent; struct child_struc { struct child_struc *next; struct child_struc *previous; struct process_struc *this_process; struct process_struc *parent; } *first_child; struct thread_struc { struct thread_struc *next; struct thread_struc *previous; int *sample_count; int *sample_order; unsigned int tid; int cycle_count; int inst_count; int total_sample_count; } *first_thread; struct module_struc *first_module; struct pointer_struc { struct sample_struc *ptr; unsigned long val; } *module_list; struct mmap_struc { struct mmap_struc *next; struct mmap_struc *previous; char *filename; unsigned long addr; unsigned long len; unsigned long time; struct module_struc *this_module; struct process_struc *this_process; struct process_struc *principal_process; unsigned int pid; unsigned int tid; unsigned long pgoff; unsigned long tsc_start; unsigned long tsc_end; unsigned long last_pgoff; } *first_mmap; struct comm_struc { struct comm_struc *next; struct comm_struc *previous; struct mmap_struc *first_mmap; char *name; unsigned long time; unsigned int pid; unsigned int tid; } *first_comm; struct module_struc *current_module; char *name; int *sample_count; int *sample_order; int module_count; unsigned int pid; int cycle_count; int inst_count; int total_sample_count; } *this_process; struct thread_struc *this_thread; struct module_struc *this_module; struct function_struc *this_function; struct branch_struc *return_list; struct branch_struc *call_list; char *asm_string; int *sample_count; int *sample_order; float *ratios; int *ratio_order; unsigned long ip; int source_file_line; int compilation_file_line; int total_sample_count; int total_sources; int total_targets; } *this_sample; unsigned long this_rva; struct hash_struc *next; } *this_array; } *this_table; struct sample_struc *first_sample; struct pointer_struc *rva_list; struct function_struc *first_function; struct function_struc *current_function; struct functionlist_struc { struct function_location { struct function_struc *this_function; char *name; char *bind; unsigned long base; unsigned int len; } *list; int size; } *function_list; struct source_struc { struct source_struc *next; struct source_struc *previous; char *source_file; char *source_name; char *path; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; } *first_source; struct source_struc *current_source; char *module_name; char *path; char *local_path; unsigned long starting_ip; unsigned long length; unsigned long time; unsigned long load_tsc; unsigned long unload_tsc; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; int rva_count; int total_branches; int total_sources; int total_targets; int local_calls; int remote_calls; int set_starting_ip; } *this_module; struct function_struc *this_function; int count; } *this_branch_target; struct branch_site_struc { struct branch_site_struc *next; unsigned long address; int count; } *branch_site_stack; } *sources; struct func_branch_struc *targets; struct sample_struc *first_rva; struct asm_struc { struct asm_struc *next; struct asm_struc *previous; unsigned long address; unsigned long target; char *asm_text; char *encoding; char *principal_source_file; char *principal_source_name; char *initial_source_file; char *initial_source_name; int *sample_count; int principal_source_line; int initial_source_line; int branch; int call; int total_sample_count; } *first_asm; struct basic_block_struc { struct basic_block_struc *next; struct basic_block_struc *previous; unsigned long address; unsigned long end_address; unsigned long target1; unsigned long target2; char *text; char *encoding; int *sample_count; int source_line; int block_count; int branch; int call; int total_sample_count; } *first_bb; struct source_line_struc { struct source_line_struc *next; struct source_line_struc *previous; char *source_text; int *sample_count; int line; } *first_source_line; char *function_name; unsigned long function_rva_start; unsigned long function_length; struct source_struc *source_file; struct principal_file_struc { struct principal_file_struc *next; struct principal_file_struc *previous; char *principal_file_name; char *path; char *compile_options; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; } *principal_file; struct file_list_struc { struct file_list_struc *next; struct file_list_struc *previous; char *principal_source_file; char *principal_source_name; int count; } *principal_file_list; struct module_struc *this_module; struct process_struc *this_process; int *sample_count; void *sample_order; int cycle_count; int inst_count; int total_sample_count; int total_branches; int total_targets; int total_sources; int func_sources; int func_targets; int funclist_index; } *

user_defined_types: struct function_struc { struct function_struc *next; struct function_struc *previous; struct func_branch_struc *sources; struct func_branch_struc *targets; struct sample_struc *first_rva; struct asm_struc *first_asm; struct basic_block_struc *first_bb; struct source_line_struc *first_source_line; char *function_name; unsigned long function_rva_start; unsigned long function_length; struct source_struc *source_file; struct principal_file_struc *principal_file; struct file_list_struc *principal_file_list; struct module_struc *this_module; struct process_struc *this_process; int *sample_count; void *sample_order; int cycle_count; int inst_count; int total_sample_count; int total_branches; int total_targets; int total_sources; int func_sources; int func_targets; int funclist_index; }

user_defined_types: struct func_branch_struc { struct func_branch_struc *next; struct branch_struc *this_branch_target; struct branch_site_struc *branch_site_stack; }

user_defined_types: struct branch_struc { struct branch_struc *next; struct branch_struc *previous; unsigned long address; char *module_name; char *function_name; struct module_struc *this_module; struct function_struc *this_function; int count; }

user_defined_types: struct module_struc { struct module_struc *next; struct module_struc *previous; struct rva_hash_struc *this_table; struct sample_struc *first_sample; struct pointer_struc *rva_list; struct function_struc *first_function; struct function_struc *current_function; struct functionlist_struc *function_list; struct source_struc *first_source; struct source_struc *current_source; char *module_name; char *path; char *local_path; unsigned long starting_ip; unsigned long length; unsigned long time; unsigned long load_tsc; unsigned long unload_tsc; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; int rva_count; int total_branches; int total_sources; int total_targets; int local_calls; int remote_calls; int set_starting_ip; }

user_defined_types: struct rva_hash_struc { int size; int entries; struct hash_struc *this_array; }

user_defined_types: struct functionlist_struc { struct function_location *list; int size; }

user_defined_types: struct hash_struc { struct sample_struc *this_sample; unsigned long this_rva; struct hash_struc *next; }

user_defined_types: struct sample_struc { struct sample_struc *next; struct sample_struc *previous; unsigned long rva; struct process_struc *this_process; struct thread_struc *this_thread; struct module_struc *this_module; struct function_struc *this_function; struct branch_struc *return_list; struct branch_struc *call_list; char *asm_string; int *sample_count; int *sample_order; float *ratios; int *ratio_order; unsigned long ip; int source_file_line; int compilation_file_line; int total_sample_count; int total_sources; int total_targets; }

user_defined_types: struct process_struc { struct process_struc *next; struct process_struc *previous; struct process_struc *principal_next; struct process_struc *principal_previous; struct process_struc *principal_process; struct process_struc *parent; struct child_struc *first_child; struct thread_struc *first_thread; struct module_struc *first_module; struct pointer_struc *module_list; struct mmap_struc *first_mmap; struct comm_struc *first_comm; struct module_struc *current_module; char *name; int *sample_count; int *sample_order; int module_count; unsigned int pid; int cycle_count; int inst_count; int total_sample_count; }


decompiled_code:
_QWORD *source_struc_create()
{
_QWORD *v0; // rbx
int v1; // eax
void *v2; // rbp

v0 = calloc(1uLL, 0x48uLL);
if ( v0 )
{
v1 = get_count();
v2 = calloc(v1, 4uLL);
v0[5] = v2;
if ( !v2 )
{
free(v0);
v0 = 0LL;
}
}
return v0;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *v0; // rbx
int v1; // eax
void *v2; // rbp

v0 = calloc(1uLL, 0x48uLL);
if ( v0 )
{
v1 = func0();
v2 = calloc(v1, 4uLL);
v0[5] = v2;
if ( !v2 )
{
free(v0);
v0 = 0LL;
}
}
return v0;
}

original_code:
source_struc_ptr
source_struc_create(void)
{
        source_struc_ptr this_struc;
 this_struc = calloc(1, sizeof(source_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

canonical_original_code:
struct source_struc *source_struc_create()
{
        struct source_struc *this_struc;
 this_struc = calloc(1, sizeof(source_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

variable_types: struct source_struc { struct source_struc *next; struct source_struc *previous; char *source_file; char *source_name; char *path; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; } *


decompiled_code:
_QWORD *principal_file_struc_create()
{
_QWORD *v0; // rbx
int v1; // eax
void *v2; // rbp

v0 = calloc(1uLL, 0x48uLL);
if ( v0 )
{
v1 = get_count();
v2 = calloc(v1, 4uLL);
v0[5] = v2;
if ( !v2 )
{
free(v0);
v0 = 0LL;
}
}
return v0;
}

canonical_decompiled_code:
_QWORD *func3()
{
_QWORD *v0; // rbx
int v1; // eax
void *v2; // rbp

v0 = calloc(1uLL, 0x48uLL);
if ( v0 )
{
v1 = func0();
v2 = calloc(v1, 4uLL);
v0[5] = v2;
if ( !v2 )
{
free(v0);
v0 = 0LL;
}
}
return v0;
}

original_code:
principal_file_struc_ptr
principal_file_struc_create(void)
{
        principal_file_struc_ptr this_struc;
 this_struc = calloc(1, sizeof(principal_file_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

canonical_original_code:
struct principal_file_struc *principal_file_struc_create()
{
        struct principal_file_struc *this_struc;
 this_struc = calloc(1, sizeof(principal_file_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

variable_types: struct principal_file_struc { struct principal_file_struc *next; struct principal_file_struc *previous; char *principal_file_name; char *path; char *compile_options; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; } *


decompiled_code:
_QWORD *module_struc_create()
{
_QWORD *v0; // rbx
int v1; // eax
void *v2; // rbp

v0 = calloc(1uLL, 0xC8uLL);
if ( v0 )
{
v1 = get_count();
v2 = calloc(v1, 4uLL);
v0[18] = v2;
if ( !v2 )
{
free(v0);
v0 = 0LL;
}
}
return v0;
}

canonical_decompiled_code:
_QWORD *func4()
{
_QWORD *v0; // rbx
int v1; // eax
void *v2; // rbp

v0 = calloc(1uLL, 0xC8uLL);
if ( v0 )
{
v1 = func0();
v2 = calloc(v1, 4uLL);
v0[18] = v2;
if ( !v2 )
{
free(v0);
v0 = 0LL;
}
}
return v0;
}

original_code:
module_struc_ptr
module_struc_create(void)
{
        module_struc_ptr this_struc;
 this_struc = calloc(1, sizeof(module_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

canonical_original_code:
struct module_struc *module_struc_create()
{
        struct module_struc *this_struc;
 this_struc = calloc(1, sizeof(module_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

variable_types: struct module_struc { struct module_struc *next; struct module_struc *previous; struct rva_hash_struc { int size; int entries; struct hash_struc { struct sample_struc { struct sample_struc *next; struct sample_struc *previous; unsigned long rva; struct process_struc { struct process_struc *next; struct process_struc *previous; struct process_struc *principal_next; struct process_struc *principal_previous; struct process_struc *principal_process; struct process_struc *parent; struct child_struc { struct child_struc *next; struct child_struc *previous; struct process_struc *this_process; struct process_struc *parent; } *first_child; struct thread_struc { struct thread_struc *next; struct thread_struc *previous; int *sample_count; int *sample_order; unsigned int tid; int cycle_count; int inst_count; int total_sample_count; } *first_thread; struct module_struc *first_module; struct pointer_struc { struct sample_struc *ptr; unsigned long val; } *module_list; struct mmap_struc { struct mmap_struc *next; struct mmap_struc *previous; char *filename; unsigned long addr; unsigned long len; unsigned long time; struct module_struc *this_module; struct process_struc *this_process; struct process_struc *principal_process; unsigned int pid; unsigned int tid; unsigned long pgoff; unsigned long tsc_start; unsigned long tsc_end; unsigned long last_pgoff; } *first_mmap; struct comm_struc { struct comm_struc *next; struct comm_struc *previous; struct mmap_struc *first_mmap; char *name; unsigned long time; unsigned int pid; unsigned int tid; } *first_comm; struct module_struc *current_module; char *name; int *sample_count; int *sample_order; int module_count; unsigned int pid; int cycle_count; int inst_count; int total_sample_count; } *this_process; struct thread_struc *this_thread; struct module_struc *this_module; struct function_struc { struct function_struc *next; struct function_struc *previous; struct func_branch_struc { struct func_branch_struc *next; struct branch_struc { struct branch_struc *next; struct branch_struc *previous; unsigned long address; char *module_name; char *function_name; struct module_struc *this_module; struct function_struc *this_function; int count; } *this_branch_target; struct branch_site_struc { struct branch_site_struc *next; unsigned long address; int count; } *branch_site_stack; } *sources; struct func_branch_struc *targets; struct sample_struc *first_rva; struct asm_struc { struct asm_struc *next; struct asm_struc *previous; unsigned long address; unsigned long target; char *asm_text; char *encoding; char *principal_source_file; char *principal_source_name; char *initial_source_file; char *initial_source_name; int *sample_count; int principal_source_line; int initial_source_line; int branch; int call; int total_sample_count; } *first_asm; struct basic_block_struc { struct basic_block_struc *next; struct basic_block_struc *previous; unsigned long address; unsigned long end_address; unsigned long target1; unsigned long target2; char *text; char *encoding; int *sample_count; int source_line; int block_count; int branch; int call; int total_sample_count; } *first_bb; struct source_line_struc { struct source_line_struc *next; struct source_line_struc *previous; char *source_text; int *sample_count; int line; } *first_source_line; char *function_name; unsigned long function_rva_start; unsigned long function_length; struct source_struc { struct source_struc *next; struct source_struc *previous; char *source_file; char *source_name; char *path; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; } *source_file; struct principal_file_struc { struct principal_file_struc *next; struct principal_file_struc *previous; char *principal_file_name; char *path; char *compile_options; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; } *principal_file; struct file_list_struc { struct file_list_struc *next; struct file_list_struc *previous; char *principal_source_file; char *principal_source_name; int count; } *principal_file_list; struct module_struc *this_module; struct process_struc *this_process; int *sample_count; void *sample_order; int cycle_count; int inst_count; int total_sample_count; int total_branches; int total_targets; int total_sources; int func_sources; int func_targets; int funclist_index; } *this_function; struct branch_struc *return_list; struct branch_struc *call_list; char *asm_string; int *sample_count; int *sample_order; float *ratios; int *ratio_order; unsigned long ip; int source_file_line; int compilation_file_line; int total_sample_count; int total_sources; int total_targets; } *this_sample; unsigned long this_rva; struct hash_struc *next; } *this_array; } *this_table; struct sample_struc *first_sample; struct pointer_struc *rva_list; struct function_struc *first_function; struct function_struc *current_function; struct functionlist_struc { struct function_location { struct function_struc *this_function; char *name; char *bind; unsigned long base; unsigned int len; } *list; int size; } *function_list; struct source_struc *first_source; struct source_struc *current_source; char *module_name; char *path; char *local_path; unsigned long starting_ip; unsigned long length; unsigned long time; unsigned long load_tsc; unsigned long unload_tsc; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; int rva_count; int total_branches; int total_sources; int total_targets; int local_calls; int remote_calls; int set_starting_ip; } *


decompiled_code:
_QWORD *thread_struc_create()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
int v2; // eax
void *v3; // rbp

v0 = calloc(1uLL, 0x30uLL);
v1 = v0;
if ( v0 )
{
*((_DWORD *)v0 + 8) = -1;
v2 = get_count();
v3 = calloc(v2, 4uLL);
v1[2] = v3;
if ( !v3 )
{
free(v1);
v1 = 0LL;
}
}
return v1;
}

canonical_decompiled_code:
_QWORD *func5()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
int v2; // eax
void *v3; // rbp

v0 = calloc(1uLL, 0x30uLL);
v1 = v0;
if ( v0 )
{
*((_DWORD *)v0 + 8) = -1;
v2 = func0();
v3 = calloc(v2, 4uLL);
v1[2] = v3;
if ( !v3 )
{
free(v1);
v1 = 0LL;
}
}
return v1;
}

original_code:
thread_struc_ptr
thread_struc_create(void)
{
        thread_struc_ptr this_struc;
 this_struc = calloc(1, sizeof(thread_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->tid = -1;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

canonical_original_code:
struct thread_struc *thread_struc_create()
{
        struct thread_struc *this_struc;
 this_struc = calloc(1, sizeof(thread_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->tid = -1;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

variable_types: struct thread_struc { struct thread_struc *next; struct thread_struc *previous; int *sample_count; int *sample_order; unsigned int tid; int cycle_count; int inst_count; int total_sample_count; } *


decompiled_code:
_QWORD *process_struc_create()
{
_QWORD *v0; // rbx
int v1; // eax
void *v2; // rbp

v0 = calloc(1uLL, 0x98uLL);
if ( v0 )
{
v1 = get_count();
v2 = calloc(v1, 4uLL);
v0[14] = v2;
if ( !v2 )
{
free(v0);
v0 = 0LL;
}
}
return v0;
}

canonical_decompiled_code:
_QWORD *func6()
{
_QWORD *v0; // rbx
int v1; // eax
void *v2; // rbp

v0 = calloc(1uLL, 0x98uLL);
if ( v0 )
{
v1 = func0();
v2 = calloc(v1, 4uLL);
v0[14] = v2;
if ( !v2 )
{
free(v0);
v0 = 0LL;
}
}
return v0;
}

original_code:
process_struc_ptr
process_struc_create(void)
{
        process_struc_ptr this_struc;
 this_struc = calloc(1, sizeof(process_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

canonical_original_code:
struct process_struc *process_struc_create()
{
        struct process_struc *this_struc;
 this_struc = calloc(1, sizeof(process_data));
 if(this_struc == ((void *)0))return this_struc;
 this_struc->sample_count = calloc(get_count(), sizeof(int));
 if(this_struc->sample_count == ((void *)0))
  {
  free(this_struc);
  return ((void *)0);
  }
        return this_struc;
}

variable_types: struct process_struc { struct process_struc *next; struct process_struc *previous; struct process_struc *principal_next; struct process_struc *principal_previous; struct process_struc *principal_process; struct process_struc *parent; struct child_struc { struct child_struc *next; struct child_struc *previous; struct process_struc *this_process; struct process_struc *parent; } *first_child; struct thread_struc { struct thread_struc *next; struct thread_struc *previous; int *sample_count; int *sample_order; unsigned int tid; int cycle_count; int inst_count; int total_sample_count; } *first_thread; struct module_struc { struct module_struc *next; struct module_struc *previous; struct rva_hash_struc { int size; int entries; struct hash_struc { struct sample_struc { struct sample_struc *next; struct sample_struc *previous; unsigned long rva; struct process_struc *this_process; struct thread_struc *this_thread; struct module_struc *this_module; struct function_struc { struct function_struc *next; struct function_struc *previous; struct func_branch_struc { struct func_branch_struc *next; struct branch_struc { struct branch_struc *next; struct branch_struc *previous; unsigned long address; char *module_name; char *function_name; struct module_struc *this_module; struct function_struc *this_function; int count; } *this_branch_target; struct branch_site_struc { struct branch_site_struc *next; unsigned long address; int count; } *branch_site_stack; } *sources; struct func_branch_struc *targets; struct sample_struc *first_rva; struct asm_struc { struct asm_struc *next; struct asm_struc *previous; unsigned long address; unsigned long target; char *asm_text; char *encoding; char *principal_source_file; char *principal_source_name; char *initial_source_file; char *initial_source_name; int *sample_count; int principal_source_line; int initial_source_line; int branch; int call; int total_sample_count; } *first_asm; struct basic_block_struc { struct basic_block_struc *next; struct basic_block_struc *previous; unsigned long address; unsigned long end_address; unsigned long target1; unsigned long target2; char *text; char *encoding; int *sample_count; int source_line; int block_count; int branch; int call; int total_sample_count; } *first_bb; struct source_line_struc { struct source_line_struc *next; struct source_line_struc *previous; char *source_text; int *sample_count; int line; } *first_source_line; char *function_name; unsigned long function_rva_start; unsigned long function_length; struct source_struc { struct source_struc *next; struct source_struc *previous; char *source_file; char *source_name; char *path; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; } *source_file; struct principal_file_struc { struct principal_file_struc *next; struct principal_file_struc *previous; char *principal_file_name; char *path; char *compile_options; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; } *principal_file; struct file_list_struc { struct file_list_struc *next; struct file_list_struc *previous; char *principal_source_file; char *principal_source_name; int count; } *principal_file_list; struct module_struc *this_module; struct process_struc *this_process; int *sample_count; void *sample_order; int cycle_count; int inst_count; int total_sample_count; int total_branches; int total_targets; int total_sources; int func_sources; int func_targets; int funclist_index; } *this_function; struct branch_struc *return_list; struct branch_struc *call_list; char *asm_string; int *sample_count; int *sample_order; float *ratios; int *ratio_order; unsigned long ip; int source_file_line; int compilation_file_line; int total_sample_count; int total_sources; int total_targets; } *this_sample; unsigned long this_rva; struct hash_struc *next; } *this_array; } *this_table; struct sample_struc *first_sample; struct pointer_struc { struct sample_struc *ptr; unsigned long val; } *rva_list; struct function_struc *first_function; struct function_struc *current_function; struct functionlist_struc { struct function_location { struct function_struc *this_function; char *name; char *bind; unsigned long base; unsigned int len; } *list; int size; } *function_list; struct source_struc *first_source; struct source_struc *current_source; char *module_name; char *path; char *local_path; unsigned long starting_ip; unsigned long length; unsigned long time; unsigned long load_tsc; unsigned long unload_tsc; int *sample_count; int *sample_order; int cycle_count; int inst_count; int total_sample_count; int rva_count; int total_branches; int total_sources; int total_targets; int local_calls; int remote_calls; int set_starting_ip; } *first_module; struct pointer_struc *module_list; struct mmap_struc { struct mmap_struc *next; struct mmap_struc *previous; char *filename; unsigned long addr; unsigned long len; unsigned long time; struct module_struc *this_module; struct process_struc *this_process; struct process_struc *principal_process; unsigned int pid; unsigned int tid; unsigned long pgoff; unsigned long tsc_start; unsigned long tsc_end; unsigned long last_pgoff; } *first_mmap; struct comm_struc { struct comm_struc *next; struct comm_struc *previous; struct mmap_struc *first_mmap; char *name; unsigned long time; unsigned int pid; unsigned int tid; } *first_comm; struct module_struc *current_module; char *name; int *sample_count; int *sample_order; int module_count; unsigned int pid; int cycle_count; int inst_count; int total_sample_count; } *