decompiled_code:
__int64 __fastcall g_mmap_meta_data(char *path, _QWORD *a2, _QWORD *a3, __int64 *a4, _DWORD *a5)
{
int v7; // ebx
unsigned __int64 v8; // rbp
__int64 v9; // r15
unsigned __int64 v12; // [rsp+10h] [rbp-248h] BYREF
__int64 v13; // [rsp+18h] [rbp-240h] BYREF
char buf[568]; // [rsp+20h] [rbp-238h] BYREF

v13 = 0LL;
v12 = 0LL;
zero_string(buf, 512LL);
if ( getcwd(buf, 0x1FFuLL) )
{
if ( path && *path )
{
v7 = chdir(path);
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 33LL, "g_meta_data.c");
}
else
{
v7 = rs_mmap("docroot.gpu", &v13, &v12, 1LL);
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "g_meta_data.c");
}
else if ( v12 )
{
v8 = v12 / 0x2C8;
if ( v12 == 712 * (v12 / 0x2C8) )
{
v9 = v13;
v7 = chdir(buf);
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "g_meta_data.c");
}
else
{
*a2 = v13;
*a3 = v12;
*a4 = v9;
*a5 = v8;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "g_meta_data.c");
v7 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "g_meta_data.c");
v7 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 32LL, "g_meta_data.c");
v7 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 31LL, "g_meta_data.c");
v7 = -1;
}
return (unsigned int)v7;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *path, _QWORD *a2, _QWORD *a3, __int64 *a4, _DWORD *a5)
{
int v7; // ebx
unsigned __int64 v8; // rbp
__int64 v9; // r15
unsigned __int64 v12; // [rsp+10h] [rbp-248h] BYREF
__int64 v13; // [rsp+18h] [rbp-240h] BYREF
char buf[568]; // [rsp+20h] [rbp-238h] BYREF

v13 = 0LL;
v12 = 0LL;
zero_string(buf, 512LL);
if ( getcwd(buf, 0x1FFuLL) )
{
if ( path && *path )
{
v7 = chdir(path);
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 33LL, "g_meta_data.c");
}
else
{
v7 = rs_mmap("docroot.gpu", &v13, &v12, 1LL);
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "g_meta_data.c");
}
else if ( v12 )
{
v8 = v12 / 0x2C8;
if ( v12 == 712 * (v12 / 0x2C8) )
{
v9 = v13;
v7 = chdir(buf);
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "g_meta_data.c");
}
else
{
*a2 = v13;
*a3 = v12;
*a4 = v9;
*a5 = v8;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "g_meta_data.c");
v7 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "g_meta_data.c");
v7 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 32LL, "g_meta_data.c");
v7 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 31LL, "g_meta_data.c");
v7 = -1;
}
return (unsigned int)v7;
}

