original_code:
int
core_srt_join_L_I_I(
          long long *src_lnk,
          int *src_val,
          long long src_nR,
          int *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;
  int v_dst_lnk;
  int v_src_val;
  long long 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_L_I_I.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_L_I_I.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_L_I_I(long long *src_lnk, int *src_val, long long src_nR, int *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;
  int v_dst_lnk;
  int v_src_val;
  long long 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_L_I_I.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_L_I_I.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_L_I_I.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_L_I_I.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_L_I_I.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_L_I_I.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


decompiled_code:
__int64 __fastcall process_aux_info(_BYTE *a1, char *a2, char *a3, char *a4)
{
char v6; // r12
char v7; // al
char v8; // dl
int v9; // ebp
char v11[47]; // [rsp+0h] [rbp-68h] BYREF
char v12[57]; // [rsp+2Fh] [rbp-39h] BYREF

zero_string(v11, 32LL);
if ( a1 )
{
if ( *a1 )
{
v9 = chk_aux_info(a1);
if ( v9 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 24LL, "aux_dld.c");
return (unsigned int)v9;
}
zero_string(v11, 32LL);
extract_S(a1, "ignore_hdr=[", "]", v11, 32LL, v12);
v6 = v12[0];
if ( v12[0] )
{
v6 = 0;
}
else if ( !strcasecmp(v11, "true") )
{
v6 = 1;
}
else if ( strcasecmp(v11, "false") )
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "aux_dld.c");
return (unsigned int)-1;
}
zero_string(v11, 32LL);
v9 = extract_S(a1, "fld_sep=[", "]", v11, 32LL, v12);
if ( v12[0] )
{
v7 = 34;
v8 = 44;
}
else if ( !strcasecmp(v11, "comma") )
{
v7 = 34;
v8 = 44;
}
else if ( !strcasecmp(v11, "tab") )
{
v7 = 0;
v8 = 9;
}
else
{
if ( strcasecmp(v11, "ctrl_z") )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "aux_dld.c");
return (unsigned int)-1;
}
v7 = 0;
v8 = 26;
}
}
else
{
v6 = 0;
v7 = 34;
v8 = 44;
v9 = 0;
}
}
else
{
v6 = 0;
v7 = 34;
v8 = 44;
v9 = 0;
}
*a2 = v6;
*a3 = v8;
*a4 = v7;
return (unsigned int)v9;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, char *a2, char *a3, char *a4)
{
char v6; // r12
char v7; // al
char v8; // dl
int v9; // ebp
char v11[47]; // [rsp+0h] [rbp-68h] BYREF
char v12[57]; // [rsp+2Fh] [rbp-39h] BYREF

zero_string(v11, 32LL);
if ( a1 )
{
if ( *a1 )
{
v9 = chk_aux_info(a1);
if ( v9 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 24LL, "aux_dld.c");
return (unsigned int)v9;
}
zero_string(v11, 32LL);
extract_S(a1, "ignore_hdr=[", "]", v11, 32LL, v12);
v6 = v12[0];
if ( v12[0] )
{
v6 = 0;
}
else if ( !strcasecmp(v11, "true") )
{
v6 = 1;
}
else if ( strcasecmp(v11, "false") )
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "aux_dld.c");
return (unsigned int)-1;
}
zero_string(v11, 32LL);
v9 = extract_S(a1, "fld_sep=[", "]", v11, 32LL, v12);
if ( v12[0] )
{
v7 = 34;
v8 = 44;
}
else if ( !strcasecmp(v11, "comma") )
{
v7 = 34;
v8 = 44;
}
else if ( !strcasecmp(v11, "tab") )
{
v7 = 0;
v8 = 9;
}
else
{
if ( strcasecmp(v11, "ctrl_z") )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "aux_dld.c");
return (unsigned int)-1;
}
v7 = 0;
v8 = 26;
}
}
else
{
v6 = 0;
v7 = 34;
v8 = 44;
v9 = 0;
}
}
else
{
v6 = 0;
v7 = 34;
v8 = 44;
v9 = 0;
}
*a2 = v6;
*a3 = v8;
*a4 = v7;
return (unsigned int)v9;
}

original_code:
int
process_aux_info(
   char *in_aux_info,
   _Bool *ptr_ignore_hdr,
   char *ptr_fld_sep,
   char *ptr_fld_delim
   )
{
  int status = 0;
  char fld_sep =',', fld_delim = '"'; _Bool ignore_hdr = 0;
  _Bool is_null; char aux_info[32]; zero_string(aux_info, 32);
  if ( ( in_aux_info != ((void *)0) ) && ( *in_aux_info != '\0' ) ) {
    status = chk_aux_info(in_aux_info); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 24, "aux_dld.c"); }; status = (status) ; goto BYE; } } };
    zero_string(aux_info, 32);
    status = extract_S(in_aux_info, "ignore_hdr=[", "]", aux_info, 32, &is_null);
    if ( is_null ) {
      ignore_hdr = 0;
    }
    else {
      if ( strcasecmp(aux_info, "true") == 0 ) {
 ignore_hdr = 1;
      }
      else if ( strcasecmp(aux_info, "false") == 0 ) {
 ignore_hdr = 0;
      }
      else {
 { { fprintf(stderr, "Line %3d of File %s \n", 38, "aux_dld.c"); }; status = -1 ; goto BYE; };
      }
    }
    zero_string(aux_info, 32);
    status = extract_S(in_aux_info, "fld_sep=[", "]", aux_info, 32, &is_null);
    if ( is_null ) {
      fld_sep = ',';
    }
    else {
      if ( strcasecmp(aux_info, "comma") == 0 ) {
 fld_sep = ',';
      }
      else if ( strcasecmp(aux_info, "tab") == 0 ) {
 fld_sep = '\t';
 fld_delim = '\0';
      }
      else if ( strcasecmp(aux_info, "ctrl_z") == 0 ) {
 fld_sep = 26;
 fld_delim = '\0';
      }
      else {
 { { fprintf(stderr, "Line %3d of File %s \n", 59, "aux_dld.c"); }; status = -1 ; goto BYE; };
      }
    }
  }
  *ptr_ignore_hdr = ignore_hdr;
  *ptr_fld_sep = fld_sep;
  *ptr_fld_delim = fld_delim;
 BYE:
  return status ;
}

canonical_original_code:
int process_aux_info(char *in_aux_info, _Bool *ptr_ignore_hdr, char *ptr_fld_sep, char *ptr_fld_delim)
{
  int status = 0;
  char fld_sep = ','; char fld_delim = '"'; _Bool ignore_hdr = 0;
  _Bool is_null; char aux_info[32]; zero_string(aux_info, 32);
  if ( ( in_aux_info != ((void *)0) ) && ( *in_aux_info != '\0' ) ) {
    status = chk_aux_info(in_aux_info); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 24, "aux_dld.c"); }; status = (status) ; goto BYE; } } };
    zero_string(aux_info, 32);
    status = extract_S(in_aux_info, "ignore_hdr=[", "]", aux_info, 32, &is_null);
    if ( is_null ) {
      ignore_hdr = 0;
    }
    else {
      if ( strcasecmp(aux_info, "true") == 0 ) {
 ignore_hdr = 1;
      }
      else if ( strcasecmp(aux_info, "false") == 0 ) {
 ignore_hdr = 0;
      }
      else {
 { { fprintf(stderr, "Line %3d of File %s \n", 38, "aux_dld.c"); }; status = -1 ; goto BYE; };
      }
    }
    zero_string(aux_info, 32);
    status = extract_S(in_aux_info, "fld_sep=[", "]", aux_info, 32, &is_null);
    if ( is_null ) {
      fld_sep = ',';
    }
    else {
      if ( strcasecmp(aux_info, "comma") == 0 ) {
 fld_sep = ',';
      }
      else if ( strcasecmp(aux_info, "tab") == 0 ) {
 fld_sep = '\t';
 fld_delim = '\0';
      }
      else if ( strcasecmp(aux_info, "ctrl_z") == 0 ) {
 fld_sep = 26;
 fld_delim = '\0';
      }
      else {
 { { fprintf(stderr, "Line %3d of File %s \n", 59, "aux_dld.c"); }; status = -1 ; goto BYE; };
      }
    }
  }
  *ptr_ignore_hdr = ignore_hdr;
  *ptr_fld_sep = fld_sep;
  *ptr_fld_delim = fld_delim;
 BYE:
  return status ;
}


normPvalue

decompiled_code:
double __fastcall normPvalue(__m128d a1)
{
double v1; // xmm1_8

v1 = COERCE_DOUBLE(normcdf(a1));
return 1.0 - v1 + 1.0 - v1;
}

canonical_decompiled_code:
double __fastcall func1(__m128d a1)
{
double v1; // xmm1_8

v1 = COERCE_DOUBLE(normcdf(a1));
return 1.0 - v1 + 1.0 - v1;
}

original_code:
double normPvalue(
    double tvalue
    )
{
  double pval = 2*(1 - normcdf(tvalue));
  return pval;
}

canonical_original_code:
double normPvalue(double tvalue)
{
  double pval = 2*(1 - normcdf(tvalue));
  return pval;
}

variable_types: tvalue double

variable_types: pval double

return_type: double


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

if ( a2 > 0 )
{
v3 = a1;
do
*a3++ = normPvalue((__m128d)*v3++);
while ( v3 != &a1[a2] );
}
}

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

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

original_code:
void
vec_pval_from_zval(
       double *in,
       int nR,
       double *out
       )
{
  for ( int i = 0; i < nR; i++ ) {
    double inval = *in;
    double outval = normPvalue(inval);
    *out = outval;
    in++;
    out++;
  }
}

canonical_original_code:
void vec_pval_from_zval(double *in, int nR, double *out)
{
  for ( int i = 0; i < nR; i++ ) {
    double inval = *in;
    double outval = normPvalue(inval);
    *out = outval;
    in++;
    out++;
  }
}

variable_types:
in
double *

variable_types: nR int

