qgdist

decompiled_code:
__int64 __fastcall qgdist(const char *a1, const char *a2, int a3, int a4, __int64 a5)
{
int v5; // er15
int v8; // ebx
int v9; // eax
int *v10; // rbx
unsigned int v11; // er15
unsigned __int64 v12; // rbp
__int64 v13; // rdi
int v14; // ebp
unsigned __int64 v15; // rbx
unsigned int v16; // ebp
int v17; // ebp
_DWORD *v18; // rdx
unsigned __int64 v19; // rbx
_DWORD *v20; // r15
__int64 v21; // rdi
unsigned int v22; // er14
int v23; // edi
unsigned __int64 v24; // rbx
int v25; // ebp
int *v26; // rdx
__int64 **i; // rdx
__int64 v28; // rcx
int v29; // eax
_DWORD *v31; // [rsp+8h] [rbp-B0h]
int v32; // [rsp+10h] [rbp-A8h]
unsigned __int64 v33; // [rsp+10h] [rbp-A8h]
unsigned __int64 v34; // [rsp+18h] [rbp-A0h]
_DWORD *v35; // [rsp+20h] [rbp-98h]
__int64 ***v36; // [rsp+28h] [rbp-90h]
int v37; // [rsp+30h] [rbp-88h]
_DWORD *ptr; // [rsp+40h] [rbp-78h]
__int64 v40; // [rsp+48h] [rbp-70h]
int v41; // [rsp+58h] [rbp-60h]
_DWORD *v42; // [rsp+60h] [rbp-58h]
int v44; // [rsp+6Ch] [rbp-4Ch]
int v45[15]; // [rsp+7Ch] [rbp-3Ch] BYREF

v5 = a3;
v8 = strlen(a1);
v32 = v8;
v9 = strlen(a2);
v41 = v9;
if ( v8 <= v9 )
v9 = v8;
if ( v5 > v9 )
return (unsigned int)-1;
ptr = get_pot_list(a4, a3);
v10 = &ptr[a3];
v40 = a3;
v42 = v10;
v31 = calloc(*v10, 4uLL);
v35 = calloc(*v10, 4uLL);
v11 = 0;
v36 = (__int64 ***)linked_list_new();
if ( a3 )
{
v12 = 1LL;
do
{
v13 = (unsigned int)a1[v12++ - 1];
v11 += *--v10 * translate(v13, a5, v45);
}
while ( a3 >= v12 );
}
v14 = v45[0];
if ( v45[0] )
return (unsigned int)-1;
v31[v11] = 1;
linked_list_add(v36, v11);
v34 = v32 - a3;
if ( v32 != a3 )
{
v44 = v14;
v15 = 1LL;
v16 = v11;
while ( 1 )
{
v17 = a4 * (v16 - ptr[v40 - 1] * translate((unsigned int)a1[v15 - 1], a5, v45));
v16 = translate((unsigned int)a1[a3 - 1 + v15], a5, v45) + v17;
if ( v45[0] )
return (unsigned int)-1;
v18 = &v31[v16];
if ( *v18 )
{
++v15;
++*v18;
if ( v15 > v34 )
goto LABEL_14;
}
else
{
++v15;
linked_list_add(v36, v16);
v31[v16] = 1;
if ( v15 > v34 )
{
LABEL_14:
v14 = v44;
break;
}
}
}
}
v19 = 1LL;
if ( a3 )
{
v20 = v42;
do
{
v21 = (unsigned int)a2[v19++ - 1];
v14 += *--v20 * translate(v21, a5, v45);
}
while ( a3 >= v19 );
}
v22 = v45[0];
if ( v45[0] )
return (unsigned int)-1;
v23 = v31[v14];
v35[v14] = 1;
if ( !v23 )
linked_list_add(v36, (unsigned int)v14);
v33 = v41 - a3;
if ( v41 != a3 )
{
v24 = 1LL;
while ( 1 )
{
v25 = a4 * (v14 - ptr[v40 - 1] * translate((unsigned int)a2[v24 - 1], a5, v45));
v14 = translate((unsigned int)a2[a3 - 1 + v24], a5, v45) + v25;
if ( v45[0] )
return (unsigned int)-1;
v26 = &v35[v14];
if ( *v26 || v31[v14] )
{
++v24;
++*v26;
if ( v24 > v33 )
break;
}
else
{
v37 = *v26;
++v24;
linked_list_add(v36, (unsigned int)v14);
v35[v14] = v37 + 1;
if ( v24 > v33 )
break;
}
}
}
for ( i = *v36; i; v22 += abs32(v29) )
{
v28 = *((int *)i + 2);
i = (__int64 **)*i;
v29 = v31[v28] - v35[v28];
}
linked_list_delete(v36);
free(ptr);
free(v31);
free(v35);
return v22;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2, int a3, int a4, __int64 a5)
{
int v5; // er15
int v8; // ebx
int v9; // eax
int *v10; // rbx
unsigned int v11; // er15
unsigned __int64 v12; // rbp
__int64 v13; // rdi
int v14; // ebp
unsigned __int64 v15; // rbx
unsigned int v16; // ebp
int v17; // ebp
_DWORD *v18; // rdx
unsigned __int64 v19; // rbx
_DWORD *v20; // r15
__int64 v21; // rdi
unsigned int v22; // er14
int v23; // edi
unsigned __int64 v24; // rbx
int v25; // ebp
int *v26; // rdx
__int64 **i; // rdx
__int64 v28; // rcx
int v29; // eax
_DWORD *v31; // [rsp+8h] [rbp-B0h]
int v32; // [rsp+10h] [rbp-A8h]
unsigned __int64 v33; // [rsp+10h] [rbp-A8h]
unsigned __int64 v34; // [rsp+18h] [rbp-A0h]
_DWORD *v35; // [rsp+20h] [rbp-98h]
__int64 ***v36; // [rsp+28h] [rbp-90h]
int v37; // [rsp+30h] [rbp-88h]
_DWORD *ptr; // [rsp+40h] [rbp-78h]
__int64 v40; // [rsp+48h] [rbp-70h]
int v41; // [rsp+58h] [rbp-60h]
_DWORD *v42; // [rsp+60h] [rbp-58h]
int v44; // [rsp+6Ch] [rbp-4Ch]
int v45[15]; // [rsp+7Ch] [rbp-3Ch] BYREF

v5 = a3;
v8 = strlen(a1);
v32 = v8;
v9 = strlen(a2);
v41 = v9;
if ( v8 <= v9 )
v9 = v8;
if ( v5 > v9 )
return (unsigned int)-1;
ptr = get_pot_list(a4, a3);
v10 = &ptr[a3];
v40 = a3;
v42 = v10;
v31 = calloc(*v10, 4uLL);
v35 = calloc(*v10, 4uLL);
v11 = 0;
v36 = (__int64 ***)linked_list_new();
if ( a3 )
{
v12 = 1LL;
do
{
v13 = (unsigned int)a1[v12++ - 1];
v11 += *--v10 * translate(v13, a5, v45);
}
while ( a3 >= v12 );
}
v14 = v45[0];
if ( v45[0] )
return (unsigned int)-1;
v31[v11] = 1;
linked_list_add(v36, v11);
v34 = v32 - a3;
if ( v32 != a3 )
{
v44 = v14;
v15 = 1LL;
v16 = v11;
while ( 1 )
{
v17 = a4 * (v16 - ptr[v40 - 1] * translate((unsigned int)a1[v15 - 1], a5, v45));
v16 = translate((unsigned int)a1[a3 - 1 + v15], a5, v45) + v17;
if ( v45[0] )
return (unsigned int)-1;
v18 = &v31[v16];
if ( *v18 )
{
++v15;
++*v18;
if ( v15 > v34 )
goto LABEL_14;
}
else
{
++v15;
linked_list_add(v36, v16);
v31[v16] = 1;
if ( v15 > v34 )
{
LABEL_14:
v14 = v44;
break;
}
}
}
}
v19 = 1LL;
if ( a3 )
{
v20 = v42;
do
{
v21 = (unsigned int)a2[v19++ - 1];
v14 += *--v20 * translate(v21, a5, v45);
}
while ( a3 >= v19 );
}
v22 = v45[0];
if ( v45[0] )
return (unsigned int)-1;
v23 = v31[v14];
v35[v14] = 1;
if ( !v23 )
linked_list_add(v36, (unsigned int)v14);
v33 = v41 - a3;
if ( v41 != a3 )
{
v24 = 1LL;
while ( 1 )
{
v25 = a4 * (v14 - ptr[v40 - 1] * translate((unsigned int)a2[v24 - 1], a5, v45));
v14 = translate((unsigned int)a2[a3 - 1 + v24], a5, v45) + v25;
if ( v45[0] )
return (unsigned int)-1;
v26 = &v35[v14];
if ( *v26 || v31[v14] )
{
++v24;
++*v26;
if ( v24 > v33 )
break;
}
else
{
v37 = *v26;
++v24;
linked_list_add(v36, (unsigned int)v14);
v35[v14] = v37 + 1;
if ( v24 > v33 )
break;
}
}
}
for ( i = *v36; i; v22 += abs32(v29) )
{
v28 = *((int *)i + 2);
i = (__int64 **)*i;
v29 = v31[v28] - v35[v28];
}
linked_list_delete(v36);
free(ptr);
free(v31);
free(v35);
return v22;
}

original_code:
int qgdist(char* u, char* v, int q, int r, int* A)
{
  int m = strlen(u);
  int n = strlen(v);
  if (q > m || q > n)
    return -1;
  int* rpot = get_pot_list(r,q);
  int* tu = (int*) calloc(rpot[q], sizeof(int));
  int* tv = (int*) calloc(rpot[q], sizeof(int));
  linkedlist* C = linked_list_new();
  unsigned long int i;
  int c = 0;
  int fail;
  for (i = 1; i <= q; i++)
  {
    c += translate(u[i-1],A,&fail)*rpot[q-i];
  }
  if (fail)
    return -1;
  tu[c] = 1;
  linked_list_add(C,c);
  for (i = 1; i <= m-q; i++)
  {
    c = (c - translate(u[i-1],A,&fail)*rpot[q-1])*r + translate(u[i+q-1],A,&fail);
    if (fail)
      return -1;
    if (tu[c] == 0)
      linked_list_add(C,c);
    tu[c]++;
  }
  c = 0;
  for (i = 1; i <= q; i++)
  {
    c += translate(v[i-1],A,&fail)*rpot[q-i];
  }
  if (fail)
    return -1;
  tv[c] = 1;
  if (tu[c] == 0)
    linked_list_add(C,c);
  for (i = 1; i <= n-q; i++)
  {
    c = (c - translate(v[i-1],A,&fail)*rpot[q-1])*r + translate(v[i+q-1],A,&fail);
    if (fail)
      return -1;
    if (tv[c] == 0 && tu[c] == 0)
      linked_list_add(C,c);
    tv[c]++;
  }
  llentry* curr = C->root;
  int result = 0;
  while (curr != ((void *)0))
  {
    c = curr->key;
    result += abs(tu[c]-tv[c]);
    curr = curr->next;
  }
  linked_list_delete(C);
  free(rpot);
  free(tu);
  free(tv);
  return result;
}

canonical_original_code:
int qgdist(char *u, char *v, int q, int r, int *A)
{
  int m = strlen(u);
  int n = strlen(v);
  if (q > m || q > n)
    return -1;
  int *rpot = get_pot_list(r,q);
  int *tu = (int*) calloc(rpot[q], sizeof(int));
  int *tv = (int*) calloc(rpot[q], sizeof(int));
  struct llStruct *C = linked_list_new();
  unsigned long i;
  int c = 0;
  int fail;
  for (i = 1; i <= q; i++)
  {
    c += translate(u[i-1],A,&fail)*rpot[q-i];
  }
  if (fail)
    return -1;
  tu[c] = 1;
  linked_list_add(C,c);
  for (i = 1; i <= m-q; i++)
  {
    c = (c - translate(u[i-1],A,&fail)*rpot[q-1])*r + translate(u[i+q-1],A,&fail);
    if (fail)
      return -1;
    if (tu[c] == 0)
      linked_list_add(C,c);
    tu[c]++;
  }
  c = 0;
  for (i = 1; i <= q; i++)
  {
    c += translate(v[i-1],A,&fail)*rpot[q-i];
  }
  if (fail)
    return -1;
  tv[c] = 1;
  if (tu[c] == 0)
    linked_list_add(C,c);
  for (i = 1; i <= n-q; i++)
  {
    c = (c - translate(v[i-1],A,&fail)*rpot[q-1])*r + translate(v[i+q-1],A,&fail);
    if (fail)
      return -1;
    if (tv[c] == 0 && tu[c] == 0)
      linked_list_add(C,c);
    tv[c]++;
  }
  struct entstruct *curr = C->root;
  int result = 0;
  while (curr != ((void *)0))
  {
    c = curr->key;
    result += abs(tu[c]-tv[c]);
    curr = curr->next;
  }
  linked_list_delete(C);
  free(rpot);
  free(tu);
  free(tv);
  return result;
}

variable_types:
u
char *

variable_types:
v
char *

variable_types: q int

variable_types: r int

variable_types:
A
int *

variable_types: m int

variable_types: n int

variable_types:
rpot
int *

variable_types:
tu
int *

variable_types:
tv
int *

variable_types: struct llStruct { struct entstruct { struct entstruct *next; int key; } *root; struct entstruct *end; } *

variable_types:
i
unsigned long

variable_types: c int

variable_types: fail int

variable_types: result int


main

canonical_name: main

repo: dr-walfeld/GSA

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r13
const char *v4; // r14
const char *v5; // rbp
int v6; // er12
int v7; // ebx
_DWORD *v8; // rax
void *v9; // rbp
unsigned int v10; // eax
int v12; // [rsp+Ch] [rbp-2Ch] BYREF

if ( argc <= 4 )
{
v6 = 0;
printf("usage: %s seq1 seq2 A q\n", *argv);
}
else
{
v3 = argv[1];
v4 = argv[2];
v5 = argv[3];
v6 = _isoc99_sscanf(argv[4], "%d", &v12);
if ( v6 == 1 && v12 > 0 )
{
v7 = strlen(v5);
v8 = new_alphabet(v5);
v9 = v8;
if ( v8 )
{
v6 = 0;
v10 = qgdist(v3, v4, v12, v7, (__int64)v8);
printf("qgdist(u,v) = %d\n", v10);
free(v9);
}
}
else
{
v6 = 1;
printf("invalid parameter q=%s\n", argv[4]);
}
}
return v6;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r13
const char *v4; // r14
const char *v5; // rbp
int v6; // er12
int v7; // ebx
_DWORD *v8; // rax
void *v9; // rbp
unsigned int v10; // eax
int v12; // [rsp+Ch] [rbp-2Ch] BYREF

