original_code:
int
core_srt_join_I_I_L(
          int *src_lnk,
          int *src_val,
          long long src_nR,
          long long *dst_lnk,
          int *dst_val,
          char *nn_dst_val,
          long long dst_lb,
          long long dst_ub,
          int ijoin_op,
          _Bool *ptr_is_any_null
          )
{
  int status = 0;
  long long src_idx;
  long long v_dst_lnk;
  int v_src_val;
  int v_src_lnk;
  _Bool found, prev_val_known = 0;
  status = set_init(nn_dst_val, dst_val, dst_lb, dst_ub, ijoin_op);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 117, "./AUX/core_srt_join_I_I_L.c"); }; status = (status) ; goto BYE; } } };
  src_idx = 0;
  for ( long long dst_idx = dst_lb; dst_idx < dst_ub; dst_idx++ ) {
    v_dst_lnk = dst_lnk[dst_idx];
    if ( dst_idx > 0 ) {
      if ( v_dst_lnk == dst_lnk[dst_idx-1] ) {
 if ( dst_val != ((void *)0) ) {
   dst_val[dst_idx] = dst_val[dst_idx-1];
 }
        nn_dst_val[dst_idx] = nn_dst_val[dst_idx-1];
        continue;
      }
    }
    found = 0;
    for ( ; src_idx < src_nR; ) {
      v_src_lnk = src_lnk[src_idx];
      if ( v_src_lnk == v_dst_lnk ) {
 found = 1;
 prev_val_known = 1;
 break;
      }
      else if ( v_src_lnk > v_dst_lnk ) {
 if ( *ptr_is_any_null == 0 ) {
          *ptr_is_any_null = 1;
 }
 found = 0;
 break;
      }
      long long delta = 1;
      long long expt_src_idx, prev_expt_src_idx;
      prev_expt_src_idx = src_idx + delta;
      for ( ; ; ) {
        expt_src_idx = src_idx + delta;
 if ( expt_src_idx >= src_nR ) {
   expt_src_idx = prev_expt_src_idx;
   break;
 }
        v_src_lnk = src_lnk[expt_src_idx];
        if ( v_src_lnk >= v_dst_lnk ) {
   expt_src_idx = prev_expt_src_idx;
   break;
        }
 else if ( v_src_lnk < v_dst_lnk ) {
   delta *= 2;
          prev_expt_src_idx = expt_src_idx;
        }
      }
      src_idx = expt_src_idx;
    }
    if ( found == 1 ) {
      nn_dst_val[dst_idx] = 1;
      for ( ; src_idx < src_nR; src_idx++ ) {
        v_src_lnk = src_lnk[src_idx];
 if ( v_src_lnk != v_dst_lnk ) {
   src_idx--;
   break;
 }
 if ( src_val != ((void *)0) ) {
   v_src_val = src_val[src_idx];
   switch ( ijoin_op ) {
   case 100 :
     dst_val[dst_idx] += v_src_val;
     break;
   case 300 :
     if ( v_src_val > dst_val[dst_idx] ) {
       dst_val[dst_idx] = v_src_val;
     }
     break;
   case 200 :
     if ( v_src_val < dst_val[dst_idx] ) {
       dst_val[dst_idx] = v_src_val;
     }
     break;
   case 600 :
     dst_val[dst_idx] |= v_src_val;
     break;
   case 700 :
     dst_val[dst_idx] &= v_src_val;
     break;
   case 500 :
     dst_val[dst_idx] = v_src_val;
     break;
   default :
     { { fprintf(stderr, "Line %3d of File %s \n", 216, "./AUX/core_srt_join_I_I_L.c"); }; status = -1 ; goto BYE; };
     break;
   }
 }
 else {
   if ( ijoin_op == 800 ) {
            dst_val[dst_idx] += 1;
   }
 }
      }
    }
    else {
      if ( *ptr_is_any_null == 0 ) {
        *ptr_is_any_null = 1;
      }
      nn_dst_val[dst_idx] = 0;
    }
  }
  if ( *ptr_is_any_null ) {
    for ( long long dst_idx = dst_lb; dst_idx < dst_ub; dst_idx++ ) {
      if ( nn_dst_val[dst_idx] == 0 ) {
 dst_val[dst_idx] = 0;
      }
    }
  }
 BYE:
  return(status);
}

canonical_original_code:
int core_srt_join_I_I_L(int *src_lnk, int *src_val, long long src_nR, long long *dst_lnk, int *dst_val, char *nn_dst_val, long long dst_lb, long long dst_ub, int ijoin_op, _Bool *ptr_is_any_null)
{
  int status = 0;
  long long src_idx;
  long long v_dst_lnk;
  int v_src_val;
  int v_src_lnk;
  _Bool found; _Bool prev_val_known = 0;
  status = set_init(nn_dst_val, dst_val, dst_lb, dst_ub, ijoin_op);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 117, "./AUX/core_srt_join_I_I_L.c"); }; status = (status) ; goto BYE; } } };
  src_idx = 0;
  for ( long long dst_idx = dst_lb; dst_idx < dst_ub; dst_idx++ ) {
    v_dst_lnk = dst_lnk[dst_idx];
    if ( dst_idx > 0 ) {
      if ( v_dst_lnk == dst_lnk[dst_idx-1] ) {
 if ( dst_val != ((void *)0) ) {
   dst_val[dst_idx] = dst_val[dst_idx-1];
 }
        nn_dst_val[dst_idx] = nn_dst_val[dst_idx-1];
        continue;
      }
    }
    found = 0;
    for ( ; src_idx < src_nR; ) {
      v_src_lnk = src_lnk[src_idx];
      if ( v_src_lnk == v_dst_lnk ) {
 found = 1;
 prev_val_known = 1;
 break;
      }
      else if ( v_src_lnk > v_dst_lnk ) {
 if ( *ptr_is_any_null == 0 ) {
          *ptr_is_any_null = 1;
 }
 found = 0;
 break;
      }
      long long delta = 1;
      long long expt_src_idx; long long prev_expt_src_idx;
      prev_expt_src_idx = src_idx + delta;
      for ( ; ; ) {
        expt_src_idx = src_idx + delta;
 if ( expt_src_idx >= src_nR ) {
   expt_src_idx = prev_expt_src_idx;
   break;
 }
        v_src_lnk = src_lnk[expt_src_idx];
        if ( v_src_lnk >= v_dst_lnk ) {
   expt_src_idx = prev_expt_src_idx;
   break;
        }
 else if ( v_src_lnk < v_dst_lnk ) {
   delta *= 2;
          prev_expt_src_idx = expt_src_idx;
        }
      }
      src_idx = expt_src_idx;
    }
    if ( found == 1 ) {
      nn_dst_val[dst_idx] = 1;
      for ( ; src_idx < src_nR; src_idx++ ) {
        v_src_lnk = src_lnk[src_idx];
 if ( v_src_lnk != v_dst_lnk ) {
   src_idx--;
   break;
 }
 if ( src_val != ((void *)0) ) {
   v_src_val = src_val[src_idx];
   switch ( ijoin_op ) {
   case 100 :
     dst_val[dst_idx] += v_src_val;
     break;
   case 300 :
     if ( v_src_val > dst_val[dst_idx] ) {
       dst_val[dst_idx] = v_src_val;
     }
     break;
   case 200 :
     if ( v_src_val < dst_val[dst_idx] ) {
       dst_val[dst_idx] = v_src_val;
     }
     break;
   case 600 :
     dst_val[dst_idx] |= v_src_val;
     break;
   case 700 :
     dst_val[dst_idx] &= v_src_val;
     break;
   case 500 :
     dst_val[dst_idx] = v_src_val;
     break;
   default :
     { { fprintf(stderr, "Line %3d of File %s \n", 216, "./AUX/core_srt_join_I_I_L.c"); }; status = -1 ; goto BYE; };
     break;
   }
 }
 else {
   if ( ijoin_op == 800 ) {
            dst_val[dst_idx] += 1;
   }
 }
      }
    }
    else {
      if ( *ptr_is_any_null == 0 ) {
        *ptr_is_any_null = 1;
      }
      nn_dst_val[dst_idx] = 0;
    }
  }
  if ( *ptr_is_any_null ) {
    for ( long long dst_idx = dst_lb; dst_idx < dst_ub; dst_idx++ ) {
      if ( nn_dst_val[dst_idx] == 0 ) {
 dst_val[dst_idx] = 0;
      }
    }
  }
 BYE:
  return(status);
}

variable_types:
delta
long long


repo: linkedin/datacl

