decompiled_code:
__int64 __fastcall g_f1f2opf3(char *s1, char *a2, const char *a3, const char *a4)
{
int v6; // ebx
char *v7; // rbp
_BYTE v9[712]; // [rsp-860h] [rbp-1D28h] BYREF
_BYTE v10[712]; // [rsp-598h] [rbp-1A60h] BYREF
_BYTE v11[712]; // [rsp-2D0h] [rbp-1798h] BYREF
char v12[1024]; // [rsp+0h] [rbp-14C8h] BYREF
char v13[2060]; // [rsp+400h] [rbp-10C8h] BYREF
unsigned int v14; // [rsp+C0Ch] [rbp-8BCh] BYREF
__int64 v15; // [rsp+C10h] [rbp-8B8h] BYREF
__int64 v16; // [rsp+C18h] [rbp-8B0h] BYREF
__int64 v17; // [rsp+C20h] [rbp-8A8h] BYREF
char *haystack; // [rsp+C28h] [rbp-8A0h] BYREF
int v19[179]; // [rsp+C30h] [rbp-898h] BYREF
int v20; // [rsp+EFCh] [rbp-5CCh] BYREF
int v21[179]; // [rsp+F00h] [rbp-5C8h] BYREF
int v22; // [rsp+11CCh] [rbp-2FCh] BYREF
int v23[179]; // [rsp+11D0h] [rbp-2F8h] BYREF
int v24[11]; // [rsp+149Ch] [rbp-2Ch] BYREF

v24[0] = -1;
v22 = -1;
v20 = -1;
haystack = 0LL;
v17 = 0LL;
v16 = 0LL;
v15 = 0LL;
v14 = 0;
g_mmap_meta_data(&g_docroot, &v17, &v16, &v15, &v14);
if ( a3 && *a3 )
{
if ( s1 && *s1 )
{
if ( a2 && *a2 )
{
if ( a4 && *a4 )
{
if ( !strcmp(s1, a2) )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( !strcmp(s1, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( !strcmp(a2, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_f1f2opf3.c");
v6 = -1;
}
else
{
v6 = g_is_fld(v15, v14, s1, v24, v23);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_f1f2opf3.c");
}
else if ( v24[0] < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v23[8]) )
{
v6 = g_is_fld(v15, v14, a2, &v22, v21);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 57LL, "g_f1f2opf3.c");
}
else if ( v22 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v21[8]) )
{
v6 = g_is_fld(v15, v14, a4, &v20, v19);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_f1f2opf3.c");
}
else if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v19[8]) )
{
qmemcpy(v11, v19, sizeof(v11));
qmemcpy(v10, v21, sizeof(v10));
qmemcpy(v9, v23, sizeof(v9));
v6 = g_chk_f1f2opf3(a3);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "g_f1f2opf3.c");
}
else
{
zero_string(v13, 2048LL);
zero_string(v12, 1024LL);
sprintf(v12, "f1f2opf3 d_fld1=%s d_fld2=%s op=%s d_fld3=%s", s1, a2, a3, a4);
v6 = g_make_url(v12, v13);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 71LL, "g_f1f2opf3.c");
}
else
{
v6 = g_call_gpu(v13, &haystack);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 72LL, "g_f1f2opf3.c");
}
else
{
v7 = haystack;
if ( !haystack )
goto LABEL_46;
if ( strstr(haystack, "\"\"") )
{
LABEL_45:
free(v7);
haystack = 0LL;
goto LABEL_46;
}
fprintf(stderr, "Response from GPU = [%s]\n", v7);
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "g_f1f2opf3.c");
v6 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "g_f1f2opf3.c");
v6 = -1;
}
v7 = haystack;
if ( haystack )
goto LABEL_45;
LABEL_46:
g_unmap_meta_data(v17, v16);
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, char *a2, const char *a3, const char *a4)
{
int v6; // ebx
char *v7; // rbp
_BYTE v9[712]; // [rsp-860h] [rbp-1D28h] BYREF
_BYTE v10[712]; // [rsp-598h] [rbp-1A60h] BYREF
_BYTE v11[712]; // [rsp-2D0h] [rbp-1798h] BYREF
char v12[1024]; // [rsp+0h] [rbp-14C8h] BYREF
char v13[2060]; // [rsp+400h] [rbp-10C8h] BYREF
unsigned int v14; // [rsp+C0Ch] [rbp-8BCh] BYREF
__int64 v15; // [rsp+C10h] [rbp-8B8h] BYREF
__int64 v16; // [rsp+C18h] [rbp-8B0h] BYREF
__int64 v17; // [rsp+C20h] [rbp-8A8h] BYREF
char *haystack; // [rsp+C28h] [rbp-8A0h] BYREF
int v19[179]; // [rsp+C30h] [rbp-898h] BYREF
int v20; // [rsp+EFCh] [rbp-5CCh] BYREF
int v21[179]; // [rsp+F00h] [rbp-5C8h] BYREF
int v22; // [rsp+11CCh] [rbp-2FCh] BYREF
int v23[179]; // [rsp+11D0h] [rbp-2F8h] BYREF
int v24[11]; // [rsp+149Ch] [rbp-2Ch] BYREF

v24[0] = -1;
v22 = -1;
v20 = -1;
haystack = 0LL;
v17 = 0LL;
v16 = 0LL;
v15 = 0LL;
v14 = 0;
g_mmap_meta_data(&g_docroot, &v17, &v16, &v15, &v14);
if ( a3 && *a3 )
{
if ( s1 && *s1 )
{
if ( a2 && *a2 )
{
if ( a4 && *a4 )
{
if ( !strcmp(s1, a2) )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( !strcmp(s1, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( !strcmp(a2, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_f1f2opf3.c");
v6 = -1;
}
else
{
v6 = g_is_fld(v15, v14, s1, v24, v23);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_f1f2opf3.c");
}
else if ( v24[0] < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v23[8]) )
{
v6 = g_is_fld(v15, v14, a2, &v22, v21);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 57LL, "g_f1f2opf3.c");
}
else if ( v22 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v21[8]) )
{
v6 = g_is_fld(v15, v14, a4, &v20, v19);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_f1f2opf3.c");
}
else if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "g_f1f2opf3.c");
v6 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu((unsigned int)v19[8]) )
{
qmemcpy(v11, v19, sizeof(v11));
qmemcpy(v10, v21, sizeof(v10));
qmemcpy(v9, v23, sizeof(v9));
v6 = g_chk_f1f2opf3(a3);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 65LL, "g_f1f2opf3.c");
}
else
{
zero_string(v13, 2048LL);
zero_string(v12, 1024LL);
sprintf(v12, "f1f2opf3 d_fld1=%s d_fld2=%s op=%s d_fld3=%s", s1, a2, a3, a4);
v6 = g_make_url(v12, v13);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 71LL, "g_f1f2opf3.c");
}
else
{
v6 = g_call_gpu(v13, &haystack);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 72LL, "g_f1f2opf3.c");
}
else
{
v7 = haystack;
if ( !haystack )
goto LABEL_46;
if ( strstr(haystack, "\"\"") )
{
LABEL_45:
free(v7);
haystack = 0LL;
goto LABEL_46;
}
fprintf(stderr, "Response from GPU = [%s]\n", v7);
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 55LL, "g_f1f2opf3.c");
v6 = -1;
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "g_f1f2opf3.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 45LL, "g_f1f2opf3.c");
v6 = -1;
}
v7 = haystack;
if ( haystack )
goto LABEL_45;
LABEL_46:
g_unmap_meta_data(v17, v16);
return (unsigned int)v6;
}

original_code:
int
g_f1f2opf3(
    char *f1,
    char *f2,
    char *str_op,
    char *f3
    )
{
  int status = 0;
  int f1_id = -1; GPU_REG_TYPE f1_rec;
  int f2_id = -1; GPU_REG_TYPE f2_rec;
  int f3_id = -1; GPU_REG_TYPE f3_rec;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( str_op == ((void *)0) ) || ( *str_op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f3 == ((void *)0) ) || ( *f3 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f3) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f2, f3) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f1, &f1_id, &f1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f2, &f2_id, &f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f3, &f3_id, &f3_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  if ( f3_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f3_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_f1f2opf3(f1_rec, f2_rec, str_op, f3_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1f2opf3 d_fld1=%s d_fld2=%s op=%s d_fld3=%s",
        f1, f2, str_op, f3);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    if ( strstr(curl_response, "\"\"") == ((void *)0) ) {
      fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
    }
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return status ;
}

canonical_original_code:
int g_f1f2opf3(char *f1, char *f2, char *str_op, char *f3)
{
  int status = 0;
  int f1_id = -1; struct _GPU_REG_TYPE f1_rec;
  int f2_id = -1; struct _GPU_REG_TYPE f2_rec;
  int f3_id = -1; struct _GPU_REG_TYPE f3_rec;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( str_op == ((void *)0) ) || ( *str_op == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 45, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f1 == ((void *)0) ) || ( *f1 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f2 == ((void *)0) ) || ( *f2 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( ( f3 == ((void *)0) ) || ( *f3 == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f2) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f1, f3) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(f2, f3) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f1, &f1_id, &f1_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  if ( f1_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f1_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 55, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f2, &f2_id, &f2_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 57, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  if ( f2_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f2_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  status = g_is_fld(gpu_reg, n_gpu_reg, f3, &f3_id, &f3_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  if ( f3_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(f3_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "g_f1f2opf3.c"); }; status = -1 ; goto BYE; }; }
  status = g_chk_f1f2opf3(f1_rec, f2_rec, str_op, f3_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 65, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "f1f2opf3 d_fld1=%s d_fld2=%s op=%s d_fld3=%s",
        f1, f2, str_op, f3);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 71, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 72, "g_f1f2opf3.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    if ( strstr(curl_response, "\"\"") == ((void *)0) ) {
      fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
    }
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return status ;
}

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