if ( argc <= 4 )
{
v6 = 0;
printf("usage: %s seq1 seq2 A q\n", *argv);
}
else
{
v3 = argv[1];
v4 = argv[2];
v5 = argv[3];
v6 = _isoc99_sscanf(argv[4], "%d", &v12);
if ( v6 == 1 && v12 > 0 )
{
v7 = strlen(v5);
v8 = new_alphabet(v5);
v9 = v8;
if ( v8 )
{
v6 = 0;
v10 = func0(v3, v4, v12, v7, (__int64)v8);
printf("qgdist(u,v) = %d\n", v10);
free(v9);
}
}
else
{
v6 = 1;
printf("invalid parameter q=%s\n", argv[4]);
}
}
return v6;
}

original_code:
int main(int argc, char* argv[])
{
  if (argc < 5)
  {
    printf("usage: %s seq1 seq2 A q\n", argv[0]);
    return 0;
  }
  char* u = argv[1];
  char* v = argv[2];
  char* Astring= argv[3];
  int q;
  if (sscanf(argv[4], "%d", &q) != 1 || q < 1)
  {
    printf ("invalid parameter q=%s\n", argv[4]);
    return 1;
  }
  int r = strlen(Astring);
  int* A = new_alphabet(Astring);
  if (A == ((void *)0))
    return 1;
  int cost = qgdist(u,v,q,r,A);
  printf("qgdist(u,v) = %d\n", cost);
  free(A);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  if (argc < 5)
  {
    printf("usage: %s seq1 seq2 A q\n", argv[0]);
    return 0;
  }
  char *u = argv[1];
  char *v = argv[2];
  char *Astring = argv[3];
  int q;
  if (sscanf(argv[4], "%d", &q) != 1 || q < 1)
  {
    printf ("invalid parameter q=%s\n", argv[4]);
    return 1;
  }
  int r = strlen(Astring);
  int *A = new_alphabet(Astring);
  if (A == ((void *)0))
    return 1;
  int cost = qgdist(u,v,q,r,A);
  printf("qgdist(u,v) = %d\n", cost);
  free(A);
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
Astring
char *

variable_types: cost int

return_type: int


original_code:
static void max_pssmscore (Pssm* pssm)
{
  int i,j,sc;
  for (i = 0; i < pssm->positions; i++)
  {
    pssm->maxscore[i] = (-0x7fffffff - 1);
    for (j = 0; j < pssm->characters; j++)
    {
      if ((sc = get_pssmscore(pssm, i, j+'A')) > pssm->maxscore[i])
      {
        pssm->maxscore[i] = sc;
      }
    }
  }
}

canonical_original_code:
static void max_pssmscore(struct pssmStruct *pssm)
{
  int i; int j; int sc;
  for (i = 0; i < pssm->positions; i++)
  {
    pssm->maxscore[i] = (-0x7fffffff - 1);
    for (j = 0; j < pssm->characters; j++)
    {
      if ((sc = get_pssmscore(pssm, i, j+'A')) > pssm->maxscore[i])
      {
        pssm->maxscore[i] = sc;
      }
    }
  }
}

variable_types: struct pssmStruct { int **matrix; int *maxscore; int characters; } *

variable_types: i int

variable_types: j int

variable_types: sc int

return_type: void


decompiled_code:
void __fastcall delete_pssm(void *ptr)
{
if ( ptr )
{
free(**(void ***)ptr);
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
if ( ptr )
{
free(**(void ***)ptr);
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(ptr);
}
}

original_code:
void delete_pssm(Pssm* pssm)
{
  if (pssm == ((void *)0))
    return;
  free(pssm->matrix[0]);
  free(pssm->matrix);
  free(pssm->maxscore);
  free(pssm);
}

canonical_original_code:
void delete_pssm(struct pssmStruct *pssm)
{
  if (pssm == ((void *)0))
    return;
  free(pssm->matrix[0]);
  free(pssm->matrix);
  free(pssm->maxscore);
  free(pssm);
}

user_defined_types: struct pssmStruct { int **matrix; int *maxscore; int characters; }


decompiled_code:
int __fastcall show_pssmatrix(__int64 a1)
{
unsigned int i; // er12
int result; // eax
int v3; // er13
unsigned int v4; // ebx
unsigned int v5; // eax

for ( i = 65; i != 92; ++i )
{
while ( 1 )
{
result = *(_DWORD *)(a1 + 20);
v3 = 0;
v4 = -1;
if ( result >= 0 )
break;
LABEL_11:
if ( ++i == 92 )
return result;
}
do
{
while ( 1 )
{
if ( v4 != -1 )
{
result = get_pssmscore(a1, v4, i);
if ( result != 0x80000000 )
{
v5 = get_pssmscore(a1, v4, i);
result = printf(" %3d", v5);
}
goto LABEL_6;
}
result = get_pssmscore(a1, 0LL, i);
if ( result != 0x80000000 )
break;
LABEL_6:
if ( *(_DWORD *)(a1 + 20) <= (signed int)++v4 )
goto LABEL_10;
}
v3 = 1;
v4 = 0;
result = putchar(i);
}
while ( *(int *)(a1 + 20) > 0 );
LABEL_10:
if ( !v3 )
goto LABEL_11;
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
unsigned int i; // er12
int result; // eax
int v3; // er13
unsigned int v4; // ebx
unsigned int v5; // eax

for ( i = 65; i != 92; ++i )
{
while ( 1 )
{
result = *(_DWORD *)(a1 + 20);
v3 = 0;
v4 = -1;
if ( result >= 0 )
break;
LABEL_11:
if ( ++i == 92 )
return result;
}
do
{
while ( 1 )
{
if ( v4 != -1 )
{
result = get_pssmscore(a1, v4, i);
if ( result != 0x80000000 )
{
v5 = get_pssmscore(a1, v4, i);
result = printf(" %3d", v5);
}
goto LABEL_6;
}
result = get_pssmscore(a1, 0LL, i);
if ( result != 0x80000000 )
break;
LABEL_6:
if ( *(_DWORD *)(a1 + 20) <= (signed int)++v4 )
goto LABEL_10;
}
v3 = 1;
v4 = 0;
result = putchar(i);
}
while ( *(int *)(a1 + 20) > 0 );
LABEL_10:
if ( !v3 )
goto LABEL_11;
result = putchar(10);
}
return result;
}

original_code:
void show_pssmatrix(Pssm* pssm)
{
  int i,j,print;
  for (i = 'A'; i <= '['; i++)
  {
    print = 0;
    for (j = -1; j < pssm->positions; j++)
    {
      if (j == -1 && get_pssmscore(pssm,0,i) > (-0x7fffffff - 1))
      {
        printf("%c", i);
        print = 1;
      }
      else if (i >= 'A' && j >= 0 && get_pssmscore(pssm,j,i) > (-0x7fffffff - 1))
        printf(" %3d", get_pssmscore(pssm,j,i));
      else
        ;
    }
    if (print)
      printf("\n");
  }
}

canonical_original_code:
void show_pssmatrix(struct pssmStruct *pssm)
{
  int i; int j; int print;
  for (i = 'A'; i <= '['; i++)
  {
    print = 0;
    for (j = -1; j < pssm->positions; j++)
    {
      if (j == -1 && get_pssmscore(pssm,0,i) > (-0x7fffffff - 1))
      {
        printf("%c", i);
        print = 1;
      }
      else if (i >= 'A' && j >= 0 && get_pssmscore(pssm,j,i) > (-0x7fffffff - 1))
        printf(" %3d", get_pssmscore(pssm,j,i));
      else
        ;
    }
    if (print)
      printf("\n");
  }
}

variable_types: print int


variable_types: struct alignentryStruct { int value; int north; int west; int northwest; } ***


unity

decompiled_code:
_BOOL8 __fastcall unity(char a1, char a2)
{
_BOOL8 result; // rax

if ( a1 == 45 || a2 == 45 )
result = 1LL;
else
result = a1 != a2;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char a1, char a2)
{
_BOOL8 result; // rax

if ( a1 == 45 || a2 == 45 )
result = 1LL;
else
result = a1 != a2;
return result;
}

original_code:
int unity (char a, char b)
{
  if (a == '-' || b == '-')
    return 1;
  return (a != b);
}

canonical_original_code:
int unity(char a, char b)
{
  if (a == '-' || b == '-')
    return 1;
  return (a != b);
}

variable_types: a char

variable_types: b char


substring

original_code:
void substring(char* sequence, int lenseq, int* set, int lenset)
{
  int* substrdist = (int*) malloc(lenset*sizeof(int));
  int i;
  int c;
  int diff = 0;
  int substrlen = 0;
  for(i = 0; i < lenset; i++)
  {
    substrdist[i] = 0;
    substrlen += set[i];
    if (set[i] != 0)
      diff++;
  }
  for(i = 0; i < lenseq; i++)
  {
    c = tolower(sequence[i]);
    if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISlower))
    {
      printf("%c is no allowed character!\n", c);
      return;
    }
    c -= 'a';
    if (set[c] == substrdist[c])
      diff++;
    else if (set[c] == substrdist[c]+1)
      diff--;
    substrdist[c]++;
    if (i >= substrlen)
    {
      c = tolower(sequence[i-substrlen])-'a';
      if (set[c] == substrdist[c])
        diff++;
      else if (set[c] == substrdist[c]-1)
        diff--;
      substrdist[c]--;
    }
    if (i >= substrlen-1 && diff == 0)
    {
      printf("matching substring found starting at %d (length %d)\n", i-substrlen+1, substrlen);
    }
  }
  free(substrdist);
}

canonical_original_code:
void substring(char *sequence, int lenseq, int *set, int lenset)
{
  int *substrdist = (int*) malloc(lenset*sizeof(int));
  int i;
  int c;
  int diff = 0;
  int substrlen = 0;
  for(i = 0; i < lenset; i++)
  {
    substrdist[i] = 0;
    substrlen += set[i];
    if (set[i] != 0)
      diff++;
  }
  for(i = 0; i < lenseq; i++)
  {
    c = tolower(sequence[i]);
    if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISlower))
    {
      printf("%c is no allowed character!\n", c);
      return;
    }
    c -= 'a';
    if (set[c] == substrdist[c])
      diff++;
    else if (set[c] == substrdist[c]+1)
      diff--;
    substrdist[c]++;
    if (i >= substrlen)
    {
      c = tolower(sequence[i-substrlen])-'a';
      if (set[c] == substrdist[c])
        diff++;
      else if (set[c] == substrdist[c]-1)
        diff--;
      substrdist[c]--;
    }
    if (i >= substrlen-1 && diff == 0)
    {
      printf("matching substring found starting at %d (length %d)\n", i-substrlen+1, substrlen);
    }
  }
  free(substrdist);
}

variable_types:
sequence
char *

variable_types: lenseq int

variable_types:
set
int *

variable_types: lenset int

variable_types:
substrdist
int *

variable_types: diff int

variable_types: substrlen int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbx
int result; // eax

if ( argc <= 2 )
{
printf("usage: %s sequence set(format a=0 c=3 ...)\n", *argv);
result = 0;
}
else
{
v3 = argv[1];
calloc(0x1AuLL, 4uLL);
strlen(v3);
__ctype_tolower_loc();
__ctype_b_loc();
__isoc99_sscanf();
printf("expression %s has incorrect format!\n", argv[2]);
result = 1;
}
return result;
}

original_code:
int main(int argc, char* argv[])
{
  if (argc < 3)
  {
    printf("usage: %s sequence set(format a=0 c=3 ...)\n", argv[0]);
    return 0;
  }
  char* seq = argv[1];
  int lenset = 26;
  int* set = (int*) calloc(lenset, sizeof(int));
  int lenseq = strlen(seq);
  int i;
  char c;
  int num;
  for (i = 2; i < argc; i++)
  {
    c = 0;
    num = -1;
    sscanf(argv[i], "%c=%d", &c, &num);
    c = tolower(c);
    if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISlower) || num == -1)
    {
      printf("expression %s has incorrect format!\n", argv[i]);
      return 1;
    }
    set[c-'a'] = num;
  }
  substring(seq, lenseq, set, lenset);
  free(set);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  if (argc < 3)
  {
    printf("usage: %s sequence set(format a=0 c=3 ...)\n", argv[0]);
    return 0;
  }
  char *seq = argv[1];
  int lenset = 26;
  int *set = (int*) calloc(lenset, sizeof(int));
  int lenseq = strlen(seq);
  int i;
  char c;
  int num;
  for (i = 2; i < argc; i++)
  {
    c = 0;
    num = -1;
    sscanf(argv[i], "%c=%d", &c, &num);
    c = tolower(c);
    if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISlower) || num == -1)
    {
      printf("expression %s has incorrect format!\n", argv[i]);
      return 1;
    }
    set[c-'a'] = num;
  }
  substring(seq, lenseq, set, lenset);
  free(set);
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
seq
char *

variable_types: c char

variable_types: num int


repo: dragansah/tpch-dbgen

decompiled_code:
char *__fastcall env_config(const char *a1, char *a2)
{
char *result; // rax

result = getenv(a1);
if ( !result )
result = a2;
return result;
}

canonical_decompiled_code:
char *__fastcall func0(const char *a1, char *a2)
{
char *result; // rax

result = getenv(a1);
if ( !result )
result = a2;
return result;
}

original_code:
char *
env_config(char *var, char *dflt)
{
   static char *evar;
   if ((evar = getenv(var)) != ((void *)0))
      return (evar);
   else
      return (dflt);
}

canonical_original_code:
char *env_config(char *var, char *dflt)
{
   static char *evar;
   if ((evar = getenv(var)) != ((void *)0))
      return (evar);
   else
      return (dflt);
}

variable_types:
var
char *

variable_types:
dflt
char *

variable_types:
evar
char *

return_type: char *