decompiled_code:
__int64 __fastcall set_init(__int64 a1, __int64 a2, __int64 a3, int a4, int a5)
{
__int64 result; // rax
__int64 v9; // rdi

assign_const_I1(a3 + a1, 0LL, (unsigned int)(char)(a4 - a3));
result = 0LL;
if ( a2 )
{
v9 = a2 + 4 * a3;
if ( a5 == 300 )
{
assign_const_I4(v9, 0xFFFFFFFF80000000LL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 > 300 )
{
if ( a5 == 700 )
{
assign_const_I4(v9, 0xFFFFFFFFLL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 <= 700 )
{
if ( a5 != 500 && a5 != 600 )
goto LABEL_7;
}
else if ( a5 != 800 )
{
LABEL_7:
fprintf(stderr, "Line %3d of File %s \n", 67LL, "./AUX/core_srt_join_I_I_L.c");
return 0xFFFFFFFFLL;
}
goto LABEL_13;
}
if ( a5 == 100 )
{
LABEL_13:
assign_const_I4(v9, 0LL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 != 200 )
goto LABEL_7;
assign_const_I4(v9, 0x7FFFFFFFLL, (unsigned int)(a4 - a3));
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, int a4, int a5)
{
__int64 result; // rax
__int64 v9; // rdi

assign_const_I1(a3 + a1, 0LL, (unsigned int)(char)(a4 - a3));
result = 0LL;
if ( a2 )
{
v9 = a2 + 4 * a3;
if ( a5 == 300 )
{
assign_const_I4(v9, 0xFFFFFFFF80000000LL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 > 300 )
{
if ( a5 == 700 )
{
assign_const_I4(v9, 0xFFFFFFFFLL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 <= 700 )
{
if ( a5 != 500 && a5 != 600 )
goto LABEL_7;
}
else if ( a5 != 800 )
{
LABEL_7:
fprintf(stderr, "Line %3d of File %s \n", 67LL, "./AUX/core_srt_join_I_I_L.c");
return 0xFFFFFFFFLL;
}
goto LABEL_13;
}
if ( a5 == 100 )
{
LABEL_13:
assign_const_I4(v9, 0LL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 != 200 )
goto LABEL_7;
assign_const_I4(v9, 0x7FFFFFFFLL, (unsigned int)(a4 - a3));
result = 0LL;
}
return result;
}

original_code:
static int
set_init(
  char *nn_dst_val,
  int *dst_val,
  long long lb,
  long long ub,
  int ijoin_op
  )
{
  int status = 0;
  assign_const_I1(nn_dst_val+lb, 0, (ub-lb));
  if ( dst_val != ((void *)0) ) {
    int *this_dst_val = dst_val;
    this_dst_val += lb;
    switch ( ijoin_op ) {
    case 500 :
    case 100 :
    case 800 :
    case 600 :
      assign_const_I4(this_dst_val, 0, (ub-lb));
      break;
    case 700 :
      assign_const_I4(this_dst_val, 0xFFFFFFFF, (ub-lb));
      break;
    case 200 :
      assign_const_I4(this_dst_val, 0x7fffffff, (ub-lb));
      break;
    case 300 :
      assign_const_I4(this_dst_val, (-0x7fffffff - 1), (ub-lb));
      break;
    default :
      { { fprintf(stderr, "Line %3d of File %s \n", 67, "./AUX/core_srt_join_I_I_L.c"); }; status = -1 ; goto BYE; };
      break;
    }
  }
 BYE:
  return(status);
}

canonical_original_code:
static int set_init(char *nn_dst_val, int *dst_val, long long lb, long long ub, int ijoin_op)
{
  int status = 0;
  assign_const_I1(nn_dst_val+lb, 0, (ub-lb));
  if ( dst_val != ((void *)0) ) {
    int *this_dst_val = dst_val;
    this_dst_val += lb;
    switch ( ijoin_op ) {
    case 500 :
    case 100 :
    case 800 :
    case 600 :
      assign_const_I4(this_dst_val, 0, (ub-lb));
      break;
    case 700 :
      assign_const_I4(this_dst_val, 0xFFFFFFFF, (ub-lb));
      break;
    case 200 :
      assign_const_I4(this_dst_val, 0x7fffffff, (ub-lb));
      break;
    case 300 :
      assign_const_I4(this_dst_val, (-0x7fffffff - 1), (ub-lb));
      break;
    default :
      { { fprintf(stderr, "Line %3d of File %s \n", 67, "./AUX/core_srt_join_I_I_L.c"); }; status = -1 ; goto BYE; };
      break;
    }
  }
 BYE:
  return(status);
}

variable_types:
lb
long long

variable_types:
ub
long long

variable_types: status int

return_type: int


original_code:
int
countf_nn_I1(
  char *fk_fld,
  int *src_fld,
  long long n,
  char *cfld,
  long long * restrict cnt,
  int n_out
  )
{
  int status = 0;
  register char *cptr = cfld;
  for ( long long i = 0; i < n; i++ ) {
    if ( *cptr++ == 0 ) { continue; }
    char idx = fk_fld[i];
    int val = src_fld[i];
    int idxI4 = (int)idx;
    cnt[idxI4] += val;
  }
  return(status);
}

canonical_original_code:
int countf_nn_I1(char *fk_fld, int *src_fld, long long n, char *cfld, long long *cnt, int n_out)
{
  int status = 0;
  register char *cptr = cfld;
  for ( long long i = 0; i < n; i++ ) {
    if ( *cptr++ == 0 ) { continue; }
    char idx = fk_fld[i];
    int val = src_fld[i];
    int idxI4 = (int)idx;
    cnt[idxI4] += val;
  }
  return(status);
}

variable_types:
n
long long

variable_types:
cfld
char *

variable_types:
cnt
long long *

variable_types:
cptr
char *

variable_types:
i
long long

variable_types: idx char

variable_types: val int


decompiled_code:
void __fastcall set_vals_int(_DWORD *a1, int a2)
{
_DWORD *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
*v2++ = mrand48();
while ( v2 != &a1[a2 - 1 + 1] );
}
}

canonical_decompiled_code:
void __fastcall func0(_DWORD *a1, int a2)
{
_DWORD *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
*v2++ = mrand48();
while ( v2 != &a1[a2 - 1 + 1] );
}
}

original_code:
void
set_vals_int(
      int X[],
      int N
      )
{
  for ( int i = 0; i < N; i++ ) {
    X[i] = (int)mrand48();
  }
}

canonical_original_code:
void set_vals_int(int X[], int N)
{
  for ( int i = 0; i < N; i++ ) {
    X[i] = (int)mrand48();
  }
}

variable_types:
X
int []

variable_types: N int

variable_types: i int

return_type: void


original_code:
void
set_vals_longlong(
    long long X[],
    int N
    )
{
  long long minval = 0x7fffffffffffffffLL, maxval = (-0x7fffffffffffffffLL - 1LL);
  for ( int i = 0; i < N; i++ ) {
    X[i] = (long long) mrand48();
    if ( X[i] < 0 ) {
      X[i] = -1 * X[i] * X[i];
    }
    else {
      X[i] = 1 * X[i] * X[i];
    }
    if ( X[i] < minval ) { minval = X[i]; }
    if ( X[i] > maxval ) { maxval = X[i]; }
  }
}

canonical_original_code:
void set_vals_longlong(long long X[], int N)
{
  long long minval = 0x7fffffffffffffffLL; long long maxval = (-0x7fffffffffffffffLL - 1LL);
  for ( int i = 0; i < N; i++ ) {
    X[i] = (long long) mrand48();
    if ( X[i] < 0 ) {
      X[i] = -1 * X[i] * X[i];
    }
    else {
      X[i] = 1 * X[i] * X[i];
    }
    if ( X[i] < minval ) { minval = X[i]; }
    if ( X[i] > maxval ) { maxval = X[i]; }
  }
}

variable_types:
X
long long []

variable_types:
minval
long long

variable_types:
maxval
long long


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_DWORD *v3; // r12
char *v4; // r14
char *v5; // r15
int *v6; // rbx
_QWORD *v7; // rbp
__int64 *v8; // r13
__int64 i; // rax
__int64 j; // rax
__int64 k; // rax
__int64 l; // rax
__int64 m; // rax
__int64 n; // rax
__int64 ii; // rax
__int64 jj; // rax
__int64 v17; // rax
__int64 v18; // rcx
__int64 v19; // rdx
int v20; // edi
__int64 v22; // rax
__int64 v23; // r12
__int64 v24; // rbx
struct timeval *tv; // [rsp+0h] [rbp-78h]
_QWORD *ptr; // [rsp+8h] [rbp-70h]
char *base; // [rsp+10h] [rbp-68h]
int v28; // [rsp+18h] [rbp-60h]
int v29; // [rsp+18h] [rbp-60h]
_DWORD *v30; // [rsp+18h] [rbp-60h]
int v31; // [rsp+20h] [rbp-58h]
int v32; // [rsp+20h] [rbp-58h]
int *v33; // [rsp+20h] [rbp-58h]
void *v34; // [rsp+28h] [rbp-50h]
__int64 v35; // [rsp+30h] [rbp-48h]
__suseconds_t v36; // [rsp+30h] [rbp-48h]
__int64 v37; // [rsp+38h] [rbp-40h]

v3 = malloc(0x400000uLL);
v4 = (char *)malloc(0x400000uLL);
v5 = (char *)malloc(0x400000uLL);
v6 = (int *)malloc(0x400000uLL);
v7 = malloc(0x800000uLL);
v8 = (__int64 *)malloc(0x800000uLL);
ptr = malloc(0x800000uLL);
base = (char *)malloc(0x800000uLL);
for ( i = 0LL; i != 0x100000; ++i )
v6[i] = i;
for ( j = 0LL; j != 0x100000; ++j )
v7[j] = j;
tv = (struct timeval *)malloc(0x10uLL);
if ( !tv )
{
fprintf(stderr, "Line %3d of File %s \n", 105LL, "test_driver_qsort.c");
v34 = 0LL;
v29 = -1;
goto LABEL_68;
}
v34 = malloc(0x10uLL);
if ( !v34 )
{
fprintf(stderr, "Line %3d of File %s \n", 107LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
gettimeofday(tv, 0LL);
srand48(tv->tv_usec);
v31 = 0;
LABEL_8:
v28 = v31 % 12;
switch ( v31 % 12 )
{
case 0:
fwrite("Regular sort --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 1:
fwrite("Sort with integer index --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 2:
fwrite("Sort with long long index --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 3:
case 4:
fwrite("Sort asc int no func --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 5:
fwrite("Sort dsc int no func --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 6:
fwrite("Sort asc longlong no func --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 7:
fwrite("Sort dsc longlong no func --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 8:
fwrite("Sort asc val int idx int --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 9:
fwrite("Sort asc val int idx LL --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 10:
fwrite("Sort asc val LL idx int --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 11:
fwrite("Sort asc val LL idx LL --", 1uLL, 0x1CuLL, stderr);
LABEL_12:
set_vals_int(v3, 0x100000);
set_vals_longlong(v8, 0x100000);
for ( k = 0LL; k != 0x100000; ++k )
*(_DWORD *)&v4[k * 4] = v3[k];
for ( l = 0LL; l != 0x100000; ++l )
*(_DWORD *)&v5[l * 4] = v3[l];
for ( m = 0LL; m != 0x100000; ++m )
v6[m] = m;
for ( n = 0LL; n != 0x100000; ++n )
v7[n] = n;
for ( ii = 0LL; ii != 0x100000; ++ii )
ptr[ii] = v8[ii];
for ( jj = 0LL; jj != 0x100000; ++jj )
*(_QWORD *)&base[jj * 8] = v8[jj];
gettimeofday(tv, 0LL);
v35 = tv->tv_usec + 1000000 * tv->tv_sec;
switch ( v28 )
{
case 0:
case 1:
case 2:
case 4:
case 8:
case 9:
qsort(v5, 0x100000uLL, 4uLL, (__compar_fn_t)&sort_asc_I4);
goto LABEL_37;
case 5:
qsort(v5, 0x100000uLL, 4uLL, (__compar_fn_t)&sort_dsc_I4);
gettimeofday(tv, 0LL);
v36 = tv->tv_usec + 1000000 * tv->tv_sec - v35;
gettimeofday(tv, 0LL);
v37 = tv->tv_usec + 1000000 * tv->tv_sec;
LABEL_39:
qsort_dsc_I4(v4, 0x100000LL, 4LL, 0LL);
goto LABEL_47;
case 6:
qsort(base, 0x100000uLL, 8uLL, (__compar_fn_t)&sort_asc_I8);
gettimeofday(tv, 0LL);
v36 = tv->tv_usec + 1000000 * tv->tv_sec - v35;
gettimeofday(tv, 0LL);
v37 = tv->tv_usec + 1000000 * tv->tv_sec;
LABEL_41:
qsort_asc_I8(ptr, 0x100000LL, 8LL, 0LL);
goto LABEL_47;
case 7:
qsort(base, 0x100000uLL, 8uLL, (__compar_fn_t)&sort_dsc_I8);
gettimeofday(tv, 0LL);
v36 = tv->tv_usec + 1000000 * tv->tv_sec - v35;
gettimeofday(tv, 0LL);
v37 = tv->tv_usec + 1000000 * tv->tv_sec;
LABEL_43:
qsort_dsc_I8(ptr, 0x100000LL, 8LL, 0LL);
LABEL_47:
gettimeofday(tv, 0LL);
v17 = 0LL;
break;
case 10:
case 11:
qsort(base, 0x100000uLL, 8uLL, (__compar_fn_t)&sort_asc_I8);
LABEL_37:
gettimeofday(tv, 0LL);
v36 = tv->tv_usec + 1000000 * tv->tv_sec - v35;
gettimeofday(tv, 0LL);
v37 = tv->tv_usec + 1000000 * tv->tv_sec;
switch ( v28 )
{
case 0:
qsort_with_idx(v6, v4, 0x100000LL, 4LL, &sort_asc_I4);
goto LABEL_47;
case 1:
qsort_with_idx_int(v6, v4, 0x100000LL, 4LL, &sort_asc_I4);
goto LABEL_47;
case 2:
qsort_with_idx_longlong(v7, v4, 0x100000LL, 4LL, &sort_asc_I4);
goto LABEL_47;
case 4:
qsort_asc_I4(v4, 0x100000LL, 4LL, 0LL);
goto LABEL_47;
case 5:
goto LABEL_39;
case 6:
goto LABEL_41;
case 7:
goto LABEL_43;
case 8:
qsort_asc_val_I4_idx_I4(v6, v4, 0x100000LL, 0LL);
goto LABEL_47;
case 9:
qsort_asc_val_I4_idx_I8(v7, v4, 0x100000LL, 0LL);
goto LABEL_47;
case 10:
qsort_asc_val_I8_idx_I4(v6, ptr, 0x100000LL, 0LL);
goto LABEL_47;
case 11:
qsort_asc_val_I8_idx_I8(v7, ptr, 0x100000LL, 0LL);
goto LABEL_47;
default:
fprintf(stderr, "Line %3d of File %s \n", 224LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
default:
fprintf(stderr, "Line %3d of File %s \n", 175LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 132LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
while ( 2 )
{
v20 = v17;
switch ( v28 )
{
case 0:
case 1:
v18 = *(int *)&v4[4 * v17];
v19 = (int)v3[v6[v17]];
goto LABEL_57;
case 2:
v18 = *(int *)&v4[4 * v17];
v19 = (int)v3[v7[v17]];
goto LABEL_57;
case 4:
case 5:
v18 = *(int *)&v4[4 * v17];
v19 = *(int *)&v5[4 * v17];
goto LABEL_57;
case 6:
case 7:
v18 = ptr[v17];
v19 = *(_QWORD *)&base[8 * v17];
goto LABEL_57;
case 8:
v18 = *(int *)&v4[4 * v17];
v19 = (int)v3[v6[v17]];
goto LABEL_57;
case 9:
v18 = *(int *)&v4[4 * v17];
v19 = (int)v3[v7[v17]];
goto LABEL_57;
case 10:
v18 = ptr[v17];
v19 = v8[v6[v17]];
goto LABEL_57;
case 11:
v18 = ptr[v17];
v19 = v8[v7[v17]];
LABEL_57:
if ( v18 == v19 )
{
if ( ++v17 != 0x100000 )
continue;
fprintf(stderr, " t_reg = %lld, t_opt = %lld \n", v36, tv->tv_usec + 1000000 * tv->tv_sec - v37);
if ( ++v31 == 768 )
{
v29 = 0;
goto LABEL_68;
}
goto LABEL_8;
}
v32 = v17;
fprintf(stderr, "mismatch at pos %d \n", (unsigned int)v17);
if ( v20 <= 0xFFFFF )
{
v22 = (unsigned int)(0xFFFFF - v32);
v30 = v3;
v33 = v6;
v23 = v20;
v24 = v20 + v22;
while ( 1 )
{
fprintf(
stderr,
"%d: good = %d, bad = %d \n",
(unsigned int)v23,
*(unsigned int *)&v5[4 * v23],
*(unsigned int *)&v4[4 * v23]);
if ( v23 == v24 )
break;
if ( ++v23 == v20 + 10LL )
{
v3 = v30;
v6 = v33;
goto LABEL_90;
}
}
v3 = v30;
v6 = v33;
}
LABEL_90:
fprintf(stderr, "Line %3d of File %s \n", 281LL, "test_driver_qsort.c");
v29 = -1;
LABEL_68:
free(v6);
free(v7);
if ( v3 )
free(v3);
if ( v4 )
free(v4);
if ( v5 )
free(v5);
if ( v8 )
free(v8);
if ( ptr )
free(ptr);
if ( base )
free(base);
if ( tv )
free(tv);
if ( v34 )
free(v34);
return v29;
default:
fprintf(stderr, "Line %3d of File %s \n", 273LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
}
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_DWORD *v3; // r12
char *v4; // r14
char *v5; // r15
int *v6; // rbx
_QWORD *v7; // rbp
__int64 *v8; // r13
__int64 i; // rax
__int64 j; // rax
__int64 k; // rax
__int64 l; // rax
__int64 m; // rax
__int64 n; // rax
__int64 ii; // rax
__int64 jj; // rax
__int64 v17; // rax
__int64 v18; // rcx
__int64 v19; // rdx
int v20; // edi
__int64 v22; // rax
__int64 v23; // r12
__int64 v24; // rbx
struct timeval *tv; // [rsp+0h] [rbp-78h]
_QWORD *ptr; // [rsp+8h] [rbp-70h]
char *base; // [rsp+10h] [rbp-68h]
int v28; // [rsp+18h] [rbp-60h]
int v29; // [rsp+18h] [rbp-60h]
_DWORD *v30; // [rsp+18h] [rbp-60h]
int v31; // [rsp+20h] [rbp-58h]
int v32; // [rsp+20h] [rbp-58h]
int *v33; // [rsp+20h] [rbp-58h]
void *v34; // [rsp+28h] [rbp-50h]
__int64 v35; // [rsp+30h] [rbp-48h]
__suseconds_t v36; // [rsp+30h] [rbp-48h]
__int64 v37; // [rsp+38h] [rbp-40h]

v3 = malloc(0x400000uLL);
v4 = (char *)malloc(0x400000uLL);
v5 = (char *)malloc(0x400000uLL);
v6 = (int *)malloc(0x400000uLL);
v7 = malloc(0x800000uLL);
v8 = (__int64 *)malloc(0x800000uLL);
ptr = malloc(0x800000uLL);
base = (char *)malloc(0x800000uLL);
for ( i = 0LL; i != 0x100000; ++i )
v6[i] = i;
for ( j = 0LL; j != 0x100000; ++j )
v7[j] = j;
tv = (struct timeval *)malloc(0x10uLL);
if ( !tv )
{
fprintf(stderr, "Line %3d of File %s \n", 105LL, "test_driver_qsort.c");
v34 = 0LL;
v29 = -1;
goto LABEL_68;
}
v34 = malloc(0x10uLL);
if ( !v34 )
{
fprintf(stderr, "Line %3d of File %s \n", 107LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
gettimeofday(tv, 0LL);
srand48(tv->tv_usec);
v31 = 0;
LABEL_8:
v28 = v31 % 12;
switch ( v31 % 12 )
{
case 0:
fwrite("Regular sort --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 1:
fwrite("Sort with integer index --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 2:
fwrite("Sort with long long index --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 3:
case 4:
fwrite("Sort asc int no func --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 5:
fwrite("Sort dsc int no func --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 6:
fwrite("Sort asc longlong no func --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 7:
fwrite("Sort dsc longlong no func --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 8:
fwrite("Sort asc val int idx int --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 9:
fwrite("Sort asc val int idx LL --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 10:
fwrite("Sort asc val LL idx int --", 1uLL, 0x1CuLL, stderr);
goto LABEL_12;
case 11:
fwrite("Sort asc val LL idx LL --", 1uLL, 0x1CuLL, stderr);
LABEL_12:
func0(v3, 0x100000);
func1(v8, 0x100000);
for ( k = 0LL; k != 0x100000; ++k )
*(_DWORD *)&v4[k * 4] = v3[k];
for ( l = 0LL; l != 0x100000; ++l )
*(_DWORD *)&v5[l * 4] = v3[l];
for ( m = 0LL; m != 0x100000; ++m )
v6[m] = m;
for ( n = 0LL; n != 0x100000; ++n )
v7[n] = n;
for ( ii = 0LL; ii != 0x100000; ++ii )
ptr[ii] = v8[ii];
for ( jj = 0LL; jj != 0x100000; ++jj )
*(_QWORD *)&base[jj * 8] = v8[jj];
gettimeofday(tv, 0LL);
v35 = tv->tv_usec + 1000000 * tv->tv_sec;
switch ( v28 )
{
case 0:
case 1:
case 2:
case 4:
case 8:
case 9:
qsort(v5, 0x100000uLL, 4uLL, (__compar_fn_t)&sort_asc_I4);
goto LABEL_37;
case 5:
qsort(v5, 0x100000uLL, 4uLL, (__compar_fn_t)&sort_dsc_I4);
gettimeofday(tv, 0LL);
v36 = tv->tv_usec + 1000000 * tv->tv_sec - v35;
gettimeofday(tv, 0LL);
v37 = tv->tv_usec + 1000000 * tv->tv_sec;
LABEL_39:
qsort_dsc_I4(v4, 0x100000LL, 4LL, 0LL);
goto LABEL_47;
case 6:
qsort(base, 0x100000uLL, 8uLL, (__compar_fn_t)&sort_asc_I8);
gettimeofday(tv, 0LL);
v36 = tv->tv_usec + 1000000 * tv->tv_sec - v35;
gettimeofday(tv, 0LL);
v37 = tv->tv_usec + 1000000 * tv->tv_sec;
LABEL_41:
qsort_asc_I8(ptr, 0x100000LL, 8LL, 0LL);
goto LABEL_47;
case 7:
qsort(base, 0x100000uLL, 8uLL, (__compar_fn_t)&sort_dsc_I8);
gettimeofday(tv, 0LL);
v36 = tv->tv_usec + 1000000 * tv->tv_sec - v35;
gettimeofday(tv, 0LL);
v37 = tv->tv_usec + 1000000 * tv->tv_sec;
LABEL_43:
qsort_dsc_I8(ptr, 0x100000LL, 8LL, 0LL);
LABEL_47:
gettimeofday(tv, 0LL);
v17 = 0LL;
break;
case 10:
case 11:
qsort(base, 0x100000uLL, 8uLL, (__compar_fn_t)&sort_asc_I8);
LABEL_37:
gettimeofday(tv, 0LL);
v36 = tv->tv_usec + 1000000 * tv->tv_sec - v35;
gettimeofday(tv, 0LL);
v37 = tv->tv_usec + 1000000 * tv->tv_sec;
switch ( v28 )
{
case 0:
qsort_with_idx(v6, v4, 0x100000LL, 4LL, &sort_asc_I4);
goto LABEL_47;
case 1:
qsort_with_idx_int(v6, v4, 0x100000LL, 4LL, &sort_asc_I4);
goto LABEL_47;
case 2:
qsort_with_idx_longlong(v7, v4, 0x100000LL, 4LL, &sort_asc_I4);
goto LABEL_47;
case 4:
qsort_asc_I4(v4, 0x100000LL, 4LL, 0LL);
goto LABEL_47;
case 5:
goto LABEL_39;
case 6:
goto LABEL_41;
case 7:
goto LABEL_43;
case 8:
qsort_asc_val_I4_idx_I4(v6, v4, 0x100000LL, 0LL);
goto LABEL_47;
case 9:
qsort_asc_val_I4_idx_I8(v7, v4, 0x100000LL, 0LL);
goto LABEL_47;
case 10:
qsort_asc_val_I8_idx_I4(v6, ptr, 0x100000LL, 0LL);
goto LABEL_47;
case 11:
qsort_asc_val_I8_idx_I8(v7, ptr, 0x100000LL, 0LL);
goto LABEL_47;
default:
fprintf(stderr, "Line %3d of File %s \n", 224LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
default:
fprintf(stderr, "Line %3d of File %s \n", 175LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 132LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
while ( 2 )
{
v20 = v17;
switch ( v28 )
{
case 0:
case 1:
v18 = *(int *)&v4[4 * v17];
v19 = (int)v3[v6[v17]];
goto LABEL_57;
case 2:
v18 = *(int *)&v4[4 * v17];
v19 = (int)v3[v7[v17]];
goto LABEL_57;
case 4:
case 5:
v18 = *(int *)&v4[4 * v17];
v19 = *(int *)&v5[4 * v17];
goto LABEL_57;
case 6:
case 7:
v18 = ptr[v17];
v19 = *(_QWORD *)&base[8 * v17];
goto LABEL_57;
case 8:
v18 = *(int *)&v4[4 * v17];
v19 = (int)v3[v6[v17]];
goto LABEL_57;
case 9:
v18 = *(int *)&v4[4 * v17];
v19 = (int)v3[v7[v17]];
goto LABEL_57;
case 10:
v18 = ptr[v17];
v19 = v8[v6[v17]];
goto LABEL_57;
case 11:
v18 = ptr[v17];
v19 = v8[v7[v17]];
LABEL_57:
if ( v18 == v19 )
{
if ( ++v17 != 0x100000 )
continue;
fprintf(stderr, " t_reg = %lld, t_opt = %lld \n", v36, tv->tv_usec + 1000000 * tv->tv_sec - v37);
if ( ++v31 == 768 )
{
v29 = 0;
goto LABEL_68;
}
goto LABEL_8;
}
v32 = v17;
fprintf(stderr, "mismatch at pos %d \n", (unsigned int)v17);
if ( v20 <= 0xFFFFF )
{
v22 = (unsigned int)(0xFFFFF - v32);
v30 = v3;
v33 = v6;
v23 = v20;
v24 = v20 + v22;
while ( 1 )
{
fprintf(
stderr,
"%d: good = %d, bad = %d \n",
(unsigned int)v23,
*(unsigned int *)&v5[4 * v23],
*(unsigned int *)&v4[4 * v23]);
if ( v23 == v24 )
break;
if ( ++v23 == v20 + 10LL )
{
v3 = v30;
v6 = v33;
goto LABEL_90;
}
}
v3 = v30;
v6 = v33;
}
LABEL_90:
fprintf(stderr, "Line %3d of File %s \n", 281LL, "test_driver_qsort.c");
v29 = -1;
LABEL_68:
free(v6);
free(v7);
if ( v3 )
free(v3);
if ( v4 )
free(v4);
if ( v5 )
free(v5);
if ( v8 )
free(v8);
if ( ptr )
free(ptr);
if ( base )
free(base);
if ( tv )
free(tv);
if ( v34 )
free(v34);
return v29;
default:
fprintf(stderr, "Line %3d of File %s \n", 273LL, "test_driver_qsort.c");
v29 = -1;
goto LABEL_68;
}
}
}

original_code:
int
main()
{
  int status = 0;
  int *X = ((void *)0); int *Y = ((void *)0); int *Z = ((void *)0);
  int *i_srt_ordr = ((void *)0);
  long long *ll_srt_ordr = ((void *)0);
  long long *XLL = ((void *)0); long long *YLL = ((void *)0); long long *ZLL = ((void *)0);
  struct timeval *Tps = ((void *)0), *Tpf = ((void *)0);
  void *Tzp = ((void *)0);
  unsigned long long int t_before_sec = 0, t_before_usec = 0, t_before = 0;
  unsigned long long int t_after_sec, t_after_usec, t_after;
  unsigned long long int t_regular, t_optimized;
  X = (int *)malloc(1*1048576 * sizeof(int));
  Y = (int *)malloc(1*1048576 * sizeof(int));
  Z = (int *)malloc(1*1048576 * sizeof(int));
  i_srt_ordr = (int *)malloc(1*1048576 * sizeof(int));
  ll_srt_ordr = (long long *)malloc(1*1048576 * sizeof(long long));
  XLL = (long long *)malloc(1*1048576 * sizeof(long long));
  YLL = (long long *)malloc(1*1048576 * sizeof(long long));
  ZLL = (long long *)malloc(1*1048576 * sizeof(long long));
  for ( int i = 0; i < 1*1048576; i++ ) { i_srt_ordr[i] = i; }
  for ( int i = 0; i < 1*1048576; i++ ) { ll_srt_ordr[i] = i; }
  Tps = (struct timeval *) malloc(sizeof(struct timeval));
  if ( Tps == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 105, "test_driver_qsort.c"); }; status = -1 ; goto BYE; }; }
  Tpf = (struct timeval *) malloc(sizeof(struct timeval));
  if ( Tpf == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 107, "test_driver_qsort.c"); }; status = -1 ; goto BYE; }; }
  Tzp = 0;
  gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
  t_before_sec = (long long int)Tps->tv_sec;
  t_before_usec = (long long int)Tps->tv_usec;
  t_before = t_before_sec * 1000000 + t_before_usec;
  srand48(t_before_usec);
  for ( int iters = 0; iters < 12*64; iters++ ) {
    int itype = iters % 12;
    switch ( itype ) {
      case 0 : fprintf(stderr, "Regular sort              --"); break;
      case 1 : fprintf(stderr, "Sort with integer index   --"); break;
      case 2 : fprintf(stderr, "Sort with long long index --"); break;
      case 3 : fprintf(stderr, "Sort asc int no func      --"); break;
      case 4 : fprintf(stderr, "Sort asc int no func      --"); break;
      case 5 : fprintf(stderr, "Sort dsc int no func      --"); break;
      case 6 : fprintf(stderr, "Sort asc longlong no func --"); break;
      case 7 : fprintf(stderr, "Sort dsc longlong no func --"); break;
      case 8 : fprintf(stderr, "Sort asc val int idx int  --"); break;
      case 9 : fprintf(stderr, "Sort asc val int idx LL   --"); break;
      case 10 : fprintf(stderr, "Sort asc val LL  idx int  --"); break;
      case 11 : fprintf(stderr, "Sort asc val LL  idx LL   --"); break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 132, "test_driver_qsort.c"); }; status = -1 ; goto BYE; }; break;
    }
    set_vals_int(X, 1*1048576);
    set_vals_longlong(XLL, 1*1048576);
    for ( int i = 0; i < 1*1048576; i++ ) { Y[i] = X[i]; }
    for ( int i = 0; i < 1*1048576; i++ ) { Z[i] = X[i]; }
    for ( int i = 0; i < 1*1048576; i++ ) { i_srt_ordr[i] = i; }
    for ( int i = 0; i < 1*1048576; i++ ) { ll_srt_ordr[i] = i; }
    for ( int i = 0; i < 1*1048576; i++ ) { YLL[i] = XLL[i]; }
    for ( int i = 0; i < 1*1048576; i++ ) { ZLL[i] = XLL[i]; }
    gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
    t_before_sec = (long long int)Tps->tv_sec;
    t_before_usec = (long long int)Tps->tv_usec;
    t_before = t_before_sec * 1000000 + t_before_usec;
    switch ( itype ) {
      case 0 :
      case 1 :
      case 2 :
      case 4 :
        qsort(Z, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 5 :
        qsort(Z, 1*1048576, sizeof(int), sort_dsc_I4);
 break;
      case 6 :
        qsort(ZLL, 1*1048576, sizeof(long long), sort_asc_I8);
 break;
      case 7 :
        qsort(ZLL, 1*1048576, sizeof(long long), sort_dsc_I8);
 break;
      case 8 :
      case 9 :
        qsort(Z, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 10 :
      case 11 :
        qsort(ZLL, 1*1048576, sizeof(long long), sort_asc_I8);
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 175, "test_driver_qsort.c"); }; status = -1 ; goto BYE; };
 break;
    }
    gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
    t_after_sec = (long long int)Tps->tv_sec;
    t_after_usec = (long long int)Tps->tv_usec;
    t_after = t_after_sec * 1000000 + t_after_usec;
    t_regular = t_after - t_before;
    gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
    t_before_sec = (long long int)Tps->tv_sec;
    t_before_usec = (long long int)Tps->tv_usec;
    t_before = t_before_sec * 1000000 + t_before_usec;
    switch ( itype ) {
      case 0 :
        qsort_with_idx(i_srt_ordr, Y, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 1 :
        qsort_with_idx_int(i_srt_ordr, Y, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 2 :
        qsort_with_idx_longlong(ll_srt_ordr, Y, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 4 :
        qsort_asc_I4(Y, 1*1048576, sizeof(int), ((void *)0));
 break;
      case 5 :
        qsort_dsc_I4(Y, 1*1048576, sizeof(int), ((void *)0));
 break;
      case 6 :
        qsort_asc_I8(YLL, 1*1048576, sizeof(long long), ((void *)0));
 break;
      case 7 :
        qsort_dsc_I8(YLL, 1*1048576, sizeof(long long), ((void *)0));
 break;
      case 8 :
        qsort_asc_val_I4_idx_I4(i_srt_ordr, (void *)Y, 1*1048576, ((void *)0));
 break;
      case 9 :
        qsort_asc_val_I4_idx_I8(ll_srt_ordr, Y, 1*1048576, ((void *)0));
 break;
      case 10 :
        qsort_asc_val_I8_idx_I4(i_srt_ordr, YLL, 1*1048576, ((void *)0));
 break;
      case 11 :
        qsort_asc_val_I8_idx_I8(ll_srt_ordr, YLL, 1*1048576, ((void *)0));
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 224, "test_driver_qsort.c"); }; status = -1 ; goto BYE; };
 break;
    }
    gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
    t_after_sec = (long long int)Tps->tv_sec;
    t_after_usec = (long long int)Tps->tv_usec;
    t_after = t_after_sec * 1000000 + t_after_usec;
    t_optimized = t_after - t_before;
    for ( int i = 0; i < 1*1048576; i++ ) {
      long long val1, val2;
      switch ( itype ) {
 case 0 :
 case 1 :
        val1 = Y[i];
        val2 = X[i_srt_ordr[i]];
 break;
 case 2 :
        val1 = Y[i];
        val2 = X[ll_srt_ordr[i]];
 break;
 case 4 :
 case 5 :
        val1 = Y[i];
        val2 = Z[i];
 break;
 case 6 :
 case 7 :
        val1 = YLL[i];
 val2 = ZLL[i];
 break;
 case 8 :
        val1 = Y[i];
        val2 = X[i_srt_ordr[i]];
 break;
 case 9 :
        val1 = Y[i];
        val2 = X[ll_srt_ordr[i]];
 break;
 case 10 :
        val1 = YLL[i];
        val2 = XLL[i_srt_ordr[i]];
 break;
 case 11 :
        val1 = YLL[i];
        val2 = XLL[ll_srt_ordr[i]];
 break;
 default :
 { { fprintf(stderr, "Line %3d of File %s \n", 273, "test_driver_qsort.c"); }; status = -1 ; goto BYE; };
 break;
      }
      if ( val1 != val2 ) {
 fprintf(stderr, "mismatch at pos %d \n", i);
        for ( int j = i; (( j < 1*1048576 ) && ( j < i + 10 )); j++ ) {
   fprintf(stderr, "%d: good =  %d, bad = %d \n", j, Z[j], Y[j]);
 }
 { { fprintf(stderr, "Line %3d of File %s \n", 281, "test_driver_qsort.c"); }; status = -1 ; goto BYE; };
      }
    }
    fprintf(stderr, " t_reg = %lld, t_opt = %lld \n", t_regular, t_optimized);
  }
 BYE:
  { if ( (i_srt_ordr) != ((void *)0) ) { free((i_srt_ordr)); (i_srt_ordr) = ((void *)0); } };
  { if ( (ll_srt_ordr) != ((void *)0) ) { free((ll_srt_ordr)); (ll_srt_ordr) = ((void *)0); } };
  { if ( (X) != ((void *)0) ) { free((X)); (X) = ((void *)0); } };
  { if ( (Y) != ((void *)0) ) { free((Y)); (Y) = ((void *)0); } };
  { if ( (Z) != ((void *)0) ) { free((Z)); (Z) = ((void *)0); } };
  { if ( (XLL) != ((void *)0) ) { free((XLL)); (XLL) = ((void *)0); } };
  { if ( (YLL) != ((void *)0) ) { free((YLL)); (YLL) = ((void *)0); } };
  { if ( (ZLL) != ((void *)0) ) { free((ZLL)); (ZLL) = ((void *)0); } };
  { if ( (Tps) != ((void *)0) ) { free((Tps)); (Tps) = ((void *)0); } };
  { if ( (Tpf) != ((void *)0) ) { free((Tpf)); (Tpf) = ((void *)0); } };
  return(status);
}

canonical_original_code:
int main()
{
  int status = 0;
  int *X = ((void *)0); int *Y = ((void *)0); int *Z = ((void *)0);
  int *i_srt_ordr = ((void *)0);
  long long *ll_srt_ordr = ((void *)0);
  long long *XLL = ((void *)0); long long *YLL = ((void *)0); long long *ZLL = ((void *)0);
  struct timeval *Tps = ((void *)0); struct timeval *Tpf = ((void *)0);
  void *Tzp = ((void *)0);
  unsigned long long t_before_sec = 0; unsigned long long t_before_usec = 0; unsigned long long t_before = 0;
  unsigned long long t_after_sec; unsigned long long t_after_usec; unsigned long long t_after;
  unsigned long long t_regular; unsigned long long t_optimized;
  X = (int *)malloc(1*1048576 * sizeof(int));
  Y = (int *)malloc(1*1048576 * sizeof(int));
  Z = (int *)malloc(1*1048576 * sizeof(int));
  i_srt_ordr = (int *)malloc(1*1048576 * sizeof(int));
  ll_srt_ordr = (long long *)malloc(1*1048576 * sizeof(long long));
  XLL = (long long *)malloc(1*1048576 * sizeof(long long));
  YLL = (long long *)malloc(1*1048576 * sizeof(long long));
  ZLL = (long long *)malloc(1*1048576 * sizeof(long long));
  for ( int i = 0; i < 1*1048576; i++ ) { i_srt_ordr[i] = i; }
  for ( int i = 0; i < 1*1048576; i++ ) { ll_srt_ordr[i] = i; }
  Tps = (struct timeval *) malloc(sizeof(struct timeval));
  if ( Tps == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 105, "test_driver_qsort.c"); }; status = -1 ; goto BYE; }; }
  Tpf = (struct timeval *) malloc(sizeof(struct timeval));
  if ( Tpf == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 107, "test_driver_qsort.c"); }; status = -1 ; goto BYE; }; }
  Tzp = 0;
  gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
  t_before_sec = (long long)Tps->tv_sec;
  t_before_usec = (long long)Tps->tv_usec;
  t_before = t_before_sec * 1000000 + t_before_usec;
  srand48(t_before_usec);
  for ( int iters = 0; iters < 12*64; iters++ ) {
    int itype = iters % 12;
    switch ( itype ) {
      case 0 : fprintf(stderr, "Regular sort              --"); break;
      case 1 : fprintf(stderr, "Sort with integer index   --"); break;
      case 2 : fprintf(stderr, "Sort with long long index --"); break;
      case 3 : fprintf(stderr, "Sort asc int no func      --"); break;
      case 4 : fprintf(stderr, "Sort asc int no func      --"); break;
      case 5 : fprintf(stderr, "Sort dsc int no func      --"); break;
      case 6 : fprintf(stderr, "Sort asc longlong no func --"); break;
      case 7 : fprintf(stderr, "Sort dsc longlong no func --"); break;
      case 8 : fprintf(stderr, "Sort asc val int idx int  --"); break;
      case 9 : fprintf(stderr, "Sort asc val int idx LL   --"); break;
      case 10 : fprintf(stderr, "Sort asc val LL  idx int  --"); break;
      case 11 : fprintf(stderr, "Sort asc val LL  idx LL   --"); break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 132, "test_driver_qsort.c"); }; status = -1 ; goto BYE; }; break;
    }
    set_vals_int(X, 1*1048576);
    set_vals_longlong(XLL, 1*1048576);
    for ( int i = 0; i < 1*1048576; i++ ) { Y[i] = X[i]; }
    for ( int i = 0; i < 1*1048576; i++ ) { Z[i] = X[i]; }
    for ( int i = 0; i < 1*1048576; i++ ) { i_srt_ordr[i] = i; }
    for ( int i = 0; i < 1*1048576; i++ ) { ll_srt_ordr[i] = i; }
    for ( int i = 0; i < 1*1048576; i++ ) { YLL[i] = XLL[i]; }
    for ( int i = 0; i < 1*1048576; i++ ) { ZLL[i] = XLL[i]; }
    gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
    t_before_sec = (long long)Tps->tv_sec;
    t_before_usec = (long long)Tps->tv_usec;
    t_before = t_before_sec * 1000000 + t_before_usec;
    switch ( itype ) {
      case 0 :
      case 1 :
      case 2 :
      case 4 :
        qsort(Z, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 5 :
        qsort(Z, 1*1048576, sizeof(int), sort_dsc_I4);
 break;
      case 6 :
        qsort(ZLL, 1*1048576, sizeof(long long), sort_asc_I8);
 break;
      case 7 :
        qsort(ZLL, 1*1048576, sizeof(long long), sort_dsc_I8);
 break;
      case 8 :
      case 9 :
        qsort(Z, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 10 :
      case 11 :
        qsort(ZLL, 1*1048576, sizeof(long long), sort_asc_I8);
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 175, "test_driver_qsort.c"); }; status = -1 ; goto BYE; };
 break;
    }
    gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
    t_after_sec = (long long)Tps->tv_sec;
    t_after_usec = (long long)Tps->tv_usec;
    t_after = t_after_sec * 1000000 + t_after_usec;
    t_regular = t_after - t_before;
    gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
    t_before_sec = (long long)Tps->tv_sec;
    t_before_usec = (long long)Tps->tv_usec;
    t_before = t_before_sec * 1000000 + t_before_usec;
    switch ( itype ) {
      case 0 :
        qsort_with_idx(i_srt_ordr, Y, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 1 :
        qsort_with_idx_int(i_srt_ordr, Y, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 2 :
        qsort_with_idx_longlong(ll_srt_ordr, Y, 1*1048576, sizeof(int), sort_asc_I4);
 break;
      case 4 :
        qsort_asc_I4(Y, 1*1048576, sizeof(int), ((void *)0));
 break;
      case 5 :
        qsort_dsc_I4(Y, 1*1048576, sizeof(int), ((void *)0));
 break;
      case 6 :
        qsort_asc_I8(YLL, 1*1048576, sizeof(long long), ((void *)0));
 break;
      case 7 :
        qsort_dsc_I8(YLL, 1*1048576, sizeof(long long), ((void *)0));
 break;
      case 8 :
        qsort_asc_val_I4_idx_I4(i_srt_ordr, (void *)Y, 1*1048576, ((void *)0));
 break;
      case 9 :
        qsort_asc_val_I4_idx_I8(ll_srt_ordr, Y, 1*1048576, ((void *)0));
 break;
      case 10 :
        qsort_asc_val_I8_idx_I4(i_srt_ordr, YLL, 1*1048576, ((void *)0));
 break;
      case 11 :
        qsort_asc_val_I8_idx_I8(ll_srt_ordr, YLL, 1*1048576, ((void *)0));
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 224, "test_driver_qsort.c"); }; status = -1 ; goto BYE; };
 break;
    }
    gettimeofday ((struct timeval *)Tps, (struct timezone *)Tzp);
    t_after_sec = (long long)Tps->tv_sec;
    t_after_usec = (long long)Tps->tv_usec;
    t_after = t_after_sec * 1000000 + t_after_usec;
    t_optimized = t_after - t_before;
    for ( int i = 0; i < 1*1048576; i++ ) {
      long long val1; long long val2;
      switch ( itype ) {
 case 0 :
 case 1 :
        val1 = Y[i];
        val2 = X[i_srt_ordr[i]];
 break;
 case 2 :
        val1 = Y[i];
        val2 = X[ll_srt_ordr[i]];
 break;
 case 4 :
 case 5 :
        val1 = Y[i];
        val2 = Z[i];
 break;
 case 6 :
 case 7 :
        val1 = YLL[i];
 val2 = ZLL[i];
 break;
 case 8 :
        val1 = Y[i];
        val2 = X[i_srt_ordr[i]];
 break;
 case 9 :
        val1 = Y[i];
        val2 = X[ll_srt_ordr[i]];
 break;
 case 10 :
        val1 = YLL[i];
        val2 = XLL[i_srt_ordr[i]];
 break;
 case 11 :
        val1 = YLL[i];
        val2 = XLL[ll_srt_ordr[i]];
 break;
 default :
 { { fprintf(stderr, "Line %3d of File %s \n", 273, "test_driver_qsort.c"); }; status = -1 ; goto BYE; };
 break;
      }
      if ( val1 != val2 ) {
 fprintf(stderr, "mismatch at pos %d \n", i);
        for ( int j = i; (( j < 1*1048576 ) && ( j < i + 10 )); j++ ) {
   fprintf(stderr, "%d: good =  %d, bad = %d \n", j, Z[j], Y[j]);
 }
 { { fprintf(stderr, "Line %3d of File %s \n", 281, "test_driver_qsort.c"); }; status = -1 ; goto BYE; };
      }
    }
    fprintf(stderr, " t_reg = %lld, t_opt = %lld \n", t_regular, t_optimized);
  }
 BYE:
  { if ( (i_srt_ordr) != ((void *)0) ) { free((i_srt_ordr)); (i_srt_ordr) = ((void *)0); } };
  { if ( (ll_srt_ordr) != ((void *)0) ) { free((ll_srt_ordr)); (ll_srt_ordr) = ((void *)0); } };
  { if ( (X) != ((void *)0) ) { free((X)); (X) = ((void *)0); } };
  { if ( (Y) != ((void *)0) ) { free((Y)); (Y) = ((void *)0); } };
  { if ( (Z) != ((void *)0) ) { free((Z)); (Z) = ((void *)0); } };
  { if ( (XLL) != ((void *)0) ) { free((XLL)); (XLL) = ((void *)0); } };
  { if ( (YLL) != ((void *)0) ) { free((YLL)); (YLL) = ((void *)0); } };
  { if ( (ZLL) != ((void *)0) ) { free((ZLL)); (ZLL) = ((void *)0); } };
  { if ( (Tps) != ((void *)0) ) { free((Tps)); (Tps) = ((void *)0); } };
  { if ( (Tpf) != ((void *)0) ) { free((Tpf)); (Tpf) = ((void *)0); } };
  return(status);
}

variable_types:
X
int *

variable_types:
Y
int *

variable_types:
Z
int *

variable_types:
XLL
long long *

variable_types:
YLL
long long *

variable_types:
ZLL
long long *

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

variable_types:
Tzp
void *

variable_types: iters int

variable_types: itype int

variable_types: j int

user_defined_types: struct timezone { int tz_minuteswest; int tz_dsttime; }


decompiled_code:
__int64 __fastcall pr_min_max_sum(const char *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14, int a15, int a16, int a17, int a18, unsigned int a19, int a20, int a21, int a22, int a23, int a24, double a25, double a26, double a27, int a28)
{
bool v20; // zf
_BOOL4 v21; // ebx
double v22; // rdx

v20 = strcmp(a1, "min") == 0;
v21 = !v20;
if ( !v20 )
{
v20 = strcmp(a1, "max") == 0;
v21 = !v20;
if ( v20 )
{
if ( BYTE2(a28) )
{
v22 = a27;
if ( a19 <= 5 )
{
if ( a19 > 1 )
goto LABEL_27;
}
else if ( a19 - 6 <= 1 )
{
fprintf(g_ofp, "%lf", a27);
return v21;
}
fprintf(stderr, "Line %3d of File %s \n", 49LL, "fld_meta.c");
return -1;
}
}
else
{
v20 = strcmp(a1, "sum") == 0;
v21 = !v20;
if ( !v20 )
{
fprintf(stderr, "Line %3d of File %s \n", 76LL, "fld_meta.c");
return -1;
}
if ( (_BYTE)a28 )
{
v22 = a25;
if ( a19 <= 5 )
{
if ( a19 > 1 )
goto LABEL_27;
}
else if ( a19 - 6 <= 1 )
{
fprintf(g_ofp, "%lf", a25);
return v21;
}
fprintf(stderr, "Line %3d of File %s \n", 67LL, "fld_meta.c");
return -1;
}
}
LABEL_9:
fwrite("undef", 1uLL, 5uLL, g_ofp);
return v21;
}
if ( !BYTE1(a28) )
goto LABEL_9;
v22 = a26;
if ( a19 <= 5 )
{
if ( a19 <= 1 )
goto LABEL_7;
LABEL_27:
fprintf(g_ofp, "%lld", *(_QWORD *)&v22);
return v21;
}
if ( a19 - 6 > 1 )
{
LABEL_7:
fprintf(stderr, "Line %3d of File %s \n", 31LL, "fld_meta.c");
return -1;
}
fprintf(g_ofp, "%lf", a26);
return v21;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, double a7, double a8, double a9, double a10, double a11, double a12, double a13, double a14, int a15, int a16, int a17, int a18, unsigned int a19, int a20, int a21, int a22, int a23, int a24, double a25, double a26, double a27, int a28)
{
bool v20; // zf
_BOOL4 v21; // ebx
double v22; // rdx

v20 = strcmp(a1, "min") == 0;
v21 = !v20;
if ( !v20 )
{
v20 = strcmp(a1, "max") == 0;
v21 = !v20;
if ( v20 )
{
if ( BYTE2(a28) )
{
v22 = a27;
if ( a19 <= 5 )
{
if ( a19 > 1 )
goto LABEL_27;
}
else if ( a19 - 6 <= 1 )
{
fprintf(g_ofp, "%lf", a27);
return v21;
}
fprintf(stderr, "Line %3d of File %s \n", 49LL, "fld_meta.c");
return -1;
}
}
else
{
v20 = strcmp(a1, "sum") == 0;
v21 = !v20;
if ( !v20 )
{
fprintf(stderr, "Line %3d of File %s \n", 76LL, "fld_meta.c");
return -1;
}
if ( (_BYTE)a28 )
{
v22 = a25;
if ( a19 <= 5 )
{
if ( a19 > 1 )
goto LABEL_27;
}
else if ( a19 - 6 <= 1 )
{
fprintf(g_ofp, "%lf", a25);
return v21;
}
fprintf(stderr, "Line %3d of File %s \n", 67LL, "fld_meta.c");
return -1;
}
}
LABEL_9:
fwrite("undef", 1uLL, 5uLL, g_ofp);
return v21;
}
if ( !BYTE1(a28) )
goto LABEL_9;
v22 = a26;
if ( a19 <= 5 )
{
if ( a19 <= 1 )
goto LABEL_7;
LABEL_27:
fprintf(g_ofp, "%lld", *(_QWORD *)&v22);
return v21;
}
if ( a19 - 6 > 1 )
{
LABEL_7:
fprintf(stderr, "Line %3d of File %s \n", 31LL, "fld_meta.c");
return -1;
}
fprintf(g_ofp, "%lf", a26);
return v21;
}

original_code:
int
pr_min_max_sum(
        char *mode,
        FLD_REC_TYPE fld_rec
        )
{
  int status = 0;
  if ( strcmp(mode, "min") == 0 ) {
    if ( fld_rec.is_min_nn == 1 ) {
      switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 :
 fprintf(g_ofp, "%lld", fld_rec.minval.minI8);
 break;
      case F4 : case F8 :
 fprintf(g_ofp, "%lf", fld_rec.minval.minF8);
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 31, "fld_meta.c"); }; status = -1 ; goto BYE; };
 break;
      }
    }
    else {
      fprintf(g_ofp, "undef");
    }
  }
  else if ( strcmp(mode, "max") == 0 ) {
    if ( fld_rec.is_max_nn == 1 ) {
      switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 :
 fprintf(g_ofp, "%lld", fld_rec.maxval.maxI8);
 break;
      case F4 : case F8 :
 fprintf(g_ofp, "%lf", fld_rec.maxval.maxF8);
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 49, "fld_meta.c"); }; status = -1 ; goto BYE; };
 break;
      }
    }
    else {
      fprintf(g_ofp, "undef");
    }
  }
  else if ( strcmp(mode, "sum") == 0 ) {
    if ( fld_rec.is_sum_nn == 1 ) {
      switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 :
 fprintf(g_ofp, "%lld", fld_rec.sumval.sumI8);
 break;
      case F4 : case F8 :
 fprintf(g_ofp, "%lf", fld_rec.sumval.sumF8);
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 67, "fld_meta.c"); }; status = -1 ; goto BYE; };
 break;
      }
    }
    else {
      fprintf(g_ofp, "undef");
    }
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 76, "fld_meta.c"); }; status = -1 ; goto BYE; };
  }
 BYE:
  return status ;
}

canonical_original_code:
int pr_min_max_sum(char *mode, struct _FLD_REC_TYPE fld_rec)
{
  int status = 0;
  if ( strcmp(mode, "min") == 0 ) {
    if ( fld_rec.is_min_nn == 1 ) {
      switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 :
 fprintf(g_ofp, "%lld", fld_rec.minval.minI8);
 break;
      case F4 : case F8 :
 fprintf(g_ofp, "%lf", fld_rec.minval.minF8);
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 31, "fld_meta.c"); }; status = -1 ; goto BYE; };
 break;
      }
    }
    else {
      fprintf(g_ofp, "undef");
    }
  }
  else if ( strcmp(mode, "max") == 0 ) {
    if ( fld_rec.is_max_nn == 1 ) {
      switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 :
 fprintf(g_ofp, "%lld", fld_rec.maxval.maxI8);
 break;
      case F4 : case F8 :
 fprintf(g_ofp, "%lf", fld_rec.maxval.maxF8);
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 49, "fld_meta.c"); }; status = -1 ; goto BYE; };
 break;
      }
    }
    else {
      fprintf(g_ofp, "undef");
    }
  }
  else if ( strcmp(mode, "sum") == 0 ) {
    if ( fld_rec.is_sum_nn == 1 ) {
      switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 :
 fprintf(g_ofp, "%lld", fld_rec.sumval.sumI8);
 break;
      case F4 : case F8 :
 fprintf(g_ofp, "%lf", fld_rec.sumval.sumF8);
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 67, "fld_meta.c"); }; status = -1 ; goto BYE; };
 break;
      }
    }
    else {
      fprintf(g_ofp, "undef");
    }
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 76, "fld_meta.c"); }; status = -1 ; goto BYE; };
  }
 BYE:
  return status ;
}