original_code:
int
g_mmap_meta_data(
        char *docroot,
        char **ptr_x_gpu_reg_X,
        size_t *ptr_x_gpu_reg_nX,
        GPU_REG_TYPE **ptr_x_gpu_reg,
        int *ptr_x_n_gpu_reg
        )
{
  int status = 0;
  char cwd[511 +1];
  char *l_gpu_reg_X = ((void *)0);
  size_t l_gpu_reg_nX = 0;
  GPU_REG_TYPE *l_gpu_reg = ((void *)0);
  int l_n_gpu_reg = 0;
  zero_string(cwd, 511 +1);
  if ( getcwd(cwd, 511) == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 31, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  if ( ( docroot == ((void *)0) ) || ( *docroot == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  status = chdir(docroot); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 33, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  status = rs_mmap("docroot.gpu", &l_gpu_reg_X, &l_gpu_reg_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  if ( l_gpu_reg_nX == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  l_n_gpu_reg = l_gpu_reg_nX / sizeof(GPU_REG_TYPE);
  if ( (l_gpu_reg_nX % sizeof(GPU_REG_TYPE) ) != 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  l_gpu_reg = (GPU_REG_TYPE *)l_gpu_reg_X;
  status = chdir(cwd); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  *ptr_x_gpu_reg_X = l_gpu_reg_X;
  *ptr_x_gpu_reg_nX = l_gpu_reg_nX;
  *ptr_x_gpu_reg = l_gpu_reg;
  *ptr_x_n_gpu_reg = l_n_gpu_reg;
 BYE:
  return status ;
}

canonical_original_code:
int g_mmap_meta_data(char *docroot, char **ptr_x_gpu_reg_X, unsigned long *ptr_x_gpu_reg_nX, struct _GPU_REG_TYPE **ptr_x_gpu_reg, int *ptr_x_n_gpu_reg)
{
  int status = 0;
  char cwd[-1];
  char *l_gpu_reg_X = ((void *)0);
  unsigned long l_gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *l_gpu_reg = ((void *)0);
  int l_n_gpu_reg = 0;
  zero_string(cwd, 511 +1);
  if ( getcwd(cwd, 511) == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 31, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  if ( ( docroot == ((void *)0) ) || ( *docroot == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  status = chdir(docroot); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 33, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  status = rs_mmap("docroot.gpu", &l_gpu_reg_X, &l_gpu_reg_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  if ( l_gpu_reg_nX == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  l_n_gpu_reg = l_gpu_reg_nX / sizeof(GPU_REG_TYPE);
  if ( (l_gpu_reg_nX % sizeof(GPU_REG_TYPE) ) != 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  l_gpu_reg = (struct _GPU_REG_TYPE *)l_gpu_reg_X;
  status = chdir(cwd); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  *ptr_x_gpu_reg_X = l_gpu_reg_X;
  *ptr_x_gpu_reg_nX = l_gpu_reg_nX;
  *ptr_x_gpu_reg = l_gpu_reg;
  *ptr_x_n_gpu_reg = l_n_gpu_reg;
 BYE:
  return status ;
}

variable_types:
docroot
char *

variable_types: struct _GPU_REG_TYPE { void *reg; unsigned long filesz; _Bool is_busy; long long nR; enum _FLD_TYPE { undef_fldtype=0, B=1, I1=2, I2=3, I4=4, I8=5, F4=6, F8=7, SC=8, SV=9 } fldtype; char filename[-1]; char tbl[-1]; char h_fld[-1]; char d_fld[-1]; } **

variable_types:
cwd
char [-1]

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


repo: linkedin/datacl

decompiled_code:
int __fastcall g_unmap_meta_data(void *a1, size_t a2)
{
int result; // eax

if ( a1 )
result = munmap(a1, a2);
return result;
}

canonical_decompiled_code:
int __fastcall func1(void *a1, size_t a2)
{
int result; // eax

if ( a1 )
result = munmap(a1, a2);
return result;
}

original_code:
void
g_unmap_meta_data(
  char *x_gpu_reg_X,
  size_t x_gpu_reg_nX
  )
{
  if ( x_gpu_reg_X != ((void *)0) ) {
    munmap(x_gpu_reg_X, x_gpu_reg_nX);
  }
}

canonical_original_code:
void g_unmap_meta_data(char *x_gpu_reg_X, unsigned long x_gpu_reg_nX)
{
  if ( x_gpu_reg_X != ((void *)0) ) {
    munmap(x_gpu_reg_X, x_gpu_reg_nX);
  }
}

return_type: void


decompiled_code:
__int64 __fastcall g_init_meta_data(char *path)
{
int v1; // ebp
unsigned __int64 v2; // r12
__int64 v3; // r13
__int64 v4; // rbx
__int64 v5; // r12
unsigned __int64 v7; // [rsp+0h] [rbp-238h] BYREF
__int64 v8; // [rsp+8h] [rbp-230h] BYREF
char buf[552]; // [rsp+10h] [rbp-228h] BYREF

v8 = 0LL;
v7 = 0LL;
if ( path && *path )
{
zero_string(buf, 512LL);
if ( getcwd(buf, 0x1FFuLL) )
{
v1 = mk_file(buf, path, "docroot.gpu", 22784LL);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "g_meta_data.c");
}
else
{
v1 = chdir(path);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 89LL, "g_meta_data.c");
}
else
{
v1 = rs_mmap("docroot.gpu", &v8, &v7, 1LL);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "g_meta_data.c");
}
else if ( v7 )
{
v2 = v7 / 0x2C8;
if ( v7 == 712 * (v7 / 0x2C8) )
{
v3 = v8;
v1 = chdir(buf);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 95LL, "g_meta_data.c");
}
else if ( (int)v2 > 0 )
{
v4 = v3;
v5 = v3 + 712LL * (unsigned int)(v2 - 1) + 712;
do
{
zero_gpu_reg(v4);
v4 += 712LL;
}
while ( v4 != v5 );
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 93LL, "g_meta_data.c");
v1 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 91LL, "g_meta_data.c");
v1 = -1;
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 84LL, "g_meta_data.c");
v1 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 82LL, "g_meta_data.c");
v1 = -1;
}
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *path)
{
int v1; // ebp
unsigned __int64 v2; // r12
__int64 v3; // r13
__int64 v4; // rbx
__int64 v5; // r12
unsigned __int64 v7; // [rsp+0h] [rbp-238h] BYREF
__int64 v8; // [rsp+8h] [rbp-230h] BYREF
char buf[552]; // [rsp+10h] [rbp-228h] BYREF

v8 = 0LL;
v7 = 0LL;
if ( path && *path )
{
zero_string(buf, 512LL);
if ( getcwd(buf, 0x1FFuLL) )
{
v1 = mk_file(buf, path, "docroot.gpu", 22784LL);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "g_meta_data.c");
}
else
{
v1 = chdir(path);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 89LL, "g_meta_data.c");
}
else
{
v1 = rs_mmap("docroot.gpu", &v8, &v7, 1LL);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "g_meta_data.c");
}
else if ( v7 )
{
v2 = v7 / 0x2C8;
if ( v7 == 712 * (v7 / 0x2C8) )
{
v3 = v8;
v1 = chdir(buf);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 95LL, "g_meta_data.c");
}
else if ( (int)v2 > 0 )
{
v4 = v3;
v5 = v3 + 712LL * (unsigned int)(v2 - 1) + 712;
do
{
zero_gpu_reg(v4);
v4 += 712LL;
}
while ( v4 != v5 );
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 93LL, "g_meta_data.c");
v1 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 91LL, "g_meta_data.c");
v1 = -1;
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 84LL, "g_meta_data.c");
v1 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 82LL, "g_meta_data.c");
v1 = -1;
}
return (unsigned int)v1;
}

