main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // rbp
char v6[536]; // [rsp+0h] [rbp-218h] BYREF

printf("HEX: ");
while ( fgets(v6, 513, stdin) )
{
v3 = strchr(v6, 10);
if ( v3 )
*v3 = 0;
if ( !v6[0] )
break;
v4 = (char *)hex2bin(v6);
printf("BIN: %s\n", v4);
free(v4);
printf("HEX: ");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // rbp
char v6[536]; // [rsp+0h] [rbp-218h] BYREF

printf("HEX: ");
while ( fgets(v6, 513, stdin) )
{
v3 = strchr(v6, 10);
if ( v3 )
*v3 = 0;
if ( !v6[0] )
break;
v4 = (char *)func7(v6);
printf("BIN: %s\n", v4);
free(v4);
printf("HEX: ");
}
return 0;
}

original_code:
int main(int argc, char *argv[]) {
 char input[512+1];
    printf("HEX: ");
    while(fgets(input, sizeof input, stdin)) {
        char *pos=input;
        if (((void *)0) != (pos = strchr(pos, '\n'))) *pos = '\0';
        if (strlen(input) == 0) break;
  char* ans = ((void *)0);
  ans = hex2bin(input);
  printf("BIN: %s\n", ans);
  free(ans);
        printf("HEX: ");
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 char input[-1];
    printf("HEX: ");
    while(fgets(input, sizeof input, stdin)) {
        char *pos = input;
        if (((void *)0) != (pos = strchr(pos, '\n'))) *pos = '\0';
        if (strlen(input) == 0) break;
  char *ans = ((void *)0);
  ans = hex2bin(input);
  printf("BIN: %s\n", ans);
  free(ans);
        printf("HEX: ");
 }
 return 0;
}

variable_types:
argv
char *[]

variable_types:
input
char [-1]

variable_types:
pos
char *

variable_types:
ans
char *


decompiled_code:
char *__fastcall hex2bin(const char *a1)
{
const char *v1; // rbx
int v2; // eax
char *v3; // rax
char *v4; // r12
char v5; // al

v1 = a1;
v2 = strlen(a1);
v3 = (char *)malloc(4 * v2);
*v3 = 0;
v4 = v3;
v5 = *a1;
if ( !*a1 )
return v4;
do
{
switch ( v5 )
{
case '0':
strcpy(&v4[strlen(v4)], "0000");
break;
case '1':
strcpy(&v4[strlen(v4)], "0001");
break;
case '2':
strcpy(&v4[strlen(v4)], "0010");
break;
case '3':
strcpy(&v4[strlen(v4)], "0011");
break;
case '4':
strcpy(&v4[strlen(v4)], "0100");
break;
case '5':
strcpy(&v4[strlen(v4)], "0101");
break;
case '6':
strcpy(&v4[strlen(v4)], "0110");
break;
case '7':
strcpy(&v4[strlen(v4)], "0111");
break;
case '8':
strcpy(&v4[strlen(v4)], "1000");
break;
case '9':
strcpy(&v4[strlen(v4)], "1001");
break;
case 'A':
case 'a':
strcpy(&v4[strlen(v4)], "1010");
break;
case 'B':
case 'b':
strcpy(&v4[strlen(v4)], "1011");
break;
case 'C':
case 'c':
strcpy(&v4[strlen(v4)], "1100");
break;
case 'D':
case 'd':
strcpy(&v4[strlen(v4)], "1101");
break;
case 'E':
case 'e':
strcpy(&v4[strlen(v4)], "1110");
break;
case 'F':
case 'f':
strcpy(&v4[strlen(v4)], "1111");
break;
default:
free(v4);
return 0LL;
}
v5 = *++v1;
}
while ( v5 );
return v4;
}

canonical_decompiled_code:
char *__fastcall func7(const char *a1)
{
const char *v1; // rbx
int v2; // eax
char *v3; // rax
char *v4; // r12
char v5; // al

v1 = a1;
v2 = strlen(a1);
v3 = (char *)malloc(4 * v2);
*v3 = 0;
v4 = v3;
v5 = *a1;
if ( !*a1 )
return v4;
do
{
switch ( v5 )
{
case '0':
strcpy(&v4[strlen(v4)], "0000");
break;
case '1':
strcpy(&v4[strlen(v4)], "0001");
break;
case '2':
strcpy(&v4[strlen(v4)], "0010");
break;
case '3':
strcpy(&v4[strlen(v4)], "0011");
break;
case '4':
strcpy(&v4[strlen(v4)], "0100");
break;
case '5':
strcpy(&v4[strlen(v4)], "0101");
break;
case '6':
strcpy(&v4[strlen(v4)], "0110");
break;
case '7':
strcpy(&v4[strlen(v4)], "0111");
break;
case '8':
strcpy(&v4[strlen(v4)], "1000");
break;
case '9':
strcpy(&v4[strlen(v4)], "1001");
break;
case 'A':
case 'a':
strcpy(&v4[strlen(v4)], "1010");
break;
case 'B':
case 'b':
strcpy(&v4[strlen(v4)], "1011");
break;
case 'C':
case 'c':
strcpy(&v4[strlen(v4)], "1100");
break;
case 'D':
case 'd':
strcpy(&v4[strlen(v4)], "1101");
break;
case 'E':
case 'e':
strcpy(&v4[strlen(v4)], "1110");
break;
case 'F':
case 'f':
strcpy(&v4[strlen(v4)], "1111");
break;
default:
free(v4);
return 0LL;
}
v5 = *++v1;
}
while ( v5 );
return v4;
}

original_code:
char* hex2bin(const char* hex)
{
 int len = strlen(hex);
 char* bin = malloc(4*len*sizeof(char));
 *bin = '\0';
 while(*hex) {
  switch(*hex) {
  case '0':
   strcat(bin, "0000");
   break;
  case '1':
   strcat(bin, "0001");
   break;
  case '2':
   strcat(bin, "0010");
   break;
  case '3':
   strcat(bin, "0011");
   break;
  case '4':
   strcat(bin, "0100");
   break;
  case '5':
   strcat(bin, "0101");
   break;
  case '6':
   strcat(bin, "0110");
   break;
  case '7':
   strcat(bin, "0111");
   break;
  case '8':
   strcat(bin, "1000");
   break;
  case '9':
   strcat(bin, "1001");
   break;
  case 'A': case 'a':
   strcat(bin, "1010");
   break;
  case 'B': case 'b':
   strcat(bin, "1011");
   break;
  case 'C': case 'c':
   strcat(bin, "1100");
   break;
  case 'D': case 'd':
   strcat(bin, "1101");
   break;
  case 'E': case 'e':
   strcat(bin, "1110");
   break;
  case 'F': case 'f':
   strcat(bin, "1111");
   break;
  default:
            free(bin);
            return ((void *)0);
  }
  ++hex;
 }
 return bin;
}

canonical_original_code:
char *hex2bin(char *hex)
{
 int len = strlen(hex);
 char *bin = malloc(4*len*sizeof(char));
 *bin = '\0';
 while(*hex) {
  switch(*hex) {
  case '0':
   strcat(bin, "0000");
   break;
  case '1':
   strcat(bin, "0001");
   break;
  case '2':
   strcat(bin, "0010");
   break;
  case '3':
   strcat(bin, "0011");
   break;
  case '4':
   strcat(bin, "0100");
   break;
  case '5':
   strcat(bin, "0101");
   break;
  case '6':
   strcat(bin, "0110");
   break;
  case '7':
   strcat(bin, "0111");
   break;
  case '8':
   strcat(bin, "1000");
   break;
  case '9':
   strcat(bin, "1001");
   break;
  case 'A': case 'a':
   strcat(bin, "1010");
   break;
  case 'B': case 'b':
   strcat(bin, "1011");
   break;
  case 'C': case 'c':
   strcat(bin, "1100");
   break;
  case 'D': case 'd':
   strcat(bin, "1101");
   break;
  case 'E': case 'e':
   strcat(bin, "1110");
   break;
  case 'F': case 'f':
   strcat(bin, "1111");
   break;
  default:
            free(bin);
            return ((void *)0);
  }
  ++hex;
 }
 return bin;
}

variable_types:
hex
char *

variable_types: len int

variable_types:
bin
char *

return_type: char *


repo: phyw/tzdata

decompiled_code:
__int64 __fastcall asctime_r(struct tm *tp, __int64 a2)
{
__int64 v3; // rax
char *v4; // r12
__int64 v5; // rax
char *v6; // r13
unsigned int v7; // er15
const char *v8; // rsi
size_t v9; // rax
__int64 result; // rax
unsigned int v11; // eax
int *v12; // rax
__m128i v13; // xmm0
unsigned int v14; // [rsp+4h] [rbp-A4h]
unsigned int v15; // [rsp+8h] [rbp-A0h]
unsigned int v16; // [rsp+Ch] [rbp-9Ch]
char s[13]; // [rsp+13h] [rbp-95h] BYREF
char v18[8]; // [rsp+20h] [rbp-88h] BYREF

if ( !tp )
{
v12 = _errno_location();
v13 = _mm_load_si128((const __m128i *)&LC4);
*v12 = 22;
strcpy((char *)(a2 + 16), ":?? ????\n");
result = a2;
*(__m128i *)a2 = v13;
return result;
}
v3 = tp->tm_wday;
v4 = (char *)&unk_268;
if ( (unsigned int)v3 <= 6 )
{
v4 = (char *)&wday_name_1 + 3 * v3;
v5 = tp->tm_mon;
v6 = (char *)&unk_268;
if ( (unsigned int)v5 > 0xB )
goto LABEL_4;
goto LABEL_12;
}
v5 = tp->tm_mon;
v6 = (char *)&unk_268;
if ( (unsigned int)v5 <= 0xB )
LABEL_12:
v6 = &mon_name_0[3 * v5];
LABEL_4:
strftime(s, 0xDuLL, "%Y", tp);
v7 = tp->tm_mday;
v16 = tp->tm_sec;
v15 = tp->tm_min;
v14 = tp->tm_hour;
v8 = "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n";
if ( strlen(s) > 4 )
v8 = "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n";
sprintf(v18, v8, v4, v6, v7, v14, v15, v16, s);
v9 = strlen(v18);
if ( v9 <= 0x19 || (_UNKNOWN *)a2 == &buf_asctime )
{
v11 = v9 + 1;
if ( v11 < 8 )
{
if ( (v11 & 4) != 0 )
{
*(_DWORD *)a2 = *(_DWORD *)v18;
*(_DWORD *)(a2 + v11 - 4) = *(_DWORD *)&v18[v11 - 4];
}
else if ( v11 )
{
*(_BYTE *)a2 = v18[0];
if ( (v11 & 2) != 0 )
*(_WORD *)(a2 + v11 - 2) = *(_WORD *)&v18[v11 - 2];
}
}
else
{
*(_QWORD *)a2 = *(_QWORD *)v18;
*(_QWORD *)(a2 + v11 - 8) = *(_QWORD *)&v18[v11 - 8];
qmemcpy(
(void *)((a2 + 8) & 0xFFFFFFFFFFFFFFF8LL),
&v18[-(a2 - ((a2 + 8) & 0xFFFFFFFFFFFFFFF8LL))],
8LL * (((_DWORD)a2 - (((_DWORD)a2 + 8) & 0xFFFFFFF8) + v11) >> 3));
}
result = a2;
}
else
{
*_errno_location() = 75;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(struct tm *tp, __int64 a2)
{
__int64 v3; // rax
char *v4; // r12
__int64 v5; // rax
char *v6; // r13
unsigned int v7; // er15
const char *v8; // rsi
size_t v9; // rax
__int64 result; // rax
unsigned int v11; // eax
int *v12; // rax
__m128i v13; // xmm0
unsigned int v14; // [rsp+4h] [rbp-A4h]
unsigned int v15; // [rsp+8h] [rbp-A0h]
unsigned int v16; // [rsp+Ch] [rbp-9Ch]
char s[13]; // [rsp+13h] [rbp-95h] BYREF
char v18[8]; // [rsp+20h] [rbp-88h] BYREF

if ( !tp )
{
v12 = _errno_location();
v13 = _mm_load_si128((const __m128i *)&LC4);
*v12 = 22;
strcpy((char *)(a2 + 16), ":?? ????\n");
result = a2;
*(__m128i *)a2 = v13;
return result;
}
v3 = tp->tm_wday;
v4 = (char *)&unk_268;
if ( (unsigned int)v3 <= 6 )
{
v4 = (char *)&wday_name_1 + 3 * v3;
v5 = tp->tm_mon;
v6 = (char *)&unk_268;
if ( (unsigned int)v5 > 0xB )
goto LABEL_4;
goto LABEL_12;
}
v5 = tp->tm_mon;
v6 = (char *)&unk_268;
if ( (unsigned int)v5 <= 0xB )
LABEL_12:
v6 = &mon_name_0[3 * v5];
LABEL_4:
strftime(s, 0xDuLL, "%Y", tp);
v7 = tp->tm_mday;
v16 = tp->tm_sec;
v15 = tp->tm_min;
v14 = tp->tm_hour;
v8 = "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n";
if ( strlen(s) > 4 )
v8 = "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n";
sprintf(v18, v8, v4, v6, v7, v14, v15, v16, s);
v9 = strlen(v18);
if ( v9 <= 0x19 || (_UNKNOWN *)a2 == &buf_asctime )
{
v11 = v9 + 1;
if ( v11 < 8 )
{
if ( (v11 & 4) != 0 )
{
*(_DWORD *)a2 = *(_DWORD *)v18;
*(_DWORD *)(a2 + v11 - 4) = *(_DWORD *)&v18[v11 - 4];
}
else if ( v11 )
{
*(_BYTE *)a2 = v18[0];
if ( (v11 & 2) != 0 )
*(_WORD *)(a2 + v11 - 2) = *(_WORD *)&v18[v11 - 2];
}
}
else
{
*(_QWORD *)a2 = *(_QWORD *)v18;
*(_QWORD *)(a2 + v11 - 8) = *(_QWORD *)&v18[v11 - 8];
qmemcpy(
(void *)((a2 + 8) & 0xFFFFFFFFFFFFFFF8LL),
&v18[-(a2 - ((a2 + 8) & 0xFFFFFFFFFFFFFFF8LL))],
8LL * (((_DWORD)a2 - (((_DWORD)a2 + 8) & 0xFFFFFFF8) + v11) >> 3));
}
result = a2;
}
else
{
*_errno_location() = 75;
result = 0LL;
}
return result;
}

original_code:
char *
asctime_r(register const struct tm *timeptr, char *buf)
{
 static const char wday_name[][3] = {
  "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 };
 static const char mon_name[][3] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 };
 register const char * wn;
 register const char * mn;
 char year[(((sizeof (int) * 8) - (((int) -1) < 0)) * 302 / 1000 + 1 + (((int) -1) < 0)) + 2];
 char result[(2*3+5*(((sizeof (int) * 8) - (((int) -1) < 0)) * 302 / 1000 + 1 + (((int) -1) < 0))+7+2+1+1)];
 if (timeptr == ((void *)0)) {
  (*__errno_location ()) = 22;
  return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
 }
 if (timeptr->tm_wday < 0 || timeptr->tm_wday >= 7)
  wn = "???";
 else wn = wday_name[timeptr->tm_wday];
 if (timeptr->tm_mon < 0 || timeptr->tm_mon >= 12)
  mn = "???";
 else mn = mon_name[timeptr->tm_mon];
 (void) strftime(year, sizeof year, "%Y", timeptr);
 (void) sprintf(result,
  ((strlen(year) <= 4) ? "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" : "%.3s %.3s%3d %2.2d:%2.2d:%2.2d     %s\n"),
  wn, mn,
  timeptr->tm_mday, timeptr->tm_hour,
  timeptr->tm_min, timeptr->tm_sec,
  year);
 if (strlen(result) < 26 || buf == buf_asctime)
  return strcpy(buf, result);
 else {
  (*__errno_location ()) = 75;
  return ((void *)0);
 }
}

canonical_original_code:
char *asctime_r(struct tm *timeptr, char *buf)
{
 static char wday_name[][3] = {
  "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 };
 static char mon_name[][3] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
 };
 register char *wn;
 register char *mn;
 char year[-1];
 char result[-1];
 if (timeptr == ((void *)0)) {
  (*__errno_location ()) = 22;
  return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
 }
 if (timeptr->tm_wday < 0 || timeptr->tm_wday >= 7)
  wn = "???";
 else wn = wday_name[timeptr->tm_wday];
 if (timeptr->tm_mon < 0 || timeptr->tm_mon >= 12)
  mn = "???";
 else mn = mon_name[timeptr->tm_mon];
 (void) strftime(year, sizeof year, "%Y", timeptr);
 (void) sprintf(result,
  ((strlen(year) <= 4) ? "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n" : "%.3s %.3s%3d %2.2d:%2.2d:%2.2d     %s\n"),
  wn, mn,
  timeptr->tm_mday, timeptr->tm_hour,
  timeptr->tm_min, timeptr->tm_sec,
  year);
 if (strlen(result) < 26 || buf == buf_asctime)
  return strcpy(buf, result);
 else {
  (*__errno_location ()) = 75;
  return ((void *)0);
 }
}

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types:
buf
char *

variable_types:
wn
char *

variable_types:
mn
char *

variable_types:
year
char [-1]

variable_types:
result
char [-1]


asctime

decompiled_code:
__int64 __fastcall asctime(struct tm *a1)
{
return asctime_r(a1, (__int64)&buf_asctime);
}

canonical_decompiled_code:
__int64 __fastcall func1(struct tm *a1)
{
return func0(a1, (__int64)&buf_asctime);
}

original_code:
char *
asctime(register const struct tm *timeptr)
{
 return asctime_r(timeptr, buf_asctime);
}

canonical_original_code:
char *asctime(struct tm *timeptr)
{
 return asctime_r(timeptr, buf_asctime);
}

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


icatalloc

decompiled_code:
char *__fastcall icatalloc(void *ptr, char *src)
{
int v3; // eax
int v4; // er12
int v5; // esi
int v6; // ebx
char *v7; // rax
char *v8; // r12

if ( !src )
{
if ( !ptr )
return (char *)malloc(1uLL);
return (char *)ptr;
}
v3 = strlen(src);
v4 = v3;
v5 = v3;
if ( !ptr )
{
v6 = 0;
goto LABEL_5;
}
if ( !v3 )
return (char *)ptr;
v6 = strlen((const char *)ptr);
v5 = v4 + v6;
LABEL_5:
v7 = (char *)realloc(ptr, v5 + 1);
v8 = v7;
if ( v7 )
strcpy(&v7[v6], src);
return v8;
}

canonical_decompiled_code:
char *__fastcall func0(void *ptr, char *src)
{
int v3; // eax
int v4; // er12
int v5; // esi
int v6; // ebx
char *v7; // rax
char *v8; // r12

if ( !src )
{
if ( !ptr )
return (char *)malloc(1uLL);
return (char *)ptr;
}
v3 = strlen(src);
v4 = v3;
v5 = v3;
if ( !ptr )
{
v6 = 0;
goto LABEL_5;
}
if ( !v3 )
return (char *)ptr;
v6 = strlen((const char *)ptr);
v5 = v4 + v6;
LABEL_5:
v7 = (char *)realloc(ptr, v5 + 1);
v8 = v7;
if ( v7 )
strcpy(&v7[v6], src);
return v8;
}

original_code:
char *
icatalloc(char *const old, const char *const new)
{
 register char * result;
 register int oldsize, newsize;
 newsize = (new == ((void *)0)) ? 0 : strlen(new);
 if (old == ((void *)0))
  oldsize = 0;
 else if (newsize == 0)
  return old;
 else oldsize = strlen(old);
 if ((result = realloc(old, oldsize + newsize + 1)) != ((void *)0))
  if (new != ((void *)0))
   (void) strcpy(result + oldsize, new);
 return result;
}

canonical_original_code:
char *icatalloc(char *old, char *new)
{
 register char *result;
 register int oldsize; register int newsize;
 newsize = (new == ((void *)0)) ? 0 : strlen(new);
 if (old == ((void *)0))
  oldsize = 0;
 else if (newsize == 0)
  return old;
 else oldsize = strlen(old);
 if ((result = realloc(old, oldsize + newsize + 1)) != ((void *)0))
  if (new != ((void *)0))
   (void) strcpy(result + oldsize, new);
 return result;
}

variable_types:
old
char *

variable_types:
new
char *

variable_types:
result
char *

variable_types: oldsize int

variable_types: newsize int


icpyalloc

decompiled_code:
char *__fastcall icpyalloc(char *src)
{
return icatalloc(0LL, src);
}

canonical_decompiled_code:
char *__fastcall func1(char *src)
{
return func0(0LL, src);
}

original_code:
char *
icpyalloc(const char *const string)
{
 return icatalloc(((void *)0), string);
}

canonical_original_code:
char *icpyalloc(char *string)
{
 return icatalloc(((void *)0), string);
}

variable_types:
string
char *


scheck

original_code:
const char *
scheck(const char *const string, const char *const format)
{
 register char * fbuf;
 register const char * fp;
 register char * tp;
 register int c;
 register const char * result;
 char dummy;
 result = "";
 if (string == ((void *)0) || format == ((void *)0))
  return result;
 fbuf = malloc(2 * strlen(format) + 4);
 if (fbuf == ((void *)0))
  return result;
 fp = format;
 tp = fbuf;
 while ((*tp++ = c = *fp++) != '\0') {
  if (c != '%')
   continue;
  if (*fp == '%') {
   *tp++ = *fp++;
   continue;
  }
  *tp++ = '*';
  if (*fp == '*')
   ++fp;
  while (((unsigned)(*fp) - '0' <= 9))
   *tp++ = *fp++;
  if (*fp == 'l' || *fp == 'h')
   *tp++ = *fp++;
  else if (*fp == '[')
   do *tp++ = *fp++;
    while (*fp != '\0' && *fp != ']');
  if ((*tp++ = *fp++) == '\0')
   break;
 }
 *(tp - 1) = '%';
 *tp++ = 'c';
 *tp = '\0';
 if (sscanf(string, fbuf, &dummy) != 1)
  result = format;
 free(fbuf);
 return result;
}

canonical_original_code:
char *scheck(char *string, char *format)
{
 register char *fbuf;
 register char *fp;
 register char *tp;
 register int c;
 register char *result;
 char dummy;
 result = "";
 if (string == ((void *)0) || format == ((void *)0))
  return result;
 fbuf = malloc(2 * strlen(format) + 4);
 if (fbuf == ((void *)0))
  return result;
 fp = format;
 tp = fbuf;
 while ((*tp++ = c = *fp++) != '\0') {
  if (c != '%')
   continue;
  if (*fp == '%') {
   *tp++ = *fp++;
   continue;
  }
  *tp++ = '*';
  if (*fp == '*')
   ++fp;
  while (((unsigned int)(*fp) - '0' <= 9))
   *tp++ = *fp++;
  if (*fp == 'l' || *fp == 'h')
   *tp++ = *fp++;
  else if (*fp == '[')
   do *tp++ = *fp++;
    while (*fp != '\0' && *fp != ']');
  if ((*tp++ = *fp++) == '\0')
   break;
 }
 *(tp - 1) = '%';
 *tp++ = 'c';
 *tp = '\0';
 if (sscanf(string, fbuf, &dummy) != 1)
  result = format;
 free(fbuf);
 return result;
}

variable_types:
format
char *

variable_types:
fbuf
char *

variable_types:
fp
char *

variable_types:
tp
char *

variable_types: c int

variable_types: dummy char


difftime

decompiled_code:
double __fastcall difftime(__int64 a1, __int64 a2)
{
double result; // xmm0_8
__int64 v3; // rsi
double v4; // xmm0_8
__int64 v5; // rdi

if ( a1 >= 0 != a2 < 0 )
return (double)((int)a1 - (int)a2);
if ( a1 >= 0 )
{
v5 = a1 - a2;
if ( v5 < 0 )
result = (double)(int)(v5 & 1 | ((unsigned __int64)v5 >> 1)) + (double)(int)(v5 & 1 | ((unsigned __int64)v5 >> 1));
else
result = (double)(int)v5;
}
else
{
v3 = a2 - a1;
if ( v3 < 0 )
v4 = (double)(int)(v3 & 1 | ((unsigned __int64)v3 >> 1)) + (double)(int)(v3 & 1 | ((unsigned __int64)v3 >> 1));
else
v4 = (double)(int)v3;
*(_QWORD *)&result = *(_QWORD *)&v4 ^ LC0;
}
return result;
}

canonical_decompiled_code:
double __fastcall func0(__int64 a1, __int64 a2)
{
double result; // xmm0_8
__int64 v3; // rsi
double v4; // xmm0_8
__int64 v5; // rdi

if ( a1 >= 0 != a2 < 0 )
return (double)((int)a1 - (int)a2);
if ( a1 >= 0 )
{
v5 = a1 - a2;
if ( v5 < 0 )
result = (double)(int)(v5 & 1 | ((unsigned __int64)v5 >> 1)) + (double)(int)(v5 & 1 | ((unsigned __int64)v5 >> 1));
else
result = (double)(int)v5;
}
else
{
v3 = a2 - a1;
if ( v3 < 0 )
v4 = (double)(int)(v3 & 1 | ((unsigned __int64)v3 >> 1)) + (double)(int)(v3 & 1 | ((unsigned __int64)v3 >> 1));
else
v4 = (double)(int)v3;
*(_QWORD *)&result = *(_QWORD *)&v4 ^ LC0;
}
return result;
}

original_code:
double
difftime(const time_t time1, const time_t time0)
{
 if (sizeof (double) > sizeof (time_t))
  return (double) time1 - (double) time0;
 if (!(((time_t) 0.5) != 0.5)) {
  return time1 - time0;
 }
 if (!(((time_t) -1) < 0)) {
  if (time1 >= time0)
   return time1 - time0;
  else return -((double) (time0 - time1));
 }
 if ((time1 < 0) == (time0 < 0))
  return time1 - time0;
 if (sizeof (unsigned long) < sizeof (time_t))
  return (double) time1 - (double) time0;
 if (time1 >= 0 )
  return (unsigned long) time1 +
   (unsigned long) (-(time0 + 1)) + 1;
 return -(double) ((unsigned long) time0 +
  (unsigned long) (-(time1 + 1)) + 1);
}

canonical_original_code:
double difftime(long time1, long time0)
{
 if (sizeof (double) > sizeof (time_t))
  return (double) time1 - (double) time0;
 if (!(((long) 0.5) != 0.5)) {
  return time1 - time0;
 }
 if (!(((time_t) -1) < 0)) {
  if (time1 >= time0)
   return time1 - time0;
  else return -((double) (time0 - time1));
 }
 if ((time1 < 0) == (time0 < 0))
  return time1 - time0;
 if (sizeof (unsigned long) < sizeof (time_t))
  return (double) time1 - (double) time0;
 if (time1 >= 0 )
  return (unsigned long) time1 +
   (unsigned long) (-(time0 + 1)) + 1;
 return -(double) ((unsigned long) time0 +
  (unsigned long) (-(time1 + 1)) + 1);
}

return_type: double


main

canonical_name: main

repo: picosync/workingDraft

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
return 0;
}

original_code: int main() {}

canonical_original_code: int main() {}

return_type: int


cyoBaseXXValidate

decompiled_code:
__int64 __fastcall cyoBaseXXValidate(unsigned __int8 *a1, unsigned __int64 a2, unsigned __int64 a3, unsigned __int64 a4, unsigned __int8 a5, __int64 a6)
{
__int64 v6; // rax
char v7; // r8

if ( !a1 || a2 % a3 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0LL;
while ( 1 )
{
v6 = *a1;
if ( (v6 & 0x80u) != 0LL || *(_BYTE *)(a6 + (unsigned __int8)v6) > a5 )
break;
++a1;
if ( !--a2 )
return 0LL;
}
if ( a4 >= a2 )
{
v7 = a5 + 1;
while ( (v6 & 0x80u) == 0LL && *(_BYTE *)(a6 + v6) == v7 )
{
++a1;
if ( !--a2 || a4 < a2 )
return a2 != 0 ? 0xFFFFFFFE : 0;
v6 = *a1;
}
}
return 4294967294LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, unsigned __int64 a2, unsigned __int64 a3, unsigned __int64 a4, unsigned __int8 a5, __int64 a6)
{
__int64 v6; // rax
char v7; // r8

if ( !a1 || a2 % a3 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0LL;
while ( 1 )
{
v6 = *a1;
if ( (v6 & 0x80u) != 0LL || *(_BYTE *)(a6 + (unsigned __int8)v6) > a5 )
break;
++a1;
if ( !--a2 )
return 0LL;
}
if ( a4 >= a2 )
{
v7 = a5 + 1;
while ( (v6 & 0x80u) == 0LL && *(_BYTE *)(a6 + v6) == v7 )
{
++a1;
if ( !--a2 || a4 < a2 )
return a2 != 0 ? 0xFFFFFFFE : 0;
v6 = *a1;
}
}
return 4294967294LL;
}

original_code:
static int cyoBaseXXValidate( const char* src, size_t size, size_t inputBytes, size_t maxPadding,
                              unsigned char maxValue, const unsigned char table[] )
{
    if (!src)
        return -1;
    if (size % inputBytes != 0)
        return -1;
    for (; size >= 1; --size, ++src)
    {
        unsigned char ch = *src;
        if ((ch >= 0x80) || (table[ ch ] > maxValue))
            break;
    }
    for (; 1 <= size && size <= maxPadding; --size, ++src)
    {
        unsigned char ch = *src;
        if ((ch >= 0x80) || (table[ ch ] != maxValue + 1))
            break;
    }
    if (size != 0)
        return -2;
    return 0;
}

canonical_original_code:
static int cyoBaseXXValidate(char *src, unsigned long size, unsigned long inputBytes, unsigned long maxPadding, unsigned char maxValue, unsigned char table[])
{
    if (!src)
        return -1;
    if (size % inputBytes != 0)
        return -1;
    for (; size >= 1; --size, ++src)
    {
        unsigned char ch = *src;
        if ((ch >= 0x80) || (table[ ch ] > maxValue))
            break;
    }
    for (; 1 <= size && size <= maxPadding; --size, ++src)
    {
        unsigned char ch = *src;
        if ((ch >= 0x80) || (table[ ch ] != maxValue + 1))
            break;
    }
    if (size != 0)
        return -2;
    return 0;
}

variable_types:
src
char *

variable_types:
size
unsigned long

variable_types:
inputBytes
unsigned long

variable_types:
maxPadding
unsigned long

variable_types:
maxValue
unsigned char

variable_types:
table
unsigned char []

variable_types:
ch
unsigned char


cyoBaseXXDecodeGetLength

decompiled_code:
unsigned __int64 __fastcall cyoBaseXXDecodeGetLength(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
unsigned __int64 result; // rax

result = 0LL;
if ( !(a1 % a2) )
result = a3 * ((a1 + a2 - 1) / a2) + 1;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
unsigned __int64 result; // rax

result = 0LL;
if ( !(a1 % a2) )
result = a3 * ((a1 + a2 - 1) / a2) + 1;
return result;
}

original_code:
static size_t cyoBaseXXDecodeGetLength( size_t size, size_t inputBytes, size_t outputBytes )
{
    if (size % inputBytes != 0)
        return 0;
    return (((size + inputBytes - 1) / inputBytes) * outputBytes) + 1;
}

canonical_original_code:
static unsigned long cyoBaseXXDecodeGetLength(unsigned long size, unsigned long inputBytes, unsigned long outputBytes)
{
    if (size % inputBytes != 0)
        return 0;
    return (((size + inputBytes - 1) / inputBytes) * outputBytes) + 1;
}

variable_types:
outputBytes
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall cyoBase16Validate(unsigned __int8 *a1, unsigned __int64 a2)
{
return cyoBaseXXValidate(a1, a2, 2uLL, 0LL, 0xFu, (__int64)&BASE16_TABLE);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 *a1, unsigned __int64 a2)
{
return func0(a1, a2, 2uLL, 0LL, 0xFu, (__int64)&BASE16_TABLE);
}

original_code:
int cyoBase16Validate( const char* src, size_t size )
{
    return cyoBaseXXValidate( src, size, BASE16_INPUT, BASE16_MAX_PADDING, BASE16_MAX_VALUE, BASE16_TABLE );
}

canonical_original_code:
int cyoBase16Validate(char *src, unsigned long size)
{
    return cyoBaseXXValidate( src, size, BASE16_INPUT, BASE16_MAX_PADDING, BASE16_MAX_VALUE, BASE16_TABLE );
}


decompiled_code:
unsigned __int64 __fastcall cyoBase16DecodeGetLength(unsigned __int64 a1)
{
return cyoBaseXXDecodeGetLength(a1, 2uLL, 1LL);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(unsigned __int64 a1)
{
return func1(a1, 2uLL, 1LL);
}

original_code:
size_t cyoBase16DecodeGetLength( size_t size )
{
    return cyoBaseXXDecodeGetLength( size, BASE16_INPUT, BASE16_OUTPUT );
}

canonical_original_code:
unsigned long cyoBase16DecodeGetLength(unsigned long size)
{
    return cyoBaseXXDecodeGetLength( size, BASE16_INPUT, BASE16_OUTPUT );
}


decompiled_code:
__int64 __fastcall cyoBase16Decode(_BYTE *a1, __int64 a2, __int64 a3)
{
__int64 v3; // rcx
__int64 v4; // r8
__int64 v6; // rax
__int64 v7; // rdx
char v8; // al
char v9; // dl

v3 = a3;
if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v4 = a3 & 1;
if ( (a3 & 1) != 0 )
return 0LL;
while ( v3 )
{
v6 = *(unsigned __int8 *)(a2 + 2 * v4);
v7 = *(unsigned __int8 *)(a2 + 2 * v4 + 1);
v3 -= 2LL;
if ( (v6 & 0x80u) != 0LL )
return 0LL;
if ( (v7 & 0x80u) != 0LL )
return 0LL;
v8 = BASE16_TABLE[v6];
v9 = BASE16_TABLE[v7];
if ( (unsigned __int8)v8 > 0xFu || (unsigned __int8)v9 > 0xFu )
return 0LL;
++a1;
++v4;
*(a1 - 1) = v9 | (16 * v8);
}
*a1 = 0;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func4(_BYTE *a1, __int64 a2, __int64 a3)
{
__int64 v3; // rcx
__int64 v4; // r8
__int64 v6; // rax
__int64 v7; // rdx
char v8; // al
char v9; // dl

v3 = a3;
if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v4 = a3 & 1;
if ( (a3 & 1) != 0 )
return 0LL;
while ( v3 )
{
v6 = *(unsigned __int8 *)(a2 + 2 * v4);
v7 = *(unsigned __int8 *)(a2 + 2 * v4 + 1);
v3 -= 2LL;
if ( (v6 & 0x80u) != 0LL )
return 0LL;
if ( (v7 & 0x80u) != 0LL )
return 0LL;
v8 = BASE16_TABLE[v6];
v9 = BASE16_TABLE[v7];
if ( (unsigned __int8)v8 > 0xFu || (unsigned __int8)v9 > 0xFu )
return 0LL;
++a1;
++v4;
*(a1 - 1) = v9 | (16 * v8);
}
*a1 = 0;
return v4;
}

original_code:
size_t cyoBase16Decode( void* dest, const char* src, size_t size )
{
    if (dest && src && (size % BASE16_INPUT == 0))
    {
        unsigned char* pDest = (unsigned char*)dest;
        size_t dwSrcSize = size;
        size_t dwDestSize = 0;
        unsigned char in1, in2;
        while (dwSrcSize >= 1)
        {
            in1 = *src++;
            in2 = *src++;
            dwSrcSize -= BASE16_INPUT;
            if (in1 >= 0x80 || in2 >= 0x80)
                return 0;
            in1 = BASE16_TABLE[ in1 ];
            in2 = BASE16_TABLE[ in2 ];
            if (in1 > BASE16_MAX_VALUE || in2 > BASE16_MAX_VALUE)
                return 0;
            *pDest++ = ((in1 << 4) | in2);
            dwDestSize += BASE16_OUTPUT;
        }
        *pDest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

canonical_original_code:
unsigned long cyoBase16Decode(void *dest, char *src, unsigned long size)
{
    if (dest && src && (size % BASE16_INPUT == 0))
    {
        unsigned char *pDest = (unsigned char*)dest;
        unsigned long dwSrcSize = size;
        unsigned long dwDestSize = 0;
        unsigned char in1; unsigned char in2;
        while (dwSrcSize >= 1)
        {
            in1 = *src++;
            in2 = *src++;
            dwSrcSize -= BASE16_INPUT;
            if (in1 >= 0x80 || in2 >= 0x80)
                return 0;
            in1 = BASE16_TABLE[ in1 ];
            in2 = BASE16_TABLE[ in2 ];
            if (in1 > BASE16_MAX_VALUE || in2 > BASE16_MAX_VALUE)
                return 0;
            *pDest++ = ((in1 << 4) | in2);
            dwDestSize += BASE16_OUTPUT;
        }
        *pDest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

variable_types:
dest
void *

variable_types:
pDest
unsigned char *

variable_types:
dwSrcSize
unsigned long

variable_types:
dwDestSize
unsigned long


decompiled_code:
__int64 __fastcall cyoBase32Validate(unsigned __int8 *a1, unsigned __int64 a2)
{
return cyoBaseXXValidate(a1, a2, 8uLL, 6uLL, 0x1Fu, (__int64)&BASE32_TABLE);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int8 *a1, unsigned __int64 a2)
{
return func0(a1, a2, 8uLL, 6uLL, 0x1Fu, (__int64)&BASE32_TABLE);
}

original_code:
int cyoBase32Validate( const char* src, size_t size )
{
    return cyoBaseXXValidate( src, size, BASE32_INPUT, BASE32_MAX_PADDING, BASE32_MAX_VALUE, BASE32_TABLE );
}

canonical_original_code:
int cyoBase32Validate(char *src, unsigned long size)
{
    return cyoBaseXXValidate( src, size, BASE32_INPUT, BASE32_MAX_PADDING, BASE32_MAX_VALUE, BASE32_TABLE );
}


decompiled_code:
unsigned __int64 __fastcall cyoBase32DecodeGetLength(unsigned __int64 a1)
{
return cyoBaseXXDecodeGetLength(a1, 8uLL, 5LL);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(unsigned __int64 a1)
{
return func1(a1, 8uLL, 5LL);
}

original_code:
size_t cyoBase32DecodeGetLength( size_t size )
{
    return cyoBaseXXDecodeGetLength( size, BASE32_INPUT, BASE32_OUTPUT );
}

canonical_original_code:
unsigned long cyoBase32DecodeGetLength(unsigned long size)
{
    return cyoBaseXXDecodeGetLength( size, BASE32_INPUT, BASE32_OUTPUT );
}


original_code:
size_t cyoBase32Decode( void* dest, const char* src, size_t size )
{
    if (dest && src && (size % BASE32_INPUT == 0))
    {
        unsigned char* pDest = (unsigned char*)dest;
        size_t dwSrcSize = size;
        size_t dwDestSize = 0;
        unsigned char in1, in2, in3, in4, in5, in6, in7, in8;
        while (dwSrcSize >= 1)
        {
            in1 = *src++;
            in2 = *src++;
            in3 = *src++;
            in4 = *src++;
            in5 = *src++;
            in6 = *src++;
            in7 = *src++;
            in8 = *src++;
            dwSrcSize -= BASE32_INPUT;
            if ( in1 >= 0x80 || in2 >= 0x80 || in3 >= 0x80 || in4 >= 0x80
                || in5 >= 0x80 || in6 >= 0x80 || in7 >= 0x80 || in8 >= 0x80)
                return 0;
            in1 = BASE32_TABLE[ in1 ];
            in2 = BASE32_TABLE[ in2 ];
            in3 = BASE32_TABLE[ in3 ];
            in4 = BASE32_TABLE[ in4 ];
            in5 = BASE32_TABLE[ in5 ];
            in6 = BASE32_TABLE[ in6 ];
            in7 = BASE32_TABLE[ in7 ];
            in8 = BASE32_TABLE[ in8 ];
            if (in1 > BASE32_MAX_VALUE || in2 > BASE32_MAX_VALUE)
                return 0;
            if ( in3 > BASE32_MAX_VALUE + 1 || in4 > BASE32_MAX_VALUE + 1 || in5 > BASE32_MAX_VALUE + 1
                || in6 > BASE32_MAX_VALUE + 1 || in7 > BASE32_MAX_VALUE + 1 || in8 > BASE32_MAX_VALUE + 1)
                return 0;
            *pDest++ = ((in1 & 0x1f) << 3) | ((in2 & 0x1c) >> 2);
            *pDest++ = ((in2 & 0x03) << 6) | ((in3 & 0x1f) << 1) | ((in4 & 0x10) >> 4);
            *pDest++ = ((in4 & 0x0f) << 4) | ((in5 & 0x1e) >> 1);
            *pDest++ = ((in5 & 0x01) << 7) | ((in6 & 0x1f) << 2) | ((in7 & 0x18) >> 3);
            *pDest++ = ((in7 & 0x07) << 5) | (in8 & 0x1f);
            dwDestSize += BASE32_OUTPUT;
            if (in8 == BASE32_MAX_VALUE + 1)
            {
                --dwDestSize;
                ((void) sizeof (((in7 == BASE32_MAX_VALUE + 1 && in6 == BASE32_MAX_VALUE + 1) || (in7 != BASE32_MAX_VALUE + 1)) ? 1 : 0), __extension__ ({ if ((in7 == BASE32_MAX_VALUE + 1 && in6 == BASE32_MAX_VALUE + 1) || (in7 != BASE32_MAX_VALUE + 1)) ; else __assert_fail ("(in7 == BASE32_MAX_VALUE + 1 && in6 == BASE32_MAX_VALUE + 1) || (in7 != BASE32_MAX_VALUE + 1)", "src/CyoDecode.c", 272, __extension__ __PRETTY_FUNCTION__); }));
                if (in6 == BASE32_MAX_VALUE + 1)
                {
                    --dwDestSize;
                    if (in5 == BASE32_MAX_VALUE + 1)
                    {
                        --dwDestSize;
                        ((void) sizeof (((in4 == BASE32_MAX_VALUE + 1 && in3 == BASE32_MAX_VALUE + 1) || (in4 != BASE32_MAX_VALUE + 1)) ? 1 : 0), __extension__ ({ if ((in4 == BASE32_MAX_VALUE + 1 && in3 == BASE32_MAX_VALUE + 1) || (in4 != BASE32_MAX_VALUE + 1)) ; else __assert_fail ("(in4 == BASE32_MAX_VALUE + 1 && in3 == BASE32_MAX_VALUE + 1) || (in4 != BASE32_MAX_VALUE + 1)", "src/CyoDecode.c", 279, __extension__ __PRETTY_FUNCTION__); }));
                        if (in3 == BASE32_MAX_VALUE + 1)
                        {
                            --dwDestSize;
                        }
                    }
                }
            }
        }
        *pDest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

canonical_original_code:
unsigned long cyoBase32Decode(void *dest, char *src, unsigned long size)
{
    if (dest && src && (size % BASE32_INPUT == 0))
    {
        unsigned char *pDest = (unsigned char*)dest;
        unsigned long dwSrcSize = size;
        unsigned long dwDestSize = 0;
        unsigned char in1; unsigned char in2; unsigned char in3; unsigned char in4; unsigned char in5; unsigned char in6; unsigned char in7; unsigned char in8;
        while (dwSrcSize >= 1)
        {
            in1 = *src++;
            in2 = *src++;
            in3 = *src++;
            in4 = *src++;
            in5 = *src++;
            in6 = *src++;
            in7 = *src++;
            in8 = *src++;
            dwSrcSize -= BASE32_INPUT;
            if ( in1 >= 0x80 || in2 >= 0x80 || in3 >= 0x80 || in4 >= 0x80
                || in5 >= 0x80 || in6 >= 0x80 || in7 >= 0x80 || in8 >= 0x80)
                return 0;
            in1 = BASE32_TABLE[ in1 ];
            in2 = BASE32_TABLE[ in2 ];
            in3 = BASE32_TABLE[ in3 ];
            in4 = BASE32_TABLE[ in4 ];
            in5 = BASE32_TABLE[ in5 ];
            in6 = BASE32_TABLE[ in6 ];
            in7 = BASE32_TABLE[ in7 ];
            in8 = BASE32_TABLE[ in8 ];
            if (in1 > BASE32_MAX_VALUE || in2 > BASE32_MAX_VALUE)
                return 0;
            if ( in3 > BASE32_MAX_VALUE + 1 || in4 > BASE32_MAX_VALUE + 1 || in5 > BASE32_MAX_VALUE + 1
                || in6 > BASE32_MAX_VALUE + 1 || in7 > BASE32_MAX_VALUE + 1 || in8 > BASE32_MAX_VALUE + 1)
                return 0;
            *pDest++ = ((in1 & 0x1f) << 3) | ((in2 & 0x1c) >> 2);
            *pDest++ = ((in2 & 0x03) << 6) | ((in3 & 0x1f) << 1) | ((in4 & 0x10) >> 4);
            *pDest++ = ((in4 & 0x0f) << 4) | ((in5 & 0x1e) >> 1);
            *pDest++ = ((in5 & 0x01) << 7) | ((in6 & 0x1f) << 2) | ((in7 & 0x18) >> 3);
            *pDest++ = ((in7 & 0x07) << 5) | (in8 & 0x1f);
            dwDestSize += BASE32_OUTPUT;
            if (in8 == BASE32_MAX_VALUE + 1)
            {
                --dwDestSize;
                ((void) sizeof (((in7 == BASE32_MAX_VALUE + 1 && in6 == BASE32_MAX_VALUE + 1) || (in7 != BASE32_MAX_VALUE + 1)) ? 1 : 0), __extension__ ({ if ((in7 == BASE32_MAX_VALUE + 1 && in6 == BASE32_MAX_VALUE + 1) || (in7 != BASE32_MAX_VALUE + 1)) ; else __assert_fail ("(in7 == BASE32_MAX_VALUE + 1 && in6 == BASE32_MAX_VALUE + 1) || (in7 != BASE32_MAX_VALUE + 1)", "src/CyoDecode.c", 272, __extension__ __PRETTY_FUNCTION__); }));
                if (in6 == BASE32_MAX_VALUE + 1)
                {
                    --dwDestSize;
                    if (in5 == BASE32_MAX_VALUE + 1)
                    {
                        --dwDestSize;
                        ((void) sizeof (((in4 == BASE32_MAX_VALUE + 1 && in3 == BASE32_MAX_VALUE + 1) || (in4 != BASE32_MAX_VALUE + 1)) ? 1 : 0), __extension__ ({ if ((in4 == BASE32_MAX_VALUE + 1 && in3 == BASE32_MAX_VALUE + 1) || (in4 != BASE32_MAX_VALUE + 1)) ; else __assert_fail ("(in4 == BASE32_MAX_VALUE + 1 && in3 == BASE32_MAX_VALUE + 1) || (in4 != BASE32_MAX_VALUE + 1)", "src/CyoDecode.c", 279, __extension__ __PRETTY_FUNCTION__); }));
                        if (in3 == BASE32_MAX_VALUE + 1)
                        {
                            --dwDestSize;
                        }
                    }
                }
            }
        }
        *pDest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}


decompiled_code:
__int64 __fastcall cyoBase64Validate(unsigned __int8 *a1, unsigned __int64 a2)
{
return cyoBaseXXValidate(a1, a2, 4uLL, 2uLL, 0x3Fu, (__int64)&BASE64_TABLE);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int8 *a1, unsigned __int64 a2)
{
return func0(a1, a2, 4uLL, 2uLL, 0x3Fu, (__int64)&BASE64_TABLE);
}

original_code:
int cyoBase64Validate( const char* src, size_t size )
{
    return cyoBaseXXValidate( src, size, BASE64_INPUT, BASE64_MAX_PADDING, BASE64_MAX_VALUE, BASE64_TABLE );
}

canonical_original_code:
int cyoBase64Validate(char *src, unsigned long size)
{
    return cyoBaseXXValidate( src, size, BASE64_INPUT, BASE64_MAX_PADDING, BASE64_MAX_VALUE, BASE64_TABLE );
}


decompiled_code:
unsigned __int64 __fastcall cyoBase64DecodeGetLength(unsigned __int64 a1)
{
return cyoBaseXXDecodeGetLength(a1, 4uLL, 3LL);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(unsigned __int64 a1)
{
return func1(a1, 4uLL, 3LL);
}

original_code:
size_t cyoBase64DecodeGetLength( size_t size )
{
    return cyoBaseXXDecodeGetLength( size, BASE64_INPUT, BASE64_OUTPUT );
}

canonical_original_code:
unsigned long cyoBase64DecodeGetLength(unsigned long size)
{
    return cyoBaseXXDecodeGetLength( size, BASE64_INPUT, BASE64_OUTPUT );
}


original_code:
size_t cyoBase64Decode( void* dest, const char* src, size_t size )
{
    if (dest && src && (size % BASE64_INPUT == 0))
    {
        unsigned char* pDest = (unsigned char*)dest;
        size_t dwSrcSize = size;
        size_t dwDestSize = 0;
        unsigned char in1, in2, in3, in4;
        while (dwSrcSize >= 1)
        {
            in1 = *src++;
            in2 = *src++;
            in3 = *src++;
            in4 = *src++;
            dwSrcSize -= BASE64_INPUT;
            if (in1 >= 0x80 || in2 >= 0x80 || in3 >= 0x80 || in4 >= 0x80)
                return 0;
            in1 = BASE64_TABLE[ in1 ];
            in2 = BASE64_TABLE[ in2 ];
            in3 = BASE64_TABLE[ in3 ];
            in4 = BASE64_TABLE[ in4 ];
            if (in1 > BASE64_MAX_VALUE || in2 > BASE64_MAX_VALUE)
                return 0;
            if (in3 > BASE64_MAX_VALUE + 1 || in4 > BASE64_MAX_VALUE + 1)
                return 0;
            *pDest++ = ((in1 & 0x3f) << 2) | ((in2 & 0x30) >> 4);
            *pDest++ = ((in2 & 0x0f) << 4) | ((in3 & 0x3c) >> 2);
            *pDest++ = ((in3 & 0x03) << 6) | (in4 & 0x3f);
            dwDestSize += BASE64_OUTPUT;
            if (in4 == BASE64_MAX_VALUE + 1)
            {
                --dwDestSize;
                if (in3 == BASE64_MAX_VALUE + 1)
                {
                    --dwDestSize;
                }
            }
        }
        *pDest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

canonical_original_code:
unsigned long cyoBase64Decode(void *dest, char *src, unsigned long size)
{
    if (dest && src && (size % BASE64_INPUT == 0))
    {
        unsigned char *pDest = (unsigned char*)dest;
        unsigned long dwSrcSize = size;
        unsigned long dwDestSize = 0;
        unsigned char in1; unsigned char in2; unsigned char in3; unsigned char in4;
        while (dwSrcSize >= 1)
        {
            in1 = *src++;
            in2 = *src++;
            in3 = *src++;
            in4 = *src++;
            dwSrcSize -= BASE64_INPUT;
            if (in1 >= 0x80 || in2 >= 0x80 || in3 >= 0x80 || in4 >= 0x80)
                return 0;
            in1 = BASE64_TABLE[ in1 ];
            in2 = BASE64_TABLE[ in2 ];
            in3 = BASE64_TABLE[ in3 ];
            in4 = BASE64_TABLE[ in4 ];
            if (in1 > BASE64_MAX_VALUE || in2 > BASE64_MAX_VALUE)
                return 0;
            if (in3 > BASE64_MAX_VALUE + 1 || in4 > BASE64_MAX_VALUE + 1)
                return 0;
            *pDest++ = ((in1 & 0x3f) << 2) | ((in2 & 0x30) >> 4);
            *pDest++ = ((in2 & 0x0f) << 4) | ((in3 & 0x3c) >> 2);
            *pDest++ = ((in3 & 0x03) << 6) | (in4 & 0x3f);
            dwDestSize += BASE64_OUTPUT;
            if (in4 == BASE64_MAX_VALUE + 1)
            {
                --dwDestSize;
                if (in3 == BASE64_MAX_VALUE + 1)
                {
                    --dwDestSize;
                }
            }
        }
        *pDest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}


cyoBaseXXEncodeGetLength

decompiled_code:
unsigned __int64 __fastcall cyoBaseXXEncodeGetLength(__int64 a1, unsigned __int64 a2, __int64 a3)
{
return a3 * ((a2 + a1 - 1) / a2) + 1;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1, unsigned __int64 a2, __int64 a3)
{
return a3 * ((a2 + a1 - 1) / a2) + 1;
}

original_code:
static size_t cyoBaseXXEncodeGetLength( size_t size, size_t inputBytes, size_t outputBytes )
{
    return (((size + inputBytes - 1) / inputBytes) * outputBytes) + 1;
}

canonical_original_code:
static unsigned long cyoBaseXXEncodeGetLength(unsigned long size, unsigned long inputBytes, unsigned long outputBytes)
{
    return (((size + inputBytes - 1) / inputBytes) * outputBytes) + 1;
}


decompiled_code:
unsigned __int64 __fastcall cyoBase16EncodeGetLength(__int64 a1)
{
return cyoBaseXXEncodeGetLength(a1, 1uLL, 2LL);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(__int64 a1)
{
return func0(a1, 1uLL, 2LL);
}

original_code:
size_t cyoBase16EncodeGetLength( size_t size )
{
    return cyoBaseXXEncodeGetLength( size, BASE16_INPUT, BASE16_OUTPUT );
}

canonical_original_code:
unsigned long cyoBase16EncodeGetLength(unsigned long size)
{
    return cyoBaseXXEncodeGetLength( size, BASE16_INPUT, BASE16_OUTPUT );
}


decompiled_code:
__int64 __fastcall cyoBase16Encode(_BYTE *a1, unsigned __int8 *a2, __int64 a3)
{
unsigned __int8 *v5; // r9
_BYTE *v6; // rdx
unsigned __int8 v7; // al
unsigned __int8 v8; // cl
char v9; // al
__int64 result; // rax

if ( !a1 || !a2 )
return 0LL;
if ( a3 )
{
v5 = &a2[a3];
v6 = a1;
do
{
v7 = *a2++;
v6 += 2;
v8 = v7;
v9 = byte_45A[v7 & 0xF];
*(v6 - 2) = byte_45A[v8 >> 4];
*(v6 - 1) = v9;
}
while ( a2 != v5 );
result = 2 * a3;
a1 += 2 * a3;
}
else
{
result = 0LL;
}
*a1 = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1, unsigned __int8 *a2, __int64 a3)
{
unsigned __int8 *v5; // r9
_BYTE *v6; // rdx
unsigned __int8 v7; // al
unsigned __int8 v8; // cl
char v9; // al
__int64 result; // rax

if ( !a1 || !a2 )
return 0LL;
if ( a3 )
{
v5 = &a2[a3];
v6 = a1;
do
{
v7 = *a2++;
v6 += 2;
v8 = v7;
v9 = byte_45A[v7 & 0xF];
*(v6 - 2) = byte_45A[v8 >> 4];
*(v6 - 1) = v9;
}
while ( a2 != v5 );
result = 2 * a3;
a1 += 2 * a3;
}
else
{
result = 0LL;
}
*a1 = 0;
return result;
}

original_code:
size_t cyoBase16Encode( char* dest, const void* src, size_t size )
{
    if (dest && src)
    {
        unsigned char* pSrc = (unsigned char*)src;
        size_t dwSrcSize = size;
        size_t dwDestSize = 0;
        unsigned char ch;
        while (dwSrcSize >= 1)
        {
            ch = *pSrc++;
            dwSrcSize -= BASE16_INPUT;
            *dest++ = BASE16_TABLE[ (ch & 0xf0) >> 4 ];
            *dest++ = BASE16_TABLE[ (ch & 0x0f) ];
            dwDestSize += BASE16_OUTPUT;
        }
        *dest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

canonical_original_code:
unsigned long cyoBase16Encode(char *dest, void *src, unsigned long size)
{
    if (dest && src)
    {
        unsigned char *pSrc = (unsigned char*)src;
        unsigned long dwSrcSize = size;
        unsigned long dwDestSize = 0;
        unsigned char ch;
        while (dwSrcSize >= 1)
        {
            ch = *pSrc++;
            dwSrcSize -= BASE16_INPUT;
            *dest++ = BASE16_TABLE[ (ch & 0xf0) >> 4 ];
            *dest++ = BASE16_TABLE[ (ch & 0x0f) ];
            dwDestSize += BASE16_OUTPUT;
        }
        *dest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

variable_types:
dest
char *

variable_types:
src
void *

variable_types:
pSrc
unsigned char *


decompiled_code:
unsigned __int64 __fastcall cyoBase32EncodeGetLength(__int64 a1)
{
return cyoBaseXXEncodeGetLength(a1, 5uLL, 8LL);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(__int64 a1)
{
return func0(a1, 5uLL, 8LL);
}

original_code:
size_t cyoBase32EncodeGetLength( size_t size )
{
    return cyoBaseXXEncodeGetLength( size, BASE32_INPUT, BASE32_OUTPUT );
}

canonical_original_code:
unsigned long cyoBase32EncodeGetLength(unsigned long size)
{
    return cyoBaseXXEncodeGetLength( size, BASE32_INPUT, BASE32_OUTPUT );
}


original_code:
size_t cyoBase32Encode( char* dest, const void* src, size_t size )
{
    if (dest && src)
    {
        unsigned char* pSrc = (unsigned char*)src;
        size_t dwSrcSize = size;
        size_t dwDestSize = 0;
        size_t dwBlockSize;
        unsigned char n1, n2, n3, n4, n5, n6, n7, n8;
        while (dwSrcSize >= 1)
        {
            dwBlockSize = (dwSrcSize < BASE32_INPUT ? dwSrcSize : BASE32_INPUT);
            n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
            switch (dwBlockSize)
            {
            case 5:
                n8 = (pSrc[ 4 ] & 0x1f);
                n7 = ((pSrc[ 4 ] & 0xe0) >> 5);
            case 4:
                n7 |= ((pSrc[ 3 ] & 0x03) << 3);
                n6 = ((pSrc[ 3 ] & 0x7c) >> 2);
                n5 = ((pSrc[ 3 ] & 0x80) >> 7);
            case 3:
                n5 |= ((pSrc[ 2 ] & 0x0f) << 1);
                n4 = ((pSrc[ 2 ] & 0xf0) >> 4);
            case 2:
                n4 |= ((pSrc[ 1 ] & 0x01) << 4);
                n3 = ((pSrc[ 1 ] & 0x3e) >> 1);
                n2 = ((pSrc[ 1 ] & 0xc0) >> 6);
            case 1:
                n2 |= ((pSrc[ 0 ] & 0x07) << 2);
                n1 = ((pSrc[ 0 ] & 0xf8) >> 3);
                break;
            default:
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/CyoEncode.c", 149, __extension__ __PRETTY_FUNCTION__); }));
            }
            pSrc += dwBlockSize;
            dwSrcSize -= dwBlockSize;
            ((void) sizeof ((n1 <= 31) ? 1 : 0), __extension__ ({ if (n1 <= 31) ; else __assert_fail ("n1 <= 31", "src/CyoEncode.c", 155, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n2 <= 31) ? 1 : 0), __extension__ ({ if (n2 <= 31) ; else __assert_fail ("n2 <= 31", "src/CyoEncode.c", 156, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n3 <= 31) ? 1 : 0), __extension__ ({ if (n3 <= 31) ; else __assert_fail ("n3 <= 31", "src/CyoEncode.c", 157, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n4 <= 31) ? 1 : 0), __extension__ ({ if (n4 <= 31) ; else __assert_fail ("n4 <= 31", "src/CyoEncode.c", 158, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n5 <= 31) ? 1 : 0), __extension__ ({ if (n5 <= 31) ; else __assert_fail ("n5 <= 31", "src/CyoEncode.c", 159, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n6 <= 31) ? 1 : 0), __extension__ ({ if (n6 <= 31) ; else __assert_fail ("n6 <= 31", "src/CyoEncode.c", 160, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n7 <= 31) ? 1 : 0), __extension__ ({ if (n7 <= 31) ; else __assert_fail ("n7 <= 31", "src/CyoEncode.c", 161, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n8 <= 31) ? 1 : 0), __extension__ ({ if (n8 <= 31) ; else __assert_fail ("n8 <= 31", "src/CyoEncode.c", 162, __extension__ __PRETTY_FUNCTION__); }));
            switch (dwBlockSize)
            {
            case 1: n3 = n4 = 32;
            case 2: n5 = 32;
            case 3: n6 = n7 = 32;
            case 4: n8 = 32;
            case 5:
                break;
            default:
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/CyoEncode.c", 175, __extension__ __PRETTY_FUNCTION__); }));
            }
            *dest++ = BASE32_TABLE[ n1 ];
            *dest++ = BASE32_TABLE[ n2 ];
            *dest++ = BASE32_TABLE[ n3 ];
            *dest++ = BASE32_TABLE[ n4 ];
            *dest++ = BASE32_TABLE[ n5 ];
            *dest++ = BASE32_TABLE[ n6 ];
            *dest++ = BASE32_TABLE[ n7 ];
            *dest++ = BASE32_TABLE[ n8 ];
            dwDestSize += BASE32_OUTPUT;
        }
        *dest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

canonical_original_code:
unsigned long cyoBase32Encode(char *dest, void *src, unsigned long size)
{
    if (dest && src)
    {
        unsigned char *pSrc = (unsigned char*)src;
        unsigned long dwSrcSize = size;
        unsigned long dwDestSize = 0;
        unsigned long dwBlockSize;
        unsigned char n1; unsigned char n2; unsigned char n3; unsigned char n4; unsigned char n5; unsigned char n6; unsigned char n7; unsigned char n8;
        while (dwSrcSize >= 1)
        {
            dwBlockSize = (dwSrcSize < BASE32_INPUT ? dwSrcSize : BASE32_INPUT);
            n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0;
            switch (dwBlockSize)
            {
            case 5:
                n8 = (pSrc[ 4 ] & 0x1f);
                n7 = ((pSrc[ 4 ] & 0xe0) >> 5);
            case 4:
                n7 |= ((pSrc[ 3 ] & 0x03) << 3);
                n6 = ((pSrc[ 3 ] & 0x7c) >> 2);
                n5 = ((pSrc[ 3 ] & 0x80) >> 7);
            case 3:
                n5 |= ((pSrc[ 2 ] & 0x0f) << 1);
                n4 = ((pSrc[ 2 ] & 0xf0) >> 4);
            case 2:
                n4 |= ((pSrc[ 1 ] & 0x01) << 4);
                n3 = ((pSrc[ 1 ] & 0x3e) >> 1);
                n2 = ((pSrc[ 1 ] & 0xc0) >> 6);
            case 1:
                n2 |= ((pSrc[ 0 ] & 0x07) << 2);
                n1 = ((pSrc[ 0 ] & 0xf8) >> 3);
                break;
            default:
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/CyoEncode.c", 149, __extension__ __PRETTY_FUNCTION__); }));
            }
            pSrc += dwBlockSize;
            dwSrcSize -= dwBlockSize;
            ((void) sizeof ((n1 <= 31) ? 1 : 0), __extension__ ({ if (n1 <= 31) ; else __assert_fail ("n1 <= 31", "src/CyoEncode.c", 155, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n2 <= 31) ? 1 : 0), __extension__ ({ if (n2 <= 31) ; else __assert_fail ("n2 <= 31", "src/CyoEncode.c", 156, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n3 <= 31) ? 1 : 0), __extension__ ({ if (n3 <= 31) ; else __assert_fail ("n3 <= 31", "src/CyoEncode.c", 157, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n4 <= 31) ? 1 : 0), __extension__ ({ if (n4 <= 31) ; else __assert_fail ("n4 <= 31", "src/CyoEncode.c", 158, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n5 <= 31) ? 1 : 0), __extension__ ({ if (n5 <= 31) ; else __assert_fail ("n5 <= 31", "src/CyoEncode.c", 159, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n6 <= 31) ? 1 : 0), __extension__ ({ if (n6 <= 31) ; else __assert_fail ("n6 <= 31", "src/CyoEncode.c", 160, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n7 <= 31) ? 1 : 0), __extension__ ({ if (n7 <= 31) ; else __assert_fail ("n7 <= 31", "src/CyoEncode.c", 161, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n8 <= 31) ? 1 : 0), __extension__ ({ if (n8 <= 31) ; else __assert_fail ("n8 <= 31", "src/CyoEncode.c", 162, __extension__ __PRETTY_FUNCTION__); }));
            switch (dwBlockSize)
            {
            case 1: n3 = n4 = 32;
            case 2: n5 = 32;
            case 3: n6 = n7 = 32;
            case 4: n8 = 32;
            case 5:
                break;
            default:
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/CyoEncode.c", 175, __extension__ __PRETTY_FUNCTION__); }));
            }
            *dest++ = BASE32_TABLE[ n1 ];
            *dest++ = BASE32_TABLE[ n2 ];
            *dest++ = BASE32_TABLE[ n3 ];
            *dest++ = BASE32_TABLE[ n4 ];
            *dest++ = BASE32_TABLE[ n5 ];
            *dest++ = BASE32_TABLE[ n6 ];
            *dest++ = BASE32_TABLE[ n7 ];
            *dest++ = BASE32_TABLE[ n8 ];
            dwDestSize += BASE32_OUTPUT;
        }
        *dest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

variable_types:
dwBlockSize
unsigned long


decompiled_code:
unsigned __int64 __fastcall cyoBase64EncodeGetLength(__int64 a1)
{
return cyoBaseXXEncodeGetLength(a1, 3uLL, 4LL);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(__int64 a1)
{
return func0(a1, 3uLL, 4LL);
}

original_code:
size_t cyoBase64EncodeGetLength( size_t size )
{
    return cyoBaseXXEncodeGetLength( size, BASE64_INPUT, BASE64_OUTPUT );
}

canonical_original_code:
unsigned long cyoBase64EncodeGetLength(unsigned long size)
{
    return cyoBaseXXEncodeGetLength( size, BASE64_INPUT, BASE64_OUTPUT );
}


original_code:
size_t cyoBase64Encode( char* dest, const void* src, size_t size )
{
    if (dest && src)
    {
        unsigned char* pSrc = (unsigned char*)src;
        size_t dwSrcSize = size;
        size_t dwDestSize = 0;
        size_t dwBlockSize = 0;
        unsigned char n1, n2, n3, n4;
        while (dwSrcSize >= 1)
        {
            dwBlockSize = (dwSrcSize < BASE64_INPUT ? dwSrcSize : BASE64_INPUT);
            n1 = n2 = n3 = n4 = 0;
            switch (dwBlockSize)
            {
            case 3:
                n4 = (pSrc[ 2 ] & 0x3f);
                n3 = ((pSrc[ 2 ] & 0xc0) >> 6);
            case 2:
                n3 |= ((pSrc[ 1 ] & 0x0f) << 2);
                n2 = ((pSrc[ 1 ] & 0xf0) >> 4);
            case 1:
                n2 |= ((pSrc[ 0 ] & 0x03) << 4);
                n1 = ((pSrc[ 0 ] & 0xfc) >> 2);
                break;
            default:
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/CyoEncode.c", 247, __extension__ __PRETTY_FUNCTION__); }));
            }
            pSrc += dwBlockSize;
            dwSrcSize -= dwBlockSize;
            ((void) sizeof ((n1 <= 63) ? 1 : 0), __extension__ ({ if (n1 <= 63) ; else __assert_fail ("n1 <= 63", "src/CyoEncode.c", 253, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n2 <= 63) ? 1 : 0), __extension__ ({ if (n2 <= 63) ; else __assert_fail ("n2 <= 63", "src/CyoEncode.c", 254, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n3 <= 63) ? 1 : 0), __extension__ ({ if (n3 <= 63) ; else __assert_fail ("n3 <= 63", "src/CyoEncode.c", 255, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n4 <= 63) ? 1 : 0), __extension__ ({ if (n4 <= 63) ; else __assert_fail ("n4 <= 63", "src/CyoEncode.c", 256, __extension__ __PRETTY_FUNCTION__); }));
            switch (dwBlockSize)
            {
            case 1: n3 = 64;
            case 2: n4 = 64;
            case 3:
                break;
            default:
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/CyoEncode.c", 267, __extension__ __PRETTY_FUNCTION__); }));
            }
            *dest++ = BASE64_TABLE[ n1 ];
            *dest++ = BASE64_TABLE[ n2 ];
            *dest++ = BASE64_TABLE[ n3 ];
            *dest++ = BASE64_TABLE[ n4 ];
            dwDestSize += BASE64_OUTPUT;
        }
        *dest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}

canonical_original_code:
unsigned long cyoBase64Encode(char *dest, void *src, unsigned long size)
{
    if (dest && src)
    {
        unsigned char *pSrc = (unsigned char*)src;
        unsigned long dwSrcSize = size;
        unsigned long dwDestSize = 0;
        unsigned long dwBlockSize = 0;
        unsigned char n1; unsigned char n2; unsigned char n3; unsigned char n4;
        while (dwSrcSize >= 1)
        {
            dwBlockSize = (dwSrcSize < BASE64_INPUT ? dwSrcSize : BASE64_INPUT);
            n1 = n2 = n3 = n4 = 0;
            switch (dwBlockSize)
            {
            case 3:
                n4 = (pSrc[ 2 ] & 0x3f);
                n3 = ((pSrc[ 2 ] & 0xc0) >> 6);
            case 2:
                n3 |= ((pSrc[ 1 ] & 0x0f) << 2);
                n2 = ((pSrc[ 1 ] & 0xf0) >> 4);
            case 1:
                n2 |= ((pSrc[ 0 ] & 0x03) << 4);
                n1 = ((pSrc[ 0 ] & 0xfc) >> 2);
                break;
            default:
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/CyoEncode.c", 247, __extension__ __PRETTY_FUNCTION__); }));
            }
            pSrc += dwBlockSize;
            dwSrcSize -= dwBlockSize;
            ((void) sizeof ((n1 <= 63) ? 1 : 0), __extension__ ({ if (n1 <= 63) ; else __assert_fail ("n1 <= 63", "src/CyoEncode.c", 253, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n2 <= 63) ? 1 : 0), __extension__ ({ if (n2 <= 63) ; else __assert_fail ("n2 <= 63", "src/CyoEncode.c", 254, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n3 <= 63) ? 1 : 0), __extension__ ({ if (n3 <= 63) ; else __assert_fail ("n3 <= 63", "src/CyoEncode.c", 255, __extension__ __PRETTY_FUNCTION__); }));
            ((void) sizeof ((n4 <= 63) ? 1 : 0), __extension__ ({ if (n4 <= 63) ; else __assert_fail ("n4 <= 63", "src/CyoEncode.c", 256, __extension__ __PRETTY_FUNCTION__); }));
            switch (dwBlockSize)
            {
            case 1: n3 = 64;
            case 2: n4 = 64;
            case 3:
                break;
            default:
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "src/CyoEncode.c", 267, __extension__ __PRETTY_FUNCTION__); }));
            }
            *dest++ = BASE64_TABLE[ n1 ];
            *dest++ = BASE64_TABLE[ n2 ];
            *dest++ = BASE64_TABLE[ n3 ];
            *dest++ = BASE64_TABLE[ n4 ];
            dwDestSize += BASE64_OUTPUT;
        }
        *dest++ = '\x0';
        return dwDestSize;
    }
    else
        return 0;
}


ps

repo: pidh/toyCrypt

decompiled_code:
int __fastcall ps(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rbx
__int64 v2; // rsi

v1 = a1;
do
{
v2 = *v1++;
printf("%02x ", v2);
}
while ( v1 != a1 + 16 );
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rbx
__int64 v2; // rsi

v1 = a1;
do
{
v2 = *v1++;
printf("%02x ", v2);
}
while ( v1 != a1 + 16 );
return putchar(10);
}

original_code:
static void
ps(u1 *s)
{
 int i;
 for(i = 0;i < 16;i++)
  printf("%02x ", s[i]);
 printf("\n");
}

canonical_original_code:
static void ps(unsigned char *s)
{
 int i;
 for(i = 0;i < 16;i++)
  printf("%02x ", s[i]);
 printf("\n");
}

variable_types:
s
unsigned char *

variable_types: i int

return_type: void


check

decompiled_code:
void __fastcall check(const __m128i *a1, const __m128i *a2, __int64 a3, unsigned int a4, const char *a5)
{
__int64 v6; // rax
void *v7; // rbp
__int128 v8[3]; // [rsp+0h] [rbp-38h] BYREF

v8[0] = (__int128)_mm_load_si128(a1);
v6 = AES_Init(a3, a4);
if ( v6 )
{
v7 = (void *)v6;
AES_Cipher(v6, v8);
ps((unsigned __int8 *)v8);
if ( *a2 != v8[0] )
printf("%s-cipher is wrong\n", a5);
v8[0] = (__int128)_mm_load_si128(a2);
AES_InvCipher(v7, v8);
ps((unsigned __int8 *)v8);
if ( *a1 != v8[0] )
printf("%s-invcipher is wrong\n", a5);
AES_Finish(v7);
}
else
{
puts("no memory");
}
}

canonical_decompiled_code:
void __fastcall func8(const __m128i *a1, const __m128i *a2, __int64 a3, unsigned int a4, const char *a5)
{
__int64 v6; // rax
void *v7; // rbp
__int128 v8[3]; // [rsp+0h] [rbp-38h] BYREF

v8[0] = (__int128)_mm_load_si128(a1);
v6 = AES_Init(a3, a4);
if ( v6 )
{
v7 = (void *)v6;
func17(v6, v8);
func7((unsigned __int8 *)v8);
if ( *a2 != v8[0] )
printf("%s-cipher is wrong\n", a5);
v8[0] = (__int128)_mm_load_si128(a2);
func18(v7, v8);
func7((unsigned __int8 *)v8);
if ( *a1 != v8[0] )
printf("%s-invcipher is wrong\n", a5);
func19(v7);
}
else
{
puts("no memory");
}
}

original_code:
static void
check(u1 *plain, u1 *cipher, u1 *key, int Nk, char *title)
{
 void *ctx;
 u1 data[4 * 4];
 memcpy(data, plain, 4 * 4);
 ctx = AES_Init(key, Nk);
 if(ctx == ((void *)0)) {
  printf("no memory\n");
  return;
 }
 AES_Cipher(ctx, data);
 ps(data);
 if(memcmp(data, cipher, 4 * 4))
  printf("%s-cipher is wrong\n", title);
 memcpy(data, cipher, 4 * 4);
 AES_InvCipher(ctx, data);
 ps(data);
 if(memcmp(data, plain, 4 * 4))
  printf("%s-invcipher is wrong\n", title);
 AES_Finish(ctx);
}

canonical_original_code:
static void check(unsigned char *plain, unsigned char *cipher, unsigned char *key, int Nk, char *title)
{
 void *ctx;
 unsigned char data[-1];
 memcpy(data, plain, 4 * 4);
 ctx = AES_Init(key, Nk);
 if(ctx == ((void *)0)) {
  printf("no memory\n");
  return;
 }
 AES_Cipher(ctx, data);
 ps(data);
 if(memcmp(data, cipher, 4 * 4))
  printf("%s-cipher is wrong\n", title);
 memcpy(data, cipher, 4 * 4);
 AES_InvCipher(ctx, data);
 ps(data);
 if(memcmp(data, plain, 4 * 4))
  printf("%s-invcipher is wrong\n", title);
 AES_Finish(ctx);
}

variable_types:
plain
unsigned char *

variable_types:
cipher
unsigned char *

variable_types:
key
unsigned char *

variable_types: Nk int

variable_types:
title
char *

variable_types:
ctx
void *

variable_types:
data
unsigned char [-1]


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
check(&plain128, &cipher128, &key128, 4LL, "AES-128");
check(&plain128_2, &cipher128_2, &key128_2, 4LL, "AES-128_2");
check(&plain192, &cipher192, &key192, 6LL, "AES-192");
check(&plain256, &cipher256, &key256, 8LL, "AES-256");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func8(&plain128, &cipher128, &key128, 4LL, "AES-128");
func8(&plain128_2, &cipher128_2, &key128_2, 4LL, "AES-128_2");
func8(&plain192, &cipher192, &key192, 6LL, "AES-192");
func8(&plain256, &cipher256, &key256, 8LL, "AES-256");
return 0;
}

variable_types: ac int

variable_types:
av
char *[]


original_code:
int
HMAC_SHA256_Calc(const u1 *text, int text_len, const u1 *key, int key_len, u1 *digest)
{
 u1 tmp[32];
 u1 pad[64];
 void *ctx;
 int i;
 if(key_len > 64) {
  ctx = SHA256_Init();
  if(ctx == ((void *)0))
   return(-1);
  SHA256_Calc(ctx, key, key_len);
  SHA256_Finish(ctx, tmp);
  key = tmp;
  key_len = sizeof(tmp);
 }
 memset(pad, 0x36, sizeof(pad));
 for(i = 0;i < key_len;i++)
  pad[i] ^= key[i];
 ctx = SHA256_Init();
 if(ctx == ((void *)0))
  return(-1);
 SHA256_Calc(ctx, pad, sizeof(pad));
 SHA256_Calc(ctx, text, text_len);
 SHA256_Finish(ctx, digest);
 for(i = 0;i < sizeof(pad);i++)
  pad[i] ^= 0x5c ^ 0x36;
 ctx = SHA256_Init();
 if(ctx == ((void *)0))
  return(-1);
 SHA256_Calc(ctx, pad, sizeof(pad));
 SHA256_Calc(ctx, digest, 32);
 SHA256_Finish(ctx, digest);
 return(0);
}

canonical_original_code:
int HMAC_SHA256_Calc(unsigned char *text, int text_len, unsigned char *key, int key_len, unsigned char *digest)
{
 unsigned char tmp[32];
 unsigned char pad[64];
 void *ctx;
 int i;
 if(key_len > 64) {
  ctx = SHA256_Init();
  if(ctx == ((void *)0))
   return(-1);
  SHA256_Calc(ctx, key, key_len);
  SHA256_Finish(ctx, tmp);
  key = tmp;
  key_len = sizeof(tmp);
 }
 memset(pad, 0x36, sizeof(pad));
 for(i = 0;i < key_len;i++)
  pad[i] ^= key[i];
 ctx = SHA256_Init();
 if(ctx == ((void *)0))
  return(-1);
 SHA256_Calc(ctx, pad, sizeof(pad));
 SHA256_Calc(ctx, text, text_len);
 SHA256_Finish(ctx, digest);
 for(i = 0;i < sizeof(pad);i++)
  pad[i] ^= 0x5c ^ 0x36;
 ctx = SHA256_Init();
 if(ctx == ((void *)0))
  return(-1);
 SHA256_Calc(ctx, pad, sizeof(pad));
 SHA256_Calc(ctx, digest, 32);
 SHA256_Finish(ctx, digest);
 return(0);
}

variable_types:
text
unsigned char *

variable_types:
digest
unsigned char *

variable_types:
tmp
unsigned char [32]

variable_types:
pad
unsigned char [64]


Hash

variable_types:
M
unsigned char *

variable_types: struct SHA1_CTX { unsigned int H0; unsigned int W[80]; unsigned int lenM; unsigned int total; unsigned char M[-1]; } *

variable_types: t int

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types:
c
unsigned int

variable_types:
d
unsigned int

variable_types:
e
unsigned int

variable_types:
T
unsigned int


decompiled_code:
char *SHA1_Init()
{
char *result; // rax

result = (char *)malloc(0x19CuLL);
if ( result )
{
*((_DWORD *)result + 4) = -1009589776;
*(_QWORD *)result = 0xEFCDAB8967452301LL;
*((_QWORD *)result + 1) = 0x1032547698BADCFELL;
*(_QWORD *)(result + 340) = 0LL;
}
return result;
}

canonical_decompiled_code:
char *func9()
{
char *result; // rax

result = (char *)malloc(0x19CuLL);
if ( result )
{
*((_DWORD *)result + 4) = -1009589776;
*(_QWORD *)result = 0xEFCDAB8967452301LL;
*((_QWORD *)result + 1) = 0x1032547698BADCFELL;
*(_QWORD *)(result + 340) = 0LL;
}
return result;
}

original_code:
void *
SHA1_Init(void)
{
 SHA1_CTX *ctx;
 ctx = malloc(sizeof(SHA1_CTX));
 if(ctx == ((void *)0))
  return(((void *)0));
 ctx->H0 = 0x67452301;
 ctx->H1 = 0xefcdab89;
 ctx->H2 = 0x98badcfe;
 ctx->H3 = 0x10325476;
 ctx->H4 = 0xc3d2e1f0;
 ctx->lenM = 0;
 ctx->total = 0;
 return((void *)ctx);
}

canonical_original_code:
void *SHA1_Init()
{
 struct SHA1_CTX *ctx;
 ctx = malloc(sizeof(SHA1_CTX));
 if(ctx == ((void *)0))
  return(((void *)0));
 ctx->H0 = 0x67452301;
 ctx->H1 = 0xefcdab89;
 ctx->H2 = 0x98badcfe;
 ctx->H3 = 0x10325476;
 ctx->H4 = 0xc3d2e1f0;
 ctx->lenM = 0;
 ctx->total = 0;
 return((void *)ctx);
}

return_type: void *

user_defined_types: struct SHA1_CTX { unsigned int H0; unsigned int W[80]; unsigned int lenM; unsigned int total; unsigned char M[-1]; }


decompiled_code:
__int64 __fastcall SHA1_Calc(__int64 a1, char *a2, unsigned int a3)
{
unsigned int v4; // er12
char *v5; // rbp
__int64 result; // rax
__int64 v7; // r15
void *v8; // rdi
size_t v9; // rdx
char *v10; // rbx
__int64 v11; // rsi
unsigned __int64 v12; // rsi
unsigned __int64 v13; // rax
char *v14; // rbx
unsigned int v15; // edx
__int64 v16; // rcx

v4 = a3;
v5 = a2;
result = *(unsigned int *)(a1 + 340);
*(_DWORD *)(a1 + 344) += a3;
if ( (_DWORD)result )
{
v7 = a1 + 348;
v8 = (void *)(a1 + 348 + (unsigned int)result);
if ( (unsigned int)result + a3 <= 0x3F )
{
result = (__int64)memcpy(v8, a2, a3);
*(_DWORD *)(a1 + 340) += v4;
return result;
}
v4 = result + a3 - 64;
v9 = (unsigned int)(64 - result);
v5 = &a2[v9];
memcpy(v8, a2, v9);
result = Hash((int *)a1, v7);
*(_DWORD *)(a1 + 340) = 0;
}
if ( v4 <= 0x3F )
{
v10 = v5;
}
else
{
v10 = &v5[64 * (unsigned __int64)(((v4 - 64) >> 6) + 1)];
do
{
v11 = (__int64)v5;
v5 += 64;
result = Hash((int *)a1, v11);
}
while ( v5 != v10 );
v4 &= 0x3Fu;
}
if ( v4 )
{
result = a1 + 348;
if ( v4 >= 8 )
{
v12 = (a1 + 356) & 0xFFFFFFFFFFFFFFF8LL;
*(_QWORD *)(a1 + 348) = *(_QWORD *)v10;
*(_QWORD *)(result + v4 - 8) = *(_QWORD *)&v10[v4 - 8];
v13 = result - v12;
v14 = &v10[-v13];
result = (v4 + (_DWORD)v13) & 0xFFFFFFF8;
if ( (unsigned int)result >= 8 )
{
result = (unsigned int)result & 0xFFFFFFF8;
v15 = 0;
do
{
v16 = v15;
v15 += 8;
*(_QWORD *)(v12 + v16) = *(_QWORD *)&v14[v16];
}
while ( v15 < (unsigned int)result );
}
}
else if ( (v4 & 4) != 0 )
{
*(_DWORD *)(a1 + 348) = *(_DWORD *)v10;
*(_DWORD *)(result + v4 - 4) = *(_DWORD *)&v10[v4 - 4];
}
else
{
*(_BYTE *)(a1 + 348) = *v10;
if ( (v4 & 2) != 0 )
*(_WORD *)(result + v4 - 2) = *(_WORD *)&v10[v4 - 2];
}
*(_DWORD *)(a1 + 340) = v4;
}
return result;
}

original_code:
void
SHA1_Calc(void *_ctx, u1 *b, u4 len)
{
 SHA1_CTX *ctx = (SHA1_CTX *)_ctx;
 u4 lenM = ctx->lenM;
 ctx->total += len;
 if(lenM) {
  if(lenM + len < 64) {
   memcpy(ctx->M + lenM, b, len);
   ctx->lenM += len;
   return;
  }
  memcpy(ctx->M + lenM, b, 64 - lenM);
  Hash(ctx, ctx->M);
  b += 64 - lenM;
  len -= 64 - lenM;
  ctx->lenM = 0;
 }
 while(len >= 64) {
  Hash(ctx, b);
  b += 64;
  len -= 64;
 }
 if(len) {
  memcpy(ctx->M, b, len);
  ctx->lenM = len;
 }
}

canonical_original_code:
void SHA1_Calc(void *_ctx, unsigned char *b, unsigned int len)
{
 struct SHA1_CTX *ctx = (SHA1_CTX *)_ctx;
 unsigned int lenM = ctx->lenM;
 ctx->total += len;
 if(lenM) {
  if(lenM + len < 64) {
   memcpy(ctx->M + lenM, b, len);
   ctx->lenM += len;
   return;
  }
  memcpy(ctx->M + lenM, b, 64 - lenM);
  Hash(ctx, ctx->M);
  b += 64 - lenM;
  len -= 64 - lenM;
  ctx->lenM = 0;
 }
 while(len >= 64) {
  Hash(ctx, b);
  b += 64;
  len -= 64;
 }
 if(len) {
  memcpy(ctx->M, b, len);
  ctx->lenM = len;
 }
}

variable_types:
b
unsigned char *

variable_types:
len
unsigned int

variable_types:
lenM
unsigned int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rbx
float v6; // xmm0_4
float v8; // [rsp+Ch] [rbp-1Ch]

v3 = 0LL;
v4 = 1000000LL;
initRand(argc, argv, envp);
do
{
v3 += (int)getRand(10LL);
--v4;
}
while ( v4 );
v5 = 1000000LL;
printf("getRand() Average %d\n", v3 / 1000000);
v8 = 0.0;
do
{
v6 = getSRand() + v8;
v8 = v6;
--v5;
}
while ( v5 );
printf("getSRand() Average %f\n", (float)(v6 / 1000000.0));
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rbx
float v6; // xmm0_4
float v8; // [rsp+Ch] [rbp-1Ch]

v3 = 0LL;
v4 = 1000000LL;
func7(argc, argv, envp);
do
{
v3 += (int)func9(10LL);
--v4;
}
while ( v4 );
v5 = 1000000LL;
printf("getRand() Average %d\n", v3 / 1000000);
v8 = 0.0;
do
{
v6 = func8() + v8;
v8 = v6;
--v5;
}
while ( v5 );
printf("getSRand() Average %f\n", (float)(v6 / 1000000.0));
return 0;
}

original_code:
int main() {
  long i;
  long isum;
  float fsum;
  initRand();
  isum = 0L;
  for (i = 0; i < 1000000L; i++) {
    isum += getRand(10);
  }
  printf("getRand() Average %d\n", (int) (isum / 1000000L));
  fsum = 0.0;
  for (i = 0; i < 1000000L; i++) {
    fsum += getSRand();
  }
  printf("getSRand() Average %f\n", (fsum / (float) 1000000L));
  return 0;
}

variable_types: i long

variable_types: isum long

variable_types: fsum float


initRand

decompiled_code:
void initRand()
{
unsigned int v0; // eax

v0 = time(0LL);
srand(v0);
}

canonical_decompiled_code:
void func7()
{
unsigned int v0; // eax

v0 = time(0LL);
srand(v0);
}

original_code:
void initRand() {
  time_t seed;
  seed = time(((void *)0));
  srand(seed);
  return;
}

canonical_original_code:
void initRand() {
  long seed;
  seed = time(((void *)0));
  srand(seed);
  return;
}

variable_types: seed long


getSRand

decompiled_code:
float getSRand()
{
return (float)rand() * 4.6566129e-10;
}

canonical_decompiled_code:
float func8()
{
return (float)rand() * 4.6566129e-10;
}

original_code:
float getSRand() {
  float randvalue;
  randvalue = ((float) rand() / (float) 2147483647);
  return randvalue;
}

variable_types: randvalue float

return_type: float


getRand

decompiled_code:
__int64 __fastcall getRand(int a1)
{
return (unsigned int)(int)((float)((float)a1 * (float)rand()) * 4.656612873077393e-10);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
return (unsigned int)(int)((float)((float)a1 * (float)rand()) * 4.656612873077393e-10);
}

original_code:
int getRand(int max) {
  int randvalue;
  randvalue = (int) ((float) max * rand() / (2147483647 + 1.0));
  return randvalue;
}

variable_types: max int

variable_types: randvalue int


getSRand

canonical_decompiled_code:
float func6()
{
return (float)rand() * 4.6566129e-10;
}

canonical_original_code:
float getSRand() {
  float randvalue;
  randvalue = ((float) rand() / (float) 2147483647);
  return randvalue;
}


getRand

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
return (unsigned int)(int)((float)((float)a1 * (float)rand()) * 4.656612873077393e-10);
}

canonical_original_code:
int getRand(int max) {
  int randvalue;
  randvalue = (int) ((float) max * rand() / (2147483647 + 1.0));
  return randvalue;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func1("--- Hello World 1---", argv, envp);
fflush(stdout);
func2("--- Hello World 2---");
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func8("--- Hello World 1---", argv, envp);
fflush(stdout);
func7("--- Hello World 2---");
return 1;
}

canonical_original_code:
int main() {
  long i;
  long isum;
  float fsum;
  initRand();
  isum = 0L;
  for (i = 0; i < 1000000L; i++) {
    isum += getRand(10);
  }
  printf("getRand() Average %d\n", (int) (isum / 1000000L));
  fsum = 0.0;
  for (i = 0; i < 1000000L; i++) {
    fsum += getSRand();
  }
  printf("getSRand() Average %f\n", (fsum / (float) 1000000L));
  return 0;
}


expconv

repo: piefel/lgrind

original_code:
static void expconv(void)
{
   register char *cs;
   register char c;
   register char *acs;
   register int temp;
   acs = ((void *)0);
   cs = ((void *)0);
   while (*ure != '\0') {
   switch (c = *ure++) {
   case '\\':
  switch (c = *ure++) {
  default:
  if (cs == ((void *)0) || (*cs & 2) == 0) {
     cs = ccre;
     *cs = 2;
     (*(cs+1)) = 1;
     ccre += 2;
  } else
     (*(cs+1))++;
  *ccre++ = c;
  break;
  case 'a':
  case 'd':
  case 'e':
  case 'p':
  if (acs != ((void *)0) && acs != cs) {
     do {
    temp = (*(acs+2));
    (*(acs+2)) = ccre - acs;
    acs -= temp;
     } while (temp != 0);
     acs = ((void *)0);
  }
  cs = ccre;
  *cs = 4;
  (*(cs+1)) = c;
     ccre = (cs+2);
     break;
  }
  break;
      case '^':
      case '$':
  if (acs != ((void *)0) && acs != cs) {
     do {
        temp = (*(acs+2));
        (*(acs+2)) = ccre - acs;
        acs -= temp;
     } while (temp != 0);
     acs = ((void *)0);
  }
  cs = ccre;
  *cs = 4;
  (*(cs+1)) = c;
  ccre = (cs+2);
  break;
      case '?':
  if (cs)
  *cs = *cs | 1;
  break;
      case '(':
  if (acs != ((void *)0) && acs != cs) {
     do {
        temp = (*(acs+2));
        (*(acs+2)) = ccre - acs;
        acs -= temp;
     } while (temp != 0);
     acs = ((void *)0);
  }
  cs = ccre;
  *cs = 16;
  (*(cs+1)) = '(';
  ccre = (cs+3);
  expconv();
  (*(cs+2)) = ccre - cs;
  break;
      case ')':
  if (acs != ((void *)0)) {
     do {
        temp = (*(acs+2));
        (*(acs+2)) = ccre - acs;
        acs -= temp;
     } while (temp != 0);
     acs = ((void *)0);
  }
  cs = ccre;
  *cs = 4;
  (*(cs+1)) = c;
  ccre = (cs+2);
  return;
      case '|':
  if (acs != ((void *)0) && acs != cs)
     (*(ccre+2)) = ccre - acs;
  else
     (*(ccre+2)) = 0;
  *cs |= 8;
  cs = ccre;
  *cs = 16;
  (*(cs+1)) = '|';
  ccre = (cs+3);
  acs = cs;
  break;
      default:
  if (cs == ((void *)0) || (*cs & 2) == 0) {
     cs = ccre;
     *cs = 2;
     (*(cs+1)) = 1;
     ccre = (cs+2);
  } else
     (*(cs+1))++;
  *ccre++ = c;
  break;
      }
   }
   if (acs != ((void *)0)) {
      do {
  temp = (*(acs+2));
  (*(acs+2)) = ccre - acs;
  acs -= temp;
      } while (temp != 0);
      acs = ((void *)0);
   }
   return;
}

canonical_original_code:
static void expconv()
{
   register char *cs;
   register char c;
   register char *acs;
   register int temp;
   acs = ((void *)0);
   cs = ((void *)0);
   while (*ure != '\0') {
   switch (c = *ure++) {
   case '\\':
  switch (c = *ure++) {
  default:
  if (cs == ((void *)0) || (*cs & 2) == 0) {
     cs = ccre;
     *cs = 2;
     (*(cs+1)) = 1;
     ccre += 2;
  } else
     (*(cs+1))++;
  *ccre++ = c;
  break;
  case 'a':
  case 'd':
  case 'e':
  case 'p':
  if (acs != ((void *)0) && acs != cs) {
     do {
    temp = (*(acs+2));
    (*(acs+2)) = ccre - acs;
    acs -= temp;
     } while (temp != 0);
     acs = ((void *)0);
  }
  cs = ccre;
  *cs = 4;
  (*(cs+1)) = c;
     ccre = (cs+2);
     break;
  }
  break;
      case '^':
      case '$':
  if (acs != ((void *)0) && acs != cs) {
     do {
        temp = (*(acs+2));
        (*(acs+2)) = ccre - acs;
        acs -= temp;
     } while (temp != 0);
     acs = ((void *)0);
  }
  cs = ccre;
  *cs = 4;
  (*(cs+1)) = c;
  ccre = (cs+2);
  break;
      case '?':
  if (cs)
  *cs = *cs | 1;
  break;
      case '(':
  if (acs != ((void *)0) && acs != cs) {
     do {
        temp = (*(acs+2));
        (*(acs+2)) = ccre - acs;
        acs -= temp;
     } while (temp != 0);
     acs = ((void *)0);
  }
  cs = ccre;
  *cs = 16;
  (*(cs+1)) = '(';
  ccre = (cs+3);
  expconv();
  (*(cs+2)) = ccre - cs;
  break;
      case ')':
  if (acs != ((void *)0)) {
     do {
        temp = (*(acs+2));
        (*(acs+2)) = ccre - acs;
        acs -= temp;
     } while (temp != 0);
     acs = ((void *)0);
  }
  cs = ccre;
  *cs = 4;
  (*(cs+1)) = c;
  ccre = (cs+2);
  return;
      case '|':
  if (acs != ((void *)0) && acs != cs)
     (*(ccre+2)) = ccre - acs;
  else
     (*(ccre+2)) = 0;
  *cs |= 8;
  cs = ccre;
  *cs = 16;
  (*(cs+1)) = '|';
  ccre = (cs+3);
  acs = cs;
  break;
      default:
  if (cs == ((void *)0) || (*cs & 2) == 0) {
     cs = ccre;
     *cs = 2;
     (*(cs+1)) = 1;
     ccre = (cs+2);
  } else
     (*(cs+1))++;
  *ccre++ = c;
  break;
      }
   }
   if (acs != ((void *)0)) {
      do {
  temp = (*(acs+2));
  (*(acs+2)) = ccre - acs;
  acs -= temp;
      } while (temp != 0);
      acs = ((void *)0);
   }
   return;
}

variable_types:
cs
char *

variable_types: c char

variable_types:
acs
char *

variable_types: temp int


decompiled_code:
__int64 __fastcall lc_strncmp(char *a1, char *a2, __int64 a3)
{
char *v4; // rbx
char *v5; // r13
const unsigned __int16 *v6; // r15
__int64 v7; // r12
int v8; // er14
__int32_t v9; // eax

if ( !a3 )
return 0LL;
v4 = a1;
v5 = &a1[a3];
v6 = *_ctype_b_loc();
do
{
v7 = *v4;
v8 = *a2;
v9 = *v4;
if ( (v6[v7] & 0x100) != 0 )
v9 = (*_ctype_tolower_loc())[v7];
if ( v8 != v9 )
return 1LL;
++v4;
++a2;
}
while ( v4 != v5 );
return 0LL;
}

original_code:
int lc_strncmp(register const char *s1, register const char *s2, register size_t len)
{
   while (len-- > 0)
      if (*s2 - (((*__ctype_b_loc ())[(int) (((*s1)))] & (unsigned short int) _ISupper) ? tolower((*s1)) : (*s1)))
  return 1;
      else
  s2++, s1++;
   return 0;
}

canonical_original_code:
int lc_strncmp(char *s1, char *s2, unsigned long len)
{
   while (len-- > 0)
      if (*s2 - (((*__ctype_b_loc ())[(int) (((*s1)))] & (unsigned short) _ISupper) ? tolower((*s1)) : (*s1)))
  return 1;
      else
  s2++, s1++;
   return 0;
}

variable_types:
len
unsigned long


expmatch

original_code:
char *expmatch(
   register char *s,
   register char *re,
   char **strtptr,
   char *mstring)
{
   register char *cs;
   register char *ptr, *s1;
   register char c;
   boolean matched;
   if (strtptr)
      *strtptr = '\0';
   if (re == ((void *)0))
      return ((void *)0);
   cs = re;
   matched = 0;
   while (*cs) {
      switch (*cs & (16 | 2 | 4)) {
      case 2:
  matched = !((*re_strncmp)(s, (cs+2), (*(cs+1))));
  if (matched) {
     s += (*(cs+1));
     cs = (cs+2+*(cs+1));
  } else if (*cs & 8) {
     cs = (cs+2+*(cs+1));
  } else if (*cs & 1) {
     cs = (cs+2+*(cs+1));
     matched = 1;
  } else {
     return ((void *)0);
  }
  break;
      case 16:
  switch ((*(cs+1))) {
  case '|':
     if (matched)
        cs = (cs+*(cs+2));
     else
        cs = (cs+3);
     break;
  case '(':
     ptr = expmatch(s, (cs+3), strtptr, mstring);
     if (ptr != ((void *)0)) {
        matched = 1;
        s = ptr;
     } else if (*cs & 8) {
        matched = 0;
     } else if (*cs & 1) {
        matched = 1;
     } else {
        return ((void *)0);
     }
     cs = (cs+*(cs+2));
     break;
  }
  break;
      case 4:
  switch ((*(cs+1))) {
  case 'p':
     s1 = s;
     do {
        ptr = expmatch(s1, (cs+2), strtptr, mstring);
        if (ptr != ((void *)0) && s1 != s) {
    if (mstring) {
       strncpy(mstring, s, (size_t)(s1 - s));
       mstring[(int)(s1 - s)] = '\0';
    }
    return ptr;
        } else if (ptr != ((void *)0) && (*cs & 1)) {
    return ptr;
        } else if (ptr != ((void *)0)) {
    return ((void *)0);
        }
        if (!((*__ctype_b_loc ())[(int) ((*s1))] & (unsigned short int) _ISalnum) && !strchr(l_id, *s1))
    return ((void *)0);
        if (*s1 == '\\')
    _escaped = _escaped ? 0 : 1;
        else
    _escaped = 0;
     } while (*s1++);
     return ((void *)0);
  case 'a':
     s1 = s;
     do {
        if(*(ptr = (cs+2)) == 2) {
    c = *(ptr+2);
    while(*s1 && *s1 != c)
       s1++;
    if (*s1 == 0)
       return ((void *)0);
    if ((ptr+2+*(ptr+1)) == 0 && (s1 != s || *cs & 1)) {
       if (strtptr)
   *strtptr = s1;
       cs = ptr;
       s = s1;
       break;
    }
        }
        ptr = expmatch(s1, (cs+2), strtptr, mstring);
        if (ptr != ((void *)0) && (s1 != s || *cs & 1)) {
    if (strtptr)
       *strtptr = s1;
    return ptr;
        } else if (ptr != ((void *)0)) {
    return ((void *)0);
        }
        if (*s1 == '\\')
    _escaped = _escaped ? 0 : 1;
        else
    _escaped = 0;
     } while (*s1++);
     return ((void *)0);
  case 'e':
     if (_escaped)
        return ((void *)0);
     cs = (cs+2);
     break;
  case 'd':
     ptr = s;
     while (*s == ' ' || *s == '\t')
        s++;
     if (s != ptr || s == _sstart) {
        matched = 1;
        cs = (cs+2);
     } else if (*s == '\n' || *s == '\0') {
        matched = 1;
        cs = (cs+2);
     } else if (*cs & 8) {
        matched = 0;
        cs = (cs+2);
     } else if (*cs & 1) {
        matched = 1;
        cs = (cs+2);
     } else
        return ((void *)0);
     break;
  case '$':
     if (*s == '\0' || *s == '\n') {
        matched = 1;
        cs = (cs+2);
     } else if (*cs & 8) {
        matched = 0;
        cs = (cs+2);
     } else if (*cs & 1) {
        matched = 1;
        cs = (cs+2);
     } else
        return ((void *)0);
     break;
  case '^':
     if (s == _sstart) {
        matched = 1;
        cs = (cs+2);
     } else if (*cs & 8) {
        matched = 0;
        cs = (cs+2);
     } else if (*cs & 1) {
        matched = 1;
        cs = (cs+2);
     } else
        return ((void *)0);
     break;
  case ')':
     return s;
  }
  break;
      }
   }
   return s;
}

canonical_original_code:
char *expmatch(char *s, char *re, char **strtptr, char *mstring)
{
   register char *cs;
   register char *ptr; register char *s1;
   register char c;
   int matched;
   if (strtptr)
      *strtptr = '\0';
   if (re == ((void *)0))
      return ((void *)0);
   cs = re;
   matched = 0;
   while (*cs) {
      switch (*cs & (16 | 2 | 4)) {
      case 2:
  matched = !((*re_strncmp)(s, (cs+2), (*(cs+1))));
  if (matched) {
     s += (*(cs+1));
     cs = (cs+2+*(cs+1));
  } else if (*cs & 8) {
     cs = (cs+2+*(cs+1));
  } else if (*cs & 1) {
     cs = (cs+2+*(cs+1));
     matched = 1;
  } else {
     return ((void *)0);
  }
  break;
      case 16:
  switch ((*(cs+1))) {
  case '|':
     if (matched)
        cs = (cs+*(cs+2));
     else
        cs = (cs+3);
     break;
  case '(':
     ptr = expmatch(s, (cs+3), strtptr, mstring);
     if (ptr != ((void *)0)) {
        matched = 1;
        s = ptr;
     } else if (*cs & 8) {
        matched = 0;
     } else if (*cs & 1) {
        matched = 1;
     } else {
        return ((void *)0);
     }
     cs = (cs+*(cs+2));
     break;
  }
  break;
      case 4:
  switch ((*(cs+1))) {
  case 'p':
     s1 = s;
     do {
        ptr = expmatch(s1, (cs+2), strtptr, mstring);
        if (ptr != ((void *)0) && s1 != s) {
    if (mstring) {
       strncpy(mstring, s, (unsigned long)(s1 - s));
       mstring[(int)(s1 - s)] = '\0';
    }
    return ptr;
        } else if (ptr != ((void *)0) && (*cs & 1)) {
    return ptr;
        } else if (ptr != ((void *)0)) {
    return ((void *)0);
        }
        if (!((*__ctype_b_loc ())[(int) ((*s1))] & (unsigned short) _ISalnum) && !strchr(l_id, *s1))
    return ((void *)0);
        if (*s1 == '\\')
    _escaped = _escaped ? 0 : 1;
        else
    _escaped = 0;
     } while (*s1++);
     return ((void *)0);
  case 'a':
     s1 = s;
     do {
        if(*(ptr = (cs+2)) == 2) {
    c = *(ptr+2);
    while(*s1 && *s1 != c)
       s1++;
    if (*s1 == 0)
       return ((void *)0);
    if ((ptr+2+*(ptr+1)) == 0 && (s1 != s || *cs & 1)) {
       if (strtptr)
   *strtptr = s1;
       cs = ptr;
       s = s1;
       break;
    }
        }
        ptr = expmatch(s1, (cs+2), strtptr, mstring);
        if (ptr != ((void *)0) && (s1 != s || *cs & 1)) {
    if (strtptr)
       *strtptr = s1;
    return ptr;
        } else if (ptr != ((void *)0)) {
    return ((void *)0);
        }
        if (*s1 == '\\')
    _escaped = _escaped ? 0 : 1;
        else
    _escaped = 0;
     } while (*s1++);
     return ((void *)0);
  case 'e':
     if (_escaped)
        return ((void *)0);
     cs = (cs+2);
     break;
  case 'd':
     ptr = s;
     while (*s == ' ' || *s == '\t')
        s++;
     if (s != ptr || s == _sstart) {
        matched = 1;
        cs = (cs+2);
     } else if (*s == '\n' || *s == '\0') {
        matched = 1;
        cs = (cs+2);
     } else if (*cs & 8) {
        matched = 0;
        cs = (cs+2);
     } else if (*cs & 1) {
        matched = 1;
        cs = (cs+2);
     } else
        return ((void *)0);
     break;
  case '$':
     if (*s == '\0' || *s == '\n') {
        matched = 1;
        cs = (cs+2);
     } else if (*cs & 8) {
        matched = 0;
        cs = (cs+2);
     } else if (*cs & 1) {
        matched = 1;
        cs = (cs+2);
     } else
        return ((void *)0);
     break;
  case '^':
     if (s == _sstart) {
        matched = 1;
        cs = (cs+2);
     } else if (*cs & 8) {
        matched = 0;
        cs = (cs+2);
     } else if (*cs & 1) {
        matched = 1;
        cs = (cs+2);
     } else
        return ((void *)0);
     break;
  case ')':
     return s;
  }
  break;
      }
   }
   return s;
}

variable_types:
s
char *

variable_types:
re
char *

variable_types:
strtptr
char **

variable_types:
mstring
char *

variable_types:
ptr
char *

variable_types: matched int


tnamatch

decompiled_code:
__int64 __fastcall tnamatch(_BYTE *a1)
{
__int64 result; // rax
char *v2; // rbp
char v3; // bl
char v4; // r13
_BYTE *v5; // rsi
const __int32_t *v6; // rdx
__int64 v7; // rax
char v8; // al
char *v9; // rdx

result = 0LL;
v2 = tbuf;
v3 = *tbuf;
if ( *tbuf != 35 )
{
v4 = *a1;
if ( !*a1 )
goto LABEL_9;
LABEL_3:
v5 = a1;
v6 = *_ctype_toupper_loc();
v7 = v4;
do
{
if ( v6[v7] != v6[v3] )
{
LABEL_5:
if ( v3 && v3 != 58 )
goto LABEL_7;
return 0LL;
}
v7 = (char)v5[1];
++v2;
++v5;
v3 = *v2;
}
while ( (_BYTE)v7 );
LABEL_9:
while ( v3 != 58 && v3 != 124 && v3 )
{
LABEL_7:
v8 = v3;
v9 = v2;
v3 = *++v2;
if ( v8 != 124 )
goto LABEL_5;
v3 = v9[1];
v2 = v9 + 1;
if ( v4 )
goto LABEL_3;
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
__int64 result; // rax
char *v2; // rbp
char v3; // bl
char v4; // r13
_BYTE *v5; // rsi
const __int32_t *v6; // rdx
__int64 v7; // rax
char v8; // al
char *v9; // rdx

result = 0LL;
v2 = tbuf;
v3 = *tbuf;
if ( *tbuf != 35 )
{
v4 = *a1;
if ( !*a1 )
goto LABEL_9;
LABEL_3:
v5 = a1;
v6 = *_ctype_toupper_loc();
v7 = v4;
do
{
if ( v6[v7] != v6[v3] )
{
LABEL_5:
if ( v3 && v3 != 58 )
goto LABEL_7;
return 0LL;
}
v7 = (char)v5[1];
++v2;
++v5;
v3 = *v2;
}
while ( (_BYTE)v7 );
LABEL_9:
while ( v3 != 58 && v3 != 124 && v3 )
{
LABEL_7:
v8 = v3;
v9 = v2;
v3 = *++v2;
if ( v8 != 124 )
goto LABEL_5;
v3 = v9[1];
v2 = v9 + 1;
if ( v4 )
goto LABEL_3;
}
result = 1LL;
}
return result;
}

original_code:
static int tnamatch(char *np)
{
   register char *Np, *Bp;
   Bp = tbuf;
   if (*Bp == '#')
      return 0;
   for (;;) {
      for (Np = np; *Np && toupper(*Bp) == toupper(*Np); Bp++, Np++)
   continue;
      if (*Np == '\0' && (*Bp == '|' || *Bp == ':' || *Bp == '\0'))
   return 1;
      while (*Bp != '\0' && *Bp != ':' && *Bp != '|')
   Bp++;
      if (*Bp == '\0' || *Bp == ':')
   return 0;
      Bp++;
   }
}

canonical_original_code:
static int tnamatch(char *np)
{
   register char *Np; register char *Bp;
   Bp = tbuf;
   if (*Bp == '#')
      return 0;
   for (;;) {
      for (Np = np; *Np && toupper(*Bp) == toupper(*Np); Bp++, Np++)
   continue;
      if (*Np == '\0' && (*Bp == '|' || *Bp == ':' || *Bp == '\0'))
   return 1;
      while (*Bp != '\0' && *Bp != ':' && *Bp != '|')
   Bp++;
      if (*Bp == '\0' || *Bp == ':')
   return 0;
      Bp++;
   }
}

variable_types:
np
char *

variable_types:
Np
char *

variable_types:
Bp
char *


tgetnum

decompiled_code:
__int64 tgetnum()
{
char *v0; // rdi
char *v1; // rax
_BYTE *v2; // rcx
char v3; // dl
char v4; // dl
int v5; // ebx
char *v6; // rbp
int v7; // er12
const unsigned __int16 *v8; // rcx
__int64 result; // rax

v0 = tbuf;
while ( 1 )
{
v1 = tskip(v0);
if ( !*v1 )
return 0xFFFFFFFFLL;
v0 = v1 + 1;
if ( *v1 == *v2 )
{
v3 = v1[1];
if ( v3 )
{
v0 = v1 + 2;
if ( v3 == v2[1] )
{
v4 = v1[2];
if ( v4 == 64 )
return 0xFFFFFFFFLL;
if ( v4 == 35 )
break;
}
}
}
}
v5 = v1[3];
v6 = v1 + 3;
v7 = 2 * (v1[3] != 48) + 8;
v8 = *_ctype_b_loc();
result = 0LL;
while ( (v8[(char)v5] & 0x800) != 0 )
{
++v6;
result = (unsigned int)(v7 * result + v5 - 48);
v5 = *v6;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
char *v0; // rdi
char *v1; // rax
_BYTE *v2; // rcx
char v3; // dl
char v4; // dl
int v5; // ebx
char *v6; // rbp
int v7; // er12
const unsigned __int16 *v8; // rcx
__int64 result; // rax

v0 = tbuf;
while ( 1 )
{
v1 = tskip(v0);
if ( !*v1 )
return 0xFFFFFFFFLL;
v0 = v1 + 1;
if ( *v1 == *v2 )
{
v3 = v1[1];
if ( v3 )
{
v0 = v1 + 2;
if ( v3 == v2[1] )
{
v4 = v1[2];
if ( v4 == 64 )
return 0xFFFFFFFFLL;
if ( v4 == 35 )
break;
}
}
}
}
v5 = v1[3];
v6 = v1 + 3;
v7 = 2 * (v1[3] != 48) + 8;
v8 = *_ctype_b_loc();
result = 0LL;
while ( (v8[(char)v5] & 0x800) != 0 )
{
++v6;
result = (unsigned int)(v7 * result + v5 - 48);
v5 = *v6;
}
return result;
}

original_code:
int tgetnum(char *id)
{
   register int i, base;
   register char *bp = tbuf;
   for (;;) {
      bp = tskip(bp);
      if (*bp == '\0')
  return -1;
      if (*bp++ != id[0] || *bp == '\0' || *bp++ != id[1])
  continue;
      if (*bp == '@')
  return -1;
      if (*bp != '#')
  continue;
      bp++;
      base = 10;
      if (*bp == '0')
  base = 8;
      i = 0;
      while (((*__ctype_b_loc ())[(int) ((*bp))] & (unsigned short int) _ISdigit))
  i *= base, i += *bp++ - '0';
      return i;
   }
}

canonical_original_code:
int tgetnum(char *id)
{
   register int i; register int base;
   register char *bp = tbuf;
   for (;;) {
      bp = tskip(bp);
      if (*bp == '\0')
  return -1;
      if (*bp++ != id[0] || *bp == '\0' || *bp++ != id[1])
  continue;
      if (*bp == '@')
  return -1;
      if (*bp != '#')
  continue;
      bp++;
      base = 10;
      if (*bp == '0')
  base = 8;
      i = 0;
      while (((*__ctype_b_loc ())[(int) ((*bp))] & (unsigned short) _ISdigit))
  i *= base, i += *bp++ - '0';
      return i;
   }
}

variable_types:
id
char *

variable_types: i int

variable_types: base int

variable_types:
bp
char *


tgetflag

decompiled_code:
__int64 tgetflag()
{
char *v0; // rdi
_BYTE *v1; // rax
_BYTE *v2; // rcx
char v3; // dl
char v4; // al

v0 = tbuf;
while ( 1 )
{
while ( 1 )
{
v1 = tskip(v0);
if ( !*v1 )
return 0LL;
v0 = v1 + 1;
if ( *v1 == *v2 )
{
v3 = v1[1];
if ( v3 )
{
v0 = v1 + 2;
if ( v3 == v2[1] )
break;
}
}
}
v4 = v1[2];
if ( !v4 || v4 == 58 )
break;
if ( v4 == 64 )
return 0LL;
}
return 1LL;
}

original_code:
int tgetflag(char *id)
{
   register char *bp = tbuf;
   for (;;) {
      bp = tskip(bp);
      if (!*bp)
  return 0;
      if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) {
  if (!*bp || *bp == ':')
     return 1;
  else if (*bp == '@')
     return 0;
      }
   }
}


tnchktc

decompiled_code:
__int64 tnchktc()
{
char *v0; // rbx
size_t v1; // rax
size_t v2; // rbp
unsigned int v3; // er12
char *i; // rax
char *j; // r13
char v7[16]; // [rsp+0h] [rbp-2038h] BYREF
char s[8232]; // [rsp+10h] [rbp-2028h] BYREF

v0 = tbuf;
v1 = (size_t)&v0[strlen(tbuf) - 2];
while ( 1 )
{
v2 = v1--;
if ( *(_BYTE *)(v2 - 1) == 58 )
break;
if ( (unsigned __int64)v0 > v1 )
goto LABEL_7;
}
v3 = 1;
if ( *(_BYTE *)(v1 + 1) == 116 && *(_BYTE *)(v1 + 2) == 99 )
{
strcpy(v7, (const char *)(v2 + 3));
for ( i = v7; *i != 58; ++i )
;
*i = 0;
if ( ++hopcount > 32 )
{
fwrite("Infinite tc= loop\n", 1uLL, 0x12uLL, stderr);
}
else
{
v3 = tgetent(s, v7, (const char *)filename);
if ( v3 == 1 )
{
for ( j = s; *j != 58; ++j )
;
if ( (int)(strlen(j) + v2 - (_DWORD)v0) > 0x2000 )
{
fwrite("LGrind entry too long\n", 1uLL, 0x16uLL, stderr);
j[0x2000 - ((int)v2 - (int)tbuf)] = 0;
}
strcpy((char *)v2, j + 1);
tbuf = v0;
return v3;
}
}
LABEL_7:
v3 = 0;
}
return v3;
}

canonical_decompiled_code:
__int64 func4()
{
char *v0; // rbx
size_t v1; // rax
size_t v2; // rbp
unsigned int v3; // er12
char *i; // rax
char *j; // r13
char v7[16]; // [rsp+0h] [rbp-2038h] BYREF
char s[8232]; // [rsp+10h] [rbp-2028h] BYREF

v0 = tbuf;
v1 = (size_t)&v0[strlen(tbuf) - 2];
while ( 1 )
{
v2 = v1--;
if ( *(_BYTE *)(v2 - 1) == 58 )
break;
if ( (unsigned __int64)v0 > v1 )
goto LABEL_7;
}
v3 = 1;
if ( *(_BYTE *)(v1 + 1) == 116 && *(_BYTE *)(v1 + 2) == 99 )
{
strcpy(v7, (const char *)(v2 + 3));
for ( i = v7; *i != 58; ++i )
;
*i = 0;
if ( ++hopcount > 32 )
{
fwrite("Infinite tc= loop\n", 1uLL, 0x12uLL, stderr);
}
else
{
v3 = func3(s, v7, (const char *)filename);
if ( v3 == 1 )
{
for ( j = s; *j != 58; ++j )
;
if ( (int)(strlen(j) + v2 - (_DWORD)v0) > 0x2000 )
{
fwrite("LGrind entry too long\n", 1uLL, 0x16uLL, stderr);
j[0x2000 - ((int)v2 - (int)tbuf)] = 0;
}
strcpy((char *)v2, j + 1);
tbuf = v0;
return v3;
}
}
LABEL_7:
v3 = 0;
}
return v3;
}

original_code:
static int tnchktc(void)
{
   register char *p, *q;
   char tcname[16];
   char tcbuf[8192];
   char *holdtbuf = tbuf;
   int l;
   p = tbuf + strlen(tbuf) - 2;
   while (*--p != ':')
      if (p < tbuf) {
  return 0;
      }
   p++;
   if (p[0] != 't' || p[1] != 'c')
      return 1;
   strcpy(tcname,p+3);
   q = tcname;
   while (q && *q != ':')
      q++;
   *q = '\0';
   if (++hopcount > 32) {
      fprintf(stderr, "Infinite tc= loop\n");
      return 0;
   }
   if (tgetent(tcbuf, tcname, filename) != 1)
      return 0;
   for (q = tcbuf; *q != ':'; q++)
      ;
   l = (int)(p - holdtbuf + strlen(q));
   if (l > 8192) {
      fprintf(stderr, "LGrind entry too long\n");
      q[(int)(8192 - (p-tbuf))] = '\0';
   }
   strcpy(p, q+1);
   tbuf = holdtbuf;
   return 1;
}

canonical_original_code:
static int tnchktc()
{
   register char *p; register char *q;
   char tcname[16];
   char tcbuf[8192];
   char *holdtbuf = tbuf;
   int l;
   p = tbuf + strlen(tbuf) - 2;
   while (*--p != ':')
      if (p < tbuf) {
  return 0;
      }
   p++;
   if (p[0] != 't' || p[1] != 'c')
      return 1;
   strcpy(tcname,p+3);
   q = tcname;
   while (q && *q != ':')
      q++;
   *q = '\0';
   if (++hopcount > 32) {
      fprintf(stderr, "Infinite tc= loop\n");
      return 0;
   }
   if (tgetent(tcbuf, tcname, filename) != 1)
      return 0;
   for (q = tcbuf; *q != ':'; q++)
      ;
   l = (int)(p - holdtbuf + strlen(q));
   if (l > 8192) {
      fprintf(stderr, "LGrind entry too long\n");
      q[(int)(8192 - (p-tbuf))] = '\0';
   }
   strcpy(p, q+1);
   tbuf = holdtbuf;
   return 1;
}

variable_types:
p
char *

variable_types:
q
char *

variable_types:
tcname
char [16]

variable_types:
tcbuf
char [8192]

variable_types:
holdtbuf
char *

variable_types: l int


repo: pielo/select

decompiled_code:
__int64 __fastcall ft_putc(int a1)
{
int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
write(1, buf, 1uLL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
write(1, buf, 1uLL);
return 1LL;
}

original_code:
int ft_putc(int c)
{
 write(1, &c, 1);
 return (1);
}

variable_types: c int


pushData

repo: pierinz/citofonoweb

decompiled_code:
__int64 __fastcall pushData(char *src)
{
void *v1; // rdi
unsigned int v2; // er12

if ( ((unsigned __int16)*current + 64) % (qsize << 6) == (unsigned __int16)*start )
return (unsigned int)-1;
f_elock(fd);
strcpy((char *)queue + (unsigned __int16)*current, src);
v1 = queue;
*current = ((unsigned __int16)*current + 64) % (qsize << 6);
msync(v1, msize, 4);
v2 = (qsize << 6) - abs32((unsigned __int16)*start - (unsigned __int16)*current);
if ( qsize << 6 == v2 )
v2 = 0;
f_unlock(fd);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src)
{
void *v1; // rdi
unsigned int v2; // er12

if ( ((unsigned __int16)*current + 64) % (qsize << 6) == (unsigned __int16)*start )
return (unsigned int)-1;
f_elock(fd);
strcpy((char *)queue + (unsigned __int16)*current, src);
v1 = queue;
*current = ((unsigned __int16)*current + 64) % (qsize << 6);
msync(v1, msize, 4);
v2 = (qsize << 6) - abs32((unsigned __int16)*start - (unsigned __int16)*current);
if ( qsize << 6 == v2 )
v2 = 0;
f_unlock(fd);
return v2;
}

original_code:
int pushData(char* param) {
 int qfree;
 if ((*current + 64) % (qsize * 64) == *start) {
  return -1;
 }
 f_elock(fd);
 sprintf(queue + *current, "%s", param);
 *current = (*current + 64) % (qsize * 64);
 msync(queue, msize, 4);
 qfree = (qsize * 64) - abs(*start - *current);
 if (qfree == qsize * 64) {
  qfree = 0;
 }
 f_unlock(fd);
 return qfree;
}

canonical_original_code:
int pushData(char *param) {
 int qfree;
 if ((*current + 64) % (qsize * 64) == *start) {
  return -1;
 }
 f_elock(fd);
 sprintf(queue + *current, "%s", param);
 *current = (*current + 64) % (qsize * 64);
 msync(queue, msize, 4);
 qfree = (qsize * 64) - abs(*start - *current);
 if (qfree == qsize * 64) {
  qfree = 0;
 }
 f_unlock(fd);
 return qfree;
}

variable_types:
param
char *

variable_types: qfree int