decompiled_code:
__int64 __fastcall t1f1t2f2opt3f3(const char *a1, _BYTE *a2, const char *a3, _BYTE *a4, const char *a5, __int64 a6, char *s2, _BYTE *a8)
{
__int64 v11; // rdx
int v12; // er13
__int64 v13; // rbp
__int64 v14; // r14
int v15; // ebx
int v16; // eax
__int64 v17; // r10
__int64 v18; // r15
__int64 v20; // rdx
int v21; // eax
int v22; // eax
int v23; // eax
__int64 v24; // rdx
int v25; // eax
__int64 v26; // r10
int v27; // eax
const char *v28; // rsi
__int64 v30; // [rsp+8h] [rbp-3E0h]
__int64 v31; // [rsp+8h] [rbp-3E0h]
unsigned int v32; // [rsp+1Ch] [rbp-3CCh] BYREF
unsigned int v33; // [rsp+20h] [rbp-3C8h] BYREF
unsigned int v34; // [rsp+24h] [rbp-3C4h] BYREF
int v35; // [rsp+28h] [rbp-3C0h] BYREF
int v36; // [rsp+2Ch] [rbp-3BCh] BYREF
unsigned int v37; // [rsp+30h] [rbp-3B8h] BYREF
int v38; // [rsp+34h] [rbp-3B4h] BYREF
int v39; // [rsp+38h] [rbp-3B0h] BYREF
int v40; // [rsp+3Ch] [rbp-3ACh] BYREF
unsigned int v41; // [rsp+40h] [rbp-3A8h] BYREF
unsigned int v42; // [rsp+44h] [rbp-3A4h] BYREF
void *addr; // [rsp+48h] [rbp-3A0h] BYREF
size_t len; // [rsp+50h] [rbp-398h] BYREF
void *v45; // [rsp+58h] [rbp-390h] BYREF
size_t v46; // [rsp+60h] [rbp-388h] BYREF
void *v47; // [rsp+68h] [rbp-380h] BYREF
size_t v48; // [rsp+70h] [rbp-378h] BYREF
__int64 v49; // [rsp+78h] [rbp-370h] BYREF
char s[32]; // [rsp+80h] [rbp-368h] BYREF
__int64 v51[6]; // [rsp+A0h] [rbp-348h] BYREF
__int64 v52[6]; // [rsp+D0h] [rbp-318h] BYREF
char v53[48]; // [rsp+100h] [rbp-2E8h] BYREF
__int64 v54; // [rsp+130h] [rbp-2B8h] BYREF
__int64 v55; // [rsp+148h] [rbp-2A0h]
__int64 v56; // [rsp+150h] [rbp-298h]
char v57[128]; // [rsp+1B0h] [rbp-238h] BYREF
__int64 v58; // [rsp+230h] [rbp-1B8h] BYREF
__int64 v59; // [rsp+248h] [rbp-1A0h]
__int64 v60; // [rsp+250h] [rbp-198h]
char v61[128]; // [rsp+2B0h] [rbp-138h] BYREF
__int64 v62[4]; // [rsp+330h] [rbp-B8h] BYREF
int v63; // [rsp+350h] [rbp-98h]

addr = 0LL;
len = 0LL;
v45 = 0LL;
v46 = 0LL;
v47 = 0LL;
v48 = 0LL;
v32 = 0x80000000;
v33 = 0x80000000;
v34 = 0x80000000;
v35 = 0x80000000;
v36 = 0x80000000;
v37 = 0x80000000;
v38 = 0x80000000;
v39 = 0x80000000;
v49 = 0xFFFFFFFF80000000LL;
v40 = 0x7FFFFFFF;
v41 = -1;
v42 = -1;
if ( !a1 || !*a1 )
{
v11 = 63LL;
goto LABEL_43;
}
if ( !a2 || !*a2 )
{
v11 = 64LL;
goto LABEL_43;
}
if ( !a3 || !*a3 )
{
v11 = 65LL;
goto LABEL_43;
}
if ( !a4 || !*a4 )
{
v11 = 66LL;
goto LABEL_43;
}
if ( !a5 || !*a5 )
{
v11 = 67LL;
goto LABEL_43;
}
if ( !a8 || !*a8 )
{
v11 = 68LL;
goto LABEL_43;
}
if ( !strcmp(a1, s2) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 69LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 70LL;
if ( !*s2 )
goto LABEL_43;
if ( !strcmp(a3, s2) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 71LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v12 = is_tbl(a1, &v32, v51);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 75LL;
if ( (v32 & 0x80000000) != 0 )
goto LABEL_43;
v13 = v51[0];
v12 = is_fld(0LL, v32, a2, &v35, &v54, &v38, v57);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 79LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 80LL;
if ( v35 < 0 )
goto LABEL_43;
v12 = get_data(&addr, &len, 0LL, "t1f1t2f2opt3f3.c");
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v12 = is_tbl(a3, &v33, v52);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 84LL;
if ( (v33 & 0x80000000) != 0 )
goto LABEL_43;
v14 = v52[0];
v12 = is_fld(0LL, v33, a4, &v36, &v58, &v39, v61);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 89LL;
if ( v36 < 0 )
{
LABEL_43:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v11, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v12 = get_data(&v45, &v46, 0LL, "t1f1t2f2opt3f3.c");
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 93LL;
if ( HIDWORD(v55) != 1 )
goto LABEL_43;
v11 = 94LL;
if ( HIDWORD(v59) != 1 )
goto LABEL_43;
if ( v38 >= 0 )
{
v11 = 96LL;
goto LABEL_43;
}
if ( v39 >= 0 )
{
v11 = 97LL;
goto LABEL_43;
}
v15 = v56;
if ( (_DWORD)v56 != (_DWORD)v60 )
{
v11 = 98LL;
goto LABEL_43;
}
if ( (unsigned int)(v56 - 4) > 1 )
{
v11 = 101LL;
goto LABEL_43;
}
v12 = get_fld_sz((unsigned int)v56, &v40, 94LL, "t1f1t2f2opt3f3.c");
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 104LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v16 = strcmp(a5, "intersection");
v17 = a6;
if ( v16 )
{
v21 = strcmp(a5, "a_minus_b");
v17 = a6;
if ( v21 )
{
v22 = strcmp(a5, "union");
v17 = a6;
if ( v22 )
{
v23 = strcmp(a5, "pvalcalc");
v17 = a6;
if ( v23 )
{
v11 = 117LL;
goto LABEL_43;
}
}
v18 = v13 + v14;
}
else
{
v18 = v13;
}
}
else
{
v18 = v14;
if ( v13 <= v14 )
v18 = v13;
}
v30 = v17;
v12 = mk_temp_file(v18 * v40, &v41, &v42);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 121LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v12 = q_mmap(v41, v42, &v47, &v48, 1LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 122LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
if ( !strcmp(a5, "intersection") )
{
if ( (_DWORD)v56 == 4 )
{
v12 = intersection_I4(addr, v13, v45, v14, v47, &v49);
}
else
{
if ( (_DWORD)v56 != 5 )
{
v11 = 134LL;
goto LABEL_43;
}
v12 = intersection_I8(addr, v13, v45, v14, v47, &v49);
}
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 136LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
}
else if ( !strcmp(a5, "a_minus_b") )
{
if ( (_DWORD)v56 == 4 )
{
a_minus_b_I4(addr, v13, v45, v14, v47, &v49);
}
else
{
if ( (_DWORD)v56 != 5 )
{
v11 = 146LL;
goto LABEL_43;
}
a_minus_b_I8(addr, v13, v45, v14, v47, &v49);
}
}
else
{
v25 = strcmp(a5, "union");
v26 = v30;
if ( v25 )
{
v27 = strcmp(a5, "pvalcalc");
v26 = v30;
if ( v27 )
{
v11 = 172LL;
goto LABEL_43;
}
}
v28 = "pvalcalc";
v31 = v26;
v62[0] = 0LL;
if ( !strcmp(a5, "pvalcalc") )
{
v28 = "mask=[";
v53[0] = 0;
extract_UI8(v31, "mask=[", "]", v62, v53);
if ( v53[0] )
{
v11 = 156LL;
goto LABEL_43;
}
}
if ( (_DWORD)v56 == 4 )
{
v12 = union_I4(addr, v13, v45, v14, v47, &v49, v62[0], v28);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 162LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
}
else
{
if ( (_DWORD)v56 != 5 )
{
v11 = 169LL;
goto LABEL_43;
}
v12 = union_I8(addr, v13, v45, v14, v47, &v49, v62[0], 5LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 167LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
}
}
if ( v47 )
{
if ( v48 )
{
munmap(v47, v48);
v47 = 0LL;
v48 = 0LL;
goto LABEL_89;
}
LABEL_109:
v20 = 173LL;
goto LABEL_57;
}
if ( v48 )
goto LABEL_109;
LABEL_89:
v24 = v49;
if ( v49 )
{
if ( v49 < v18 )
{
v12 = q_trunc(v41, v42, v40 * v49);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 180LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v24 = v49;
}
else if ( v49 > v18 )
{
v11 = 183LL;
goto LABEL_43;
}
sprintf(s, "%lld", v24);
v12 = add_tbl(s2, s, &v34, v53);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 187LL, "t1f1t2f2opt3f3.c");
}
else
{
zero_fld_rec(v62);
v63 = v15;
v12 = add_fld(v34, a8, v41, v42, &v37, v62);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 189LL, "t1f1t2f2opt3f3.c");
}
else if ( !strcmp(a5, "union") || !strcmp(a5, "intersection") || !strcmp(a5, "a_minus_b") )
{
v12 = int_set_meta(v34, v37, "srttype", "ascending", 1LL);
if ( v12 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 193LL, "t1f1t2f2opt3f3.c");
}
}
}
else
{
v12 = q_delete(v41, v42);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 175LL, "t1f1t2f2opt3f3.c");
}
else
{
v12 = 0;
v42 = -1;
v41 = -1;
fprintf(stderr, "Line %3d of File %s \n", 177LL, "t1f1t2f2opt3f3.c");
}
}
LABEL_44:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_47;
}
LABEL_56:
v20 = 197LL;
LABEL_57:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v20, "t1f1t2f2opt3f3.c");
return (unsigned int)v12;
}
if ( len )
goto LABEL_56;
LABEL_47:
if ( v45 )
{
if ( v46 )
{
munmap(v45, v46);
v45 = 0LL;
v46 = 0LL;
goto LABEL_50;
}
goto LABEL_59;
}
if ( v46 )
{
LABEL_59:
v20 = 198LL;
goto LABEL_57;
}
LABEL_50:
if ( !v47 )
{
if ( !v48 )
return (unsigned int)v12;
goto LABEL_61;
}
if ( !v48 )
{
LABEL_61:
v20 = 199LL;
goto LABEL_57;
}
munmap(v47, v48);
return (unsigned int)v12;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, _BYTE *a2, const char *a3, _BYTE *a4, const char *a5, __int64 a6, char *s2, _BYTE *a8)
{
__int64 v11; // rdx
int v12; // er13
__int64 v13; // rbp
__int64 v14; // r14
int v15; // ebx
int v16; // eax
__int64 v17; // r10
__int64 v18; // r15
__int64 v20; // rdx
int v21; // eax
int v22; // eax
int v23; // eax
__int64 v24; // rdx
int v25; // eax
__int64 v26; // r10
int v27; // eax
const char *v28; // rsi
__int64 v30; // [rsp+8h] [rbp-3E0h]
__int64 v31; // [rsp+8h] [rbp-3E0h]
unsigned int v32; // [rsp+1Ch] [rbp-3CCh] BYREF
unsigned int v33; // [rsp+20h] [rbp-3C8h] BYREF
unsigned int v34; // [rsp+24h] [rbp-3C4h] BYREF
int v35; // [rsp+28h] [rbp-3C0h] BYREF
int v36; // [rsp+2Ch] [rbp-3BCh] BYREF
unsigned int v37; // [rsp+30h] [rbp-3B8h] BYREF
int v38; // [rsp+34h] [rbp-3B4h] BYREF
int v39; // [rsp+38h] [rbp-3B0h] BYREF
int v40; // [rsp+3Ch] [rbp-3ACh] BYREF
unsigned int v41; // [rsp+40h] [rbp-3A8h] BYREF
unsigned int v42; // [rsp+44h] [rbp-3A4h] BYREF
void *addr; // [rsp+48h] [rbp-3A0h] BYREF
size_t len; // [rsp+50h] [rbp-398h] BYREF
void *v45; // [rsp+58h] [rbp-390h] BYREF
size_t v46; // [rsp+60h] [rbp-388h] BYREF
void *v47; // [rsp+68h] [rbp-380h] BYREF
size_t v48; // [rsp+70h] [rbp-378h] BYREF
__int64 v49; // [rsp+78h] [rbp-370h] BYREF
char s[32]; // [rsp+80h] [rbp-368h] BYREF
__int64 v51[6]; // [rsp+A0h] [rbp-348h] BYREF
__int64 v52[6]; // [rsp+D0h] [rbp-318h] BYREF
char v53[48]; // [rsp+100h] [rbp-2E8h] BYREF
__int64 v54; // [rsp+130h] [rbp-2B8h] BYREF
__int64 v55; // [rsp+148h] [rbp-2A0h]
__int64 v56; // [rsp+150h] [rbp-298h]
char v57[128]; // [rsp+1B0h] [rbp-238h] BYREF
__int64 v58; // [rsp+230h] [rbp-1B8h] BYREF
__int64 v59; // [rsp+248h] [rbp-1A0h]
__int64 v60; // [rsp+250h] [rbp-198h]
char v61[128]; // [rsp+2B0h] [rbp-138h] BYREF
__int64 v62[4]; // [rsp+330h] [rbp-B8h] BYREF
int v63; // [rsp+350h] [rbp-98h]

addr = 0LL;
len = 0LL;
v45 = 0LL;
v46 = 0LL;
v47 = 0LL;
v48 = 0LL;
v32 = 0x80000000;
v33 = 0x80000000;
v34 = 0x80000000;
v35 = 0x80000000;
v36 = 0x80000000;
v37 = 0x80000000;
v38 = 0x80000000;
v39 = 0x80000000;
v49 = 0xFFFFFFFF80000000LL;
v40 = 0x7FFFFFFF;
v41 = -1;
v42 = -1;
if ( !a1 || !*a1 )
{
v11 = 63LL;
goto LABEL_43;
}
if ( !a2 || !*a2 )
{
v11 = 64LL;
goto LABEL_43;
}
if ( !a3 || !*a3 )
{
v11 = 65LL;
goto LABEL_43;
}
if ( !a4 || !*a4 )
{
v11 = 66LL;
goto LABEL_43;
}
if ( !a5 || !*a5 )
{
v11 = 67LL;
goto LABEL_43;
}
if ( !a8 || !*a8 )
{
v11 = 68LL;
goto LABEL_43;
}
if ( !strcmp(a1, s2) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 69LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 70LL;
if ( !*s2 )
goto LABEL_43;
if ( !strcmp(a3, s2) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 71LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v12 = is_tbl(a1, &v32, v51);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 75LL;
if ( (v32 & 0x80000000) != 0 )
goto LABEL_43;
v13 = v51[0];
v12 = is_fld(0LL, v32, a2, &v35, &v54, &v38, v57);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 79LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 80LL;
if ( v35 < 0 )
goto LABEL_43;
v12 = get_data(&addr, &len, 0LL, "t1f1t2f2opt3f3.c");
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v12 = is_tbl(a3, &v33, v52);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 84LL;
if ( (v33 & 0x80000000) != 0 )
goto LABEL_43;
v14 = v52[0];
v12 = is_fld(0LL, v33, a4, &v36, &v58, &v39, v61);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 89LL;
if ( v36 < 0 )
{
LABEL_43:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v11, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v12 = get_data(&v45, &v46, 0LL, "t1f1t2f2opt3f3.c");
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v11 = 93LL;
if ( HIDWORD(v55) != 1 )
goto LABEL_43;
v11 = 94LL;
if ( HIDWORD(v59) != 1 )
goto LABEL_43;
if ( v38 >= 0 )
{
v11 = 96LL;
goto LABEL_43;
}
if ( v39 >= 0 )
{
v11 = 97LL;
goto LABEL_43;
}
v15 = v56;
if ( (_DWORD)v56 != (_DWORD)v60 )
{
v11 = 98LL;
goto LABEL_43;
}
if ( (unsigned int)(v56 - 4) > 1 )
{
v11 = 101LL;
goto LABEL_43;
}
v12 = get_fld_sz((unsigned int)v56, &v40, 94LL, "t1f1t2f2opt3f3.c");
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 104LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v16 = strcmp(a5, "intersection");
v17 = a6;
if ( v16 )
{
v21 = strcmp(a5, "a_minus_b");
v17 = a6;
if ( v21 )
{
v22 = strcmp(a5, "union");
v17 = a6;
if ( v22 )
{
v23 = strcmp(a5, "pvalcalc");
v17 = a6;
if ( v23 )
{
v11 = 117LL;
goto LABEL_43;
}
}
v18 = v13 + v14;
}
else
{
v18 = v13;
}
}
else
{
v18 = v14;
if ( v13 <= v14 )
v18 = v13;
}
v30 = v17;
v12 = mk_temp_file(v18 * v40, &v41, &v42);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 121LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v12 = q_mmap(v41, v42, &v47, &v48, 1LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 122LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
if ( !strcmp(a5, "intersection") )
{
if ( (_DWORD)v56 == 4 )
{
v12 = intersection_I4(addr, v13, v45, v14, v47, &v49);
}
else
{
if ( (_DWORD)v56 != 5 )
{
v11 = 134LL;
goto LABEL_43;
}
v12 = intersection_I8(addr, v13, v45, v14, v47, &v49);
}
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 136LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
}
else if ( !strcmp(a5, "a_minus_b") )
{
if ( (_DWORD)v56 == 4 )
{
a_minus_b_I4(addr, v13, v45, v14, v47, &v49);
}
else
{
if ( (_DWORD)v56 != 5 )
{
v11 = 146LL;
goto LABEL_43;
}
a_minus_b_I8(addr, v13, v45, v14, v47, &v49);
}
}
else
{
v25 = strcmp(a5, "union");
v26 = v30;
if ( v25 )
{
v27 = strcmp(a5, "pvalcalc");
v26 = v30;
if ( v27 )
{
v11 = 172LL;
goto LABEL_43;
}
}
v28 = "pvalcalc";
v31 = v26;
v62[0] = 0LL;
if ( !strcmp(a5, "pvalcalc") )
{
v28 = "mask=[";
v53[0] = 0;
extract_UI8(v31, "mask=[", "]", v62, v53);
if ( v53[0] )
{
v11 = 156LL;
goto LABEL_43;
}
}
if ( (_DWORD)v56 == 4 )
{
v12 = union_I4(addr, v13, v45, v14, v47, &v49, v62[0], v28);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 162LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
}
else
{
if ( (_DWORD)v56 != 5 )
{
v11 = 169LL;
goto LABEL_43;
}
v12 = union_I8(addr, v13, v45, v14, v47, &v49, v62[0], 5LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 167LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
}
}
if ( v47 )
{
if ( v48 )
{
munmap(v47, v48);
v47 = 0LL;
v48 = 0LL;
goto LABEL_89;
}
LABEL_109:
v20 = 173LL;
goto LABEL_57;
}
if ( v48 )
goto LABEL_109;
LABEL_89:
v24 = v49;
if ( v49 )
{
if ( v49 < v18 )
{
v12 = q_trunc(v41, v42, v40 * v49);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 180LL, "t1f1t2f2opt3f3.c");
goto LABEL_44;
}
v24 = v49;
}
else if ( v49 > v18 )
{
v11 = 183LL;
goto LABEL_43;
}
sprintf(s, "%lld", v24);
v12 = add_tbl(s2, s, &v34, v53);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 187LL, "t1f1t2f2opt3f3.c");
}
else
{
zero_fld_rec(v62);
v63 = v15;
v12 = add_fld(v34, a8, v41, v42, &v37, v62);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 189LL, "t1f1t2f2opt3f3.c");
}
else if ( !strcmp(a5, "union") || !strcmp(a5, "intersection") || !strcmp(a5, "a_minus_b") )
{
v12 = int_set_meta(v34, v37, "srttype", "ascending", 1LL);
if ( v12 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 193LL, "t1f1t2f2opt3f3.c");
}
}
}
else
{
v12 = q_delete(v41, v42);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 175LL, "t1f1t2f2opt3f3.c");
}
else
{
v12 = 0;
v42 = -1;
v41 = -1;
fprintf(stderr, "Line %3d of File %s \n", 177LL, "t1f1t2f2opt3f3.c");
}
}
LABEL_44:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_47;
}
LABEL_56:
v20 = 197LL;
LABEL_57:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v20, "t1f1t2f2opt3f3.c");
return (unsigned int)v12;
}
if ( len )
goto LABEL_56;
LABEL_47:
if ( v45 )
{
if ( v46 )
{
munmap(v45, v46);
v45 = 0LL;
v46 = 0LL;
goto LABEL_50;
}
goto LABEL_59;
}
if ( v46 )
{
LABEL_59:
v20 = 198LL;
goto LABEL_57;
}
LABEL_50:
if ( !v47 )
{
if ( !v48 )
return (unsigned int)v12;
goto LABEL_61;
}
if ( !v48 )
{
LABEL_61:
v20 = 199LL;
goto LABEL_57;
}
munmap(v47, v48);
return (unsigned int)v12;
}

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

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

