patmatch

decompiled_code:
__int64 __fastcall patmatch(const char *a1, const char *a2, _BYTE *a3, const char *a4, const char *a5, const char *a6, char *s1, char *s2)
{
int v12; // er12
__int64 v13; // rdx
__int64 v14; // r8
__int64 v15; // rcx
__int64 v16; // rbp
__int64 v17; // rcx
char *v18; // rsi
_DWORD *v19; // rdi
int v20; // eax
__int64 v22; // rdx
__int64 v23; // rcx
char *v24; // rsi
_DWORD *v25; // rdi
_DWORD *v26; // r14
__int64 v27; // rcx
char *v28; // rsi
_DWORD *v29; // rdi
__int64 v30; // r9
_DWORD *v31; // r15
char *v32; // rsi
__int64 v33; // rcx
_DWORD *v34; // rdi
__int64 v35; // rax
int v36; // edx
_QWORD v37[15]; // [rsp-80h] [rbp-538h] BYREF
__int64 v38; // [rsp-8h] [rbp-4C0h]
__int64 v39; // [rsp+8h] [rbp-4B0h]
unsigned int v40; // [rsp+10h] [rbp-4A8h] BYREF
unsigned int v41; // [rsp+14h] [rbp-4A4h] BYREF
int v42; // [rsp+18h] [rbp-4A0h] BYREF
int v43; // [rsp+1Ch] [rbp-49Ch] BYREF
int v44; // [rsp+20h] [rbp-498h] BYREF
int v45; // [rsp+24h] [rbp-494h] BYREF
int v46; // [rsp+28h] [rbp-490h] BYREF
int v47; // [rsp+2Ch] [rbp-48Ch] BYREF
int v48; // [rsp+30h] [rbp-488h] BYREF
int v49; // [rsp+34h] [rbp-484h] BYREF
unsigned int v50; // [rsp+38h] [rbp-480h] BYREF
unsigned int v51; // [rsp+3Ch] [rbp-47Ch] BYREF
void *addr; // [rsp+40h] [rbp-478h] BYREF
size_t len; // [rsp+48h] [rbp-470h] BYREF
void *v54; // [rsp+50h] [rbp-468h] BYREF
size_t v55; // [rsp+58h] [rbp-460h] BYREF
void *v56; // [rsp+60h] [rbp-458h] BYREF
size_t v57; // [rsp+68h] [rbp-450h] BYREF
void *v58; // [rsp+70h] [rbp-448h] BYREF
size_t v59; // [rsp+78h] [rbp-440h] BYREF
void *v60; // [rsp+80h] [rbp-438h] BYREF
size_t v61; // [rsp+88h] [rbp-430h] BYREF
void *v62; // [rsp+90h] [rbp-428h] BYREF
size_t v63; // [rsp+98h] [rbp-420h] BYREF
__int64 v64[6]; // [rsp+A0h] [rbp-418h] BYREF
__int64 v65[6]; // [rsp+D0h] [rbp-3E8h] BYREF
__int64 v66[4]; // [rsp+100h] [rbp-3B8h] BYREF
__int64 v67; // [rsp+120h] [rbp-398h]
__int64 v68; // [rsp+128h] [rbp-390h]
__int64 v69; // [rsp+130h] [rbp-388h]
__int64 v70; // [rsp+138h] [rbp-380h]
__int64 v71; // [rsp+140h] [rbp-378h]
__int64 v72; // [rsp+148h] [rbp-370h]
__int64 v73; // [rsp+150h] [rbp-368h]
__int64 v74; // [rsp+158h] [rbp-360h]
__int64 v75; // [rsp+160h] [rbp-358h]
__int64 v76; // [rsp+168h] [rbp-350h]
__int64 v77; // [rsp+170h] [rbp-348h]
char v78[32]; // [rsp+180h] [rbp-338h] BYREF
int v79; // [rsp+1A0h] [rbp-318h]
char v80[32]; // [rsp+200h] [rbp-2B8h] BYREF
int v81; // [rsp+220h] [rbp-298h]
char v82[128]; // [rsp+280h] [rbp-238h] BYREF
char v83[32]; // [rsp+300h] [rbp-1B8h] BYREF
int v84; // [rsp+320h] [rbp-198h]
char v85[32]; // [rsp+380h] [rbp-138h] BYREF
int v86; // [rsp+3A0h] [rbp-118h]
char v87[32]; // [rsp+400h] [rbp-B8h] BYREF
int v88; // [rsp+420h] [rbp-98h]

v40 = -1;
v41 = -1;
v42 = -1;
v43 = -1;
v44 = -1;
v45 = -1;
v46 = -1;
v47 = -1;
v48 = -1;
addr = 0LL;
len = 0LL;
v54 = 0LL;
v55 = 0LL;
v56 = 0LL;
v57 = 0LL;
v58 = 0LL;
v59 = 0LL;
v60 = 0LL;
v61 = 0LL;
v62 = 0LL;
v63 = 0LL;
v49 = 0;
if ( !a1 || !*a1 )
{
v13 = 44LL;
goto LABEL_42;
}
if ( !a2 || !*a2 )
{
v13 = 45LL;
goto LABEL_42;
}
if ( !a4 || !*a4 )
{
v13 = 46LL;
goto LABEL_42;
}
if ( !a5 || !*a5 )
{
v13 = 47LL;
goto LABEL_42;
}
if ( !s1 || !*s1 )
{
v13 = 48LL;
goto LABEL_42;
}
if ( !s2 || !*s2 )
{
v13 = 49LL;
goto LABEL_42;
}
if ( !a6 || !*a6 )
{
v13 = 50LL;
goto LABEL_42;
}
if ( !strcmp(a1, a5) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 52LL, "patmatch.c");
goto LABEL_43;
}
if ( !strcmp(a2, a4) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 53LL, "patmatch.c");
goto LABEL_43;
}
if ( !strcmp(s1, s2) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 54LL, "patmatch.c");
goto LABEL_43;
}
if ( !strcmp(s1, a6) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 55LL, "patmatch.c");
goto LABEL_43;
}
if ( !strcmp(s2, a6) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 56LL, "patmatch.c");
goto LABEL_43;
}
v12 = is_tbl(a1, &v40, v64);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "patmatch.c");
goto LABEL_43;
}
v13 = 59LL;
if ( (v40 & 0x80000000) != 0 )
goto LABEL_42;
v39 = v64[0];
v12 = is_fld(0LL, v40, a2, &v42, v66, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "patmatch.c");
goto LABEL_43;
}
v13 = 64LL;
if ( v42 < 0 )
goto LABEL_42;
v13 = 65LL;
if ( v45 >= 0 )
goto LABEL_42;
v37[14] = v77;
v37[13] = v76;
v37[12] = v75;
v37[11] = v74;
v37[10] = v73;
v37[9] = v72;
v37[8] = v71;
v37[7] = v70;
v37[6] = v69;
v37[5] = v68;
v37[4] = v67;
v37[3] = v66[3];
v37[2] = v66[2];
v37[1] = v66[1];
v37[0] = v66[0];
v12 = get_data(&addr, &len, 0LL, "patmatch.c");
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "patmatch.c");
goto LABEL_43;
}
v13 = 69LL;
if ( (unsigned int)(v67 - 2) > 2 )
{
LABEL_42:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v13, "patmatch.c");
goto LABEL_43;
}
if ( a3 && *a3 )
{
v38 = v14;
v12 = is_fld(0LL, v40, a3, &v43, v78, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "patmatch.c");
goto LABEL_43;
}
if ( v43 < 0 )
{
v13 = 75LL;
goto LABEL_42;
}
if ( v45 >= 0 )
{
v13 = 76LL;
goto LABEL_42;
}
v23 = 30LL;
v24 = v78;
v25 = v37;
while ( v23 )
{
*v25 = *(_DWORD *)v24;
v24 += 4;
++v25;
--v23;
}
v12 = get_data(&v54, &v55, 0LL, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 77LL, "patmatch.c");
goto LABEL_43;
}
if ( v79 != 2 )
{
v13 = 78LL;
goto LABEL_42;
}
}
v12 = is_tbl(a5, &v41, v65);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "patmatch.c");
}
else
{
if ( (v41 & 0x80000000) != 0 )
{
v13 = 82LL;
goto LABEL_42;
}
v16 = v65[0];
if ( v65[0] <= 1 )
{
v13 = 85LL;
goto LABEL_42;
}
v38 = v15;
v12 = is_fld(0LL, v41, s1, &v46, v83, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "patmatch.c");
}
else
{
if ( v46 < 0 )
{
v13 = 89LL;
goto LABEL_42;
}
if ( v45 >= 0 )
{
v13 = 90LL;
goto LABEL_42;
}
v17 = 30LL;
v18 = v83;
v19 = v37;
while ( v17 )
{
*v19 = *(_DWORD *)v18;
v18 += 4;
++v19;
--v17;
}
v20 = get_data(&v58, &v59, 0LL, 0LL);
v12 = v20;
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 91LL, "patmatch.c");
}
else
{
if ( v84 != 4 )
{
v13 = 92LL;
goto LABEL_42;
}
v26 = v58;
v38 = (unsigned int)v20;
v12 = is_fld(0LL, v41, s2, &v47, v85, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 96LL, "patmatch.c");
}
else
{
if ( v47 < 0 )
{
v13 = 97LL;
goto LABEL_42;
}
if ( v45 >= 0 )
{
v13 = 98LL;
goto LABEL_42;
}
v27 = 30LL;
v28 = v85;
v29 = v37;
while ( v27 )
{
*v29 = *(_DWORD *)v28;
v28 += 4;
++v29;
--v27;
}
v12 = get_data(&v60, &v61, 0LL, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 99LL, "patmatch.c");
}
else
{
if ( v86 != 4 )
{
v13 = 100LL;
goto LABEL_42;
}
v31 = v60;
v38 = v30;
v12 = is_fld(0LL, v41, a6, &v48, v87, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 104LL, "patmatch.c");
}
else
{
if ( v48 < 0 )
{
v13 = 105LL;
goto LABEL_42;
}
if ( v45 >= 0 )
{
v13 = 106LL;
goto LABEL_42;
}
v32 = v87;
v33 = 30LL;
v34 = v37;
while ( v33 )
{
*v34 = *(_DWORD *)v32;
v32 += 4;
++v34;
--v33;
}
v12 = get_data(&v62, &v63, 0LL, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 107LL, "patmatch.c");
}
else
{
v35 = 0LL;
if ( v88 == (_DWORD)v67 )
{
do
{
v36 = v26[v35];
if ( v36 > v31[v35] )
{
v13 = 112LL;
goto LABEL_42;
}
if ( v36 <= 0 )
{
v13 = 113LL;
goto LABEL_42;
}
++v35;
}
while ( v16 > v35 );
v12 = get_fld_sz(2LL, &v49);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 116LL, "patmatch.c");
}
else
{
v12 = mk_temp_file(v39 * v49, &v50, &v51);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 118LL, "patmatch.c");
}
else
{
v12 = q_mmap(v50, v51, &v56, &v57, 1LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 119LL, "patmatch.c");
}
else
{
switch ( (_DWORD)v67 )
{
case 3:
v38 = v16;
v12 = inner_patmatch_I2(addr, v54, v56, v39, v62, v26, v31);
break;
case 4:
v12 = inner_patmatch_I4(addr, v54, v56, v39, v62, v26, v31, v16);
break;
case 2:
v12 = inner_patmatch_I1(addr, v54, v56, v39, v62, v26, v31, v16);
break;
default:
v13 = 132LL;
goto LABEL_42;
}
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 135LL, "patmatch.c");
}
else
{
zero_fld_rec(v80);
v81 = 2;
v12 = add_fld(v40, a4, v50, v51, &v44, v80);
if ( v12 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 138LL, "patmatch.c");
}
}
}
}
}
else
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 108LL, "patmatch.c");
}
}
}
}
}
}
}
}
LABEL_43:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_46;
}
LABEL_64:
v22 = 141LL;
LABEL_65:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v22, "patmatch.c");
return (unsigned int)v12;
}
if ( len )
goto LABEL_64;
LABEL_46:
if ( v54 )
{
if ( v55 )
{
munmap(v54, v55);
v54 = 0LL;
v55 = 0LL;
goto LABEL_49;
}
goto LABEL_67;
}
if ( v55 )
{
LABEL_67:
v22 = 142LL;
goto LABEL_65;
}
LABEL_49:
if ( v56 )
{
if ( v57 )
{
munmap(v56, v57);
v56 = 0LL;
v57 = 0LL;
goto LABEL_52;
}
goto LABEL_69;
}
if ( v57 )
{
LABEL_69:
v22 = 143LL;
goto LABEL_65;
}
LABEL_52:
if ( v58 )
{
if ( v59 )
{
munmap(v58, v59);
v58 = 0LL;
v59 = 0LL;
goto LABEL_55;
}
goto LABEL_71;
}
if ( v59 )
{
LABEL_71:
v22 = 144LL;
goto LABEL_65;
}
LABEL_55:
if ( v60 )
{
if ( v61 )
{
munmap(v60, v61);
v60 = 0LL;
v61 = 0LL;
goto LABEL_58;
}
goto LABEL_73;
}
if ( v61 )
{
LABEL_73:
v22 = 145LL;
goto LABEL_65;
}
LABEL_58:
if ( !v62 )
{
if ( !v63 )
return (unsigned int)v12;
goto LABEL_75;
}
if ( !v63 )
{
LABEL_75:
v22 = 146LL;
goto LABEL_65;
}
munmap(v62, v63);
return (unsigned int)v12;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2, _BYTE *a3, const char *a4, const char *a5, const char *a6, char *s1, char *s2)
{
int v12; // er12
__int64 v13; // rdx
__int64 v14; // r8
__int64 v15; // rcx
__int64 v16; // rbp
__int64 v17; // rcx
char *v18; // rsi
_DWORD *v19; // rdi
int v20; // eax
__int64 v22; // rdx
__int64 v23; // rcx
char *v24; // rsi
_DWORD *v25; // rdi
_DWORD *v26; // r14
__int64 v27; // rcx
char *v28; // rsi
_DWORD *v29; // rdi
__int64 v30; // r9
_DWORD *v31; // r15
char *v32; // rsi
__int64 v33; // rcx
_DWORD *v34; // rdi
__int64 v35; // rax
int v36; // edx
_QWORD v37[15]; // [rsp-80h] [rbp-538h] BYREF
__int64 v38; // [rsp-8h] [rbp-4C0h]
__int64 v39; // [rsp+8h] [rbp-4B0h]
unsigned int v40; // [rsp+10h] [rbp-4A8h] BYREF
unsigned int v41; // [rsp+14h] [rbp-4A4h] BYREF
int v42; // [rsp+18h] [rbp-4A0h] BYREF
int v43; // [rsp+1Ch] [rbp-49Ch] BYREF
int v44; // [rsp+20h] [rbp-498h] BYREF
int v45; // [rsp+24h] [rbp-494h] BYREF
int v46; // [rsp+28h] [rbp-490h] BYREF
int v47; // [rsp+2Ch] [rbp-48Ch] BYREF
int v48; // [rsp+30h] [rbp-488h] BYREF
int v49; // [rsp+34h] [rbp-484h] BYREF
unsigned int v50; // [rsp+38h] [rbp-480h] BYREF
unsigned int v51; // [rsp+3Ch] [rbp-47Ch] BYREF
void *addr; // [rsp+40h] [rbp-478h] BYREF
size_t len; // [rsp+48h] [rbp-470h] BYREF
void *v54; // [rsp+50h] [rbp-468h] BYREF
size_t v55; // [rsp+58h] [rbp-460h] BYREF
void *v56; // [rsp+60h] [rbp-458h] BYREF
size_t v57; // [rsp+68h] [rbp-450h] BYREF
void *v58; // [rsp+70h] [rbp-448h] BYREF
size_t v59; // [rsp+78h] [rbp-440h] BYREF
void *v60; // [rsp+80h] [rbp-438h] BYREF
size_t v61; // [rsp+88h] [rbp-430h] BYREF
void *v62; // [rsp+90h] [rbp-428h] BYREF
size_t v63; // [rsp+98h] [rbp-420h] BYREF
__int64 v64[6]; // [rsp+A0h] [rbp-418h] BYREF
__int64 v65[6]; // [rsp+D0h] [rbp-3E8h] BYREF
__int64 v66[4]; // [rsp+100h] [rbp-3B8h] BYREF
__int64 v67; // [rsp+120h] [rbp-398h]
__int64 v68; // [rsp+128h] [rbp-390h]
__int64 v69; // [rsp+130h] [rbp-388h]
__int64 v70; // [rsp+138h] [rbp-380h]
__int64 v71; // [rsp+140h] [rbp-378h]
__int64 v72; // [rsp+148h] [rbp-370h]
__int64 v73; // [rsp+150h] [rbp-368h]
__int64 v74; // [rsp+158h] [rbp-360h]
__int64 v75; // [rsp+160h] [rbp-358h]
__int64 v76; // [rsp+168h] [rbp-350h]
__int64 v77; // [rsp+170h] [rbp-348h]
char v78[32]; // [rsp+180h] [rbp-338h] BYREF
int v79; // [rsp+1A0h] [rbp-318h]
char v80[32]; // [rsp+200h] [rbp-2B8h] BYREF
int v81; // [rsp+220h] [rbp-298h]
char v82[128]; // [rsp+280h] [rbp-238h] BYREF
char v83[32]; // [rsp+300h] [rbp-1B8h] BYREF
int v84; // [rsp+320h] [rbp-198h]
char v85[32]; // [rsp+380h] [rbp-138h] BYREF
int v86; // [rsp+3A0h] [rbp-118h]
char v87[32]; // [rsp+400h] [rbp-B8h] BYREF
int v88; // [rsp+420h] [rbp-98h]

v40 = -1;
v41 = -1;
v42 = -1;
v43 = -1;
v44 = -1;
v45 = -1;
v46 = -1;
v47 = -1;
v48 = -1;
addr = 0LL;
len = 0LL;
v54 = 0LL;
v55 = 0LL;
v56 = 0LL;
v57 = 0LL;
v58 = 0LL;
v59 = 0LL;
v60 = 0LL;
v61 = 0LL;
v62 = 0LL;
v63 = 0LL;
v49 = 0;
if ( !a1 || !*a1 )
{
v13 = 44LL;
goto LABEL_42;
}
if ( !a2 || !*a2 )
{
v13 = 45LL;
goto LABEL_42;
}
if ( !a4 || !*a4 )
{
v13 = 46LL;
goto LABEL_42;
}
if ( !a5 || !*a5 )
{
v13 = 47LL;
goto LABEL_42;
}
if ( !s1 || !*s1 )
{
v13 = 48LL;
goto LABEL_42;
}
if ( !s2 || !*s2 )
{
v13 = 49LL;
goto LABEL_42;
}
if ( !a6 || !*a6 )
{
v13 = 50LL;
goto LABEL_42;
}
if ( !strcmp(a1, a5) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 52LL, "patmatch.c");
goto LABEL_43;
}
if ( !strcmp(a2, a4) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 53LL, "patmatch.c");
goto LABEL_43;
}
if ( !strcmp(s1, s2) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 54LL, "patmatch.c");
goto LABEL_43;
}
if ( !strcmp(s1, a6) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 55LL, "patmatch.c");
goto LABEL_43;
}
if ( !strcmp(s2, a6) )
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 56LL, "patmatch.c");
goto LABEL_43;
}
v12 = is_tbl(a1, &v40, v64);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "patmatch.c");
goto LABEL_43;
}
v13 = 59LL;
if ( (v40 & 0x80000000) != 0 )
goto LABEL_42;
v39 = v64[0];
v12 = is_fld(0LL, v40, a2, &v42, v66, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "patmatch.c");
goto LABEL_43;
}
v13 = 64LL;
if ( v42 < 0 )
goto LABEL_42;
v13 = 65LL;
if ( v45 >= 0 )
goto LABEL_42;
v37[14] = v77;
v37[13] = v76;
v37[12] = v75;
v37[11] = v74;
v37[10] = v73;
v37[9] = v72;
v37[8] = v71;
v37[7] = v70;
v37[6] = v69;
v37[5] = v68;
v37[4] = v67;
v37[3] = v66[3];
v37[2] = v66[2];
v37[1] = v66[1];
v37[0] = v66[0];
v12 = get_data(&addr, &len, 0LL, "patmatch.c");
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "patmatch.c");
goto LABEL_43;
}
v13 = 69LL;
if ( (unsigned int)(v67 - 2) > 2 )
{
LABEL_42:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v13, "patmatch.c");
goto LABEL_43;
}
if ( a3 && *a3 )
{
v38 = v14;
v12 = is_fld(0LL, v40, a3, &v43, v78, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "patmatch.c");
goto LABEL_43;
}
if ( v43 < 0 )
{
v13 = 75LL;
goto LABEL_42;
}
if ( v45 >= 0 )
{
v13 = 76LL;
goto LABEL_42;
}
v23 = 30LL;
v24 = v78;
v25 = v37;
while ( v23 )
{
*v25 = *(_DWORD *)v24;
v24 += 4;
++v25;
--v23;
}
v12 = get_data(&v54, &v55, 0LL, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 77LL, "patmatch.c");
goto LABEL_43;
}
if ( v79 != 2 )
{
v13 = 78LL;
goto LABEL_42;
}
}
v12 = is_tbl(a5, &v41, v65);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "patmatch.c");
}
else
{
if ( (v41 & 0x80000000) != 0 )
{
v13 = 82LL;
goto LABEL_42;
}
v16 = v65[0];
if ( v65[0] <= 1 )
{
v13 = 85LL;
goto LABEL_42;
}
v38 = v15;
v12 = is_fld(0LL, v41, s1, &v46, v83, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "patmatch.c");
}
else
{
if ( v46 < 0 )
{
v13 = 89LL;
goto LABEL_42;
}
if ( v45 >= 0 )
{
v13 = 90LL;
goto LABEL_42;
}
v17 = 30LL;
v18 = v83;
v19 = v37;
while ( v17 )
{
*v19 = *(_DWORD *)v18;
v18 += 4;
++v19;
--v17;
}
v20 = get_data(&v58, &v59, 0LL, 0LL);
v12 = v20;
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 91LL, "patmatch.c");
}
else
{
if ( v84 != 4 )
{
v13 = 92LL;
goto LABEL_42;
}
v26 = v58;
v38 = (unsigned int)v20;
v12 = is_fld(0LL, v41, s2, &v47, v85, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 96LL, "patmatch.c");
}
else
{
if ( v47 < 0 )
{
v13 = 97LL;
goto LABEL_42;
}
if ( v45 >= 0 )
{
v13 = 98LL;
goto LABEL_42;
}
v27 = 30LL;
v28 = v85;
v29 = v37;
while ( v27 )
{
*v29 = *(_DWORD *)v28;
v28 += 4;
++v29;
--v27;
}
v12 = get_data(&v60, &v61, 0LL, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 99LL, "patmatch.c");
}
else
{
if ( v86 != 4 )
{
v13 = 100LL;
goto LABEL_42;
}
v31 = v60;
v38 = v30;
v12 = is_fld(0LL, v41, a6, &v48, v87, &v45, v82);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 104LL, "patmatch.c");
}
else
{
if ( v48 < 0 )
{
v13 = 105LL;
goto LABEL_42;
}
if ( v45 >= 0 )
{
v13 = 106LL;
goto LABEL_42;
}
v32 = v87;
v33 = 30LL;
v34 = v37;
while ( v33 )
{
*v34 = *(_DWORD *)v32;
v32 += 4;
++v34;
--v33;
}
v12 = get_data(&v62, &v63, 0LL, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 107LL, "patmatch.c");
}
else
{
v35 = 0LL;
if ( v88 == (_DWORD)v67 )
{
do
{
v36 = v26[v35];
if ( v36 > v31[v35] )
{
v13 = 112LL;
goto LABEL_42;
}
if ( v36 <= 0 )
{
v13 = 113LL;
goto LABEL_42;
}
++v35;
}
while ( v16 > v35 );
v12 = get_fld_sz(2LL, &v49);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 116LL, "patmatch.c");
}
else
{
v12 = mk_temp_file(v39 * v49, &v50, &v51);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 118LL, "patmatch.c");
}
else
{
v12 = q_mmap(v50, v51, &v56, &v57, 1LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 119LL, "patmatch.c");
}
else
{
switch ( (_DWORD)v67 )
{
case 3:
v38 = v16;
v12 = inner_patmatch_I2(addr, v54, v56, v39, v62, v26, v31);
break;
case 4:
v12 = inner_patmatch_I4(addr, v54, v56, v39, v62, v26, v31, v16);
break;
case 2:
v12 = inner_patmatch_I1(addr, v54, v56, v39, v62, v26, v31, v16);
break;
default:
v13 = 132LL;
goto LABEL_42;
}
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 135LL, "patmatch.c");
}
else
{
zero_fld_rec(v80);
v81 = 2;
v12 = add_fld(v40, a4, v50, v51, &v44, v80);
if ( v12 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 138LL, "patmatch.c");
}
}
}
}
}
else
{
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", 108LL, "patmatch.c");
}
}
}
}
}
}
}
}
LABEL_43:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_46;
}
LABEL_64:
v22 = 141LL;
LABEL_65:
v12 = -1;
fprintf(stderr, "Line %3d of File %s \n", v22, "patmatch.c");
return (unsigned int)v12;
}
if ( len )
goto LABEL_64;
LABEL_46:
if ( v54 )
{
if ( v55 )
{
munmap(v54, v55);
v54 = 0LL;
v55 = 0LL;
goto LABEL_49;
}
goto LABEL_67;
}
if ( v55 )
{
LABEL_67:
v22 = 142LL;
goto LABEL_65;
}
LABEL_49:
if ( v56 )
{
if ( v57 )
{
munmap(v56, v57);
v56 = 0LL;
v57 = 0LL;
goto LABEL_52;
}
goto LABEL_69;
}
if ( v57 )
{
LABEL_69:
v22 = 143LL;
goto LABEL_65;
}
LABEL_52:
if ( v58 )
{
if ( v59 )
{
munmap(v58, v59);
v58 = 0LL;
v59 = 0LL;
goto LABEL_55;
}
goto LABEL_71;
}
if ( v59 )
{
LABEL_71:
v22 = 144LL;
goto LABEL_65;
}
LABEL_55:
if ( v60 )
{
if ( v61 )
{
munmap(v60, v61);
v60 = 0LL;
v61 = 0LL;
goto LABEL_58;
}
goto LABEL_73;
}
if ( v61 )
{
LABEL_73:
v22 = 145LL;
goto LABEL_65;
}
LABEL_58:
if ( !v62 )
{
if ( !v63 )
return (unsigned int)v12;
goto LABEL_75;
}
if ( !v63 )
{
LABEL_75:
v22 = 146LL;
goto LABEL_65;
}
munmap(v62, v63);
return (unsigned int)v12;
}

