decompiled_code:
__int64 __fastcall pr_min_max_sum(const char *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, unsigned int a11, int a12, int a13, int a14, int a15, int a16, __int64 a17, __int64 a18, __int64 a19, int a20)
{
__int64 v22; // rdx

if ( !strcmp(a1, "min") )
{
if ( BYTE1(a20) )
{
if ( a11 > 5 )
{
if ( a11 - 6 <= 1 )
{
LABEL_5:
fprintf(g_ofp, "%lf", *(double *)&a18);
return 0LL;
}
goto LABEL_7;
}
if ( a11 <= 1 )
{
LABEL_7:
v22 = 31LL;
LABEL_8:
fprintf(stderr, "Line %3d of File %s \n", v22, "fld_meta.c");
return 0xFFFFFFFFLL;
}
goto LABEL_17;
}
LABEL_11:
fwrite("undef", 1uLL, 5uLL, g_ofp);
return 0LL;
}
if ( strcmp(a1, "max") )
{
if ( strcmp(a1, "sum") )
{
v22 = 76LL;
goto LABEL_8;
}
if ( !(_BYTE)a20 )
goto LABEL_11;
a18 = a17;
if ( a11 > 5 )
{
if ( a11 - 6 <= 1 )
goto LABEL_5;
}
else if ( a11 > 1 )
{
goto LABEL_17;
}
v22 = 67LL;
goto LABEL_8;
}
if ( !BYTE2(a20) )
goto LABEL_11;
a18 = a19;
if ( a11 > 5 )
{
if ( a11 - 6 <= 1 )
goto LABEL_5;
goto LABEL_20;
}
if ( a11 <= 1 )
{
LABEL_20:
v22 = 49LL;
goto LABEL_8;
}
LABEL_17:
fprintf(g_ofp, "%lld", a18);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, int a9, int a10, unsigned int a11, int a12, int a13, int a14, int a15, int a16, __int64 a17, __int64 a18, __int64 a19, int a20)
{
__int64 v22; // rdx

if ( !strcmp(a1, "min") )
{
if ( BYTE1(a20) )
{
if ( a11 > 5 )
{
if ( a11 - 6 <= 1 )
{
LABEL_5:
fprintf(g_ofp, "%lf", *(double *)&a18);
return 0LL;
}
goto LABEL_7;
}
if ( a11 <= 1 )
{
LABEL_7:
v22 = 31LL;
LABEL_8:
fprintf(stderr, "Line %3d of File %s \n", v22, "fld_meta.c");
return 0xFFFFFFFFLL;
}
goto LABEL_17;
}
LABEL_11:
fwrite("undef", 1uLL, 5uLL, g_ofp);
return 0LL;
}
if ( strcmp(a1, "max") )
{
if ( strcmp(a1, "sum") )
{
v22 = 76LL;
goto LABEL_8;
}
if ( !(_BYTE)a20 )
goto LABEL_11;
a18 = a17;
if ( a11 > 5 )
{
if ( a11 - 6 <= 1 )
goto LABEL_5;
}
else if ( a11 > 1 )
{
goto LABEL_17;
}
v22 = 67LL;
goto LABEL_8;
}
if ( !BYTE2(a20) )
goto LABEL_11;
a18 = a19;
if ( a11 > 5 )
{
if ( a11 - 6 <= 1 )
goto LABEL_5;
goto LABEL_20;
}
if ( a11 <= 1 )
{
LABEL_20:
v22 = 49LL;
goto LABEL_8;
}
LABEL_17:
fprintf(g_ofp, "%lld", a18);
return 0LL;
}

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

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

variable_types:
mode
char *

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

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


repo: linkedin/datacl

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

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

variable_types:
tbl
char *

variable_types:
fld
char *

variable_types: status int

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

variable_types:
cptr
char *

return_type: int

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

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

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

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

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

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