variable_types:
url
char [2048]

variable_types:
command
char [1024]

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


repo: linkedin/datacl

original_code:
int
update_counter (
  int * cntr_id,
  int * cntr_freq,
  long long cntr_siz,
  long long *ptr_active_cntr_siz,
  int * bf_id,
  int * bf_freq,
  long long bf_siz
  )
{
  int status = 0;
  int * temp_cntr_id = ((void *)0);
  int * temp_cntr_freq = ((void *)0);
  if ( cntr_id == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 77, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  if ( cntr_freq == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  if ( ptr_active_cntr_siz == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  if ( bf_id == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  if ( bf_freq == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  long long ii = 0, jj = 0, kk = 0;
  temp_cntr_id = (int *)malloc( ((*ptr_active_cntr_siz)+bf_siz)*sizeof(int) );
  temp_cntr_freq = (int *)malloc( ((*ptr_active_cntr_siz)+bf_siz)*sizeof(int) );
  while (1) {
    if ( ii < (*ptr_active_cntr_siz) && jj < bf_siz ) {
      if ( cntr_id[ii] < bf_id[jj] ) {
 temp_cntr_id[kk] = cntr_id[ii];
 temp_cntr_freq[kk++] = cntr_freq[ii++];
      }
      else if ( bf_id[jj] < cntr_id[ii] ) {
 temp_cntr_id[kk] = bf_id[jj];
 temp_cntr_freq[kk++] = bf_freq[jj++];
      }
      else {
 temp_cntr_id[kk] = bf_id[jj];
 temp_cntr_freq[kk++] = bf_freq[jj++] + cntr_freq[ii++];
      }
    }
    else if ( ii < (*ptr_active_cntr_siz) && jj == bf_siz ) {
      temp_cntr_id[kk] = cntr_id[ii];
      temp_cntr_freq[kk++] = cntr_freq[ii++];
    }
    else if ( ii == (*ptr_active_cntr_siz) && jj < bf_siz ) {
      temp_cntr_id[kk] = bf_id[jj];
      temp_cntr_freq[kk++] = bf_freq[jj++];
    }
    else {
      break;
    }
  }
  *ptr_active_cntr_siz = kk;
  while ( *ptr_active_cntr_siz > cntr_siz ) {
    for ( long long kk = 0; kk < *ptr_active_cntr_siz; kk++ ) {
      temp_cntr_freq[kk]--;
    }
    jj = 0;
    for ( long long kk = 0; kk < *ptr_active_cntr_siz; kk++ ) {
      if ( temp_cntr_freq[kk] > 0 ) {
 temp_cntr_freq[jj] = temp_cntr_freq[kk];
 temp_cntr_id[jj++] = temp_cntr_id[kk];
      }
    }
    *ptr_active_cntr_siz = jj;
  }
  memcpy(cntr_id, temp_cntr_id, *ptr_active_cntr_siz*sizeof(int));
  memcpy(cntr_freq, temp_cntr_freq, *ptr_active_cntr_siz*sizeof(int));
 BYE:
  { if ( (temp_cntr_id) != ((void *)0) ) { free((temp_cntr_id)); (temp_cntr_id) = ((void *)0); } };
  { if ( (temp_cntr_freq) != ((void *)0) ) { free((temp_cntr_freq)); (temp_cntr_freq) = ((void *)0); } };
  return(status);
}

canonical_original_code:
int update_counter(int *cntr_id, int *cntr_freq, long long cntr_siz, long long *ptr_active_cntr_siz, int *bf_id, int *bf_freq, long long bf_siz)
{
  int status = 0;
  int *temp_cntr_id = ((void *)0);
  int *temp_cntr_freq = ((void *)0);
  if ( cntr_id == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 77, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  if ( cntr_freq == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 78, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  if ( ptr_active_cntr_siz == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 79, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  if ( bf_id == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 80, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  if ( bf_freq == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "update_counter.c"); }; status = -1 ; goto BYE; }; }
  long long ii = 0; long long jj = 0; long long kk = 0;
  temp_cntr_id = (int *)malloc( ((*ptr_active_cntr_siz)+bf_siz)*sizeof(int) );
  temp_cntr_freq = (int *)malloc( ((*ptr_active_cntr_siz)+bf_siz)*sizeof(int) );
  while (1) {
    if ( ii < (*ptr_active_cntr_siz) && jj < bf_siz ) {
      if ( cntr_id[ii] < bf_id[jj] ) {
 temp_cntr_id[kk] = cntr_id[ii];
 temp_cntr_freq[kk++] = cntr_freq[ii++];
      }
      else if ( bf_id[jj] < cntr_id[ii] ) {
 temp_cntr_id[kk] = bf_id[jj];
 temp_cntr_freq[kk++] = bf_freq[jj++];
      }
      else {
 temp_cntr_id[kk] = bf_id[jj];
 temp_cntr_freq[kk++] = bf_freq[jj++] + cntr_freq[ii++];
      }
    }
    else if ( ii < (*ptr_active_cntr_siz) && jj == bf_siz ) {
      temp_cntr_id[kk] = cntr_id[ii];
      temp_cntr_freq[kk++] = cntr_freq[ii++];
    }
    else if ( ii == (*ptr_active_cntr_siz) && jj < bf_siz ) {
      temp_cntr_id[kk] = bf_id[jj];
      temp_cntr_freq[kk++] = bf_freq[jj++];
    }
    else {
      break;
    }
  }
  *ptr_active_cntr_siz = kk;
  while ( *ptr_active_cntr_siz > cntr_siz ) {
    for ( long long kk = 0; kk < *ptr_active_cntr_siz; kk++ ) {
      temp_cntr_freq[kk]--;
    }
    jj = 0;
    for ( long long kk = 0; kk < *ptr_active_cntr_siz; kk++ ) {
      if ( temp_cntr_freq[kk] > 0 ) {
 temp_cntr_freq[jj] = temp_cntr_freq[kk];
 temp_cntr_id[jj++] = temp_cntr_id[kk];
      }
    }
    *ptr_active_cntr_siz = jj;
  }
  memcpy(cntr_id, temp_cntr_id, *ptr_active_cntr_siz*sizeof(int));
  memcpy(cntr_freq, temp_cntr_freq, *ptr_active_cntr_siz*sizeof(int));
 BYE:
  { if ( (temp_cntr_id) != ((void *)0) ) { free((temp_cntr_id)); (temp_cntr_id) = ((void *)0); } };
  { if ( (temp_cntr_freq) != ((void *)0) ) { free((temp_cntr_freq)); (temp_cntr_freq) = ((void *)0); } };
  return(status);
}

variable_types: status int

variable_types:
ii
long long

variable_types:
jj
long long

variable_types:
kk
long long

return_type: int


original_code:
int
countf_I8(
  long long *fk_fld,
  int *src_fld,
  long long n,
  long long * restrict cnt,
  int n_out
  )
{
  int status = 0;
  for ( long long i = 0; i < n; i++ ) {
    long long idx = fk_fld[i];
    int idxI4 = (int )idx;
    int val = src_fld[i];
    cnt[idxI4] += val;
  }
  return(status);
}

canonical_original_code:
int countf_I8(long long *fk_fld, int *src_fld, long long n, long long *cnt, int n_out)
{
  int status = 0;
  for ( long long i = 0; i < n; i++ ) {
    long long idx = fk_fld[i];
    int idxI4 = (int )idx;
    int val = src_fld[i];
    cnt[idxI4] += val;
  }
  return(status);
}

variable_types:
n
long long

variable_types:
cnt
long long *

variable_types:
i
long long

variable_types:
idx
long long

variable_types: val int


decompiled_code:
__int64 __fastcall intersection_I4(int *a1, __int64 a2, int *a3, __int64 a4, _DWORD *a5, _QWORD *a6)
{
int *v6; // r11
int *v7; // r10
__int64 v9; // rsi
__int64 v10; // rbx
__int64 result; // rax
int v12; // eax
int v13; // ecx

v6 = &a1[a2];
v7 = &a3[a4];
if ( a3 == v7 || a1 == v6 )
{
*a6 = 0LL;
result = 0LL;
}
else
{
v9 = 0LL;
v10 = a2 + a4;
do
{
v12 = *a1;
v13 = *a3;
if ( *a1 == *a3 )
{
*a5++ = v12;
if ( v10 < ++v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 30LL, "./AUTOGEN/GENFILES/intersection_I4.c");
return 0xFFFFFFFFLL;
}
++a1;
++a3;
}
else if ( v12 >= v13 )
{
if ( v12 > v13 )
++a3;
}
else
{
++a1;
}
}
while ( a3 != v7 && a1 != v6 );
*a6 = v9;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1, __int64 a2, int *a3, __int64 a4, _DWORD *a5, _QWORD *a6)
{
int *v6; // r11
int *v7; // r10
__int64 v9; // rsi
__int64 v10; // rbx
__int64 result; // rax
int v12; // eax
int v13; // ecx

v6 = &a1[a2];
v7 = &a3[a4];
if ( a3 == v7 || a1 == v6 )
{
*a6 = 0LL;
result = 0LL;
}
else
{
v9 = 0LL;
v10 = a2 + a4;
do
{
v12 = *a1;
v13 = *a3;
if ( *a1 == *a3 )
{
*a5++ = v12;
if ( v10 < ++v9 )
{
fprintf(stderr, "Line %3d of File %s \n", 30LL, "./AUTOGEN/GENFILES/intersection_I4.c");
return 0xFFFFFFFFLL;
}
++a1;
++a3;
}
else if ( v12 >= v13 )
{
if ( v12 > v13 )
++a3;
}
else
{
++a1;
}
}
while ( a3 != v7 && a1 != v6 );
*a6 = v9;
result = 0LL;
}
return result;
}

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

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


original_code:
int
pos_nn_copy_I1_I4(
    char *f1,
    char *nn_f1,
    long long nR1,
    int *f2,
    char *nn_f2,
    long long nR2,
    char *f3,
    long long *ptr_cnt
    )
{
  int status = 0;
  long long cnt = 0;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( nn_f2 != ((void *)0) ) && ( nn_f2[i] == 0 ) ) { continue; }
    int f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "./AUX/pos_nn_copy_I1_I4.c"); }; status = -1 ; goto BYE; }; }
    if ( ( nn_f1 != ((void *)0) ) && ( nn_f1[f1idx] == 0 ) ) { continue; }
    char ival = f1[f1idx];
    f3[cnt++] = ival;
  }
  *ptr_cnt = cnt;
BYE:
  return(status);
}

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

