decompiled_code:
__int64 __fastcall f_to_s(_BYTE *a1, _BYTE *a2, const char *a3, char *a4, unsigned int a5)
{
__int64 v7; // r15
int v8; // er13
__int64 v10; // rdx
double v11; // xmm0_8
__int64 v12; // [rsp+8h] [rbp-220h]
__int64 v13; // [rsp+18h] [rbp-210h] BYREF
__int64 v14[4]; // [rsp+20h] [rbp-208h] BYREF
__int64 v15[5]; // [rsp+40h] [rbp-1E8h] BYREF
char v16; // [rsp+6Fh] [rbp-1B9h] BYREF
char v17[44]; // [rsp+70h] [rbp-1B8h] BYREF
int v18; // [rsp+9Ch] [rbp-18Ch] BYREF
__int64 v19; // [rsp+A0h] [rbp-188h] BYREF
unsigned int v20; // [rsp+11Ch] [rbp-10Ch] BYREF
__int64 v21; // [rsp+120h] [rbp-108h] BYREF
__int64 v22; // [rsp+140h] [rbp-E8h]
double v23; // [rsp+170h] [rbp-B8h]
double v24; // [rsp+178h] [rbp-B0h]
double v25; // [rsp+180h] [rbp-A8h]
__int64 v26; // [rsp+188h] [rbp-A0h]
__int64 v27; // [rsp+190h] [rbp-98h]
unsigned int v28; // [rsp+19Ch] [rbp-8Ch] BYREF
__int64 v29[6]; // [rsp+1A0h] [rbp-88h] BYREF
size_t v30; // [rsp+1D0h] [rbp-58h] BYREF
void *v31; // [rsp+1D8h] [rbp-50h] BYREF
size_t len; // [rsp+1E0h] [rbp-48h] BYREF
void *addr; // [rsp+1E8h] [rbp-40h] BYREF

addr = 0LL;
len = 0LL;
v31 = 0LL;
v30 = 0LL;
if ( !a1 || (v7 = a5, !*a1) )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
v8 = is_tbl(a1, &v28, v29);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "f_to_s.c");
goto LABEL_9;
}
if ( (v28 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
v12 = v29[0];
v8 = is_fld(a1, 0xFFFFFFFFLL, a2, &v20, &v21, &v18, &v19);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "f_to_s.c");
goto LABEL_9;
}
if ( (v20 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
v8 = get_data(&addr, &len, 0LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "f_to_s.c");
goto LABEL_9;
}
if ( v18 >= 0 )
{
v8 = get_data(&v31, &v30, 0LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "f_to_s.c");
goto LABEL_9;
}
}
zero_string(v17, 32LL);
v8 = extract_S(a3, "op=[", "]", v17, 32LL, &v16);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "f_to_s.c");
goto LABEL_9;
}
if ( !strcmp(a3, "is_sorted") )
{
if ( v18 >= 0 )
{
*(_DWORD *)(g_flds + 120LL * (int)v20 + 28) = 3;
goto LABEL_28;
}
if ( *(_DWORD *)(g_flds + 120LL * (int)v20 + 28) )
{
LABEL_28:
v8 = mk_str_srttype(*(unsigned int *)(g_flds + 120LL * (int)v20 + 28), a4);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 88LL, "f_to_s.c");
goto LABEL_9;
}
if ( (_DWORD)v22 == 4 )
{
is_sorted_alldef_I4(addr, v12, v15);
goto LABEL_46;
}
if ( (unsigned int)v22 > 4 )
{
if ( (_DWORD)v22 == 5 )
{
is_sorted_alldef_I8(addr, v12, v15);
goto LABEL_46;
}
}
else
{
if ( (_DWORD)v22 == 2 )
{
is_sorted_alldef_I1(addr, v12, v15);
goto LABEL_46;
}
if ( (_DWORD)v22 == 3 )
{
is_sorted_alldef_I2(addr, v12, v15);
LABEL_46:
*(_DWORD *)(g_flds + 120LL * (int)v20 + 28) = v15[0];
goto LABEL_28;
}
}
fprintf(stderr, "Line %3d of File %s \n", 83LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !strcmp(a3, "approx_uq") )
{
if ( (_DWORD)v22 == 4 )
{
v8 = approx_unique(addr, v31, v12, v14, v15, &v13);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 94LL, "f_to_s.c");
else
sprintf(a4, "%lld:%lf:%d", v14[0], *(double *)v15, (unsigned int)v13);
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 92LL, "f_to_s.c");
v8 = -1;
}
}
else if ( !strcmp(v17, "get_idx") )
{
v13 = -1LL;
zero_string(v14, 32LL);
zero_string(v15, 32LL);
v8 = chk_aux_info(a3);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 101LL, "f_to_s.c");
}
else
{
v8 = extract_S(a3, "val=[", "]", v15, 32LL, &v16);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 103LL, "f_to_s.c");
}
else if ( v16 )
{
fprintf(stderr, "Line %3d of File %s \n", 104LL, "f_to_s.c");
v8 = -1;
}
else
{
v8 = int_get_meta(v28, v20, "srttype", v14);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 105LL, "f_to_s.c");
}
else
{
v8 = is_s_in_f(addr, v31, (unsigned int)v22, v14, v15, v12, &v13);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 108LL, "f_to_s.c");
else
sprintf(a4, "%lld", v13);
}
}
}
}
else if ( !strcmp(v17, "get_val") )
{
v15[0] = -1LL;
v8 = chk_aux_info(a3);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 114LL, "f_to_s.c");
}
else
{
v8 = extract_I8(a3, "idx=[", "]", v15, &v16);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 116LL, "f_to_s.c");
}
else if ( v16 )
{
fprintf(stderr, "Line %3d of File %s \n", 117LL, "f_to_s.c");
v8 = -1;
}
else if ( v15[0] < 0 || v15[0] >= v12 )
{
fprintf(stderr, "Line %3d of File %s \n", 118LL, "f_to_s.c");
v8 = -1;
}
else
{
switch ( (int)v22 )
{
case 2:
v10 = *((char *)addr + v15[0]);
goto LABEL_84;
case 3:
v10 = *((__int16 *)addr + v15[0]);
goto LABEL_84;
case 4:
v10 = *((int *)addr + v15[0]);
goto LABEL_84;
case 5:
v10 = *((_QWORD *)addr + v15[0]);
LABEL_84:
sprintf(a4, "%lld", v10);
break;
case 6:
v11 = *((float *)addr + v15[0]);
goto LABEL_89;
case 7:
v11 = *((double *)addr + v15[0]);
LABEL_89:
sprintf(a4, "%lf", v11);
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 126LL, "f_to_s.c");
v8 = -1;
break;
}
}
}
}
else
{
if ( !strcmp(a3, "min") && BYTE1(v26) )
{
if ( (unsigned int)v22 > 5 )
{
if ( (unsigned int)(v22 - 6) <= 1 )
{
sprintf(a4, "%lf:%lld", v24, v27);
goto LABEL_9;
}
}
else if ( (_DWORD)v22 )
{
sprintf(a4, "%lld:%lld", *(_QWORD *)&v24, v27);
goto LABEL_9;
}
fprintf(stderr, "Line %3d of File %s \n", 153LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !strcmp(a3, "max") && BYTE2(v26) )
{
if ( (unsigned int)v22 > 5 )
{
if ( (unsigned int)(v22 - 6) <= 1 )
{
sprintf(a4, "%lf:%lld", v25, v27);
goto LABEL_9;
}
}
else if ( (_DWORD)v22 )
{
sprintf(a4, "%lld:%lld", *(_QWORD *)&v25, v27);
goto LABEL_9;
}
fprintf(stderr, "Line %3d of File %s \n", 168LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !strcmp(a3, "sum") && (_BYTE)v26 )
{
if ( (unsigned int)v22 <= 5 )
{
if ( (_DWORD)v22 )
{
sprintf(a4, "%lld:%lld", *(_QWORD *)&v23, v27);
goto LABEL_9;
}
}
else if ( (unsigned int)(v22 - 6) <= 1 )
{
sprintf(a4, "%lf:%lld", v23, v27);
goto LABEL_9;
}
fprintf(stderr, "Line %3d of File %s \n", 183LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
v8 = vec_f_to_s(addr, (unsigned int)v22, v31, v12, a3, a4, v7);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 190LL, "f_to_s.c");
}
else
{
v8 = int_set_meta(v28, v20, a3, a4, 1LL);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 192LL, "f_to_s.c");
}
}
LABEL_9:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_12;
}
LABEL_116:
fprintf(stderr, "Line %3d of File %s \n", 198LL, "f_to_s.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_116;
LABEL_12:
if ( !v31 )
{
if ( !v30 )
return (unsigned int)v8;
LABEL_119:
fprintf(stderr, "Line %3d of File %s \n", 199LL, "f_to_s.c");
return (unsigned int)-1;
}
if ( !v30 )
goto LABEL_119;
munmap(v31, v30);
return (unsigned int)v8;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, _BYTE *a2, const char *a3, char *a4, unsigned int a5)
{
__int64 v7; // r15
int v8; // er13
__int64 v10; // rdx
double v11; // xmm0_8
__int64 v12; // [rsp+8h] [rbp-220h]
__int64 v13; // [rsp+18h] [rbp-210h] BYREF
__int64 v14[4]; // [rsp+20h] [rbp-208h] BYREF
__int64 v15[5]; // [rsp+40h] [rbp-1E8h] BYREF
char v16; // [rsp+6Fh] [rbp-1B9h] BYREF
char v17[44]; // [rsp+70h] [rbp-1B8h] BYREF
int v18; // [rsp+9Ch] [rbp-18Ch] BYREF
__int64 v19; // [rsp+A0h] [rbp-188h] BYREF
unsigned int v20; // [rsp+11Ch] [rbp-10Ch] BYREF
__int64 v21; // [rsp+120h] [rbp-108h] BYREF
__int64 v22; // [rsp+140h] [rbp-E8h]
double v23; // [rsp+170h] [rbp-B8h]
double v24; // [rsp+178h] [rbp-B0h]
double v25; // [rsp+180h] [rbp-A8h]
__int64 v26; // [rsp+188h] [rbp-A0h]
__int64 v27; // [rsp+190h] [rbp-98h]
unsigned int v28; // [rsp+19Ch] [rbp-8Ch] BYREF
__int64 v29[6]; // [rsp+1A0h] [rbp-88h] BYREF
size_t v30; // [rsp+1D0h] [rbp-58h] BYREF
void *v31; // [rsp+1D8h] [rbp-50h] BYREF
size_t len; // [rsp+1E0h] [rbp-48h] BYREF
void *addr; // [rsp+1E8h] [rbp-40h] BYREF

addr = 0LL;
len = 0LL;
v31 = 0LL;
v30 = 0LL;
if ( !a1 || (v7 = a5, !*a1) )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
v8 = is_tbl(a1, &v28, v29);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "f_to_s.c");
goto LABEL_9;
}
if ( (v28 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
v12 = v29[0];
v8 = is_fld(a1, 0xFFFFFFFFLL, a2, &v20, &v21, &v18, &v19);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "f_to_s.c");
goto LABEL_9;
}
if ( (v20 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
v8 = get_data(&addr, &len, 0LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "f_to_s.c");
goto LABEL_9;
}
if ( v18 >= 0 )
{
v8 = get_data(&v31, &v30, 0LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "f_to_s.c");
goto LABEL_9;
}
}
zero_string(v17, 32LL);
v8 = extract_S(a3, "op=[", "]", v17, 32LL, &v16);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "f_to_s.c");
goto LABEL_9;
}
if ( !strcmp(a3, "is_sorted") )
{
if ( v18 >= 0 )
{
*(_DWORD *)(g_flds + 120LL * (int)v20 + 28) = 3;
goto LABEL_28;
}
if ( *(_DWORD *)(g_flds + 120LL * (int)v20 + 28) )
{
LABEL_28:
v8 = mk_str_srttype(*(unsigned int *)(g_flds + 120LL * (int)v20 + 28), a4);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 88LL, "f_to_s.c");
goto LABEL_9;
}
if ( (_DWORD)v22 == 4 )
{
is_sorted_alldef_I4(addr, v12, v15);
goto LABEL_46;
}
if ( (unsigned int)v22 > 4 )
{
if ( (_DWORD)v22 == 5 )
{
is_sorted_alldef_I8(addr, v12, v15);
goto LABEL_46;
}
}
else
{
if ( (_DWORD)v22 == 2 )
{
is_sorted_alldef_I1(addr, v12, v15);
goto LABEL_46;
}
if ( (_DWORD)v22 == 3 )
{
is_sorted_alldef_I2(addr, v12, v15);
LABEL_46:
*(_DWORD *)(g_flds + 120LL * (int)v20 + 28) = v15[0];
goto LABEL_28;
}
}
fprintf(stderr, "Line %3d of File %s \n", 83LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !strcmp(a3, "approx_uq") )
{
if ( (_DWORD)v22 == 4 )
{
v8 = approx_unique(addr, v31, v12, v14, v15, &v13);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 94LL, "f_to_s.c");
else
sprintf(a4, "%lld:%lf:%d", v14[0], *(double *)v15, (unsigned int)v13);
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 92LL, "f_to_s.c");
v8 = -1;
}
}
else if ( !strcmp(v17, "get_idx") )
{
v13 = -1LL;
zero_string(v14, 32LL);
zero_string(v15, 32LL);
v8 = chk_aux_info(a3);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 101LL, "f_to_s.c");
}
else
{
v8 = extract_S(a3, "val=[", "]", v15, 32LL, &v16);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 103LL, "f_to_s.c");
}
else if ( v16 )
{
fprintf(stderr, "Line %3d of File %s \n", 104LL, "f_to_s.c");
v8 = -1;
}
else
{
v8 = int_get_meta(v28, v20, "srttype", v14);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 105LL, "f_to_s.c");
}
else
{
v8 = is_s_in_f(addr, v31, (unsigned int)v22, v14, v15, v12, &v13);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 108LL, "f_to_s.c");
else
sprintf(a4, "%lld", v13);
}
}
}
}
else if ( !strcmp(v17, "get_val") )
{
v15[0] = -1LL;
v8 = chk_aux_info(a3);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 114LL, "f_to_s.c");
}
else
{
v8 = extract_I8(a3, "idx=[", "]", v15, &v16);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 116LL, "f_to_s.c");
}
else if ( v16 )
{
fprintf(stderr, "Line %3d of File %s \n", 117LL, "f_to_s.c");
v8 = -1;
}
else if ( v15[0] < 0 || v15[0] >= v12 )
{
fprintf(stderr, "Line %3d of File %s \n", 118LL, "f_to_s.c");
v8 = -1;
}
else
{
switch ( (int)v22 )
{
case 2:
v10 = *((char *)addr + v15[0]);
goto LABEL_84;
case 3:
v10 = *((__int16 *)addr + v15[0]);
goto LABEL_84;
case 4:
v10 = *((int *)addr + v15[0]);
goto LABEL_84;
case 5:
v10 = *((_QWORD *)addr + v15[0]);
LABEL_84:
sprintf(a4, "%lld", v10);
break;
case 6:
v11 = *((float *)addr + v15[0]);
goto LABEL_89;
case 7:
v11 = *((double *)addr + v15[0]);
LABEL_89:
sprintf(a4, "%lf", v11);
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 126LL, "f_to_s.c");
v8 = -1;
break;
}
}
}
}
else
{
if ( !strcmp(a3, "min") && BYTE1(v26) )
{
if ( (unsigned int)v22 > 5 )
{
if ( (unsigned int)(v22 - 6) <= 1 )
{
sprintf(a4, "%lf:%lld", v24, v27);
goto LABEL_9;
}
}
else if ( (_DWORD)v22 )
{
sprintf(a4, "%lld:%lld", *(_QWORD *)&v24, v27);
goto LABEL_9;
}
fprintf(stderr, "Line %3d of File %s \n", 153LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !strcmp(a3, "max") && BYTE2(v26) )
{
if ( (unsigned int)v22 > 5 )
{
if ( (unsigned int)(v22 - 6) <= 1 )
{
sprintf(a4, "%lf:%lld", v25, v27);
goto LABEL_9;
}
}
else if ( (_DWORD)v22 )
{
sprintf(a4, "%lld:%lld", *(_QWORD *)&v25, v27);
goto LABEL_9;
}
fprintf(stderr, "Line %3d of File %s \n", 168LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
if ( !strcmp(a3, "sum") && (_BYTE)v26 )
{
if ( (unsigned int)v22 <= 5 )
{
if ( (_DWORD)v22 )
{
sprintf(a4, "%lld:%lld", *(_QWORD *)&v23, v27);
goto LABEL_9;
}
}
else if ( (unsigned int)(v22 - 6) <= 1 )
{
sprintf(a4, "%lf:%lld", v23, v27);
goto LABEL_9;
}
fprintf(stderr, "Line %3d of File %s \n", 183LL, "f_to_s.c");
v8 = -1;
goto LABEL_9;
}
v8 = vec_f_to_s(addr, (unsigned int)v22, v31, v12, a3, a4, v7);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 190LL, "f_to_s.c");
}
else
{
v8 = int_set_meta(v28, v20, a3, a4, 1LL);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 192LL, "f_to_s.c");
}
}
LABEL_9:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_12;
}
LABEL_116:
fprintf(stderr, "Line %3d of File %s \n", 198LL, "f_to_s.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_116;
LABEL_12:
if ( !v31 )
{
if ( !v30 )
return (unsigned int)v8;
LABEL_119:
fprintf(stderr, "Line %3d of File %s \n", 199LL, "f_to_s.c");
return (unsigned int)-1;
}
if ( !v30 )
goto LABEL_119;
munmap(v31, v30);
return (unsigned int)v8;
}