variable_types:
out
double *

variable_types: i int

variable_types: inval double

variable_types: outval double

return_type: void


decompiled_code:
__int64 __fastcall g_countf(char *s1, char *a2, char *a3, char *s2)
{
int v6; // ebx
const char *v7; // rdx
const char *v8; // rcx
const char *v9; // r8
const char *v10; // r9
char *v11; // rbp
_BYTE v13[712]; // [rsp-B20h] [rbp-22B8h] BYREF
_BYTE v14[712]; // [rsp-858h] [rbp-1FF0h] BYREF
_BYTE v15[712]; // [rsp-590h] [rbp-1D28h] BYREF
_BYTE v16[712]; // [rsp-2C8h] [rbp-1A60h] BYREF
char v17[1024]; // [rsp+0h] [rbp-1798h] BYREF
char v18[2060]; // [rsp+400h] [rbp-1398h] BYREF
unsigned int v19; // [rsp+C0Ch] [rbp-B8Ch] BYREF
__int64 v20; // [rsp+C10h] [rbp-B88h] BYREF
__int64 v21; // [rsp+C18h] [rbp-B80h] BYREF
__int64 v22; // [rsp+C20h] [rbp-B78h] BYREF
char *haystack; // [rsp+C28h] [rbp-B70h] BYREF
int v24[179]; // [rsp+C30h] [rbp-B68h] BYREF
int v25; // [rsp+EFCh] [rbp-89Ch] BYREF
int v26[179]; // [rsp+F00h] [rbp-898h] BYREF
int v27; // [rsp+11CCh] [rbp-5CCh] BYREF
int v28[179]; // [rsp+11D0h] [rbp-5C8h] BYREF
int v29; // [rsp+149Ch] [rbp-2FCh] BYREF
int v30[179]; // [rsp+14A0h] [rbp-2F8h] BYREF
int v31[11]; // [rsp+176Ch] [rbp-2Ch] BYREF

v31[0] = -1;
v29 = -1;
v27 = -1;
v25 = -1;
haystack = 0LL;
v22 = 0LL;
v21 = 0LL;
v20 = 0LL;
v19 = 0;
g_mmap_meta_data(&g_docroot, &v22, &v21, &v20, &v19);
if ( s1 && *s1 )
{
if ( a2 && *a2 )
{
if ( a3 && *a3 )
{
if ( !strcmp(s1, a2) )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(s1, a3) )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(s1, s2) )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(a2, a3) )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(a2, s2) )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(a3, s2) )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "g_countf.c");
v6 = -1;
}
else
{
v6 = g_is_fld(v20, v19, s1, v31, v30);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 56LL, "g_countf.c");
}
else if ( v31[0] < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 57LL, "g_countf.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v30[8]) )
{
v6 = g_is_fld(v20, v19, a2, &v29, v28);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "g_countf.c");
}
else if ( v29 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_countf.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v28[8]) )
{
v6 = g_is_fld(v20, v19, a3, &v27, v26);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "g_countf.c");
}
else if ( v27 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "g_countf.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v26[8]) )
{
v6 = g_is_fld(v20, v19, s2, &v25, v24);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 68LL, "g_countf.c");
}
else if ( v25 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 69LL, "g_countf.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v24[8]) )
{
qmemcpy(v16, v24, sizeof(v16));
qmemcpy(v15, v26, sizeof(v15));
qmemcpy(v14, v28, sizeof(v14));
qmemcpy(v13, v30, sizeof(v13));
v6 = g_chk_countf();
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "g_countf.c");
}
else
{
zero_string(v18, "%s d_cfld=%s d_fld2=%s d_out=%s", v7, v8, v9, v10);
zero_string(v17, (_BYTE *)&loc_3FE + 2);
sprintf(v17, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s d_out=%s", s1, a2, a3, s2);
v6 = g_make_url(v17, v18);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 79LL, "g_countf.c");
}
else
{
v6 = g_call_gpu(v18, &haystack);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "g_countf.c");
}
else
{
v11 = haystack;
if ( !haystack )
goto LABEL_43;
if ( strstr(haystack, "\"\"") )
{
LABEL_42:
free(v11);
haystack = 0LL;
goto LABEL_43;
}
fprintf(stderr, "Response from GPU = [%s]\n", v11);
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 70LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_countf.c");
v6 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "g_countf.c");
v6 = -1;
}
v11 = haystack;
if ( haystack )
goto LABEL_42;
LABEL_43:
g_unmap_meta_data(v22, v21);
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, char *a2, char *a3, char *s2)
{
int v6; // ebx
const char *v7; // rdx
const char *v8; // rcx
const char *v9; // r8
const char *v10; // r9
char *v11; // rbp
_BYTE v13[712]; // [rsp-B20h] [rbp-22B8h] BYREF
_BYTE v14[712]; // [rsp-858h] [rbp-1FF0h] BYREF
_BYTE v15[712]; // [rsp-590h] [rbp-1D28h] BYREF
_BYTE v16[712]; // [rsp-2C8h] [rbp-1A60h] BYREF
char v17[1024]; // [rsp+0h] [rbp-1798h] BYREF
char v18[2060]; // [rsp+400h] [rbp-1398h] BYREF
unsigned int v19; // [rsp+C0Ch] [rbp-B8Ch] BYREF
__int64 v20; // [rsp+C10h] [rbp-B88h] BYREF
__int64 v21; // [rsp+C18h] [rbp-B80h] BYREF
__int64 v22; // [rsp+C20h] [rbp-B78h] BYREF
char *haystack; // [rsp+C28h] [rbp-B70h] BYREF
int v24[179]; // [rsp+C30h] [rbp-B68h] BYREF
int v25; // [rsp+EFCh] [rbp-89Ch] BYREF
int v26[179]; // [rsp+F00h] [rbp-898h] BYREF
int v27; // [rsp+11CCh] [rbp-5CCh] BYREF
int v28[179]; // [rsp+11D0h] [rbp-5C8h] BYREF
int v29; // [rsp+149Ch] [rbp-2FCh] BYREF
int v30[179]; // [rsp+14A0h] [rbp-2F8h] BYREF
int v31[11]; // [rsp+176Ch] [rbp-2Ch] BYREF

v31[0] = -1;
v29 = -1;
v27 = -1;
v25 = -1;
haystack = 0LL;
v22 = 0LL;
v21 = 0LL;
v20 = 0LL;
v19 = 0;
g_mmap_meta_data(&g_docroot, &v22, &v21, &v20, &v19);
if ( s1 && *s1 )
{
if ( a2 && *a2 )
{
if ( a3 && *a3 )
{
if ( !strcmp(s1, a2) )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(s1, a3) )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(s1, s2) )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(a2, a3) )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(a2, s2) )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_countf.c");
v6 = -1;
}
else if ( !strcmp(a3, s2) )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "g_countf.c");
v6 = -1;
}
else
{
v6 = g_is_fld(v20, v19, s1, v31, v30);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 56LL, "g_countf.c");
}
else if ( v31[0] < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 57LL, "g_countf.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v30[8]) )
{
v6 = g_is_fld(v20, v19, a2, &v29, v28);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "g_countf.c");
}
else if ( v29 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_countf.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v28[8]) )
{
v6 = g_is_fld(v20, v19, a3, &v27, v26);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "g_countf.c");
}
else if ( v27 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "g_countf.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v26[8]) )
{
v6 = g_is_fld(v20, v19, s2, &v25, v24);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 68LL, "g_countf.c");
}
else if ( v25 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 69LL, "g_countf.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v24[8]) )
{
qmemcpy(v16, v24, sizeof(v16));
qmemcpy(v15, v26, sizeof(v15));
qmemcpy(v14, v28, sizeof(v14));
qmemcpy(v13, v30, sizeof(v13));
v6 = g_chk_countf();
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "g_countf.c");
}
else
{
zero_string(v18, "%s d_cfld=%s d_fld2=%s d_out=%s", v7, v8, v9, v10);
zero_string(v17, (_BYTE *)&loc_3FE + 2);
sprintf(v17, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s d_out=%s", s1, a2, a3, s2);
v6 = g_make_url(v17, v18);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 79LL, "g_countf.c");
}
else
{
v6 = g_call_gpu(v18, &haystack);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "g_countf.c");
}
else
{
v11 = haystack;
if ( !haystack )
goto LABEL_43;
if ( strstr(haystack, "\"\"") )
{
LABEL_42:
free(v11);
haystack = 0LL;
goto LABEL_43;
}
fprintf(stderr, "Response from GPU = [%s]\n", v11);
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 70LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_countf.c");
v6 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_countf.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "g_countf.c");
v6 = -1;
}
v11 = haystack;
if ( haystack )
goto LABEL_42;
LABEL_43:
g_unmap_meta_data(v22, v21);
return (unsigned int)v6;
}