variable_types:
cnt
long long

variable_types: ival char


decompiled_code:
void __fastcall vec_sqrt_F8(double *a1, int a2, double *a3)
{
double *v3; // rbx
double v5; // xmm0_8
double v6; // xmm0_8

if ( a2 > 0 )
{
v3 = a1;
do
{
v5 = *v3;
if ( *v3 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
*a3 = v6;
++v3;
++a3;
}
while ( v3 != &a1[a2] );
}
}

canonical_decompiled_code:
void __fastcall func0(double *a1, int a2, double *a3)
{
double *v3; // rbx
double v5; // xmm0_8
double v6; // xmm0_8

if ( a2 > 0 )
{
v3 = a1;
do
{
v5 = *v3;
if ( *v3 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
*a3 = v6;
++v3;
++a3;
}
while ( v3 != &a1[a2] );
}
}

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

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

variable_types:
in
double *

variable_types: nR int

variable_types:
out
double *

variable_types: i int

return_type: void


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

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

variable_types:
nR
long long

variable_types: outv double


decompiled_code:
__int64 __fastcall g_store(_BYTE *a1, const char *a2, _BYTE *a3)
{
int v4; // ebx
__int64 v5; // r12
char v7[1024]; // [rsp+0h] [rbp-1088h] BYREF
char v8[2048]; // [rsp+400h] [rbp-C88h] BYREF
char v9[28]; // [rsp+C00h] [rbp-488h] BYREF
unsigned int v10; // [rsp+C1Ch] [rbp-46Ch] BYREF
__int64 v11; // [rsp+C20h] [rbp-468h] BYREF
__int64 v12; // [rsp+C28h] [rbp-460h] BYREF
__int64 v13; // [rsp+C30h] [rbp-458h] BYREF
void *ptr; // [rsp+C38h] [rbp-450h] BYREF
int v15; // [rsp+C44h] [rbp-444h] BYREF
unsigned int v16; // [rsp+C48h] [rbp-440h] BYREF
unsigned int v17; // [rsp+C4Ch] [rbp-43Ch] BYREF
char v18[124]; // [rsp+C50h] [rbp-438h] BYREF
int v19; // [rsp+CCCh] [rbp-3BCh] BYREF
char v20[24]; // [rsp+CD0h] [rbp-3B8h] BYREF
__int64 v21; // [rsp+CE8h] [rbp-3A0h]
unsigned int v22; // [rsp+CF0h] [rbp-398h]
int v23; // [rsp+F9Ch] [rbp-ECh] BYREF
char v24[32]; // [rsp+FA0h] [rbp-E8h] BYREF
unsigned int v25; // [rsp+FC0h] [rbp-C8h]
int v26; // [rsp+101Ch] [rbp-6Ch] BYREF
__int64 v27[7]; // [rsp+1020h] [rbp-68h] BYREF
unsigned int v28[11]; // [rsp+105Ch] [rbp-2Ch] BYREF

v28[0] = -1;
v26 = -1;
v23 = -1;
v19 = -1;
v17 = -1;
v16 = -1;
v15 = 0;
ptr = 0LL;
v13 = 0LL;
v12 = 0LL;
v11 = 0LL;
v10 = 0;
g_mmap_meta_data(&g_docroot, &v13, &v12, &v11, &v10);
if ( a1 && *a1 )
{
if ( a3 && *a3 )
{
if ( a2 && *a2 )
{
v4 = chk_fld_name(a2);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_store.c");
}
else
{
v4 = is_tbl(a1, v28, v27);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "g_store.c");
}
else if ( (v28[0] & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_store.c");
v4 = -1;
}
else
{
v5 = v27[0];
is_fld(0LL, v28[0], a3, &v26, v24, &v19, v18);
if ( v26 >= 0 && (v4 = del_fld(0LL, v28[0], 0LL), v4 < 0) )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_store.c");
}
else
{
v4 = g_is_fld(v11, v10, a2, &v23, v20);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_store.c");
}
else if ( v23 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "g_store.c");
v4 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu(v22) )
{
if ( v21 == v5 )
{
get_fld_sz(v22, &v15);
v4 = mk_temp_file(v5 * v15, &v17, &v16);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 69LL, "g_store.c");
}
else
{
zero_fld_rec(v24);
v25 = v22;
v4 = add_fld(v28[0], a3, v17, v16, &v26, v24);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "g_store.c");
}
else
{
zero_string(v9, 16LL);
zero_string(v8, 2048LL);
zero_string(v7, 1024LL);
v4 = mk_full_filename(v17, v16, v9, 15LL);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "g_store.c");
}
else
{
sprintf(v7, "store d_fld=%s filename=%s", a2, v9);
v4 = g_make_url(v7, v8);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "g_store.c");
}
else
{
v4 = g_call_gpu(v8, &ptr);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 84LL, "g_store.c");
}
else
{
if ( !ptr )
goto LABEL_29;
fprintf(stderr, "Response from GPU = [%s]\n", (const char *)ptr);
}
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "g_store.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "g_store.c");
v4 = -1;
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_store.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_store.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_store.c");
v4 = -1;
}
if ( ptr )
{
free(ptr);
ptr = 0LL;
}
LABEL_29:
g_unmap_meta_data(v13, v12);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, const char *a2, _BYTE *a3)
{
int v4; // ebx
__int64 v5; // r12
char v7[1024]; // [rsp+0h] [rbp-1088h] BYREF
char v8[2048]; // [rsp+400h] [rbp-C88h] BYREF
char v9[28]; // [rsp+C00h] [rbp-488h] BYREF
unsigned int v10; // [rsp+C1Ch] [rbp-46Ch] BYREF
__int64 v11; // [rsp+C20h] [rbp-468h] BYREF
__int64 v12; // [rsp+C28h] [rbp-460h] BYREF
__int64 v13; // [rsp+C30h] [rbp-458h] BYREF
void *ptr; // [rsp+C38h] [rbp-450h] BYREF
int v15; // [rsp+C44h] [rbp-444h] BYREF
unsigned int v16; // [rsp+C48h] [rbp-440h] BYREF
unsigned int v17; // [rsp+C4Ch] [rbp-43Ch] BYREF
char v18[124]; // [rsp+C50h] [rbp-438h] BYREF
int v19; // [rsp+CCCh] [rbp-3BCh] BYREF
char v20[24]; // [rsp+CD0h] [rbp-3B8h] BYREF
__int64 v21; // [rsp+CE8h] [rbp-3A0h]
unsigned int v22; // [rsp+CF0h] [rbp-398h]
int v23; // [rsp+F9Ch] [rbp-ECh] BYREF
char v24[32]; // [rsp+FA0h] [rbp-E8h] BYREF
unsigned int v25; // [rsp+FC0h] [rbp-C8h]
int v26; // [rsp+101Ch] [rbp-6Ch] BYREF
__int64 v27[7]; // [rsp+1020h] [rbp-68h] BYREF
unsigned int v28[11]; // [rsp+105Ch] [rbp-2Ch] BYREF

v28[0] = -1;
v26 = -1;
v23 = -1;
v19 = -1;
v17 = -1;
v16 = -1;
v15 = 0;
ptr = 0LL;
v13 = 0LL;
v12 = 0LL;
v11 = 0LL;
v10 = 0;
g_mmap_meta_data(&g_docroot, &v13, &v12, &v11, &v10);
if ( a1 && *a1 )
{
if ( a3 && *a3 )
{
if ( a2 && *a2 )
{
v4 = chk_fld_name(a2);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_store.c");
}
else
{
v4 = is_tbl(a1, v28, v27);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "g_store.c");
}
else if ( (v28[0] & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 53LL, "g_store.c");
v4 = -1;
}
else
{
v5 = v27[0];
is_fld(0LL, v28[0], a3, &v26, v24, &v19, v18);
if ( v26 >= 0 && (v4 = del_fld(0LL, v28[0], 0LL), v4 < 0) )
{
fprintf(stderr, "Line %3d of File %s \n", 58LL, "g_store.c");
}
else
{
v4 = g_is_fld(v11, v10, a2, &v23, v20);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 61LL, "g_store.c");
}
else if ( v23 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 62LL, "g_store.c");
v4 = -1;
}
else if ( (unsigned int)is_fldtype_goodfor_gpu(v22) )
{
if ( v21 == v5 )
{
get_fld_sz(v22, &v15);
v4 = mk_temp_file(v5 * v15, &v17, &v16);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 69LL, "g_store.c");
}
else
{
zero_fld_rec(v24);
v25 = v22;
v4 = add_fld(v28[0], a3, v17, v16, &v26, v24);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 73LL, "g_store.c");
}
else
{
zero_string(v9, 16LL);
zero_string(v8, 2048LL);
zero_string(v7, 1024LL);
v4 = mk_full_filename(v17, v16, v9, 15LL);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 81LL, "g_store.c");
}
else
{
sprintf(v7, "store d_fld=%s filename=%s", a2, v9);
v4 = g_make_url(v7, v8);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 83LL, "g_store.c");
}
else
{
v4 = g_call_gpu(v8, &ptr);
if ( v4 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 84LL, "g_store.c");
}
else
{
if ( !ptr )
goto LABEL_29;
fprintf(stderr, "Response from GPU = [%s]\n", (const char *)ptr);
}
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 64LL, "g_store.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 63LL, "g_store.c");
v4 = -1;
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_store.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_store.c");
v4 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "g_store.c");
v4 = -1;
}
if ( ptr )
{
free(ptr);
ptr = 0LL;
}
LABEL_29:
g_unmap_meta_data(v13, v12);
return (unsigned int)v4;
}