original_code:
int
patmatch(
  char *t1,
  char *f1,
  char *brk_fld,
  char *out_fld,
  char *tp,
  char *pat_fld,
  char *lb_fld,
  char *ub_fld
  )
{
  int status = 0;
  long long nR1 = 0, nR2 = 0;
  int t1_id = -1, tp_id = -1;
  TBL_REC_TYPE t1_rec, tp_rec;
  int f1_id = -1, brk_id = -1, out_id = -1, nn_id = -1;
  int lb_id = -1, ub_id = -1, pat_id = -1;
  FLD_REC_TYPE f1_rec, brk_rec, out_rec, nn_rec;
  FLD_REC_TYPE lb_rec, ub_rec, pat_rec;
  char *f1_X = ((void *)0); size_t f1_nX = 0;
  char *brk_X = ((void *)0); size_t brk_nX = 0;
  char *out_X = ((void *)0); size_t out_nX = 0;
  char *lb_X = ((void *)0); size_t lb_nX = 0;
  char *ub_X = ((void *)0); size_t ub_nX = 0;
  char *pat_X = ((void *)0); size_t pat_nX = 0;
  long long filesz = 0; int fldsz = 0; int ddir_id; int fileno;
  if ( ( t1 == ((void *)0) ) || ( *t1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( out_fld == ((void *)0) ) || ( *out_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( tp == ((void *)0) ) || ( *tp == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( lb_fld == ((void *)0) ) || ( *lb_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( ub_fld == ((void *)0) ) || ( *ub_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( pat_fld == ((void *)0) ) || ( *pat_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t1, tp) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, out_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(lb_fld, ub_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(lb_fld, pat_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(ub_fld, pat_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(t1, &t1_id, &t1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( t1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  nR1 = t1_rec.nR;
  status = is_fld(((void *)0), t1_id, f1, &f1_id, &f1_rec, &nn_id, &nn_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "patmatch.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", 66, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  switch ( f1_rec.fldtype ) {
  case I1 : case I2: case I4 : break;
  default : { { fprintf(stderr, "Line %3d of File %s \n", 69, "patmatch.c"); }; status = -1 ; goto BYE; }; break;
  }
  if ( ( brk_fld != ((void *)0) ) && ( *brk_fld != '\0' ) ) {
    status = is_fld(((void *)0), t1_id, brk_fld, &brk_id, &brk_rec, &nn_id, &nn_rec);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "patmatch.c"); }; status = (status) ; goto BYE; } } };
    if ( brk_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "patmatch.c"); }; status = -1 ; goto BYE; }; }
    if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 76, "patmatch.c"); }; status = -1 ; goto BYE; }; }
    status = get_data(brk_rec, &brk_X, &brk_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 77, "patmatch.c"); }; status = (status) ; goto BYE; } } };
    if ( brk_rec.fldtype != I1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  }
  status = is_tbl(tp, &tp_id, &tp_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( tp_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 82, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  nR2 = tp_rec.nR;
  if ( nR2 <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = is_fld(((void *)0), tp_id, lb_fld, &lb_id, &lb_rec, &nn_id, &nn_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( lb_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(lb_rec, &lb_X, &lb_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 91, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( lb_rec.fldtype != I4 ) { { { fprintf(stderr, "Line %3d of File %s \n", 92, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  int *lbI4 = (int *)lb_X;
  status = is_fld(((void *)0), tp_id, ub_fld, &ub_id, &ub_rec, &nn_id, &nn_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 96, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( ub_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 97, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 98, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(ub_rec, &ub_X, &ub_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 99, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( ub_rec.fldtype != I4 ) { { { fprintf(stderr, "Line %3d of File %s \n", 100, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  int *ubI4 = (int *)ub_X;
  status = is_fld(((void *)0), tp_id, pat_fld, &pat_id, &pat_rec, &nn_id, &nn_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 104, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( pat_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 105, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 106, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(pat_rec, &pat_X, &pat_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 107, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( pat_rec.fldtype != f1_rec.fldtype ) { { { fprintf(stderr, "Line %3d of File %s \n", 108, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  for ( int i = 0; i < nR2; i++ ) {
    if ( lbI4[i] > ubI4[i] ) { { { fprintf(stderr, "Line %3d of File %s \n", 112, "patmatch.c"); }; status = -1 ; goto BYE; }; }
    if ( lbI4[i] < 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 113, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  }
  status = get_fld_sz(I1, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 116, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  filesz = nR1 * fldsz;
  status = mk_temp_file(filesz, &ddir_id, &fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 118, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, fileno, &out_X, &out_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 119, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  switch ( f1_rec.fldtype ) {
      case I1 :
      status = inner_patmatch_I1((char *)f1_X, brk_X, out_X, nR1, (char *)pat_X, lbI4, ubI4, nR2);
      break;
      case I2 :
      status = inner_patmatch_I2((short *)f1_X, brk_X, out_X, nR1, (short *)pat_X, lbI4, ubI4, nR2);
      break;
  case I4 :
    status = inner_patmatch_I4((int *)f1_X, brk_X, out_X, nR1, (int *)pat_X, lbI4, ubI4, nR2);
    break;
  default :
    { { fprintf(stderr, "Line %3d of File %s \n", 132, "patmatch.c"); }; status = -1 ; goto BYE; };
    break;
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 135, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  zero_fld_rec(&out_rec); out_rec.fldtype = I1;
  status = add_fld(t1_id, out_fld, ddir_id, fileno, &out_id, &out_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 138, "patmatch.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 141, "patmatch.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 141, "patmatch.c"); }; return(-1); } if ( f1_X != ((void *)0) ) { munmap(f1_X, f1_nX); f1_X = ((void *)0); f1_nX = 0; } };
  { if ( ( brk_X == ((void *)0) ) && ( brk_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 142, "patmatch.c"); }; return(-1); } if ( ( brk_X != ((void *)0) ) && ( brk_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 142, "patmatch.c"); }; return(-1); } if ( brk_X != ((void *)0) ) { munmap(brk_X, brk_nX); brk_X = ((void *)0); brk_nX = 0; } };
  { if ( ( out_X == ((void *)0) ) && ( out_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 143, "patmatch.c"); }; return(-1); } if ( ( out_X != ((void *)0) ) && ( out_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 143, "patmatch.c"); }; return(-1); } if ( out_X != ((void *)0) ) { munmap(out_X, out_nX); out_X = ((void *)0); out_nX = 0; } };
  { if ( ( lb_X == ((void *)0) ) && ( lb_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 144, "patmatch.c"); }; return(-1); } if ( ( lb_X != ((void *)0) ) && ( lb_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 144, "patmatch.c"); }; return(-1); } if ( lb_X != ((void *)0) ) { munmap(lb_X, lb_nX); lb_X = ((void *)0); lb_nX = 0; } };
  { if ( ( ub_X == ((void *)0) ) && ( ub_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 145, "patmatch.c"); }; return(-1); } if ( ( ub_X != ((void *)0) ) && ( ub_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 145, "patmatch.c"); }; return(-1); } if ( ub_X != ((void *)0) ) { munmap(ub_X, ub_nX); ub_X = ((void *)0); ub_nX = 0; } };
  { if ( ( pat_X == ((void *)0) ) && ( pat_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 146, "patmatch.c"); }; return(-1); } if ( ( pat_X != ((void *)0) ) && ( pat_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 146, "patmatch.c"); }; return(-1); } if ( pat_X != ((void *)0) ) { munmap(pat_X, pat_nX); pat_X = ((void *)0); pat_nX = 0; } };
  return(status);
}

canonical_original_code:
int patmatch(char *t1, char *f1, char *brk_fld, char *out_fld, char *tp, char *pat_fld, char *lb_fld, char *ub_fld)
{
  int status = 0;
  long long nR1 = 0; long long nR2 = 0;
  int t1_id = -1; int tp_id = -1;
  struct _TBL_REC_TYPE t1_rec; struct _TBL_REC_TYPE tp_rec;
  int f1_id = -1; int brk_id = -1; int out_id = -1; int nn_id = -1;
  int lb_id = -1; int ub_id = -1; int pat_id = -1;
  struct _FLD_REC_TYPE f1_rec; struct _FLD_REC_TYPE brk_rec; struct _FLD_REC_TYPE out_rec; struct _FLD_REC_TYPE nn_rec;
  struct _FLD_REC_TYPE lb_rec; struct _FLD_REC_TYPE ub_rec; struct _FLD_REC_TYPE pat_rec;
  char *f1_X = ((void *)0); unsigned long f1_nX = 0;
  char *brk_X = ((void *)0); unsigned long brk_nX = 0;
  char *out_X = ((void *)0); unsigned long out_nX = 0;
  char *lb_X = ((void *)0); unsigned long lb_nX = 0;
  char *ub_X = ((void *)0); unsigned long ub_nX = 0;
  char *pat_X = ((void *)0); unsigned long pat_nX = 0;
  long long filesz = 0; int fldsz = 0; int ddir_id; int fileno;
  if ( ( t1 == ((void *)0) ) || ( *t1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( out_fld == ((void *)0) ) || ( *out_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( tp == ((void *)0) ) || ( *tp == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( lb_fld == ((void *)0) ) || ( *lb_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( ub_fld == ((void *)0) ) || ( *ub_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( ( pat_fld == ((void *)0) ) || ( *pat_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t1, tp) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, out_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(lb_fld, ub_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(lb_fld, pat_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(ub_fld, pat_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(t1, &t1_id, &t1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( t1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  nR1 = t1_rec.nR;
  status = is_fld(((void *)0), t1_id, f1, &f1_id, &f1_rec, &nn_id, &nn_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "patmatch.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", 66, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  switch ( f1_rec.fldtype ) {
  case I1 : case I2: case I4 : break;
  default : { { fprintf(stderr, "Line %3d of File %s \n", 69, "patmatch.c"); }; status = -1 ; goto BYE; }; break;
  }
  if ( ( brk_fld != ((void *)0) ) && ( *brk_fld != '\0' ) ) {
    status = is_fld(((void *)0), t1_id, brk_fld, &brk_id, &brk_rec, &nn_id, &nn_rec);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "patmatch.c"); }; status = (status) ; goto BYE; } } };
    if ( brk_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "patmatch.c"); }; status = -1 ; goto BYE; }; }
    if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 76, "patmatch.c"); }; status = -1 ; goto BYE; }; }
    status = get_data(brk_rec, &brk_X, &brk_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 77, "patmatch.c"); }; status = (status) ; goto BYE; } } };
    if ( brk_rec.fldtype != I1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  }
  status = is_tbl(tp, &tp_id, &tp_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( tp_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 82, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  nR2 = tp_rec.nR;
  if ( nR2 <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = is_fld(((void *)0), tp_id, lb_fld, &lb_id, &lb_rec, &nn_id, &nn_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 88, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( lb_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(lb_rec, &lb_X, &lb_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 91, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( lb_rec.fldtype != I4 ) { { { fprintf(stderr, "Line %3d of File %s \n", 92, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  int *lbI4 = (int *)lb_X;
  status = is_fld(((void *)0), tp_id, ub_fld, &ub_id, &ub_rec, &nn_id, &nn_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 96, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( ub_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 97, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 98, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(ub_rec, &ub_X, &ub_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 99, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( ub_rec.fldtype != I4 ) { { { fprintf(stderr, "Line %3d of File %s \n", 100, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  int *ubI4 = (int *)ub_X;
  status = is_fld(((void *)0), tp_id, pat_fld, &pat_id, &pat_rec, &nn_id, &nn_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 104, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( pat_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 105, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 106, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(pat_rec, &pat_X, &pat_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 107, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  if ( pat_rec.fldtype != f1_rec.fldtype ) { { { fprintf(stderr, "Line %3d of File %s \n", 108, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  for ( int i = 0; i < nR2; i++ ) {
    if ( lbI4[i] > ubI4[i] ) { { { fprintf(stderr, "Line %3d of File %s \n", 112, "patmatch.c"); }; status = -1 ; goto BYE; }; }
    if ( lbI4[i] < 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 113, "patmatch.c"); }; status = -1 ; goto BYE; }; }
  }
  status = get_fld_sz(I1, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 116, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  filesz = nR1 * fldsz;
  status = mk_temp_file(filesz, &ddir_id, &fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 118, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, fileno, &out_X, &out_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 119, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  switch ( f1_rec.fldtype ) {
      case I1 :
      status = inner_patmatch_I1((char *)f1_X, brk_X, out_X, nR1, (char *)pat_X, lbI4, ubI4, nR2);
      break;
      case I2 :
      status = inner_patmatch_I2((short *)f1_X, brk_X, out_X, nR1, (short *)pat_X, lbI4, ubI4, nR2);
      break;
  case I4 :
    status = inner_patmatch_I4((int *)f1_X, brk_X, out_X, nR1, (int *)pat_X, lbI4, ubI4, nR2);
    break;
  default :
    { { fprintf(stderr, "Line %3d of File %s \n", 132, "patmatch.c"); }; status = -1 ; goto BYE; };
    break;
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 135, "patmatch.c"); }; status = (status) ; goto BYE; } } };
  zero_fld_rec(&out_rec); out_rec.fldtype = I1;
  status = add_fld(t1_id, out_fld, ddir_id, fileno, &out_id, &out_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 138, "patmatch.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 141, "patmatch.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 141, "patmatch.c"); }; return(-1); } if ( f1_X != ((void *)0) ) { munmap(f1_X, f1_nX); f1_X = ((void *)0); f1_nX = 0; } };
  { if ( ( brk_X == ((void *)0) ) && ( brk_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 142, "patmatch.c"); }; return(-1); } if ( ( brk_X != ((void *)0) ) && ( brk_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 142, "patmatch.c"); }; return(-1); } if ( brk_X != ((void *)0) ) { munmap(brk_X, brk_nX); brk_X = ((void *)0); brk_nX = 0; } };
  { if ( ( out_X == ((void *)0) ) && ( out_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 143, "patmatch.c"); }; return(-1); } if ( ( out_X != ((void *)0) ) && ( out_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 143, "patmatch.c"); }; return(-1); } if ( out_X != ((void *)0) ) { munmap(out_X, out_nX); out_X = ((void *)0); out_nX = 0; } };
  { if ( ( lb_X == ((void *)0) ) && ( lb_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 144, "patmatch.c"); }; return(-1); } if ( ( lb_X != ((void *)0) ) && ( lb_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 144, "patmatch.c"); }; return(-1); } if ( lb_X != ((void *)0) ) { munmap(lb_X, lb_nX); lb_X = ((void *)0); lb_nX = 0; } };
  { if ( ( ub_X == ((void *)0) ) && ( ub_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 145, "patmatch.c"); }; return(-1); } if ( ( ub_X != ((void *)0) ) && ( ub_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 145, "patmatch.c"); }; return(-1); } if ( ub_X != ((void *)0) ) { munmap(ub_X, ub_nX); ub_X = ((void *)0); ub_nX = 0; } };
  { if ( ( pat_X == ((void *)0) ) && ( pat_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 146, "patmatch.c"); }; return(-1); } if ( ( pat_X != ((void *)0) ) && ( pat_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 146, "patmatch.c"); }; return(-1); } if ( pat_X != ((void *)0) ) { munmap(pat_X, pat_nX); pat_X = ((void *)0); pat_nX = 0; } };
  return(status);
}

variable_types:
tp
char *

variable_types: status int

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

variable_types: fileno int

variable_types: i int

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
count_nn_I8(
  long long *in,
  long long n,
  char *cfld,
  long long * restrict cnt,
  int n_out
  )
{
  int status = 0;
  register char *cptr = cfld;
  for ( long long i = 0; i < n; i++ ) {
    if ( *cptr++ == 0 ) { continue; }
    long long idx = in[i];
    int idxI4 = (int)idx;
    cnt[idxI4]++;
  }
  return(status);
}

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

variable_types:
in
long long *

variable_types:
n
long long

variable_types:
cfld
char *

variable_types:
cnt
long long *

variable_types:
cptr
char *

variable_types:
i
long long

variable_types:
idx
long long

return_type: int


decompiled_code:
__int64 __fastcall from_hex(int a1)
{
__int64 result; // rax

if ( ((*_ctype_b_loc())[(char)a1] & 0x800) != 0 )
result = (unsigned int)(a1 - 48);
else
result = (unsigned int)((*_ctype_tolower_loc())[(char)a1] - 87);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 result; // rax

if ( ((*_ctype_b_loc())[(char)a1] & 0x800) != 0 )
result = (unsigned int)(a1 - 48);
else
result = (unsigned int)((*_ctype_tolower_loc())[(char)a1] - 87);
return result;
}

original_code:
char
from_hex(
    char ch
    )
{
  return ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit) ? ch - '0' : tolower(ch) - 'a' + 10;
}

canonical_original_code:
char from_hex(char ch)
{
  return ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit) ? ch - '0' : tolower(ch) - 'a' + 10;
}

variable_types: ch char

return_type: char


decompiled_code:
__int64 __fastcall to_hex(char a1)
{
return (unsigned __int8)hex_0[a1 & 0xF];
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1)
{
return (unsigned __int8)hex_0[a1 & 0xF];
}

original_code:
char
to_hex(
    char code
    )
{
  static char hex[] = "0123456789abcdef";
  return hex[code & 15];
}

canonical_original_code:
char to_hex(char code)
{
  static char hex[] = "0123456789abcdef";
  return hex[code & 15];
}

variable_types: code char

variable_types:
hex
char []


decompiled_code:
__int64 __fastcall url_encode(const char *a1, char **a2)
{
const char *v3; // rbp
size_t v4; // rax
char *v5; // rax
char v6; // bl
char *v7; // r13
char *v8; // rdx
const unsigned __int16 **v9; // rax
const unsigned __int16 *v10; // rsi
__int64 result; // rax
char v12; // al
__int64 v13; // rdx
char v14; // al
__int64 v15; // rdx
char *v16; // rcx

v3 = a1;
v4 = strlen(a1);
v5 = (char *)malloc(3 * v4 + 1);
if ( v5 )
{
v6 = *a1;
v7 = v5;
v8 = v5;
if ( *a1 )
{
v9 = _ctype_b_loc();
v8 = v7;
v10 = *v9;
do
{
if ( (unsigned __int8)(v6 - 45) <= 1u || v6 == 95 || v6 == 126 || (v10[v6] & 8) != 0 )
{
*v8++ = v6;
}
else if ( v6 == 32 )
{
*v8++ = 43;
}
else
{
*v8 = 37;
v12 = to_hex(v6 >> 4);
*(_BYTE *)(v13 + 1) = v12;
v14 = to_hex(v6 & 0xF);
*(_BYTE *)(v15 + 2) = v14;
v8 = v16;
}
v6 = *++v3;
}
while ( v6 );
}
*v8 = 0;
result = 0LL;
*a2 = v7;
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 48LL, "url.c");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, char **a2)
{
const char *v3; // rbp
size_t v4; // rax
char *v5; // rax
char v6; // bl
char *v7; // r13
char *v8; // rdx
const unsigned __int16 **v9; // rax
const unsigned __int16 *v10; // rsi
__int64 result; // rax
char v12; // al
__int64 v13; // rdx
char v14; // al
__int64 v15; // rdx
char *v16; // rcx

v3 = a1;
v4 = strlen(a1);
v5 = (char *)malloc(3 * v4 + 1);
if ( v5 )
{
v6 = *a1;
v7 = v5;
v8 = v5;
if ( *a1 )
{
v9 = _ctype_b_loc();
v8 = v7;
v10 = *v9;
do
{
if ( (unsigned __int8)(v6 - 45) <= 1u || v6 == 95 || v6 == 126 || (v10[v6] & 8) != 0 )
{
*v8++ = v6;
}
else if ( v6 == 32 )
{
*v8++ = 43;
}
else
{
*v8 = 37;
v12 = func1(v6 >> 4);
*(_BYTE *)(v13 + 1) = v12;
v14 = func1(v6 & 0xF);
*(_BYTE *)(v15 + 2) = v14;
v8 = v16;
}
v6 = *++v3;
}
while ( v6 );
}
*v8 = 0;
result = 0LL;
*a2 = v7;
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 48LL, "url.c");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
url_encode(
    char *in_str,
    char **ptr_out_str
    )
{
  int status = 0;
  char *pstr = ((void *)0);
  char *out_str = ((void *)0);
  char *pbuf = ((void *)0);
  pstr = in_str;
  out_str = malloc(strlen(in_str) * 3 + 1);
  { if ( out_str == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 48, "url.c"); }; status = -1 ; goto BYE; }; } };
  pbuf = out_str;
  while (*pstr) {
    if (((*__ctype_b_loc ())[(int) ((*pstr))] & (unsigned short int) _ISalnum) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
      *pbuf++ = *pstr;
    else if (*pstr == ' ')
      *pbuf++ = '+';
    else
      *pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15);
    pstr++;
  }
  *pbuf = '\0';
  *ptr_out_str = out_str;
BYE:
  return status ;
}

canonical_original_code:
int url_encode(char *in_str, char **ptr_out_str)
{
  int status = 0;
  char *pstr = ((void *)0);
  char *out_str = ((void *)0);
  char *pbuf = ((void *)0);
  pstr = in_str;
  out_str = malloc(strlen(in_str) * 3 + 1);
  { if ( out_str == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 48, "url.c"); }; status = -1 ; goto BYE; }; } };
  pbuf = out_str;
  while (*pstr) {
    if (((*__ctype_b_loc ())[(int) ((*pstr))] & (unsigned short) _ISalnum) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
      *pbuf++ = *pstr;
    else if (*pstr == ' ')
      *pbuf++ = '+';
    else
      *pbuf++ = '%', *pbuf++ = to_hex(*pstr >> 4), *pbuf++ = to_hex(*pstr & 15);
    pstr++;
  }
  *pbuf = '\0';
  *ptr_out_str = out_str;
BYE:
  return status ;
}

variable_types:
pstr
char *

variable_types:
pbuf
char *


decompiled_code:
__int64 __fastcall url_decode(const char *a1, _QWORD *a2)
{
char v2; // bl
const char *v3; // rbp
size_t v4; // rax
_BYTE *v5; // rax
_BYTE *v6; // r14
char *v7; // r12
int v8; // edi
__int64 result; // rax
char v10; // r15
char v11; // bl
__int64 v12; // rdx

if ( a1 && (v2 = *a1, v3 = a1, *a1) )
{
v4 = strlen(a1);
v5 = malloc(v4 + 1);
v6 = v5;
if ( v5 )
{
v7 = v5;
while ( 1 )
{
v8 = v3[1];
if ( v2 != 37 )
break;
if ( !(_BYTE)v8 )
{
LABEL_11:
*v7 = 0;
result = 0LL;
*a2 = v6;
return result;
}
v10 = v3[2];
if ( v10 )
{
++v7;
v3 += 2;
v11 = from_hex(v8);
*(v7 - 1) = from_hex(v10) | (16 * v11);
v2 = v3[1];
LABEL_8:
++v3;
if ( !v2 )
goto LABEL_11;
}
else
{
++v3;
v2 = v8;
}
}
if ( v2 == 43 )
*v7 = 32;
else
*v7 = v2;
v2 = v8;
++v7;
goto LABEL_8;
}
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
v12 = 85LL;
}
else
{
v12 = 81LL;
}
fprintf(stderr, "Line %3d of File %s \n", v12, "url.c");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1, _QWORD *a2)
{
char v2; // bl
const char *v3; // rbp
size_t v4; // rax
_BYTE *v5; // rax
_BYTE *v6; // r14
char *v7; // r12
int v8; // edi
__int64 result; // rax
char v10; // r15
char v11; // bl
__int64 v12; // rdx

if ( a1 && (v2 = *a1, v3 = a1, *a1) )
{
v4 = strlen(a1);
v5 = malloc(v4 + 1);
v6 = v5;
if ( v5 )
{
v7 = v5;
while ( 1 )
{
v8 = v3[1];
if ( v2 != 37 )
break;
if ( !(_BYTE)v8 )
{
LABEL_11:
*v7 = 0;
result = 0LL;
*a2 = v6;
return result;
}
v10 = v3[2];
if ( v10 )
{
++v7;
v3 += 2;
v11 = func0(v8);
*(v7 - 1) = func0(v10) | (16 * v11);
v2 = v3[1];
LABEL_8:
++v3;
if ( !v2 )
goto LABEL_11;
}
else
{
++v3;
v2 = v8;
}
}
if ( v2 == 43 )
*v7 = 32;
else
*v7 = v2;
v2 = v8;
++v7;
goto LABEL_8;
}
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
v12 = 85LL;
}
else
{
v12 = 81LL;
}
fprintf(stderr, "Line %3d of File %s \n", v12, "url.c");
return 0xFFFFFFFFLL;
}

original_code:
int
url_decode(
    char *in_str,
    char **ptr_out_str
    )
{
  int status = 0;
  char *pstr;
  char *out_str;
  char *pbuf;
  if ( ( in_str == ((void *)0) ) || ( *in_str == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "url.c"); }; status = -1 ; goto BYE; }; }
  pstr = in_str;
  out_str = malloc(strlen(in_str) + 1);
  { if ( out_str == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 85, "url.c"); }; status = -1 ; goto BYE; }; } };
  pbuf = out_str;
  while (*pstr) {
    if (*pstr == '%') {
      if (pstr[1] && pstr[2]) {
 *pbuf++ = from_hex(pstr[1]) << 4 | from_hex(pstr[2]);
 pstr += 2;
      }
    } else if (*pstr == '+') {
      *pbuf++ = ' ';
    } else {
      *pbuf++ = *pstr;
    }
    pstr++;
  }
  *pbuf = '\0';
  *ptr_out_str = out_str;
BYE:
  return status ;
}

canonical_original_code:
int url_decode(char *in_str, char **ptr_out_str)
{
  int status = 0;
  char *pstr;
  char *out_str;
  char *pbuf;
  if ( ( in_str == ((void *)0) ) || ( *in_str == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "url.c"); }; status = -1 ; goto BYE; }; }
  pstr = in_str;
  out_str = malloc(strlen(in_str) + 1);
  { if ( out_str == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 85, "url.c"); }; status = -1 ; goto BYE; }; } };
  pbuf = out_str;
  while (*pstr) {
    if (*pstr == '%') {
      if (pstr[1] && pstr[2]) {
 *pbuf++ = from_hex(pstr[1]) << 4 | from_hex(pstr[2]);
 pstr += 2;
      }
    } else if (*pstr == '+') {
      *pbuf++ = ' ';
    } else {
      *pbuf++ = *pstr;
    }
    pstr++;
  }
  *pbuf = '\0';
  *ptr_out_str = out_str;
BYE:
  return status ;
}

variable_types: status int


decompiled_code:
__int64 __fastcall ext_url_encode(const char *a1, void *a2, int a3)
{
size_t v3; // rbx
int v4; // er12
char *v5; // r13
size_t v6; // rax
char *s; // [rsp+8h] [rbp-30h] BYREF

v3 = a3;
s = 0LL;
v4 = url_encode(a1, &s);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 120LL, "url.c");
}
else
{
v5 = s;
v6 = strlen(s);
if ( v6 < v3 )
{
memcpy(a2, v5, v6 + 1);
LABEL_4:
free(v5);
return (unsigned int)v4;
}
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 121LL, "url.c");
}
v5 = s;
if ( s )
goto LABEL_4;
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, void *a2, int a3)
{
size_t v3; // rbx
int v4; // er12
char *v5; // r13
size_t v6; // rax
char *s; // [rsp+8h] [rbp-30h] BYREF

v3 = a3;
s = 0LL;
v4 = func2(a1, &s);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 120LL, "url.c");
}
else
{
v5 = s;
v6 = strlen(s);
if ( v6 < v3 )
{
memcpy(a2, v5, v6 + 1);
LABEL_4:
free(v5);
return (unsigned int)v4;
}
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 121LL, "url.c");
}
v5 = s;
if ( s )
goto LABEL_4;
return (unsigned int)v4;
}