variable_types:
mode
char *

variable_types: struct _FLD_REC_TYPE { short tbl_id; short ddir_id; short parent_id; short nn_fld_id; short len; unsigned long filesz; _Bool is_external; enum _SORT_TYPE { unknown=0, ascending=1, descending=2, unsorted=3 } srttype; enum _FLD_TYPE { undef_fldtype=0, B=1, I1=2, I2=3, I4=4, I8=5, F4=6, F8=7, SC=8, SV=9 } fldtype; enum _AUX_TYPE { undef_auxtype=0, nn=1, len=2, off=3 } auxtype; char name[-1]; int fileno; union sumval { long long sumI8; double sumF8; } sumval; union minval { long long minI8; double minF8; } minval; union maxval { long long maxI8; double maxF8; } maxval; _Bool is_sum_nn; _Bool is_min_nn; _Bool is_max_nn; long long num_nn; }

variable_types: status int

user_defined_types: struct _FLD_REC_TYPE { short tbl_id; short ddir_id; short parent_id; short nn_fld_id; short len; unsigned long filesz; _Bool is_external; enum _SORT_TYPE srttype; enum _FLD_TYPE fldtype; enum _AUX_TYPE auxtype; char name[-1]; int fileno; union sumval sumval; union minval minval; union maxval maxval; _Bool is_sum_nn; _Bool is_min_nn; _Bool is_max_nn; long long num_nn; }