decompiled_code:
__int64 __fastcall yes_no(const char *a1)
{
char v2[136]; // [rsp+0h] [rbp-88h] BYREF

while ( 1 )
{
printf("%s [Y/N]: ", a1);
fgets(v2, 128, stdin);
if ( v2[0] == 110 )
break;
if ( v2[0] > 110 )
{
if ( v2[0] == 121 )
return 1LL;
}
else
{
if ( v2[0] == 78 )
return 0LL;
if ( v2[0] == 89 )
return 1LL;
}
puts("Please answer 'yes' or 'no'.");
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
char v2[136]; // [rsp+0h] [rbp-88h] BYREF

while ( 1 )
{
printf("%s [Y/N]: ", a1);
fgets(v2, 128, stdin);
if ( v2[0] == 110 )
break;
if ( v2[0] > 110 )
{
if ( v2[0] == 121 )
return 1LL;
}
else
{
if ( v2[0] == 78 )
return 0LL;
if ( v2[0] == 89 )
return 1LL;
}
puts("Please answer 'yes' or 'no'.");
}
return 0LL;
}

original_code:
long
yes_no(char *prompt)
{
    char reply[128];
    while (1)
        {
        printf("%s [Y/N]: ", prompt);
        fgets(reply, 128, stdin);
        switch (*reply)
            {
            case 'y':
            case 'Y':
                return (1);
            case 'n':
            case 'N':
                return (0);
            default:
                printf("Please answer 'yes' or 'no'.\n");
            }
        }
}

variable_types:
prompt
char *

variable_types:
reply
char [128]

return_type: long


original_code:
void
a_rnd(int min, int max, int column, char *dest)
{
   long long int i,
             len,
             char_int;
   dss_random(&len, min, max, column);
   for (i = 0; i < len; i++)
      {
      if (i % 5 == 0)
        dss_random(&char_int, 0, 0x7FFFFFFF, column);
      *(dest + i) = alpha_num[char_int & 077];
      char_int >>= 6;
      }
   *(dest + len) = '\0';
   return;
}

canonical_original_code:
void a_rnd(int min, int max, int column, char *dest)
{
   long long i; long long len; long long char_int;
   dss_random(&len, min, max, column);
   for (i = 0; i < len; i++)
      {
      if (i % 5 == 0)
        dss_random(&char_int, 0, 0x7FFFFFFF, column);
      *(dest + i) = alpha_num[char_int & 077];
      char_int >>= 6;
      }
   *(dest + len) = '\0';
   return;
}

variable_types: min int

variable_types: max int

variable_types: column int

variable_types:
dest
char *

variable_types:
i
long long

variable_types:
len
long long


original_code:
int
pick_str(distribution *s, int c, char *target)
{
    long i = 0;
    long long int j;
    dss_random(&j, 1, s->list[s->count - 1].weight, c);
    while (s->list[i].weight < j)
        i++;
    strcpy(target, s->list[i].text);
    return(i);
}

canonical_original_code:
int pick_str(struct distribution *s, int c, char *target)
{
    long i = 0;
    long long j;
    dss_random(&j, 1, s->list[s->count - 1].weight, c);
    while (s->list[i].weight < j)
        i++;
    strcpy(target, s->list[i].text);
    return(i);
}

variable_types: struct distribution { int count; int max; struct set_member { long weight; char *text; } *list; long *permute; } *

variable_types: c int

variable_types:
target
char *

variable_types: i long

variable_types:
j
long long

user_defined_types: struct distribution { int count; int max; struct set_member *list; long *permute; }


decompiled_code:
char *__fastcall e_str(int *a1, int a2, int a3, int a4, const char *a5)
{
size_t v7; // r12
int v8; // eax
__int64 v10; // [rsp+8h] [rbp-40h] BYREF
char s[56]; // [rsp+10h] [rbp-38h] BYREF

a_rnd(a2, a3, a4, (__int64)a5);
pick_str(a1, a4, s);
v7 = strlen(s);
v8 = strlen(a5);
dss_random(&v10, 0LL, v8 - 1 - (int)v7, a4);
return strncpy((char *)&a5[v10], s, v7);
}

canonical_decompiled_code:
char *__fastcall func4(int *a1, int a2, int a3, int a4, const char *a5)
{
size_t v7; // r12
int v8; // eax
__int64 v10; // [rsp+8h] [rbp-40h] BYREF
char s[56]; // [rsp+10h] [rbp-38h] BYREF

func2(a2, a3, a4, (__int64)a5);
func3(a1, a4, s);
v7 = strlen(s);
v8 = strlen(a5);
dss_random(&v10, 0LL, v8 - 1 - (int)v7, a4);
return strncpy((char *)&a5[v10], s, v7);
}

original_code:
void
e_str(distribution *d, int min, int max, int stream, char *dest)
{
    char strtmp[20 + 1];
    long long int loc;
    int len;
    a_rnd(min, max, stream, dest);
    pick_str(d, stream, strtmp);
    len = (int)strlen(strtmp);
    dss_random(&loc, 0, ((int)strlen(dest) - 1 - len), stream);
    strncpy(dest + loc, strtmp, len);
    return;
}

canonical_original_code:
void e_str(struct distribution *d, int min, int max, int stream, char *dest)
{
    char strtmp[-1];
    long long loc;
    int len;
    a_rnd(min, max, stream, dest);
    pick_str(d, stream, strtmp);
    len = (int)strlen(strtmp);
    dss_random(&loc, 0, ((int)strlen(dest) - 1 - len), stream);
    strncpy(dest + loc, strtmp, len);
    return;
}

variable_types: stream int

variable_types:
strtmp
char [-1]

variable_types:
loc
long long

variable_types: len int

user_defined_types: struct set_member { long weight; char *text; }


unjulian

variable_types: date long

variable_types: i int

variable_types: res long


julian

original_code:
long
julian(long date)
{
    long offset;
    long result;
    long yr;
    long yend;
    offset = date - 92001;
    result = 92001;
    while (1)
        {
        yr = result / 1000;
        yend = yr * 1000 + 365 + ((!(yr % 4) && (yr % 100))?1:0);
        if (result + offset > yend)
            {
            offset -= yend - result + 1;
            result += 1000;
            continue;
            }
        else
            break;
        }
    return (result + offset);
}

variable_types: offset long

variable_types: result long

variable_types: yr long

variable_types: yend long


decompiled_code:
__int64 __fastcall agg_str(__int64 a1, __int64 a2, __int64 a3, const char *a4)
{
__int64 v6; // rbx
char *v7; // rdi
__int64 v8; // rax
__int64 result; // rax

*a4 = 0;
permute_dist(a1, a3);
if ( a2 > 0 )
{
v6 = 0LL;
do
{
v7 = (char *)&a4[strlen(a4)];
v8 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + v6);
v6 += 8LL;
*(_WORD *)stpcpy(v7, *(const char **)(*(_QWORD *)(a1 + 8) + 16 * v8 + 8)) = 32;
}
while ( 8 * a2 != v6 );
}
result = (int)strlen(a4);
a4[(int)result - 1] = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3, const char *a4)
{
__int64 v6; // rbx
char *v7; // rdi
__int64 v8; // rax
__int64 result; // rax

*a4 = 0;
permute_dist(a1, a3);
if ( a2 > 0 )
{
v6 = 0LL;
do
{
v7 = (char *)&a4[strlen(a4)];
v8 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + v6);
v6 += 8LL;
*(_WORD *)stpcpy(v7, *(const char **)(*(_QWORD *)(a1 + 8) + 16 * v8 + 8)) = 32;
}
while ( 8 * a2 != v6 );
}
result = (int)strlen(a4);
a4[(int)result - 1] = 0;
return result;
}

original_code:
void
agg_str(distribution *set, long count, long col, char *dest)
{
 distribution *d;
 int i;
 d = set;
 *dest = '\0';
 permute_dist(d, col);
 for (i=0; i < count; i++)
  {
  strcat(dest, ((set_member *)((set)->list + (d->permute[i])))->text);
  strcat(dest, " ");
  }
 *(dest + (int)strlen(dest) - 1) = '\0';
    return;
}

canonical_original_code:
void agg_str(struct distribution *set, long count, long col, char *dest)
{
 struct distribution *d;
 int i;
 d = set;
 *dest = '\0';
 permute_dist(d, col);
 for (i=0; i < count; i++)
  {
  strcat(dest, ((struct set_member *)((set)->list + (d->permute[i])))->text);
  strcat(dest, " ");
  }
 *(dest + (int)strlen(dest) - 1) = '\0';
    return;
}

variable_types: count long

variable_types: col long

variable_types:
dest
char *


dssncasecmp

decompiled_code:
__int64 __fastcall dssncasecmp(__int64 a1, __int64 a2, int a3)
{
const __int32_t **v5; // rax
__int64 v6; // r8
const __int32_t *v7; // rcx
__int64 i; // rax
__int64 v9; // rdi
__int32_t v10; // ebx

if ( a3 <= 0 )
return 0LL;
v5 = _ctype_tolower_loc();
v6 = a3;
v7 = *v5;
for ( i = 0LL; i != v6; ++i )
{
v9 = *(char *)(a1 + i);
v10 = v7[*(char *)(a2 + i)];
if ( v7[v9] != v10 )
return 2LL * (v7[v9] >= v10) - 1;
if ( !(_BYTE)v9 )
break;
}
return 0LL;
}

original_code:
long
dssncasecmp(char *s1, char *s2, int n)
{
    for (; n > 0; ++s1, ++s2, --n)
        if (tolower(*s1) != tolower(*s2))
            return ((tolower(*s1) < tolower(*s2)) ? -1 : 1);
        else if (*s1 == '\0')
            return (0);
        return (0);
}

variable_types: n int


dsscasecmp

decompiled_code:
__int64 __fastcall dsscasecmp(__int64 a1, __int64 a2)
{
const __int32_t *v4; // rcx
__int64 v5; // rax
__int64 v6; // rdi
__int32_t v7; // esi

v4 = *_ctype_tolower_loc();
v5 = 0LL;
do
{
v6 = *(char *)(a1 + v5);
v7 = v4[*(char *)(a2 + v5)];
if ( v4[v6] != v7 )
return 2LL * (v4[v6] >= v7) - 1;
++v5;
}
while ( (_BYTE)v6 );
return 0LL;
}

original_code:
long
dsscasecmp(char *s1, char *s2)
{
    for (; tolower(*s1) == tolower(*s2); ++s1, ++s2)
        if (*s1 == '\0')
            return (0);
    return ((tolower(*s1) < tolower(*s2)) ? -1 : 1);
}


decompiled_code:
_QWORD *mk_ascdate()
{
_QWORD *v0; // rax
_QWORD *v1; // r12
__int64 i; // rbx
__int64 v4; // [rsp+0h] [rbp-58h] BYREF
char s[80]; // [rsp+8h] [rbp-50h] BYREF

v0 = malloc(0x4FE8uLL);
if ( !v0 )
{
fprintf(stderr, "Malloc failed at %s:%d\n", "bm_utils.c", 540LL);
exit(1);
}
v1 = v0;
for ( i = 0LL; i != 2557; v1[i - 1] = strdup(s) )
mk_time(++i, &v4);
return v1;
}

canonical_decompiled_code:
_QWORD *func11()
{
_QWORD *v0; // rax
_QWORD *v1; // r12
__int64 i; // rbx
__int64 v4; // [rsp+0h] [rbp-58h] BYREF
char s[80]; // [rsp+8h] [rbp-50h] BYREF

v0 = malloc(0x4FE8uLL);
if ( !v0 )
{
fprintf(stderr, "Malloc failed at %s:%d\n", "bm_utils.c", 540LL);
exit(1);
}
v1 = v0;
for ( i = 0LL; i != 2557; v1[i - 1] = strdup(s) )
mk_time(++i, &v4);
return v1;
}

original_code:
char **
mk_ascdate(void)
{
    char **m;
    dss_time_t t;
    long long int i;
    m = (char**) malloc((size_t)(2557 * sizeof (char *)));
    if ((m) == ((void *)0)) { fprintf(stderr, "Malloc failed at %s:%d\n", "bm_utils.c", 540); exit(1); };
    for (i = 0; i < 2557; i++)
        {
        mk_time(i + 1, &t);
        m[i] = strdup(t.alpha);
        }
    return(m);
}

canonical_original_code:
char **mk_ascdate()
{
    char **m;
    struct dss_time_t t;
    long long i;
    m = (char **) malloc((unsigned long)(2557 * sizeof (char *)));
    if ((m) == ((void *)0)) { fprintf(stderr, "Malloc failed at %s:%d\n", "bm_utils.c", 540); exit(1); };
    for (i = 0; i < 2557; i++)
        {
        mk_time(i + 1, &t);
        m[i] = strdup(t.alpha);
        }
    return(m);
}

variable_types:
m
char **

variable_types: struct dss_time_t { long long timekey; char alpha[13]; long year; long month; long week; long day; }

variable_types:
i
long long

return_type: char **


original_code:
long long int
set_state(int table, long sf, long procs, long step, long long int *extra_rows)
{
    int i;
 long long int rowcount, remainder, result;
    if (sf == 0 || step == 0)
        return(0);
 rowcount = tdefs[table].base;
 rowcount *= sf;
 *extra_rows = rowcount % procs;
 rowcount /= procs;
 result = rowcount;
 for (i=0; i < step - 1; i++)
  {
  if (table == 5)
   tdefs[table].gen_seed(1, rowcount);
  else
   tdefs[table].gen_seed(0, rowcount);
   if (tdefs[table].child != -1)
   tdefs[tdefs[table].child].gen_seed(0,rowcount);
  }
 if (step > procs)
  tdefs[table].gen_seed(0, *extra_rows);
 return(result);
}

canonical_original_code:
long long set_state(int table, long sf, long procs, long step, long long *extra_rows)
{
    int i;
 long long rowcount; long long remainder; long long result;
    if (sf == 0 || step == 0)
        return(0);
 rowcount = tdefs[table].base;
 rowcount *= sf;
 *extra_rows = rowcount % procs;
 rowcount /= procs;
 result = rowcount;
 for (i=0; i < step - 1; i++)
  {
  if (table == 5)
   tdefs[table].gen_seed(1, rowcount);
  else
   tdefs[table].gen_seed(0, rowcount);
   if (tdefs[table].child != -1)
   tdefs[tdefs[table].child].gen_seed(0,rowcount);
  }
 if (step > procs)
  tdefs[table].gen_seed(0, *extra_rows);
 return(result);
}

variable_types: table int

variable_types: sf long

variable_types: procs long

variable_types: step long

variable_types:
rowcount
long long

variable_types:
remainder
long long

variable_types:
result
long long

return_type: long long


decompiled_code:
__int64 __fastcall strip_comments(char *dest)
{
char *v1; // rax
char *v2; // rax
char *v3; // rax

if ( in_comment_2 )
goto LABEL_6;
while ( 1 )
{
v1 = strchr(dest, 45);
if ( v1 )
{
if ( v1[1] == 45 )
break;
}
v2 = strchr(dest, 123);
if ( !v2 )
return 0LL;
in_comment_2 = 1;
*v2 = 32;
LABEL_6:
v3 = strchr(dest, 125);
if ( !v3 )
{
*dest = 0;
return 0LL;
}
strcpy(dest, v3 + 1);
in_comment_2 = 0;
}
*v1 = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *dest)
{
char *v1; // rax
char *v2; // rax
char *v3; // rax

if ( in_comment_2 )
goto LABEL_6;
while ( 1 )
{
v1 = strchr(dest, 45);
if ( v1 )
{
if ( v1[1] == 45 )
break;
}
v2 = strchr(dest, 123);
if ( !v2 )
return 0LL;
in_comment_2 = 1;
*v2 = 32;
LABEL_6:
v3 = strchr(dest, 125);
if ( !v3 )
{
*dest = 0;
return 0LL;
}
strcpy(dest, v3 + 1);
in_comment_2 = 0;
}
*v1 = 0;
return 0LL;
}

original_code:
int
strip_comments(char *line)
{
    static int in_comment = 0;
    char *cp1, *cp2;
    cp1 = line;
    while (1)
        {
        if (in_comment)
            {
            if ((cp2 = strchr(cp1, '}')) != ((void *)0))
                {
                strcpy(cp1, cp2 + 1);
                in_comment = 0;
                continue;
                }
            else
                {
                *cp1 = '\0';
                break;
                }
            }
        else
            {
            if ((cp2 = strchr(cp1, '-')) != ((void *)0))
                {
                if (*(cp2 + 1) == '-')
                    {
                    *cp2 = '\0';
                    break;
                    }
                }
            if ((cp2 = strchr(cp1, '{')) != ((void *)0))
                {
                in_comment = 1;
                *cp2 = ' ';
                continue;
                }
            else break;
            }
        }
    return(0);
}