variable_types:
op
char *

variable_types:
options
char *

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

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

variable_types:
filesz
unsigned long

variable_types: fileno int

variable_types:
mask
unsigned long long

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

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


repo: linkedin/datacl

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

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

variable_types:
lb
long long

variable_types:
ub
long long

variable_types: status int

variable_types:
cnt
long long

variable_types:
val
long long

return_type: int


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

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

variable_types:
nR
long long

variable_types:
out
unsigned long long *

variable_types:
outv
long long

variable_types:
i
long long

return_type: void


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

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

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

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

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

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

variable_types: m int

variable_types: rho int

variable_types: loc int


decompiled_code:
__int64 __fastcall intersection_I8(_QWORD *a1, __int64 a2, _QWORD *a3, __int64 a4, _QWORD *a5, _QWORD *a6)
{
_QWORD *v6; // r10
_QWORD *v8; // rsi
__int64 v10; // rcx
__int64 v11; // r11

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

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, __int64 a2, _QWORD *a3, __int64 a4, _QWORD *a5, _QWORD *a6)
{
_QWORD *v6; // r10
_QWORD *v8; // rsi
__int64 v10; // rcx
__int64 v11; // r11

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

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

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


Output

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

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

variable_types:
siz
long long

variable_types: b int

variable_types:
k
long long

variable_types: ii int

variable_types:
jj
long long


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

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

variable_types:
out
long long *


decompiled_code:
__int64 __fastcall count_I2(__int16 *a1, __int64 a2, __int64 a3, int a4)
{
__int16 *v6; // r8
__int64 v7; // rcx

if ( a2 <= 0 )
return 0LL;
v6 = &a1[a2];
while ( 1 )
{
v7 = *a1;
if ( (int)v7 >= a4 || (v7 & 0x8000u) != 0LL )
break;
++a1;
++*(_QWORD *)(a3 + 8 * v7);
if ( v6 == a1 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 30LL, "./AUX/count_I2.c");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 *a1, __int64 a2, __int64 a3, int a4)
{
__int16 *v6; // r8
__int64 v7; // rcx

if ( a2 <= 0 )
return 0LL;
v6 = &a1[a2];
while ( 1 )
{
v7 = *a1;
if ( (int)v7 >= a4 || (v7 & 0x8000u) != 0LL )
break;
++a1;
++*(_QWORD *)(a3 + 8 * v7);
if ( v6 == a1 )
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 30LL, "./AUX/count_I2.c");
return 0xFFFFFFFFLL;
}

original_code:
int
count_I2(
  short *in,
  long long n,
  long long * restrict cnt,
  int n_out
  )
{
  int status = 0;
  for ( long long i = 0; i < n; i++ ) {
    short idx = in[i];
    int idxI4 = (int)idx;
    if ( ( idx < 0 ) || ( idx >= n_out ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "./AUX/count_I2.c"); }; status = -1 ; goto BYE; }; }
    cnt[idxI4]++;
  }
 BYE:
  return(status);
}