original_code:
int
g_countf(
    char *f1,
    char *cfld,
    char *f2,
    char *fout
    )
{
  int status = 0;
  int f1_id = -1; GPU_REG_TYPE f1_rec;
  int cfld_id = -1; GPU_REG_TYPE cfld_rec;
  int f2_id = -1; GPU_REG_TYPE f2_rec;
  int fout_id = -1; GPU_REG_TYPE fout_rec;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( ( cfld == ((void *)0) ) || ( *cfld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, cfld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, fout) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(cfld, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(cfld, fout) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f2, fout) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f1, &f1_id, &f1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, cfld, &cfld_id, &cfld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( cfld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(cfld_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f2, &f2_id, &f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, fout, &fout_id, &fout_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( fout_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(fout_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_countf(f1_rec, cfld_rec, f2_rec, fout_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 73, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s d_out=%s",
        f1, cfld, f2, fout);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    if ( strstr(curl_response, "\"\"") == ((void *)0) ) {
      fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
    }
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return status ;
}

canonical_original_code:
int g_countf(char *f1, char *cfld, char *f2, char *fout)
{
  int status = 0;
  int f1_id = -1; struct _GPU_REG_TYPE f1_rec;
  int cfld_id = -1; struct _GPU_REG_TYPE cfld_rec;
  int f2_id = -1; struct _GPU_REG_TYPE f2_rec;
  int fout_id = -1; struct _GPU_REG_TYPE fout_rec;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( ( cfld == ((void *)0) ) || ( *cfld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, cfld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, fout) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(cfld, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(cfld, fout) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f2, fout) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f1, &f1_id, &f1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, cfld, &cfld_id, &cfld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( cfld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(cfld_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f2, &f2_id, &f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, fout, &fout_id, &fout_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( fout_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(fout_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "g_countf.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_countf(f1_rec, cfld_rec, f2_rec, fout_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 73, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s d_out=%s",
        f1, cfld, f2, fout);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "g_countf.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    if ( strstr(curl_response, "\"\"") == ((void *)0) ) {
      fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
    }
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return status ;
}

variable_types:
cfld
char *

variable_types:
fout
char *

variable_types: struct _GPU_REG_TYPE { void *reg; unsigned long filesz; _Bool is_busy; long long nR; 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; char filename[-1]; char tbl[-1]; char h_fld[-1]; char d_fld[-1]; } *

variable_types:
url
char [2048]

variable_types:
command
char [1024]

user_defined_types: struct _GPU_REG_TYPE { void *reg; unsigned long filesz; _Bool is_busy; long long nR; enum _FLD_TYPE fldtype; char filename[-1]; char tbl[-1]; char h_fld[-1]; char d_fld[-1]; }


original_code:
void
vec_abs_F8(
       double *in,
       int nR,
       double *out
       )
{
  int i;
  for ( i = 0; i < nR; i++ ) {
    *out = (double)fabs(*in);
    in++;
    out++;
  }
}

canonical_original_code:
void vec_abs_F8(double *in, int nR, double *out)
{
  int i;
  for ( i = 0; i < nR; i++ ) {
    *out = (double)fabs(*in);
    in++;
    out++;
  }
}


decompiled_code:
__int64 __fastcall permute_I8(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 *v3; // rax
__int64 v4; // rdx
__int64 v5; // rax
double result; // [rsp+8h] [rbp-40h] BYREF
struct drand48_data buffer; // [rsp+10h] [rbp-38h] BYREF

srand48_r(852187451LL, &buffer);
if ( a1 )
{
if ( a2 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 22LL, "./AUTOGEN/GENFILES/permute_I8.c");
v5 = 0xFFFFFFFFLL;
}
else
{
v2 = a2 - 1;
do
{
drand48_r(&buffer, &result);
v3 = (__int64 *)(a1
+ 8
* ((unsigned int)(int)((double)(int)a2 * result)
- (unsigned __int64)(a2 == (int)((double)(int)a2 * result))));
v4 = *v3;
*v3 = *(_QWORD *)(a1 + 8 * v2);
*(_QWORD *)(a1 + 8 * v2--) = v4;
}
while ( v2 != -1 );
v5 = 0LL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 21LL, "./AUTOGEN/GENFILES/permute_I8.c");
v5 = 0xFFFFFFFFLL;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 *v3; // rax
__int64 v4; // rdx
__int64 v5; // rax
double result; // [rsp+8h] [rbp-40h] BYREF
struct drand48_data buffer; // [rsp+10h] [rbp-38h] BYREF

srand48_r(852187451LL, &buffer);
if ( a1 )
{
if ( a2 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 22LL, "./AUTOGEN/GENFILES/permute_I8.c");
v5 = 0xFFFFFFFFLL;
}
else
{
v2 = a2 - 1;
do
{
drand48_r(&buffer, &result);
v3 = (__int64 *)(a1
+ 8
* ((unsigned int)(int)((double)(int)a2 * result)
- (unsigned __int64)(a2 == (int)((double)(int)a2 * result))));
v4 = *v3;
*v3 = *(_QWORD *)(a1 + 8 * v2);
*(_QWORD *)(a1 + 8 * v2--) = v4;
}
while ( v2 != -1 );
v5 = 0LL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 21LL, "./AUTOGEN/GENFILES/permute_I8.c");
v5 = 0xFFFFFFFFLL;
}
return v5;
}

original_code:
int
permute_I8(
    long long *X,
    long long n
    )
{
  int status = 0;
  struct drand48_data buffer;
  srand48_r(852187451, &buffer);
  if ( X == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 21, "./AUTOGEN/GENFILES/permute_I8.c"); }; status = -1 ; goto BYE; }; }
  if ( n <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 22, "./AUTOGEN/GENFILES/permute_I8.c"); }; status = -1 ; goto BYE; }; }
  for (long long k = n-1; k >= 0; k--) {
    long long pos;
    double dtemp;
    long long swap;
    drand48_r(&buffer, &dtemp);
    pos = dtemp * n; if ( pos == n ) { pos--; }
    swap = X[pos];
    X[pos] = X[k];
    X[k] = swap;
  }
BYE:
  return(status);
}

canonical_original_code:
int permute_I8(long long *X, long long n)
{
  int status = 0;
  struct drand48_data buffer;
  srand48_r(852187451, &buffer);
  if ( X == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 21, "./AUTOGEN/GENFILES/permute_I8.c"); }; status = -1 ; goto BYE; }; }
  if ( n <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 22, "./AUTOGEN/GENFILES/permute_I8.c"); }; status = -1 ; goto BYE; }; }
  for (long long k = n-1; k >= 0; k--) {
    long long pos;
    double dtemp;
    long long swap;
    drand48_r(&buffer, &dtemp);
    pos = dtemp * n; if ( pos == n ) { pos--; }
    swap = X[pos];
    X[pos] = X[k];
    X[k] = swap;
  }
BYE:
  return(status);
}

variable_types:
X
long long *

variable_types:
n
long long

variable_types: struct drand48_data { unsigned short __x[3]; unsigned short __old_x[3]; unsigned short __c; unsigned short __init; unsigned long long __a; }

variable_types:
k
long long

variable_types:
pos
long long

variable_types: dtemp double

variable_types:
swap
long long


decompiled_code:
__int64 __fastcall g_describe(const char *a1, char *a2, int a3)
{
int v4; // ebp
char *v5; // rbx
char v7[1024]; // [rsp+0h] [rbp-F28h] BYREF
char v8[2052]; // [rsp+400h] [rbp-B28h] BYREF
unsigned int v9; // [rsp+C04h] [rbp-324h] BYREF
__int64 v10; // [rsp+C08h] [rbp-320h] BYREF
__int64 v11; // [rsp+C10h] [rbp-318h] BYREF
__int64 v12; // [rsp+C18h] [rbp-310h] BYREF
char v13[720]; // [rsp+C20h] [rbp-308h] BYREF
char *src; // [rsp+EF0h] [rbp-38h] BYREF
int v15[11]; // [rsp+EFCh] [rbp-2Ch] BYREF

v15[0] = -1;
src = 0LL;
v12 = 0LL;
v11 = 0LL;
v10 = 0LL;
v9 = 0;
g_mmap_meta_data(&g_docroot, &v12, &v11, &v10, &v9);
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "g_describe.c");
v4 = -1;
goto LABEL_13;
}
if ( !a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "g_describe.c");
v4 = -1;
goto LABEL_13;
}
if ( a3 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "g_describe.c");
v4 = -1;
goto LABEL_13;
}
v4 = chk_fld_name(a1);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "g_describe.c");
goto LABEL_13;
}
v4 = g_is_fld(v10, v9, a1, v15, v13);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "g_describe.c");
goto LABEL_13;
}
if ( v15[0] < 0 )
{
strncpy(a2, "Field not found", a3);
return (unsigned int)v4;
}
zero_string(v8, 2048LL);
zero_string(v7, 1024LL);
sprintf(v7, "describe_register d_fld=%s", a1);
v4 = g_make_url(v7, v8);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_describe.c");
goto LABEL_13;
}
v4 = g_call_gpu(v8, &src);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "g_describe.c");
LABEL_13:
v5 = src;
if ( src )
goto LABEL_14;
goto LABEL_15;
}
v5 = src;
if ( src )
{
strncpy(a2, src, a3);
LABEL_14:
free(v5);
src = 0LL;
}
LABEL_15:
g_unmap_meta_data(v12, v11);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, char *a2, int a3)
{
int v4; // ebp
char *v5; // rbx
char v7[1024]; // [rsp+0h] [rbp-F28h] BYREF
char v8[2052]; // [rsp+400h] [rbp-B28h] BYREF
unsigned int v9; // [rsp+C04h] [rbp-324h] BYREF
__int64 v10; // [rsp+C08h] [rbp-320h] BYREF
__int64 v11; // [rsp+C10h] [rbp-318h] BYREF
__int64 v12; // [rsp+C18h] [rbp-310h] BYREF
char v13[720]; // [rsp+C20h] [rbp-308h] BYREF
char *src; // [rsp+EF0h] [rbp-38h] BYREF
int v15[11]; // [rsp+EFCh] [rbp-2Ch] BYREF

v15[0] = -1;
src = 0LL;
v12 = 0LL;
v11 = 0LL;
v10 = 0LL;
v9 = 0;
g_mmap_meta_data(&g_docroot, &v12, &v11, &v10, &v9);
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "g_describe.c");
v4 = -1;
goto LABEL_13;
}
if ( !a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "g_describe.c");
v4 = -1;
goto LABEL_13;
}
if ( a3 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "g_describe.c");
v4 = -1;
goto LABEL_13;
}
v4 = chk_fld_name(a1);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "g_describe.c");
goto LABEL_13;
}
v4 = g_is_fld(v10, v9, a1, v15, v13);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "g_describe.c");
goto LABEL_13;
}
if ( v15[0] < 0 )
{
strncpy(a2, "Field not found", a3);
return (unsigned int)v4;
}
zero_string(v8, 2048LL);
zero_string(v7, 1024LL);
sprintf(v7, "describe_register d_fld=%s", a1);
v4 = g_make_url(v7, v8);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_describe.c");
goto LABEL_13;
}
v4 = g_call_gpu(v8, &src);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "g_describe.c");
LABEL_13:
v5 = src;
if ( src )
goto LABEL_14;
goto LABEL_15;
}
v5 = src;
if ( src )
{
strncpy(a2, src, a3);
LABEL_14:
free(v5);
src = 0LL;
}
LABEL_15:
g_unmap_meta_data(v12, v11);
return (unsigned int)v4;
}