original_code:
int
g_init_meta_data(
        char *docroot
        )
{
  int status = 0;
  char cwd[511 +1];
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  if ( ( docroot == ((void *)0) ) || ( *docroot == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 82, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  zero_string(cwd, 511 +1);
  if ( getcwd(cwd, 511) == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  size_t filesz = 32 * sizeof(GPU_REG_TYPE);
  status = mk_file(cwd, docroot, "docroot.gpu", filesz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  status = chdir(docroot); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  status = rs_mmap("docroot.gpu", &gpu_reg_X, &gpu_reg_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  if ( gpu_reg_nX == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 91, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  n_gpu_reg = gpu_reg_nX / sizeof(GPU_REG_TYPE);
  if ( (gpu_reg_nX % sizeof(GPU_REG_TYPE) ) != 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 93, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  gpu_reg = (GPU_REG_TYPE *)gpu_reg_X;
  status = chdir(cwd); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 95, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  for ( int i = 0; i < n_gpu_reg; i++ ) {
    zero_gpu_reg(&(gpu_reg[i]));
  }
 BYE:
  return status ;
}

canonical_original_code:
int g_init_meta_data(char *docroot)
{
  int status = 0;
  char cwd[-1];
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  if ( ( docroot == ((void *)0) ) || ( *docroot == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 82, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  zero_string(cwd, 511 +1);
  if ( getcwd(cwd, 511) == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  unsigned long filesz = 32 * sizeof(GPU_REG_TYPE);
  status = mk_file(cwd, docroot, "docroot.gpu", filesz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  status = chdir(docroot); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  status = rs_mmap("docroot.gpu", &gpu_reg_X, &gpu_reg_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  if ( gpu_reg_nX == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 91, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  n_gpu_reg = gpu_reg_nX / sizeof(GPU_REG_TYPE);
  if ( (gpu_reg_nX % sizeof(GPU_REG_TYPE) ) != 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 93, "g_meta_data.c"); }; status = -1 ; goto BYE; }; }
  gpu_reg = (struct _GPU_REG_TYPE *)gpu_reg_X;
  status = chdir(cwd); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 95, "g_meta_data.c"); }; status = (status) ; goto BYE; } } };
  for ( int i = 0; i < n_gpu_reg; i++ ) {
    zero_gpu_reg(&(gpu_reg[i]));
  }
 BYE:
  return status ;
}

variable_types: status int

variable_types: struct _GPU_REG_TYPE { void *reg; unsigned long filesz; _Bool is_busy; long long nR; enum _FLD_TYPE { undef_fldtype=0, B=1, I1=2, I2=3, I4=4, I8=5, F4=6, F8=7, SC=8, SV=9 } fldtype; char filename[-1]; char tbl[-1]; char h_fld[-1]; char d_fld[-1]; } *

variable_types:
filesz
unsigned long

variable_types: i int

return_type: int


decompiled_code:
__int64 __fastcall get_val(const char *a1, const char *a2, _BYTE *a3, char *a4)
{
int v6; // er13
__int64 v8; // r15
__int64 v9; // [rsp+8h] [rbp-1A0h] BYREF
int v10; // [rsp+14h] [rbp-194h] BYREF
int v11; // [rsp+18h] [rbp-190h] BYREF
unsigned int v12; // [rsp+1Ch] [rbp-18Ch] BYREF
size_t v13; // [rsp+20h] [rbp-188h] BYREF
void *v14; // [rsp+28h] [rbp-180h] BYREF
size_t len; // [rsp+30h] [rbp-178h] BYREF
void *addr; // [rsp+38h] [rbp-170h] BYREF
__int64 v17; // [rsp+40h] [rbp-168h] BYREF
__int64 v18; // [rsp+C0h] [rbp-E8h] BYREF
__int64 v19; // [rsp+E0h] [rbp-C8h]
__int64 v20[13]; // [rsp+140h] [rbp-68h] BYREF

addr = 0LL;
len = 0LL;
v14 = 0LL;
v13 = 0LL;
if ( a1 && *a1 )
{
if ( a2 && *a2 )
{
if ( a3 && *a3 )
{
v6 = is_tbl(a1, &v12, v20);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "get_val.c");
}
else if ( (v12 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "get_val.c");
v6 = -1;
}
else
{
v8 = v20[0];
v6 = is_fld(0LL, v12, a2, &v11, &v18, &v10, &v17);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "get_val.c");
}
else if ( v11 < 0 )
{
fprintf(stderr, "Field [%s] not in Table [%s] \n", a2, a1);
fprintf(stderr, "Line %3d of File %s \n", 43LL, "get_val.c");
v6 = -1;
}
else
{
v6 = get_data(&addr, &len, 1LL);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "get_val.c");
}
else if ( v10 >= 0 && (v6 = get_data(&v14, &v13, 1LL), v6 < 0) )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "get_val.c");
}
else
{
v6 = stoI8(a3, &v9);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "get_val.c");
}
else if ( v9 < 0 || v9 >= v8 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "get_val.c");
v6 = -1;
}
else if ( v14 && !*((_BYTE *)v14 + v9) )
{
strcpy(a4, "\"\"");
}
else
{
switch ( (int)v19 )
{
case 2:
sprintf(a4, "\"%d\"", (unsigned int)*((char *)addr + v9));
break;
case 3:
sprintf(a4, "\"%d\"", (unsigned int)*((__int16 *)addr + v9));
break;
case 4:
sprintf(a4, "\"%d\"", *((unsigned int *)addr + v9));
break;
case 5:
sprintf(a4, "\"%lld\"", *((_QWORD *)addr + v9));
break;
case 6:
sprintf(a4, "\"%f\"", *((float *)addr + v9));
break;
case 7:
sprintf(a4, "\"%lf\"", *((double *)addr + v9));
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 64LL, "get_val.c");
v6 = -1;
break;
}
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 34LL, "get_val.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 33LL, "get_val.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 32LL, "get_val.c");
v6 = -1;
}
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_12;
}
LABEL_47:
fprintf(stderr, "Line %3d of File %s \n", 68LL, "get_val.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_47;
LABEL_12:
if ( !v14 )
{
if ( !v13 )
return (unsigned int)v6;
LABEL_50:
fprintf(stderr, "Line %3d of File %s \n", 69LL, "get_val.c");
return (unsigned int)-1;
}
if ( !v13 )
goto LABEL_50;
munmap(v14, v13);
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2, _BYTE *a3, char *a4)
{
int v6; // er13
__int64 v8; // r15
__int64 v9; // [rsp+8h] [rbp-1A0h] BYREF
int v10; // [rsp+14h] [rbp-194h] BYREF
int v11; // [rsp+18h] [rbp-190h] BYREF
unsigned int v12; // [rsp+1Ch] [rbp-18Ch] BYREF
size_t v13; // [rsp+20h] [rbp-188h] BYREF
void *v14; // [rsp+28h] [rbp-180h] BYREF
size_t len; // [rsp+30h] [rbp-178h] BYREF
void *addr; // [rsp+38h] [rbp-170h] BYREF
__int64 v17; // [rsp+40h] [rbp-168h] BYREF
__int64 v18; // [rsp+C0h] [rbp-E8h] BYREF
__int64 v19; // [rsp+E0h] [rbp-C8h]
__int64 v20[13]; // [rsp+140h] [rbp-68h] BYREF

addr = 0LL;
len = 0LL;
v14 = 0LL;
v13 = 0LL;
if ( a1 && *a1 )
{
if ( a2 && *a2 )
{
if ( a3 && *a3 )
{
v6 = is_tbl(a1, &v12, v20);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "get_val.c");
}
else if ( (v12 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "get_val.c");
v6 = -1;
}
else
{
v8 = v20[0];
v6 = is_fld(0LL, v12, a2, &v11, &v18, &v10, &v17);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "get_val.c");
}
else if ( v11 < 0 )
{
fprintf(stderr, "Field [%s] not in Table [%s] \n", a2, a1);
fprintf(stderr, "Line %3d of File %s \n", 43LL, "get_val.c");
v6 = -1;
}
else
{
v6 = get_data(&addr, &len, 1LL);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "get_val.c");
}
else if ( v10 >= 0 && (v6 = get_data(&v14, &v13, 1LL), v6 < 0) )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "get_val.c");
}
else
{
v6 = stoI8(a3, &v9);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "get_val.c");
}
else if ( v9 < 0 || v9 >= v8 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "get_val.c");
v6 = -1;
}
else if ( v14 && !*((_BYTE *)v14 + v9) )
{
strcpy(a4, "\"\"");
}
else
{
switch ( (int)v19 )
{
case 2:
sprintf(a4, "\"%d\"", (unsigned int)*((char *)addr + v9));
break;
case 3:
sprintf(a4, "\"%d\"", (unsigned int)*((__int16 *)addr + v9));
break;
case 4:
sprintf(a4, "\"%d\"", *((unsigned int *)addr + v9));
break;
case 5:
sprintf(a4, "\"%lld\"", *((_QWORD *)addr + v9));
break;
case 6:
sprintf(a4, "\"%f\"", *((float *)addr + v9));
break;
case 7:
sprintf(a4, "\"%lf\"", *((double *)addr + v9));
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 64LL, "get_val.c");
v6 = -1;
break;
}
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 34LL, "get_val.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 33LL, "get_val.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 32LL, "get_val.c");
v6 = -1;
}
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_12;
}
LABEL_47:
fprintf(stderr, "Line %3d of File %s \n", 68LL, "get_val.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_47;
LABEL_12:
if ( !v14 )
{
if ( !v13 )
return (unsigned int)v6;
LABEL_50:
fprintf(stderr, "Line %3d of File %s \n", 69LL, "get_val.c");
return (unsigned int)-1;
}
if ( !v13 )
goto LABEL_50;
munmap(v14, v13);
return (unsigned int)v6;
}

