decompiled_code:
__int64 __fastcall s_to_f(_BYTE *a1, _BYTE *a2, _BYTE *a3)
{
int v4; // ebx
__int64 v6; // r13
char v7; // [rsp+7h] [rbp-161h] BYREF
__int64 v8; // [rsp+8h] [rbp-160h] BYREF
char v9; // [rsp+17h] [rbp-151h] BYREF
unsigned int v10; // [rsp+18h] [rbp-150h] BYREF
unsigned int v11; // [rsp+1Ch] [rbp-14Ch] BYREF
char v12[32]; // [rsp+20h] [rbp-148h] BYREF
unsigned int v13; // [rsp+40h] [rbp-128h]
unsigned int v14; // [rsp+9Ch] [rbp-CCh] BYREF
__int64 v15[7]; // [rsp+A0h] [rbp-C8h] BYREF
int v16; // [rsp+DCh] [rbp-8Ch] BYREF
char v17[32]; // [rsp+E0h] [rbp-88h] BYREF
char v18[40]; // [rsp+100h] [rbp-68h] BYREF
unsigned int v19; // [rsp+128h] [rbp-40h] BYREF
unsigned int v20; // [rsp+12Ch] [rbp-3Ch] BYREF
size_t len; // [rsp+130h] [rbp-38h] BYREF
void *addr; // [rsp+138h] [rbp-30h] BYREF

addr = 0LL;
len = 0LL;
v20 = -1;
v19 = -1;
v16 = 0x80000000;
v9 = 1;
zero_string(v18, 32LL);
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
v4 = is_tbl(a1, &v14, v15);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "s_to_f.c");
goto LABEL_9;
}
if ( (v14 & 0x80000000) != 0 || (int)v14 >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
v6 = v15[0];
zero_string(v17, 32LL);
v4 = extract_S(a3, "op=[", "]", v17, 32LL, &v9);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "s_to_f.c");
goto LABEL_9;
}
if ( v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 56LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
if ( strcmp(v17, "const") && strcmp(v17, "seq") )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
extract_S(a3, "fldtype=[", "]", v18, 32LL, &v9);
if ( v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
if ( !v18[0] )
{
fprintf(stderr, "Line %3d of File %s \n", 67LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
v4 = unstr_fldtype(v18, &v10);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 68LL, "s_to_f.c");
goto LABEL_9;
}
v4 = get_fld_sz(v10, &v16);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 71LL, "s_to_f.c");
goto LABEL_9;
}
v4 = mk_temp_file(v6 * v16, &v19, &v20);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "s_to_f.c");
goto LABEL_9;
}
v4 = q_mmap(v19, v20, &addr, &len, 1LL);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "s_to_f.c");
goto LABEL_9;
}
v4 = vec_s_to_f(addr, v6, a3);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 76LL, "s_to_f.c");
goto LABEL_9;
}
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_33;
}
LABEL_52:
fprintf(stderr, "Line %3d of File %s \n", 77LL, "s_to_f.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_52;
LABEL_33:
zero_fld_rec(v12);
v13 = v10;
v4 = add_fld(v14, a2, v19, v20, &v11, v12);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "s_to_f.c");
}
else if ( !strcmp(v17, "seq") )
{
v4 = extract_I8(a3, "incr=[", "]", &v8, &v7);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "s_to_f.c");
}
else if ( v7 )
{
fprintf(stderr, "Line %3d of File %s \n", 86LL, "s_to_f.c");
v4 = -1;
}
else if ( v8 < 0 )
{
v4 = int_set_meta(v14, v11, "srttype", "descending", 1LL);
if ( v4 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 89LL, "s_to_f.c");
}
else if ( v8 > 0 )
{
v4 = int_set_meta(v14, v11, "srttype", "ascending", 1LL);
if ( v4 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 93LL, "s_to_f.c");
}
}
LABEL_9:
if ( !addr )
{
if ( !len )
return (unsigned int)v4;
LABEL_60:
fprintf(stderr, "Line %3d of File %s \n", 98LL, "s_to_f.c");
return (unsigned int)-1;
}
if ( !len )
goto LABEL_60;
munmap(addr, len);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, _BYTE *a2, _BYTE *a3)
{
int v4; // ebx
__int64 v6; // r13
char v7; // [rsp+7h] [rbp-161h] BYREF
__int64 v8; // [rsp+8h] [rbp-160h] BYREF
char v9; // [rsp+17h] [rbp-151h] BYREF
unsigned int v10; // [rsp+18h] [rbp-150h] BYREF
unsigned int v11; // [rsp+1Ch] [rbp-14Ch] BYREF
char v12[32]; // [rsp+20h] [rbp-148h] BYREF
unsigned int v13; // [rsp+40h] [rbp-128h]
unsigned int v14; // [rsp+9Ch] [rbp-CCh] BYREF
__int64 v15[7]; // [rsp+A0h] [rbp-C8h] BYREF
int v16; // [rsp+DCh] [rbp-8Ch] BYREF
char v17[32]; // [rsp+E0h] [rbp-88h] BYREF
char v18[40]; // [rsp+100h] [rbp-68h] BYREF
unsigned int v19; // [rsp+128h] [rbp-40h] BYREF
unsigned int v20; // [rsp+12Ch] [rbp-3Ch] BYREF
size_t len; // [rsp+130h] [rbp-38h] BYREF
void *addr; // [rsp+138h] [rbp-30h] BYREF

addr = 0LL;
len = 0LL;
v20 = -1;
v19 = -1;
v16 = 0x80000000;
v9 = 1;
zero_string(v18, 32LL);
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
v4 = is_tbl(a1, &v14, v15);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "s_to_f.c");
goto LABEL_9;
}
if ( (v14 & 0x80000000) != 0 || (int)v14 >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
v6 = v15[0];
zero_string(v17, 32LL);
v4 = extract_S(a3, "op=[", "]", v17, 32LL, &v9);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "s_to_f.c");
goto LABEL_9;
}
if ( v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 56LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
if ( strcmp(v17, "const") && strcmp(v17, "seq") )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
extract_S(a3, "fldtype=[", "]", v18, 32LL, &v9);
if ( v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
if ( !v18[0] )
{
fprintf(stderr, "Line %3d of File %s \n", 67LL, "s_to_f.c");
v4 = -1;
goto LABEL_9;
}
v4 = unstr_fldtype(v18, &v10);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 68LL, "s_to_f.c");
goto LABEL_9;
}
v4 = get_fld_sz(v10, &v16);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 71LL, "s_to_f.c");
goto LABEL_9;
}
v4 = mk_temp_file(v6 * v16, &v19, &v20);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "s_to_f.c");
goto LABEL_9;
}
v4 = q_mmap(v19, v20, &addr, &len, 1LL);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "s_to_f.c");
goto LABEL_9;
}
v4 = vec_s_to_f(addr, v6, a3);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 76LL, "s_to_f.c");
goto LABEL_9;
}
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_33;
}
LABEL_52:
fprintf(stderr, "Line %3d of File %s \n", 77LL, "s_to_f.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_52;
LABEL_33:
zero_fld_rec(v12);
v13 = v10;
v4 = add_fld(v14, a2, v19, v20, &v11, v12);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "s_to_f.c");
}
else if ( !strcmp(v17, "seq") )
{
v4 = extract_I8(a3, "incr=[", "]", &v8, &v7);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "s_to_f.c");
}
else if ( v7 )
{
fprintf(stderr, "Line %3d of File %s \n", 86LL, "s_to_f.c");
v4 = -1;
}
else if ( v8 < 0 )
{
v4 = int_set_meta(v14, v11, "srttype", "descending", 1LL);
if ( v4 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 89LL, "s_to_f.c");
}
else if ( v8 > 0 )
{
v4 = int_set_meta(v14, v11, "srttype", "ascending", 1LL);
if ( v4 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 93LL, "s_to_f.c");
}
}
LABEL_9:
if ( !addr )
{
if ( !len )
return (unsigned int)v4;
LABEL_60:
fprintf(stderr, "Line %3d of File %s \n", 98LL, "s_to_f.c");
return (unsigned int)-1;
}
if ( !len )
goto LABEL_60;
munmap(addr, len);
return (unsigned int)v4;
}