original_code:
int
g_describe(
    char *d_fld,
    char *rslt_buf,
    int sz_rslt_buf
    )
{
  int status = 0;
  int d_fld_id = -1;
  char *curl_response = ((void *)0);
  GPU_REG_TYPE d_fld_rec;
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "g_describe.c"); }; status = -1 ; goto BYE; }; }
  if ( rslt_buf == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "g_describe.c"); }; status = -1 ; goto BYE; }; }
  if ( sz_rslt_buf <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "g_describe.c"); }; status = -1 ; goto BYE; }; }
  status = chk_fld_name(d_fld); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "g_describe.c"); }; status = (status) ; goto BYE; } } };
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "g_describe.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) {
    strncpy(rslt_buf, "Field not found", sz_rslt_buf);
    return(status);
  }
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "describe_register d_fld=%s", d_fld);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_describe.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "g_describe.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    strncpy(rslt_buf, curl_response, sz_rslt_buf);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

canonical_original_code:
int g_describe(char *d_fld, char *rslt_buf, int sz_rslt_buf)
{
  int status = 0;
  int d_fld_id = -1;
  char *curl_response = ((void *)0);
  struct _GPU_REG_TYPE d_fld_rec;
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "g_describe.c"); }; status = -1 ; goto BYE; }; }
  if ( rslt_buf == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "g_describe.c"); }; status = -1 ; goto BYE; }; }
  if ( sz_rslt_buf <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "g_describe.c"); }; status = -1 ; goto BYE; }; }
  status = chk_fld_name(d_fld); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "g_describe.c"); }; status = (status) ; goto BYE; } } };
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "g_describe.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) {
    strncpy(rslt_buf, "Field not found", sz_rslt_buf);
    return(status);
  }
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "describe_register d_fld=%s", d_fld);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_describe.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "g_describe.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    strncpy(rslt_buf, curl_response, sz_rslt_buf);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

variable_types: status int

variable_types: struct _GPU_REG_TYPE { void *reg; unsigned long filesz; _Bool is_busy; long long nR; 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; char filename[-1]; char tbl[-1]; char h_fld[-1]; char d_fld[-1]; }


original_code:
int
countf_I2(
  short *fk_fld,
  int *src_fld,
  long long n,
  long long * restrict cnt,
  int n_out
  )
{
  int status = 0;
  for ( long long i = 0; i < n; i++ ) {
    short idx = fk_fld[i];
    int idxI4 = (int )idx;
    int val = src_fld[i];
    cnt[idxI4] += val;
  }
  return(status);
}

canonical_original_code:
int countf_I2(short *fk_fld, int *src_fld, long long n, long long *cnt, int n_out)
{
  int status = 0;
  for ( long long i = 0; i < n; i++ ) {
    short idx = fk_fld[i];
    int idxI4 = (int )idx;
    int val = src_fld[i];
    cnt[idxI4] += val;
  }
  return(status);
}

variable_types:
cnt
long long *

variable_types:
i
long long

variable_types: idx short

variable_types: val int


decompiled_code:
__int64 __fastcall count_I1(char *a1, __int64 a2, __int64 a3, int a4)
{
char *v6; // rdx
char *v7; // rdi
char v8; // al

if ( a2 <= 0 )
return 0LL;
v6 = a1;
v7 = &a1[a2];
while ( 1 )
{
v8 = *v6;
if ( *v6 >= a4 || v8 < 0 )
break;
++*(_QWORD *)(a3 + 8LL * v8);
if ( ++v6 == v7 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 30LL, "./AUX/count_I1.c");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, __int64 a2, __int64 a3, int a4)
{
char *v6; // rdx
char *v7; // rdi
char v8; // al

if ( a2 <= 0 )
return 0LL;
v6 = a1;
v7 = &a1[a2];
while ( 1 )
{
v8 = *v6;
if ( *v6 >= a4 || v8 < 0 )
break;
++*(_QWORD *)(a3 + 8LL * v8);
if ( ++v6 == v7 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 30LL, "./AUX/count_I1.c");
return 0xFFFFFFFFLL;
}

original_code:
int
count_I1(
  char *in,
  long long n,
  long long * restrict cnt,
  int n_out
  )
{
  int status = 0;
  for ( long long i = 0; i < n; i++ ) {
    char idx = in[i];
    int idxI4 = (int)idx;
    if ( ( idx < 0 ) || ( idx >= n_out ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "./AUX/count_I1.c"); }; status = -1 ; goto BYE; }; }
    cnt[idxI4]++;
  }
 BYE:
  return(status);
}

canonical_original_code:
int count_I1(char *in, long long n, long long *cnt, int n_out)
{
  int status = 0;
  for ( long long i = 0; i < n; i++ ) {
    char idx = in[i];
    int idxI4 = (int)idx;
    if ( ( idx < 0 ) || ( idx >= n_out ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "./AUX/count_I1.c"); }; status = -1 ; goto BYE; }; }
    cnt[idxI4]++;
  }
 BYE:
  return(status);
}

variable_types:
in
char *

variable_types: idx char


decompiled_code:
__int64 __fastcall sorted_array_to_id_freq(_DWORD *a1, __int64 a2, __int64 a3, __int64 a4, _QWORD *a5)
{
_DWORD *v5; // rbp
_DWORD *v8; // rax
__int64 v9; // r11
int v10; // esi
__int64 v11; // rdx
__int64 result; // rax
__int64 v13; // rbx
__int64 v14; // rdi

if ( a1 )
{
v5 = a1;
if ( a3 )
{
if ( a4 )
{
if ( a5 )
{
if ( a2 <= 1 )
{
v10 = 1;
v11 = 0LL;
v13 = 0LL;
}
else
{
v8 = a1;
v9 = (__int64)&a1[a2 - 1];
v10 = 1;
v11 = 0LL;
do
{
if ( *v8 == v8[1] )
{
++v10;
}
else
{
v14 = 4 * v11;
*(_DWORD *)(a3 + 4 * v11++) = *v8;
*(_DWORD *)(a4 + v14) = v10;
v10 = 1;
}
++v8;
}
while ( v8 != (_DWORD *)v9 );
v13 = a2 - 1;
}
*(_DWORD *)(a3 + 4 * v11) = v5[v13];
*(_DWORD *)(a4 + 4 * v11) = v10;
*a5 = v11 + 1;
result = 0LL;
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "sorted_array_to_id_freq.c");
result = 0xFFFFFFFFLL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "sorted_array_to_id_freq.c");
result = 0xFFFFFFFFLL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "sorted_array_to_id_freq.c");
result = 0xFFFFFFFFLL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "sorted_array_to_id_freq.c");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1, __int64 a2, __int64 a3, __int64 a4, _QWORD *a5)
{
_DWORD *v5; // rbp
_DWORD *v8; // rax
__int64 v9; // r11
int v10; // esi
__int64 v11; // rdx
__int64 result; // rax
__int64 v13; // rbx
__int64 v14; // rdi

if ( a1 )
{
v5 = a1;
if ( a3 )
{
if ( a4 )
{
if ( a5 )
{
if ( a2 <= 1 )
{
v10 = 1;
v11 = 0LL;
v13 = 0LL;
}
else
{
v8 = a1;
v9 = (__int64)&a1[a2 - 1];
v10 = 1;
v11 = 0LL;
do
{
if ( *v8 == v8[1] )
{
++v10;
}
else
{
v14 = 4 * v11;
*(_DWORD *)(a3 + 4 * v11++) = *v8;
*(_DWORD *)(a4 + v14) = v10;
v10 = 1;
}
++v8;
}
while ( v8 != (_DWORD *)v9 );
v13 = a2 - 1;
}
*(_DWORD *)(a3 + 4 * v11) = v5[v13];
*(_DWORD *)(a4 + 4 * v11) = v10;
*a5 = v11 + 1;
result = 0LL;
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "sorted_array_to_id_freq.c");
result = 0xFFFFFFFFLL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "sorted_array_to_id_freq.c");
result = 0xFFFFFFFFLL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "sorted_array_to_id_freq.c");
result = 0xFFFFFFFFLL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "sorted_array_to_id_freq.c");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
sorted_array_to_id_freq (
     int * buf,
     long long num_buf,
     int * bf_id,
     int * bf_freq,
     long long * ptr_bf_siz
     )
{
  int status = 0;
  if ( buf == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "sorted_array_to_id_freq.c"); }; status = -1 ; goto BYE; }; }
  if ( bf_id == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "sorted_array_to_id_freq.c"); }; status = -1 ; goto BYE; }; }
  if ( bf_freq == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "sorted_array_to_id_freq.c"); }; status = -1 ; goto BYE; }; }
  if ( ptr_bf_siz == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "sorted_array_to_id_freq.c"); }; status = -1 ; goto BYE; }; }
  long long ii = 0, jj = 0;
  int temp_freq = 1;
  while ( ii < num_buf-1 ) {
    if ( buf[ii] == buf[ii+1] ) {
      temp_freq++;
    }
    else {
      bf_id[jj] = buf[ii];
      bf_freq[jj++] = temp_freq;
      temp_freq = 1;
    }
    ii++;
  }
  bf_id[jj] = buf[ii];
  bf_freq[jj] = temp_freq;
  jj++;
  *ptr_bf_siz = jj;
 BYE:
  return(status);
}

