decompiled_code:
__int64 __fastcall parse_command_line(int a1, const char **a2, _DWORD *a3, __int64 a4)
{
unsigned int v7; // er13
int v8; // ebx
bool v9; // al
bool v10; // cf
bool v11; // zf
const char *v12; // rdi
const char *v13; // rsi
char v14; // al
bool v15; // cf
bool v16; // zf
const char *v17; // rdi
const char *v18; // rsi
bool v19; // cf
bool v20; // zf
int v21; // eax
const char *v22; // r8
__int64 v23; // rdx
__int64 v24; // rdx
const char **v25; // rbp
const char *v26; // rbx
__int64 v27; // rcx
const char *v28; // rdi
const char *v29; // rsi
char v30; // al
bool v31; // cf
bool v32; // zf
const char *v33; // rax
const char *v34; // rdi
const char *v35; // rsi
__int64 v36; // rdx
__int64 v37; // rcx
char v38; // al
const char *v40; // rdx
unsigned int v41; // [rsp+Ch] [rbp-5Ch]
const char *v42; // [rsp+10h] [rbp-58h]
char *s1; // [rsp+18h] [rbp-50h]
char *s1a; // [rsp+18h] [rbp-50h]
int v45[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v45[0] = -1;
if ( a1 <= 1 )
{
a3[45] = 2;
v7 = -1;
v8 = 1;
v42 = 0LL;
v41 = 0;
goto LABEL_53;
}
v7 = -1;
v8 = 1;
v42 = 0LL;
v41 = 0;
while ( 1 )
{
while ( 1 )
{
v22 = a2[v8];
v23 = v8;
if ( !strcmp(v22, "-kl") )
{
if ( !(unsigned int)get_arg_int(a2, v8, a1, (__int64)v45, "block length") )
return 0;
goto LABEL_19;
}
v9 = strcmp(a2[v8], "-bkl") != 0;
v10 = 0;
v11 = !v9;
if ( v9 )
break;
if ( !(unsigned int)get_arg_int(a2, v8, a1, (__int64)v45, "block & key length") )
return 0;
v7 = v45[0];
LABEL_19:
v8 += 2;
if ( a1 <= v8 )
goto LABEL_20;
}
v12 = "-nocbc";
a4 = 7LL;
v13 = a2[v8];
do
{
if ( !a4 )
break;
v10 = *v13 < (unsigned int)*v12;
v11 = *v13++ == *v12++;
--a4;
}
while ( v11 );
v14 = (!v10 && !v11) - v10;
v15 = 0;
v16 = v14 == 0;
if ( !v14 )
goto LABEL_33;
v17 = "-ecb";
a4 = 5LL;
v18 = a2[v8];
do
{
if ( !a4 )
break;
v15 = *v18 < (unsigned int)*v17;
v16 = *v18++ == *v17++;
--a4;
}
while ( v16 );
if ( (!v15 && !v16) == v15 )
{
LABEL_33:
a3[40] = 0;
goto LABEL_16;
}
v19 = *v22 < 0x2Du;
v20 = *v22 == 45;
if ( *v22 != 45 )
break;
v19 = v22[1] < 0x63u;
v20 = v22[1] == 99;
if ( v22[1] != 99 )
break;
v19 = 0;
v20 = v22[2] == 0;
if ( v22[2] )
break;
++v8;
s1 = (char *)&a2[v23 + 1];
v21 = block_cipher_select(*(_QWORD *)s1, a3, a3 + 2);
a4 = (__int64)s1;
if ( !v21 )
{
fprintf(stderr, "Couldn't find cipher \"%s\".\n", *(const char **)s1);
return 0;
}
LABEL_16:
if ( a1 <= ++v8 )
goto LABEL_20;
}
v28 = "-iv";
a4 = 4LL;
v29 = a2[v8];
do
{
if ( !a4 )
break;
v19 = *v29 < (unsigned int)*v28;
v20 = *v29++ == *v28++;
--a4;
}
while ( v20 );
v30 = (!v19 && !v20) - v19;
v31 = 0;
v32 = v30 == 0;
if ( !v30 )
{
v33 = a2[v23 + 1];
++v8;
a3[20] = 1;
v42 = v33;
goto LABEL_16;
}
v34 = "-app";
a4 = 5LL;
v35 = a2[v8];
do
{
if ( !a4 )
break;
v31 = *v35 < (unsigned int)*v34;
v32 = *v35++ == *v34++;
--a4;
}
while ( v32 );
if ( (!v31 && !v32) == v31 )
{
++a3[46];
goto LABEL_16;
}
s1a = (char *)a2[v8];
if ( !strcmp(s1a, "-alg") )
{
++a3[41];
goto LABEL_16;
}
if ( !strcmp(s1a, "-list") )
{
block_cipher_list(s1a, "-list", v36, v37, s1a);
exit(0);
}
if ( !strcmp(s1a, "-nospin") )
{
a3[48] = 0;
goto LABEL_16;
}
if ( !strcmp(s1a, "-crc") )
{
a3[47] = 1;
goto LABEL_16;
}
if ( !strcmp(s1a, "-nocrc") )
{
a3[47] = 0;
goto LABEL_16;
}
if ( !strcmp(s1a, "-dump") )
{
v41 = 1;
goto LABEL_16;
}
if ( !strcmp(s1a, "--help") )
return 0;
LABEL_20:
v24 = (unsigned int)v45[0];
a3[45] = v8 + 1;
if ( (_DWORD)v24 == -1 )
LABEL_53:
v24 = *(unsigned int *)(*(_QWORD *)a3 + 8LL);
a3[2] = v24;
if ( v7 == -1 )
v7 = *(_DWORD *)(*(_QWORD *)a3 + 12LL);
a3[3] = v7;
if ( v7 - 1 > 0x3F )
{
fprintf(stderr, "%s: Key length %d out of range for application.\n", *a2, v7);
return 0;
}
if ( (unsigned int)(v24 - 1) > 0x3F )
{
fprintf(stderr, "%s: Block length %d out of range for application.\n", *a2, (unsigned int)v24);
return 0;
}
if ( a3[20] && !(unsigned int)bc_read_block_from_file(v42, a3 + 4, v24, a4) )
LABEL_64:
exit(1);
if ( v41 )
{
fprintf(stderr, "Cipher: %s\n", **(const char ***)a3);
fprintf(stderr, "Block length: %d\n", (unsigned int)a3[2]);
fprintf(stderr, "Key length: %d\n", (unsigned int)a3[3]);
v40 = "yes";
if ( !a3[40] )
v40 = "no";
fprintf(stderr, "CBC: %s\n", v40);
exit(0);
}
if ( a1 <= v8 )
{
fprintf(stderr, "%s: Missing verb (check, +key or -key).\n", *a2);
return v41;
}
v25 = &a2[v8];
v26 = *v25;
if ( !strcmp(*v25, "check") )
{
a3[44] = 3;
}
else
{
*((_QWORD *)a3 + 21) = v26 + 1;
v38 = **v25;
if ( v38 == 43 )
{
a3[44] = 1;
}
else
{
if ( v38 != 45 )
return 0;
a3[44] = 2;
}
if ( v26[1] == 64 )
{
if ( !(unsigned int)bc_read_block_from_file(v26 + 2, a3 + 21, (unsigned int)a3[3], v27) )
goto LABEL_64;
a3[37] = 1;
}
}
if ( a3[46] || (v41 = 1, a3[41]) )
{
a3[48] = 0;
v41 = 1;
}
return v41;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, const char **a2, _DWORD *a3, __int64 a4)
{
unsigned int v7; // er13
int v8; // ebx
bool v9; // al
bool v10; // cf
bool v11; // zf
const char *v12; // rdi
const char *v13; // rsi
char v14; // al
bool v15; // cf
bool v16; // zf
const char *v17; // rdi
const char *v18; // rsi
bool v19; // cf
bool v20; // zf
int v21; // eax
const char *v22; // r8
__int64 v23; // rdx
__int64 v24; // rdx
const char **v25; // rbp
const char *v26; // rbx
__int64 v27; // rcx
const char *v28; // rdi
const char *v29; // rsi
char v30; // al
bool v31; // cf
bool v32; // zf
const char *v33; // rax
const char *v34; // rdi
const char *v35; // rsi
__int64 v36; // rdx
__int64 v37; // rcx
char v38; // al
const char *v40; // rdx
unsigned int v41; // [rsp+Ch] [rbp-5Ch]
const char *v42; // [rsp+10h] [rbp-58h]
char *s1; // [rsp+18h] [rbp-50h]
char *s1a; // [rsp+18h] [rbp-50h]
int v45[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

v45[0] = -1;
if ( a1 <= 1 )
{
a3[45] = 2;
v7 = -1;
v8 = 1;
v42 = 0LL;
v41 = 0;
goto LABEL_53;
}
v7 = -1;
v8 = 1;
v42 = 0LL;
v41 = 0;
while ( 1 )
{
while ( 1 )
{
v22 = a2[v8];
v23 = v8;
if ( !strcmp(v22, "-kl") )
{
if ( !(unsigned int)func1(a2, v8, a1, (__int64)v45, "block length") )
return 0;
goto LABEL_19;
}
v9 = strcmp(a2[v8], "-bkl") != 0;
v10 = 0;
v11 = !v9;
if ( v9 )
break;
if ( !(unsigned int)func1(a2, v8, a1, (__int64)v45, "block & key length") )
return 0;
v7 = v45[0];
LABEL_19:
v8 += 2;
if ( a1 <= v8 )
goto LABEL_20;
}
v12 = "-nocbc";
a4 = 7LL;
v13 = a2[v8];
do
{
if ( !a4 )
break;
v10 = *v13 < (unsigned int)*v12;
v11 = *v13++ == *v12++;
--a4;
}
while ( v11 );
v14 = (!v10 && !v11) - v10;
v15 = 0;
v16 = v14 == 0;
if ( !v14 )
goto LABEL_33;
v17 = "-ecb";
a4 = 5LL;
v18 = a2[v8];
do
{
if ( !a4 )
break;
v15 = *v18 < (unsigned int)*v17;
v16 = *v18++ == *v17++;
--a4;
}
while ( v16 );
if ( (!v15 && !v16) == v15 )
{
LABEL_33:
a3[40] = 0;
goto LABEL_16;
}
v19 = *v22 < 0x2Du;
v20 = *v22 == 45;
if ( *v22 != 45 )
break;
v19 = v22[1] < 0x63u;
v20 = v22[1] == 99;
if ( v22[1] != 99 )
break;
v19 = 0;
v20 = v22[2] == 0;
if ( v22[2] )
break;
++v8;
s1 = (char *)&a2[v23 + 1];
v21 = block_cipher_select(*(_QWORD *)s1, a3, a3 + 2);
a4 = (__int64)s1;
if ( !v21 )
{
fprintf(stderr, "Couldn't find cipher \"%s\".\n", *(const char **)s1);
return 0;
}
LABEL_16:
if ( a1 <= ++v8 )
goto LABEL_20;
}
v28 = "-iv";
a4 = 4LL;
v29 = a2[v8];
do
{
if ( !a4 )
break;
v19 = *v29 < (unsigned int)*v28;
v20 = *v29++ == *v28++;
--a4;
}
while ( v20 );
v30 = (!v19 && !v20) - v19;
v31 = 0;
v32 = v30 == 0;
if ( !v30 )
{
v33 = a2[v23 + 1];
++v8;
a3[20] = 1;
v42 = v33;
goto LABEL_16;
}
v34 = "-app";
a4 = 5LL;
v35 = a2[v8];
do
{
if ( !a4 )
break;
v31 = *v35 < (unsigned int)*v34;
v32 = *v35++ == *v34++;
--a4;
}
while ( v32 );
if ( (!v31 && !v32) == v31 )
{
++a3[46];
goto LABEL_16;
}
s1a = (char *)a2[v8];
if ( !strcmp(s1a, "-alg") )
{
++a3[41];
goto LABEL_16;
}
if ( !strcmp(s1a, "-list") )
{
block_cipher_list(s1a, "-list", v36, v37, s1a);
exit(0);
}
if ( !strcmp(s1a, "-nospin") )
{
a3[48] = 0;
goto LABEL_16;
}
if ( !strcmp(s1a, "-crc") )
{
a3[47] = 1;
goto LABEL_16;
}
if ( !strcmp(s1a, "-nocrc") )
{
a3[47] = 0;
goto LABEL_16;
}
if ( !strcmp(s1a, "-dump") )
{
v41 = 1;
goto LABEL_16;
}
if ( !strcmp(s1a, "--help") )
return 0;
LABEL_20:
v24 = (unsigned int)v45[0];
a3[45] = v8 + 1;
if ( (_DWORD)v24 == -1 )
LABEL_53:
v24 = *(unsigned int *)(*(_QWORD *)a3 + 8LL);
a3[2] = v24;
if ( v7 == -1 )
v7 = *(_DWORD *)(*(_QWORD *)a3 + 12LL);
a3[3] = v7;
if ( v7 - 1 > 0x3F )
{
fprintf(stderr, "%s: Key length %d out of range for application.\n", *a2, v7);
return 0;
}
if ( (unsigned int)(v24 - 1) > 0x3F )
{
fprintf(stderr, "%s: Block length %d out of range for application.\n", *a2, (unsigned int)v24);
return 0;
}
if ( a3[20] && !(unsigned int)bc_read_block_from_file(v42, a3 + 4, v24, a4) )
LABEL_64:
exit(1);
if ( v41 )
{
fprintf(stderr, "Cipher: %s\n", **(const char ***)a3);
fprintf(stderr, "Block length: %d\n", (unsigned int)a3[2]);
fprintf(stderr, "Key length: %d\n", (unsigned int)a3[3]);
v40 = "yes";
if ( !a3[40] )
v40 = "no";
fprintf(stderr, "CBC: %s\n", v40);
exit(0);
}
if ( a1 <= v8 )
{
fprintf(stderr, "%s: Missing verb (check, +key or -key).\n", *a2);
return v41;
}
v25 = &a2[v8];
v26 = *v25;
if ( !strcmp(*v25, "check") )
{
a3[44] = 3;
}
else
{
*((_QWORD *)a3 + 21) = v26 + 1;
v38 = **v25;
if ( v38 == 43 )
{
a3[44] = 1;
}
else
{
if ( v38 != 45 )
return 0;
a3[44] = 2;
}
if ( v26[1] == 64 )
{
if ( !(unsigned int)bc_read_block_from_file(v26 + 2, a3 + 21, (unsigned int)a3[3], v27) )
goto LABEL_64;
a3[37] = 1;
}
}
if ( a3[46] || (v41 = 1, a3[41]) )
{
a3[48] = 0;
v41 = 1;
}
return v41;
}

original_code:
static int parse_command_line(
 int argc,
 char ** argv,
 opts_t * popts)
{
 int argi;
 int bl = -1;
 int kl = -1;
 int dump = 0;
 char * IV_file_name = 0;
 for (argi = 1; argi < argc; argi++) {
  if (strcmp(argv[argi], "-kl") == 0) {
   if (!get_arg_int(argv, argi, argc, &bl,
     "block length"))
    return 0;
   argi++;
  }
  else if (strcmp(argv[argi], "-kl") == 0) {
   if (!get_arg_int(argv, argi, argc, &kl,
     "key length"))
    return 0;
   argi++;
  }
  else if (strcmp(argv[argi], "-bkl") == 0) {
   if (!get_arg_int(argv, argi, argc, &bl,
     "block & key length"))
    return 0;
   kl = bl;
   argi++;
  }
  else if (strcmp(argv[argi], "-nocbc") == 0) {
   popts->ciphinst.do_cbc = 0;
  }
  else if (strcmp(argv[argi], "-ecb") == 0) {
   popts->ciphinst.do_cbc = 0;
  }
  else if (strcmp(argv[argi], "-c") == 0) {
   argi++;
   if (!block_cipher_select(argv[argi],
    &popts->pcipher, &popts->ciphinst))
   {
    fprintf(stderr,
     "Couldn't find cipher \"%s\".\n",
     argv[argi]);
    return 0;
   }
  }
  else if (strcmp(argv[argi], "-iv") == 0) {
   popts->ciphinst.have_user_IV = 1;
   argi++;
   IV_file_name = argv[argi];
  }
  else if (strcmp(argv[argi], "-app") == 0) {
   popts->app_debug++;
  }
  else if (strcmp(argv[argi], "-alg") == 0) {
   popts->ciphinst.alg_debug++;
  }
  else if (strcmp(argv[argi], "-list") == 0) {
   block_cipher_list();
   exit(0);
  }
  else if (strcmp(argv[argi], "-nospin") == 0) {
   popts->do_spin = 0;
  }
  else if (strcmp(argv[argi], "-crc") == 0) {
   popts->do_crc = 1;
  }
  else if (strcmp(argv[argi], "-nocrc") == 0) {
   popts->do_crc = 0;
  }
  else if (strcmp(argv[argi], "-dump") == 0) {
   dump = 1;
  }
  else if (strcmp(argv[argi], "--help") == 0) {
   return 0;
  }
  else {
   break;
  }
 }
 popts->first_file_argi = argi + 1;
 if (bl == -1)
  popts->ciphinst.bl =
   popts->pcipher->default_bl;
 else
  popts->ciphinst.bl = bl;
 if (kl == -1)
  popts->ciphinst.kl =
   popts->pcipher->default_kl;
 else
  popts->ciphinst.kl = kl;
 if ((popts->ciphinst.kl < 1) || (popts->ciphinst.kl > 64)) {
  fprintf(stderr,
   "%s:  Key length %d out of range for application.\n",
   argv[0], popts->ciphinst.kl);
  return 0;
 }
 if ((popts->ciphinst.bl < 1) || (popts->ciphinst.bl > 64)) {
  fprintf(stderr,
   "%s:  Block length %d out of range for application.\n",
   argv[0], popts->ciphinst.bl);
  return 0;
 }
 if ((popts->ciphinst.kl < 1) || (popts->ciphinst.kl > 64)) {
  fprintf(stderr,
   "%s:  Key length %d out of range for application.\n",
   argv[0], popts->ciphinst.kl);
  return 0;
 }
 if ((popts->ciphinst.bl < 1) || (popts->ciphinst.bl > 64)) {
  fprintf(stderr,
   "%s:  Block length %d out of range for application.\n",
   argv[0], popts->ciphinst.bl);
  return 0;
 }
 if (popts->ciphinst.have_user_IV) {
  if (!bc_read_block_from_file(IV_file_name,
  popts->ciphinst.user_IV,
  popts->ciphinst.bl))
  {
   exit(1);
  }
 }
 if (dump) {
  fprintf(stderr, "Cipher:       %s\n",
   popts->pcipher->cipher_name);
  fprintf(stderr, "Block length: %d\n",
   popts->ciphinst.bl);
  fprintf(stderr, "Key   length: %d\n",
   popts->ciphinst.kl);
  fprintf(stderr, "CBC:          %s\n",
   popts->ciphinst.do_cbc ? "yes" : "no");
  exit(0);
 }
 if (argi >= argc) {
  fprintf(stderr,
   "%s:  Missing verb (check, +key or -key).\n",
   argv[0]);
  return 0;
 }
 if (strcmp(argv[argi], "check") == 0) {
  popts->operation = 3;
 }
 else {
  popts->key_text = &argv[argi][1];
  if (argv[argi][0] == '+')
   popts->operation = 1;
  else if (argv[argi][0] == '-')
   popts->operation = 2;
  else
   return 0;
  if (popts->key_text[0] == '@') {
   if (!bc_read_block_from_file(&popts->key_text[1],
   popts->ciphinst.user_key_mat,
   popts->ciphinst.kl))
    exit(1);
   popts->ciphinst.have_user_key_mat = 1;
  }
 }
 if (popts->app_debug || popts->ciphinst.alg_debug)
  popts->do_spin = 0;
 return 1;
}

canonical_original_code:
static int parse_command_line(int argc, char **argv, struct _opts_t *popts)
{
 int argi;
 int bl = -1;
 int kl = -1;
 int dump = 0;
 char *IV_file_name = 0;
 for (argi = 1; argi < argc; argi++) {
  if (strcmp(argv[argi], "-kl") == 0) {
   if (!get_arg_int(argv, argi, argc, &bl,
     "block length"))
    return 0;
   argi++;
  }
  else if (strcmp(argv[argi], "-kl") == 0) {
   if (!get_arg_int(argv, argi, argc, &kl,
     "key length"))
    return 0;
   argi++;
  }
  else if (strcmp(argv[argi], "-bkl") == 0) {
   if (!get_arg_int(argv, argi, argc, &bl,
     "block & key length"))
    return 0;
   kl = bl;
   argi++;
  }
  else if (strcmp(argv[argi], "-nocbc") == 0) {
   popts->ciphinst.do_cbc = 0;
  }
  else if (strcmp(argv[argi], "-ecb") == 0) {
   popts->ciphinst.do_cbc = 0;
  }
  else if (strcmp(argv[argi], "-c") == 0) {
   argi++;
   if (!block_cipher_select(argv[argi],
    &popts->pcipher, &popts->ciphinst))
   {
    fprintf(stderr,
     "Couldn't find cipher \"%s\".\n",
     argv[argi]);
    return 0;
   }
  }
  else if (strcmp(argv[argi], "-iv") == 0) {
   popts->ciphinst.have_user_IV = 1;
   argi++;
   IV_file_name = argv[argi];
  }
  else if (strcmp(argv[argi], "-app") == 0) {
   popts->app_debug++;
  }
  else if (strcmp(argv[argi], "-alg") == 0) {
   popts->ciphinst.alg_debug++;
  }
  else if (strcmp(argv[argi], "-list") == 0) {
   block_cipher_list();
   exit(0);
  }
  else if (strcmp(argv[argi], "-nospin") == 0) {
   popts->do_spin = 0;
  }
  else if (strcmp(argv[argi], "-crc") == 0) {
   popts->do_crc = 1;
  }
  else if (strcmp(argv[argi], "-nocrc") == 0) {
   popts->do_crc = 0;
  }
  else if (strcmp(argv[argi], "-dump") == 0) {
   dump = 1;
  }
  else if (strcmp(argv[argi], "--help") == 0) {
   return 0;
  }
  else {
   break;
  }
 }
 popts->first_file_argi = argi + 1;
 if (bl == -1)
  popts->ciphinst.bl =
   popts->pcipher->default_bl;
 else
  popts->ciphinst.bl = bl;
 if (kl == -1)
  popts->ciphinst.kl =
   popts->pcipher->default_kl;
 else
  popts->ciphinst.kl = kl;
 if ((popts->ciphinst.kl < 1) || (popts->ciphinst.kl > 64)) {
  fprintf(stderr,
   "%s:  Key length %d out of range for application.\n",
   argv[0], popts->ciphinst.kl);
  return 0;
 }
 if ((popts->ciphinst.bl < 1) || (popts->ciphinst.bl > 64)) {
  fprintf(stderr,
   "%s:  Block length %d out of range for application.\n",
   argv[0], popts->ciphinst.bl);
  return 0;
 }
 if ((popts->ciphinst.kl < 1) || (popts->ciphinst.kl > 64)) {
  fprintf(stderr,
   "%s:  Key length %d out of range for application.\n",
   argv[0], popts->ciphinst.kl);
  return 0;
 }
 if ((popts->ciphinst.bl < 1) || (popts->ciphinst.bl > 64)) {
  fprintf(stderr,
   "%s:  Block length %d out of range for application.\n",
   argv[0], popts->ciphinst.bl);
  return 0;
 }
 if (popts->ciphinst.have_user_IV) {
  if (!bc_read_block_from_file(IV_file_name,
  popts->ciphinst.user_IV,
  popts->ciphinst.bl))
  {
   exit(1);
  }
 }
 if (dump) {
  fprintf(stderr, "Cipher:       %s\n",
   popts->pcipher->cipher_name);
  fprintf(stderr, "Block length: %d\n",
   popts->ciphinst.bl);
  fprintf(stderr, "Key   length: %d\n",
   popts->ciphinst.kl);
  fprintf(stderr, "CBC:          %s\n",
   popts->ciphinst.do_cbc ? "yes" : "no");
  exit(0);
 }
 if (argi >= argc) {
  fprintf(stderr,
   "%s:  Missing verb (check, +key or -key).\n",
   argv[0]);
  return 0;
 }
 if (strcmp(argv[argi], "check") == 0) {
  popts->operation = 3;
 }
 else {
  popts->key_text = &argv[argi][1];
  if (argv[argi][0] == '+')
   popts->operation = 1;
  else if (argv[argi][0] == '-')
   popts->operation = 2;
  else
   return 0;
  if (popts->key_text[0] == '@') {
   if (!bc_read_block_from_file(&popts->key_text[1],
   popts->ciphinst.user_key_mat,
   popts->ciphinst.kl))
    exit(1);
   popts->ciphinst.have_user_key_mat = 1;
  }
 }
 if (popts->app_debug || popts->ciphinst.alg_debug)
  popts->do_spin = 0;
 return 1;
}

variable_types: bl int

variable_types: kl int

variable_types: dump int


usage

repo: johnkerl/ctools

decompiled_code:
void __fastcall __noreturn usage(const char *a1)
{
fprintf(stderr, " Usage: %s [options] {verb} {file name(s) ... }\n", a1);
fwrite(" Options:\n", 1uLL, 0xBuLL, stderr);
fwrite(" -kl {n}: Key length in bytes.\n", 1uLL, 0x25uLL, stderr);
fwrite(" -bl {n}: Block length in bytes.\n", 1uLL, 0x25uLL, stderr);
fwrite(" Verb:\n", 1uLL, 8uLL, stderr);
fwrite(" +{key text} for encrypt\n", 1uLL, 0x1CuLL, stderr);
fwrite(" -{key text} for decrypt\n", 1uLL, 0x1CuLL, stderr);
fwrite(" check to see if file was encrypted with this program\n", 1uLL, 0x3FuLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(const char *a1)
{
fprintf(stderr, " Usage: %s [options] {verb} {file name(s) ... }\n", a1);
fwrite(" Options:\n", 1uLL, 0xBuLL, stderr);
fwrite(" -kl {n}: Key length in bytes.\n", 1uLL, 0x25uLL, stderr);
fwrite(" -bl {n}: Block length in bytes.\n", 1uLL, 0x25uLL, stderr);
fwrite(" Verb:\n", 1uLL, 8uLL, stderr);
fwrite(" +{key text} for encrypt\n", 1uLL, 0x1CuLL, stderr);
fwrite(" -{key text} for decrypt\n", 1uLL, 0x1CuLL, stderr);
fwrite(" check to see if file was encrypted with this program\n", 1uLL, 0x3FuLL, stderr);
exit(1);
}

original_code:
static void usage(char *argv0)
{
 fprintf(stderr,
  "  Usage: %s [options] {verb} {file name(s) ... }\n",
  argv0);
 fprintf(stderr, "  Options:\n");
 fprintf(stderr, "    -kl {n}:  Key   length in bytes.\n");
 fprintf(stderr, "    -bl {n}:  Block length in bytes.\n");
 fprintf(stderr, "  Verb:\n");
 fprintf(stderr, "    +{key text} for encrypt\n");
 fprintf(stderr, "    -{key text} for decrypt\n");
 fprintf(stderr,
 "    check       to see if file was encrypted with this program\n");
 exit(1);
}

return_type: void


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rcx
int v4; // eax
int v5; // er12
const char **v6; // rbx
const char **v7; // rbp
unsigned int v9; // eax
const char *v10; // rax
bool v11; // zf
__int64 v12; // [rsp+0h] [rbp-F8h] BYREF
char v13[160]; // [rsp+8h] [rbp-F0h] BYREF
__int64 v14; // [rsp+A8h] [rbp-50h]
int v15; // [rsp+B0h] [rbp-48h]
int v16; // [rsp+B4h] [rbp-44h]

set_defaults((__int64)&v12);
if ( !(unsigned int)parse_command_line(argc, argv, &v12, v3) )
usage(*argv);
if ( (unsigned int)(v15 - 1) <= 1 )
{
v9 = (*(__int64 (__fastcall **)(__int64, char *))(v12 + 32))(v14, v13);
if ( v9 != 1 )
{
v10 = (const char *)(*(__int64 (__fastcall **)(_QWORD))(v12 + 64))(v9);
fprintf(stderr, "%s: %s while scheduling key.\n", *(const char **)v12, v10);
exit(1);
}
}
v4 = v16;
v5 = 0;
if ( v16 == argc )
{
v11 = (unsigned int)bc_handle_fp_pair(stdin, stdout, "stdin", "stdout", &v12) == 0;
v4 = v16;
v5 = v11;
}
if ( argc > v4 )
{
v6 = &argv[v4];
v7 = &(&argv[v4])[(unsigned __int64)(unsigned int)(argc - 1 - v4) + 1];
do
v5 += bc_handle_file_name(*v6++, &v12) == 0;
while ( v6 != v7 );
}
(*(void (__fastcall **)(__int64, char *))(v12 + 40))(v14, v13);
return v5;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rcx
int v4; // eax
int v5; // er12
const char **v6; // rbx
const char **v7; // rbp
unsigned int v9; // eax
const char *v10; // rax
bool v11; // zf
__int64 v12; // [rsp+0h] [rbp-F8h] BYREF
char v13[160]; // [rsp+8h] [rbp-F0h] BYREF
__int64 v14; // [rsp+A8h] [rbp-50h]
int v15; // [rsp+B0h] [rbp-48h]
int v16; // [rsp+B4h] [rbp-44h]

func0((__int64)&v12);
if ( !(unsigned int)func2(argc, argv, &v12, v3) )
func3(*argv);
if ( (unsigned int)(v15 - 1) <= 1 )
{
v9 = (*(__int64 (__fastcall **)(__int64, char *))(v12 + 32))(v14, v13);
if ( v9 != 1 )
{
v10 = (const char *)(*(__int64 (__fastcall **)(_QWORD))(v12 + 64))(v9);
fprintf(stderr, "%s: %s while scheduling key.\n", *(const char **)v12, v10);
exit(1);
}
}
v4 = v16;
v5 = 0;
if ( v16 == argc )
{
v11 = (unsigned int)bc_handle_fp_pair(stdin, stdout, "stdin", "stdout", &v12) == 0;
v4 = v16;
v5 = v11;
}
if ( argc > v4 )
{
v6 = &argv[v4];
v7 = &(&argv[v4])[(unsigned __int64)(unsigned int)(argc - 1 - v4) + 1];
do
v5 += bc_handle_file_name(*v6++, &v12) == 0;
while ( v6 != v7 );
}
(*(void (__fastcall **)(__int64, char *))(v12 + 40))(v14, v13);
return v5;
}

original_code:
int main(int argc, char **argv)
{
 opts_t opts;
 int argi;
 int rv = 0;
 int make_key_rc;
 set_defaults(&opts);
 if (!parse_command_line(argc, argv, &opts))
  usage(argv[0]);
 if (opts.operation == 1 || opts.operation == 2) {
  make_key_rc = opts.pcipher->pkey_maker(opts.key_text,
  &opts.ciphinst);
  if (make_key_rc != 1) {
   fprintf(stderr, "%s:  %s while scheduling key.\n",
    opts.pcipher->cipher_name,
    opts.pcipher->perror_explainer(make_key_rc));
   exit(1);
  }
 }
 if (opts.first_file_argi == argc) {
  if (!bc_handle_fp_pair(stdin, stdout, "stdin", "stdout", &opts))
   rv++;
 }
 for (argi = opts.first_file_argi; argi < argc; argi++) {
  if (!bc_handle_file_name(argv[argi], &opts))
   rv++;
 }
 opts.pcipher->pkey_freer(opts.key_text, &opts.ciphinst);
 return rv;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct _opts_t opts;
 int argi;
 int rv = 0;
 int make_key_rc;
 set_defaults(&opts);
 if (!parse_command_line(argc, argv, &opts))
  usage(argv[0]);
 if (opts.operation == 1 || opts.operation == 2) {
  make_key_rc = opts.pcipher->pkey_maker(opts.key_text,
  &opts.ciphinst);
  if (make_key_rc != 1) {
   fprintf(stderr, "%s:  %s while scheduling key.\n",
    opts.pcipher->cipher_name,
    opts.pcipher->perror_explainer(make_key_rc));
   exit(1);
  }
 }
 if (opts.first_file_argi == argc) {
  if (!bc_handle_fp_pair(stdin, stdout, "stdin", "stdout", &opts))
   rv++;
 }
 for (argi = opts.first_file_argi; argi < argc; argi++) {
  if (!bc_handle_file_name(argv[argi], &opts))
   rv++;
 }
 opts.pcipher->pkey_freer(opts.key_text, &opts.ciphinst);
 return rv;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct _opts_t { struct _block_cipher_t { char *cipher_name; int default_bl; int default_kl; int (*pencryptor)(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t { int bl; int kl; char user_IV[64]; int have_user_IV; char user_key_mat[64]; int have_user_key_mat; void *pkey_schedule; int do_cbc; int alg_debug; } *pciphinst); int (*pdecryptor)(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst); int (*pkey_maker)(char *key_material, struct _block_cipher_instance_t *pciphinst); void (*pkey_freer)(char *key_material, struct _block_cipher_instance_t *pciphinst); int (*pbl_checker)(int bl); int (*pkl_checker)(int kl); char *(*perror_explainer)(int error_code); } *pcipher; struct _block_cipher_instance_t ciphinst; char *key_text; int operation; int first_file_argi; int app_debug; int do_crc; int do_spin; }

variable_types: argi int

variable_types: rv int

return_type: int

user_defined_types: struct _opts_t { struct _block_cipher_t *pcipher; struct _block_cipher_instance_t ciphinst; char *key_text; int operation; int first_file_argi; int app_debug; int do_crc; int do_spin; }

user_defined_types: struct _block_cipher_t { char *cipher_name; int default_bl; int default_kl; int (*pencryptor)(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst); int (*pdecryptor)(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst); int (*pkey_maker)(char *key_material, struct _block_cipher_instance_t *pciphinst); void (*pkey_freer)(char *key_material, struct _block_cipher_instance_t *pciphinst); int (*pbl_checker)(int bl); int (*pkl_checker)(int kl); char *(*perror_explainer)(int error_code); }


decompiled_code:
__int64 __fastcall block_cipher_select(char *s1, const char ***a2)
{
__int64 v2; // r12
__int64 v3; // rbx
unsigned int v4; // er15
const char **v5; // rbp

v2 = num_block_ciphers;
if ( num_block_ciphers <= 0 )
return 0;
v3 = 0LL;
v4 = 0;
do
{
v5 = (const char **)*(&pblock_ciphers + v3);
if ( !strcasecmp(s1, *v5) )
{
*a2 = v5;
v4 = 1;
}
++v3;
}
while ( v3 != v2 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1, const char ***a2)
{
__int64 v2; // r12
__int64 v3; // rbx
unsigned int v4; // er15
const char **v5; // rbp

v2 = num_block_ciphers;
if ( num_block_ciphers <= 0 )
return 0;
v3 = 0LL;
v4 = 0;
do
{
v5 = (const char **)*(&pblock_ciphers + v3);
if ( !strcasecmp(s1, *v5) )
{
*a2 = v5;
v4 = 1;
}
++v3;
}
while ( v3 != v2 );
return v4;
}

original_code:
int block_cipher_select(
 char * cipher_name,
 block_cipher_t ** ppcipher,
 block_cipher_instance_t * pciphinst)
{
 int i;
 int got = 0;
 for (i = 0; i < num_block_ciphers; i++) {
  if (strcasecmp(
   cipher_name, pblock_ciphers[i]->cipher_name) == 0)
  {
   *ppcipher = pblock_ciphers[i];
   got = 1;
  }
 }
 return got;
}

canonical_original_code:
int block_cipher_select(char *cipher_name, struct _block_cipher_t **ppcipher, struct _block_cipher_instance_t *pciphinst)
{
 int i;
 int got = 0;
 for (i = 0; i < num_block_ciphers; i++) {
  if (strcasecmp(
   cipher_name, pblock_ciphers[i]->cipher_name) == 0)
  {
   *ppcipher = pblock_ciphers[i];
   got = 1;
  }
 }
 return got;
}

variable_types: struct _block_cipher_t { char *cipher_name; int default_bl; int default_kl; int (*pencryptor)(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t { int bl; int kl; char user_IV[64]; int have_user_IV; char user_key_mat[64]; int have_user_key_mat; void *pkey_schedule; int do_cbc; int alg_debug; } *pciphinst); int (*pdecryptor)(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst); int (*pkey_maker)(char *key_material, struct _block_cipher_instance_t *pciphinst); void (*pkey_freer)(char *key_material, struct _block_cipher_instance_t *pciphinst); int (*pbl_checker)(int bl); int (*pkl_checker)(int kl); char *(*perror_explainer)(int error_code); } **

variable_types:
pciphinst
struct _block_cipher_instance_t *

variable_types: i int

variable_types: got int


decompiled_code:
int block_cipher_list()
{
__int64 v0; // rbx
const char **v1; // rax

fwrite("Available ciphers:\n", 1uLL, 0x13uLL, stderr);
if ( num_block_ciphers > 0 )
{
v0 = 0LL;
do
{
v1 = (const char **)*(&pblock_ciphers + v0++);
fprintf(stderr, " %s\n", *v1);
}
while ( num_block_ciphers > (int)v0 );
}
return fputc(10, stderr);
}

canonical_decompiled_code:
int func2()
{
__int64 v0; // rbx
const char **v1; // rax

fwrite("Available ciphers:\n", 1uLL, 0x13uLL, stderr);
if ( num_block_ciphers > 0 )
{
v0 = 0LL;
do
{
v1 = (const char **)*(&pblock_ciphers + v0++);
fprintf(stderr, " %s\n", *v1);
}
while ( num_block_ciphers > (int)v0 );
}
return fputc(10, stderr);
}

original_code:
void block_cipher_list(void)
{
 int i;
 fprintf(stderr, "Available ciphers:\n");
 for (i = 0; i < num_block_ciphers; i++) {
  fprintf(stderr, "  %s\n", pblock_ciphers[i]->cipher_name);
 }
 fprintf(stderr, "\n");
}

canonical_original_code:
void block_cipher_list()
{
 int i;
 fprintf(stderr, "Available ciphers:\n");
 for (i = 0; i < num_block_ciphers; i++) {
  fprintf(stderr, "  %s\n", pblock_ciphers[i]->cipher_name);
 }
 fprintf(stderr, "\n");
}


original_code:
static void block_to_stream(
 int block_length_in_bits,
 word8 block[4][(256/32)],
 BYTE * output)
{
 int j;
 int n = block_length_in_bits >> 5;
 int j2;
 for (j = 0; j < n; j++) {
  j2 = j << 2;
  output[j2 ] = (BYTE) block[0][j];
  output[j2+1] = (BYTE) block[1][j];
  output[j2+2] = (BYTE) block[2][j];
  output[j2+3] = (BYTE) block[3][j];
 }
}

canonical_original_code:
static void block_to_stream(int block_length_in_bits, unsigned char block[4][-1], unsigned char *output)
{
 int j;
 int n = block_length_in_bits >> 5;
 int j2;
 for (j = 0; j < n; j++) {
  j2 = j << 2;
  output[j2 ] = (unsigned char) block[0][j];
  output[j2+1] = (unsigned char) block[1][j];
  output[j2+2] = (unsigned char) block[2][j];
  output[j2+3] = (unsigned char) block[3][j];
 }
}

variable_types:
block
unsigned char [4][-1]

variable_types:
output
unsigned char *

variable_types: j int

variable_types: n int


original_code:
int AES_encrypt(
 int mode,
 int block_length_in_bits,
 key_instance * key,
 BYTE * IV,
 BYTE * input,
 int input_length_in_bits,
 BYTE * output)
{
 int i, num_blocks;
 word8 block[4][(256/32)];
 int progress_interval;
 int bl5 = block_length_in_bits >> 5;
 int bl3 = block_length_in_bits >> 3;
 if (key == ((void *)0))
  return -2;
 if (!valid_key_length(key->key_length_in_bits))
  return -2;
 if (mode != 1 && mode != 2)
  return -4;
 if (!valid_block_length(block_length_in_bits))
  return -5;
 num_blocks = input_length_in_bits/block_length_in_bits;
 switch (mode) {
 case 1:
  for (i = 0; i < num_blocks; i++) {
   stream_to_block(block_length_in_bits, input, block, 0);
   AES_encrypt_block(block, key->key_length_in_bits,
    block_length_in_bits, key->key_sched);
   block_to_stream(block_length_in_bits, block, output);
   input += bl3;
   output += bl3;
  }
  break;
 case 2:
  stream_to_block(block_length_in_bits, IV, block, 0);
  if (num_blocks < 10)
   progress_interval = 1;
  else if (num_blocks > 1000)
   progress_interval = num_blocks / 20;
  else
   progress_interval = num_blocks / 10;
  fprintf(stderr, "\n");
  for (i = 0; i < num_blocks; i++) {
   if (((i % progress_interval) == 0) || (i+1 == num_blocks)) {
    fprintf(stderr, "\r    %3d%%",
     (100 * (i+1)) / num_blocks);
    fflush(stdout);
   }
   stream_to_block(block_length_in_bits, input, block, 1);
   AES_encrypt_block(block, key->key_length_in_bits,
    block_length_in_bits, key->key_sched);
   block_to_stream(block_length_in_bits, block, output);
   input += bl3;
   output += bl3;
  }
  fprintf(stderr, "\n");
  break;
 default:
  return -4;
 }
 return num_blocks * block_length_in_bits;
}

canonical_original_code:
int AES_encrypt(int mode, int block_length_in_bits, struct _key_instance *key, unsigned char *IV, unsigned char *input, int input_length_in_bits, unsigned char *output)
{
 int i; int num_blocks;
 unsigned char block[4][-1];
 int progress_interval;
 int bl5 = block_length_in_bits >> 5;
 int bl3 = block_length_in_bits >> 3;
 if (key == ((void *)0))
  return -2;
 if (!valid_key_length(key->key_length_in_bits))
  return -2;
 if (mode != 1 && mode != 2)
  return -4;
 if (!valid_block_length(block_length_in_bits))
  return -5;
 num_blocks = input_length_in_bits/block_length_in_bits;
 switch (mode) {
 case 1:
  for (i = 0; i < num_blocks; i++) {
   stream_to_block(block_length_in_bits, input, block, 0);
   AES_encrypt_block(block, key->key_length_in_bits,
    block_length_in_bits, key->key_sched);
   block_to_stream(block_length_in_bits, block, output);
   input += bl3;
   output += bl3;
  }
  break;
 case 2:
  stream_to_block(block_length_in_bits, IV, block, 0);
  if (num_blocks < 10)
   progress_interval = 1;
  else if (num_blocks > 1000)
   progress_interval = num_blocks / 20;
  else
   progress_interval = num_blocks / 10;
  fprintf(stderr, "\n");
  for (i = 0; i < num_blocks; i++) {
   if (((i % progress_interval) == 0) || (i+1 == num_blocks)) {
    fprintf(stderr, "\r    %3d%%",
     (100 * (i+1)) / num_blocks);
    fflush(stdout);
   }
   stream_to_block(block_length_in_bits, input, block, 1);
   AES_encrypt_block(block, key->key_length_in_bits,
    block_length_in_bits, key->key_sched);
   block_to_stream(block_length_in_bits, block, output);
   input += bl3;
   output += bl3;
  }
  fprintf(stderr, "\n");
  break;
 default:
  return -4;
 }
 return num_blocks * block_length_in_bits;
}

variable_types: mode int

variable_types: struct _key_instance { int key_length_in_bits; unsigned char key_sched[-1][4][-1]; } *

variable_types:
IV
unsigned char *

variable_types:
input
unsigned char *


original_code:
int AES_decrypt(
 int mode,
 int block_length_in_bits,
 key_instance * key,
 BYTE * IV,
 BYTE * input,
 int input_length_in_bits,
 BYTE * output)
{
 int i, j, num_blocks;
 word8 block[4][(256/32)];
 int progress_interval;
 int bl5 = block_length_in_bits >> 5;
 int bl3 = block_length_in_bits >> 3;
 if (key == ((void *)0))
  return -2;
 if (!valid_key_length(key->key_length_in_bits))
  return -2;
 if (mode != 1 && mode != 2)
  return -4;
 if (!valid_block_length(block_length_in_bits))
  return -5;
 num_blocks = input_length_in_bits/block_length_in_bits;
 switch (mode) {
 case 1:
  for (i = 0; i < num_blocks; i++) {
   stream_to_block(block_length_in_bits, input, block, 0);
   AES_decrypt_block(block, key->key_length_in_bits,
    block_length_in_bits, key->key_sched);
   block_to_stream(block_length_in_bits, block, output);
   input += bl3;
   output += bl3;
  }
  break;
 case 2:
  if (num_blocks < 10)
   progress_interval = 1;
  else if (num_blocks > 1000)
   progress_interval = num_blocks / 20;
  else
   progress_interval = num_blocks / 10;
  stream_to_block(block_length_in_bits, input, block, 0);
  AES_decrypt_block(block, key->key_length_in_bits,
   block_length_in_bits, key->key_sched);
  input += bl3;
  for (j = 0; j < bl5; j++) {
   int idx = j << 2;
   output[idx ] = (BYTE) (block[0][j] ^ IV[ idx]);
   output[idx+1] = (BYTE) (block[1][j] ^ IV[1+idx]);
   output[idx+2] = (BYTE) (block[2][j] ^ IV[2+idx]);
   output[idx+3] = (BYTE) (block[3][j] ^ IV[3+idx]);
  }
  output += bl3;
  fprintf(stderr, "\n");
  for (i = 1; i < num_blocks; i++) {
   if (((i % progress_interval) == 0) || (i+1 == num_blocks)) {
    fprintf(stderr, "\r    %3d%%", (100 * (i+1)) / num_blocks);
    fflush(stdout);
   }
   stream_to_block(block_length_in_bits, input, block, 0);
   AES_decrypt_block(block, key->key_length_in_bits,
    block_length_in_bits, key->key_sched);
   for (j = 0; j < bl5; j++) {
    int idxo = j << 2;
    int idxi = idxo - bl3;
    output[idxo+0] = (BYTE) (block[0][j] ^ input[idxi+0]);
    output[idxo+1] = (BYTE) (block[1][j] ^ input[idxi+1]);
    output[idxo+2] = (BYTE) (block[2][j] ^ input[idxi+2]);
    output[idxo+3] = (BYTE) (block[3][j] ^ input[idxi+3]);
   }
   input += bl3;
   output += bl3;
  }
  fprintf(stderr, "\n");
  break;
 default: return -4;
 }
 return num_blocks * block_length_in_bits;
}

canonical_original_code:
int AES_decrypt(int mode, int block_length_in_bits, struct _key_instance *key, unsigned char *IV, unsigned char *input, int input_length_in_bits, unsigned char *output)
{
 int i; int j; int num_blocks;
 unsigned char block[4][-1];
 int progress_interval;
 int bl5 = block_length_in_bits >> 5;
 int bl3 = block_length_in_bits >> 3;
 if (key == ((void *)0))
  return -2;
 if (!valid_key_length(key->key_length_in_bits))
  return -2;
 if (mode != 1 && mode != 2)
  return -4;
 if (!valid_block_length(block_length_in_bits))
  return -5;
 num_blocks = input_length_in_bits/block_length_in_bits;
 switch (mode) {
 case 1:
  for (i = 0; i < num_blocks; i++) {
   stream_to_block(block_length_in_bits, input, block, 0);
   AES_decrypt_block(block, key->key_length_in_bits,
    block_length_in_bits, key->key_sched);
   block_to_stream(block_length_in_bits, block, output);
   input += bl3;
   output += bl3;
  }
  break;
 case 2:
  if (num_blocks < 10)
   progress_interval = 1;
  else if (num_blocks > 1000)
   progress_interval = num_blocks / 20;
  else
   progress_interval = num_blocks / 10;
  stream_to_block(block_length_in_bits, input, block, 0);
  AES_decrypt_block(block, key->key_length_in_bits,
   block_length_in_bits, key->key_sched);
  input += bl3;
  for (j = 0; j < bl5; j++) {
   int idx = j << 2;
   output[idx ] = (BYTE) (block[0][j] ^ IV[ idx]);
   output[idx+1] = (BYTE) (block[1][j] ^ IV[1+idx]);
   output[idx+2] = (BYTE) (block[2][j] ^ IV[2+idx]);
   output[idx+3] = (BYTE) (block[3][j] ^ IV[3+idx]);
  }
  output += bl3;
  fprintf(stderr, "\n");
  for (i = 1; i < num_blocks; i++) {
   if (((i % progress_interval) == 0) || (i+1 == num_blocks)) {
    fprintf(stderr, "\r    %3d%%", (100 * (i+1)) / num_blocks);
    fflush(stdout);
   }
   stream_to_block(block_length_in_bits, input, block, 0);
   AES_decrypt_block(block, key->key_length_in_bits,
    block_length_in_bits, key->key_sched);
   for (j = 0; j < bl5; j++) {
    int idxo = j << 2;
    int idxi = idxo - bl3;
    output[idxo+0] = (BYTE) (block[0][j] ^ input[idxi+0]);
    output[idxo+1] = (BYTE) (block[1][j] ^ input[idxi+1]);
    output[idxo+2] = (BYTE) (block[2][j] ^ input[idxi+2]);
    output[idxo+3] = (BYTE) (block[3][j] ^ input[idxi+3]);
   }
   input += bl3;
   output += bl3;
  }
  fprintf(stderr, "\n");
  break;
 default: return -4;
 }
 return num_blocks * block_length_in_bits;
}

variable_types: idx int

variable_types: idxo int

variable_types: idxi int

user_defined_types: struct _key_instance { int key_length_in_bits; unsigned char key_sched[-1][4][-1]; }


decompiled_code:
__int64 __fastcall valid_key_length(int a1)
{
return (a1 == 256) | (unsigned __int8)((a1 & 0xFFFFFFBF) == 128);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
return (a1 == 256) | (unsigned __int8)((a1 & 0xFFFFFFBF) == 128);
}

original_code:
static int valid_key_length(
 int key_length_in_bits)
{
 if (key_length_in_bits == 128)
  return 1;
 else if (key_length_in_bits == 192)
  return 1;
 else if (key_length_in_bits == 256)
  return 1;
 else
  return 0;
}

canonical_original_code:
static int valid_key_length(int key_length_in_bits)
{
 if (key_length_in_bits == 128)
  return 1;
 else if (key_length_in_bits == 192)
  return 1;
 else if (key_length_in_bits == 256)
  return 1;
 else
  return 0;
}


original_code:
int AES_make_key(
 key_instance * key,
 int key_length_in_bits,
 int block_length_in_bits,
 char * key_material)
{
 word8 k[4][(256/32)];
 int i, j;
 if (key == ((void *)0))
  return -3;
 if (valid_key_length(key_length_in_bits))
  key->key_length_in_bits = key_length_in_bits;
 else
  return -2;
 if (key_material == ((void *)0))
  return -2;
 for (i = 0; i < key->key_length_in_bits >> 3; i++)
  k[i & 3][i >> 2] = (word8) key_material[i];
 AES_key_schedule(k, key->key_length_in_bits,
  block_length_in_bits, key->key_sched);
 return 1;
}

canonical_original_code:
int AES_make_key(struct _key_instance *key, int key_length_in_bits, int block_length_in_bits, char *key_material)
{
 unsigned char k[4][-1];
 int i; int j;
 if (key == ((void *)0))
  return -3;
 if (valid_key_length(key_length_in_bits))
  key->key_length_in_bits = key_length_in_bits;
 else
  return -2;
 if (key_material == ((void *)0))
  return -2;
 for (i = 0; i < key->key_length_in_bits >> 3; i++)
  k[i & 3][i >> 2] = (unsigned char) key_material[i];
 AES_key_schedule(k, key->key_length_in_bits,
  block_length_in_bits, key->key_sched);
 return 1;
}

variable_types:
k
unsigned char [4][-1]


decompiled_code:
void *__fastcall my_malloc(unsigned int a1)
{
void *result; // rax

result = malloc((int)a1);
if ( !result )
{
fprintf(stderr, "malloc(%d) failed.\n", a1);
exit(1);
}
return result;
}

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

result = malloc((int)a1);
if ( !result )
{
fprintf(stderr, "malloc(%d) failed.\n", a1);
exit(1);
}
return result;
}

original_code:
void * my_malloc(
 int num_bytes)
{
 void * rv;
 rv = malloc(num_bytes);
 if (rv == 0) {
  fprintf(stderr, "malloc(%d) failed.\n", num_bytes);
  exit(1);
 }
 return rv;
}

canonical_original_code:
void *my_malloc(int num_bytes)
{
 void *rv;
 rv = malloc(num_bytes);
 if (rv == 0) {
  fprintf(stderr, "malloc(%d) failed.\n", num_bytes);
  exit(1);
 }
 return rv;
}

variable_types:
rv
void *

return_type: void *


decompiled_code:
__int64 __fastcall round_up(int a1, int a2)
{
return (unsigned int)(a2 * ((a2 + a1 - 1) / a2));
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2)
{
return (unsigned int)(a2 * ((a2 + a1 - 1) / a2));
}

original_code:
int round_up(
 int x,
 int n)
{
 return ((x + n - 1) / n) * n;
}

canonical_original_code:
int round_up(int x, int n)
{
 return ((x + n - 1) / n) * n;
}

variable_types: x int


decompiled_code:
__int64 __fastcall get_ethernet_CRC(char *a1, int a2)
{
unsigned int v2; // eax
char *v3; // rcx
char v4; // dl

if ( !a2 )
return 0LL;
v2 = -1;
v3 = &a1[a2];
do
{
v4 = *a1++;
v2 = crctable[2 * (unsigned __int8)(v2 ^ v4)] ^ (v2 >> 8);
}
while ( a1 != v3 );
return ~v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, int a2)
{
unsigned int v2; // eax
char *v3; // rcx
char v4; // dl

if ( !a2 )
return 0LL;
v2 = -1;
v3 = &a1[a2];
do
{
v4 = *a1++;
v2 = crctable[2 * (unsigned __int8)(v2 ^ v4)] ^ (v2 >> 8);
}
while ( a1 != v3 );
return ~v2;
}

original_code:
unsigned get_ethernet_CRC(
 void * pfile_contents,
 int file_size)
{
 unsigned char * p;
 int len;
 unsigned crc;
 p = (unsigned char *)pfile_contents;
 len = file_size;
 crc = 0xffffffff;
 while (len--)
  crc = crctable[(crc ^ *p++) & 0xff] ^ (crc >> 8);
 return crc ^ 0xffffffff;
}

canonical_original_code:
unsigned int get_ethernet_CRC(void *pfile_contents, int file_size)
{
 unsigned char *p;
 int len;
 unsigned int crc;
 p = (unsigned char *)pfile_contents;
 len = file_size;
 crc = 0xffffffff;
 while (len--)
  crc = crctable[(crc ^ *p++) & 0xff] ^ (crc >> 8);
 return crc ^ 0xffffffff;
}

variable_types:
p
unsigned char *

variable_types: len int

variable_types:
crc
unsigned int

return_type: unsigned int


decompiled_code:
void __fastcall accum_CRCA(char *a1, unsigned int a2, unsigned int *a3, int a4)
{
unsigned int v4; // eax
char *v5; // rcx
char v6; // r8
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
unsigned int v13; // eax
char *v14; // rsi
char v15; // di

switch ( a4 )
{
case 1:
v4 = *a3;
if ( a2 <= 7 )
{
v5 = a1;
}
else
{
v5 = &a1[8 * ((a2 - 8) >> 3) + 8];
do
{
v6 = *a1;
a1 += 8;
v7 = CRCA_table[(unsigned __int8)(v4 ^ v6)] ^ (v4 >> 8);
v8 = CRCA_table[(unsigned __int8)(v7 ^ *(a1 - 7))] ^ (v7 >> 8);
v9 = CRCA_table[(unsigned __int8)(v8 ^ *(a1 - 6))] ^ (v8 >> 8);
v10 = CRCA_table[(unsigned __int8)(v9 ^ *(a1 - 5))] ^ (v9 >> 8);
v11 = CRCA_table[(unsigned __int8)(v10 ^ *(a1 - 4))] ^ (v10 >> 8);
v12 = CRCA_table[(unsigned __int8)(v11 ^ *(a1 - 3))] ^ (v11 >> 8);
v13 = CRCA_table[(unsigned __int8)(v12 ^ *(a1 - 2))] ^ (v12 >> 8);
v4 = CRCA_table[(unsigned __int8)(v13 ^ *(a1 - 1))] ^ (v13 >> 8);
}
while ( a1 != v5 );
a2 &= 7u;
}
if ( a2 )
{
v14 = &v5[a2];
do
{
v15 = *v5++;
v4 = CRCA_table[(unsigned __int8)(v4 ^ v15)] ^ (v4 >> 8);
}
while ( v5 != v14 );
}
*a3 = v4;
break;
case 2:
*a3 = ~*a3;
break;
case 0:
*a3 = -1;
break;
}
}

canonical_decompiled_code:
void __fastcall func0(char *a1, unsigned int a2, unsigned int *a3, int a4)
{
unsigned int v4; // eax
char *v5; // rcx
char v6; // r8
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
unsigned int v13; // eax
char *v14; // rsi
char v15; // di

switch ( a4 )
{
case 1:
v4 = *a3;
if ( a2 <= 7 )
{
v5 = a1;
}
else
{
v5 = &a1[8 * ((a2 - 8) >> 3) + 8];
do
{
v6 = *a1;
a1 += 8;
v7 = CRCA_table[(unsigned __int8)(v4 ^ v6)] ^ (v4 >> 8);
v8 = CRCA_table[(unsigned __int8)(v7 ^ *(a1 - 7))] ^ (v7 >> 8);
v9 = CRCA_table[(unsigned __int8)(v8 ^ *(a1 - 6))] ^ (v8 >> 8);
v10 = CRCA_table[(unsigned __int8)(v9 ^ *(a1 - 5))] ^ (v9 >> 8);
v11 = CRCA_table[(unsigned __int8)(v10 ^ *(a1 - 4))] ^ (v10 >> 8);
v12 = CRCA_table[(unsigned __int8)(v11 ^ *(a1 - 3))] ^ (v11 >> 8);
v13 = CRCA_table[(unsigned __int8)(v12 ^ *(a1 - 2))] ^ (v12 >> 8);
v4 = CRCA_table[(unsigned __int8)(v13 ^ *(a1 - 1))] ^ (v13 >> 8);
}
while ( a1 != v5 );
a2 &= 7u;
}
if ( a2 )
{
v14 = &v5[a2];
do
{
v15 = *v5++;
v4 = CRCA_table[(unsigned __int8)(v4 ^ v15)] ^ (v4 >> 8);
}
while ( v5 != v14 );
}
*a3 = v4;
break;
case 2:
*a3 = ~*a3;
break;
case 0:
*a3 = -1;
break;
}
}

original_code:
void accum_CRCA(
 int8u * buf,
 int32u len,
 int32u * pcsum,
 int32u op)
{
 int32u csum;
 switch (op) {
 case 0:
  *pcsum = 0xffffffff;
  break;
 case 1:
  csum = *pcsum;
  while (len >= 8) {
   csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;;; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;;;;
   len -= 8;
  }
  if (len) {
   do {
    csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;
   } while (--len);
  }
  while (len--)
   csum = CRCA_table[(csum ^ *buf++) & 0xff] ^ (csum >> 8);
  *pcsum = csum;
  break;
 case 2:
  *pcsum ^= 0xffffffff;
  break;
 }
}

canonical_original_code:
void accum_CRCA(unsigned char *buf, unsigned int len, unsigned int *pcsum, unsigned int op)
{
 unsigned int csum;
 switch (op) {
 case 0:
  *pcsum = 0xffffffff;
  break;
 case 1:
  csum = *pcsum;
  while (len >= 8) {
   csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;;; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);; csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;;;;
   len -= 8;
  }
  if (len) {
   do {
    csum = CRCA_table[((int)csum ^ (*buf++)) & 0xff] ^ (csum >> 8);;
   } while (--len);
  }
  while (len--)
   csum = CRCA_table[(csum ^ *buf++) & 0xff] ^ (csum >> 8);
  *pcsum = csum;
  break;
 case 2:
  *pcsum ^= 0xffffffff;
  break;
 }
}

variable_types:
buf
unsigned char *

variable_types:
len
unsigned int

variable_types:
pcsum
unsigned int *

variable_types:
op
unsigned int

variable_types:
csum
unsigned int


decompiled_code:
__int64 __fastcall ulong_from_binary_string(char *a1, __int64 *a2)
{
char v2; // al
__int64 v3; // rdx

v2 = *a1;
v3 = 0LL;
if ( !*a1 )
{
LABEL_9:
*a2 = v3;
return 1LL;
}
while ( 1 )
{
while ( 1 )
{
if ( v2 == 95 )
goto LABEL_5;
if ( v2 != 49 )
break;
v2 = *++a1;
v3 = 2 * v3 + 1;
if ( !v2 )
goto LABEL_9;
}
if ( v2 != 48 )
return 0LL;
v3 *= 2LL;
LABEL_5:
v2 = *++a1;
if ( !v2 )
goto LABEL_9;
}
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1, __int64 *a2)
{
char v2; // al
__int64 v3; // rdx

v2 = *a1;
v3 = 0LL;
if ( !*a1 )
{
LABEL_9:
*a2 = v3;
return 1LL;
}
while ( 1 )
{
while ( 1 )
{
if ( v2 == 95 )
goto LABEL_5;
if ( v2 != 49 )
break;
v2 = *++a1;
v3 = 2 * v3 + 1;
if ( !v2 )
goto LABEL_9;
}
if ( v2 != 48 )
return 0LL;
v3 *= 2LL;
LABEL_5:
v2 = *++a1;
if ( !v2 )
goto LABEL_9;
}
}

original_code:
int ulong_from_binary_string(
 char input[],
 unsigned long * poutput)
{
 unsigned long u = 0;
 char * p;
 for (p = input; *p; p++) {
  if (*p == '_')
   continue;
  else if (*p == '1') {
   u <<= 1;
   u++;
  }
  else if (*p == '0') {
   u <<= 1;
  }
  else {
   return 0;
  }
 }
 *poutput = u;
 return 1;
}

canonical_original_code:
int ulong_from_binary_string(char input[], unsigned long *poutput)
{
 unsigned long u = 0;
 char *p;
 for (p = input; *p; p++) {
  if (*p == '_')
   continue;
  else if (*p == '1') {
   u <<= 1;
   u++;
  }
  else if (*p == '0') {
   u <<= 1;
  }
  else {
   return 0;
  }
 }
 *poutput = u;
 return 1;
}

variable_types:
input
char []

variable_types:
poutput
unsigned long *

variable_types:
u
unsigned long

variable_types:
p
char *


decompiled_code:
__int64 __fastcall accum_floppy_CRC(_BYTE *a1, unsigned int a2, _BYTE *a3, char *a4, int a5)
{
__int64 result; // rax
char v8; // dl
_BYTE *v9; // rcx

result = a2;
if ( a5 )
{
if ( a5 == 1 && (_DWORD)result )
{
v8 = *a4;
v9 = &a1[(unsigned int)result];
do
{
LOBYTE(result) = *a3 ^ *a1++;
result = (unsigned __int8)result;
*a3 = floppy_CRC_table_1[(unsigned __int8)result] ^ v8;
v8 = floppy_CRC_table_2[(unsigned __int8)result];
*a4 = v8;
}
while ( a1 != v9 );
}
}
else
{
*a3 = -107;
*a4 = -30;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, unsigned int a2, _BYTE *a3, char *a4, int a5)
{
__int64 result; // rax
char v8; // dl
_BYTE *v9; // rcx

result = a2;
if ( a5 )
{
if ( a5 == 1 && (_DWORD)result )
{
v8 = *a4;
v9 = &a1[(unsigned int)result];
do
{
LOBYTE(result) = *a3 ^ *a1++;
result = (unsigned __int8)result;
*a3 = floppy_CRC_table_1[(unsigned __int8)result] ^ v8;
v8 = floppy_CRC_table_2[(unsigned __int8)result];
*a4 = v8;
}
while ( a1 != v9 );
}
}
else
{
*a3 = -107;
*a4 = -30;
}
return result;
}

original_code:
void accum_floppy_CRC(
 int8u * buf,
 int32u len,
 int8u * pcsumh,
 int8u * pcsuml,
 int32u op)
{
 int32u i;
 int8u c;
 switch (op) {
 case 0:
  *pcsumh = 0x95;
  *pcsuml = 0xe2;
  break;
 case 1:
  for (i = 0; i < len; i++) {
   c = (*buf++) ^ *pcsumh;
   *pcsumh = floppy_CRC_table_1[c] ^ *pcsuml;
   *pcsuml = floppy_CRC_table_2[c];
  }
  break;
 case 2:
  break;
 }
}

canonical_original_code:
void accum_floppy_CRC(unsigned char *buf, unsigned int len, unsigned char *pcsumh, unsigned char *pcsuml, unsigned int op)
{
 unsigned int i;
 unsigned char c;
 switch (op) {
 case 0:
  *pcsumh = 0x95;
  *pcsuml = 0xe2;
  break;
 case 1:
  for (i = 0; i < len; i++) {
   c = (*buf++) ^ *pcsumh;
   *pcsumh = floppy_CRC_table_1[c] ^ *pcsuml;
   *pcsuml = floppy_CRC_table_2[c];
  }
  break;
 case 2:
  break;
 }
}

variable_types:
pcsumh
unsigned char *

variable_types:
pcsuml
unsigned char *

variable_types:
i
unsigned int

variable_types:
c
unsigned char


decompiled_code:
void *__fastcall malloc_or_die(unsigned int a1)
{
void *result; // rax

result = malloc((int)a1);
if ( !result )
{
fprintf(stderr, "malloc(%d) failed.\n", a1);
exit(1);
}
return result;
}

original_code:
void* malloc_or_die(int num_bytes)
{
 void* rv;
 rv = malloc(num_bytes);
 if (rv == 0) {
  fprintf(stderr, "malloc(%d) failed.\n", num_bytes);
  exit(1);
 }
 return rv;
}

canonical_original_code:
void *malloc_or_die(int num_bytes)
{
 void *rv;
 rv = malloc(num_bytes);
 if (rv == 0) {
  fprintf(stderr, "malloc(%d) failed.\n", num_bytes);
  exit(1);
 }
 return rv;
}

variable_types:
rv
void *


decompiled_code:
void *__fastcall int_malloc_or_die(int a1)
{
return malloc_or_die(4 * a1);
}

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

original_code:
int* int_malloc_or_die(int num_ints)
{
 return (int*)malloc_or_die(num_ints * sizeof(int));
}

canonical_original_code:
int *int_malloc_or_die(int num_ints)
{
 return (int *)malloc_or_die(num_ints * sizeof(int));
}

return_type: int *


decompiled_code:
// attributes: thunk
void *__fastcall char_malloc_or_die(unsigned int a1)
{
return malloc_or_die(a1);
}

canonical_decompiled_code:
void *__fastcall func2(unsigned int a1)
{
return func0(a1);
}

original_code:
char* char_malloc_or_die(int num_chars)
{
 return (char*)malloc_or_die(num_chars * sizeof(char));
}

canonical_original_code:
char *char_malloc_or_die(int num_chars)
{
 return (char *)malloc_or_die(num_chars * sizeof(char));
}

return_type: char *


decompiled_code:
void *__fastcall double_malloc_or_die(int a1)
{
return malloc_or_die(8 * a1);
}

canonical_decompiled_code:
void *__fastcall func3(int a1)
{
return func0(8 * a1);
}

original_code:
double* double_malloc_or_die(int num_doubles)
{
 return (double*)malloc_or_die(num_doubles * sizeof(double));
}

canonical_original_code:
double *double_malloc_or_die(int num_doubles)
{
 return (double *)malloc_or_die(num_doubles * sizeof(double));
}

return_type: double *


ipow

decompiled_code:
__int64 __fastcall ipow(int a1, int a2)
{
int v2; // eax
unsigned int v3; // er8

if ( a2 <= 0 )
return 1LL;
v2 = 0;
v3 = 1;
do
{
++v2;
v3 *= a1;
}
while ( a2 != v2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2)
{
int v2; // eax
unsigned int v3; // er8

if ( a2 <= 0 )
return 1LL;
v2 = 0;
v3 = 1;
do
{
++v2;
v3 *= a1;
}
while ( a2 != v2 );
return v3;
}

original_code:
int ipow(int x, int n)
{
 int xn = 1;
 int i;
 for (i = 0; i < n; i++)
  xn *= x;
 return xn;
}

variable_types: x int

variable_types: n int

variable_types: xn int

variable_types: i int


decompiled_code:
int check_stop()
{
int result; // eax
const char *v1; // rax
struct stat v2; // [rsp+0h] [rbp-98h] BYREF

result = stat("./__stop__", &v2);
if ( !result )
{
v1 = (const char *)get_sys_time_string();
printf("Exiting due to __stop__ file. Time: %s", v1);
exit(1);
}
return result;
}

canonical_decompiled_code:
int func8()
{
int result; // eax
const char *v1; // rax
struct stat v2; // [rsp+0h] [rbp-98h] BYREF

result = stat("./__stop__", &v2);
if ( !result )
{
v1 = (const char *)get_sys_time_string();
printf("Exiting due to __stop__ file. Time: %s", v1);
exit(1);
}
return result;
}

original_code:
void check_stop(void)
{
 struct stat statbuf;
 if (stat("./__stop__", &statbuf) == 0) {
  printf("Exiting due to __stop__ file.  Time:  %s",
   get_sys_time_string());
  exit(1);
 }
}

canonical_original_code:
void check_stop()
{
 struct stat statbuf;
 if (stat("./__stop__", &statbuf) == 0) {
  printf("Exiting due to __stop__ file.  Time:  %s",
   get_sys_time_string());
  exit(1);
 }
}

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

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


decompiled_code:
void __fastcall vector_accumulate(__int64 a1, __int64 a2, int a3)
{
__int64 i; // rax

if ( a3 > 0 )
{
for ( i = 0LL; i != a3; ++i )
*(double *)(a1 + 8 * i) = *(double *)(a1 + 8 * i) + *(double *)(a2 + 8 * i);
}
}

original_code:
void vector_accumulate(double * sum, double * v, int length)
{
 int i;
 for (i = 0; i < length; i++)
  sum[i] += v[i];
}

canonical_original_code:
void vector_accumulate(double *sum, double *v, int length)
{
 int i;
 for (i = 0; i < length; i++)
  sum[i] += v[i];
}

variable_types:
sum
double *

variable_types:
v
double *

variable_types: length int


decompiled_code:
void __fastcall vector_iaccumulate(__int64 a1, __int64 a2, int a3)
{
__int64 i; // rax

if ( a3 > 0 )
{
for ( i = 0LL; i != a3; ++i )
*(double *)(a1 + 8 * i) = (double)*(int *)(a2 + 4 * i) + *(double *)(a1 + 8 * i);
}
}

original_code:
void vector_iaccumulate(double * sum, int * v, int length)
{
 int i;
 for (i = 0; i < length; i++)
  sum[i] += (double)v[i];
}

canonical_original_code:
void vector_iaccumulate(double *sum, int *v, int length)
{
 int i;
 for (i = 0; i < length; i++)
  sum[i] += (double)v[i];
}

variable_types:
v
int *


decompiled_code:
void __fastcall vector_scale(__int64 a1, __int64 a2, int a3, double a4)
{
__int64 i; // rax

if ( a3 > 0 )
{
for ( i = 0LL; i != a3; ++i )
*(double *)(a1 + 8 * i) = *(double *)(a2 + 8 * i) * a4;
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, __int64 a2, int a3, double a4)
{
__int64 i; // rax

if ( a3 > 0 )
{
for ( i = 0LL; i != a3; ++i )
*(double *)(a1 + 8 * i) = *(double *)(a2 + 8 * i) * a4;
}
}

original_code:
void vector_scale(double* v, double* u, double a, int length)
{
 int i;
 for (i = 0; i < length; i++)
  v[i] = a * u[i];
}

canonical_original_code:
void vector_scale(double *v, double *u, double a, int length)
{
 int i;
 for (i = 0; i < length; i++)
  v[i] = a * u[i];
}

variable_types:
u
double *

variable_types: a double


decompiled_code:
int __fastcall vector_row_printf(double *a1, int a2, const char *a3)
{
double *v4; // rbx
double v5; // xmm0_8

if ( a2 > 0 )
{
v4 = a1;
while ( 1 )
{
v5 = *v4++;
printf(a3, v5);
if ( v4 == &a1[(unsigned int)(a2 - 1) + 1] )
break;
putchar(32);
}
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func4(double *a1, int a2, const char *a3)
{
double *v4; // rbx
double v5; // xmm0_8

if ( a2 > 0 )
{
v4 = a1;
while ( 1 )
{
v5 = *v4++;
printf(a3, v5);
if ( v4 == &a1[(unsigned int)(a2 - 1) + 1] )
break;
putchar(32);
}
}
return putchar(10);
}

original_code:
void vector_row_printf(double* v, int length, char* format)
{
 int i;
 for (i = 0; i < length; i++) {
  if (i > 0)
   printf(" ");
  printf(format, v[i]);
 }
 printf("\n");
}

canonical_original_code:
void vector_row_printf(double *v, int length, char *format)
{
 int i;
 for (i = 0; i < length; i++) {
  if (i > 0)
   printf(" ");
  printf(format, v[i]);
 }
 printf("\n");
}

variable_types:
format
char *


decompiled_code:
int __fastcall vector_col_printf(double *a1, int a2, const char *a3)
{
double *v4; // rbx
double v5; // xmm0_8
int result; // eax

if ( a2 > 0 )
{
v4 = a1;
do
{
v5 = *v4++;
printf(a3, v5);
result = putchar(10);
}
while ( v4 != &a1[(unsigned int)(a2 - 1) + 1] );
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(double *a1, int a2, const char *a3)
{
double *v4; // rbx
double v5; // xmm0_8
int result; // eax

if ( a2 > 0 )
{
v4 = a1;
do
{
v5 = *v4++;
printf(a3, v5);
result = putchar(10);
}
while ( v4 != &a1[(unsigned int)(a2 - 1) + 1] );
}
return result;
}

original_code:
void vector_col_printf (double* v, int length, char* format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v[i]);
  printf("\n");
 }
}

canonical_original_code:
void vector_col_printf(double *v, int length, char *format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v[i]);
  printf("\n");
 }
}


decompiled_code:
int __fastcall vector_col2_printf(__int64 a1, __int64 a2, int a3, const char *a4)
{
__int64 v4; // r12
__int64 i; // rbx
double v7; // xmm0_8
int result; // eax

if ( a3 > 0 )
{
v4 = a3;
for ( i = 0LL; i != v4; ++i )
{
printf(a4, *(double *)(a1 + 8 * i));
putchar(32);
v7 = *(double *)(a2 + 8 * i);
printf(a4, v7);
result = putchar(10);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1, __int64 a2, int a3, const char *a4)
{
__int64 v4; // r12
__int64 i; // rbx
double v7; // xmm0_8
int result; // eax

if ( a3 > 0 )
{
v4 = a3;
for ( i = 0LL; i != v4; ++i )
{
printf(a4, *(double *)(a1 + 8 * i));
putchar(32);
v7 = *(double *)(a2 + 8 * i);
printf(a4, v7);
result = putchar(10);
}
}
return result;
}

original_code:
void vector_col2_printf(double* v1, double* v2, int length, char* format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf("\n");
 }
}

canonical_original_code:
void vector_col2_printf(double *v1, double *v2, int length, char *format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf("\n");
 }
}


decompiled_code:
int __fastcall vector_col3_printf(__int64 a1, __int64 a2, __int64 a3, int a4, const char *a5)
{
__int64 v6; // r12
__int64 i; // rbx
double v9; // xmm0_8
int result; // eax

if ( a4 > 0 )
{
v6 = a4;
for ( i = 0LL; i != v6; ++i )
{
printf(a5, *(double *)(a1 + 8 * i));
putchar(32);
printf(a5, *(double *)(a2 + 8 * i));
putchar(32);
v9 = *(double *)(a3 + 8 * i);
printf(a5, v9);
result = putchar(10);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, __int64 a2, __int64 a3, int a4, const char *a5)
{
__int64 v6; // r12
__int64 i; // rbx
double v9; // xmm0_8
int result; // eax

if ( a4 > 0 )
{
v6 = a4;
for ( i = 0LL; i != v6; ++i )
{
printf(a5, *(double *)(a1 + 8 * i));
putchar(32);
printf(a5, *(double *)(a2 + 8 * i));
putchar(32);
v9 = *(double *)(a3 + 8 * i);
printf(a5, v9);
result = putchar(10);
}
}
return result;
}

original_code:
void vector_col3_printf(double* v1, double* v2, double* v3, int length,
 char* format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf("\n");
 }
}

canonical_original_code:
void vector_col3_printf(double *v1, double *v2, double *v3, int length, char *format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf("\n");
 }
}


decompiled_code:
int __fastcall vector_col4_printf(__int64 a1, __int64 a2, __int64 a3, __int64 a4, int a5, const char *a6)
{
__int64 v9; // rbx
double v10; // xmm0_8
int result; // eax
__int64 v12; // [rsp+0h] [rbp-40h]

if ( a5 > 0 )
{
v9 = 0LL;
v12 = a5;
do
{
printf(a6, *(double *)(a1 + 8 * v9));
putchar(32);
printf(a6, *(double *)(a2 + 8 * v9));
putchar(32);
printf(a6, *(double *)(a3 + 8 * v9));
putchar(32);
v10 = *(double *)(a4 + 8 * v9++);
printf(a6, v10);
result = putchar(10);
}
while ( v9 != v12 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, __int64 a2, __int64 a3, __int64 a4, int a5, const char *a6)
{
__int64 v9; // rbx
double v10; // xmm0_8
int result; // eax
__int64 v12; // [rsp+0h] [rbp-40h]

if ( a5 > 0 )
{
v9 = 0LL;
v12 = a5;
do
{
printf(a6, *(double *)(a1 + 8 * v9));
putchar(32);
printf(a6, *(double *)(a2 + 8 * v9));
putchar(32);
printf(a6, *(double *)(a3 + 8 * v9));
putchar(32);
v10 = *(double *)(a4 + 8 * v9++);
printf(a6, v10);
result = putchar(10);
}
while ( v9 != v12 );
}
return result;
}

original_code:
void vector_col4_printf(double* v1, double* v2, double* v3, double* v4,
 int length, char* format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf("\n");
 }
}

canonical_original_code:
void vector_col4_printf(double *v1, double *v2, double *v3, double *v4, int length, char *format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf("\n");
 }
}


decompiled_code:
int __fastcall vector_col5_printf(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, int a6, char *format)
{
__int64 v11; // rbp
double v12; // xmm0_8
int result; // eax
__int64 v14; // [rsp+0h] [rbp-48h]
__int64 v15; // [rsp+8h] [rbp-40h]

if ( a6 > 0 )
{
v15 = a6;
v11 = 0LL;
do
{
v14 = a1;
printf(format, *(double *)(a1 + 8 * v11));
putchar(32);
printf(format, *(double *)(a2 + 8 * v11));
putchar(32);
printf(format, *(double *)(a3 + 8 * v11));
putchar(32);
printf(format, *(double *)(a4 + 8 * v11));
putchar(32);
v12 = *(double *)(a5 + 8 * v11++);
printf(format, v12);
result = putchar(10);
a1 = v14;
}
while ( v11 != v15 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, int a6, char *format)
{
__int64 v11; // rbp
double v12; // xmm0_8
int result; // eax
__int64 v14; // [rsp+0h] [rbp-48h]
__int64 v15; // [rsp+8h] [rbp-40h]

if ( a6 > 0 )
{
v15 = a6;
v11 = 0LL;
do
{
v14 = a1;
printf(format, *(double *)(a1 + 8 * v11));
putchar(32);
printf(format, *(double *)(a2 + 8 * v11));
putchar(32);
printf(format, *(double *)(a3 + 8 * v11));
putchar(32);
printf(format, *(double *)(a4 + 8 * v11));
putchar(32);
v12 = *(double *)(a5 + 8 * v11++);
printf(format, v12);
result = putchar(10);
a1 = v14;
}
while ( v11 != v15 );
}
return result;
}

original_code:
void vector_col5_printf(double* v1, double* v2, double* v3, double* v4, double* v5,
 int length, char* format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf(" ");
  printf(format, v5[i]);
  printf("\n");
 }
}

canonical_original_code:
void vector_col5_printf(double *v1, double *v2, double *v3, double *v4, double *v5, int length, char *format)
{
 int i;
 for (i = 0; i < length; i++) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf(" ");
  printf(format, v5[i]);
  printf("\n");
 }
}


decompiled_code:
int __fastcall vector_col5_printf_decimated(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, int a6, char *format)
{
__int64 v11; // r12
int v12; // ebp
int result; // eax
__int64 v14; // [rsp+0h] [rbp-58h]
int v15; // [rsp+8h] [rbp-50h]

if ( a6 <= 2000 )
{
result = a6;
if ( a6 <= 0 )
return result;
v15 = 1;
}
else
{
v15 = a6 / 2000;
}
v11 = 0LL;
v12 = 0;
do
{
v14 = a1;
printf(format, *(double *)(a1 + v11));
putchar(32);
printf(format, *(double *)(a2 + v11));
putchar(32);
printf(format, *(double *)(a3 + v11));
putchar(32);
printf(format, *(double *)(a4 + v11));
putchar(32);
printf(format, *(double *)(a5 + v11));
result = putchar(10);
v12 += v15;
v11 += 8LL * v15;
a1 = v14;
}
while ( a6 > v12 );
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, int a6, char *format)
{
__int64 v11; // r12
int v12; // ebp
int result; // eax
__int64 v14; // [rsp+0h] [rbp-58h]
int v15; // [rsp+8h] [rbp-50h]

if ( a6 <= 2000 )
{
result = a6;
if ( a6 <= 0 )
return result;
v15 = 1;
}
else
{
v15 = a6 / 2000;
}
v11 = 0LL;
v12 = 0;
do
{
v14 = a1;
printf(format, *(double *)(a1 + v11));
putchar(32);
printf(format, *(double *)(a2 + v11));
putchar(32);
printf(format, *(double *)(a3 + v11));
putchar(32);
printf(format, *(double *)(a4 + v11));
putchar(32);
printf(format, *(double *)(a5 + v11));
result = putchar(10);
v12 += v15;
v11 += 8LL * v15;
a1 = v14;
}
while ( a6 > v12 );
return result;
}

original_code:
void vector_col5_printf_decimated(
 double* v1, double* v2, double* v3, double* v4, double* v5,
 int length, char* format)
{
 int stride = 1;
 int i;
 const int maxlen = 2000;
 if (length > maxlen)
  stride = length / maxlen;
 for (i = 0; i < length; i += stride) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf(" ");
  printf(format, v5[i]);
  printf("\n");
 }
}

canonical_original_code:
void vector_col5_printf_decimated(double *v1, double *v2, double *v3, double *v4, double *v5, int length, char *format)
{
 int stride = 1;
 int i;
 int maxlen = 2000;
 if (length > maxlen)
  stride = length / maxlen;
 for (i = 0; i < length; i += stride) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf(" ");
  printf(format, v5[i]);
  printf("\n");
 }
}

variable_types: stride int

variable_types: maxlen int


decompiled_code:
int __fastcall vector_col6_printf_decimated(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, char *format)
{
__int64 v13; // rbp
int v14; // ecx
int result; // eax
__int64 v16; // [rsp+0h] [rbp-58h]
int v17; // [rsp+8h] [rbp-50h]
int v18; // [rsp+Ch] [rbp-4Ch]

if ( a7 <= 2000 )
{
result = a7;
if ( a7 <= 0 )
return result;
v18 = 1;
}
else
{
v18 = a7 / 2000;
}
v13 = 0LL;
v14 = 0;
do
{
v17 = v14;
v16 = a1;
printf(format, *(double *)(a1 + v13));
putchar(32);
printf(format, *(double *)(a2 + v13));
putchar(32);
printf(format, *(double *)(a3 + v13));
putchar(32);
printf(format, *(double *)(a4 + v13));
putchar(32);
printf(format, *(double *)(a5 + v13));
putchar(32);
printf(format, *(double *)(a6 + v13));
result = putchar(10);
v13 += 8LL * v18;
v14 = v18 + v17;
a1 = v16;
}
while ( a7 > v18 + v17 );
return result;
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, char *format)
{
__int64 v13; // rbp
int v14; // ecx
int result; // eax
__int64 v16; // [rsp+0h] [rbp-58h]
int v17; // [rsp+8h] [rbp-50h]
int v18; // [rsp+Ch] [rbp-4Ch]

if ( a7 <= 2000 )
{
result = a7;
if ( a7 <= 0 )
return result;
v18 = 1;
}
else
{
v18 = a7 / 2000;
}
v13 = 0LL;
v14 = 0;
do
{
v17 = v14;
v16 = a1;
printf(format, *(double *)(a1 + v13));
putchar(32);
printf(format, *(double *)(a2 + v13));
putchar(32);
printf(format, *(double *)(a3 + v13));
putchar(32);
printf(format, *(double *)(a4 + v13));
putchar(32);
printf(format, *(double *)(a5 + v13));
putchar(32);
printf(format, *(double *)(a6 + v13));
result = putchar(10);
v13 += 8LL * v18;
v14 = v18 + v17;
a1 = v16;
}
while ( a7 > v18 + v17 );
return result;
}

original_code:
void vector_col6_printf_decimated(
 double* v1, double* v2, double* v3, double* v4, double* v5, double* v6,
 int length, char* format)
{
 int stride = 1;
 int i;
 const int maxlen = 2000;
 if (length > maxlen)
  stride = length / maxlen;
 for (i = 0; i < length; i += stride) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf(" ");
  printf(format, v5[i]);
  printf(" ");
  printf(format, v6[i]);
  printf("\n");
 }
}

canonical_original_code:
void vector_col6_printf_decimated(double *v1, double *v2, double *v3, double *v4, double *v5, double *v6, int length, char *format)
{
 int stride = 1;
 int i;
 int maxlen = 2000;
 if (length > maxlen)
  stride = length / maxlen;
 for (i = 0; i < length; i += stride) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf(" ");
  printf(format, v5[i]);
  printf(" ");
  printf(format, v6[i]);
  printf("\n");
 }
}


decompiled_code:
int __fastcall vector_col7_printf_decimated(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, int a8, char *format)
{
__int64 v14; // rbp
int v15; // ecx
int result; // eax
__int64 v17; // [rsp+0h] [rbp-58h]
int v18; // [rsp+8h] [rbp-50h]
int v19; // [rsp+Ch] [rbp-4Ch]

if ( a8 <= 2000 )
{
result = a8;
if ( a8 <= 0 )
return result;
v19 = 1;
}
else
{
v19 = a8 / 2000;
}
v14 = 0LL;
v15 = 0;
do
{
v18 = v15;
v17 = a1;
printf(format, *(double *)(a1 + v14));
putchar(32);
printf(format, *(double *)(a2 + v14));
putchar(32);
printf(format, *(double *)(a3 + v14));
putchar(32);
printf(format, *(double *)(a4 + v14));
putchar(32);
printf(format, *(double *)(a5 + v14));
putchar(32);
printf(format, *(double *)(a6 + v14));
putchar(32);
printf(format, *(double *)(a7 + v14));
result = putchar(10);
v14 += 8LL * v19;
v15 = v19 + v18;
a1 = v17;
}
while ( a8 > v19 + v18 );
return result;
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, int a8, char *format)
{
__int64 v14; // rbp
int v15; // ecx
int result; // eax
__int64 v17; // [rsp+0h] [rbp-58h]
int v18; // [rsp+8h] [rbp-50h]
int v19; // [rsp+Ch] [rbp-4Ch]

if ( a8 <= 2000 )
{
result = a8;
if ( a8 <= 0 )
return result;
v19 = 1;
}
else
{
v19 = a8 / 2000;
}
v14 = 0LL;
v15 = 0;
do
{
v18 = v15;
v17 = a1;
printf(format, *(double *)(a1 + v14));
putchar(32);
printf(format, *(double *)(a2 + v14));
putchar(32);
printf(format, *(double *)(a3 + v14));
putchar(32);
printf(format, *(double *)(a4 + v14));
putchar(32);
printf(format, *(double *)(a5 + v14));
putchar(32);
printf(format, *(double *)(a6 + v14));
putchar(32);
printf(format, *(double *)(a7 + v14));
result = putchar(10);
v14 += 8LL * v19;
v15 = v19 + v18;
a1 = v17;
}
while ( a8 > v19 + v18 );
return result;
}

original_code:
void vector_col7_printf_decimated(
 double* v1, double* v2, double* v3, double* v4, double* v5, double* v6,
 double* v7, int length, char* format)
{
 int stride = 1;
 int i;
 const int maxlen = 2000;
 if (length > maxlen)
  stride = length / maxlen;
 for (i = 0; i < length; i += stride) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf(" ");
  printf(format, v5[i]);
  printf(" ");
  printf(format, v6[i]);
  printf(" ");
  printf(format, v7[i]);
  printf("\n");
 }
}

canonical_original_code:
void vector_col7_printf_decimated(double *v1, double *v2, double *v3, double *v4, double *v5, double *v6, double *v7, int length, char *format)
{
 int stride = 1;
 int i;
 int maxlen = 2000;
 if (length > maxlen)
  stride = length / maxlen;
 for (i = 0; i < length; i += stride) {
  printf(format, v1[i]);
  printf(" ");
  printf(format, v2[i]);
  printf(" ");
  printf(format, v3[i]);
  printf(" ");
  printf(format, v4[i]);
  printf(" ");
  printf(format, v5[i]);
  printf(" ");
  printf(format, v6[i]);
  printf(" ");
  printf(format, v7[i]);
  printf("\n");
 }
}


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

if ( gettimeofday(&v1, 0LL) < 0 )
{
perror("gettimeofday");
exit(1);
}
return (double)SLODWORD(v1.tv_usec) * 0.000001 + (double)SLODWORD(v1.tv_sec);
}

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