original_code:
int
s_to_f(
       const char *tbl,
       const char *fld,
       const char *str_scalar
       )
{
  int status = 0;
  char *X = ((void *)0); size_t nX = 0;
  int fileno = -1, ddir_id = -1;
  char str_fldtype[32];
  char op[32];
  long long nR;
  int fldsz = (-0x7fffffff - 1);
  TBL_REC_TYPE tbl_rec; int tbl_id;
  FLD_REC_TYPE fld_rec; int fld_id;
  FLD_TYPE fldtype;
  _Bool is_null = 1;
  zero_string(str_fldtype, 32);
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_scalar == ((void *)0) ) || ( *str_scalar == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "s_to_f.c"); }; status = -1 ; goto BYE; }; } };
  nR = tbl_rec.nR;
  zero_string(op, 32);
  status = extract_S(str_scalar, "op=[", "]", op, 32, &is_null);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  if ( ( strcmp(op, "const") == 0 ) ||
       ( strcmp(op, "seq") == 0 ) ) {
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 62, "s_to_f.c"); }; status = -1 ; goto BYE; };
  }
  status = extract_S(str_scalar, "fldtype=[", "]", str_fldtype, 32, &is_null);
  if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_fldtype == ((void *)0) ) || ( *str_fldtype == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 67, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  status = unstr_fldtype(str_fldtype, &fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  status = get_fld_sz(fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  size_t filesz = nR * fldsz;
  status = mk_temp_file(filesz, &ddir_id, &fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 73, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, fileno, &X, &nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  status = vec_s_to_f(X, nR, str_scalar); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 76, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 77, "s_to_f.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 77, "s_to_f.c"); }; return(-1); } if ( X != ((void *)0) ) { munmap(X, nX); X = ((void *)0); nX = 0; } };
  zero_fld_rec(&fld_rec); fld_rec.fldtype = fldtype;
  status = add_fld(tbl_id, fld, ddir_id, fileno, &fld_id, &fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  if ( strcmp(op, "seq") == 0 ) {
    long long incrI8; _Bool is_null;
    status = extract_I8(str_scalar, "incr=[", "]", &incrI8, &is_null);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
    if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 86, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
    if ( incrI8 < 0 ) {
      status = int_set_meta(tbl_id, fld_id, "srttype", "descending", 1);
      { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
    }
    else if ( incrI8 > 0 ) {
      status = int_set_meta(tbl_id, fld_id, "srttype", "ascending", 1);
      { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 93, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
    }
  }
 BYE:
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 98, "s_to_f.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 98, "s_to_f.c"); }; return(-1); } if ( X != ((void *)0) ) { munmap(X, nX); X = ((void *)0); nX = 0; } };
  return(status);
}

canonical_original_code:
int s_to_f(char *tbl, char *fld, char *str_scalar)
{
  int status = 0;
  char *X = ((void *)0); unsigned long nX = 0;
  int fileno = -1; int ddir_id = -1;
  char str_fldtype[32];
  char op[32];
  long long nR;
  int fldsz = (-0x7fffffff - 1);
  struct _TBL_REC_TYPE tbl_rec; int tbl_id;
  struct _FLD_REC_TYPE fld_rec; int fld_id;
  enum _FLD_TYPE fldtype;
  _Bool is_null = 1;
  zero_string(str_fldtype, 32);
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_scalar == ((void *)0) ) || ( *str_scalar == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "s_to_f.c"); }; status = -1 ; goto BYE; }; } };
  nR = tbl_rec.nR;
  zero_string(op, 32);
  status = extract_S(str_scalar, "op=[", "]", op, 32, &is_null);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 56, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  if ( ( strcmp(op, "const") == 0 ) ||
       ( strcmp(op, "seq") == 0 ) ) {
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 62, "s_to_f.c"); }; status = -1 ; goto BYE; };
  }
  status = extract_S(str_scalar, "fldtype=[", "]", str_fldtype, 32, &is_null);
  if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  if ( ( str_fldtype == ((void *)0) ) || ( *str_fldtype == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 67, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
  status = unstr_fldtype(str_fldtype, &fldtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 68, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  status = get_fld_sz(fldtype, &fldsz); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  unsigned long filesz = nR * fldsz;
  status = mk_temp_file(filesz, &ddir_id, &fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 73, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ddir_id, fileno, &X, &nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  status = vec_s_to_f(X, nR, str_scalar); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 76, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 77, "s_to_f.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 77, "s_to_f.c"); }; return(-1); } if ( X != ((void *)0) ) { munmap(X, nX); X = ((void *)0); nX = 0; } };
  zero_fld_rec(&fld_rec); fld_rec.fldtype = fldtype;
  status = add_fld(tbl_id, fld, ddir_id, fileno, &fld_id, &fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
  if ( strcmp(op, "seq") == 0 ) {
    long long incrI8; _Bool is_null;
    status = extract_I8(str_scalar, "incr=[", "]", &incrI8, &is_null);
    { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
    if ( is_null ) { { { fprintf(stderr, "Line %3d of File %s \n", 86, "s_to_f.c"); }; status = -1 ; goto BYE; }; }
    if ( incrI8 < 0 ) {
      status = int_set_meta(tbl_id, fld_id, "srttype", "descending", 1);
      { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 89, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
    }
    else if ( incrI8 > 0 ) {
      status = int_set_meta(tbl_id, fld_id, "srttype", "ascending", 1);
      { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 93, "s_to_f.c"); }; status = (status) ; goto BYE; } } };
    }
  }
 BYE:
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 98, "s_to_f.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 98, "s_to_f.c"); }; return(-1); } if ( X != ((void *)0) ) { munmap(X, nX); X = ((void *)0); nX = 0; } };
  return(status);
}

variable_types:
tbl
char *

variable_types:
fld
char *

variable_types:
X
char *

variable_types:
nX
unsigned long

variable_types: fileno int

variable_types:
op
char [32]

variable_types:
nR
long long

variable_types: fldsz 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
unsigned long


repo: linkedin/datacl

original_code:
int
pos_mmad_I4_I8(
    int *f1,
    long long nR1,
    long long *f2,
    long long nR2,
    int *ptr_minval,
    int *ptr_maxval,
    long long *ptr_sum
    )
{
  int status = 0;
  int minval = *ptr_minval;
  int maxval = *ptr_maxval;
  long long sum = *ptr_sum;
  for ( long long i = 0; i < nR2; i++ ) {
    long long f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "./AUX/pos_mmad_I4_I8.c"); }; status = -1 ; goto BYE; }; }
    int f1val = f1[f1idx];
    if ( f1val < minval ) { minval = f1val; }
    if ( f1val > maxval ) { maxval = f1val; }
    sum += (long long)f1val;
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 43, "./AUX/pos_mmad_I4_I8.c"); }; status = (status) ; goto BYE; } } };
  *ptr_minval = minval;
  *ptr_maxval = maxval;
  *ptr_sum = sum;
BYE:
  return(status);
}

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

variable_types: status int

variable_types: minval int

variable_types: maxval int

variable_types:
sum
long long

variable_types:
i
long long

return_type: int


original_code:
void
vec_abs_F4(
       float *in,
       int nR,
       float *out
       )
{
  int i;
  for ( i = 0; i < nR; i++ ) {
    *out = (float)fabsf(*in);
    in++;
    out++;
  }
}

canonical_original_code:
void vec_abs_F4(float *in, int nR, float *out)
{
  int i;
  for ( i = 0; i < nR; i++ ) {
    *out = (float)fabsf(*in);
    in++;
    out++;
  }
}

variable_types:
in
float *

variable_types: nR int

variable_types:
out
float *

variable_types: i int

return_type: void


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

canonical_original_code:
int pos_sel_copy_I8_I4(long long *f1, long long nR1, int *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++ ) {
    int f1idx = f2[i2];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "./AUX/pos_sel_copy_I8_I4.c"); }; status = -1 ; goto BYE; }; }
    long long val = f1[f1idx];
    if ( ( val >= lb ) && ( val <= ub ) ) {
      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


original_code:
int
find_closest_I4(
    int *X,
    long long n,
    int val,
    char *str_mode,
    long long *ptr_idx
    )
{
  int status = 0;
  int mode;
  if ( strcmp(str_mode, "lowest") == 0 ) {
    mode = 100;
  }
  else if ( strcmp(str_mode, "highest") == 0 ) {
    mode = 200;
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 41, "./dir_utils/find_closest_I4.c"); }; status = -1 ; goto BYE; };
  }
  long long mid = (-0x7fffffffffffffffLL - 1LL);
  long long bot = 0;
  long long top = n-1;
  for ( ; ; ) {
    mid = ( bot + top ) / 2;
    if ( ( mid == 0 ) || ( mid == n-1 ) ) {
      *ptr_idx = mid;
      break;
    }
    if ( X[mid] > val ) {
      top = mid;
    }
    else if ( X[mid] < val ) {
      bot = mid;
    }
    else {
      if ( mode == 100 ) {
 if ( X[mid-1] == val ) {
   top = mid;
 }
 else {
   *ptr_idx = mid; break;
 }
      }
      else if ( mode == 200 ) {
 if ( X[mid+1] == val ) {
   bot = mid;
 }
 else {
   *ptr_idx = mid; break;
 }
      }
      else {
 { { fprintf(stderr, "Line %3d of File %s \n", 76, "./dir_utils/find_closest_I4.c"); }; status = -1 ; goto BYE; };
      }
    }
  }
BYE:
  return(status);
}