original_code:
int
get_val(
 char *tbl,
 char *fld,
 char *str_idx,
 char *rslt_buf,
 int sz_rslt_buf
 )
{
  int status = 0;
  TBL_REC_TYPE tbl_rec;
  FLD_REC_TYPE fld_rec, nn_fld_rec;
  char *X = ((void *)0); size_t nX = 0;
  char *nn_X = ((void *)0); size_t nn_nX = 0;
  int tbl_id, fld_id, nn_fld_id;
  long long nR;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "get_val.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 33, "get_val.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_idx == ((void *)0) ) || ( *str_idx == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "get_val.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "get_val.c"); }; status = (status) ; goto BYE; } } };
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "get_val.c"); }; status = -1 ; goto BYE; }; }
  nR = tbl_rec.nR;
  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", 40, "get_val.c"); }; status = (status) ; goto BYE; } } };
  if ( fld_id < 0 ) {
    fprintf(stderr, "Field [%s] not in Table [%s] \n", fld, tbl);
    { { fprintf(stderr, "Line %3d of File %s \n", 43, "get_val.c"); }; status = -1 ; goto BYE; };
  }
  status = get_data(fld_rec, &X, &nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "get_val.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_fld_id >= 0 ) {
    status = get_data(nn_fld_rec, &nn_X, &nn_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "get_val.c"); }; status = (status) ; goto BYE; } } };
  }
  long long idx;
  status = stoI8(str_idx, &idx); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "get_val.c"); }; status = (status) ; goto BYE; } } };
  if ( ( idx < 0 ) || ( idx >= nR ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "get_val.c"); }; status = -1 ; goto BYE; }; }
  if ( ( nn_X != ((void *)0) ) && ( nn_X[idx] == 0 ) ) {
    sprintf(rslt_buf, "\"\"");
  }
  else {
  switch ( fld_rec.fldtype ) {
    case I1 : sprintf(rslt_buf, "\"%d\"", (int) ((char *)X)[idx]); break;
    case I2 : sprintf(rslt_buf, "\"%d\"", (int) ((short *)X)[idx]); break;
    case I4 : sprintf(rslt_buf, "\"%d\"", (int) ((int *)X)[idx]); break;
    case I8 : sprintf(rslt_buf, "\"%lld\"", (long long) ((long long *)X)[idx]); break;
    case F4 : sprintf(rslt_buf, "\"%f\"", (float) ((float *)X)[idx]); break;
    case F8 : sprintf(rslt_buf, "\"%lf\"", (double) ((double *)X)[idx]); break;
    default : { { fprintf(stderr, "Line %3d of File %s \n", 64, "get_val.c"); }; status = -1 ; goto BYE; }; break;
  }
  }
 BYE:
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 68, "get_val.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 68, "get_val.c"); }; return(-1); } if ( X != ((void *)0) ) { munmap(X, nX); X = ((void *)0); nX = 0; } };
  { if ( ( nn_X == ((void *)0) ) && ( nn_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 69, "get_val.c"); }; return(-1); } if ( ( nn_X != ((void *)0) ) && ( nn_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 69, "get_val.c"); }; return(-1); } if ( nn_X != ((void *)0) ) { munmap(nn_X, nn_nX); nn_X = ((void *)0); nn_nX = 0; } };
  return(status);
}