canonical_original_code:
int count_I2(short *in, long long n, long long *cnt, int n_out)
{
  int status = 0;
  for ( long long i = 0; i < n; i++ ) {
    short idx = in[i];
    int idxI4 = (int)idx;
    if ( ( idx < 0 ) || ( idx >= n_out ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "./AUX/count_I2.c"); }; status = -1 ; goto BYE; }; }
    cnt[idxI4]++;
  }
 BYE:
  return(status);
}

variable_types:
in
short *

variable_types:
n
long long

variable_types:
cnt
long long *

variable_types: idx short


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

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

variable_types:
lb
long long

variable_types:
ub
long long

variable_types: status int

variable_types:
cnt
long long

variable_types:
val
long long


decompiled_code:
__int64 __fastcall open_temp_file(char *path, char *a2, char *a3, unsigned __int64 a4)
{
int v6; // eax
int v7; // er12
__int64 v9; // rdx
unsigned __int64 v10[6]; // [rsp+8h] [rbp-30h] BYREF

if ( !path )
{
v9 = 54LL;
goto LABEL_12;
}
if ( !a2 )
{
v9 = 55LL;
goto LABEL_12;
}
if ( !a3 )
{
v9 = 56LL;
goto LABEL_12;
}
if ( a4 )
{
v7 = avail_space(a2, v10);
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "./dir_dbutils/open_temp_file.c");
return (unsigned int)v7;
}
if ( v10[0] <= a4 )
{
fprintf(stderr, "Space (%lld bytes) in directory [%s] not available \n", a4, a2);
v9 = 65LL;
LABEL_12:
v7 = -1;
fprintf(stderr, "Line %3d of File %s \n", v9, "./dir_dbutils/open_temp_file.c");
return (unsigned int)v7;
}
}
if ( chdir(a2) )
{
fprintf(stderr, "Directory [%s] not accessible \n", a2);
v9 = 72LL;
goto LABEL_12;
}
strcpy(a3, "_tempf_XXXXXX");
v6 = mkstemp(a3);
close(v6);
v7 = chdir(path);
if ( v7 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 80LL, "./dir_dbutils/open_temp_file.c");
return (unsigned int)v7;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *path, char *a2, char *a3, unsigned __int64 a4)
{
int v6; // eax
int v7; // er12
__int64 v9; // rdx
unsigned __int64 v10[6]; // [rsp+8h] [rbp-30h] BYREF

if ( !path )
{
v9 = 54LL;
goto LABEL_12;
}
if ( !a2 )
{
v9 = 55LL;
goto LABEL_12;
}
if ( !a3 )
{
v9 = 56LL;
goto LABEL_12;
}
if ( a4 )
{
v7 = func0(a2, v10);
if ( v7 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "./dir_dbutils/open_temp_file.c");
return (unsigned int)v7;
}
if ( v10[0] <= a4 )
{
fprintf(stderr, "Space (%lld bytes) in directory [%s] not available \n", a4, a2);
v9 = 65LL;
LABEL_12:
v7 = -1;
fprintf(stderr, "Line %3d of File %s \n", v9, "./dir_dbutils/open_temp_file.c");
return (unsigned int)v7;
}
}
if ( chdir(a2) )
{
fprintf(stderr, "Directory [%s] not accessible \n", a2);
v9 = 72LL;
goto LABEL_12;
}
strcpy(a3, "_tempf_XXXXXX");
v6 = mkstemp(a3);
close(v6);
v7 = chdir(path);
if ( v7 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 80LL, "./dir_dbutils/open_temp_file.c");
return (unsigned int)v7;
}