canonical_original_code:
int find_closest_I4(int *X, long long n, int val, char *str_mode, long long *ptr_idx)
{
  int status = 0;
  int mode;
  if ( strcmp(str_mode, "lowest") == 0 ) {
    mode = 100;
  }
  else if ( strcmp(str_mode, "highest") == 0 ) {
    mode = 200;
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 41, "./dir_utils/find_closest_I4.c"); }; status = -1 ; goto BYE; };
  }
  long long mid = (-0x7fffffffffffffffLL - 1LL);
  long long bot = 0;
  long long top = n-1;
  for ( ; ; ) {
    mid = ( bot + top ) / 2;
    if ( ( mid == 0 ) || ( mid == n-1 ) ) {
      *ptr_idx = mid;
      break;
    }
    if ( X[mid] > val ) {
      top = mid;
    }
    else if ( X[mid] < val ) {
      bot = mid;
    }
    else {
      if ( mode == 100 ) {
 if ( X[mid-1] == val ) {
   top = mid;
 }
 else {
   *ptr_idx = mid; break;
 }
      }
      else if ( mode == 200 ) {
 if ( X[mid+1] == val ) {
   bot = mid;
 }
 else {
   *ptr_idx = mid; break;
 }
      }
      else {
 { { fprintf(stderr, "Line %3d of File %s \n", 76, "./dir_utils/find_closest_I4.c"); }; status = -1 ; goto BYE; };
      }
    }
  }
BYE:
  return(status);
}

variable_types:
X
int *

variable_types:
n
long long

variable_types: val int

variable_types: mode int

variable_types:
mid
long long

variable_types:
bot
long long

variable_types:
top
long long


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

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

variable_types: status int

variable_types:
delta
long long


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

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

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

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

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

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


original_code:
int
pos_mmad_I8_I4(
    long long *f1,
    long long nR1,
    int *f2,
    long long nR2,
    long long *ptr_minval,
    long long *ptr_maxval,
    long long *ptr_sum
    )
{
  int status = 0;
  long long minval = *ptr_minval;
  long long maxval = *ptr_maxval;
  long long sum = *ptr_sum;
  for ( long long i = 0; i < nR2; i++ ) {
    int f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 36, "./AUX/pos_mmad_I8_I4.c"); }; status = -1 ; goto BYE; }; }
    long long f1val = f1[f1idx];
    if ( f1val < minval ) { minval = f1val; }
    if ( f1val > maxval ) { maxval = f1val; }
    sum += (long long)f1val;
  }
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 43, "./AUX/pos_mmad_I8_I4.c"); }; status = (status) ; goto BYE; } } };
  *ptr_minval = minval;
  *ptr_maxval = maxval;
  *ptr_sum = sum;
BYE:
  return(status);
}

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

variable_types:
minval
long long

variable_types:
maxval
long long

variable_types:
sum
long long

variable_types:
i
long long


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

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

variable_types:
cfld
char *

variable_types:
cnt
long long *

variable_types:
cptr
char *

variable_types:
idx
long long


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

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

variable_types:
X
char *

variable_types:
nR
long long

variable_types: yval int

variable_types: zval int

variable_types:
W
int *

variable_types:
Y
int *

variable_types:
Z
int *


decompiled_code:
__int64 __fastcall replace_char(__int64 a1, const char *a2, const char *a3)
{
int v4; // ebp
char v5; // bl
char v7; // cl
size_t v8; // rax
size_t len; // [rsp+0h] [rbp-38h] BYREF
void *addr; // [rsp+8h] [rbp-30h] BYREF

addr = 0LL;
len = 0LL;
v4 = rs_mmap(a1, &addr, &len, 1LL);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 21LL, "replace_char.c");
goto LABEL_10;
}
if ( !len )
{
fprintf(stderr, "Line %3d of File %s \n", 22LL, "replace_char.c");
v4 = -1;
goto LABEL_10;
}
if ( strlen(a2) <= 1 )
{
v5 = *a2;
}
else if ( !strcmp(a2, "bslashn") )
{
v5 = 10;
}
else if ( !strcmp(a2, "ctrl_z") )
{
v5 = 32;
}
else
{
v5 = 13;
if ( strcmp(a2, "bslashr") )
{
fprintf(stderr, "str_inchar = [%s] \n", a2);
fprintf(stderr, "Line %3d of File %s \n", 36LL, "replace_char.c");
v4 = -1;
goto LABEL_10;
}
}
if ( strlen(a3) <= 1 )
{
v7 = *a3;
}
else if ( !strcmp(a3, "bslashn") )
{
v7 = 10;
}
else if ( !strcmp(a3, "bslashr") )
{
v7 = 13;
}
else
{
v7 = 9;
if ( strcmp(a3, "tab") )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "replace_char.c");
v4 = -1;
goto LABEL_10;
}
}
v8 = 0LL;
do
{
if ( *((_BYTE *)addr + v8) == v5 )
*((_BYTE *)addr + v8) = v7;
++v8;
}
while ( len > v8 );
LABEL_10:
if ( !addr )
{
if ( !len )
return (unsigned int)v4;
LABEL_30:
fprintf(stderr, "Line %3d of File %s \n", 62LL, "replace_char.c");
return (unsigned int)-1;
}
if ( !len )
goto LABEL_30;
munmap(addr, len);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2, const char *a3)
{
int v4; // ebp
char v5; // bl
char v7; // cl
size_t v8; // rax
size_t len; // [rsp+0h] [rbp-38h] BYREF
void *addr; // [rsp+8h] [rbp-30h] BYREF

addr = 0LL;
len = 0LL;
v4 = rs_mmap(a1, &addr, &len, 1LL);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 21LL, "replace_char.c");
goto LABEL_10;
}
if ( !len )
{
fprintf(stderr, "Line %3d of File %s \n", 22LL, "replace_char.c");
v4 = -1;
goto LABEL_10;
}
if ( strlen(a2) <= 1 )
{
v5 = *a2;
}
else if ( !strcmp(a2, "bslashn") )
{
v5 = 10;
}
else if ( !strcmp(a2, "ctrl_z") )
{
v5 = 32;
}
else
{
v5 = 13;
if ( strcmp(a2, "bslashr") )
{
fprintf(stderr, "str_inchar = [%s] \n", a2);
fprintf(stderr, "Line %3d of File %s \n", 36LL, "replace_char.c");
v4 = -1;
goto LABEL_10;
}
}
if ( strlen(a3) <= 1 )
{
v7 = *a3;
}
else if ( !strcmp(a3, "bslashn") )
{
v7 = 10;
}
else if ( !strcmp(a3, "bslashr") )
{
v7 = 13;
}
else
{
v7 = 9;
if ( strcmp(a3, "tab") )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "replace_char.c");
v4 = -1;
goto LABEL_10;
}
}
v8 = 0LL;
do
{
if ( *((_BYTE *)addr + v8) == v5 )
*((_BYTE *)addr + v8) = v7;
++v8;
}
while ( len > v8 );
LABEL_10:
if ( !addr )
{
if ( !len )
return (unsigned int)v4;
LABEL_30:
fprintf(stderr, "Line %3d of File %s \n", 62LL, "replace_char.c");
return (unsigned int)-1;
}
if ( !len )
goto LABEL_30;
munmap(addr, len);
return (unsigned int)v4;
}

original_code:
int
replace_char(
    char *infile,
    char *str_inchar,
    char *str_outchar
    )
{
  int status = 0;
  char *X = ((void *)0); size_t nX = 0;
  char inchar, outchar;
  status = rs_mmap(infile, &X, &nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 21, "replace_char.c"); }; status = (status) ; goto BYE; } } };
  if ( nX == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 22, "replace_char.c"); }; status = -1 ; goto BYE; }; }
  if ( strlen(str_inchar) > 1 ) {
    if ( strcmp(str_inchar, "bslashn") == 0 ) {
      inchar = '\n';
    }
    else if ( strcmp(str_inchar, "ctrl_z") == 0 ) {
      inchar = 32;
    }
    else if ( strcmp(str_inchar, "bslashr") == 0 ) {
      inchar = '\r';
    }
    else {
      fprintf(stderr, "str_inchar = [%s] \n", str_inchar);
      { { fprintf(stderr, "Line %3d of File %s \n", 36, "replace_char.c"); }; status = -1 ; goto BYE; }; }
  }
  else {
    inchar = *str_inchar;
  }
  if ( strlen(str_outchar) > 1 ) {
    if ( strcmp(str_outchar, "bslashn") == 0 ) {
      outchar = '\n';
    }
    else if ( strcmp(str_outchar, "bslashr") == 0 ) {
      outchar = '\r';
    }
    else if ( strcmp(str_outchar, "tab") == 0 ) {
      outchar = '\t';
    }
    else { { { fprintf(stderr, "Line %3d of File %s \n", 52, "replace_char.c"); }; status = -1 ; goto BYE; }; }
  }
  else {
    outchar = *str_outchar;
  }
  for ( long long i = 0; i < nX; i++ ) {
    if ( X[i] == inchar ) { X[i] = outchar; }
  }