canonical_original_code:
int get_val(char *tbl, char *fld, char *str_idx, char *rslt_buf, int sz_rslt_buf)
{
  int status = 0;
  struct _TBL_REC_TYPE tbl_rec;
  struct _FLD_REC_TYPE fld_rec; struct _FLD_REC_TYPE nn_fld_rec;
  char *X = ((void *)0); unsigned long nX = 0;
  char *nn_X = ((void *)0); unsigned long nn_nX = 0;
  int tbl_id; int fld_id; int nn_fld_id;
  long long nR;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "get_val.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 33, "get_val.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_idx == ((void *)0) ) || ( *str_idx == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "get_val.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "get_val.c"); }; status = (status) ; goto BYE; } } };
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "get_val.c"); }; status = -1 ; goto BYE; }; }
  nR = tbl_rec.nR;
  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", 40, "get_val.c"); }; status = (status) ; goto BYE; } } };
  if ( fld_id < 0 ) {
    fprintf(stderr, "Field [%s] not in Table [%s] \n", fld, tbl);
    { { fprintf(stderr, "Line %3d of File %s \n", 43, "get_val.c"); }; status = -1 ; goto BYE; };
  }
  status = get_data(fld_rec, &X, &nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "get_val.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_fld_id >= 0 ) {
    status = get_data(nn_fld_rec, &nn_X, &nn_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "get_val.c"); }; status = (status) ; goto BYE; } } };
  }
  long long idx;
  status = stoI8(str_idx, &idx); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "get_val.c"); }; status = (status) ; goto BYE; } } };
  if ( ( idx < 0 ) || ( idx >= nR ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "get_val.c"); }; status = -1 ; goto BYE; }; }
  if ( ( nn_X != ((void *)0) ) && ( nn_X[idx] == 0 ) ) {
    sprintf(rslt_buf, "\"\"");
  }
  else {
  switch ( fld_rec.fldtype ) {
    case I1 : sprintf(rslt_buf, "\"%d\"", (int) ((char *)X)[idx]); break;
    case I2 : sprintf(rslt_buf, "\"%d\"", (int) ((short *)X)[idx]); break;
    case I4 : sprintf(rslt_buf, "\"%d\"", (int) ((int *)X)[idx]); break;
    case I8 : sprintf(rslt_buf, "\"%lld\"", (long long) ((long long *)X)[idx]); break;
    case F4 : sprintf(rslt_buf, "\"%f\"", (float) ((float *)X)[idx]); break;
    case F8 : sprintf(rslt_buf, "\"%lf\"", (double) ((double *)X)[idx]); break;
    default : { { fprintf(stderr, "Line %3d of File %s \n", 64, "get_val.c"); }; status = -1 ; goto BYE; }; break;
  }
  }
 BYE:
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 68, "get_val.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 68, "get_val.c"); }; return(-1); } if ( X != ((void *)0) ) { munmap(X, nX); X = ((void *)0); nX = 0; } };
  { if ( ( nn_X == ((void *)0) ) && ( nn_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 69, "get_val.c"); }; return(-1); } if ( ( nn_X != ((void *)0) ) && ( nn_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 69, "get_val.c"); }; return(-1); } if ( nn_X != ((void *)0) ) { munmap(nn_X, nn_nX); nn_X = ((void *)0); nn_nX = 0; } };
  return(status);
}

variable_types:
tbl
char *

variable_types:
fld
char *

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

variable_types: 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:
X
char *

variable_types:
nX
unsigned long

variable_types:
nR
long long

variable_types:
idx
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:
void
bwise_xor2_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_xor2_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:
out
unsigned long long *

variable_types:
outv
long long

variable_types:
i
long long