original_code:
int
g_store(
    char *tbl,
    char *d_fld,
    char *h_fld
    )
{
  int status = 0;
  int tbl_id = -1; TBL_REC_TYPE tbl_rec;
  int h_fld_id = -1; FLD_REC_TYPE h_fld_rec;
  int d_fld_id = -1; GPU_REG_TYPE d_fld_rec;
  int nn_fld_id = -1; FLD_REC_TYPE nn_fld_rec;
  int ddir_id = -1, fileno = -1; int fldsz = 0; size_t filesz = 0;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_store.c"); }; status = -1 ; goto BYE; }; }
  if ( ( h_fld == ((void *)0) ) || ( *h_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_store.c"); }; status = -1 ; goto BYE; }; }
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_store.c"); }; status = -1 ; goto BYE; }; }
  status = chk_fld_name(d_fld); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_store.c"); }; status = (status) ; goto BYE; } } };
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "g_store.c"); }; status = (status) ; goto BYE; } } };
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_store.c"); }; status = -1 ; goto BYE; }; }
  long long nR = tbl_rec.nR;
  status = is_fld(((void *)0), tbl_id, h_fld, &h_fld_id, &h_fld_rec,
      &nn_fld_id, &nn_fld_rec);
  if ( h_fld_id >= 0 ) {
    status = del_fld(((void *)0), tbl_id, ((void *)0), h_fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "g_store.c"); }; status = (status) ; goto BYE; } } };
  }
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_store.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "g_store.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(d_fld_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "g_store.c"); }; status = -1 ; goto BYE; }; }
  if ( d_fld_rec.nR != nR ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "g_store.c"); }; status = -1 ; goto BYE; }; }
  status = get_fld_sz(d_fld_rec.fldtype, &fldsz);
  filesz = fldsz * nR;
  status = mk_temp_file(filesz, &ddir_id, &fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "g_store.c"); }; status = (status) ; goto BYE; } } };
  zero_fld_rec(&h_fld_rec);
  h_fld_rec.fldtype = d_fld_rec.fldtype;
  status = add_fld(tbl_id, h_fld, ddir_id, fileno, &h_fld_id, &h_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 73, "g_store.c"); }; status = (status) ; goto BYE; } } }
  char filename[15 +1];
  zero_string(filename, 15 +1);
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  status = mk_full_filename(ddir_id, fileno, filename, 15);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "g_store.c"); }; status = (status) ; goto BYE; } } };
  sprintf(command, "store d_fld=%s filename=%s", d_fld, filename);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "g_store.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "g_store.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

canonical_original_code:
int g_store(char *tbl, char *d_fld, char *h_fld)
{
  int status = 0;
  int tbl_id = -1; struct _TBL_REC_TYPE tbl_rec;
  int h_fld_id = -1; struct _FLD_REC_TYPE h_fld_rec;
  int d_fld_id = -1; struct _GPU_REG_TYPE d_fld_rec;
  int nn_fld_id = -1; struct _FLD_REC_TYPE nn_fld_rec;
  int ddir_id = -1; int fileno = -1; int fldsz = 0; unsigned long filesz = 0;
  char *curl_response = ((void *)0);
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 47, "g_store.c"); }; status = -1 ; goto BYE; }; }
  if ( ( h_fld == ((void *)0) ) || ( *h_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_store.c"); }; status = -1 ; goto BYE; }; }
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_store.c"); }; status = -1 ; goto BYE; }; }
  status = chk_fld_name(d_fld); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_store.c"); }; status = (status) ; goto BYE; } } };
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "g_store.c"); }; status = (status) ; goto BYE; } } };
  if ( tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 53, "g_store.c"); }; status = -1 ; goto BYE; }; }
  long long nR = tbl_rec.nR;
  status = is_fld(((void *)0), tbl_id, h_fld, &h_fld_id, &h_fld_rec,
      &nn_fld_id, &nn_fld_rec);
  if ( h_fld_id >= 0 ) {
    status = del_fld(((void *)0), tbl_id, ((void *)0), h_fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 58, "g_store.c"); }; status = (status) ; goto BYE; } } };
  }
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 61, "g_store.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 62, "g_store.c"); }; status = -1 ; goto BYE; }; }
  if ( is_fldtype_goodfor_gpu(d_fld_rec.fldtype) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 63, "g_store.c"); }; status = -1 ; goto BYE; }; }
  if ( d_fld_rec.nR != nR ) { { { fprintf(stderr, "Line %3d of File %s \n", 64, "g_store.c"); }; status = -1 ; goto BYE; }; }
  status = get_fld_sz(d_fld_rec.fldtype, &fldsz);
  filesz = fldsz * nR;
  status = mk_temp_file(filesz, &ddir_id, &fileno); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 69, "g_store.c"); }; status = (status) ; goto BYE; } } };
  zero_fld_rec(&h_fld_rec);
  h_fld_rec.fldtype = d_fld_rec.fldtype;
  status = add_fld(tbl_id, h_fld, ddir_id, fileno, &h_fld_id, &h_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 73, "g_store.c"); }; status = (status) ; goto BYE; } } }
  char filename[-1];
  zero_string(filename, 15 +1);
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  status = mk_full_filename(ddir_id, fileno, filename, 15);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 81, "g_store.c"); }; status = (status) ; goto BYE; } } };
  sprintf(command, "store d_fld=%s filename=%s", d_fld, filename);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 83, "g_store.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 84, "g_store.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    fprintf(stderr, "Response from GPU = [%s]\n", curl_response);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

variable_types:
tbl
char *

variable_types: status int

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

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

variable_types: fileno int

variable_types: fldsz int

variable_types:
filesz
unsigned long

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

variable_types:
filename
char [-1]

variable_types:
url
char [2048]

variable_types:
command
char [1024]

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

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


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

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

variable_types:
in
float *

variable_types:
out
float *


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

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

variable_types:
minval
long long

variable_types:
maxval
long long

variable_types:
sum
long long

variable_types:
cnt
long long

variable_types:
i
long long


decompiled_code:
__int64 __fastcall is_aux_fld(_BYTE *a1, _BYTE *a2, __int64 a3, unsigned int *a4, char *a5)
{
int v8; // ebx
int v10; // [rsp+Ch] [rbp-16Ch] BYREF
char v11[120]; // [rsp+10h] [rbp-168h] BYREF
int v12; // [rsp+88h] [rbp-F0h] BYREF
unsigned int v13; // [rsp+8Ch] [rbp-ECh] BYREF
char v14[124]; // [rsp+90h] [rbp-E8h] BYREF
unsigned int v15; // [rsp+10Ch] [rbp-6Ch] BYREF
char v16[60]; // [rsp+110h] [rbp-68h] BYREF
int v17[11]; // [rsp+14Ch] [rbp-2Ch] BYREF

v13 = -1;
v12 = -1;
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 26LL, "is_aux_fld.c");
return (unsigned int)-1;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 27LL, "is_aux_fld.c");
return (unsigned int)-1;
}
v8 = is_tbl(a1, v17, v16);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 29LL, "is_aux_fld.c");
return (unsigned int)v8;
}
if ( v17[0] < 0 || v17[0] >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 30LL, "is_aux_fld.c");
return (unsigned int)-1;
}
v8 = is_fld(0LL, (unsigned int)v17[0], a2, &v15, v14, &v12, v11);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 32LL, "is_aux_fld.c");
return (unsigned int)v8;
}
if ( (v15 & 0x80000000) != 0 || (int)v15 >= g_n_fld )
{
fprintf(stderr, "Line %3d of File %s \n", 33LL, "is_aux_fld.c");
return (unsigned int)-1;
}
v8 = unstr_auxtype(a3, &v10);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 35LL, "is_aux_fld.c");
return (unsigned int)v8;
}
switch ( v10 )
{
case 2:
v8 = get_fld_info(2LL, v15, &v13);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "is_aux_fld.c");
return (unsigned int)v8;
}
break;
case 3:
v8 = get_fld_info(3LL, v15, &v13);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "is_aux_fld.c");
return (unsigned int)v8;
}
break;
case 1:
v13 = *(__int16 *)(g_flds + 120LL * (int)v15 + 6);
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 46LL, "is_aux_fld.c");
return (unsigned int)-1;
}
if ( (v13 & 0x80000000) != 0 )
strcpy(a5, "0:-1");
else
sprintf(a5, "1:%d", v13);
*a4 = v13;
return (unsigned int)v8;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, _BYTE *a2, __int64 a3, unsigned int *a4, char *a5)
{
int v8; // ebx
int v10; // [rsp+Ch] [rbp-16Ch] BYREF
char v11[120]; // [rsp+10h] [rbp-168h] BYREF
int v12; // [rsp+88h] [rbp-F0h] BYREF
unsigned int v13; // [rsp+8Ch] [rbp-ECh] BYREF
char v14[124]; // [rsp+90h] [rbp-E8h] BYREF
unsigned int v15; // [rsp+10Ch] [rbp-6Ch] BYREF
char v16[60]; // [rsp+110h] [rbp-68h] BYREF
int v17[11]; // [rsp+14Ch] [rbp-2Ch] BYREF

v13 = -1;
v12 = -1;
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 26LL, "is_aux_fld.c");
return (unsigned int)-1;
}
if ( !a2 || !*a2 )
{
fprintf(stderr, "Line %3d of File %s \n", 27LL, "is_aux_fld.c");
return (unsigned int)-1;
}
v8 = is_tbl(a1, v17, v16);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 29LL, "is_aux_fld.c");
return (unsigned int)v8;
}
if ( v17[0] < 0 || v17[0] >= g_n_tbl )
{
fprintf(stderr, "Line %3d of File %s \n", 30LL, "is_aux_fld.c");
return (unsigned int)-1;
}
v8 = is_fld(0LL, (unsigned int)v17[0], a2, &v15, v14, &v12, v11);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 32LL, "is_aux_fld.c");
return (unsigned int)v8;
}
if ( (v15 & 0x80000000) != 0 || (int)v15 >= g_n_fld )
{
fprintf(stderr, "Line %3d of File %s \n", 33LL, "is_aux_fld.c");
return (unsigned int)-1;
}
v8 = unstr_auxtype(a3, &v10);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 35LL, "is_aux_fld.c");
return (unsigned int)v8;
}
switch ( v10 )
{
case 2:
v8 = get_fld_info(2LL, v15, &v13);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "is_aux_fld.c");
return (unsigned int)v8;
}
break;
case 3:
v8 = get_fld_info(3LL, v15, &v13);
if ( v8 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "is_aux_fld.c");
return (unsigned int)v8;
}
break;
case 1:
v13 = *(__int16 *)(g_flds + 120LL * (int)v15 + 6);
break;
default:
fprintf(stderr, "Line %3d of File %s \n", 46LL, "is_aux_fld.c");
return (unsigned int)-1;
}
if ( (v13 & 0x80000000) != 0 )
strcpy(a5, "0:-1");
else
sprintf(a5, "1:%d", v13);
*a4 = v13;
return (unsigned int)v8;
}