original_code:
int
f_to_s(
    const char *tbl,
    const char *fld,
    const char *str_op_spec,
    char *rslt_buf,
    int sz_rslt_buf
    )
{
  int status = 0;
  char *X = ((void *)0); size_t nX = 0;
  char *nn_X = ((void *)0); size_t nn_nX = 0;
  long long nR;
  TBL_REC_TYPE tbl_rec; int tbl_id;
  FLD_REC_TYPE fld_rec; int fld_id;
  FLD_REC_TYPE nn_fld_rec; int nn_fld_id;
  char op[32]; _Bool is_null;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_op_spec == ((void *)0) ) || ( *str_op_spec == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  nR = tbl_rec.nR;
  status = is_fld(tbl, -1, fld, &fld_id, &fld_rec, &nn_fld_id, &nn_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(fld_rec, &X, &nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_fld_id >= 0 ) {
    status = get_data(nn_fld_rec, &nn_X, &nn_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  }
  zero_string(op, 32);
  status = extract_S(str_op_spec, "op=[", "]", op, 32, &is_null);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( strcmp(str_op_spec, "is_sorted") == 0 ) {
    if ( nn_fld_id >= 0 ) {
      g_flds[fld_id].srttype = unsorted;
    }
    else if ( g_flds[fld_id].srttype == unknown ) {
      char *fI1 = (char *)X;
      short *fI2 = (short *)X;
      int *fI4 = (int *)X;
      long long *fI8 = (long long *)X;
      SORT_TYPE srttype;
      switch ( fld_rec.fldtype ) {
 case I1 : is_sorted_alldef_I1(fI1, nR, &srttype); break;
 case I2 : is_sorted_alldef_I2(fI2, nR, &srttype); break;
 case I4 : is_sorted_alldef_I4(fI4, nR, &srttype); break;
 case I8 : is_sorted_alldef_I8(fI8, nR, &srttype); break;
 default : { { fprintf(stderr, "Line %3d of File %s \n", 83, "f_to_s.c"); }; status = -1 ; goto BYE; }; break;
      }
      g_flds[fld_id].srttype = srttype;
    }
    status = mk_str_srttype(g_flds[fld_id].srttype, rslt_buf);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(str_op_spec, "approx_uq") == 0 ) {
    long long num_uq_I8; double accuracy_F8; int is_good;
    if ( fld_rec.fldtype != I4 ) { { { fprintf(stderr, "Line %3d of File %s \n", 92, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
    status = approx_unique((int *)X, nn_X, nR, &num_uq_I8, &accuracy_F8, &is_good);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 94, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    sprintf(rslt_buf, "%lld:%lf:%d", num_uq_I8, accuracy_F8, is_good);
  }
  else if ( strcmp(op, "get_idx") == 0 ) {
    long long idx = -1;
    char str_srttype[32]; zero_string(str_srttype, 32);
    char str_val[32]; zero_string(str_val, 32);
    status = chk_aux_info(str_op_spec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 101, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    status = extract_S(str_op_spec, "val=[", "]", str_val, 32, &is_null);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 103, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 104, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
    status = int_get_meta(tbl_id, fld_id, "srttype", str_srttype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 105, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    status = is_s_in_f(X, nn_X, fld_rec.fldtype, str_srttype,
 str_val, nR, &idx);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 108, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    sprintf(rslt_buf, "%lld", idx);
  }
  else if ( strcmp(op, "get_val") == 0 ) {
    long long idx = -1;
    long long valI8; double valF8;
    status = chk_aux_info(str_op_spec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 114, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    status = extract_I8(str_op_spec, "idx=[", "]", &idx, &is_null);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 116, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    if ( is_null == 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 117, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
    if ( ( idx < 0 ) || ( idx >= nR ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 118, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
    switch ( fld_rec.fldtype ) {
      case I1 : valI8 = ((char *)X)[idx]; break;
      case I2 : valI8 = ((short *)X)[idx]; break;
      case I4 : valI8 = ((int *)X)[idx]; break;
      case I8 : valI8 = ((long long *)X)[idx]; break;
      case F4 : valF8 = ((float *)X)[idx]; break;
      case F8 : valF8 = ((double *)X)[idx]; break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 126, "f_to_s.c"); }; status = -1 ; goto BYE; }; break;
    }
    switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 :
        sprintf(rslt_buf, "%lld", valI8);
 break;
      case F4 : case F8 :
        sprintf(rslt_buf, "%lf", valF8);
 break;
      default :
   { { fprintf(stderr, "Line %3d of File %s \n", 136, "f_to_s.c"); }; status = -1 ; goto BYE; };
 break;
    }
  }
  else {
    _Bool exists = 0;
    if ( ( strcmp(str_op_spec, "min") == 0 ) &&
 ( fld_rec.is_min_nn == 1 ) ) {
      exists = 1;
      switch ( fld_rec.fldtype ) {
 case B : case I1 : case I2 : case I4 : case I8 :
         sprintf(rslt_buf, "%lld:%lld", fld_rec.minval.minI8, fld_rec.num_nn);
  break;
 case F4 : case F8 :
         sprintf(rslt_buf, "%lf:%lld", fld_rec.minval.minF8, fld_rec.num_nn);
  break;
 default :
  { { fprintf(stderr, "Line %3d of File %s \n", 153, "f_to_s.c"); }; status = -1 ; goto BYE; };
  break;
      }
    }
    else if ( ( strcmp(str_op_spec, "max") == 0 ) &&
 ( fld_rec.is_max_nn == 1 ) ) {
      exists = 1;
      switch ( fld_rec.fldtype ) {
 case B : case I1 : case I2 : case I4 : case I8 :
         sprintf(rslt_buf, "%lld:%lld", fld_rec.maxval.maxI8, fld_rec.num_nn);
  break;
 case F4 : case F8 :
         sprintf(rslt_buf, "%lf:%lld", fld_rec.maxval.maxF8, fld_rec.num_nn);
  break;
 default :
  { { fprintf(stderr, "Line %3d of File %s \n", 168, "f_to_s.c"); }; status = -1 ; goto BYE; };
  break;
      }
    }
    else if ( ( strcmp(str_op_spec, "sum") == 0 ) &&
 ( fld_rec.is_sum_nn == 1 ) ) {
      exists = 1;
      switch ( fld_rec.fldtype ) {
 case B : case I1 : case I2 : case I4 : case I8 :
         sprintf(rslt_buf, "%lld:%lld", fld_rec.sumval.sumI8, fld_rec.num_nn);
  break;
 case F4 : case F8 :
         sprintf(rslt_buf, "%lf:%lld", fld_rec.sumval.sumF8, fld_rec.num_nn);
  break;
 default :
  { { fprintf(stderr, "Line %3d of File %s \n", 183, "f_to_s.c"); }; status = -1 ; goto BYE; };
  break;
      }
    }
    if ( exists == 0 ) {
       status = vec_f_to_s(X, fld_rec.fldtype, nn_X, nR, str_op_spec,
   rslt_buf, sz_rslt_buf);
       { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 190, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
       status = int_set_meta(tbl_id, fld_id, str_op_spec, rslt_buf, 1);
       { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 192, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    }
    else {
    }
  }
 BYE:
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 198, "f_to_s.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 198, "f_to_s.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", 199, "f_to_s.c"); }; return(-1); } if ( ( nn_X != ((void *)0) ) && ( nn_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 199, "f_to_s.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 f_to_s(char *tbl, char *fld, char *str_op_spec, char *rslt_buf, int sz_rslt_buf)
{
  int status = 0;
  char *X = ((void *)0); unsigned long nX = 0;
  char *nn_X = ((void *)0); unsigned long nn_nX = 0;
  long long nR;
  struct _TBL_REC_TYPE tbl_rec; int tbl_id;
  struct _FLD_REC_TYPE fld_rec; int fld_id;
  struct _FLD_REC_TYPE nn_fld_rec; int nn_fld_id;
  char op[32]; _Bool is_null;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_op_spec == ((void *)0) ) || ( *str_op_spec == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  nR = tbl_rec.nR;
  status = is_fld(tbl, -1, fld, &fld_id, &fld_rec, &nn_fld_id, &nn_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(fld_rec, &X, &nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_fld_id >= 0 ) {
    status = get_data(nn_fld_rec, &nn_X, &nn_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  }
  zero_string(op, 32);
  status = extract_S(str_op_spec, "op=[", "]", op, 32, &is_null);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  if ( strcmp(str_op_spec, "is_sorted") == 0 ) {
    if ( nn_fld_id >= 0 ) {
      g_flds[fld_id].srttype = unsorted;
    }
    else if ( g_flds[fld_id].srttype == unknown ) {
      char *fI1 = (char *)X;
      short *fI2 = (short *)X;
      int *fI4 = (int *)X;
      long long *fI8 = (long long *)X;
      enum _SORT_TYPE srttype;
      switch ( fld_rec.fldtype ) {
 case I1 : is_sorted_alldef_I1(fI1, nR, &srttype); break;
 case I2 : is_sorted_alldef_I2(fI2, nR, &srttype); break;
 case I4 : is_sorted_alldef_I4(fI4, nR, &srttype); break;
 case I8 : is_sorted_alldef_I8(fI8, nR, &srttype); break;
 default : { { fprintf(stderr, "Line %3d of File %s \n", 83, "f_to_s.c"); }; status = -1 ; goto BYE; }; break;
      }
      g_flds[fld_id].srttype = srttype;
    }
    status = mk_str_srttype(g_flds[fld_id].srttype, rslt_buf);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
  }
  else if ( strcmp(str_op_spec, "approx_uq") == 0 ) {
    long long num_uq_I8; double accuracy_F8; int is_good;
    if ( fld_rec.fldtype != I4 ) { { { fprintf(stderr, "Line %3d of File %s \n", 92, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
    status = approx_unique((int *)X, nn_X, nR, &num_uq_I8, &accuracy_F8, &is_good);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 94, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    sprintf(rslt_buf, "%lld:%lf:%d", num_uq_I8, accuracy_F8, is_good);
  }
  else if ( strcmp(op, "get_idx") == 0 ) {
    long long idx = -1;
    char str_srttype[32]; zero_string(str_srttype, 32);
    char str_val[32]; zero_string(str_val, 32);
    status = chk_aux_info(str_op_spec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 101, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    status = extract_S(str_op_spec, "val=[", "]", str_val, 32, &is_null);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 103, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 104, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
    status = int_get_meta(tbl_id, fld_id, "srttype", str_srttype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 105, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    status = is_s_in_f(X, nn_X, fld_rec.fldtype, str_srttype,
 str_val, nR, &idx);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 108, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    sprintf(rslt_buf, "%lld", idx);
  }
  else if ( strcmp(op, "get_val") == 0 ) {
    long long idx = -1;
    long long valI8; double valF8;
    status = chk_aux_info(str_op_spec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 114, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    status = extract_I8(str_op_spec, "idx=[", "]", &idx, &is_null);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 116, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    if ( is_null == 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 117, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
    if ( ( idx < 0 ) || ( idx >= nR ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 118, "f_to_s.c"); }; status = -1 ; goto BYE; }; }
    switch ( fld_rec.fldtype ) {
      case I1 : valI8 = ((char *)X)[idx]; break;
      case I2 : valI8 = ((short *)X)[idx]; break;
      case I4 : valI8 = ((int *)X)[idx]; break;
      case I8 : valI8 = ((long long *)X)[idx]; break;
      case F4 : valF8 = ((float *)X)[idx]; break;
      case F8 : valF8 = ((double *)X)[idx]; break;
      default : { { fprintf(stderr, "Line %3d of File %s \n", 126, "f_to_s.c"); }; status = -1 ; goto BYE; }; break;
    }
    switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 :
        sprintf(rslt_buf, "%lld", valI8);
 break;
      case F4 : case F8 :
        sprintf(rslt_buf, "%lf", valF8);
 break;
      default :
   { { fprintf(stderr, "Line %3d of File %s \n", 136, "f_to_s.c"); }; status = -1 ; goto BYE; };
 break;
    }
  }
  else {
    _Bool exists = 0;
    if ( ( strcmp(str_op_spec, "min") == 0 ) &&
 ( fld_rec.is_min_nn == 1 ) ) {
      exists = 1;
      switch ( fld_rec.fldtype ) {
 case B : case I1 : case I2 : case I4 : case I8 :
         sprintf(rslt_buf, "%lld:%lld", fld_rec.minval.minI8, fld_rec.num_nn);
  break;
 case F4 : case F8 :
         sprintf(rslt_buf, "%lf:%lld", fld_rec.minval.minF8, fld_rec.num_nn);
  break;
 default :
  { { fprintf(stderr, "Line %3d of File %s \n", 153, "f_to_s.c"); }; status = -1 ; goto BYE; };
  break;
      }
    }
    else if ( ( strcmp(str_op_spec, "max") == 0 ) &&
 ( fld_rec.is_max_nn == 1 ) ) {
      exists = 1;
      switch ( fld_rec.fldtype ) {
 case B : case I1 : case I2 : case I4 : case I8 :
         sprintf(rslt_buf, "%lld:%lld", fld_rec.maxval.maxI8, fld_rec.num_nn);
  break;
 case F4 : case F8 :
         sprintf(rslt_buf, "%lf:%lld", fld_rec.maxval.maxF8, fld_rec.num_nn);
  break;
 default :
  { { fprintf(stderr, "Line %3d of File %s \n", 168, "f_to_s.c"); }; status = -1 ; goto BYE; };
  break;
      }
    }
    else if ( ( strcmp(str_op_spec, "sum") == 0 ) &&
 ( fld_rec.is_sum_nn == 1 ) ) {
      exists = 1;
      switch ( fld_rec.fldtype ) {
 case B : case I1 : case I2 : case I4 : case I8 :
         sprintf(rslt_buf, "%lld:%lld", fld_rec.sumval.sumI8, fld_rec.num_nn);
  break;
 case F4 : case F8 :
         sprintf(rslt_buf, "%lf:%lld", fld_rec.sumval.sumF8, fld_rec.num_nn);
  break;
 default :
  { { fprintf(stderr, "Line %3d of File %s \n", 183, "f_to_s.c"); }; status = -1 ; goto BYE; };
  break;
      }
    }
    if ( exists == 0 ) {
       status = vec_f_to_s(X, fld_rec.fldtype, nn_X, nR, str_op_spec,
   rslt_buf, sz_rslt_buf);
       { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 190, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
       status = int_set_meta(tbl_id, fld_id, str_op_spec, rslt_buf, 1);
       { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 192, "f_to_s.c"); }; status = (status) ; goto BYE; } } };
    }
    else {
    }
  }
 BYE:
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 198, "f_to_s.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 198, "f_to_s.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", 199, "f_to_s.c"); }; return(-1); } if ( ( nn_X != ((void *)0) ) && ( nn_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 199, "f_to_s.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:
X
char *

variable_types:
nX
unsigned long

variable_types:
nR
long long

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:
op
char [32]

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


repo: linkedin/datacl

decompiled_code:
__int64 __fastcall mk_hashes_I2(__int16 *a1, int a2, _QWORD *a3, unsigned int *a4, unsigned int *a5, unsigned int *a6)
{
_WORD *v6; // r12
_BYTE *v7; // rbp
__int64 v8; // rax
__int64 v9; // r13
__int64 v10; // rax
__int64 v11; // rax
__int16 *v12; // rcx
__int16 v13; // si
__int64 v14; // rdx
__int64 v15; // rax
int v16; // esi
unsigned int v17; // ebx
char v18; // dl
unsigned int v20; // [rsp+0h] [rbp-68h]
unsigned int v21; // [rsp+4h] [rbp-64h]
unsigned int size; // [rsp+8h] [rbp-60h]

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

canonical_decompiled_code:
__int64 __fastcall func0(__int16 *a1, int a2, _QWORD *a3, unsigned int *a4, unsigned int *a5, unsigned int *a6)
{
_WORD *v6; // r12
_BYTE *v7; // rbp
__int64 v8; // rax
__int64 v9; // r13
__int64 v10; // rax
__int64 v11; // rax
__int16 *v12; // rcx
__int16 v13; // si
__int64 v14; // rdx
__int64 v15; // rax
int v16; // esi
unsigned int v17; // ebx
char v18; // dl
unsigned int v20; // [rsp+0h] [rbp-68h]
unsigned int v21; // [rsp+4h] [rbp-64h]
unsigned int size; // [rsp+8h] [rbp-60h]

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

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

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

variable_types:
scalars
short *

variable_types: status int

variable_types:
hashes
short *

variable_types:
used
unsigned char *

variable_types:
n
unsigned int

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types: iter int

variable_types: i int

variable_types:
val
unsigned long long

variable_types:
ltemp
unsigned long long

variable_types:
loc
unsigned short

return_type: int


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

variable_types: outv double

variable_types:
i
long long

return_type: void


decompiled_code:
void __fastcall vec_reciprocal_F8(__int64 a1, int a2, __int64 a3)
{
__int64 i; // rax

if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
*(double *)(a3 + 8 * i) = 1.0 / *(double *)(a1 + 8 * i);
}
}

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

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

variable_types:
in
double *

variable_types: nR int


decompiled_code:
__int64 __fastcall f1opf2_shift(void *a1, __int64 a2, __int64 a3, unsigned int a4, unsigned int a5, char *a6, _QWORD *a7)
{
char *v11; // rax
int v12; // er13
unsigned int v13; // ebx
__int64 v14; // rbp
size_t v15; // r15
char *v16; // rsi
char *v17; // r12
_QWORD *v18; // rbp
__int64 v19; // rbp
size_t v20; // r15
_QWORD *v21; // rbp
void *v23; // [rsp+8h] [rbp-2050h]
__int64 src[1024]; // [rsp+10h] [rbp-2048h] BYREF
char v25[12]; // [rsp+2010h] [rbp-48h] BYREF
int v26[15]; // [rsp+201Ch] [rbp-3Ch] BYREF

v23 = a1;
v11 = (char *)src;
do
*v11++ = 0;
while ( v11 != v25 );
if ( a5 + 1023 > 0x7FE )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "./dir_helpers/f1opf2_shift.c");
v12 = -1;
}
else if ( (int)a5 <= -a3 || (int)a5 >= a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "./dir_helpers/f1opf2_shift.c");
v12 = -1;
}
else
{
v12 = get_fld_sz(a4, v26, v25);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "./dir_helpers/f1opf2_shift.c");
}
else if ( (int)a5 > 0 )
{
v19 = a3 - (int)a5;
v20 = (int)(a5 * v26[0]);
memcpy(&a6[v20], v23, v19 * v26[0]);
memcpy(a6, src, v20);
if ( a2 )
{
v21 = (_QWORD *)((char *)a7 + v19);
if ( a5 >= 8 )
{
*v21 = src[0];
*(_QWORD *)((char *)v21 + a5 - 8) = *(void **)((char *)&v23 + a5);
qmemcpy(
(void *)((unsigned __int64)(v21 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)src - ((char *)v21 - ((unsigned __int64)(v21 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * ((a5 + (_DWORD)v21 - (((_DWORD)v21 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (a5 & 4) != 0 )
{
*(_DWORD *)v21 = src[0];
*(_DWORD *)((char *)v21 + a5 - 4) = *(_DWORD *)((char *)src + a5 - 4);
}
else
{
*(_BYTE *)v21 = src[0];
if ( (a5 & 2) != 0 )
*(_WORD *)((char *)v21 + a5 - 2) = *(_WORD *)((char *)src + a5 - 2);
}
}
else
{
assign_const_I1((char *)a7 + (int)a5, v19, 1LL);
}
if ( a5 >= 8 )
{
*a7 = src[0];
*(_QWORD *)((char *)a7 + a5 - 8) = *(void **)((char *)&v23 + a5);
qmemcpy(
(void *)((unsigned __int64)(a7 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)src - ((char *)a7 - ((unsigned __int64)(a7 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * ((a5 + (_DWORD)a7 - (((_DWORD)a7 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (a5 & 4) != 0 )
{
*(_DWORD *)a7 = src[0];
*(_DWORD *)((char *)a7 + a5 - 4) = *(_DWORD *)((char *)src + a5 - 4);
}
else
{
*(_BYTE *)a7 = src[0];
if ( (a5 & 2) != 0 )
*(_WORD *)((char *)a7 + a5 - 2) = *(_WORD *)((char *)src + a5 - 2);
}
}
else if ( (a5 & 0x80000000) == 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "./dir_helpers/f1opf2_shift.c");
v12 = -1;
}
else
{
v13 = -a5;
v14 = a3 - (int)v13;
v15 = (int)(v13 * v26[0]);
v16 = (char *)v23 + v15;
v23 = (void *)(v14 * v26[0]);
memcpy(a6, v16, (size_t)v23);
v17 = &a6[(_QWORD)v23];
memcpy(v17, src, v15);
if ( a2 )
memcpy(v17, src, v15);
else
assign_const_I1(a7, v14, 1LL);
v18 = (_QWORD *)((char *)a7 + v14);
if ( v13 >= 8 )
{
*v18 = src[0];
*(_QWORD *)((char *)v18 + v13 - 8) = *(void **)((char *)&v23 + v13);
qmemcpy(
(void *)((unsigned __int64)(v18 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)src - ((char *)v18 - ((unsigned __int64)(v18 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * ((v13 + (_DWORD)v18 - (((_DWORD)v18 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (v13 & 4) != 0 )
{
*(_DWORD *)v18 = src[0];
*(_DWORD *)((char *)v18 + v13 - 4) = *(_DWORD *)((char *)src + v13 - 4);
}
else if ( v13 )
{
*(_BYTE *)v18 = src[0];
if ( (v13 & 2) != 0 )
*(_WORD *)((char *)v18 + v13 - 2) = *(_WORD *)((char *)src + v13 - 2);
}
}
}
return (unsigned int)v12;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *a1, __int64 a2, __int64 a3, unsigned int a4, unsigned int a5, char *a6, _QWORD *a7)
{
char *v11; // rax
int v12; // er13
unsigned int v13; // ebx
__int64 v14; // rbp
size_t v15; // r15
char *v16; // rsi
char *v17; // r12
_QWORD *v18; // rbp
__int64 v19; // rbp
size_t v20; // r15
_QWORD *v21; // rbp
void *v23; // [rsp+8h] [rbp-2050h]
__int64 src[1024]; // [rsp+10h] [rbp-2048h] BYREF
char v25[12]; // [rsp+2010h] [rbp-48h] BYREF
int v26[15]; // [rsp+201Ch] [rbp-3Ch] BYREF

v23 = a1;
v11 = (char *)src;
do
*v11++ = 0;
while ( v11 != v25 );
if ( a5 + 1023 > 0x7FE )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "./dir_helpers/f1opf2_shift.c");
v12 = -1;
}
else if ( (int)a5 <= -a3 || (int)a5 >= a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "./dir_helpers/f1opf2_shift.c");
v12 = -1;
}
else
{
v12 = get_fld_sz(a4, v26, v25);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "./dir_helpers/f1opf2_shift.c");
}
else if ( (int)a5 > 0 )
{
v19 = a3 - (int)a5;
v20 = (int)(a5 * v26[0]);
memcpy(&a6[v20], v23, v19 * v26[0]);
memcpy(a6, src, v20);
if ( a2 )
{
v21 = (_QWORD *)((char *)a7 + v19);
if ( a5 >= 8 )
{
*v21 = src[0];
*(_QWORD *)((char *)v21 + a5 - 8) = *(void **)((char *)&v23 + a5);
qmemcpy(
(void *)((unsigned __int64)(v21 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)src - ((char *)v21 - ((unsigned __int64)(v21 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * ((a5 + (_DWORD)v21 - (((_DWORD)v21 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (a5 & 4) != 0 )
{
*(_DWORD *)v21 = src[0];
*(_DWORD *)((char *)v21 + a5 - 4) = *(_DWORD *)((char *)src + a5 - 4);
}
else
{
*(_BYTE *)v21 = src[0];
if ( (a5 & 2) != 0 )
*(_WORD *)((char *)v21 + a5 - 2) = *(_WORD *)((char *)src + a5 - 2);
}
}
else
{
assign_const_I1((char *)a7 + (int)a5, v19, 1LL);
}
if ( a5 >= 8 )
{
*a7 = src[0];
*(_QWORD *)((char *)a7 + a5 - 8) = *(void **)((char *)&v23 + a5);
qmemcpy(
(void *)((unsigned __int64)(a7 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)src - ((char *)a7 - ((unsigned __int64)(a7 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * ((a5 + (_DWORD)a7 - (((_DWORD)a7 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (a5 & 4) != 0 )
{
*(_DWORD *)a7 = src[0];
*(_DWORD *)((char *)a7 + a5 - 4) = *(_DWORD *)((char *)src + a5 - 4);
}
else
{
*(_BYTE *)a7 = src[0];
if ( (a5 & 2) != 0 )
*(_WORD *)((char *)a7 + a5 - 2) = *(_WORD *)((char *)src + a5 - 2);
}
}
else if ( (a5 & 0x80000000) == 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "./dir_helpers/f1opf2_shift.c");
v12 = -1;
}
else
{
v13 = -a5;
v14 = a3 - (int)v13;
v15 = (int)(v13 * v26[0]);
v16 = (char *)v23 + v15;
v23 = (void *)(v14 * v26[0]);
memcpy(a6, v16, (size_t)v23);
v17 = &a6[(_QWORD)v23];
memcpy(v17, src, v15);
if ( a2 )
memcpy(v17, src, v15);
else
assign_const_I1(a7, v14, 1LL);
v18 = (_QWORD *)((char *)a7 + v14);
if ( v13 >= 8 )
{
*v18 = src[0];
*(_QWORD *)((char *)v18 + v13 - 8) = *(void **)((char *)&v23 + v13);
qmemcpy(
(void *)((unsigned __int64)(v18 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)src - ((char *)v18 - ((unsigned __int64)(v18 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * ((v13 + (_DWORD)v18 - (((_DWORD)v18 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (v13 & 4) != 0 )
{
*(_DWORD *)v18 = src[0];
*(_DWORD *)((char *)v18 + v13 - 4) = *(_DWORD *)((char *)src + v13 - 4);
}
else if ( v13 )
{
*(_BYTE *)v18 = src[0];
if ( (v13 & 2) != 0 )
*(_WORD *)((char *)v18 + v13 - 2) = *(_WORD *)((char *)src + v13 - 2);
}
}
}
return (unsigned int)v12;
}

original_code:
int
f1opf2_shift(
      char *X,
      char *nn_X,
      long long nR,
      FLD_TYPE fldtype,
      int shift_by,
      char *op_X,
      char *nn_op_X
    )
{
  int status = 0;
  int fldsz;
  char zeros[1024*8];
  for ( int i = 0; i < 1024*8; i++ ) { zeros[i] = 0; }
  if ( ( shift_by <= -1024 ) || (shift_by >= 1024 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "./dir_helpers/f1opf2_shift.c"); }; status = -1 ; goto BYE; }; }
  if ( ( shift_by <= -1 * nR ) || (shift_by >= nR ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "./dir_helpers/f1opf2_shift.c"); }; status = -1 ; goto BYE; }; }
  status = get_fld_sz(fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "./dir_helpers/f1opf2_shift.c"); }; status = (status) ; goto BYE; } } };
  if ( shift_by > 0 ) {
    memcpy(op_X + (fldsz*shift_by), X, (nR-shift_by)*fldsz);
    memcpy(op_X, zeros, (shift_by *fldsz));
    if ( nn_X != ((void *)0) ) {
      memcpy(nn_op_X + (nR-shift_by), zeros, shift_by);
    }
    else {
      assign_const_I1(nn_op_X+shift_by, (nR-shift_by), 1);
    }
    memcpy(nn_op_X, zeros, shift_by);
  }
  else if ( shift_by < 0 ) {
    shift_by *= -1;
    memcpy(op_X, X + (fldsz*shift_by), (nR-shift_by)*fldsz);
    memcpy(op_X + ((nR-shift_by)*fldsz), zeros, (shift_by *fldsz));
    if ( nn_X != ((void *)0) ) {
      memcpy(op_X + ((nR-shift_by)*fldsz), zeros, (shift_by *fldsz));
    }
    else {
      assign_const_I1(nn_op_X, (nR-shift_by), 1);
    }
    memcpy(nn_op_X + (nR-shift_by), zeros, shift_by);
  }
  else { { { fprintf(stderr, "Line %3d of File %s \n", 80, "./dir_helpers/f1opf2_shift.c"); }; status = -1 ; goto BYE; }; }
BYE:
  return(status);
}

canonical_original_code:
int f1opf2_shift(char *X, char *nn_X, long long nR, enum _FLD_TYPE fldtype, int shift_by, char *op_X, char *nn_op_X)
{
  int status = 0;
  int fldsz;
  char zeros[-1];
  for ( int i = 0; i < 1024*8; i++ ) { zeros[i] = 0; }
  if ( ( shift_by <= -1024 ) || (shift_by >= 1024 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "./dir_helpers/f1opf2_shift.c"); }; status = -1 ; goto BYE; }; }
  if ( ( shift_by <= -1 * nR ) || (shift_by >= nR ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "./dir_helpers/f1opf2_shift.c"); }; status = -1 ; goto BYE; }; }
  status = get_fld_sz(fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "./dir_helpers/f1opf2_shift.c"); }; status = (status) ; goto BYE; } } };
  if ( shift_by > 0 ) {
    memcpy(op_X + (fldsz*shift_by), X, (nR-shift_by)*fldsz);
    memcpy(op_X, zeros, (shift_by *fldsz));
    if ( nn_X != ((void *)0) ) {
      memcpy(nn_op_X + (nR-shift_by), zeros, shift_by);
    }
    else {
      assign_const_I1(nn_op_X+shift_by, (nR-shift_by), 1);
    }
    memcpy(nn_op_X, zeros, shift_by);
  }
  else if ( shift_by < 0 ) {
    shift_by *= -1;
    memcpy(op_X, X + (fldsz*shift_by), (nR-shift_by)*fldsz);
    memcpy(op_X + ((nR-shift_by)*fldsz), zeros, (shift_by *fldsz));
    if ( nn_X != ((void *)0) ) {
      memcpy(op_X + ((nR-shift_by)*fldsz), zeros, (shift_by *fldsz));
    }
    else {
      assign_const_I1(nn_op_X, (nR-shift_by), 1);
    }
    memcpy(nn_op_X + (nR-shift_by), zeros, shift_by);
  }
  else { { { fprintf(stderr, "Line %3d of File %s \n", 80, "./dir_helpers/f1opf2_shift.c"); }; status = -1 ; goto BYE; }; }
BYE:
  return(status);
}

variable_types:
X
char *

variable_types: status int

variable_types: fldsz int

variable_types:
zeros
char [-1]


decompiled_code:
__int64 __fastcall g_del_fld(const char *a1)
{
int v1; // ebp
char v3[512]; // [rsp+0h] [rbp-D18h] BYREF
char v4[2060]; // [rsp+200h] [rbp-B18h] BYREF
unsigned int v5; // [rsp+A0Ch] [rbp-30Ch] BYREF
__int64 v6; // [rsp+A10h] [rbp-308h] BYREF
__int64 v7; // [rsp+A18h] [rbp-300h] BYREF
__int64 v8; // [rsp+A20h] [rbp-2F8h] BYREF
void *ptr; // [rsp+A28h] [rbp-2F0h] BYREF
char v10[716]; // [rsp+A30h] [rbp-2E8h] BYREF
int v11[7]; // [rsp+CFCh] [rbp-1Ch] BYREF

v11[0] = -1;
ptr = 0LL;
v8 = 0LL;
v7 = 0LL;
v6 = 0LL;
v5 = 0;
g_mmap_meta_data(&g_docroot, &v8, &v7, &v6, &v5);
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "g_del_fld.c");
v1 = -1;
goto LABEL_4;
}
v1 = g_is_fld(v6, v5, a1, v11, v10);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "g_del_fld.c");
goto LABEL_4;
}
if ( v11[0] < 0 )
return (unsigned int)v1;
zero_string(v4, 2048LL);
zero_string(v4, 512LL);
sprintf(v3, "del_fld d_fld=%s", a1);
v1 = g_make_url(v3, v4);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_del_fld.c");
goto LABEL_4;
}
v1 = g_call_gpu(v4, &ptr);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_del_fld.c");
LABEL_4:
if ( ptr )
{
free(ptr);
ptr = 0LL;
}
goto LABEL_6;
}
if ( ptr )
{
fprintf(stderr, "Response from GPU = [%s]\n", (const char *)ptr);
goto LABEL_4;
}
LABEL_6:
g_unmap_meta_data(v8, v7);
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
int v1; // ebp
char v3[512]; // [rsp+0h] [rbp-D18h] BYREF
char v4[2060]; // [rsp+200h] [rbp-B18h] BYREF
unsigned int v5; // [rsp+A0Ch] [rbp-30Ch] BYREF
__int64 v6; // [rsp+A10h] [rbp-308h] BYREF
__int64 v7; // [rsp+A18h] [rbp-300h] BYREF
__int64 v8; // [rsp+A20h] [rbp-2F8h] BYREF
void *ptr; // [rsp+A28h] [rbp-2F0h] BYREF
char v10[716]; // [rsp+A30h] [rbp-2E8h] BYREF
int v11[7]; // [rsp+CFCh] [rbp-1Ch] BYREF

v11[0] = -1;
ptr = 0LL;
v8 = 0LL;
v7 = 0LL;
v6 = 0LL;
v5 = 0;
g_mmap_meta_data(&g_docroot, &v8, &v7, &v6, &v5);
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "g_del_fld.c");
v1 = -1;
goto LABEL_4;
}
v1 = g_is_fld(v6, v5, a1, v11, v10);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "g_del_fld.c");
goto LABEL_4;
}
if ( v11[0] < 0 )
return (unsigned int)v1;
zero_string(v4, 2048LL);
zero_string(v4, 512LL);
sprintf(v3, "del_fld d_fld=%s", a1);
v1 = g_make_url(v3, v4);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_del_fld.c");
goto LABEL_4;
}
v1 = g_call_gpu(v4, &ptr);
if ( v1 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_del_fld.c");
LABEL_4:
if ( ptr )
{
free(ptr);
ptr = 0LL;
}
goto LABEL_6;
}
if ( ptr )
{
fprintf(stderr, "Response from GPU = [%s]\n", (const char *)ptr);
goto LABEL_4;
}
LABEL_6:
g_unmap_meta_data(v8, v7);
return (unsigned int)v1;
}

original_code:
int
g_del_fld(
    char *d_fld
    )
{
  int status = 0;
  int d_fld_id = -1; GPU_REG_TYPE d_fld_rec;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "g_del_fld.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "g_del_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) { return status ; }
  char url[2048]; zero_string(url, 2048);
  char command[512]; zero_string(url, 512);
  sprintf(command, "del_fld d_fld=%s", d_fld);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_del_fld.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "g_del_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return status ;
}

canonical_original_code:
int g_del_fld(char *d_fld)
{
  int status = 0;
  int d_fld_id = -1; struct _GPU_REG_TYPE d_fld_rec;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "g_del_fld.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "g_del_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) { return status ; }
  char url[2048]; zero_string(url, 2048);
  char command[512]; zero_string(url, 512);
  sprintf(command, "del_fld d_fld=%s", d_fld);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_del_fld.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "g_del_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return status ;
}

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

variable_types:
url
char [2048]

variable_types:
command
char [512]

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


decompiled_code:
__int64 __fastcall sort_asc_F4(float *a1, float *a2)
{
__int64 result; // rax

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

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

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

original_code:
int sort_asc_F4(
         const void *ii,
         const void *jj
         )
{
  float val1, val2;
  float *ptr1, *ptr2;
  ptr1 = (float *)ii;
  ptr2 = (float *)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_F4(void *ii, void *jj)
{
  float val1; float val2;
  float *ptr1; float *ptr2;
  ptr1 = (float *)ii;
  ptr2 = (float *)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 *


original_code:
void
hash_I4(
       unsigned int *in,
       long long nR,
       unsigned long long seed,
       unsigned long long * restrict out
       )
{
  for ( long long i = 0; i < nR; i++ ) {
    *out = spooky_hash64(in, sizeof(int), seed);
    in++;
    out++;
  }
}

canonical_original_code:
void hash_I4(unsigned int *in, long long nR, unsigned long long seed, unsigned long long *out)
{
  for ( long long i = 0; i < nR; i++ ) {
    *out = spooky_hash64(in, sizeof(int), seed);
    in++;
    out++;
  }
}

variable_types:
in
unsigned int *

variable_types:
seed
unsigned long long

variable_types:
out
unsigned long long *


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

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

variable_types:
nR
long long

variable_types:
out
float *

variable_types: outv float


decompiled_code:
__int64 __fastcall udf_eq_B(_BYTE *a1, const char *a2, _BYTE *a3, const char *a4)
{
int v6; // ebp
__int64 v8; // r15
__int64 v9; // r12
int v10; // er14
char *v11; // rdi
char *v12; // rdi
_QWORD *v13; // rax
__int64 v14; // rax
__int64 v15; // r13
__int64 v16; // r13
char *v17; // rbp
char *v18; // rdi
char *v19; // rdi
_QWORD *v20; // rax
__int64 v21; // [rsp+8h] [rbp-2BA0h]
__int64 v22; // [rsp+10h] [rbp-2B98h]
int v23; // [rsp+18h] [rbp-2B90h]
int v24; // [rsp+1Ch] [rbp-2B8Ch]
__int64 v25[128]; // [rsp+20h] [rbp-2B88h] BYREF
char v26[8204]; // [rsp+420h] [rbp-2788h] BYREF
unsigned int v27; // [rsp+242Ch] [rbp-77Ch] BYREF
__int64 v28; // [rsp+2430h] [rbp-778h] BYREF
unsigned int v29; // [rsp+243Ch] [rbp-76Ch] BYREF
size_t v30; // [rsp+2440h] [rbp-768h] BYREF
void *v31; // [rsp+2448h] [rbp-760h] BYREF
size_t len; // [rsp+2450h] [rbp-758h] BYREF
void *addr; // [rsp+2458h] [rbp-750h] BYREF
char v34[256]; // [rsp+2460h] [rbp-748h] BYREF
char v35[128]; // [rsp+2560h] [rbp-648h] BYREF
char v36[32]; // [rsp+25E0h] [rbp-5C8h] BYREF
char v37[64]; // [rsp+2600h] [rbp-5A8h] BYREF
char v38[128]; // [rsp+2640h] [rbp-568h] BYREF
char v39[256]; // [rsp+26C0h] [rbp-4E8h] BYREF
__int64 v40; // [rsp+27C0h] [rbp-3E8h] BYREF
int v41; // [rsp+27CCh] [rbp-3DCh] BYREF
char v42; // [rsp+27D1h] [rbp-3D7h] BYREF
__int16 v43; // [rsp+27D2h] [rbp-3D6h] BYREF
unsigned int v44; // [rsp+27D4h] [rbp-3D4h] BYREF
__int64 v45; // [rsp+27D8h] [rbp-3D0h] BYREF
char v46[28]; // [rsp+27E0h] [rbp-3C8h] BYREF
char v47[4]; // [rsp+27FCh] [rbp-3ACh] BYREF
char v48[232]; // [rsp+2800h] [rbp-3A8h] BYREF
int v49; // [rsp+28E8h] [rbp-2C0h] BYREF
int v50; // [rsp+28ECh] [rbp-2BCh] BYREF
char v51[224]; // [rsp+28F0h] [rbp-2B8h] BYREF
__int64 v52; // [rsp+29D0h] [rbp-1D8h] BYREF
__int64 v53; // [rsp+29E8h] [rbp-1C0h]
__int64 v54[23]; // [rsp+2AB0h] [rbp-F8h] BYREF
unsigned int v55[15]; // [rsp+2B6Ch] [rbp-3Ch] BYREF

v45 = 0x7FFFFFFFFFFFFFFFLL;
v44 = 0x7FFFFFFF;
v43 = 0x7FFF;
v42 = 127;
v41 = 2139095039;
v40 = LC1;
addr = 0LL;
len = 0LL;
v31 = 0LL;
v30 = 0LL;
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 82LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
if ( !a4 || !*a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
if ( !strcmp(a2, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 84LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
zero_string(v46, 16LL);
v6 = is_tbl(a1, v55, v54);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
if ( (v55[0] & 0x80000000) != 0 || (int)v55[0] >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 89LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
v8 = v54[0];
is_fld(0LL, v55[0], a2, &v50, &v52, &v49, v51);
if ( v50 < 0 || v50 >= g_n_fld )
{
fprintf(stderr, "Line %3d of File %s \n", 93LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
v6 = get_data(&addr, &len, 0LL);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 94LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
if ( v49 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 95LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
v29 = -1;
v6 = break_into_scalars(a3, (unsigned int)v53, &v29, &v45, &v44, &v43, &v42, &v41, &v40, v39, v38, v37, v36, v35, v34);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 102LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
v28 = -1LL;
v27 = -1;
v6 = get_file_size_B(v8, &v28);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 106LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
v6 = mk_temp_file(v46, v28, &v27);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 107LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
v6 = q_mmap(v27, v46, &v31, &v30, 1LL);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 108LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
v24 = v8 / 4096;
if ( v24 )
{
if ( (int)(v8 / 4096) <= 0 )
goto LABEL_77;
}
else
{
v24 = 1;
}
v9 = 0LL;
v10 = 0;
v23 = v24 - 1;
do
{
v14 = v9;
v21 = v9;
v22 = v9;
v9 += 4096LL;
v15 = v8;
if ( v23 != v10 )
v15 = v9;
v16 = v15 - v14;
v6 = -1;
if ( v16 <= 0x2000 )
{
v17 = (char *)addr;
assign_const_I1(v26, 0x2000LL, 0LL);
if ( (_DWORD)v53 == 4 )
{
v19 = &v17[4 * v22];
if ( v29 == 1 )
cmp_eq_scalar_I4(v19, v44, v16, v26);
else
cmp_eq_mult_scalar_I4(v19, v16, v38, v29, v26);
}
else if ( (unsigned int)v53 > 4 )
{
if ( (_DWORD)v53 != 5 )
{
v6 = -1;
goto LABEL_57;
}
v11 = &v17[8 * v22];
if ( v29 == 1 )
cmp_eq_scalar_I8(v11, v45, v16, v26);
else
cmp_eq_mult_scalar_I8(v11, v16, v39, v29, v26);
}
else if ( (_DWORD)v53 == 2 )
{
v12 = &v17[v22];
if ( v29 == 1 )
cmp_eq_scalar_I1(v12, (unsigned int)v42, v16, v26);
else
cmp_eq_mult_scalar_I1(v12, v16, v36, v29, v26);
}
else
{
if ( (_DWORD)v53 != 3 )
{
v6 = -1;
goto LABEL_57;
}
v18 = &v17[2 * v22];
if ( v29 == 1 )
cmp_eq_scalar_I2(v18, (unsigned int)v43, v16, v26);
else
cmp_eq_mult_scalar_I2(v18, v16, v37, v29, v26);
}
v6 = conv_I1_to_B(v26, v16, v25);
if ( v6 >= 0 )
{
if ( v23 != v10 || v16 == 4096 )
{
v13 = (char *)v31 + v21 / 8;
*v13 = v25[0];
v13[63] = v25[63];
qmemcpy(
(void *)((unsigned __int64)(v13 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)v25 - ((char *)v13 - ((unsigned __int64)(v13 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v13 - (((_DWORD)v13 + 8) & 0xFFFFFFF8) + 512) >> 3));
}
else
{
v20 = (char *)v31 + v21 / 8;
*v20 = v25[0];
v20[127] = v25[127];
qmemcpy(
(void *)((unsigned __int64)(v20 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)v25 - ((char *)v20 - ((unsigned __int64)(v20 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v20 - (((_DWORD)v20 + 8) & 0xFFFFFFF8) + 1024) >> 3));
}
}
}
LABEL_57:
++v10;
}
while ( v10 < v24 );
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 183LL, "./dir_wr_verbs/udf_eq_B.c");
}
else
{
LABEL_77:
v6 = add_fld(v55[0], a4, v27, v46, 1LL, 0xFFFFFFFFLL, v47, v48);
if ( v6 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 188LL, "./dir_wr_verbs/udf_eq_B.c");
}
LABEL_15:
if ( !addr )
{
if ( len )
goto LABEL_81;
LABEL_18:
if ( v31 )
{
if ( v30 )
{
munmap(v31, v30);
return (unsigned int)v6;
}
}
else if ( !v30 )
{
return (unsigned int)v6;
}
fprintf(stderr, "Line %3d of File %s \n", 192LL, "./dir_wr_verbs/udf_eq_B.c");
return (unsigned int)-1;
}
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_18;
}
LABEL_81:
fprintf(stderr, "Line %3d of File %s \n", 191LL, "./dir_wr_verbs/udf_eq_B.c");
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, const char *a2, _BYTE *a3, const char *a4)
{
int v6; // ebp
__int64 v8; // r15
__int64 v9; // r12
int v10; // er14
char *v11; // rdi
char *v12; // rdi
_QWORD *v13; // rax
__int64 v14; // rax
__int64 v15; // r13
__int64 v16; // r13
char *v17; // rbp
char *v18; // rdi
char *v19; // rdi
_QWORD *v20; // rax
__int64 v21; // [rsp+8h] [rbp-2BA0h]
__int64 v22; // [rsp+10h] [rbp-2B98h]
int v23; // [rsp+18h] [rbp-2B90h]
int v24; // [rsp+1Ch] [rbp-2B8Ch]
__int64 v25[128]; // [rsp+20h] [rbp-2B88h] BYREF
char v26[8204]; // [rsp+420h] [rbp-2788h] BYREF
unsigned int v27; // [rsp+242Ch] [rbp-77Ch] BYREF
__int64 v28; // [rsp+2430h] [rbp-778h] BYREF
unsigned int v29; // [rsp+243Ch] [rbp-76Ch] BYREF
size_t v30; // [rsp+2440h] [rbp-768h] BYREF
void *v31; // [rsp+2448h] [rbp-760h] BYREF
size_t len; // [rsp+2450h] [rbp-758h] BYREF
void *addr; // [rsp+2458h] [rbp-750h] BYREF
char v34[256]; // [rsp+2460h] [rbp-748h] BYREF
char v35[128]; // [rsp+2560h] [rbp-648h] BYREF
char v36[32]; // [rsp+25E0h] [rbp-5C8h] BYREF
char v37[64]; // [rsp+2600h] [rbp-5A8h] BYREF
char v38[128]; // [rsp+2640h] [rbp-568h] BYREF
char v39[256]; // [rsp+26C0h] [rbp-4E8h] BYREF
__int64 v40; // [rsp+27C0h] [rbp-3E8h] BYREF
int v41; // [rsp+27CCh] [rbp-3DCh] BYREF
char v42; // [rsp+27D1h] [rbp-3D7h] BYREF
__int16 v43; // [rsp+27D2h] [rbp-3D6h] BYREF
unsigned int v44; // [rsp+27D4h] [rbp-3D4h] BYREF
__int64 v45; // [rsp+27D8h] [rbp-3D0h] BYREF
char v46[28]; // [rsp+27E0h] [rbp-3C8h] BYREF
char v47[4]; // [rsp+27FCh] [rbp-3ACh] BYREF
char v48[232]; // [rsp+2800h] [rbp-3A8h] BYREF
int v49; // [rsp+28E8h] [rbp-2C0h] BYREF
int v50; // [rsp+28ECh] [rbp-2BCh] BYREF
char v51[224]; // [rsp+28F0h] [rbp-2B8h] BYREF
__int64 v52; // [rsp+29D0h] [rbp-1D8h] BYREF
__int64 v53; // [rsp+29E8h] [rbp-1C0h]
__int64 v54[23]; // [rsp+2AB0h] [rbp-F8h] BYREF
unsigned int v55[15]; // [rsp+2B6Ch] [rbp-3Ch] BYREF

v45 = 0x7FFFFFFFFFFFFFFFLL;
v44 = 0x7FFFFFFF;
v43 = 0x7FFF;
v42 = 127;
v41 = 2139095039;
v40 = LC1;
addr = 0LL;
len = 0LL;
v31 = 0LL;
v30 = 0LL;
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 82LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
if ( !a4 || !*a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
if ( !strcmp(a2, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 84LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
zero_string(v46, 16LL);
v6 = is_tbl(a1, v55, v54);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
if ( (v55[0] & 0x80000000) != 0 || (int)v55[0] >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 89LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
v8 = v54[0];
is_fld(0LL, v55[0], a2, &v50, &v52, &v49, v51);
if ( v50 < 0 || v50 >= g_n_fld )
{
fprintf(stderr, "Line %3d of File %s \n", 93LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
v6 = get_data(&addr, &len, 0LL);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 94LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
if ( v49 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 95LL, "./dir_wr_verbs/udf_eq_B.c");
v6 = -1;
goto LABEL_15;
}
v29 = -1;
v6 = break_into_scalars(a3, (unsigned int)v53, &v29, &v45, &v44, &v43, &v42, &v41, &v40, v39, v38, v37, v36, v35, v34);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 102LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
v28 = -1LL;
v27 = -1;
v6 = get_file_size_B(v8, &v28);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 106LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
v6 = mk_temp_file(v46, v28, &v27);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 107LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
v6 = q_mmap(v27, v46, &v31, &v30, 1LL);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 108LL, "./dir_wr_verbs/udf_eq_B.c");
goto LABEL_15;
}
v24 = v8 / 4096;
if ( v24 )
{
if ( (int)(v8 / 4096) <= 0 )
goto LABEL_77;
}
else
{
v24 = 1;
}
v9 = 0LL;
v10 = 0;
v23 = v24 - 1;
do
{
v14 = v9;
v21 = v9;
v22 = v9;
v9 += 4096LL;
v15 = v8;
if ( v23 != v10 )
v15 = v9;
v16 = v15 - v14;
v6 = -1;
if ( v16 <= 0x2000 )
{
v17 = (char *)addr;
assign_const_I1(v26, 0x2000LL, 0LL);
if ( (_DWORD)v53 == 4 )
{
v19 = &v17[4 * v22];
if ( v29 == 1 )
cmp_eq_scalar_I4(v19, v44, v16, v26);
else
cmp_eq_mult_scalar_I4(v19, v16, v38, v29, v26);
}
else if ( (unsigned int)v53 > 4 )
{
if ( (_DWORD)v53 != 5 )
{
v6 = -1;
goto LABEL_57;
}
v11 = &v17[8 * v22];
if ( v29 == 1 )
cmp_eq_scalar_I8(v11, v45, v16, v26);
else
cmp_eq_mult_scalar_I8(v11, v16, v39, v29, v26);
}
else if ( (_DWORD)v53 == 2 )
{
v12 = &v17[v22];
if ( v29 == 1 )
cmp_eq_scalar_I1(v12, (unsigned int)v42, v16, v26);
else
cmp_eq_mult_scalar_I1(v12, v16, v36, v29, v26);
}
else
{
if ( (_DWORD)v53 != 3 )
{
v6 = -1;
goto LABEL_57;
}
v18 = &v17[2 * v22];
if ( v29 == 1 )
cmp_eq_scalar_I2(v18, (unsigned int)v43, v16, v26);
else
cmp_eq_mult_scalar_I2(v18, v16, v37, v29, v26);
}
v6 = conv_I1_to_B(v26, v16, v25);
if ( v6 >= 0 )
{
if ( v23 != v10 || v16 == 4096 )
{
v13 = (char *)v31 + v21 / 8;
*v13 = v25[0];
v13[63] = v25[63];
qmemcpy(
(void *)((unsigned __int64)(v13 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)v25 - ((char *)v13 - ((unsigned __int64)(v13 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v13 - (((_DWORD)v13 + 8) & 0xFFFFFFF8) + 512) >> 3));
}
else
{
v20 = (char *)v31 + v21 / 8;
*v20 = v25[0];
v20[127] = v25[127];
qmemcpy(
(void *)((unsigned __int64)(v20 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)v25 - ((char *)v20 - ((unsigned __int64)(v20 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v20 - (((_DWORD)v20 + 8) & 0xFFFFFFF8) + 1024) >> 3));
}
}
}
LABEL_57:
++v10;
}
while ( v10 < v24 );
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 183LL, "./dir_wr_verbs/udf_eq_B.c");
}
else
{
LABEL_77:
v6 = add_fld(v55[0], a4, v27, v46, 1LL, 0xFFFFFFFFLL, v47, v48);
if ( v6 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 188LL, "./dir_wr_verbs/udf_eq_B.c");
}
LABEL_15:
if ( !addr )
{
if ( len )
goto LABEL_81;
LABEL_18:
if ( v31 )
{
if ( v30 )
{
munmap(v31, v30);
return (unsigned int)v6;
}
}
else if ( !v30 )
{
return (unsigned int)v6;
}
fprintf(stderr, "Line %3d of File %s \n", 192LL, "./dir_wr_verbs/udf_eq_B.c");
return (unsigned int)-1;
}
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_18;
}
LABEL_81:
fprintf(stderr, "Line %3d of File %s \n", 191LL, "./dir_wr_verbs/udf_eq_B.c");
return (unsigned int)-1;
}

original_code:
int
udf_eq_B(
  char *tbl,
  char *f1,
  char *str_scalar,
  char *f2
  )
{
  int status = 0;
  long long nR; int tbl_id;
  TBL_REC_TYPE tbl_rec;
  FLD_REC_TYPE f1_rec, nn_f1_rec; int f1_id, nn_f1_id;
  FLD_REC_TYPE f2_rec ; int f2_id;
  char opfile[15 +1];
  long long sval_I8 = 0x7fffffffffffffffLL;
  int sval_I4 = 0x7fffffff;
  short sval_I2 = 0x7fff;
  char sval_I1 = 0x7f;
  float sval_F4 = 3.40282346638528859811704183484516925e+38F;
  double sval_F8 = ((double)1.79769313486231570814527423731704357e+308L);
  long long svals_I8[32];
  int svals_I4[32];
  short svals_I2[32];
  char svals_I1[32];
  float svals_F4[32];
  double svals_F8[32];
  char *f1_X = ((void *)0); size_t f1_nX = 0;
  char *f2_X = ((void *)0); size_t f2_nX = 0;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_scalar == ((void *)0) ) || ( *str_scalar == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 82, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  zero_string(opfile, 15 +1);
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; } };
  nR = tbl_rec.nR;
  status = is_fld(((void *)0), tbl_id, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec);
  { if ( ( (f1_id) < (0) ) || ( (f1_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 93, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; } };
  status = get_data(f1_rec, &f1_X, &f1_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 94, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_f1_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 95, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  int num_scalar_vals = -1;
  status = break_into_scalars(str_scalar, f1_rec.fldtype, &num_scalar_vals,
          &sval_I8, &sval_I4, &sval_I2, &sval_I1, &sval_F4, &sval_F8,
          svals_I8, svals_I4, svals_I2, svals_I1, svals_F4, svals_F8);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 102, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  long long filesz = -1; int ddir_id = -1;
  status = get_file_size_B(nR, &filesz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 106, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  status = mk_temp_file(opfile, filesz, &ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 107, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, opfile, &f2_X, &f2_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 108, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  if ( ( ( 4096 / 8 ) * 8 ) != 4096 ) { { { fprintf(stderr, "Line %3d of File %s \n", 111, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  int nT;
  nT = nR / 4096;
  if ( nT == 0 ) { nT = 1; }
  for ( int tid = 0; tid < nT; tid++ ) {
    long long lb = tid * 4096;
    long long ub = lb + 4096;
    if ( tid == (nT-1) ) { ub = nR; }
    long long nX = ub - lb;
    if ( nX > (2*4096) ) { status = -1; continue; }
    char opI1[2*4096];
    char opB[2*(4096/8)];
    char *f1I1 = (char *)f1_X; f1I1 += lb;
    short *f1I2 = (short *)f1_X; f1I2 += lb;
    int *f1I4 = (int *)f1_X; f1I4 += lb;
    long long *f1I8 = (long long *)f1_X; f1I8 += lb;
    assign_const_I1(opI1, 2*4096, (char)0);
    switch ( f1_rec.fldtype ) {
    case I1 :
      if ( num_scalar_vals == 1 ) {
 cmp_eq_scalar_I1(f1I1, sval_I1, nX, opI1);
      }
      else {
 cmp_eq_mult_scalar_I1(f1I1, nX, svals_I1, num_scalar_vals, opI1);
      }
      break;
    case I2 :
      if ( num_scalar_vals == 1 ) {
 cmp_eq_scalar_I2(f1I2, sval_I2, nX, opI1);
      }
      else {
 cmp_eq_mult_scalar_I2(f1I2, nX, svals_I2, num_scalar_vals, opI1);
      }
      break;
    case I4 :
      if ( num_scalar_vals == 1 ) {
 cmp_eq_scalar_I4(f1I4, sval_I4, nX, opI1);
      }
      else {
 cmp_eq_mult_scalar_I4(f1I4, nX, svals_I4, num_scalar_vals, opI1);
      }
      break;
    case I8 :
      if ( num_scalar_vals == 1 ) {
 cmp_eq_scalar_I8(f1I8, sval_I8, nX, opI1);
      }
      else {
 cmp_eq_mult_scalar_I8(f1I8, nX, svals_I8, num_scalar_vals, opI1);
      }
      break;
    default :
      status = -1; continue;
      break;
    }
    status = conv_I1_to_B(opI1, nX, opB); if ( status < 0 ) { continue; }
    if ( tid == (nT-1) ) {
      if ( nX == 4096 ) {
        memcpy(f2_X+(lb/8), opB, 4096/8);
      }
      else {
        memcpy(f2_X+(lb/8), opB, 2*4096/8);
      }
    }
    else {
      memcpy(f2_X+(lb/8), opB, 4096/8);
    }
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 183, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(tbl_id, f2, ddir_id, opfile, B, -1, &f2_id, &f2_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 188, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 191, "./dir_wr_verbs/udf_eq_B.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 191, "./dir_wr_verbs/udf_eq_B.c"); }; return(-1); } if ( f1_X != ((void *)0) ) { munmap(f1_X, f1_nX); f1_X = ((void *)0); f1_nX = 0; } };
  { if ( ( f2_X == ((void *)0) ) && ( f2_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 192, "./dir_wr_verbs/udf_eq_B.c"); }; return(-1); } if ( ( f2_X != ((void *)0) ) && ( f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 192, "./dir_wr_verbs/udf_eq_B.c"); }; return(-1); } if ( f2_X != ((void *)0) ) { munmap(f2_X, f2_nX); f2_X = ((void *)0); f2_nX = 0; } };
  return(status);
}

canonical_original_code:
int udf_eq_B(char *tbl, char *f1, char *str_scalar, char *f2)
{
  int status = 0;
  long long nR; int tbl_id;
  struct _TBL_REC_TYPE tbl_rec;
  struct _FLD_REC_TYPE f1_rec; struct _FLD_REC_TYPE nn_f1_rec; int f1_id; int nn_f1_id;
  struct _FLD_REC_TYPE f2_rec; int f2_id;
  char opfile[-1];
  long long sval_I8 = 0x7fffffffffffffffLL;
  int sval_I4 = 0x7fffffff;
  short sval_I2 = 0x7fff;
  char sval_I1 = 0x7f;
  float sval_F4 = 3.40282346638528859811704183484516925e+38F;
  double sval_F8 = ((double)1.79769313486231570814527423731704357e+308L);
  long long svals_I8[32];
  int svals_I4[32];
  short svals_I2[32];
  char svals_I1[32];
  float svals_F4[32];
  double svals_F8[32];
  char *f1_X = ((void *)0); unsigned long f1_nX = 0;
  char *f2_X = ((void *)0); unsigned long f2_nX = 0;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_scalar == ((void *)0) ) || ( *str_scalar == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 82, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  zero_string(opfile, 15 +1);
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; } };
  nR = tbl_rec.nR;
  status = is_fld(((void *)0), tbl_id, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec);
  { if ( ( (f1_id) < (0) ) || ( (f1_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 93, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; } };
  status = get_data(f1_rec, &f1_X, &f1_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 94, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_f1_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 95, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  int num_scalar_vals = -1;
  status = break_into_scalars(str_scalar, f1_rec.fldtype, &num_scalar_vals,
          &sval_I8, &sval_I4, &sval_I2, &sval_I1, &sval_F4, &sval_F8,
          svals_I8, svals_I4, svals_I2, svals_I1, svals_F4, svals_F8);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 102, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  long long filesz = -1; int ddir_id = -1;
  status = get_file_size_B(nR, &filesz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 106, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  status = mk_temp_file(opfile, filesz, &ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 107, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, opfile, &f2_X, &f2_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 108, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  if ( ( ( 4096 / 8 ) * 8 ) != 4096 ) { { { fprintf(stderr, "Line %3d of File %s \n", 111, "./dir_wr_verbs/udf_eq_B.c"); }; status = -1 ; goto BYE; }; }
  int nT;
  nT = nR / 4096;
  if ( nT == 0 ) { nT = 1; }
  for ( int tid = 0; tid < nT; tid++ ) {
    long long lb = tid * 4096;
    long long ub = lb + 4096;
    if ( tid == (nT-1) ) { ub = nR; }
    long long nX = ub - lb;
    if ( nX > (2*4096) ) { status = -1; continue; }
    char opI1[-1];
    char opB[-1];
    char *f1I1 = (char *)f1_X; f1I1 += lb;
    short *f1I2 = (short *)f1_X; f1I2 += lb;
    int *f1I4 = (int *)f1_X; f1I4 += lb;
    long long *f1I8 = (long long *)f1_X; f1I8 += lb;
    assign_const_I1(opI1, 2*4096, (char)0);
    switch ( f1_rec.fldtype ) {
    case I1 :
      if ( num_scalar_vals == 1 ) {
 cmp_eq_scalar_I1(f1I1, sval_I1, nX, opI1);
      }
      else {
 cmp_eq_mult_scalar_I1(f1I1, nX, svals_I1, num_scalar_vals, opI1);
      }
      break;
    case I2 :
      if ( num_scalar_vals == 1 ) {
 cmp_eq_scalar_I2(f1I2, sval_I2, nX, opI1);
      }
      else {
 cmp_eq_mult_scalar_I2(f1I2, nX, svals_I2, num_scalar_vals, opI1);
      }
      break;
    case I4 :
      if ( num_scalar_vals == 1 ) {
 cmp_eq_scalar_I4(f1I4, sval_I4, nX, opI1);
      }
      else {
 cmp_eq_mult_scalar_I4(f1I4, nX, svals_I4, num_scalar_vals, opI1);
      }
      break;
    case I8 :
      if ( num_scalar_vals == 1 ) {
 cmp_eq_scalar_I8(f1I8, sval_I8, nX, opI1);
      }
      else {
 cmp_eq_mult_scalar_I8(f1I8, nX, svals_I8, num_scalar_vals, opI1);
      }
      break;
    default :
      status = -1; continue;
      break;
    }
    status = conv_I1_to_B(opI1, nX, opB); if ( status < 0 ) { continue; }
    if ( tid == (nT-1) ) {
      if ( nX == 4096 ) {
        memcpy(f2_X+(lb/8), opB, 4096/8);
      }
      else {
        memcpy(f2_X+(lb/8), opB, 2*4096/8);
      }
    }
    else {
      memcpy(f2_X+(lb/8), opB, 4096/8);
    }
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 183, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(tbl_id, f2, ddir_id, opfile, B, -1, &f2_id, &f2_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 188, "./dir_wr_verbs/udf_eq_B.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 191, "./dir_wr_verbs/udf_eq_B.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 191, "./dir_wr_verbs/udf_eq_B.c"); }; return(-1); } if ( f1_X != ((void *)0) ) { munmap(f1_X, f1_nX); f1_X = ((void *)0); f1_nX = 0; } };
  { if ( ( f2_X == ((void *)0) ) && ( f2_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 192, "./dir_wr_verbs/udf_eq_B.c"); }; return(-1); } if ( ( f2_X != ((void *)0) ) && ( f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 192, "./dir_wr_verbs/udf_eq_B.c"); }; return(-1); } if ( f2_X != ((void *)0) ) { munmap(f2_X, f2_nX); f2_X = ((void *)0); f2_nX = 0; } };
  return(status);
}

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

variable_types:
opfile
char [-1]

variable_types:
filesz
long long

variable_types: nT int

variable_types: tid int

variable_types:
lb
long long

variable_types:
ub
long long

variable_types:
nX
long long

variable_types:
opB
char [-1]

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

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

variable_types: status int

variable_types: minval int

variable_types: maxval int

variable_types:
sum
long long

variable_types:
cnt
long long

variable_types:
i
long long


decompiled_code:
__int64 __fastcall pos_copy_I8_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;
*(_QWORD *)(a5 + 8 * v7++) = *(_QWORD *)(a1 + 8 * v8);
if ( a4 == v7 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 29LL, "./AUX/pos_copy_I8_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;
*(_QWORD *)(a5 + 8 * v7++) = *(_QWORD *)(a1 + 8 * v8);
if ( a4 == v7 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 29LL, "./AUX/pos_copy_I8_I8.c");
return 0xFFFFFFFFLL;
}

original_code:
int
pos_copy_I8_I8(
    long long *f1,
    long long nR1,
    long long *f2,
    long long nR2,
    long long *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_I8_I8.c"); }; status = -1 ; goto BYE; }; }
    long long ival = f1[f1idx];
    f3[i] = ival;
  }
BYE:
  return(status);
}

canonical_original_code:
int pos_copy_I8_I8(long long *f1, long long nR1, long long *f2, long long nR2, long long *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_I8_I8.c"); }; status = -1 ; goto BYE; }; }
    long long ival = f1[f1idx];
    f3[i] = ival;
  }
BYE:
  return(status);
}

variable_types:
ival
long long


decompiled_code:
__int64 __fastcall pos_copy_I4_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;
*(_DWORD *)(a5 + 4 * v6++) = *(_DWORD *)(a1 + 4LL * v7);
if ( a4 == v6 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 29LL, "./AUX/pos_copy_I4_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;
*(_DWORD *)(a5 + 4 * v6++) = *(_DWORD *)(a1 + 4LL * v7);
if ( a4 == v6 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 29LL, "./AUX/pos_copy_I4_I4.c");
return 0xFFFFFFFFLL;
}

original_code:
int
pos_copy_I4_I4(
    int *f1,
    long long nR1,
    int *f2,
    long long nR2,
    int *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_I4_I4.c"); }; status = -1 ; goto BYE; }; }
    int ival = f1[f1idx];
    f3[i] = ival;
  }
BYE:
  return(status);
}

canonical_original_code:
int pos_copy_I4_I4(int *f1, long long nR1, int *f2, long long nR2, int *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_I4_I4.c"); }; status = -1 ; goto BYE; }; }
    int ival = f1[f1idx];
    f3[i] = ival;
  }
BYE:
  return(status);
}

variable_types: ival int