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

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


repo: linkedin/datacl

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_L.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_L.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_L.c"); }; status = -1 ; goto BYE; };
      break;
    }
  }
 BYE:
  return(status);
}

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

variable_types:
lb
long long

variable_types:
ub
long long

variable_types: status int

return_type: int


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

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

variable_types: lb int

variable_types: ub int

variable_types:
cnt
long long

variable_types: val int


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

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

variable_types:
n
long long

variable_types:
cfld
char *

variable_types:
cnt
long long *

variable_types:
cptr
char *

variable_types:
i
long long

variable_types: idx short


original_code:
int
pos_count_I8_I8(
    long long *f1,
    long long nR1,
    long long *f2,
    long long nR2,
    int *f3,
    long long nR3
    )
{
  int status = 0;
  for ( long long i = 0; i < nR2; i++ ) {
    long long f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "./AUX/pos_count_I8_I8.c"); }; status = -1 ; goto BYE; }; }
    long long f3idx = f1[f1idx];
    if ( ( f3idx < 0 ) || ( f3idx >= nR3 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "./AUX/pos_count_I8_I8.c"); }; status = -1 ; goto BYE; }; }
    f3[f3idx]++;
  }
BYE:
  return(status);
}

canonical_original_code:
int pos_count_I8_I8(long long *f1, long long nR1, long long *f2, long long nR2, int *f3, long long nR3)
{
  int status = 0;
  for ( long long i = 0; i < nR2; i++ ) {
    long long f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "./AUX/pos_count_I8_I8.c"); }; status = -1 ; goto BYE; }; }
    long long f3idx = f1[f1idx];
    if ( ( f3idx < 0 ) || ( f3idx >= nR3 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "./AUX/pos_count_I8_I8.c"); }; status = -1 ; goto BYE; }; }
    f3[f3idx]++;
  }
BYE:
  return(status);
}


decompiled_code:
__int64 __fastcall sort2_dsc_F4(float *a1, float *a2)
{
__int64 result; // rax
float v3; // xmm3_4
float v4; // xmm2_4

result = 1LL;
v3 = a1[1];
v4 = a2[1];
if ( *a2 <= *a1 )
{
result = 0xFFFFFFFFLL;
if ( *a1 <= *a2 )
{
result = 1LL;
if ( v4 <= v3 )
result = (unsigned int)-(v3 > v4);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(float *a1, float *a2)
{
__int64 result; // rax
float v3; // xmm3_4
float v4; // xmm2_4

result = 1LL;
v3 = a1[1];
v4 = a2[1];
if ( *a2 <= *a1 )
{
result = 0xFFFFFFFFLL;
if ( *a1 <= *a2 )
{
result = 1LL;
if ( v4 <= v3 )
result = (unsigned int)-(v3 > v4);
}
}
return result;
}

original_code:
int sort2_dsc_F4(
         const void *ii,
         const void *jj
         )
{
  float val11, val12, val21,val22;
  float *ptr1, *ptr2;
  ptr1 = (float *)ii;
  ptr2 = (float *)jj;
  val11 = *ptr1++;
  val12 = *ptr1++;
  val21 = *ptr2++;
  val22 = *ptr2++;
  if ( val11 < val21 ) {
    return (1);
  }
  else if ( val11 > val21 ) {
    return (-1);
  }
  else {
    if ( val12 < val22 ) {
      return (1);
    }
    else if ( val12 > val22 ) {
      return (-1);
    }
    else {
      return(0);
    }
  }
}

canonical_original_code:
int sort2_dsc_F4(void *ii, void *jj)
{
  float val11; float val12; float val21; float val22;
  float *ptr1; float *ptr2;
  ptr1 = (float *)ii;
  ptr2 = (float *)jj;
  val11 = *ptr1++;
  val12 = *ptr1++;
  val21 = *ptr2++;
  val22 = *ptr2++;
  if ( val11 < val21 ) {
    return (1);
  }
  else if ( val11 > val21 ) {
    return (-1);
  }
  else {
    if ( val12 < val22 ) {
      return (1);
    }
    else if ( val12 > val22 ) {
      return (-1);
    }
    else {
      return(0);
    }
  }
}

variable_types:
ii
void *

variable_types:
jj
void *


decompiled_code:
__int64 __fastcall pos_copy_I4_I8(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v6; // rax
__int64 v9; // rdx

if ( a4 <= 0 )
return 0LL;
v6 = 0LL;
while ( 1 )
{
v9 = *(_QWORD *)(a3 + 8 * v6);
if ( v9 < 0 || v9 >= a2 )
break;
*(_DWORD *)(a5 + 4 * v6++) = *(_DWORD *)(a1 + 4 * v9);
if ( a4 == v6 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 29LL, "./AUX/pos_copy_I4_I8.c");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v6; // rax
__int64 v9; // rdx

if ( a4 <= 0 )
return 0LL;
v6 = 0LL;
while ( 1 )
{
v9 = *(_QWORD *)(a3 + 8 * v6);
if ( v9 < 0 || v9 >= a2 )
break;
*(_DWORD *)(a5 + 4 * v6++) = *(_DWORD *)(a1 + 4 * v9);
if ( a4 == v6 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 29LL, "./AUX/pos_copy_I4_I8.c");
return 0xFFFFFFFFLL;
}

original_code:
int
pos_copy_I4_I8(
    int *f1,
    long long nR1,
    long long *f2,
    long long nR2,
    int *f3
    )
{
  int status = 0;
  for ( long long i = 0; i < nR2; i++ ) {
    long long f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 29, "./AUX/pos_copy_I4_I8.c"); }; status = -1 ; goto BYE; }; }
    int ival = f1[f1idx];
    f3[i] = ival;
  }
BYE:
  return(status);
}

canonical_original_code:
int pos_copy_I4_I8(int *f1, long long nR1, long long *f2, long long nR2, int *f3)
{
  int status = 0;
  for ( long long i = 0; i < nR2; i++ ) {
    long long f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 29, "./AUX/pos_copy_I4_I8.c"); }; status = -1 ; goto BYE; }; }
    int ival = f1[f1idx];
    f3[i] = ival;
  }
BYE:
  return(status);
}

variable_types: ival int


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

if ( a4 > 8 )
result = cmp_eq_mult_scalar_log_I1();
else
result = cmp_eq_mult_scalar_simple_I1();
return result;
}

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

if ( a4 > 8 )
result = cmp_eq_mult_scalar_log_I1();
else
result = cmp_eq_mult_scalar_simple_I1();
return result;
}

original_code:
void
cmp_eq_mult_scalar_I1(
         char *in1,
         long long n1,
         char *in2,
         int n2,
         char * restrict out
          )
{
  if ( n2 <= 8 ) {
    cmp_eq_mult_scalar_simple_I1( in1, n1, in2, n2, out);
  }
  else
    cmp_eq_mult_scalar_log_I1( in1, n1, in2, n2, out);
}

canonical_original_code:
void cmp_eq_mult_scalar_I1(char *in1, long long n1, char *in2, int n2, char *out)
{
  if ( n2 <= 8 ) {
    cmp_eq_mult_scalar_simple_I1( in1, n1, in2, n2, out);
  }
  else
    cmp_eq_mult_scalar_log_I1( in1, n1, in2, n2, out);
}

variable_types:
out
char *

return_type: void