BYE:
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 62, "replace_char.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 62, "replace_char.c"); }; return(-1); } if ( X != ((void *)0) ) { munmap(X, nX); X = ((void *)0); nX = 0; } };
  return(status);
}

canonical_original_code:
int replace_char(char *infile, char *str_inchar, char *str_outchar)
{
  int status = 0;
  char *X = ((void *)0); unsigned long nX = 0;
  char inchar; char outchar;
  status = rs_mmap(infile, &X, &nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 21, "replace_char.c"); }; status = (status) ; goto BYE; } } };
  if ( nX == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 22, "replace_char.c"); }; status = -1 ; goto BYE; }; }
  if ( strlen(str_inchar) > 1 ) {
    if ( strcmp(str_inchar, "bslashn") == 0 ) {
      inchar = '\n';
    }
    else if ( strcmp(str_inchar, "ctrl_z") == 0 ) {
      inchar = 32;
    }
    else if ( strcmp(str_inchar, "bslashr") == 0 ) {
      inchar = '\r';
    }
    else {
      fprintf(stderr, "str_inchar = [%s] \n", str_inchar);
      { { fprintf(stderr, "Line %3d of File %s \n", 36, "replace_char.c"); }; status = -1 ; goto BYE; }; }
  }
  else {
    inchar = *str_inchar;
  }
  if ( strlen(str_outchar) > 1 ) {
    if ( strcmp(str_outchar, "bslashn") == 0 ) {
      outchar = '\n';
    }
    else if ( strcmp(str_outchar, "bslashr") == 0 ) {
      outchar = '\r';
    }
    else if ( strcmp(str_outchar, "tab") == 0 ) {
      outchar = '\t';
    }
    else { { { fprintf(stderr, "Line %3d of File %s \n", 52, "replace_char.c"); }; status = -1 ; goto BYE; }; }
  }
  else {
    outchar = *str_outchar;
  }
  for ( long long i = 0; i < nX; i++ ) {
    if ( X[i] == inchar ) { X[i] = outchar; }
  }
BYE:
  { if ( ( X == ((void *)0) ) && ( nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 62, "replace_char.c"); }; return(-1); } if ( ( X != ((void *)0) ) && ( nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 62, "replace_char.c"); }; return(-1); } if ( X != ((void *)0) ) { munmap(X, nX); X = ((void *)0); nX = 0; } };
  return(status);
}

variable_types:
infile
char *

variable_types: status int

variable_types:
nX
unsigned long

variable_types: inchar char

variable_types: outchar char


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

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

variable_types:
iX
char *

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

variable_types:
i
long long