original_code:
int
fld_meta(
  const char *tbl,
  const char *fld,
  const char *what_to_pr,
  int *ptr_fld_id,
  _Bool is_print
  )
{
  int status = 0;
  int tbl_id = -1; TBL_REC_TYPE tbl_rec;
  int fld_id = -1; FLD_REC_TYPE fld_rec;
  int nn_fld_id = -1; FLD_REC_TYPE nn_fld_rec;
  char str_fldtype[32]; zero_string(str_fldtype, 32);
  char str_auxtype[32]; zero_string(str_auxtype, 32);
  char str_srttype[32]; zero_string(str_srttype, 32);
  _Bool all_digits = 1;
  *ptr_fld_id = -1;
  zero_string(str_fldtype, 32);
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 106, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 107, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 109, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  if ( tbl_id < 0 ) {
    return status ;
  }
  for ( char *cptr = (char *)fld; *cptr != '\0' ; cptr++ ) {
    if ( !((*__ctype_b_loc ())[(int) ((*cptr))] & (unsigned short int) _ISdigit) ) { all_digits = 0; }
  }
  if ( all_digits ) {
    status = stoI4(fld, &fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 117, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 118, "fld_meta.c"); }; status = -1 ; goto BYE; }; } };
    if ( g_flds[fld_id].name[0] == '\0' ) {
      return status ;
    }
    fld_rec = g_flds[fld_id];
  }
  else {
    status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec, &nn_fld_id,
      &nn_fld_rec);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 127, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  *ptr_fld_id = fld_id;
  if ( fld_id < 0 ) {
    return status ;
  }
  if ( is_print == 0 ) {
    return status ;
  }
  if ( strcmp(what_to_pr, "name") == 0 ) {
    fprintf(g_ofp, "%s", fld_rec.name);
  }
  else if ( strcmp(what_to_pr, "file") == 0 ) {
    fprintf(g_ofp, "%d", fld_rec.fileno);
  }
  else if ( strcmp(what_to_pr, "filesz") == 0 ) {
    fprintf(g_ofp, "%llu", (unsigned long long)fld_rec.filesz);
  }
  else if ( strcmp(what_to_pr, "external") == 0 ) {
    fprintf(g_ofp, "%d", fld_rec.is_external);
  }
  else if ( strcmp(what_to_pr, "min") == 0 ) {
    status = pr_min_max_sum("min", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 150, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(what_to_pr, "max") == 0 ) {
    status = pr_min_max_sum("max", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 153, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(what_to_pr, "sum") == 0 ) {
    status = pr_min_max_sum("sum", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 156, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(what_to_pr, "len") == 0 ) {
    if ( fld_rec.fldtype == SC ) {
      fprintf(g_ofp, "%d", fld_rec.len);
    }
    else {
      { { fprintf(stderr, "Line %3d of File %s \n", 163, "fld_meta.c"); }; status = -1 ; goto BYE; };
    }
  }
  else if ( strcmp(what_to_pr, "fldtype") == 0 ) {
    status = mk_str_fldtype(fld_rec.fldtype, str_fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 167, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s", str_fldtype);
  }
  else if ( strcmp(what_to_pr, "auxtype") == 0 ) {
    status = mk_str_auxtype(fld_rec.auxtype, str_auxtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 171, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s", str_auxtype);
  }
  else if ( strcmp(what_to_pr, "srttype") == 0 ) {
    status = mk_str_srttype(fld_rec.srttype, str_srttype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 175, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s", str_srttype);
  }
  else {
    fprintf(g_ofp, "id,name,fileno,external,num_nn,min,max,sum,len,filesz,fldtype,auxtype,srttype\n");
    fprintf(g_ofp, "%d,", fld_id);
    fprintf(g_ofp, "%s,", fld_rec.name);
    fprintf(g_ofp, "%d,", fld_rec.fileno);
    fprintf(g_ofp, "%d,", fld_rec.is_external);
    if ( fld_rec.num_nn < 0 ) {
      fprintf(g_ofp, "undef"); fprintf(g_ofp, ",");
    }
    else {
      fprintf(g_ofp, "%lld", fld_rec.num_nn); fprintf(g_ofp, ",");
    }
    status = pr_min_max_sum("min", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 190, "fld_meta.c"); }; status = (status) ; goto BYE; } } }; fprintf(g_ofp, ",");
    status = pr_min_max_sum("max", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 191, "fld_meta.c"); }; status = (status) ; goto BYE; } } }; fprintf(g_ofp, ",");
    status = pr_min_max_sum("sum", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 192, "fld_meta.c"); }; status = (status) ; goto BYE; } } }; fprintf(g_ofp, ",");
    if ( fld_rec.fldtype == SC ) {
      fprintf(g_ofp, "%d,", fld_rec.len);
    }
    else {
      fprintf(g_ofp, "0,");
    }
    fprintf(g_ofp, "%llu,", (unsigned long long)fld_rec.filesz);
    status = mk_str_fldtype(fld_rec.fldtype, str_fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 200, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s,", str_fldtype);
    status = mk_str_auxtype(fld_rec.auxtype, str_auxtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 202, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s,", str_auxtype);
    status = mk_str_srttype(fld_rec.srttype, str_srttype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 204, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s\n", str_srttype);
  }
 BYE:
  return status ;
}

canonical_original_code:
int fld_meta(char *tbl, char *fld, char *what_to_pr, int *ptr_fld_id, _Bool is_print)
{
  int status = 0;
  int tbl_id = -1; struct _TBL_REC_TYPE tbl_rec;
  int fld_id = -1; struct _FLD_REC_TYPE fld_rec;
  int nn_fld_id = -1; struct _FLD_REC_TYPE nn_fld_rec;
  char str_fldtype[32]; zero_string(str_fldtype, 32);
  char str_auxtype[32]; zero_string(str_auxtype, 32);
  char str_srttype[32]; zero_string(str_srttype, 32);
  _Bool all_digits = 1;
  *ptr_fld_id = -1;
  zero_string(str_fldtype, 32);
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 106, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 107, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 109, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  if ( tbl_id < 0 ) {
    return status ;
  }
  for ( char *cptr = (char *)fld; *cptr != '\0' ; cptr++ ) {
    if ( !((*__ctype_b_loc ())[(int) ((*cptr))] & (unsigned short) _ISdigit) ) { all_digits = 0; }
  }
  if ( all_digits ) {
    status = stoI4(fld, &fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 117, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 118, "fld_meta.c"); }; status = -1 ; goto BYE; }; } };
    if ( g_flds[fld_id].name[0] == '\0' ) {
      return status ;
    }
    fld_rec = g_flds[fld_id];
  }
  else {
    status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec, &nn_fld_id,
      &nn_fld_rec);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 127, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  *ptr_fld_id = fld_id;
  if ( fld_id < 0 ) {
    return status ;
  }
  if ( is_print == 0 ) {
    return status ;
  }
  if ( strcmp(what_to_pr, "name") == 0 ) {
    fprintf(g_ofp, "%s", fld_rec.name);
  }
  else if ( strcmp(what_to_pr, "file") == 0 ) {
    fprintf(g_ofp, "%d", fld_rec.fileno);
  }
  else if ( strcmp(what_to_pr, "filesz") == 0 ) {
    fprintf(g_ofp, "%llu", (unsigned long long)fld_rec.filesz);
  }
  else if ( strcmp(what_to_pr, "external") == 0 ) {
    fprintf(g_ofp, "%d", fld_rec.is_external);
  }
  else if ( strcmp(what_to_pr, "min") == 0 ) {
    status = pr_min_max_sum("min", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 150, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(what_to_pr, "max") == 0 ) {
    status = pr_min_max_sum("max", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 153, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(what_to_pr, "sum") == 0 ) {
    status = pr_min_max_sum("sum", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 156, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(what_to_pr, "len") == 0 ) {
    if ( fld_rec.fldtype == SC ) {
      fprintf(g_ofp, "%d", fld_rec.len);
    }
    else {
      { { fprintf(stderr, "Line %3d of File %s \n", 163, "fld_meta.c"); }; status = -1 ; goto BYE; };
    }
  }
  else if ( strcmp(what_to_pr, "fldtype") == 0 ) {
    status = mk_str_fldtype(fld_rec.fldtype, str_fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 167, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s", str_fldtype);
  }
  else if ( strcmp(what_to_pr, "auxtype") == 0 ) {
    status = mk_str_auxtype(fld_rec.auxtype, str_auxtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 171, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s", str_auxtype);
  }
  else if ( strcmp(what_to_pr, "srttype") == 0 ) {
    status = mk_str_srttype(fld_rec.srttype, str_srttype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 175, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s", str_srttype);
  }
  else {
    fprintf(g_ofp, "id,name,fileno,external,num_nn,min,max,sum,len,filesz,fldtype,auxtype,srttype\n");
    fprintf(g_ofp, "%d,", fld_id);
    fprintf(g_ofp, "%s,", fld_rec.name);
    fprintf(g_ofp, "%d,", fld_rec.fileno);
    fprintf(g_ofp, "%d,", fld_rec.is_external);
    if ( fld_rec.num_nn < 0 ) {
      fprintf(g_ofp, "undef"); fprintf(g_ofp, ",");
    }
    else {
      fprintf(g_ofp, "%lld", fld_rec.num_nn); fprintf(g_ofp, ",");
    }
    status = pr_min_max_sum("min", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 190, "fld_meta.c"); }; status = (status) ; goto BYE; } } }; fprintf(g_ofp, ",");
    status = pr_min_max_sum("max", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 191, "fld_meta.c"); }; status = (status) ; goto BYE; } } }; fprintf(g_ofp, ",");
    status = pr_min_max_sum("sum", fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 192, "fld_meta.c"); }; status = (status) ; goto BYE; } } }; fprintf(g_ofp, ",");
    if ( fld_rec.fldtype == SC ) {
      fprintf(g_ofp, "%d,", fld_rec.len);
    }
    else {
      fprintf(g_ofp, "0,");
    }
    fprintf(g_ofp, "%llu,", (unsigned long long)fld_rec.filesz);
    status = mk_str_fldtype(fld_rec.fldtype, str_fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 200, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s,", str_fldtype);
    status = mk_str_auxtype(fld_rec.auxtype, str_auxtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 202, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s,", str_auxtype);
    status = mk_str_srttype(fld_rec.srttype, str_srttype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 204, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
    fprintf(g_ofp, "%s\n", str_srttype);
  }
 BYE:
  return status ;
}

variable_types:
tbl
char *

variable_types:
fld
char *

variable_types: struct _TBL_REC_TYPE { long long nR; _Bool is_temp; char name[-1]; enum _TBL_TYPE { undef_tbl=0, regular=1, ldb_dict=2, txt_lkp=3, min_max=4, first_last=5, bins=6 } tbltype; }

variable_types:
cptr
char *

user_defined_types: struct _TBL_REC_TYPE { long long nR; _Bool is_temp; char name[-1]; enum _TBL_TYPE tbltype; }

user_defined_types: enum _SORT_TYPE { unknown=0, ascending=1, descending=2, unsorted=3 }

user_defined_types: enum _AUX_TYPE { undef_auxtype=0, nn=1, len=2, off=3 }

user_defined_types: union sumval { long long sumI8; double sumF8; }

user_defined_types: union minval { long long minI8; double minF8; }

user_defined_types: union maxval { long long maxI8; double maxF8; }


decompiled_code:
__int64 __fastcall int_get_fld_meta(_BYTE *a1, __int64 a2, __int64 a3, int a4, const char *a5, char *a6)
{
int v10; // er12
char v12[124]; // [rsp+0h] [rbp-168h] BYREF
int v13; // [rsp+7Ch] [rbp-ECh] BYREF
char v14[124]; // [rsp+80h] [rbp-E8h] BYREF
int v15; // [rsp+FCh] [rbp-6Ch] BYREF
char v16[60]; // [rsp+100h] [rbp-68h] BYREF
unsigned int v17[11]; // [rsp+13Ch] [rbp-2Ch] BYREF

v17[0] = -1;
v15 = -1;
v13 = -1;
if ( (int)a2 < 0 )
{
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 232LL, "fld_meta.c");
return (unsigned int)-1;
}
v10 = is_tbl(a1, v17, v16);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 233LL, "fld_meta.c");
return (unsigned int)v10;
}
a2 = v17[0];
if ( (v17[0] & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 238LL, "fld_meta.c");
return (unsigned int)-1;
}
}
else
{
v17[0] = a2;
v10 = 0;
}
if ( a4 < 0 )
{
v10 = is_fld(0LL, a2, a3, &v15, v14, &v13, v12);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 243LL, "fld_meta.c");
return (unsigned int)v10;
}
a4 = v15;
if ( v15 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 248LL, "fld_meta.c");
return (unsigned int)-1;
}
}
else
{
v15 = a4;
}
if ( !strcmp(a5, "fileno") )
{
sprintf(a6, "%d", *(unsigned int *)(g_flds + 120LL * a4 + 72));
}
else if ( !strcmp(a5, "ddir_id") )
{
sprintf(a6, "%d", (unsigned int)*(__int16 *)(g_flds + 120LL * a4 + 2));
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 256LL, "fld_meta.c");
v10 = -1;
}
return (unsigned int)v10;
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1, __int64 a2, __int64 a3, int a4, const char *a5, char *a6)
{
int v10; // er12
char v12[124]; // [rsp+0h] [rbp-168h] BYREF
int v13; // [rsp+7Ch] [rbp-ECh] BYREF
char v14[124]; // [rsp+80h] [rbp-E8h] BYREF
int v15; // [rsp+FCh] [rbp-6Ch] BYREF
char v16[60]; // [rsp+100h] [rbp-68h] BYREF
unsigned int v17[11]; // [rsp+13Ch] [rbp-2Ch] BYREF

v17[0] = -1;
v15 = -1;
v13 = -1;
if ( (int)a2 < 0 )
{
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 232LL, "fld_meta.c");
return (unsigned int)-1;
}
v10 = is_tbl(a1, v17, v16);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 233LL, "fld_meta.c");
return (unsigned int)v10;
}
a2 = v17[0];
if ( (v17[0] & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 238LL, "fld_meta.c");
return (unsigned int)-1;
}
}
else
{
v17[0] = a2;
v10 = 0;
}
if ( a4 < 0 )
{
v10 = is_fld(0LL, a2, a3, &v15, v14, &v13, v12);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 243LL, "fld_meta.c");
return (unsigned int)v10;
}
a4 = v15;
if ( v15 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 248LL, "fld_meta.c");
return (unsigned int)-1;
}
}
else
{
v15 = a4;
}
if ( !strcmp(a5, "fileno") )
{
sprintf(a6, "%d", *(unsigned int *)(g_flds + 120LL * a4 + 72));
}
else if ( !strcmp(a5, "ddir_id") )
{
sprintf(a6, "%d", (unsigned int)*(__int16 *)(g_flds + 120LL * a4 + 2));
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 256LL, "fld_meta.c");
v10 = -1;
}
return (unsigned int)v10;
}