original_code:
int
open_temp_file(
        char *cwd,
        char *dir,
        char *fname,
        size_t filesize
        )
{
  int status = 0;
  if ( cwd == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; }; }
  if ( dir == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; }; }
  if ( fname == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; }; }
  if ( filesize > 0 ) {
    size_t space_available;
    status = avail_space(dir, &space_available); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "./dir_dbutils/open_temp_file.c"); }; status = (status) ; goto BYE; } } };
    if ( space_available <= filesize ) {
      fprintf(stderr, "Space (%lld bytes) in directory [%s] not available \n",
       (long long)filesize, dir);
      { { fprintf(stderr, "Line %3d of File %s \n", 65, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; };
    }
  }
  status = chdir(dir);
  if ( status != 0 ) {
    fprintf(stderr, "Directory [%s] not accessible \n", dir);
    { { fprintf(stderr, "Line %3d of File %s \n", 72, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; };
  }
  strcpy(fname, "_tempf_XXXXXX");
  int fd = mkstemp(fname);
  close(fd);
  status = chdir(cwd);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "./dir_dbutils/open_temp_file.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  return(status);
}

canonical_original_code:
int open_temp_file(char *cwd, char *dir, char *fname, unsigned long filesize)
{
  int status = 0;
  if ( cwd == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; }; }
  if ( dir == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; }; }
  if ( fname == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; }; }
  if ( filesize > 0 ) {
    unsigned long space_available;
    status = avail_space(dir, &space_available); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "./dir_dbutils/open_temp_file.c"); }; status = (status) ; goto BYE; } } };
    if ( space_available <= filesize ) {
      fprintf(stderr, "Space (%lld bytes) in directory [%s] not available \n",
       (long long)filesize, dir);
      { { fprintf(stderr, "Line %3d of File %s \n", 65, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; };
    }
  }
  status = chdir(dir);
  if ( status != 0 ) {
    fprintf(stderr, "Directory [%s] not accessible \n", dir);
    { { fprintf(stderr, "Line %3d of File %s \n", 72, "./dir_dbutils/open_temp_file.c"); }; status = -1 ; goto BYE; };
  }
  strcpy(fname, "_tempf_XXXXXX");
  int fd = mkstemp(fname);
  close(fd);
  status = chdir(cwd);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "./dir_dbutils/open_temp_file.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  return(status);
}

