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 v10; // ebx
const char *v11; // rdi
__int64 v12; // rbp
__int64 v13; // r15
__int64 v14; // rax
const __m128i *v15; // roff
__int64 v16; // rdx
unsigned int v21; // [rsp+1Ch] [rbp-21Ch]
char v22[4]; // [rsp+2Ch] [rbp-20Ch] BYREF
char v23[236]; // [rsp+30h] [rbp-208h] BYREF
unsigned int v24; // [rsp+11Ch] [rbp-11Ch] BYREF
char v25[280]; // [rsp+120h] [rbp-118h] BYREF

*a7 = -1;
zero_fld_rec(a8);
if ( a1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 98LL, "./dir_wr_verbs/add_fld.c");
v10 = -1;
}
else if ( a2 && *a2 )
{
v10 = chk_fld_name(a2, 0LL);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 101LL, "./dir_wr_verbs/add_fld.c");
}
else
{
if ( a3 < 0 )
{
chdir(g_data_dir);
}
else
{
v11 = (const char *)(g_ddirs + ((__int64)a3 << 9));
if ( !v11 || !*v11 )
{
fprintf(stderr, "Line %3d of File %s \n", 108LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
chdir(v11);
}
v10 = chk_file_size(a4, *(_QWORD *)(g_tbls + 176LL * a1), a5);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 111LL, "./dir_wr_verbs/add_fld.c");
}
else
{
chdir(&g_cwd);
v10 = is_fld(0LL, (unsigned int)a1, a2, &v24, v25, v22, v23);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 114LL, "./dir_wr_verbs/add_fld.c");
}
else
{
if ( (v24 & 0x80000000) != 0 )
{
v10 = get_empty_fld(a2, g_flds, g_n_fld, (int *)&v24);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 120LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v10;
}
}
else
{
v10 = del_fld(0LL, (unsigned int)a1, 0LL, v24, 1LL);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 117LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v10;
}
}
zero_fld_rec(g_flds + 224LL * (int)v24);
*(_DWORD *)(g_flds + 224LL * (int)v24) = a1;
v21 = v24;
v12 = 224LL * (int)v24;
v13 = g_flds + v12;
*(_DWORD *)(v13 + 8) = 0;
*(_DWORD *)(v13 + 12) = 0;
*(_DWORD *)(v13 + 16) = 0x80000000;
*(_DWORD *)(v13 + 20) = 0x80000000;
*(_QWORD *)(v13 + 24) = a5;
if ( a6 < 0 )
{
*(_QWORD *)(v13 + 216) = -1LL;
}
else
{
if ( a5 != 8 )
{
fprintf(stderr, "Line %3d of File %s \n", 134LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
if ( a6 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 135LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
*(_QWORD *)(v13 + 216) = a6;
}
if ( strlen(a4) > 0xF )
{
fprintf(stderr, "Filename=[%s] too long > %d characters\n", a4, 15LL);
fprintf(stderr, "Line %3d of File %s \n", 143LL, "./dir_wr_verbs/add_fld.c");
v10 = -1;
}
else
{
strcpy((char *)(v13 + 64), a4);
*(_DWORD *)(v13 + 4) = a3;
if ( strlen(a2) > 0x1F )
{
fprintf(stderr, "Line %3d of File %s \n", 149LL, "./dir_wr_verbs/add_fld.c");
v10 = -1;
}
else
{
strcpy((char *)(g_flds + v12 + 32), a2);
*a7 = v21;
v14 = g_flds;
v15 = (const __m128i *)(g_flds + v12);
*a8 = _mm_loadu_si128((const __m128i *)(g_flds + v12));
a8[1] = _mm_loadu_si128(v15 + 1);
a8[2] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 32));
a8[3] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 48));
a8[4] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 64));
a8[5] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 80));
a8[6] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 96));
a8[7] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 112));
a8[8] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 128));
a8[9] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 144));
a8[10] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 160));
a8[11] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 176));
a8[12] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 192));
v16 = *(_QWORD *)(v14 + v12 + 216);
a8[13].m128i_i64[0] = *(_QWORD *)(v14 + v12 + 208);
a8[13].m128i_i64[1] = v16;
}
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 99LL, "./dir_wr_verbs/add_fld.c");
v10 = -1;
}
return (unsigned int)v10;
}

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 v10; // ebx
const char *v11; // rdi
__int64 v12; // rbp
__int64 v13; // r15
__int64 v14; // rax
const __m128i *v15; // roff
__int64 v16; // rdx
unsigned int v21; // [rsp+1Ch] [rbp-21Ch]
char v22[4]; // [rsp+2Ch] [rbp-20Ch] BYREF
char v23[236]; // [rsp+30h] [rbp-208h] BYREF
unsigned int v24; // [rsp+11Ch] [rbp-11Ch] BYREF
char v25[280]; // [rsp+120h] [rbp-118h] BYREF