original_code:
int
ext_url_encode(
    char *in_str,
    char *rslt_buf,
    int sz_rslt_buf
    )
{
  int status = 0;
  char *out_str = ((void *)0);
  status = url_encode(in_str, &out_str); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 120, "url.c"); }; status = (status) ; goto BYE; } } };
  if ( strlen(out_str) >= sz_rslt_buf ) { { { fprintf(stderr, "Line %3d of File %s \n", 121, "url.c"); }; status = -1 ; goto BYE; }; }
  strcpy(rslt_buf, out_str);
BYE:
  { if ( (out_str) != ((void *)0) ) { free((out_str)); (out_str) = ((void *)0); } };
  return status ;
}

canonical_original_code:
int ext_url_encode(char *in_str, char *rslt_buf, int sz_rslt_buf)
{
  int status = 0;
  char *out_str = ((void *)0);
  status = url_encode(in_str, &out_str); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 120, "url.c"); }; status = (status) ; goto BYE; } } };
  if ( strlen(out_str) >= sz_rslt_buf ) { { { fprintf(stderr, "Line %3d of File %s \n", 121, "url.c"); }; status = -1 ; goto BYE; }; }
  strcpy(rslt_buf, out_str);
BYE:
  { if ( (out_str) != ((void *)0) ) { free((out_str)); (out_str) = ((void *)0); } };
  return status ;
}