original_code:
int
int_get_fld_meta(
   const char *tbl,
   int in_tbl_id,
   const char *fld,
   int in_fld_id,
   const char *attr,
   char *value,
   int sz
   )
{
  int status = 0;
  int tbl_id = -1; TBL_REC_TYPE tbl_rec;
  int fld_id = -1; FLD_REC_TYPE fld_rec;
  int nn_fld_id = -1; FLD_REC_TYPE nn_fld_rec;
  if ( in_tbl_id < 0 ) {
    if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 232, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
    status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 233, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else {
    tbl_id = in_tbl_id;
  }
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 238, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  if ( in_fld_id < 0 ) {
    status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec,
      &nn_fld_id, &nn_fld_rec);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 243, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else {
    fld_id = in_fld_id;
  }
  if ( fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 248, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(attr, "fileno") == 0 ) {
    sprintf(value, "%d", g_flds[fld_id].fileno);
  }
  else if ( strcmp(attr, "ddir_id") == 0 ) {
    sprintf(value, "%d", g_flds[fld_id].ddir_id);
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 256, "fld_meta.c"); }; status = -1 ; goto BYE; };
  }
 BYE:
  return status ;
}

canonical_original_code:
int int_get_fld_meta(char *tbl, int in_tbl_id, char *fld, int in_fld_id, char *attr, char *value, int sz)
{
  int status = 0;
  int tbl_id = -1; struct _TBL_REC_TYPE tbl_rec;
  int fld_id = -1; struct _FLD_REC_TYPE fld_rec;
  int nn_fld_id = -1; struct _FLD_REC_TYPE nn_fld_rec;
  if ( in_tbl_id < 0 ) {
    if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 232, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
    status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 233, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else {
    tbl_id = in_tbl_id;
  }
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 238, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  if ( in_fld_id < 0 ) {
    status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec,
      &nn_fld_id, &nn_fld_rec);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 243, "fld_meta.c"); }; status = (status) ; goto BYE; } } };
  }
  else {
    fld_id = in_fld_id;
  }
  if ( fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 248, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(attr, "fileno") == 0 ) {
    sprintf(value, "%d", g_flds[fld_id].fileno);
  }
  else if ( strcmp(attr, "ddir_id") == 0 ) {
    sprintf(value, "%d", g_flds[fld_id].ddir_id);
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 256, "fld_meta.c"); }; status = -1 ; goto BYE; };
  }
 BYE:
  return status ;
}