canonical_original_code:
int strip_comments(char *line)
{
    static int in_comment = 0;
    char *cp1; char *cp2;
    cp1 = line;
    while (1)
        {
        if (in_comment)
            {
            if ((cp2 = strchr(cp1, '}')) != ((void *)0))
                {
                strcpy(cp1, cp2 + 1);
                in_comment = 0;
                continue;
                }
            else
                {
                *cp1 = '\0';
                break;
                }
            }
        else
            {
            if ((cp2 = strchr(cp1, '-')) != ((void *)0))
                {
                if (*(cp2 + 1) == '-')
                    {
                    *cp2 = '\0';
                    break;
                    }
                }
            if ((cp2 = strchr(cp1, '{')) != ((void *)0))
                {
                in_comment = 1;
                *cp2 = ' ';
                continue;
                }
            else break;
            }
        }
    return(0);
}

variable_types:
line
char *


decompiled_code:
__int64 __fastcall process_options(int argc, char **argv)
{
int v2; // eax
char *v3; // r12
int v4; // eax
char *v5; // r12
int v6; // eax
char *v7; // r12
int v8; // eax
char *v9; // r12
int v10; // eax
char *v11; // r12
int v12; // eax
char *v13; // r12
int v14; // eax
__int64 v16; // rcx

while ( 1 )
{
v2 = getopt(argc, argv, "ab:cdhi:n:Nl:o:p:r:s:t:vx");
if ( v2 == -1 )
return 0LL;
switch ( v2 )
{
case 'N':
flags |= 0x4000u;
continue;
case 'a':
flags |= 0x200u;
continue;
case 'b':
v13 = optarg;
v14 = strlen(optarg);
d_path = (__int64)malloc(v14 + 1);
if ( !d_path )
{
v16 = 305LL;
goto LABEL_29;
}
strcpy((char *)d_path, v13);
continue;
case 'c':
flags |= 0x800u;
continue;
case 'd':
flags |= 1u;
continue;
case 'h':
usage();
exit(0);
case 'i':
v11 = optarg;
v12 = strlen(optarg);
ifile = (char *)malloc(v12 + 1);
if ( !ifile )
{
v16 = 320LL;
goto LABEL_29;
}
strcpy(ifile, v11);
flags |= 0x1000u;
break;
case 'l':
v9 = optarg;
v10 = strlen(optarg);
lfile = (__int64)malloc(v10 + 1);
if ( !lfile )
{
v16 = 326LL;
LABEL_29:
fprintf(stderr, "Malloc failed at %s:%d\n", "qgen.c", v16);
exit(1);
}
strcpy((char *)lfile, v9);
flags |= 0x40u;
break;
case 'n':
v7 = optarg;
v8 = strlen(optarg);
db_name = (__int64)malloc(v8 + 1);
if ( !db_name )
{
v16 = 335LL;
goto LABEL_29;
}
strcpy((char *)db_name, v7);
flags |= 8u;
continue;
case 'o':
v5 = optarg;
v6 = strlen(optarg);
osuff = (__int64)malloc(v6 + 1);
if ( !osuff )
{
v16 = 341LL;
goto LABEL_29;
}
strcpy((char *)osuff, v5);
flags |= 2u;
continue;
case 'p':
snum = atoi(optarg);
continue;
case 'r':
flags |= 0x400u;
rndm = atol(optarg);
continue;
case 's':
flt_scale = atof(optarg);
if ( (double)(int)scale > 100000.0 )
fprintf(
stderr,
"%s %5.0f %s\n%s\n",
"WARNING: Support for scale factors >",
*(double *)&LC36,
"GB is still in development.",
"Data set integrity is not guaranteed.\n");
continue;
case 't':
v3 = optarg;
v4 = strlen(optarg);
tfile = (char *)malloc(v4 + 1);
if ( !tfile )
{
v16 = 363LL;
goto LABEL_29;
}
strcpy(tfile, v3);
flags |= 0x2000u;
continue;
case 'v':
flags |= 0x10u;
continue;
case 'x':
flags |= 4u;
continue;
default:
printf("unknown option '%s' ignored\n", argv[optind]);
usage();
exit(1);
}
}
}

canonical_decompiled_code:
__int64 __fastcall func3(int argc, char **argv)
{
int v2; // eax
char *v3; // r12
int v4; // eax
char *v5; // r12
int v6; // eax
char *v7; // r12
int v8; // eax
char *v9; // r12
int v10; // eax
char *v11; // r12
int v12; // eax
char *v13; // r12
int v14; // eax
__int64 v16; // rcx

while ( 1 )
{
v2 = getopt(argc, argv, "ab:cdhi:n:Nl:o:p:r:s:t:vx");
if ( v2 == -1 )
return 0LL;
switch ( v2 )
{
case 'N':
flags |= 0x4000u;
continue;
case 'a':
flags |= 0x200u;
continue;
case 'b':
v13 = optarg;
v14 = strlen(optarg);
d_path = (__int64)malloc(v14 + 1);
if ( !d_path )
{
v16 = 305LL;
goto LABEL_29;
}
strcpy((char *)d_path, v13);
continue;
case 'c':
flags |= 0x800u;
continue;
case 'd':
flags |= 1u;
continue;
case 'h':
func2();
exit(0);
case 'i':
v11 = optarg;
v12 = strlen(optarg);
ifile = (char *)malloc(v12 + 1);
if ( !ifile )
{
v16 = 320LL;
goto LABEL_29;
}
strcpy(ifile, v11);
flags |= 0x1000u;
break;
case 'l':
v9 = optarg;
v10 = strlen(optarg);
lfile = (__int64)malloc(v10 + 1);
if ( !lfile )
{
v16 = 326LL;
LABEL_29:
fprintf(stderr, "Malloc failed at %s:%d\n", "qgen.c", v16);
exit(1);
}
strcpy((char *)lfile, v9);
flags |= 0x40u;
break;
case 'n':
v7 = optarg;
v8 = strlen(optarg);
db_name = (__int64)malloc(v8 + 1);
if ( !db_name )
{
v16 = 335LL;
goto LABEL_29;
}
strcpy((char *)db_name, v7);
flags |= 8u;
continue;
case 'o':
v5 = optarg;
v6 = strlen(optarg);
osuff = (__int64)malloc(v6 + 1);
if ( !osuff )
{
v16 = 341LL;
goto LABEL_29;
}
strcpy((char *)osuff, v5);
flags |= 2u;
continue;
case 'p':
snum = atoi(optarg);
continue;
case 'r':
flags |= 0x400u;
rndm = atol(optarg);
continue;
case 's':
flt_scale = atof(optarg);
if ( (double)(int)scale > 100000.0 )
fprintf(
stderr,
"%s %5.0f %s\n%s\n",
"WARNING: Support for scale factors >",
*(double *)&LC36,
"GB is still in development.",
"Data set integrity is not guaranteed.\n");
continue;
case 't':
v3 = optarg;
v4 = strlen(optarg);
tfile = (char *)malloc(v4 + 1);
if ( !tfile )
{
v16 = 363LL;
goto LABEL_29;
}
strcpy(tfile, v3);
flags |= 0x2000u;
continue;
case 'v':
flags |= 0x10u;
continue;
case 'x':
flags |= 4u;
continue;
default:
printf("unknown option '%s' ignored\n", argv[optind]);
func2();
exit(1);
}
}
}

original_code:
int
process_options(int cnt, char **args)
{
    int flag;
    while((flag = getopt(cnt, args, "ab:cdhi:n:Nl:o:p:r:s:t:vx")) != -1)
        switch(flag)
            {
            case 'a':
                flags |= 0x0200;
                break;
   case 'b':
    d_path = (char *)malloc((int)strlen(optarg) + 1);
    if ((d_path) == ((void *)0)) { fprintf(stderr, "Malloc failed at %s:%d\n", "qgen.c", 305); exit(1); };
    strcpy(d_path, optarg);
    break;
   case 'c':
                flags |= 0x0800;
                break;
            case 'd':
                flags |= 0x0001;
                break;
            case 'h':
                usage();
                exit(0);
                break;
            case 'i':
                ifile = malloc((int)strlen(optarg) + 1);
                if ((ifile) == ((void *)0)) { fprintf(stderr, "Malloc failed at %s:%d\n", "qgen.c", 320); exit(1); };
                strcpy(ifile, optarg);
                flags |= 0x1000;
                break;
            case 'l':
                lfile = malloc((int)strlen(optarg) + 1);
                if ((lfile) == ((void *)0)) { fprintf(stderr, "Malloc failed at %s:%d\n", "qgen.c", 326); exit(1); };
                strcpy(lfile, optarg);
                flags |= 0x0040;
                break;
            case 'N':
                flags |= 0x4000;
                break;
            case 'n':
                db_name = malloc((int)strlen(optarg) + 1);
                if ((db_name) == ((void *)0)) { fprintf(stderr, "Malloc failed at %s:%d\n", "qgen.c", 335); exit(1); };
                strcpy(db_name, optarg);
                flags |= 0x0008;
                break;
            case 'o':
                osuff = malloc((int)strlen(optarg) + 1);
                if ((osuff) == ((void *)0)) { fprintf(stderr, "Malloc failed at %s:%d\n", "qgen.c", 341); exit(1); };
                strcpy(osuff, optarg);
                flags |=0x0002;
                break;
            case 'p':
                snum = atoi(optarg);
                break;
            case 'r':
                flags |= 0x0400;
                rndm = atol(optarg);
                break;
            case 's':
                flt_scale = atof(optarg);
    if (scale > 100000.0)
     fprintf(stderr, "%s %5.0f %s\n%s\n",
      "WARNING: Support for scale factors >",
      100000.0,
      "GB is still in development.",
      "Data set integrity is not guaranteed.\n");
                break;
            case 't':
                tfile = malloc((int)strlen(optarg) + 1);
                if ((tfile) == ((void *)0)) { fprintf(stderr, "Malloc failed at %s:%d\n", "qgen.c", 363); exit(1); };
                strcpy(tfile, optarg);
                flags |= 0x2000;
                break;
            case 'v':
                flags |= 0x0010;
                break;
            case 'x':
                flags |= 0x0004;
                break;
            default:
                printf("unknown option '%s' ignored\n", args[optind]);
                usage();
                exit(1);
                break;
            }
    return(0);
}

variable_types: cnt int

variable_types:
args
char **

variable_types: flag int


setup

decompiled_code:
__int64 setup()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax

asc_date = mk_ascdate();
v0 = env_config("DSS_DIST", "dists.dss");
read_dist(v0, "p_cntr", &p_cntr_set);
v1 = env_config("DSS_DIST", "dists.dss");
read_dist(v1, "colors", &colors);
v2 = env_config("DSS_DIST", "dists.dss");
read_dist(v2, "p_types", &p_types_set);
v3 = env_config("DSS_DIST", "dists.dss");
read_dist(v3, "nations", &nations);
v4 = env_config("DSS_DIST", "dists.dss");
read_dist(v4, "nations2", &nations2);
v5 = env_config("DSS_DIST", "dists.dss");
read_dist(v5, "regions", &regions);
v6 = env_config("DSS_DIST", "dists.dss");
read_dist(v6, "o_oprio", &o_priority_set);
v7 = env_config("DSS_DIST", "dists.dss");
read_dist(v7, "instruct", &l_instruct_set);
v8 = env_config("DSS_DIST", "dists.dss");
read_dist(v8, "smode", &l_smode_set);
v9 = env_config("DSS_DIST", "dists.dss");
read_dist(v9, "category", &l_category_set);
v10 = env_config("DSS_DIST", "dists.dss");
read_dist(v10, "rflag", &l_rflag_set);
v11 = env_config("DSS_DIST", "dists.dss");
read_dist(v11, "msegmnt", &c_mseg_set);
v12 = env_config("DSS_DIST", "dists.dss");
read_dist(v12, "Q13a", &q13a);
v13 = env_config("DSS_DIST", "dists.dss");
read_dist(v13, "Q13b", &q13b);
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax

asc_date = mk_ascdate();
v0 = env_config("DSS_DIST", "dists.dss");
read_dist(v0, "p_cntr", &p_cntr_set);
v1 = env_config("DSS_DIST", "dists.dss");
read_dist(v1, "colors", &colors);
v2 = env_config("DSS_DIST", "dists.dss");
read_dist(v2, "p_types", &p_types_set);
v3 = env_config("DSS_DIST", "dists.dss");
read_dist(v3, "nations", &nations);
v4 = env_config("DSS_DIST", "dists.dss");
read_dist(v4, "nations2", &nations2);
v5 = env_config("DSS_DIST", "dists.dss");
read_dist(v5, "regions", &regions);
v6 = env_config("DSS_DIST", "dists.dss");
read_dist(v6, "o_oprio", &o_priority_set);
v7 = env_config("DSS_DIST", "dists.dss");
read_dist(v7, "instruct", &l_instruct_set);
v8 = env_config("DSS_DIST", "dists.dss");
read_dist(v8, "smode", &l_smode_set);
v9 = env_config("DSS_DIST", "dists.dss");
read_dist(v9, "category", &l_category_set);
v10 = env_config("DSS_DIST", "dists.dss");
read_dist(v10, "rflag", &l_rflag_set);
v11 = env_config("DSS_DIST", "dists.dss");
read_dist(v11, "msegmnt", &c_mseg_set);
v12 = env_config("DSS_DIST", "dists.dss");
read_dist(v12, "Q13a", &q13a);
v13 = env_config("DSS_DIST", "dists.dss");
read_dist(v13, "Q13b", &q13b);
return 0LL;
}

original_code:
int
setup(void)
{
    asc_date = mk_ascdate();
    read_dist(env_config("DSS_DIST", "dists.dss"), "p_cntr", &p_cntr_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "colors", &colors);
    read_dist(env_config("DSS_DIST", "dists.dss"), "p_types", &p_types_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "nations", &nations);
    read_dist(env_config("DSS_DIST", "dists.dss"), "nations2", &nations2);
    read_dist(env_config("DSS_DIST", "dists.dss"), "regions", &regions);
    read_dist(env_config("DSS_DIST", "dists.dss"), "o_oprio",
        &o_priority_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "instruct",
        &l_instruct_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "smode", &l_smode_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "category",
        &l_category_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "rflag", &l_rflag_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "msegmnt", &c_mseg_set);
 read_dist(env_config("DSS_DIST", "dists.dss"), "Q13a", &q13a);
 read_dist(env_config("DSS_DIST", "dists.dss"), "Q13b", &q13b);
    return(0);
}