decompiled_code:
__int64 __fastcall pos_count_I4_I4(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v7; // rdx
int v8; // eax
int v9; // eax

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

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v7; // rdx
int v8; // eax
int v9; // eax

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

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

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


original_code:
void
is_sorted_alldef_I2(
    short *iX,
    long long nR,
    SORT_TYPE *ptr_is_sorted
    )
{
  short first_val, second_val, prev_val, curr_val;
  SORT_TYPE sort_order;
  _Bool second_val_seen = 0;
  long long i = 0;
  if ( nR == 0 ) { *ptr_is_sorted = unknown; return; }
  if ( nR == 1 ) { *ptr_is_sorted = ascending; return; }
  first_val = iX[0];
  for ( i = 1; i < nR; i++ ) {
    if ( iX[i] != first_val ) {
      second_val = iX[i];
      second_val_seen = 1;
      break;
    }
  }
  if ( !second_val_seen ) { *ptr_is_sorted = ascending; return; }
  if ( first_val < second_val ) {
    sort_order = ascending;
  }
  else {
    sort_order = descending;
  }
  if ( i == nR ) { return; }
  prev_val = second_val;
  iX += i;
  nR -= i;
  for ( ; i < nR; i++ ) {
    curr_val = iX[i];
    switch ( sort_order ) {
      case ascending :
 if ( curr_val < prev_val ) { *ptr_is_sorted = unsorted; return; } break;
 if ( curr_val > prev_val ) { prev_val = curr_val; }
 break;
      case descending :
 if ( curr_val > prev_val ) { *ptr_is_sorted = unsorted; return; } break;
 if ( curr_val < prev_val ) { prev_val = curr_val; }
      default :
 exit(-1);
    }
    prev_val = curr_val;
  }
  *ptr_is_sorted = sort_order;
}

canonical_original_code:
void is_sorted_alldef_I2(short *iX, long long nR, enum _SORT_TYPE *ptr_is_sorted)
{
  short first_val; short second_val; short prev_val; short curr_val;
  enum _SORT_TYPE sort_order;
  _Bool second_val_seen = 0;
  long long i = 0;
  if ( nR == 0 ) { *ptr_is_sorted = unknown; return; }
  if ( nR == 1 ) { *ptr_is_sorted = ascending; return; }
  first_val = iX[0];
  for ( i = 1; i < nR; i++ ) {
    if ( iX[i] != first_val ) {
      second_val = iX[i];
      second_val_seen = 1;
      break;
    }
  }
  if ( !second_val_seen ) { *ptr_is_sorted = ascending; return; }
  if ( first_val < second_val ) {
    sort_order = ascending;
  }
  else {
    sort_order = descending;
  }
  if ( i == nR ) { return; }
  prev_val = second_val;
  iX += i;
  nR -= i;
  for ( ; i < nR; i++ ) {
    curr_val = iX[i];
    switch ( sort_order ) {
      case ascending :
 if ( curr_val < prev_val ) { *ptr_is_sorted = unsorted; return; } break;
 if ( curr_val > prev_val ) { prev_val = curr_val; }
 break;
      case descending :
 if ( curr_val > prev_val ) { *ptr_is_sorted = unsorted; return; } break;
 if ( curr_val < prev_val ) { prev_val = curr_val; }
      default :
 exit(-1);
    }
    prev_val = curr_val;
  }
  *ptr_is_sorted = sort_order;
}

variable_types:
iX
short *

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


decompiled_code:
__int64 __fastcall pos_copy_I8_I4(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v6; // rdx
int v7; // eax

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

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v6; // rdx
int v7; // eax

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

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

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

variable_types: status int

variable_types:
ival
long long


decompiled_code:
__int64 __fastcall sort_asc_F8(double *a1, double *a2)
{
__int64 result; // rax

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

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

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

original_code:
int sort_asc_F8(
         const void *ii,
         const void *jj
         )
{
  double val1, val2;
  double *ptr1, *ptr2;
  ptr1 = (double *)ii;
  ptr2 = (double *)jj;
  val1 = *ptr1;
  val2 = *ptr2;
  if ( val1 > val2 ) {
    return (1);
  }
  else if ( val1 < val2 ) {
    return (-1);
  }
  else {
    return(0);
  }
}

canonical_original_code:
int sort_asc_F8(void *ii, void *jj)
{
  double val1; double val2;
  double *ptr1; double *ptr2;
  ptr1 = (double *)ii;
  ptr2 = (double *)jj;
  val1 = *ptr1;
  val2 = *ptr2;
  if ( val1 > val2 ) {
    return (1);
  }
  else if ( val1 < val2 ) {
    return (-1);
  }
  else {
    return(0);
  }
}

variable_types:
ii
void *

variable_types:
jj
void *


decompiled_code:
__int64 __fastcall sort_dsc_F8(double *a1, double *a2)
{
__int64 result; // rax

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

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

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

original_code:
int sort_dsc_F8(
         const void *ii,
         const void *jj
         )
{
  double val1, val2;
  double *ptr1, *ptr2;
  ptr1 = (double *)ii;
  ptr2 = (double *)jj;
  val1 = *ptr1;
  val2 = *ptr2;
  if ( val1 < val2 ) {
    return (1);
  }
  else if ( val1 > val2 ) {
    return (-1);
  }
  else {
    return(0);
  }
}

canonical_original_code:
int sort_dsc_F8(void *ii, void *jj)
{
  double val1; double val2;
  double *ptr1; double *ptr2;
  ptr1 = (double *)ii;
  ptr2 = (double *)jj;
  val1 = *ptr1;
  val2 = *ptr2;
  if ( val1 < val2 ) {
    return (1);
  }
  else if ( val1 > val2 ) {
    return (-1);
  }
  else {
    return(0);
  }
}


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

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

variable_types: lb int

variable_types: ub int

variable_types:
cnt
long long

variable_types: val int


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

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

variable_types:
X
char *

variable_types:
yval
long long

variable_types:
zval
long long

variable_types:
W
long long *

variable_types:
Y
long long *

variable_types:
Z
long long *


original_code:
void
mul2_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 mul2_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:
nR
long long

variable_types:
out
long long *

variable_types:
outv
long long

variable_types:
i
long long


original_code:
int
xfer_SC_I4(
    char *src_fld_X,
    int fld_len,
    long long src_nR,
    char *dst_idx_X,
    char *nn_dst_idx_X,
    long long dst_nR,
    char *dst_fld_X
    )
{
  int status = 0;
  int nT = g_num_cores;
  long long block_size = dst_nR / nT;
  int *idxptr = (int *)dst_idx_X;

#pragma omp parallel for
  for ( int tid = 0; tid < nT; tid++ ) {
    long long lb = tid * block_size;
    long long ub = lb + block_size;
    if ( tid == (nT-1) ) { ub = dst_nR; }
    for ( long long i = lb; i < ub; i++ ) {
      char *dst_ptr = dst_fld_X + (i * (fld_len+1) );
      if ( ( nn_dst_idx_X == ((void *)0) ) || ( nn_dst_idx_X[i] == 0 ) ) {

#pragma omp simd
 for ( int j = 0; j < fld_len+1; j++ ) {
   dst_ptr[j] = '\0';
 }
      }
      else {
 int idx = idxptr[i];
 if ( ( idx < 0 ) || ( idx >= src_nR ) ) { status = -1; continue; }
 char *src_ptr = src_fld_X + (idx * (fld_len+1) );
 memcpy(dst_ptr, src_ptr, (fld_len+1));
      }
    }
  }
  return status;
}

canonical_original_code:
int xfer_SC_I4(char *src_fld_X, int fld_len, long long src_nR, char *dst_idx_X, char *nn_dst_idx_X, long long dst_nR, char *dst_fld_X)
{
  int status = 0;
  int nT = g_num_cores;
  long long block_size = dst_nR / nT;
  int *idxptr = (int *)dst_idx_X;

#pragma omp parallel for
  for ( int tid = 0; tid < nT; tid++ ) {
    long long lb = tid * block_size;
    long long ub = lb + block_size;
    if ( tid == (nT-1) ) { ub = dst_nR; }
    for ( long long i = lb; i < ub; i++ ) {
      char *dst_ptr = dst_fld_X + (i * (fld_len+1) );
      if ( ( nn_dst_idx_X == ((void *)0) ) || ( nn_dst_idx_X[i] == 0 ) ) {

#pragma omp simd
 for ( int j = 0; j < fld_len+1; j++ ) {
   dst_ptr[j] = '\0';
 }
      }
      else {
 int idx = idxptr[i];
 if ( ( idx < 0 ) || ( idx >= src_nR ) ) { status = -1; continue; }
 char *src_ptr = src_fld_X + (idx * (fld_len+1) );
 memcpy(dst_ptr, src_ptr, (fld_len+1));
      }
    }
  }
  return status;
}

variable_types: status int

variable_types: nT int

variable_types:
idxptr
int *

variable_types: tid int

variable_types:
lb
long long

variable_types:
ub
long long

variable_types: j int

variable_types: idx int


decompiled_code:
__int64 __fastcall setup_dict(const char *a1, const char *a2, int a3)
{
int v4; // ebx
int v6[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v4 = is_dict(a1, a2, v6);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "mk_ldb_dict.c");
}
else if ( a3 == 200 )
{
if ( v6[0] == 1 && (fprintf(stderr, "Deleting ldb dict %s from %s \n", a1, a2), v4 = del_dict(a1, a2), v4 < 0) )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "mk_ldb_dict.c");
}
else
{
v4 = mk_dict(a1, a2);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "mk_ldb_dict.c");
}
else
{
v4 = is_dict(a1, a2, v6);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "mk_ldb_dict.c");
}
else if ( v6[0] != 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "mk_ldb_dict.c");
v4 = -1;
}
}
}
}
else if ( a3 == 300 || a3 == 100 )
{
if ( v6[0] != 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "mk_ldb_dict.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "mk_ldb_dict.c");
v4 = -1;
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2, int a3)
{
int v4; // ebx
int v6[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v4 = is_dict(a1, a2, v6);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "mk_ldb_dict.c");
}
else if ( a3 == 200 )
{
if ( v6[0] == 1 && (fprintf(stderr, "Deleting ldb dict %s from %s \n", a1, a2), v4 = del_dict(a1, a2), v4 < 0) )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "mk_ldb_dict.c");
}
else
{
v4 = mk_dict(a1, a2);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "mk_ldb_dict.c");
}
else
{
v4 = is_dict(a1, a2, v6);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "mk_ldb_dict.c");
}
else if ( v6[0] != 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "mk_ldb_dict.c");
v4 = -1;
}
}
}
}
else if ( a3 == 300 || a3 == 100 )
{
if ( v6[0] != 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "mk_ldb_dict.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "mk_ldb_dict.c");
v4 = -1;
}
return (unsigned int)v4;
}