variable_types:
attr
char *

variable_types:
value
char *

variable_types: sz int

user_defined_types: enum _TBL_TYPE { undef_tbl=0, regular=1, ldb_dict=2, txt_lkp=3, min_max=4, first_last=5, bins=6 }


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

zero_fld_rec(a2);
if ( a1 < 0 || g_n_fld <= a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 272LL, "fld_meta.c");
result = 0xFFFFFFFFLL;
}
else
{
copy_fld_meta(a2);
result = 0LL;
}
return result;
}

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

zero_fld_rec(a2);
if ( a1 < 0 || g_n_fld <= a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 272LL, "fld_meta.c");
result = 0xFFFFFFFFLL;
}
else
{
copy_fld_meta(a2);
result = 0LL;
}
return result;
}

original_code:
int
get_fld_meta(
      int fld_id,
      FLD_REC_TYPE *ptr_fld_meta
      )
{
  int status = 0;
  zero_fld_rec(ptr_fld_meta);
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 272, "fld_meta.c"); }; status = -1 ; goto BYE; }; } };
  copy_fld_meta(ptr_fld_meta, g_flds[fld_id]);
 BYE:
  return status ;
}

canonical_original_code:
int get_fld_meta(int fld_id, struct _FLD_REC_TYPE *ptr_fld_meta)
{
  int status = 0;
  zero_fld_rec(ptr_fld_meta);
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 272, "fld_meta.c"); }; status = -1 ; goto BYE; }; } };
  copy_fld_meta(ptr_fld_meta, g_flds[fld_id]);
 BYE:
  return status ;
}