if ( gettimeofday(&v1, 0LL) < 0 )
{
perror("gettimeofday");
exit(1);
}
return (double)SLODWORD(v1.tv_usec) * 0.000001 + (double)SLODWORD(v1.tv_sec);
}

original_code:
double get_sys_time_double(void)
{
 struct timeval now;
 if (gettimeofday(&now, 0) < 0) {
  perror("gettimeofday");
  exit(1);
 }
 return (double)now.tv_sec + (double)now.tv_usec * 1e-6;
}

canonical_original_code:
double get_sys_time_double()
{
 struct timeval now;
 if (gettimeofday(&now, 0) < 0) {
  perror("gettimeofday");
  exit(1);
 }
 return (double)now.tv_sec + (double)now.tv_usec * 1e-6;
}

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

return_type: double


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

if ( gettimeofday(&v1, 0LL) < 0 )
{
perror("gettimeofday");
exit(1);
}
return ctime(&v1.tv_sec);
}

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

if ( gettimeofday(&v1, 0LL) < 0 )
{
perror("gettimeofday");
exit(1);
}
return ctime(&v1.tv_sec);
}

original_code:
char* get_sys_time_string(void)
{
 struct timeval now;
 if (gettimeofday(&now, 0) < 0) {
  perror("gettimeofday");
  exit(1);
 }
 return ctime(&now.tv_sec);
}