variable_types:
cwd
char *

variable_types:
dir
char *

variable_types:
fname
char *

variable_types:
filesize
unsigned long

variable_types: fd int


decompiled_code:
__int64 __fastcall avail_space(const char *a1, _QWORD *a2)
{
int v2; // er12
struct statvfs v4; // [rsp+0h] [rbp-88h] BYREF

v2 = statvfs(a1, &v4);
if ( v2 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 32LL, "./dir_dbutils/open_temp_file.c");
else
*a2 = v4.f_bavail * v4.f_bsize;
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, _QWORD *a2)
{
int v2; // er12
struct statvfs v4; // [rsp+0h] [rbp-88h] BYREF

v2 = statvfs(a1, &v4);
if ( v2 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 32LL, "./dir_dbutils/open_temp_file.c");
else
*a2 = v4.f_bavail * v4.f_bsize;
return (unsigned int)v2;
}

original_code:
int
avail_space(
     char *dir,
     size_t *ptr_avail_space
     )
{
  int status = 0;
  struct statvfs sbuf;
  status = statvfs(dir , &sbuf); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "./dir_dbutils/open_temp_file.c"); }; status = (status) ; goto BYE; } } };
  *ptr_avail_space = sbuf.f_bsize * sbuf.f_bavail;
 BYE:
  return(status);
}

canonical_original_code:
int avail_space(char *dir, unsigned long *ptr_avail_space)
{
  int status = 0;
  struct statvfs sbuf;
  status = statvfs(dir , &sbuf); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "./dir_dbutils/open_temp_file.c"); }; status = (status) ; goto BYE; } } };
  *ptr_avail_space = sbuf.f_bsize * sbuf.f_bavail;
 BYE:
  return(status);
}

variable_types: struct statvfs { unsigned long f_bsize; unsigned long f_frsize; unsigned long f_blocks; unsigned long f_bfree; unsigned long f_bavail; unsigned long f_files; unsigned long f_ffree; unsigned long f_favail; unsigned long f_fsid; unsigned long f_flag; unsigned long f_namemax; int __f_spare[6]; }


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

canonical_original_code:
void bwise_and2_I1(char *in1, char *in2, long long nR, char *out)
{
  char inv1; char inv2; char 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
char *

variable_types: outv char

variable_types:
i
long long


decompiled_code:
__int64 __fastcall is_nn_fld(_BYTE *a1, _BYTE *a2, _DWORD *a3, char *a4)
{
int v6; // er12
__int64 v7; // rdx
__int64 v9; // rdx
int v10; // [rsp+4h] [rbp-2A4h] BYREF
int v11; // [rsp+8h] [rbp-2A0h] BYREF
int v12; // [rsp+Ch] [rbp-29Ch] BYREF
char v13[176]; // [rsp+10h] [rbp-298h] BYREF
char v14[224]; // [rsp+C0h] [rbp-1E8h] BYREF
char v15[264]; // [rsp+1A0h] [rbp-108h] BYREF

if ( !a1 || !*a1 )
{
v9 = 34LL;
goto LABEL_19;
}
if ( !a2 || !*a2 )
{
v9 = 35LL;
LABEL_19:
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", v9, "./dir_ro_verbs/is_nn_fld.c");
return (unsigned int)v6;
}
v6 = is_tbl(a1, &v10, v13);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "./dir_ro_verbs/is_nn_fld.c");
return (unsigned int)v6;
}
if ( v10 < 0 || v10 >= g_n_tbl )
{
v9 = 38LL;
goto LABEL_19;
}
v6 = is_fld(0LL, (unsigned int)v10, a2, &v11, v14, &v12, v15);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "./dir_ro_verbs/is_nn_fld.c");
return (unsigned int)v6;
}
if ( v11 < 0 || v11 >= g_n_fld )
{
v9 = 41LL;
goto LABEL_19;
}
v7 = *(unsigned int *)(g_flds + 224LL * v11 + 20);
v12 = v7;
if ( (int)v7 < 0 )
{
strcpy(a4, "0,-1");
}
else
{
sprintf(a4, "1,%d", v7);
LODWORD(v7) = v12;
}
*a3 = v7;
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, _BYTE *a2, _DWORD *a3, char *a4)
{
int v6; // er12
__int64 v7; // rdx
__int64 v9; // rdx
int v10; // [rsp+4h] [rbp-2A4h] BYREF
int v11; // [rsp+8h] [rbp-2A0h] BYREF
int v12; // [rsp+Ch] [rbp-29Ch] BYREF
char v13[176]; // [rsp+10h] [rbp-298h] BYREF
char v14[224]; // [rsp+C0h] [rbp-1E8h] BYREF
char v15[264]; // [rsp+1A0h] [rbp-108h] BYREF

if ( !a1 || !*a1 )
{
v9 = 34LL;
goto LABEL_19;
}
if ( !a2 || !*a2 )
{
v9 = 35LL;
LABEL_19:
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", v9, "./dir_ro_verbs/is_nn_fld.c");
return (unsigned int)v6;
}
v6 = is_tbl(a1, &v10, v13);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "./dir_ro_verbs/is_nn_fld.c");
return (unsigned int)v6;
}
if ( v10 < 0 || v10 >= g_n_tbl )
{
v9 = 38LL;
goto LABEL_19;
}
v6 = is_fld(0LL, (unsigned int)v10, a2, &v11, v14, &v12, v15);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "./dir_ro_verbs/is_nn_fld.c");
return (unsigned int)v6;
}
if ( v11 < 0 || v11 >= g_n_fld )
{
v9 = 41LL;
goto LABEL_19;
}
v7 = *(unsigned int *)(g_flds + 224LL * v11 + 20);
v12 = v7;
if ( (int)v7 < 0 )
{
strcpy(a4, "0,-1");
}
else
{
sprintf(a4, "1,%d", v7);
LODWORD(v7) = v12;
}
*a3 = v7;
return (unsigned int)v6;
}