variable_types: struct _FLD_REC_TYPE { short tbl_id; short ddir_id; short parent_id; short nn_fld_id; short len; unsigned long filesz; _Bool is_external; enum _SORT_TYPE { unknown=0, ascending=1, descending=2, unsorted=3 } srttype; enum _FLD_TYPE { undef_fldtype=0, B=1, I1=2, I2=3, I4=4, I8=5, F4=6, F8=7, SC=8, SV=9 } fldtype; enum _AUX_TYPE { undef_auxtype=0, nn=1, len=2, off=3 } auxtype; char name[-1]; int fileno; union sumval { long long sumI8; double sumF8; } sumval; union minval { long long minI8; double minF8; } minval; union maxval { long long maxI8; double maxF8; } maxval; _Bool is_sum_nn; _Bool is_min_nn; _Bool is_max_nn; long long num_nn; } *


decompiled_code:
__int64 __fastcall file_to_fld(_BYTE *a1, _DWORD *a2, char *a3, int a4)
{
unsigned int v6; // er13
int v7; // edx
__int16 *v8; // rax
int v9; // ebx
int v11[11]; // [rsp+Ch] [rbp-2Ch] BYREF

if ( a1 && *a1 )
{
v6 = stoI4(a1, v11);
v7 = v11[0];
if ( v11[0] <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 296LL, "fld_meta.c");
v6 = -1;
}
else
{
*a2 = -1;
if ( g_n_fld > 0 )
{
v8 = (__int16 *)g_flds;
v9 = 0;
while ( v7 != *((_DWORD *)v8 + 18) )
{
++v9;
v8 += 60;
if ( v9 == g_n_fld )
return v6;
}
snprintf(a3, a4, "%s:%s\n", (const char *)(g_tbls + 48LL * *v8 + 9), (const char *)v8 + 40);
*a2 = v9;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 293LL, "fld_meta.c");
v6 = -1;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1, _DWORD *a2, char *a3, int a4)
{
unsigned int v6; // er13
int v7; // edx
__int16 *v8; // rax
int v9; // ebx
int v11[11]; // [rsp+Ch] [rbp-2Ch] BYREF

if ( a1 && *a1 )
{
v6 = stoI4(a1, v11);
v7 = v11[0];
if ( v11[0] <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 296LL, "fld_meta.c");
v6 = -1;
}
else
{
*a2 = -1;
if ( g_n_fld > 0 )
{
v8 = (__int16 *)g_flds;
v9 = 0;
while ( v7 != *((_DWORD *)v8 + 18) )
{
++v9;
v8 += 60;
if ( v9 == g_n_fld )
return v6;
}
snprintf(a3, a4, "%s:%s\n", (const char *)(g_tbls + 48LL * *v8 + 9), (const char *)v8 + 40);
*a2 = v9;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 293LL, "fld_meta.c");
v6 = -1;
}
return v6;
}

original_code:
int
file_to_fld(
     char *str_fileno,
     int *ptr_fld_id,
     char *rslt_buf,
     int sz_rslt_buf
     )
{
  int status = 0;
  int fileno;
  if ( ( str_fileno == ((void *)0) ) || ( *str_fileno == '\0' ) ) {
    { { fprintf(stderr, "Line %3d of File %s \n", 293, "fld_meta.c"); }; status = -1 ; goto BYE; };
  }
  status = stoI4(str_fileno, &fileno);
  if ( fileno <= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 296, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  *ptr_fld_id = -1;
  for ( int i = 0; i < g_n_fld; i++ ) {
    if ( g_flds[i].fileno == fileno ) {
      int tbl_id = g_flds[i].tbl_id;
      char *tbl = g_tbls[tbl_id].name;
      snprintf(rslt_buf, sz_rslt_buf, "%s:%s\n", tbl, g_flds[i].name);
      *ptr_fld_id = i;
      break;
    }
  }
 BYE:
  return status ;
}

canonical_original_code:
int file_to_fld(char *str_fileno, int *ptr_fld_id, char *rslt_buf, int sz_rslt_buf)
{
  int status = 0;
  int fileno;
  if ( ( str_fileno == ((void *)0) ) || ( *str_fileno == '\0' ) ) {
    { { fprintf(stderr, "Line %3d of File %s \n", 293, "fld_meta.c"); }; status = -1 ; goto BYE; };
  }
  status = stoI4(str_fileno, &fileno);
  if ( fileno <= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 296, "fld_meta.c"); }; status = -1 ; goto BYE; }; }
  *ptr_fld_id = -1;
  for ( int i = 0; i < g_n_fld; i++ ) {
    if ( g_flds[i].fileno == fileno ) {
      int tbl_id = g_flds[i].tbl_id;
      char *tbl = g_tbls[tbl_id].name;
      snprintf(rslt_buf, sz_rslt_buf, "%s:%s\n", tbl, g_flds[i].name);
      *ptr_fld_id = i;
      break;
    }
  }
 BYE:
  return status ;
}

variable_types: fileno int

variable_types: i int