original_code:
static int
setup_dict(
    char *dict,
    char *data_dir,
    int mode
    )
{
  int status = 0;
  int dict_exists;
  status = is_dict(dict, data_dir, &dict_exists);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "mk_ldb_dict.c"); }; status = (status) ; goto BYE; } } };
  switch ( mode ) {
  case 100 : case 300 :
    if ( dict_exists != 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "mk_ldb_dict.c"); }; status = -1 ; goto BYE; }; }
    break;
  case 200 :
    if ( dict_exists == 1 ) {
      fprintf(stderr, "Deleting ldb dict %s from %s \n", dict, data_dir);
      status = del_dict(dict, data_dir); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "mk_ldb_dict.c"); }; status = (status) ; goto BYE; } } };
    }
    status = mk_dict(dict, data_dir); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "mk_ldb_dict.c"); }; status = (status) ; goto BYE; } } };
    status = is_dict(dict, data_dir, &dict_exists); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "mk_ldb_dict.c"); }; status = (status) ; goto BYE; } } };
    if ( dict_exists != 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "mk_ldb_dict.c"); }; status = -1 ; goto BYE; }; }
    break;
  default :
    { { fprintf(stderr, "Line %3d of File %s \n", 51, "mk_ldb_dict.c"); }; status = -1 ; goto BYE; }; break;
  }
 BYE:
  return(status);
}

canonical_original_code:
static int setup_dict(char *dict, char *data_dir, int mode)
{
  int status = 0;
  int dict_exists;
  status = is_dict(dict, data_dir, &dict_exists);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "mk_ldb_dict.c"); }; status = (status) ; goto BYE; } } };
  switch ( mode ) {
  case 100 : case 300 :
    if ( dict_exists != 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "mk_ldb_dict.c"); }; status = -1 ; goto BYE; }; }
    break;
  case 200 :
    if ( dict_exists == 1 ) {
      fprintf(stderr, "Deleting ldb dict %s from %s \n", dict, data_dir);
      status = del_dict(dict, data_dir); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "mk_ldb_dict.c"); }; status = (status) ; goto BYE; } } };
    }
    status = mk_dict(dict, data_dir); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "mk_ldb_dict.c"); }; status = (status) ; goto BYE; } } };
    status = is_dict(dict, data_dir, &dict_exists); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "mk_ldb_dict.c"); }; status = (status) ; goto BYE; } } };
    if ( dict_exists != 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "mk_ldb_dict.c"); }; status = -1 ; goto BYE; }; }
    break;
  default :
    { { fprintf(stderr, "Line %3d of File %s \n", 51, "mk_ldb_dict.c"); }; status = -1 ; goto BYE; }; break;
  }
 BYE:
  return(status);
}

variable_types:
dict
char *

variable_types: mode int


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

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

variable_types:
in
short *

variable_types:
n
long long

variable_types:
cfld
char *

variable_types:
cnt
long long *

variable_types:
cptr
char *

variable_types: idx short