decompiled_code:
__int64 __fastcall ext_url_decode(const char *a1, void *a2, int a3)
{
size_t v3; // rbx
int v4; // er12
char *v5; // r13
size_t v6; // rax
char *s; // [rsp+8h] [rbp-30h] BYREF

v3 = a3;
s = 0LL;
v4 = url_decode(a1, &s);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 140LL, "url.c");
}
else
{
v5 = s;
v6 = strlen(s);
if ( v6 < v3 )
{
memcpy(a2, v5, v6 + 1);
LABEL_4:
free(v5);
return (unsigned int)v4;
}
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 141LL, "url.c");
}
v5 = s;
if ( s )
goto LABEL_4;
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, void *a2, int a3)
{
size_t v3; // rbx
int v4; // er12
char *v5; // r13
size_t v6; // rax
char *s; // [rsp+8h] [rbp-30h] BYREF

v3 = a3;
s = 0LL;
v4 = func3(a1, &s);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 140LL, "url.c");
}
else
{
v5 = s;
v6 = strlen(s);
if ( v6 < v3 )
{
memcpy(a2, v5, v6 + 1);
LABEL_4:
free(v5);
return (unsigned int)v4;
}
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 141LL, "url.c");
}
v5 = s;
if ( s )
goto LABEL_4;
return (unsigned int)v4;
}