decompiled_code:
__int64 esc_for_latex()
{
__int64 v0; // rbp
int v1; // eax
int v2; // ebx
unsigned __int64 v3; // rax

v0 = 0x1A0000003LL;
while ( 1 )
{
v1 = fgetc(stdin);
v2 = v1;
if ( v1 == -1 )
break;
if ( (unsigned int)(v1 - 35) <= 3 || (v3 = (unsigned int)(v1 - 94), (unsigned int)v3 <= 0x20) && _bittest64(&v0, v3) )
fputc(92, stdout);
fputc(v2, stdout);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
int v1; // eax
int v2; // ebx
unsigned __int64 v3; // rax

v0 = 0x1A0000003LL;
while ( 1 )
{
v1 = fgetc(stdin);
v2 = v1;
if ( v1 == -1 )
break;
if ( (unsigned int)(v1 - 35) <= 3 || (v3 = (unsigned int)(v1 - 94), (unsigned int)v3 <= 0x20) && _bittest64(&v0, v3) )
fputc(92, stdout);
fputc(v2, stdout);
}
return 0LL;
}

original_code:
int
esc_for_latex(
    )
{
  int status = 0;
  unsigned int uitemp;
  for ( ; ; ) {
    uitemp = fgetc(stdin);
    if ( uitemp == (-1) ) { break; }
    if ( ( uitemp == '_' ) || ( uitemp == '#' ) || ( uitemp == '$' ) ||
         ( uitemp == '%' ) || ( uitemp == '&' ) || ( uitemp == '~' ) ||
         ( uitemp == '^' ) || ( uitemp == '{' ) || ( uitemp == '}' ) ) {
      fputc('\\', stdout);
    }
    fputc(uitemp, stdout);
  }
  return status ;
}

canonical_original_code:
int esc_for_latex()
{
  int status = 0;
  unsigned int uitemp;
  for ( ; ; ) {
    uitemp = fgetc(stdin);
    if ( uitemp == (-1) ) { break; }
    if ( ( uitemp == '_' ) || ( uitemp == '#' ) || ( uitemp == '$' ) ||
         ( uitemp == '%' ) || ( uitemp == '&' ) || ( uitemp == '~' ) ||
         ( uitemp == '^' ) || ( uitemp == '{' ) || ( uitemp == '}' ) ) {
      fputc('\\', stdout);
    }
    fputc(uitemp, stdout);
  }
  return status ;
}

variable_types:
uitemp
unsigned int


decompiled_code:
__int64 __fastcall mk_hashes_I4(int *a1, int a2, _QWORD *a3, unsigned int *a4, unsigned int *a5, unsigned int *a6)
{
_DWORD *v6; // r12
_BYTE *v7; // rbp
__int64 v8; // rax
__int64 v9; // r13
__int64 v10; // rax
__int64 v11; // rax
int *v12; // rcx
int v13; // esi
__int64 v14; // rdx
__int64 v15; // rax
int v16; // esi
unsigned int v17; // ebx
char v18; // dl
unsigned int v20; // [rsp+0h] [rbp-68h]
unsigned int v21; // [rsp+4h] [rbp-64h]
unsigned int size; // [rsp+8h] [rbp-60h]

*a6 = 0;
*a5 = 0;
*a4 = 0;
*a3 = 0LL;
if ( (unsigned int)(a2 - 1) > 0x7F )
{
fprintf(stderr, "Line %3d of File %s \n", 35LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
else
{
size = prime_geq((unsigned int)(a2 * a2));
if ( size <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
else
{
v6 = malloc(4LL * size);
if ( v6 )
{
v7 = malloc(size);
if ( v7 )
{
v8 = get_time_usec();
srand48(v8);
v9 = (__int64)&a1[a2 - 1 + 1];
LABEL_6:
v10 = mrand48();
v20 = prime_geq(v10);
v11 = mrand48();
v21 = prime_geq(v11);
assign_const_I4(v6, size, 0LL);
assign_const_I1(v7, size, 0LL);
v12 = a1;
do
{
v13 = *v12;
v14 = (unsigned __int16)((v21 + (unsigned __int64)v20 * *v12) % size);
if ( v7[v14] )
goto LABEL_6;
v7[v14] = 1;
v6[v14] = v13;
++v12;
}
while ( v12 != (int *)v9 );
v15 = 0LL;
v16 = 0;
do
{
v18 = v7[v15];
if ( v18 == 1 )
{
++v16;
}
else if ( !v18 && v6[v15] )
{
fprintf(stderr, "Line %3d of File %s \n", 72LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
goto LABEL_22;
}
++v15;
}
while ( v15 != size );
if ( a2 == v16 )
{
*a3 = v6;
*a5 = v20;
*a6 = v21;
*a4 = size;
v17 = 0;
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 75LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
LABEL_22:
free(v7);
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 41LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 39LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
}
}
return v17;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, int a2, _QWORD *a3, unsigned int *a4, unsigned int *a5, unsigned int *a6)
{
_DWORD *v6; // r12
_BYTE *v7; // rbp
__int64 v8; // rax
__int64 v9; // r13
__int64 v10; // rax
__int64 v11; // rax
int *v12; // rcx
int v13; // esi
__int64 v14; // rdx
__int64 v15; // rax
int v16; // esi
unsigned int v17; // ebx
char v18; // dl
unsigned int v20; // [rsp+0h] [rbp-68h]
unsigned int v21; // [rsp+4h] [rbp-64h]
unsigned int size; // [rsp+8h] [rbp-60h]

*a6 = 0;
*a5 = 0;
*a4 = 0;
*a3 = 0LL;
if ( (unsigned int)(a2 - 1) > 0x7F )
{
fprintf(stderr, "Line %3d of File %s \n", 35LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
else
{
size = prime_geq((unsigned int)(a2 * a2));
if ( size <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
else
{
v6 = malloc(4LL * size);
if ( v6 )
{
v7 = malloc(size);
if ( v7 )
{
v8 = get_time_usec();
srand48(v8);
v9 = (__int64)&a1[a2 - 1 + 1];
LABEL_6:
v10 = mrand48();
v20 = prime_geq(v10);
v11 = mrand48();
v21 = prime_geq(v11);
assign_const_I4(v6, size, 0LL);
assign_const_I1(v7, size, 0LL);
v12 = a1;
do
{
v13 = *v12;
v14 = (unsigned __int16)((v21 + (unsigned __int64)v20 * *v12) % size);
if ( v7[v14] )
goto LABEL_6;
v7[v14] = 1;
v6[v14] = v13;
++v12;
}
while ( v12 != (int *)v9 );
v15 = 0LL;
v16 = 0;
do
{
v18 = v7[v15];
if ( v18 == 1 )
{
++v16;
}
else if ( !v18 && v6[v15] )
{
fprintf(stderr, "Line %3d of File %s \n", 72LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
goto LABEL_22;
}
++v15;
}
while ( v15 != size );
if ( a2 == v16 )
{
*a3 = v6;
*a5 = v20;
*a6 = v21;
*a4 = size;
v17 = 0;
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 75LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
LABEL_22:
free(v7);
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 41LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 39LL, "./AUTOGEN/GENFILES/mk_hashes_I4.c");
v17 = -1;
}
}
}
return v17;
}

original_code:
int
mk_hashes_I4(
      int *scalars,
      int num_scalars,
      int **ptr_hashes,
      unsigned int *ptr_n,
      unsigned int *ptr_a,
      unsigned int *ptr_b
      )
{
  int status = 0;
  int *hashes = ((void *)0);
  unsigned char *used = ((void *)0);
  unsigned int n, a, b;
  *ptr_n = *ptr_a = *ptr_b = 0; *ptr_hashes = ((void *)0);
  if ( ( num_scalars < 1 ) || ( num_scalars > 128 ) ){ { { fprintf(stderr, "Line %3d of File %s \n", 35, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; };}
  n = prime_geq(num_scalars * num_scalars);
  if ( n <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; }
  hashes = malloc(n * sizeof(int));
  { if ( hashes == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 39, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; } };
  used = malloc(n * sizeof(unsigned char));
  { if ( used == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 41, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; } };
  srand48(get_time_usec());
  for ( int iter = 0; ; iter++ ) {
    a = (unsigned int)mrand48();
    a = prime_geq(a);
    b = (unsigned int)mrand48();
    b = prime_geq(b);
    _Bool is_collision = 0;
    assign_const_I4( hashes, n, 0);
    assign_const_I1((char *)used, n, 0);
    for ( int i = 0; i < num_scalars; i++ ) {
      unsigned long long val = scalars[i];
      unsigned long long ltemp = ( ( a * val ) + b ) % n;
      unsigned short loc = (unsigned short)ltemp;
      if ( used[loc] == 0 ) {
 used[loc] = 1;
 hashes[loc] = scalars[i];
      }
      else {
 is_collision = 1;
 break;
      }
    }
    if ( is_collision == 0 ) { break; }
  }
  int chk_cnt = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( used[i] == 1 ) { chk_cnt++; }
    if ( ( used[i] == 0 ) && ( hashes[i] != 0 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; }
  }
  if ( chk_cnt != num_scalars ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; }
  *ptr_hashes = hashes;
  *ptr_a = a;
  *ptr_b = b;
  *ptr_n = n;
 BYE:
  { if ( (used) != ((void *)0) ) { free((used)); (used) = ((void *)0); } };
  return(status);
}

canonical_original_code:
int mk_hashes_I4(int *scalars, int num_scalars, int **ptr_hashes, unsigned int *ptr_n, unsigned int *ptr_a, unsigned int *ptr_b)
{
  int status = 0;
  int *hashes = ((void *)0);
  unsigned char *used = ((void *)0);
  unsigned int n; unsigned int a; unsigned int b;
  *ptr_n = *ptr_a = *ptr_b = 0; *ptr_hashes = ((void *)0);
  if ( ( num_scalars < 1 ) || ( num_scalars > 128 ) ){ { { fprintf(stderr, "Line %3d of File %s \n", 35, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; };}
  n = prime_geq(num_scalars * num_scalars);
  if ( n <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; }
  hashes = malloc(n * sizeof(int));
  { if ( hashes == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 39, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; } };
  used = malloc(n * sizeof(unsigned char));
  { if ( used == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 41, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; } };
  srand48(get_time_usec());
  for ( int iter = 0; ; iter++ ) {
    a = (unsigned int)mrand48();
    a = prime_geq(a);
    b = (unsigned int)mrand48();
    b = prime_geq(b);
    _Bool is_collision = 0;
    assign_const_I4( hashes, n, 0);
    assign_const_I1((char *)used, n, 0);
    for ( int i = 0; i < num_scalars; i++ ) {
      unsigned long long val = scalars[i];
      unsigned long long ltemp = ( ( a * val ) + b ) % n;
      unsigned short loc = (unsigned short)ltemp;
      if ( used[loc] == 0 ) {
 used[loc] = 1;
 hashes[loc] = scalars[i];
      }
      else {
 is_collision = 1;
 break;
      }
    }
    if ( is_collision == 0 ) { break; }
  }
  int chk_cnt = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( used[i] == 1 ) { chk_cnt++; }
    if ( ( used[i] == 0 ) && ( hashes[i] != 0 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; }
  }
  if ( chk_cnt != num_scalars ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "./AUTOGEN/GENFILES/mk_hashes_I4.c"); }; status = -1 ; goto BYE; }; }
  *ptr_hashes = hashes;
  *ptr_a = a;
  *ptr_b = b;
  *ptr_n = n;
 BYE:
  { if ( (used) != ((void *)0) ) { free((used)); (used) = ((void *)0); } };
  return(status);
}

variable_types:
scalars
int *

variable_types:
hashes
int *

variable_types:
used
unsigned char *

variable_types:
n
unsigned int

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types: iter int

variable_types:
val
unsigned long long

variable_types:
ltemp
unsigned long long

variable_types:
loc
unsigned short


decompiled_code:
bool __fastcall space_in_dir(_BYTE *a1, __int64 a2)
{
int v2; // ebx

if ( a1 && *a1 )
{
v2 = get_disk_space(a1, a2, "free_space");
if ( v2 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 26LL, "mk_temp_file.c");
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 25LL, "mk_temp_file.c");
v2 = -1;
}
return v2 != 0;
}

canonical_decompiled_code:
bool __fastcall func0(_BYTE *a1, __int64 a2)
{
int v2; // ebx

if ( a1 && *a1 )
{
v2 = get_disk_space(a1, a2, "free_space");
if ( v2 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 26LL, "mk_temp_file.c");
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 25LL, "mk_temp_file.c");
v2 = -1;
}
return v2 != 0;
}

original_code:
_Bool
  space_in_dir(
      char *dir,
      size_t *ptr_free_space
      )
{
  int status = 0;
  if ( ( dir == ((void *)0) ) || ( *dir == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 25, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; }
  status = get_disk_space(dir, ptr_free_space, "free_space"); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 26, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
BYE:
  return status;
}

canonical_original_code:
_Bool space_in_dir(char *dir, unsigned long *ptr_free_space)
{
  int status = 0;
  if ( ( dir == ((void *)0) ) || ( *dir == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 25, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; }
  status = get_disk_space(dir, ptr_free_space, "free_space"); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 26, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
BYE:
  return status;
}

variable_types:
dir
char *

variable_types: status int


decompiled_code:
__int64 __fastcall mk_temp_file(__int64 a1, _BOOL4 *a2, int *a3)
{
_BOOL4 v4; // er15
int v5; // ebx
const char *v6; // r13
int v7; // eax
int v8; // er12
unsigned __int64 v10; // [rsp+18h] [rbp-70h] BYREF
char s[40]; // [rsp+20h] [rbp-68h] BYREF
unsigned __int64 v12[8]; // [rsp+48h] [rbp-40h] BYREF

if ( g_ram_ddir_id == 1 || g_ram_ddir_id < 0 )
{
if ( a1 )
{
*a3 = -1;
if ( g_ram_ddir_id < 0 )
{
v4 = 0;
}
else if ( g_use_ram_dir )
{
if ( !*g_ddirs )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "mk_temp_file.c");
return (unsigned int)-1;
}
v10 = 0LL;
space_in_dir(g_ddirs, (__int64)&v10);
v4 = a1 + 0x40000000 <= v10;
}
else
{
v4 = 0;
}
v6 = (const char *)(g_ddirs + 514LL * v4);
if ( v6 )
{
v12[0] = 0LL;
space_in_dir((_BYTE *)(g_ddirs + 514LL * v4), (__int64)v12);
if ( a1 + 0x40000000 > v12[0] )
{
fprintf(stderr, "insufficient space (%llu) in %s \n", v12[0], v6);
fprintf(stderr, "need (%llu) plus (%llu) reserve \n", a1, 0x40000000LL);
fprintf(stderr, "Line %3d of File %s \n", 77LL, "mk_temp_file.c");
v5 = -1;
}
else
{
zero_string(s, 32LL);
v7 = get_max_fileno();
v8 = v7;
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "mk_temp_file.c");
v5 = -1;
}
else
{
sprintf(s, "_%d", (unsigned int)v7);
v5 = open_file_in_dir(&g_cwd, v6, s, a1);
if ( v5 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "mk_temp_file.c");
}
else
{
v5 = mk_file(&g_cwd, v6, s, a1);
if ( v5 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 87LL, "mk_temp_file.c");
}
else
{
*a3 = v8;
*a2 = v4;
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 67LL, "mk_temp_file.c");
v5 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "mk_temp_file.c");
v5 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "mk_temp_file.c");
v5 = -1;
}
return (unsigned int)v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _BOOL4 *a2, int *a3)
{
_BOOL4 v4; // er15
int v5; // ebx
const char *v6; // r13
int v7; // eax
int v8; // er12
unsigned __int64 v10; // [rsp+18h] [rbp-70h] BYREF
char s[40]; // [rsp+20h] [rbp-68h] BYREF
unsigned __int64 v12[8]; // [rsp+48h] [rbp-40h] BYREF

if ( g_ram_ddir_id == 1 || g_ram_ddir_id < 0 )
{
if ( a1 )
{
*a3 = -1;
if ( g_ram_ddir_id < 0 )
{
v4 = 0;
}
else if ( g_use_ram_dir )
{
if ( !*g_ddirs )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "mk_temp_file.c");
return (unsigned int)-1;
}
v10 = 0LL;
func0(g_ddirs, (__int64)&v10);
v4 = a1 + 0x40000000 <= v10;
}
else
{
v4 = 0;
}
v6 = (const char *)(g_ddirs + 514LL * v4);
if ( v6 )
{
v12[0] = 0LL;
func0((_BYTE *)(g_ddirs + 514LL * v4), (__int64)v12);
if ( a1 + 0x40000000 > v12[0] )
{
fprintf(stderr, "insufficient space (%llu) in %s \n", v12[0], v6);
fprintf(stderr, "need (%llu) plus (%llu) reserve \n", a1, 0x40000000LL);
fprintf(stderr, "Line %3d of File %s \n", 77LL, "mk_temp_file.c");
v5 = -1;
}
else
{
zero_string(s, 32LL);
v7 = get_max_fileno();
v8 = v7;
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "mk_temp_file.c");
v5 = -1;
}
else
{
sprintf(s, "_%d", (unsigned int)v7);
v5 = open_file_in_dir(&g_cwd, v6, s, a1);
if ( v5 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "mk_temp_file.c");
}
else
{
v5 = mk_file(&g_cwd, v6, s, a1);
if ( v5 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 87LL, "mk_temp_file.c");
}
else
{
*a3 = v8;
*a2 = v4;
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 67LL, "mk_temp_file.c");
v5 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "mk_temp_file.c");
v5 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "mk_temp_file.c");
v5 = -1;
}
return (unsigned int)v5;
}

original_code:
int
mk_temp_file(
    size_t filesz,
    int *ptr_ddir_id,
    int *ptr_fileno
    )
{
  int status = 0;
  char *dir = ((void *)0);
  int ddir_id = -1;
  if ( g_ram_ddir_id >= 0 ) { if ( g_ram_ddir_id != 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; } }
  if ( filesz <= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; }
  *ptr_fileno = -1;
  if ( ( g_ram_ddir_id >= 0 ) && ( g_use_ram_dir == 1 ) ) {
    char *dir = g_ddirs[0].name;
    if ( *dir == '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; }
    size_t free_space = 0, reserve = 1024*1048576;
    status = space_in_dir(dir, &free_space); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
    if ( (filesz + reserve) > free_space ) {
      ddir_id = 0;
    }
    else {
      ddir_id = 1;
    }
  }
  else {
    ddir_id = 0;
  }
  dir = g_ddirs[ddir_id].name;
  if ( dir == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 67, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; }
  size_t free_space = 0, reserve = 1024*1048576;
  status = space_in_dir(dir, &free_space); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
  if ( (filesz + reserve) > free_space ) {
    fprintf(stderr, "insufficient space (%llu) in %s \n",
 (unsigned long long)free_space, dir);
    fprintf(stderr, "need (%llu) plus (%llu) reserve \n",
 (unsigned long long)filesz,
 (unsigned long long)reserve);
    { { fprintf(stderr, "Line %3d of File %s \n", 77, "mk_temp_file.c"); }; status = -1 ; goto BYE; };
  }
  char filename[32]; zero_string(filename, 32);
  int l_max_fileno = get_max_fileno();
  { if ( filename == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; } if ( l_max_fileno < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; } sprintf(filename, "_%d", l_max_fileno); };
  status = open_file_in_dir(g_cwd, dir, filename, filesz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
  status = mk_file(g_cwd, dir, filename, filesz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 87, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
  *ptr_fileno = l_max_fileno;
  *ptr_ddir_id = ddir_id;
BYE:
  return(status);
}

canonical_original_code:
int mk_temp_file(unsigned long filesz, int *ptr_ddir_id, int *ptr_fileno)
{
  int status = 0;
  char *dir = ((void *)0);
  int ddir_id = -1;
  if ( g_ram_ddir_id >= 0 ) { if ( g_ram_ddir_id != 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; } }
  if ( filesz <= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; }
  *ptr_fileno = -1;
  if ( ( g_ram_ddir_id >= 0 ) && ( g_use_ram_dir == 1 ) ) {
    char *dir = g_ddirs[0].name;
    if ( *dir == '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; }
    unsigned long free_space = 0; unsigned long reserve = 1024*1048576;
    status = space_in_dir(dir, &free_space); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
    if ( (filesz + reserve) > free_space ) {
      ddir_id = 0;
    }
    else {
      ddir_id = 1;
    }
  }
  else {
    ddir_id = 0;
  }
  dir = g_ddirs[ddir_id].name;
  if ( dir == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 67, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; }
  unsigned long free_space = 0; unsigned long reserve = 1024*1048576;
  status = space_in_dir(dir, &free_space); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
  if ( (filesz + reserve) > free_space ) {
    fprintf(stderr, "insufficient space (%llu) in %s \n",
 (unsigned long long)free_space, dir);
    fprintf(stderr, "need (%llu) plus (%llu) reserve \n",
 (unsigned long long)filesz,
 (unsigned long long)reserve);
    { { fprintf(stderr, "Line %3d of File %s \n", 77, "mk_temp_file.c"); }; status = -1 ; goto BYE; };
  }
  char filename[32]; zero_string(filename, 32);
  int l_max_fileno = get_max_fileno();
  { if ( filename == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; } if ( l_max_fileno < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "mk_temp_file.c"); }; status = -1 ; goto BYE; }; } sprintf(filename, "_%d", l_max_fileno); };
  status = open_file_in_dir(g_cwd, dir, filename, filesz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
  status = mk_file(g_cwd, dir, filename, filesz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 87, "mk_temp_file.c"); }; status = (status) ; goto BYE; } } };
  *ptr_fileno = l_max_fileno;
  *ptr_ddir_id = ddir_id;
BYE:
  return(status);
}

variable_types:
filesz
unsigned long

variable_types:
reserve
unsigned long

variable_types:
filename
char [32]


decompiled_code:
__int64 __fastcall time1(_DWORD *a1)
{
*a1 = time(0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1)
{
*a1 = time(0LL);
return 0LL;
}

original_code:
int
time1(
    int *ptr_t
    )
{
  int status = 0;
  *ptr_t = time(((void *)0));
  return(status);
}

canonical_original_code:
int time1(int *ptr_t)
{
  int status = 0;
  *ptr_t = time(((void *)0));
  return(status);
}