canonical_original_code:
char *get_sys_time_string()
{
 struct timeval now;
 if (gettimeofday(&now, 0) < 0) {
  perror("gettimeofday");
  exit(1);
 }
 return ctime(&now.tv_sec);
}

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


decompiled_code:
void __fastcall sran32(int a1)
{
non_reentrant_state0 = 0;
non_reentrant_state1 = a1;
non_reentrant_seeded = 1;
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
non_reentrant_state0 = 0;
non_reentrant_state1 = a1;
non_reentrant_seeded = 1;
}

original_code:
void sran32(unsigned s)
{
 non_reentrant_state0 = 0;
 non_reentrant_state1 = s;
 non_reentrant_seeded = 1;
}

canonical_original_code:
void sran32(unsigned int s)
{
 non_reentrant_state0 = 0;
 non_reentrant_state1 = s;
 non_reentrant_seeded = 1;
}

variable_types:
s
unsigned int


decompiled_code:
void __fastcall sran32b(int a1, int a2)
{
non_reentrant_state0 = a1;
non_reentrant_state1 = a2;
non_reentrant_seeded = 1;
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2)
{
non_reentrant_state0 = a1;
non_reentrant_state1 = a2;
non_reentrant_seeded = 1;
}

original_code:
void sran32b(unsigned s0, unsigned s1)
{
 non_reentrant_state0 = s0;
 non_reentrant_state1 = s1;
 non_reentrant_seeded = 1;
}