original_code:
int
ext_url_decode(
    char *in_str,
    char *rslt_buf,
    int sz_rslt_buf
    )
{
  int status = 0;
  char *out_str = ((void *)0);
  status = url_decode(in_str, &out_str); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 140, "url.c"); }; status = (status) ; goto BYE; } } };
  if ( strlen(out_str) >= sz_rslt_buf ) { { { fprintf(stderr, "Line %3d of File %s \n", 141, "url.c"); }; status = -1 ; goto BYE; }; }
  strcpy(rslt_buf, out_str);
BYE:
  { if ( (out_str) != ((void *)0) ) { free((out_str)); (out_str) = ((void *)0); } };
  return status ;
}

canonical_original_code:
int ext_url_decode(char *in_str, char *rslt_buf, int sz_rslt_buf)
{
  int status = 0;
  char *out_str = ((void *)0);
  status = url_decode(in_str, &out_str); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 140, "url.c"); }; status = (status) ; goto BYE; } } };
  if ( strlen(out_str) >= sz_rslt_buf ) { { { fprintf(stderr, "Line %3d of File %s \n", 141, "url.c"); }; status = -1 ; goto BYE; }; }
  strcpy(rslt_buf, out_str);
BYE:
  { if ( (out_str) != ((void *)0) ) { free((out_str)); (out_str) = ((void *)0); } };
  return status ;
}


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

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

variable_types:
nR
long long

variable_types:
out
int *

variable_types: outv int

return_type: void