original_code:
int
is_aux_fld(
 char *tbl,
 char *fld,
 char *str_auxtype,
 int *ptr_aux_fld_id,
 char *str_result
 )
{
  int status = 0;
  int tbl_id; TBL_REC_TYPE tbl_rec;
  int fld_id; FLD_REC_TYPE fld_rec;
  int aux_fld_id = -1;
  int nn_fld_id = -1; FLD_REC_TYPE nn_fld_rec;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 26, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 27, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 29, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; } };
  status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec, &nn_fld_id, &nn_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 33, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; } };
  AUX_TYPE auxtype;
  status = unstr_auxtype(str_auxtype, &auxtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
  switch ( auxtype ) {
    case nn :
      aux_fld_id = g_flds[fld_id].nn_fld_id;
      break;
    case len :
      status = get_fld_info(fk_fld_len, fld_id, &aux_fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
      break;
    case off :
      status = get_fld_info(fk_fld_off, fld_id, &aux_fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
      break;
    default : { { fprintf(stderr, "Line %3d of File %s \n", 46, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; break;
  }
  if ( aux_fld_id >= 0 ) {
    sprintf(str_result, "1:%d", aux_fld_id);
  }
  else {
    strcpy(str_result, "0:-1");
  }
  *ptr_aux_fld_id = aux_fld_id;
 BYE:
  return status ;
}

canonical_original_code:
int is_aux_fld(char *tbl, char *fld, char *str_auxtype, int *ptr_aux_fld_id, char *str_result)
{
  int status = 0;
  int tbl_id; struct _TBL_REC_TYPE tbl_rec;
  int fld_id; struct _FLD_REC_TYPE fld_rec;
  int aux_fld_id = -1;
  int nn_fld_id = -1; struct _FLD_REC_TYPE nn_fld_rec;
  if ( ( tbl == ((void *)0) ) || ( *tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 26, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( fld == ((void *)0) ) || ( *fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 27, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(tbl, &tbl_id, &tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 29, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (tbl_id) < (0) ) || ( (tbl_id) >= (g_n_tbl ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 30, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; } };
  status = is_fld(((void *)0), tbl_id, fld, &fld_id, &fld_rec, &nn_fld_id, &nn_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 32, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
  { if ( ( (fld_id) < (0) ) || ( (fld_id) >= (g_n_fld ) ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 33, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; } };
  enum _AUX_TYPE auxtype;
  status = unstr_auxtype(str_auxtype, &auxtype); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 35, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
  switch ( auxtype ) {
    case nn :
      aux_fld_id = g_flds[fld_id].nn_fld_id;
      break;
    case len :
      status = get_fld_info(fk_fld_len, fld_id, &aux_fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
      break;
    case off :
      status = get_fld_info(fk_fld_off, fld_id, &aux_fld_id); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "is_aux_fld.c"); }; status = (status) ; goto BYE; } } };
      break;
    default : { { fprintf(stderr, "Line %3d of File %s \n", 46, "is_aux_fld.c"); }; status = -1 ; goto BYE; }; break;
  }
  if ( aux_fld_id >= 0 ) {
    sprintf(str_result, "1:%d", aux_fld_id);
  }
  else {
    strcpy(str_result, "0:-1");
  }
  *ptr_aux_fld_id = aux_fld_id;
 BYE:
  return status ;
}

variable_types:
tbl
char *

variable_types:
fld
char *

variable_types: status int

variable_types: enum _AUX_TYPE { undef_auxtype=0, nn=1, len=2, off=3 }

user_defined_types: enum _TBL_TYPE { undef_tbl=0, regular=1, ldb_dict=2, txt_lkp=3, min_max=4, first_last=5, bins=6 }

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

user_defined_types: union sumval { long long sumI8; double sumF8; }

user_defined_types: union minval { long long minI8; double minF8; }

user_defined_types: union maxval { long long maxI8; double maxF8; }


decompiled_code:
__int64 __fastcall g_print_reg_data(const char *a1, const char *a2, const char *a3, char *a4, int a5)
{
bool v10; // cf
bool v11; // zf
const char *v12; // rdi
__int64 v13; // rcx
const char *v14; // rsi
char v15; // al
bool v16; // cf
bool v17; // zf
const char *v18; // rdi
__int64 v19; // rcx
int v20; // ebx
int v21; // eax
char *v22; // rbp
char v24[1024]; // [rsp+0h] [rbp-F38h] BYREF
char v25[2052]; // [rsp+400h] [rbp-B38h] BYREF
unsigned int v26; // [rsp+C04h] [rbp-334h] BYREF
__int64 v27; // [rsp+C08h] [rbp-330h] BYREF
__int64 v28; // [rsp+C10h] [rbp-328h] BYREF
__int64 v29; // [rsp+C18h] [rbp-320h] BYREF
char v30[24]; // [rsp+C20h] [rbp-318h] BYREF
__int64 v31; // [rsp+C38h] [rbp-300h]
char *src; // [rsp+EF0h] [rbp-48h] BYREF
int v33; // [rsp+EF8h] [rbp-40h] BYREF
int v34[15]; // [rsp+EFCh] [rbp-3Ch] BYREF

v34[0] = -1;
src = 0LL;
v29 = 0LL;
v28 = 0LL;
v27 = 0LL;
v26 = 0;
g_mmap_meta_data(&g_docroot, &v29, &v28, &v27, &v26);
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
if ( !a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
if ( !a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
v10 = a5 == 0;
v11 = a5 == 1;
if ( a5 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
v12 = "head";
v13 = 5LL;
v14 = a3;
do
{
if ( !v13 )
break;
v10 = *v14 < (unsigned int)*v12;
v11 = *v14++ == *v12++;
--v13;
}
while ( v11 );
v15 = (!v10 && !v11) - v10;
v16 = 0;
v17 = v15 == 0;
if ( v15 )
{
v18 = "tail";
v19 = 5LL;
v14 = a3;
do
{
if ( !v19 )
break;
v16 = *v14 < (unsigned int)*v18;
v17 = *v14++ == *v18++;
--v19;
}
while ( v17 );
if ( (!v16 && !v17) != v16 )
{
fprintf(stderr, "Line %3d of File %s \n", 43LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
}
v20 = chk_fld_name(a1, v14);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "g_print_reg_data.c");
goto LABEL_31;
}
v20 = g_is_fld(v27, v26, a1, v34, v30);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_print_reg_data.c");
goto LABEL_31;
}
if ( v34[0] < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
v20 = stoI4(a2, &v33);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_print_reg_data.c");
goto LABEL_31;
}
if ( (unsigned int)(v33 - 1) > 0x3FF )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
v21 = v33;
if ( v31 <= v33 )
v21 = v31;
v33 = v21;
zero_string(v25, 2048LL);
zero_string(v24, 1024LL);
sprintf(v24, "print_reg_data d_fld=%s n=%s mode=%s", a1, a2, a3);
v20 = g_make_url(v24, v25);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "g_print_reg_data.c");
goto LABEL_31;
}
v20 = g_call_gpu(v25, &src);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "g_print_reg_data.c");
LABEL_31:
v22 = src;
if ( src )
goto LABEL_32;
goto LABEL_33;
}
v22 = src;
if ( src )
{
strncpy(a4, src, a5);
LABEL_32:
free(v22);
src = 0LL;
}
LABEL_33:
g_unmap_meta_data(v29, v28);
return (unsigned int)v20;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2, const char *a3, char *a4, int a5)
{
bool v10; // cf
bool v11; // zf
const char *v12; // rdi
__int64 v13; // rcx
const char *v14; // rsi
char v15; // al
bool v16; // cf
bool v17; // zf
const char *v18; // rdi
__int64 v19; // rcx
int v20; // ebx
int v21; // eax
char *v22; // rbp
char v24[1024]; // [rsp+0h] [rbp-F38h] BYREF
char v25[2052]; // [rsp+400h] [rbp-B38h] BYREF
unsigned int v26; // [rsp+C04h] [rbp-334h] BYREF
__int64 v27; // [rsp+C08h] [rbp-330h] BYREF
__int64 v28; // [rsp+C10h] [rbp-328h] BYREF
__int64 v29; // [rsp+C18h] [rbp-320h] BYREF
char v30[24]; // [rsp+C20h] [rbp-318h] BYREF
__int64 v31; // [rsp+C38h] [rbp-300h]
char *src; // [rsp+EF0h] [rbp-48h] BYREF
int v33; // [rsp+EF8h] [rbp-40h] BYREF
int v34[15]; // [rsp+EFCh] [rbp-3Ch] BYREF

v34[0] = -1;
src = 0LL;
v29 = 0LL;
v28 = 0LL;
v27 = 0LL;
v26 = 0;
g_mmap_meta_data(&g_docroot, &v29, &v28, &v27, &v26);
if ( !a1 || !*a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
if ( !a4 )
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
if ( !a3 )
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
v10 = a5 == 0;
v11 = a5 == 1;
if ( a5 <= 1 )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
v12 = "head";
v13 = 5LL;
v14 = a3;
do
{
if ( !v13 )
break;
v10 = *v14 < (unsigned int)*v12;
v11 = *v14++ == *v12++;
--v13;
}
while ( v11 );
v15 = (!v10 && !v11) - v10;
v16 = 0;
v17 = v15 == 0;
if ( v15 )
{
v18 = "tail";
v19 = 5LL;
v14 = a3;
do
{
if ( !v19 )
break;
v16 = *v14 < (unsigned int)*v18;
v17 = *v14++ == *v18++;
--v19;
}
while ( v17 );
if ( (!v16 && !v17) != v16 )
{
fprintf(stderr, "Line %3d of File %s \n", 43LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
}
v20 = chk_fld_name(a1, v14);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 46LL, "g_print_reg_data.c");
goto LABEL_31;
}
v20 = g_is_fld(v27, v26, a1, v34, v30);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "g_print_reg_data.c");
goto LABEL_31;
}
if ( v34[0] < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
v20 = stoI4(a2, &v33);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 50LL, "g_print_reg_data.c");
goto LABEL_31;
}
if ( (unsigned int)(v33 - 1) > 0x3FF )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "g_print_reg_data.c");
v20 = -1;
goto LABEL_31;
}
v21 = v33;
if ( v31 <= v33 )
v21 = v31;
v33 = v21;
zero_string(v25, 2048LL);
zero_string(v24, 1024LL);
sprintf(v24, "print_reg_data d_fld=%s n=%s mode=%s", a1, a2, a3);
v20 = g_make_url(v24, v25);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "g_print_reg_data.c");
goto LABEL_31;
}
v20 = g_call_gpu(v25, &src);
if ( v20 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 60LL, "g_print_reg_data.c");
LABEL_31:
v22 = src;
if ( src )
goto LABEL_32;
goto LABEL_33;
}
v22 = src;
if ( src )
{
strncpy(a4, src, a5);
LABEL_32:
free(v22);
src = 0LL;
}
LABEL_33:
g_unmap_meta_data(v29, v28);
return (unsigned int)v20;
}

