getnum

decompiled_code:
__int64 __fastcall getnum(__int64 a1)
{
__int64 v2; // rbp
int v3; // edi
__int64 v4; // r9

v2 = *(int *)(a1 + 8);
atol((const char *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 72LL) + v2));
do
v3 = (char)popc(a1);
while ( (unsigned int)(v3 - 48) <= 9 );
unputc(v3, a1);
*(_DWORD *)(a1 + 4) = v2;
return v4;
}

original_code:
static long getnum(yyenv_t* penv)
{
 long a;
 char c;
 int i, errpos = (penv->scanpos);
 a = atol((penv->pstmt->sqlexpr) + (penv->scanpos));
 for(i=0;;i++)
 {
  c = popc(penv);
  if( ! isdigit(c) )
  {
   unputc(c, penv);
   break;
  }
 }
 (penv->errpos) = errpos;
 return a;
}

canonical_original_code:
static long getnum(struct yyenv_t *penv)
{
 long a;
 char c;
 int i; int errpos = (penv->scanpos);
 a = atol((penv->pstmt->sqlexpr) + (penv->scanpos));
 for(i=0;;i++)
 {
  c = popc(penv);
  if( ! isdigit(c) )
  {
   unputc(c, penv);
   break;
  }
 }
 (penv->errpos) = errpos;
 return a;
}

variable_types: a long

variable_types: errpos int

user_defined_types: struct yyattr_t { int stat; int wstat; int article; union { char *location; long number; struct date_t date; } value; void *nntp_hand; }

user_defined_types: struct yypar_t { int type; union { char *location; long number; struct date_t date; } value; }

user_defined_types: struct tnode { int type; union { int cmpop; int logop; int iattr; int ipar; char *qstr; long num; struct date_t date; char esc; } value; struct tnode *left; struct tnode *right; }

user_defined_types: struct date_t { int year; int month; int day; }


getcmpopidxbyname

repo: xiaotmiaomiao/unixODBC-SPEC

decompiled_code:
__int64 __fastcall getcmpopidxbyname(char *s1)
{
const char *v1; // rsi
const char **v2; // rbp
int v3; // ebx

v1 = "=";
v2 = (const char **)&off_778;
v3 = 0;
while ( strcmp(s1, v1) )
{
if ( ++v3 == 8 )
return 256LL;
v1 = *v2;
v2 += 2;
}
return *((unsigned int *)&cmpop_tab + 4 * v3);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s1)
{
const char *v1; // rsi
const char **v2; // rbp
int v3; // ebx

v1 = "=";
v2 = (const char **)&off_778;
v3 = 0;
while ( strcmp(s1, v1) )
{
if ( ++v3 == 8 )
return 256LL;
v1 = *v2;
v2 += 2;
}
return *((unsigned int *)&cmpop_tab + 4 * v3);
}

original_code:
static int getcmpopidxbyname(char* name)
{
 int i, size;
 size = sizeof(cmpop_tab)/sizeof(cmpop_tab[0]);
 for(i=0; i<size; i++)
 {
  if((strcmp((char*)(name), (char*)(cmpop_tab[i].name)) == 0))
   return cmpop_tab[i].idx;
 }
 return 256;
}

canonical_original_code:
static int getcmpopidxbyname(char *name)
{
 int i; int size;
 size = sizeof(cmpop_tab)/sizeof(cmpop_tab[0]);
 for(i=0; i<size; i++)
 {
  if((strcmp((char *)(name), (char *)(cmpop_tab[i].name)) == 0))
   return cmpop_tab[i].idx;
 }
 return 256;
}

variable_types:
name
char *

variable_types: i int

variable_types: size int

return_type: int


getcmpop

decompiled_code:
__int64 __fastcall getcmpop(__int64 a1)
{
char v1; // al
int v2; // er9
char s1; // [rsp+Dh] [rbp-Bh] BYREF
char v5; // [rsp+Eh] [rbp-Ah]
char v6; // [rsp+Fh] [rbp-9h]

s1 = popc(a1);
v1 = popc(a1);
v6 = 0;
v5 = v1;
if ( (unsigned __int8)(v1 - 60) > 2u )
{
v5 = 0;
unputc(v1, a1);
}
*(_DWORD *)(a1 + 4) = v2;
return getcmpopidxbyname(&s1);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
char v1; // al
int v2; // er9
char s1; // [rsp+Dh] [rbp-Bh] BYREF
char v5; // [rsp+Eh] [rbp-Ah]
char v6; // [rsp+Fh] [rbp-9h]

s1 = func0(a1);
v1 = func0(a1);
v6 = 0;
v5 = v1;
if ( (unsigned __int8)(v1 - 60) > 2u )
{
v5 = 0;
unputc(v1, a1);
}
*(_DWORD *)(a1 + 4) = v2;
return func4(&s1);
}

original_code:
static int getcmpop(yyenv_t* penv)
{
 char opname[3];
 char c, c1;
 int errpos = (penv->scanpos);
 opname[0] = c = popc(penv);
 opname[1] = c1= popc(penv);
 opname[2] = 0;
 if( c1 != '=' && c1 != '>' && c1 != '<' )
 {
  opname[1] = 0;
  unputc(c1, penv);
 }
 (penv->errpos) = errpos;
 return getcmpopidxbyname(opname);
}

canonical_original_code:
static int getcmpop(struct yyenv_t *penv)
{
 char opname[3];
 char c; char c1;
 int errpos = (penv->scanpos);
 opname[0] = c = popc(penv);
 opname[1] = c1= popc(penv);
 opname[2] = 0;
 if( c1 != '=' && c1 != '>' && c1 != '<' )
 {
  opname[1] = 0;
  unputc(c1, penv);
 }
 (penv->errpos) = errpos;
 return getcmpopidxbyname(opname);
}

variable_types: struct yyenv_t { int extlevel; int errpos; int scanpos; char *texts_bufptr; int dummy_npar; struct yystmt_t { void *hcndes; int type; int errcode; int errpos; struct yycol_t { int iattr; char *table; union { long num; char *qstr; struct date_t { int year; int month; int day; } date; } value; } *pcol; struct yyattr_t { int stat; int wstat; int article; union { char *location; long number; struct date_t date; } value; void *nntp_hand; } *pattr; struct yypar_t { int type; union { char *location; long number; struct date_t date; } value; } *ppar; char *table; int ncol; int npar; int count; char *sqlexpr; char *texts_buf; char msgbuf[64]; struct tnode { int type; union { int cmpop; int logop; int iattr; int ipar; char *qstr; long num; struct date_t date; char esc; } value; struct tnode *left; struct tnode *right; } *srchtree; struct tnode *node_buf; int srchtreesize; int srchtreenum; char **ins_heads; struct tnode *ins_values; long artnum_min; long artnum_max; } *pstmt; } *

variable_types:
opname
char [3]

variable_types: c char

user_defined_types: struct yyenv_t { int extlevel; int errpos; int scanpos; char *texts_bufptr; int dummy_npar; struct yystmt_t *pstmt; }

user_defined_types: struct yystmt_t { void *hcndes; int type; int errcode; int errpos; struct yycol_t *pcol; struct yyattr_t *pattr; struct yypar_t *ppar; char *table; int ncol; int npar; int count; char *sqlexpr; char *texts_buf; char msgbuf[64]; struct tnode *srchtree; struct tnode *node_buf; int srchtreesize; int srchtreenum; char **ins_heads; struct tnode *ins_values; long artnum_min; long artnum_max; }

user_defined_types: struct yycol_t { int iattr; char *table; union { long num; char *qstr; struct date_t date; } value; }


original_code:
int nnsql_yylex(YYSTYPE* pyylval, yyenv_t* penv)
{
 int len, cmpop;
 char c;
 do
 { c = popc(penv); }
 while( c == ' ' || c == '\t' || c == '\n' );
 if( isalpha(c) )
 {
  int keywdidx;
  unputc(c, penv);
  len = getname(penv->texts_bufptr, -1, penv);
  if( len == 256 )
   return len;
  if( penv->extlevel )
   keywdidx = getxkeywdidxbyname( penv->texts_bufptr );
  else
   keywdidx = 256;
  if( keywdidx == 256 )
   keywdidx = getkeywdidxbyname( penv->texts_bufptr);
  if( keywdidx != 256 )
   return keywdidx;
  pyylval->name = penv->texts_bufptr;
  (penv->texts_bufptr) += (len + 1);
  return 300;
 }
 if( isdigit(c) )
 {
  unputc(c, penv);
  pyylval->number = getnum(penv);
  return 299;
 }
 switch( c )
 {
  case ';':
  case '\0':
   return ';';
  case '\'':
  case '"':
   len = getqstring(penv->texts_bufptr, -1, penv, c);
   if( len == 256 )
    return len;
   if( c == '\'' )
   {
    pyylval->qstring = penv->texts_bufptr;
    penv->texts_bufptr += (len + 1);
    return 298;
   }
   pyylval->name = penv->texts_bufptr;
   (penv->texts_bufptr) += (len + 1);
   return 300;
  case '=':
  case '<':
  case '>':
  case '!':
   unputc(c, penv);
   cmpop = getcmpop( penv );
   if(cmpop == 256 )
    return cmpop;
   pyylval->cmpop = cmpop;
   return 305;
  case '?':
   pyylval->ipar = (++(penv->dummy_npar));
   return 301;
  case '{':
   penv->extlevel ++;
   break;
  case '}':
   penv->extlevel --;
   break;
  default:
   break;
 }
 return c;
}

canonical_original_code:
int nnsql_yylex(union YYSTYPE *pyylval, struct yyenv_t *penv)
{
 int len; int cmpop;
 char c;
 do
 { c = popc(penv); }
 while( c == ' ' || c == '\t' || c == '\n' );
 if( isalpha(c) )
 {
  int keywdidx;
  unputc(c, penv);
  len = getname(penv->texts_bufptr, -1, penv);
  if( len == 256 )
   return len;
  if( penv->extlevel )
   keywdidx = getxkeywdidxbyname( penv->texts_bufptr );
  else
   keywdidx = 256;
  if( keywdidx == 256 )
   keywdidx = getkeywdidxbyname( penv->texts_bufptr);
  if( keywdidx != 256 )
   return keywdidx;
  pyylval->name = penv->texts_bufptr;
  (penv->texts_bufptr) += (len + 1);
  return 300;
 }
 if( isdigit(c) )
 {
  unputc(c, penv);
  pyylval->number = getnum(penv);
  return 299;
 }
 switch( c )
 {
  case ';':
  case '\0':
   return ';';
  case '\'':
  case '"':
   len = getqstring(penv->texts_bufptr, -1, penv, c);
   if( len == 256 )
    return len;
   if( c == '\'' )
   {
    pyylval->qstring = penv->texts_bufptr;
    penv->texts_bufptr += (len + 1);
    return 298;
   }
   pyylval->name = penv->texts_bufptr;
   (penv->texts_bufptr) += (len + 1);
   return 300;
  case '=':
  case '<':
  case '>':
  case '!':
   unputc(c, penv);
   cmpop = getcmpop( penv );
   if(cmpop == 256 )
    return cmpop;
   pyylval->cmpop = cmpop;
   return 305;
  case '?':
   pyylval->ipar = (++(penv->dummy_npar));
   return 301;
  case '{':
   penv->extlevel ++;
   break;
  case '}':
   penv->extlevel --;
   break;
  default:
   break;
 }
 return c;
}

variable_types: union YYSTYPE { char *qstring; char *name; long number; int ipar; int cmpop; char esc; int flag; int idx; void *offset; struct tnode { int type; union { int cmpop; int logop; int iattr; int ipar; char *qstr; long num; struct date_t { int year; int month; int day; } date; char esc; } value; struct tnode *left; struct tnode *right; } node; } *

variable_types: struct yyenv_t { int extlevel; int errpos; int scanpos; char *texts_bufptr; int dummy_npar; struct yystmt_t { void *hcndes; int type; int errcode; int errpos; struct yycol_t { int iattr; char *table; union { long num; char *qstr; struct date_t date; } value; } *pcol; struct yyattr_t { int stat; int wstat; int article; union { char *location; long number; struct date_t date; } value; void *nntp_hand; } *pattr; struct yypar_t { int type; union { char *location; long number; struct date_t date; } value; } *ppar; char *table; int ncol; int npar; int count; char *sqlexpr; char *texts_buf; char msgbuf[64]; struct tnode *srchtree; struct tnode *node_buf; int srchtreesize; int srchtreenum; char **ins_heads; struct tnode *ins_values; long artnum_min; long artnum_max; } *pstmt; } *

variable_types: len int

variable_types: cmpop int

variable_types: keywdidx int

user_defined_types: union YYSTYPE { char *qstring; char *name; long number; int ipar; int cmpop; char esc; int flag; int idx; void *offset; struct tnode node; }


original_code:
void nnsql_yyinit(yyenv_t* penv, yystmt_t* yystmt)
{
 penv->extlevel = 0;
 penv->dummy_npar = penv->errpos = penv->scanpos = 0;
 penv->pstmt = yystmt;
 penv->texts_bufptr = yystmt->texts_buf;
}

canonical_original_code:
void nnsql_yyinit(struct yyenv_t *penv, struct yystmt_t *yystmt)
{
 penv->extlevel = 0;
 penv->dummy_npar = penv->errpos = penv->scanpos = 0;
 penv->pstmt = yystmt;
 penv->texts_bufptr = yystmt->texts_buf;
}

variable_types:
yystmt
struct yystmt_t *

return_type: void