canonical_original_code:
void sran32b(unsigned int s0, unsigned int s1)
{
 non_reentrant_state0 = s0;
 non_reentrant_state1 = s1;
 non_reentrant_seeded = 1;
}


decompiled_code:
__int64 sran32_tod()
{
__pid_t v0; // eax
__int64 result; // rax
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v2, 0LL);
v0 = getpid();
non_reentrant_seeded = 1;
non_reentrant_state0 = LODWORD(v2.tv_usec) ^ v0;
result = LODWORD(v2.tv_sec) ^ (unsigned int)(LODWORD(v2.tv_usec) * LODWORD(v2.tv_usec) + 1);
non_reentrant_state1 = LODWORD(v2.tv_sec) ^ (LODWORD(v2.tv_usec) * LODWORD(v2.tv_usec) + 1);
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__pid_t v0; // eax
__int64 result; // rax
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v2, 0LL);
v0 = getpid();
non_reentrant_seeded = 1;
non_reentrant_state0 = LODWORD(v2.tv_usec) ^ v0;
result = LODWORD(v2.tv_sec) ^ (unsigned int)(LODWORD(v2.tv_usec) * LODWORD(v2.tv_usec) + 1);
non_reentrant_state1 = LODWORD(v2.tv_sec) ^ (LODWORD(v2.tv_usec) * LODWORD(v2.tv_usec) + 1);
return result;
}