original_code:
int
g_print_reg_data(
    char *d_fld,
    char *str_n,
    char *mode,
    char *rslt_buf,
    int sz_rslt_buf
    )
{
  int status = 0;
  int d_fld_id = -1; int n;
  char *curl_response = ((void *)0);
  GPU_REG_TYPE d_fld_rec;
  char *gpu_reg_X = ((void *)0);
  size_t gpu_reg_nX = 0;
  GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  if ( rslt_buf == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  if ( mode == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  if ( sz_rslt_buf <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  if ( ( strcmp(mode, "head") != 0 ) && ( strcmp(mode, "tail") != 0 ) ) {
    { { fprintf(stderr, "Line %3d of File %s \n", 43, "g_print_reg_data.c"); }; status = -1 ; goto BYE; };
  }
  status = chk_fld_name(d_fld); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  status = stoI4(str_n, &n); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  if ( ( n < 1 ) || ( n > 1024 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  n = ((n) < (d_fld_rec.nR) ? (n) : (d_fld_rec.nR));
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "print_reg_data d_fld=%s n=%s mode=%s", d_fld, str_n, mode);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    strncpy(rslt_buf, curl_response, sz_rslt_buf);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

canonical_original_code:
int g_print_reg_data(char *d_fld, char *str_n, char *mode, char *rslt_buf, int sz_rslt_buf)
{
  int status = 0;
  int d_fld_id = -1; int n;
  char *curl_response = ((void *)0);
  struct _GPU_REG_TYPE d_fld_rec;
  char *gpu_reg_X = ((void *)0);
  unsigned long gpu_reg_nX = 0;
  struct _GPU_REG_TYPE *gpu_reg = ((void *)0);
  int n_gpu_reg = 0;
  status = g_mmap_meta_data(g_docroot, &gpu_reg_X, &gpu_reg_nX,
      &gpu_reg, &n_gpu_reg);
  if ( ( d_fld == ((void *)0) ) || ( *d_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  if ( rslt_buf == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  if ( mode == ((void *)0) ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  if ( sz_rslt_buf <= 1 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  if ( ( strcmp(mode, "head") != 0 ) && ( strcmp(mode, "tail") != 0 ) ) {
    { { fprintf(stderr, "Line %3d of File %s \n", 43, "g_print_reg_data.c"); }; status = -1 ; goto BYE; };
  }
  status = chk_fld_name(d_fld); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 46, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  status = g_is_fld(gpu_reg, n_gpu_reg, d_fld, &d_fld_id, &d_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  if ( d_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  status = stoI4(str_n, &n); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 50, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  if ( ( n < 1 ) || ( n > 1024 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "g_print_reg_data.c"); }; status = -1 ; goto BYE; }; }
  n = ((n) < (d_fld_rec.nR) ? (n) : (d_fld_rec.nR));
  char url[2048]; zero_string(url, 2048);
  char command[1024]; zero_string(command, 1024);
  sprintf(command, "print_reg_data d_fld=%s n=%s mode=%s", d_fld, str_n, mode);
  status = g_make_url(command, url); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  status = g_call_gpu(url, &curl_response); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 60, "g_print_reg_data.c"); }; status = (status) ; goto BYE; } } };
  if ( curl_response != ((void *)0) ) {
    strncpy(rslt_buf, curl_response, sz_rslt_buf);
  }
BYE:
  { if ( (curl_response) != ((void *)0) ) { free((curl_response)); (curl_response) = ((void *)0); } };
  g_unmap_meta_data(gpu_reg_X, gpu_reg_nX);
  return(status);
}

variable_types:
mode
char *

variable_types: n int

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


decompiled_code:
__int64 __fastcall bin_search_I2(_WORD *a1, __int64 a2, __int16 a3, __int64 *a4, const char *a5)
{
__int64 v9; // rcx
__int64 v10; // rdx
__int64 result; // rax
__int64 v12; // rax
__int64 v13; // rbp
__int16 v14; // si
__int64 v15; // r13
__int64 v16; // [rsp+8h] [rbp-40h]

if ( !a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 27LL, "./AUTOGEN/GENFILES/bin_search_I2.c");
return 0xFFFFFFFFLL;
}
if ( a2 <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 28LL, "./AUTOGEN/GENFILES/bin_search_I2.c");
return 0xFFFFFFFFLL;
}
if ( a2 == 1 )
{
if ( *a1 == a3 )
*a4 = 0LL;
else
*a4 = -1LL;
result = 0LL;
}
else
{
v16 = a2 - 1;
*a4 = -1LL;
v9 = a2 - 1;
v10 = 0LL;
while ( 1 )
{
v12 = (v10 + v9) / 2;
v13 = v12;
v14 = a1[v12];
if ( v14 == a3 )
break;
if ( v14 <= a3 )
{
if ( v12 <= v10 )
v12 = v10 + 1;
v10 = v12;
}
else
{
if ( v12 >= v9 )
v12 = v9 - 1;
v9 = v12;
}
if ( v10 > v9 )
{
v13 = -1LL;
break;
}
}
if ( !a5 || !*a5 )
goto LABEL_34;
if ( !strcasecmp(a5, "lowest") )
{
if ( v13 > 0 )
{
do
{
if ( a1[v13 - 1] != a3 )
break;
--v13;
}
while ( v13 );
}
goto LABEL_34;
}
if ( !strcasecmp(a5, "highest") )
{
v15 = a2 - 1;
if ( v13 < v16 )
{
while ( a1[v13 + 1] == a3 )
{
if ( ++v13 == v15 )
{
v13 = v15;
goto LABEL_34;
}
}
}
goto LABEL_34;
}
if ( !strcasecmp(a5, "dontcare") )
{
LABEL_34:
*a4 = v13;
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 69LL, "./AUTOGEN/GENFILES/bin_search_I2.c");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_WORD *a1, __int64 a2, __int16 a3, __int64 *a4, const char *a5)
{
__int64 v9; // rcx
__int64 v10; // rdx
__int64 result; // rax
__int64 v12; // rax
__int64 v13; // rbp
__int16 v14; // si
__int64 v15; // r13
__int64 v16; // [rsp+8h] [rbp-40h]

if ( !a1 )
{
fprintf(stderr, "Line %3d of File %s \n", 27LL, "./AUTOGEN/GENFILES/bin_search_I2.c");
return 0xFFFFFFFFLL;
}
if ( a2 <= 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 28LL, "./AUTOGEN/GENFILES/bin_search_I2.c");
return 0xFFFFFFFFLL;
}
if ( a2 == 1 )
{
if ( *a1 == a3 )
*a4 = 0LL;
else
*a4 = -1LL;
result = 0LL;
}
else
{
v16 = a2 - 1;
*a4 = -1LL;
v9 = a2 - 1;
v10 = 0LL;
while ( 1 )
{
v12 = (v10 + v9) / 2;
v13 = v12;
v14 = a1[v12];
if ( v14 == a3 )
break;
if ( v14 <= a3 )
{
if ( v12 <= v10 )
v12 = v10 + 1;
v10 = v12;
}
else
{
if ( v12 >= v9 )
v12 = v9 - 1;
v9 = v12;
}
if ( v10 > v9 )
{
v13 = -1LL;
break;
}
}
if ( !a5 || !*a5 )
goto LABEL_34;
if ( !strcasecmp(a5, "lowest") )
{
if ( v13 > 0 )
{
do
{
if ( a1[v13 - 1] != a3 )
break;
--v13;
}
while ( v13 );
}
goto LABEL_34;
}
if ( !strcasecmp(a5, "highest") )
{
v15 = a2 - 1;
if ( v13 < v16 )
{
while ( a1[v13 + 1] == a3 )
{
if ( ++v13 == v15 )
{
v13 = v15;
goto LABEL_34;
}
}
}
goto LABEL_34;
}
if ( !strcasecmp(a5, "dontcare") )
{
LABEL_34:
*a4 = v13;
return 0LL;
}
fprintf(stderr, "Line %3d of File %s \n", 69LL, "./AUTOGEN/GENFILES/bin_search_I2.c");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
bin_search_I2(
    const short *X,
    long long nX,
    short key,
    long long *ptr_pos,
    char *str_direction
    )
{
  int status = 0;
  long long pos, lb, ub, mid;
  int direction;
  if ( X == ((void *)0) ) { { fprintf(stderr, "Line %3d of File %s \n", 27, "./AUTOGEN/GENFILES/bin_search_I2.c"); }; status = -1 ; goto BYE; };
  if ( nX <= 0 ) { { fprintf(stderr, "Line %3d of File %s \n", 28, "./AUTOGEN/GENFILES/bin_search_I2.c"); }; status = -1 ; goto BYE; };
  if ( nX == 1 ) {
    if ( X[0] == key ) {
      *ptr_pos = 0;
    }
    else {
      *ptr_pos = -1;
    }
    return status ;
  }
  lb = 0; ub = nX - 1;
  *ptr_pos = pos = -1;
  for ( ; lb <= ub ; ) {
    mid = ( lb + ub ) / 2 ;
    if ( X[mid] == key ) {
      pos = mid;
      break;
    }
    else if ( key < X[mid] ) {
      ub = ((ub - 1) < (mid) ? (ub - 1) : (mid));
    }
    else {
      lb = ((lb + 1) > (mid) ? (lb + 1) : (mid));
    }
  }
  if ( ( str_direction == ((void *)0) ) || ( strlen(str_direction) == 0 ) ) {
    direction = 3;
  }
  else if ( strcasecmp(str_direction, "lowest") == 0 ) {
    direction = 1;
  }
  else if ( strcasecmp(str_direction, "highest") == 0 ) {
    direction = 2;
  }
  else if ( strcasecmp(str_direction, "dontcare") == 0 ) {
    direction = 3;
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 69, "./AUTOGEN/GENFILES/bin_search_I2.c"); }; status = -1 ; goto BYE; };
  }
  switch ( direction ) {
  case 1 :
    for ( ; pos > 0; ) {
      if ( X[pos-1] == key ) { pos--; } else { break; }
    }
    break;
  case 2 :
    for ( ; pos < nX-1; ) {
      if ( X[pos+1] == key ) { pos++; } else { break; }
    }
    break;
  case 3 :
    break;
  default : { { fprintf(stderr, "Line %3d of File %s \n", 85, "./AUTOGEN/GENFILES/bin_search_I2.c"); }; status = -1 ; goto BYE; };
  }
  *ptr_pos = pos;
 BYE:
  return status ;
}

canonical_original_code:
int bin_search_I2(short *X, long long nX, short key, long long *ptr_pos, char *str_direction)
{
  int status = 0;
  long long pos; long long lb; long long ub; long long mid;
  int direction;
  if ( X == ((void *)0) ) { { fprintf(stderr, "Line %3d of File %s \n", 27, "./AUTOGEN/GENFILES/bin_search_I2.c"); }; status = -1 ; goto BYE; };
  if ( nX <= 0 ) { { fprintf(stderr, "Line %3d of File %s \n", 28, "./AUTOGEN/GENFILES/bin_search_I2.c"); }; status = -1 ; goto BYE; };
  if ( nX == 1 ) {
    if ( X[0] == key ) {
      *ptr_pos = 0;
    }
    else {
      *ptr_pos = -1;
    }
    return status ;
  }
  lb = 0; ub = nX - 1;
  *ptr_pos = pos = -1;
  for ( ; lb <= ub ; ) {
    mid = ( lb + ub ) / 2 ;
    if ( X[mid] == key ) {
      pos = mid;
      break;
    }
    else if ( key < X[mid] ) {
      ub = ((ub - 1) < (mid) ? (ub - 1) : (mid));
    }
    else {
      lb = ((lb + 1) > (mid) ? (lb + 1) : (mid));
    }
  }
  if ( ( str_direction == ((void *)0) ) || ( strlen(str_direction) == 0 ) ) {
    direction = 3;
  }
  else if ( strcasecmp(str_direction, "lowest") == 0 ) {
    direction = 1;
  }
  else if ( strcasecmp(str_direction, "highest") == 0 ) {
    direction = 2;
  }
  else if ( strcasecmp(str_direction, "dontcare") == 0 ) {
    direction = 3;
  }
  else {
    { { fprintf(stderr, "Line %3d of File %s \n", 69, "./AUTOGEN/GENFILES/bin_search_I2.c"); }; status = -1 ; goto BYE; };
  }
  switch ( direction ) {
  case 1 :
    for ( ; pos > 0; ) {
      if ( X[pos-1] == key ) { pos--; } else { break; }
    }
    break;
  case 2 :
    for ( ; pos < nX-1; ) {
      if ( X[pos+1] == key ) { pos++; } else { break; }
    }
    break;
  case 3 :
    break;
  default : { { fprintf(stderr, "Line %3d of File %s \n", 85, "./AUTOGEN/GENFILES/bin_search_I2.c"); }; status = -1 ; goto BYE; };
  }
  *ptr_pos = pos;
 BYE:
  return status ;
}

variable_types:
X
short *

variable_types:
nX
long long

variable_types: key short

variable_types:
pos
long long

variable_types:
lb
long long

variable_types:
ub
long long

variable_types:
mid
long long

variable_types: direction int


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

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

variable_types:
pbase
void *

variable_types:
size
unsigned long

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

variable_types:
lo
char *

variable_types:
hi
char *

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

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

variable_types:
mid
char *

variable_types:
ia
long long *

variable_types:
ib
long long *

variable_types:
itmp
long long

variable_types:
thresh
char *

variable_types:
trav
char *

variable_types: c char


original_code:
int
pos_nn_copy_I4_I8(
    int *f1,
    char *nn_f1,
    long long nR1,
    long long *f2,
    char *nn_f2,
    long long nR2,
    int *f3,
    long long *ptr_cnt
    )
{
  int status = 0;
  long long cnt = 0;
  for ( long long i = 0; i < nR2; i++ ) {
    if ( ( nn_f2 != ((void *)0) ) && ( nn_f2[i] == 0 ) ) { continue; }
    long long f1idx = f2[i];
    if ( ( f1idx < 0 ) || ( f1idx >= nR1 ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 34, "./AUX/pos_nn_copy_I4_I8.c"); }; status = -1 ; goto BYE; }; }
    if ( ( nn_f1 != ((void *)0) ) && ( nn_f1[f1idx] == 0 ) ) { continue; }
    int ival = f1[f1idx];
    f3[cnt++] = ival;
  }
  *ptr_cnt = cnt;
BYE:
  return(status);
}

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