decompiled_code:
__int64 __fastcall drop_nn_fld(_BYTE *a1, _BYTE *a2)
{
int v2; // ebx
char v4[224]; // [rsp+0h] [rbp-298h] BYREF
char v5[224]; // [rsp+E0h] [rbp-1B8h] BYREF
char v6[180]; // [rsp+1C0h] [rbp-D8h] BYREF
int v7; // [rsp+274h] [rbp-24h] BYREF
int v8; // [rsp+278h] [rbp-20h] BYREF
int v9[7]; // [rsp+27Ch] [rbp-1Ch] BYREF

v9[0] = 0x80000000;
v8 = 0x80000000;
v7 = 0x80000000;
if ( a1 && *a1 )
{
if ( a2 && *a2 )
{
v2 = is_tbl(a1, v9, v6);
if ( v2 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "./dir_wr_verbs/drop_nn_fld.c");
}
else if ( v9[0] < 0 || v9[0] >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "./dir_wr_verbs/drop_nn_fld.c");
v2 = -1;
}
else
{
v2 = is_fld(0LL, (unsigned int)v9[0], a2, &v8, v5, &v7, v4);
if ( v2 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "./dir_wr_verbs/drop_nn_fld.c");
}
else if ( v8 < 0 || v8 >= g_n_fld )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "./dir_wr_verbs/drop_nn_fld.c");
v2 = -1;
}
else
{
del_aux_fld((unsigned int)v8, 1LL);
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "./dir_wr_verbs/drop_nn_fld.c");
v2 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 35LL, "./dir_wr_verbs/drop_nn_fld.c");
v2 = -1;
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, _BYTE *a2)
{
int v2; // ebx
char v4[224]; // [rsp+0h] [rbp-298h] BYREF
char v5[224]; // [rsp+E0h] [rbp-1B8h] BYREF
char v6[180]; // [rsp+1C0h] [rbp-D8h] BYREF
int v7; // [rsp+274h] [rbp-24h] BYREF
int v8; // [rsp+278h] [rbp-20h] BYREF
int v9[7]; // [rsp+27Ch] [rbp-1Ch] BYREF

v9[0] = 0x80000000;
v8 = 0x80000000;
v7 = 0x80000000;
if ( a1 && *a1 )
{
if ( a2 && *a2 )
{
v2 = is_tbl(a1, v9, v6);
if ( v2 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "./dir_wr_verbs/drop_nn_fld.c");
}
else if ( v9[0] < 0 || v9[0] >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "./dir_wr_verbs/drop_nn_fld.c");
v2 = -1;
}
else
{
v2 = is_fld(0LL, (unsigned int)v9[0], a2, &v8, v5, &v7, v4);
if ( v2 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "./dir_wr_verbs/drop_nn_fld.c");
}
else if ( v8 < 0 || v8 >= g_n_fld )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "./dir_wr_verbs/drop_nn_fld.c");
v2 = -1;
}
else
{
del_aux_fld((unsigned int)v8, 1LL);
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 36LL, "./dir_wr_verbs/drop_nn_fld.c");
v2 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 35LL, "./dir_wr_verbs/drop_nn_fld.c");
v2 = -1;
}
return (unsigned int)v2;
}

original_code:
int
drop_nn_fld(
    char *tbl,
    char *fld
    )
{
  int status = 0;
  int tbl_id = (-0x7fffffff - 1), fld_id = (-0x7fffffff - 1), nn_fld_id = (-0x7fffffff - 1);
  TBL_REC_TYPE tbl_rec; FLD_REC_TYPE fld_rec, nn_fld_rec;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "./dir_wr_verbs/drop_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "./dir_wr_verbs/drop_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "./dir_wr_verbs/drop_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "./dir_wr_verbs/drop_nn_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 ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "./dir_wr_verbs/drop_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "./dir_wr_verbs/drop_nn_fld.c"); }; status = -1 ; goto BYE; }; } };
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "./dir_wr_verbs/drop_nn_fld.c"); }; status = -1 ; goto BYE; }; } };
  del_aux_fld(fld_id, nn);
 BYE:
  return(status);
}

canonical_original_code:
int drop_nn_fld(char *tbl, char *fld)
{
  int status = 0;
  int tbl_id = (-0x7fffffff - 1); int fld_id = (-0x7fffffff - 1); int nn_fld_id = (-0x7fffffff - 1);
  struct _TBL_REC_TYPE tbl_rec; struct _FLD_REC_TYPE fld_rec; struct _FLD_REC_TYPE nn_fld_rec;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "./dir_wr_verbs/drop_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "./dir_wr_verbs/drop_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "./dir_wr_verbs/drop_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "./dir_wr_verbs/drop_nn_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 ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "./dir_wr_verbs/drop_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "./dir_wr_verbs/drop_nn_fld.c"); }; status = -1 ; goto BYE; }; } };
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "./dir_wr_verbs/drop_nn_fld.c"); }; status = -1 ; goto BYE; }; } };
  del_aux_fld(fld_id, nn);
 BYE:
  return(status);
}

variable_types:
tbl
char *

variable_types:
fld
char *

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

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

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


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

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

variable_types: status int

variable_types:
delta
long long


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

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

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

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

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

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

variable_types:
lb
long long

variable_types:
ub
long long


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

variable_types: outv int

variable_types:
i
long long


original_code:
void
add2_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 add2_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 *

variable_types:
outv
long long


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

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


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

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

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

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

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

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


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

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

variable_types: lb int

variable_types: ub int

variable_types:
cnt
long long

variable_types: val int


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

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

variable_types:
n
long long

variable_types:
cfld
char *

variable_types:
cnt
long long *

variable_types:
cptr
char *

variable_types: idx short


decompiled_code:
__int64 __fastcall pos_count_I8_I8(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 v8; // rdx
__int64 v9; // rax
__int64 v10; // rax

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

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

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

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

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

variable_types: status int


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

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

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

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

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

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

variable_types:
ii
void *

variable_types:
jj
void *


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

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

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

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

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

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

variable_types: ival int


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

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

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

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

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

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

variable_types:
out
char *


decompiled_code:
__int64 __fastcall get_empty_fld(_BYTE *a1, __int64 a2, int a3, int *a4)
{
unsigned int v7; // esi
unsigned int v8; // ecx
__int64 v9; // rax
int v10; // edx
_BYTE *v11; // rbx
int v12; // eax
struct timezone tz; // [rsp+8h] [rbp-40h] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF
unsigned int v16[7]; // [rsp+2Ch] [rbp-1Ch] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, __int64 a2, int a3, int *a4)
{
unsigned int v7; // esi
unsigned int v8; // ecx
__int64 v9; // rax
int v10; // edx
_BYTE *v11; // rbx
int v12; // eax
struct timezone tz; // [rsp+8h] [rbp-40h] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF
unsigned int v16[7]; // [rsp+2Ch] [rbp-1Ch] BYREF

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

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

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

variable_types:
fld
char *

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

variable_types:
startidx
unsigned int

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

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

variable_types: i int