original_code:
void sran32_tod(void)
{
 struct timeval tod;
 (void)gettimeofday(&tod, 0);
 non_reentrant_state0 = getpid() ^ tod.tv_usec;
 non_reentrant_state1 = tod.tv_sec ^ (tod.tv_usec * tod.tv_usec + 1);
 non_reentrant_seeded = 1;
}

canonical_original_code:
void sran32_tod()
{
 struct timeval tod;
 (void)gettimeofday(&tod, 0);
 non_reentrant_state0 = getpid() ^ tod.tv_usec;
 non_reentrant_state1 = tod.tv_sec ^ (tod.tv_usec * tod.tv_usec + 1);
 non_reentrant_seeded = 1;
}


decompiled_code:
__int64 __fastcall sran32_tod_r(int *a1, _DWORD *a2)
{
int v2; // edx
int v3; // eax
__int64 result; // rax
struct timeval v5; // [rsp+0h] [rbp-28h] BYREF

gettimeofday(&v5, 0LL);
v2 = LODWORD(v5.tv_usec) ^ getpid();
v3 = LODWORD(v5.tv_usec) * LODWORD(v5.tv_usec);
*a1 = v2;
result = LODWORD(v5.tv_sec) ^ (unsigned int)(v3 + 1);
*a2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1, _DWORD *a2)
{
int v2; // edx
int v3; // eax
__int64 result; // rax
struct timeval v5; // [rsp+0h] [rbp-28h] BYREF

gettimeofday(&v5, 0LL);
v2 = LODWORD(v5.tv_usec) ^ getpid();
v3 = LODWORD(v5.tv_usec) * LODWORD(v5.tv_usec);
*a1 = v2;
result = LODWORD(v5.tv_sec) ^ (unsigned int)(v3 + 1);
*a2 = result;
return result;
}