variable_types: status int

variable_types:
cnt
long long

variable_types:
i
long long

variable_types: ival int


decompiled_code:
__int64 __fastcall break_nn_fld(_BYTE *a1, const char *a2, _BYTE *a3, const char *a4)
{
int v6; // ebx
__int64 v7; // r14
int v9; // [rsp+Ch] [rbp-21Ch] BYREF
int v10; // [rsp+10h] [rbp-218h] BYREF
int v11; // [rsp+14h] [rbp-214h] BYREF
unsigned int v12; // [rsp+18h] [rbp-210h] BYREF
unsigned int v13; // [rsp+1Ch] [rbp-20Ch] BYREF
char v14[32]; // [rsp+20h] [rbp-208h] BYREF
int v15; // [rsp+40h] [rbp-1E8h]
char v16[2]; // [rsp+A0h] [rbp-188h] BYREF
__int16 v17; // [rsp+A2h] [rbp-186h]
int v18; // [rsp+C0h] [rbp-168h]
unsigned int v19; // [rsp+E8h] [rbp-140h]
char v20[128]; // [rsp+120h] [rbp-108h] BYREF
__int64 v21[6]; // [rsp+1A0h] [rbp-88h] BYREF
__int64 v22[11]; // [rsp+1D0h] [rbp-58h] BYREF

v13 = 0x80000000;
v12 = 0x80000000;
v11 = 0x80000000;
v10 = 0x80000000;
v9 = 0x80000000;
if ( a1 && *a1 )
{
if ( a2 && *a2 )
{
if ( a3 && *a3 )
{
if ( a4 && *a4 )
{
if ( !strcmp(a2, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "break_nn_fld.c");
v6 = -1;
}
else
{
v6 = is_tbl(a1, &v13, v22);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 43LL, "break_nn_fld.c");
}
else if ( (v13 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "break_nn_fld.c");
v6 = -1;
}
else
{
v7 = v22[0];
v6 = is_fld(0LL, v13, a2, &v11, v20, &v9, v16);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "break_nn_fld.c");
}
else if ( v11 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "break_nn_fld.c");
v6 = -1;
}
else if ( v9 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "break_nn_fld.c");
v6 = -1;
}
else
{
v6 = is_tbl(a3, &v12, v21);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "break_nn_fld.c");
}
else if ( (v12 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "break_nn_fld.c");
v6 = -1;
}
else if ( v7 == v21[0] )
{
zero_fld_rec(v14);
v15 = v18;
v6 = add_fld(v12, a4, (unsigned int)v17, v19, &v10, v14);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "break_nn_fld.c");
}
else
{
zero_fld_rec(g_flds + 120LL * v9);
*(_WORD *)(g_flds + 120LL * v11 + 6) = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "break_nn_fld.c");
v6 = -1;
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "break_nn_fld.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "break_nn_fld.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "break_nn_fld.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "break_nn_fld.c");
v6 = -1;
}
return (unsigned int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, const char *a2, _BYTE *a3, const char *a4)
{
int v6; // ebx
__int64 v7; // r14
int v9; // [rsp+Ch] [rbp-21Ch] BYREF
int v10; // [rsp+10h] [rbp-218h] BYREF
int v11; // [rsp+14h] [rbp-214h] BYREF
unsigned int v12; // [rsp+18h] [rbp-210h] BYREF
unsigned int v13; // [rsp+1Ch] [rbp-20Ch] BYREF
char v14[32]; // [rsp+20h] [rbp-208h] BYREF
int v15; // [rsp+40h] [rbp-1E8h]
char v16[2]; // [rsp+A0h] [rbp-188h] BYREF
__int16 v17; // [rsp+A2h] [rbp-186h]
int v18; // [rsp+C0h] [rbp-168h]
unsigned int v19; // [rsp+E8h] [rbp-140h]
char v20[128]; // [rsp+120h] [rbp-108h] BYREF
__int64 v21[6]; // [rsp+1A0h] [rbp-88h] BYREF
__int64 v22[11]; // [rsp+1D0h] [rbp-58h] BYREF

v13 = 0x80000000;
v12 = 0x80000000;
v11 = 0x80000000;
v10 = 0x80000000;
v9 = 0x80000000;
if ( a1 && *a1 )
{
if ( a2 && *a2 )
{
if ( a3 && *a3 )
{
if ( a4 && *a4 )
{
if ( !strcmp(a2, a4) )
{
fprintf(stderr, "Line %3d of File %s \n", 41LL, "break_nn_fld.c");
v6 = -1;
}
else
{
v6 = is_tbl(a1, &v13, v22);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 43LL, "break_nn_fld.c");
}
else if ( (v13 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 44LL, "break_nn_fld.c");
v6 = -1;
}
else
{
v7 = v22[0];
v6 = is_fld(0LL, v13, a2, &v11, v20, &v9, v16);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 47LL, "break_nn_fld.c");
}
else if ( v11 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 48LL, "break_nn_fld.c");
v6 = -1;
}
else if ( v9 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 49LL, "break_nn_fld.c");
v6 = -1;
}
else
{
v6 = is_tbl(a3, &v12, v21);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 51LL, "break_nn_fld.c");
}
else if ( (v12 & 0x80000000) != 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 52LL, "break_nn_fld.c");
v6 = -1;
}
else if ( v7 == v21[0] )
{
zero_fld_rec(v14);
v15 = v18;
v6 = add_fld(v12, a4, (unsigned int)v17, v19, &v10, v14);
if ( v6 < 0 )
{
fprintf(stderr, "Line %3d of File %s \n", 59LL, "break_nn_fld.c");
}
else
{
zero_fld_rec(g_flds + 120LL * v9);
*(_WORD *)(g_flds + 120LL * v11 + 6) = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 54LL, "break_nn_fld.c");
v6 = -1;
}
}
}
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 40LL, "break_nn_fld.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 39LL, "break_nn_fld.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 38LL, "break_nn_fld.c");
v6 = -1;
}
}
else
{
fprintf(stderr, "Line %3d of File %s \n", 37LL, "break_nn_fld.c");
v6 = -1;
}
return (unsigned int)v6;
}