original_code:
int
is_nn_fld(
 char *tbl,
 char *fld,
 int *ptr_nn_fld_id,
 char *str_result
 )
{
  int status = 0;
  int tbl_id; TBL_REC_TYPE tbl_rec;
  int fld_id; FLD_REC_TYPE fld_rec;
  int nn_fld_id; FLD_REC_TYPE nn_fld_rec;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "./dir_ro_verbs/is_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "./dir_ro_verbs/is_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "./dir_ro_verbs/is_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "./dir_ro_verbs/is_nn_fld.c"); }; status = -1 ; goto BYE; }; } };
  status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec, &nn_fld_id, &nn_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "./dir_ro_verbs/is_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "./dir_ro_verbs/is_nn_fld.c"); }; status = -1 ; goto BYE; }; } };
  nn_fld_id = g_flds[fld_id].nn_fld_id;
  if ( nn_fld_id >= 0 ) {
    sprintf(str_result, "1,%d", nn_fld_id);
  }
  else {
    strcpy(str_result, "0,-1");
  }
  *ptr_nn_fld_id = nn_fld_id;
 BYE:
  return(status);
}

canonical_original_code:
int is_nn_fld(char *tbl, char *fld, int *ptr_nn_fld_id, char *str_result)
{
  int status = 0;
  int tbl_id; struct _TBL_REC_TYPE tbl_rec;
  int fld_id; struct _FLD_REC_TYPE fld_rec;
  int nn_fld_id; struct _FLD_REC_TYPE nn_fld_rec;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "./dir_ro_verbs/is_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "./dir_ro_verbs/is_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "./dir_ro_verbs/is_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "./dir_ro_verbs/is_nn_fld.c"); }; status = -1 ; goto BYE; }; } };
  status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec, &nn_fld_id, &nn_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "./dir_ro_verbs/is_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "./dir_ro_verbs/is_nn_fld.c"); }; status = -1 ; goto BYE; }; } };
  nn_fld_id = g_flds[fld_id].nn_fld_id;
  if ( nn_fld_id >= 0 ) {
    sprintf(str_result, "1,%d", nn_fld_id);
  }
  else {
    strcpy(str_result, "0,-1");
  }
  *ptr_nn_fld_id = nn_fld_id;
 BYE:
  return(status);
}

variable_types:
tbl
char *

variable_types:
fld
char *

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

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

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


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

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

variable_types:
out
long long *

variable_types:
outv
long long


decompiled_code:
__int64 __fastcall find_largest_leq_I8(__int64 a1, __int64 a2, __int64 a3, __int64 *a4)
{
__int64 v4; // rsi
__int64 v7; // rdi
__int64 i; // rdx
__int64 v10; // rdx

if ( a1 )
{
if ( a2 > 1 )
{
v4 = a2 - 1;
v7 = 0LL;
for ( i = v4 / 2; ; i = (v7 + v4) / 2 )
{
if ( *(_QWORD *)(a1 + 8 * i) <= a3 )
{
if ( *(_QWORD *)(a1 + 8 * i) >= a3 )
{
*a4 = i;
return 0LL;
}
v7 = i;
}
else
{
v4 = i;
}
if ( (v7 + v4) / 2 == i )
{
*a4 = v7;
return 0LL;
}
}
}
v10 = 19LL;
}
else
{
v10 = 18LL;
}
fprintf(stderr, "Line %3d of File %s \n", v10, "./AUTOGEN/GENFILES/find_largest_leq_I8.c");
return 0xFFFFFFFFLL;
}

original_code:
int
find_largest_leq_I8(
    long long *X,
    long long n,
    long long val,
    long long *ptr_idx
    )
{
  int status = 0;
  long long mid, prev_mid = (-0x7fffffffffffffffLL - 1LL);
  long long bot = 0;
  long long top = n-1;
  if ( X == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 18, "./AUTOGEN/GENFILES/find_largest_leq_I8.c"); }; status = -1 ; goto BYE; }; }
  if ( n <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 19, "./AUTOGEN/GENFILES/find_largest_leq_I8.c"); }; status = -1 ; goto BYE; }; }
  for ( ; ; ) {
    mid = ( bot + top ) / 2;
    if ( mid == prev_mid ) { *ptr_idx = bot; break; }
    if ( X[mid] > val ) {
      top = mid;
    }
    else if ( X[mid] < val ) {
      bot = mid;
    }
    else {
      *ptr_idx = mid; break;
    }
    prev_mid = mid;
  }
BYE:
  return(status);
}

canonical_original_code:
int find_largest_leq_I8(long long *X, long long n, long long val, long long *ptr_idx)
{
  int status = 0;
  long long mid; long long prev_mid = (-0x7fffffffffffffffLL - 1LL);
  long long bot = 0;
  long long top = n-1;
  if ( X == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 18, "./AUTOGEN/GENFILES/find_largest_leq_I8.c"); }; status = -1 ; goto BYE; }; }
  if ( n <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 19, "./AUTOGEN/GENFILES/find_largest_leq_I8.c"); }; status = -1 ; goto BYE; }; }
  for ( ; ; ) {
    mid = ( bot + top ) / 2;
    if ( mid == prev_mid ) { *ptr_idx = bot; break; }
    if ( X[mid] > val ) {
      top = mid;
    }
    else if ( X[mid] < val ) {
      bot = mid;
    }
    else {
      *ptr_idx = mid; break;
    }
    prev_mid = mid;
  }
BYE:
  return(status);
}

variable_types:
X
long long *

variable_types:
n
long long

variable_types:
val
long long

variable_types: status int

variable_types:
mid
long long

variable_types:
bot
long long

variable_types:
top
long long