original_code:
void sran32_tod_r(unsigned * pstate0, unsigned * pstate1)
{
 struct timeval tod;
 (void)gettimeofday(&tod, 0);
 *pstate0 = getpid() ^ tod.tv_usec;
 *pstate1 = tod.tv_sec ^ (tod.tv_usec * tod.tv_usec + 1);
}

canonical_original_code:
void sran32_tod_r(unsigned int *pstate0, unsigned int *pstate1)
{
 struct timeval tod;
 (void)gettimeofday(&tod, 0);
 *pstate0 = getpid() ^ tod.tv_usec;
 *pstate1 = tod.tv_sec ^ (tod.tv_usec * tod.tv_usec + 1);
}


decompiled_code:
__int64 __fastcall psdes_hash_64(int *a1, int *a2)
{
int v3; // er11
__int64 v4; // rdi
int v5; // eax
int v6; // ecx
int v7; // er8
unsigned int v8; // ecx
__int64 result; // rax

v3 = *a1;
v4 = 0LL;
v5 = 1259289432;
v6 = -1163302777;
while ( 1 )
{
v7 = *a2;
++v4;
v8 = *a2 ^ v6;
result = v3 ^ ((v5 ^ __ROL4__((unsigned __int16)v8 * (unsigned __int16)v8 - 1 - HIWORD(v8) * HIWORD(v8), 16))
+ (unsigned __int16)v8 * HIWORD(v8));
*a2 = result;
*a1 = v7;
if ( v4 == 4 )
break;
v6 = c1_1[v4];
v5 = c2_0[v4];
v3 = v7;
}
return result;
}