decompiled_code:
__int64 __fastcall cfld_to_range(char *s1, _BYTE *a2, const char *a3, _BYTE *a4, _BYTE *a5)
{
int v8; // er14
__int64 v10; // r15
int v11; // edx
__int64 v12; // rbp
__int64 v13; // rdi
__int64 v14; // rsi
__int64 v15; // rax
__int64 v16; // [rsp+0h] [rbp-5C8h]
_QWORD *v17; // [rsp+0h] [rbp-5C8h]
_QWORD *v18; // [rsp+8h] [rbp-5C0h]
char s[32]; // [rsp+10h] [rbp-5B8h] BYREF
char v20[16]; // [rsp+30h] [rbp-598h] BYREF
char v21[24]; // [rsp+40h] [rbp-588h] BYREF
int v22; // [rsp+58h] [rbp-570h] BYREF
int v23; // [rsp+5Ch] [rbp-56Ch] BYREF
int v24; // [rsp+60h] [rbp-568h] BYREF
int v25; // [rsp+64h] [rbp-564h] BYREF
unsigned int v26; // [rsp+68h] [rbp-560h] BYREF
int v27; // [rsp+6Ch] [rbp-55Ch] BYREF
char v28[224]; // [rsp+70h] [rbp-558h] BYREF
__int64 v29; // [rsp+150h] [rbp-478h] BYREF
__int64 v30; // [rsp+168h] [rbp-460h]
char v31[224]; // [rsp+230h] [rbp-398h] BYREF
char v32[224]; // [rsp+310h] [rbp-2B8h] BYREF
char v33[176]; // [rsp+3F0h] [rbp-1D8h] BYREF
__int64 v34[22]; // [rsp+4A0h] [rbp-128h] BYREF
unsigned int v35; // [rsp+554h] [rbp-74h] BYREF
size_t v36; // [rsp+558h] [rbp-70h] BYREF
void *v37; // [rsp+560h] [rbp-68h] BYREF
unsigned int v38; // [rsp+56Ch] [rbp-5Ch] BYREF
size_t v39; // [rsp+570h] [rbp-58h] BYREF
void *v40; // [rsp+578h] [rbp-50h] BYREF
size_t len; // [rsp+580h] [rbp-48h] BYREF
void *addr; // [rsp+588h] [rbp-40h] BYREF

addr = 0LL;
len = 0LL;
v40 = 0LL;
v39 = 0LL;
v37 = 0LL;
v36 = 0LL;
v27 = 0x80000000;
v26 = 0x80000000;
v25 = 0x80000000;
v24 = 0x80000000;
v23 = 0x80000000;
v22 = 0x80000000;
zero_string(v21, 16LL);
zero_string(v20, 16LL);
if ( !s1 || !*s1 )
{
fprintf(stderr, "Line %3d of File %s \n", 57LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !strcmp(s1, a3) )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !a4 || !*a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !a5 || !*a5 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
v8 = is_tbl(s1, &v27, v34);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
if ( v27 < 0 || v27 >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
v10 = v34[0];
v16 = 8 * v34[0];
v8 = mk_temp_file(v21, 8 * v34[0], &v38);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
v8 = q_mmap(v38, v21, &v40, &v39, 1LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
v18 = v40;
v8 = mk_temp_file(v20, v16, &v35);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 77LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
v8 = q_mmap(v35, v20, &v37, &v36, 1LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 78LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
v17 = v37;
v8 = is_fld(0LL, (unsigned int)v27, a2, &v25, &v29, &v24, v28);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
if ( v25 < 0 || v25 >= g_n_fld )
{
fprintf(stderr, "Line %3d of File %s \n", 84LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( v24 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
v8 = get_data(&addr, &len, 0LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 86LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
if ( (_DWORD)v30 != 2 )
{
fprintf(stderr, "Line %3d of File %s \n", 87LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( v10 > 0 )
{
v11 = 0;
v12 = 0LL;
v13 = 0LL;
do
{
if ( *((_BYTE *)addr + v11) )
{
if ( v10 <= v11 )
{
v14 = -1LL;
}
else
{
v15 = v11 + 1;
while ( 1 )
{
v11 = v15;
v14 = v15;
if ( v10 == v15 )
break;
if ( !*((char *)addr + v15++) )
goto LABEL_55;
}
v14 = v10;
}
LABEL_55:
v18[v12] = v13;
v17[v12++] = v14;
}
v13 = ++v11;
}
while ( v11 < v10 );
if ( v12 )
{
if ( v40 )
{
if ( v39 )
{
munmap(v40, v39);
v40 = 0LL;
v39 = 0LL;
goto LABEL_68;
}
}
else if ( !v39 )
{
LABEL_68:
if ( v37 )
{
if ( v36 )
{
munmap(v37, v36);
v37 = 0LL;
v36 = 0LL;
LABEL_71:
if ( v12 < v10 )
{
q_trunc(v38, v21, 8 * v12);
q_trunc(v35, v20, 8 * v12);
}
sprintf(s, "%lld", v12);
v8 = add_tbl(a3, s, &v26, v33);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 123LL, "./dir_wr_verbs/cfld_to_range.c");
}
else
{
v8 = add_fld(v26, a4, v38, v21, 5LL, 0xFFFFFFFFLL, &v23, v32);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 126LL, "./dir_wr_verbs/cfld_to_range.c");
}
else
{
v8 = add_fld(v26, a5, v35, v20, 5LL, 0xFFFFFFFFLL, &v22, v31);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 128LL, "./dir_wr_verbs/cfld_to_range.c");
}
}
goto LABEL_14;
}
}
else if ( !v36 )
{
goto LABEL_71;
}
fprintf(stderr, "Line %3d of File %s \n", 115LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
fprintf(stderr, "Line %3d of File %s \n", 114LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
}
LABEL_14:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_17;
}
LABEL_86:
fprintf(stderr, "Line %3d of File %s \n", 130LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_86;
LABEL_17:
if ( v40 )
{
if ( v39 )
{
munmap(v40, v39);
v40 = 0LL;
v39 = 0LL;
goto LABEL_20;
}
LABEL_89:
fprintf(stderr, "Line %3d of File %s \n", 131LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
if ( v39 )
goto LABEL_89;
LABEL_20:
if ( !v37 )
{
if ( !v36 )
return (unsigned int)v8;
LABEL_92:
fprintf(stderr, "Line %3d of File %s \n", 132LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
if ( !v36 )
goto LABEL_92;
munmap(v37, v36);
return (unsigned int)v8;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, _BYTE *a2, const char *a3, _BYTE *a4, _BYTE *a5)
{
int v8; // er14
__int64 v10; // r15
int v11; // edx
__int64 v12; // rbp
__int64 v13; // rdi
__int64 v14; // rsi
__int64 v15; // rax
__int64 v16; // [rsp+0h] [rbp-5C8h]
_QWORD *v17; // [rsp+0h] [rbp-5C8h]
_QWORD *v18; // [rsp+8h] [rbp-5C0h]
char s[32]; // [rsp+10h] [rbp-5B8h] BYREF
char v20[16]; // [rsp+30h] [rbp-598h] BYREF
char v21[24]; // [rsp+40h] [rbp-588h] BYREF
int v22; // [rsp+58h] [rbp-570h] BYREF
int v23; // [rsp+5Ch] [rbp-56Ch] BYREF
int v24; // [rsp+60h] [rbp-568h] BYREF
int v25; // [rsp+64h] [rbp-564h] BYREF
unsigned int v26; // [rsp+68h] [rbp-560h] BYREF
int v27; // [rsp+6Ch] [rbp-55Ch] BYREF
char v28[224]; // [rsp+70h] [rbp-558h] BYREF
__int64 v29; // [rsp+150h] [rbp-478h] BYREF
__int64 v30; // [rsp+168h] [rbp-460h]
char v31[224]; // [rsp+230h] [rbp-398h] BYREF
char v32[224]; // [rsp+310h] [rbp-2B8h] BYREF
char v33[176]; // [rsp+3F0h] [rbp-1D8h] BYREF
__int64 v34[22]; // [rsp+4A0h] [rbp-128h] BYREF
unsigned int v35; // [rsp+554h] [rbp-74h] BYREF
size_t v36; // [rsp+558h] [rbp-70h] BYREF
void *v37; // [rsp+560h] [rbp-68h] BYREF
unsigned int v38; // [rsp+56Ch] [rbp-5Ch] BYREF
size_t v39; // [rsp+570h] [rbp-58h] BYREF
void *v40; // [rsp+578h] [rbp-50h] BYREF
size_t len; // [rsp+580h] [rbp-48h] BYREF
void *addr; // [rsp+588h] [rbp-40h] BYREF

addr = 0LL;
len = 0LL;
v40 = 0LL;
v39 = 0LL;
v37 = 0LL;
v36 = 0LL;
v27 = 0x80000000;
v26 = 0x80000000;
v25 = 0x80000000;
v24 = 0x80000000;
v23 = 0x80000000;
v22 = 0x80000000;
zero_string(v21, 16LL);
zero_string(v20, 16LL);
if ( !s1 || !*s1 )
{
fprintf(stderr, "Line %3d of File %s \n", 57LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !a3 || !*a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !strcmp(s1, a3) )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !a4 || !*a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( !a5 || !*a5 )
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
v8 = is_tbl(s1, &v27, v34);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
if ( v27 < 0 || v27 >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 66LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
v10 = v34[0];
v16 = 8 * v34[0];
v8 = mk_temp_file(v21, 8 * v34[0], &v38);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
v8 = q_mmap(v38, v21, &v40, &v39, 1LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
v18 = v40;
v8 = mk_temp_file(v20, v16, &v35);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 77LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
v8 = q_mmap(v35, v20, &v37, &v36, 1LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 78LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
v17 = v37;
v8 = is_fld(0LL, (unsigned int)v27, a2, &v25, &v29, &v24, v28);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
if ( v25 < 0 || v25 >= g_n_fld )
{
fprintf(stderr, "Line %3d of File %s \n", 84LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( v24 >= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 85LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
v8 = get_data(&addr, &len, 0LL);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 86LL, "./dir_wr_verbs/cfld_to_range.c");
goto LABEL_14;
}
if ( (_DWORD)v30 != 2 )
{
fprintf(stderr, "Line %3d of File %s \n", 87LL, "./dir_wr_verbs/cfld_to_range.c");
v8 = -1;
goto LABEL_14;
}
if ( v10 > 0 )
{
v11 = 0;
v12 = 0LL;
v13 = 0LL;
do
{
if ( *((_BYTE *)addr + v11) )
{
if ( v10 <= v11 )
{
v14 = -1LL;
}
else
{
v15 = v11 + 1;
while ( 1 )
{
v11 = v15;
v14 = v15;
if ( v10 == v15 )
break;
if ( !*((char *)addr + v15++) )
goto LABEL_55;
}
v14 = v10;
}
LABEL_55:
v18[v12] = v13;
v17[v12++] = v14;
}
v13 = ++v11;
}
while ( v11 < v10 );
if ( v12 )
{
if ( v40 )
{
if ( v39 )
{
munmap(v40, v39);
v40 = 0LL;
v39 = 0LL;
goto LABEL_68;
}
}
else if ( !v39 )
{
LABEL_68:
if ( v37 )
{
if ( v36 )
{
munmap(v37, v36);
v37 = 0LL;
v36 = 0LL;
LABEL_71:
if ( v12 < v10 )
{
q_trunc(v38, v21, 8 * v12);
q_trunc(v35, v20, 8 * v12);
}
sprintf(s, "%lld", v12);
v8 = add_tbl(a3, s, &v26, v33);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 123LL, "./dir_wr_verbs/cfld_to_range.c");
}
else
{
v8 = add_fld(v26, a4, v38, v21, 5LL, 0xFFFFFFFFLL, &v23, v32);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 126LL, "./dir_wr_verbs/cfld_to_range.c");
}
else
{
v8 = add_fld(v26, a5, v35, v20, 5LL, 0xFFFFFFFFLL, &v22, v31);
if ( v8 < 0 )
fprintf(stderr, "Line %3d of File %s \n", 128LL, "./dir_wr_verbs/cfld_to_range.c");
}
}
goto LABEL_14;
}
}
else if ( !v36 )
{
goto LABEL_71;
}
fprintf(stderr, "Line %3d of File %s \n", 115LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
fprintf(stderr, "Line %3d of File %s \n", 114LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
}
LABEL_14:
if ( addr )
{
if ( len )
{
munmap(addr, len);
addr = 0LL;
len = 0LL;
goto LABEL_17;
}
LABEL_86:
fprintf(stderr, "Line %3d of File %s \n", 130LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
if ( len )
goto LABEL_86;
LABEL_17:
if ( v40 )
{
if ( v39 )
{
munmap(v40, v39);
v40 = 0LL;
v39 = 0LL;
goto LABEL_20;
}
LABEL_89:
fprintf(stderr, "Line %3d of File %s \n", 131LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
if ( v39 )
goto LABEL_89;
LABEL_20:
if ( !v37 )
{
if ( !v36 )
return (unsigned int)v8;
LABEL_92:
fprintf(stderr, "Line %3d of File %s \n", 132LL, "./dir_wr_verbs/cfld_to_range.c");
return (unsigned int)-1;
}
if ( !v36 )
goto LABEL_92;
munmap(v37, v36);
return (unsigned int)v8;
}

original_code:
int
cfld_to_range(
       char *src_tbl,
       char *src_fld,
       char *dst_tbl,
       char *lb_fld,
       char *ub_fld
       )
{
  int status = 0;
  char *src_X = ((void *)0); size_t src_nX = 0;
  char *lb_X = ((void *)0); size_t lb_nX = 0; int lb_ddir_id;
  char *ub_X = ((void *)0); size_t ub_nX = 0; int ub_ddir_id;
  TBL_REC_TYPE src_tbl_rec, dst_tbl_rec;
  FLD_REC_TYPE lb_fld_rec, ub_fld_rec;
  FLD_REC_TYPE src_fld_rec, nn_src_fld_rec;
  long long src_nR = (-0x7fffffffffffffffLL - 1LL), dst_nR = (-0x7fffffffffffffffLL - 1LL);
  int src_tbl_id = (-0x7fffffff - 1), dst_tbl_id = (-0x7fffffff - 1);
  int src_fld_id = (-0x7fffffff - 1), nn_src_fld_id = (-0x7fffffff - 1);
  int lb_fld_id = (-0x7fffffff - 1);
  int ub_fld_id = (-0x7fffffff - 1);
  char lbfile[15 +1];
  char ubfile[15 +1];
  zero_string(lbfile, 15 +1);
  zero_string(ubfile, 15 +1);
  if ( ( src_tbl == ((void *)0) ) || ( *src_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( ( dst_tbl == ((void *)0) ) || ( *dst_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(src_tbl, dst_tbl) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( ( src_fld == ((void *)0) ) || ( *src_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( ( lb_fld == ((void *)0) ) || ( *lb_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( ( ub_fld == ((void *)0) ) || ( *ub_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(src_tbl, &src_tbl_id, &src_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (src_tbl_id) < (0) ) || ( (src_tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; } };
  src_nR = src_tbl_rec.nR;
  long long max_dst_nR = src_nR;
  long long filesz = max_dst_nR * sizeof(long long);
  status = mk_temp_file(lbfile, filesz, &lb_ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 73, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(lb_ddir_id, lbfile, &lb_X, &lb_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  long long *lbI8 = (long long *)lb_X;
  status = mk_temp_file(ubfile, filesz, &ub_ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 77, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ub_ddir_id, ubfile, &ub_X, &ub_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  long long *ubI8 = (long long *)ub_X;
  status = is_fld(((void *)0), src_tbl_id, src_fld, &src_fld_id,
    &src_fld_rec, &nn_src_fld_id, &nn_src_fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (src_fld_id) < (0) ) || ( (src_fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; } };
  if ( nn_src_fld_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(src_fld_rec, &src_X, &src_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 86, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  if ( src_fld_rec.fldtype != I1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 87, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  long long rangelb, rangeub;
  dst_nR = 0;
  for ( int i = 0; i < src_nR; i++ ) {
    if ( src_X[i] == 0 ) { continue; }
    rangelb = i;
    rangeub = -1;
    for ( ; i < src_nR; i++ ) {
      if ( src_X[i] == 0 ) {
 rangeub = i;
 break;
      }
      if ( rangeub < 0 ) {
 rangeub = src_nR;
      }
    }
    lbI8[dst_nR] = rangelb;
    ubI8[dst_nR] = rangeub;
    dst_nR++;
  }
  if ( dst_nR == 0 ) { goto BYE; }
  { if ( ( lb_X == ((void *)0) ) && ( lb_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 114, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( lb_X != ((void *)0) ) && ( lb_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 114, "./dir_wr_verbs/cfld_to_range.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", 115, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( ub_X != ((void *)0) ) && ( ub_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 115, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ub_X != ((void *)0) ) { munmap(ub_X, ub_nX); ub_X = ((void *)0); ub_nX = 0; } };
  if ( dst_nR < src_nR ) {
    q_trunc(lb_ddir_id, lbfile, (dst_nR * sizeof(long long)));
    q_trunc(ub_ddir_id, ubfile, (dst_nR * sizeof(long long)));
  }
  char strbuf[32];
  sprintf(strbuf, "%lld", dst_nR);
  status = add_tbl(dst_tbl, strbuf, &dst_tbl_id, &dst_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 123, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(dst_tbl_id, lb_fld, lb_ddir_id, lbfile, I8, -1,
      &lb_fld_id, &lb_fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 126, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(dst_tbl_id, ub_fld, ub_ddir_id, ubfile, I8, -1,
      &ub_fld_id, &ub_fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 128, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  { if ( ( src_X == ((void *)0) ) && ( src_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 130, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( src_X != ((void *)0) ) && ( src_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 130, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( src_X != ((void *)0) ) { munmap(src_X, src_nX); src_X = ((void *)0); src_nX = 0; } };
  { if ( ( lb_X == ((void *)0) ) && ( lb_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 131, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( lb_X != ((void *)0) ) && ( lb_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 131, "./dir_wr_verbs/cfld_to_range.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", 132, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( ub_X != ((void *)0) ) && ( ub_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 132, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ub_X != ((void *)0) ) { munmap(ub_X, ub_nX); ub_X = ((void *)0); ub_nX = 0; } };
  return(status);
}

canonical_original_code:
int cfld_to_range(char *src_tbl, char *src_fld, char *dst_tbl, char *lb_fld, char *ub_fld)
{
  int status = 0;
  char *src_X = ((void *)0); unsigned long src_nX = 0;
  char *lb_X = ((void *)0); unsigned long lb_nX = 0; int lb_ddir_id;
  char *ub_X = ((void *)0); unsigned long ub_nX = 0; int ub_ddir_id;
  struct _TBL_REC_TYPE src_tbl_rec; struct _TBL_REC_TYPE dst_tbl_rec;
  struct _FLD_REC_TYPE lb_fld_rec; struct _FLD_REC_TYPE ub_fld_rec;
  struct _FLD_REC_TYPE src_fld_rec; struct _FLD_REC_TYPE nn_src_fld_rec;
  long long src_nR = (-0x7fffffffffffffffLL - 1LL); long long dst_nR = (-0x7fffffffffffffffLL - 1LL);
  int src_tbl_id = (-0x7fffffff - 1); int dst_tbl_id = (-0x7fffffff - 1);
  int src_fld_id = (-0x7fffffff - 1); int nn_src_fld_id = (-0x7fffffff - 1);
  int lb_fld_id = (-0x7fffffff - 1);
  int ub_fld_id = (-0x7fffffff - 1);
  char lbfile[-1];
  char ubfile[-1];
  zero_string(lbfile, 15 +1);
  zero_string(ubfile, 15 +1);
  if ( ( src_tbl == ((void *)0) ) || ( *src_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( ( dst_tbl == ((void *)0) ) || ( *dst_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(src_tbl, dst_tbl) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( ( src_fld == ((void *)0) ) || ( *src_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( ( lb_fld == ((void *)0) ) || ( *lb_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  if ( ( ub_fld == ((void *)0) ) || ( *ub_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(src_tbl, &src_tbl_id, &src_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (src_tbl_id) < (0) ) || ( (src_tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; } };
  src_nR = src_tbl_rec.nR;
  long long max_dst_nR = src_nR;
  long long filesz = max_dst_nR * sizeof(long long);
  status = mk_temp_file(lbfile, filesz, &lb_ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 73, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(lb_ddir_id, lbfile, &lb_X, &lb_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  long long *lbI8 = (long long *)lb_X;
  status = mk_temp_file(ubfile, filesz, &ub_ddir_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 77, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  status = q_mmap(ub_ddir_id, ubfile, &ub_X, &ub_nX, 1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  long long *ubI8 = (long long *)ub_X;
  status = is_fld(((void *)0), src_tbl_id, src_fld, &src_fld_id,
    &src_fld_rec, &nn_src_fld_id, &nn_src_fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (src_fld_id) < (0) ) || ( (src_fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; } };
  if ( nn_src_fld_id >= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 85, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  status = get_data(src_fld_rec, &src_X, &src_nX, 0); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 86, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  if ( src_fld_rec.fldtype != I1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 87, "./dir_wr_verbs/cfld_to_range.c"); }; status = -1 ; goto BYE; }; }
  long long rangelb; long long rangeub;
  dst_nR = 0;
  for ( int i = 0; i < src_nR; i++ ) {
    if ( src_X[i] == 0 ) { continue; }
    rangelb = i;
    rangeub = -1;
    for ( ; i < src_nR; i++ ) {
      if ( src_X[i] == 0 ) {
 rangeub = i;
 break;
      }
      if ( rangeub < 0 ) {
 rangeub = src_nR;
      }
    }
    lbI8[dst_nR] = rangelb;
    ubI8[dst_nR] = rangeub;
    dst_nR++;
  }
  if ( dst_nR == 0 ) { goto BYE; }
  { if ( ( lb_X == ((void *)0) ) && ( lb_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 114, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( lb_X != ((void *)0) ) && ( lb_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 114, "./dir_wr_verbs/cfld_to_range.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", 115, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( ub_X != ((void *)0) ) && ( ub_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 115, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ub_X != ((void *)0) ) { munmap(ub_X, ub_nX); ub_X = ((void *)0); ub_nX = 0; } };
  if ( dst_nR < src_nR ) {
    q_trunc(lb_ddir_id, lbfile, (dst_nR * sizeof(long long)));
    q_trunc(ub_ddir_id, ubfile, (dst_nR * sizeof(long long)));
  }
  char strbuf[32];
  sprintf(strbuf, "%lld", dst_nR);
  status = add_tbl(dst_tbl, strbuf, &dst_tbl_id, &dst_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 123, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(dst_tbl_id, lb_fld, lb_ddir_id, lbfile, I8, -1,
      &lb_fld_id, &lb_fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 126, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
  status = add_fld(dst_tbl_id, ub_fld, ub_ddir_id, ubfile, I8, -1,
      &ub_fld_id, &ub_fld_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 128, "./dir_wr_verbs/cfld_to_range.c"); }; status = (status) ; goto BYE; } } };
 BYE:
  { if ( ( src_X == ((void *)0) ) && ( src_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 130, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( src_X != ((void *)0) ) && ( src_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 130, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( src_X != ((void *)0) ) { munmap(src_X, src_nX); src_X = ((void *)0); src_nX = 0; } };
  { if ( ( lb_X == ((void *)0) ) && ( lb_nX != 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 131, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( lb_X != ((void *)0) ) && ( lb_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 131, "./dir_wr_verbs/cfld_to_range.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", 132, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ( ub_X != ((void *)0) ) && ( ub_nX == 0 ) ) { { fprintf(stderr, "Line %3d of File %s \n", 132, "./dir_wr_verbs/cfld_to_range.c"); }; return(-1); } if ( ub_X != ((void *)0) ) { munmap(ub_X, ub_nX); ub_X = ((void *)0); ub_nX = 0; } };
  return(status);
}

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:
lbfile
char [-1]

variable_types:
ubfile
char [-1]

variable_types:
filesz
long long

variable_types:
rangelb
long long

variable_types:
rangeub
long long

variable_types: i int

variable_types:
strbuf
char [32]

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


decompiled_code:
__int64 __fastcall get_file_names(char *s, int *a2, const char **a3, __int64 **a4)
{
const char *v4; // rbp
const unsigned __int16 **v5; // rax
__int64 v6; // rdx
const unsigned __int16 *v7; // rax
__int64 v8; // r12
char *v9; // rax
int v10; // er15
int v11; // er13
__int64 *v12; // r14
const char *v13; // rbx
char *v14; // rbx
size_t v15; // rax
char v16; // al
__int64 v17; // rdx
int v18; // ecx
char *v20; // rax
char *ptr; // [rsp+20h] [rbp-108h]
int i; // [rsp+2Ch] [rbp-FCh]
__int64 v25; // [rsp+30h] [rbp-F8h]
__int64 *v26; // [rsp+38h] [rbp-F0h]
char needle[32]; // [rsp+40h] [rbp-E8h] BYREF
char sa[136]; // [rsp+60h] [rbp-C8h] BYREF
int v29; // [rsp+E8h] [rbp-40h] BYREF
int v30[15]; // [rsp+ECh] [rbp-3Ch] BYREF

zero_string(sa, 128LL);
if ( s && *s )
{
ptr = strdup(s);
v4 = strchr(ptr, 91);
if ( v4 )
{
v5 = _ctype_b_loc();
v6 = v4[1];
v7 = *v5;
v8 = (__int64)&v4[((v7[v6] & 0x2000) != 0) + 1];
v9 = strchr(&v4[((v7[v6] & 0x2000) != 0) + 2], 93);
v4 = v9;
if ( v9 )
{
*v9 = 0;
v10 = count_char(v8, 123LL, v30);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "aux_hdfs.c");
v12 = 0LL;
v4 = 0LL;
v11 = 0;
}
else
{
v10 = count_char(v8, 125LL, &v29);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "aux_hdfs.c");
v12 = 0LL;
v4 = 0LL;
v11 = 0;
}
else
{
v11 = v30[0];
if ( v30[0] == v29 )
{
v4 = (const char *)malloc(8LL * v30[0]);
if ( v4 )
{
v12 = (__int64 *)malloc(8LL * v11);
if ( v12 )
{
while ( 2 )
{
for ( i = 1; ; i = 2 )
{
zero_string(needle, 32LL);
if ( i != 1 )
break;
strcpy(needle, "\"length\":");
if ( v30[0] > 0 )
goto LABEL_25;
}
if ( i != 2 )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "aux_hdfs.c");
LABEL_40:
v10 = -1;
break;
}
strcpy(needle, "\"pathSuffix\":");
if ( v30[0] <= 0 )
break;
LABEL_25:
v26 = v12;
v13 = (const char *)v8;
v25 = 0LL;
do
{
v14 = strstr(v13, needle);
if ( !v14 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "aux_hdfs.c");
goto LABEL_40;
}
v15 = strlen(needle);
v13 = &v14[v15 + (v14[v15] == 34)];
zero_string(sa, 128LL);
v16 = *v13;
if ( *v13 != 44 && v16 != 34 )
{
v17 = 1LL;
while ( v16 )
{
++v13;
needle[v17 + 31] = v16;
v18 = v17;
v16 = *v13;
if ( *v13 == 44 || v16 == 34 )
goto LABEL_37;
if ( ++v17 == 128 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "aux_hdfs.c");
goto LABEL_40;
}
}
fprintf(stderr, "Line %3d of File %s \n", 66LL, "aux_hdfs.c");
goto LABEL_40;
}
v18 = 0;
LABEL_37:
sa[v18] = 0;
if ( i == 1 )
{
v10 = stoI8(sa, v26);
if ( *v26 <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "aux_hdfs.c");
goto LABEL_40;
}
}
else
{
v20 = strdup(sa);
*(_QWORD *)&v4[8 * v25] = v20;
if ( !v20 )
{
fprintf(stderr, "Line %3d of File %s \n", 78LL, "aux_hdfs.c");
goto LABEL_40;
}
}
++v25;
++v26;
}
while ( v30[0] > (int)v25 );
if ( ++i != 3 )
continue;
break;
}
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 47LL, "aux_hdfs.c");
v10 = -1;
}
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 45LL, "aux_hdfs.c");
v12 = 0LL;
v10 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "aux_hdfs.c");
v12 = 0LL;
v4 = 0LL;
v11 = 0;
v10 = -1;
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "aux_hdfs.c");
v12 = 0LL;
v11 = 0;
v10 = -1;
}
}
else
{
fprintf(stderr, "in_str=%s\n", s);
fprintf(stderr, "Line %3d of File %s \n", 33LL, "aux_hdfs.c");
v12 = 0LL;
v11 = 0;
v10 = -1;
}
free(ptr);
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 30LL, "aux_hdfs.c");
v12 = 0LL;
v4 = 0LL;
v11 = 0;
v10 = -1;
}
*a2 = v11;
*a3 = v4;
*a4 = v12;
return (unsigned int)v10;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s, int *a2, const char **a3, __int64 **a4)
{
const char *v4; // rbp
const unsigned __int16 **v5; // rax
__int64 v6; // rdx
const unsigned __int16 *v7; // rax
__int64 v8; // r12
char *v9; // rax
int v10; // er15
int v11; // er13
__int64 *v12; // r14
const char *v13; // rbx
char *v14; // rbx
size_t v15; // rax
char v16; // al
__int64 v17; // rdx
int v18; // ecx
char *v20; // rax
char *ptr; // [rsp+20h] [rbp-108h]
int i; // [rsp+2Ch] [rbp-FCh]
__int64 v25; // [rsp+30h] [rbp-F8h]
__int64 *v26; // [rsp+38h] [rbp-F0h]
char needle[32]; // [rsp+40h] [rbp-E8h] BYREF
char sa[136]; // [rsp+60h] [rbp-C8h] BYREF
int v29; // [rsp+E8h] [rbp-40h] BYREF
int v30[15]; // [rsp+ECh] [rbp-3Ch] BYREF

zero_string(sa, 128LL);
if ( s && *s )
{
ptr = strdup(s);
v4 = strchr(ptr, 91);
if ( v4 )
{
v5 = _ctype_b_loc();
v6 = v4[1];
v7 = *v5;
v8 = (__int64)&v4[((v7[v6] & 0x2000) != 0) + 1];
v9 = strchr(&v4[((v7[v6] & 0x2000) != 0) + 2], 93);
v4 = v9;
if ( v9 )
{
*v9 = 0;
v10 = count_char(v8, 123LL, v30);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "aux_hdfs.c");
v12 = 0LL;
v4 = 0LL;
v11 = 0;
}
else
{
v10 = count_char(v8, 125LL, &v29);
if ( v10 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "aux_hdfs.c");
v12 = 0LL;
v4 = 0LL;
v11 = 0;
}
else
{
v11 = v30[0];
if ( v30[0] == v29 )
{
v4 = (const char *)malloc(8LL * v30[0]);
if ( v4 )
{
v12 = (__int64 *)malloc(8LL * v11);
if ( v12 )
{
while ( 2 )
{
for ( i = 1; ; i = 2 )
{
zero_string(needle, 32LL);
if ( i != 1 )
break;
strcpy(needle, "\"length\":");
if ( v30[0] > 0 )
goto LABEL_25;
}
if ( i != 2 )
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "aux_hdfs.c");
LABEL_40:
v10 = -1;
break;
}
strcpy(needle, "\"pathSuffix\":");
if ( v30[0] <= 0 )
break;
LABEL_25:
v26 = v12;
v13 = (const char *)v8;
v25 = 0LL;
do
{
v14 = strstr(v13, needle);
if ( !v14 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "aux_hdfs.c");
goto LABEL_40;
}
v15 = strlen(needle);
v13 = &v14[v15 + (v14[v15] == 34)];
zero_string(sa, 128LL);
v16 = *v13;
if ( *v13 != 44 && v16 != 34 )
{
v17 = 1LL;
while ( v16 )
{
++v13;
needle[v17 + 31] = v16;
v18 = v17;
v16 = *v13;
if ( *v13 == 44 || v16 == 34 )
goto LABEL_37;
if ( ++v17 == 128 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "aux_hdfs.c");
goto LABEL_40;
}
}
fprintf(stderr, "Line %3d of File %s \n", 66LL, "aux_hdfs.c");
goto LABEL_40;
}
v18 = 0;
LABEL_37:
sa[v18] = 0;
if ( i == 1 )
{
v10 = stoI8(sa, v26);
if ( *v26 <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 74LL, "aux_hdfs.c");
goto LABEL_40;
}
}
else
{
v20 = strdup(sa);
*(_QWORD *)&v4[8 * v25] = v20;
if ( !v20 )
{
fprintf(stderr, "Line %3d of File %s \n", 78LL, "aux_hdfs.c");
goto LABEL_40;
}
}
++v25;
++v26;
}
while ( v30[0] > (int)v25 );
if ( ++i != 3 )
continue;
break;
}
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 47LL, "aux_hdfs.c");
v10 = -1;
}
}
else
{
fwrite("Unable to allocate memory\n", 1uLL, 0x1AuLL, stderr);
fprintf(stderr, "Line %3d of File %s \n", 45LL, "aux_hdfs.c");
v12 = 0LL;
v10 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 42LL, "aux_hdfs.c");
v12 = 0LL;
v4 = 0LL;
v11 = 0;
v10 = -1;
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "aux_hdfs.c");
v12 = 0LL;
v11 = 0;
v10 = -1;
}
}
else
{
fprintf(stderr, "in_str=%s\n", s);
fprintf(stderr, "Line %3d of File %s \n", 33LL, "aux_hdfs.c");
v12 = 0LL;
v11 = 0;
v10 = -1;
}
free(ptr);
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 30LL, "aux_hdfs.c");
v12 = 0LL;
v4 = 0LL;
v11 = 0;
v10 = -1;
}
*a2 = v11;
*a3 = v4;
*a4 = v12;
return (unsigned int)v10;
}

original_code:
int
get_file_names(
        const char *in_str,
        int *ptr_num_files,
        char ***ptr_filenames,
        long long **ptr_file_lengths
        )
{
  int status = 0;
  int num_files = 0;
  char **filenames = ((void *)0);
  long long *file_lengths = ((void *)0);
  char *lstr = ((void *)0);
  char *str, *cptr;
  int n1, n2;
  char buffer[127 +1];
  zero_string(buffer, 127 +1);
  if ( ( in_str == ((void *)0) ) || ( *in_str == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
  lstr = strdup(in_str);
  str = strstr(lstr, "[");
  if ( str == ((void *)0) ) { fprintf(stderr, "in_str=%s\n", in_str);{ { fprintf(stderr, "Line %3d of File %s \n", 33, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
  str++;
  if ( ((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short int) _ISspace) ) { str++; }
  cptr = strstr(str+1, "]");
  if ( cptr == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
  *cptr = '\0';
  status = count_char(str, '{', &n1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "aux_hdfs.c"); }; status = (status) ; goto BYE; } } };
  status = count_char(str, '}', &n2); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "aux_hdfs.c"); }; status = (status) ; goto BYE; } } };
  if ( n1 != n2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
  num_files = n1;
  filenames = malloc(num_files * sizeof(char *));
  { if ( filenames == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 45, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; } };
  file_lengths = malloc(num_files * sizeof(long long));
  { if ( file_lengths == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 47, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; } };
  char *save_str = str;
  for ( int mode = 1; mode <= 2; mode++ ) {
    str = save_str;
    char start_str[32]; zero_string(start_str, 32);
    switch ( mode ) {
    case 1 : strcpy(start_str, "\"length\":"); break;
    case 2 : strcpy(start_str, "\"pathSuffix\":"); break;
    default : { { fprintf(stderr, "Line %3d of File %s \n", 55, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; break;
    }
    for ( int i = 0; i < n1; i++ ) {
      cptr = strstr(str, start_str);
      if ( cptr == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
      cptr += strlen(start_str);
      if ( *cptr == '"' ) { cptr++; }
      int j;
      zero_string(buffer, 127 +1);
      for ( j = 0; ( ( *cptr != ',' ) && ( *cptr != '"' ) ); j++ ) {
 if ( j >= 127 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
 if ( *cptr == '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
 buffer[j] = *cptr++;
      }
      buffer[j] = '\0';
      switch ( mode ) {
      case 1 :
 status = stoI8(buffer, &(file_lengths[i]));
 if ( file_lengths[i] <= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
 break;
      case 2 :
 filenames[i] = strdup(buffer);
 if ( filenames[i] == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 81, "aux_hdfs.c"); }; status = -1 ; goto BYE; };
 break;
      }
      str = cptr;
    }
  }
 BYE:
  { if ( (lstr) != ((void *)0) ) { free((lstr)); (lstr) = ((void *)0); } };
  *ptr_num_files = num_files;
  *ptr_filenames = filenames;
  *ptr_file_lengths = file_lengths;
  return status ;
}

canonical_original_code:
int get_file_names(char *in_str, int *ptr_num_files, char ***ptr_filenames, long long **ptr_file_lengths)
{
  int status = 0;
  int num_files = 0;
  char **filenames = ((void *)0);
  long long *file_lengths = ((void *)0);
  char *lstr = ((void *)0);
  char *str; char *cptr;
  int n1; int n2;
  char buffer[-1];
  zero_string(buffer, 127 +1);
  if ( ( in_str == ((void *)0) ) || ( *in_str == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
  lstr = strdup(in_str);
  str = strstr(lstr, "[");
  if ( str == ((void *)0) ) { fprintf(stderr, "in_str=%s\n", in_str);{ { fprintf(stderr, "Line %3d of File %s \n", 33, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
  str++;
  if ( ((*__ctype_b_loc ())[(int) ((*str))] & (unsigned short) _ISspace) ) { str++; }
  cptr = strstr(str+1, "]");
  if ( cptr == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
  *cptr = '\0';
  status = count_char(str, '{', &n1); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "aux_hdfs.c"); }; status = (status) ; goto BYE; } } };
  status = count_char(str, '}', &n2); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "aux_hdfs.c"); }; status = (status) ; goto BYE; } } };
  if ( n1 != n2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 42, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
  num_files = n1;
  filenames = malloc(num_files * sizeof(char *));
  { if ( filenames == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 45, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; } };
  file_lengths = malloc(num_files * sizeof(long long));
  { if ( file_lengths == ((void *)0) ) { fprintf(stderr, "Unable to allocate memory\n"); { { fprintf(stderr, "Line %3d of File %s \n", 47, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; } };
  char *save_str = str;
  for ( int mode = 1; mode <= 2; mode++ ) {
    str = save_str;
    char start_str[32]; zero_string(start_str, 32);
    switch ( mode ) {
    case 1 : strcpy(start_str, "\"length\":"); break;
    case 2 : strcpy(start_str, "\"pathSuffix\":"); break;
    default : { { fprintf(stderr, "Line %3d of File %s \n", 55, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; break;
    }
    for ( int i = 0; i < n1; i++ ) {
      cptr = strstr(str, start_str);
      if ( cptr == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
      cptr += strlen(start_str);
      if ( *cptr == '"' ) { cptr++; }
      int j;
      zero_string(buffer, 127 +1);
      for ( j = 0; ( ( *cptr != ',' ) && ( *cptr != '"' ) ); j++ ) {
 if ( j >= 127 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
 if ( *cptr == '\0' ) { { { fprintf(stderr, "Line %3d of File %s \n", 66, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
 buffer[j] = *cptr++;
      }
      buffer[j] = '\0';
      switch ( mode ) {
      case 1 :
 status = stoI8(buffer, &(file_lengths[i]));
 if ( file_lengths[i] <= 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 74, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
 break;
      case 2 :
 filenames[i] = strdup(buffer);
 if ( filenames[i] == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "aux_hdfs.c"); }; status = -1 ; goto BYE; }; }
 break;
      default :
 { { fprintf(stderr, "Line %3d of File %s \n", 81, "aux_hdfs.c"); }; status = -1 ; goto BYE; };
 break;
      }
      str = cptr;
    }
  }
 BYE:
  { if ( (lstr) != ((void *)0) ) { free((lstr)); (lstr) = ((void *)0); } };
  *ptr_num_files = num_files;
  *ptr_filenames = filenames;
  *ptr_file_lengths = file_lengths;
  return status ;
}

variable_types:
filenames
char **

variable_types:
lstr
char *

variable_types:
str
char *

variable_types:
cptr
char *

variable_types:
buffer
char [-1]

variable_types: mode int

variable_types: j int


original_code:
void
bwise_and2_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_and2_I4(int *in1, int *in2, long long nR, int *out)
{
  int inv1; int inv2; int outv;
  for ( long long i = 0; i < nR; i++ ) {
    inv1 = *in1;
    inv2 = *in2;
    outv = inv1 & inv2;
    *out = outv;
    in1++;
    in2++;
    out++;
  }
}

variable_types:
nR
long long

variable_types:
out
int *

variable_types: outv int

variable_types:
i
long long


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

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

variable_types:
out
float *

variable_types: outv float