subsample

decompiled_code:
__int64 __fastcall subsample(const char *a1, _BYTE *a2, const char *a3, const char *a4, _BYTE *a5)
{
const char *v6; // r14
_BYTE *v7; // r15
int v8; // er12
int v9; // ecx
const char *v10; // rsi
unsigned int v11; // ebx
__int64 v13; // r15
__int64 v14; // rax
__int64 v15; // r14
__int64 v16; // r12
__int64 v17; // rax
__int64 v18; // rdi
__int64 v19; // r15
_DWORD *v20; // rbp
char *v21; // rdx
unsigned __int64 v22; // r14
__int64 v23; // r12
char v24; // al
char *v25; // r13
unsigned int v26; // eax
__int64 v27; // r15
_QWORD *v28; // rbp
char *v29; // rdx
unsigned __int64 v30; // r14
__int64 v31; // r12
char v32; // al
char *v33; // r13
__int64 v34; // [rsp+8h] [rbp-510h]
__int64 v35; // [rsp+10h] [rbp-508h]
__int64 v36; // [rsp+18h] [rbp-500h]
__int64 v37; // [rsp+20h] [rbp-4F8h]
__int64 v38; // [rsp+28h] [rbp-4F0h]
__int64 v39; // [rsp+30h] [rbp-4E8h]
int v40; // [rsp+38h] [rbp-4E0h]
int v41; // [rsp+3Ch] [rbp-4DCh]
const char *v42; // [rsp+40h] [rbp-4D8h]
_BYTE *v43; // [rsp+48h] [rbp-4D0h]
char s[36]; // [rsp+50h] [rbp-4C8h] BYREF
int v45; // [rsp+74h] [rbp-4A4h] BYREF
__int64 v46; // [rsp+78h] [rbp-4A0h] BYREF
char *endptr; // [rsp+80h] [rbp-498h] BYREF
unsigned int v48; // [rsp+88h] [rbp-490h] BYREF
int v49; // [rsp+8Ch] [rbp-48Ch] BYREF
char v50[28]; // [rsp+90h] [rbp-488h] BYREF
int v51; // [rsp+ACh] [rbp-46Ch] BYREF
int v52; // [rsp+B0h] [rbp-468h] BYREF
int v53; // [rsp+B4h] [rbp-464h] BYREF
unsigned int v54; // [rsp+B8h] [rbp-460h] BYREF
unsigned int v55; // [rsp+BCh] [rbp-45Ch] BYREF
char v56[224]; // [rsp+C0h] [rbp-458h] BYREF
char v57[224]; // [rsp+1A0h] [rbp-378h] BYREF
__int64 v58; // [rsp+280h] [rbp-298h] BYREF
__int64 v59; // [rsp+298h] [rbp-280h]
char v60[176]; // [rsp+360h] [rbp-1B8h] BYREF
__int64 v61[22]; // [rsp+410h] [rbp-108h] BYREF
size_t v62; // [rsp+4C0h] [rbp-58h] BYREF
void *v63; // [rsp+4C8h] [rbp-50h] BYREF
size_t len; // [rsp+4D0h] [rbp-48h] BYREF
void *addr; // [rsp+4D8h] [rbp-40h] BYREF

addr = 0LL;
len = 0LL;
v63 = 0LL;
v62 = 0LL;
v55 = 0x80000000;
v54 = 0x80000000;
v53 = 0x80000000;
v52 = 0x80000000;
v51 = 0x80000000;
v49 = 0x7FFFFFFF;
v48 = 0x7FFFFFFF;
if ( !a1 || (v6 = a4, v7 = a5, !*a1) )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( !a4 || !*a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( !a5 || !*a5 )
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( !strcmp(a1, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
v34 = strtoll(a3, &endptr, 10);
if ( v34 <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 68LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
zero_string(v50, 16LL);
v8 = is_tbl(a1, &v55, v61);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 71LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
if ( (v55 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 72LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
v37 = v61[0];
v8 = is_fld(0LL, v55, a2, &v53, &v58, &v51, v56);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 75LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
if ( v53 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 76LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
v8 = get_data(&addr, &len, 0LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 77LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
if ( v51 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 79LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( (_DWORD)v59 != 4 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( v34 >= v37 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
v8 = get_fld_sz(4LL, &v49);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
v8 = mk_temp_file(v50, v34 * v49, &v48);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 86LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
v8 = q_mmap(v48, v50, &v63, &v62, 1LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 87LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
v8 = partition(v34, 1024LL, 0xFFFFFFFFLL, &v46, &v45);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
v9 = v45;
v10 = (const char *)v45;
v39 = v37 / v45;
v11 = 2;
if ( (unsigned int)(v37 / v34) != 1 )
v11 = v37 / v34;
if ( v45 <= 0 )
goto LABEL_87;
v40 = 2059879141;
v38 = 0LL;
v36 = 0LL;
v41 = v8;
v42 = v6;
v43 = v7;
do
{
v13 = v38;
v14 = v39 + v38;
v38 = v14;
v15 = v37;
if ( v14 <= v37 )
v15 = v14;
if ( v15 <= v13 )
{
v10 = "Line %3d of File %s \n";
fprintf(stderr, "Line %3d of File %s \n", 98LL, "./dir_wr_verbs/subsample.c");
v41 = -1;
goto LABEL_53;
}
v16 = v46 * v36;
v17 = v46 * v36 + v46;
if ( v9 - 1 == (_DWORD)v36 )
v17 = v34;
v35 = v17 - v16;
srand48(v40);
v18 = (unsigned int)mrand48();
if ( (_DWORD)v59 == 4 )
{
v19 = 4 * v13;
v20 = (char *)addr + v19;
v21 = (char *)v63 + 4 * v16;
if ( v35 <= 0 )
goto LABEL_53;
v22 = 4 * v15;
v23 = 0LL;
LABEL_74:
v25 = v21;
while ( 1 )
{
v26 = mix_I4(v18, v10, v21);
v18 = v26;
if ( !(v26 % v11) )
break;
++v20;
v24 = 0;
v21 = v25;
if ( v22 <= (unsigned __int64)v20 )
goto LABEL_67;
LABEL_68:
if ( v24 )
{
v21 = v25;
LABEL_73:
if ( v35 == ++v23 )
goto LABEL_53;
goto LABEL_74;
}
}
v21 = v25 + 4;
*(_DWORD *)v25 = *v20++;
if ( (unsigned __int64)v20 < v22 )
goto LABEL_73;
v24 = 1;
LABEL_67:
v20 = (char *)addr + v19;
v25 = v21;
goto LABEL_68;
}
if ( (_DWORD)v59 == 5 )
{
v27 = 8 * v13;
v28 = (char *)addr + v27;
v29 = (char *)v63 + 8 * v16;
if ( v35 <= 0 )
goto LABEL_53;
v30 = 8 * v15;
v31 = 0LL;
LABEL_85:
v33 = v29;
while ( 1 )
{
LODWORD(v18) = mix_I8((unsigned int)v18, v10, v29);
if ( !((unsigned int)v18 % v11) )
break;
++v28;
v32 = 0;
v29 = v33;
if ( v30 <= (unsigned __int64)v28 )
goto LABEL_78;
LABEL_79:
if ( v32 )
{
v29 = v33;
LABEL_84:
if ( v35 == ++v31 )
goto LABEL_53;
goto LABEL_85;
}
}
v29 = v33 + 8;
*(_QWORD *)v33 = *v28++;
if ( (unsigned __int64)v28 < v30 )
goto LABEL_84;
v32 = 1;
LABEL_78:
v28 = (char *)addr + v27;
v33 = v29;
goto LABEL_79;
}
if ( !v41 )
{
v10 = "Line %3d of File %s \n";
fprintf(stderr, "Line %3d of File %s \n", 120LL, "./dir_wr_verbs/subsample.c");
}
v41 = -1;
LABEL_53:
v9 = v45;
++v36;
v40 += 2059879141;
}
while ( v45 > (int)v36 );
v8 = v41;
v6 = v42;
v7 = v43;
if ( v41 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 124LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
LABEL_87:
v8 = del_tbl(v6, 0xFFFFFFFFLL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 126LL, "./dir_wr_verbs/subsample.c");
}
else
{
sprintf(s, "%lld", v34);
v8 = add_tbl(v6, s, &v54, v60);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 129LL, "./dir_wr_verbs/subsample.c");
}
else
{
v8 = add_fld(v54, v7, v48, v50, (unsigned int)v59, 0xFFFFFFFFLL, &v52, v57);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 131LL, "./dir_wr_verbs/subsample.c");
}
}
LABEL_28:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_31;
}
LABEL_95:
fprintf(stderr, "Line %3d of File %s \n", 133LL, "./dir_wr_verbs/subsample.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_95;
LABEL_31:
if ( !v63 )
{
if ( !v62 )
return (unsigned int)v8;
LABEL_98:
fprintf(stderr, "Line %3d of File %s \n", 134LL, "./dir_wr_verbs/subsample.c");
return (unsigned int)-1;
}
if ( !v62 )
goto LABEL_98;
munmap(v63, v62);
return (unsigned int)v8;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, _BYTE *a2, const char *a3, const char *a4, _BYTE *a5)
{
const char *v6; // r14
_BYTE *v7; // r15
int v8; // er12
int v9; // ecx
const char *v10; // rsi
unsigned int v11; // ebx
__int64 v13; // r15
__int64 v14; // rax
__int64 v15; // r14
__int64 v16; // r12
__int64 v17; // rax
__int64 v18; // rdi
__int64 v19; // r15
_DWORD *v20; // rbp
char *v21; // rdx
unsigned __int64 v22; // r14
__int64 v23; // r12
char v24; // al
char *v25; // r13
unsigned int v26; // eax
__int64 v27; // r15
_QWORD *v28; // rbp
char *v29; // rdx
unsigned __int64 v30; // r14
__int64 v31; // r12
char v32; // al
char *v33; // r13
__int64 v34; // [rsp+8h] [rbp-510h]
__int64 v35; // [rsp+10h] [rbp-508h]
__int64 v36; // [rsp+18h] [rbp-500h]
__int64 v37; // [rsp+20h] [rbp-4F8h]
__int64 v38; // [rsp+28h] [rbp-4F0h]
__int64 v39; // [rsp+30h] [rbp-4E8h]
int v40; // [rsp+38h] [rbp-4E0h]
int v41; // [rsp+3Ch] [rbp-4DCh]
const char *v42; // [rsp+40h] [rbp-4D8h]
_BYTE *v43; // [rsp+48h] [rbp-4D0h]
char s[36]; // [rsp+50h] [rbp-4C8h] BYREF
int v45; // [rsp+74h] [rbp-4A4h] BYREF
__int64 v46; // [rsp+78h] [rbp-4A0h] BYREF
char *endptr; // [rsp+80h] [rbp-498h] BYREF
unsigned int v48; // [rsp+88h] [rbp-490h] BYREF
int v49; // [rsp+8Ch] [rbp-48Ch] BYREF
char v50[28]; // [rsp+90h] [rbp-488h] BYREF
int v51; // [rsp+ACh] [rbp-46Ch] BYREF
int v52; // [rsp+B0h] [rbp-468h] BYREF
int v53; // [rsp+B4h] [rbp-464h] BYREF
unsigned int v54; // [rsp+B8h] [rbp-460h] BYREF
unsigned int v55; // [rsp+BCh] [rbp-45Ch] BYREF
char v56[224]; // [rsp+C0h] [rbp-458h] BYREF
char v57[224]; // [rsp+1A0h] [rbp-378h] BYREF
__int64 v58; // [rsp+280h] [rbp-298h] BYREF
__int64 v59; // [rsp+298h] [rbp-280h]
char v60[176]; // [rsp+360h] [rbp-1B8h] BYREF
__int64 v61[22]; // [rsp+410h] [rbp-108h] BYREF
size_t v62; // [rsp+4C0h] [rbp-58h] BYREF
void *v63; // [rsp+4C8h] [rbp-50h] BYREF
size_t len; // [rsp+4D0h] [rbp-48h] BYREF
void *addr; // [rsp+4D8h] [rbp-40h] BYREF

addr = 0LL;
len = 0LL;
v63 = 0LL;
v62 = 0LL;
v55 = 0x80000000;
v54 = 0x80000000;
v53 = 0x80000000;
v52 = 0x80000000;
v51 = 0x80000000;
v49 = 0x7FFFFFFF;
v48 = 0x7FFFFFFF;
if ( !a1 || (v6 = a4, v7 = a5, !*a1) )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( !a4 || !*a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( !a5 || !*a5 )
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( !strcmp(a1, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
v34 = strtoll(a3, &endptr, 10);
if ( v34 <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 68LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
zero_string(v50, 16LL);
v8 = is_tbl(a1, &v55, v61);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 71LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
if ( (v55 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 72LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
v37 = v61[0];
v8 = is_fld(0LL, v55, a2, &v53, &v58, &v51, v56);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 75LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
if ( v53 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 76LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
v8 = get_data(&addr, &len, 0LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 77LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
if ( v51 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 79LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( (_DWORD)v59 != 4 )
{
fprintf(stderr, "Line %3d of File %s \n", 80LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
if ( v34 >= v37 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "./dir_wr_verbs/subsample.c");
v8 = -1;
goto LABEL_28;
}
v8 = get_fld_sz(4LL, &v49);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
v8 = mk_temp_file(v50, v34 * v49, &v48);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 86LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
v8 = q_mmap(v48, v50, &v63, &v62, 1LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 87LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
v8 = partition(v34, 1024LL, 0xFFFFFFFFLL, &v46, &v45);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
v9 = v45;
v10 = (const char *)v45;
v39 = v37 / v45;
v11 = 2;
if ( (unsigned int)(v37 / v34) != 1 )
v11 = v37 / v34;
if ( v45 <= 0 )
goto LABEL_87;
v40 = 2059879141;
v38 = 0LL;
v36 = 0LL;
v41 = v8;
v42 = v6;
v43 = v7;
do
{
v13 = v38;
v14 = v39 + v38;
v38 = v14;
v15 = v37;
if ( v14 <= v37 )
v15 = v14;
if ( v15 <= v13 )
{
v10 = "Line %3d of File %s \n";
fprintf(stderr, "Line %3d of File %s \n", 98LL, "./dir_wr_verbs/subsample.c");
v41 = -1;
goto LABEL_53;
}
v16 = v46 * v36;
v17 = v46 * v36 + v46;
if ( v9 - 1 == (_DWORD)v36 )
v17 = v34;
v35 = v17 - v16;
srand48(v40);
v18 = (unsigned int)mrand48();
if ( (_DWORD)v59 == 4 )
{
v19 = 4 * v13;
v20 = (char *)addr + v19;
v21 = (char *)v63 + 4 * v16;
if ( v35 <= 0 )
goto LABEL_53;
v22 = 4 * v15;
v23 = 0LL;
LABEL_74:
v25 = v21;
while ( 1 )
{
v26 = mix_I4(v18, v10, v21);
v18 = v26;
if ( !(v26 % v11) )
break;
++v20;
v24 = 0;
v21 = v25;
if ( v22 <= (unsigned __int64)v20 )
goto LABEL_67;
LABEL_68:
if ( v24 )
{
v21 = v25;
LABEL_73:
if ( v35 == ++v23 )
goto LABEL_53;
goto LABEL_74;
}
}
v21 = v25 + 4;
*(_DWORD *)v25 = *v20++;
if ( (unsigned __int64)v20 < v22 )
goto LABEL_73;
v24 = 1;
LABEL_67:
v20 = (char *)addr + v19;
v25 = v21;
goto LABEL_68;
}
if ( (_DWORD)v59 == 5 )
{
v27 = 8 * v13;
v28 = (char *)addr + v27;
v29 = (char *)v63 + 8 * v16;
if ( v35 <= 0 )
goto LABEL_53;
v30 = 8 * v15;
v31 = 0LL;
LABEL_85:
v33 = v29;
while ( 1 )
{
LODWORD(v18) = mix_I8((unsigned int)v18, v10, v29);
if ( !((unsigned int)v18 % v11) )
break;
++v28;
v32 = 0;
v29 = v33;
if ( v30 <= (unsigned __int64)v28 )
goto LABEL_78;
LABEL_79:
if ( v32 )
{
v29 = v33;
LABEL_84:
if ( v35 == ++v31 )
goto LABEL_53;
goto LABEL_85;
}
}
v29 = v33 + 8;
*(_QWORD *)v33 = *v28++;
if ( (unsigned __int64)v28 < v30 )
goto LABEL_84;
v32 = 1;
LABEL_78:
v28 = (char *)addr + v27;
v33 = v29;
goto LABEL_79;
}
if ( !v41 )
{
v10 = "Line %3d of File %s \n";
fprintf(stderr, "Line %3d of File %s \n", 120LL, "./dir_wr_verbs/subsample.c");
}
v41 = -1;
LABEL_53:
v9 = v45;
++v36;
v40 += 2059879141;
}
while ( v45 > (int)v36 );
v8 = v41;
v6 = v42;
v7 = v43;
if ( v41 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 124LL, "./dir_wr_verbs/subsample.c");
goto LABEL_28;
}
LABEL_87:
v8 = del_tbl(v6, 0xFFFFFFFFLL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 126LL, "./dir_wr_verbs/subsample.c");
}
else
{
sprintf(s, "%lld", v34);
v8 = add_tbl(v6, s, &v54, v60);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 129LL, "./dir_wr_verbs/subsample.c");
}
else
{
v8 = add_fld(v54, v7, v48, v50, (unsigned int)v59, 0xFFFFFFFFLL, &v52, v57);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 131LL, "./dir_wr_verbs/subsample.c");
}
}
LABEL_28:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_31;
}
LABEL_95:
fprintf(stderr, "Line %3d of File %s \n", 133LL, "./dir_wr_verbs/subsample.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_95;
LABEL_31:
if ( !v63 )
{
if ( !v62 )
return (unsigned int)v8;
LABEL_98:
fprintf(stderr, "Line %3d of File %s \n", 134LL, "./dir_wr_verbs/subsample.c");
return (unsigned int)-1;
}
if ( !v62 )
goto LABEL_98;
munmap(v63, v62);
return (unsigned int)v8;
}

original_code:
int
subsample(
   char *t1,
   char *f1,
   char *str_nR2,
   char *t2,
   char *f2
   )
{
  int status = 0;
  char *f1_X = ((void *)0); size_t f1_nX = 0;
  char *f2_X = ((void *)0); size_t f2_nX = 0;
  TBL_REC_TYPE t1_rec, t2_rec;
  FLD_REC_TYPE f1_rec, f2_rec;
  FLD_REC_TYPE nn_f1_rec;
  long long nR1, nR2;
  int t1_id = (-0x7fffffff - 1), t2_id = (-0x7fffffff - 1);
  int f1_id = (-0x7fffffff - 1), f2_id = (-0x7fffffff - 1);
  int nn_f1_id = (-0x7fffffff - 1);
  char opfile[15 +1];
  int fldsz = 0x7fffffff, ddir_id = 0x7fffffff;
   long long chk_nR2 = 0;
  if ( ( t1 == ((void *)0) ) || ( *t1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( ( t2 == ((void *)0) ) || ( *t2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t1, t2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  char *endptr;
  nR2 = strtoll(str_nR2, &endptr, 10);
  if ( nR2 <= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  zero_string(opfile, (15 +1));
  status = is_tbl(t1, &t1_id, &t1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  if ( t1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  nR1 = t1_rec.nR;
  status = is_fld(((void *)0), t1_id, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 76, "./dir_wr_verbs/subsample.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", 77, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_f1_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.fldtype != I4 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  int *max_I4f1 = (int *)f1_X; max_I4f1 += nR1;
  if ( nR1 <= nR2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  status = get_fld_sz(f1_rec.fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  status = mk_temp_file(opfile, (nR2 * fldsz), &ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 86, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, opfile, &f2_X, &f2_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 87, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  long long block_size; int nT;
  status = partition(nR2, 1024, -1, &block_size, &nT); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  long long block_size_1 = (nR1 / nT);
  int ratio = nR1 / nR2; if ( ratio == 1 ) { ratio++; }
  for ( int tid = 0; tid < nT; tid++ ) {
    long long lb1 = tid * block_size_1;
    long long ub1 = lb1 + block_size_1;
    if ( ub1 > nR1 ) { ub1 = nR1; }
    if ( ub1 <= lb1 ) { { fprintf(stderr, "Line %3d of File %s \n", 98, "./dir_wr_verbs/subsample.c"); }; status = -1; continue; }
    long long lb2 = 0 + (tid * block_size);
    long long ub2 = lb2 + block_size;
    if ( tid == (nT-1) ) { ub2 = nR2; }
    long long range2 = ub2 - lb2;
    srand48(2059879141*(tid+1));
    unsigned int rnum = (unsigned int)mrand48();
    int *I4f1 = ((void *)0), *I4f2 = ((void *)0), *max_I4f1 = ((void *)0);
    long long *I8f1 = ((void *)0), *I8f2 = ((void *)0), *max_I8f1 = ((void *)0);
    max_I4f1 = I4f1 + ub1;
    max_I8f1 = I8f1 + ub1;
    switch ( f1_rec.fldtype ) {
      case I4 :
    I4f1 = (int *)f1_X; I4f1 += lb1;
    I4f2 = (int *)f2_X; I4f2 += lb2;
    for ( int i = 0; i < range2; i++ ) {
 for ( _Bool found = 0; found == 0; ) {
   rnum = mix_I4(rnum);
   int x = rnum % ratio;
   if ( x == 0 ) {
     *I4f2++ = *I4f1;
     chk_nR2++;
     found = 1;
   }
   I4f1++;
   if ( I4f1 >= max_I4f1 ) {
     I4f1 = (int *)f1_X; I4f1 += lb1;
   }
 }
      }
 break;
      case I8 :
    I8f1 = (long long *)f1_X; I8f1 += lb1;
    I8f2 = (long long *)f2_X; I8f2 += lb2;
    for ( int i = 0; i < range2; i++ ) {
 for ( _Bool found = 0; found == 0; ) {
   rnum = mix_I8(rnum);
   int x = rnum % ratio;
   if ( x == 0 ) {
     *I8f2++ = *I8f1;
     chk_nR2++;
     found = 1;
   }
   I8f1++;
   if ( I8f1 >= max_I8f1 ) {
     I8f1 = (long long *)f1_X; I8f1 += lb1;
   }
 }
      }
 break;
      default :
 if ( status == 0 ) { { fprintf(stderr, "Line %3d of File %s \n", 120, "./dir_wr_verbs/subsample.c"); }; } status = -1; continue;
 break;
    }
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 124, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  status = del_tbl(t2, -1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 126, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  char strbuf[32];
  sprintf(strbuf, "%lld", nR2);
  status = add_tbl(t2, strbuf, &t2_id, &t2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 129, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(t2_id, f2, ddir_id, opfile, f1_rec.fldtype, -1, &f2_id, &f2_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 131, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 133, "./dir_wr_verbs/subsample.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 133, "./dir_wr_verbs/subsample.c"); }; return(-1); } if ( f1_X != ((void *)0) ) { munmap(f1_X, f1_nX); f1_X = ((void *)0); f1_nX = 0; } };
  { if ( ( f2_X == ((void *)0) ) && ( f2_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 134, "./dir_wr_verbs/subsample.c"); }; return(-1); } if ( ( f2_X != ((void *)0) ) && ( f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 134, "./dir_wr_verbs/subsample.c"); }; return(-1); } if ( f2_X != ((void *)0) ) { munmap(f2_X, f2_nX); f2_X = ((void *)0); f2_nX = 0; } };
  return(status);
}

canonical_original_code:
int subsample(char *t1, char *f1, char *str_nR2, char *t2, char *f2)
{
  int status = 0;
  char *f1_X = ((void *)0); unsigned long f1_nX = 0;
  char *f2_X = ((void *)0); unsigned long f2_nX = 0;
  struct _TBL_REC_TYPE t1_rec; struct _TBL_REC_TYPE t2_rec;
  struct _FLD_REC_TYPE f1_rec; struct _FLD_REC_TYPE f2_rec;
  struct _FLD_REC_TYPE nn_f1_rec;
  long long nR1; long long nR2;
  int t1_id = (-0x7fffffff - 1); int t2_id = (-0x7fffffff - 1);
  int f1_id = (-0x7fffffff - 1); int f2_id = (-0x7fffffff - 1);
  int nn_f1_id = (-0x7fffffff - 1);
  char opfile[-1];
  int fldsz = 0x7fffffff; int ddir_id = 0x7fffffff;
   long long chk_nR2 = 0;
  if ( ( t1 == ((void *)0) ) || ( *t1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( ( t2 == ((void *)0) ) || ( *t2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(t1, t2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  char *endptr;
  nR2 = strtoll(str_nR2, &endptr, 10);
  if ( nR2 <= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  zero_string(opfile, (15 +1));
  status = is_tbl(t1, &t1_id, &t1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  if ( t1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  nR1 = t1_rec.nR;
  status = is_fld(((void *)0), t1_id, f1, &f1_id, &f1_rec, &nn_f1_id, &nn_f1_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 75, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 76, "./dir_wr_verbs/subsample.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", 77, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  if ( nn_f1_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  if ( f1_rec.fldtype != I4 ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  int *max_I4f1 = (int *)f1_X; max_I4f1 += nR1;
  if ( nR1 <= nR2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "./dir_wr_verbs/subsample.c"); }; status = -1 ; goto BYE; }; }
  status = get_fld_sz(f1_rec.fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  status = mk_temp_file(opfile, (nR2 * fldsz), &ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 86, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, opfile, &f2_X, &f2_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 87, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  long long block_size; int nT;
  status = partition(nR2, 1024, -1, &block_size, &nT); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 90, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  long long block_size_1 = (nR1 / nT);
  int ratio = nR1 / nR2; if ( ratio == 1 ) { ratio++; }
  for ( int tid = 0; tid < nT; tid++ ) {
    long long lb1 = tid * block_size_1;
    long long ub1 = lb1 + block_size_1;
    if ( ub1 > nR1 ) { ub1 = nR1; }
    if ( ub1 <= lb1 ) { { fprintf(stderr, "Line %3d of File %s \n", 98, "./dir_wr_verbs/subsample.c"); }; status = -1; continue; }
    long long lb2 = 0 + (tid * block_size);
    long long ub2 = lb2 + block_size;
    if ( tid == (nT-1) ) { ub2 = nR2; }
    long long range2 = ub2 - lb2;
    srand48(2059879141*(tid+1));
    unsigned int rnum = (unsigned int)mrand48();
    int *I4f1 = ((void *)0); int *I4f2 = ((void *)0); int *max_I4f1 = ((void *)0);
    long long *I8f1 = ((void *)0); long long *I8f2 = ((void *)0); long long *max_I8f1 = ((void *)0);
    max_I4f1 = I4f1 + ub1;
    max_I8f1 = I8f1 + ub1;
    switch ( f1_rec.fldtype ) {
      case I4 :
    I4f1 = (int *)f1_X; I4f1 += lb1;
    I4f2 = (int *)f2_X; I4f2 += lb2;
    for ( int i = 0; i < range2; i++ ) {
 for ( _Bool found = 0; found == 0; ) {
   rnum = mix_I4(rnum);
   int x = rnum % ratio;
   if ( x == 0 ) {
     *I4f2++ = *I4f1;
     chk_nR2++;
     found = 1;
   }
   I4f1++;
   if ( I4f1 >= max_I4f1 ) {
     I4f1 = (int *)f1_X; I4f1 += lb1;
   }
 }
      }
 break;
      case I8 :
    I8f1 = (long long *)f1_X; I8f1 += lb1;
    I8f2 = (long long *)f2_X; I8f2 += lb2;
    for ( int i = 0; i < range2; i++ ) {
 for ( _Bool found = 0; found == 0; ) {
   rnum = mix_I8(rnum);
   int x = rnum % ratio;
   if ( x == 0 ) {
     *I8f2++ = *I8f1;
     chk_nR2++;
     found = 1;
   }
   I8f1++;
   if ( I8f1 >= max_I8f1 ) {
     I8f1 = (long long *)f1_X; I8f1 += lb1;
   }
 }
      }
 break;
      default :
 if ( status == 0 ) { { fprintf(stderr, "Line %3d of File %s \n", 120, "./dir_wr_verbs/subsample.c"); }; } status = -1; continue;
 break;
    }
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 124, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  status = del_tbl(t2, -1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 126, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  char strbuf[32];
  sprintf(strbuf, "%lld", nR2);
  status = add_tbl(t2, strbuf, &t2_id, &t2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 129, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(t2_id, f2, ddir_id, opfile, f1_rec.fldtype, -1, &f2_id, &f2_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 131, "./dir_wr_verbs/subsample.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  { if ( ( f1_X == ((void *)0) ) && ( f1_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 133, "./dir_wr_verbs/subsample.c"); }; return(-1); } if ( ( f1_X != ((void *)0) ) && ( f1_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 133, "./dir_wr_verbs/subsample.c"); }; return(-1); } if ( f1_X != ((void *)0) ) { munmap(f1_X, f1_nX); f1_X = ((void *)0); f1_nX = 0; } };
  { if ( ( f2_X == ((void *)0) ) && ( f2_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 134, "./dir_wr_verbs/subsample.c"); }; return(-1); } if ( ( f2_X != ((void *)0) ) && ( f2_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 134, "./dir_wr_verbs/subsample.c"); }; return(-1); } if ( f2_X != ((void *)0) ) { munmap(f2_X, f2_nX); f2_X = ((void *)0); f2_nX = 0; } };
  return(status);
}

variable_types: status int

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

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

variable_types:
opfile
char [-1]

variable_types: fldsz int

variable_types:
endptr
char *

variable_types: nT int

variable_types: ratio int

variable_types: tid int

variable_types:
rnum
unsigned int

variable_types: x int

variable_types:
strbuf
char [32]


repo: linkedin/datacl

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

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

variable_types:
nR
long long

variable_types:
out
char *

variable_types: outv char

variable_types:
i
long long

return_type: void


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

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


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

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

variable_types:
lb
long long

variable_types:
ub
long long

variable_types:
cnt
long long

variable_types:
val
long long

return_type: int


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; // er15
__int64 v13; // rbx
char *v14; // rsi
__int64 v15; // rcx
_DWORD *v16; // rdi
char *v18; // rsi
__int64 v19; // rcx
_DWORD *v20; // rdi
_DWORD *v21; // r12
char *v22; // rsi
__int64 v23; // rcx
_DWORD *v24; // rdi
_DWORD *v25; // r14
char *v26; // rsi
__int64 v27; // rcx
_DWORD *v28; // rdi
__int64 v29; // rax
int v30; // edx
_QWORD v31[17]; // [rsp-80h] [rbp-548h] BYREF
__int64 v32; // [rsp+8h] [rbp-4C0h]
unsigned int v33; // [rsp+14h] [rbp-4B4h] BYREF
unsigned int v34; // [rsp+18h] [rbp-4B0h] BYREF
int v35; // [rsp+1Ch] [rbp-4ACh] BYREF
size_t v36; // [rsp+20h] [rbp-4A8h] BYREF
void *v37; // [rsp+28h] [rbp-4A0h] BYREF
size_t v38; // [rsp+30h] [rbp-498h] BYREF
void *v39; // [rsp+38h] [rbp-490h] BYREF
size_t v40; // [rsp+40h] [rbp-488h] BYREF
void *v41; // [rsp+48h] [rbp-480h] BYREF
size_t v42; // [rsp+50h] [rbp-478h] BYREF
void *v43; // [rsp+58h] [rbp-470h] BYREF
size_t v44; // [rsp+60h] [rbp-468h] BYREF
void *v45; // [rsp+68h] [rbp-460h] BYREF
size_t len; // [rsp+70h] [rbp-458h] BYREF
void *addr; // [rsp+78h] [rbp-450h] BYREF
char v48[32]; // [rsp+80h] [rbp-448h] BYREF
int v49; // [rsp+A0h] [rbp-428h]
char v50[32]; // [rsp+100h] [rbp-3C8h] BYREF
int v51; // [rsp+120h] [rbp-3A8h]
char v52[32]; // [rsp+180h] [rbp-348h] BYREF
int v53; // [rsp+1A0h] [rbp-328h]
char v54[128]; // [rsp+200h] [rbp-2C8h] BYREF
char v55[32]; // [rsp+280h] [rbp-248h] BYREF
int v56; // [rsp+2A0h] [rbp-228h]
char v57[32]; // [rsp+300h] [rbp-1C8h] BYREF
int v58; // [rsp+320h] [rbp-1A8h]
__int64 v59[4]; // [rsp+380h] [rbp-148h] BYREF
__int64 v60; // [rsp+3A0h] [rbp-128h]
__int64 v61; // [rsp+3A8h] [rbp-120h]
__int64 v62; // [rsp+3B0h] [rbp-118h]
__int64 v63; // [rsp+3B8h] [rbp-110h]
__int64 v64; // [rsp+3C0h] [rbp-108h]
__int64 v65; // [rsp+3C8h] [rbp-100h]
__int64 v66; // [rsp+3D0h] [rbp-F8h]
__int64 v67; // [rsp+3D8h] [rbp-F0h]
__int64 v68; // [rsp+3E0h] [rbp-E8h]
__int64 v69; // [rsp+3E8h] [rbp-E0h]
__int64 v70; // [rsp+3F0h] [rbp-D8h]
int v71; // [rsp+404h] [rbp-C4h] BYREF
int v72; // [rsp+408h] [rbp-C0h] BYREF
int v73; // [rsp+40Ch] [rbp-BCh] BYREF
int v74; // [rsp+410h] [rbp-B8h] BYREF
int v75; // [rsp+414h] [rbp-B4h] BYREF
int v76; // [rsp+418h] [rbp-B0h] BYREF
int v77; // [rsp+41Ch] [rbp-ACh] BYREF
__int64 v78[6]; // [rsp+420h] [rbp-A8h] BYREF
__int64 v79[7]; // [rsp+450h] [rbp-78h] BYREF
unsigned int v80; // [rsp+488h] [rbp-40h] BYREF
unsigned int v81[15]; // [rsp+48Ch] [rbp-3Ch] BYREF

v81[0] = -1;
v80 = -1;
v77 = -1;
v76 = -1;
v75 = -1;
v74 = -1;
v73 = -1;
v72 = -1;
v71 = -1;
addr = 0LL;
len = 0LL;
v45 = 0LL;
v44 = 0LL;
v43 = 0LL;
v42 = 0LL;
v41 = 0LL;
v40 = 0LL;
v39 = 0LL;
v38 = 0LL;
v37 = 0LL;
v36 = 0LL;
v35 = 0;
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !a4 || !*a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !a5 || !*a5 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !s1 || !*s1 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !s2 || !*s2 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !a6 || !*a6 )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !strcmp(a1, a5) )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !strcmp(a2, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !strcmp(s1, s2) )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !strcmp(s1, a6) )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( !strcmp(s2, a6) )
{
fprintf(stderr, "Line %3d of File %s \n", 56LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
v12 = is_tbl(a1, v81, v79);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "patmatch.c");
goto LABEL_42;
}
if ( (v81[0] & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
v32 = v79[0];
v12 = is_fld(0LL, v81[0], a2, &v77, v59, &v74, v54);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "patmatch.c");
goto LABEL_42;
}
if ( v77 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( v74 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
v31[14] = v70;
v31[13] = v69;
v31[12] = v68;
v31[11] = v67;
v31[10] = v66;
v31[9] = v65;
v31[8] = v64;
v31[7] = v63;
v31[6] = v62;
v31[5] = v61;
v31[4] = v60;
v31[3] = v59[3];
v31[2] = v59[2];
v31[1] = v59[1];
v31[0] = v59[0];
v12 = get_data(&addr, &len, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "patmatch.c");
goto LABEL_42;
}
if ( (unsigned int)(v60 - 2) > 2 )
{
fprintf(stderr, "Line %3d of File %s \n", 69LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( a3 && *a3 )
{
v12 = is_fld(0LL, v81[0], a3, &v76, v57, &v74, v54);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "patmatch.c");
goto LABEL_42;
}
if ( v76 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 75LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( v74 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 76LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
v18 = v57;
v19 = 30LL;
v20 = v31;
while ( v19 )
{
*v20 = *(_DWORD *)v18;
v18 += 4;
++v20;
--v19;
}
v12 = get_data(&v45, &v44, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 77LL, "patmatch.c");
goto LABEL_42;
}
if ( v58 != 2 )
{
fprintf(stderr, "Line %3d of File %s \n", 78LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
}
v12 = is_tbl(a5, &v80, v78);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "patmatch.c");
}
else if ( (v80 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 82LL, "patmatch.c");
v12 = -1;
}
else
{
v13 = v78[0];
if ( v78[0] <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "patmatch.c");
v12 = -1;
}
else
{
v12 = is_fld(0LL, v80, s1, &v73, v52, &v74, v54);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 88LL, "patmatch.c");
}
else if ( v73 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 89LL, "patmatch.c");
v12 = -1;
}
else if ( v74 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 90LL, "patmatch.c");
v12 = -1;
}
else
{
v14 = v52;
v15 = 30LL;
v16 = v31;
while ( v15 )
{
*v16 = *(_DWORD *)v14;
v14 += 4;
++v16;
--v15;
}
v12 = get_data(&v41, &v40, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 91LL, "patmatch.c");
}
else if ( v53 == 4 )
{
v21 = v41;
v12 = is_fld(0LL, v80, s2, &v72, v50, &v74, v54);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 96LL, "patmatch.c");
}
else if ( v72 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 97LL, "patmatch.c");
v12 = -1;
}
else if ( v74 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 98LL, "patmatch.c");
v12 = -1;
}
else
{
v22 = v50;
v23 = 30LL;
v24 = v31;
while ( v23 )
{
*v24 = *(_DWORD *)v22;
v22 += 4;
++v24;
--v23;
}
v12 = get_data(&v39, &v38, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 99LL, "patmatch.c");
}
else if ( v51 == 4 )
{
v25 = v39;
v12 = is_fld(0LL, v80, a6, &v71, v48, &v74, v54);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 104LL, "patmatch.c");
}
else if ( v71 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 105LL, "patmatch.c");
v12 = -1;
}
else if ( v74 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 106LL, "patmatch.c");
v12 = -1;
}
else
{
v26 = v48;
v27 = 30LL;
v28 = v31;
while ( v27 )
{
*v28 = *(_DWORD *)v26;
v26 += 4;
++v28;
--v27;
}
v12 = get_data(&v37, &v36, 0LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 107LL, "patmatch.c");
}
else
{
v29 = 0LL;
if ( v49 == (_DWORD)v60 )
{
do
{
v30 = v21[v29];
if ( v30 > v25[v29] )
{
fprintf(stderr, "Line %3d of File %s \n", 112LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( v30 <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 113LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
++v29;
}
while ( v29 < v13 );
v12 = get_fld_sz(2LL, &v35);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 116LL, "patmatch.c");
}
else
{
v12 = mk_temp_file(v32 * v35, &v34, &v33);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 118LL, "patmatch.c");
}
else
{
v12 = q_mmap(v34, v33, &v43, &v42, 1LL);
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 119LL, "patmatch.c");
}
else
{
switch ( (_DWORD)v60 )
{
case 3:
v12 = inner_patmatch_I2(addr, v45, v43, v32, v37, v21, v25, v13);
break;
case 4:
v12 = inner_patmatch_I4(addr, v45, v43, v32, v37, v21, v25, v13);
break;
case 2:
v12 = inner_patmatch_I1(addr, v45, v43, v32, v37, v21, v25, v13);
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 132LL, "patmatch.c");
v12 = -1;
goto LABEL_42;
}
if ( v12 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 135LL, "patmatch.c");
}
else
{
zero_fld_rec(v55);
v56 = 2;
v12 = add_fld(v81[0], a4, v34, v33, &v75, v55);
if ( v12 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 138LL, "patmatch.c");
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 108LL, "patmatch.c");
v12 = -1;
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 100LL, "patmatch.c");
v12 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 92LL, "patmatch.c");
v12 = -1;
}
}
}
}
LABEL_42:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_45;
}
LABEL_148:
fprintf(stderr, "Line %3d of File %s \n", 141LL, "patmatch.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_148;
LABEL_45:
if ( v45 )
{
if ( v44 )
{
munmap(v45, v44);
v45 = 0LL;
v44 = 0LL;
goto LABEL_48;
}
LABEL_151:
fprintf(stderr, "Line %3d of File %s \n", 142LL, "patmatch.c");
return (unsigned int)-1;
}
if ( v44 )
goto LABEL_151;
LABEL_48:
if ( v43 )
{
if ( v42 )
{
munmap(v43, v42);
v43 = 0LL;
v42 = 0LL;
goto LABEL_51;
}
LABEL_154:
fprintf(stderr, "Line %3d of File %s \n", 143LL, "patmatch.c");
return (unsigned int)-1;
}
if ( v42 )
goto LABEL_154;
LABEL_51:
if ( v41 )
{
if ( v40 )
{
munmap(v41, v40);
v41 = 0LL;
v40 = 0LL;
goto LABEL_54;
}
LABEL_157:
fprintf(stderr, "Line %3d of File %s \n", 144LL, "patmatch.c");
return (unsigned int)-1;
}
if ( v40 )
goto LABEL_157;
LABEL_54:
if ( v39 )
{
if ( v38 )
{
munmap(v39, v38);
v39 = 0LL;
v38 = 0LL;
goto LABEL_57;
}
LABEL_160:
fprintf(stderr, "Line %3d of File %s \n", 145LL, "patmatch.c");
return (unsigned int)-1;
}
if ( v38 )
goto LABEL_160;
LABEL_57:
if ( !v37 )
{
if ( !v36 )
return (unsigned int)v12;
LABEL_163:
fprintf(stderr, "Line %3d of File %s \n", 146LL, "patmatch.c");
return (unsigned int)-1;
}
if ( !v36 )
goto LABEL_163;
munmap(v37, v36);
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; // er15
__int64 v13; // rbx
char *v14; // rsi
__int64 v15; // rcx
_DWORD *v16; // rdi
char *v18; // rsi
__int64 v19; // rcx
_DWORD *v20; // rdi
_DWORD *v21; // r12
char *v22; // rsi
__int64 v23; // rcx
_DWORD *v24; // rdi
_DWORD *v25; // r14
char *v26; // rsi
__int64 v27; // rcx
_DWORD *v28; // rdi
__int64 v29; // rax
int v30; // edx
_QWORD v31[17]; // [rsp-80h] [rbp-548h] BYREF
__int64 v32; // [rsp+8h] [rbp-4C0h]
unsigned int v33; // [rsp+14h] [rbp-4B4h] BYREF
unsigned int v34; // [rsp+18h] [rbp-4B0h] BYREF
int v35; // [rsp+1Ch] [rbp-4ACh] BYREF
size_t v36; // [rsp+20h] [rbp-4A8h] BYREF
void *v37; // [rsp+28h] [rbp-4A0h] BYREF
size_t v38; // [rsp+30h] [rbp-498h] BYREF
void *v39; // [rsp+38h] [rbp-490h] BYREF
size_t v40; // [rsp+40h] [rbp-488h] BYREF
void *v41; // [rsp+48h] [rbp-480h] BYREF
size_t v42; // [rsp+50h] [rbp-478h] BYREF
void *v43; // [rsp+58h] [rbp-470h] BYREF
size_t v44; // [rsp+60h] [rbp-468h] BYREF
void *v45; // [rsp+68h] [rbp-460h] BYREF
size_t len; // [rsp+70h] [rbp-458h] BYREF
void *addr; // [rsp+78h] [rbp-450h] BYREF
char v48[32]; // [rsp+80h] [rbp-448h] BYREF
int v49; // [rsp+A0h] [rbp-428h]
char v50[32]; // [rsp+100h] [rbp-3C8h] BYREF
int v51; // [rsp+120h] [rbp-3A8h]
char v52[32]; // [rsp+180h] [rbp-348h] BYREF
int v53; // [rsp+1A0h] [rbp-328h]
char v54[128]; // [rsp+200h] [rbp-2C8h] BYREF
char v55[32]; // [rsp+280h] [rbp-248h] BYREF
int v56; // [rsp+2A0h] [rbp-228h]
char v57[32]; // [rsp+300h] [rbp-1C8h] BYREF
int v58; // [rsp+320h] [rbp-1A8h]
__int64 v59[4]; // [rsp+380h] [rbp-148h] BYREF
__int64 v60; // [rsp+3A0h] [rbp-128h]
__int64 v61; // [rsp+3A8h] [rbp-120h]
__int64 v62; // [rsp+3B0h] [rbp-118h]
__int64 v63; // [rsp+3B8h] [rbp-110h]
__int64 v64; // [rsp+3C0h] [rbp-108h]
__int64 v65; // [rsp+3C8h] [rbp-100h]
__int64 v66; // [rsp+3D0h] [rbp-F8h]
__int64 v67; // [rsp+3D8h] [rbp-F0h]
__int64 v68; // [rsp+3E0h] [rbp-E8h]
__int64 v69; // [rsp+3E8h] [rbp-E0h]
__int64 v70; // [rsp+3F0h] [rbp-D8h]
int v71; // [rsp+404h] [rbp-C4h] BYREF
int v72; // [rsp+408h] [rbp-C0h] BYREF
int v73; // [rsp+40Ch] [rbp-BCh] BYREF
int v74; // [rsp+410h] [rbp-B8h] BYREF
int v75; // [rsp+414h] [rbp-B4h] BYREF
int v76; // [rsp+418h] [rbp-B0h] BYREF
int v77; // [rsp+41Ch] [rbp-ACh] BYREF
__int64 v78[6]; // [rsp+420h] [rbp-A8h] BYREF
__int64 v79[7]; // [rsp+450h] [rbp-78h] BYREF
unsigned int v80; // [rsp+488h] [rbp-40h] BYREF
unsigned int v81[15]; // [rsp+48Ch] [rbp-3Ch] BYREF

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


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


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, _QWORD *a2)
{
const char *v2; // rbp
size_t v3; // rax
_BYTE *v4; // rax
_BYTE *v5; // r13
char v6; // bl
char *v7; // r12
const unsigned __int16 *v8; // r14
__int64 result; // rax

v2 = a1;
v3 = strlen(a1);
v4 = malloc(3 * v3 + 1);
if ( v4 )
{
v5 = v4;
v6 = *a1;
v7 = v4;
if ( *a1 )
{
v8 = *_ctype_b_loc();
do
{
if ( (unsigned __int8)(v6 - 45) <= 1u || v6 == 126 || v6 == 95 || (v8[v6] & 8) != 0 )
{
*v7++ = v6;
}
else if ( v6 == 32 )
{
*v7++ = 43;
}
else
{
*v7 = 37;
v7[1] = to_hex(v6 >> 4);
v7[2] = to_hex(v6 & 0xF);
v7 += 3;
}
v6 = *++v2;
}
while ( *v2 );
}
*v7 = 0;
*a2 = v5;
result = 0LL;
}
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, _QWORD *a2)
{
const char *v2; // rbp
size_t v3; // rax
_BYTE *v4; // rax
_BYTE *v5; // r13
char v6; // bl
char *v7; // r12
const unsigned __int16 *v8; // r14
__int64 result; // rax

v2 = a1;
v3 = strlen(a1);
v4 = malloc(3 * v3 + 1);
if ( v4 )
{
v5 = v4;
v6 = *a1;
v7 = v4;
if ( *a1 )
{
v8 = *_ctype_b_loc();
do
{
if ( (unsigned __int8)(v6 - 45) <= 1u || v6 == 126 || v6 == 95 || (v8[v6] & 8) != 0 )
{
*v7++ = v6;
}
else if ( v6 == 32 )
{
*v7++ = 43;
}
else
{
*v7 = 37;
v7[1] = func1(v6 >> 4);
v7[2] = func1(v6 & 0xF);
v7 += 3;
}
v6 = *++v2;
}
while ( *v2 );
}
*v7 = 0;
*a2 = v5;
result = 0LL;
}
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)
{
const char *v2; // rbp
char v3; // bl
size_t v4; // rax
_BYTE *v5; // rax
_BYTE *v6; // r13
char *v7; // r12
char v9; // di
char v10; // bl
char v11; // r15
const char *v12; // rax

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

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1, _QWORD *a2)
{
const char *v2; // rbp
char v3; // bl
size_t v4; // rax
_BYTE *v5; // rax
_BYTE *v6; // r13
char *v7; // r12
char v9; // di
char v10; // bl
char v11; // r15
const char *v12; // rax

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

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, char *a2, int a3)
{
int v4; // ebx
char *v5; // rbp
char *s; // [rsp+8h] [rbp-30h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, char *a2, int a3)
{
int v4; // ebx
char *v5; // rbp
char *s; // [rsp+8h] [rbp-30h] BYREF

s = 0LL;
v4 = func2(a1, &s);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 120LL, "url.c");
goto LABEL_7;
}
v5 = s;
if ( strlen(s) >= a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 121LL, "url.c");
v4 = -1;
LABEL_7:
v5 = s;
if ( !s )
return (unsigned int)v4;
goto LABEL_4;
}
strcpy(a2, v5);
LABEL_4:
free(v5);
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, char *a2, int a3)
{
int v4; // ebx
char *v5; // rbp
char *s; // [rsp+8h] [rbp-30h] BYREF

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

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, char *a2, int a3)
{
int v4; // ebx
char *v5; // rbp
char *s; // [rsp+8h] [rbp-30h] BYREF

s = 0LL;
v4 = func3(a1, &s);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 140LL, "url.c");
goto LABEL_7;
}
v5 = s;
if ( strlen(s) >= a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 141LL, "url.c");
v4 = -1;
LABEL_7:
v5 = s;
if ( !s )
return (unsigned int)v4;
goto LABEL_4;
}
strcpy(a2, v5);
LABEL_4:
free(v5);
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

variable_types:
i
long long