original_code:
void
qsort_dsc_I4 (
     void *const pbase,
     size_t total_elems,
     size_t size,
     __compar_fn_t cmp
     )
{
  register char *base_ptr = (char *) pbase;
  if ( size != sizeof(int) ) { exit(1); }
  const size_t max_thresh = 4 * size;
  if (total_elems == 0) {
    return;
  }
  if ( total_elems > 4 ) {
    char *lo = base_ptr;
    char *hi = &lo[size * (total_elems - 1)];
    stack_node stack[(8 * sizeof(size_t))];
    stack_node *top = stack;
    ((void) ((top->lo = (((void *)0))), (top->hi = (((void *)0))), ++top));
    while ((stack < top)) {
      char *left_ptr;
      char *right_ptr;
      char *mid = lo + size * ((hi - lo) / size >> 1);
      if ( *((int *)mid) > *((int *)lo) ) {
 { int *ia = (int *)mid; int *ib = (int *)lo; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      if ( *((int *)hi) > *((int *)mid) ) {
 { int *ia = (int *)mid; int *ib = (int *)hi; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      else {
 goto jump_over;
      }
      if ( *((int *)mid) > *((int *)lo) ) {
 { int *ia = (int *)mid; int *ib = (int *)lo; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
    jump_over:;
      left_ptr = lo + size;
      right_ptr = hi - size;
      do {
 while ( *((int *)left_ptr) > *((int *)mid) ) {
   left_ptr += size;
 }
 while ( *((int *)mid) > *((int *)right_ptr) ) {
   right_ptr -= size;
 }
 if (left_ptr < right_ptr) {
   { int *ia = (int *)left_ptr; int *ib = (int *)right_ptr; int itmp = *ia; *ia = *ib; *ib = itmp; };
   if (mid == left_ptr) {
     mid = right_ptr;
   }
   else if (mid == right_ptr) {
     mid = left_ptr;
   }
   left_ptr += size;
   right_ptr -= size;
 }
 else if (left_ptr == right_ptr) {
   left_ptr += size;
   right_ptr -= size;
   break;
 }
      } while (left_ptr <= right_ptr);
      if ((size_t) (right_ptr - lo) <= max_thresh) {
 if ((size_t) (hi - left_ptr) <= max_thresh) {
   ((void) (--top, (lo = top->lo), (hi = top->hi)));
 }
 else {
   lo = left_ptr;
 }
      }
      else if ((size_t) (hi - left_ptr) <= max_thresh) {
 hi = right_ptr;
      }
      else if ((right_ptr - lo) > (hi - left_ptr)) {
 ((void) ((top->lo = (lo)), (top->hi = (right_ptr)), ++top));
 lo = left_ptr;
      }
      else {
 ((void) ((top->lo = (left_ptr)), (top->hi = (hi)), ++top));
 hi = right_ptr;
      }
    }
  }
  {
    char *const end_ptr = &base_ptr[size * (total_elems - 1)];
    char *tmp_ptr = base_ptr;
    char *thresh = ((end_ptr) < (base_ptr + max_thresh) ? (end_ptr) : (base_ptr + max_thresh));
    register char *run_ptr;
    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) {
      if ( *((int *)run_ptr) > *((int *) tmp_ptr) ) {
        tmp_ptr = run_ptr;
      }
    }
    if (tmp_ptr != base_ptr) {
      { int *ia = (int *)tmp_ptr; int *ib = (int *)base_ptr; int itmp = *ia; *ia = *ib; *ib = itmp; };
    }
    run_ptr = base_ptr + size;
    while ((run_ptr += size) <= end_ptr) {
      tmp_ptr = run_ptr - size;
      while ( *((int *)run_ptr) > *((int *)tmp_ptr) ) {
 tmp_ptr -= size;
      }
      tmp_ptr += size;
      if (tmp_ptr != run_ptr) {
 char *trav;
 trav = run_ptr + size;
 while (--trav >= run_ptr) {
   char c = *trav;
   char *hi, *lo;
   for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) {
     *hi = *lo;
   }
   *hi = c;
 }
      }
    }
  }
}

canonical_original_code:
void qsort_dsc_I4(void *pbase, unsigned long total_elems, unsigned long size, int (*cmp)(void *, void *))
{
  register char *base_ptr = (char *) pbase;
  if ( size != sizeof(int) ) { exit(1); }
  unsigned long max_thresh = 4 * size;
  if (total_elems == 0) {
    return;
  }
  if ( total_elems > 4 ) {
    char *lo = base_ptr;
    char *hi = &lo[size * (total_elems - 1)];
    struct stack_node stack[-1];
    struct stack_node *top = stack;
    ((void) ((top->lo = (((void *)0))), (top->hi = (((void *)0))), ++top));
    while ((stack < top)) {
      char *left_ptr;
      char *right_ptr;
      char *mid = lo + size * ((hi - lo) / size >> 1);
      if ( *((int *)mid) > *((int *)lo) ) {
 { int *ia = (int *)mid; int *ib = (int *)lo; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      if ( *((int *)hi) > *((int *)mid) ) {
 { int *ia = (int *)mid; int *ib = (int *)hi; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      else {
 goto jump_over;
      }
      if ( *((int *)mid) > *((int *)lo) ) {
 { int *ia = (int *)mid; int *ib = (int *)lo; int itmp = *ia; *ia = *ib; *ib = itmp; };
      }
    jump_over:;
      left_ptr = lo + size;
      right_ptr = hi - size;
      do {
 while ( *((int *)left_ptr) > *((int *)mid) ) {
   left_ptr += size;
 }
 while ( *((int *)mid) > *((int *)right_ptr) ) {
   right_ptr -= size;
 }
 if (left_ptr < right_ptr) {
   { int *ia = (int *)left_ptr; int *ib = (int *)right_ptr; int itmp = *ia; *ia = *ib; *ib = itmp; };
   if (mid == left_ptr) {
     mid = right_ptr;
   }
   else if (mid == right_ptr) {
     mid = left_ptr;
   }
   left_ptr += size;
   right_ptr -= size;
 }
 else if (left_ptr == right_ptr) {
   left_ptr += size;
   right_ptr -= size;
   break;
 }
      } while (left_ptr <= right_ptr);
      if ((unsigned long) (right_ptr - lo) <= max_thresh) {
 if ((unsigned long) (hi - left_ptr) <= max_thresh) {
   ((void) (--top, (lo = top->lo), (hi = top->hi)));
 }
 else {
   lo = left_ptr;
 }
      }
      else if ((unsigned long) (hi - left_ptr) <= max_thresh) {
 hi = right_ptr;
      }
      else if ((right_ptr - lo) > (hi - left_ptr)) {
 ((void) ((top->lo = (lo)), (top->hi = (right_ptr)), ++top));
 lo = left_ptr;
      }
      else {
 ((void) ((top->lo = (left_ptr)), (top->hi = (hi)), ++top));
 hi = right_ptr;
      }
    }
  }
  {
    char *end_ptr = &base_ptr[size * (total_elems - 1)];
    char *tmp_ptr = base_ptr;
    char *thresh = ((end_ptr) < (base_ptr + max_thresh) ? (end_ptr) : (base_ptr + max_thresh));
    register char *run_ptr;
    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) {
      if ( *((int *)run_ptr) > *((int *) tmp_ptr) ) {
        tmp_ptr = run_ptr;
      }
    }
    if (tmp_ptr != base_ptr) {
      { int *ia = (int *)tmp_ptr; int *ib = (int *)base_ptr; int itmp = *ia; *ia = *ib; *ib = itmp; };
    }
    run_ptr = base_ptr + size;
    while ((run_ptr += size) <= end_ptr) {
      tmp_ptr = run_ptr - size;
      while ( *((int *)run_ptr) > *((int *)tmp_ptr) ) {
 tmp_ptr -= size;
      }
      tmp_ptr += size;
      if (tmp_ptr != run_ptr) {
 char *trav;
 trav = run_ptr + size;
 while (--trav >= run_ptr) {
   char c = *trav;
   char *hi; char *lo;
   for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) {
     *hi = *lo;
   }
   *hi = c;
 }
      }
    }
  }
}

variable_types:
pbase
void *

variable_types:
size
unsigned long

variable_types:
cmp
int (*)(void *, void *)

variable_types:
lo
char *

variable_types:
hi
char *

variable_types: struct stack_node { char *lo; char *hi; } [-1]

variable_types: struct stack_node { char *lo; char *hi; } *

variable_types:
mid
char *

variable_types:
ia
int *

variable_types:
ib
int *

variable_types: itmp int

variable_types:
thresh
char *

variable_types:
trav
char *

variable_types: c char


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

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

variable_types:
nR
long long

variable_types:
i
long long


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

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

variable_types: status int


original_code:
void
qsort_asc_I8 (
     void *const pbase,
     size_t total_elems,
     size_t size,
     __compar_fn_t cmp
     )
{
  register char *base_ptr = (char *) pbase;
  if ( size != sizeof(long long) ) { exit(1); }
  const size_t max_thresh = 4 * size;
  if (total_elems == 0) {
    return;
  }
  if ( total_elems > 4 ) {
    char *lo = base_ptr;
    char *hi = &lo[size * (total_elems - 1)];
    stack_node stack[(8 * sizeof(size_t))];
    stack_node *top = stack;
    ((void) ((top->lo = (((void *)0))), (top->hi = (((void *)0))), ++top));
    while ((stack < top)) {
      char *left_ptr;
      char *right_ptr;
      char *mid = lo + size * ((hi - lo) / size >> 1);
      if ( *((long long *)mid) < *((long long *)lo) ) {
 { long long *ia = (long long *)mid; long long *ib = (long long *)lo; long long itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      if ( *((long long *)hi) < *((long long *)mid) ) {
 { long long *ia = (long long *)mid; long long *ib = (long long *)hi; long long itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      else {
 goto jump_over;
      }
      if ( *((long long *)mid) < *((long long *)lo) ) {
 { long long *ia = (long long *)mid; long long *ib = (long long *)lo; long long itmp = *ia; *ia = *ib; *ib = itmp; };
      }
    jump_over:;
      left_ptr = lo + size;
      right_ptr = hi - size;
      do {
 while ( *((long long *)left_ptr) < *((long long *)mid) ) {
   left_ptr += size;
 }
 while ( *((long long *)mid) < *((long long *)right_ptr) ) {
   right_ptr -= size;
 }
 if (left_ptr < right_ptr) {
   { long long *ia = (long long *)left_ptr; long long *ib = (long long *)right_ptr; long long itmp = *ia; *ia = *ib; *ib = itmp; };
   if (mid == left_ptr) {
     mid = right_ptr;
   }
   else if (mid == right_ptr) {
     mid = left_ptr;
   }
   left_ptr += size;
   right_ptr -= size;
 }
 else if (left_ptr == right_ptr) {
   left_ptr += size;
   right_ptr -= size;
   break;
 }
      } while (left_ptr <= right_ptr);
      if ((size_t) (right_ptr - lo) <= max_thresh) {
 if ((size_t) (hi - left_ptr) <= max_thresh) {
   ((void) (--top, (lo = top->lo), (hi = top->hi)));
 }
 else {
   lo = left_ptr;
 }
      }
      else if ((size_t) (hi - left_ptr) <= max_thresh) {
 hi = right_ptr;
      }
      else if ((right_ptr - lo) > (hi - left_ptr)) {
 ((void) ((top->lo = (lo)), (top->hi = (right_ptr)), ++top));
 lo = left_ptr;
      }
      else {
 ((void) ((top->lo = (left_ptr)), (top->hi = (hi)), ++top));
 hi = right_ptr;
      }
    }
  }
  {
    char *const end_ptr = &base_ptr[size * (total_elems - 1)];
    char *tmp_ptr = base_ptr;
    char *thresh = ((end_ptr) < (base_ptr + max_thresh) ? (end_ptr) : (base_ptr + max_thresh));
    register char *run_ptr;
    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) {
      if ( *((long long *)run_ptr) < *((long long *) tmp_ptr) ) {
        tmp_ptr = run_ptr;
      }
    }
    if (tmp_ptr != base_ptr) {
      { long long *ia = (long long *)tmp_ptr; long long *ib = (long long *)base_ptr; long long itmp = *ia; *ia = *ib; *ib = itmp; };
    }
    run_ptr = base_ptr + size;
    while ((run_ptr += size) <= end_ptr) {
      tmp_ptr = run_ptr - size;
      while ( *((long long *)run_ptr) < *((long long *)tmp_ptr) ) {
 tmp_ptr -= size;
      }
      tmp_ptr += size;
      if (tmp_ptr != run_ptr) {
 char *trav;
 trav = run_ptr + size;
 while (--trav >= run_ptr) {
   char c = *trav;
   char *hi, *lo;
   for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) {
     *hi = *lo;
   }
   *hi = c;
 }
      }
    }
  }
}

canonical_original_code:
void qsort_asc_I8(void *pbase, unsigned long total_elems, unsigned long size, int (*cmp)(void *, void *))
{
  register char *base_ptr = (char *) pbase;
  if ( size != sizeof(long long) ) { exit(1); }
  unsigned long max_thresh = 4 * size;
  if (total_elems == 0) {
    return;
  }
  if ( total_elems > 4 ) {
    char *lo = base_ptr;
    char *hi = &lo[size * (total_elems - 1)];
    struct stack_node stack[-1];
    struct stack_node *top = stack;
    ((void) ((top->lo = (((void *)0))), (top->hi = (((void *)0))), ++top));
    while ((stack < top)) {
      char *left_ptr;
      char *right_ptr;
      char *mid = lo + size * ((hi - lo) / size >> 1);
      if ( *((long long *)mid) < *((long long *)lo) ) {
 { long long *ia = (long long *)mid; long long *ib = (long long *)lo; long long itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      if ( *((long long *)hi) < *((long long *)mid) ) {
 { long long *ia = (long long *)mid; long long *ib = (long long *)hi; long long itmp = *ia; *ia = *ib; *ib = itmp; };
      }
      else {
 goto jump_over;
      }
      if ( *((long long *)mid) < *((long long *)lo) ) {
 { long long *ia = (long long *)mid; long long *ib = (long long *)lo; long long itmp = *ia; *ia = *ib; *ib = itmp; };
      }
    jump_over:;
      left_ptr = lo + size;
      right_ptr = hi - size;
      do {
 while ( *((long long *)left_ptr) < *((long long *)mid) ) {
   left_ptr += size;
 }
 while ( *((long long *)mid) < *((long long *)right_ptr) ) {
   right_ptr -= size;
 }
 if (left_ptr < right_ptr) {
   { long long *ia = (long long *)left_ptr; long long *ib = (long long *)right_ptr; long long itmp = *ia; *ia = *ib; *ib = itmp; };
   if (mid == left_ptr) {
     mid = right_ptr;
   }
   else if (mid == right_ptr) {
     mid = left_ptr;
   }
   left_ptr += size;
   right_ptr -= size;
 }
 else if (left_ptr == right_ptr) {
   left_ptr += size;
   right_ptr -= size;
   break;
 }
      } while (left_ptr <= right_ptr);
      if ((unsigned long) (right_ptr - lo) <= max_thresh) {
 if ((unsigned long) (hi - left_ptr) <= max_thresh) {
   ((void) (--top, (lo = top->lo), (hi = top->hi)));
 }
 else {
   lo = left_ptr;
 }
      }
      else if ((unsigned long) (hi - left_ptr) <= max_thresh) {
 hi = right_ptr;
      }
      else if ((right_ptr - lo) > (hi - left_ptr)) {
 ((void) ((top->lo = (lo)), (top->hi = (right_ptr)), ++top));
 lo = left_ptr;
      }
      else {
 ((void) ((top->lo = (left_ptr)), (top->hi = (hi)), ++top));
 hi = right_ptr;
      }
    }
  }
  {
    char *end_ptr = &base_ptr[size * (total_elems - 1)];
    char *tmp_ptr = base_ptr;
    char *thresh = ((end_ptr) < (base_ptr + max_thresh) ? (end_ptr) : (base_ptr + max_thresh));
    register char *run_ptr;
    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) {
      if ( *((long long *)run_ptr) < *((long long *) tmp_ptr) ) {
        tmp_ptr = run_ptr;
      }
    }
    if (tmp_ptr != base_ptr) {
      { long long *ia = (long long *)tmp_ptr; long long *ib = (long long *)base_ptr; long long itmp = *ia; *ia = *ib; *ib = itmp; };
    }
    run_ptr = base_ptr + size;
    while ((run_ptr += size) <= end_ptr) {
      tmp_ptr = run_ptr - size;
      while ( *((long long *)run_ptr) < *((long long *)tmp_ptr) ) {
 tmp_ptr -= size;
      }
      tmp_ptr += size;
      if (tmp_ptr != run_ptr) {
 char *trav;
 trav = run_ptr + size;
 while (--trav >= run_ptr) {
   char c = *trav;
   char *hi; char *lo;
   for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) {
     *hi = *lo;
   }
   *hi = c;
 }
      }
    }
  }
}

variable_types:
pbase
void *

variable_types:
ia
long long *

variable_types:
ib
long long *

variable_types:
itmp
long long

user_defined_types: struct stack_node { char *lo; char *hi; }


decompiled_code:
__int64 __fastcall copy_tbl(char *s1, char *s2)
{
int v3; // er13
__int64 v4; // rbx
__int64 v5; // rsi
__int64 v7; // rdx
int v8; // [rsp+4h] [rbp-10B4h] BYREF
char v9[4]; // [rsp+8h] [rbp-10B0h] BYREF
int v10; // [rsp+Ch] [rbp-10ACh] BYREF
char s[32]; // [rsp+10h] [rbp-10A8h] BYREF
__int64 v12[6]; // [rsp+30h] [rbp-1088h] BYREF
char v13[48]; // [rsp+60h] [rbp-1058h] BYREF
int v14[1034]; // [rsp+90h] [rbp-1028h] BYREF

v10 = 0;
zero_string(s, 32LL);
if ( !s1 || !*s1 )
{
v7 = 31LL;
goto LABEL_21;
}
if ( !s2 || !*s2 )
{
v7 = 32LL;
goto LABEL_21;
}
if ( !strcmp(s1, s2) )
{
v3 = -1;
fprintf(stderr, "Line %3d of File %s \n", 33LL, "copy_tbl.c");
return (unsigned int)v3;
}
v3 = is_tbl(s1, &v8, v12);
if ( v3 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 35LL, "copy_tbl.c");
return (unsigned int)v3;
}
if ( v8 < 0 || v8 >= g_n_tbl )
{
v7 = 36LL;
LABEL_21:
v3 = -1;
fprintf(stderr, "Line %3d of File %s \n", v7, "copy_tbl.c");
return (unsigned int)v3;
}
v3 = del_tbl(s2, 0xFFFFFFFFLL);
if ( v3 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "copy_tbl.c");
}
else
{
sprintf(s, "%lld", v12[0]);
tbl_meta(s1, 0LL, v14, &v10);
v3 = add_tbl(s2, s, v9, v13);
if ( v3 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "copy_tbl.c");
}
else
{
v4 = 0LL;
if ( v10 > 0 )
{
while ( 1 )
{
v5 = g_flds + 120LL * v14[v4];
if ( (unsigned int)(*(_DWORD *)(v5 + 32) - 2) <= 5 )
{
v3 = copy_fld(s1, v5 + 40, 0LL, s2);
if ( v3 < 0 )
break;
}
if ( v10 <= (int)++v4 )
return (unsigned int)v3;
}
fprintf(stderr, "Line %3d of File %s \n", 57LL, "copy_tbl.c");
}
}
}
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, char *s2)
{
int v3; // er13
__int64 v4; // rbx
__int64 v5; // rsi
__int64 v7; // rdx
int v8; // [rsp+4h] [rbp-10B4h] BYREF
char v9[4]; // [rsp+8h] [rbp-10B0h] BYREF
int v10; // [rsp+Ch] [rbp-10ACh] BYREF
char s[32]; // [rsp+10h] [rbp-10A8h] BYREF
__int64 v12[6]; // [rsp+30h] [rbp-1088h] BYREF
char v13[48]; // [rsp+60h] [rbp-1058h] BYREF
int v14[1034]; // [rsp+90h] [rbp-1028h] BYREF

v10 = 0;
zero_string(s, 32LL);
if ( !s1 || !*s1 )
{
v7 = 31LL;
goto LABEL_21;
}
if ( !s2 || !*s2 )
{
v7 = 32LL;
goto LABEL_21;
}
if ( !strcmp(s1, s2) )
{
v3 = -1;
fprintf(stderr, "Line %3d of File %s \n", 33LL, "copy_tbl.c");
return (unsigned int)v3;
}
v3 = is_tbl(s1, &v8, v12);
if ( v3 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 35LL, "copy_tbl.c");
return (unsigned int)v3;
}
if ( v8 < 0 || v8 >= g_n_tbl )
{
v7 = 36LL;
LABEL_21:
v3 = -1;
fprintf(stderr, "Line %3d of File %s \n", v7, "copy_tbl.c");
return (unsigned int)v3;
}
v3 = del_tbl(s2, 0xFFFFFFFFLL);
if ( v3 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "copy_tbl.c");
}
else
{
sprintf(s, "%lld", v12[0]);
tbl_meta(s1, 0LL, v14, &v10);
v3 = add_tbl(s2, s, v9, v13);
if ( v3 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "copy_tbl.c");
}
else
{
v4 = 0LL;
if ( v10 > 0 )
{
while ( 1 )
{
v5 = g_flds + 120LL * v14[v4];
if ( (unsigned int)(*(_DWORD *)(v5 + 32) - 2) <= 5 )
{
v3 = copy_fld(s1, v5 + 40, 0LL, s2);
if ( v3 < 0 )
break;
}
if ( v10 <= (int)++v4 )
return (unsigned int)v3;
}
fprintf(stderr, "Line %3d of File %s \n", 57LL, "copy_tbl.c");
}
}
}
return (unsigned int)v3;
}

original_code:
int
copy_tbl(
  char *in_tbl,
  char *out_tbl
  )
{
  int status = 0;
  int in_tbl_id, out_tbl_id;
  TBL_REC_TYPE in_tbl_rec, out_tbl_rec;
  long long nR; char str_nR[32];
  int num_flds = 0; int fld_ids[1024];
  zero_string(str_nR, 32);
  if ( ( in_tbl == ((void *)0) ) || ( *in_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 31, "copy_tbl.c"); }; status = -1 ; goto BYE; }; }
  if ( ( out_tbl == ((void *)0) ) || ( *out_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "copy_tbl.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(in_tbl, out_tbl) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 33, "copy_tbl.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(in_tbl, &in_tbl_id, &in_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "copy_tbl.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (in_tbl_id) < (0) ) || ( (in_tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "copy_tbl.c"); }; status = -1 ; goto BYE; }; } };
  status = del_tbl(out_tbl, -1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "copy_tbl.c"); }; status = (status) ; goto BYE; } } };
  nR = in_tbl_rec.nR;
  sprintf(str_nR, "%lld", nR);
  status = tbl_meta(in_tbl, 0, fld_ids, &num_flds);
  status = add_tbl(out_tbl, str_nR, &out_tbl_id, &out_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "copy_tbl.c"); }; status = (status) ; goto BYE; } } };
  for ( int i = 0; i < num_flds; i++ ) {
    int fld_id; char *fldname = ((void *)0);
    fld_id = fld_ids[i];
    FLD_REC_TYPE fld_rec = g_flds[fld_id];
    fldname = g_flds[fld_id].name;
    _Bool skip_fld = 0;
    switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 : case F4 : case F8 : break;
      default : skip_fld = 1; break;
    }
    if ( skip_fld == 1 ) { continue; }
    status = copy_fld(in_tbl, fldname, ((void *)0), out_tbl);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "copy_tbl.c"); }; status = (status) ; goto BYE; } } };
  }
 BYE:
  return status ;
}