decompiled_code:
__int64 __fastcall nnodbc_getenverrstack(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

original_code:
void* nnodbc_getenverrstack(void* henv)
{
 return ((env_t*)henv)->herr;
}

canonical_original_code:
void *nnodbc_getenverrstack(void *henv)
{
 return ((struct env_t *)henv)->herr;
}

variable_types:
henv
void *

return_type: void *

user_defined_types: struct env_t { void *hdbc; void *herr; }


decompiled_code:
__int64 __fastcall nnodbc_getdbcerrstack(__int64 a1)
{
return *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(_QWORD *)(a1 + 24);
}

original_code:
void* nnodbc_getdbcerrstack(void* hdbc)
{
 return ((dbc_t*)hdbc)->herr;
}

canonical_original_code:
void *nnodbc_getdbcerrstack(void *hdbc)
{
 return ((struct DBC *)hdbc)->herr;
}

variable_types:
hdbc
void *

user_defined_types: struct DBC { void *hcndes; void *henv; struct GSTMT *stmt; void *herr; struct DBC *next; }

user_defined_types: struct GSTMT { void *hdbc; void *hstmt; struct GSTMT *next; }


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

result = nnodbc_pusherr(*(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 24) = result;
return result;
}

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

result = nnodbc_pusherr(*(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 24) = result;
return result;
}

original_code:
void nnodbc_pushdbcerr( void* hdbc, int code, char* msg )
{
 ((dbc_t*)hdbc)->herr = nnodbc_pusherr(((dbc_t*)hdbc)->herr, code, msg);
}

canonical_original_code:
void nnodbc_pushdbcerr(void *hdbc, int code, char *msg)
{
 ((struct DBC *)hdbc)->herr = nnodbc_pusherr(((struct DBC *)hdbc)->herr, code, msg);
}

variable_types: code int

variable_types:
msg
char *


decompiled_code:
__int64 __fastcall nnodbc_getnntpcndes(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
void* nnodbc_getnntpcndes( void* hdbc )
{
 return ((dbc_t*)hdbc)->hcndes;
}

canonical_original_code:
void *nnodbc_getnntpcndes(void *hdbc)
{
 return ((struct DBC *)hdbc)->hcndes;
}


decompiled_code:
__int64 __fastcall nnodbc_attach_stmt(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
__int64 v3; // rdx
__int64 result; // rax

v2 = malloc(0x18uLL);
if ( v2 )
{
v3 = *(_QWORD *)(a1 + 16);
v2[1] = a2;
*(_QWORD *)(a1 + 16) = v2;
v2[2] = v3;
*v2 = a1;
result = 0LL;
}
else
{
*(_QWORD *)(a1 + 24) = nnodbc_pusherr(*(_QWORD *)(a1 + 24));
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
__int64 v3; // rdx
__int64 result; // rax

v2 = malloc(0x18uLL);
if ( v2 )
{
v3 = *(_QWORD *)(a1 + 16);
v2[1] = a2;
*(_QWORD *)(a1 + 16) = v2;
v2[2] = v3;
*v2 = a1;
result = 0LL;
}
else
{
*(_QWORD *)(a1 + 24) = nnodbc_pusherr(*(_QWORD *)(a1 + 24));
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int nnodbc_attach_stmt(void* hdbc, void* hstmt)
{
 dbc_t* pdbc = hdbc;
 gstmt_t* pstmt;
 pstmt = (gstmt_t*)(malloc((size_t)(sizeof(gstmt_t))));
 if( ! pstmt )
 {
  pdbc->herr = nnodbc_pusherr(pdbc->herr, en_S1001, 0);
  return (-1);
 }
 pstmt->next = pdbc->stmt;
 pdbc->stmt = pstmt;
 pstmt->hstmt= hstmt;
 pstmt->hdbc = pdbc;
 return 0;
}

canonical_original_code:
int nnodbc_attach_stmt(void *hdbc, void *hstmt)
{
 struct DBC *pdbc = hdbc;
 struct GSTMT *pstmt;
 pstmt = (struct GSTMT *)(malloc((unsigned long)(sizeof(gstmt_t))));
 if( ! pstmt )
 {
  pdbc->herr = nnodbc_pusherr(pdbc->herr, en_S1001, 0);
  return (-1);
 }
 pstmt->next = pdbc->stmt;
 pdbc->stmt = pstmt;
 pstmt->hstmt= hstmt;
 pstmt->hdbc = pdbc;
 return 0;
}

variable_types:
hstmt
void *

variable_types: struct DBC { void *hcndes; void *henv; struct GSTMT { void *hdbc; void *hstmt; struct GSTMT *next; } *stmt; void *herr; struct DBC *next; } *


decompiled_code:
__int64 __fastcall nnodbc_detach_stmt(__int64 a1, __int64 a2)
{
_QWORD *v3; // rdi
_QWORD *v4; // r8
__int64 result; // rax

v3 = *(_QWORD **)(a1 + 16);
if ( !v3 )
return 0xFFFFFFFFLL;
v4 = (_QWORD *)v3[2];
if ( v3[1] == a2 )
{
LABEL_6:
*(_QWORD *)(a1 + 16) = v4;
free(v3);
result = 0LL;
}
else
{
while ( v4[1] != a2 )
{
v3 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
v4 = (_QWORD *)v4[2];
if ( v3[1] == a2 )
goto LABEL_6;
}
v3[2] = v4[2];
free(v4);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
_QWORD *v3; // rdi
_QWORD *v4; // r8
__int64 result; // rax

v3 = *(_QWORD **)(a1 + 16);
if ( !v3 )
return 0xFFFFFFFFLL;
v4 = (_QWORD *)v3[2];
if ( v3[1] == a2 )
{
LABEL_6:
*(_QWORD *)(a1 + 16) = v4;
free(v3);
result = 0LL;
}
else
{
while ( v4[1] != a2 )
{
v3 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
v4 = (_QWORD *)v4[2];
if ( v3[1] == a2 )
goto LABEL_6;
}
v3[2] = v4[2];
free(v4);
result = 0LL;
}
return result;
}

original_code:
int nnodbc_detach_stmt(void* hdbc, void* hstmt)
{
 dbc_t* pdbc = hdbc;
 gstmt_t* pstmt;
 gstmt_t* ptr;
 for(pstmt=pdbc->stmt;pstmt;pstmt = pstmt->next)
 {
  if(pstmt->hstmt == hstmt)
  {
   pdbc->stmt = pstmt->next;
   {if(pstmt) free(pstmt);};
   return 0;
  }
  if(pstmt->next->hstmt == hstmt )
  {
   ptr = pstmt->next;
   pstmt->next = ptr->next;
   {if(ptr) free(ptr);};
   return 0;
  }
 }
 return -1;
}

canonical_original_code:
int nnodbc_detach_stmt(void *hdbc, void *hstmt)
{
 struct DBC *pdbc = hdbc;
 struct GSTMT *pstmt;
 struct GSTMT *ptr;
 for(pstmt=pdbc->stmt;pstmt;pstmt = pstmt->next)
 {
  if(pstmt->hstmt == hstmt)
  {
   pdbc->stmt = pstmt->next;
   {if(pstmt) free(pstmt);};
   return 0;
  }
  if(pstmt->next->hstmt == hstmt )
  {
   ptr = pstmt->next;
   pstmt->next = ptr->next;
   {if(ptr) free(ptr);};
   return 0;
  }
 }
 return -1;
}

variable_types: struct GSTMT { void *hdbc; void *hstmt; struct GSTMT *next; } *


getinitfile

decompiled_code:
char *__fastcall getinitfile(char *s, int a2)
{
__uid_t v2; // eax
struct passwd *v3; // rax
const char *v4; // r12
size_t v5; // rax

if ( a2 <= 9 )
return 0LL;
v2 = getuid();
v3 = getpwuid(v2);
if ( !v3 )
return 0LL;
v4 = v3->pw_dir;
if ( v4 && *v4 )
{
v5 = strlen(v3->pw_dir) + 10;
}
else
{
v5 = 15LL;
v4 = "/home";
}
if ( v5 > a2 )
return 0LL;
sprintf(s, "%s%s", v4, "/.odbc.ini");
return s;
}

canonical_decompiled_code:
char *__fastcall func6(char *s, int a2)
{
__uid_t v2; // eax
struct passwd *v3; // rax
const char *v4; // r12
size_t v5; // rax

if ( a2 <= 9 )
return 0LL;
v2 = getuid();
v3 = getpwuid(v2);
if ( !v3 )
return 0LL;
v4 = v3->pw_dir;
if ( v4 && *v4 )
{
v5 = strlen(v3->pw_dir) + 10;
}
else
{
v5 = 15LL;
v4 = "/home";
}
if ( v5 > a2 )
return 0LL;
sprintf(s, "%s%s", v4, "/.odbc.ini");
return s;
}

original_code:
char*
getinitfile(char* buf, int size)
{
 int i, j;
 char* ptr;
 j = (("/odbc.ini")? strlen((char*)("/odbc.ini")):0) + 1;
 if( size < j )
 {
  return ((void *)0);
 }
 ptr = (char*)getpwuid(getuid());
 if( ptr == ((void *)0) )
 {
  return ((void *)0);
 }
 ptr = ((struct passwd*)ptr)->pw_dir;
 if( ptr == ((void *)0) || *ptr == '\0' )
 {
  ptr = "/home";
 }
 if( size < ((ptr)? strlen((char*)(ptr)):0) + j )
 {
  return ((void *)0);
 }
 sprintf( buf, "%s%s", ptr, "/.odbc.ini");
 return buf;
}

canonical_original_code:
char *getinitfile(char *buf, int size)
{
 int i; int j;
 char *ptr;
 j = (("/odbc.ini")? strlen((char *)("/odbc.ini")):0) + 1;
 if( size < j )
 {
  return ((void *)0);
 }
 ptr = (char *)getpwuid(getuid());
 if( ptr == ((void *)0) )
 {
  return ((void *)0);
 }
 ptr = ((struct passwd *)ptr)->pw_dir;
 if( ptr == ((void *)0) || *ptr == '\0' )
 {
  ptr = "/home";
 }
 if( size < ((ptr)? strlen((char *)(ptr)):0) + j )
 {
  return ((void *)0);
 }
 sprintf( buf, "%s%s", ptr, "/.odbc.ini");
 return buf;
}

variable_types:
buf
char *

variable_types: size int

variable_types: i int

variable_types: j int

variable_types:
ptr
char *

return_type: char *

user_defined_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; }


getkeyvalinstr

decompiled_code:
char *__fastcall getkeyvalinstr(char *s, int a2, const char *a3, char *a4, int a5)
{
char *v5; // rbp
size_t v8; // r13
int i; // er15
size_t v10; // rax
__int128 v12; // [rsp+0h] [rbp-438h] BYREF
char v13[1008]; // [rsp+10h] [rbp-428h] BYREF

v5 = s;
v12 = 0LL;
memset(v13, 0, sizeof(v13));
if ( !s )
return 0LL;
if ( !a4 )
return 0LL;
if ( !a3 )
return 0LL;
v8 = a5;
if ( a5 <= 0 )
return 0LL;
if ( a2 == -3 )
a2 = strlen(s);
if ( a2 <= 0 )
return 0LL;
for ( i = 0; ; i = 1 )
{
LABEL_9:
v5 = readtoken(v5, &v12);
if ( !(_BYTE)v12 )
return 0LL;
if ( (_WORD)v12 == 59 )
break;
if ( i != 1 )
goto LABEL_13;
if ( (_BYTE)v12 == 61 )
goto LABEL_17;
LABEL_24:
;
}
while ( 1 )
{
v5 = readtoken(v5, &v12);
if ( !(_BYTE)v12 )
return 0LL;
if ( (_BYTE)v12 == 59 )
{
i = BYTE1(v12);
if ( !BYTE1(v12) )
goto LABEL_9;
}
LABEL_13:
v10 = strlen(a3);
i = upper_strneq(&v12, a3, v10);
if ( !i )
goto LABEL_9;
v5 = readtoken(v5, &v12);
if ( !(_BYTE)v12 )
return 0LL;
if ( (_WORD)v12 != 59 )
{
if ( (_BYTE)v12 != 61 )
goto LABEL_24;
LABEL_17:
if ( BYTE1(v12) )
goto LABEL_24;
v5 = readtoken(v5, &v12);
if ( !(_BYTE)v12 )
return 0LL;
if ( (_WORD)v12 != 59 )
break;
}
}
if ( v8 >= strlen((const char *)&v12) + 1 )
return strncpy(a4, (const char *)&v12, v8);
return 0LL;
}

canonical_decompiled_code:
char *__fastcall func8(char *s, int a2, const char *a3, char *a4, int a5)
{
char *v5; // rbp
size_t v8; // r13
int i; // er15
size_t v10; // rax
__int128 v12; // [rsp+0h] [rbp-438h] BYREF
char v13[1008]; // [rsp+10h] [rbp-428h] BYREF

v5 = s;
v12 = 0LL;
memset(v13, 0, sizeof(v13));
if ( !s )
return 0LL;
if ( !a4 )
return 0LL;
if ( !a3 )
return 0LL;
v8 = a5;
if ( a5 <= 0 )
return 0LL;
if ( a2 == -3 )
a2 = strlen(s);
if ( a2 <= 0 )
return 0LL;
for ( i = 0; ; i = 1 )
{
LABEL_9:
v5 = readtoken(v5, &v12);
if ( !(_BYTE)v12 )
return 0LL;
if ( (_WORD)v12 == 59 )
break;
if ( i != 1 )
goto LABEL_13;
if ( (_BYTE)v12 == 61 )
goto LABEL_17;
LABEL_24:
;
}
while ( 1 )
{
v5 = readtoken(v5, &v12);
if ( !(_BYTE)v12 )
return 0LL;
if ( (_BYTE)v12 == 59 )
{
i = BYTE1(v12);
if ( !BYTE1(v12) )
goto LABEL_9;
}
LABEL_13:
v10 = strlen(a3);
i = upper_strneq(&v12, a3, v10);
if ( !i )
goto LABEL_9;
v5 = readtoken(v5, &v12);
if ( !(_BYTE)v12 )
return 0LL;
if ( (_WORD)v12 != 59 )
{
if ( (_BYTE)v12 != 61 )
goto LABEL_24;
LABEL_17:
if ( BYTE1(v12) )
goto LABEL_24;
v5 = readtoken(v5, &v12);
if ( !(_BYTE)v12 )
return 0LL;
if ( (_WORD)v12 != 59 )
break;
}
}
if ( v8 >= strlen((const char *)&v12) + 1 )
return strncpy(a4, (const char *)&v12, v8);
return 0LL;
}

original_code:
char* getkeyvalinstr(
  char* cnstr,
  int cnlen,
  char* keywd,
  char* value,
  int size )
{
 char token[1024] = { '\0' };
 int flag = 0;
 if( cnstr == ((void *)0) || value == ((void *)0)
  || keywd == ((void *)0) || size < 1 )
 {
  return ((void *)0);
 }
 if( cnlen == (-3) )
 {
  cnlen = ((cnstr)? strlen((char*)(cnstr)):0);
 }
 if( cnlen <= 0 )
 {
  return ((void *)0);
 }
 for(;;)
 {
  cnstr = readtoken(cnstr, token);
  if( *token == '\0' )
  {
   break;
  }
  if( (strcmp((char*)(token), (char*)(";")) == 0) )
  {
   flag = 0;
   continue;
  }
  switch(flag)
  {
   case 0:
    if( upper_strneq(token, keywd, strlen(keywd)) )
    {
     flag = 1;
    }
    break;
   case 1:
    if( (strcmp((char*)(token), (char*)("=")) == 0) )
    {
     flag = 2;
    }
    break;
   case 2:
    if( size < strlen(token) + 1 )
    {
     return ((void *)0);
    }
    (strncpy((char*)(value), (char*)(token), (size_t)(size)));
    return value;
   default:
    break;
  }
 }
 return ((void *)0);
}

canonical_original_code:
char *getkeyvalinstr(char *cnstr, int cnlen, char *keywd, char *value, int size)
{
 char token[1024] = { '\0' };
 int flag = 0;
 if( cnstr == ((void *)0) || value == ((void *)0)
  || keywd == ((void *)0) || size < 1 )
 {
  return ((void *)0);
 }
 if( cnlen == (-3) )
 {
  cnlen = ((cnstr)? strlen((char *)(cnstr)):0);
 }
 if( cnlen <= 0 )
 {
  return ((void *)0);
 }
 for(;;)
 {
  cnstr = readtoken(cnstr, token);
  if( *token == '\0' )
  {
   break;
  }
  if( (strcmp((char *)(token), (char *)(";")) == 0) )
  {
   flag = 0;
   continue;
  }
  switch(flag)
  {
   case 0:
    if( upper_strneq(token, keywd, strlen(keywd)) )
    {
     flag = 1;
    }
    break;
   case 1:
    if( (strcmp((char *)(token), (char *)("=")) == 0) )
    {
     flag = 2;
    }
    break;
   case 2:
    if( size < strlen(token) + 1 )
    {
     return ((void *)0);
    }
    (strncpy((char *)(value), (char *)(token), (unsigned long)(size)));
    return value;
   default:
    break;
  }
 }
 return ((void *)0);
}

variable_types:
cnstr
char *

variable_types: cnlen int

variable_types:
keywd
char *

variable_types:
value
char *

variable_types:
token
char [1024]

variable_types: flag int


decompiled_code:
__int64 __fastcall nndate2date(const char *a1, __int64 a2)
{
int v3; // ebx
int v4; // eax
unsigned int v5; // er12
__int64 v6; // rbx
void *i; // rsi
__int64 v9; // rax
int v10; // eax
char v11[4]; // [rsp+0h] [rbp-38h] BYREF
__int64 v12; // [rsp+4h] [rbp-34h] BYREF
int v13; // [rsp+Ch] [rbp-2Ch] BYREF

if ( !a1 || strlen(a1) <= 7 )
return 0xFFFFFFFFLL;
_isoc99_sscanf(a1, "%d %s %d", &v13, v11, &v12);
if ( (unsigned int)(v12 - 1) <= 0x62 )
LODWORD(v12) = v12 + 1900;
v3 = v13;
if ( (unsigned int)(v13 - 1) > 0x1E )
return 0xFFFFFFFFLL;
v4 = atoi(v11);
v5 = v4;
if ( v4 )
{
HIDWORD(v12) = v4;
if ( (unsigned int)(v4 - 1) <= 0xB )
{
v9 = v12;
*(_DWORD *)(a2 + 8) = v3;
*(_QWORD *)a2 = v9;
return 0LL;
}
return 0xFFFFFFFFLL;
}
v6 = 1LL;
for ( i = &LC0; !(unsigned int)upper_strneq(v11, i, 3LL); i = *(&month_name + v6++) )
{
if ( v6 == 12 )
return 0xFFFFFFFFLL;
}
*(_QWORD *)a2 = v12;
v10 = v13;
*(_DWORD *)(a2 + 4) = v6;
*(_DWORD *)(a2 + 8) = v10;
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, __int64 a2)
{
int v3; // ebx
int v4; // eax
unsigned int v5; // er12
__int64 v6; // rbx
void *i; // rsi
__int64 v9; // rax
int v10; // eax
char v11[4]; // [rsp+0h] [rbp-38h] BYREF
__int64 v12; // [rsp+4h] [rbp-34h] BYREF
int v13; // [rsp+Ch] [rbp-2Ch] BYREF

if ( !a1 || strlen(a1) <= 7 )
return 0xFFFFFFFFLL;
_isoc99_sscanf(a1, "%d %s %d", &v13, v11, &v12);
if ( (unsigned int)(v12 - 1) <= 0x62 )
LODWORD(v12) = v12 + 1900;
v3 = v13;
if ( (unsigned int)(v13 - 1) > 0x1E )
return 0xFFFFFFFFLL;
v4 = atoi(v11);
v5 = v4;
if ( v4 )
{
HIDWORD(v12) = v4;
if ( (unsigned int)(v4 - 1) <= 0xB )
{
v9 = v12;
*(_DWORD *)(a2 + 8) = v3;
*(_QWORD *)a2 = v9;
return 0LL;
}
return 0xFFFFFFFFLL;
}
v6 = 1LL;
for ( i = &LC0; !(unsigned int)upper_strneq(v11, i, 3LL); i = *(&month_name + v6++) )
{
if ( v6 == 12 )
return 0xFFFFFFFFLL;
}
*(_QWORD *)a2 = v12;
v10 = v13;
*(_DWORD *)(a2 + 4) = v6;
*(_DWORD *)(a2 + 8) = v10;
return v5;
}

original_code:
static int nndate2date(char* str, date_t* date)
{
 int i;
 char buf[4];
 date_t dt;
 if( ((str)? strlen((char*)(str)):0) < (("yyyy m d")? strlen((char*)("yyyy m d")):0) )
  return -1;
 sscanf(str, "%d %s %d", &(dt.day), buf, &(dt.year));
 if( dt.year < 100 && dt.year > 0 )
  dt.year += 1900;
 if( dt.day <= 0 || dt.day > 31 )
  return -1;
 if(i = atoi(buf))
 {
  dt.month = i;
  if( i <= 0 || i > 12 )
   return -1;
  *date = dt;
  date->month = i;
  return 0;
 }
 for(i=0;i<12;i++)
 {
  if( upper_strneq(buf, month_name[i], 3) )
  {
   *date = dt;
   date->month = i+1;
   return 0;
  }
 }
 return -1;
}

canonical_original_code:
static int nndate2date(char *str, struct date_t *date)
{
 int i;
 char buf[4];
 struct date_t dt;
 if( ((str)? strlen((char *)(str)):0) < (("yyyy m d")? strlen((char *)("yyyy m d")):0) )
  return -1;
 sscanf(str, "%d %s %d", &(dt.day), buf, &(dt.year));
 if( dt.year < 100 && dt.year > 0 )
  dt.year += 1900;
 if( dt.day <= 0 || dt.day > 31 )
  return -1;
 if(i = atoi(buf))
 {
  dt.month = i;
  if( i <= 0 || i > 12 )
   return -1;
  *date = dt;
  date->month = i;
  return 0;
 }
 for(i=0;i<12;i++)
 {
  if( upper_strneq(buf, month_name[i], 3) )
  {
   *date = dt;
   date->month = i+1;
   return 0;
  }
 }
 return -1;
}

variable_types:
str
char *

variable_types: struct date_t { int year; int month; int day; } *

variable_types:
buf
char [4]


decompiled_code:
__int64 __fastcall nnsql_nndatestr2date(const char *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // [rsp+4h] [rbp-24h] BYREF
int v4; // [rsp+Ch] [rbp-1Ch]

if ( a1 )
{
if ( atoi(a1) )
result = nndate2date(a1, (__int64)&v3);
else
result = nndate2date(a1 + 5, (__int64)&v3);
if ( (_DWORD)result )
v4 = 0;
if ( a2 )
{
*(_QWORD *)a2 = v3;
*(_DWORD *)(a2 + 8) = v4;
}
}
else
{
result = 0LL;
if ( a2 )
*(_DWORD *)(a2 + 8) = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // [rsp+4h] [rbp-24h] BYREF
int v4; // [rsp+Ch] [rbp-1Ch]

if ( a1 )
{
if ( atoi(a1) )
result = func0(a1, (__int64)&v3);
else
result = func0(a1 + 5, (__int64)&v3);
if ( (_DWORD)result )
v4 = 0;
if ( a2 )
{
*(_QWORD *)a2 = v3;
*(_DWORD *)(a2 + 8) = v4;
}
}
else
{
result = 0LL;
if ( a2 )
*(_DWORD *)(a2 + 8) = 0;
}
return result;
}

original_code:
int nnsql_nndatestr2date(char* str, date_t* date)
{
 int r;
 date_t dt;
 if( !str )
 {
  if(date)
   date->day = 0;
  return 0;
 }
 if(atoi(str))
  r = nndate2date(str, &dt);
 else
  r = nndate2date(str+5, &dt);
 if( r )
  dt.day = 0;
 if( date )
  *date = dt;
 return r;
}

canonical_original_code:
int nnsql_nndatestr2date(char *str, struct date_t *date)
{
 int r;
 struct date_t dt;
 if( !str )
 {
  if(date)
   date->day = 0;
  return 0;
 }
 if(atoi(str))
  r = nndate2date(str, &dt);
 else
  r = nndate2date(str+5, &dt);
 if( r )
  dt.day = 0;
 if( date )
  *date = dt;
 return r;
}

variable_types: r int

variable_types: struct date_t { int year; int month; int day; }


decompiled_code:
__int64 __fastcall nnsql_datecmp(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = (unsigned int)(*a1 - *a2);
if ( *a1 == *a2 )
{
result = (unsigned int)(a1[1] - a2[1]);
if ( !(_DWORD)result )
result = (unsigned int)(a1[2] - a2[2]);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = (unsigned int)(*a1 - *a2);
if ( *a1 == *a2 )
{
result = (unsigned int)(a1[1] - a2[1]);
if ( !(_DWORD)result )
result = (unsigned int)(a1[2] - a2[2]);
}
return result;
}

original_code:
int nnsql_datecmp(date_t* a, date_t* b)
{
 int r;
 if( (r = a->year - b->year) )
  return r;
 if( (r = a->month- b->month) )
  return r;
 return (a->day - b->day);
}

canonical_original_code:
int nnsql_datecmp(struct date_t *a, struct date_t *b)
{
 int r;
 if( (r = a->year - b->year) )
  return r;
 if( (r = a->month- b->month) )
  return r;
 return (a->day - b->day);
}

variable_types:
b
struct date_t *


decompiled_code:
__int64 __fastcall nnsql_odbcdatestr2date(char *nptr, int *a2)
{
int v4; // eax
int v5; // er14
__int64 v6; // rbx
void *i; // rsi
__int64 result; // rax
const char *v9; // rdi
int v10; // eax
int v11; // [rsp+Ch] [rbp-3Ch]

if ( !nptr )
{
if ( a2 )
{
a2[2] = 0;
return 0LL;
}
return 0LL;
}
if ( strlen(nptr) > 7 )
{
v11 = atoi(nptr);
v4 = atoi(nptr + 5);
v5 = v4;
if ( (unsigned int)v4 <= 0xC )
{
if ( v4 )
{
if ( nptr[5] == 48 || (v9 = nptr + 7, v4 > 9) )
v9 = nptr + 8;
}
else
{
v6 = 1LL;
for ( i = &LC0; ; i = *(&month_name + v6++) )
{
v5 = v6;
if ( (unsigned int)upper_strneq(nptr + 5, i, 3LL) )
break;
if ( v6 == 12 )
goto LABEL_9;
}
v9 = nptr + 9;
}
v10 = atoi(v9);
if ( (unsigned int)(v10 - 1) <= 0x1E )
{
if ( a2 )
{
a2[1] = v5;
a2[2] = v10;
*a2 = v11;
}
return 0LL;
}
}
}
LABEL_9:
result = 0xFFFFFFFFLL;
if ( a2 )
a2[2] = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *nptr, int *a2)
{
int v4; // eax
int v5; // er14
__int64 v6; // rbx
void *i; // rsi
__int64 result; // rax
const char *v9; // rdi
int v10; // eax
int v11; // [rsp+Ch] [rbp-3Ch]

if ( !nptr )
{
if ( a2 )
{
a2[2] = 0;
return 0LL;
}
return 0LL;
}
if ( strlen(nptr) > 7 )
{
v11 = atoi(nptr);
v4 = atoi(nptr + 5);
v5 = v4;
if ( (unsigned int)v4 <= 0xC )
{
if ( v4 )
{
if ( nptr[5] == 48 || (v9 = nptr + 7, v4 > 9) )
v9 = nptr + 8;
}
else
{
v6 = 1LL;
for ( i = &LC0; ; i = *(&month_name + v6++) )
{
v5 = v6;
if ( (unsigned int)upper_strneq(nptr + 5, i, 3LL) )
break;
if ( v6 == 12 )
goto LABEL_9;
}
v9 = nptr + 9;
}
v10 = atoi(v9);
if ( (unsigned int)(v10 - 1) <= 0x1E )
{
if ( a2 )
{
a2[1] = v5;
a2[2] = v10;
*a2 = v11;
}
return 0LL;
}
}
}
LABEL_9:
result = 0xFFFFFFFFLL;
if ( a2 )
a2[2] = 0;
return result;
}

original_code:
int nnsql_odbcdatestr2date(char* str, date_t* date)
{
 date_t dt;
 int i;
 if( ! str )
 {
  if( date )
   date->day = 0;
  return 0;
 }
 if( ((str)? strlen((char*)(str)):0) < (("yyyy-m-d")? strlen((char*)("yyyy-m-d")):0) )
 {
  if( date )
   date->day = 0;
  return -1;
 }
 dt.day = 0;
 dt.year = atoi(str); str += 5;
 dt.month = atoi(str);
 if( dt.month < 0 || dt.month > 12 )
 {
  if(date)
   date->day = 0;
  return -1;
 }
 if(! dt.month)
 {
  for(i=0;i<12;i++)
  {
   if( upper_strneq(str, month_name[i], 3) )
   {
    dt.month = i+1;
    break;
   }
  }
  if( ! dt.month )
  {
   if(date)
    date->day = 0;
   return -1;
  }
  str += 4;
 }
 else
 {
  if( *str == '0' || dt.month > 9 )
   str += 3;
  else
   str += 2;
 }
 dt.day = atoi(str);
 if( dt.day <= 0 || dt.day > 31 )
 {
  if(date)
   date->day = 0;
  return -1;
 }
 if(date)
  *date = dt;
 return 0;
}

canonical_original_code:
int nnsql_odbcdatestr2date(char *str, struct date_t *date)
{
 struct date_t dt;
 int i;
 if( ! str )
 {
  if( date )
   date->day = 0;
  return 0;
 }
 if( ((str)? strlen((char *)(str)):0) < (("yyyy-m-d")? strlen((char *)("yyyy-m-d")):0) )
 {
  if( date )
   date->day = 0;
  return -1;
 }
 dt.day = 0;
 dt.year = atoi(str); str += 5;
 dt.month = atoi(str);
 if( dt.month < 0 || dt.month > 12 )
 {
  if(date)
   date->day = 0;
  return -1;
 }
 if(! dt.month)
 {
  for(i=0;i<12;i++)
  {
   if( upper_strneq(str, month_name[i], 3) )
   {
    dt.month = i+1;
    break;
   }
  }
  if( ! dt.month )
  {
   if(date)
    date->day = 0;
   return -1;
  }
  str += 4;
 }
 else
 {
  if( *str == '0' || dt.month > 9 )
   str += 3;
  else
   str += 2;
 }
 dt.day = atoi(str);
 if( dt.day <= 0 || dt.day > 31 )
 {
  if(date)
   date->day = 0;
  return -1;
 }
 if(date)
  *date = dt;
 return 0;
}


decompiled_code:
__int64 __fastcall odate2date(__int16 *a1, __int64 a2, _DWORD *a3)
{
if ( *a3 > 0x270Fu || (unsigned int)(a3[1] - 1) > 0xB || (unsigned int)(a3[2] - 1) > 0x1E )
return -1LL;
*a3 = *a1;
a3[1] = (unsigned __int16)a1[1];
a3[2] = (unsigned __int16)a1[2];
return (__int64)a3;
}

original_code:
char* odate2date( odbc_date_t* odt, int size, date_t* dt )
{
 if( dt->year < 0 || dt->year > 9999
  || dt->month< 1 || dt->month> 12
  || dt->day < 1 || dt->day > 31 )
  return (char*)(-1);
 dt->year = odt->year;
 dt->month= odt->month;
 dt->day = odt->day;
 return (char*)dt;
}

canonical_original_code:
char *odate2date(struct DATE_STRUCT *odt, int size, struct date_t *dt)
{
 if( dt->year < 0 || dt->year > 9999
  || dt->month< 1 || dt->month> 12
  || dt->day < 1 || dt->day > 31 )
  return (char *)(-1);
 dt->year = odt->year;
 dt->month= odt->month;
 dt->day = odt->day;
 return (char *)dt;
}

variable_types: struct DATE_STRUCT { short year; unsigned short month; unsigned short day; } *


decompiled_code:
__int64 __fastcall tint2num(char *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1)
{
return *a1;
}

original_code:
char* tint2num( char* d )
{
 long num = *d;
 return (char*)num;
}

canonical_original_code:
char *tint2num(char *d)
{
 long num = *d;
 return (char *)num;
}

variable_types:
d
char *

variable_types: num long


decompiled_code:
__int64 __fastcall short2num(__int16 *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int16 *a1)
{
return *a1;
}

original_code:
char* short2num( short* d )
{
 long num = *d;
 return (char*)num;
}

canonical_original_code:
char *short2num(short *d)
{
 long num = *d;
 return (char *)num;
}

variable_types:
d
short *


decompiled_code:
__int64 __fastcall long2num(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
char* long2num( long* d )
{
 return (char*)*d;
}

canonical_original_code:
char *long2num(long *d)
{
 return (char *)*d;
}

variable_types:
d
long *


decompiled_code:
__int64 __fastcall num2tint(unsigned __int64 a1, _BYTE *a2, __int64 a3, unsigned __int64 *a4)
{
__int64 result; // rax

if ( a1 <= 0xFF )
{
*a2 = a1;
result = 0LL;
}
else
{
*a4 = a1;
result = -1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 a1, _BYTE *a2, __int64 a3, unsigned __int64 *a4)
{
__int64 result; // rax

if ( a1 <= 0xFF )
{
*a2 = a1;
result = 0LL;
}
else
{
*a4 = a1;
result = -1LL;
}
return result;
}

original_code:
static char* num2tint(long x, char* buf, long size, long* psize)
{
 unsigned long a = x, b = (unsigned char)(-1);
 if( a > b )
 {
  *psize = x;
  return (char*)(-1);
 }
 *buf = (char)x;
 return 0;
}

canonical_original_code:
static char *num2tint(long x, char *buf, long size, long *psize)
{
 unsigned long a = x; unsigned long b = (unsigned char)(-1);
 if( a > b )
 {
  *psize = x;
  return (char *)(-1);
 }
 *buf = (char)x;
 return 0;
}

variable_types: x long

variable_types:
buf
char *

variable_types: size long

variable_types:
psize
long *

variable_types:
a
unsigned long

variable_types:
b
unsigned long


decompiled_code:
__int64 __fastcall num2short(unsigned __int64 a1, _WORD *a2, __int64 a3, unsigned __int64 *a4)
{
__int64 result; // rax

if ( a1 <= 0xFFFF )
{
*a2 = a1;
result = 0LL;
}
else
{
*a4 = a1;
result = -1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int64 a1, _WORD *a2, __int64 a3, unsigned __int64 *a4)
{
__int64 result; // rax

if ( a1 <= 0xFFFF )
{
*a2 = a1;
result = 0LL;
}
else
{
*a4 = a1;
result = -1LL;
}
return result;
}

original_code:
static char* num2short(long x, short* buf, long size, long* psize)
{
 unsigned long a = x, b = (unsigned short)(-1);
 if( a > b)
 {
  *psize = x;
  return (char*)(-1);
 }
 *buf = (short)x;
 return 0;
}

canonical_original_code:
static char *num2short(long x, short *buf, long size, long *psize)
{
 unsigned long a = x; unsigned long b = (unsigned short)(-1);
 if( a > b)
 {
  *psize = x;
  return (char *)(-1);
 }
 *buf = (short)x;
 return 0;
}

variable_types:
buf
short *


decompiled_code:
__int64 __fastcall num2long(__int64 a1, _QWORD *a2)
{
*a2 = a1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _QWORD *a2)
{
*a2 = a1;
return 0LL;
}

original_code:
static char* num2long(long x, long* buf )
{
 *buf = x;
 return 0;
}

canonical_original_code:
static char *num2long(long x, long *buf)
{
 *buf = x;
 return 0;
}

variable_types:
buf
long *


original_code:
static char* date2odate(date_t* dt, odbc_date_t* buf)
{
 buf->year = dt->year;
 buf->month= dt->month;
 buf->day = dt->day;
 return 0;
}

canonical_original_code:
static char *date2odate(struct date_t *dt, struct DATE_STRUCT *buf)
{
 buf->year = dt->year;
 buf->month= dt->month;
 buf->day = dt->day;
 return 0;
}

variable_types: struct date_t { int year; int month; int day; } *

user_defined_types: struct DATE_STRUCT { short year; unsigned short month; unsigned short day; }


decompiled_code:
char *__fastcall char2str(char *src, int a2)
{
__int64 v2; // rbx
size_t v3; // r12
char *v4; // rax
char *v5; // rax
int v8; // eax

v2 = a2;
if ( a2 < 0 )
{
if ( src )
{
v8 = strlen(src);
v2 = v8;
v3 = v8 + 1;
}
else
{
v3 = 1LL;
v2 = 0LL;
}
}
else
{
v3 = a2 + 1;
}
v4 = (char *)malloc(v3);
if ( !v4 )
return (char *)-1LL;
v5 = strncpy(v4, src, v3);
v5[v2] = 0;
return v5;
}

canonical_decompiled_code:
char *__fastcall func8(char *src, int a2)
{
__int64 v2; // rbx
size_t v3; // r12
char *v4; // rax
char *v5; // rax
int v8; // eax

v2 = a2;
if ( a2 < 0 )
{
if ( src )
{
v8 = strlen(src);
v2 = v8;
v3 = v8 + 1;
}
else
{
v3 = 1LL;
v2 = 0LL;
}
}
else
{
v3 = a2 + 1;
}
v4 = (char *)malloc(v3);
if ( !v4 )
return (char *)-1LL;
v5 = strncpy(v4, src, v3);
v5[v2] = 0;
return v5;
}

original_code:
char* char2str( char* buf, int size )
{
 char* ptr;
 int len;
 if( size < 0 )
  size = ((buf)? strlen((char*)(buf)):0);
 ptr = (char*)(malloc((size_t)(size + 1)));
 if( ! ptr )
  return (char*)(-1);
 (strncpy((char*)(ptr), (char*)(buf), (size_t)(size+1)));
 ptr[size] = 0;
 return ptr;
}

canonical_original_code:
char *char2str(char *buf, int size)
{
 char *ptr;
 int len;
 if( size < 0 )
  size = ((buf)? strlen((char *)(buf)):0);
 ptr = (char *)(malloc((unsigned long)(size + 1)));
 if( ! ptr )
  return (char *)(-1);
 (strncpy((char *)(ptr), (char *)(buf), (unsigned long)(size+1)));
 ptr[size] = 0;
 return ptr;
}

variable_types: size int

variable_types:
ptr
char *

variable_types: len int


decompiled_code:
__int64 __fastcall str2char(char *src, char *dest, signed __int64 a3, signed __int64 *a4)
{
signed __int64 v4; // rax

v4 = 1LL;
if ( src )
v4 = strlen(src) + 1;
if ( v4 <= a3 )
a3 = v4;
if ( a3 )
{
strncpy(dest, src, a3);
dest[a3 - 1] = 0;
}
*a4 = a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(char *src, char *dest, signed __int64 a3, signed __int64 *a4)
{
signed __int64 v4; // rax

v4 = 1LL;
if ( src )
v4 = strlen(src) + 1;
if ( v4 <= a3 )
a3 = v4;
if ( a3 )
{
strncpy(dest, src, a3);
dest[a3 - 1] = 0;
}
*a4 = a3;
return 0LL;
}

original_code:
static char* str2char( char* ptr, char* buf, long size, long* psize)
{
 long len;
 len = ((ptr)? strlen((char*)(ptr)):0) + 1;
 if( len > size )
  len = size;
 if( len )
 {
  (strncpy((char*)(buf), (char*)(ptr), (size_t)(len)));
  buf[len - 1] = 0;
 }
 *psize = len;
 return 0;
}

canonical_original_code:
static char *str2char(char *ptr, char *buf, long size, long *psize)
{
 long len;
 len = ((ptr)? strlen((char *)(ptr)):0) + 1;
 if( len > size )
  len = size;
 if( len )
 {
  (strncpy((char *)(buf), (char *)(ptr), (unsigned long)(len)));
  buf[len - 1] = 0;
 }
 *psize = len;
 return 0;
}

variable_types: len long


decompiled_code:
__int64 __fastcall char2num(char *src, int a2)
{
char *v2; // rax
char v4[24]; // [rsp+0h] [rbp-18h] BYREF

if ( a2 < 0 )
a2 = strlen(src);
if ( a2 > 15 )
a2 = 15;
v2 = strncpy(v4, src, a2);
v4[15] = 0;
return atol(v2);
}

canonical_decompiled_code:
__int64 __fastcall func10(char *src, int a2)
{
char *v2; // rax
char v4[24]; // [rsp+0h] [rbp-18h] BYREF

if ( a2 < 0 )
a2 = strlen(src);
if ( a2 > 15 )
a2 = 15;
v2 = strncpy(v4, src, a2);
v4[15] = 0;
return atol(v2);
}

original_code:
char* char2num( char* buf, int size)
{
 char tbuf[16];
 if( size < 0 )
  size = strlen(buf);
 if( size>15 )
  size = 15;
 (strncpy((char*)(tbuf), (char*)(buf), (size_t)(size)));
 tbuf[15] = 0;
 return (char*)atol(tbuf);
}

canonical_original_code:
char *char2num(char *buf, int size)
{
 char tbuf[16];
 if( size < 0 )
  size = strlen(buf);
 if( size>15 )
  size = 15;
 (strncpy((char *)(tbuf), (char *)(buf), (unsigned long)(size)));
 tbuf[15] = 0;
 return (char *)atol(tbuf);
}

variable_types:
tbuf
char [16]


decompiled_code:
__int64 __fastcall str2long(const char *a1, __int64 *a2)
{
*a2 = atol(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(const char *a1, __int64 *a2)
{
*a2 = atol(a1);
return 0LL;
}

original_code:
static char* str2long( char* ptr, long* buf)
{
 *buf = atol(ptr);
 return 0;
}

canonical_original_code:
static char *str2long(char *ptr, long *buf)
{
 *buf = atol(ptr);
 return 0;
}


decompiled_code:
__int64 __fastcall str2tint(const char *a1, _BYTE *a2, __int64 a3, unsigned __int64 *a4)
{
unsigned __int64 v5; // rax
__int64 result; // rax

v5 = atol(a1);
if ( v5 <= 0xFF )
{
*a2 = v5;
result = 0LL;
}
else
{
*a4 = v5;
result = -1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(const char *a1, _BYTE *a2, __int64 a3, unsigned __int64 *a4)
{
unsigned __int64 v5; // rax
__int64 result; // rax

v5 = atol(a1);
if ( v5 <= 0xFF )
{
*a2 = v5;
result = 0LL;
}
else
{
*a4 = v5;
result = -1LL;
}
return result;
}

original_code:
static char* str2tint( char* ptr, char* buf, long size, long* psize )
{
 unsigned long a, b = (unsigned char)(-1);
 a = (unsigned long)atol(ptr);
 if( a > b )
 {
  *psize = a;
  return (char*)(-1);
 }
 *buf = (char)a;
 return 0;
}

canonical_original_code:
static char *str2tint(char *ptr, char *buf, long size, long *psize)
{
 unsigned long a; unsigned long b = (unsigned char)(-1);
 a = (unsigned long)atol(ptr);
 if( a > b )
 {
  *psize = a;
  return (char *)(-1);
 }
 *buf = (char)a;
 return 0;
}


decompiled_code:
__int64 __fastcall char2date(char *src, int a2, __int64 a3)
{
char *v4; // rax
char v6[40]; // [rsp+0h] [rbp-28h] BYREF

if ( a2 < 0 )
a2 = strlen(src);
if ( a2 > 15 )
a2 = 15;
v4 = strncpy(v6, src, a2);
v6[15] = 0;
if ( (unsigned int)nnsql_odbcdatestr2date(v4, a3) )
a3 = -1LL;
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func13(char *src, int a2, __int64 a3)
{
char *v4; // rax
char v6[40]; // [rsp+0h] [rbp-28h] BYREF

if ( a2 < 0 )
a2 = strlen(src);
if ( a2 > 15 )
a2 = 15;
v4 = strncpy(v6, src, a2);
v6[15] = 0;
if ( (unsigned int)nnsql_odbcdatestr2date(v4, a3) )
a3 = -1LL;
return a3;
}

original_code:
char* char2date( char* buf, int size, date_t* dt)
{
 char tbuf[16];
 if( size < 0 )
  size = strlen(buf);
 if( size > 15 )
  size = 15;
 (strncpy((char*)(tbuf), (char*)(buf), (size_t)(size)));
 tbuf[15] = 0;
 if( nnsql_odbcdatestr2date(tbuf, dt) )
  return (char*)(-1);
 return (char*)dt;
}

canonical_original_code:
char *char2date(char *buf, int size, struct date_t *dt)
{
 char tbuf[16];
 if( size < 0 )
  size = strlen(buf);
 if( size > 15 )
  size = 15;
 (strncpy((char *)(tbuf), (char *)(buf), (unsigned long)(size)));
 tbuf[15] = 0;
 if( nnsql_odbcdatestr2date(tbuf, dt) )
  return (char *)(-1);
 return (char *)dt;
}


decompiled_code:
__int64 __fastcall date2str(__int16 *a1)
{
__int16 v1; // bx
unsigned __int16 v2; // bp
char *v3; // r12
unsigned __int16 v5; // r13
char *v6; // rax

v1 = *a1;
if ( (unsigned __int16)*a1 > 0x270Fu )
return -1LL;
v2 = a1[1];
if ( (unsigned __int16)(v2 - 1) > 0xBu )
return -1LL;
v5 = a1[2];
if ( (unsigned __int16)(v5 - 1) > 0x1Eu )
return -1LL;
v6 = (char *)malloc(0xCuLL);
v3 = v6;
if ( !v6 )
return -1LL;
sprintf(v6, "%04d-%02d-%02d", (unsigned int)v1, v2, v5);
return (__int64)v3;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int16 *a1)
{
__int16 v1; // bx
unsigned __int16 v2; // bp
char *v3; // r12
unsigned __int16 v5; // r13
char *v6; // rax

v1 = *a1;
if ( (unsigned __int16)*a1 > 0x270Fu )
return -1LL;
v2 = a1[1];
if ( (unsigned __int16)(v2 - 1) > 0xBu )
return -1LL;
v5 = a1[2];
if ( (unsigned __int16)(v5 - 1) > 0x1Eu )
return -1LL;
v6 = (char *)malloc(0xCuLL);
v3 = v6;
if ( !v6 )
return -1LL;
sprintf(v6, "%04d-%02d-%02d", (unsigned int)v1, v2, v5);
return (__int64)v3;
}

original_code:
char* date2str( odbc_date_t* dt )
{
 char* ptr;
 if( dt->year < 0 || dt->year > 9999
  || dt->month< 1 || dt->month> 12
  || dt->day < 1 || dt->day > 31
  || !( ptr = (char*)(malloc((size_t)(12)))) )
  return (char*)(-1);
 sprintf(ptr, "%04d-%02d-%02d", dt->year, dt->month, dt->day);
 return ptr;
}

canonical_original_code:
char *date2str(struct DATE_STRUCT *dt)
{
 char *ptr;
 if( dt->year < 0 || dt->year > 9999
  || dt->month< 1 || dt->month> 12
  || dt->day < 1 || dt->day > 31
  || !( ptr = (char *)(malloc((unsigned long)(12)))) )
  return (char *)(-1);
 sprintf(ptr, "%04d-%02d-%02d", dt->year, dt->month, dt->day);
 return ptr;
}

variable_types: struct DATE_STRUCT { short year; unsigned short month; unsigned short day; } *


decompiled_code:
__int64 __fastcall tint2str(char *a1)
{
unsigned int v1; // er13
char *v2; // rax
char *v3; // r12

v1 = *a1;
v2 = (char *)malloc(5uLL);
if ( !v2 )
return -1LL;
v3 = v2;
sprintf(v2, "%d", v1);
return (__int64)v3;
}

canonical_decompiled_code:
__int64 __fastcall func15(char *a1)
{
unsigned int v1; // er13
char *v2; // rax
char *v3; // r12

v1 = *a1;
v2 = (char *)malloc(5uLL);
if ( !v2 )
return -1LL;
v3 = v2;
sprintf(v2, "%d", v1);
return (__int64)v3;
}

original_code:
char* tint2str( char* d )
{
 int c = *d;
 char* ptr;
 if( ! (ptr = (malloc((size_t)(5)))) )
  return (char*)(-1);
 sprintf(ptr, "%d", c);
 return ptr;
}

canonical_original_code:
char *tint2str(char *d)
{
 int c = *d;
 char *ptr;
 if( ! (ptr = (malloc((unsigned long)(5)))) )
  return (char *)(-1);
 sprintf(ptr, "%d", c);
 return ptr;
}

variable_types:
d
char *

variable_types: c int


decompiled_code:
__int64 __fastcall short2str(__int16 *a1)
{
unsigned int v1; // er13
char *v2; // rax
char *v3; // r12

v1 = *a1;
v2 = (char *)malloc(0x20uLL);
if ( !v2 )
return -1LL;
v3 = v2;
sprintf(v2, "%d", v1);
return (__int64)v3;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int16 *a1)
{
unsigned int v1; // er13
char *v2; // rax
char *v3; // r12

v1 = *a1;
v2 = (char *)malloc(0x20uLL);
if ( !v2 )
return -1LL;
v3 = v2;
sprintf(v2, "%d", v1);
return (__int64)v3;
}

original_code:
char* short2str( short* d )
{
 int c = *d;
 char* ptr;
 if( ! (ptr = (malloc((size_t)(32)))) )
  return (char*)(-1);
 sprintf(ptr, "%d", c);
 return ptr;
}

canonical_original_code:
char *short2str(short *d)
{
 int c = *d;
 char *ptr;
 if( ! (ptr = (malloc((unsigned long)(32)))) )
  return (char *)(-1);
 sprintf(ptr, "%d", c);
 return ptr;
}

variable_types:
d
short *


decompiled_code:
__int64 __fastcall long2str(__int64 *a1)
{
__int64 v1; // r13
char *v2; // rax
char *v3; // r12

v1 = *a1;
v2 = (char *)malloc(0x40uLL);
if ( !v2 )
return -1LL;
v3 = v2;
sprintf(v2, "%ld", v1);
return (__int64)v3;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 *a1)
{
__int64 v1; // r13
char *v2; // rax
char *v3; // r12

v1 = *a1;
v2 = (char *)malloc(0x40uLL);
if ( !v2 )
return -1LL;
v3 = v2;
sprintf(v2, "%ld", v1);
return (__int64)v3;
}

original_code:
char* long2str( long* d )
{
 long l = *d;
 char* ptr;
 if( ! (ptr = (malloc((size_t)(64)))) )
  return (char*)(-1);
 sprintf(ptr, "%ld", l);
 return ptr;
}

canonical_original_code:
char *long2str(long *d)
{
 long l = *d;
 char *ptr;
 if( ! (ptr = (malloc((unsigned long)(64)))) )
  return (char *)(-1);
 sprintf(ptr, "%ld", l);
 return ptr;
}

variable_types:
d
long *

variable_types: l long


decompiled_code:
__int64 __fastcall date2char(unsigned int *a1, char *a2, __int64 a3, _QWORD *a4)
{
*a4 = 11LL;
if ( a3 <= 10 )
return -1LL;
sprintf(a2, "%04d-%02d-%02d", *a1, a1[1], a1[2]);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func18(unsigned int *a1, char *a2, __int64 a3, _QWORD *a4)
{
*a4 = 11LL;
if ( a3 <= 10 )
return -1LL;
sprintf(a2, "%04d-%02d-%02d", *a1, a1[1], a1[2]);
return 0LL;
}

original_code:
static char* date2char(date_t* dt, char* buf, long size, long* psize)
{
 *psize = 11;
 if(size < 11)
  return (char*)(-1);
 sprintf(buf, "%04d-%02d-%02d", dt->year, dt->month, dt->day);
 return 0;
}

canonical_original_code:
static char *date2char(struct date_t *dt, char *buf, long size, long *psize)
{
 *psize = 11;
 if(size < 11)
  return (char *)(-1);
 sprintf(buf, "%04d-%02d-%02d", dt->year, dt->month, dt->day);
 return 0;
}

variable_types:
buf
char *

variable_types: size long

variable_types:
psize
long *


decompiled_code:
__int64 __fastcall num2char(__int64 a1, char *a2, signed __int64 a3, signed __int64 *a4)
{
signed __int64 v6; // rax
char v8[88]; // [rsp+0h] [rbp-58h] BYREF

sprintf(v8, "%ld", a1);
v6 = 1LL;
if ( a2 )
v6 = strlen(a2) + 1;
*a4 = v6;
if ( v6 > a3 )
return -1LL;
strcpy(a2, v8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, char *a2, signed __int64 a3, signed __int64 *a4)
{
signed __int64 v6; // rax
char v8[88]; // [rsp+0h] [rbp-58h] BYREF

sprintf(v8, "%ld", a1);
v6 = 1LL;
if ( a2 )
v6 = strlen(a2) + 1;
*a4 = v6;
if ( v6 > a3 )
return -1LL;
strcpy(a2, v8);
return 0LL;
}

original_code:
static char* num2char( long x, char* buf, long size, long* psize)
{
 char tbuf[48];
 sprintf(tbuf, "%ld", x);
 *psize = ((buf)? strlen((char*)(buf)):0) + 1;
 if(*psize > size )
  return (char*)(-1);
 (strcpy((char*)(buf), (char*)(tbuf)));
 return 0;
}

canonical_original_code:
static char *num2char(long x, char *buf, long size, long *psize)
{
 char tbuf[48];
 sprintf(tbuf, "%ld", x);
 *psize = ((buf)? strlen((char *)(buf)):0) + 1;
 if(*psize > size )
  return (char *)(-1);
 (strcpy((char *)(buf), (char *)(tbuf)));
 return 0;
}

variable_types: x long

variable_types:
tbuf
char [48]


decompiled_code:
__int64 __fastcall str2date(__int64 a1, _WORD *a2)
{
int v2; // er8
__int64 result; // rax
int v4; // [rsp+4h] [rbp-14h] BYREF
int v5; // [rsp+8h] [rbp-10h]
int v6; // [rsp+Ch] [rbp-Ch]

v2 = nnsql_nndatestr2date(a1, &v4);
result = -1LL;
if ( !v2 )
{
*a2 = v4;
a2[1] = v5;
a2[2] = v6;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, _WORD *a2)
{
int v2; // er8
__int64 result; // rax
int v4; // [rsp+4h] [rbp-14h] BYREF
int v5; // [rsp+8h] [rbp-10h]
int v6; // [rsp+Ch] [rbp-Ch]

v2 = nnsql_nndatestr2date(a1, &v4);
result = -1LL;
if ( !v2 )
{
*a2 = v4;
a2[1] = v5;
a2[2] = v6;
result = 0LL;
}
return result;
}

original_code:
static char* str2date( char* ptr, odbc_date_t* buf )
{
 date_t dt;
 if( nnsql_nndatestr2date(ptr, &dt) )
  return (char*)(-1);
 buf->year = dt.year;
 buf->month= dt.month;
 buf->day = dt.day;
 return 0;
}

canonical_original_code:
static char *str2date(char *ptr, struct DATE_STRUCT *buf)
{
 struct date_t dt;
 if( nnsql_nndatestr2date(ptr, &dt) )
  return (char *)(-1);
 buf->year = dt.year;
 buf->month= dt.month;
 buf->day = dt.day;
 return 0;
}

variable_types: struct date_t { int year; int month; int day; }


decompiled_code:
__int64 __fastcall str2short(const char *a1, _WORD *a2, __int64 a3, _QWORD *a4)
{
int v5; // eax
__int64 result; // rax

v5 = atoi(a1);
if ( (unsigned __int64)v5 <= 0xFFFF )
{
*a2 = v5;
result = 0LL;
}
else
{
*a4 = v5;
result = -1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func21(const char *a1, _WORD *a2, __int64 a3, _QWORD *a4)
{
int v5; // eax
__int64 result; // rax

v5 = atoi(a1);
if ( (unsigned __int64)v5 <= 0xFFFF )
{
*a2 = v5;
result = 0LL;
}
else
{
*a4 = v5;
result = -1LL;
}
return result;
}

original_code:
static char* str2short( char* ptr, short* buf, long size, long* psize)
{
 unsigned long a, b = (unsigned short)(-1);
 a = atoi(ptr);
 if( a > b )
 {
  *psize = a;
  return (char*)(-1);
 }
 *buf = (short)a;
 return 0;
}

canonical_original_code:
static char *str2short(char *ptr, short *buf, long size, long *psize)
{
 unsigned long a; unsigned long b = (unsigned short)(-1);
 a = atoi(ptr);
 if( a > b )
 {
  *psize = a;
  return (char *)(-1);
 }
 *buf = (short)a;
 return 0;
}

variable_types:
buf
short *

variable_types:
a
unsigned long

variable_types:
b
unsigned long


decompiled_code:
__int64 __fastcall nnodbc_get_c2sql_cvt(int a1, int a2)
{
__int64 v2; // rax
int v3; // edx
__int64 v4; // rcx
int v5; // edx
__int64 v6; // rdx
__int64 v8; // rax

v2 = 1LL;
v3 = -6;
if ( a1 == 1 )
{
v8 = 0LL;
}
else
{
while ( 1 )
{
v4 = (int)v2++;
if ( v3 == a1 )
break;
v3 = ctype_idx_tab[2 * v2];
}
v8 = ctype_idx_tab[2 * v4 + 1];
if ( (_DWORD)v8 == -1 )
return 0LL;
}
switch ( a2 )
{
case 1:
v6 = 0LL;
return (__int64)*(&c2sql_cvt_tab[3 * v8] + v6);
case 12:
v5 = 1;
break;
case -1:
v5 = 2;
break;
case -6:
v5 = 3;
break;
case 5:
v5 = 4;
break;
default:
v5 = (a2 != 4) + 5;
break;
}
v6 = sqltype_idx_tab[2 * v5 + 1];
if ( (_DWORD)v6 != -1 )
return (__int64)*(&c2sql_cvt_tab[3 * v8] + v6);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func22(int a1, int a2)
{
__int64 v2; // rax
int v3; // edx
__int64 v4; // rcx
int v5; // edx
__int64 v6; // rdx
__int64 v8; // rax

v2 = 1LL;
v3 = -6;
if ( a1 == 1 )
{
v8 = 0LL;
}
else
{
while ( 1 )
{
v4 = (int)v2++;
if ( v3 == a1 )
break;
v3 = ctype_idx_tab[2 * v2];
}
v8 = ctype_idx_tab[2 * v4 + 1];
if ( (_DWORD)v8 == -1 )
return 0LL;
}
switch ( a2 )
{
case 1:
v6 = 0LL;
return (__int64)*(&c2sql_cvt_tab[3 * v8] + v6);
case 12:
v5 = 1;
break;
case -1:
v5 = 2;
break;
case -6:
v5 = 3;
break;
case 5:
v5 = 4;
break;
default:
v5 = (a2 != 4) + 5;
break;
}
v6 = sqltype_idx_tab[2 * v5 + 1];
if ( (_DWORD)v6 != -1 )
return (__int64)*(&c2sql_cvt_tab[3 * v8] + v6);
return 0LL;
}

original_code:
fptr_t nnodbc_get_c2sql_cvt(int ctype, int sqltype)
{
 int i, cidx = -1, sqlidx = -1;
 for(i=0; i< sizeof(ctype_idx_tab); i++ )
 {
  if( ctype_idx_tab[i].ctype == ctype )
  {
   cidx = ctype_idx_tab[i].idx;
   break;
  }
 }
 if( cidx == -1 )
  return 0;
 for(i=0; i< sizeof(ctype_idx_tab); i++ )
 {
  if( sqltype_idx_tab[i].sqltype == sqltype )
  {
   sqlidx = sqltype_idx_tab[i].idx;
   break;
  }
 }
 if( sqlidx == -1 )
  return 0;
 return c2sql_cvt_tab[cidx][sqlidx];
}

canonical_original_code:
char *(*nnodbc_get_c2sql_cvt(int ctype, int sqltype))()
{
 int i; int cidx = -1; int sqlidx = -1;
 for(i=0; i< sizeof(ctype_idx_tab); i++ )
 {
  if( ctype_idx_tab[i].ctype == ctype )
  {
   cidx = ctype_idx_tab[i].idx;
   break;
  }
 }
 if( cidx == -1 )
  return 0;
 for(i=0; i< sizeof(ctype_idx_tab); i++ )
 {
  if( sqltype_idx_tab[i].sqltype == sqltype )
  {
   sqlidx = sqltype_idx_tab[i].idx;
   break;
  }
 }
 if( sqlidx == -1 )
  return 0;
 return c2sql_cvt_tab[cidx][sqlidx];
}

variable_types: ctype int

variable_types: sqltype int

variable_types: i int

variable_types: cidx int

variable_types: sqlidx int


decompiled_code:
__int64 __fastcall nnodbc_get_sql2c_cvt(int a1, int a2)
{
__int64 v2; // rax
int v3; // edx
__int64 v4; // rcx
int v5; // eax
__int64 v6; // rax
__int64 v8; // rdx

v2 = 1LL;
v3 = -6;
if ( a2 == 1 )
{
v8 = 0LL;
}
else
{
while ( 1 )
{
v4 = (int)v2++;
if ( v3 == a2 )
break;
v3 = ctype_idx_tab[2 * v2];
}
v8 = ctype_idx_tab[2 * v4 + 1];
if ( (_DWORD)v8 == -1 )
return 0LL;
}
switch ( a1 )
{
case 1:
v6 = 0LL;
return (__int64)*(&sql2c_cvt_tab + 5 * v6 + v8);
case 12:
v5 = 1;
break;
case -1:
v5 = 2;
break;
case -6:
v5 = 3;
break;
case 5:
v5 = 4;
break;
default:
v5 = (a1 != 4) + 5;
break;
}
v6 = sqltype_idx_tab[2 * v5 + 1];
if ( (_DWORD)v6 != -1 )
return (__int64)*(&sql2c_cvt_tab + 5 * v6 + v8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func23(int a1, int a2)
{
__int64 v2; // rax
int v3; // edx
__int64 v4; // rcx
int v5; // eax
__int64 v6; // rax
__int64 v8; // rdx

v2 = 1LL;
v3 = -6;
if ( a2 == 1 )
{
v8 = 0LL;
}
else
{
while ( 1 )
{
v4 = (int)v2++;
if ( v3 == a2 )
break;
v3 = ctype_idx_tab[2 * v2];
}
v8 = ctype_idx_tab[2 * v4 + 1];
if ( (_DWORD)v8 == -1 )
return 0LL;
}
switch ( a1 )
{
case 1:
v6 = 0LL;
return (__int64)*(&sql2c_cvt_tab + 5 * v6 + v8);
case 12:
v5 = 1;
break;
case -1:
v5 = 2;
break;
case -6:
v5 = 3;
break;
case 5:
v5 = 4;
break;
default:
v5 = (a1 != 4) + 5;
break;
}
v6 = sqltype_idx_tab[2 * v5 + 1];
if ( (_DWORD)v6 != -1 )
return (__int64)*(&sql2c_cvt_tab + 5 * v6 + v8);
return 0LL;
}

original_code:
fptr_t nnodbc_get_sql2c_cvt(int sqltype, int ctype)
{
 int i, cidx = -1, sqlidx = -1;
 for(i=0; i< sizeof(ctype_idx_tab); i++ )
 {
  if( ctype_idx_tab[i].ctype == ctype )
  {
   cidx = ctype_idx_tab[i].idx;
   break;
  }
 }
 if( cidx == -1 )
  return 0;
 for(i=0; i< sizeof(ctype_idx_tab); i++ )
 {
  if( sqltype_idx_tab[i].sqltype == sqltype )
  {
   sqlidx = sqltype_idx_tab[i].idx;
   break;
  }
 }
 if( sqlidx == -1 )
  return 0;
 return sql2c_cvt_tab[sqlidx][cidx];
}

canonical_original_code:
char *(*nnodbc_get_sql2c_cvt(int sqltype, int ctype))()
{
 int i; int cidx = -1; int sqlidx = -1;
 for(i=0; i< sizeof(ctype_idx_tab); i++ )
 {
  if( ctype_idx_tab[i].ctype == ctype )
  {
   cidx = ctype_idx_tab[i].idx;
   break;
  }
 }
 if( cidx == -1 )
  return 0;
 for(i=0; i< sizeof(ctype_idx_tab); i++ )
 {
  if( sqltype_idx_tab[i].sqltype == sqltype )
  {
   sqlidx = sqltype_idx_tab[i].idx;
   break;
  }
 }
 if( sqlidx == -1 )
  return 0;
 return sql2c_cvt_tab[sqlidx][cidx];
}


decompiled_code:
_BOOL8 __fastcall nnodbc_errstkempty(__int64 a1)
{
_BOOL8 result; // rax

if ( a1 )
result = *(_DWORD *)(a1 + 48) == 0;
else
result = 1LL;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1)
{
_BOOL8 result; // rax

if ( a1 )
result = *(_DWORD *)(a1 + 48) == 0;
else
result = 1LL;
return result;
}

original_code:
int nnodbc_errstkempty(void* stack)
{
 err_stack_t* err_stack = stack;
 if( ! err_stack
  || ! err_stack->top )
  return 1;
 return 0;
}

canonical_original_code:
int nnodbc_errstkempty(void *stack)
{
 struct err_stack_t *err_stack = stack;
 if( ! err_stack
  || ! err_stack->top )
  return 1;
 return 0;
}

variable_types:
stack
void *

variable_types: struct err_stack_t { struct err_t { int code; char *msg; } stack[3]; int top; } *

user_defined_types: struct err_stack_t { struct err_t stack[3]; int top; }


decompiled_code:
void __fastcall nnodbc_errstkunset(__int64 a1)
{
if ( a1 )
*(_DWORD *)(a1 + 48) = 0;
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
if ( a1 )
*(_DWORD *)(a1 + 48) = 0;
}

original_code:
void nnodbc_errstkunset(void* stack)
{
 if( stack )
  ((err_stack_t*)stack)->top = 0;
}

canonical_original_code:
void nnodbc_errstkunset(void *stack)
{
 if( stack )
  ((struct err_stack_t *)stack)->top = 0;
}


decompiled_code:
_BOOL8 __fastcall nnodbc_poperr(__int64 a1)
{
_BOOL8 result; // rax

result = nnodbc_errstkempty(a1);
if ( !result )
--*(_DWORD *)(a1 + 48);
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
_BOOL8 result; // rax

result = func1(a1);
if ( !result )
--*(_DWORD *)(a1 + 48);
return result;
}

original_code:
void nnodbc_poperr(void* stack )
{
 err_stack_t* err_stack = stack;
 if( ! nnodbc_errstkempty( err_stack ) )
  err_stack->top --;
 return;
}

canonical_original_code:
void nnodbc_poperr(void *stack)
{
 struct err_stack_t *err_stack = stack;
 if( ! nnodbc_errstkempty( err_stack ) )
  err_stack->top --;
 return;
}


decompiled_code:
__int64 __fastcall nnodbc_getsqlstatcode(__int64 a1)
{
__int64 result; // rax
unsigned int *v2; // rdx

result = is_sqlerr_isra_0(*(_QWORD *)(a1 + 16LL * *(int *)(a1 + 48) - 16 + 8));
if ( (_DWORD)result )
result = *v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax
unsigned int *v2; // rdx

result = func0(*(_QWORD *)(a1 + 16LL * *(int *)(a1 + 48) - 16 + 8));
if ( (_DWORD)result )
result = *v2;
return result;
}

original_code:
int nnodbc_getsqlstatcode(void* stack)
{
 err_stack_t* err_stack = stack;
 err_t* err;
 err = err_stack->stack + err_stack->top - 1;
 if( ! is_sqlerr(err) )
  return 0;
 return err->code;
}

canonical_original_code:
int nnodbc_getsqlstatcode(void *stack)
{
 struct err_stack_t *err_stack = stack;
 struct err_t *err;
 err = err_stack->stack + err_stack->top - 1;
 if( ! is_sqlerr(err) )
  return 0;
 return err->code;
}

variable_types:
err
struct err_t { int code; char *msg; } *


decompiled_code:
const char *__fastcall nnodbc_getsqlstatstr(__int64 a1)
{
int *v1; // rdx
int v2; // ecx
char *v3; // rax
int v4; // edx
const char *v5; // r8

if ( !is_sqlerr_isra_0(*(_QWORD *)(a1 + 16LL * *(int *)(a1 + 48) - 16 + 8)) )
return 0LL;
v2 = *v1;
v3 = (char *)&unk_E98;
v4 = 0;
v5 = "00000";
while ( v2 != v4 )
{
v5 = (const char *)*((_QWORD *)v3 + 1);
if ( !v5 )
break;
v4 = *(_DWORD *)v3;
v3 += 24;
}
return v5;
}

canonical_decompiled_code:
const char *__fastcall func5(__int64 a1)
{
int *v1; // rdx
int v2; // ecx
char *v3; // rax
int v4; // edx
const char *v5; // r8

if ( !func0(*(_QWORD *)(a1 + 16LL * *(int *)(a1 + 48) - 16 + 8)) )
return 0LL;
v2 = *v1;
v3 = (char *)&unk_E98;
v4 = 0;
v5 = "00000";
while ( v2 != v4 )
{
v5 = (const char *)*((_QWORD *)v3 + 1);
if ( !v5 )
break;
v4 = *(_DWORD *)v3;
v3 += 24;
}
return v5;
}

original_code:
char* nnodbc_getsqlstatstr(void* stack)
{
 err_stack_t* err_stack = stack;
 err_t* err;
 int i;
 err = err_stack->stack + err_stack->top - 1;
 if( ! is_sqlerr(err) )
  return 0;
 for(i=0;sqlerrmsg_tab[i].stat;i++)
 {
  if( sqlerrmsg_tab[i].code == err->code )
   return sqlerrmsg_tab[i].stat;
 }
 return 0;
}

canonical_original_code:
char *nnodbc_getsqlstatstr(void *stack)
{
 struct err_stack_t *err_stack = stack;
 struct err_t *err;
 int i;
 err = err_stack->stack + err_stack->top - 1;
 if( ! is_sqlerr(err) )
  return 0;
 for(i=0;sqlerrmsg_tab[i].stat;i++)
 {
  if( sqlerrmsg_tab[i].code == err->code )
   return sqlerrmsg_tab[i].stat;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall nnodbc_getsqlstatmsg(__int64 a1)
{
int *v1; // rdx
int v2; // esi
_QWORD *v3; // rax
int v4; // ecx
int v5; // edx
__int64 v6; // r8

if ( !is_sqlerr_isra_0(*(_QWORD *)(a1 + 16LL * *(int *)(a1 + 48) - 16 + 8)) )
return 0LL;
v2 = *v1;
v3 = &unk_E98;
v4 = 0;
v5 = 0;
while ( v2 != v4 )
{
v6 = v3[1];
++v5;
if ( !v6 )
return v6;
v4 = *(_DWORD *)v3;
v3 += 3;
}
return *((_QWORD *)&sqlerrmsg_tab + 3 * v5 + 2);
}

original_code:
char* nnodbc_getsqlstatmsg(void* stack)
{
 err_stack_t* err_stack = stack;
 err_t* err;
 int i;
 err = err_stack->stack + err_stack->top - 1;
 if( ! is_sqlerr(err) )
  return 0;
 for(i=0;sqlerrmsg_tab[i].stat;i++)
 {
  if( sqlerrmsg_tab[i].code == err->code )
   return sqlerrmsg_tab[i].msg;
 }
 return 0;
}

canonical_original_code:
char *nnodbc_getsqlstatmsg(void *stack)
{
 struct err_stack_t *err_stack = stack;
 struct err_t *err;
 int i;
 err = err_stack->stack + err_stack->top - 1;
 if( ! is_sqlerr(err) )
  return 0;
 for(i=0;sqlerrmsg_tab[i].stat;i++)
 {
  if( sqlerrmsg_tab[i].code == err->code )
   return sqlerrmsg_tab[i].msg;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall nnodbc_getnativcode(__int64 a1)
{
unsigned int *v1; // rdx
_BOOL4 v2; // er8
__int64 result; // rax

v2 = is_sqlerr_isra_0(*(_QWORD *)(a1 + 16LL * *(int *)(a1 + 48) - 16 + 8));
result = 0LL;
if ( !v2 )
result = *v1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
unsigned int *v1; // rdx
_BOOL4 v2; // er8
__int64 result; // rax

v2 = func0(*(_QWORD *)(a1 + 16LL * *(int *)(a1 + 48) - 16 + 8));
result = 0LL;
if ( !v2 )
result = *v1;
return result;
}

original_code:
int nnodbc_getnativcode(void* stack)
{
 err_stack_t* err_stack = stack;
 err_t* err;
 err = err_stack->stack + err_stack->top - 1;
 if( is_sqlerr(err) )
  return 0;
 return err->code;
}

canonical_original_code:
int nnodbc_getnativcode(void *stack)
{
 struct err_stack_t *err_stack = stack;
 struct err_t *err;
 err = err_stack->stack + err_stack->top - 1;
 if( is_sqlerr(err) )
  return 0;
 return err->code;
}


decompiled_code:
__int64 __fastcall nnodbc_getnativemsg(__int64 a1)
{
return *(_QWORD *)(a1 + 16LL * *(int *)(a1 + 48) - 8);
}

original_code:
char* nnodbc_getnativemsg(void* stack)
{
 err_stack_t* err_stack = stack;
 err_t* err;
 err = err_stack->stack + err_stack->top - 1;
 return err->msg;
}

canonical_original_code:
char *nnodbc_getnativemsg(void *stack)
{
 struct err_stack_t *err_stack = stack;
 struct err_t *err;
 err = err_stack->stack + err_stack->top - 1;
 return err->msg;
}


decompiled_code:
__int64 __fastcall nnodbc_clearerr(void *a1)
{
if ( a1 )
free(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(void *a1)
{
if ( a1 )
free(a1);
return 0LL;
}

original_code:
void* nnodbc_clearerr(void* stack)
{
 {if(stack) free(stack);};
 return 0;
}

canonical_original_code:
void *nnodbc_clearerr(void *stack)
{
 {if(stack) free(stack);};
 return 0;
}


SQLDummyOrdinal

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

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

original_code:
RETCODE SQLDummyOrdinal(void)
{
 return 0;
}

canonical_original_code:
short SQLDummyOrdinal()
{
 return 0;
}

return_type: short


init

decompiled_code:
__int64 init()
{
getGlobalDefaults("PostgreSQL", "ODBCINST.INI", 0LL);
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
getGlobalDefaults("PostgreSQL", "ODBCINST.INI", 0LL);
return 1LL;
}

original_code:
static int
__attribute__((constructor))
init(void)
{
 getGlobalDefaults("PostgreSQL", "ODBCINST.INI", (int)0);
 return (int)1;
}

canonical_original_code:
static int init()
{
 getGlobalDefaults("PostgreSQL", "ODBCINST.INI", (int)0);
 return (int)1;
}


sqlputdata

decompiled_code:
__int64 __fastcall sqlputdata(__int64 a1, int a2, __int64 a3)
{
__int64 result; // rax
__int64 v4; // rdi

switch ( *(_DWORD *)(*(_QWORD *)(a1 + 24) + 80LL * a2 - 28) )
{
case 0xFFFFFFFA:
case 4:
case 5:
nnsql_putnum(*(_QWORD *)(a1 + 40));
result = 0LL;
break;
case 0xFFFFFFFB:
case 0xFFFFFFFC:
case 0xFFFFFFFD:
case 0xFFFFFFFE:
case 0:
case 2:
case 3:
case 6:
case 7:
case 8:
case 0xA:
case 0xB:
result = 0xFFFFFFFFLL;
break;
case 0xFFFFFFFF:
case 1:
case 0xC:
v4 = *(_QWORD *)(a1 + 40);
if ( !a3 )
goto LABEL_8;
nnsql_putstr(v4);
result = 0LL;
break;
case 9:
v4 = *(_QWORD *)(a1 + 40);
if ( a3 )
{
nnsql_putdate(v4);
result = 0LL;
}
else
{
LABEL_8:
nnsql_putnull(v4);
result = 0LL;
}
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

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

switch ( *(_DWORD *)(*(_QWORD *)(a1 + 24) + 80LL * a2 - 28) )
{
case 0xFFFFFFFA:
case 4:
case 5:
nnsql_putnum(*(_QWORD *)(a1 + 40));
result = 0LL;
break;
case 0xFFFFFFFB:
case 0xFFFFFFFC:
case 0xFFFFFFFD:
case 0xFFFFFFFE:
case 0:
case 2:
case 3:
case 6:
case 7:
case 8:
case 0xA:
case 0xB:
result = 0xFFFFFFFFLL;
break;
case 0xFFFFFFFF:
case 1:
case 0xC:
v4 = *(_QWORD *)(a1 + 40);
if ( !a3 )
goto LABEL_8;
nnsql_putstr(v4);
result = 0LL;
break;
case 9:
v4 = *(_QWORD *)(a1 + 40);
if ( a3 )
{
nnsql_putdate(v4);
result = 0LL;
}
else
{
LABEL_8:
nnsql_putnull(v4);
result = 0LL;
}
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

original_code:
int sqlputdata (
  stmt_t* pstmt,
  int ipar,
  char* data )
{
 param_t* ppar;
 ppar = pstmt->ppar + ipar - 1;
 switch( ppar->sqltype )
 {
  case 1:
  case 12:
  case (-1):
   if( ! data )
    nnsql_putnull(pstmt->yystmt, ipar );
   else
    nnsql_putstr(pstmt->yystmt, ipar, (char*)data);
   break;
  case (-6):
  case 5:
  case 4:
   nnsql_putnum(pstmt->yystmt, ipar, (long)data);
   break;
  case 9:
   if(!data )
    nnsql_putnull(pstmt->yystmt, ipar );
   else
    nnsql_putdate(pstmt->yystmt, ipar, (date_t*)data);
   break;
  default:
   return -1;
 }
 return 0;
}

canonical_original_code:
int sqlputdata(struct stmt_t *pstmt, int ipar, char *data)
{
 struct param_t *ppar;
 ppar = pstmt->ppar + ipar - 1;
 switch( ppar->sqltype )
 {
  case 1:
  case 12:
  case (-1):
   if( ! data )
    nnsql_putnull(pstmt->yystmt, ipar );
   else
    nnsql_putstr(pstmt->yystmt, ipar, (char *)data);
   break;
  case (-6):
  case 5:
  case 4:
   nnsql_putnum(pstmt->yystmt, ipar, (long)data);
   break;
  case 9:
   if(!data )
    nnsql_putnull(pstmt->yystmt, ipar );
   else
    nnsql_putdate(pstmt->yystmt, ipar, (struct date_t *)data);
   break;
  default:
   return -1;
 }
 return 0;
}

variable_types: struct stmt_t { void *herr; void *hdbc; struct column_t { short ctype; char *userbuf; long userbufsize; long *pdatalen; long offset; } *pcol; struct param_t { int bind; short type; unsigned long coldef; short scale; char *userbuf; long userbufsize; long *pdatalen; int ctype; int sqltype; char *(*cvt)(); char *putdtbuf; int putdtlen; int need; } *ppar; int ndelay; void *yystmt; int refetch; int putipar; } *

variable_types: ipar int

variable_types:
data
char *

user_defined_types: struct stmt_t { void *herr; void *hdbc; struct column_t *pcol; struct param_t *ppar; int ndelay; void *yystmt; int refetch; int putipar; }


sqlexecute

original_code:
int sqlexecute (
 stmt_t* pstmt)
{
 param_t* ppar = pstmt->ppar;
 int i, npar, flag = 0;
 long csize;
 pstmt->refetch = 0;
 pstmt->ndelay = 0;
 npar = nnsql_getparnum(pstmt->yystmt);
 for( i = 0; ppar && i< npar; i++ )
 {
  ppar = pstmt->ppar + i;
  if( ! ppar->bind )
  {
   pstmt->herr = nnodbc_pusherr(pstmt->herr, en_07001, 0);
   return (-1);
  }
  if( ( ! ppar->userbuf && ppar->pdatalen )
   || ( ppar->userbuf && ppar->pdatalen
      && *ppar->pdatalen < 0 && *ppar->pdatalen != (-3) ) )
  {
    if( *ppar->pdatalen
     || *ppar->pdatalen == (long)(-1)
     || *ppar->pdatalen == (long)(-2)
     || *ppar->pdatalen <= (long)( (-100) - 0 ) )
    continue;
   pstmt->herr = nnodbc_pusherr(pstmt->herr, en_S1090, 0);
   return (-1);
  }
 }
 for( i = 0; ppar && i< npar; i++ )
 {
  char* (*cvt)();
  date_t date;
  char* data;
  ppar = pstmt->ppar + i;
  if( ! ppar->pdatalen )
   csize = 0;
  else
   csize = *(ppar->pdatalen);
  if( csize == (long)(-1) )
  {
   nnsql_putnull(pstmt->yystmt, i+1);
   continue;
  }
  if( csize == (long)(-2)
   || csize <= (long)( (-100) - 0 ) )
  {
   pstmt->ndelay ++;
   ppar->need = 1;
   continue;
  }
  cvt = ppar->cvt;
  data= cvt(ppar->userbuf, csize, &date );
  if( data == (char*)(-1) )
  {
   pstmt->herr = nnodbc_pusherr(pstmt->herr, en_S1000, 0);
   return (-1);
  }
  sqlputdata(pstmt, i+1, data);
 }
 if( pstmt->ndelay )
  return 99;
 if( nnsql_execute(pstmt->yystmt) )
 {
  int code;
  code = nnsql_errcode( pstmt->yystmt );
  if( code == -1 )
   code = (*__errno_location ());
  pstmt->herr = nnodbc_pusherr(pstmt->herr, code, nnsql_errmsg(pstmt->yystmt));
  return (-1);
 }
 if( ! nnsql_getcolnum(pstmt->yystmt)
  && nnsql_getrowcount(pstmt->yystmt) > 1 )
 {
  pstmt->herr = nnodbc_pusherr(pstmt->herr, en_01S04, 0);
  return 1;
 }
 return 0;
}

canonical_original_code:
int sqlexecute(struct stmt_t *pstmt)
{
 struct param_t *ppar = pstmt->ppar;
 int i; int npar; int flag = 0;
 long csize;
 pstmt->refetch = 0;
 pstmt->ndelay = 0;
 npar = nnsql_getparnum(pstmt->yystmt);
 for( i = 0; ppar && i< npar; i++ )
 {
  ppar = pstmt->ppar + i;
  if( ! ppar->bind )
  {
   pstmt->herr = nnodbc_pusherr(pstmt->herr, en_07001, 0);
   return (-1);
  }
  if( ( ! ppar->userbuf && ppar->pdatalen )
   || ( ppar->userbuf && ppar->pdatalen
      && *ppar->pdatalen < 0 && *ppar->pdatalen != (-3) ) )
  {
    if( *ppar->pdatalen
     || *ppar->pdatalen == (long)(-1)
     || *ppar->pdatalen == (long)(-2)
     || *ppar->pdatalen <= (long)( (-100) - 0 ) )
    continue;
   pstmt->herr = nnodbc_pusherr(pstmt->herr, en_S1090, 0);
   return (-1);
  }
 }
 for( i = 0; ppar && i< npar; i++ )
 {
  char *(*cvt)();
  struct date_t date;
  char *data;
  ppar = pstmt->ppar + i;
  if( ! ppar->pdatalen )
   csize = 0;
  else
   csize = *(ppar->pdatalen);
  if( csize == (long)(-1) )
  {
   nnsql_putnull(pstmt->yystmt, i+1);
   continue;
  }
  if( csize == (long)(-2)
   || csize <= (long)( (-100) - 0 ) )
  {
   pstmt->ndelay ++;
   ppar->need = 1;
   continue;
  }
  cvt = ppar->cvt;
  data= cvt(ppar->userbuf, csize, &date );
  if( data == (char *)(-1) )
  {
   pstmt->herr = nnodbc_pusherr(pstmt->herr, en_S1000, 0);
   return (-1);
  }
  sqlputdata(pstmt, i+1, data);
 }
 if( pstmt->ndelay )
  return 99;
 if( nnsql_execute(pstmt->yystmt) )
 {
  int code;
  code = nnsql_errcode( pstmt->yystmt );
  if( code == -1 )
   code = (*__errno_location ());
  pstmt->herr = nnodbc_pusherr(pstmt->herr, code, nnsql_errmsg(pstmt->yystmt));
  return (-1);
 }
 if( ! nnsql_getcolnum(pstmt->yystmt)
  && nnsql_getrowcount(pstmt->yystmt) > 1 )
 {
  pstmt->herr = nnodbc_pusherr(pstmt->herr, en_01S04, 0);
  return 1;
 }
 return 0;
}

variable_types: struct param_t { int bind; short type; unsigned long coldef; short scale; char *userbuf; long userbufsize; long *pdatalen; int ctype; int sqltype; char *(*cvt)(); char *putdtbuf; int putdtlen; int need; } *

variable_types: npar int

variable_types: flag int

variable_types: csize long

variable_types:
cvt
char *(*)()

variable_types: code int

user_defined_types: struct column_t { short ctype; char *userbuf; long userbufsize; long *pdatalen; long offset; }


SQLProcedureColumns

decompiled_code:
__int64 __fastcall SQLProcedureColumns(__int64 a1)
{
if ( !a1 )
return 4294967294LL;
sprintf((char *)(a1 + 136), "hStmt = $%08lX", a1);
logPushMsg(*(_QWORD *)(a1 + 1160), "SQLProcedureColumns.c", "SQLProcedureColumns.c", 34LL, 1LL, 1LL, a1 + 136);
logPushMsg(
*(_QWORD *)(a1 + 1160),
"SQLProcedureColumns.c",
"SQLProcedureColumns.c",
39LL,
1LL,
1LL,
"SQL_ERROR This function not supported");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( !a1 )
return 4294967294LL;
sprintf((char *)(a1 + 136), "hStmt = $%08lX", a1);
logPushMsg(*(_QWORD *)(a1 + 1160), "SQLProcedureColumns.c", "SQLProcedureColumns.c", 34LL, 1LL, 1LL, a1 + 136);
logPushMsg(
*(_QWORD *)(a1 + 1160),
"SQLProcedureColumns.c",
"SQLProcedureColumns.c",
39LL,
1LL,
1LL,
"SQL_ERROR This function not supported");
return 0xFFFFFFFFLL;
}

original_code:
RETCODE SQLProcedureColumns(
                                    HSTMT hstmt,
                                    UCHAR * szProcQualifier,
                                    SWORD cbProcQualifier,
                                    UCHAR * szProcOwner,
                                    SWORD cbProcOwner,
                                    UCHAR * szProcName,
                                    SWORD cbProcName,
                                    UCHAR * szColumnName,
                                    SWORD cbColumnName)
{
static char* const func="SQLProcedureColumns";
 mylog("%s: entering...\n", func);
 SC_log_error(func, "Function not implemented", (StatementClass *) hstmt);
    return (-1);
}

canonical_original_code:
short SQLProcedureColumns(void *hstmt, unsigned char *szProcQualifier, short cbProcQualifier, unsigned char *szProcOwner, short cbProcOwner, unsigned char *szProcName, short cbProcName, unsigned char *szColumnName, short cbColumnName)
{
static char *func = "SQLProcedureColumns";
 mylog("%s: entering...\n", func);
 SC_log_error(func, "Function not implemented", (struct StatementClass_ *) hstmt);
    return (-1);
}

variable_types:
hstmt
void *

variable_types:
szProcQualifier
unsigned char *

variable_types: cbProcQualifier short

variable_types:
szProcOwner
unsigned char *

variable_types: cbProcOwner short

variable_types:
szProcName
unsigned char *

variable_types: cbProcName short

variable_types:
szColumnName
unsigned char *

variable_types: cbColumnName short

variable_types:
func
char *

user_defined_types: struct StatementClass_ { struct ConnectionClass_ *hdbc; struct QResultClass_ *result; void **phstmt; struct StatementOptions_ options; enum STMT_Status status; char *__error_message; int __error_number; struct BindInfoClass_ *bindings; struct BindInfoClass_ bookmark; int bindings_allocated; int parameters_allocated; struct ParameterInfoClass_ *parameters; int currTuple; int save_rowset_size; int rowset_start; int bind_row; int last_fetch_count; int current_col; int lobj_fd; char *statement; struct TABLE_INFO **ti; struct FIELD_INFO **fi; int nfld; int ntab; int parse_status; int statement_type; int data_at_exec; int current_exec_param; char put_data; char errormsg_created; char manual_result; char prepare; char internal; char cursor_name[-1]; char stmt_with_params[65536]; int reexecute; }

user_defined_types: enum STMT_Status { STMT_ALLOCATED=0, STMT_READY=1, STMT_PREMATURE=2, STMT_FINISHED=3, STMT_EXECUTING=4 }

user_defined_types: struct ConnectionClass_ { void *henv; struct StatementOptions_ stmtOptions; char *__error_message; int __error_number; enum CONN_Status status; struct ConnInfo connInfo; struct StatementClass_ **stmts; int num_stmts; struct SocketClass_ *sock; int lobj_type; int ntables; struct col_info **col_info; long translation_option; void *translation_handle; int (*DataSourceToDriver)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); int (*DriverToDataSource)(unsigned long, short, void *, long, void *, long, long *, unsigned char *, short, short *); short driver_version; char transact_status; char errormsg_created; char pg_version[128]; float pg_version_number; short pg_version_major; short pg_version_minor; char ms_jet; char unicode; char result_uncommitted; char schema_support; char *client_encoding; char *server_encoding; int ccsc; int be_pid; int be_key; unsigned int isolation; char *current_schema; int num_discardp; char **discardp; }

user_defined_types: struct BindInfoClass_ { int buflen; int data_left; char *buffer; long *used; short returntype; }

user_defined_types: struct ParameterInfoClass_ { int buflen; char *buffer; long *used; short paramType; short CType; short SQLType; unsigned int precision; short scale; unsigned int lobj_oid; int *EXEC_used; char *EXEC_buffer; char data_at_exec; }

user_defined_types: struct StatementOptions_ { int maxRows; int maxLength; int rowset_size; int keyset_size; int cursor_type; int scroll_concurrency; int retrieve_data; int bind_size; int use_bookmarks; }

user_defined_types: enum CONN_Status { CONN_NOT_CONNECTED=0, CONN_CONNECTED=1, CONN_DOWN=2, CONN_EXECUTING=3 }

user_defined_types: struct ConnInfo { char dsn[256]; char desc[256]; char driver[256]; char server[256]; char database[256]; char username[256]; char password[256]; char conn_settings[4096]; char protocol[10]; char port[10]; char uds[4096]; char onlyread[10]; char fake_oid_index[10]; char show_oid_column[10]; char row_versioning[10]; char show_system_tables[10]; char translation_dll[256]; char translation_option[10]; char focus_password; }

user_defined_types: struct TABLE_INFO { struct col_info *col_info; char name[-1]; char alias[-1]; }

user_defined_types: struct FIELD_INFO { struct TABLE_INFO *ti; int precision; int display_size; int length; int type; char nullable; char func; char expr; char quote; char dquote; char numeric; char dot[-1]; char name[-1]; char alias[-1]; }

user_defined_types: struct SocketClass_ { int buffer_filled_in; int buffer_filled_out; int buffer_read_in; unsigned char *buffer_in; unsigned char *buffer_out; int socket; char *errormsg; int errornumber; char reverse; }

user_defined_types: struct col_info { struct QResultClass_ *result; char name[-1]; }

user_defined_types: struct QResultClass_ { struct ColumnInfoClass_ *fields; struct TupleListClass_ *manual_tuples; struct ConnectionClass_ *conn; int fetch_count; int fcount; int currTuple; int base; int num_fields; int cache_size; int rowset_size; enum QueryResultCode_ status; char *message; char *cursor; char *command; char *notice; struct TupleField_ *backend_tuples; struct TupleField_ *tupleField; char inTuples; char aborted; }

user_defined_types: enum QueryResultCode_ { PGRES_EMPTY_QUERY=0, PGRES_COMMAND_OK=1, PGRES_TUPLES_OK=2, PGRES_COPY_OUT=3, PGRES_COPY_IN=4, PGRES_BAD_RESPONSE=5, PGRES_NONFATAL_ERROR=6, PGRES_FATAL_ERROR=7, PGRES_FIELDS_OK=8, PGRES_END_TUPLES=9, PGRES_INTERNAL_ERROR=10 }

user_defined_types: struct ColumnInfoClass_ { short num_fields; char **name; unsigned int *adtid; short *adtsize; short *display_size; int *atttypmod; }

user_defined_types: struct TupleListClass_ { int num_fields; int num_tuples; struct TupleNode_ *list_start; int last_indexed; }

user_defined_types: struct TupleNode_ { struct TupleNode_ *prev; struct TupleField_ tuple[1]; }

user_defined_types: struct TupleField_ { int len; void *value; }


SQLTablePrivileges

decompiled_code:
__int64 __fastcall SQLTablePrivileges(__int64 a1)
{
if ( !a1 )
return 4294967294LL;
sprintf((char *)(a1 + 136), "hStmt = $%08lX", a1);
logPushMsg(*(_QWORD *)(a1 + 1160), "SQLTablePrivileges.c", "SQLTablePrivileges.c", 31LL, 1LL, 1LL, a1 + 136);
logPushMsg(
*(_QWORD *)(a1 + 1160),
"SQLTablePrivileges.c",
"SQLTablePrivileges.c",
37LL,
1LL,
1LL,
"SQL_ERROR This function not supported");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( !a1 )
return 4294967294LL;
sprintf((char *)(a1 + 136), "hStmt = $%08lX", a1);
logPushMsg(*(_QWORD *)(a1 + 1160), "SQLTablePrivileges.c", "SQLTablePrivileges.c", 31LL, 1LL, 1LL, a1 + 136);
logPushMsg(
*(_QWORD *)(a1 + 1160),
"SQLTablePrivileges.c",
"SQLTablePrivileges.c",
37LL,
1LL,
1LL,
"SQL_ERROR This function not supported");
return 0xFFFFFFFFLL;
}

original_code:
RETCODE SQLTablePrivileges(
                                   HSTMT hstmt,
                                   UCHAR * szTableQualifier,
                                   SWORD cbTableQualifier,
                                   UCHAR * szTableOwner,
                                   SWORD cbTableOwner,
                                   UCHAR * szTableName,
                                   SWORD cbTableName)
{
static char* const func="SQLTablePrivileges";
 mylog("%s: entering...\n", func);
 SC_log_error(func, "Function not implemented", (StatementClass *) hstmt);
    return (-1);
}

canonical_original_code:
short SQLTablePrivileges(void *hstmt, unsigned char *szTableQualifier, short cbTableQualifier, unsigned char *szTableOwner, short cbTableOwner, unsigned char *szTableName, short cbTableName)
{
static char *func = "SQLTablePrivileges";
 mylog("%s: entering...\n", func);
 SC_log_error(func, "Function not implemented", (struct StatementClass_ *) hstmt);
    return (-1);
}

variable_types:
szTableQualifier
unsigned char *

variable_types: cbTableQualifier short

variable_types:
szTableOwner
unsigned char *

variable_types: cbTableOwner short

variable_types:
szTableName
unsigned char *

variable_types: cbTableName short

user_defined_types: struct StatementClass_ { struct ConnectionClass_ *hdbc; struct QResultClass_ *result; void **phstmt; struct StatementOptions_ options; enum STMT_Status status; char *__error_message; int __error_number; struct BindInfoClass_ *bindings; struct BindInfoClass_ bookmark; int bindings_allocated; int parameters_allocated; struct ParameterInfoClass_ *parameters; int currTuple; int save_rowset_size; int rowset_start; int bind_row; int last_fetch_count; int current_col; int lobj_fd; char *statement; struct TABLE_INFO **ti; struct FIELD_INFO **fi; int nfld; int ntab; int parse_status; int statement_type; int data_at_exec; int current_exec_param; char put_data; char errormsg_created; char manual_result; char prepare; char internal; char cursor_name[-1]; char stmt_with_params[65536]; int reexecute; }

user_defined_types: enum STMT_Status { STMT_ALLOCATED=0, STMT_READY=1, STMT_PREMATURE=2, STMT_FINISHED=3, STMT_EXECUTING=4 }


decompiled_code:
__pid_t __fastcall generate_filename(char *src, char *a2, char *s)
{
__uid_t v4; // eax
struct passwd *v5; // rbx
__pid_t result; // eax
unsigned int v7; // er14
char *v8; // rax
size_t v9; // rax

v4 = getuid();
v5 = getpwuid(v4);
result = getpid();
if ( src && s )
{
v7 = result;
v8 = stpcpy(s, src);
*(_WORD *)v8 = 47;
if ( a2 )
strcpy(v8 + 1, a2);
v9 = strlen(s);
strcpy(&s[v9], v5->pw_name);
result = sprintf(s, "%s%u%s", s, v7, ".log");
}
return result;
}

canonical_decompiled_code:
__pid_t __fastcall func0(char *src, char *a2, char *s)
{
__uid_t v4; // eax
struct passwd *v5; // rbx
__pid_t result; // eax
unsigned int v7; // er14
char *v8; // rax
size_t v9; // rax

v4 = getuid();
v5 = getpwuid(v4);
result = getpid();
if ( src && s )
{
v7 = result;
v8 = stpcpy(s, src);
*(_WORD *)v8 = 47;
if ( a2 )
strcpy(v8 + 1, a2);
v9 = strlen(s);
strcpy(&s[v9], v5->pw_name);
result = sprintf(s, "%s%u%s", s, v7, ".log");
}
return result;
}

original_code:
void
generate_filename(char* dirname,char* prefix,char* filename)
{
 int pid = 0;
 struct passwd *ptr = 0;
 ptr = getpwuid(getuid());
 pid = getpid();
 if(dirname == 0 || filename == 0)
  return;
 strcpy(filename,dirname);
 strcat(filename,"/");
 if(prefix != 0)
  strcat(filename,prefix);
 strcat(filename,ptr->pw_name);
 sprintf(filename,"%s%u%s",filename,pid,".log");
 return;
}

canonical_original_code:
void generate_filename(char *dirname, char *prefix, char *filename)
{
 int pid = 0;
 struct passwd *ptr = 0;
 ptr = getpwuid(getuid());
 pid = getpid();
 if(dirname == 0 || filename == 0)
  return;
 strcpy(filename,dirname);
 strcat(filename,"/");
 if(prefix != 0)
  strcat(filename,prefix);
 strcat(filename,ptr->pw_name);
 sprintf(filename,"%s%u%s",filename,pid,".log");
 return;
}

variable_types:
dirname
char *

variable_types:
prefix
char *

variable_types:
filename
char *

variable_types: pid int

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *


decompiled_code:
size_t __fastcall my_strcpy(void *dest, int a2, const char *a3, int a4)
{
size_t result; // rax
__int64 v6; // rbx

result = 0LL;
if ( a2 > 0 )
{
if ( a4 == -1 )
{
*(_BYTE *)dest = 0;
result = 4294967294LL;
}
else
{
if ( a4 == -3 )
a4 = strlen(a3);
result = 0LL;
if ( a4 > 0 )
{
if ( a4 >= a2 )
{
memcpy(dest, a3, a2 - 1);
*((char *)dest + a2 - 1) = 0;
result = 0xFFFFFFFFLL;
}
else
{
v6 = a4;
memcpy(dest, a3, a4);
*((_BYTE *)dest + v6) = 0;
result = strlen((const char *)dest);
}
}
}
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func3(void *dest, int a2, const char *a3, int a4)
{
size_t result; // rax
__int64 v6; // rbx

result = 0LL;
if ( a2 > 0 )
{
if ( a4 == -1 )
{
*(_BYTE *)dest = 0;
result = 4294967294LL;
}
else
{
if ( a4 == -3 )
a4 = strlen(a3);
result = 0LL;
if ( a4 > 0 )
{
if ( a4 >= a2 )
{
memcpy(dest, a3, a2 - 1);
*((char *)dest + a2 - 1) = 0;
result = 0xFFFFFFFFLL;
}
else
{
v6 = a4;
memcpy(dest, a3, a4);
*((_BYTE *)dest + v6) = 0;
result = strlen((const char *)dest);
}
}
}
}
return result;
}

original_code:
int
my_strcpy(char *dst, int dst_len, char *src, int src_len)
{
 if (dst_len <= 0)
  return 0;
 if (src_len == (-1)) {
  dst[0] = '\0';
  return -2;
 }
 else if (src_len == (-3))
  src_len = strlen(src);
 if (src_len <= 0)
  return 0;
 else {
  if (src_len < dst_len) {
   memcpy(dst, src, src_len);
   dst[src_len] = '\0';
  }
  else {
   memcpy(dst, src, dst_len-1);
   dst[dst_len-1] = '\0';
   return -1;
  }
 }
 return strlen(dst);
}

variable_types:
dst
char *

variable_types:
src
char *


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

result = 0LL;
if ( a1 )
{
result = (unsigned int)a2;
if ( a2 <= 0 )
{
result = 0LL;
if ( a2 == -3 )
{
if ( *a1 )
result = strlen(a1);
}
}
}
return result;
}

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

result = 0LL;
if ( a1 )
{
result = (unsigned int)a2;
if ( a2 <= 0 )
{
result = 0LL;
if ( a2 == -3 )
{
if ( *a1 )
result = strlen(a1);
}
}
}
return result;
}

original_code:
int
my_strlen(char *s, int len)
{
 int length = 0;
 if(s && (len > 0 || (len == (-3) && strlen(s) > 0))) {
     length = (len > 0) ? len : strlen(s);
 }
 return length;
}

variable_types:
s
char *

variable_types: len int

variable_types: length int


decompiled_code:
char *__fastcall my_strcat(char *s, char *format, char *a3, int a4)
{
unsigned int v5; // er12
char *result; // rax
int v7; // eax

if ( !a3 )
return 0LL;
v5 = a4;
if ( a4 > 0 )
goto LABEL_6;
result = 0LL;
if ( a4 == -3 && *a3 )
{
v5 = strlen(a3);
LABEL_6:
v7 = strlen(s);
sprintf(&s[v7], format, v5, a3);
result = s;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func5(char *s, char *format, char *a3, int a4)
{
unsigned int v5; // er12
char *result; // rax
int v7; // eax

if ( !a3 )
return 0LL;
v5 = a4;
if ( a4 > 0 )
goto LABEL_6;
result = 0LL;
if ( a4 == -3 && *a3 )
{
v5 = strlen(a3);
LABEL_6:
v7 = strlen(s);
sprintf(&s[v7], format, v5, a3);
result = s;
}
return result;
}

original_code:
char *
my_strcat(char *buf, char *fmt, char *s, int len)
{
 if (s && (len > 0 || (len == (-3) && strlen(s) > 0))) {
  int length = (len > 0) ? len : strlen(s);
  int pos = strlen(buf);
  sprintf(&buf[pos], fmt, length, s);
  return buf;
 }
 return ((void *)0);
}

canonical_original_code:
char *my_strcat(char *buf, char *fmt, char *s, int len)
{
 if (s && (len > 0 || (len == (-3) && strlen(s) > 0))) {
  int length = (len > 0) ? len : strlen(s);
  int pos = strlen(buf);
  sprintf(&buf[pos], fmt, length, s);
  return buf;
 }
 return ((void *)0);
}

variable_types:
buf
char *

variable_types:
fmt
char *

variable_types: pos int


decompiled_code:
size_t __fastcall remove_newlines(const char *a1)
{
size_t result; // rax
unsigned __int64 v2; // rsi
unsigned int v3; // edx
char *v4; // rax

result = strlen(a1);
if ( result )
{
v2 = result;
v3 = 0;
result = 0LL;
do
{
while ( 1 )
{
v4 = (char *)&a1[result];
if ( *v4 == 10 || *v4 == 13 )
break;
result = ++v3;
if ( v3 >= v2 )
return result;
}
*v4 = 32;
result = ++v3;
}
while ( v3 < v2 );
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func6(const char *a1)
{
size_t result; // rax
unsigned __int64 v2; // rsi
unsigned int v3; // edx
char *v4; // rax

result = strlen(a1);
if ( result )
{
v2 = result;
v3 = 0;
result = 0LL;
do
{
while ( 1 )
{
v4 = (char *)&a1[result];
if ( *v4 == 10 || *v4 == 13 )
break;
result = ++v3;
if ( v3 >= v2 )
return result;
}
*v4 = 32;
result = ++v3;
}
while ( v3 < v2 );
}
return result;
}

original_code:
void remove_newlines(char *string)
{
 unsigned int i;
 size_t stlen=strlen(string);
 for(i=0; i < stlen; i++) {
  if((string[i] == '\n') ||
     (string[i] == '\r')) {
   string[i] = ' ';
  }
 }
}

canonical_original_code:
void remove_newlines(char *string)
{
 unsigned int i;
 unsigned long stlen = strlen(string);
 for(i=0; i < stlen; i++) {
  if((string[i] == '\n') ||
     (string[i] == '\r')) {
   string[i] = ' ';
  }
 }
}

variable_types:
string
char *

variable_types:
i
unsigned int

variable_types:
stlen
unsigned long


trim

decompiled_code:
const char *__fastcall trim(const char *a1)
{
__int64 v1; // rax

LODWORD(v1) = strlen(a1) - 1;
if ( (int)v1 >= 0 )
{
v1 = (int)v1;
do
{
if ( a1[v1] != 32 )
break;
a1[v1--] = 0;
}
while ( (int)v1 >= 0 );
}
return a1;
}

canonical_decompiled_code:
const char *__fastcall func7(const char *a1)
{
__int64 v1; // rax

LODWORD(v1) = strlen(a1) - 1;
if ( (int)v1 >= 0 )
{
v1 = (int)v1;
do
{
if ( a1[v1] != 32 )
break;
a1[v1--] = 0;
}
while ( (int)v1 >= 0 );
}
return a1;
}

original_code:
char *
trim(char *s)
{
 int i;
 for (i = strlen(s) - 1; i >= 0; i--) {
  if (s[i] == ' ')
   s[i] = '\0';
  else
   break;
 }
 return s;
}

canonical_original_code:
char *trim(char *s)
{
 int i;
 for (i = strlen(s) - 1; i >= 0; i--) {
  if (s[i] == ' ')
   s[i] = '\0';
  else
   break;
 }
 return s;
}

variable_types: i int