decompiled_code:
__int64 __fastcall SOCK_connect_to_unix_port(__int64 a1, unsigned __int16 a2, const char *a3)
{
__int64 result; // rax
int v5; // eax
int v6; // er8
int v7; // edi
_BYTE v8[104]; // [rsp+0h] [rbp-88h] BYREF
int v9; // [rsp+68h] [rbp-20h]
__int16 v10; // [rsp+6Ch] [rbp-1Ch]

if ( *(_DWORD *)(a1 + 32) == -1 )
{
memset(v8, 0, sizeof(v8));
v10 = 0;
v9 = 0;
*(_WORD *)v8 = 1;
sprintf(&v8[2], "%s.%d", a3, a2);
v5 = socket(1, 1, 0);
*(_DWORD *)(a1 + 32) = v5;
if ( v5 == -1 )
{
*(_DWORD *)(a1 + 48) = 3;
*(_QWORD *)(a1 + 40) = "Could not create Socket.";
result = 0LL;
}
else
{
v6 = connect(v5, (const struct sockaddr *)v8, 0x6Eu);
result = 1LL;
if ( v6 < 0 )
{
*(_DWORD *)(a1 + 48) = 4;
v7 = *(_DWORD *)(a1 + 32);
*(_QWORD *)(a1 + 40) = "Could not connect to remote socket.";
close(v7);
*(_DWORD *)(a1 + 32) = -1;
result = 0LL;
}
}
}
else
{
*(_DWORD *)(a1 + 48) = 1;
*(_QWORD *)(a1 + 40) = "Socket is already connected";
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned __int16 a2, const char *a3)
{
__int64 result; // rax
int v5; // eax
int v6; // er8
int v7; // edi
_BYTE v8[104]; // [rsp+0h] [rbp-88h] BYREF
int v9; // [rsp+68h] [rbp-20h]
__int16 v10; // [rsp+6Ch] [rbp-1Ch]

if ( *(_DWORD *)(a1 + 32) == -1 )
{
memset(v8, 0, sizeof(v8));
v10 = 0;
v9 = 0;
*(_WORD *)v8 = 1;
sprintf(&v8[2], "%s.%d", a3, a2);
v5 = socket(1, 1, 0);
*(_DWORD *)(a1 + 32) = v5;
if ( v5 == -1 )
{
*(_DWORD *)(a1 + 48) = 3;
*(_QWORD *)(a1 + 40) = "Could not create Socket.";
result = 0LL;
}
else
{
v6 = connect(v5, (const struct sockaddr *)v8, 0x6Eu);
result = 1LL;
if ( v6 < 0 )
{
*(_DWORD *)(a1 + 48) = 4;
v7 = *(_DWORD *)(a1 + 32);
*(_QWORD *)(a1 + 40) = "Could not connect to remote socket.";
close(v7);
*(_DWORD *)(a1 + 32) = -1;
result = 0LL;
}
}
}
else
{
*(_DWORD *)(a1 + 48) = 1;
*(_QWORD *)(a1 + 40) = "Socket is already connected";
result = 0LL;
}
return result;
}

original_code:
char
SOCK_connect_to_unix_port(SocketClass *self, unsigned short port, char *path )
{
struct sockaddr_un sadr;
 if (self->socket != -1) {
  self->errornumber = 1;
  self->errormsg = "Socket is already connected";
  return 0;
 }
 memset((char *)&sadr, 0, sizeof(sadr));
 sadr.sun_family = 1;
 sprintf( sadr.sun_path, "%s.%d", path, port );
 self->socket = socket(1, SOCK_STREAM, 0);
 if (self->socket == -1) {
  self->errornumber = 3;
  self->errormsg = "Could not create Socket.";
  return 0;
 }
 if ( connect(self->socket, (struct sockaddr *)&(sadr),
   sizeof(sadr)) < 0) {
  self->errornumber = 4;
  self->errormsg = "Could not connect to remote socket.";
  close(self->socket);
  self->socket = (int) -1;
  return 0;
 }
 return 1;
}

canonical_original_code:
char SOCK_connect_to_unix_port(struct SocketClass_ *self, unsigned short port, char *path)
{
struct sockaddr_un sadr;
 if (self->socket != -1) {
  self->errornumber = 1;
  self->errormsg = "Socket is already connected";
  return 0;
 }
 memset((char *)&sadr, 0, sizeof(sadr));
 sadr.sun_family = 1;
 sprintf( sadr.sun_path, "%s.%d", path, port );
 self->socket = socket(1, SOCK_STREAM, 0);
 if (self->socket == -1) {
  self->errornumber = 3;
  self->errormsg = "Could not create Socket.";
  return 0;
 }
 if ( connect(self->socket, (struct sockaddr *)&(sadr),
   sizeof(sadr)) < 0) {
  self->errornumber = 4;
  self->errormsg = "Could not connect to remote socket.";
  close(self->socket);
  self->socket = (int) -1;
  return 0;
 }
 return 1;
}

variable_types:
path
char *

variable_types: struct sockaddr_un { unsigned short sun_family; char sun_path[108]; }


repo: xiaotmiaomiao/unixODBC-SPEC

decompiled_code:
_BOOL8 __fastcall SOCK_connect_to_unix(__int64 a1, unsigned __int16 a2, const char *a3)
{
char v3; // r8
_BOOL8 result; // rax
char v5; // r8

if ( *a3 )
return (unsigned __int8)SOCK_connect_to_unix_port(a1, a2, a3) == 0;
v3 = SOCK_connect_to_unix_port(a1, a2, "/tmp/.s.PGSQL");
result = 1LL;
if ( !v3 )
{
v5 = SOCK_connect_to_unix_port(a1, a2, "/var/run/postgresql/.s.PGSQL");
result = 0LL;
if ( v5 )
{
SOCK_clear_error(a1);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1, unsigned __int16 a2, const char *a3)
{
char v3; // r8
_BOOL8 result; // rax
char v5; // r8

if ( *a3 )
return (unsigned __int8)func5(a1, a2, a3) == 0;
v3 = func5(a1, a2, "/tmp/.s.PGSQL");
result = 1LL;
if ( !v3 )
{
v5 = func5(a1, a2, "/var/run/postgresql/.s.PGSQL");
result = 0LL;
if ( v5 )
{
func3(a1);
result = 1LL;
}
}
return result;
}

original_code:
int
SOCK_connect_to_unix(SocketClass *self, unsigned short port, char *path )
    {
    if ( strlen( path ) > 0 )
    {
        return !SOCK_connect_to_unix_port( self, port, path );
    }
    if ( !SOCK_connect_to_unix_port( self, port, "/tmp/.s.PGSQL" ))
    {
        if ( SOCK_connect_to_unix_port( self, port, "/var/run/postgresql/.s.PGSQL" ))
        {
            SOCK_clear_error(self);
            return 1;
        }
        else
        {
            return 0;
        }
    }
    else
    {
        return 1;
    }
}

canonical_original_code:
int SOCK_connect_to_unix(struct SocketClass_ *self, unsigned short port, char *path)
    {
    if ( strlen( path ) > 0 )
    {
        return !SOCK_connect_to_unix_port( self, port, path );
    }
    if ( !SOCK_connect_to_unix_port( self, port, "/tmp/.s.PGSQL" ))
    {
        if ( SOCK_connect_to_unix_port( self, port, "/var/run/postgresql/.s.PGSQL" ))
        {
            SOCK_clear_error(self);
            return 1;
        }
        else
        {
            return 0;
        }
    }
    else
    {
        return 1;
    }
}

variable_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; } *

variable_types:
port
unsigned short

return_type: int


decompiled_code:
__int64 __fastcall SOCK_connect_to(__int64 a1, __int16 a2, const char *a3, const char *a4)
{
__int64 result; // rax

if ( !strcmp(a3, "localhost") )
result = SOCK_connect_to_unix(a1, a2, a4);
else
result = SOCK_connect_to_ip(a1, a2, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int16 a2, const char *a3, const char *a4)
{
__int64 result; // rax

if ( !strcmp(a3, "localhost") )
result = func6(a1, a2, a4);
else
result = func1(a1, a2, a3);
return result;
}

original_code:
char
SOCK_connect_to(SocketClass *self, unsigned short port, char *hostname, char *uds)
{
 if ( strcmp( hostname, "localhost" ) == 0 )
  return SOCK_connect_to_unix( self, port, uds );
 else
  return SOCK_connect_to_ip( self, port, hostname );
}

canonical_original_code:
char SOCK_connect_to(struct SocketClass_ *self, unsigned short port, char *hostname, char *uds)
{
 if ( strcmp( hostname, "localhost" ) == 0 )
  return SOCK_connect_to_unix( self, port, uds );
 else
  return SOCK_connect_to_ip( self, port, hostname );
}

variable_types:
hostname
char *

variable_types:
uds
char *

return_type: char

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


decompiled_code:
const char *__fastcall SOCK_flush_output(__int64 a1)
{
const char *result; // rax

result = (const char *)send(*(_DWORD *)(a1 + 32), *(const void **)(a1 + 24), *(int *)(a1 + 4), 0x4000);
if ( *(_DWORD *)(a1 + 4) != (_DWORD)result )
{
result = "Could not flush socket buffer.";
*(_DWORD *)(a1 + 48) = 6;
*(_QWORD *)(a1 + 40) = "Could not flush socket buffer.";
}
*(_DWORD *)(a1 + 4) = 0;
return result;
}

canonical_decompiled_code:
const char *__fastcall func8(__int64 a1)
{
const char *result; // rax

result = (const char *)send(*(_DWORD *)(a1 + 32), *(const void **)(a1 + 24), *(int *)(a1 + 4), 0x4000);
if ( *(_DWORD *)(a1 + 4) != (_DWORD)result )
{
result = "Could not flush socket buffer.";
*(_DWORD *)(a1 + 48) = 6;
*(_QWORD *)(a1 + 40) = "Could not flush socket buffer.";
}
*(_DWORD *)(a1 + 4) = 0;
return result;
}

original_code:
void
SOCK_flush_output(SocketClass *self)
{
int written;
    written = send(self->socket, (char *)self->buffer_out, self->buffer_filled_out, MSG_NOSIGNAL);
 if (written != self->buffer_filled_out) {
  self->errornumber = 6;
  self->errormsg = "Could not flush socket buffer.";
 }
 self->buffer_filled_out = 0;
}

canonical_original_code:
void SOCK_flush_output(struct SocketClass_ *self)
{
int written;
    written = send(self->socket, (char *)self->buffer_out, self->buffer_filled_out, MSG_NOSIGNAL);
 if (written != self->buffer_filled_out) {
  self->errornumber = 6;
  self->errormsg = "Could not flush socket buffer.";
 }
 self->buffer_filled_out = 0;
}

variable_types: written int

return_type: void


decompiled_code:
__int64 __fastcall SOCK_get_next_byte(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx
__int64 result; // rax
void *v4; // rsi
ssize_t v5; // rax
__int64 v6; // rdx

v1 = *(int *)(a1 + 8);
if ( (int)v1 < *(_DWORD *)a1 )
goto LABEL_2;
v4 = *(void **)(a1 + 16);
*(_DWORD *)(a1 + 8) = 0;
v5 = recv(*(_DWORD *)(a1 + 32), v4, *((int *)&globals + 1), 0);
v6 = *((unsigned int *)&globals + 1);
*(_DWORD *)a1 = v5;
mylog("read %d, global_socket_buffersize=%d\n", v5, v6);
if ( *(int *)a1 < 0 )
{
*(_DWORD *)(a1 + 48) = 5;
*(_QWORD *)(a1 + 40) = "Error while reading from the socket.";
result = 0LL;
*(_DWORD *)a1 = 0;
}
else
{
if ( *(_DWORD *)a1 )
{
v1 = *(int *)(a1 + 8);
LABEL_2:
v2 = *(_QWORD *)(a1 + 16);
*(_DWORD *)(a1 + 8) = v1 + 1;
return *(unsigned __int8 *)(v2 + v1);
}
*(_DWORD *)(a1 + 48) = 10;
*(_QWORD *)(a1 + 40) = "Socket has been closed.";
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx
__int64 result; // rax
void *v4; // rsi
ssize_t v5; // rax
__int64 v6; // rdx

v1 = *(int *)(a1 + 8);
if ( (int)v1 < *(_DWORD *)a1 )
goto LABEL_2;
v4 = *(void **)(a1 + 16);
*(_DWORD *)(a1 + 8) = 0;
v5 = recv(*(_DWORD *)(a1 + 32), v4, *((int *)&globals + 1), 0);
v6 = *((unsigned int *)&globals + 1);
*(_DWORD *)a1 = v5;
mylog("read %d, global_socket_buffersize=%d\n", v5, v6);
if ( *(int *)a1 < 0 )
{
*(_DWORD *)(a1 + 48) = 5;
*(_QWORD *)(a1 + 40) = "Error while reading from the socket.";
result = 0LL;
*(_DWORD *)a1 = 0;
}
else
{
if ( *(_DWORD *)a1 )
{
v1 = *(int *)(a1 + 8);
LABEL_2:
v2 = *(_QWORD *)(a1 + 16);
*(_DWORD *)(a1 + 8) = v1 + 1;
return *(unsigned __int8 *)(v2 + v1);
}
*(_DWORD *)(a1 + 48) = 10;
*(_QWORD *)(a1 + 40) = "Socket has been closed.";
result = 0LL;
}
return result;
}

original_code:
UCHAR
SOCK_get_next_byte(SocketClass *self)
{
 if (self->buffer_read_in >= self->buffer_filled_in) {
  self->buffer_read_in = 0;
  self->buffer_filled_in = recv(self->socket, (char *)self->buffer_in, globals.socket_buffersize, 0);
  mylog("read %d, global_socket_buffersize=%d\n", self->buffer_filled_in, globals.socket_buffersize);
  if (self->buffer_filled_in < 0) {
   self->errornumber = 5;
   self->errormsg = "Error while reading from the socket.";
   self->buffer_filled_in = 0;
   return 0;
  }
  if (self->buffer_filled_in == 0) {
   self->errornumber = 10;
   self->errormsg = "Socket has been closed.";
   self->buffer_filled_in = 0;
   return 0;
  }
 }
 return self->buffer_in[self->buffer_read_in++];
}

canonical_original_code:
unsigned char SOCK_get_next_byte(struct SocketClass_ *self)
{
 if (self->buffer_read_in >= self->buffer_filled_in) {
  self->buffer_read_in = 0;
  self->buffer_filled_in = recv(self->socket, (char *)self->buffer_in, globals.socket_buffersize, 0);
  mylog("read %d, global_socket_buffersize=%d\n", self->buffer_filled_in, globals.socket_buffersize);
  if (self->buffer_filled_in < 0) {
   self->errornumber = 5;
   self->errormsg = "Error while reading from the socket.";
   self->buffer_filled_in = 0;
   return 0;
  }
  if (self->buffer_filled_in == 0) {
   self->errornumber = 10;
   self->errormsg = "Socket has been closed.";
   self->buffer_filled_in = 0;
   return 0;
  }
 }
 return self->buffer_in[self->buffer_read_in++];
}

return_type: unsigned char


decompiled_code:
void __fastcall SOCK_get_n_char(__int64 a1, _BYTE *a2, int a3)
{
_BYTE *v3; // rbx
_BYTE *v4; // r12
_BYTE *v5; // rax

if ( a2 )
{
if ( a3 > 0 )
{
v3 = a2;
v4 = &a2[a3 - 1];
do
{
*v3 = SOCK_get_next_byte(a1);
v5 = v3++;
}
while ( v5 != v4 );
}
}
else
{
*(_DWORD *)(a1 + 48) = 7;
*(_QWORD *)(a1 + 40) = "get_n_char was called with NULL-Pointer";
}
}

canonical_decompiled_code:
void __fastcall func10(__int64 a1, _BYTE *a2, int a3)
{
_BYTE *v3; // rbx
_BYTE *v4; // r12
_BYTE *v5; // rax

if ( a2 )
{
if ( a3 > 0 )
{
v3 = a2;
v4 = &a2[a3 - 1];
do
{
*v3 = func9(a1);
v5 = v3++;
}
while ( v5 != v4 );
}
}
else
{
*(_DWORD *)(a1 + 48) = 7;
*(_QWORD *)(a1 + 40) = "get_n_char was called with NULL-Pointer";
}
}

original_code:
void
SOCK_get_n_char(SocketClass *self, char *buffer, int len)
{
 int lf;
 if ( ! buffer) {
  self->errornumber = 7;
  self->errormsg = "get_n_char was called with NULL-Pointer";
  return;
 }
 for(lf=0; lf < len; lf++)
  buffer[lf] = SOCK_get_next_byte(self);
}

canonical_original_code:
void SOCK_get_n_char(struct SocketClass_ *self, char *buffer, int len)
{
 int lf;
 if ( ! buffer) {
  self->errornumber = 7;
  self->errormsg = "get_n_char was called with NULL-Pointer";
  return;
 }
 for(lf=0; lf < len; lf++)
  buffer[lf] = SOCK_get_next_byte(self);
}

variable_types:
buffer
char *

variable_types: len int

variable_types: lf int


decompiled_code:
__int64 __fastcall SOCK_get_int(__int64 a1, __int16 a2)
{
__int64 result; // rax
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( a2 == 2 )
{
SOCK_get_n_char(a1, v3, 2);
if ( *(_BYTE *)(a1 + 52) )
result = LOWORD(v3[0]);
else
result = (unsigned __int16)_bswap_16(v3[0]);
}
else if ( a2 == 4 )
{
SOCK_get_n_char(a1, v3, 4);
if ( *(_BYTE *)(a1 + 52) )
result = v3[0];
else
result = _bswap_32(v3[0]);
}
else
{
*(_DWORD *)(a1 + 48) = 9;
*(_QWORD *)(a1 + 40) = "Cannot read ints of that length";
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int16 a2)
{
__int64 result; // rax
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( a2 == 2 )
{
func10(a1, v3, 2);
if ( *(_BYTE *)(a1 + 52) )
result = LOWORD(v3[0]);
else
result = (unsigned __int16)func0(v3[0]);
}
else if ( a2 == 4 )
{
func10(a1, v3, 4);
if ( *(_BYTE *)(a1 + 52) )
result = v3[0];
else
result = func2(v3[0]);
}
else
{
*(_DWORD *)(a1 + 48) = 9;
*(_QWORD *)(a1 + 40) = "Cannot read ints of that length";
result = 0LL;
}
return result;
}

original_code:
int
SOCK_get_int(SocketClass *self, short len)
{
char buf[4];
 switch (len) {
 case 2:
  SOCK_get_n_char(self, buf, len);
  if (self->reverse)
   return *((unsigned short *) buf);
  else
   return ntohs( *((unsigned short *) buf) );
 case 4:
  SOCK_get_n_char(self, buf, len);
  if (self->reverse)
   return *((unsigned int *) buf);
  else
   return ntohl( *((unsigned int *) buf) );
 default:
  self->errornumber = 9;
  self->errormsg = "Cannot read ints of that length";
  return 0;
 }
}

canonical_original_code:
int SOCK_get_int(struct SocketClass_ *self, short len)
{
char buf[4];
 switch (len) {
 case 2:
  SOCK_get_n_char(self, buf, len);
  if (self->reverse)
   return *((unsigned short *) buf);
  else
   return ntohs( *((unsigned short *) buf) );
 case 4:
  SOCK_get_n_char(self, buf, len);
  if (self->reverse)
   return *((unsigned int *) buf);
  else
   return ntohl( *((unsigned int *) buf) );
 default:
  self->errornumber = 9;
  self->errormsg = "Cannot read ints of that length";
  return 0;
 }
}

variable_types: len short

variable_types:
buf
char [4]


decompiled_code:
__int64 __fastcall SOCK_get_string(__int64 a1, _BYTE *a2, int a3)
{
__int64 v3; // r12
_BYTE *v4; // r14
char v5; // al
__int64 result; // rax

v3 = a3;
if ( a3 <= 1 )
{
LABEL_6:
a2[v3 - 1] = 0;
result = 1LL;
}
else
{
v4 = a2;
while ( 1 )
{
v5 = SOCK_get_next_byte(a1);
*v4 = v5;
if ( !v5 )
break;
if ( ++v4 == &a2[(unsigned int)(v3 - 2) + 1] )
goto LABEL_6;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, _BYTE *a2, int a3)
{
__int64 v3; // r12
_BYTE *v4; // r14
char v5; // al
__int64 result; // rax

v3 = a3;
if ( a3 <= 1 )
{
LABEL_6:
a2[v3 - 1] = 0;
result = 1LL;
}
else
{
v4 = a2;
while ( 1 )
{
v5 = func9(a1);
*v4 = v5;
if ( !v5 )
break;
if ( ++v4 == &a2[(unsigned int)(v3 - 2) + 1] )
goto LABEL_6;
}
result = 0LL;
}
return result;
}

original_code:
int
SOCK_get_string(SocketClass *self, char *buffer, int bufsize)
{
 register int lf = 0;
 for (lf = 0; lf < bufsize - 1; lf++)
  if (!(buffer[lf] = SOCK_get_next_byte(self)))
   return (int)0;
 buffer[bufsize - 1] = '\0';
 return (int)1;
}

canonical_original_code:
int SOCK_get_string(struct SocketClass_ *self, char *buffer, int bufsize)
{
 register int lf = 0;
 for (lf = 0; lf < bufsize - 1; lf++)
  if (!(buffer[lf] = SOCK_get_next_byte(self)))
   return (int)0;
 buffer[bufsize - 1] = '\0';
 return (int)1;
}

variable_types: bufsize int


decompiled_code:
ssize_t __fastcall SOCK_put_next_byte(__int64 a1, char a2)
{
ssize_t result; // rax
__int64 v3; // rdx
size_t v4; // rdx

result = *(int *)(a1 + 4);
v3 = *(_QWORD *)(a1 + 24);
*(_DWORD *)(a1 + 4) = result + 1;
*(_BYTE *)(v3 + result) = a2;
v4 = *((int *)&globals + 1);
if ( *(_DWORD *)(a1 + 4) == (_DWORD)v4 )
{
result = send(*(_DWORD *)(a1 + 32), *(const void **)(a1 + 24), v4, 0);
if ( *((_DWORD *)&globals + 1) != (_DWORD)result )
{
result = (ssize_t)"Error while writing to the socket.";
*(_DWORD *)(a1 + 48) = 6;
*(_QWORD *)(a1 + 40) = "Error while writing to the socket.";
}
*(_DWORD *)(a1 + 4) = 0;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func13(__int64 a1, char a2)
{
ssize_t result; // rax
__int64 v3; // rdx
size_t v4; // rdx

result = *(int *)(a1 + 4);
v3 = *(_QWORD *)(a1 + 24);
*(_DWORD *)(a1 + 4) = result + 1;
*(_BYTE *)(v3 + result) = a2;
v4 = *((int *)&globals + 1);
if ( *(_DWORD *)(a1 + 4) == (_DWORD)v4 )
{
result = send(*(_DWORD *)(a1 + 32), *(const void **)(a1 + 24), v4, 0);
if ( *((_DWORD *)&globals + 1) != (_DWORD)result )
{
result = (ssize_t)"Error while writing to the socket.";
*(_DWORD *)(a1 + 48) = 6;
*(_QWORD *)(a1 + 40) = "Error while writing to the socket.";
}
*(_DWORD *)(a1 + 4) = 0;
}
return result;
}

original_code:
void
SOCK_put_next_byte(SocketClass *self, unsigned char next_byte)
{
int bytes_sent;
 self->buffer_out[self->buffer_filled_out++] = next_byte;
 if (self->buffer_filled_out == globals.socket_buffersize) {
  bytes_sent = send(self->socket, (char *)self->buffer_out, globals.socket_buffersize, 0);
  if (bytes_sent != globals.socket_buffersize) {
   self->errornumber = 6;
   self->errormsg = "Error while writing to the socket.";
  }
  self->buffer_filled_out = 0;
 }
}

canonical_original_code:
void SOCK_put_next_byte(struct SocketClass_ *self, unsigned char next_byte)
{
int bytes_sent;
 self->buffer_out[self->buffer_filled_out++] = next_byte;
 if (self->buffer_filled_out == globals.socket_buffersize) {
  bytes_sent = send(self->socket, (char *)self->buffer_out, globals.socket_buffersize, 0);
  if (bytes_sent != globals.socket_buffersize) {
   self->errornumber = 6;
   self->errormsg = "Error while writing to the socket.";
  }
  self->buffer_filled_out = 0;
 }
}


decompiled_code:
void __fastcall SOCK_Destructor(void *ptr)
{
void *v2; // rdi
void *v3; // rdi

if ( *((_DWORD *)ptr + 8) != -1 )
{
SOCK_put_next_byte((__int64)ptr, 88);
SOCK_flush_output((__int64)ptr);
close(*((_DWORD *)ptr + 8));
}
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 3);
if ( v3 )
free(v3);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func14(void *ptr)
{
void *v2; // rdi
void *v3; // rdi

if ( *((_DWORD *)ptr + 8) != -1 )
{
func13((__int64)ptr, 88);
func8((__int64)ptr);
close(*((_DWORD *)ptr + 8));
}
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 3);
if ( v3 )
free(v3);
free(ptr);
}

original_code:
void
SOCK_Destructor(SocketClass *self)
{
 if (self->socket != -1) {
  (SOCK_put_next_byte(self, 'X'));
  SOCK_flush_output(self);
  close(self->socket);
 }
 if (self->buffer_in)
  free(self->buffer_in);
 if (self->buffer_out)
  free(self->buffer_out);
 free(self);
}

canonical_original_code:
void SOCK_Destructor(struct SocketClass_ *self)
{
 if (self->socket != -1) {
  (SOCK_put_next_byte(self, 'X'));
  SOCK_flush_output(self);
  close(self->socket);
 }
 if (self->buffer_in)
  free(self->buffer_in);
 if (self->buffer_out)
  free(self->buffer_out);
 free(self);
}


decompiled_code:
const char *__fastcall SOCK_put_n_char(__int64 a1, char *a2, int a3)
{
char *v3; // rbx
const char *v4; // r12
const char *result; // rax

if ( a2 )
{
if ( a3 > 0 )
{
v3 = a2;
v4 = &a2[a3 - 1];
do
{
SOCK_put_next_byte(a1, *v3);
result = v3++;
}
while ( result != v4 );
}
}
else
{
result = "put_n_char was called with NULL-Pointer";
*(_DWORD *)(a1 + 48) = 7;
*(_QWORD *)(a1 + 40) = "put_n_char was called with NULL-Pointer";
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func15(__int64 a1, char *a2, int a3)
{
char *v3; // rbx
const char *v4; // r12
const char *result; // rax

if ( a2 )
{
if ( a3 > 0 )
{
v3 = a2;
v4 = &a2[a3 - 1];
do
{
func13(a1, *v3);
result = v3++;
}
while ( result != v4 );
}
}
else
{
result = "put_n_char was called with NULL-Pointer";
*(_DWORD *)(a1 + 48) = 7;
*(_QWORD *)(a1 + 40) = "put_n_char was called with NULL-Pointer";
}
return result;
}

original_code:
void
SOCK_put_n_char(SocketClass *self, char *buffer, int len)
{
 int lf;
 if ( ! buffer) {
  self->errornumber = 7;
  self->errormsg = "put_n_char was called with NULL-Pointer";
  return;
 }
 for(lf=0; lf < len; lf++)
  SOCK_put_next_byte(self, (unsigned char)buffer[lf]);
}

canonical_original_code:
void SOCK_put_n_char(struct SocketClass_ *self, char *buffer, int len)
{
 int lf;
 if ( ! buffer) {
  self->errornumber = 7;
  self->errormsg = "put_n_char was called with NULL-Pointer";
  return;
 }
 for(lf=0; lf < len; lf++)
  SOCK_put_next_byte(self, (unsigned char)buffer[lf]);
}


decompiled_code:
const char *__fastcall SOCK_put_int(__int64 a1, int a2, __int16 a3)
{
const char *result; // rax
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( a3 == 2 )
{
if ( !*(_BYTE *)(a1 + 52) )
a2 = (unsigned __int16)_bswap_16(a2);
v5[0] = a2;
result = SOCK_put_n_char(a1, (char *)v5, 2);
}
else if ( a3 == 4 )
{
if ( !*(_BYTE *)(a1 + 52) )
a2 = _bswap_32(a2);
v5[0] = a2;
result = SOCK_put_n_char(a1, (char *)v5, 4);
}
else
{
result = "Cannot write ints of that length";
*(_DWORD *)(a1 + 48) = 8;
*(_QWORD *)(a1 + 40) = "Cannot write ints of that length";
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func16(__int64 a1, int a2, __int16 a3)
{
const char *result; // rax
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( a3 == 2 )
{
if ( !*(_BYTE *)(a1 + 52) )
a2 = (unsigned __int16)func0(a2);
v5[0] = a2;
result = func15(a1, (char *)v5, 2);
}
else if ( a3 == 4 )
{
if ( !*(_BYTE *)(a1 + 52) )
a2 = func2(a2);
v5[0] = a2;
result = func15(a1, (char *)v5, 4);
}
else
{
result = "Cannot write ints of that length";
*(_DWORD *)(a1 + 48) = 8;
*(_QWORD *)(a1 + 40) = "Cannot write ints of that length";
}
return result;
}

original_code:
void
SOCK_put_int(SocketClass *self, int value, short len)
{
unsigned int rv;
 switch (len) {
 case 2:
  rv = self->reverse ? value : htons( (unsigned short) value);
  SOCK_put_n_char(self, (char *) &rv, 2);
  return;
 case 4:
  rv = self->reverse ? value : htonl( (unsigned int) value);
  SOCK_put_n_char(self, (char *) &rv, 4);
  return;
 default:
  self->errornumber = 8;
  self->errormsg = "Cannot write ints of that length";
  return;
  }
}

canonical_original_code:
void SOCK_put_int(struct SocketClass_ *self, int value, short len)
{
unsigned int rv;
 switch (len) {
 case 2:
  rv = self->reverse ? value : htons( (unsigned short) value);
  SOCK_put_n_char(self, (char *) &rv, 2);
  return;
 case 4:
  rv = self->reverse ? value : htonl( (unsigned int) value);
  SOCK_put_n_char(self, (char *) &rv, 4);
  return;
 default:
  self->errornumber = 8;
  self->errormsg = "Cannot write ints of that length";
  return;
  }
}

variable_types: value int

variable_types:
rv
unsigned int


decompiled_code:
size_t __fastcall SOCK_put_string(__int64 a1, const char *a2)
{
char *v2; // rbx
size_t result; // rax
__int64 v4; // r12
char v5; // si

v2 = (char *)a2;
result = strlen(a2);
if ( (int)result + 1 > 0 )
{
v4 = (__int64)&a2[(unsigned int)result + 1];
do
{
v5 = *v2++;
result = SOCK_put_next_byte(a1, v5);
}
while ( v2 != (char *)v4 );
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func17(__int64 a1, const char *a2)
{
char *v2; // rbx
size_t result; // rax
__int64 v4; // r12
char v5; // si

v2 = (char *)a2;
result = strlen(a2);
if ( (int)result + 1 > 0 )
{
v4 = (__int64)&a2[(unsigned int)result + 1];
do
{
v5 = *v2++;
result = func13(a1, v5);
}
while ( v2 != (char *)v4 );
}
return result;
}

original_code:
void
SOCK_put_string(SocketClass *self, char *string)
{
 register int lf;
 int len;
 len = strlen(string)+1;
 for(lf = 0; lf < len; lf++)
  SOCK_put_next_byte(self, (unsigned char)string[lf]);
}

canonical_original_code:
void SOCK_put_string(struct SocketClass_ *self, char *string)
{
 register int lf;
 int len;
 len = strlen(string)+1;
 for(lf = 0; lf < len; lf++)
  SOCK_put_next_byte(self, (unsigned char)string[lf]);
}

variable_types:
string
char *


calculateDigestFromBuffer

original_code:
static int
calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16])
{
 register uint32 i,
    j,
    k,
    newI;
 uint32 l;
 uint8 *input;
 register uint32 *wbp;
 uint32 workBuff[16],
    state[4];
 l = len;
 state[0] = 0x67452301;
 state[1] = 0xEFCDAB89;
 state[2] = 0x98BADCFE;
 state[3] = 0x10325476;
 if ((input = createPaddedCopyWithLength(b, &l)) == ((void *)0))
  return 0;
 for (i = 0;;)
 {
  if ((newI = i + 16 * 4) > l)
   break;
  k = i + 3;
  for (j = 0; j < 16; j++)
  {
   wbp = (workBuff + j);
   *wbp = input[k--];
   *wbp <<= 8;
   *wbp |= input[k--];
   *wbp <<= 8;
   *wbp |= input[k--];
   *wbp <<= 8;
   *wbp |= input[k];
   k += 7;
  }
  doTheRounds(workBuff, state);
  i = newI;
 }
 free(input);
 j = 0;
 for (i = 0; i < 4; i++)
 {
  k = state[i];
  sum[j++] = (k & 0xff);
  k >>= 8;
  sum[j++] = (k & 0xff);
  k >>= 8;
  sum[j++] = (k & 0xff);
  k >>= 8;
  sum[j++] = (k & 0xff);
 }
 return 1;
}

canonical_original_code:
static int calculateDigestFromBuffer(unsigned char *b, unsigned int len, unsigned char sum[16])
{
 register unsigned int i; register unsigned int j; register unsigned int k; register unsigned int newI;
 unsigned int l;
 unsigned char *input;
 register unsigned int *wbp;
 unsigned int workBuff[16]; unsigned int state[4];
 l = len;
 state[0] = 0x67452301;
 state[1] = 0xEFCDAB89;
 state[2] = 0x98BADCFE;
 state[3] = 0x10325476;
 if ((input = createPaddedCopyWithLength(b, &l)) == ((void *)0))
  return 0;
 for (i = 0;;)
 {
  if ((newI = i + 16 * 4) > l)
   break;
  k = i + 3;
  for (j = 0; j < 16; j++)
  {
   wbp = (workBuff + j);
   *wbp = input[k--];
   *wbp <<= 8;
   *wbp |= input[k--];
   *wbp <<= 8;
   *wbp |= input[k--];
   *wbp <<= 8;
   *wbp |= input[k];
   k += 7;
  }
  doTheRounds(workBuff, state);
  i = newI;
 }
 free(input);
 j = 0;
 for (i = 0; i < 4; i++)
 {
  k = state[i];
  sum[j++] = (k & 0xff);
  k >>= 8;
  sum[j++] = (k & 0xff);
  k >>= 8;
  sum[j++] = (k & 0xff);
  k >>= 8;
  sum[j++] = (k & 0xff);
 }
 return 1;
}

variable_types:
b
unsigned char *

variable_types:
len
unsigned int

variable_types:
sum
unsigned char [16]

variable_types:
i
unsigned int

variable_types:
j
unsigned int

variable_types:
k
unsigned int

variable_types:
newI
unsigned int

variable_types:
l
unsigned int

variable_types:
input
unsigned char *

variable_types:
wbp
unsigned int *

variable_types:
workBuff
unsigned int [16]

variable_types:
state
unsigned int [4]


decompiled_code:
__int64 __fastcall md5_hash(void *a1, unsigned int a2, __int64 a3)
{
int v4; // er8
__int64 result; // rax
_BYTE v6[40]; // [rsp+0h] [rbp-28h] BYREF

v4 = calculateDigestFromBuffer(a1, a2, (__int64)v6);
result = 0LL;
if ( v4 )
{
bytesToHex((__int64)v6, a3);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *a1, unsigned int a2, __int64 a3)
{
int v4; // er8
__int64 result; // rax
_BYTE v6[40]; // [rsp+0h] [rbp-28h] BYREF

v4 = func2(a1, a2, (__int64)v6);
result = 0LL;
if ( v4 )
{
func1((__int64)v6, a3);
result = 1LL;
}
return result;
}

original_code:
bool
md5_hash(const void *buff, size_t len, char *hexsum)
{
 uint8 sum[16];
 if (!calculateDigestFromBuffer((uint8 *) buff, len, sum))
  return ((bool) 0);
 bytesToHex(sum, hexsum);
 return ((bool) 1);
}

canonical_original_code:
char md5_hash(void *buff, unsigned long len, char *hexsum)
{
 unsigned char sum[16];
 if (!calculateDigestFromBuffer((unsigned char *) buff, len, sum))
  return ((char) 0);
 bytesToHex(sum, hexsum);
 return ((char) 1);
}

variable_types:
buff
void *

variable_types:
len
unsigned long

variable_types:
hexsum
char *


decompiled_code:
__int64 __fastcall EncryptMD5(void *src, void *a2, size_t n, _DWORD *a4)
{
size_t v6; // rbx
char *v7; // rbp

v6 = strlen((const char *)src);
v7 = (char *)malloc(v6 + n);
memcpy(v7, src, v6);
memcpy(&v7[v6], a2, n);
*a4 = 3499117;
LODWORD(n) = md5_hash(v7, (int)v6 + (int)n, (__int64)a4 + 3);
free(v7);
return (unsigned int)n;
}

canonical_decompiled_code:
__int64 __fastcall func4(void *src, void *a2, size_t n, _DWORD *a4)
{
size_t v6; // rbx
char *v7; // rbp

v6 = strlen((const char *)src);
v7 = (char *)malloc(v6 + n);
memcpy(v7, src, v6);
memcpy(&v7[v6], a2, n);
*a4 = 3499117;
LODWORD(n) = func3(v7, (int)v6 + (int)n, (__int64)a4 + 3);
free(v7);
return (unsigned int)n;
}

original_code:
bool
EncryptMD5(const char *passwd, const char *salt, size_t salt_len,
     char *buf)
{
 size_t passwd_len = strlen(passwd);
 char *crypt_buf = malloc(passwd_len + salt_len);
 bool ret;
 strcpy(crypt_buf, passwd);
 memcpy(crypt_buf + passwd_len, salt, salt_len);
 strcpy(buf, "md5");
 ret = md5_hash(crypt_buf, passwd_len + salt_len, buf + 3);
 free(crypt_buf);
 return ret;
}

canonical_original_code:
char EncryptMD5(char *passwd, char *salt, unsigned long salt_len, char *buf)
{
 unsigned long passwd_len = strlen(passwd);
 char *crypt_buf = malloc(passwd_len + salt_len);
 char ret;
 strcpy(crypt_buf, passwd);
 memcpy(crypt_buf + passwd_len, salt, salt_len);
 strcpy(buf, "md5");
 ret = md5_hash(crypt_buf, passwd_len + salt_len, buf + 3);
 free(crypt_buf);
 return ret;
}

variable_types:
passwd
char *

variable_types:
salt
char *

variable_types:
buf
char *

variable_types: ret char


decompiled_code:
_QWORD *CI_Constructor()
{
_QWORD *result; // rax

result = malloc(0x30uLL);
if ( result )
{
result[1] = 0LL;
*(_WORD *)result = 0;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
}
return result;
}

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

result = malloc(0x30uLL);
if ( result )
{
result[1] = 0LL;
*(_WORD *)result = 0;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
}
return result;
}

original_code:
ColumnInfoClass *
CI_Constructor()
{
ColumnInfoClass *rv;
 rv = (ColumnInfoClass *) malloc(sizeof(ColumnInfoClass));
 if (rv) {
  rv->num_fields = 0;
  rv->name = ((void *)0);
  rv->adtid = ((void *)0);
  rv->adtsize = ((void *)0);
  rv->display_size = ((void *)0);
  rv->atttypmod = ((void *)0);
 }
 return rv;
}

canonical_original_code:
struct ColumnInfoClass_ *CI_Constructor()
{
struct ColumnInfoClass_ *rv;
 rv = (struct ColumnInfoClass_ *) malloc(sizeof(ColumnInfoClass));
 if (rv) {
  rv->num_fields = 0;
  rv->name = ((void *)0);
  rv->adtid = ((void *)0);
  rv->adtsize = ((void *)0);
  rv->display_size = ((void *)0);
  rv->atttypmod = ((void *)0);
 }
 return rv;
}

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


decompiled_code:
void __fastcall CI_Destructor(void *ptr)
{
if ( ptr )
{
CI_free_memory((__int16 *)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
if ( ptr )
{
func1((__int16 *)ptr);
free(ptr);
}
}

original_code:
void
CI_Destructor(ColumnInfoClass *self)
{
    if ( self )
    {
        CI_free_memory(self);
        free(self);
    }
}

canonical_original_code:
void CI_Destructor(struct ColumnInfoClass_ *self)
{
    if ( self )
    {
        CI_free_memory(self);
        free(self);
    }
}

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


original_code:
void
CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
                                      Oid new_adtid, short new_adtsize, int new_atttypmod)
{
 if((field_num < 0) || (field_num >= self->num_fields)) {
  return;
 }
 self->name[field_num] = strdup(new_name);
 self->adtid[field_num] = new_adtid;
 self->adtsize[field_num] = new_adtsize;
 self->atttypmod[field_num] = new_atttypmod;
 self->display_size[field_num] = 0;
}

canonical_original_code:
void CI_set_field_info(struct ColumnInfoClass_ *self, int field_num, char *new_name, unsigned int new_adtid, short new_adtsize, int new_atttypmod)
{
 if((field_num < 0) || (field_num >= self->num_fields)) {
  return;
 }
 self->name[field_num] = strdup(new_name);
 self->adtid[field_num] = new_adtid;
 self->adtsize[field_num] = new_adtsize;
 self->atttypmod[field_num] = new_atttypmod;
 self->display_size[field_num] = 0;
}


SQLConfigDriver

decompiled_code:
__int64 __fastcall SQLConfigDriver(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4, __int64 a5, unsigned __int16 a6, unsigned __int16 *a7)
{
void *v7; // r15
void *v12; // rbp
unsigned __int16 v13; // r9
void *v14; // rbx
unsigned int v15; // er12
void *v17; // rax
unsigned __int16 v18; // [rsp+1Ah] [rbp-3Eh] BYREF
int v19[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v7 = 0LL;
inst_logClear();
if ( a3 )
v7 = (void *)single_string_alloc_and_expand(a3);
v12 = 0LL;
if ( a4 )
v12 = (void *)multi_string_alloc_and_expand(a4);
v13 = a6;
if ( a6 && a5 )
{
v17 = calloc(a6 + 1, 2uLL);
v13 = a6;
v14 = v17;
}
else
{
v14 = 0LL;
}
v15 = SQLConfigDriverWide(a1, a2, a3, a4, a5, v13, (__int64)&v18, (__int64)v7, (__int64)v12, (__int64)v14, v19);
if ( v7 )
free(v7);
if ( v12 )
free(v12);
if ( v19[0] && v15 )
{
if ( !v14 )
goto LABEL_17;
single_copy_from_wide(a5, v14, (unsigned int)v18 + 1);
goto LABEL_16;
}
if ( v14 )
LABEL_16:
free(v14);
LABEL_17:
if ( a7 )
*a7 = v18;
return v15;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4, __int64 a5, unsigned __int16 a6, unsigned __int16 *a7)
{
void *v7; // r15
void *v12; // rbp
unsigned __int16 v13; // r9
void *v14; // rbx
unsigned int v15; // er12
void *v17; // rax
unsigned __int16 v18; // [rsp+1Ah] [rbp-3Eh] BYREF
int v19[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v7 = 0LL;
inst_logClear();
if ( a3 )
v7 = (void *)single_string_alloc_and_expand(a3);
v12 = 0LL;
if ( a4 )
v12 = (void *)multi_string_alloc_and_expand(a4);
v13 = a6;
if ( a6 && a5 )
{
v17 = calloc(a6 + 1, 2uLL);
v13 = a6;
v14 = v17;
}
else
{
v14 = 0LL;
}
v15 = func0(a1, a2, a3, a4, a5, v13, (__int64)&v18, (__int64)v7, (__int64)v12, (__int64)v14, v19);
if ( v7 )
free(v7);
if ( v12 )
free(v12);
if ( v19[0] && v15 )
{
if ( !v14 )
goto LABEL_17;
single_copy_from_wide(a5, v14, (unsigned int)v18 + 1);
goto LABEL_16;
}
if ( v14 )
LABEL_16:
free(v14);
LABEL_17:
if ( a7 )
*a7 = v18;
return v15;
}

original_code:
int SQLConfigDriver(HWND hwndParent,
                             WORD fRequest,
                             LPCSTR lpszDriver,
                             LPCSTR lpszArgs,
                             LPSTR lpszMsg,
                             WORD cbMsgMax,
                             WORD *pcbMsgOut)
{
 SQLWCHAR *drv;
 SQLWCHAR *args;
 SQLWCHAR *msg;
 int ret;
 WORD len;
 int iswide;
    inst_logClear();
 drv = lpszDriver ? _single_string_alloc_and_expand( lpszDriver ) : (SQLWCHAR*)((void *)0);
 args = lpszArgs ? _multi_string_alloc_and_expand( lpszArgs ) : (SQLWCHAR*)((void *)0);
 if ( lpszMsg )
 {
  if ( cbMsgMax > 0 )
  {
   msg = calloc( cbMsgMax + 1, sizeof( SQLWCHAR ));
  }
  else
  {
   msg = ((void *)0);
  }
 }
 else
 {
  msg = ((void *)0);
 }
 ret = SQLConfigDriverWide( hwndParent,
       fRequest,
       lpszDriver,
       lpszArgs,
       lpszMsg,
       cbMsgMax,
       &len,
          drv,
       args,
       msg,
          &iswide );
 if ( drv )
  free( drv );
 if ( args )
  free( args );
 if ( iswide )
 {
  if ( ret && msg )
  {
   _single_copy_from_wide((SQLCHAR*) lpszMsg, msg, len + 1 );
  }
 }
 else
 {
 }
 if ( msg )
  free( msg );
 if ( pcbMsgOut )
  *pcbMsgOut = len;
 return ret;
}

canonical_original_code:
int SQLConfigDriver(void *hwndParent, unsigned short fRequest, char *lpszDriver, char *lpszArgs, char *lpszMsg, unsigned short cbMsgMax, unsigned short *pcbMsgOut)
{
 unsigned short *drv;
 unsigned short *args;
 unsigned short *msg;
 int ret;
 unsigned short len;
 int iswide;
    inst_logClear();
 drv = lpszDriver ? _single_string_alloc_and_expand( lpszDriver ) : (unsigned short *)((void *)0);
 args = lpszArgs ? _multi_string_alloc_and_expand( lpszArgs ) : (unsigned short *)((void *)0);
 if ( lpszMsg )
 {
  if ( cbMsgMax > 0 )
  {
   msg = calloc( cbMsgMax + 1, sizeof( SQLWCHAR ));
  }
  else
  {
   msg = ((void *)0);
  }
 }
 else
 {
  msg = ((void *)0);
 }
 ret = SQLConfigDriverWide( hwndParent,
       fRequest,
       lpszDriver,
       lpszArgs,
       lpszMsg,
       cbMsgMax,
       &len,
          drv,
       args,
       msg,
          &iswide );
 if ( drv )
  free( drv );
 if ( args )
  free( args );
 if ( iswide )
 {
  if ( ret && msg )
  {
   _single_copy_from_wide((unsigned char *) lpszMsg, msg, len + 1 );
  }
 }
 else
 {
 }
 if ( msg )
  free( msg );
 if ( pcbMsgOut )
  *pcbMsgOut = len;
 return ret;
}

variable_types:
hwndParent
void *

variable_types:
fRequest
unsigned short

variable_types:
lpszDriver
char *

variable_types:
lpszArgs
char *

variable_types:
lpszMsg
char *

variable_types:
cbMsgMax
unsigned short

variable_types:
pcbMsgOut
unsigned short *

variable_types:
drv
unsigned short *

variable_types:
args
unsigned short *

variable_types:
msg
unsigned short *

variable_types: ret int

variable_types:
len
unsigned short

variable_types: iswide int


SQLConfigDriverW

decompiled_code:
__int64 __fastcall SQLConfigDriverW(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4, __int64 a5, unsigned __int16 a6, unsigned __int16 *a7)
{
void *v7; // r15
void *v12; // rbx
unsigned __int16 v13; // r9
void *v14; // r13
unsigned int v15; // er12
void *v17; // rax
unsigned __int16 v18; // [rsp+1Ah] [rbp-3Eh] BYREF
int v19[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v7 = 0LL;
inst_logClear();
if ( a3 )
v7 = (void *)single_string_alloc_and_copy(a3);
v12 = 0LL;
if ( a4 )
v12 = (void *)multi_string_alloc_and_copy(a4);
v13 = a6;
if ( a6 && a5 )
{
v17 = calloc(a6 + 1, 1uLL);
v13 = a6;
v14 = v17;
}
else
{
v14 = 0LL;
}
v15 = SQLConfigDriverWide(a1, a2, (__int64)v7, (__int64)v12, (__int64)v14, v13, (__int64)&v18, a3, a4, a5, v19);
if ( v7 )
free(v7);
if ( v12 )
free(v12);
if ( !v19[0] && v15 )
{
if ( !v14 )
goto LABEL_17;
single_copy_to_wide(a5, v14, (unsigned int)v18 + 1);
goto LABEL_16;
}
if ( v14 )
LABEL_16:
free(v14);
LABEL_17:
if ( a7 )
*a7 = v18;
return v15;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4, __int64 a5, unsigned __int16 a6, unsigned __int16 *a7)
{
void *v7; // r15
void *v12; // rbx
unsigned __int16 v13; // r9
void *v14; // r13
unsigned int v15; // er12
void *v17; // rax
unsigned __int16 v18; // [rsp+1Ah] [rbp-3Eh] BYREF
int v19[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v7 = 0LL;
inst_logClear();
if ( a3 )
v7 = (void *)single_string_alloc_and_copy(a3);
v12 = 0LL;
if ( a4 )
v12 = (void *)multi_string_alloc_and_copy(a4);
v13 = a6;
if ( a6 && a5 )
{
v17 = calloc(a6 + 1, 1uLL);
v13 = a6;
v14 = v17;
}
else
{
v14 = 0LL;
}
v15 = func0(a1, a2, (__int64)v7, (__int64)v12, (__int64)v14, v13, (__int64)&v18, a3, a4, a5, v19);
if ( v7 )
free(v7);
if ( v12 )
free(v12);
if ( !v19[0] && v15 )
{
if ( !v14 )
goto LABEL_17;
single_copy_to_wide(a5, v14, (unsigned int)v18 + 1);
goto LABEL_16;
}
if ( v14 )
LABEL_16:
free(v14);
LABEL_17:
if ( a7 )
*a7 = v18;
return v15;
}

original_code:
int SQLConfigDriverW(HWND hwndParent,
                             WORD fRequest,
                             LPCWSTR lpszDriver,
                             LPCWSTR lpszArgs,
                             LPWSTR lpszMsg,
                             WORD cbMsgMax,
                             WORD *pcbMsgOut)
{
 char *drv;
 char *args;
 char *msg;
 int ret;
 WORD len;
 int iswide;
    inst_logClear();
 drv = lpszDriver ? _single_string_alloc_and_copy( lpszDriver ) : (char*)((void *)0);
 args = lpszArgs ? _multi_string_alloc_and_copy( lpszArgs ) : (char*)((void *)0);
 if ( lpszMsg )
 {
  if ( cbMsgMax > 0 )
  {
   msg = calloc( cbMsgMax + 1, 1 );
  }
  else
  {
   msg = ((void *)0);
  }
 }
 else
 {
  msg = ((void *)0);
 }
 ret = SQLConfigDriverWide( hwndParent,
       fRequest,
       drv,
       args,
       msg,
       cbMsgMax,
       &len,
          lpszDriver,
       lpszArgs,
       lpszMsg,
          &iswide );
 if ( drv )
  free( drv );
 if ( args )
  free( args );
 if ( iswide )
 {
 }
 else
 {
  if ( ret && msg )
  {
   _single_copy_to_wide( lpszMsg, msg, len + 1 );
  }
 }
 if ( msg )
  free( msg );
 if ( pcbMsgOut )
  *pcbMsgOut = len;
 return ret;
}

canonical_original_code:
int SQLConfigDriverW(void *hwndParent, unsigned short fRequest, unsigned short *lpszDriver, unsigned short *lpszArgs, unsigned short *lpszMsg, unsigned short cbMsgMax, unsigned short *pcbMsgOut)
{
 char *drv;
 char *args;
 char *msg;
 int ret;
 unsigned short len;
 int iswide;
    inst_logClear();
 drv = lpszDriver ? _single_string_alloc_and_copy( lpszDriver ) : (char *)((void *)0);
 args = lpszArgs ? _multi_string_alloc_and_copy( lpszArgs ) : (char *)((void *)0);
 if ( lpszMsg )
 {
  if ( cbMsgMax > 0 )
  {
   msg = calloc( cbMsgMax + 1, 1 );
  }
  else
  {
   msg = ((void *)0);
  }
 }
 else
 {
  msg = ((void *)0);
 }
 ret = SQLConfigDriverWide( hwndParent,
       fRequest,
       drv,
       args,
       msg,
       cbMsgMax,
       &len,
          lpszDriver,
       lpszArgs,
       lpszMsg,
          &iswide );
 if ( drv )
  free( drv );
 if ( args )
  free( args );
 if ( iswide )
 {
 }
 else
 {
  if ( ret && msg )
  {
   _single_copy_to_wide( lpszMsg, msg, len + 1 );
  }
 }
 if ( msg )
  free( msg );
 if ( pcbMsgOut )
  *pcbMsgOut = len;
 return ret;
}

variable_types:
lpszDriver
unsigned short *

variable_types:
lpszArgs
unsigned short *

variable_types:
lpszMsg
unsigned short *

variable_types:
drv
char *

variable_types:
args
char *

variable_types:
msg
char *


decompiled_code:
void __fastcall set_tuplefield_null(__int64 a1)
{
*(_DWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = 0LL;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
*(_DWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = 0LL;
}

original_code:
void set_tuplefield_null(TupleField *tuple_field)
{
 tuple_field->len = 0;
 tuple_field->value = ((void *)0);
}

canonical_original_code:
void set_tuplefield_null(struct TupleField_ *tuple_field)
{
 tuple_field->len = 0;
 tuple_field->value = ((void *)0);
}

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


decompiled_code:
char *__fastcall set_tuplefield_string(__int64 a1, const char *a2)
{
size_t v2; // rax
char *v3; // rax

*(_DWORD *)a1 = strlen(a2);
v2 = strlen(a2);
v3 = (char *)malloc(v2 + 1);
*(_QWORD *)(a1 + 8) = v3;
return strcpy(v3, a2);
}

canonical_decompiled_code:
char *__fastcall func1(__int64 a1, const char *a2)
{
size_t v2; // rax
char *v3; // rax

*(_DWORD *)a1 = strlen(a2);
v2 = strlen(a2);
v3 = (char *)malloc(v2 + 1);
*(_QWORD *)(a1 + 8) = v3;
return strcpy(v3, a2);
}

original_code:
void set_tuplefield_string(TupleField *tuple_field, char *string)
{
 tuple_field->len = strlen(string);
 tuple_field->value = malloc(strlen(string)+1);
 strcpy(tuple_field->value, string);
}

canonical_original_code:
void set_tuplefield_string(struct TupleField_ *tuple_field, char *string)
{
 tuple_field->len = strlen(string);
 tuple_field->value = malloc(strlen(string)+1);
 strcpy(tuple_field->value, string);
}

variable_types:
string
char *

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


decompiled_code:
char *__fastcall set_tuplefield_int2(__int64 a1, __int16 a2)
{
char *result; // rax
char s[34]; // [rsp+6h] [rbp-22h] BYREF

sprintf(s, "%d", (unsigned int)a2);
*(_DWORD *)a1 = strlen(s) + 1;
result = strdup(s);
*(_QWORD *)(a1 + 8) = result;
return result;
}

canonical_decompiled_code:
char *__fastcall func2(__int64 a1, __int16 a2)
{
char *result; // rax
char s[34]; // [rsp+6h] [rbp-22h] BYREF

sprintf(s, "%d", (unsigned int)a2);
*(_DWORD *)a1 = strlen(s) + 1;
result = strdup(s);
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
void set_tuplefield_int2(TupleField *tuple_field, short value)
{
char buffer[10];
 sprintf(buffer,"%d", value);
 tuple_field->len = strlen(buffer)+1;
 tuple_field->value = strdup(buffer);
}

canonical_original_code:
void set_tuplefield_int2(struct TupleField_ *tuple_field, short value)
{
char buffer[10];
 sprintf(buffer,"%d", value);
 tuple_field->len = strlen(buffer)+1;
 tuple_field->value = strdup(buffer);
}

variable_types: value short

variable_types:
buffer
char [10]


decompiled_code:
char *__fastcall set_tuplefield_int4(__int64 a1, int a2)
{
char *result; // rax
char s[39]; // [rsp+1h] [rbp-27h] BYREF

sprintf(s, "%ld", a2);
*(_DWORD *)a1 = strlen(s) + 1;
result = strdup(s);
*(_QWORD *)(a1 + 8) = result;
return result;
}

canonical_decompiled_code:
char *__fastcall func3(__int64 a1, int a2)
{
char *result; // rax
char s[39]; // [rsp+1h] [rbp-27h] BYREF

sprintf(s, "%ld", a2);
*(_DWORD *)a1 = strlen(s) + 1;
result = strdup(s);
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
void set_tuplefield_int4(TupleField *tuple_field, int value)
{
char buffer[15];
 sprintf(buffer,"%ld", (long)value);
 tuple_field->len = strlen(buffer)+1;
 tuple_field->value = strdup(buffer);
}

canonical_original_code:
void set_tuplefield_int4(struct TupleField_ *tuple_field, int value)
{
char buffer[15];
 sprintf(buffer,"%ld", (long)value);
 tuple_field->len = strlen(buffer)+1;
 tuple_field->value = strdup(buffer);
}

variable_types: value int

variable_types:
buffer
char [15]


cInc

decompiled_code:
int cInc()
{
puts("#ifndef HAVE_UNISTD_H\n #define HAVE_UNISTD_H\n#endif");
puts("#ifndef HAVE_PWD_H\n #define HAVE_PWD_H\n#endif");
puts("#ifndef HAVE_SYS_TYPES_H\n #define HAVE_SYS_TYPES_H\n#endif");
puts("#ifndef HAVE_LONG_LONG\n #define HAVE_LONG_LONG\n#endif");
printf("#ifndef ODBCINT64\n #define ODBCINT64 %s\n#endif\n", "long long");
printf("#ifndef UODBCINT64\n #define UODBCINT64 %s\n#endif\n", "unsigned long long");
return printf("#ifndef SIZEOF_LONG_INT\n #define SIZEOF_LONG_INT %d\n#endif\n", 4LL);
}

canonical_decompiled_code:
int func0()
{
puts("#ifndef HAVE_UNISTD_H\n #define HAVE_UNISTD_H\n#endif");
puts("#ifndef HAVE_PWD_H\n #define HAVE_PWD_H\n#endif");
puts("#ifndef HAVE_SYS_TYPES_H\n #define HAVE_SYS_TYPES_H\n#endif");
puts("#ifndef HAVE_LONG_LONG\n #define HAVE_LONG_LONG\n#endif");
printf("#ifndef ODBCINT64\n #define ODBCINT64 %s\n#endif\n", "long long");
printf("#ifndef UODBCINT64\n #define UODBCINT64 %s\n#endif\n", "unsigned long long");
return printf("#ifndef SIZEOF_LONG_INT\n #define SIZEOF_LONG_INT %d\n#endif\n", 4LL);
}

original_code:
static void cInc( void )
{
    printf( "#ifndef HAVE_UNISTD_H\n #define HAVE_UNISTD_H\n#endif\n" );
    printf( "#ifndef HAVE_PWD_H\n #define HAVE_PWD_H\n#endif\n" );
    printf( "#ifndef HAVE_SYS_TYPES_H\n #define HAVE_SYS_TYPES_H\n#endif\n" );
    printf( "#ifndef HAVE_LONG_LONG\n #define HAVE_LONG_LONG\n#endif\n" );
    printf( "#ifndef ODBCINT64\n #define ODBCINT64 %s\n#endif\n", "long long" );
    printf( "#ifndef UODBCINT64\n #define UODBCINT64 %s\n#endif\n", "unsigned long long" );
    printf( "#ifndef SIZEOF_LONG_INT\n #define SIZEOF_LONG_INT %d\n#endif\n", 4 );
}

canonical_original_code:
static void cInc()
{
    printf( "#ifndef HAVE_UNISTD_H\n #define HAVE_UNISTD_H\n#endif\n" );
    printf( "#ifndef HAVE_PWD_H\n #define HAVE_PWD_H\n#endif\n" );
    printf( "#ifndef HAVE_SYS_TYPES_H\n #define HAVE_SYS_TYPES_H\n#endif\n" );
    printf( "#ifndef HAVE_LONG_LONG\n #define HAVE_LONG_LONG\n#endif\n" );
    printf( "#ifndef ODBCINT64\n #define ODBCINT64 %s\n#endif\n", "long long" );
    printf( "#ifndef UODBCINT64\n #define UODBCINT64 %s\n#endif\n", "unsigned long long" );
    printf( "#ifndef SIZEOF_LONG_INT\n #define SIZEOF_LONG_INT %d\n#endif\n", 4 );
}


ulen

decompiled_code:
int ulen()
{
return printf("-DSIZEOF_SQLULEN=%d\n", 8LL);
}

canonical_decompiled_code:
int func1()
{
return printf("-DSIZEOF_SQLULEN=%d\n", 8LL);
}

original_code:
static void ulen( void )
{
 printf( "-DSIZEOF_SQLULEN=%d\n", (int)sizeof( SQLUINTEGER ));
}

canonical_original_code:
static void ulen()
{
 printf( "-DSIZEOF_SQLULEN=%d\n", (int)sizeof( SQLUINTEGER ));
}


cflags

decompiled_code:
int cflags()
{
printf("-DHAVE_UNISTD_H ");
printf("-DHAVE_PWD_H ");
printf("-DHAVE_SYS_TYPES_H ");
printf("-DHAVE_LONG_LONG ");
printf("-DSIZEOF_LONG_INT=%d ", 4LL);
printf("-I%s ", "/usr/include");
return putchar(10);
}

canonical_decompiled_code:
int func2()
{
printf("-DHAVE_UNISTD_H ");
printf("-DHAVE_PWD_H ");
printf("-DHAVE_SYS_TYPES_H ");
printf("-DHAVE_LONG_LONG ");
printf("-DSIZEOF_LONG_INT=%d ", 4LL);
printf("-I%s ", "/usr/include");
return putchar(10);
}

original_code:
static void cflags( void )
{
    printf( "-DHAVE_UNISTD_H " );
    printf( "-DHAVE_PWD_H " );
    printf( "-DHAVE_SYS_TYPES_H " );
    printf( "-DHAVE_LONG_LONG " );
    printf( "-DSIZEOF_LONG_INT=%d ", 4 );
 printf( "-I%s ", "/usr/include" );
    printf( "\n" );
}

canonical_original_code:
static void cflags()
{
    printf( "-DHAVE_UNISTD_H " );
    printf( "-DHAVE_PWD_H " );
    printf( "-DHAVE_SYS_TYPES_H " );
    printf( "-DHAVE_LONG_LONG " );
    printf( "-DSIZEOF_LONG_INT=%d ", 4 );
 printf( "-I%s ", "/usr/include" );
    printf( "\n" );
}


usage

decompiled_code:
size_t usage()
{
return fwrite(
"Usage: odbc_config\n"
"\t\t[--prefix]\n"
"\t\t[--exec-prefix]\n"
"\t\t[--include-prefix]\n"
"\t\t[--lib-prefix]\n"
"\t\t[--bin-prefix]\n"
"\t\t[--version]\n"
"\t\t[--libs]\n"
"\t\t[--static-libs]\n"
"\t\t[--libtool-libs]\n"
"\t\t[--cflags]\n"
"\t\t[--odbcversion]\n"
"\t\t[--longodbcversion]\n"
"\t\t[--odbcini]\n"
"\t\t[--odbcinstini]\n"
"\t\t[--header]\n"
"\t\t[--ulen]\n",
1uLL,
0x114uLL,
stderr);
}

canonical_decompiled_code:
size_t func3()
{
return fwrite(
"Usage: odbc_config\n"
"\t\t[--prefix]\n"
"\t\t[--exec-prefix]\n"
"\t\t[--include-prefix]\n"
"\t\t[--lib-prefix]\n"
"\t\t[--bin-prefix]\n"
"\t\t[--version]\n"
"\t\t[--libs]\n"
"\t\t[--static-libs]\n"
"\t\t[--libtool-libs]\n"
"\t\t[--cflags]\n"
"\t\t[--odbcversion]\n"
"\t\t[--longodbcversion]\n"
"\t\t[--odbcini]\n"
"\t\t[--odbcinstini]\n"
"\t\t[--header]\n"
"\t\t[--ulen]\n",
1uLL,
0x114uLL,
stderr);
}

original_code:
static void usage( void )
{
        fprintf( stderr, "Usage: odbc_config\n\t\t[--prefix]\n\t\t[--exec-prefix]\n\t\t[--include-prefix]\n\t\t[--lib-prefix]\n\t\t[--bin-prefix]\n\t\t[--version]\n\t\t[--libs]\n\t\t[--static-libs]\n\t\t[--libtool-libs]\n\t\t[--cflags]\n\t\t[--odbcversion]\n\t\t[--longodbcversion]\n\t\t[--odbcini]\n\t\t[--odbcinstini]\n\t\t[--header]\n\t\t[--ulen]\n" );
}

canonical_original_code:
static void usage()
{
        fprintf( stderr, "Usage: odbc_config\n\t\t[--prefix]\n\t\t[--exec-prefix]\n\t\t[--include-prefix]\n\t\t[--lib-prefix]\n\t\t[--bin-prefix]\n\t\t[--version]\n\t\t[--libs]\n\t\t[--static-libs]\n\t\t[--libtool-libs]\n\t\t[--cflags]\n\t\t[--odbcversion]\n\t\t[--longodbcversion]\n\t\t[--odbcini]\n\t\t[--odbcinstini]\n\t\t[--header]\n\t\t[--ulen]\n" );
}


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rbp

if ( argc > 1 )
{
v3 = argv + 1;
while ( 1 )
{
v4 = *v3;
if ( !strcmp(*v3, "--prefix") || !strcmp(*v3, "--exec-prefix") )
{
puts("/usr");
}
else if ( !strcmp(*v3, "--bin-prefix") )
{
puts("/usr/bin");
}
else if ( !strcmp(*v3, "--include-prefix") )
{
puts("/usr/include");
}
else if ( !strcmp(*v3, "--lib-prefix") )
{
puts("/usr/lib");
}
else if ( !strcmp(*v3, "--version") )
{
puts("2.3.0");
}
else if ( !strcmp(*v3, "--libs") )
{
printf("-L%s -lodbc\n", "/usr/lib");
}
else if ( !strcmp(*v3, "--static-libs") )
{
printf("%s/libodbc.a\n", "/usr/lib");
}
else if ( !strcmp(*v3, "--libtool-libs") )
{
printf("%s/libodbc.la\n", "/usr/lib");
}
else if ( !strcmp(v4, "--cflags") )
{
cflags();
}
else if ( !strcmp(v4, "--header") )
{
cInc();
}
else if ( !strcmp(v4, "--odbcversion") )
{
puts("3");
}
else if ( !strcmp(v4, "--longodbcversion") )
{
puts("3.52");
}
else if ( !strcmp(v4, "--odbcini") )
{
printf("%s/odbc.ini\n", "/etc");
}
else if ( !strcmp(v4, "--odbcinstini") )
{
printf("%s/odbcinst.ini\n", "/etc");
}
else
{
if ( strcmp(v4, "--ulen") )
break;
ulen();
}
if ( ++v3 == &argv[(unsigned int)(argc - 2) + 2] )
exit(0);
}
}
usage();
exit(-1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rbp

if ( argc > 1 )
{
v3 = argv + 1;
while ( 1 )
{
v4 = *v3;
if ( !strcmp(*v3, "--prefix") || !strcmp(*v3, "--exec-prefix") )
{
puts("/usr");
}
else if ( !strcmp(*v3, "--bin-prefix") )
{
puts("/usr/bin");
}
else if ( !strcmp(*v3, "--include-prefix") )
{
puts("/usr/include");
}
else if ( !strcmp(*v3, "--lib-prefix") )
{
puts("/usr/lib");
}
else if ( !strcmp(*v3, "--version") )
{
puts("2.3.0");
}
else if ( !strcmp(*v3, "--libs") )
{
printf("-L%s -lodbc\n", "/usr/lib");
}
else if ( !strcmp(*v3, "--static-libs") )
{
printf("%s/libodbc.a\n", "/usr/lib");
}
else if ( !strcmp(*v3, "--libtool-libs") )
{
printf("%s/libodbc.la\n", "/usr/lib");
}
else if ( !strcmp(v4, "--cflags") )
{
func2();
}
else if ( !strcmp(v4, "--header") )
{
func0();
}
else if ( !strcmp(v4, "--odbcversion") )
{
puts("3");
}
else if ( !strcmp(v4, "--longodbcversion") )
{
puts("3.52");
}
else if ( !strcmp(v4, "--odbcini") )
{
printf("%s/odbc.ini\n", "/etc");
}
else if ( !strcmp(v4, "--odbcinstini") )
{
printf("%s/odbcinst.ini\n", "/etc");
}
else
{
if ( strcmp(v4, "--ulen") )
break;
func1();
}
if ( ++v3 == &argv[(unsigned int)(argc - 2) + 2] )
exit(0);
}
}
func3();
exit(-1);
}

original_code:
int main( int argc, char **argv )
{
    int i;
    if ( argc < 2 )
    {
        usage();
        exit( -1 );
    }
    for ( i = 1; i < argc; i ++ )
    {
        if ( strcmp( argv[ i ], "--prefix" ) == 0 )
        {
            printf( "%s\n", "/usr" );
        }
        else if ( strcmp( argv[ i ], "--exec-prefix" ) == 0 )
        {
            printf( "%s\n", "/usr" );
        }
        else if ( strcmp( argv[ i ], "--bin-prefix" ) == 0 )
        {
            printf( "%s\n", "/usr/bin" );
        }
        else if ( strcmp( argv[ i ], "--include-prefix" ) == 0 )
        {
            printf( "%s\n", "/usr/include" );
        }
        else if ( strcmp( argv[ i ], "--lib-prefix" ) == 0 )
        {
            printf( "%s\n", "/usr/lib" );
        }
        else if ( strcmp( argv[ i ], "--version" ) == 0 )
        {
            printf( "%s\n", "2.3.0" );
        }
        else if ( strcmp( argv[ i ], "--libs" ) == 0 )
        {
            printf( "-L%s -lodbc\n", "/usr/lib" );
        }
        else if ( strcmp( argv[ i ], "--static-libs" ) == 0 )
        {
            printf( "%s/libodbc.a\n", "/usr/lib" );
        }
        else if ( strcmp( argv[ i ], "--libtool-libs" ) == 0 )
        {
            printf( "%s/libodbc.la\n", "/usr/lib" );
        }
        else if ( strcmp( argv[ i ], "--cflags" ) == 0 )
        {
            cflags();
        }
        else if ( strcmp( argv[ i ], "--header" ) == 0 )
        {
            cInc();
        }
        else if ( strcmp( argv[ i ], "--odbcversion" ) == 0 )
        {
            printf( "3\n" );
        }
        else if ( strcmp( argv[ i ], "--longodbcversion" ) == 0 )
        {
            printf( "3.52\n" );
        }
        else if ( strcmp( argv[ i ], "--odbcini" ) == 0 )
        {
            printf( "%s/odbc.ini\n", "/etc" );
        }
        else if ( strcmp( argv[ i ], "--odbcinstini" ) == 0 )
        {
            printf( "%s/odbcinst.ini\n", "/etc" );
        }
        else if ( strcmp( argv[ i ], "--ulen" ) == 0 )
        {
            ulen();
        }
        else
        {
            usage();
            exit( -1 );
        }
    }
 exit(0);
}

canonical_original_code:
int main(int argc, char **argv)
{
    int i;
    if ( argc < 2 )
    {
        usage();
        exit( -1 );
    }
    for ( i = 1; i < argc; i ++ )
    {
        if ( strcmp( argv[ i ], "--prefix" ) == 0 )
        {
            printf( "%s\n", "/usr" );
        }
        else if ( strcmp( argv[ i ], "--exec-prefix" ) == 0 )
        {
            printf( "%s\n", "/usr" );
        }
        else if ( strcmp( argv[ i ], "--bin-prefix" ) == 0 )
        {
            printf( "%s\n", "/usr/bin" );
        }
        else if ( strcmp( argv[ i ], "--include-prefix" ) == 0 )
        {
            printf( "%s\n", "/usr/include" );
        }
        else if ( strcmp( argv[ i ], "--lib-prefix" ) == 0 )
        {
            printf( "%s\n", "/usr/lib" );
        }
        else if ( strcmp( argv[ i ], "--version" ) == 0 )
        {
            printf( "%s\n", "2.3.0" );
        }
        else if ( strcmp( argv[ i ], "--libs" ) == 0 )
        {
            printf( "-L%s -lodbc\n", "/usr/lib" );
        }
        else if ( strcmp( argv[ i ], "--static-libs" ) == 0 )
        {
            printf( "%s/libodbc.a\n", "/usr/lib" );
        }
        else if ( strcmp( argv[ i ], "--libtool-libs" ) == 0 )
        {
            printf( "%s/libodbc.la\n", "/usr/lib" );
        }
        else if ( strcmp( argv[ i ], "--cflags" ) == 0 )
        {
            cflags();
        }
        else if ( strcmp( argv[ i ], "--header" ) == 0 )
        {
            cInc();
        }
        else if ( strcmp( argv[ i ], "--odbcversion" ) == 0 )
        {
            printf( "3\n" );
        }
        else if ( strcmp( argv[ i ], "--longodbcversion" ) == 0 )
        {
            printf( "3.52\n" );
        }
        else if ( strcmp( argv[ i ], "--odbcini" ) == 0 )
        {
            printf( "%s/odbc.ini\n", "/etc" );
        }
        else if ( strcmp( argv[ i ], "--odbcinstini" ) == 0 )
        {
            printf( "%s/odbcinst.ini\n", "/etc" );
        }
        else if ( strcmp( argv[ i ], "--ulen" ) == 0 )
        {
            ulen();
        }
        else
        {
            usage();
            exit( -1 );
        }
    }
 exit(0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int


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

if ( a1 )
result = *(unsigned int *)(a1 + 12);
else
result = 0xFFFFFFFFLL;
return result;
}

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

if ( a1 )
result = *(unsigned int *)(a1 + 12);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int nnsql_errcode(void* yystmt)
{
 if( ! yystmt )
  return -1;
 return ((yystmt_t*)yystmt)->errcode;
}

canonical_original_code:
int nnsql_errcode(void *yystmt)
{
 if( ! yystmt )
  return -1;
 return ((struct yystmt_t *)yystmt)->errcode;
}

variable_types:
yystmt
void *

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

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


decompiled_code:
char *__fastcall nnsql_errmsg(_QWORD *a1, __int64 a2)
{
int v2; // eax
char **v3; // rcx
int v4; // edx
int v5; // esi
int *v7; // rax

v2 = nnsql_errcode((__int64)a1);
if ( !v2 )
return (char *)nntp_errmsg(*a1);
if ( v2 == 256 )
return (char *)(a1 + 11);
v3 = &off_710;
v4 = 0;
if ( v2 == -1 )
{
if ( !(unsigned int)nntp_errcode(*a1, a2, 0LL, &off_710) )
{
v7 = _errno_location();
return strerror(*v7);
}
return (char *)nntp_errmsg(*a1);
}
while ( ++v4 != 24 )
{
v5 = *(_DWORD *)v3;
v3 += 2;
if ( v5 == v2 )
return (&yy_errmsg)[2 * v4 + 1];
}
return 0LL;
}

canonical_decompiled_code:
char *__fastcall func1(_QWORD *a1, __int64 a2)
{
int v2; // eax
char **v3; // rcx
int v4; // edx
int v5; // esi
int *v7; // rax

v2 = func0((__int64)a1);
if ( !v2 )
return (char *)nntp_errmsg(*a1);
if ( v2 == 256 )
return (char *)(a1 + 11);
v3 = &off_710;
v4 = 0;
if ( v2 == -1 )
{
if ( !(unsigned int)nntp_errcode(*a1, a2, 0LL, &off_710) )
{
v7 = _errno_location();
return strerror(*v7);
}
return (char *)nntp_errmsg(*a1);
}
while ( ++v4 != 24 )
{
v5 = *(_DWORD *)v3;
v3 += 2;
if ( v5 == v2 )
return (&yy_errmsg)[2 * v4 + 1];
}
return 0LL;
}

original_code:
char* nnsql_errmsg(void* yystmt)
{
 yystmt_t* pstmt = yystmt;
 int i, errcode;
 errcode = nnsql_errcode( yystmt );
 switch( errcode )
 {
  case 0:
   return nntp_errmsg(pstmt->hcndes);
  case -1:
   if( nntp_errcode(pstmt->hcndes) )
    return nntp_errmsg(pstmt->hcndes);
   else
    return strerror( (*__errno_location ()) );
  case 256:
   return ((yystmt_t*)yystmt)->msgbuf;
  default:
   break;
 }
 for(i=0; i<sizeof(yy_errmsg)/sizeof(yy_errmsg[0]);i++)
 {
  if( yy_errmsg[i].errcode == errcode )
   return yy_errmsg[i].msg;
 }
 return 0;
}

canonical_original_code:
char *nnsql_errmsg(void *yystmt)
{
 struct yystmt_t *pstmt = yystmt;
 int i; int errcode;
 errcode = nnsql_errcode( yystmt );
 switch( errcode )
 {
  case 0:
   return nntp_errmsg(pstmt->hcndes);
  case -1:
   if( nntp_errcode(pstmt->hcndes) )
    return nntp_errmsg(pstmt->hcndes);
   else
    return strerror( (*__errno_location ()) );
  case 256:
   return ((struct yystmt_t *)yystmt)->msgbuf;
  default:
   break;
 }
 for(i=0; i<sizeof(yy_errmsg)/sizeof(yy_errmsg[0]);i++)
 {
  if( yy_errmsg[i].errcode == errcode )
   return yy_errmsg[i].msg;
 }
 return 0;
}

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

variable_types: errcode int

return_type: char *


decompiled_code:
__int64 __fastcall nnsql_errpos(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

original_code:
int nnsql_errpos(void* yystmt)
{
 return ((yystmt_t*)yystmt)->errpos;
}

canonical_original_code:
int nnsql_errpos(void *yystmt)
{
 return ((struct yystmt_t *)yystmt)->errpos;
}


SQLGetInstalledDriversW

decompiled_code:
__int64 __fastcall SQLGetInstalledDriversW(__int64 a1, unsigned __int16 a2, _WORD *a3)
{
void *v4; // rbp
unsigned int v5; // er13

inst_logClear();
v4 = calloc(a2, 1uLL);
v5 = SQLGetInstalledDrivers(v4, a2, a3);
if ( v5 )
multi_string_copy_to_wide(a1, v4, a2);
free(v4);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned __int16 a2, _WORD *a3)
{
void *v4; // rbp
unsigned int v5; // er13

inst_logClear();
v4 = calloc(a2, 1uLL);
v5 = func0(v4, a2, a3);
if ( v5 )
multi_string_copy_to_wide(a1, v4, a2);
free(v4);
return v5;
}

original_code:
int SQLGetInstalledDriversW (LPWSTR lpszBuf,
                                      WORD cbBufMax,
                                      WORD * pcbBufOut)
{
 char *path;
 int ret;
    inst_logClear();
 path = calloc( cbBufMax, 1 );
 ret = SQLGetInstalledDrivers( path, cbBufMax, pcbBufOut );
 if ( ret )
 {
  _multi_string_copy_to_wide( lpszBuf, path, cbBufMax );
 }
 free( path );
 return ret;
}

canonical_original_code:
int SQLGetInstalledDriversW(unsigned short *lpszBuf, unsigned short cbBufMax, unsigned short *pcbBufOut)
{
 char *path;
 int ret;
    inst_logClear();
 path = calloc( cbBufMax, 1 );
 ret = SQLGetInstalledDrivers( path, cbBufMax, pcbBufOut );
 if ( ret )
 {
  _multi_string_copy_to_wide( lpszBuf, path, cbBufMax );
 }
 free( path );
 return ret;
}

variable_types:
lpszBuf
unsigned short *

variable_types:
cbBufMax
unsigned short

variable_types:
pcbBufOut
unsigned short *

variable_types:
path
char *

variable_types: ret int


SQLGetConfigMode

decompiled_code:
__int64 __fastcall SQLGetConfigMode(_WORD *a1)
{
inst_logClear();
*a1 = _get_config_mode();
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_WORD *a1)
{
inst_logClear();
*a1 = _get_config_mode();
return 1LL;
}

original_code:
int SQLGetConfigMode( UWORD *pnConfigMode )
{
    inst_logClear();
    *pnConfigMode = __get_config_mode();
    return 1;
}

canonical_original_code:
int SQLGetConfigMode(unsigned short *pnConfigMode)
{
    inst_logClear();
    *pnConfigMode = __get_config_mode();
    return 1;
}

variable_types:
pnConfigMode
unsigned short *


SQLCloseCursor

decompiled_code:
__int64 __fastcall SQLCloseCursor(__int64 a1)
{
if ( !a1 )
return 4294967294LL;
sprintf((char *)(a1 + 136), "hStmt = $%08lX", a1);
logPushMsg(*(_QWORD *)(a1 + 1160), "SQLCloseCursor.c", "SQLCloseCursor.c", 25LL, 1LL, 1LL, a1 + 136);
logPushMsg(
*(_QWORD *)(a1 + 1160),
"SQLCloseCursor.c",
"SQLCloseCursor.c",
30LL,
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), "SQLCloseCursor.c", "SQLCloseCursor.c", 25LL, 1LL, 1LL, a1 + 136);
logPushMsg(
*(_QWORD *)(a1 + 1160),
"SQLCloseCursor.c",
"SQLCloseCursor.c",
30LL,
1LL,
1LL,
"SQL_ERROR This function not supported");
return 0xFFFFFFFFLL;
}

original_code:
SQLRETURN SQLCloseCursor( SQLHSTMT statement_handle )
{
    DMHSTMT statement = (DMHSTMT) statement_handle;
    SQLRETURN ret;
    SQLCHAR s1[ 100 + 128 ];
    if ( !__validate_stmt( statement ))
    {
        dm_log_write( "SQLCloseCursor.c",
                122,
                    0,
                    0,
                    "Error: SQL_INVALID_HANDLE" );
        return (-2);
    }
    function_entry( statement );
    if ( log_info.log_flag )
    {
        sprintf( statement -> msg, "\n\t\tEntry:\n\t\t\tStatement = %p",
                statement );
        dm_log_write( "SQLCloseCursor.c",
                139,
                0,
                0,
                statement -> msg );
    }
    thread_protect( 3, statement );
    if ( statement -> state == 1 ||
            statement -> state == 2 ||
            statement -> state == 3 ||
            statement -> state == 4 )
    {
        dm_log_write( "SQLCloseCursor.c",
                157,
                0,
                0,
                "Error: 24000" );
        __post_internal_error( &statement -> error,
                ERROR_24000, ((void *)0),
                statement -> connection -> environment -> requested_version );
        return function_return_ex(3,statement,(-1),0);
    }
    else if ( statement -> state == 8 ||
            statement -> state == 9 ||
            statement -> state == 10 ||
            statement -> state == 11 ||
            statement -> state == 12 )
    {
        dm_log_write( "SQLCloseCursor.c",
                175,
                0,
                0,
                "Error: HY010" );
        __post_internal_error( &statement -> error,
                ERROR_HY010, ((void *)0),
                statement -> connection -> environment -> requested_version );
        return function_return_ex(3,statement,(-1),0);
    }
    if ( !(statement -> connection->functions[11].func!=((void *)0)))
    {
        if ( !(statement -> connection->functions[34].func!=((void *)0)))
        {
            dm_log_write( "SQLCloseCursor.c",
                    192,
                    0,
                    0,
                    "Error: IM001" );
            __post_internal_error( &statement -> error,
                    ERROR_IM001, ((void *)0),
                    statement -> connection -> environment -> requested_version );
            return function_return_ex(3,statement,(-1),0);
        }
        else
        {
            ret = (statement -> connection->functions[34].func)(statement -> driver_stmt,0);
        }
    }
    else
    {
        ret = (statement -> connection->functions[11].func)(statement -> driver_stmt);
    }
    if ( (((ret)&(~1))==0))
    {
        if ( statement -> prepared )
            statement -> state = 3;
        else
            statement -> state = 1;
    }
    if ( log_info.log_flag )
    {
        sprintf( statement -> msg,
                "\n\t\tExit:[%s]",
                    __get_return_status( ret, s1 ));
        dm_log_write( "SQLCloseCursor.c",
                231,
                0,
                0,
                statement -> msg );
    }
    return function_return_ex(3,statement,ret,0);
}

canonical_original_code:
short SQLCloseCursor(void *statement_handle)
{
    struct statement *statement = (DMHSTMT) statement_handle;
    short ret;
    unsigned char s1[-1];
    if ( !__validate_stmt( statement ))
    {
        dm_log_write( "SQLCloseCursor.c",
                122,
                    0,
                    0,
                    "Error: SQL_INVALID_HANDLE" );
        return (-2);
    }
    function_entry( statement );
    if ( log_info.log_flag )
    {
        sprintf( statement -> msg, "\n\t\tEntry:\n\t\t\tStatement = %p",
                statement );
        dm_log_write( "SQLCloseCursor.c",
                139,
                0,
                0,
                statement -> msg );
    }
    thread_protect( 3, statement );
    if ( statement -> state == 1 ||
            statement -> state == 2 ||
            statement -> state == 3 ||
            statement -> state == 4 )
    {
        dm_log_write( "SQLCloseCursor.c",
                157,
                0,
                0,
                "Error: 24000" );
        __post_internal_error( &statement -> error,
                ERROR_24000, ((void *)0),
                statement -> connection -> environment -> requested_version );
        return function_return_ex(3,statement,(-1),0);
    }
    else if ( statement -> state == 8 ||
            statement -> state == 9 ||
            statement -> state == 10 ||
            statement -> state == 11 ||
            statement -> state == 12 )
    {
        dm_log_write( "SQLCloseCursor.c",
                175,
                0,
                0,
                "Error: HY010" );
        __post_internal_error( &statement -> error,
                ERROR_HY010, ((void *)0),
                statement -> connection -> environment -> requested_version );
        return function_return_ex(3,statement,(-1),0);
    }
    if ( !(statement -> connection->functions[11].func!=((void *)0)))
    {
        if ( !(statement -> connection->functions[34].func!=((void *)0)))
        {
            dm_log_write( "SQLCloseCursor.c",
                    192,
                    0,
                    0,
                    "Error: IM001" );
            __post_internal_error( &statement -> error,
                    ERROR_IM001, ((void *)0),
                    statement -> connection -> environment -> requested_version );
            return function_return_ex(3,statement,(-1),0);
        }
        else
        {
            ret = (statement -> connection->functions[34].func)(statement -> driver_stmt,0);
        }
    }
    else
    {
        ret = (statement -> connection->functions[11].func)(statement -> driver_stmt);
    }
    if ( (((ret)&(~1))==0))
    {
        if ( statement -> prepared )
            statement -> state = 3;
        else
            statement -> state = 1;
    }
    if ( log_info.log_flag )
    {
        sprintf( statement -> msg,
                "\n\t\tExit:[%s]",
                    __get_return_status( ret, s1 ));
        dm_log_write( "SQLCloseCursor.c",
                231,
                0,
                0,
                statement -> msg );
    }
    return function_return_ex(3,statement,ret,0);
}

variable_types: struct statement { int type; struct statement *next_class_list; char msg[1024]; int state; struct connection { int type; struct connection *next_class_list; char msg[1024]; int state; struct environment { int type; struct environment *next_class_list; char msg[1024]; int state; long requested_version; int connection_count; int sql_driver_count; struct error_head { struct error_header { int error_count; struct error { unsigned short sqlstate[6]; unsigned short *msg; long native_error; int return_val; short diag_column_number_ret; short diag_row_number_ret; short diag_class_origin_ret; short diag_subclass_origin_ret; short diag_connection_name_ret; short diag_server_name_ret; long diag_column_number; long diag_row_number; unsigned short diag_class_origin[128]; unsigned short diag_subclass_origin[128]; unsigned short diag_connection_name[128]; unsigned short diag_server_name[128]; struct error *next; struct error *prev; } *error_list_head; struct error *error_list_tail; int internal_count; struct error *internal_list_head; struct error *internal_list_tail; } sql_error_head; struct error_header sql_diag_head; void *owning_handle; int handle_type; short return_code; long header_set; short diag_cursor_row_count_ret; short diag_dynamic_function_ret; short diag_dynamic_function_code_ret; short diag_number_ret; short diag_row_count_ret; long diag_cursor_row_count; unsigned short diag_dynamic_function[128]; long diag_dynamic_function_code; long diag_number; long diag_row_count; } error; long connection_pooling; long cp_match; int fetch_mode; int entry; void *sh; struct env_lib_struct { char *lib_name; void *env_handle; int count; struct env_lib_struct *next; } *env_lib_list; } *environment; void *dl_handle; char dl_name[256]; struct driver_func { int ordinal; char *name; void *dm_func; void *dm_funcW; short (*func)(); short (*funcW)(); short (*funcA)(); int can_supply; } *functions; struct driver_func ini_func; struct driver_func fini_func; int unicode_driver; void *driver_env; void *driver_dbc; int driver_version; int driver_act_ver; int statement_count; struct error_head error; char dsn[-1]; int access_mode; int access_mode_set; int login_timeout; int login_timeout_set; int auto_commit; int auto_commit_set; int async_enable; int async_enable_set; int auto_ipd; int auto_ipd_set; int connection_timeout; int connection_timeout_set; int metadata_id; int metadata_id_set; int packet_size; int packet_size_set; long quite_mode; int quite_mode_set; int txn_isolation; int txn_isolation_set; long cursors; void *cl_handle; int trace; char tracefile[-1]; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; int protection_level; int ex_fetch_mapping; int disable_gf; int dont_dlclose; int bookmarks_on; void *pooled_connection; int pooling_timeout; int ttl; char driver_connect_string[1024]; int dsn_length; char server[128]; int server_length; char user[128]; int user_length; char password[128]; int password_length; char cli_year[5]; struct attr_struct { int count; struct attr_set { char *keyword; char *value; int override; int attribute; int is_int_type; int int_value; struct attr_set *next; } *list; } env_attribute; struct attr_struct dbc_attribute; struct attr_struct stmt_attribute; struct save_attr { int attr_type; char *str_attr; int str_len; int int_attr; struct save_attr *next; } *save_attr; void *iconv_cd_uc_to_ascii; void *iconv_cd_ascii_to_uc; char unicode_string[64]; struct env_lib_struct *env_list_ent; char probe_sql[512]; int threading_level; int cbs_found; short ccb_value; short crb_value; } *connection; void *driver_stmt; short hascols; int prepared; int interupted_func; int interupted_state; int bookmarks_on; struct error_head error; long metadata_id; struct descriptor { int type; struct descriptor *next_class_list; char msg[1024]; int state; struct error_head error; void *driver_desc; struct connection *connection; int implicit; void *associated_with; union pthread_mutex_t mutex; } *ipd; struct descriptor *apd; struct descriptor *ird; struct descriptor *ard; struct descriptor *implicit_ipd; struct descriptor *implicit_apd; struct descriptor *implicit_ird; struct descriptor *implicit_ard; unsigned long *fetch_bm_ptr; unsigned long *row_ct_ptr; unsigned short *row_st_arr; unsigned long row_array_size; void *valueptr; union pthread_mutex_t mutex; int eod; } *

variable_types: ret short

return_type: short

user_defined_types: struct statement { int type; struct statement *next_class_list; char msg[1024]; int state; struct connection *connection; void *driver_stmt; short hascols; int prepared; int interupted_func; int interupted_state; int bookmarks_on; struct error_head error; long metadata_id; struct descriptor *ipd; struct descriptor *apd; struct descriptor *ird; struct descriptor *ard; struct descriptor *implicit_ipd; struct descriptor *implicit_apd; struct descriptor *implicit_ird; struct descriptor *implicit_ard; unsigned long *fetch_bm_ptr; unsigned long *row_ct_ptr; unsigned short *row_st_arr; unsigned long row_array_size; void *valueptr; union pthread_mutex_t mutex; int eod; }

user_defined_types: struct connection { int type; struct connection *next_class_list; char msg[1024]; int state; struct environment *environment; void *dl_handle; char dl_name[256]; struct driver_func *functions; struct driver_func ini_func; struct driver_func fini_func; int unicode_driver; void *driver_env; void *driver_dbc; int driver_version; int driver_act_ver; int statement_count; struct error_head error; char dsn[-1]; int access_mode; int access_mode_set; int login_timeout; int login_timeout_set; int auto_commit; int auto_commit_set; int async_enable; int async_enable_set; int auto_ipd; int auto_ipd_set; int connection_timeout; int connection_timeout_set; int metadata_id; int metadata_id_set; int packet_size; int packet_size_set; long quite_mode; int quite_mode_set; int txn_isolation; int txn_isolation_set; long cursors; void *cl_handle; int trace; char tracefile[-1]; union pthread_mutex_t mutex; int protection_level; int ex_fetch_mapping; int disable_gf; int dont_dlclose; int bookmarks_on; void *pooled_connection; int pooling_timeout; int ttl; char driver_connect_string[1024]; int dsn_length; char server[128]; int server_length; char user[128]; int user_length; char password[128]; int password_length; char cli_year[5]; struct attr_struct env_attribute; struct attr_struct dbc_attribute; struct attr_struct stmt_attribute; struct save_attr *save_attr; void *iconv_cd_uc_to_ascii; void *iconv_cd_ascii_to_uc; char unicode_string[64]; struct env_lib_struct *env_list_ent; char probe_sql[512]; int threading_level; int cbs_found; short ccb_value; short crb_value; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct attr_struct { int count; struct attr_set *list; }

user_defined_types: struct environment { int type; struct environment *next_class_list; char msg[1024]; int state; long requested_version; int connection_count; int sql_driver_count; struct error_head error; long connection_pooling; long cp_match; int fetch_mode; int entry; void *sh; struct env_lib_struct *env_lib_list; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct error_head { struct error_header sql_error_head; struct error_header sql_diag_head; void *owning_handle; int handle_type; short return_code; long header_set; short diag_cursor_row_count_ret; short diag_dynamic_function_ret; short diag_dynamic_function_code_ret; short diag_number_ret; short diag_row_count_ret; long diag_cursor_row_count; unsigned short diag_dynamic_function[128]; long diag_dynamic_function_code; long diag_number; long diag_row_count; }

user_defined_types: struct error_header { int error_count; struct error *error_list_head; struct error *error_list_tail; int internal_count; struct error *internal_list_head; struct error *internal_list_tail; }


SQLPostInstallerError

decompiled_code:
__int64 __fastcall SQLPostInstallerError(unsigned __int64 a1, __int64 a2)
{
if ( a1 > 0x16 )
return 0xFFFFFFFFLL;
inst_logPushMsg("SQLPostInstallerError.c", "SQLPostInstallerError.c", 28LL, 2LL, (unsigned int)a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1, __int64 a2)
{
if ( a1 > 0x16 )
return 0xFFFFFFFFLL;
inst_logPushMsg("SQLPostInstallerError.c", "SQLPostInstallerError.c", 28LL, 2LL, (unsigned int)a1, a2);
return 0LL;
}

original_code:
RETCODE SQLPostInstallerError( DWORD nErrorCode,
        LPCSTR szErrorMsg )
{
 if ( nErrorCode > 22 )
  return (-1);
    inst_logPushMsg( "SQLPostInstallerError.c", "SQLPostInstallerError.c", 28, 2, nErrorCode, (char *)szErrorMsg );
 return 0;
}

canonical_original_code:
short SQLPostInstallerError(unsigned long nErrorCode, char *szErrorMsg)
{
 if ( nErrorCode > 22 )
  return (-1);
    inst_logPushMsg( "SQLPostInstallerError.c", "SQLPostInstallerError.c", 28, 2, nErrorCode, (char *)szErrorMsg );
 return 0;
}

variable_types:
nErrorCode
unsigned long

variable_types:
szErrorMsg
char *


SQLPostInstallerErrorW

decompiled_code:
__int64 __fastcall SQLPostInstallerErrorW(unsigned __int64 a1, __int64 a2)
{
void *v2; // r12
unsigned int v3; // er13

if ( !a2 )
return SQLPostInstallerError(a1, 0LL);
v2 = (void *)single_string_alloc_and_copy(a2);
v3 = SQLPostInstallerError(a1, (__int64)v2);
if ( v2 )
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int64 a1, __int64 a2)
{
void *v2; // r12
unsigned int v3; // er13

if ( !a2 )
return func0(a1, 0LL);
v2 = (void *)single_string_alloc_and_copy(a2);
v3 = func0(a1, (__int64)v2);
if ( v2 )
free(v2);
return v3;
}

original_code:
SQLRETURN SQLPostInstallerErrorW(DWORD dwErrorCode,
                            LPCWSTR lpszErrorMsg)
{
 char *msg = lpszErrorMsg ? _single_string_alloc_and_copy( lpszErrorMsg ) : (char*)((void *)0);
 SQLRETURN ret;
 ret = SQLPostInstallerError( dwErrorCode, msg );
 if ( msg )
  free( msg );
 return ret;
}

canonical_original_code:
short SQLPostInstallerErrorW(unsigned long dwErrorCode, unsigned short *lpszErrorMsg)
{
 char *msg = lpszErrorMsg ? _single_string_alloc_and_copy( lpszErrorMsg ) : (char*)((void *)0);
 short ret;
 ret = SQLPostInstallerError( dwErrorCode, msg );
 if ( msg )
  free( msg );
 return ret;
}

variable_types:
dwErrorCode
unsigned long

variable_types:
lpszErrorMsg
unsigned short *

variable_types:
msg
char *


SQLPrimaryKeys

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

original_code:
RETCODE SQLPrimaryKeys(
                               HSTMT hstmt,
                               UCHAR * szTableQualifier,
                               SWORD cbTableQualifier,
                               UCHAR * szTableOwner,
                               SWORD cbTableOwner,
                               UCHAR * szTableName,
                               SWORD cbTableName)
{
    return PG_SQLPrimaryKeys( hstmt,
                            szTableQualifier,
                            cbTableQualifier,
                            szTableOwner,
                            cbTableOwner,
                            szTableName,
                            cbTableName );
}

canonical_original_code:
short SQLPrimaryKeys(void *hstmt, unsigned char *szTableQualifier, short cbTableQualifier, unsigned char *szTableOwner, short cbTableOwner, unsigned char *szTableName, short cbTableName)
{
    return PG_SQLPrimaryKeys( hstmt,
                            szTableQualifier,
                            cbTableQualifier,
                            szTableOwner,
                            cbTableOwner,
                            szTableName,
                            cbTableName );
}

variable_types:
hstmt
void *

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


SQLInstallerErrorW

decompiled_code:
__int64 __fastcall SQLInstallerErrorW(unsigned __int16 a1, _QWORD *a2, __int64 a3, unsigned __int16 a4, unsigned __int16 *a5)
{
unsigned __int16 v5; // r9
unsigned int v6; // er13
bool v9; // bl
void *v10; // r15
__int64 result; // rax
void *v12; // rax
unsigned int v13; // [rsp+Ch] [rbp-4Ch]
unsigned int v14; // [rsp+Ch] [rbp-4Ch]
unsigned __int16 v15; // [rsp+1Eh] [rbp-3Ah]

v5 = a1;
v6 = a4;
v9 = a3 != 0;
if ( a4 && a3 )
{
v12 = calloc(a4 + 1, 1uLL);
v5 = a1;
v10 = v12;
}
else
{
v10 = 0LL;
}
result = SQLInstallerError(v5, a2, v10, v6);
if ( (_WORD)result )
{
if ( (_WORD)result == 1 )
{
if ( a5 )
*a5 = v15;
if ( v10 && v9 )
{
v13 = result;
single_copy_to_wide(a3, v10, v6);
result = v13;
}
}
}
else
{
if ( a5 )
*a5 = v15;
if ( v10 )
{
if ( v9 )
{
v14 = result;
single_copy_to_wide(a3, v10, (unsigned int)v15 + 1);
result = v14;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int16 a1, _QWORD *a2, __int64 a3, unsigned __int16 a4, unsigned __int16 *a5)
{
unsigned __int16 v5; // r9
unsigned int v6; // er13
bool v9; // bl
void *v10; // r15
__int64 result; // rax
void *v12; // rax
unsigned int v13; // [rsp+Ch] [rbp-4Ch]
unsigned int v14; // [rsp+Ch] [rbp-4Ch]
unsigned __int16 v15; // [rsp+1Eh] [rbp-3Ah]

v5 = a1;
v6 = a4;
v9 = a3 != 0;
if ( a4 && a3 )
{
v12 = calloc(a4 + 1, 1uLL);
v5 = a1;
v10 = v12;
}
else
{
v10 = 0LL;
}
result = func0(v5, a2, v10, v6);
if ( (_WORD)result )
{
if ( (_WORD)result == 1 )
{
if ( a5 )
*a5 = v15;
if ( v10 && v9 )
{
v13 = result;
single_copy_to_wide(a3, v10, v6);
result = v13;
}
}
}
else
{
if ( a5 )
*a5 = v15;
if ( v10 )
{
if ( v9 )
{
v14 = result;
single_copy_to_wide(a3, v10, (unsigned int)v15 + 1);
result = v14;
}
}
}
return result;
}

original_code:
SQLRETURN SQLInstallerErrorW(WORD iError,
                            DWORD *pfErrorCode,
                            LPWSTR lpszErrorMsg,
                            WORD cbErrorMsgMax,
                            WORD *pcbErrorMsg)
{
 char *msg;
 SQLRETURN ret;
 WORD len;
 if ( lpszErrorMsg )
 {
  if ( cbErrorMsgMax > 0 )
  {
   msg = calloc( cbErrorMsgMax + 1, 1 );
  }
  else
  {
   msg = ((void *)0);
  }
 }
 else
 {
  msg = ((void *)0);
 }
 ret = SQLInstallerError( iError,
       pfErrorCode,
       msg,
       cbErrorMsgMax,
       &len );
 if ( ret == 0 )
 {
  if ( pcbErrorMsg )
   *pcbErrorMsg = len;
  if ( msg && lpszErrorMsg )
  {
   _single_copy_to_wide( lpszErrorMsg, msg, len + 1 );
  }
 }
 else if ( ret == 1 )
 {
  if ( pcbErrorMsg )
   *pcbErrorMsg = len;
  if ( msg && lpszErrorMsg )
  {
   _single_copy_to_wide( lpszErrorMsg, msg, cbErrorMsgMax );
  }
 }
 return ret;
}

canonical_original_code:
short SQLInstallerErrorW(unsigned short iError, unsigned long *pfErrorCode, unsigned short *lpszErrorMsg, unsigned short cbErrorMsgMax, unsigned short *pcbErrorMsg)
{
 char *msg;
 short ret;
 unsigned short len;
 if ( lpszErrorMsg )
 {
  if ( cbErrorMsgMax > 0 )
  {
   msg = calloc( cbErrorMsgMax + 1, 1 );
  }
  else
  {
   msg = ((void *)0);
  }
 }
 else
 {
  msg = ((void *)0);
 }
 ret = SQLInstallerError( iError,
       pfErrorCode,
       msg,
       cbErrorMsgMax,
       &len );
 if ( ret == 0 )
 {
  if ( pcbErrorMsg )
   *pcbErrorMsg = len;
  if ( msg && lpszErrorMsg )
  {
   _single_copy_to_wide( lpszErrorMsg, msg, len + 1 );
  }
 }
 else if ( ret == 1 )
 {
  if ( pcbErrorMsg )
   *pcbErrorMsg = len;
  if ( msg && lpszErrorMsg )
  {
   _single_copy_to_wide( lpszErrorMsg, msg, cbErrorMsgMax );
  }
 }
 return ret;
}

variable_types:
iError
unsigned short

variable_types:
pfErrorCode
unsigned long *

variable_types:
cbErrorMsgMax
unsigned short

variable_types:
pcbErrorMsg
unsigned short *

variable_types:
len
unsigned short


SQLConfigDataSourceW

decompiled_code:
__int64 __fastcall SQLConfigDataSourceW(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4)
{
char *v6; // r12
void *v7; // rbp

inst_logClear();
v6 = (char *)single_string_alloc_and_copy(a3);
v7 = (void *)multi_string_alloc_and_copy(a4);
LODWORD(a3) = SQLConfigDataSourceWide(a1, a2, v6, (__int64)v7, a3, a4);
free(v6);
free(v7);
return (unsigned int)a3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4)
{
char *v6; // r12
void *v7; // rbp

inst_logClear();
v6 = (char *)single_string_alloc_and_copy(a3);
v7 = (void *)multi_string_alloc_and_copy(a4);
LODWORD(a3) = func0(a1, a2, v6, (__int64)v7, a3, a4);
free(v6);
free(v7);
return (unsigned int)a3;
}

original_code:
int SQLConfigDataSourceW (HWND hwndParent,
                                      WORD fRequest,
                                      LPCWSTR lpszDriver,
                                      LPCWSTR lpszAttributes)
{
 char *drv, *attr;
 int ret;
    inst_logClear();
 drv = _single_string_alloc_and_copy( lpszDriver );
 attr = _multi_string_alloc_and_copy( lpszAttributes );
 ret = SQLConfigDataSourceWide( hwndParent, fRequest, drv, attr, lpszDriver, lpszAttributes );
 free( drv );
 free( attr );
 return ret;
}

canonical_original_code:
int SQLConfigDataSourceW(void *hwndParent, unsigned short fRequest, unsigned short *lpszDriver, unsigned short *lpszAttributes)
{
 char *drv; char *attr;
 int ret;
    inst_logClear();
 drv = _single_string_alloc_and_copy( lpszDriver );
 attr = _multi_string_alloc_and_copy( lpszAttributes );
 ret = SQLConfigDataSourceWide( hwndParent, fRequest, drv, attr, lpszDriver, lpszAttributes );
 free( drv );
 free( attr );
 return ret;
}

variable_types:
hwndParent
void *

variable_types:
fRequest
unsigned short

variable_types:
lpszDriver
unsigned short *

variable_types:
lpszAttributes
unsigned short *

variable_types:
drv
char *

variable_types:
attr
char *

variable_types: ret int


SQLConfigDataSource

decompiled_code:
__int64 __fastcall SQLConfigDataSource(__int64 a1, unsigned __int16 a2, const char *a3, __int64 a4)
{
void *v6; // r12
void *v7; // rbp

inst_logClear();
v6 = (void *)single_string_alloc_and_expand(a3);
v7 = (void *)multi_string_alloc_and_expand(a4);
LODWORD(a3) = SQLConfigDataSourceWide(a1, a2, a3, a4, (__int64)v6, (__int64)v7);
free(v6);
free(v7);
return (unsigned int)a3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned __int16 a2, const char *a3, __int64 a4)
{
void *v6; // r12
void *v7; // rbp

inst_logClear();
v6 = (void *)single_string_alloc_and_expand(a3);
v7 = (void *)multi_string_alloc_and_expand(a4);
LODWORD(a3) = func0(a1, a2, a3, a4, (__int64)v6, (__int64)v7);
free(v6);
free(v7);
return (unsigned int)a3;
}

original_code:
int SQLConfigDataSource (HWND hwndParent,
                                      WORD fRequest,
                                      LPCSTR lpszDriver,
                                      LPCSTR lpszAttributes)
{
 SQLWCHAR *drv, *attr;
 int ret;
    inst_logClear();
 drv = _single_string_alloc_and_expand( lpszDriver );
 attr = _multi_string_alloc_and_expand( lpszAttributes );
 ret = SQLConfigDataSourceWide( hwndParent, fRequest, lpszDriver, lpszAttributes, drv, attr );
 free( drv );
 free( attr );
 return ret;
}

canonical_original_code:
int SQLConfigDataSource(void *hwndParent, unsigned short fRequest, char *lpszDriver, char *lpszAttributes)
{
 unsigned short *drv; unsigned short *attr;
 int ret;
    inst_logClear();
 drv = _single_string_alloc_and_expand( lpszDriver );
 attr = _multi_string_alloc_and_expand( lpszAttributes );
 ret = SQLConfigDataSourceWide( hwndParent, fRequest, lpszDriver, lpszAttributes, drv, attr );
 free( drv );
 free( attr );
 return ret;
}

variable_types:
lpszDriver
char *

variable_types:
lpszAttributes
char *

variable_types:
drv
unsigned short *

variable_types:
attr
unsigned short *


SQLRemoveDefaultDataSource

decompiled_code:
__int64 SQLRemoveDefaultDataSource()
{
inst_logClear();
return SQLConfigDataSource(0LL, 7LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 func3()
{
inst_logClear();
return SQLConfigDataSource(0LL, 7LL, 0LL, 0LL);
}

original_code:
int SQLRemoveDefaultDataSource( void )
{
    inst_logClear();
 return SQLConfigDataSource (((void *)0), 7, ((void *)0), ((void *)0));
}

canonical_original_code:
int SQLRemoveDefaultDataSource()
{
    inst_logClear();
 return SQLConfigDataSource (((void *)0), 7, ((void *)0), ((void *)0));
}


SQLInstallDriverW

decompiled_code:
// attributes: thunk
__int64 SQLInstallDriverW()
{
return SQLInstallDriver_localalias();
}

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

original_code:
int SQLInstallDriverW (LPCWSTR lpszInfFile,
                                      LPCWSTR lpszDriver,
                                      LPWSTR lpszPath,
                                      WORD cbPathMax,
                                      WORD * pcbPathOut)
{
 return 0;
}

canonical_original_code:
int SQLInstallDriverW(unsigned short *lpszInfFile, unsigned short *lpszDriver, unsigned short *lpszPath, unsigned short cbPathMax, unsigned short *pcbPathOut)
{
 return 0;
}

variable_types:
lpszInfFile
unsigned short *

variable_types:
lpszPath
unsigned short *

variable_types:
cbPathMax
unsigned short

variable_types:
pcbPathOut
unsigned short *


SQLInstallODBCW

decompiled_code:
// attributes: thunk
__int64 SQLInstallODBCW()
{
return SQLInstallODBC_localalias();
}

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

original_code:
int SQLInstallODBCW (HWND hwndParent,
                                      LPCWSTR lpszInfFile,
           LPCWSTR lpszSrcPath,
           LPCWSTR lpszDrivers)
{
 return 0;
}

canonical_original_code:
int SQLInstallODBCW(void *hwndParent, unsigned short *lpszInfFile, unsigned short *lpszSrcPath, unsigned short *lpszDrivers)
{
 return 0;
}

variable_types:
lpszSrcPath
unsigned short *

variable_types:
lpszDrivers
unsigned short *


SQLInstallTranslatorW

decompiled_code:
// attributes: thunk
__int64 SQLInstallTranslatorW()
{
return SQLInstallTranslator_localalias();
}

canonical_decompiled_code:
__int64 func6()
{
return func2();
}

original_code:
int SQLInstallTranslatorW(LPCWSTR lpszInfFile,
                                  LPCWSTR lpszTranslator,
                                  LPCWSTR lpszPathIn,
                                  LPWSTR lpszPathOut,
                                  WORD cbPathOutMax,
                                  WORD *pcbPathOut,
                                  WORD fRequest,
                                  LPDWORD lpdwUsageCount)
{
    inst_logClear();
 return 0;
}

canonical_original_code:
int SQLInstallTranslatorW(unsigned short *lpszInfFile, unsigned short *lpszTranslator, unsigned short *lpszPathIn, unsigned short *lpszPathOut, unsigned short cbPathOutMax, unsigned short *pcbPathOut, unsigned short fRequest, unsigned long *lpdwUsageCount)
{
    inst_logClear();
 return 0;
}

variable_types:
lpszTranslator
unsigned short *

variable_types:
lpszPathIn
unsigned short *

variable_types:
lpszPathOut
unsigned short *

variable_types:
cbPathOutMax
unsigned short

variable_types:
lpdwUsageCount
unsigned long *


SQLWriteDSNToIniW

decompiled_code:
__int64 __fastcall SQLWriteDSNToIniW(__int64 a1, __int64 a2)
{
char *v2; // r12
_BYTE *v3; // rbp
unsigned int v4; // er13

v2 = (char *)((__int64 (*)(void))single_string_alloc_and_copy)();
v3 = (_BYTE *)single_string_alloc_and_copy(a2);
v4 = SQLWriteDSNToIni(v2, v3);
free(v2);
free(v3);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
char *v2; // r12
_BYTE *v3; // rbp
unsigned int v4; // er13

v2 = (char *)((__int64 (*)(void))single_string_alloc_and_copy)();
v3 = (_BYTE *)single_string_alloc_and_copy(a2);
v4 = func0(v2, v3);
free(v2);
free(v3);
return v4;
}

original_code:
int SQLWriteDSNToIniW (LPCWSTR lpszDSN,
                                      LPCWSTR lpszDriver)
{
 char *drv, *dsn;
 int ret;
 dsn = _single_string_alloc_and_copy( lpszDSN );
 drv = _single_string_alloc_and_copy( lpszDriver );
 ret = SQLWriteDSNToIni( dsn, drv );
 free( dsn );
 free( drv );
 return ret;
}

canonical_original_code:
int SQLWriteDSNToIniW(unsigned short *lpszDSN, unsigned short *lpszDriver)
{
 char *drv; char *dsn;
 int ret;
 dsn = _single_string_alloc_and_copy( lpszDSN );
 drv = _single_string_alloc_and_copy( lpszDriver );
 ret = SQLWriteDSNToIni( dsn, drv );
 free( dsn );
 free( drv );
 return ret;
}

variable_types:
lpszDSN
unsigned short *

variable_types:
lpszDriver
unsigned short *

variable_types:
drv
char *

variable_types:
dsn
char *