canonical_original_code:
int sorted_array_to_id_freq(int *buf, long long num_buf, int *bf_id, int *bf_freq, long long *ptr_bf_siz)
{
  int status = 0;
  if ( buf == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "sorted_array_to_id_freq.c"); }; status = -1 ; goto BYE; }; }
  if ( bf_id == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "sorted_array_to_id_freq.c"); }; status = -1 ; goto BYE; }; }
  if ( bf_freq == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "sorted_array_to_id_freq.c"); }; status = -1 ; goto BYE; }; }
  if ( ptr_bf_siz == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "sorted_array_to_id_freq.c"); }; status = -1 ; goto BYE; }; }
  long long ii = 0; long long jj = 0;
  int temp_freq = 1;
  while ( ii < num_buf-1 ) {
    if ( buf[ii] == buf[ii+1] ) {
      temp_freq++;
    }
    else {
      bf_id[jj] = buf[ii];
      bf_freq[jj++] = temp_freq;
      temp_freq = 1;
    }
    ii++;
  }
  bf_id[jj] = buf[ii];
  bf_freq[jj] = temp_freq;
  jj++;
  *ptr_bf_siz = jj;
 BYE:
  return(status);
}

variable_types:
buf
int *

variable_types:
ii
long long

variable_types:
jj
long long


decompiled_code:
__int64 __fastcall find_smallest_geq_I8(__int64 a1, __int64 a2, __int64 a3, __int64 *a4)
{
__int64 v7; // rdi
__int64 v8; // rdx
__int64 i; // r8
__int64 v11; // rax

if ( !a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 18LL, "./AUTOGEN/GENFILES/find_smallest_geq_I8.c");
return 0xFFFFFFFFLL;
}
v7 = a2 - 1;
if ( a2 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 19LL, "./AUTOGEN/GENFILES/find_smallest_geq_I8.c");
return 0xFFFFFFFFLL;
}
v8 = v7 / 2;
for ( i = 0LL; ; v8 = (v7 + i) / 2 )
{
v11 = *(_QWORD *)(a1 + 8 * v8);
if ( v11 > a3 )
{
v7 = v8;
goto LABEL_7;
}
if ( v11 >= a3 )
break;
i = v8;
LABEL_7:
if ( (v7 + i) / 2 == v8 )
{
*a4 = i;
return 0LL;
}
}
*a4 = v8;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 *a4)
{
__int64 v7; // rdi
__int64 v8; // rdx
__int64 i; // r8
__int64 v11; // rax

if ( !a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 18LL, "./AUTOGEN/GENFILES/find_smallest_geq_I8.c");
return 0xFFFFFFFFLL;
}
v7 = a2 - 1;
if ( a2 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 19LL, "./AUTOGEN/GENFILES/find_smallest_geq_I8.c");
return 0xFFFFFFFFLL;
}
v8 = v7 / 2;
for ( i = 0LL; ; v8 = (v7 + i) / 2 )
{
v11 = *(_QWORD *)(a1 + 8 * v8);
if ( v11 > a3 )
{
v7 = v8;
goto LABEL_7;
}
if ( v11 >= a3 )
break;
i = v8;
LABEL_7:
if ( (v7 + i) / 2 == v8 )
{
*a4 = i;
return 0LL;
}
}
*a4 = v8;
return 0LL;
}

original_code:
int
find_smallest_geq_I8(
    long long *X,
    long long n,
    long long val,
    long long *ptr_idx
    )
{
  int status = 0;
  long long mid, prev_mid = (-0x7fffffffffffffffLL - 1LL);
  long long bot = 0;
  long long top = n-1;
  if ( X == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 18, "./AUTOGEN/GENFILES/find_smallest_geq_I8.c"); }; status = -1 ; goto BYE; }; }
  if ( n <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 19, "./AUTOGEN/GENFILES/find_smallest_geq_I8.c"); }; status = -1 ; goto BYE; }; }
  for ( ; ; ) {
    mid = ( bot + top ) / 2;
    if ( mid == prev_mid ) { *ptr_idx = bot; break; }
    if ( X[mid] > val ) {
      top = mid;
    }
    else if ( X[mid] < val ) {
      bot = mid;
    }
    else {
      *ptr_idx = mid; break;
    }
    prev_mid = mid;
  }
BYE:
  return(status);
}

canonical_original_code:
int find_smallest_geq_I8(long long *X, long long n, long long val, long long *ptr_idx)
{
  int status = 0;
  long long mid; long long prev_mid = (-0x7fffffffffffffffLL - 1LL);
  long long bot = 0;
  long long top = n-1;
  if ( X == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 18, "./AUTOGEN/GENFILES/find_smallest_geq_I8.c"); }; status = -1 ; goto BYE; }; }
  if ( n <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 19, "./AUTOGEN/GENFILES/find_smallest_geq_I8.c"); }; status = -1 ; goto BYE; }; }
  for ( ; ; ) {
    mid = ( bot + top ) / 2;
    if ( mid == prev_mid ) { *ptr_idx = bot; break; }
    if ( X[mid] > val ) {
      top = mid;
    }
    else if ( X[mid] < val ) {
      bot = mid;
    }
    else {
      *ptr_idx = mid; break;
    }
    prev_mid = mid;
  }
BYE:
  return(status);
}

variable_types:
X
long long *

variable_types:
n
long long

variable_types:
val
long long

variable_types:
mid
long long

variable_types:
bot
long long

variable_types:
top
long long


decompiled_code:
__int64 __fastcall g_f1f2_to_s(const char *a1, const char *a2, const char *a3, char *a4, int a5)
{
int v8; // ebx
char *v9; // rbp
_BYTE v11[712]; // [rsp-590h] [rbp-1798h] BYREF
_BYTE v12[712]; // [rsp-2C8h] [rbp-14D0h] BYREF
char v13[1024]; // [rsp+0h] [rbp-1208h] BYREF
char v14[2060]; // [rsp+400h] [rbp-E08h] BYREF
unsigned int v15; // [rsp+C0Ch] [rbp-5FCh] BYREF
__int64 v16; // [rsp+C10h] [rbp-5F8h] BYREF
__int64 v17; // [rsp+C18h] [rbp-5F0h] BYREF
__int64 v18; // [rsp+C20h] [rbp-5E8h] BYREF
char *src; // [rsp+C28h] [rbp-5E0h] BYREF
__int64 v20[89]; // [rsp+C30h] [rbp-5D8h] BYREF
int v21; // [rsp+EFCh] [rbp-30Ch] BYREF
__int64 v22[89]; // [rsp+F00h] [rbp-308h] BYREF
int v23[15]; // [rsp+11CCh] [rbp-3Ch] BYREF

v23[0] = -1;
v21 = -1;
src = 0LL;
v18 = 0LL;
v17 = 0LL;
v16 = 0LL;
v15 = 0;
g_mmap_meta_data(&g_docroot, &v18, &v17, &v16, &v15);
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 43LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
v8 = g_is_fld(v16, v15, a1, v23, v22);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_f1f2_to_s.c");
goto LABEL_33;
}
if ( v23[0] < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu(LODWORD(v22[4])) )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
v8 = g_is_fld(v16, v15, a2, &v21, v20);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_f1f2_to_s.c");
goto LABEL_33;
}
if ( v21 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu(LODWORD(v20[4])) )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !v22[1] )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !v22[3] )
{
fprintf(stderr, "Line %3d of File %s \n", 56LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !v20[1] )
{
fprintf(stderr, "Line %3d of File %s \n", 57LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !v20[3] )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
qmemcpy(v12, v20, sizeof(v12));
qmemcpy(v11, v22, sizeof(v11));
v8 = g_chk_f1f2_to_s(a3);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "g_f1f2_to_s.c");
goto LABEL_33;
}
zero_string(v14, 2048LL);
zero_string(v13, 1024LL);
sprintf(v13, "f1f2_to_s d_fld1=%s d_fld2=%s op=%s ", a1, a2, a3);
v8 = g_make_url(v13, v14);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "g_f1f2_to_s.c");
goto LABEL_33;
}
v8 = g_call_gpu(v14, &src);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "g_f1f2_to_s.c");
LABEL_33:
v9 = src;
if ( src )
goto LABEL_34;
goto LABEL_35;
}
v9 = src;
if ( src )
{
strncpy(a4, src, a5);
LABEL_34:
free(v9);
src = 0LL;
}
LABEL_35:
g_unmap_meta_data(v18, v17);
return (unsigned int)v8;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2, const char *a3, char *a4, int a5)
{
int v8; // ebx
char *v9; // rbp
_BYTE v11[712]; // [rsp-590h] [rbp-1798h] BYREF
_BYTE v12[712]; // [rsp-2C8h] [rbp-14D0h] BYREF
char v13[1024]; // [rsp+0h] [rbp-1208h] BYREF
char v14[2060]; // [rsp+400h] [rbp-E08h] BYREF
unsigned int v15; // [rsp+C0Ch] [rbp-5FCh] BYREF
__int64 v16; // [rsp+C10h] [rbp-5F8h] BYREF
__int64 v17; // [rsp+C18h] [rbp-5F0h] BYREF
__int64 v18; // [rsp+C20h] [rbp-5E8h] BYREF
char *src; // [rsp+C28h] [rbp-5E0h] BYREF
__int64 v20[89]; // [rsp+C30h] [rbp-5D8h] BYREF
int v21; // [rsp+EFCh] [rbp-30Ch] BYREF
__int64 v22[89]; // [rsp+F00h] [rbp-308h] BYREF
int v23[15]; // [rsp+11CCh] [rbp-3Ch] BYREF

v23[0] = -1;
v21 = -1;
src = 0LL;
v18 = 0LL;
v17 = 0LL;
v16 = 0LL;
v15 = 0;
g_mmap_meta_data(&g_docroot, &v18, &v17, &v16, &v15);
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 43LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
v8 = g_is_fld(v16, v15, a1, v23, v22);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_f1f2_to_s.c");
goto LABEL_33;
}
if ( v23[0] < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu(LODWORD(v22[4])) )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
v8 = g_is_fld(v16, v15, a2, &v21, v20);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_f1f2_to_s.c");
goto LABEL_33;
}
if ( v21 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu(LODWORD(v20[4])) )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !v22[1] )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !v22[3] )
{
fprintf(stderr, "Line %3d of File %s \n", 56LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !v20[1] )
{
fprintf(stderr, "Line %3d of File %s \n", 57LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
if ( !v20[3] )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_f1f2_to_s.c");
v8 = -1;
goto LABEL_33;
}
qmemcpy(v12, v20, sizeof(v12));
qmemcpy(v11, v22, sizeof(v11));
v8 = g_chk_f1f2_to_s(a3);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "g_f1f2_to_s.c");
goto LABEL_33;
}
zero_string(v14, 2048LL);
zero_string(v13, 1024LL);
sprintf(v13, "f1f2_to_s d_fld1=%s d_fld2=%s op=%s ", a1, a2, a3);
v8 = g_make_url(v13, v14);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "g_f1f2_to_s.c");
goto LABEL_33;
}
v8 = g_call_gpu(v14, &src);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "g_f1f2_to_s.c");
LABEL_33:
v9 = src;
if ( src )
goto LABEL_34;
goto LABEL_35;
}
v9 = src;
if ( src )
{
strncpy(a4, src, a5);
LABEL_34:
free(v9);
src = 0LL;
}
LABEL_35:
g_unmap_meta_data(v18, v17);
return (unsigned int)v8;
}