canonical_original_code:
int copy_tbl(char *in_tbl, char *out_tbl)
{
  int status = 0;
  int in_tbl_id; int out_tbl_id;
  struct _TBL_REC_TYPE in_tbl_rec; struct _TBL_REC_TYPE out_tbl_rec;
  long long nR; char str_nR[32];
  int num_flds = 0; int fld_ids[1024];
  zero_string(str_nR, 32);
  if ( ( in_tbl == ((void *)0) ) || ( *in_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 31, "copy_tbl.c"); }; status = -1 ; goto BYE; }; }
  if ( ( out_tbl == ((void *)0) ) || ( *out_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "copy_tbl.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(in_tbl, out_tbl) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 33, "copy_tbl.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(in_tbl, &in_tbl_id, &in_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "copy_tbl.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (in_tbl_id) < (0) ) || ( (in_tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "copy_tbl.c"); }; status = -1 ; goto BYE; }; } };
  status = del_tbl(out_tbl, -1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "copy_tbl.c"); }; status = (status) ; goto BYE; } } };
  nR = in_tbl_rec.nR;
  sprintf(str_nR, "%lld", nR);
  status = tbl_meta(in_tbl, 0, fld_ids, &num_flds);
  status = add_tbl(out_tbl, str_nR, &out_tbl_id, &out_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "copy_tbl.c"); }; status = (status) ; goto BYE; } } };
  for ( int i = 0; i < num_flds; i++ ) {
    int fld_id; char *fldname = ((void *)0);
    fld_id = fld_ids[i];
    struct _FLD_REC_TYPE fld_rec = g_flds[fld_id];
    fldname = g_flds[fld_id].name;
    _Bool skip_fld = 0;
    switch ( fld_rec.fldtype ) {
      case I1 : case I2 : case I4 : case I8 : case F4 : case F8 : break;
      default : skip_fld = 1; break;
    }
    if ( skip_fld == 1 ) { continue; }
    status = copy_fld(in_tbl, fldname, ((void *)0), out_tbl);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "copy_tbl.c"); }; status = (status) ; goto BYE; } } };
  }
 BYE:
  return status ;
}

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