original_code:
void psdes_hash_64(
 unsigned * pword0,
 unsigned * pword1)
{
 unsigned i;
 unsigned iswap, ia, iah, ial, ib, ic;
 static unsigned c1[4] = {
  0xbaa96887, 0x1e17d32c, 0x03bcdc3c, 0x0f33d1b2 };
 static unsigned c2[4] = {
  0x4b0f3b58, 0xe874f0c3, 0x6955c5a6, 0x55a7ca46 };
 for (i = 0; i < 4; i++) {
  iswap = *pword1;
  ia = iswap ^ c1[i];
  ial = ia & 0xffff;
  iah = ia >> 16;
  ib = ial * ial + ~(iah * iah);
  ic = (ib >> 16) | ((ib & 0xffff) << 16);
  *pword1 = (*pword0) ^ ((ic ^ c2[i]) + ial * iah);
  *pword0 = iswap;
 }
}

canonical_original_code:
void psdes_hash_64(unsigned int *pword0, unsigned int *pword1)
{
 unsigned int i;
 unsigned int iswap; unsigned int ia; unsigned int iah; unsigned int ial; unsigned int ib; unsigned int ic;
 static unsigned int c1[4] = {
  0xbaa96887, 0x1e17d32c, 0x03bcdc3c, 0x0f33d1b2 };
 static unsigned int c2[4] = {
  0x4b0f3b58, 0xe874f0c3, 0x6955c5a6, 0x55a7ca46 };
 for (i = 0; i < 4; i++) {
  iswap = *pword1;
  ia = iswap ^ c1[i];
  ial = ia & 0xffff;
  iah = ia >> 16;
  ib = ial * ial + ~(iah * iah);
  ic = (ib >> 16) | ((ib & 0xffff) << 16);
  *pword1 = (*pword0) ^ ((ic ^ c2[i]) + ial * iah);
  *pword0 = iswap;
 }
}

variable_types:
i
unsigned int

variable_types:
iswap
unsigned int

variable_types:
ia
unsigned int

variable_types:
iah
unsigned int

variable_types:
ial
unsigned int

variable_types:
ib
unsigned int

variable_types:
ic
unsigned int


decompiled_code:
__int64 __fastcall iran32_r(int *a1, int *a2)
{
int v4; // [rsp+8h] [rbp-18h] BYREF
unsigned int v5[5]; // [rsp+Ch] [rbp-14h] BYREF

v4 = *a1;
v5[0] = *a2;
psdes_hash_64(&v4, (int *)v5);
if ( (*a2)++ == -1 )
++*a1;
return v5[0];
}

canonical_decompiled_code:
__int64 __fastcall func5(int *a1, int *a2)
{
int v4; // [rsp+8h] [rbp-18h] BYREF
unsigned int v5[5]; // [rsp+Ch] [rbp-14h] BYREF

v4 = *a1;
v5[0] = *a2;
func4(&v4, (int *)v5);
if ( (*a2)++ == -1 )
++*a1;
return v5[0];
}

original_code:
unsigned iran32_r(unsigned * pstate0, unsigned * pstate1)
{
 unsigned word0 = *pstate0;
 unsigned word1 = *pstate1;
 psdes_hash_64(&word0, &word1);
 (*pstate1)++;
 if (*pstate1 == 0)
  (*pstate0)++;
 return word1;
}

canonical_original_code:
unsigned int iran32_r(unsigned int *pstate0, unsigned int *pstate1)
{
 unsigned int word0 = *pstate0;
 unsigned int word1 = *pstate1;
 psdes_hash_64(&word0, &word1);
 (*pstate1)++;
 if (*pstate1 == 0)
  (*pstate0)++;
 return word1;
}


decompiled_code:
__int64 iran32()
{
if ( !non_reentrant_seeded )
sran32_tod();
return iran32_r(&non_reentrant_state0, &non_reentrant_state1);
}

canonical_decompiled_code:
__int64 func6()
{
if ( !non_reentrant_seeded )
func2();
return func5(&non_reentrant_state0, &non_reentrant_state1);
}

original_code:
unsigned iran32(void)
{
 if (!non_reentrant_seeded)
  sran32_tod();
 return iran32_r(&non_reentrant_state0, &non_reentrant_state1);
}

canonical_original_code:
unsigned int iran32()
{
 if (!non_reentrant_seeded)
  sran32_tod();
 return iran32_r(&non_reentrant_state0, &non_reentrant_state1);
}


decompiled_code:
double __fastcall fran32_r(int *a1, int *a2)
{
return (double)(int)iran32_r(a1, a2) * 2.328306436538696e-10;
}

canonical_decompiled_code:
double __fastcall func7(int *a1, int *a2)
{
return (double)(int)func5(a1, a2) * 2.328306436538696e-10;
}

original_code:
double fran32_r(unsigned * pstate0, unsigned * pstate1)
{
 unsigned word = iran32_r(pstate0, pstate1);
 return (double)( (double)word / (double)4294967296.0 );
}

canonical_original_code:
double fran32_r(unsigned int *pstate0, unsigned int *pstate1)
{
 unsigned int word = iran32_r(pstate0, pstate1);
 return (double)( (double)word / (double)4294967296.0 );
}

variable_types:
word
unsigned int


decompiled_code:
double fran32()
{
if ( !non_reentrant_seeded )
sran32_tod();
return fran32_r(&non_reentrant_state0, &non_reentrant_state1);
}

canonical_decompiled_code:
double func8()
{
if ( !non_reentrant_seeded )
func2();
return func7(&non_reentrant_state0, &non_reentrant_state1);
}

original_code:
double fran32(void)
{
 if (!non_reentrant_seeded)
  sran32_tod();
 return fran32_r(&non_reentrant_state0, &non_reentrant_state1);
}

canonical_original_code:
double fran32()
{
 if (!non_reentrant_seeded)
  sran32_tod();
 return fran32_r(&non_reentrant_state0, &non_reentrant_state1);
}


decompiled_code:
__int64 __fastcall iran64_r(int *a1, int *a2, int *a3, int *a4)
{
__int64 result; // rax

*a1 = *a3;
*a2 = *a4;
result = psdes_hash_64(a1, a2);
if ( (*a4)++ == -1 )
++*a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int *a1, int *a2, int *a3, int *a4)
{
__int64 result; // rax

*a1 = *a3;
*a2 = *a4;
result = func4(a1, a2);
if ( (*a4)++ == -1 )
++*a3;
return result;
}

original_code:
void iran64_r(unsigned * pout0, unsigned * pout1,
 unsigned * pstate0, unsigned * pstate1)
{
 *pout0 = *pstate0;
 *pout1 = *pstate1;
 psdes_hash_64(pout0, pout1);
 (*pstate1)++;
 if (*pstate1 == 0)
  (*pstate0)++;
}

canonical_original_code:
void iran64_r(unsigned int *pout0, unsigned int *pout1, unsigned int *pstate0, unsigned int *pstate1)
{
 *pout0 = *pstate0;
 *pout1 = *pstate1;
 psdes_hash_64(pout0, pout1);
 (*pstate1)++;
 if (*pstate1 == 0)
  (*pstate0)++;
}


decompiled_code:
__int64 __fastcall iran64(int *a1, int *a2)
{
if ( !non_reentrant_seeded )
sran32_tod();
return iran64_r(a1, a2, &non_reentrant_state0, &non_reentrant_state1);
}

canonical_decompiled_code:
__int64 __fastcall func10(int *a1, int *a2)
{
if ( !non_reentrant_seeded )
func2();
return func9(a1, a2, &non_reentrant_state0, &non_reentrant_state1);
}

original_code:
void iran64(unsigned * pout0, unsigned * pout1)
{
 if (!non_reentrant_seeded)
  sran32_tod();
 return iran64_r(pout0, pout1,
  &non_reentrant_state0, &non_reentrant_state1);
}

canonical_original_code:
void iran64(unsigned int *pout0, unsigned int *pout1)
{
 if (!non_reentrant_seeded)
  sran32_tod();
 return iran64_r(pout0, pout1,
  &non_reentrant_state0, &non_reentrant_state1);
}


xmalloc

decompiled_code:
void *__fastcall xmalloc(int a1)
{
void *v1; // r12

v1 = calloc(a1, 1uLL);
if ( !v1 )
fprintf(stderr, "Line : %d , malloc\n", 21LL);
return v1;
}

canonical_decompiled_code:
void *__fastcall func0(int a1)
{
void *v1; // r12

v1 = calloc(a1, 1uLL);
if ( !v1 )
fprintf(stderr, "Line : %d , malloc\n", 21LL);
return v1;
}

original_code:
void *xmalloc(int bytes)
{
 void *tmp = malloc(bytes);
 if (!tmp) {
  fprintf(stderr, "Line : %d , malloc\n", 21);
  return ((void *)0);
 }
 memset(tmp, 0, bytes);
 return tmp;
}

variable_types: bytes int

variable_types:
tmp
void *


printfd

decompiled_code:
ssize_t printfd(int fd, char *format, ...)
{
int v2; // eax
gcc_va_list arg; // [rsp+8h] [rbp-2D0h] BYREF
char s[512]; // [rsp+20h] [rbp-2B8h] BYREF

va_start(arg, format);
v2 = vsnprintf(s, 0x200uLL, format, arg);
return write(fd, s, v2);
}

canonical_decompiled_code:
ssize_t func1(int fd, char *format, ...)
{
int v2; // eax
gcc_va_list arg; // [rsp+8h] [rbp-2D0h] BYREF
char s[512]; // [rsp+20h] [rbp-2B8h] BYREF

va_start(arg, format);
v2 = vsnprintf(s, 0x200uLL, format, arg);
return write(fd, s, v2);
}

original_code:
int printfd(int fd, const char *fmt, ...)
{
 char data[512];
 int len;
 va_list ap;
 int wr;
 __builtin_va_start(ap,fmt);
 len = vsnprintf(data, 512, fmt, ap);
 __builtin_va_end(ap);
 wr = write(fd, data, len);
 return wr;
}

canonical_original_code:
int printfd(int fd, char *fmt, ...)
{
 char data[512];
 int len;
 __builtin_va_list ap;
 int wr;
 __builtin_va_start(ap,fmt);
 len = vsnprintf(data, 512, fmt, ap);
 __builtin_va_end(ap);
 wr = write(fd, data, len);
 return wr;
}

variable_types: fd int

variable_types:
fmt
char *

variable_types:
data
char [512]

variable_types: len int

variable_types: wr int


ascii

decompiled_code:
char *__fastcall ascii(char *s, unsigned int a2)
{
unsigned int v2; // er12

v2 = a2;
if ( ((*_ctype_b_loc())[a2] & 0x4000) == 0 )
v2 = 46;
sprintf(s, "%c", v2);
return s + 1;
}