decompiled_code:
__int64 __fastcall g_f1s1opf2(char *s1, const char *a2, const char *a3, const char *a4)
{
int v6; // er15
void *v7; // rdi
__int64 v9; // rdx
_BYTE v10[712]; // [rsp-590h] [rbp-2568h] BYREF
_BYTE v11[712]; // [rsp-2C8h] [rbp-22A0h] BYREF
char v12; // [rsp+5h] [rbp-1FD3h] BYREF
__int16 v13; // [rsp+6h] [rbp-1FD2h] BYREF
int v14; // [rsp+8h] [rbp-1FD0h] BYREF
int v15; // [rsp+Ch] [rbp-1FCCh] BYREF
unsigned int v16; // [rsp+10h] [rbp-1FC8h] BYREF
int v17; // [rsp+14h] [rbp-1FC4h] BYREF
int v18; // [rsp+18h] [rbp-1FC0h] BYREF
int v19; // [rsp+1Ch] [rbp-1FBCh] BYREF
int v20; // [rsp+20h] [rbp-1FB8h] BYREF
int v21; // [rsp+24h] [rbp-1FB4h] BYREF
int v22; // [rsp+28h] [rbp-1FB0h] BYREF
int v23; // [rsp+2Ch] [rbp-1FACh] BYREF
void *ptr; // [rsp+30h] [rbp-1FA8h] BYREF
__int64 v25; // [rsp+38h] [rbp-1FA0h] BYREF
__int64 v26; // [rsp+40h] [rbp-1F98h] BYREF
__int64 v27; // [rsp+48h] [rbp-1F90h] BYREF
__int64 v28; // [rsp+50h] [rbp-1F88h] BYREF
__int64 v29; // [rsp+58h] [rbp-1F80h] BYREF
__int64 v30; // [rsp+60h] [rbp-1F78h] BYREF
__int64 v31; // [rsp+68h] [rbp-1F70h] BYREF
__int64 v32; // [rsp+70h] [rbp-1F68h] BYREF
__int64 v33; // [rsp+78h] [rbp-1F60h] BYREF
char v34[128]; // [rsp+80h] [rbp-1F58h] BYREF
char v35[256]; // [rsp+100h] [rbp-1ED8h] BYREF
char v36[512]; // [rsp+200h] [rbp-1DD8h] BYREF
char v37[512]; // [rsp+400h] [rbp-1BD8h] BYREF
__int64 v38[90]; // [rsp+600h] [rbp-19D8h] BYREF
__int64 v39[90]; // [rsp+8D0h] [rbp-1708h] BYREF
char v40[1024]; // [rsp+BA0h] [rbp-1438h] BYREF
char v41[1024]; // [rsp+FA0h] [rbp-1038h] BYREF
char s[1024]; // [rsp+13A0h] [rbp-C38h] BYREF
char v43[2104]; // [rsp+17A0h] [rbp-838h] BYREF

v28 = 0x7FFFFFFFFFFFFFFFLL;
v13 = 0x7FFF;
v14 = -1;
v15 = -1;
ptr = 0LL;
v25 = 0LL;
v26 = 0LL;
v27 = 0LL;
v16 = 0;
v17 = 0x7FFFFFFF;
v12 = 127;
v18 = 2139095039;
v29 = LC1;
v19 = -1;
v30 = 0LL;
v31 = 0LL;
v32 = 0LL;
v33 = 0LL;
v20 = 0;
v21 = 0;
v22 = 0;
g_mmap_meta_data(&g_docroot, &v25, &v26, &v27, &v16);
if ( !a2 || !*a2 )
{
v9 = 68LL;
goto LABEL_36;
}
if ( !a3 || !*a3 )
{
v9 = 69LL;
goto LABEL_36;
}
if ( !s1 || !*s1 )
{
v9 = 70LL;
goto LABEL_36;
}
if ( !a4 || !*a4 )
{
v9 = 71LL;
goto LABEL_36;
}
if ( !strcmp(s1, a4) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 72LL, "g_f1s1opf2.c");
goto LABEL_28;
}
v6 = g_is_fld(v27, v16, s1, &v14, v38);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "g_f1s1opf2.c");
goto LABEL_28;
}
if ( v14 < 0 )
{
v9 = 75LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu(LODWORD(v38[4])) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 76LL, "g_f1s1opf2.c");
goto LABEL_28;
}
v6 = g_is_fld(v27, v16, a4, &v15, v39);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 78LL, "g_f1s1opf2.c");
goto LABEL_28;
}
if ( v15 < 0 )
{
v9 = 79LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu(LODWORD(v39[4])) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 80LL, "g_f1s1opf2.c");
LABEL_28:
v7 = ptr;
if ( !ptr )
goto LABEL_26;
LABEL_29:
free(v7);
ptr = 0LL;
goto LABEL_26;
}
if ( v38[3] != v39[3] )
{
v9 = 82LL;
goto LABEL_36;
}
if ( !v38[1] )
{
v9 = 83LL;
goto LABEL_36;
}
if ( !v38[3] )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 84LL, "g_f1s1opf2.c");
goto LABEL_28;
}
get_type_op_fld("f1s1opf2", a3, LODWORD(v38[4]), LODWORD(v38[4]), &unk_675, &v23);
if ( LODWORD(v39[4]) != v23 )
{
v9 = 88LL;
LABEL_36:
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", v9, "g_f1s1opf2.c");
goto LABEL_28;
}
qmemcpy(v11, v39, sizeof(v11));
qmemcpy(v10, v38, sizeof(v10));
v6 = g_chk_f1s1opf2(a3);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "g_f1s1opf2.c");
goto LABEL_28;
}
v6 = break_into_scalars(
a2,
LODWORD(v38[4]),
&v19,
&v28,
&v17,
&v13,
&v12,
&v18,
&v29,
v40,
v36,
v35,
v34,
v37,
v41,
&v30,
&v31,
&v32,
&v33,
&v20,
&v21,
&v22);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 95LL, "g_f1s1opf2.c");
goto LABEL_28;
}
zero_string(v43, 2048LL);
zero_string(s, 1024LL);
sprintf(s, "f1s1opf2 d_fld1=%s scalar=%s op=%s d_fld2=%s", s1, a2, a3, a4);
v6 = g_make_url(s, v43);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 101LL, "g_f1s1opf2.c");
goto LABEL_28;
}
v6 = g_call_gpu(v43, &ptr);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 102LL, "g_f1s1opf2.c");
goto LABEL_28;
}
if ( ptr )
{
fprintf(stderr, "Response from GPU = [%s]\n", (const char *)ptr);
v7 = ptr;
if ( ptr )
goto LABEL_29;
}
LABEL_26:
g_unmap_meta_data(v25, v26);
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, const char *a2, const char *a3, const char *a4)
{
int v6; // er15
void *v7; // rdi
__int64 v9; // rdx
_BYTE v10[712]; // [rsp-590h] [rbp-2568h] BYREF
_BYTE v11[712]; // [rsp-2C8h] [rbp-22A0h] BYREF
char v12; // [rsp+5h] [rbp-1FD3h] BYREF
__int16 v13; // [rsp+6h] [rbp-1FD2h] BYREF
int v14; // [rsp+8h] [rbp-1FD0h] BYREF
int v15; // [rsp+Ch] [rbp-1FCCh] BYREF
unsigned int v16; // [rsp+10h] [rbp-1FC8h] BYREF
int v17; // [rsp+14h] [rbp-1FC4h] BYREF
int v18; // [rsp+18h] [rbp-1FC0h] BYREF
int v19; // [rsp+1Ch] [rbp-1FBCh] BYREF
int v20; // [rsp+20h] [rbp-1FB8h] BYREF
int v21; // [rsp+24h] [rbp-1FB4h] BYREF
int v22; // [rsp+28h] [rbp-1FB0h] BYREF
int v23; // [rsp+2Ch] [rbp-1FACh] BYREF
void *ptr; // [rsp+30h] [rbp-1FA8h] BYREF
__int64 v25; // [rsp+38h] [rbp-1FA0h] BYREF
__int64 v26; // [rsp+40h] [rbp-1F98h] BYREF
__int64 v27; // [rsp+48h] [rbp-1F90h] BYREF
__int64 v28; // [rsp+50h] [rbp-1F88h] BYREF
__int64 v29; // [rsp+58h] [rbp-1F80h] BYREF
__int64 v30; // [rsp+60h] [rbp-1F78h] BYREF
__int64 v31; // [rsp+68h] [rbp-1F70h] BYREF
__int64 v32; // [rsp+70h] [rbp-1F68h] BYREF
__int64 v33; // [rsp+78h] [rbp-1F60h] BYREF
char v34[128]; // [rsp+80h] [rbp-1F58h] BYREF
char v35[256]; // [rsp+100h] [rbp-1ED8h] BYREF
char v36[512]; // [rsp+200h] [rbp-1DD8h] BYREF
char v37[512]; // [rsp+400h] [rbp-1BD8h] BYREF
__int64 v38[90]; // [rsp+600h] [rbp-19D8h] BYREF
__int64 v39[90]; // [rsp+8D0h] [rbp-1708h] BYREF
char v40[1024]; // [rsp+BA0h] [rbp-1438h] BYREF
char v41[1024]; // [rsp+FA0h] [rbp-1038h] BYREF
char s[1024]; // [rsp+13A0h] [rbp-C38h] BYREF
char v43[2104]; // [rsp+17A0h] [rbp-838h] BYREF

v28 = 0x7FFFFFFFFFFFFFFFLL;
v13 = 0x7FFF;
v14 = -1;
v15 = -1;
ptr = 0LL;
v25 = 0LL;
v26 = 0LL;
v27 = 0LL;
v16 = 0;
v17 = 0x7FFFFFFF;
v12 = 127;
v18 = 2139095039;
v29 = LC1;
v19 = -1;
v30 = 0LL;
v31 = 0LL;
v32 = 0LL;
v33 = 0LL;
v20 = 0;
v21 = 0;
v22 = 0;
g_mmap_meta_data(&g_docroot, &v25, &v26, &v27, &v16);
if ( !a2 || !*a2 )
{
v9 = 68LL;
goto LABEL_36;
}
if ( !a3 || !*a3 )
{
v9 = 69LL;
goto LABEL_36;
}
if ( !s1 || !*s1 )
{
v9 = 70LL;
goto LABEL_36;
}
if ( !a4 || !*a4 )
{
v9 = 71LL;
goto LABEL_36;
}
if ( !strcmp(s1, a4) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 72LL, "g_f1s1opf2.c");
goto LABEL_28;
}
v6 = g_is_fld(v27, v16, s1, &v14, v38);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "g_f1s1opf2.c");
goto LABEL_28;
}
if ( v14 < 0 )
{
v9 = 75LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu(LODWORD(v38[4])) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 76LL, "g_f1s1opf2.c");
goto LABEL_28;
}
v6 = g_is_fld(v27, v16, a4, &v15, v39);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 78LL, "g_f1s1opf2.c");
goto LABEL_28;
}
if ( v15 < 0 )
{
v9 = 79LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu(LODWORD(v39[4])) )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 80LL, "g_f1s1opf2.c");
LABEL_28:
v7 = ptr;
if ( !ptr )
goto LABEL_26;
LABEL_29:
free(v7);
ptr = 0LL;
goto LABEL_26;
}
if ( v38[3] != v39[3] )
{
v9 = 82LL;
goto LABEL_36;
}
if ( !v38[1] )
{
v9 = 83LL;
goto LABEL_36;
}
if ( !v38[3] )
{
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", 84LL, "g_f1s1opf2.c");
goto LABEL_28;
}
get_type_op_fld("f1s1opf2", a3, LODWORD(v38[4]), LODWORD(v38[4]), &unk_675, &v23);
if ( LODWORD(v39[4]) != v23 )
{
v9 = 88LL;
LABEL_36:
v6 = -1;
fprintf(stderr, "Line %3d of File %s \n", v9, "g_f1s1opf2.c");
goto LABEL_28;
}
qmemcpy(v11, v39, sizeof(v11));
qmemcpy(v10, v38, sizeof(v10));
v6 = g_chk_f1s1opf2(a3);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "g_f1s1opf2.c");
goto LABEL_28;
}
v6 = break_into_scalars(
a2,
LODWORD(v38[4]),
&v19,
&v28,
&v17,
&v13,
&v12,
&v18,
&v29,
v40,
v36,
v35,
v34,
v37,
v41,
&v30,
&v31,
&v32,
&v33,
&v20,
&v21,
&v22);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 95LL, "g_f1s1opf2.c");
goto LABEL_28;
}
zero_string(v43, 2048LL);
zero_string(s, 1024LL);
sprintf(s, "f1s1opf2 d_fld1=%s scalar=%s op=%s d_fld2=%s", s1, a2, a3, a4);
v6 = g_make_url(s, v43);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 101LL, "g_f1s1opf2.c");
goto LABEL_28;
}
v6 = g_call_gpu(v43, &ptr);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 102LL, "g_f1s1opf2.c");
goto LABEL_28;
}
if ( ptr )
{
fprintf(stderr, "Response from GPU = [%s]\n", (const char *)ptr);
v7 = ptr;
if ( ptr )
goto LABEL_29;
}
LABEL_26:
g_unmap_meta_data(v25, v26);
return (unsigned int)v6;
}