decompiled_code:
__int64 __fastcall get_empty_fld(_BYTE *a1, __int64 a2, int a3, int *a4)
{
unsigned int v7; // er8
int v8; // esi
int v9; // ecx
__int64 v10; // rax
_BYTE *v12; // rcx
int v13; // eax
unsigned int v14; // [rsp+4h] [rbp-34h] BYREF
struct timezone tz; // [rsp+8h] [rbp-30h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

if ( a1 && *a1 )
{
v7 = hash_string_UI4(a1, &v14);
v14 %= (unsigned int)a3;
v8 = v14;
}
else
{
gettimeofday(&tv, &tz);
v7 = 0;
v14 = tv.tv_usec % a3;
v8 = v14;
}
*a4 = 0x80000000;
if ( a3 > v8 )
{
v9 = v8;
v10 = a2 + 224LL * v8;
while ( *(_BYTE *)(v10 + 32) )
{
++v9;
v10 += 224LL;
if ( a3 == v9 )
goto LABEL_10;
}
*a4 = v9;
if ( v9 >= 0 )
return v7;
}
LABEL_10:
v12 = (_BYTE *)(a2 + 32);
v13 = 0;
if ( !v8 )
{
LABEL_11:
fwrite("TO BE IMPLEMENTED\n", 1uLL, 0x12uLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 70LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
while ( *v12 )
{
++v13;
v12 += 224;
if ( v8 == v13 )
goto LABEL_11;
}
*a4 = v13;
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, __int64 a2, int a3, int *a4)
{
unsigned int v7; // er8
int v8; // esi
int v9; // ecx
__int64 v10; // rax
_BYTE *v12; // rcx
int v13; // eax
unsigned int v14; // [rsp+4h] [rbp-34h] BYREF
struct timezone tz; // [rsp+8h] [rbp-30h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

if ( a1 && *a1 )
{
v7 = hash_string_UI4(a1, &v14);
v14 %= (unsigned int)a3;
v8 = v14;
}
else
{
gettimeofday(&tv, &tz);
v7 = 0;
v14 = tv.tv_usec % a3;
v8 = v14;
}
*a4 = 0x80000000;
if ( a3 > v8 )
{
v9 = v8;
v10 = a2 + 224LL * v8;
while ( *(_BYTE *)(v10 + 32) )
{
++v9;
v10 += 224LL;
if ( a3 == v9 )
goto LABEL_10;
}
*a4 = v9;
if ( v9 >= 0 )
return v7;
}
LABEL_10:
v12 = (_BYTE *)(a2 + 32);
v13 = 0;
if ( !v8 )
{
LABEL_11:
fwrite("TO BE IMPLEMENTED\n", 1uLL, 0x12uLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 70LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
while ( *v12 )
{
++v13;
v12 += 224;
if ( v8 == v13 )
goto LABEL_11;
}
*a4 = v13;
return v7;
}

original_code:
int
get_empty_fld(
    const char *fld,
       FLD_REC_TYPE *flds,
       int n_fld,
       int *ptr_fld_id
       )
{
  int status = 0;
  unsigned int startidx;
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) {
    struct timeval Tps; struct timezone Tpf;
    gettimeofday(&Tps, &Tpf);
    startidx = Tps.tv_usec % n_fld;
  }
  else {
    status = hash_string_UI4(fld, &startidx);
    startidx = startidx % n_fld;
  }
  *ptr_fld_id = (-0x7fffffff - 1);
  for ( int i = startidx; i < n_fld; i++ ) {
    if ( flds[i].name[0] == '\0' ) {
      *ptr_fld_id = i;
      break;
    }
  }
  if ( *ptr_fld_id < 0 ) {
  for ( int i = 0; i < startidx; i++ ) {
    if ( flds[i].name[0] == '\0' ) {
      *ptr_fld_id = i;
      break;
    }
  }
  }
  if ( *ptr_fld_id < 0 ) {
    fprintf(stderr, "TO BE IMPLEMENTED\n");
    { { fprintf(stderr, "Line %3d of File %s \n", 70, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; };
  }
 BYE:
  return(status);
}

canonical_original_code:
int get_empty_fld(char *fld, struct _FLD_REC_TYPE *flds, int n_fld, int *ptr_fld_id)
{
  int status = 0;
  unsigned int startidx;
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) {
    struct timeval Tps; struct timezone Tpf;
    gettimeofday(&Tps, &Tpf);
    startidx = Tps.tv_usec % n_fld;
  }
  else {
    status = hash_string_UI4(fld, &startidx);
    startidx = startidx % n_fld;
  }
  *ptr_fld_id = (-0x7fffffff - 1);
  for ( int i = startidx; i < n_fld; i++ ) {
    if ( flds[i].name[0] == '\0' ) {
      *ptr_fld_id = i;
      break;
    }
  }
  if ( *ptr_fld_id < 0 ) {
  for ( int i = 0; i < startidx; i++ ) {
    if ( flds[i].name[0] == '\0' ) {
      *ptr_fld_id = i;
      break;
    }
  }
  }
  if ( *ptr_fld_id < 0 ) {
    fprintf(stderr, "TO BE IMPLEMENTED\n");
    { { fprintf(stderr, "Line %3d of File %s \n", 70, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; };
  }
 BYE:
  return(status);
}

variable_types:
fld
char *

variable_types: struct _FLD_REC_TYPE { int tbl_id; int ddir_id; int is_external; enum _SORT_TYPE { unknown=0, ascending=1, descending=2, unsorted=3 } sort_type; int parent_id; int nn_fld_id; enum _FLD_TYPE { xunknown=0, B=1, I1=2, I2=3, I4=4, I8=5, F4=6, F8=7, clob=8 } fldtype; enum _AUX_TYPE { undef=0, nn=1 } auxtype; char name[-1]; char filename[-1]; char dispname[-1]; int dict_tbl_id; int alias_of_fld_id; long long cnt; } *

variable_types:
startidx
unsigned int

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

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

variable_types: i int

user_defined_types: struct _FLD_REC_TYPE { int tbl_id; int ddir_id; int is_external; enum _SORT_TYPE sort_type; int parent_id; int nn_fld_id; enum _FLD_TYPE fldtype; enum _AUX_TYPE auxtype; char name[-1]; char filename[-1]; char dispname[-1]; int dict_tbl_id; int alias_of_fld_id; long long cnt; }


decompiled_code:
__int64 __fastcall add_fld(int a1, char *a2, int a3, const char *a4, unsigned int a5, int a6, unsigned int *a7, __m128i *a8)
{
int v12; // er14
const char *v13; // rdi
__int64 v14; // rdx
size_t v15; // rax
unsigned int v16; // eax
const __m128i *v17; // rcx
size_t v18; // rax
unsigned int v19; // eax
const __m128i *v20; // rcx
unsigned __int64 v22; // r9
__int8 *v23; // rcx
const char *v24; // r13
unsigned int v25; // eax
unsigned int v26; // eax
unsigned int v27; // esi
__int64 v28; // rdi
unsigned __int64 v29; // r9
__int8 *v30; // rcx
char *v31; // rbx
unsigned int v32; // eax
unsigned int v33; // eax
unsigned int v34; // ecx
__int64 v35; // rsi
__int64 v36; // rdx
const __m128i *v39; // [rsp+10h] [rbp-218h]
unsigned int v40; // [rsp+1Ch] [rbp-20Ch]
unsigned int v41; // [rsp+28h] [rbp-200h] BYREF
char v42[4]; // [rsp+2Ch] [rbp-1FCh] BYREF
char v43[224]; // [rsp+30h] [rbp-1F8h] BYREF
char v44[280]; // [rsp+110h] [rbp-118h] BYREF

*a7 = -1;
zero_fld_rec(a8);
if ( a1 < 0 )
{
v36 = 98LL;
goto LABEL_50;
}
if ( !a2 || !*a2 )
{
v36 = 99LL;
goto LABEL_50;
}
v12 = chk_fld_name(a2, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 101LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
if ( a3 >= 0 )
{
v13 = (const char *)(g_ddirs + ((__int64)a3 << 9));
if ( v13 && *v13 )
{
chdir(v13);
goto LABEL_9;
}
v36 = 108LL;
LABEL_50:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v36, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
chdir(g_data_dir);
LABEL_9:
v12 = chk_file_size(a4, *(_QWORD *)(g_tbls + 176LL * a1), a5);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 111LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
chdir(&g_cwd);
v12 = is_fld(0LL, (unsigned int)a1, a2, &v41, v43, v42, v44);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 114LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
if ( (v41 & 0x80000000) != 0 )
{
v12 = get_empty_fld(a2, g_flds, g_n_fld, (int *)&v41);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 120LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
}
else
{
v12 = del_fld(0LL, (unsigned int)a1, 0LL, v41, 1LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 117LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
}
zero_fld_rec(g_flds + 224LL * (int)v41);
v40 = v41;
v14 = g_flds + 224LL * (int)v41;
*(_QWORD *)(v14 + 16) = 0x8000000080000000LL;
*(_DWORD *)v14 = a1;
*(_QWORD *)(v14 + 8) = 0LL;
*(_DWORD *)(v14 + 24) = a5;
*(_DWORD *)(v14 + 28) = 0;
if ( a6 < 0 )
{
*(_QWORD *)(v14 + 216) = -1LL;
}
else
{
if ( a5 != 8 )
{
v36 = 134LL;
goto LABEL_50;
}
if ( a6 <= 1 )
{
v36 = 135LL;
goto LABEL_50;
}
*(_QWORD *)(v14 + 216) = a6;
}
v39 = (const __m128i *)v14;
v15 = strlen(a4);
if ( v15 > 0xF )
{
fprintf(stderr, "Filename=[%s] too long > %d characters\n", a4, 15LL);
v36 = 143LL;
goto LABEL_50;
}
v16 = v15 + 1;
v17 = v39 + 4;
if ( v16 >= 8 )
{
v22 = (unsigned __int64)&v39[4].m128i_u64[1] & 0xFFFFFFFFFFFFFFF8LL;
v39[4].m128i_i64[0] = *(_QWORD *)a4;
*(__int64 *)((char *)&v17->m128i_i64[-1] + v16) = *(_QWORD *)&a4[v16 - 8];
v23 = &v17->m128i_i8[-v22];
v24 = (const char *)(a4 - v23);
v25 = ((_DWORD)v23 + v16) & 0xFFFFFFF8;
if ( v25 >= 8 )
{
v26 = v25 & 0xFFFFFFF8;
v27 = 0;
do
{
v28 = v27;
v27 += 8;
*(_QWORD *)(v22 + v28) = *(_QWORD *)&v24[v28];
}
while ( v27 < v26 );
}
}
else if ( (v16 & 4) != 0 )
{
v39[4].m128i_i32[0] = *(_DWORD *)a4;
*(__int32 *)((char *)&v17->m128i_i32[-1] + v16) = *(_DWORD *)&a4[v16 - 4];
}
else if ( v16 )
{
v39[4].m128i_i8[0] = *a4;
if ( (v16 & 2) != 0 )
*(__int16 *)((char *)&v17->m128i_i16[-1] + v16) = *(_WORD *)&a4[v16 - 2];
}
v39->m128i_i32[1] = a3;
v18 = strlen(a2);
if ( v18 > 0x1F )
{
v36 = 149LL;
goto LABEL_50;
}
v19 = v18 + 1;
v20 = v39 + 2;
if ( v19 >= 8 )
{
v29 = (unsigned __int64)&v39[2].m128i_u64[1] & 0xFFFFFFFFFFFFFFF8LL;
v39[2].m128i_i64[0] = *(_QWORD *)a2;
*(__int64 *)((char *)&v20->m128i_i64[-1] + v19) = *(_QWORD *)&a2[v19 - 8];
v30 = &v20->m128i_i8[-v29];
v31 = (char *)(a2 - v30);
v32 = ((_DWORD)v30 + v19) & 0xFFFFFFF8;
if ( v32 >= 8 )
{
v33 = v32 & 0xFFFFFFF8;
v34 = 0;
do
{
v35 = v34;
v34 += 8;
*(_QWORD *)(v29 + v35) = *(_QWORD *)&v31[v35];
}
while ( v34 < v33 );
}
}
else if ( (v19 & 4) != 0 )
{
v39[2].m128i_i32[0] = *(_DWORD *)a2;
*(__int32 *)((char *)&v20->m128i_i32[-1] + v19) = *(_DWORD *)&a2[v19 - 4];
}
else if ( v19 )
{
v39[2].m128i_i8[0] = *a2;
if ( (v19 & 2) != 0 )
*(__int16 *)((char *)&v20->m128i_i16[-1] + v19) = *(_WORD *)&a2[v19 - 2];
}
*a7 = v40;
*a8 = _mm_loadu_si128(v39);
a8[1] = _mm_loadu_si128(v39 + 1);
a8[2] = _mm_loadu_si128(v39 + 2);
a8[3] = _mm_loadu_si128(v39 + 3);
a8[4] = _mm_loadu_si128(v39 + 4);
a8[5] = _mm_loadu_si128(v39 + 5);
a8[6] = _mm_loadu_si128(v39 + 6);
a8[7] = _mm_loadu_si128(v39 + 7);
a8[8] = _mm_loadu_si128(v39 + 8);
a8[9] = _mm_loadu_si128(v39 + 9);
a8[10] = _mm_loadu_si128(v39 + 10);
a8[11] = _mm_loadu_si128(v39 + 11);
a8[12] = _mm_loadu_si128(v39 + 12);
a8[13] = _mm_loadu_si128(v39 + 13);
return (unsigned int)v12;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, char *a2, int a3, const char *a4, unsigned int a5, int a6, unsigned int *a7, __m128i *a8)
{
int v12; // er14
const char *v13; // rdi
__int64 v14; // rdx
size_t v15; // rax
unsigned int v16; // eax
const __m128i *v17; // rcx
size_t v18; // rax
unsigned int v19; // eax
const __m128i *v20; // rcx
unsigned __int64 v22; // r9
__int8 *v23; // rcx
const char *v24; // r13
unsigned int v25; // eax
unsigned int v26; // eax
unsigned int v27; // esi
__int64 v28; // rdi
unsigned __int64 v29; // r9
__int8 *v30; // rcx
char *v31; // rbx
unsigned int v32; // eax
unsigned int v33; // eax
unsigned int v34; // ecx
__int64 v35; // rsi
__int64 v36; // rdx
const __m128i *v39; // [rsp+10h] [rbp-218h]
unsigned int v40; // [rsp+1Ch] [rbp-20Ch]
unsigned int v41; // [rsp+28h] [rbp-200h] BYREF
char v42[4]; // [rsp+2Ch] [rbp-1FCh] BYREF
char v43[224]; // [rsp+30h] [rbp-1F8h] BYREF
char v44[280]; // [rsp+110h] [rbp-118h] BYREF

*a7 = -1;
zero_fld_rec(a8);
if ( a1 < 0 )
{
v36 = 98LL;
goto LABEL_50;
}
if ( !a2 || !*a2 )
{
v36 = 99LL;
goto LABEL_50;
}
v12 = chk_fld_name(a2, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 101LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
if ( a3 >= 0 )
{
v13 = (const char *)(g_ddirs + ((__int64)a3 << 9));
if ( v13 && *v13 )
{
chdir(v13);
goto LABEL_9;
}
v36 = 108LL;
LABEL_50:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v36, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
chdir(g_data_dir);
LABEL_9:
v12 = chk_file_size(a4, *(_QWORD *)(g_tbls + 176LL * a1), a5);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 111LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
chdir(&g_cwd);
v12 = is_fld(0LL, (unsigned int)a1, a2, &v41, v43, v42, v44);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 114LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
if ( (v41 & 0x80000000) != 0 )
{
v12 = func0(a2, g_flds, g_n_fld, (int *)&v41);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 120LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
}
else
{
v12 = del_fld(0LL, (unsigned int)a1, 0LL, v41, 1LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 117LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v12;
}
}
zero_fld_rec(g_flds + 224LL * (int)v41);
v40 = v41;
v14 = g_flds + 224LL * (int)v41;
*(_QWORD *)(v14 + 16) = 0x8000000080000000LL;
*(_DWORD *)v14 = a1;
*(_QWORD *)(v14 + 8) = 0LL;
*(_DWORD *)(v14 + 24) = a5;
*(_DWORD *)(v14 + 28) = 0;
if ( a6 < 0 )
{
*(_QWORD *)(v14 + 216) = -1LL;
}
else
{
if ( a5 != 8 )
{
v36 = 134LL;
goto LABEL_50;
}
if ( a6 <= 1 )
{
v36 = 135LL;
goto LABEL_50;
}
*(_QWORD *)(v14 + 216) = a6;
}
v39 = (const __m128i *)v14;
v15 = strlen(a4);
if ( v15 > 0xF )
{
fprintf(stderr, "Filename=[%s] too long > %d characters\n", a4, 15LL);
v36 = 143LL;
goto LABEL_50;
}
v16 = v15 + 1;
v17 = v39 + 4;
if ( v16 >= 8 )
{
v22 = (unsigned __int64)&v39[4].m128i_u64[1] & 0xFFFFFFFFFFFFFFF8LL;
v39[4].m128i_i64[0] = *(_QWORD *)a4;
*(__int64 *)((char *)&v17->m128i_i64[-1] + v16) = *(_QWORD *)&a4[v16 - 8];
v23 = &v17->m128i_i8[-v22];
v24 = (const char *)(a4 - v23);
v25 = ((_DWORD)v23 + v16) & 0xFFFFFFF8;
if ( v25 >= 8 )
{
v26 = v25 & 0xFFFFFFF8;
v27 = 0;
do
{
v28 = v27;
v27 += 8;
*(_QWORD *)(v22 + v28) = *(_QWORD *)&v24[v28];
}
while ( v27 < v26 );
}
}
else if ( (v16 & 4) != 0 )
{
v39[4].m128i_i32[0] = *(_DWORD *)a4;
*(__int32 *)((char *)&v17->m128i_i32[-1] + v16) = *(_DWORD *)&a4[v16 - 4];
}
else if ( v16 )
{
v39[4].m128i_i8[0] = *a4;
if ( (v16 & 2) != 0 )
*(__int16 *)((char *)&v17->m128i_i16[-1] + v16) = *(_WORD *)&a4[v16 - 2];
}
v39->m128i_i32[1] = a3;
v18 = strlen(a2);
if ( v18 > 0x1F )
{
v36 = 149LL;
goto LABEL_50;
}
v19 = v18 + 1;
v20 = v39 + 2;
if ( v19 >= 8 )
{
v29 = (unsigned __int64)&v39[2].m128i_u64[1] & 0xFFFFFFFFFFFFFFF8LL;
v39[2].m128i_i64[0] = *(_QWORD *)a2;
*(__int64 *)((char *)&v20->m128i_i64[-1] + v19) = *(_QWORD *)&a2[v19 - 8];
v30 = &v20->m128i_i8[-v29];
v31 = (char *)(a2 - v30);
v32 = ((_DWORD)v30 + v19) & 0xFFFFFFF8;
if ( v32 >= 8 )
{
v33 = v32 & 0xFFFFFFF8;
v34 = 0;
do
{
v35 = v34;
v34 += 8;
*(_QWORD *)(v29 + v35) = *(_QWORD *)&v31[v35];
}
while ( v34 < v33 );
}
}
else if ( (v19 & 4) != 0 )
{
v39[2].m128i_i32[0] = *(_DWORD *)a2;
*(__int32 *)((char *)&v20->m128i_i32[-1] + v19) = *(_DWORD *)&a2[v19 - 4];
}
else if ( v19 )
{
v39[2].m128i_i8[0] = *a2;
if ( (v19 & 2) != 0 )
*(__int16 *)((char *)&v20->m128i_i16[-1] + v19) = *(_WORD *)&a2[v19 - 2];
}
*a7 = v40;
*a8 = _mm_loadu_si128(v39);
a8[1] = _mm_loadu_si128(v39 + 1);
a8[2] = _mm_loadu_si128(v39 + 2);
a8[3] = _mm_loadu_si128(v39 + 3);
a8[4] = _mm_loadu_si128(v39 + 4);
a8[5] = _mm_loadu_si128(v39 + 5);
a8[6] = _mm_loadu_si128(v39 + 6);
a8[7] = _mm_loadu_si128(v39 + 7);
a8[8] = _mm_loadu_si128(v39 + 8);
a8[9] = _mm_loadu_si128(v39 + 9);
a8[10] = _mm_loadu_si128(v39 + 10);
a8[11] = _mm_loadu_si128(v39 + 11);
a8[12] = _mm_loadu_si128(v39 + 12);
a8[13] = _mm_loadu_si128(v39 + 13);
return (unsigned int)v12;
}

original_code:
int
add_fld(
 int tbl_id,
 const char *fld,
 int ddir_id,
 char *filename,
 FLD_TYPE fldtype,
 int len,
 int *ptr_fld_id,
 FLD_REC_TYPE *ptr_fld_rec
 )
{
  int status = 0;
  FLD_REC_TYPE fld_rec; int fld_id;
  FLD_REC_TYPE nn_fld_rec; int nn_fld_id;
  *ptr_fld_id = -1;
  zero_fld_rec(ptr_fld_rec);
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 98, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 99, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = chk_fld_name(fld, 0);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 101, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( ddir_id < 0 ) {
    chdir(g_data_dir);
  }
  else {
    char *alt_data_dir = g_ddirs[ddir_id].name;
    if ( ( alt_data_dir == ((void *)0) ) || ( *alt_data_dir == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 108, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    chdir(alt_data_dir);
  }
  status = chk_file_size(filename, g_tbls[tbl_id].nR, fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 111, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  chdir(g_cwd);
  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", 114, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( fld_id >= 0 ) {
    status = del_fld(((void *)0), tbl_id, ((void *)0), fld_id, 1);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 117, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  }
  else {
    status = get_empty_fld(fld, g_flds, g_n_fld, &fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 120, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  }
  zero_fld_rec(&(g_flds[fld_id]));
  g_flds[fld_id].tbl_id = tbl_id;
  g_flds[fld_id].is_external = 0;
  g_flds[fld_id].sort_type = unknown;
  g_flds[fld_id].parent_id = (-0x7fffffff - 1);
  g_flds[fld_id].nn_fld_id = (-0x7fffffff - 1);
  g_flds[fld_id].fldtype = fldtype;
  g_flds[fld_id].auxtype = undef;
  if ( len < 0 ) {
    g_flds[fld_id].cnt = -1;
  }
  else {
    if ( fldtype != clob ) { { { fprintf(stderr, "Line %3d of File %s \n", 134, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    if ( len < 2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 135, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    g_flds[fld_id].cnt = len;
  }
  if ( strlen(filename) > 15 ) {
    fprintf(stderr, "Filename=[%s] too long > %d characters\n",
 filename, 15);
    { { fprintf(stderr, "Line %3d of File %s \n", 143, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; };
  }
  strcpy(g_flds[fld_id].filename, filename);
  g_flds[fld_id].ddir_id = ddir_id;
  if ( strlen(fld) > 31 ) { { { fprintf(stderr, "Line %3d of File %s \n", 149, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  strcpy(g_flds[fld_id].name, fld);
  *ptr_fld_id = fld_id;
  *ptr_fld_rec = g_flds[fld_id];
 BYE:
  return(status);
}

canonical_original_code:
int add_fld(int tbl_id, char *fld, int ddir_id, char *filename, enum _FLD_TYPE fldtype, int len, int *ptr_fld_id, struct _FLD_REC_TYPE *ptr_fld_rec)
{
  int status = 0;
  struct _FLD_REC_TYPE fld_rec; int fld_id;
  struct _FLD_REC_TYPE nn_fld_rec; int nn_fld_id;
  *ptr_fld_id = -1;
  zero_fld_rec(ptr_fld_rec);
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 98, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 99, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = chk_fld_name(fld, 0);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 101, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( ddir_id < 0 ) {
    chdir(g_data_dir);
  }
  else {
    char *alt_data_dir = g_ddirs[ddir_id].name;
    if ( ( alt_data_dir == ((void *)0) ) || ( *alt_data_dir == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 108, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    chdir(alt_data_dir);
  }
  status = chk_file_size(filename, g_tbls[tbl_id].nR, fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 111, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  chdir(g_cwd);
  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", 114, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( fld_id >= 0 ) {
    status = del_fld(((void *)0), tbl_id, ((void *)0), fld_id, 1);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 117, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  }
  else {
    status = get_empty_fld(fld, g_flds, g_n_fld, &fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 120, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  }
  zero_fld_rec(&(g_flds[fld_id]));
  g_flds[fld_id].tbl_id = tbl_id;
  g_flds[fld_id].is_external = 0;
  g_flds[fld_id].sort_type = unknown;
  g_flds[fld_id].parent_id = (-0x7fffffff - 1);
  g_flds[fld_id].nn_fld_id = (-0x7fffffff - 1);
  g_flds[fld_id].fldtype = fldtype;
  g_flds[fld_id].auxtype = undef;
  if ( len < 0 ) {
    g_flds[fld_id].cnt = -1;
  }
  else {
    if ( fldtype != clob ) { { { fprintf(stderr, "Line %3d of File %s \n", 134, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    if ( len < 2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 135, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    g_flds[fld_id].cnt = len;
  }
  if ( strlen(filename) > 15 ) {
    fprintf(stderr, "Filename=[%s] too long > %d characters\n",
 filename, 15);
    { { fprintf(stderr, "Line %3d of File %s \n", 143, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; };
  }
  strcpy(g_flds[fld_id].filename, filename);
  g_flds[fld_id].ddir_id = ddir_id;
  if ( strlen(fld) > 31 ) { { { fprintf(stderr, "Line %3d of File %s \n", 149, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  strcpy(g_flds[fld_id].name, fld);
  *ptr_fld_id = fld_id;
  *ptr_fld_rec = g_flds[fld_id];
 BYE:
  return(status);
}

variable_types:
filename
char *

variable_types: len int

variable_types: status int

variable_types: struct _FLD_REC_TYPE { int tbl_id; int ddir_id; int is_external; enum _SORT_TYPE { unknown=0, ascending=1, descending=2, unsorted=3 } sort_type; int parent_id; int nn_fld_id; enum _FLD_TYPE { xunknown=0, B=1, I1=2, I2=3, I4=4, I8=5, F4=6, F8=7, clob=8 } fldtype; enum _AUX_TYPE { undef=0, nn=1 } auxtype; char name[-1]; char filename[-1]; char dispname[-1]; int dict_tbl_id; int alias_of_fld_id; long long cnt; }


decompiled_code:
__int64 __fastcall ext_add_fld(__int64 a1, char *a2, __int64 a3)
{
int v4; // er12
int v5; // er9
int v7; // eax
__int64 v8; // rdx
char v9; // [rsp+7h] [rbp-EB1h] BYREF
int v10; // [rsp+8h] [rbp-EB0h] BYREF
int v11; // [rsp+Ch] [rbp-EACh] BYREF
char v12[4]; // [rsp+10h] [rbp-EA8h] BYREF
unsigned int v13; // [rsp+14h] [rbp-EA4h] BYREF
char *endptr; // [rsp+18h] [rbp-EA0h] BYREF
char v15[176]; // [rsp+20h] [rbp-E98h] BYREF
__m128i v16[4]; // [rsp+D0h] [rbp-DE8h] BYREF
char s1[160]; // [rsp+110h] [rbp-DA8h] BYREF
char v18[224]; // [rsp+1B0h] [rbp-D08h] BYREF
char nptr[1024]; // [rsp+290h] [rbp-C28h] BYREF
char v20[1024]; // [rsp+690h] [rbp-828h] BYREF
char s2[1064]; // [rsp+A90h] [rbp-428h] BYREF

is_tbl(a1, &v10, v15);
if ( v10 < 0 || v10 >= g_n_tbl )
{
v8 = 180LL;
goto LABEL_18;
}
is_fld(0LL, (unsigned int)v10, a2, &v11, v16, v12, v18);
if ( v11 >= 0 )
{
extract_S(a3, "filename=[", "]", s2, 1024LL, &v9);
if ( v9 )
{
v8 = 184LL;
goto LABEL_18;
}
if ( !strcmp(s1, s2) )
{
fwrite("Need to handle this case\n", 1uLL, 0x19uLL, stderr);
v8 = 187LL;
goto LABEL_18;
}
del_fld(0LL, (unsigned int)v10, 0LL, (unsigned int)v11, 1LL);
}
extract_S(a3, "fldtype=[", "]", v20, 1024LL, &v9);
if ( v9 )
{
v8 = 194LL;
goto LABEL_18;
}
v4 = unstr_fldtype(v20, &v13);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 195LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v4;
}
extract_S(a3, "filename=[", "]", s2, 1024LL, &v9);
if ( v9 )
{
v8 = 198LL;
goto LABEL_18;
}
extract_S(a3, "len=[", "]", nptr, 1024LL, &v9);
if ( v9 )
{
v5 = -1;
goto LABEL_12;
}
v7 = strtoll(nptr, &endptr, 10);
v5 = v7;
if ( *endptr )
{
fprintf(stderr, "Line %3d of File %s \n", 204LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
if ( v7 <= 1 )
{
v8 = 205LL;
LABEL_18:
fprintf(stderr, "Line %3d of File %s \n", v8, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
LABEL_12:
v4 = add_fld(v10, a2, -1, s2, v13, v5, (unsigned int *)&v11, v16);
if ( v4 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 209LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, char *a2, __int64 a3)
{
int v4; // er12
int v5; // er9
int v7; // eax
__int64 v8; // rdx
char v9; // [rsp+7h] [rbp-EB1h] BYREF
int v10; // [rsp+8h] [rbp-EB0h] BYREF
int v11; // [rsp+Ch] [rbp-EACh] BYREF
char v12[4]; // [rsp+10h] [rbp-EA8h] BYREF
unsigned int v13; // [rsp+14h] [rbp-EA4h] BYREF
char *endptr; // [rsp+18h] [rbp-EA0h] BYREF
char v15[176]; // [rsp+20h] [rbp-E98h] BYREF
__m128i v16[4]; // [rsp+D0h] [rbp-DE8h] BYREF
char s1[160]; // [rsp+110h] [rbp-DA8h] BYREF
char v18[224]; // [rsp+1B0h] [rbp-D08h] BYREF
char nptr[1024]; // [rsp+290h] [rbp-C28h] BYREF
char v20[1024]; // [rsp+690h] [rbp-828h] BYREF
char s2[1064]; // [rsp+A90h] [rbp-428h] BYREF

is_tbl(a1, &v10, v15);
if ( v10 < 0 || v10 >= g_n_tbl )
{
v8 = 180LL;
goto LABEL_18;
}
is_fld(0LL, (unsigned int)v10, a2, &v11, v16, v12, v18);
if ( v11 >= 0 )
{
extract_S(a3, "filename=[", "]", s2, 1024LL, &v9);
if ( v9 )
{
v8 = 184LL;
goto LABEL_18;
}
if ( !strcmp(s1, s2) )
{
fwrite("Need to handle this case\n", 1uLL, 0x19uLL, stderr);
v8 = 187LL;
goto LABEL_18;
}
del_fld(0LL, (unsigned int)v10, 0LL, (unsigned int)v11, 1LL);
}
extract_S(a3, "fldtype=[", "]", v20, 1024LL, &v9);
if ( v9 )
{
v8 = 194LL;
goto LABEL_18;
}
v4 = unstr_fldtype(v20, &v13);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 195LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v4;
}
extract_S(a3, "filename=[", "]", s2, 1024LL, &v9);
if ( v9 )
{
v8 = 198LL;
goto LABEL_18;
}
extract_S(a3, "len=[", "]", nptr, 1024LL, &v9);
if ( v9 )
{
v5 = -1;
goto LABEL_12;
}
v7 = strtoll(nptr, &endptr, 10);
v5 = v7;
if ( *endptr )
{
fprintf(stderr, "Line %3d of File %s \n", 204LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
if ( v7 <= 1 )
{
v8 = 205LL;
LABEL_18:
fprintf(stderr, "Line %3d of File %s \n", v8, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
LABEL_12:
v4 = func1(v10, a2, -1, s2, v13, v5, (unsigned int *)&v11, v16);
if ( v4 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 209LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v4;
}

original_code:
int
ext_add_fld(
 const char *tbl,
 const char *fld,
 const char *fldspec
 )
{
  int status = 0;
  TBL_REC_TYPE tbl_rec; int tbl_id;
  FLD_REC_TYPE fld_rec; int fld_id;
  FLD_REC_TYPE nn_fld_rec; int nn_fld_id;
  FLD_TYPE fldtype;
  char str_len[1024];
  char str_fldtype[1024];
  char filename[1024];
  _Bool is_null; int len = -1;
  status = is_tbl(tbl, &tbl_id, &tbl_rec);
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 180, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; } };
  status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec, &nn_fld_id, &nn_fld_rec);
  if ( fld_id >= 0 ) {
    status = extract_S(fldspec, "filename=[", "]", filename, 1024, &is_null);
    if ( is_null ){ { { fprintf(stderr, "Line %3d of File %s \n", 184, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    if ( strcmp(fld_rec.filename, filename) == 0 ) {
      fprintf(stderr, "Need to handle this case\n");
      { { fprintf(stderr, "Line %3d of File %s \n", 187, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; };
    }
    status = del_fld(((void *)0), tbl_id, ((void *)0), fld_id, 1);
  }
  status = extract_S(fldspec, "fldtype=[", "]", str_fldtype, 1024, &is_null);
  if ( is_null ){ { { fprintf(stderr, "Line %3d of File %s \n", 194, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = unstr_fldtype(str_fldtype, &fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 195, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  status = extract_S(fldspec, "filename=[", "]", filename, 1024, &is_null);
  if ( is_null ){ { { fprintf(stderr, "Line %3d of File %s \n", 198, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = extract_S(fldspec, "len=[", "]", str_len, 1024, &is_null);
  if ( !is_null ) {
    char *endptr;
    len = strtoll(str_len, &endptr, 10);
    if ( *endptr != '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 204, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    if ( len < 2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 205, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  }
  int ddir_id = -1;
  status = add_fld(tbl_id, fld, ddir_id, filename, fldtype, len, &fld_id, &fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 209, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
BYE:
  return(status);
}

canonical_original_code:
int ext_add_fld(char *tbl, char *fld, char *fldspec)
{
  int status = 0;
  struct _TBL_REC_TYPE tbl_rec; int tbl_id;
  struct _FLD_REC_TYPE fld_rec; int fld_id;
  struct _FLD_REC_TYPE nn_fld_rec; int nn_fld_id;
  enum _FLD_TYPE fldtype;
  char str_len[1024];
  char str_fldtype[1024];
  char filename[1024];
  _Bool is_null; int len = -1;
  status = is_tbl(tbl, &tbl_id, &tbl_rec);
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 180, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; } };
  status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec, &nn_fld_id, &nn_fld_rec);
  if ( fld_id >= 0 ) {
    status = extract_S(fldspec, "filename=[", "]", filename, 1024, &is_null);
    if ( is_null ){ { { fprintf(stderr, "Line %3d of File %s \n", 184, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    if ( strcmp(fld_rec.filename, filename) == 0 ) {
      fprintf(stderr, "Need to handle this case\n");
      { { fprintf(stderr, "Line %3d of File %s \n", 187, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; };
    }
    status = del_fld(((void *)0), tbl_id, ((void *)0), fld_id, 1);
  }
  status = extract_S(fldspec, "fldtype=[", "]", str_fldtype, 1024, &is_null);
  if ( is_null ){ { { fprintf(stderr, "Line %3d of File %s \n", 194, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = unstr_fldtype(str_fldtype, &fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 195, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
  status = extract_S(fldspec, "filename=[", "]", filename, 1024, &is_null);
  if ( is_null ){ { { fprintf(stderr, "Line %3d of File %s \n", 198, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  status = extract_S(fldspec, "len=[", "]", str_len, 1024, &is_null);
  if ( !is_null ) {
    char *endptr;
    len = strtoll(str_len, &endptr, 10);
    if ( *endptr != '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 204, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
    if ( len < 2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 205, "./dir_wr_verbs/add_fld.c"); }; status = -1 ; goto BYE; }; }
  }
  int ddir_id = -1;
  status = add_fld(tbl_id, fld, ddir_id, filename, fldtype, len, &fld_id, &fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 209, "./dir_wr_verbs/add_fld.c"); }; status = (status) ; goto BYE; } } };
BYE:
  return(status);
}

variable_types:
tbl
char *

variable_types:
fldspec
char *

variable_types: struct _TBL_REC_TYPE { long long nR; char name[-1]; char dispname[-1]; _Bool is_dict_tbl; }

variable_types:
filename
char [1024]

variable_types:
endptr
char *

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


original_code:
int
pos_nn_copy_I8_I8(
    long long *f1,
    char *nn_f1,
    long long nR1,
    long long *f2,
    char *nn_f2,
    long long nR2,
    long long *f3,
    long long *ptr_cnt
    )
{
  int status = 0;
  long long cnt = 0;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( nn_f2 != ((void *)0) ) && ( nn_f2[i] == 0 ) ) { continue; }
    long long f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "./AUX/pos_nn_copy_I8_I8.c"); }; status = -1 ; goto BYE; }; }
    if ( ( nn_f1 != ((void *)0) ) && ( nn_f1[f1idx] == 0 ) ) { continue; }
    long long ival = f1[f1idx];
    f3[cnt++] = ival;
  }
  *ptr_cnt = cnt;
BYE:
  return(status);
}

canonical_original_code:
int pos_nn_copy_I8_I8(long long *f1, char *nn_f1, long long nR1, long long *f2, char *nn_f2, long long nR2, long long *f3, long long *ptr_cnt)
{
  int status = 0;
  long long cnt = 0;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( nn_f2 != ((void *)0) ) && ( nn_f2[i] == 0 ) ) { continue; }
    long long f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "./AUX/pos_nn_copy_I8_I8.c"); }; status = -1 ; goto BYE; }; }
    if ( ( nn_f1 != ((void *)0) ) && ( nn_f1[f1idx] == 0 ) ) { continue; }
    long long ival = f1[f1idx];
    f3[cnt++] = ival;
  }
  *ptr_cnt = cnt;
BYE:
  return(status);
}

variable_types:
cnt
long long

variable_types:
i
long long

variable_types:
ival
long long


original_code:
void
add2_F4(
       float *in1,
       float *in2,
       long long nR,
       float * restrict out
       )
{
  float inv1, inv2, outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 + inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

canonical_original_code:
void add2_F4(float *in1, float *in2, long long nR, float *out)
{
  float inv1; float inv2; float outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 + inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

variable_types:
nR
long long

variable_types:
out
float *

variable_types: outv float


original_code:
int
int_stride_I4(
    int *f1,
    long long nR1,
    long long start,
    long long stride,
    int *f2,
    char *nn_f2_X,
    long long nR2,
    _Bool *ptr_is_any_null
    )
{
  int status = 0;
  *ptr_is_any_null = 0;
  for ( int i = 0; i < nR2; i++ ) {
    long long f1_idx = start + i*stride;
    if ( ( f1_idx < 0 ) || ( f1_idx >= nR1 ) ) {
      f2[i] = 0;
      nn_f2_X[i] = 0;
      *ptr_is_any_null = 1;
    }
    else {
      f2[i] = f1[f1_idx];
      nn_f2_X[i] = 1;
    }
  }
  return(status);
}

canonical_original_code:
int int_stride_I4(int *f1, long long nR1, long long start, long long stride, int *f2, char *nn_f2_X, long long nR2, _Bool *ptr_is_any_null)
{
  int status = 0;
  *ptr_is_any_null = 0;
  for ( int i = 0; i < nR2; i++ ) {
    long long f1_idx = start + i*stride;
    if ( ( f1_idx < 0 ) || ( f1_idx >= nR1 ) ) {
      f2[i] = 0;
      nn_f2_X[i] = 0;
      *ptr_is_any_null = 1;
    }
    else {
      f2[i] = f1[f1_idx];
      nn_f2_X[i] = 1;
    }
  }
  return(status);
}

variable_types:
start
long long

variable_types:
stride
long long


original_code:
int
int_stride_I8(
    long long *f1,
    long long nR1,
    long long start,
    long long stride,
    long long *f2,
    char *nn_f2_X,
    long long nR2,
    _Bool *ptr_is_any_null
    )
{
  int status = 0;
  *ptr_is_any_null = 0;
  for ( int i = 0; i < nR2; i++ ) {
    long long f1_idx = start + i*stride;
    if ( ( f1_idx < 0 ) || ( f1_idx >= nR1 ) ) {
      f2[i] = 0;
      nn_f2_X[i] = 0;
      *ptr_is_any_null = 1;
    }
    else {
      f2[i] = f1[f1_idx];
      nn_f2_X[i] = 1;
    }
  }
  return(status);
}

canonical_original_code:
int int_stride_I8(long long *f1, long long nR1, long long start, long long stride, long long *f2, char *nn_f2_X, long long nR2, _Bool *ptr_is_any_null)
{
  int status = 0;
  *ptr_is_any_null = 0;
  for ( int i = 0; i < nR2; i++ ) {
    long long f1_idx = start + i*stride;
    if ( ( f1_idx < 0 ) || ( f1_idx >= nR1 ) ) {
      f2[i] = 0;
      nn_f2_X[i] = 0;
      *ptr_is_any_null = 1;
    }
    else {
      f2[i] = f1[f1_idx];
      nn_f2_X[i] = 1;
    }
  }
  return(status);
}

variable_types: i int


decompiled_code:
__int64 __fastcall ext_stride(const char *a1, _BYTE *a2, const char *a3, const char *a4, const char *a5, _BYTE *a6, char *nptr)
{
__int64 v11; // rax
__int64 v12; // rdx
__int64 v13; // rax
__int64 v14; // r15
__int64 v15; // rax
__int64 v16; // rdx
__int64 v17; // rcx
int v18; // er13
__int64 v20; // rdx
__int64 v21; // rax
__int64 v22; // [rsp+8h] [rbp-5B0h]
__int64 v23; // [rsp+10h] [rbp-5A8h]
__int64 v24; // [rsp+18h] [rbp-5A0h]
char v25; // [rsp+23h] [rbp-595h] BYREF
char v26[4]; // [rsp+24h] [rbp-594h] BYREF
unsigned int v27; // [rsp+28h] [rbp-590h] BYREF
char v28[4]; // [rsp+2Ch] [rbp-58Ch] BYREF
int v29; // [rsp+30h] [rbp-588h] BYREF
unsigned int v30; // [rsp+34h] [rbp-584h] BYREF
char v31[4]; // [rsp+38h] [rbp-580h] BYREF
int v32; // [rsp+3Ch] [rbp-57Ch] BYREF
unsigned int v33; // [rsp+40h] [rbp-578h] BYREF
unsigned int v34; // [rsp+44h] [rbp-574h] BYREF
void *addr; // [rsp+48h] [rbp-570h] BYREF
size_t len; // [rsp+50h] [rbp-568h] BYREF
void *v37; // [rsp+58h] [rbp-560h] BYREF
size_t v38; // [rsp+60h] [rbp-558h] BYREF
void *v39; // [rsp+68h] [rbp-550h] BYREF
size_t v40; // [rsp+70h] [rbp-548h] BYREF
char *endptr; // [rsp+78h] [rbp-540h] BYREF
char v42[16]; // [rsp+80h] [rbp-538h] BYREF
char v43[16]; // [rsp+90h] [rbp-528h] BYREF
__int64 v44[22]; // [rsp+A0h] [rbp-518h] BYREF
char v45[176]; // [rsp+150h] [rbp-468h] BYREF
__int64 v46; // [rsp+200h] [rbp-3B8h] BYREF
__int64 v47; // [rsp+218h] [rbp-3A0h]
char v48[224]; // [rsp+2E0h] [rbp-2D8h] BYREF
char v49[224]; // [rsp+3C0h] [rbp-1F8h] BYREF
char v50[280]; // [rsp+4A0h] [rbp-118h] BYREF

addr = 0LL;
len = 0LL;
v37 = 0LL;
v38 = 0LL;
v39 = 0LL;
v40 = 0LL;
v32 = 0x7FFFFFFF;
v33 = 0x7FFFFFFF;
v34 = 0x7FFFFFFF;
if ( !a1 || !*a1 )
{
v12 = 128LL;
goto LABEL_31;
}
if ( !a2 || !*a2 )
{
v12 = 129LL;
goto LABEL_31;
}
if ( !a5 || !*a5 )
{
v12 = 130LL;
goto LABEL_31;
}
if ( !a6 || !*a6 )
{
v12 = 131LL;
goto LABEL_31;
}
if ( !strcmp(a1, a5) )
{
v18 = -1;
fprintf(stderr, "Line %3d of File %s \n", 132LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v11 = strtoll(a3, &endptr, 10);
v12 = 134LL;
v22 = v11;
if ( *endptr )
goto LABEL_31;
v13 = strtoll(a4, &endptr, 10);
v12 = 136LL;
v14 = v13;
if ( *endptr )
goto LABEL_31;
v15 = strtoll(nptr, &endptr, 10);
v12 = 138LL;
v23 = v15;
if ( *endptr )
goto LABEL_31;
zero_string(v42, 16LL, 138LL, "./dir_wr_verbs/stride.c");
zero_string(v43, 16LL, v16, v17);
v18 = is_tbl(a1, v26, v44);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 142LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v24 = v44[0];
v18 = is_fld(a1, 0xFFFFFFFFLL, a2, v28, &v46, &v29, v48);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 145LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = get_data(&addr, &len, 0LL);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 146LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v12 = 147LL;
if ( v29 >= 0 )
{
LABEL_31:
v18 = -1;
fprintf(stderr, "Line %3d of File %s \n", v12, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = del_tbl(a5, 0xFFFFFFFFLL, 147LL, "./dir_wr_verbs/stride.c");
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 148LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
if ( v22 < 0 || v22 >= v24 )
{
v12 = 150LL;
goto LABEL_31;
}
if ( v14 <= 0 || v14 >= v24 )
{
v12 = 151LL;
goto LABEL_31;
}
v18 = get_fld_sz((unsigned int)v47, &v32);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 154LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = mk_temp_file(v42, v23 * v32, &v33);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 156LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = q_mmap(v33, v42, &v37, &v38, 1LL);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 157LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = mk_temp_file(v43, v23, &v34);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 159LL, "./dir_wr_verbs/stride.c");
}
else
{
if ( v22 + v14 * v23 >= v23 )
{
v18 = q_mmap(v34, v43, &v39, &v40, 1LL);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 161LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
}
if ( (_DWORD)v47 == 4 )
{
v18 = int_stride_I4((__int64)addr, v24, v22, v14, (__int64)v37, (__int64)v39, v23, &v25);
}
else
{
if ( (_DWORD)v47 != 5 )
{
v12 = 174LL;
goto LABEL_31;
}
v18 = int_stride_I8((__int64)addr, v24, v22, v14, (__int64)v37, (__int64)v39, v23, &v25);
}
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 177LL, "./dir_wr_verbs/stride.c");
}
else
{
v18 = add_tbl(a5, nptr, &v27, v45);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 179LL, "./dir_wr_verbs/stride.c");
}
else
{
v21 = add_fld(v27, a6, v33, v42, (unsigned int)v47, 0xFFFFFFFFLL, &v30, v49);
v18 = v21;
if ( (int)v21 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 181LL, "./dir_wr_verbs/stride.c");
}
else if ( v25 )
{
v18 = add_aux_fld(0LL, v27, 0LL, v30, v34, v43, "nn", v31, v50, v21);
}
}
}
}
LABEL_32:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_35;
}
LABEL_44:
v20 = 190LL;
LABEL_45:
v18 = -1;
fprintf(stderr, "Line %3d of File %s \n", v20, "./dir_wr_verbs/stride.c");
return (unsigned int)v18;
}
if ( len )
goto LABEL_44;
LABEL_35:
if ( v37 )
{
if ( v38 )
{
munmap(v37, v38);
v37 = 0LL;
v38 = 0LL;
goto LABEL_38;
}
goto LABEL_47;
}
if ( v38 )
{
LABEL_47:
v20 = 191LL;
goto LABEL_45;
}
LABEL_38:
if ( !v39 )
{
if ( !v40 )
return (unsigned int)v18;
goto LABEL_49;
}
if ( !v40 )
{
LABEL_49:
v20 = 192LL;
goto LABEL_45;
}
munmap(v39, v40);
return (unsigned int)v18;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, _BYTE *a2, const char *a3, const char *a4, const char *a5, _BYTE *a6, char *nptr)
{
__int64 v11; // rax
__int64 v12; // rdx
__int64 v13; // rax
__int64 v14; // r15
__int64 v15; // rax
__int64 v16; // rdx
__int64 v17; // rcx
int v18; // er13
__int64 v20; // rdx
__int64 v21; // rax
__int64 v22; // [rsp+8h] [rbp-5B0h]
__int64 v23; // [rsp+10h] [rbp-5A8h]
__int64 v24; // [rsp+18h] [rbp-5A0h]
char v25; // [rsp+23h] [rbp-595h] BYREF
char v26[4]; // [rsp+24h] [rbp-594h] BYREF
unsigned int v27; // [rsp+28h] [rbp-590h] BYREF
char v28[4]; // [rsp+2Ch] [rbp-58Ch] BYREF
int v29; // [rsp+30h] [rbp-588h] BYREF
unsigned int v30; // [rsp+34h] [rbp-584h] BYREF
char v31[4]; // [rsp+38h] [rbp-580h] BYREF
int v32; // [rsp+3Ch] [rbp-57Ch] BYREF
unsigned int v33; // [rsp+40h] [rbp-578h] BYREF
unsigned int v34; // [rsp+44h] [rbp-574h] BYREF
void *addr; // [rsp+48h] [rbp-570h] BYREF
size_t len; // [rsp+50h] [rbp-568h] BYREF
void *v37; // [rsp+58h] [rbp-560h] BYREF
size_t v38; // [rsp+60h] [rbp-558h] BYREF
void *v39; // [rsp+68h] [rbp-550h] BYREF
size_t v40; // [rsp+70h] [rbp-548h] BYREF
char *endptr; // [rsp+78h] [rbp-540h] BYREF
char v42[16]; // [rsp+80h] [rbp-538h] BYREF
char v43[16]; // [rsp+90h] [rbp-528h] BYREF
__int64 v44[22]; // [rsp+A0h] [rbp-518h] BYREF
char v45[176]; // [rsp+150h] [rbp-468h] BYREF
__int64 v46; // [rsp+200h] [rbp-3B8h] BYREF
__int64 v47; // [rsp+218h] [rbp-3A0h]
char v48[224]; // [rsp+2E0h] [rbp-2D8h] BYREF
char v49[224]; // [rsp+3C0h] [rbp-1F8h] BYREF
char v50[280]; // [rsp+4A0h] [rbp-118h] BYREF

addr = 0LL;
len = 0LL;
v37 = 0LL;
v38 = 0LL;
v39 = 0LL;
v40 = 0LL;
v32 = 0x7FFFFFFF;
v33 = 0x7FFFFFFF;
v34 = 0x7FFFFFFF;
if ( !a1 || !*a1 )
{
v12 = 128LL;
goto LABEL_31;
}
if ( !a2 || !*a2 )
{
v12 = 129LL;
goto LABEL_31;
}
if ( !a5 || !*a5 )
{
v12 = 130LL;
goto LABEL_31;
}
if ( !a6 || !*a6 )
{
v12 = 131LL;
goto LABEL_31;
}
if ( !strcmp(a1, a5) )
{
v18 = -1;
fprintf(stderr, "Line %3d of File %s \n", 132LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v11 = strtoll(a3, &endptr, 10);
v12 = 134LL;
v22 = v11;
if ( *endptr )
goto LABEL_31;
v13 = strtoll(a4, &endptr, 10);
v12 = 136LL;
v14 = v13;
if ( *endptr )
goto LABEL_31;
v15 = strtoll(nptr, &endptr, 10);
v12 = 138LL;
v23 = v15;
if ( *endptr )
goto LABEL_31;
zero_string(v42, 16LL, 138LL, "./dir_wr_verbs/stride.c");
zero_string(v43, 16LL, v16, v17);
v18 = is_tbl(a1, v26, v44);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 142LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v24 = v44[0];
v18 = is_fld(a1, 0xFFFFFFFFLL, a2, v28, &v46, &v29, v48);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 145LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = get_data(&addr, &len, 0LL);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 146LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v12 = 147LL;
if ( v29 >= 0 )
{
LABEL_31:
v18 = -1;
fprintf(stderr, "Line %3d of File %s \n", v12, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = del_tbl(a5, 0xFFFFFFFFLL, 147LL, "./dir_wr_verbs/stride.c");
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 148LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
if ( v22 < 0 || v22 >= v24 )
{
v12 = 150LL;
goto LABEL_31;
}
if ( v14 <= 0 || v14 >= v24 )
{
v12 = 151LL;
goto LABEL_31;
}
v18 = get_fld_sz((unsigned int)v47, &v32);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 154LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = mk_temp_file(v42, v23 * v32, &v33);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 156LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = q_mmap(v33, v42, &v37, &v38, 1LL);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 157LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
v18 = mk_temp_file(v43, v23, &v34);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 159LL, "./dir_wr_verbs/stride.c");
}
else
{
if ( v22 + v14 * v23 >= v23 )
{
v18 = q_mmap(v34, v43, &v39, &v40, 1LL);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 161LL, "./dir_wr_verbs/stride.c");
goto LABEL_32;
}
}
if ( (_DWORD)v47 == 4 )
{
v18 = func0((__int64)addr, v24, v22, v14, (__int64)v37, (__int64)v39, v23, &v25);
}
else
{
if ( (_DWORD)v47 != 5 )
{
v12 = 174LL;
goto LABEL_31;
}
v18 = func1((__int64)addr, v24, v22, v14, (__int64)v37, (__int64)v39, v23, &v25);
}
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 177LL, "./dir_wr_verbs/stride.c");
}
else
{
v18 = add_tbl(a5, nptr, &v27, v45);
if ( v18 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 179LL, "./dir_wr_verbs/stride.c");
}
else
{
v21 = add_fld(v27, a6, v33, v42, (unsigned int)v47, 0xFFFFFFFFLL, &v30, v49);
v18 = v21;
if ( (int)v21 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 181LL, "./dir_wr_verbs/stride.c");
}
else if ( v25 )
{
v18 = add_aux_fld(0LL, v27, 0LL, v30, v34, v43, "nn", v31, v50, v21);
}
}
}
}
LABEL_32:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_35;
}
LABEL_44:
v20 = 190LL;
LABEL_45:
v18 = -1;
fprintf(stderr, "Line %3d of File %s \n", v20, "./dir_wr_verbs/stride.c");
return (unsigned int)v18;
}
if ( len )
goto LABEL_44;
LABEL_35:
if ( v37 )
{
if ( v38 )
{
munmap(v37, v38);
v37 = 0LL;
v38 = 0LL;
goto LABEL_38;
}
goto LABEL_47;
}
if ( v38 )
{
LABEL_47:
v20 = 191LL;
goto LABEL_45;
}
LABEL_38:
if ( !v39 )
{
if ( !v40 )
return (unsigned int)v18;
goto LABEL_49;
}
if ( !v40 )
{
LABEL_49:
v20 = 192LL;
goto LABEL_45;
}
munmap(v39, v40);
return (unsigned int)v18;
}

original_code:
int
ext_stride(
    const char *t1,
    const char *f1,
    char *str_start,
    char *str_stride,
    const char *t2,
    const char *f2,
    char *str_nR2
    )
{
  int status = 0;
  char *f1_X = ((void *)0); size_t f1_nX = 0;
  char *f2_X = ((void *)0); size_t f2_nX = 0;
  char *nn_f2_X = ((void *)0); size_t nn_f2_nX = 0;
  long long nR1, nR2;
  TBL_REC_TYPE t1_rec; int t1_id;
  TBL_REC_TYPE t2_rec; int t2_id;
  FLD_REC_TYPE f1_rec; int f1_id;
  FLD_REC_TYPE nn_f1_rec; int nn_f1_id;
  FLD_REC_TYPE f2_rec; int f2_id;
  FLD_REC_TYPE nn_f2_rec; int nn_f2_id;
  long long start, stride; char *endptr;
  _Bool is_any_null;
  char opfile[15 +1];
  char nn_opfile[15 +1];
  int fldsz = 0x7fffffff, ddir_id = 0x7fffffff, nn_ddir_id = 0x7fffffff;
  if ( ( t1 == ((void *)0) ) || ( *t1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 128, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 129, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( ( t2 == ((void *)0) ) || ( *t2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 130, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 131, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t1, t2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 132, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  start = strtoll(str_start, &endptr, 10);
  if ( *endptr != '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 134, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  stride = strtoll(str_stride, &endptr, 10);
  if ( *endptr != '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 136, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  nR2 = strtoll(str_nR2, &endptr, 10);
  if ( *endptr != '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 138, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  zero_string(opfile, 15 +1);
  zero_string(nn_opfile, 15 +1);
  status = is_tbl(t1, &t1_id, &t1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 142, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  nR1 = t1_rec.nR;
  status = is_fld(t1, -1, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 145, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = get_data(f1_rec, &f1_X, &f1_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 146, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_f1_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 147, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  status = del_tbl(t2, -1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 148, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  if ( ( start < 0 ) || ( start >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 150, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( ( stride <= 0 ) || ( stride >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 151, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  status = get_fld_sz(f1_rec.fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 154, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = mk_temp_file(opfile, (nR2 * fldsz), &ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 156, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, opfile, &f2_X, &f2_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 157, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = mk_temp_file(nn_opfile, (nR2 * sizeof(char)), &nn_ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 159, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  if ( start + (stride * nR2) >= nR2 ) {
    status = q_mmap(nn_ddir_id, nn_opfile, &nn_f2_X, &nn_f2_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 161, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  }
  switch ( f1_rec.fldtype ) {
    case I4 :
      status = int_stride_I4((int *)f1_X, nR1, start, stride,
   (int *)f2_X, nn_f2_X, nR2, &is_any_null);
      break;
    case I8 :
      status = int_stride_I8((long long *)f1_X, nR1, start, stride,
   (long long *)f2_X, nn_f2_X, nR2, &is_any_null);
      break;
    default :
      { { fprintf(stderr, "Line %3d of File %s \n", 174, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; };
      break;
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 177, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = add_tbl(t2, str_nR2, &t2_id, &t2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 179, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(t2_id, f2, ddir_id, opfile, f1_rec.fldtype, -1, &f2_id, &f2_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 181, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  if ( is_any_null == 1 ) {
    status = add_aux_fld(((void *)0), t2_id, ((void *)0), f2_id, nn_ddir_id,
 nn_opfile, "nn", &nn_f2_id, &nn_f2_rec);
  }
  else {
  }
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 190, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 190, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( f1_X != ((void *)0) ) { munmap(f1_X, f1_nX); f1_X = ((void *)0); f1_nX = 0; } };
  { if ( ( f2_X == ((void *)0) ) && ( f2_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 191, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( ( f2_X != ((void *)0) ) && ( f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 191, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( f2_X != ((void *)0) ) { munmap(f2_X, f2_nX); f2_X = ((void *)0); f2_nX = 0; } };
  { if ( ( nn_f2_X == ((void *)0) ) && ( nn_f2_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 192, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( ( nn_f2_X != ((void *)0) ) && ( nn_f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 192, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( nn_f2_X != ((void *)0) ) { munmap(nn_f2_X, nn_f2_nX); nn_f2_X = ((void *)0); nn_f2_nX = 0; } };
  return(status);
}

canonical_original_code:
int ext_stride(char *t1, char *f1, char *str_start, char *str_stride, char *t2, char *f2, char *str_nR2)
{
  int status = 0;
  char *f1_X = ((void *)0); unsigned long f1_nX = 0;
  char *f2_X = ((void *)0); unsigned long f2_nX = 0;
  char *nn_f2_X = ((void *)0); unsigned long nn_f2_nX = 0;
  long long nR1; long long nR2;
  struct _TBL_REC_TYPE t1_rec; int t1_id;
  struct _TBL_REC_TYPE t2_rec; int t2_id;
  struct _FLD_REC_TYPE f1_rec; int f1_id;
  struct _FLD_REC_TYPE nn_f1_rec; int nn_f1_id;
  struct _FLD_REC_TYPE f2_rec; int f2_id;
  struct _FLD_REC_TYPE nn_f2_rec; int nn_f2_id;
  long long start; long long stride; char *endptr;
  _Bool is_any_null;
  char opfile[-1];
  char nn_opfile[-1];
  int fldsz = 0x7fffffff; int ddir_id = 0x7fffffff; int nn_ddir_id = 0x7fffffff;
  if ( ( t1 == ((void *)0) ) || ( *t1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 128, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 129, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( ( t2 == ((void *)0) ) || ( *t2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 130, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 131, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t1, t2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 132, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  start = strtoll(str_start, &endptr, 10);
  if ( *endptr != '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 134, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  stride = strtoll(str_stride, &endptr, 10);
  if ( *endptr != '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 136, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  nR2 = strtoll(str_nR2, &endptr, 10);
  if ( *endptr != '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 138, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  zero_string(opfile, 15 +1);
  zero_string(nn_opfile, 15 +1);
  status = is_tbl(t1, &t1_id, &t1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 142, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  nR1 = t1_rec.nR;
  status = is_fld(t1, -1, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 145, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = get_data(f1_rec, &f1_X, &f1_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 146, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_f1_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 147, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  status = del_tbl(t2, -1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 148, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  if ( ( start < 0 ) || ( start >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 150, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  if ( ( stride <= 0 ) || ( stride >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 151, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; }; }
  status = get_fld_sz(f1_rec.fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 154, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = mk_temp_file(opfile, (nR2 * fldsz), &ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 156, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, opfile, &f2_X, &f2_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 157, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = mk_temp_file(nn_opfile, (nR2 * sizeof(char)), &nn_ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 159, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  if ( start + (stride * nR2) >= nR2 ) {
    status = q_mmap(nn_ddir_id, nn_opfile, &nn_f2_X, &nn_f2_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 161, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  }
  switch ( f1_rec.fldtype ) {
    case I4 :
      status = int_stride_I4((int *)f1_X, nR1, start, stride,
   (int *)f2_X, nn_f2_X, nR2, &is_any_null);
      break;
    case I8 :
      status = int_stride_I8((long long *)f1_X, nR1, start, stride,
   (long long *)f2_X, nn_f2_X, nR2, &is_any_null);
      break;
    default :
      { { fprintf(stderr, "Line %3d of File %s \n", 174, "./dir_wr_verbs/stride.c"); }; status = -1 ; goto BYE; };
      break;
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 177, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = add_tbl(t2, str_nR2, &t2_id, &t2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 179, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(t2_id, f2, ddir_id, opfile, f1_rec.fldtype, -1, &f2_id, &f2_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 181, "./dir_wr_verbs/stride.c"); }; status = (status) ; goto BYE; } } };
  if ( is_any_null == 1 ) {
    status = add_aux_fld(((void *)0), t2_id, ((void *)0), f2_id, nn_ddir_id,
 nn_opfile, "nn", &nn_f2_id, &nn_f2_rec);
  }
  else {
  }
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 190, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 190, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( f1_X != ((void *)0) ) { munmap(f1_X, f1_nX); f1_X = ((void *)0); f1_nX = 0; } };
  { if ( ( f2_X == ((void *)0) ) && ( f2_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 191, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( ( f2_X != ((void *)0) ) && ( f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 191, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( f2_X != ((void *)0) ) { munmap(f2_X, f2_nX); f2_X = ((void *)0); f2_nX = 0; } };
  { if ( ( nn_f2_X == ((void *)0) ) && ( nn_f2_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 192, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( ( nn_f2_X != ((void *)0) ) && ( nn_f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 192, "./dir_wr_verbs/stride.c"); }; return(-1); } if ( nn_f2_X != ((void *)0) ) { munmap(nn_f2_X, nn_f2_nX); nn_f2_X = ((void *)0); nn_f2_nX = 0; } };
  return(status);
}

variable_types:
opfile
char [-1]

variable_types: fldsz int

user_defined_types: struct _TBL_REC_TYPE { long long nR; char name[-1]; char dispname[-1]; _Bool is_dict_tbl; }


decompiled_code:
__int64 __fastcall hop_sort_compare(const void *a1, const void *a2)
{
__int64 result; // rax

result = 1LL;
if ( *(_QWORD *)a1 <= *(_QWORD *)a2 )
result = (unsigned int)-(*(_QWORD *)a1 < *(_QWORD *)a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
__int64 result; // rax

result = 1LL;
if ( *(_QWORD *)a1 <= *(_QWORD *)a2 )
result = (unsigned int)-(*(_QWORD *)a1 < *(_QWORD *)a2);
return result;
}

original_code:
int hop_sort_compare(
       const void *in1,
       const void *in2
       )
{
  HOP_REC_TYPE *hop1, *hop2;
  hop1 = (HOP_REC_TYPE *)in1;
  hop2 = (HOP_REC_TYPE *)in2;
  long long hash1 = (long long)(hop1->key);
  long long hash2 = (long long)(hop2->key);
  if ( hash1 > hash2 ) {
    return (1);
  }
  else if ( hash1 < hash2 ) {
    return (-1);
  }
  else {
    return(0);
  }
}

canonical_original_code:
int hop_sort_compare(void *in1, void *in2)
{
  struct _HOP_REC_TYPE *hop1; struct _HOP_REC_TYPE *hop2;
  hop1 = (struct _HOP_REC_TYPE *)in1;
  hop2 = (struct _HOP_REC_TYPE *)in2;
  long long hash1 = (long long)(hop1->key);
  long long hash2 = (long long)(hop2->key);
  if ( hash1 > hash2 ) {
    return (1);
  }
  else if ( hash1 < hash2 ) {
    return (-1);
  }
  else {
    return(0);
  }
}

variable_types: struct _HOP_REC_TYPE { unsigned long long key; unsigned int len; unsigned int orig_idx; } *


original_code:
int
pos_mmad_I4_I4_nn(
    int *f1,
    char *nn_f1,
    long long nR1,
    int *f2,
    char *nn_f2,
    long long nR2,
    int *ptr_minval,
    int *ptr_maxval,
    long long *ptr_sum,
    long long *ptr_cnt
    )
{
  int status = 0;
  int minval = *ptr_minval;
  int maxval = *ptr_maxval;
  long long sum = *ptr_sum;
  long long cnt = *ptr_cnt;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( nn_f2 != ((void *)0) ) && ( nn_f2[i] == 0 ) ) { continue; }
    int f1idx = f2[i];
    if ( ( nn_f1 != ((void *)0) ) && ( nn_f1[f1idx] == 0 ) ) { continue; }
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "./AUX/pos_mmad_I4_I4_nn.c"); }; status = -1 ; goto BYE; }; }
    int f1val = f1[f1idx];
    if ( f1val < minval ) { minval = f1val; }
    if ( f1val > maxval ) { maxval = f1val; }
    sum += (long long)f1val;
    cnt++;
  }
  *ptr_minval = minval;
  *ptr_maxval = maxval;
  *ptr_sum = sum;
  *ptr_cnt = cnt;
BYE:
  return(status);
}

canonical_original_code:
int pos_mmad_I4_I4_nn(int *f1, char *nn_f1, long long nR1, int *f2, char *nn_f2, long long nR2, int *ptr_minval, int *ptr_maxval, long long *ptr_sum, long long *ptr_cnt)
{
  int status = 0;
  int minval = *ptr_minval;
  int maxval = *ptr_maxval;
  long long sum = *ptr_sum;
  long long cnt = *ptr_cnt;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( nn_f2 != ((void *)0) ) && ( nn_f2[i] == 0 ) ) { continue; }
    int f1idx = f2[i];
    if ( ( nn_f1 != ((void *)0) ) && ( nn_f1[f1idx] == 0 ) ) { continue; }
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "./AUX/pos_mmad_I4_I4_nn.c"); }; status = -1 ; goto BYE; }; }
    int f1val = f1[f1idx];
    if ( f1val < minval ) { minval = f1val; }
    if ( f1val > maxval ) { maxval = f1val; }
    sum += (long long)f1val;
    cnt++;
  }
  *ptr_minval = minval;
  *ptr_maxval = maxval;
  *ptr_sum = sum;
  *ptr_cnt = cnt;
BYE:
  return(status);
}

variable_types: status int

variable_types: minval int

variable_types: maxval int

variable_types:
sum
long long


original_code:
void
shiftright2_UI4(
       unsigned int *in1,
       unsigned int *in2,
       long long nR,
       unsigned int * restrict out
       )
{
  unsigned int inv1, inv2, outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 >> inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

canonical_original_code:
void shiftright2_UI4(unsigned int *in1, unsigned int *in2, long long nR, unsigned int *out)
{
  unsigned int inv1; unsigned int inv2; unsigned int outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 >> inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

variable_types:
out
unsigned int *

variable_types:
outv
unsigned int


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

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

variable_types:
lb
long long

variable_types:
ub
long long

variable_types:
cnt
long long

variable_types:
val
long long