decompiled_code:
__int64 __fastcall int_get_fld_meta(_BYTE *a1, __int64 a2, __int64 a3, int a4, const char *a5, char *a6)
{
__int64 v9; // rbx
unsigned int v10; // er13
__int64 v12; // rdx
unsigned int v13; // [rsp+4h] [rbp-164h] BYREF
int v14; // [rsp+8h] [rbp-160h] BYREF
int v15; // [rsp+Ch] [rbp-15Ch] BYREF
char v16[48]; // [rsp+10h] [rbp-158h] BYREF
char v17[128]; // [rsp+40h] [rbp-128h] BYREF
char v18[168]; // [rsp+C0h] [rbp-A8h] BYREF

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

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

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

variable_types:
attr
char *

variable_types:
value
char *

variable_types: sz int

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


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

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

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

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

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

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

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


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

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

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

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

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

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

variable_types: fileno int

variable_types: i int


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

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

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

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

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

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

variable_types:
uitemp
unsigned int


decompiled_code:
__int64 __fastcall mk_hashes_I4(int *a1, int a2, _QWORD *a3, unsigned int *a4, unsigned int *a5, unsigned int *a6)
{
__int64 v6; // rbx
_DWORD *v7; // r13
_BYTE *v8; // r14
__int64 v9; // rax
__int64 v10; // rbx
__int64 v11; // rax
unsigned int v12; // ebp
__int64 v13; // rax
unsigned int v14; // er12
int *v15; // rcx
__int64 v16; // rsi
__int64 v17; // rdx
unsigned int v18; // ebx
__int64 v19; // rax
int v20; // ecx
char v21; // dl
unsigned int v22; // er12
__int64 v24; // rdx
__int64 v25; // rdx
unsigned int size; // [rsp+Ch] [rbp-5Ch]

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

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, int a2, _QWORD *a3, unsigned int *a4, unsigned int *a5, unsigned int *a6)
{
__int64 v6; // rbx
_DWORD *v7; // r13
_BYTE *v8; // r14
__int64 v9; // rax
__int64 v10; // rbx
__int64 v11; // rax
unsigned int v12; // ebp
__int64 v13; // rax
unsigned int v14; // er12
int *v15; // rcx
__int64 v16; // rsi
__int64 v17; // rdx
unsigned int v18; // ebx
__int64 v19; // rax
int v20; // ecx
char v21; // dl
unsigned int v22; // er12
__int64 v24; // rdx
__int64 v25; // rdx
unsigned int size; // [rsp+Ch] [rbp-5Ch]

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

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

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

variable_types:
scalars
int *

variable_types:
hashes
int *

variable_types:
used
unsigned char *

variable_types:
n
unsigned int

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types: iter int

variable_types:
val
unsigned long long

variable_types:
ltemp
unsigned long long

variable_types:
loc
unsigned short


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

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

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

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

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

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

variable_types:
dir
char *

variable_types: status int


decompiled_code:
__int64 __fastcall mk_temp_file(__int64 a1, _BOOL4 *a2, int *a3)
{
__int64 v4; // rbp
_BYTE *v5; // rbp
int v6; // eax
int v7; // er15
int v8; // er12
__int64 v10; // rdx
_BOOL4 v11; // [rsp+Ch] [rbp-6Ch]
unsigned __int64 v12; // [rsp+18h] [rbp-60h] BYREF
char s[8]; // [rsp+20h] [rbp-58h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _BOOL4 *a2, int *a3)
{
__int64 v4; // rbp
_BYTE *v5; // rbp
int v6; // eax
int v7; // er15
int v8; // er12
__int64 v10; // rdx
_BOOL4 v11; // [rsp+Ch] [rbp-6Ch]
unsigned __int64 v12; // [rsp+18h] [rbp-60h] BYREF
char s[8]; // [rsp+20h] [rbp-58h] BYREF

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

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

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

variable_types:
filesz
unsigned long

variable_types:
reserve
unsigned long

variable_types:
filename
char [32]


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

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

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

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


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


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

assign_const_I1(a3 + a1, 0LL, (unsigned int)(char)(a4 - a3));
if ( !a2 )
return 0LL;
v8 = a2 + 4 * a3;
if ( a5 == 300 )
{
assign_const_I4(v8, 0xFFFFFFFF80000000LL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 <= 300 )
{
if ( a5 == 100 )
{
LABEL_14:
assign_const_I4(v8, 0LL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 != 200 )
goto LABEL_7;
assign_const_I4(v8, 0x7FFFFFFFLL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 != 700 )
{
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_14;
}
assign_const_I4(v8, 0xFFFFFFFFLL, (unsigned int)(a4 - a3));
return 0LL;
}

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

assign_const_I1(a3 + a1, 0LL, (unsigned int)(char)(a4 - a3));
if ( !a2 )
return 0LL;
v8 = a2 + 4 * a3;
if ( a5 == 300 )
{
assign_const_I4(v8, 0xFFFFFFFF80000000LL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 <= 300 )
{
if ( a5 == 100 )
{
LABEL_14:
assign_const_I4(v8, 0LL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 != 200 )
goto LABEL_7;
assign_const_I4(v8, 0x7FFFFFFFLL, (unsigned int)(a4 - a3));
return 0LL;
}
if ( a5 != 700 )
{
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_14;
}
assign_const_I4(v8, 0xFFFFFFFFLL, (unsigned int)(a4 - a3));
return 0LL;
}

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


decompiled_code:
__int64 __fastcall process_aux_info(_BYTE *a1, char *a2, char *a3, char *a4)
{
char v6; // r15
char v7; // al
char v8; // dl
unsigned int v9; // er12
__int64 v11; // rdx
char v12; // [rsp+Fh] [rbp-59h] BYREF
char s1[88]; // [rsp+10h] [rbp-58h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, char *a2, char *a3, char *a4)
{
char v6; // r15
char v7; // al
char v8; // dl
unsigned int v9; // er12
__int64 v11; // rdx
char v12; // [rsp+Fh] [rbp-59h] BYREF
char s1[88]; // [rsp+10h] [rbp-58h] BYREF

zero_string(s1, 32LL);
if ( a1 && *a1 )
{
v9 = chk_aux_info(a1);
if ( (v9 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 24LL, "aux_dld.c");
return v9;
}
zero_string(s1, 32LL);
extract_S(a1, "ignore_hdr=[", "]", s1, 32LL, &v12);
v6 = v12;
if ( v12 )
{
v6 = 0;
}
else if ( !strcasecmp(s1, "true") )
{
v6 = 1;
}
else if ( strcasecmp(s1, "false") )
{
v11 = 38LL;
goto LABEL_21;
}
zero_string(s1, 32LL);
v9 = extract_S(a1, "fld_sep=[", "]", s1, 32LL, &v12);
if ( v12 || !strcasecmp(s1, "comma") )
{
v7 = 34;
v8 = 44;
goto LABEL_4;
}
if ( !strcasecmp(s1, "tab") )
{
v7 = 0;
v8 = 9;
goto LABEL_4;
}
if ( !strcasecmp(s1, "ctrl_z") )
{
v7 = 0;
v8 = 26;
goto LABEL_4;
}
v11 = 59LL;
LABEL_21:
v9 = -1;
fprintf(stderr, "Line %3d of File %s \n", v11, "aux_dld.c");
return v9;
}
v6 = 0;
v7 = 34;
v8 = 44;
v9 = 0;
LABEL_4:
*a2 = v6;
*a3 = v8;
*a4 = v7;
return 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, __int64 a3)
{
unsigned __int64 *v4; // rbx
__m128d v5; // xmm0

if ( a2 > 0 )
{
v4 = a1;
do
{
v5 = (__m128d)*v4++;
a3 += 8LL;
*(double *)(a3 - 8) = normPvalue(v5);
}
while ( v4 != &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; // er15
char *v7; // rbp
__int64 v9; // rdx
_BYTE v10[712]; // [rsp-B20h] [rbp-22D8h] BYREF
_BYTE v11[712]; // [rsp-858h] [rbp-2010h] BYREF
_BYTE v12[712]; // [rsp-590h] [rbp-1D48h] BYREF
_BYTE v13[712]; // [rsp-2C8h] [rbp-1A80h] BYREF
int v14; // [rsp+Ch] [rbp-17ACh] BYREF
int v15; // [rsp+10h] [rbp-17A8h] BYREF
int v16; // [rsp+14h] [rbp-17A4h] BYREF
int v17; // [rsp+18h] [rbp-17A0h] BYREF
unsigned int v18; // [rsp+1Ch] [rbp-179Ch] BYREF
char *haystack; // [rsp+20h] [rbp-1798h] BYREF
__int64 v20; // [rsp+28h] [rbp-1790h] BYREF
__int64 v21; // [rsp+30h] [rbp-1788h] BYREF
__int64 v22; // [rsp+38h] [rbp-1780h] BYREF
int v23[180]; // [rsp+40h] [rbp-1778h] BYREF
int v24[180]; // [rsp+310h] [rbp-14A8h] BYREF
int v25[180]; // [rsp+5E0h] [rbp-11D8h] BYREF
int v26[180]; // [rsp+8B0h] [rbp-F08h] BYREF
char s[1024]; // [rsp+B80h] [rbp-C38h] BYREF
char v28[2104]; // [rsp+F80h] [rbp-838h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, char *a2, char *a3, char *s2)
{
int v6; // er15
char *v7; // rbp
__int64 v9; // rdx
_BYTE v10[712]; // [rsp-B20h] [rbp-22D8h] BYREF
_BYTE v11[712]; // [rsp-858h] [rbp-2010h] BYREF
_BYTE v12[712]; // [rsp-590h] [rbp-1D48h] BYREF
_BYTE v13[712]; // [rsp-2C8h] [rbp-1A80h] BYREF
int v14; // [rsp+Ch] [rbp-17ACh] BYREF
int v15; // [rsp+10h] [rbp-17A8h] BYREF
int v16; // [rsp+14h] [rbp-17A4h] BYREF
int v17; // [rsp+18h] [rbp-17A0h] BYREF
unsigned int v18; // [rsp+1Ch] [rbp-179Ch] BYREF
char *haystack; // [rsp+20h] [rbp-1798h] BYREF
__int64 v20; // [rsp+28h] [rbp-1790h] BYREF
__int64 v21; // [rsp+30h] [rbp-1788h] BYREF
__int64 v22; // [rsp+38h] [rbp-1780h] BYREF
int v23[180]; // [rsp+40h] [rbp-1778h] BYREF
int v24[180]; // [rsp+310h] [rbp-14A8h] BYREF
int v25[180]; // [rsp+5E0h] [rbp-11D8h] BYREF
int v26[180]; // [rsp+8B0h] [rbp-F08h] BYREF
char s[1024]; // [rsp+B80h] [rbp-C38h] BYREF
char v28[2104]; // [rsp+F80h] [rbp-838h] BYREF

v14 = -1;
v15 = -1;
v16 = -1;
v17 = -1;
haystack = 0LL;
v20 = 0LL;
v21 = 0LL;
v22 = 0LL;
v18 = 0;
g_mmap_meta_data(&g_docroot, &v20, &v21, &v22, &v18);
if ( !s1 || !*s1 )
{
v9 = 46LL;
LABEL_43:
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", v9, "g_countf.c");
goto LABEL_33;
}
if ( !a2 || !*a2 )
{
v9 = 47LL;
goto LABEL_43;
}
if ( !a3 || !*a3 )
{
v9 = 48LL;
goto LABEL_43;
}
if ( !strcmp(s1, a2) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_countf.c");
goto LABEL_33;
}
if ( !strcmp(s1, a3) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_countf.c");
goto LABEL_33;
}
if ( !strcmp(s1, s2) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_countf.c");
goto LABEL_33;
}
if ( !strcmp(a2, a3) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 52LL, "g_countf.c");
goto LABEL_33;
}
if ( !strcmp(a2, s2) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_countf.c");
goto LABEL_33;
}
if ( !strcmp(a3, s2) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 54LL, "g_countf.c");
goto LABEL_33;
}
v6 = g_is_fld(v22, v18, s1, &v14, v23);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 56LL, "g_countf.c");
goto LABEL_33;
}
if ( v14 < 0 )
{
v9 = 57LL;
goto LABEL_43;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v23[8]) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_countf.c");
goto LABEL_33;
}
v6 = g_is_fld(v22, v18, a2, &v15, v24);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "g_countf.c");
goto LABEL_33;
}
if ( v15 < 0 )
{
v9 = 61LL;
goto LABEL_43;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v24[8]) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 62LL, "g_countf.c");
goto LABEL_33;
}
v6 = g_is_fld(v22, v18, a3, &v16, v25);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "g_countf.c");
goto LABEL_33;
}
if ( v16 < 0 )
{
v9 = 65LL;
goto LABEL_43;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v25[8]) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 66LL, "g_countf.c");
goto LABEL_33;
}
v6 = g_is_fld(v22, v18, s2, &v17, v26);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 68LL, "g_countf.c");
goto LABEL_33;
}
if ( v17 < 0 )
{
v9 = 69LL;
goto LABEL_43;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v26[8]) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 70LL, "g_countf.c");
goto LABEL_33;
}
qmemcpy(v13, v26, sizeof(v13));
qmemcpy(v12, v25, sizeof(v12));
qmemcpy(v11, v24, sizeof(v11));
qmemcpy(v10, v23, sizeof(v10));
v6 = g_chk_countf();
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "g_countf.c");
goto LABEL_33;
}
zero_string(v28, 2048LL);
zero_string(s, 1024LL);
sprintf(s, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s d_out=%s", s1, a2, a3, s2);
v6 = g_make_url(s, v28);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 79LL, "g_countf.c");
goto LABEL_33;
}
v6 = g_call_gpu(v28, &haystack);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "g_countf.c");
goto LABEL_33;
}
v7 = haystack;
if ( haystack )
{
if ( strstr(haystack, "\"\"") )
{
LABEL_30:
free(v7);
haystack = 0LL;
goto LABEL_31;
}
fprintf(stderr, "Response from GPU = [%s]\n", v7);
LABEL_33:
v7 = haystack;
if ( !haystack )
goto LABEL_31;
goto LABEL_30;
}
LABEL_31:
g_unmap_meta_data(v20, 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; // rax
__int64 v5; // rdx
__int64 v8; // rdx
double result; // [rsp+8h] [rbp-50h] BYREF
struct drand48_data buffer; // [rsp+10h] [rbp-48h] BYREF

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

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

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

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: status int

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)
{
__int64 v4; // rdx
int v5; // er13
char *v6; // r12
int v8; // [rsp+8h] [rbp-F20h] BYREF
unsigned int v9; // [rsp+Ch] [rbp-F1Ch] BYREF
char *src; // [rsp+10h] [rbp-F18h] BYREF
__int64 v11; // [rsp+18h] [rbp-F10h] BYREF
__int64 v12; // [rsp+20h] [rbp-F08h] BYREF
__int64 v13; // [rsp+28h] [rbp-F00h] BYREF
char v14[720]; // [rsp+30h] [rbp-EF8h] BYREF
char s[1024]; // [rsp+300h] [rbp-C28h] BYREF
char v16[2088]; // [rsp+700h] [rbp-828h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, char *a2, int a3)
{
__int64 v4; // rdx
int v5; // er13
char *v6; // r12
int v8; // [rsp+8h] [rbp-F20h] BYREF
unsigned int v9; // [rsp+Ch] [rbp-F1Ch] BYREF
char *src; // [rsp+10h] [rbp-F18h] BYREF
__int64 v11; // [rsp+18h] [rbp-F10h] BYREF
__int64 v12; // [rsp+20h] [rbp-F08h] BYREF
__int64 v13; // [rsp+28h] [rbp-F00h] BYREF
char v14[720]; // [rsp+30h] [rbp-EF8h] BYREF
char s[1024]; // [rsp+300h] [rbp-C28h] BYREF
char v16[2088]; // [rsp+700h] [rbp-828h] BYREF

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

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