original_code:
int
break_nn_fld(
  char *src_tbl,
  char *src_fld,
  char *dst_tbl,
  char *dst_fld
  )
{
  int status = 0;
  TBL_REC_TYPE src_tbl_rec, dst_tbl_rec;
  FLD_REC_TYPE src_fld_rec, nn_src_fld_rec;
  FLD_REC_TYPE dst_fld_rec; long long nR1 = (-0x7fffffffffffffffLL - 1LL), nR2 = (-0x7fffffffffffffffLL - 1LL);
  int src_tbl_id = (-0x7fffffff - 1), dst_tbl_id = (-0x7fffffff - 1);
  int src_fld_id = (-0x7fffffff - 1), dst_fld_id = (-0x7fffffff - 1);
  int nn_src_fld_id = (-0x7fffffff - 1);
  if ( ( src_tbl == ((void *)0) ) || ( *src_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( src_fld == ((void *)0) ) || ( *src_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( dst_tbl == ((void *)0) ) || ( *dst_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( dst_fld == ((void *)0) ) || ( *dst_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(src_fld, dst_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "break_nn_fld.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", 43, "break_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( src_tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  nR1 = src_tbl_rec.nR;
  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", 47, "break_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( src_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_src_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(dst_tbl, &dst_tbl_id, &dst_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "break_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( dst_tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  nR2 = dst_tbl_rec.nR;
  if ( nR1 != nR2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  zero_fld_rec(&dst_fld_rec); dst_fld_rec.fldtype = nn_src_fld_rec.fldtype;
  status = add_fld(dst_tbl_id, dst_fld, nn_src_fld_rec.ddir_id,
      nn_src_fld_rec.fileno, &dst_fld_id, &dst_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "break_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  zero_fld_rec(&(g_flds[nn_src_fld_id]));
  g_flds[src_fld_id].nn_fld_id = -1;
 BYE:
  return status ;
}

canonical_original_code:
int break_nn_fld(char *src_tbl, char *src_fld, char *dst_tbl, char *dst_fld)
{
  int status = 0;
  struct _TBL_REC_TYPE src_tbl_rec; struct _TBL_REC_TYPE dst_tbl_rec;
  struct _FLD_REC_TYPE src_fld_rec; struct _FLD_REC_TYPE nn_src_fld_rec;
  struct _FLD_REC_TYPE dst_fld_rec; long long nR1 = (-0x7fffffffffffffffLL - 1LL); long long nR2 = (-0x7fffffffffffffffLL - 1LL);
  int src_tbl_id = (-0x7fffffff - 1); int dst_tbl_id = (-0x7fffffff - 1);
  int src_fld_id = (-0x7fffffff - 1); int dst_fld_id = (-0x7fffffff - 1);
  int nn_src_fld_id = (-0x7fffffff - 1);
  if ( ( src_tbl == ((void *)0) ) || ( *src_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 37, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( src_fld == ((void *)0) ) || ( *src_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 38, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( dst_tbl == ((void *)0) ) || ( *dst_tbl == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 39, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( ( dst_fld == ((void *)0) ) || ( *dst_fld == '\0' ) ) { { { fprintf(stderr, "Line %3d of File %s \n", 40, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( strcmp(src_fld, dst_fld) == 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 41, "break_nn_fld.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", 43, "break_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( src_tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 44, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  nR1 = src_tbl_rec.nR;
  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", 47, "break_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( src_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 48, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  if ( nn_src_fld_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 49, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  status = is_tbl(dst_tbl, &dst_tbl_id, &dst_tbl_rec); { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 51, "break_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  if ( dst_tbl_id < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 52, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  nR2 = dst_tbl_rec.nR;
  if ( nR1 != nR2 ) { { { fprintf(stderr, "Line %3d of File %s \n", 54, "break_nn_fld.c"); }; status = -1 ; goto BYE; }; }
  zero_fld_rec(&dst_fld_rec); dst_fld_rec.fldtype = nn_src_fld_rec.fldtype;
  status = add_fld(dst_tbl_id, dst_fld, nn_src_fld_rec.ddir_id,
      nn_src_fld_rec.fileno, &dst_fld_id, &dst_fld_rec);
  { if ( (status) < 0 ) { { { fprintf(stderr, "Line %3d of File %s \n", 59, "break_nn_fld.c"); }; status = (status) ; goto BYE; } } };
  zero_fld_rec(&(g_flds[nn_src_fld_id]));
  g_flds[src_fld_id].nn_fld_id = -1;
 BYE:
  return status ;
}

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

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