canonical_decompiled_code:
char *__fastcall func2(char *s, unsigned int a2)
{
unsigned int v2; // er12

v2 = a2;
if ( ((*_ctype_b_loc())[a2] & 0x4000) == 0 )
v2 = 46;
sprintf(s, "%c", v2);
return s + 1;
}

original_code:
char *ascii(char *position, int c)
{
 if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISprint))
  c = '.';
 sprintf(position, "%c", c);
 return (++position);
}

canonical_original_code:
char *ascii(char *position, int c)
{
 if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISprint))
  c = '.';
 sprintf(position, "%c", c);
 return (++position);
}

variable_types:
position
char *

variable_types: c int


hex

decompiled_code:
char *__fastcall hex(char *a1, unsigned __int8 a2)
{
char *result; // rax

sprintf(a1, "%02x ", a2);
result = a1 + 3;
a1[3] = 32;
return result;
}

canonical_decompiled_code:
char *__fastcall func3(char *a1, unsigned __int8 a2)
{
char *result; // rax

sprintf(a1, "%02x ", a2);
result = a1 + 3;
a1[3] = 32;
return result;
}

original_code:
char *hex(char *position, int c)
{
 int offset = 3;
 sprintf(position, "%02x ", (unsigned char)c);
 *(position + offset) = ' ';
 return (position + offset);
}

variable_types: offset int


original_code:
void raw_dump(struct procinfo *pi)
{
 int left, written;
 u_char *ptr;
 struct map_addr *ma_ptr,*ma_tmp;
 if((pi->pi_debug | 4) & 1)
  ma_tmp = pi->pi_stack;
 else
  ma_tmp = pi->pi_addr;
 for (ma_ptr = ma_tmp; ma_ptr; ma_ptr = ma_ptr->ma_next) {
  ptr = ma_ptr->ma_data;
  left = pi->pi_offset;
  while (left > 0) {
   written = write(1, ptr, left);
   left -= written;
   ptr += written;
  }
 }
}

canonical_original_code:
void raw_dump(struct procinfo *pi)
{
 int left; int written;
 unsigned char *ptr;
 struct map_addr *ma_ptr; struct map_addr *ma_tmp;
 if((pi->pi_debug | 4) & 1)
  ma_tmp = pi->pi_stack;
 else
  ma_tmp = pi->pi_addr;
 for (ma_ptr = ma_tmp; ma_ptr; ma_ptr = ma_ptr->ma_next) {
  ptr = ma_ptr->ma_data;
  left = pi->pi_offset;
  while (left > 0) {
   written = write(1, ptr, left);
   left -= written;
   ptr += written;
  }
 }
}

variable_types: struct procinfo { int pi_pid; unsigned char *pi_target; unsigned char *pi_args; unsigned long pi_address; unsigned char *pi_data; unsigned long long pi_map[2]; unsigned long pi_saved_offset; unsigned long pi_offset; unsigned int pi_debug; struct perms { unsigned short p_read; unsigned short p_write; unsigned short p_exec; unsigned short p_exist; unsigned char *p_full_path; unsigned char *p_symb; } *pi_perm; struct map_addr { unsigned long long ma_map[2]; unsigned char *ma_data; struct map_addr *ma_next; } *pi_addr; struct map_addr *pi_stack; struct map_addr *pi_heap; } *

variable_types: left int

variable_types: written int

variable_types:
ptr
unsigned char *

user_defined_types: struct procinfo { int pi_pid; unsigned char *pi_target; unsigned char *pi_args; unsigned long pi_address; unsigned char *pi_data; unsigned long long pi_map[2]; unsigned long pi_saved_offset; unsigned long pi_offset; unsigned int pi_debug; struct perms *pi_perm; struct map_addr *pi_addr; struct map_addr *pi_stack; struct map_addr *pi_heap; }


die

decompiled_code:
void __fastcall __noreturn die(const char *a1)
{
int *v1; // rax

perror(a1);
v1 = _errno_location();
exit(*v1);
}

canonical_decompiled_code:
void __fastcall __noreturn func6(const char *a1)
{
int *v1; // rax

perror(a1);
v1 = _errno_location();
exit(*v1);
}

original_code:
void die(const char *msg)
{
 perror(msg);
 exit((*__errno_location ()));
}

canonical_original_code:
void die(char *msg)
{
 perror(msg);
 exit((*__errno_location ()));
}

variable_types:
msg
char *


decompiled_code:
void __fastcall __noreturn btrace_banner(const char *a1, int a2)
{
printfd(1LL, "Usage : %s <options> \n", a1);
printfd(1LL, "Written By M.Ghannam (Simo36)\n\n");
printfd(
1LL,
"Process Invoker methods : \n"
" -p --attach <process id> \tSet a process id\n"
" -t --target <binary process>\tBinary process which you want to leak from\n"
" -A --args [bianry args] \tTarget arguments (optional)\n"
"\n");
printfd(
1LL,
"Dump facilities : \n"
" -d --dump <hex/raw> \tDump memory data (default output)\n"
" -D --dump-elf <out_file> \tDump ELF binary\n"
" -a --address <memory_addr> \tMemory address\n"
" -o --offset <byte offset> \tHow many byte you want to leak?\n"
" -s --stack\t\t\t \tDump the stack \n"
"\n");
exit(a2);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1, int a2)
{
printfd(1LL, "Usage : %s <options> \n", a1);
printfd(1LL, "Written By M.Ghannam (Simo36)\n\n");
printfd(
1LL,
"Process Invoker methods : \n"
" -p --attach <process id> \tSet a process id\n"
" -t --target <binary process>\tBinary process which you want to leak from\n"
" -A --args [bianry args] \tTarget arguments (optional)\n"
"\n");
printfd(
1LL,
"Dump facilities : \n"
" -d --dump <hex/raw> \tDump memory data (default output)\n"
" -D --dump-elf <out_file> \tDump ELF binary\n"
" -a --address <memory_addr> \tMemory address\n"
" -o --offset <byte offset> \tHow many byte you want to leak?\n"
" -s --stack\t\t\t \tDump the stack \n"
"\n");
exit(a2);
}

original_code:
void btrace_banner(char *arg, int status)
{
 printfd(1, "Usage : %s <options>  \n", arg);
 printfd(1, "Written By  M.Ghannam (Simo36)\n\n");
 printfd(1,
  "Process Invoker methods : \n"
  "  -p  --attach  <process id>    \tSet a process id\n"
  "  -t  --target  <binary process>\tBinary process which you want to leak from\n"
  "  -A  --args    [bianry args]   \tTarget arguments (optional)\n"
  "\n");
 printfd(1,
  "Dump facilities : \n"
  "  -d  --dump     <hex/raw>       \tDump memory data (default output)\n"
  "  -D  --dump-elf <out_file>       \tDump ELF binary\n"
  "  -a  --address  <memory_addr>    \tMemory address\n"
  "  -o  --offset   <byte offset>    \tHow many byte you want to leak?\n"
  "  -s  --stack			   \tDump the stack \n"
  "\n"
  );
 exit(status);
}

variable_types:
arg
char *

variable_types: status int


decompiled_code:
__int64 __fastcall parse_args(int argc, char **argv, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // r13
__int64 v6; // r14
int v7; // eax
int longind[11]; // [rsp+Ch] [rbp-2Ch] BYREF

*(_QWORD *)a3 = 0x10000000000LL;
*(_BYTE *)(a3 + 8) = 0;
longind[0] = 0;
v4 = bt_proc_init();
v5 = *(_QWORD *)(v4 + 8);
v6 = v4;
while ( 1 )
{
v7 = getopt_long(argc, argv, "a:p:o:d:D:rst:A:h", &lo, longind);
if ( v7 == -1 )
break;
switch ( v7 )
{
case 'A':
*(_QWORD *)(v5 + 16) = strdup(optarg);
*(_BYTE *)(a3 + 7) |= 1u;
break;
case 'D':
*(_BYTE *)(a3 + 8) |= 1u;
break;
case 'a':
*(_QWORD *)(v5 + 24) = strtol(optarg, 0LL, 16);
*(_BYTE *)(a3 + 1) |= 1u;
break;
case 'd':
*(_WORD *)(a3 + 4) |= 0x102u;
if ( *optarg == 114 && optarg[1] == 97 && optarg[2] == 119 )
*(_BYTE *)(a3 + 3) |= 1u;
break;
case 'h':
btrace_banner(*argv, 0);
case 'o':
*(_QWORD *)(v5 + 64) = strtol(optarg, 0LL, 10);
*(_BYTE *)(a3 + 2) |= 1u;
break;
case 'p':
*(_DWORD *)v5 = atoi(optarg);
*(_BYTE *)a3 |= 1u;
break;
case 's':
*(_BYTE *)(a3 + 4) |= 1u;
break;
case 't':
*(_QWORD *)(v5 + 8) = strdup(optarg);
*(_BYTE *)(a3 + 6) |= 1u;
break;
default:
btrace_banner(*argv, -1);
}
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func1(int argc, char **argv, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // r13
__int64 v6; // r14
int v7; // eax
int longind[11]; // [rsp+Ch] [rbp-2Ch] BYREF

*(_QWORD *)a3 = 0x10000000000LL;
*(_BYTE *)(a3 + 8) = 0;
longind[0] = 0;
v4 = bt_proc_init();
v5 = *(_QWORD *)(v4 + 8);
v6 = v4;
while ( 1 )
{
v7 = getopt_long(argc, argv, "a:p:o:d:D:rst:A:h", &lo, longind);
if ( v7 == -1 )
break;
switch ( v7 )
{
case 'A':
*(_QWORD *)(v5 + 16) = strdup(optarg);
*(_BYTE *)(a3 + 7) |= 1u;
break;
case 'D':
*(_BYTE *)(a3 + 8) |= 1u;
break;
case 'a':
*(_QWORD *)(v5 + 24) = strtol(optarg, 0LL, 16);
*(_BYTE *)(a3 + 1) |= 1u;
break;
case 'd':
*(_WORD *)(a3 + 4) |= 0x102u;
if ( *optarg == 114 && optarg[1] == 97 && optarg[2] == 119 )
*(_BYTE *)(a3 + 3) |= 1u;
break;
case 'h':
func0(*argv, 0);
case 'o':
*(_QWORD *)(v5 + 64) = strtol(optarg, 0LL, 10);
*(_BYTE *)(a3 + 2) |= 1u;
break;
case 'p':
*(_DWORD *)v5 = atoi(optarg);
*(_BYTE *)a3 |= 1u;
break;
case 's':
*(_BYTE *)(a3 + 4) |= 1u;
break;
case 't':
*(_QWORD *)(v5 + 8) = strdup(optarg);
*(_BYTE *)(a3 + 6) |= 1u;
break;
default:
func0(*argv, -1);
}
}
return v6;
}

original_code:
static struct btproc *parse_args(int argc, char **argv, struct bt_opts *opts)
{
 int opt, long_opt_index = 0;
 struct procinfo *pi;
 struct btproc *bt;
 opts->pid_opt = 0;
 opts->force_addr_opt = 0;
 opts->off_opt = 0;
 opts->raw_opt = 0;
 opts->target_opt = 0;
 opts->debug_opt = 0;
 opts->target_has_args = 0;
 opts->elf_dump_opts = 0;
 opts->use_data_opt = 1;
 opts->off_opt = 0;
 bt = bt_proc_init();
 pi = bt->pi;
 while ((opt =
  getopt_long(argc, argv, "a:p:o:d:D:rst:A:h", lo,
       &long_opt_index)) != -1) {
  switch (opt) {
  case 'a':
   pi->pi_address = strtol(optarg, ((void *)0), 0x10);
   opts->force_addr_opt |= 1;
   break;
  case 'p':
   pi->pi_pid = atoi(optarg);
   opts->pid_opt |= 1;
   break;
  case 't':
   pi->pi_target = (u_char *) strdup((const char *)optarg);
   opts->target_opt |= 1;
   break;
  case 'A':
   pi->pi_args = (u_char *) strdup((const char *)optarg);
   opts->target_has_args |= 1;
   break;
  case 'h':
   btrace_banner(*argv, 0);
   break;
  case 'o':
   pi->pi_offset = strtol(optarg, ((void *)0), 10);
   opts->off_opt |= 1;
   break;
  case 'd':
   opts->use_data_opt |= 1;
   opts->debug_opt |= 2;
   if(!strncmp(optarg,"raw",3))
    opts->raw_opt |= 1;
   break;
  case 's':
   opts->debug_opt |= 1;
   break;
  case 'D':
   opts->elf_dump_opts |= 1;
   break;
  default:
   btrace_banner(*argv, -1);
  }
 }
 return bt;
}

canonical_original_code:
static struct btproc *parse_args(int argc, char **argv, struct bt_opts *opts)
{
 int opt; int long_opt_index = 0;
 struct procinfo *pi;
 struct btproc *bt;
 opts->pid_opt = 0;
 opts->force_addr_opt = 0;
 opts->off_opt = 0;
 opts->raw_opt = 0;
 opts->target_opt = 0;
 opts->debug_opt = 0;
 opts->target_has_args = 0;
 opts->elf_dump_opts = 0;
 opts->use_data_opt = 1;
 opts->off_opt = 0;
 bt = bt_proc_init();
 pi = bt->pi;
 while ((opt =
  getopt_long(argc, argv, "a:p:o:d:D:rst:A:h", lo,
       &long_opt_index)) != -1) {
  switch (opt) {
  case 'a':
   pi->pi_address = strtol(optarg, ((void *)0), 0x10);
   opts->force_addr_opt |= 1;
   break;
  case 'p':
   pi->pi_pid = atoi(optarg);
   opts->pid_opt |= 1;
   break;
  case 't':
   pi->pi_target = (unsigned char *) strdup((char *)optarg);
   opts->target_opt |= 1;
   break;
  case 'A':
   pi->pi_args = (unsigned char *) strdup((char *)optarg);
   opts->target_has_args |= 1;
   break;
  case 'h':
   btrace_banner(*argv, 0);
   break;
  case 'o':
   pi->pi_offset = strtol(optarg, ((void *)0), 10);
   opts->off_opt |= 1;
   break;
  case 'd':
   opts->use_data_opt |= 1;
   opts->debug_opt |= 2;
   if(!strncmp(optarg,"raw",3))
    opts->raw_opt |= 1;
   break;
  case 's':
   opts->debug_opt |= 1;
   break;
  case 'D':
   opts->elf_dump_opts |= 1;
   break;
  default:
   btrace_banner(*argv, -1);
  }
 }
 return bt;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct bt_opts { unsigned int pid_opt; unsigned int force_addr_opt; unsigned int off_opt; unsigned int raw_opt; unsigned int debug_opt; unsigned int use_data_opt; unsigned int target_opt; unsigned int target_has_args; unsigned int elf_dump_opts; } *

variable_types: opt int

variable_types: struct btproc { unsigned char *exec; struct procinfo { int pi_pid; unsigned char *pi_target; unsigned char *pi_args; unsigned long pi_address; unsigned char *pi_data; unsigned long long pi_map[2]; unsigned long pi_saved_offset; unsigned long pi_offset; unsigned int pi_debug; struct perms { unsigned short p_read; unsigned short p_write; unsigned short p_exec; unsigned short p_exist; unsigned char *p_full_path; unsigned char *p_symb; } *pi_perm; struct map_addr { unsigned long long ma_map[2]; unsigned char *ma_data; struct map_addr *ma_next; } *pi_addr; struct map_addr *pi_stack; struct map_addr *pi_heap; } *pi; char **proc_arguments; void (*args_parser)(char *, struct btproc *); } *

user_defined_types: struct btproc { unsigned char *exec; struct procinfo *pi; char **proc_arguments; void (*args_parser)(char *, struct btproc *); }