original_code:
int
g_f1s1opf2(
    char *f1,
    char *str_scalar,
    char *str_op,
    char *f2
    )
{
  int status = 0;
  int f1_id = -1; GPU_REG_TYPE f1_rec;
  int f2_id = -1; GPU_REG_TYPE f2_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;
  long long svals_I8[128];
  int svals_I4[128];
  short svals_I2[128];
  char svals_I1[128];
  float svals_F4[128];
  double svals_F8[128];
  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);
  int num_scalar_vals = -1;
  char *hashes_I1 = ((void *)0);
  short *hashes_I2 = ((void *)0);
  int *hashes_I4 = ((void *)0);
  long long *hashes_I8 = ((void *)0);
  unsigned int n = 0;
  unsigned int a = 0, b = 0;
  FLD_TYPE f2_fldtype;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( str_scalar == ((void *)0) ) || ( *str_scalar == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_op == ((void *)0) ) || ( *str_op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f1, &f1_id, &f1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 76, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f2, &f2_id, &f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.nR != f2_rec.nR ) { { { fprintf(stderr, "Line %3d of File %s \n", 82, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.filesz == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.nR == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  status = get_type_op_fld("f1s1opf2", str_op, f1_rec.fldtype,
      f1_rec.fldtype, "", &f2_fldtype);
  if ( f2_fldtype != f2_rec.fldtype ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_f1s1opf2(f1_rec, f2_rec, str_op); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  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,
 &hashes_I1, &hashes_I2, &hashes_I4, &hashes_I8, &n, &a, &b);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 95, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1s1opf2 d_fld1=%s scalar=%s op=%s d_fld2=%s",
        f1, str_scalar, str_op, f2);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 101, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 102, "g_f1s1opf2.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_f1s1opf2(char *f1, char *str_scalar, char *str_op, char *f2)
{
  int status = 0;
  int f1_id = -1; struct _GPU_REG_TYPE f1_rec;
  int f2_id = -1; struct _GPU_REG_TYPE f2_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;
  long long svals_I8[128];
  int svals_I4[128];
  short svals_I2[128];
  char svals_I1[128];
  float svals_F4[128];
  double svals_F8[128];
  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);
  int num_scalar_vals = -1;
  char *hashes_I1 = ((void *)0);
  short *hashes_I2 = ((void *)0);
  int *hashes_I4 = ((void *)0);
  long long *hashes_I8 = ((void *)0);
  unsigned int n = 0;
  unsigned int a = 0; unsigned int b = 0;
  enum _FLD_TYPE f2_fldtype;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( str_scalar == ((void *)0) ) || ( *str_scalar == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_op == ((void *)0) ) || ( *str_op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f1, &f1_id, &f1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 76, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f2, &f2_id, &f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.nR != f2_rec.nR ) { { { fprintf(stderr, "Line %3d of File %s \n", 82, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.filesz == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.nR == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  status = get_type_op_fld("f1s1opf2", str_op, f1_rec.fldtype,
      f1_rec.fldtype, "", &f2_fldtype);
  if ( f2_fldtype != f2_rec.fldtype ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "g_f1s1opf2.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_f1s1opf2(f1_rec, f2_rec, str_op); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  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,
 &hashes_I1, &hashes_I2, &hashes_I4, &hashes_I8, &n, &a, &b);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 95, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1s1opf2 d_fld1=%s scalar=%s op=%s d_fld2=%s",
        f1, str_scalar, str_op, f2);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 101, "g_f1s1opf2.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 102, "g_f1s1opf2.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:
n
unsigned int

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types:
url
char [2048]

variable_types:
command
char [1024]

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


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

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

variable_types:
iX
int *

variable_types:
nR
long long

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

variable_types:
i
long long