original_code:
int
g_f1f2_to_s(
    char *f1,
    char *f2,
    char *str_op,
    char *rslt_buf,
    int sz_rslt_buf
    )
{
  int status = 0;
  int f1_id = -1; GPU_REG_TYPE f1_rec;
  int f2_id = -1; GPU_REG_TYPE f2_rec;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( str_op == ((void *)0) ) || ( *str_op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 43, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_op == ((void *)0) ) || ( *str_op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f1, &f1_id, &f1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f2, &f2_id, &f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.filesz == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.nR == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( f2_rec.filesz == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( f2_rec.nR == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_f1f2_to_s(f1_rec, f2_rec, str_op); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1f2_to_s d_fld1=%s d_fld2=%s op=%s ", f1, f2, str_op);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    strncpy(rslt_buf, curl_response, sz_rslt_buf);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

canonical_original_code:
int g_f1f2_to_s(char *f1, char *f2, char *str_op, char *rslt_buf, int sz_rslt_buf)
{
  int status = 0;
  int f1_id = -1; struct _GPU_REG_TYPE f1_rec;
  int f2_id = -1; struct _GPU_REG_TYPE f2_rec;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( str_op == ((void *)0) ) || ( *str_op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 43, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_op == ((void *)0) ) || ( *str_op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f1, &f1_id, &f1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f2, &f2_id, &f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.filesz == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.nR == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( f2_rec.filesz == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( f2_rec.nR == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "g_f1f2_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_f1f2_to_s(f1_rec, f2_rec, str_op); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1f2_to_s d_fld1=%s d_fld2=%s op=%s ", f1, f2, str_op);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "g_f1f2_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    strncpy(rslt_buf, curl_response, sz_rslt_buf);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

variable_types: status int

variable_types: struct _GPU_REG_TYPE { void *reg; unsigned long filesz; _Bool is_busy; long long nR; 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; char filename[-1]; char tbl[-1]; char h_fld[-1]; char d_fld[-1]; } *

variable_types:
url
char [2048]

variable_types:
command
char [1024]


original_code:
int
conv_I1_to_B(
    char *X,
    long long nX,
    char * restrict Y
    )
{
  int status = 0;
  long long n;
  unsigned int uix, uiy;
  n = ( nX / 8 ) * 8 ;
  long long xindex = 0;
  long long yindex = 0;
  for ( xindex = 0; xindex < n; ) {
    uiy = 0;
    for ( int j = 0; j < 8; j++ ) {
      uix = X[xindex++];
      if ( ( uix != 0 ) && ( uix != 1 ) ) {
 { fprintf(stderr, "Line %3d of File %s \n", 39, "./AUX/conv_I1_to_B.c"); }; status = -1; continue;
      }
      uix = uix << j;
      uiy = uiy | uix;
    }
    Y[yindex++] = uiy;
  }
  int leftover = nX - n;
  for ( ; xindex < nX; ) {
    uiy = 0;
    for ( int j = 0; j < leftover; j++ ) {
      uix = X[xindex++];
      uix = uix << j;
      uiy = uiy | uix;
    }
    Y[yindex++] = uiy;
  }
  if ( xindex != nX ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "./AUX/conv_I1_to_B.c"); }; status = -1 ; goto BYE; }; }
  long long chk_yindex;
  chk_yindex = nX / 8;
  if ( ( ( nX / 8 ) * 8 ) != nX ) {
    chk_yindex++;
  }
  if ( yindex != chk_yindex ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "./AUX/conv_I1_to_B.c"); }; status = -1 ; goto BYE; }; }
BYE:
  return(status);
}

canonical_original_code:
int conv_I1_to_B(char *X, long long nX, char *Y)
{
  int status = 0;
  long long n;
  unsigned int uix; unsigned int uiy;
  n = ( nX / 8 ) * 8 ;
  long long xindex = 0;
  long long yindex = 0;
  for ( xindex = 0; xindex < n; ) {
    uiy = 0;
    for ( int j = 0; j < 8; j++ ) {
      uix = X[xindex++];
      if ( ( uix != 0 ) && ( uix != 1 ) ) {
 { fprintf(stderr, "Line %3d of File %s \n", 39, "./AUX/conv_I1_to_B.c"); }; status = -1; continue;
      }
      uix = uix << j;
      uiy = uiy | uix;
    }
    Y[yindex++] = uiy;
  }
  int leftover = nX - n;
  for ( ; xindex < nX; ) {
    uiy = 0;
    for ( int j = 0; j < leftover; j++ ) {
      uix = X[xindex++];
      uix = uix << j;
      uiy = uiy | uix;
    }
    Y[yindex++] = uiy;
  }
  if ( xindex != nX ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "./AUX/conv_I1_to_B.c"); }; status = -1 ; goto BYE; }; }
  long long chk_yindex;
  chk_yindex = nX / 8;
  if ( ( ( nX / 8 ) * 8 ) != nX ) {
    chk_yindex++;
  }
  if ( yindex != chk_yindex ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "./AUX/conv_I1_to_B.c"); }; status = -1 ; goto BYE; }; }
BYE:
  return(status);
}

variable_types:
X
char *

variable_types:
nX
long long

variable_types:
Y
char *

variable_types:
uix
unsigned int

variable_types:
uiy
unsigned int

variable_types:
xindex
long long

variable_types:
yindex
long long

variable_types: j int

variable_types: leftover int


decompiled_code:
__int64 __fastcall g_add_fld(const char *a1, const char *a2, const char *a3)
{
int v4; // ebx
__int64 v5; // r14
__int64 v6; // rbx
char *v7; // rbx
char s[1024]; // [rsp+0h] [rbp-F68h] BYREF
char v10[2048]; // [rsp+400h] [rbp-B68h] BYREF
unsigned int v11; // [rsp+C00h] [rbp-368h] BYREF
unsigned int v12; // [rsp+C04h] [rbp-364h] BYREF
__int64 v13; // [rsp+C08h] [rbp-360h] BYREF
__int64 v14; // [rsp+C10h] [rbp-358h] BYREF
__int64 v15; // [rsp+C18h] [rbp-350h] BYREF
int v16; // [rsp+C24h] [rbp-344h] BYREF
char *haystack; // [rsp+C28h] [rbp-340h] BYREF
char v18[716]; // [rsp+C30h] [rbp-338h] BYREF
int v19; // [rsp+EFCh] [rbp-6Ch] BYREF
__int64 v20[7]; // [rsp+F00h] [rbp-68h] BYREF
int v21[11]; // [rsp+F3Ch] [rbp-2Ch] BYREF

v21[0] = -1;
v19 = -1;
haystack = 0LL;
v16 = 0;
v15 = 0LL;
v14 = 0LL;
v13 = 0LL;
v12 = 0;
if ( a1 && *a1 )
{
if ( a2 && *a2 )
{
if ( a3 && *a3 )
{
v4 = chk_fld_name(a2);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "g_add_fld.c");
}
else
{
v4 = unstr_fldtype(a3, &v11);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_add_fld.c");
}
else if ( (unsigned int)is_fldtype_goodfor_gpu(v11) )
{
v4 = is_tbl(a1, v21, v20);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_add_fld.c");
}
else
{
v5 = v20[0];
v4 = get_fld_sz(v11, &v16);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_add_fld.c");
}
else
{
v6 = v5 * v16;
zero_string(v10, 2048LL);
zero_string(v10, 1024LL);
sprintf(
s,
"add_fld filesz=%lld nR=%lld fldtype=%s tbl=%s d_fld=%s h_fld=undefined filename=undefined",
v6,
v5,
a3,
a1,
a2);
v4 = g_make_url(s, v10);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "g_add_fld.c");
}
else
{
v4 = g_call_gpu(v10, &haystack);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_add_fld.c");
}
else
{
v7 = haystack;
if ( haystack && !strstr(haystack, "\"\"") )
fprintf(stderr, "Response from GPU = [%s]\n", v7);
g_mmap_meta_data(&g_docroot, &v15, &v14, &v13, &v12);
v4 = g_is_fld(v13, v12, a2, &v19, v18);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 71LL, "g_add_fld.c");
}
else if ( v19 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 72LL, "g_add_fld.c");
v4 = -1;
}
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_add_fld.c");
v4 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "g_add_fld.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 43LL, "g_add_fld.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "g_add_fld.c");
v4 = -1;
}
if ( haystack )
{
free(haystack);
haystack = 0LL;
}
g_unmap_meta_data(v15, v14);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2, const char *a3)
{
int v4; // ebx
__int64 v5; // r14
__int64 v6; // rbx
char *v7; // rbx
char s[1024]; // [rsp+0h] [rbp-F68h] BYREF
char v10[2048]; // [rsp+400h] [rbp-B68h] BYREF
unsigned int v11; // [rsp+C00h] [rbp-368h] BYREF
unsigned int v12; // [rsp+C04h] [rbp-364h] BYREF
__int64 v13; // [rsp+C08h] [rbp-360h] BYREF
__int64 v14; // [rsp+C10h] [rbp-358h] BYREF
__int64 v15; // [rsp+C18h] [rbp-350h] BYREF
int v16; // [rsp+C24h] [rbp-344h] BYREF
char *haystack; // [rsp+C28h] [rbp-340h] BYREF
char v18[716]; // [rsp+C30h] [rbp-338h] BYREF
int v19; // [rsp+EFCh] [rbp-6Ch] BYREF
__int64 v20[7]; // [rsp+F00h] [rbp-68h] BYREF
int v21[11]; // [rsp+F3Ch] [rbp-2Ch] BYREF

v21[0] = -1;
v19 = -1;
haystack = 0LL;
v16 = 0;
v15 = 0LL;
v14 = 0LL;
v13 = 0LL;
v12 = 0;
if ( a1 && *a1 )
{
if ( a2 && *a2 )
{
if ( a3 && *a3 )
{
v4 = chk_fld_name(a2);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "g_add_fld.c");
}
else
{
v4 = unstr_fldtype(a3, &v11);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_add_fld.c");
}
else if ( (unsigned int)is_fldtype_goodfor_gpu(v11) )
{
v4 = is_tbl(a1, v21, v20);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_add_fld.c");
}
else
{
v5 = v20[0];
v4 = get_fld_sz(v11, &v16);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_add_fld.c");
}
else
{
v6 = v5 * v16;
zero_string(v10, 2048LL);
zero_string(v10, 1024LL);
sprintf(
s,
"add_fld filesz=%lld nR=%lld fldtype=%s tbl=%s d_fld=%s h_fld=undefined filename=undefined",
v6,
v5,
a3,
a1,
a2);
v4 = g_make_url(s, v10);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "g_add_fld.c");
}
else
{
v4 = g_call_gpu(v10, &haystack);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_add_fld.c");
}
else
{
v7 = haystack;
if ( haystack && !strstr(haystack, "\"\"") )
fprintf(stderr, "Response from GPU = [%s]\n", v7);
g_mmap_meta_data(&g_docroot, &v15, &v14, &v13, &v12);
v4 = g_is_fld(v13, v12, a2, &v19, v18);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 71LL, "g_add_fld.c");
}
else if ( v19 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 72LL, "g_add_fld.c");
v4 = -1;
}
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_add_fld.c");
v4 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "g_add_fld.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 43LL, "g_add_fld.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "g_add_fld.c");
v4 = -1;
}
if ( haystack )
{
free(haystack);
haystack = 0LL;
}
g_unmap_meta_data(v15, v14);
return (unsigned int)v4;
}