variable_types:
fldname
char *

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


decompiled_code:
__int64 __fastcall g_count(char *s1, char *s2, char *a3)
{
int v4; // er15
char *v5; // rbp
__int64 v7; // rdx
_BYTE v8[712]; // [rsp-860h] [rbp-1D38h] BYREF
_BYTE v9[712]; // [rsp-598h] [rbp-1A70h] BYREF
_BYTE v10[712]; // [rsp-2D0h] [rbp-17A8h] BYREF
int v11; // [rsp+0h] [rbp-14D8h] BYREF
int v12; // [rsp+4h] [rbp-14D4h] BYREF
int v13; // [rsp+8h] [rbp-14D0h] BYREF
unsigned int v14; // [rsp+Ch] [rbp-14CCh] BYREF
char *haystack; // [rsp+10h] [rbp-14C8h] BYREF
__int64 v16; // [rsp+18h] [rbp-14C0h] BYREF
__int64 v17; // [rsp+20h] [rbp-14B8h] BYREF
__int64 v18; // [rsp+28h] [rbp-14B0h] BYREF
int v19[180]; // [rsp+30h] [rbp-14A8h] BYREF
int v20[180]; // [rsp+300h] [rbp-11D8h] BYREF
int v21[180]; // [rsp+5D0h] [rbp-F08h] BYREF
char s[1024]; // [rsp+8A0h] [rbp-C38h] BYREF
char v23[2104]; // [rsp+CA0h] [rbp-838h] BYREF

v11 = -1;
v12 = -1;
v13 = -1;
haystack = 0LL;
v16 = 0LL;
v17 = 0LL;
v18 = 0LL;
v14 = 0;
g_mmap_meta_data(&g_docroot, &v16, &v17, &v18, &v14);
if ( !s1 || !*s1 )
{
v7 = 44LL;
LABEL_36:
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", v7, "g_count.c");
goto LABEL_27;
}
if ( !s2 || !*s2 )
{
v7 = 45LL;
goto LABEL_36;
}
if ( !a3 || !*a3 )
{
v7 = 46LL;
goto LABEL_36;
}
if ( !strcmp(s1, s2) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_count.c");
goto LABEL_27;
}
if ( !strcmp(s1, a3) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_count.c");
goto LABEL_27;
}
if ( !strcmp(a3, s2) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_count.c");
goto LABEL_27;
}
v4 = g_is_fld(v18, v14, s1, &v11, v19);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_count.c");
goto LABEL_27;
}
if ( v11 < 0 )
{
v7 = 52LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v19[8]) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_count.c");
goto LABEL_27;
}
v4 = g_is_fld(v18, v14, s2, &v12, v20);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "g_count.c");
goto LABEL_27;
}
if ( v12 < 0 )
{
v7 = 56LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v20[8]) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 57LL, "g_count.c");
goto LABEL_27;
}
v4 = g_is_fld(v18, v14, a3, &v13, v21);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "g_count.c");
goto LABEL_27;
}
if ( v13 < 0 )
{
v7 = 60LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v21[8]) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_count.c");
goto LABEL_27;
}
qmemcpy(v10, v21, sizeof(v10));
qmemcpy(v9, v20, sizeof(v9));
qmemcpy(v8, v19, sizeof(v8));
v4 = g_chk_count();
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "g_count.c");
goto LABEL_27;
}
zero_string(v23, 2048LL);
zero_string(s, 1024LL);
sprintf(s, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s", s1, s2, a3);
v4 = g_make_url(s, v23);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 69LL, "g_count.c");
goto LABEL_27;
}
v4 = g_call_gpu(v23, &haystack);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 70LL, "g_count.c");
goto LABEL_27;
}
v5 = haystack;
if ( haystack )
{
if ( strstr(haystack, "\"\"") )
{
LABEL_24:
free(v5);
haystack = 0LL;
goto LABEL_25;
}
fprintf(stderr, "Response from GPU = [%s]\n", v5);
LABEL_27:
v5 = haystack;
if ( !haystack )
goto LABEL_25;
goto LABEL_24;
}
LABEL_25:
g_unmap_meta_data(v16, v17);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, char *s2, char *a3)
{
int v4; // er15
char *v5; // rbp
__int64 v7; // rdx
_BYTE v8[712]; // [rsp-860h] [rbp-1D38h] BYREF
_BYTE v9[712]; // [rsp-598h] [rbp-1A70h] BYREF
_BYTE v10[712]; // [rsp-2D0h] [rbp-17A8h] BYREF
int v11; // [rsp+0h] [rbp-14D8h] BYREF
int v12; // [rsp+4h] [rbp-14D4h] BYREF
int v13; // [rsp+8h] [rbp-14D0h] BYREF
unsigned int v14; // [rsp+Ch] [rbp-14CCh] BYREF
char *haystack; // [rsp+10h] [rbp-14C8h] BYREF
__int64 v16; // [rsp+18h] [rbp-14C0h] BYREF
__int64 v17; // [rsp+20h] [rbp-14B8h] BYREF
__int64 v18; // [rsp+28h] [rbp-14B0h] BYREF
int v19[180]; // [rsp+30h] [rbp-14A8h] BYREF
int v20[180]; // [rsp+300h] [rbp-11D8h] BYREF
int v21[180]; // [rsp+5D0h] [rbp-F08h] BYREF
char s[1024]; // [rsp+8A0h] [rbp-C38h] BYREF
char v23[2104]; // [rsp+CA0h] [rbp-838h] BYREF

v11 = -1;
v12 = -1;
v13 = -1;
haystack = 0LL;
v16 = 0LL;
v17 = 0LL;
v18 = 0LL;
v14 = 0;
g_mmap_meta_data(&g_docroot, &v16, &v17, &v18, &v14);
if ( !s1 || !*s1 )
{
v7 = 44LL;
LABEL_36:
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", v7, "g_count.c");
goto LABEL_27;
}
if ( !s2 || !*s2 )
{
v7 = 45LL;
goto LABEL_36;
}
if ( !a3 || !*a3 )
{
v7 = 46LL;
goto LABEL_36;
}
if ( !strcmp(s1, s2) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_count.c");
goto LABEL_27;
}
if ( !strcmp(s1, a3) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_count.c");
goto LABEL_27;
}
if ( !strcmp(a3, s2) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_count.c");
goto LABEL_27;
}
v4 = g_is_fld(v18, v14, s1, &v11, v19);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_count.c");
goto LABEL_27;
}
if ( v11 < 0 )
{
v7 = 52LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v19[8]) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_count.c");
goto LABEL_27;
}
v4 = g_is_fld(v18, v14, s2, &v12, v20);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "g_count.c");
goto LABEL_27;
}
if ( v12 < 0 )
{
v7 = 56LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v20[8]) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 57LL, "g_count.c");
goto LABEL_27;
}
v4 = g_is_fld(v18, v14, a3, &v13, v21);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "g_count.c");
goto LABEL_27;
}
if ( v13 < 0 )
{
v7 = 60LL;
goto LABEL_36;
}
if ( !(unsigned int)is_fldtype_goodfor_gpu((unsigned int)v21[8]) )
{
v4 = -1;
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_count.c");
goto LABEL_27;
}
qmemcpy(v10, v21, sizeof(v10));
qmemcpy(v9, v20, sizeof(v9));
qmemcpy(v8, v19, sizeof(v8));
v4 = g_chk_count();
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "g_count.c");
goto LABEL_27;
}
zero_string(v23, 2048LL);
zero_string(s, 1024LL);
sprintf(s, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s", s1, s2, a3);
v4 = g_make_url(s, v23);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 69LL, "g_count.c");
goto LABEL_27;
}
v4 = g_call_gpu(v23, &haystack);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 70LL, "g_count.c");
goto LABEL_27;
}
v5 = haystack;
if ( haystack )
{
if ( strstr(haystack, "\"\"") )
{
LABEL_24:
free(v5);
haystack = 0LL;
goto LABEL_25;
}
fprintf(stderr, "Response from GPU = [%s]\n", v5);
LABEL_27:
v5 = haystack;
if ( !haystack )
goto LABEL_25;
goto LABEL_24;
}
LABEL_25:
g_unmap_meta_data(v16, v17);
return (unsigned int)v4;
}

original_code:
int
g_count(
    char *f1,
    char *cfld,
    char *f2
    )
{
  int status = 0;
  int f1_id = -1; GPU_REG_TYPE f1_rec;
  int cfld_id = -1; GPU_REG_TYPE cfld_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;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( ( cfld == ((void *)0) ) || ( *cfld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, cfld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f2, cfld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_count.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", 51, "g_count.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_count.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, cfld, &cfld_id, &cfld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "g_count.c"); }; status = (status) ; goto BYE; } } };
  if ( cfld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(cfld_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "g_count.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", 59, "g_count.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_count.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_count(f1_rec, cfld_rec, f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "g_count.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s",
        f1, cfld, f2);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "g_count.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "g_count.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    if ( strstr(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_count(char *f1, char *cfld, char *f2)
{
  int status = 0;
  int f1_id = -1; struct _GPU_REG_TYPE f1_rec;
  int cfld_id = -1; struct _GPU_REG_TYPE cfld_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;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( ( cfld == ((void *)0) ) || ( *cfld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, cfld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f2, cfld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_count.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", 51, "g_count.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_count.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, cfld, &cfld_id, &cfld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "g_count.c"); }; status = (status) ; goto BYE; } } };
  if ( cfld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(cfld_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "g_count.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", 59, "g_count.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "g_count.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_count.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_count(f1_rec, cfld_rec, f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "g_count.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1f2opf3 d_fld1=%s d_cfld=%s d_fld2=%s",
        f1, cfld, f2);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "g_count.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 70, "g_count.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    if ( strstr(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:
cfld
char *

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

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

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

variable_types:
out
double *

variable_types: outv double