canonical_original_code:
int setup()
{
    asc_date = mk_ascdate();
    read_dist(env_config("DSS_DIST", "dists.dss"), "p_cntr", &p_cntr_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "colors", &colors);
    read_dist(env_config("DSS_DIST", "dists.dss"), "p_types", &p_types_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "nations", &nations);
    read_dist(env_config("DSS_DIST", "dists.dss"), "nations2", &nations2);
    read_dist(env_config("DSS_DIST", "dists.dss"), "regions", &regions);
    read_dist(env_config("DSS_DIST", "dists.dss"), "o_oprio",
        &o_priority_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "instruct",
        &l_instruct_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "smode", &l_smode_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "category",
        &l_category_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "rflag", &l_rflag_set);
    read_dist(env_config("DSS_DIST", "dists.dss"), "msegmnt", &c_mseg_set);
 read_dist(env_config("DSS_DIST", "dists.dss"), "Q13a", &q13a);
 read_dist(env_config("DSS_DIST", "dists.dss"), "Q13b", &q13b);
    return(0);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v4; // rax
__int64 v5; // rdi
unsigned __int64 v6; // r12
__int64 v7; // rax
const char **v8; // r12
const char **v9; // rbp
const char *v10; // rdi
int v11; // eax
char **v13; // r12
const char **v14; // rbx
char *v15; // rdi
FILE *v16; // r13
FILE *v17; // rbx
int j; // ebp
__int64 v19; // rcx
unsigned int i; // ebp
const char *v21; // rdx
__int64 v22; // r8
char s[10]; // [rsp+6h] [rbp-232h] BYREF
char v24[552]; // [rsp+10h] [rbp-228h] BYREF

v4 = *argv;
flags = 0;
d_path = 0LL;
prog = (__int64)v4;
flt_scale = LC59;
process_options(argc, (char **)argv);
if ( (flags & 0x10) != 0 )
fprintf(stdout, "-- TPC %s Parameter Substitution (Version %d.%d.%d build %d)\n", "TPC-H", 2LL, 14LL, 0LL, 0LL);
setup();
if ( (flags & 1) != 0 )
{
puts("-- using default substitutions");
}
else
{
if ( (flags & 0x400) != 0 )
{
v5 = rndm;
if ( rndm < 0 )
{
v5 = rndm + 0x7FFFFFFF;
rndm += 0x7FFFFFFFLL;
}
}
else
{
v5 = (unsigned int)time(0LL);
rndm = v5;
}
Seed[1] = v5;
v6 = (unsigned int)((_DWORD)Seed + 48);
do
{
v7 = NextRand();
v6 += 40LL;
Seed[1] = v7;
*(_QWORD *)(v6 - 40) = v7;
}
while ( (_QWORD *)v6 != &Seed[116] );
printf("-- using %ld as a seed to the RNG\n", rndm);
}
if ( (flags & 0x1000) != 0 )
{
v16 = fopen64(ifile, "r");
if ( !v16 )
{
v21 = ifile;
v22 = 446LL;
goto LABEL_39;
}
while ( fgets(v24, 512, v16) )
fputs(v24, stdout);
}
if ( snum < 0 )
{
if ( argc <= optind )
{
for ( i = 1; i != 23; ++i )
{
sprintf(s, "%d", i);
printf("\n\n-- QUERY%d", i);
qsub(s, flags);
}
}
else
{
v13 = (char **)&argv[optind];
v14 = &(&argv[optind])[(unsigned __int64)(unsigned int)(argc + ~optind) + 1];
do
{
v15 = *v13++;
qsub(v15, flags);
}
while ( v13 != (char **)v14 );
}
}
else if ( argc <= optind )
{
for ( j = 0; j != 22; ++j )
{
v19 = j;
sprintf(s, "%d", permutation[22 * (snum % 41) + v19]);
qsub(s, flags);
}
}
else
{
v8 = &argv[optind];
v9 = &(&argv[optind])[(unsigned __int64)(unsigned int)(argc + ~optind) + 1];
do
{
v10 = *v8++;
v11 = atoi(v10);
sprintf(s, "%d", permutation[22 * (snum % 41) - 1 + v11]);
qsub(s, flags);
}
while ( v9 != v8 );
}
if ( (flags & 0x2000) != 0 )
{
v17 = fopen64(tfile, "r");
if ( v17 )
{
while ( fgets(v24, 512, v17) )
fputs(v24, stdout);
return 0;
}
v21 = tfile;
v22 = 483LL;
LABEL_39:
fprintf(stderr, "Open failed for %s at %s:%d\n", v21, "qgen.c", v22);
exit(1);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v4; // rax
__int64 v5; // rdi
unsigned __int64 v6; // r12
__int64 v7; // rax
const char **v8; // r12
const char **v9; // rbp
const char *v10; // rdi
int v11; // eax
char **v13; // r12
const char **v14; // rbx
char *v15; // rdi
FILE *v16; // r13
FILE *v17; // rbx
int j; // ebp
__int64 v19; // rcx
unsigned int i; // ebp
const char *v21; // rdx
__int64 v22; // r8
char s[10]; // [rsp+6h] [rbp-232h] BYREF
char v24[552]; // [rsp+10h] [rbp-228h] BYREF

v4 = *argv;
flags = 0;
d_path = 0LL;
prog = (__int64)v4;
flt_scale = LC59;
func3(argc, (char **)argv);
if ( (flags & 0x10) != 0 )
fprintf(stdout, "-- TPC %s Parameter Substitution (Version %d.%d.%d build %d)\n", "TPC-H", 2LL, 14LL, 0LL, 0LL);
func4();
if ( (flags & 1) != 0 )
{
puts("-- using default substitutions");
}
else
{
if ( (flags & 0x400) != 0 )
{
v5 = rndm;
if ( rndm < 0 )
{
v5 = rndm + 0x7FFFFFFF;
rndm += 0x7FFFFFFFLL;
}
}
else
{
v5 = (unsigned int)time(0LL);
rndm = v5;
}
Seed[1] = v5;
v6 = (unsigned int)((_DWORD)Seed + 48);
do
{
v7 = NextRand();
v6 += 40LL;
Seed[1] = v7;
*(_QWORD *)(v6 - 40) = v7;
}
while ( (_QWORD *)v6 != &Seed[116] );
printf("-- using %ld as a seed to the RNG\n", rndm);
}
if ( (flags & 0x1000) != 0 )
{
v16 = fopen64(ifile, "r");
if ( !v16 )
{
v21 = ifile;
v22 = 446LL;
goto LABEL_39;
}
while ( fgets(v24, 512, v16) )
fputs(v24, stdout);
}
if ( snum < 0 )
{
if ( argc <= optind )
{
for ( i = 1; i != 23; ++i )
{
sprintf(s, "%d", i);
printf("\n\n-- QUERY%d", i);
func1(s, flags);
}
}
else
{
v13 = (char **)&argv[optind];
v14 = &(&argv[optind])[(unsigned __int64)(unsigned int)(argc + ~optind) + 1];
do
{
v15 = *v13++;
func1(v15, flags);
}
while ( v13 != (char **)v14 );
}
}
else if ( argc <= optind )
{
for ( j = 0; j != 22; ++j )
{
v19 = j;
sprintf(s, "%d", permutation[22 * (snum % 41) + v19]);
func1(s, flags);
}
}
else
{
v8 = &argv[optind];
v9 = &(&argv[optind])[(unsigned __int64)(unsigned int)(argc + ~optind) + 1];
do
{
v10 = *v8++;
v11 = atoi(v10);
sprintf(s, "%d", permutation[22 * (snum % 41) - 1 + v11]);
func1(s, flags);
}
while ( v9 != v8 );
}
if ( (flags & 0x2000) != 0 )
{
v17 = fopen64(tfile, "r");
if ( v17 )
{
while ( fgets(v24, 512, v17) )
fputs(v24, stdout);
return 0;
}
v21 = tfile;
v22 = 483LL;
LABEL_39:
fprintf(stderr, "Open failed for %s at %s:%d\n", v21, "qgen.c", v22);
exit(1);
}
return 0;
}

original_code:
int
main (int ac, char **av)
{
 long long int i;
 table = (1 << 3) |
  (1 << 2) |
  (1 << 8) |
  (1 << 9) |
  (1 << 7) |
  (1 << 6);
 force = 0;
    insert_segments=0;
    delete_segments=0;
    insert_orders_segment=0;
    insert_lineitem_segment=0;
    delete_segment=0;
 verbose = 0;
 set_seeds = 0;
 scale = 1;
 flt_scale = 1.0;
 updates = 0;
 step = -1;
 tdefs[4].base *=
  10;
 tdefs[5].base *=
  10;
 tdefs[6].base *=
  10;
 children = 1;
 d_path = ((void *)0);
 process_options (ac, av);
 validate_options();
 if (verbose >= 0)
  {
  fprintf (stderr,
   "%s Population Generator (Version %d.%d.%d)\n",
   "TPC-H", 2, 14, 0);
  fprintf (stderr, "Copyright %s %s\n", "Transaction Processing Performance Council", "1994 - 2010");
  }
 load_dists ();
 for (i=0; i <= 47; i++)
  Seed[i].nCalls = 0;
 tdefs[8].base = nations.count;
 tdefs[9].base = regions.count;
 if (updates)
  {
  set_state (4, scale, 100, 101, &i);
  rowcnt = (int)(tdefs[6].base / 10000 * scale * 10);
  if (step > 0)
   {
       for (i=1; i < step; i++)
         {
   sd_order(0, rowcnt);
   sd_line(0, rowcnt);
         }
   upd_num = step - 1;
   }
  else
   upd_num = 0;
  while (upd_num < updates)
   {
   if (verbose > 0)
    fprintf (stderr,
    "Generating update pair #%d for %s",
    upd_num + 1, tdefs[6].comment);
   insert_orders_segment=0;
   insert_lineitem_segment=0;
   delete_segment=0;
   minrow = upd_num * rowcnt + 1;
   gen_tbl (6, minrow, rowcnt, upd_num + 1);
   if (verbose > 0)
    fprintf (stderr, "done.\n");
   pr_drange (6, minrow, rowcnt, upd_num + 1);
   upd_num++;
   }
  exit (0);
  }
 for (i = 0; i <= 9; i++)
  if (table & (1 << i))
  {
   if (children > 1 && i < 8)
   {
    partial ((int)i, step);
   }
   else
   {
    minrow = 1;
    if (i < 8)
     rowcnt = tdefs[i].base * scale;
    else
     rowcnt = tdefs[i].base;
    if (verbose > 0)
     fprintf (stderr, "Generating data for %s", tdefs[i].comment);
    gen_tbl ((int)i, minrow, rowcnt, upd_num);
    if (verbose > 0)
     fprintf (stderr, "done.\n");
   }
  }
  return (0);
}

canonical_original_code:
int main(int ac, char **av)
{
 long long i;
 table = (1 << 3) |
  (1 << 2) |
  (1 << 8) |
  (1 << 9) |
  (1 << 7) |
  (1 << 6);
 force = 0;
    insert_segments=0;
    delete_segments=0;
    insert_orders_segment=0;
    insert_lineitem_segment=0;
    delete_segment=0;
 verbose = 0;
 set_seeds = 0;
 scale = 1;
 flt_scale = 1.0;
 updates = 0;
 step = -1;
 tdefs[4].base *=
  10;
 tdefs[5].base *=
  10;
 tdefs[6].base *=
  10;
 children = 1;
 d_path = ((void *)0);
 process_options (ac, av);
 validate_options();
 if (verbose >= 0)
  {
  fprintf (stderr,
   "%s Population Generator (Version %d.%d.%d)\n",
   "TPC-H", 2, 14, 0);
  fprintf (stderr, "Copyright %s %s\n", "Transaction Processing Performance Council", "1994 - 2010");
  }
 load_dists ();
 for (i=0; i <= 47; i++)
  Seed[i].nCalls = 0;
 tdefs[8].base = nations.count;
 tdefs[9].base = regions.count;
 if (updates)
  {
  set_state (4, scale, 100, 101, &i);
  rowcnt = (int)(tdefs[6].base / 10000 * scale * 10);
  if (step > 0)
   {
       for (i=1; i < step; i++)
         {
   sd_order(0, rowcnt);
   sd_line(0, rowcnt);
         }
   upd_num = step - 1;
   }
  else
   upd_num = 0;
  while (upd_num < updates)
   {
   if (verbose > 0)
    fprintf (stderr,
    "Generating update pair #%d for %s",
    upd_num + 1, tdefs[6].comment);
   insert_orders_segment=0;
   insert_lineitem_segment=0;
   delete_segment=0;
   minrow = upd_num * rowcnt + 1;
   gen_tbl (6, minrow, rowcnt, upd_num + 1);
   if (verbose > 0)
    fprintf (stderr, "done.\n");
   pr_drange (6, minrow, rowcnt, upd_num + 1);
   upd_num++;
   }
  exit (0);
  }
 for (i = 0; i <= 9; i++)
  if (table & (1 << i))
  {
   if (children > 1 && i < 8)
   {
    partial ((int)i, step);
   }
   else
   {
    minrow = 1;
    if (i < 8)
     rowcnt = tdefs[i].base * scale;
    else
     rowcnt = tdefs[i].base;
    if (verbose > 0)
     fprintf (stderr, "Generating data for %s", tdefs[i].comment);
    gen_tbl ((int)i, minrow, rowcnt, upd_num);
    if (verbose > 0)
     fprintf (stderr, "done.\n");
   }
  }
  return (0);
}

variable_types: ac int

variable_types:
av
char **


original_code:
int
bin_bcd2(long binary, long *low_res, long *high_res)
{
    char number[15],
         *current;
    int count;
    long *dest;
 *low_res = *high_res = 0;
    sprintf(number, "%014ld", binary);
    for (current = number, count=13; *current; current++, count--)
        {
        dest = (count < 7)?low_res:high_res;
        *dest = *dest << 4;
        *dest |= *current - '0';
        }
    return(0);
}

canonical_original_code:
int bin_bcd2(long binary, long *low_res, long *high_res)
{
    char number[15]; char *current;
    int count;
    long *dest;
 *low_res = *high_res = 0;
    sprintf(number, "%014ld", binary);
    for (current = number, count=13; *current; current++, count--)
        {
        dest = (count < 7)?low_res:high_res;
        *dest = *dest << 4;
        *dest |= *current - '0';
        }
    return(0);
}

variable_types: binary long

variable_types:
number
char [15]

variable_types:
current
char *

variable_types: count int

variable_types:
dest
long *


original_code:
int
bcd2_bin(long *dest, long bcd)
{
    int count;
    long mask;
    count = 7 - 1;
    mask = 0xF000000;
 *dest = 0;
    while (mask)
        {
        *dest *= 10;
        *dest += (bcd & mask) >> (4 * count);
        mask = mask >> 4;
        count -= 1;
        }
    return(0);
}

variable_types: bcd long

variable_types: mask long


original_code:
int
bcd2_add(long *bcd_low, long *bcd_high, long addend)
{
    long tmp_lo, tmp_hi, carry, res;
    int digit;
    bin_bcd2(addend, &tmp_lo, &tmp_hi);
    carry = 0;
    for (digit=0; digit < 14; digit++)
        {
        res = ((digit) >= 7)? (*bcd_high & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (*bcd_low & (0xF << (4 * (digit)))) >> ((digit) * 4);
        res += ((digit) >= 7)? (tmp_hi & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (tmp_lo & (0xF << (4 * (digit)))) >> ((digit) * 4);
        res += carry;
        carry = res / 10;
        res %= 10;
        if ((digit) >= 7) { *bcd_high &= (0xFFFFFFF ^ (0xF << (4 * ((digit) - 7)))); *bcd_high |= (res << (4 * ((digit) - 7))); } else { *bcd_low = (*bcd_low & (0xFFFFFFF ^ (0xF << (4 * (digit))))); *bcd_low |= (res << (4 * (digit))); };
        }
    return(carry);
}

canonical_original_code:
int bcd2_add(long *bcd_low, long *bcd_high, long addend)
{
    long tmp_lo; long tmp_hi; long carry; long res;
    int digit;
    bin_bcd2(addend, &tmp_lo, &tmp_hi);
    carry = 0;
    for (digit=0; digit < 14; digit++)
        {
        res = ((digit) >= 7)? (*bcd_high & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (*bcd_low & (0xF << (4 * (digit)))) >> ((digit) * 4);
        res += ((digit) >= 7)? (tmp_hi & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (tmp_lo & (0xF << (4 * (digit)))) >> ((digit) * 4);
        res += carry;
        carry = res / 10;
        res %= 10;
        if ((digit) >= 7) { *bcd_high &= (0xFFFFFFF ^ (0xF << (4 * ((digit) - 7)))); *bcd_high |= (res << (4 * ((digit) - 7))); } else { *bcd_low = (*bcd_low & (0xFFFFFFF ^ (0xF << (4 * (digit))))); *bcd_low |= (res << (4 * (digit))); };
        }
    return(carry);
}

variable_types: addend long

variable_types: carry long

variable_types: res long

variable_types: digit int


original_code:
int
bcd2_sub(long *bcd_low, long *bcd_high, long subend)
{
    long tmp_lo, tmp_hi, carry, res;
    int digit;
    bin_bcd2(subend, &tmp_lo, &tmp_hi);
    carry = 0;
    for (digit=0; digit < 14; digit++)
        {
        res = ((digit) >= 7)? (*bcd_high & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (*bcd_low & (0xF << (4 * (digit)))) >> ((digit) * 4);
        res -= ((digit) >= 7)? (tmp_hi & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (tmp_lo & (0xF << (4 * (digit)))) >> ((digit) * 4);
        res -= carry;
        if (res < 0)
   {
   res += 10;
   carry = 1;
   }
        if ((digit) >= 7) { *bcd_high &= (0xFFFFFFF ^ (0xF << (4 * ((digit) - 7)))); *bcd_high |= (res << (4 * ((digit) - 7))); } else { *bcd_low = (*bcd_low & (0xFFFFFFF ^ (0xF << (4 * (digit))))); *bcd_low |= (res << (4 * (digit))); };
        }
    return(carry);
}

canonical_original_code:
int bcd2_sub(long *bcd_low, long *bcd_high, long subend)
{
    long tmp_lo; long tmp_hi; long carry; long res;
    int digit;
    bin_bcd2(subend, &tmp_lo, &tmp_hi);
    carry = 0;
    for (digit=0; digit < 14; digit++)
        {
        res = ((digit) >= 7)? (*bcd_high & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (*bcd_low & (0xF << (4 * (digit)))) >> ((digit) * 4);
        res -= ((digit) >= 7)? (tmp_hi & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (tmp_lo & (0xF << (4 * (digit)))) >> ((digit) * 4);
        res -= carry;
        if (res < 0)
   {
   res += 10;
   carry = 1;
   }
        if ((digit) >= 7) { *bcd_high &= (0xFFFFFFF ^ (0xF << (4 * ((digit) - 7)))); *bcd_high |= (res << (4 * ((digit) - 7))); } else { *bcd_low = (*bcd_low & (0xFFFFFFF ^ (0xF << (4 * (digit))))); *bcd_low |= (res << (4 * (digit))); };
        }
    return(carry);
}

variable_types: subend long


original_code:
int
bcd2_mul(long *bcd_low, long *bcd_high, long multiplier)
{
    long tmp_lo, tmp_hi, carry, m_lo, m_hi, m1, m2;
    int udigit, ldigit, res;
    tmp_lo = *bcd_low;
    tmp_hi = *bcd_high;
    bin_bcd2(multiplier, &m_lo, &m_hi);
    *bcd_low = 0;
    *bcd_high = 0;
    carry = 0;
    for (ldigit=0; ldigit < 14; ldigit++)
        {
        m1 = ((ldigit) >= 7)? (m_hi & (0xF << (4 * ((ldigit) - 7)))) >> (((ldigit) - 7) * 4): (m_lo & (0xF << (4 * (ldigit)))) >> ((ldigit) * 4);
        carry = 0;
        for (udigit=0; udigit < 14; udigit++)
            {
            m2 = ((udigit) >= 7)? (tmp_hi & (0xF << (4 * ((udigit) - 7)))) >> (((udigit) - 7) * 4): (tmp_lo & (0xF << (4 * (udigit)))) >> ((udigit) * 4);
            res = m1 * m2;
            res += carry;
            if (udigit + ldigit < 14)
                {
                carry = ((udigit + ldigit) >= 7)? (*bcd_high & (0xF << (4 * ((udigit + ldigit) - 7)))) >> (((udigit + ldigit) - 7) * 4): (*bcd_low & (0xF << (4 * (udigit + ldigit)))) >> ((udigit + ldigit) * 4);
                res += carry;
                }
            carry = res / 10;
            res %= 10;
            if (udigit + ldigit < 14)
                if ((udigit + ldigit) >= 7) { *bcd_high &= (0xFFFFFFF ^ (0xF << (4 * ((udigit + ldigit) - 7)))); *bcd_high |= (res << (4 * ((udigit + ldigit) - 7))); } else { *bcd_low = (*bcd_low & (0xFFFFFFF ^ (0xF << (4 * (udigit + ldigit))))); *bcd_low |= (res << (4 * (udigit + ldigit))); };
            }
        }
    return(carry);
}

canonical_original_code:
int bcd2_mul(long *bcd_low, long *bcd_high, long multiplier)
{
    long tmp_lo; long tmp_hi; long carry; long m_lo; long m_hi; long m1; long m2;
    int udigit; int ldigit; int res;
    tmp_lo = *bcd_low;
    tmp_hi = *bcd_high;
    bin_bcd2(multiplier, &m_lo, &m_hi);
    *bcd_low = 0;
    *bcd_high = 0;
    carry = 0;
    for (ldigit=0; ldigit < 14; ldigit++)
        {
        m1 = ((ldigit) >= 7)? (m_hi & (0xF << (4 * ((ldigit) - 7)))) >> (((ldigit) - 7) * 4): (m_lo & (0xF << (4 * (ldigit)))) >> ((ldigit) * 4);
        carry = 0;
        for (udigit=0; udigit < 14; udigit++)
            {
            m2 = ((udigit) >= 7)? (tmp_hi & (0xF << (4 * ((udigit) - 7)))) >> (((udigit) - 7) * 4): (tmp_lo & (0xF << (4 * (udigit)))) >> ((udigit) * 4);
            res = m1 * m2;
            res += carry;
            if (udigit + ldigit < 14)
                {
                carry = ((udigit + ldigit) >= 7)? (*bcd_high & (0xF << (4 * ((udigit + ldigit) - 7)))) >> (((udigit + ldigit) - 7) * 4): (*bcd_low & (0xF << (4 * (udigit + ldigit)))) >> ((udigit + ldigit) * 4);
                res += carry;
                }
            carry = res / 10;
            res %= 10;
            if (udigit + ldigit < 14)
                if ((udigit + ldigit) >= 7) { *bcd_high &= (0xFFFFFFF ^ (0xF << (4 * ((udigit + ldigit) - 7)))); *bcd_high |= (res << (4 * ((udigit + ldigit) - 7))); } else { *bcd_low = (*bcd_low & (0xFFFFFFF ^ (0xF << (4 * (udigit + ldigit))))); *bcd_low |= (res << (4 * (udigit + ldigit))); };
            }
        }
    return(carry);
}

variable_types: multiplier long

variable_types: udigit int

variable_types: ldigit int

variable_types: res int


original_code:
int
bcd2_div(long *bcd_low, long *bcd_high, long divisor)
{
    long tmp_lo, tmp_hi, carry, d1, res, digit;
    carry = 0;
    tmp_lo = *bcd_low;
    tmp_hi = *bcd_high;
    *bcd_low = *bcd_high = 0;
    for (digit=13; digit >= 0; digit--)
        {
        d1 = ((digit) >= 7)? (tmp_hi & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (tmp_lo & (0xF << (4 * (digit)))) >> ((digit) * 4);
        d1 += 10 * carry;
        res = d1 / divisor;
        carry = d1 % divisor;
        if ((digit) >= 7) { *bcd_high &= (0xFFFFFFF ^ (0xF << (4 * ((digit) - 7)))); *bcd_high |= (res << (4 * ((digit) - 7))); } else { *bcd_low = (*bcd_low & (0xFFFFFFF ^ (0xF << (4 * (digit))))); *bcd_low |= (res << (4 * (digit))); };
        }
    return(carry);
}

canonical_original_code:
int bcd2_div(long *bcd_low, long *bcd_high, long divisor)
{
    long tmp_lo; long tmp_hi; long carry; long d1; long res; long digit;
    carry = 0;
    tmp_lo = *bcd_low;
    tmp_hi = *bcd_high;
    *bcd_low = *bcd_high = 0;
    for (digit=13; digit >= 0; digit--)
        {
        d1 = ((digit) >= 7)? (tmp_hi & (0xF << (4 * ((digit) - 7)))) >> (((digit) - 7) * 4): (tmp_lo & (0xF << (4 * (digit)))) >> ((digit) * 4);
        d1 += 10 * carry;
        res = d1 / divisor;
        carry = d1 % divisor;
        if ((digit) >= 7) { *bcd_high &= (0xFFFFFFF ^ (0xF << (4 * ((digit) - 7)))); *bcd_high |= (res << (4 * ((digit) - 7))); } else { *bcd_low = (*bcd_low & (0xFFFFFFF ^ (0xF << (4 * (digit))))); *bcd_low |= (res << (4 * (digit))); };
        }
    return(carry);
}

variable_types: divisor long

variable_types: digit long


decompiled_code:
__int64 __fastcall bcd2_mod(__int64 *a1, __int64 *a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // [rsp+0h] [rbp-18h] BYREF
__int64 v7; // [rsp+8h] [rbp-10h] BYREF

result = *a1;
v5 = *a2;
v6 = *a1;
v7 = v5;
if ( !v5 )
goto LABEL_3;
do
{
do
{
bcd2_sub(&v6, &v7, a3);
result = v6;
}
while ( v7 );
LABEL_3:
;
}
while ( result > a3 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1, __int64 *a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // [rsp+0h] [rbp-18h] BYREF
__int64 v7; // [rsp+8h] [rbp-10h] BYREF

result = *a1;
v5 = *a2;
v6 = *a1;
v7 = v5;
if ( !v5 )
goto LABEL_3;
do
{
do
{
func3(&v6, &v7, a3);
result = v6;
}
while ( v7 );
LABEL_3:
;
}
while ( result > a3 );
return result;
}

original_code:
long
bcd2_mod(long *bcd_low, long *bcd_high, long modulo)
{
 long tmp_low, tmp_high;
 tmp_low = *bcd_low;
 tmp_high = *bcd_high;
 while (tmp_high || tmp_low > modulo)
  bcd2_sub(&tmp_low, &tmp_high, modulo);
 return(tmp_low);
}

canonical_original_code:
long bcd2_mod(long *bcd_low, long *bcd_high, long modulo)
{
 long tmp_low; long tmp_high;
 tmp_low = *bcd_low;
 tmp_high = *bcd_high;
 while (tmp_high || tmp_low > modulo)
  bcd2_sub(&tmp_low, &tmp_high, modulo);
 return(tmp_low);
}

variable_types: modulo long


decompiled_code:
__int64 __fastcall bcd2_cmp(__int64 a1, __int64 *a2)
{
__int64 v2; // rsi
__int64 *v3; // r10
__int64 result; // rax
__int64 v5; // r9
__int64 v6; // [rsp+8h] [rbp-8h] BYREF

v2 = *a2;
v6 = 0LL;
bcd2_bin(&v6, v2);
result = 1LL;
if ( v6 <= 214 )
{
bcd2_bin(&v6, *v3);
result = v6 - v5;
}
return result;
}

original_code:
long
bcd2_cmp(long *low1, long *high1, long comp)
{
 long temp = 0;
    bcd2_bin(&temp, *high1);
 if (temp > 214)
  return(1);
    bcd2_bin(&temp, *low1);
 return(temp - comp);
}

variable_types: comp long

variable_types: temp long


decompiled_code:
__int64 close_direct()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
int
close_direct(void)
{
    return(0);
}

canonical_original_code:
int close_direct()
{
    return(0);
}


decompiled_code:
// attributes: thunk
__int64 prep_direct()
{
return close_direct();
}

canonical_decompiled_code:
__int64 func1()
{
return func0();
}

original_code:
int
prep_direct(void)
{
    return(0);
}

canonical_original_code:
int prep_direct()
{
    return(0);
}


decompiled_code:
__int64 ld_cust()
{
if ( !count_14++ )
printf("%s %s\n", "No load routine has been defined", "for the customer table");
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
if ( !count_14++ )
printf("%s %s\n", "No load routine has been defined", "for the customer table");
return 0LL;
}

original_code:
int
ld_cust (customer_t *cp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the customer table");
    return(0);
}

canonical_original_code:
int ld_cust(struct customer_t *cp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the customer table");
    return(0);
}

variable_types: struct customer_t { long long custkey; char name[-1]; char address[-1]; int alen; long long nation_code; char phone[-1]; long long acctbal; char mktsegment[-1]; char comment[-1]; int clen; } *

variable_types: mode int

variable_types: count int


decompiled_code:
__int64 ld_part()
{
if ( !count_12++ )
puts("No load routine has been defined for the part table");
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
if ( !count_12++ )
puts("No load routine has been defined for the part table");
return 0LL;
}

original_code:
int
ld_part (part_t *pp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("No load routine has been defined for the part table\n");
    return(0);
}

canonical_original_code:
int ld_part(struct part_t *pp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("No load routine has been defined for the part table\n");
    return(0);
}

variable_types: struct part_t { long long partkey; char name[-1]; int nlen; char mfgr[-1]; char brand[-1]; char type[-1]; int tlen; long long size; char container[-1]; long long retailprice; char comment[-1]; int clen; struct partsupp_t { long long partkey; long long suppkey; long long qty; long long scost; char comment[-1]; int clen; } s[4]; } *

user_defined_types: struct part_t { long long partkey; char name[-1]; int nlen; char mfgr[-1]; char brand[-1]; char type[-1]; int tlen; long long size; char container[-1]; long long retailprice; char comment[-1]; int clen; struct partsupp_t s[4]; }


decompiled_code:
__int64 ld_psupp()
{
if ( !count_11++ )
printf("%s %s\n", "No load routine has been defined for the", "psupp table\n");
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
if ( !count_11++ )
printf("%s %s\n", "No load routine has been defined for the", "psupp table\n");
return 0LL;
}

original_code:
int
ld_psupp (part_t *pp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined for the",
            "psupp table\n");
    return(0);
}

canonical_original_code:
int ld_psupp(struct part_t *pp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined for the",
            "psupp table\n");
    return(0);
}

user_defined_types: struct partsupp_t { long long partkey; long long suppkey; long long qty; long long scost; char comment[-1]; int clen; }


decompiled_code:
__int64 ld_supp()
{
if ( !count_9++ )
printf("%s %s\n", "No load routine has been defined", "for the supplier table\n");
return 0LL;
}

canonical_decompiled_code:
__int64 func8()
{
if ( !count_9++ )
printf("%s %s\n", "No load routine has been defined", "for the supplier table\n");
return 0LL;
}

original_code:
int
ld_supp (supplier_t *sp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the supplier table\n");
    return(0);
}

canonical_original_code:
int ld_supp(struct supplier_t *sp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the supplier table\n");
    return(0);
}

variable_types: struct supplier_t { long long suppkey; char name[-1]; char address[-1]; int alen; long long nation_code; char phone[-1]; long long acctbal; char comment[-1]; int clen; } *


decompiled_code:
__int64 ld_order()
{
if ( !count_7++ )
printf("%s %s\n", "No load routine has been defined", "for the order table");
return 0LL;
}

canonical_decompiled_code:
__int64 func10()
{
if ( !count_7++ )
printf("%s %s\n", "No load routine has been defined", "for the order table");
return 0LL;
}

original_code:
int
ld_order (order_t *p, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the order table");
    return(0);
}

canonical_original_code:
int ld_order(struct order_t *p, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the order table");
    return(0);
}

variable_types: struct order_t { long long okey; long long custkey; char orderstatus; long long totalprice; char odate[13]; char opriority[-1]; char clerk[-1]; long spriority; long long lines; char comment[-1]; int clen; struct line_t { long long okey; long long partkey; long long suppkey; long long lcnt; long long quantity; long long eprice; long long discount; long long tax; char rflag[1]; char lstatus[1]; char cdate[13]; char sdate[13]; char rdate[13]; char shipinstruct[-1]; char shipmode[-1]; char comment[-1]; int clen; } l[7]; } *

user_defined_types: struct order_t { long long okey; long long custkey; char orderstatus; long long totalprice; char odate[13]; char opriority[-1]; char clerk[-1]; long spriority; long long lines; char comment[-1]; int clen; struct line_t l[7]; }


decompiled_code:
__int64 ld_line()
{
if ( !count_6++ )
printf("%s %s\n", "No load routine has been defined", "for the line table");
return 0LL;
}

canonical_decompiled_code:
__int64 func11()
{
if ( !count_6++ )
printf("%s %s\n", "No load routine has been defined", "for the line table");
return 0LL;
}

original_code:
int ld_line (order_t *p, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the line table");
    return(0);
}

canonical_original_code:
int ld_line(struct order_t *p, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the line table");
    return(0);
}

user_defined_types: struct line_t { long long okey; long long partkey; long long suppkey; long long lcnt; long long quantity; long long eprice; long long discount; long long tax; char rflag[1]; char lstatus[1]; char cdate[13]; char sdate[13]; char rdate[13]; char shipinstruct[-1]; char shipmode[-1]; char comment[-1]; int clen; }


decompiled_code:
__int64 ld_nation()
{
if ( !count_2++ )
printf("%s %s\n", "No load routine has been defined", "for the nation table");
return 0LL;
}

canonical_decompiled_code:
__int64 func15()
{
if ( !count_2++ )
printf("%s %s\n", "No load routine has been defined", "for the nation table");
return 0LL;
}

original_code:
int
ld_nation (code_t *cp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the nation table");
    return(0);
}

canonical_original_code:
int ld_nation(struct code_t *cp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the nation table");
    return(0);
}

variable_types: struct code_t { long long code; char *text; long join; char comment[-1]; int clen; } *


decompiled_code:
__int64 ld_region()
{
if ( !count_0++ )
printf("%s %s\n", "No load routine has been defined", "for the region table");
return 0LL;
}

canonical_decompiled_code:
__int64 func17()
{
if ( !count_0++ )
printf("%s %s\n", "No load routine has been defined", "for the region table");
return 0LL;
}

original_code:
int
ld_region (code_t *cp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the region table");
    return(0);
}

canonical_original_code:
int ld_region(struct code_t *cp, int mode)
{
    static int count = 0;
    if (! count++)
        printf("%s %s\n",
            "No load routine has been defined",
            "for the region table");
    return(0);
}

user_defined_types: struct code_t { long long code; char *text; long join; char comment[-1]; int clen; }


decompiled_code:
__int64 __fastcall ld_order_line(__int64 a1, unsigned int a2)
{
ld_order();
ld_line(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, unsigned int a2)
{
func10();
func11(a1, a2);
return 0LL;
}

original_code:
int
ld_order_line (order_t *p, int mode)
{
    ld_order(p, mode);
    ld_line (p, mode);
    return(0);
}

canonical_original_code:
int ld_order_line(struct order_t *p, int mode)
{
    ld_order(p, mode);
    ld_line (p, mode);
    return(0);
}


decompiled_code:
__int64 __fastcall ld_part_psupp(__int64 a1, unsigned int a2)
{
ld_part();
ld_psupp(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, unsigned int a2)
{
func5();
func6(a1, a2);
return 0LL;
}

original_code:
int
ld_part_psupp (part_t *p, int mode)
{
    ld_part(p, mode);
    ld_psupp (p, mode);
    return(0);
}

canonical_original_code:
int ld_part_psupp(struct part_t *p, int mode)
{
    ld_part(p, mode);
    ld_psupp (p, mode);
    return(0);
}


decompiled_code:
__int64 *row_start()
{
__int64 *result; // rax

result = (__int64 *)(unsigned int)((_DWORD)&Seed + 16);
do
{
*result = 0LL;
result += 5;
}
while ( result != &Seed + 242 );
return result;
}

canonical_decompiled_code:
__int64 *func0()
{
__int64 *result; // rax

result = (__int64 *)(unsigned int)((_DWORD)&Seed + 16);
do
{
*result = 0LL;
result += 5;
}
while ( result != &Seed + 242 );
return result;
}

original_code:
void
row_start(int t) {
 int i;
 for (i=0; i <= 47; i++)
  Seed[i].usage = 0 ;
 return;
}

variable_types: t int

variable_types: i int


decompiled_code:
__int64 __fastcall row_stop(int a1)
{
__int64 v1; // r12
unsigned __int64 v2; // rbx
unsigned int v3; // ebp
__int64 v4; // r13
__int64 result; // rax
__int64 v6; // rcx
__int64 v7; // rdi

if ( a1 == 6 )
{
v1 = 4LL;
a1 = 4;
}
else
{
v1 = a1;
if ( a1 == 7 )
{
v1 = 0LL;
a1 = 0;
}
}
v2 = (unsigned int)((_DWORD)&Seed + 8);
v3 = 0;
v4 = 56LL * a1;
do
{
while ( 1 )
{
result = *(_QWORD *)(v2 - 8);
if ( result != v1 && result != *(_DWORD *)((char *)&tdefs + v4 + 40) )
goto LABEL_6;
v6 = *(_QWORD *)(v2 + 8);
v7 = *(_QWORD *)(v2 + 16);
if ( !set_seeds || v6 <= v7 )
break;
fprintf(stderr, "\nSEED CHANGE: seed[%d].usage = %d\n", v3, v6);
result = *(_QWORD *)(v2 + 8);
*(_QWORD *)(v2 + 16) = result;
LABEL_6:
++v3;
v2 += 40LL;
if ( v3 == 48 )
return result;
}
++v3;
NthElement(v7 - v6, v2);
result = *(_QWORD *)(v2 + 16) - *(_QWORD *)(v2 + 8);
*(_QWORD *)(v2 + 24) += result;
v2 += 40LL;
}
while ( v3 != 48 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 v1; // r12
unsigned __int64 v2; // rbx
unsigned int v3; // ebp
__int64 v4; // r13
__int64 result; // rax
__int64 v6; // rcx
__int64 v7; // rdi

if ( a1 == 6 )
{
v1 = 4LL;
a1 = 4;
}
else
{
v1 = a1;
if ( a1 == 7 )
{
v1 = 0LL;
a1 = 0;
}
}
v2 = (unsigned int)((_DWORD)&Seed + 8);
v3 = 0;
v4 = 56LL * a1;
do
{
while ( 1 )
{
result = *(_QWORD *)(v2 - 8);
if ( result != v1 && result != *(_DWORD *)((char *)&tdefs + v4 + 40) )
goto LABEL_6;
v6 = *(_QWORD *)(v2 + 8);
v7 = *(_QWORD *)(v2 + 16);
if ( !set_seeds || v6 <= v7 )
break;
fprintf(stderr, "\nSEED CHANGE: seed[%d].usage = %d\n", v3, v6);
result = *(_QWORD *)(v2 + 8);
*(_QWORD *)(v2 + 16) = result;
LABEL_6:
++v3;
v2 += 40LL;
if ( v3 == 48 )
return result;
}
++v3;
NthElement(v7 - v6, v2);
result = *(_QWORD *)(v2 + 16) - *(_QWORD *)(v2 + 8);
*(_QWORD *)(v2 + 24) += result;
v2 += 40LL;
}
while ( v3 != 48 );
return result;
}

original_code:
void
row_stop(int t) {
 int i;
 if (t == 6)
  t = 4;
 if (t == 7)
  t = 0;
 for (i=0; i <= 47; i++)
  if ((Seed[i].table == t) || (Seed[i].table == tdefs[t].child))
   {
   if (set_seeds && (Seed[i].usage > Seed[i].boundary))
    {
    fprintf(stderr, "\nSEED CHANGE: seed[%d].usage = %d\n",
     i, Seed[i].usage);
    Seed[i].boundary = Seed[i].usage;
    }
   else
    {
    NthElement((Seed[i].boundary - Seed[i].usage), &Seed[i].value);
    Seed[i].nCalls += Seed[i].boundary - Seed[i].usage;
    }
   }
  return;
 }


decompiled_code:
int __fastcall dump_seeds(int a1)
{
unsigned int v1; // ebp
__int64 *v2; // rbx
__int64 v3; // rcx
__int64 v4; // rdx
__int64 v5; // rsi
int result; // eax

v1 = 0;
v2 = &Seed;
do
{
while ( *v2 != a1 )
{
++v1;
v2 += 5;
if ( v1 == 48 )
return result;
}
v3 = v2[1];
v4 = v2[4];
v5 = v1++;
v2 += 5;
result = printf("%d(%ld):\t%ld\n", v5, v4, v3);
}
while ( v1 != 48 );
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
unsigned int v1; // ebp
__int64 *v2; // rbx
__int64 v3; // rcx
__int64 v4; // rdx
__int64 v5; // rsi
int result; // eax

v1 = 0;
v2 = &Seed;
do
{
while ( *v2 != a1 )
{
++v1;
v2 += 5;
if ( v1 == 48 )
return result;
}
v3 = v2[1];
v4 = v2[4];
v5 = v1++;
v2 += 5;
result = printf("%d(%ld):\t%ld\n", v5, v4, v3);
}
while ( v1 != 48 );
return result;
}

original_code:
void
dump_seeds(int tbl)
{
 int i;
 for (i=0; i <= 47; i++)
  if (Seed[i].table == tbl)
   printf("%d(%ld):\t%ld\n", i, Seed[i].nCalls, Seed[i].value);
 return;
}

variable_types: tbl int


NextRand

decompiled_code:
__int64 __fastcall NextRand(__int64 a1)
{
return 16807 * a1 % 0x7FFFFFFF;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return 16807 * a1 % 0x7FFFFFFF;
}

original_code:
long long int
NextRand(long long int nSeed)
{
 nSeed = (nSeed * 16807) % 2147483647;
    return (nSeed);
}

canonical_original_code:
long long NextRand(long long nSeed)
{
 nSeed = (nSeed * 16807) % 2147483647;
    return (nSeed);
}

variable_types:
nSeed
long long


UnifInt

decompiled_code:
__int64 __fastcall UnifInt(__int64 a1, __int64 a2, unsigned __int64 a3)
{
double v3; // xmm1_8
__int64 *v4; // rsi
__int64 v5; // rax
double v6; // xmm0_8
__int64 v7; // rcx

if ( a3 >= 0x30 )
a3 = 0LL;
if ( a2 != 0x7FFFFFFF || (v3 = *(double *)&LC2, a1) )
v3 = (double)((int)a2 - (int)a1 + 1);
v4 = &Seed[5 * a3];
v5 = NextRand(v4[1]);
++v4[4];
v6 = (double)(int)v5 / *(double *)&dM * v3;
v4[1] = v5;
return v7 + (unsigned int)(int)v6;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, unsigned __int64 a3)
{
double v3; // xmm1_8
__int64 *v4; // rsi
__int64 v5; // rax
double v6; // xmm0_8
__int64 v7; // rcx

if ( a3 >= 0x30 )
a3 = 0LL;
if ( a2 != 0x7FFFFFFF || (v3 = *(double *)&LC2, a1) )
v3 = (double)((int)a2 - (int)a1 + 1);
v4 = &Seed[5 * a3];
v5 = func3(v4[1]);
++v4[4];
v6 = (double)(int)v5 / *(double *)&dM * v3;
v4[1] = v5;
return v7 + (unsigned int)(int)v6;
}

original_code:
long long int
UnifInt(long long int nLow, long long int nHigh, long nStream)
{
    double dRange;
    long long int nTemp,
  nRange;
    int32_t nLow32 = (int32_t)nLow,
  nHigh32 = (int32_t)nHigh;
    if (nStream < 0 || nStream > 47)
        nStream = 0;
 if ((nHigh == 0x7FFFFFFF) && (nLow == 0))
 {
  dRange = (double) (nHigh32 - nLow32 + 1);
  nRange = nHigh32 - nLow32 + 1;
 }
 else
 {
  dRange = (double) (nHigh - nLow + 1);
  nRange = nHigh - nLow + 1;
 }
    Seed[nStream].value = NextRand(Seed[nStream].value);
 Seed[nStream].nCalls += 1;
 nTemp = (long long int) (((double) Seed[nStream].value / dM) * (dRange));
    return (nLow + nTemp);
}

canonical_original_code:
long long UnifInt(long long nLow, long long nHigh, long nStream)
{
    double dRange;
    long long nTemp; long long nRange;
    int nLow32 = (int32_t)nLow; int nHigh32 = (int32_t)nHigh;
    if (nStream < 0 || nStream > 47)
        nStream = 0;
 if ((nHigh == 0x7FFFFFFF) && (nLow == 0))
 {
  dRange = (double) (nHigh32 - nLow32 + 1);
  nRange = nHigh32 - nLow32 + 1;
 }
 else
 {
  dRange = (double) (nHigh - nLow + 1);
  nRange = nHigh - nLow + 1;
 }
    Seed[nStream].value = NextRand(Seed[nStream].value);
 Seed[nStream].nCalls += 1;
 nTemp = (long long) (((double) Seed[nStream].value / dM) * (dRange));
    return (nLow + nTemp);
}

variable_types:
nLow
long long

variable_types:
nHigh
long long

variable_types: nStream long

variable_types: dRange double

variable_types:
nTemp
long long

variable_types:
nRange
long long


decompiled_code:
__int64 __fastcall NextRand64(__int64 a1)
{
return 0x5851F42D4C957F2DLL * a1 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return 0x5851F42D4C957F2DLL * a1 + 1;
}

original_code:
long long int
NextRand64(long long int nSeed){
 long long int a = (unsigned long long int) 6364136223846793005ull;
    long long int c = (unsigned long long int) 1ull;
    nSeed = (nSeed * a + c);
    return (nSeed);
}

canonical_original_code:
long long NextRand64(long long nSeed){
 long long a = (unsigned long long int) 6364136223846793005ull;
    long long c = (unsigned long long int) 1ull;
    nSeed = (nSeed * a + c);
    return (nSeed);
}

variable_types:
a
long long

variable_types:
c
long long


original_code:
long long int AdvanceRand64( long long int nSeed,
      long long int nCount) {
  unsigned long long int a = 6364136223846793005ull ;
  unsigned long long int c = 1ull ;
  int nBit;
  unsigned long long int Apow=a, Dsum=c;
  if( nCount == 0 ) return nSeed;
  for( nBit = 0; (nCount >> nBit) != 1ull ; nBit ++){}
  while( --nBit >= 0 ) {
    Dsum *= (Apow + 1);
    Apow = Apow * Apow;
    if( ((nCount >> nBit) % 2) == 1 ) {
      Dsum += Apow;
      Apow *= a;
    }
  }
  nSeed = nSeed * Apow + Dsum * c;
  return nSeed;
}

canonical_original_code:
long long AdvanceRand64(long long nSeed, long long nCount) {
  unsigned long long a = 6364136223846793005ull;
  unsigned long long c = 1ull;
  int nBit;
  unsigned long long Apow = a; unsigned long long Dsum = c;
  if( nCount == 0 ) return nSeed;
  for( nBit = 0; (nCount >> nBit) != 1ull ; nBit ++){}
  while( --nBit >= 0 ) {
    Dsum *= (Apow + 1);
    Apow = Apow * Apow;
    if( ((nCount >> nBit) % 2) == 1 ) {
      Dsum += Apow;
      Apow *= a;
    }
  }
  nSeed = nSeed * Apow + Dsum * c;
  return nSeed;
}

variable_types:
nCount
long long

variable_types:
a
unsigned long long

variable_types:
c
unsigned long long

variable_types: nBit int

variable_types:
Apow
unsigned long long

variable_types:
Dsum
unsigned long long


decompiled_code:
__int64 __fastcall sd_part(__int64 a1, __int64 a2)
{
int i; // ebx
int v3; // edi

for ( i = 0; i != 5; ++i )
{
v3 = i;
advanceStream(v3, a2, 0);
}
advanceStream(6, 2 * a2, 0);
advanceStream(37, 92 * a2, 0);
return 0LL;
}

original_code:
long
sd_part(int child, long long int skip_count)
{
   int i;
   for (i=0; i<= 4; i++)
       advanceStream(i, skip_count, 0);
   advanceStream(6, skip_count * 2, 0);
   advanceStream(37, skip_count * 92, 0);
   return(0L);
}

canonical_original_code:
long sd_part(int child, long long skip_count)
{
   int i;
   for (i=0; i<= 4; i++)
       advanceStream(i, skip_count, 0);
   advanceStream(6, skip_count * 2, 0);
   advanceStream(37, skip_count * 92, 0);
   return(0L);
}

variable_types: child int

variable_types: i int


decompiled_code:
__int64 __fastcall sd_line(int a1, __int64 a2)
{
int v3; // er12
int i; // ebx
int v5; // edi

v3 = 7;
do
{
for ( i = 14; i != 25; ++i )
{
v5 = i;
advanceStream(v5, a2, 0);
}
advanceStream(25, 2 * a2, 0);
--v3;
}
while ( v3 );
if ( a1 == 1 )
{
advanceStream(13, a2, 0);
advanceStream(43, a2, 0);
}
return 0LL;
}

original_code:
long
sd_line(int child, long long int skip_count)
 {
 int i,j;
 for (j=0; j < 7; j++)
 {
  for (i=14; i<= 24; i++)
    advanceStream(i, skip_count, 0);
  advanceStream(25, skip_count * 2, 0);
 }
 if (child == 1)
 {
  advanceStream(13, skip_count, 0);
  advanceStream(43, skip_count, 0);
 }
 return(0L);
 }

canonical_original_code:
long sd_line(int child, long long skip_count)
 {
 int i; int j;
 for (j=0; j < 7; j++)
 {
  for (i=14; i<= 24; i++)
    advanceStream(i, skip_count, 0);
  advanceStream(25, skip_count * 2, 0);
 }
 if (child == 1)
 {
  advanceStream(13, skip_count, 0);
  advanceStream(43, skip_count, 0);
 }
 return(0L);
 }

variable_types: j int


decompiled_code:
__int64 __fastcall sd_order(__int64 a1, __int64 a2)
{
advanceStream(43, a2, 0);
advanceStream(40, a2, 0);
advanceStream(12, 2 * a2, 0);
advanceStream(10, a2, 0);
advanceStream(11, a2, 0);
advanceStream(38, a2, 0);
advanceStream(13, a2, 0);
return 0LL;
}

original_code:
long
sd_order(int child, long long int skip_count)
{
 advanceStream(43, skip_count, 0);
  advanceStream(40, skip_count, 0);
 advanceStream(12, skip_count * 2, 0);
 advanceStream(10, skip_count, 0);
 advanceStream(11, skip_count, 0);
 advanceStream(38, skip_count, 0);
 advanceStream(13, skip_count, 0);
 return (0L);
}

canonical_original_code:
long sd_order(int child, long long skip_count)
{
 advanceStream(43, skip_count, 0);
  advanceStream(40, skip_count, 0);
 advanceStream(12, skip_count * 2, 0);
 advanceStream(10, skip_count, 0);
 advanceStream(11, skip_count, 0);
 advanceStream(38, skip_count, 0);
 advanceStream(13, skip_count, 0);
 return (0L);
}


decompiled_code:
__int64 __fastcall sd_psupp(__int64 a1, __int64 a2)
{
int v2; // ebx

v2 = 4;
do
{
advanceStream(7, a2, 0);
advanceStream(8, a2, 0);
advanceStream(9, 2 * a2, 0);
--v2;
}
while ( v2 );
return 0LL;
}

original_code:
long
sd_psupp(int child, long long int skip_count)
 {
 int j;
 for (j=0; j < 4; j++)
  {
  advanceStream(7, skip_count, 0);
  advanceStream(8, skip_count, 0);
  advanceStream(9, skip_count * 2, 0);
  }
 return(0L);
 }

canonical_original_code:
long sd_psupp(int child, long long skip_count)
 {
 int j;
 for (j=0; j < 4; j++)
  {
  advanceStream(7, skip_count, 0);
  advanceStream(8, skip_count, 0);
  advanceStream(9, skip_count * 2, 0);
  }
 return(0L);
 }


decompiled_code:
__int64 __fastcall sd_cust(__int64 a1, __int64 a2)
{
advanceStream(26, 9 * a2, 0);
advanceStream(31, 2 * a2, 0);
advanceStream(27, a2, 0);
advanceStream(28, 3 * a2, 0);
advanceStream(29, a2, 0);
advanceStream(30, a2, 0);
return 0LL;
}

original_code:
long
sd_cust(int child, long long int skip_count)
{
   advanceStream(26, skip_count * 9, 0);
   advanceStream(31, skip_count * 2, 0);
   advanceStream(27, skip_count, 0);
   advanceStream(28, 3L * skip_count, 0);
   advanceStream(29, skip_count, 0);
   advanceStream(30, skip_count, 0);
   return(0L);
}

canonical_original_code:
long sd_cust(int child, long long skip_count)
{
   advanceStream(26, skip_count * 9, 0);
   advanceStream(31, skip_count * 2, 0);
   advanceStream(27, skip_count, 0);
   advanceStream(28, 3L * skip_count, 0);
   advanceStream(29, skip_count, 0);
   advanceStream(30, skip_count, 0);
   return(0L);
}


decompiled_code:
__int64 __fastcall sd_supp(__int64 a1, __int64 a2)
{
advanceStream(33, a2, 0);
advanceStream(34, 3 * a2, 0);
advanceStream(35, a2, 0);
advanceStream(32, 9 * a2, 0);
advanceStream(36, 2 * a2, 0);
advanceStream(46, a2, 0);
advanceStream(44, a2, 0);
advanceStream(47, a2, 0);
advanceStream(45, a2, 0);
return 0LL;
}

original_code:
long
sd_supp(int child, long long int skip_count)
{
   advanceStream(33, skip_count, 0);
   advanceStream(34, 3L * skip_count, 0);
   advanceStream(35, skip_count, 0);
   advanceStream(32, skip_count * 9, 0);
   advanceStream(36, skip_count * 2, 0);
   advanceStream(46, skip_count, 0);
   advanceStream(44, skip_count, 0);
   advanceStream(47, skip_count, 0);
   advanceStream(45, skip_count, 0);
   return(0L);
}

canonical_original_code:
long sd_supp(int child, long long skip_count)
{
   advanceStream(33, skip_count, 0);
   advanceStream(34, 3L * skip_count, 0);
   advanceStream(35, skip_count, 0);
   advanceStream(32, skip_count * 9, 0);
   advanceStream(36, skip_count * 2, 0);
   advanceStream(46, skip_count, 0);
   advanceStream(44, skip_count, 0);
   advanceStream(47, skip_count, 0);
   advanceStream(45, skip_count, 0);
   return(0L);
}


decompiled_code:
int __fastcall gen_phone(__int64 a1, char *a2, __int64 a3)
{
int result; // eax
unsigned int v5; // [rsp+8h] [rbp-30h] BYREF
unsigned int v6; // [rsp+10h] [rbp-28h] BYREF
unsigned int v7[8]; // [rsp+18h] [rbp-20h] BYREF

dss_random(&v5, 100LL, 999LL, a3);
dss_random(&v6, 100LL, 999LL, a3);
dss_random(v7, 1000LL, 9999LL, a3);
sprintf(a2, "%02d", (unsigned int)(a1 % 90) + 10);
sprintf(a2 + 3, "%03d", v5);
sprintf(a2 + 7, "%03d", v6);
result = sprintf(a2 + 11, "%04d", v7[0]);
a2[10] = 45;
a2[6] = 45;
a2[2] = 45;
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, char *a2, __int64 a3)
{
int result; // eax
unsigned int v5; // [rsp+8h] [rbp-30h] BYREF
unsigned int v6; // [rsp+10h] [rbp-28h] BYREF
unsigned int v7[8]; // [rsp+18h] [rbp-20h] BYREF

dss_random(&v5, 100LL, 999LL, a3);
dss_random(&v6, 100LL, 999LL, a3);
dss_random(v7, 1000LL, 9999LL, a3);
sprintf(a2, "%02d", (unsigned int)(a1 % 90) + 10);
sprintf(a2 + 3, "%03d", v5);
sprintf(a2 + 7, "%03d", v6);
result = sprintf(a2 + 11, "%04d", v7[0]);
a2[10] = 45;
a2[6] = 45;
a2[2] = 45;
return result;
}

original_code:
static void
gen_phone(long long int ind, char *target, long seed)
{
 long long int acode, exchg, number;
 dss_random(&acode, 100, 999, seed);
 dss_random(&exchg, 100, 999, seed);
 dss_random(&number, 1000, 9999, seed);
 sprintf(target, "%02d", (int) (10 + (ind % 90)));
 sprintf(target + 3, "%03d", (int) acode);
 sprintf(target + 7, "%03d", (int) exchg);
 sprintf(target + 11, "%04d", (int) number);
 target[2] = target[6] = target[10] = '-';
 return;
}

canonical_original_code:
static void gen_phone(long long ind, char *target, long seed)
{
 long long acode; long long exchg; long long number;
 dss_random(&acode, 100, 999, seed);
 dss_random(&exchg, 100, 999, seed);
 dss_random(&number, 1000, 9999, seed);
 sprintf(target, "%02d", (int) (10 + (ind % 90)));
 sprintf(target + 3, "%03d", (int) acode);
 sprintf(target + 7, "%03d", (int) exchg);
 sprintf(target + 11, "%04d", (int) number);
 target[2] = target[6] = target[10] = '-';
 return;
}

variable_types:
ind
long long

variable_types:
target
char *

variable_types: seed long

variable_types:
acode
long long

variable_types:
exchg
long long

variable_types:
number
long long


original_code:
long long int
rpb_routine(long long int p)
{
 long long int price;
 price = 90000;
 price += (p / 10) % 20001;
 price += (p % 1000) * 100;
 return (price);
}

canonical_original_code:
long long rpb_routine(long long p)
{
 long long price;
 price = 90000;
 price += (p / 10) % 20001;
 price += (p % 1000) * 100;
 return (price);
}

variable_types:
p
long long

variable_types:
price
long long


original_code:
long
mk_cust(long long int n_cust, customer_t * c)
{
 long long int i;
 static int bInit = 0;
 static char szFormat[100];
 if (!bInit)
 {
  sprintf(szFormat, "%%s%%0%d%s", 9, "%lld" + 1);
  bInit = 1;
 }
 c->custkey = n_cust;
 sprintf(c->name, szFormat, "Customer#", n_cust);
 a_rnd((int)(25 * 0.4),(int)(25 * 1.6), 26, c->address);
 c->alen = (int)strlen(c->address);
 dss_random(&i, 0, (nations.count - 1), 27);
 c->nation_code = i;
 gen_phone(i, c->phone, (long) 28);
 dss_random(&c->acctbal, -99999, 999999, 29);
 pick_str(&c_mseg_set, 30, c->mktsegment);
 dbg_text(c->comment, (int)(73 * 0.4),(int)(73 * 1.6), 31);
 c->clen = (int)strlen(c->comment);
 return (0);
}

canonical_original_code:
long mk_cust(long long n_cust, struct customer_t *c)
{
 long long i;
 static int bInit = 0;
 static char szFormat[100];
 if (!bInit)
 {
  sprintf(szFormat, "%%s%%0%d%s", 9, "%lld" + 1);
  bInit = 1;
 }
 c->custkey = n_cust;
 sprintf(c->name, szFormat, "Customer#", n_cust);
 a_rnd((int)(25 * 0.4),(int)(25 * 1.6), 26, c->address);
 c->alen = (int)strlen(c->address);
 dss_random(&i, 0, (nations.count - 1), 27);
 c->nation_code = i;
 gen_phone(i, c->phone, (long) 28);
 dss_random(&c->acctbal, -99999, 999999, 29);
 pick_str(&c_mseg_set, 30, c->mktsegment);
 dbg_text(c->comment, (int)(73 * 0.4),(int)(73 * 1.6), 31);
 c->clen = (int)strlen(c->comment);
 return (0);
}

variable_types: struct customer_t { long long custkey; char name[-1]; char address[-1]; int alen; long long nation_code; char phone[-1]; long long acctbal; char mktsegment[-1]; char comment[-1]; int clen; } *

variable_types:
i
long long

variable_types: bInit int

variable_types:
szFormat
char [100]