original_code:
int
g_add_fld(
    char *tbl,
    char *d_fld,
    char *str_fldtype
    )
{
  int status = 0;
  int tbl_id = -1; TBL_REC_TYPE tbl_rec;
  int d_fld_id = -1; GPU_REG_TYPE d_fld_rec;
  char *curl_response = ((void *)0);
  int fldsz = 0; size_t filesz = 0;
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 43, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_fldtype == ((void *)0) ) || ( *str_fldtype == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = chk_fld_name(d_fld); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  FLD_TYPE fldtype;
  status = unstr_fldtype(str_fldtype, &fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( is_fldtype_goodfor_gpu(fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  long long nR = tbl_rec.nR;
  status = get_fld_sz(fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  filesz = nR * fldsz;
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(url, 1024);
  sprintf(command, "add_fld filesz=%lld nR=%lld fldtype=%s tbl=%s d_fld=%s h_fld=undefined filename=undefined",
      (unsigned long long)filesz, nR, str_fldtype, tbl, d_fld);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    if ( strstr(curl_response, "\"\"") == ((void *)0) ) {
      fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
    }
  }
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

canonical_original_code:
int g_add_fld(char *tbl, char *d_fld, char *str_fldtype)
{
  int status = 0;
  int tbl_id = -1; struct _TBL_REC_TYPE tbl_rec;
  int d_fld_id = -1; struct _GPU_REG_TYPE d_fld_rec;
  char *curl_response = ((void *)0);
  int fldsz = 0; unsigned long filesz = 0;
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 43, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_fldtype == ((void *)0) ) || ( *str_fldtype == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = chk_fld_name(d_fld); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  enum _FLD_TYPE fldtype;
  status = unstr_fldtype(str_fldtype, &fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( is_fldtype_goodfor_gpu(fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  long long nR = tbl_rec.nR;
  status = get_fld_sz(fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  filesz = nR * fldsz;
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(url, 1024);
  sprintf(command, "add_fld filesz=%lld nR=%lld fldtype=%s tbl=%s d_fld=%s h_fld=undefined filename=undefined",
      (unsigned long long)filesz, nR, str_fldtype, tbl, d_fld);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    if ( strstr(curl_response, "\"\"") == ((void *)0) ) {
      fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
    }
  }
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "g_add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "g_add_fld.c"); }; status = -1 ; goto BYE; }; }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

variable_types:
tbl
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: struct _GPU_REG_TYPE { void *reg; unsigned long filesz; _Bool is_busy; long long nR; 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; char filename[-1]; char tbl[-1]; char h_fld[-1]; char d_fld[-1]; }

variable_types: fldsz int

variable_types:
filesz
unsigned long

variable_types:
nR
long long

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


original_code:
void
qsort_asc_I1 (
     void *const pbase,
     size_t total_elems,
     size_t size,
     __compar_fn_t cmp
     )
{
  register char *base_ptr = (char *) pbase;
  if ( size != sizeof(char) ) { exit(1); }
  const size_t max_thresh = 4 * size;
  if (total_elems == 0) {
    return;
  }
  if ( total_elems > 4 ) {
    char *lo = base_ptr;
    char *hi = &lo[size * (total_elems - 1)];
    stack_node stack[(8 * sizeof(size_t))];
    stack_node *top = stack;
    ((void) ((top->lo = (((void *)0))), (top->hi = (((void *)0))), ++top));
    while ((stack < top)) {
      char *left_ptr;
      char *right_ptr;
      char *mid = lo + size * ((hi - lo) / size >> 1);
      if ( *((char *)mid) < *((char *)lo) ) {
 { char *ia = (char *)mid; char *ib = (char *)lo; char itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      if ( *((char *)hi) < *((char *)mid) ) {
 { char *ia = (char *)mid; char *ib = (char *)hi; char itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      else {
 goto jump_over;
      }
      if ( *((char *)mid) < *((char *)lo) ) {
 { char *ia = (char *)mid; char *ib = (char *)lo; char itmp = *ia; *ia = *ib; *ib = itmp; };
      }
    jump_over:;
      left_ptr = lo + size;
      right_ptr = hi - size;
      do {
 while ( *((char *)left_ptr) < *((char *)mid) ) {
   left_ptr += size;
 }
 while ( *((char *)mid) < *((char *)right_ptr) ) {
   right_ptr -= size;
 }
 if (left_ptr < right_ptr) {
   { char *ia = (char *)left_ptr; char *ib = (char *)right_ptr; char itmp = *ia; *ia = *ib; *ib = itmp; };
   if (mid == left_ptr) {
     mid = right_ptr;
   }
   else if (mid == right_ptr) {
     mid = left_ptr;
   }
   left_ptr += size;
   right_ptr -= size;
 }
 else if (left_ptr == right_ptr) {
   left_ptr += size;
   right_ptr -= size;
   break;
 }
      } while (left_ptr <= right_ptr);
      if ((size_t) (right_ptr - lo) <= max_thresh) {
 if ((size_t) (hi - left_ptr) <= max_thresh) {
   ((void) (--top, (lo = top->lo), (hi = top->hi)));
 }
 else {
   lo = left_ptr;
 }
      }
      else if ((size_t) (hi - left_ptr) <= max_thresh) {
 hi = right_ptr;
      }
      else if ((right_ptr - lo) > (hi - left_ptr)) {
 ((void) ((top->lo = (lo)), (top->hi = (right_ptr)), ++top));
 lo = left_ptr;
      }
      else {
 ((void) ((top->lo = (left_ptr)), (top->hi = (hi)), ++top));
 hi = right_ptr;
      }
    }
  }
  {
    char *const end_ptr = &base_ptr[size * (total_elems - 1)];
    char *tmp_ptr = base_ptr;
    char *thresh = ((end_ptr) < (base_ptr + max_thresh) ? (end_ptr) : (base_ptr + max_thresh));
    register char *run_ptr;
    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) {
      if ( *((char *)run_ptr) < *((char *) tmp_ptr) ) {
        tmp_ptr = run_ptr;
      }
    }
    if (tmp_ptr != base_ptr) {
      { char *ia = (char *)tmp_ptr; char *ib = (char *)base_ptr; char itmp = *ia; *ia = *ib; *ib = itmp; };
    }
    run_ptr = base_ptr + size;
    while ((run_ptr += size) <= end_ptr) {
      tmp_ptr = run_ptr - size;
      while ( *((char *)run_ptr) < *((char *)tmp_ptr) ) {
 tmp_ptr -= size;
      }
      tmp_ptr += size;
      if (tmp_ptr != run_ptr) {
 char *trav;
 trav = run_ptr + size;
 while (--trav >= run_ptr) {
   char c = *trav;
   char *hi, *lo;
   for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) {
     *hi = *lo;
   }
   *hi = c;
 }
      }
    }
  }
}

canonical_original_code:
void qsort_asc_I1(void *pbase, unsigned long total_elems, unsigned long size, int (*cmp)(void *, void *))
{
  register char *base_ptr = (char *) pbase;
  if ( size != sizeof(char) ) { exit(1); }
  unsigned long max_thresh = 4 * size;
  if (total_elems == 0) {
    return;
  }
  if ( total_elems > 4 ) {
    char *lo = base_ptr;
    char *hi = &lo[size * (total_elems - 1)];
    struct stack_node stack[-1];
    struct stack_node *top = stack;
    ((void) ((top->lo = (((void *)0))), (top->hi = (((void *)0))), ++top));
    while ((stack < top)) {
      char *left_ptr;
      char *right_ptr;
      char *mid = lo + size * ((hi - lo) / size >> 1);
      if ( *((char *)mid) < *((char *)lo) ) {
 { char *ia = (char *)mid; char *ib = (char *)lo; char itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      if ( *((char *)hi) < *((char *)mid) ) {
 { char *ia = (char *)mid; char *ib = (char *)hi; char itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      else {
 goto jump_over;
      }
      if ( *((char *)mid) < *((char *)lo) ) {
 { char *ia = (char *)mid; char *ib = (char *)lo; char itmp = *ia; *ia = *ib; *ib = itmp; };
      }
    jump_over:;
      left_ptr = lo + size;
      right_ptr = hi - size;
      do {
 while ( *((char *)left_ptr) < *((char *)mid) ) {
   left_ptr += size;
 }
 while ( *((char *)mid) < *((char *)right_ptr) ) {
   right_ptr -= size;
 }
 if (left_ptr < right_ptr) {
   { char *ia = (char *)left_ptr; char *ib = (char *)right_ptr; char itmp = *ia; *ia = *ib; *ib = itmp; };
   if (mid == left_ptr) {
     mid = right_ptr;
   }
   else if (mid == right_ptr) {
     mid = left_ptr;
   }
   left_ptr += size;
   right_ptr -= size;
 }
 else if (left_ptr == right_ptr) {
   left_ptr += size;
   right_ptr -= size;
   break;
 }
      } while (left_ptr <= right_ptr);
      if ((unsigned long) (right_ptr - lo) <= max_thresh) {
 if ((unsigned long) (hi - left_ptr) <= max_thresh) {
   ((void) (--top, (lo = top->lo), (hi = top->hi)));
 }
 else {
   lo = left_ptr;
 }
      }
      else if ((unsigned long) (hi - left_ptr) <= max_thresh) {
 hi = right_ptr;
      }
      else if ((right_ptr - lo) > (hi - left_ptr)) {
 ((void) ((top->lo = (lo)), (top->hi = (right_ptr)), ++top));
 lo = left_ptr;
      }
      else {
 ((void) ((top->lo = (left_ptr)), (top->hi = (hi)), ++top));
 hi = right_ptr;
      }
    }
  }
  {
    char *end_ptr = &base_ptr[size * (total_elems - 1)];
    char *tmp_ptr = base_ptr;
    char *thresh = ((end_ptr) < (base_ptr + max_thresh) ? (end_ptr) : (base_ptr + max_thresh));
    register char *run_ptr;
    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) {
      if ( *((char *)run_ptr) < *((char *) tmp_ptr) ) {
        tmp_ptr = run_ptr;
      }
    }
    if (tmp_ptr != base_ptr) {
      { char *ia = (char *)tmp_ptr; char *ib = (char *)base_ptr; char itmp = *ia; *ia = *ib; *ib = itmp; };
    }
    run_ptr = base_ptr + size;
    while ((run_ptr += size) <= end_ptr) {
      tmp_ptr = run_ptr - size;
      while ( *((char *)run_ptr) < *((char *)tmp_ptr) ) {
 tmp_ptr -= size;
      }
      tmp_ptr += size;
      if (tmp_ptr != run_ptr) {
 char *trav;
 trav = run_ptr + size;
 while (--trav >= run_ptr) {
   char c = *trav;
   char *hi; char *lo;
   for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) {
     *hi = *lo;
   }
   *hi = c;
 }
      }
    }
  }
}

variable_types:
pbase
void *

variable_types:
size
unsigned long

variable_types:
cmp
int (*)(void *, void *)

variable_types:
lo
char *

variable_types:
hi
char *

variable_types: struct stack_node { char *lo; char *hi; } [-1]

variable_types: struct stack_node { char *lo; char *hi; } *

variable_types:
mid
char *

variable_types:
ia
char *

variable_types:
ib
char *

variable_types: itmp char

variable_types:
thresh
char *

variable_types:
trav
char *

variable_types: c char


original_code:
int
countf_nn_I4(
  int *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; }
    int idx = fk_fld[i];
    int val = src_fld[i];
    int idxI4 = (int)idx;
    cnt[idxI4] += val;
  }
  return(status);
}

canonical_original_code:
int countf_nn_I4(int *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; }
    int 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: status int

variable_types:
cptr
char *

variable_types:
i
long long

variable_types: idx int

variable_types: val int


original_code:
int
pos_sel_aux_copy_I4_I4(
    int *f1_select,
    int *f1_copy,
    long long nR1,
    int *f2,
    long long nR2,
    int lb,
    int ub,
    int *f3,
    long long *ptr_cnt
    )
{
  int status = 0;
  long long cnt = 0;
  long long i3 = 0;
  for ( long long i2 = 0; i2 < nR2; i2++ ) {
    int f1idx = f2[i2];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "./AUX/pos_sel_aux_copy_I4_I4.c"); }; status = -1 ; goto BYE; }; }
    int val = f1_select[f1idx];
    if ( ( val >= lb ) && ( val <= ub ) ) {
      val = f1_copy[f1idx];
      f3[i3++] = val;
      cnt++;
    }
  }
  *ptr_cnt = cnt;
BYE:
  return(status);
}

canonical_original_code:
int pos_sel_aux_copy_I4_I4(int *f1_select, int *f1_copy, long long nR1, int *f2, long long nR2, int lb, int ub, int *f3, long long *ptr_cnt)
{
  int status = 0;
  long long cnt = 0;
  long long i3 = 0;
  for ( long long i2 = 0; i2 < nR2; i2++ ) {
    int f1idx = f2[i2];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "./AUX/pos_sel_aux_copy_I4_I4.c"); }; status = -1 ; goto BYE; }; }
    int val = f1_select[f1idx];
    if ( ( val >= lb ) && ( val <= ub ) ) {
      val = f1_copy[f1idx];
      f3[i3++] = val;
      cnt++;
    }
  }
  *ptr_cnt = cnt;
BYE:
  return(status);
}

variable_types: lb int

variable_types: ub int

variable_types:
cnt
long long


original_code:
void
core_wisifxthenyelsez_I1(
      char *X,
      char *nn_X,
      long long nR,
      char yval,
      char *in_Y,
      char *nn_Y,
      char zval,
      char *in_Z,
      char *nn_Z,
      char *in_W,
      char *nn_W,
      _Bool *ptr_is_some_null
      )
{
  char *W = (char *)in_W;
  char *Y = (char *)in_Y;
  char *Z = (char *)in_Z;
  for ( long long i = 0; i < nR; i++ ) {
    if ( ( nn_X == ((void *)0) ) || ( nn_X[i] == 1 ) ) {
      if ( X[i] == 1 ) {
 if ( in_Y == ((void *)0) ) {
   W[i] = yval;
   nn_W[i] = 1;
 }
 else {
   if ( ( nn_Y == ((void *)0) ) || ( nn_Y[i] == 1 ) ) {
     W[i] = Y[i];
     nn_W[i] = 1;
   }
   else {
     W[i] = 0;
     nn_W[i] = 0;
     *ptr_is_some_null = 0;
   }
 }
      }
      else if ( X[i] == 0 ) {
 if ( in_Z == ((void *)0) ) {
   W[i] = zval;
   nn_W[i] = 1;
 }
 else {
   if ( ( nn_Z == ((void *)0) ) || ( nn_Z[i] == 1 ) ) {
     W[i] = Z[i];
     nn_W[i] = 1;
   }
   else {
     W[i] = 0;
     nn_W[i] = 0;
     *ptr_is_some_null = 0;
   }
 }
      }
      else {
 exit(-1);
      }
    }
    else {
      W[i] = 0;
      nn_W[i] = 0;
      *ptr_is_some_null = 0;
    }
  }
}

canonical_original_code:
void core_wisifxthenyelsez_I1(char *X, char *nn_X, long long nR, char yval, char *in_Y, char *nn_Y, char zval, char *in_Z, char *nn_Z, char *in_W, char *nn_W, _Bool *ptr_is_some_null)
{
  char *W = (char *)in_W;
  char *Y = (char *)in_Y;
  char *Z = (char *)in_Z;
  for ( long long i = 0; i < nR; i++ ) {
    if ( ( nn_X == ((void *)0) ) || ( nn_X[i] == 1 ) ) {
      if ( X[i] == 1 ) {
 if ( in_Y == ((void *)0) ) {
   W[i] = yval;
   nn_W[i] = 1;
 }
 else {
   if ( ( nn_Y == ((void *)0) ) || ( nn_Y[i] == 1 ) ) {
     W[i] = Y[i];
     nn_W[i] = 1;
   }
   else {
     W[i] = 0;
     nn_W[i] = 0;
     *ptr_is_some_null = 0;
   }
 }
      }
      else if ( X[i] == 0 ) {
 if ( in_Z == ((void *)0) ) {
   W[i] = zval;
   nn_W[i] = 1;
 }
 else {
   if ( ( nn_Z == ((void *)0) ) || ( nn_Z[i] == 1 ) ) {
     W[i] = Z[i];
     nn_W[i] = 1;
   }
   else {
     W[i] = 0;
     nn_W[i] = 0;
     *ptr_is_some_null = 0;
   }
 }
      }
      else {
 exit(-1);
      }
    }
    else {
      W[i] = 0;
      nn_W[i] = 0;
      *ptr_is_some_null = 0;
    }
  }
}

variable_types:
X
char *

variable_types:
nR
long long

variable_types: yval char

variable_types: zval char

variable_types:
W
char *

variable_types:
Y
char *

variable_types:
Z
char *