*a7 = -1;
zero_fld_rec(a8);
if ( a1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 98LL, "./dir_wr_verbs/add_fld.c");
v10 = -1;
}
else if ( a2 && *a2 )
{
v10 = chk_fld_name(a2, 0LL);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 101LL, "./dir_wr_verbs/add_fld.c");
}
else
{
if ( a3 < 0 )
{
chdir(g_data_dir);
}
else
{
v11 = (const char *)(g_ddirs + ((__int64)a3 << 9));
if ( !v11 || !*v11 )
{
fprintf(stderr, "Line %3d of File %s \n", 108LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
chdir(v11);
}
v10 = chk_file_size(a4, *(_QWORD *)(g_tbls + 176LL * a1), a5);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 111LL, "./dir_wr_verbs/add_fld.c");
}
else
{
chdir(&g_cwd);
v10 = is_fld(0LL, (unsigned int)a1, a2, &v24, v25, v22, v23);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 114LL, "./dir_wr_verbs/add_fld.c");
}
else
{
if ( (v24 & 0x80000000) != 0 )
{
v10 = func0(a2, g_flds, g_n_fld, (int *)&v24);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 120LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v10;
}
}
else
{
v10 = del_fld(0LL, (unsigned int)a1, 0LL, v24, 1LL);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 117LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)v10;
}
}
zero_fld_rec(g_flds + 224LL * (int)v24);
*(_DWORD *)(g_flds + 224LL * (int)v24) = a1;
v21 = v24;
v12 = 224LL * (int)v24;
v13 = g_flds + v12;
*(_DWORD *)(v13 + 8) = 0;
*(_DWORD *)(v13 + 12) = 0;
*(_DWORD *)(v13 + 16) = 0x80000000;
*(_DWORD *)(v13 + 20) = 0x80000000;
*(_QWORD *)(v13 + 24) = a5;
if ( a6 < 0 )
{
*(_QWORD *)(v13 + 216) = -1LL;
}
else
{
if ( a5 != 8 )
{
fprintf(stderr, "Line %3d of File %s \n", 134LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
if ( a6 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 135LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
*(_QWORD *)(v13 + 216) = a6;
}
if ( strlen(a4) > 0xF )
{
fprintf(stderr, "Filename=[%s] too long > %d characters\n", a4, 15LL);
fprintf(stderr, "Line %3d of File %s \n", 143LL, "./dir_wr_verbs/add_fld.c");
v10 = -1;
}
else
{
strcpy((char *)(v13 + 64), a4);
*(_DWORD *)(v13 + 4) = a3;
if ( strlen(a2) > 0x1F )
{
fprintf(stderr, "Line %3d of File %s \n", 149LL, "./dir_wr_verbs/add_fld.c");
v10 = -1;
}
else
{
strcpy((char *)(g_flds + v12 + 32), a2);
*a7 = v21;
v14 = g_flds;
v15 = (const __m128i *)(g_flds + v12);
*a8 = _mm_loadu_si128((const __m128i *)(g_flds + v12));
a8[1] = _mm_loadu_si128(v15 + 1);
a8[2] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 32));
a8[3] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 48));
a8[4] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 64));
a8[5] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 80));
a8[6] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 96));
a8[7] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 112));
a8[8] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 128));
a8[9] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 144));
a8[10] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 160));
a8[11] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 176));
a8[12] = _mm_loadu_si128((const __m128i *)(v14 + v12 + 192));
v16 = *(_QWORD *)(v14 + v12 + 216);
a8[13].m128i_i64[0] = *(_QWORD *)(v14 + v12 + 208);
a8[13].m128i_i64[1] = v16;
}
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 99LL, "./dir_wr_verbs/add_fld.c");
v10 = -1;
}
return (unsigned int)v10;
}

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


repo: linkedin/datacl

decompiled_code:
__int64 __fastcall ext_add_fld(__int64 a1, char *a2, __int64 a3)
{
int v4; // ebx
int v5; // eax
int v6; // er9
char *v8; // [rsp+0h] [rbp-EC8h] BYREF
char v9; // [rsp+Fh] [rbp-EB9h] BYREF
char s2[1024]; // [rsp+10h] [rbp-EB8h] BYREF
char v11[1024]; // [rsp+410h] [rbp-AB8h] BYREF
char nptr[1032]; // [rsp+810h] [rbp-6B8h] BYREF
unsigned int v13; // [rsp+C18h] [rbp-2B0h] BYREF
char v14[4]; // [rsp+C1Ch] [rbp-2ACh] BYREF
char v15[236]; // [rsp+C20h] [rbp-2A8h] BYREF
int v16; // [rsp+D0Ch] [rbp-1BCh] BYREF
__m128i v17[4]; // [rsp+D10h] [rbp-1B8h] BYREF
char s1[172]; // [rsp+D50h] [rbp-178h] BYREF
int v19; // [rsp+DFCh] [rbp-CCh] BYREF
char v20[200]; // [rsp+E00h] [rbp-C8h] BYREF

is_tbl(a1, &v19, v20);
if ( v19 < 0 || v19 >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 180LL, "./dir_wr_verbs/add_fld.c");
v4 = -1;
}
else
{
is_fld(0LL, (unsigned int)v19, a2, &v16, v17, v14, v15);
if ( v16 >= 0 )
{
extract_S(a3, "filename=[", "]", s2, 1024LL, &v9);
if ( v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 184LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
if ( !strcmp(s1, s2) )
{
fwrite("Need to handle this case\n", 1uLL, 0x19uLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 187LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
del_fld(0LL, (unsigned int)v19, 0LL, (unsigned int)v16, 1LL);
}
extract_S(a3, "fldtype=[", "]", v11, 1024LL, &v9);
if ( v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 194LL, "./dir_wr_verbs/add_fld.c");
v4 = -1;
}
else
{
v4 = unstr_fldtype(v11, &v13);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 195LL, "./dir_wr_verbs/add_fld.c");
}
else
{
extract_S(a3, "filename=[", "]", s2, 1024LL, &v9);
if ( v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 198LL, "./dir_wr_verbs/add_fld.c");
v4 = -1;
}
else
{
extract_S(a3, "len=[", "]", nptr, 1024LL, &v9);
if ( v9 )
{
v6 = -1;
}
else
{
v5 = strtoll(nptr, &v8, 10);
v6 = v5;
if ( *v8 )
{
fprintf(stderr, "Line %3d of File %s \n", 204LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
if ( v5 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 205LL, "./dir_wr_verbs/add_fld.c");
return (unsigned int)-1;
}
}
v4 = add_fld(v19, a2, -1, s2, v13, v6, (unsigned int *)&v16, v17);
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; // ebx
int v5; // eax
int v6; // er9
char *v8; // [rsp+0h] [rbp-EC8h] BYREF
char v9; // [rsp+Fh] [rbp-EB9h] BYREF
char s2[1024]; // [rsp+10h] [rbp-EB8h] BYREF
char v11[1024]; // [rsp+410h] [rbp-AB8h] BYREF
char nptr[1032]; // [rsp+810h] [rbp-6B8h] BYREF
unsigned int v13; // [rsp+C18h] [rbp-2B0h] BYREF
char v14[4]; // [rsp+C1Ch] [rbp-2ACh] BYREF
char v15[236]; // [rsp+C20h] [rbp-2A8h] BYREF
int v16; // [rsp+D0Ch] [rbp-1BCh] BYREF
__m128i v17[4]; // [rsp+D10h] [rbp-1B8h] BYREF
char s1[172]; // [rsp+D50h] [rbp-178h] BYREF
int v19; // [rsp+DFCh] [rbp-CCh] BYREF
char v20[200]; // [rsp+E00h] [rbp-C8h] BYREF

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

variable_types:
fldspec
char *

variable_types: status int

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 *

return_type: 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; }

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

return_type: void


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

variable_types: i int


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


decompiled_code:
__int64 __fastcall ext_stride(const char *a1, _BYTE *a2, const char *a3, const char *a4, const char *a5, _BYTE *a6, char *nptr)
{
int v11; // er14
__int64 v12; // r15
__int64 v14; // [rsp+8h] [rbp-600h]
__int64 v15; // [rsp+10h] [rbp-5F8h]
__int64 v16; // [rsp+18h] [rbp-5F0h]
unsigned int v17; // [rsp+24h] [rbp-5E4h] BYREF
unsigned int v18; // [rsp+28h] [rbp-5E0h] BYREF
int v19; // [rsp+2Ch] [rbp-5DCh] BYREF
char v20[16]; // [rsp+30h] [rbp-5D8h] BYREF
char v21[31]; // [rsp+40h] [rbp-5C8h] BYREF
char v22; // [rsp+5Fh] [rbp-5A9h] BYREF
char *endptr; // [rsp+60h] [rbp-5A8h] BYREF
char v24[4]; // [rsp+6Ch] [rbp-59Ch] BYREF
char v25[236]; // [rsp+70h] [rbp-598h] BYREF
unsigned int v26; // [rsp+15Ch] [rbp-4ACh] BYREF
char v27[236]; // [rsp+160h] [rbp-4A8h] BYREF
int v28; // [rsp+24Ch] [rbp-3BCh] BYREF
char v29[236]; // [rsp+250h] [rbp-3B8h] BYREF
char v30[4]; // [rsp+33Ch] [rbp-2CCh] BYREF
__int64 v31; // [rsp+340h] [rbp-2C8h] BYREF
__int64 v32; // [rsp+358h] [rbp-2B0h]
unsigned int v33; // [rsp+42Ch] [rbp-1DCh] BYREF
char v34[188]; // [rsp+430h] [rbp-1D8h] BYREF
char v35[4]; // [rsp+4ECh] [rbp-11Ch] BYREF
__int64 v36[22]; // [rsp+4F0h] [rbp-118h] BYREF
size_t v37; // [rsp+5A0h] [rbp-68h] BYREF
void *v38; // [rsp+5A8h] [rbp-60h] BYREF
size_t v39; // [rsp+5B0h] [rbp-58h] BYREF
void *v40; // [rsp+5B8h] [rbp-50h] BYREF
size_t len; // [rsp+5C0h] [rbp-48h] BYREF
void *addr; // [rsp+5C8h] [rbp-40h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, _BYTE *a2, const char *a3, const char *a4, const char *a5, _BYTE *a6, char *nptr)
{
int v11; // er14
__int64 v12; // r15
__int64 v14; // [rsp+8h] [rbp-600h]
__int64 v15; // [rsp+10h] [rbp-5F8h]
__int64 v16; // [rsp+18h] [rbp-5F0h]
unsigned int v17; // [rsp+24h] [rbp-5E4h] BYREF
unsigned int v18; // [rsp+28h] [rbp-5E0h] BYREF
int v19; // [rsp+2Ch] [rbp-5DCh] BYREF
char v20[16]; // [rsp+30h] [rbp-5D8h] BYREF
char v21[31]; // [rsp+40h] [rbp-5C8h] BYREF
char v22; // [rsp+5Fh] [rbp-5A9h] BYREF
char *endptr; // [rsp+60h] [rbp-5A8h] BYREF
char v24[4]; // [rsp+6Ch] [rbp-59Ch] BYREF
char v25[236]; // [rsp+70h] [rbp-598h] BYREF
unsigned int v26; // [rsp+15Ch] [rbp-4ACh] BYREF
char v27[236]; // [rsp+160h] [rbp-4A8h] BYREF
int v28; // [rsp+24Ch] [rbp-3BCh] BYREF
char v29[236]; // [rsp+250h] [rbp-3B8h] BYREF
char v30[4]; // [rsp+33Ch] [rbp-2CCh] BYREF
__int64 v31; // [rsp+340h] [rbp-2C8h] BYREF
__int64 v32; // [rsp+358h] [rbp-2B0h]
unsigned int v33; // [rsp+42Ch] [rbp-1DCh] BYREF
char v34[188]; // [rsp+430h] [rbp-1D8h] BYREF
char v35[4]; // [rsp+4ECh] [rbp-11Ch] BYREF
__int64 v36[22]; // [rsp+4F0h] [rbp-118h] BYREF
size_t v37; // [rsp+5A0h] [rbp-68h] BYREF
void *v38; // [rsp+5A8h] [rbp-60h] BYREF
size_t v39; // [rsp+5B0h] [rbp-58h] BYREF
void *v40; // [rsp+5B8h] [rbp-50h] BYREF
size_t len; // [rsp+5C0h] [rbp-48h] BYREF
void *addr; // [rsp+5C8h] [rbp-40h] BYREF

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

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


original_code:
int
t1f1t2f2opt3f3(
        char *t1,
        char *f1,
        char *t2,
        char *f2,
        char *op,
        char *options,
        char *t3,
        char *f3
        )
{
  int status = 0;
  char *f1_X = ((void *)0); size_t f1_nX = 0;
  char *f2_X = ((void *)0); size_t f2_nX = 0;
  char *f3_X = ((void *)0); size_t f3_nX = 0;
  int t1_id = (-0x7fffffff - 1), t2_id = (-0x7fffffff - 1), t3_id = (-0x7fffffff - 1);
  int f1_id = (-0x7fffffff - 1), f2_id = (-0x7fffffff - 1), f3_id = (-0x7fffffff - 1);
  int nn_f1_id = (-0x7fffffff - 1), nn_f2_id = (-0x7fffffff - 1);
  TBL_REC_TYPE t1_rec, t2_rec, t3_rec;
  FLD_REC_TYPE f1_rec, nn_f1_rec;
  FLD_REC_TYPE f2_rec, nn_f2_rec;
  FLD_REC_TYPE f3_rec;
  FLD_TYPE f3_type = undef_fldtype;
  long long nR1 = (-0x7fffffff - 1), nR2 = (-0x7fffffff - 1);
  long long nR3 = (-0x7fffffff - 1), nR3_allocated = (-0x7fffffff - 1);
  int f3_fldsz = 0x7fffffff; size_t filesz;
  int ddir_id = -1, fileno = -1;
  if ( ( t1 == ((void *)0) ) || ( *t1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( t2 == ((void *)0) ) || ( *t2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( op == ((void *)0) ) || ( *op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 67, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f3 == ((void *)0) ) || ( *f3 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t1, t3) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( t3 == ((void *)0) ) || ( *t3 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t2, t3) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(t1, &t1_id, &t1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( t1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  nR1 = t1_rec.nR;
  status = is_fld(((void *)0), t1_id, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(f1_rec, &f1_X, &f1_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  status = is_tbl(t2, &t2_id, &t2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( t2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  nR2 = t2_rec.nR;
  status = is_fld(((void *)0), t2_id, f2, &f2_id, &f2_rec, &nn_f2_id, &nn_f2_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(f2_rec, &f2_X, &f2_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_rec.srttype != ascending ) { { { fprintf(stderr, "Line %3d of File %s \n", 93, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( f2_rec.srttype != ascending ) { { { fprintf(stderr, "Line %3d of File %s \n", 94, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_f1_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 96, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_f2_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 97, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.fldtype != f2_rec.fldtype ) { { { fprintf(stderr, "Line %3d of File %s \n", 98, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  switch ( f1_rec.fldtype ) {
    case I4 : case I8 : break;
    default : { { fprintf(stderr, "Line %3d of File %s \n", 101, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; break;
  }
  f3_type = f1_rec.fldtype;
  status = get_fld_sz(f3_type, &f3_fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 104, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( strcmp(op, "intersection") == 0 ) {
    nR3_allocated = ((nR1) < (nR2) ? (nR1) : (nR2));
  }
  else if ( strcmp(op, "a_minus_b") == 0 ) {
    nR3_allocated = nR1;
  }
  else if ( ( strcmp(op, "union") == 0 ) ||
            ( strcmp(op, "pvalcalc") == 0 ) ) {
    nR3_allocated = nR1 + nR2;
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 117, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; };
  }
  filesz = f3_fldsz * nR3_allocated;
  status = mk_temp_file(filesz, &ddir_id, &fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 121, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, fileno, &f3_X, &f3_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 122, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( strcmp(op, "intersection") == 0 ) {
    switch ( f1_rec.fldtype ) {
      case I4 :
 status = intersection_I4((int *)f1_X, nR1, (int *)f2_X, nR2,
     (int *)f3_X, &nR3);
 break;
      case I8 :
 status = intersection_I8((long long *)f1_X, nR1,
     (long long *)f2_X, nR2, (long long *)f3_X, &nR3);
 break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 134, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; break;
    }
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 136, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(op, "a_minus_b") == 0 ) {
    switch ( f1_rec.fldtype ) {
      case I4 :
 a_minus_b_I4((int *)f1_X, nR1, (int *)f2_X, nR2, (int *)f3_X, &nR3);
 break;
      case I8 :
 a_minus_b_I8((long long *)f1_X, nR1, (long long *)f2_X, nR2, (long long *)f3_X, &nR3);
 break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 146, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; break;
    }
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 148, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( ( strcmp(op, "union") == 0 ) ||
            ( strcmp(op, "pvalcalc") == 0 ) ) {
    unsigned long long mask = 0;
    if ( strcmp(op, "pvalcalc") == 0 ) {
      _Bool is_null = 0;
      status = extract_UI8(options, "mask=[", "]", &mask, &is_null);
      if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 156, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
    }
    switch ( f1_rec.fldtype ) {
      case I4 :
        status = union_I4((int *)f1_X, nR1, (int *)f2_X, nR2,
           (int *)f3_X, &nR3, (unsigned int)mask);
        { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 162, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
      break;
      case I8 :
        status = union_I8((long long *)f1_X, nR1, (long long *)f2_X, nR2,
          (long long *)f3_X, &nR3, (unsigned long long)mask);
      { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 167, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
      break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 169, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; break;
    }
  }
  else { { { fprintf(stderr, "Line %3d of File %s \n", 172, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  { if ( ( f3_X == ((void *)0) ) && ( f3_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 173, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( ( f3_X != ((void *)0) ) && ( f3_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 173, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( f3_X != ((void *)0) ) { munmap(f3_X, f3_nX); f3_X = ((void *)0); f3_nX = 0; } };
  if ( nR3 == 0 ) {
    status = q_delete(ddir_id, fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 175, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
    ddir_id = fileno = -1;
    { { fprintf(stderr, "Line %3d of File %s \n", 177, "t1f1t2f2opt3f3.c"); }; status = 0 ; goto BYE; };
  }
  else if ( nR3 < nR3_allocated ) {
    status = q_trunc(ddir_id, fileno, (nR3 * f3_fldsz)); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 180, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( nR3 > nR3_allocated ) {
    { { fprintf(stderr, "Line %3d of File %s \n", 183, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; };
  }
  char str_nR3[32]; sprintf(str_nR3, "%lld", nR3);
  status = add_tbl(t3, str_nR3, &t3_id, &t3_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 187, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  zero_fld_rec(&f3_rec); f3_rec.fldtype = f3_type;
  status = add_fld(t3_id, f3, ddir_id, fileno, &f3_id, &f3_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 189, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( ( strcmp(op, "union") == 0 ) || ( strcmp(op, "intersection") == 0 ) ||
         ( strcmp(op, "a_minus_b") == 0 ) ) {
    status = int_set_meta(t3_id, f3_id, "srttype", "ascending", 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 193, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  }
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 197, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 197, "t1f1t2f2opt3f3.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", 198, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( ( f2_X != ((void *)0) ) && ( f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 198, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( f2_X != ((void *)0) ) { munmap(f2_X, f2_nX); f2_X = ((void *)0); f2_nX = 0; } };
  { if ( ( f3_X == ((void *)0) ) && ( f3_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 199, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( ( f3_X != ((void *)0) ) && ( f3_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 199, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( f3_X != ((void *)0) ) { munmap(f3_X, f3_nX); f3_X = ((void *)0); f3_nX = 0; } };
  return status ;
}

canonical_original_code:
int t1f1t2f2opt3f3(char *t1, char *f1, char *t2, char *f2, char *op, char *options, char *t3, char *f3)
{
  int status = 0;
  char *f1_X = ((void *)0); unsigned long f1_nX = 0;
  char *f2_X = ((void *)0); unsigned long f2_nX = 0;
  char *f3_X = ((void *)0); unsigned long f3_nX = 0;
  int t1_id = (-0x7fffffff - 1); int t2_id = (-0x7fffffff - 1); int t3_id = (-0x7fffffff - 1);
  int f1_id = (-0x7fffffff - 1); int f2_id = (-0x7fffffff - 1); int f3_id = (-0x7fffffff - 1);
  int nn_f1_id = (-0x7fffffff - 1); int nn_f2_id = (-0x7fffffff - 1);
  struct _TBL_REC_TYPE t1_rec; struct _TBL_REC_TYPE t2_rec; struct _TBL_REC_TYPE t3_rec;
  struct _FLD_REC_TYPE f1_rec; struct _FLD_REC_TYPE nn_f1_rec;
  struct _FLD_REC_TYPE f2_rec; struct _FLD_REC_TYPE nn_f2_rec;
  struct _FLD_REC_TYPE f3_rec;
  enum _FLD_TYPE f3_type = undef_fldtype;
  long long nR1 = (-0x7fffffff - 1); long long nR2 = (-0x7fffffff - 1);
  long long nR3 = (-0x7fffffff - 1); long long nR3_allocated = (-0x7fffffff - 1);
  int f3_fldsz = 0x7fffffff; unsigned long filesz;
  int ddir_id = -1; int fileno = -1;
  if ( ( t1 == ((void *)0) ) || ( *t1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( t2 == ((void *)0) ) || ( *t2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( op == ((void *)0) ) || ( *op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 67, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f3 == ((void *)0) ) || ( *f3 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t1, t3) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( t3 == ((void *)0) ) || ( *t3 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t2, t3) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(t1, &t1_id, &t1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( t1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  nR1 = t1_rec.nR;
  status = is_fld(((void *)0), t1_id, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(f1_rec, &f1_X, &f1_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  status = is_tbl(t2, &t2_id, &t2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( t2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  nR2 = t2_rec.nR;
  status = is_fld(((void *)0), t2_id, f2, &f2_id, &f2_rec, &nn_f2_id, &nn_f2_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(f2_rec, &f2_X, &f2_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_rec.srttype != ascending ) { { { fprintf(stderr, "Line %3d of File %s \n", 93, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( f2_rec.srttype != ascending ) { { { fprintf(stderr, "Line %3d of File %s \n", 94, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_f1_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 96, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_f2_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 97, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.fldtype != f2_rec.fldtype ) { { { fprintf(stderr, "Line %3d of File %s \n", 98, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  switch ( f1_rec.fldtype ) {
    case I4 : case I8 : break;
    default : { { fprintf(stderr, "Line %3d of File %s \n", 101, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; break;
  }
  f3_type = f1_rec.fldtype;
  status = get_fld_sz(f3_type, &f3_fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 104, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( strcmp(op, "intersection") == 0 ) {
    nR3_allocated = ((nR1) < (nR2) ? (nR1) : (nR2));
  }
  else if ( strcmp(op, "a_minus_b") == 0 ) {
    nR3_allocated = nR1;
  }
  else if ( ( strcmp(op, "union") == 0 ) ||
            ( strcmp(op, "pvalcalc") == 0 ) ) {
    nR3_allocated = nR1 + nR2;
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 117, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; };
  }
  filesz = f3_fldsz * nR3_allocated;
  status = mk_temp_file(filesz, &ddir_id, &fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 121, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, fileno, &f3_X, &f3_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 122, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( strcmp(op, "intersection") == 0 ) {
    switch ( f1_rec.fldtype ) {
      case I4 :
 status = intersection_I4((int *)f1_X, nR1, (int *)f2_X, nR2,
     (int *)f3_X, &nR3);
 break;
      case I8 :
 status = intersection_I8((long long *)f1_X, nR1,
     (long long *)f2_X, nR2, (long long *)f3_X, &nR3);
 break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 134, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; break;
    }
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 136, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(op, "a_minus_b") == 0 ) {
    switch ( f1_rec.fldtype ) {
      case I4 :
 a_minus_b_I4((int *)f1_X, nR1, (int *)f2_X, nR2, (int *)f3_X, &nR3);
 break;
      case I8 :
 a_minus_b_I8((long long *)f1_X, nR1, (long long *)f2_X, nR2, (long long *)f3_X, &nR3);
 break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 146, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; break;
    }
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 148, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( ( strcmp(op, "union") == 0 ) ||
            ( strcmp(op, "pvalcalc") == 0 ) ) {
    unsigned long long mask = 0;
    if ( strcmp(op, "pvalcalc") == 0 ) {
      _Bool is_null = 0;
      status = extract_UI8(options, "mask=[", "]", &mask, &is_null);
      if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 156, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
    }
    switch ( f1_rec.fldtype ) {
      case I4 :
        status = union_I4((int *)f1_X, nR1, (int *)f2_X, nR2,
           (int *)f3_X, &nR3, (unsigned int)mask);
        { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 162, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
      break;
      case I8 :
        status = union_I8((long long *)f1_X, nR1, (long long *)f2_X, nR2,
          (long long *)f3_X, &nR3, (unsigned long long)mask);
      { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 167, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
      break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 169, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; break;
    }
  }
  else { { { fprintf(stderr, "Line %3d of File %s \n", 172, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; }; }
  { if ( ( f3_X == ((void *)0) ) && ( f3_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 173, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( ( f3_X != ((void *)0) ) && ( f3_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 173, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( f3_X != ((void *)0) ) { munmap(f3_X, f3_nX); f3_X = ((void *)0); f3_nX = 0; } };
  if ( nR3 == 0 ) {
    status = q_delete(ddir_id, fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 175, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
    ddir_id = fileno = -1;
    { { fprintf(stderr, "Line %3d of File %s \n", 177, "t1f1t2f2opt3f3.c"); }; status = 0 ; goto BYE; };
  }
  else if ( nR3 < nR3_allocated ) {
    status = q_trunc(ddir_id, fileno, (nR3 * f3_fldsz)); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 180, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( nR3 > nR3_allocated ) {
    { { fprintf(stderr, "Line %3d of File %s \n", 183, "t1f1t2f2opt3f3.c"); }; status = -1 ; goto BYE; };
  }
  char str_nR3[32]; sprintf(str_nR3, "%lld", nR3);
  status = add_tbl(t3, str_nR3, &t3_id, &t3_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 187, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  zero_fld_rec(&f3_rec); f3_rec.fldtype = f3_type;
  status = add_fld(t3_id, f3, ddir_id, fileno, &f3_id, &f3_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 189, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  if ( ( strcmp(op, "union") == 0 ) || ( strcmp(op, "intersection") == 0 ) ||
         ( strcmp(op, "a_minus_b") == 0 ) ) {
    status = int_set_meta(t3_id, f3_id, "srttype", "ascending", 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 193, "t1f1t2f2opt3f3.c"); }; status = (status) ; goto BYE; } } };
  }
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 197, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 197, "t1f1t2f2opt3f3.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", 198, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( ( f2_X != ((void *)0) ) && ( f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 198, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( f2_X != ((void *)0) ) { munmap(f2_X, f2_nX); f2_X = ((void *)0); f2_nX = 0; } };
  { if ( ( f3_X == ((void *)0) ) && ( f3_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 199, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( ( f3_X != ((void *)0) ) && ( f3_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 199, "t1f1t2f2opt3f3.c"); }; return(-1); } if ( f3_X != ((void *)0) ) { munmap(f3_X, f3_nX); f3_X = ((void *)0); f3_nX = 0; } };
  return status ;
}

variable_types:
op
char *

variable_types:
options
char *

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

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

variable_types:
filesz
unsigned long

variable_types: fileno int

variable_types:
mask
unsigned long long

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

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


original_code:
int
pos_sel_aux_copy_I8_I8(
    long long *f1_select,
    long long *f1_copy,
    long long nR1,
    long long *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++ ) {
    long long f1idx = f2[i2];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "./AUX/pos_sel_aux_copy_I8_I8.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_I8(long long *f1_select, long long *f1_copy, long long nR1, long long *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++ ) {
    long long f1idx = f2[i2];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "./AUX/pos_sel_aux_copy_I8_I8.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: status int


original_code:
void
bwise_or2_I8(
       unsigned long long *in1,
       unsigned long long *in2,
       long long nR,
       unsigned long long * restrict out
       )
{
  long long 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 bwise_or2_I8(unsigned long long *in1, unsigned long long *in2, long long nR, unsigned long long *out)
{
  long long inv1; long long inv2; long long 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
unsigned long long *

variable_types:
outv
long long

variable_types:
i
long long


decompiled_code:
__int64 __fastcall determine_rho_loc(unsigned __int64 _RDI, int a2, int *a3, _DWORD *a4)
{
int v5; // eax
int v6; // esi
__int64 result; // rax

if ( _RDI )
{
*a3 = -1;
*a4 = -1;
__asm { tzcnt rax, rdi }
v5 = _RAX + 1;
v6 = (_RDI >> 44) & (a2 - 1);
if ( v5 > 44 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "determine_rho_loc.c");
result = 0xFFFFFFFFLL;
}
else
{
*a3 = v5;
*a4 = v6;
result = 0LL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "determine_rho_loc.c");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 _RDI, int a2, int *a3, _DWORD *a4)
{
int v5; // eax
int v6; // esi
__int64 result; // rax

if ( _RDI )
{
*a3 = -1;
*a4 = -1;
__asm { tzcnt rax, rdi }
v5 = _RAX + 1;
v6 = (_RDI >> 44) & (a2 - 1);
if ( v5 > 44 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "determine_rho_loc.c");
result = 0xFFFFFFFFLL;
}
else
{
*a3 = v5;
*a4 = v6;
result = 0LL;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "determine_rho_loc.c");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
determine_rho_loc (
     uint64_t hash_val,
     int m,
     int *ptr_rho,
     int *ptr_loc
     )
{
  int status = 0;
  if ( hash_val == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "determine_rho_loc.c"); }; status = -1 ; goto BYE; }; }
  *ptr_rho = -1;
  *ptr_loc = -1;
  int rho = __builtin_ctzll(hash_val)+1;
  unsigned int uint_hash_val = (unsigned int) (hash_val >> (64-20));
  int loc = (int) (uint_hash_val & (m-1));
  if ( rho > (64-20) ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "determine_rho_loc.c"); }; status = -1 ; goto BYE; }; }
  *ptr_rho = rho;
  *ptr_loc = loc;
 BYE:
  return (status);
}

canonical_original_code:
int determine_rho_loc(unsigned long hash_val, int m, int *ptr_rho, int *ptr_loc)
{
  int status = 0;
  if ( hash_val == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "determine_rho_loc.c"); }; status = -1 ; goto BYE; }; }
  *ptr_rho = -1;
  *ptr_loc = -1;
  int rho = __builtin_ctzll(hash_val)+1;
  unsigned int uint_hash_val = (unsigned int) (hash_val >> (64-20));
  int loc = (int) (uint_hash_val & (m-1));
  if ( rho > (64-20) ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "determine_rho_loc.c"); }; status = -1 ; goto BYE; }; }
  *ptr_rho = rho;
  *ptr_loc = loc;
 BYE:
  return (status);
}

variable_types: m int

variable_types: rho int

variable_types: loc int


decompiled_code:
__int64 __fastcall intersection_I8(_QWORD *a1, __int64 a2, _QWORD *a3, __int64 a4, _QWORD *a5, _QWORD *a6)
{
_QWORD *v6; // r11
_QWORD *v7; // r10
__int64 v9; // rsi
__int64 result; // rax

v6 = &a1[a2];
v7 = &a3[a4];
if ( a3 == v7 || a1 == v6 )
{
*a6 = 0LL;
result = 0LL;
}
else
{
v9 = 0LL;
do
{
if ( *a1 == *a3 )
{
*a5++ = *a1;
if ( a2 + a4 < ++v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 30LL, "./AUTOGEN/GENFILES/intersection_I8.c");
return 0xFFFFFFFFLL;
}
++a1;
++a3;
}
else if ( *a1 >= *a3 )
{
if ( *a1 > *a3 )
++a3;
}
else
{
++a1;
}
}
while ( a3 != v7 && a1 != v6 );
*a6 = v9;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, __int64 a2, _QWORD *a3, __int64 a4, _QWORD *a5, _QWORD *a6)
{
_QWORD *v6; // r11
_QWORD *v7; // r10
__int64 v9; // rsi
__int64 result; // rax

v6 = &a1[a2];
v7 = &a3[a4];
if ( a3 == v7 || a1 == v6 )
{
*a6 = 0LL;
result = 0LL;
}
else
{
v9 = 0LL;
do
{
if ( *a1 == *a3 )
{
*a5++ = *a1;
if ( a2 + a4 < ++v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 30LL, "./AUTOGEN/GENFILES/intersection_I8.c");
return 0xFFFFFFFFLL;
}
++a1;
++a3;
}
else if ( *a1 >= *a3 )
{
if ( *a1 > *a3 )
++a3;
}
else
{
++a1;
}
}
while ( a3 != v7 && a1 != v6 );
*a6 = v9;
result = 0LL;
}
return result;
}

original_code:
int
intersection_I8(
    long long *f1ptr,
    long long nR1,
    long long *f2ptr,
    long long nR2,
    long long *f3ptr,
    long long *ptr_nR3
    )
{
  int status = 0;
  long long nR3 = 0;
  long long f1val, f2val;
  long long *endf1ptr = f1ptr + nR1;
  long long *endf2ptr = f2ptr + nR2;
  for ( ; ; ) {
    if ( f1ptr == endf1ptr ) { break; }
    if ( f2ptr == endf2ptr ) { break; }
    f1val = *f1ptr;
    f2val = *f2ptr;
    if ( f1val == f2val ) {
 *f3ptr = f1val;
 f3ptr++;
 nR3++;
 if ( nR3 > (nR1+nR2) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "./AUTOGEN/GENFILES/intersection_I8.c"); }; status = -1 ; goto BYE; }; }
 f1ptr++;
 f2ptr++;
      }
      else if ( f1val < f2val ) {
 f1ptr++;
      }
      else if ( f2val < f1val ) {
 f2ptr++;
      }
    }
  *ptr_nR3 = nR3;
BYE:
  return(status);
}

canonical_original_code:
int intersection_I8(long long *f1ptr, long long nR1, long long *f2ptr, long long nR2, long long *f3ptr, long long *ptr_nR3)
{
  int status = 0;
  long long nR3 = 0;
  long long f1val; long long f2val;
  long long *endf1ptr = f1ptr + nR1;
  long long *endf2ptr = f2ptr + nR2;
  for ( ; ; ) {
    if ( f1ptr == endf1ptr ) { break; }
    if ( f2ptr == endf2ptr ) { break; }
    f1val = *f1ptr;
    f2val = *f2ptr;
    if ( f1val == f2val ) {
 *f3ptr = f1val;
 f3ptr++;
 nR3++;
 if ( nR3 > (nR1+nR2) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "./AUTOGEN/GENFILES/intersection_I8.c"); }; status = -1 ; goto BYE; }; }
 f1ptr++;
 f2ptr++;
      }
      else if ( f1val < f2val ) {
 f1ptr++;
      }
      else if ( f2val < f1val ) {
 f2ptr++;
      }
    }
  *ptr_nR3 = nR3;
BYE:
  return(status);
}


Output

original_code:
int
Output(
       int **src_bufs,
       int *ptr_weight,
       int *last_packet,
       int last_packet_incomplete,
       long long last_packet_siz,
       long long siz,
       int num_quantiles,
       int *ptr_y,
       int b,
       long long k
       )
{
  int status = 0;
  int * current_loc_buf = ((void *)0);
  if ( src_bufs == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "Output.c"); }; status = -1 ; goto BYE; }; }
  if ( ptr_weight == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "Output.c"); }; status = -1 ; goto BYE; }; }
  if ( ptr_y == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 67, "Output.c"); }; status = -1 ; goto BYE; }; }
  if ( last_packet_siz > k ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "Output.c"); }; status = -1 ; goto BYE; }; }
  current_loc_buf = (int *)malloc( b * sizeof(int));
  for ( int ii = 0; ii < b; ii++ ) {
    current_loc_buf[ii] = 0;
  }
  long long current_loc_lp = 0;
  long long current_proc_element_rank = 0;
  long long jj = 0;
  long long next_quantile_rank = (long long)ceil((jj+1)*(double)siz/num_quantiles);
  while ( 1 ) {
    int min_unproc_val = 0x7FFFFFFF;
    int min_unproc_val_loc = -1;
    for ( int ii = 0; ii < b; ii++ ) {
      if ( ptr_weight[ii] > 0 && current_loc_buf[ii] < k ) {
 if ( src_bufs[ii][current_loc_buf[ii]] < min_unproc_val ) {
   min_unproc_val = src_bufs[ii][current_loc_buf[ii]];
   min_unproc_val_loc = ii;
 }
      }
    }
    if ( last_packet_incomplete == 1 && current_loc_lp < last_packet_siz ) {
      if ( last_packet[current_loc_lp] < min_unproc_val ) {
 min_unproc_val = last_packet[current_loc_lp];
 min_unproc_val_loc = b;
      }
    }
    if ( min_unproc_val_loc < 0 ) { break; }
    if ( min_unproc_val_loc < b ) {
      current_proc_element_rank += ptr_weight[min_unproc_val_loc];
      current_loc_buf[min_unproc_val_loc]++;
    }
    else if ( min_unproc_val_loc == b ) {
      current_proc_element_rank += 1;
      current_loc_lp++;
    }
    else { { { fprintf(stderr, "Line %3d of File %s \n", 131, "Output.c"); }; status = -1 ; goto BYE; }; }
    while ( current_proc_element_rank >= next_quantile_rank && jj < num_quantiles ) {
      ptr_y[jj++] = min_unproc_val;
      next_quantile_rank = (long long) ceil((jj+1)*(double)siz/num_quantiles);
    }
  }
 BYE:
  { if ( (current_loc_buf) != ((void *)0) ) { free((current_loc_buf)); (current_loc_buf) = ((void *)0); } };
  return(status);
}

canonical_original_code:
int Output(int **src_bufs, int *ptr_weight, int *last_packet, int last_packet_incomplete, long long last_packet_siz, long long siz, int num_quantiles, int *ptr_y, int b, long long k)
{
  int status = 0;
  int *current_loc_buf = ((void *)0);
  if ( src_bufs == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "Output.c"); }; status = -1 ; goto BYE; }; }
  if ( ptr_weight == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "Output.c"); }; status = -1 ; goto BYE; }; }
  if ( ptr_y == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 67, "Output.c"); }; status = -1 ; goto BYE; }; }
  if ( last_packet_siz > k ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "Output.c"); }; status = -1 ; goto BYE; }; }
  current_loc_buf = (int *)malloc( b * sizeof(int));
  for ( int ii = 0; ii < b; ii++ ) {
    current_loc_buf[ii] = 0;
  }
  long long current_loc_lp = 0;
  long long current_proc_element_rank = 0;
  long long jj = 0;
  long long next_quantile_rank = (long long)ceil((jj+1)*(double)siz/num_quantiles);
  while ( 1 ) {
    int min_unproc_val = 0x7FFFFFFF;
    int min_unproc_val_loc = -1;
    for ( int ii = 0; ii < b; ii++ ) {
      if ( ptr_weight[ii] > 0 && current_loc_buf[ii] < k ) {
 if ( src_bufs[ii][current_loc_buf[ii]] < min_unproc_val ) {
   min_unproc_val = src_bufs[ii][current_loc_buf[ii]];
   min_unproc_val_loc = ii;
 }
      }
    }
    if ( last_packet_incomplete == 1 && current_loc_lp < last_packet_siz ) {
      if ( last_packet[current_loc_lp] < min_unproc_val ) {
 min_unproc_val = last_packet[current_loc_lp];
 min_unproc_val_loc = b;
      }
    }
    if ( min_unproc_val_loc < 0 ) { break; }
    if ( min_unproc_val_loc < b ) {
      current_proc_element_rank += ptr_weight[min_unproc_val_loc];
      current_loc_buf[min_unproc_val_loc]++;
    }
    else if ( min_unproc_val_loc == b ) {
      current_proc_element_rank += 1;
      current_loc_lp++;
    }
    else { { { fprintf(stderr, "Line %3d of File %s \n", 131, "Output.c"); }; status = -1 ; goto BYE; }; }
    while ( current_proc_element_rank >= next_quantile_rank && jj < num_quantiles ) {
      ptr_y[jj++] = min_unproc_val;
      next_quantile_rank = (long long) ceil((jj+1)*(double)siz/num_quantiles);
    }
  }
 BYE:
  { if ( (current_loc_buf) != ((void *)0) ) { free((current_loc_buf)); (current_loc_buf) = ((void *)0); } };
  return(status);
}

variable_types:
siz
long long

variable_types: b int

variable_types:
k
long long

variable_types: ii int

variable_types:
jj
long long


original_code:
void
shiftleft2_I8(
       long long *in1,
       long long *in2,
       long long nR,
       long long * restrict out
       )
{
  long long 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 shiftleft2_I8(long long *in1, long long *in2, long long nR, long long *out)
{
  long long inv1; long long inv2; long long outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 << inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

variable_types:
out
long long *