repo: ozette/roloc

decompiled_code:
__int64 __fastcall process_line(char *s1, const char **a2)
{
const char **v3; // rbx
const char *v4; // rsi
int v5; // eax
bool v6; // cf
bool v7; // zf
__int64 result; // rax
const char *v9; // rdi
__int64 v10; // rcx
char *v11; // rsi

v3 = a2;
v4 = *a2;
if ( v4 )
{
while ( 1 )
{
v5 = strcmp(s1, v4);
v6 = 0;
v7 = v5 == 0;
if ( !v5 )
break;
v3 += 3;
v4 = *v3;
if ( !*v3 )
goto LABEL_4;
}
v9 = "list";
v10 = 5LL;
v11 = s1;
do
{
if ( !v10 )
break;
v6 = (unsigned __int8)*v11 < (unsigned int)*v9;
v7 = *v11++ == *v9++;
--v10;
}
while ( v7 );
if ( (!v6 && !v7) == v6 )
result = ((__int64 (__fastcall *)(_QWORD, char *))v3[2])(RLC_PATH, v11);
else
result = ((__int64 (__fastcall *)(const char *, char *))v3[2])(v9, v11);
}
else
{
LABEL_4:
find_color(s1, RLC_PATH, 0LL);
find_arithmetic(s1);
result = find_request(s1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1, const char **a2)
{
const char **v3; // rbx
const char *v4; // rsi
int v5; // eax
bool v6; // cf
bool v7; // zf
__int64 result; // rax
const char *v9; // rdi
__int64 v10; // rcx
char *v11; // rsi

v3 = a2;
v4 = *a2;
if ( v4 )
{
while ( 1 )
{
v5 = strcmp(s1, v4);
v6 = 0;
v7 = v5 == 0;
if ( !v5 )
break;
v3 += 3;
v4 = *v3;
if ( !*v3 )
goto LABEL_4;
}
v9 = "list";
v10 = 5LL;
v11 = s1;
do
{
if ( !v10 )
break;
v6 = (unsigned __int8)*v11 < (unsigned int)*v9;
v7 = *v11++ == *v9++;
--v10;
}
while ( v7 );
if ( (!v6 && !v7) == v6 )
result = ((__int64 (__fastcall *)(_QWORD, char *))v3[2])(RLC_PATH, v11);
else
result = ((__int64 (__fastcall *)(const char *, char *))v3[2])(v9, v11);
}
else
{
LABEL_4:
find_color(s1, RLC_PATH, 0LL);
find_arithmetic(s1);
result = find_request(s1);
}
return result;
}

original_code:
void process_line(char *line, RLC_CMD pool[])
{
  int itr;
  for(itr = 0; pool[itr].cmd; itr++) {
    if(strcmp(line, pool[itr].cmd) == 0) {
      if(strcmp(line, "list") == 0) {
        pool[itr].func(RLC_PATH);
        return;
      } else {
        pool[itr].func();
        return;
      }
    }
  }
  find_color(line, RLC_PATH, 0);
  find_arithmetic(line);
  find_request(line);
}

canonical_original_code:
void process_line(char *line, struct RLC_CMD pool[])
{
  int itr;
  for(itr = 0; pool[itr].cmd; itr++) {
    if(strcmp(line, pool[itr].cmd) == 0) {
      if(strcmp(line, "list") == 0) {
        pool[itr].func(RLC_PATH);
        return;
      } else {
        pool[itr].func();
        return;
      }
    }
  }
  find_color(line, RLC_PATH, 0);
  find_arithmetic(line);
  find_request(line);
}

variable_types:
line
char *

variable_types: struct RLC_CMD { char *cmd; char *description; int (*func)(); } []

variable_types: itr int


decompiled_code:
__int64 __fastcall start_interpreter(const char **a1)
{
__int64 v3; // rax
char *v4; // rbx
bool v5; // cf
bool v6; // zf
const char *v7; // rdi
__int64 v8; // rcx
const char *v9; // rsi
char v10; // al
bool v11; // cf
bool v12; // zf
__int64 v13; // rcx
struct sigaction v14; // [rsp+0h] [rbp-B8h] BYREF

v14.sa_handler = (__sighandler_t)&cleanup;
sigaction(2, &v14, 0LL);
while ( 1 )
{
v3 = readline("> ");
v4 = (char *)v3;
v5 = 0;
v6 = v3 == 0;
if ( !v3 )
return ((__int64 (*)(void))cleanup)();
v7 = "quit";
v8 = 5LL;
v9 = (const char *)v3;
do
{
if ( !v8 )
break;
v5 = *v9 < (unsigned int)*v7;
v6 = *v9++ == *v7++;
--v8;
}
while ( v6 );
v10 = (!v5 && !v6) - v5;
v11 = 0;
v12 = v10 == 0;
if ( !v10 )
break;
v7 = "q";
v13 = 2LL;
v9 = v4;
do
{
if ( !v13 )
break;
v11 = *v9 < (unsigned int)*v7;
v12 = *v9++ == *v7++;
--v13;
}
while ( v12 );
if ( (!v11 && !v12) == v11 )
break;
add_history(v4);
process_line(v4, a1);
free(v4);
}
return cleanup(v7, v9);
}

canonical_decompiled_code:
__int64 __fastcall func1(const char **a1)
{
__int64 v3; // rax
char *v4; // rbx
bool v5; // cf
bool v6; // zf
const char *v7; // rdi
__int64 v8; // rcx
const char *v9; // rsi
char v10; // al
bool v11; // cf
bool v12; // zf
__int64 v13; // rcx
struct sigaction v14; // [rsp+0h] [rbp-B8h] BYREF

v14.sa_handler = (__sighandler_t)&cleanup;
sigaction(2, &v14, 0LL);
while ( 1 )
{
v3 = readline("> ");
v4 = (char *)v3;
v5 = 0;
v6 = v3 == 0;
if ( !v3 )
return ((__int64 (*)(void))cleanup)();
v7 = "quit";
v8 = 5LL;
v9 = (const char *)v3;
do
{
if ( !v8 )
break;
v5 = *v9 < (unsigned int)*v7;
v6 = *v9++ == *v7++;
--v8;
}
while ( v6 );
v10 = (!v5 && !v6) - v5;
v11 = 0;
v12 = v10 == 0;
if ( !v10 )
break;
v7 = "q";
v13 = 2LL;
v9 = v4;
do
{
if ( !v13 )
break;
v11 = *v9 < (unsigned int)*v7;
v12 = *v9++ == *v7++;
--v13;
}
while ( v12 );
if ( (!v11 && !v12) == v11 )
break;
add_history(v4);
func0(v4, a1);
free(v4);
}
return cleanup(v7, v9);
}

original_code:
void start_interpreter(RLC_CMD pool[])
{
  int QUIT = 0;
  struct sigaction EXIT;
  EXIT.__sigaction_handler.sa_handler = cleanup;
  sigaction(2, &EXIT, ((void *)0));
  for(; QUIT == 0;) {
    char *line = readline("> ");
    if(((void *)0) == line) {
      QUIT = 1;
      cleanup();
    }
    if(line) {
      if(strcmp(line, "quit") == 0 || strcmp(line, "q") == 0 ) {
        QUIT = 1;
        cleanup();
      } else {
        add_history(line);
        process_line(line, pool);
        free(line);
      }
    }
  }
}

canonical_original_code:
void start_interpreter(struct RLC_CMD pool[])
{
  int QUIT = 0;
  struct sigaction EXIT;
  EXIT.__sigaction_handler.sa_handler = cleanup;
  sigaction(2, &EXIT, ((void *)0));
  for(; QUIT == 0;) {
    char *line = readline("> ");
    if(((void *)0) == line) {
      QUIT = 1;
      cleanup();
    }
    if(line) {
      if(strcmp(line, "quit") == 0 || strcmp(line, "q") == 0 ) {
        QUIT = 1;
        cleanup();
      } else {
        add_history(line);
        process_line(line, pool);
        free(line);
      }
    }
  }
}

variable_types: QUIT int

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

return_type: void

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct RLC_CMD { char *cmd; char *description; int (*func)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


decompiled_code:
char *__fastcall set_last_color(char *src)
{
RLC_last_processed_color = 0;
return strncpy(&RLC_last_processed_color, src, 7uLL);
}

canonical_decompiled_code:
char *__fastcall func2(char *src)
{
RLC_last_processed_color = 0;
return strncpy(&RLC_last_processed_color, src, 7uLL);
}

original_code:
void set_last_color(char *line)
{
  RLC_last_processed_color[0] = '\0';
  strncpy(RLC_last_processed_color, line, 7);
  return;
}


decompiled_code:
void *__fastcall r_set_last_color(void *src, int a2)
{
void *result; // rax

if ( roloc_last_processed_colors )
free(roloc_last_processed_colors);
roloc_last_processed_colors = malloc(12LL * a2);
result = memcpy(roloc_last_processed_colors, src, 12LL * a2);
roloc_store_count = a2;
return result;
}

canonical_decompiled_code:
void *__fastcall func3(void *src, int a2)
{
void *result; // rax

if ( roloc_last_processed_colors )
free(roloc_last_processed_colors);
roloc_last_processed_colors = malloc(12LL * a2);
result = memcpy(roloc_last_processed_colors, src, 12LL * a2);
roloc_store_count = a2;
return result;
}

original_code:
void r_set_last_color(roloc_rgb *store, int amount)
{
  if(roloc_last_processed_colors) {
    free(roloc_last_processed_colors);
    roloc_last_processed_colors = ((void *)0);
    roloc_last_processed_colors = malloc(sizeof(roloc_rgb)*amount);
    memcpy(roloc_last_processed_colors, store, sizeof(roloc_rgb)*amount);
    roloc_store_count = amount;
  } else {
    roloc_last_processed_colors = malloc(sizeof(roloc_rgb)*amount);
    memcpy(roloc_last_processed_colors, store, sizeof(roloc_rgb)*amount);
    roloc_store_count = amount;
  }
  return;
}

canonical_original_code:
void r_set_last_color(struct roloc_rgb *store, int amount)
{
  if(roloc_last_processed_colors) {
    free(roloc_last_processed_colors);
    roloc_last_processed_colors = ((void *)0);
    roloc_last_processed_colors = malloc(sizeof(roloc_rgb)*amount);
    memcpy(roloc_last_processed_colors, store, sizeof(roloc_rgb)*amount);
    roloc_store_count = amount;
  } else {
    roloc_last_processed_colors = malloc(sizeof(roloc_rgb)*amount);
    memcpy(roloc_last_processed_colors, store, sizeof(roloc_rgb)*amount);
    roloc_store_count = amount;
  }
  return;
}

variable_types: struct roloc_rgb { float red; float green; float blue; } *

variable_types: amount int


original_code:
float hex_to_rgb(char hexchar, char hexchar2)
{
  int head = hexchar;
  int tail = hexchar2;
  if(head > 57) {
    head = head - ('0')-7;
  } else {
    head = head - '0';
  }
  head = head* ((int) pow(16, 1));
  if(tail > 57) {
    tail = tail - ('0')-7;
  } else {
    tail = tail - '0';
  }
  tail = tail* ((int) pow(16, 0));
  float rgb_component = ((head+tail)/255.0);
  return rgb_component;
}

variable_types: hexchar char

variable_types: head int

variable_types: tail int

return_type: float


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

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

original_code:
char *rgb_to_hex(float value)
{
  int val = (int) (value*255.0);
  char hex_component[3];
  hex_component[0] = repr[((val-(val%16))/16)];
  hex_component[1] = repr[(val%16)];
  hex_component[2] = '\0';
  return hex_component;
}

variable_types: value float

variable_types: val int

return_type: char *


original_code:
roloc_cmy rgb_to_cmy(roloc_rgb color)
{
  float red = color.red * 255;
  float green = color.green * 255;
  float blue = color.blue * 255;
  roloc_cmy cmy_color;
  cmy_color.c = 1 - (red/255);
  cmy_color.m = 1 - (green/255);
  cmy_color.y = 1 - (blue/255);
  return cmy_color;
}

canonical_original_code:
struct roloc_cmy rgb_to_cmy(struct roloc_rgb color)
{
  float red = color.red * 255;
  float green = color.green * 255;
  float blue = color.blue * 255;
  struct roloc_cmy cmy_color;
  cmy_color.c = 1 - (red/255);
  cmy_color.m = 1 - (green/255);
  cmy_color.y = 1 - (blue/255);
  return cmy_color;
}

variable_types: struct roloc_rgb { float red; float green; float blue; }

variable_types: red float

variable_types: green float

variable_types: blue float

variable_types: struct roloc_cmy { float c; float m; float y; }


original_code:
roloc_rgb hsv_to_rgb(roloc_hsv object)
{
  roloc_rgb color = {0.0, 0.0, 0.0};
  if(object.saturation == 0) {
    color.red = color.green = color.blue = object.value;
    return color;
  }
  object.hue = object.hue/60;
  int i = floor(object.hue);
  float factorial = object.hue - i;
  float p = object.value * (1 - object.saturation);
  float q = object.value * (1 - object.saturation * factorial);
  float t = object.value * (1 - object.saturation * (1 - factorial));
  switch(i) {
    case 0: color = (roloc_rgb) {object.value, t, p}; break;
    case 1: color = (roloc_rgb) {q, object.value, p}; break;
    case 2: color = (roloc_rgb) {p, object.value, t}; break;
    case 3: color = (roloc_rgb) {p, q, object.value}; break;
    case 4: color = (roloc_rgb) {t, p, object.value}; break;
    case 5: color = (roloc_rgb) {object.value, p, q}; break;
  }
  color.red = color.red*255;
  color.green = color.green*255;
  color.blue = color.blue*255;
  return color;
}

canonical_original_code:
struct roloc_rgb hsv_to_rgb(struct roloc_hsv object)
{
  struct roloc_rgb color = {0.0, 0.0, 0.0};
  if(object.saturation == 0) {
    color.red = color.green = color.blue = object.value;
    return color;
  }
  object.hue = object.hue/60;
  int i = floor(object.hue);
  float factorial = object.hue - i;
  float p = object.value * (1 - object.saturation);
  float q = object.value * (1 - object.saturation * factorial);
  float t = object.value * (1 - object.saturation * (1 - factorial));
  switch(i) {
    case 0: color = (struct roloc_rgb) {object.value, t, p}; break;
    case 1: color = (struct roloc_rgb) {q, object.value, p}; break;
    case 2: color = (struct roloc_rgb) {p, object.value, t}; break;
    case 3: color = (struct roloc_rgb) {p, q, object.value}; break;
    case 4: color = (struct roloc_rgb) {t, p, object.value}; break;
    case 5: color = (struct roloc_rgb) {object.value, p, q}; break;
  }
  color.red = color.red*255;
  color.green = color.green*255;
  color.blue = color.blue*255;
  return color;
}

variable_types: struct roloc_hsv { float hue; float saturation; float value; }

variable_types: i int

variable_types: factorial float

variable_types: p float

variable_types: q float

variable_types: t float

return_type: struct roloc_rgb { float red; float green; float blue; }


original_code:
roloc_hsv rgb_to_hsv(float red, float green, float blue)
{
  roloc_hsv computed;
  float minimum = red < green ? fmin(red, blue) : fmin(green, blue);
  float maximum = red > green ? fmax(red, blue) : fmax(green, blue);
  computed.value = maximum;
  float delta = maximum - minimum;
  if(maximum == minimum) {
    computed.hue = 0;
    computed.saturation = 0;
    return computed;
  }
  computed.saturation = delta/maximum;
  float d_red = ((maximum - red)/6 + (delta/2)) / delta;
  float d_green = ((maximum - green)/6 + (delta/2)) / delta;
  float d_blue = ((maximum - blue)/6 + (delta/2)) / delta;
  if(red == maximum) {
    computed.hue = d_blue - d_green;
  } else if(green == maximum) {
    computed.hue = (1.0/3.0) + d_red - d_blue;
  } else if(blue == maximum) {
    computed.hue = (2.0/3.0) + d_green - d_red;
  }
  if(computed.hue < 0) {
    computed.hue = computed.hue + 1;
  }
  if(computed.hue > 1) {
    computed.hue = computed.hue - 1;
  }
  computed.hue = computed.hue * 360;
  return computed;
}

canonical_original_code:
struct roloc_hsv rgb_to_hsv(float red, float green, float blue)
{
  struct roloc_hsv computed;
  float minimum = red < green ? fmin(red, blue) : fmin(green, blue);
  float maximum = red > green ? fmax(red, blue) : fmax(green, blue);
  computed.value = maximum;
  float delta = maximum - minimum;
  if(maximum == minimum) {
    computed.hue = 0;
    computed.saturation = 0;
    return computed;
  }
  computed.saturation = delta/maximum;
  float d_red = ((maximum - red)/6 + (delta/2)) / delta;
  float d_green = ((maximum - green)/6 + (delta/2)) / delta;
  float d_blue = ((maximum - blue)/6 + (delta/2)) / delta;
  if(red == maximum) {
    computed.hue = d_blue - d_green;
  } else if(green == maximum) {
    computed.hue = (1.0/3.0) + d_red - d_blue;
  } else if(blue == maximum) {
    computed.hue = (2.0/3.0) + d_green - d_red;
  }
  if(computed.hue < 0) {
    computed.hue = computed.hue + 1;
  }
  if(computed.hue > 1) {
    computed.hue = computed.hue - 1;
  }
  computed.hue = computed.hue * 360;
  return computed;
}

variable_types: minimum float

variable_types: maximum float

variable_types: delta float

return_type: struct roloc_hsv { float hue; float saturation; float value; }


decompiled_code:
__int64 __fastcall find_arithmetic(char *src)
{
void *v1; // rsp
char *v3; // rdi
int v4; // er12
char *v5; // rax
char *v6; // rbx
unsigned int v7; // er14
__m128i v8; // xmm6
unsigned int v9; // er13
__m128i v10; // xmm7
unsigned int v11; // ebx
const char *v12; // rax
const char *v13; // rsi
const char *v14; // rax
__m128i v15; // xmm5
char v16[4]; // [rsp+0h] [rbp-50h] BYREF
float v17; // [rsp+4h] [rbp-4Ch]
float v18; // [rsp+8h] [rbp-48h]
float v19; // [rsp+Ch] [rbp-44h]
char dest[7]; // [rsp+1Dh] [rbp-33h] BYREF
int v21[11]; // [rsp+24h] [rbp-2Ch] BYREF

v1 = alloca(strlen(src) + 1);
strcpy(v16, src);
if ( !strpbrk(v16, "`~!@#$%^&*()-_=[{]}\\|';:'\",<.>/?") && strchr(v16, 43) )
{
v3 = strtok(v16, "+ ");
if ( v3 )
{
v19 = 0.0;
v4 = 0;
v18 = 0.0;
v17 = 0.0;
do
{
v5 = (char *)find_color(v3, RLC_PATH, 1LL);
v6 = v5;
if ( v5 )
{
v18 = hex_to_rgb((unsigned int)*v5, (unsigned int)v5[1]) + v18;
v17 = hex_to_rgb((unsigned int)v6[2], (unsigned int)v6[3]) + v17;
v19 = hex_to_rgb((unsigned int)v6[4], (unsigned int)v6[5]) + v19;
++v4;
}
v3 = strtok(0LL, "+ ");
}
while ( v3 );
v7 = LC0;
if ( v18 != 0.0 )
{
v8 = (__m128i)LODWORD(v18);
*(float *)v8.m128i_i32 = v18 / (float)v4;
v7 = _mm_cvtsi128_si32(v8);
}
v9 = LC0;
if ( v17 != 0.0 )
{
v10 = (__m128i)LODWORD(v17);
*(float *)v10.m128i_i32 = v17 / (float)v4;
v9 = _mm_cvtsi128_si32(v10);
}
}
else
{
v4 = 0;
v19 = 0.0;
v7 = _mm_cvtsi128_si32((__m128i)0LL);
v9 = v7;
}
v11 = LC0;
if ( v19 != 0.0 )
{
v15 = (__m128i)LODWORD(v19);
*(float *)v15.m128i_i32 = v19 / (float)v4;
v11 = _mm_cvtsi128_si32(v15);
}
dest[0] = 0;
v12 = (const char *)rgb_to_hex(*(double *)_mm_cvtsi32_si128(v7).m128i_i64);
strcat(dest, v12);
v13 = (const char *)rgb_to_hex(*(double *)_mm_cvtsi32_si128(v9).m128i_i64);
strcat(dest, v13);
v14 = (const char *)rgb_to_hex(*(double *)_mm_cvtsi32_si128(v11).m128i_i64);
strcat(dest, v14);
puts(dest);
v21[0] = v7;
v21[1] = v9;
v21[2] = v11;
r_set_last_color(v21, 1LL);
}
return 0LL;
}

original_code:
char *find_arithmetic(char *line)
{
  char linecopy[strlen(line)+1];
  strcpy(linecopy, line);
  char *nosupport = strpbrk(linecopy, "`~!@#$%^&*()-_=[{]}\\|';:'\",<.>/?");
  if(nosupport) {
    return ((void *)0);
  } else if(strpbrk(linecopy, "+")) {
    int count = 0;
    float red = 0.0;
    float green = 0.0;
    float blue = 0.0;
    char *token = strtok(linecopy, "+ ");
    while(token) {
      char *color = find_color(token, RLC_PATH, 1);
      if(color == ((void *)0)) {
        token = strtok(((void *)0), "+ ");
      } else {
        red = red + hex_to_rgb(color[0], color[1]);
        green = green + hex_to_rgb(color[2], color[3]);
        blue = blue + hex_to_rgb(color[4], color[5]);
        count = count+1;
        token = strtok(((void *)0), "+ ");
      }
    }
    red = red ? red/count : 0.0;
    green = green ? green/count : 0.0;
    blue = blue ? blue/count : 0.0;
    char result[7];
    result[0] = '\0';
    strcat(result, rgb_to_hex(red));
    strcat(result, rgb_to_hex(green));
    strcat(result, rgb_to_hex(blue));
    printf("%s\n", result);
    roloc_rgb val;
    val.red = red;
    val.green = green;
    val.blue = blue;
    r_set_last_color(&val, 1);
    return result;
  }
  return ((void *)0);
}

canonical_original_code:
char *find_arithmetic(char *line)
{
  char linecopy[-1];
  strcpy(linecopy, line);
  char *nosupport = strpbrk(linecopy, "`~!@#$%^&*()-_=[{]}\\|';:'\",<.>/?");
  if(nosupport) {
    return ((void *)0);
  } else if(strpbrk(linecopy, "+")) {
    int count = 0;
    float red = 0.0;
    float green = 0.0;
    float blue = 0.0;
    char *token = strtok(linecopy, "+ ");
    while(token) {
      char *color = find_color(token, RLC_PATH, 1);
      if(color == ((void *)0)) {
        token = strtok(((void *)0), "+ ");
      } else {
        red = red + hex_to_rgb(color[0], color[1]);
        green = green + hex_to_rgb(color[2], color[3]);
        blue = blue + hex_to_rgb(color[4], color[5]);
        count = count+1;
        token = strtok(((void *)0), "+ ");
      }
    }
    red = red ? red/count : 0.0;
    green = green ? green/count : 0.0;
    blue = blue ? blue/count : 0.0;
    char result[7];
    result[0] = '\0';
    strcat(result, rgb_to_hex(red));
    strcat(result, rgb_to_hex(green));
    strcat(result, rgb_to_hex(blue));
    printf("%s\n", result);
    struct roloc_rgb val;
    val.red = red;
    val.green = green;
    val.blue = blue;
    r_set_last_color(&val, 1);
    return result;
  }
  return ((void *)0);
}

variable_types:
line
char *

variable_types:
linecopy
char [-1]

variable_types:
nosupport
char *

variable_types: count int

variable_types:
token
char *

variable_types:
color
char *

variable_types:
result
char [7]

user_defined_types: struct roloc_rgb { float red; float green; float blue; }


decompiled_code:
float *__fastcall calculate_gradient(char *a1, char *a2, int a3, __m128i a4)
{
int v6; // ebx
int v7; // er15
float *v8; // rbp
float *v9; // r13
int v10; // er14
float v11; // xmm0_4
const char *v12; // rax
const char *v13; // rsi
const char *v14; // rax
float *v15; // r12
double v16; // xmm4_8
float v17; // xmm0_4
float v18; // xmm2_4
float v19; // xmm1_4
const char *v20; // rax
const char *v21; // rsi
const char *v22; // rax
const char *v23; // rax
const char *v24; // rsi
const char *v25; // rax
float v27; // [rsp+0h] [rbp-68h]
float v28; // [rsp+0h] [rbp-68h]
float v29; // [rsp+Ch] [rbp-5Ch]
char v30[7]; // [rsp+1Bh] [rbp-4Dh] BYREF
char s[7]; // [rsp+22h] [rbp-46h] BYREF
char dest[63]; // [rsp+29h] [rbp-3Fh] BYREF

v6 = a3;
v7 = a3 + 2;
v8 = (float *)malloc(12LL * (a3 + 2));
v27 = hex_to_rgb((unsigned int)*a1, (unsigned int)a1[1]);
v29 = hex_to_rgb((unsigned int)a1[2], (unsigned int)a1[3]);
*(float *)a4.m128i_i32 = hex_to_rgb((unsigned int)a1[4], (unsigned int)a1[5]);
*v8 = v27;
v8[1] = v29;
v8[2] = *(float *)a4.m128i_i32;
v9 = &v8[3 * v7 - 3];
*(float *)a4.m128i_i32 = hex_to_rgb((unsigned int)*a2, (unsigned int)a2[1]);
v10 = _mm_cvtsi128_si32(a4);
v28 = hex_to_rgb((unsigned int)a2[2], (unsigned int)a2[3]);
v11 = hex_to_rgb((unsigned int)a2[4], (unsigned int)a2[5]);
*(_DWORD *)v9 = v10;
v9[1] = v28;
v9[2] = v11;
dest[0] = 0;
v12 = (const char *)rgb_to_hex(*v8);
strcat(dest, v12);
v13 = (const char *)rgb_to_hex(v8[1]);
strcat(dest, v13);
v14 = (const char *)rgb_to_hex(v8[2]);
strcat(dest, v14);
printf("%s ", dest);
if ( v6 > 0 )
{
v15 = v8 + 3;
do
{
v16 = (double)v6 * (100.0 / (double)v7 / 100.0);
v17 = *v9 * (1.0 - v16) + *v8 * v16;
*v15 = v17;
v18 = v9[1] * (1.0 - v16) + v8[1] * v16;
v15[1] = v18;
v19 = v8[2] * v16 + v9[2] * (1.0 - v16);
v15[2] = v19;
v30[0] = 0;
v20 = (const char *)rgb_to_hex(v17);
strcat(v30, v20);
v21 = (const char *)rgb_to_hex(v15[1]);
strcat(v30, v21);
v22 = (const char *)rgb_to_hex(v15[2]);
strcat(v30, v22);
printf("%s ", v30);
v15 += 3;
--v6;
}
while ( v6 );
}
s[0] = 0;
v23 = (const char *)rgb_to_hex(*v9);
strcat(s, v23);
v24 = (const char *)rgb_to_hex(v9[1]);
strcat(s, v24);
v25 = (const char *)rgb_to_hex(v9[2]);
strcat(s, v25);
puts(s);
return v8;
}

canonical_decompiled_code:
float *__fastcall func0(char *a1, char *a2, int a3, __m128i a4)
{
int v6; // ebx
int v7; // er15
float *v8; // rbp
float *v9; // r13
int v10; // er14
float v11; // xmm0_4
const char *v12; // rax
const char *v13; // rsi
const char *v14; // rax
float *v15; // r12
double v16; // xmm4_8
float v17; // xmm0_4
float v18; // xmm2_4
float v19; // xmm1_4
const char *v20; // rax
const char *v21; // rsi
const char *v22; // rax
const char *v23; // rax
const char *v24; // rsi
const char *v25; // rax
float v27; // [rsp+0h] [rbp-68h]
float v28; // [rsp+0h] [rbp-68h]
float v29; // [rsp+Ch] [rbp-5Ch]
char v30[7]; // [rsp+1Bh] [rbp-4Dh] BYREF
char s[7]; // [rsp+22h] [rbp-46h] BYREF
char dest[63]; // [rsp+29h] [rbp-3Fh] BYREF

v6 = a3;
v7 = a3 + 2;
v8 = (float *)malloc(12LL * (a3 + 2));
v27 = hex_to_rgb((unsigned int)*a1, (unsigned int)a1[1]);
v29 = hex_to_rgb((unsigned int)a1[2], (unsigned int)a1[3]);
*(float *)a4.m128i_i32 = hex_to_rgb((unsigned int)a1[4], (unsigned int)a1[5]);
*v8 = v27;
v8[1] = v29;
v8[2] = *(float *)a4.m128i_i32;
v9 = &v8[3 * v7 - 3];
*(float *)a4.m128i_i32 = hex_to_rgb((unsigned int)*a2, (unsigned int)a2[1]);
v10 = _mm_cvtsi128_si32(a4);
v28 = hex_to_rgb((unsigned int)a2[2], (unsigned int)a2[3]);
v11 = hex_to_rgb((unsigned int)a2[4], (unsigned int)a2[5]);
*(_DWORD *)v9 = v10;
v9[1] = v28;
v9[2] = v11;
dest[0] = 0;
v12 = (const char *)rgb_to_hex(*v8);
strcat(dest, v12);
v13 = (const char *)rgb_to_hex(v8[1]);
strcat(dest, v13);
v14 = (const char *)rgb_to_hex(v8[2]);
strcat(dest, v14);
printf("%s ", dest);
if ( v6 > 0 )
{
v15 = v8 + 3;
do
{
v16 = (double)v6 * (100.0 / (double)v7 / 100.0);
v17 = *v9 * (1.0 - v16) + *v8 * v16;
*v15 = v17;
v18 = v9[1] * (1.0 - v16) + v8[1] * v16;
v15[1] = v18;
v19 = v8[2] * v16 + v9[2] * (1.0 - v16);
v15[2] = v19;
v30[0] = 0;
v20 = (const char *)rgb_to_hex(v17);
strcat(v30, v20);
v21 = (const char *)rgb_to_hex(v15[1]);
strcat(v30, v21);
v22 = (const char *)rgb_to_hex(v15[2]);
strcat(v30, v22);
printf("%s ", v30);
v15 += 3;
--v6;
}
while ( v6 );
}
s[0] = 0;
v23 = (const char *)rgb_to_hex(*v9);
strcat(s, v23);
v24 = (const char *)rgb_to_hex(v9[1]);
strcat(s, v24);
v25 = (const char *)rgb_to_hex(v9[2]);
strcat(s, v25);
puts(s);
return v8;
}

original_code:
roloc_rgb *calculate_gradient(char *color1, char *color2, int amount)
{
  int listsize = amount+2;
  roloc_rgb *store = malloc(sizeof(roloc_rgb)*listsize);
  store[0] = (roloc_rgb) {
    hex_to_rgb(color1[0], color1[1]),
    hex_to_rgb(color1[2], color1[3]),
    hex_to_rgb(color1[4], color1[5])
  };
  store[listsize-1] = (roloc_rgb) {
    hex_to_rgb(color2[0], color2[1]),
    hex_to_rgb(color2[2], color2[3]),
    hex_to_rgb(color2[4], color2[5])
  };
  double full = 100.0;
  double divide = ((full/listsize) / 100);
  char firstvalue[7];
  firstvalue[0] = '\0';
  strcat(firstvalue, rgb_to_hex(store[0].red));
  strcat(firstvalue, rgb_to_hex(store[0].green));
  strcat(firstvalue, rgb_to_hex(store[0].blue));
  printf("%s ", firstvalue);
  int pos = 1;
  int itr;
  for(itr = amount; itr > 0; itr--) {
    store[pos].red = (store[0].red * (divide*(itr)) )
                   + (store[listsize-1].red *(1 - (divide*(itr))));
    store[pos].green = (store[0].green * (divide*(itr)) )
                     + (store[listsize-1].green *(1 - (divide*(itr))));
    store[pos].blue = (store[0].blue * (divide*(itr)) )
                    + (store[listsize-1].blue *(1 - (divide*(itr))));
    char value[7];
    value[0] = '\0';
    strcat(value, rgb_to_hex(store[pos].red));
    strcat(value, rgb_to_hex(store[pos].green));
    strcat(value, rgb_to_hex(store[pos].blue));
    printf("%s ", value);
    pos = pos+1;
  }
  char lastvalue[7];
  lastvalue[0] = '\0';
  strcat(lastvalue, rgb_to_hex(store[listsize-1].red));
  strcat(lastvalue, rgb_to_hex(store[listsize-1].green));
  strcat(lastvalue, rgb_to_hex(store[listsize-1].blue));
  printf("%s\n", lastvalue);
  return store;
}

canonical_original_code:
struct roloc_rgb *calculate_gradient(char *color1, char *color2, int amount)
{
  int listsize = amount+2;
  struct roloc_rgb *store = malloc(sizeof(roloc_rgb)*listsize);
  store[0] = (struct roloc_rgb) {
    hex_to_rgb(color1[0], color1[1]),
    hex_to_rgb(color1[2], color1[3]),
    hex_to_rgb(color1[4], color1[5])
  };
  store[listsize-1] = (struct roloc_rgb) {
    hex_to_rgb(color2[0], color2[1]),
    hex_to_rgb(color2[2], color2[3]),
    hex_to_rgb(color2[4], color2[5])
  };
  double full = 100.0;
  double divide = ((full/listsize) / 100);
  char firstvalue[7];
  firstvalue[0] = '\0';
  strcat(firstvalue, rgb_to_hex(store[0].red));
  strcat(firstvalue, rgb_to_hex(store[0].green));
  strcat(firstvalue, rgb_to_hex(store[0].blue));
  printf("%s ", firstvalue);
  int pos = 1;
  int itr;
  for(itr = amount; itr > 0; itr--) {
    store[pos].red = (store[0].red * (divide*(itr)) )
                   + (store[listsize-1].red *(1 - (divide*(itr))));
    store[pos].green = (store[0].green * (divide*(itr)) )
                     + (store[listsize-1].green *(1 - (divide*(itr))));
    store[pos].blue = (store[0].blue * (divide*(itr)) )
                    + (store[listsize-1].blue *(1 - (divide*(itr))));
    char value[7];
    value[0] = '\0';
    strcat(value, rgb_to_hex(store[pos].red));
    strcat(value, rgb_to_hex(store[pos].green));
    strcat(value, rgb_to_hex(store[pos].blue));
    printf("%s ", value);
    pos = pos+1;
  }
  char lastvalue[7];
  lastvalue[0] = '\0';
  strcat(lastvalue, rgb_to_hex(store[listsize-1].red));
  strcat(lastvalue, rgb_to_hex(store[listsize-1].green));
  strcat(lastvalue, rgb_to_hex(store[listsize-1].blue));
  printf("%s\n", lastvalue);
  return store;
}

variable_types: amount int

variable_types: listsize int

variable_types: struct roloc_rgb { float red; float green; float blue; } *

variable_types: full double

variable_types: divide double

variable_types:
firstvalue
char [7]

variable_types: pos int

variable_types: itr int

variable_types:
value
char [7]

variable_types:
lastvalue
char [7]


decompiled_code:
__m128i __fastcall calculate_complement(char *a1, double a2)
{
float v3; // xmm0_4
float v5; // [rsp+8h] [rbp-40h]
float v6; // [rsp+Ch] [rbp-3Ch]
double v7; // [rsp+28h] [rbp-20h]
__m128i v8; // [rsp+34h] [rbp-14h] BYREF

v5 = hex_to_rgb((unsigned int)*a1, (unsigned int)a1[1]);
v6 = hex_to_rgb((unsigned int)a1[2], (unsigned int)a1[3]);
*(float *)&a2 = hex_to_rgb((unsigned int)a1[4], (unsigned int)a1[5]);
v7 = rgb_to_hsv(v5, v6, a2);
v3 = *(float *)&v7 + 180.0;
if ( (float)(*(float *)&v7 + 180.0) > 360.0 )
v3 = v3 - 360.0;
v8.m128i_i64[0] = __PAIR64__(HIDWORD(v7), LODWORD(v3));
return _mm_loadl_epi64(&v8);
}

canonical_decompiled_code:
__m128i __fastcall func1(char *a1, double a2)
{
float v3; // xmm0_4
float v5; // [rsp+8h] [rbp-40h]
float v6; // [rsp+Ch] [rbp-3Ch]
double v7; // [rsp+28h] [rbp-20h]
__m128i v8; // [rsp+34h] [rbp-14h] BYREF

v5 = hex_to_rgb((unsigned int)*a1, (unsigned int)a1[1]);
v6 = hex_to_rgb((unsigned int)a1[2], (unsigned int)a1[3]);
*(float *)&a2 = hex_to_rgb((unsigned int)a1[4], (unsigned int)a1[5]);
v7 = rgb_to_hsv(v5, v6, a2);
v3 = *(float *)&v7 + 180.0;
if ( (float)(*(float *)&v7 + 180.0) > 360.0 )
v3 = v3 - 360.0;
v8.m128i_i64[0] = __PAIR64__(HIDWORD(v7), LODWORD(v3));
return _mm_loadl_epi64(&v8);
}

original_code:
roloc_hsv calculate_complement(char *keycolor)
{
  float r = hex_to_rgb(keycolor[0], keycolor[1]);
  float g = hex_to_rgb(keycolor[2], keycolor[3]);
  float b = hex_to_rgb(keycolor[4], keycolor[5]);
  roloc_hsv key_color = rgb_to_hsv(r, g, b);
  roloc_hsv complementary_color = {
    key_color.hue+180 > 360 ? key_color.hue+180-360 : key_color.hue+180,
    key_color.saturation,
    key_color.value
  };
  return complementary_color;
}

canonical_original_code:
struct roloc_hsv calculate_complement(char *keycolor)
{
  float r = hex_to_rgb(keycolor[0], keycolor[1]);
  float g = hex_to_rgb(keycolor[2], keycolor[3]);
  float b = hex_to_rgb(keycolor[4], keycolor[5]);
  struct roloc_hsv key_color = rgb_to_hsv(r, g, b);
  struct roloc_hsv complementary_color = {
    key_color.hue+180 > 360 ? key_color.hue+180-360 : key_color.hue+180,
    key_color.saturation,
    key_color.value
  };
  return complementary_color;
}

variable_types:
keycolor
char *

variable_types: r float

variable_types: g float

variable_types: b float

variable_types: struct roloc_hsv { float hue; float saturation; float value; }


decompiled_code:
__m128i __fastcall calculate_splitcomplement(char *a1, int a2, int a3, double a4)
{
double v6; // xmm0_8
float v8; // [rsp+8h] [rbp-50h]
float v9; // [rsp+Ch] [rbp-4Ch]
__m128i v10[2]; // [rsp+34h] [rbp-24h] BYREF

v8 = hex_to_rgb((unsigned int)*a1, (unsigned int)a1[1]);
v9 = hex_to_rgb((unsigned int)a1[2], (unsigned int)a1[3]);
*(float *)&a4 = hex_to_rgb((unsigned int)a1[4], (unsigned int)a1[5]);
v6 = rgb_to_hsv(v8, v9, a4);
if ( a3 )
{
*(float *)&v6 = *(float *)&v6 + (float)a2;
if ( *(float *)&v6 > 360.0 )
*(float *)&v6 = *(float *)&v6 - 360.0;
}
else
{
*(float *)&v6 = *(float *)&v6 - (float)a2;
if ( *(float *)&v6 < 0.0 )
*(float *)&v6 = *(float *)&v6 + 360.0;
}
*(double *)v10[0].m128i_i64 = v6;
return _mm_loadl_epi64(v10);
}

canonical_decompiled_code:
__m128i __fastcall func2(char *a1, int a2, int a3, double a4)
{
double v6; // xmm0_8
float v8; // [rsp+8h] [rbp-50h]
float v9; // [rsp+Ch] [rbp-4Ch]
__m128i v10[2]; // [rsp+34h] [rbp-24h] BYREF

v8 = hex_to_rgb((unsigned int)*a1, (unsigned int)a1[1]);
v9 = hex_to_rgb((unsigned int)a1[2], (unsigned int)a1[3]);
*(float *)&a4 = hex_to_rgb((unsigned int)a1[4], (unsigned int)a1[5]);
v6 = rgb_to_hsv(v8, v9, a4);
if ( a3 )
{
*(float *)&v6 = *(float *)&v6 + (float)a2;
if ( *(float *)&v6 > 360.0 )
*(float *)&v6 = *(float *)&v6 - 360.0;
}
else
{
*(float *)&v6 = *(float *)&v6 - (float)a2;
if ( *(float *)&v6 < 0.0 )
*(float *)&v6 = *(float *)&v6 + 360.0;
}
*(double *)v10[0].m128i_i64 = v6;
return _mm_loadl_epi64(v10);
}

original_code:
roloc_hsv calculate_splitcomplement(char *keycolor, int offset, int dirn)
{
  float r = hex_to_rgb(keycolor[0], keycolor[1]);
  float g = hex_to_rgb(keycolor[2], keycolor[3]);
  float b = hex_to_rgb(keycolor[4], keycolor[5]);
  roloc_hsv key_color = rgb_to_hsv(r, g, b);
  roloc_hsv split_color;
  if(dirn) {
    split_color = (roloc_hsv) {
      key_color.hue+offset > 360 ? key_color.hue+offset-360 :
                                   key_color.hue+offset,
      key_color.saturation,
      key_color.value
    };
  } else {
    split_color = (roloc_hsv) {
      key_color.hue-offset < 0 ? key_color.hue-offset+360 :
                                 key_color.hue-offset,
      key_color.saturation,
      key_color.value
    };
  }
  return split_color;
}

canonical_original_code:
struct roloc_hsv calculate_splitcomplement(char *keycolor, int offset, int dirn)
{
  float r = hex_to_rgb(keycolor[0], keycolor[1]);
  float g = hex_to_rgb(keycolor[2], keycolor[3]);
  float b = hex_to_rgb(keycolor[4], keycolor[5]);
  struct roloc_hsv key_color = rgb_to_hsv(r, g, b);
  struct roloc_hsv split_color;
  if(dirn) {
    split_color = (struct roloc_hsv) {
      key_color.hue+offset > 360 ? key_color.hue+offset-360 :
                                   key_color.hue+offset,
      key_color.saturation,
      key_color.value
    };
  } else {
    split_color = (struct roloc_hsv) {
      key_color.hue-offset < 0 ? key_color.hue-offset+360 :
                                 key_color.hue-offset,
      key_color.saturation,
      key_color.value
    };
  }
  return split_color;
}

variable_types: offset int

variable_types: dirn int

user_defined_types: struct roloc_hsv { float hue; float saturation; float value; }


decompiled_code:
__int64 X509_TRUST_get_count()
{
__int64 result; // rax

if ( trtable )
result = (unsigned int)sk_num(trtable) + 8;
else
result = 8LL;
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax

if ( trtable )
result = (unsigned int)sk_num(trtable) + 8;
else
result = 8LL;
return result;
}

original_code:
int X509_TRUST_get_count(void)
{
    if (!trtable)
        return X509_TRUST_COUNT;
    return sk_X509_TRUST_num(trtable) + X509_TRUST_COUNT;
}

canonical_original_code:
int X509_TRUST_get_count()
{
    if (!trtable)
        return X509_TRUST_COUNT;
    return sk_X509_TRUST_num(trtable) + X509_TRUST_COUNT;
}

return_type: int


decompiled_code:
__int64 __fastcall X509_TRUST_set(int *a1, int a2)
{
__int64 result; // rax

if ( (unsigned int)X509_TRUST_get_by_id(a2) == -1 )
{
ERR_put_error(11LL, 141LL, 123LL, "x509_trs.c", 163LL);
result = 0LL;
}
else
{
*a1 = a2;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int *a1, int a2)
{
__int64 result; // rax

if ( (unsigned int)func8(a2) == -1 )
{
ERR_put_error(11LL, 141LL, 123LL, "x509_trs.c", 163LL);
result = 0LL;
}
else
{
*a1 = a2;
result = 1LL;
}
return result;
}

original_code:
int X509_TRUST_set(int *t, int trust)
{
    if (X509_TRUST_get_by_id(trust) == -1) {
        X509err(X509_F_X509_TRUST_SET, X509_R_INVALID_TRUST);
        return 0;
    }
    *t = trust;
    return 1;
}

variable_types:
t
int *

variable_types: trust int


decompiled_code:
__int64 X509_TRUST_cleanup()
{
char *v0; // rbx
__int64 result; // rax

v0 = (char *)&trstandard;
do
{
trtable_free((__int64)v0);
v0 += 40;
}
while ( v0 != (char *)&default_trust );
result = sk_pop_free(trtable, trtable_free);
trtable = 0LL;
return result;
}

canonical_decompiled_code:
__int64 func12()
{
char *v0; // rbx
__int64 result; // rax

v0 = (char *)&trstandard;
do
{
func5((__int64)v0);
v0 += 40;
}
while ( v0 != (char *)&default_trust );
result = sk_pop_free(trtable, trtable_free);
trtable = 0LL;
return result;
}

original_code:
void X509_TRUST_cleanup(void)
{
    unsigned int i;
    for (i = 0; i < X509_TRUST_COUNT; i++)
        trtable_free(trstandard + i);
    sk_X509_TRUST_pop_free(trtable, trtable_free);
    trtable = NULL;
}

canonical_original_code:
void X509_TRUST_cleanup()
{
    unsigned int i;
    for (i = 0; i < X509_TRUST_COUNT; i++)
        trtable_free(trstandard + i);
    sk_X509_TRUST_pop_free(trtable, trtable_free);
    trtable = NULL;
}

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall in_utf8(__int64 a1, _DWORD *a2)
{
++*a2;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _DWORD *a2)
{
++*a2;
return 1LL;
}

original_code:
static int in_utf8(unsigned long value, void *arg)
{
    int *nchar;
    nchar = arg;
    (*nchar)++;
    return 1;
}

variable_types:
value
unsigned long

variable_types:
arg
void *

variable_types:
nchar
int *


decompiled_code:
__int64 __fastcall cpy_asc(char a1, _QWORD *a2)
{
*(_BYTE *)(*a2)++ = a1;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1, _QWORD *a2)
{
*(_BYTE *)(*a2)++ = a1;
return 1LL;
}

original_code:
static int cpy_asc(unsigned long value, void *arg)
{
    unsigned char **p, *q;
    p = arg;
    q = *p;
    *q = (unsigned char)value;
    (*p)++;
    return 1;
}

canonical_original_code:
static int cpy_asc(unsigned long value, void *arg)
{
    unsigned char **p; unsigned char *q;
    p = arg;
    q = *p;
    *q = (unsigned char)value;
    (*p)++;
    return 1;
}

variable_types:
p
unsigned char **

variable_types:
q
unsigned char *


decompiled_code:
__int64 __fastcall cpy_bmp(__int16 a1, _BYTE **a2)
{
_BYTE *v2; // rax

v2 = *a2;
*v2 = HIBYTE(a1);
v2[1] = a1;
*a2 += 2;
return 1LL;
}

original_code:
static int cpy_bmp(unsigned long value, void *arg)
{
    unsigned char **p, *q;
    p = arg;
    q = *p;
    *q++ = (unsigned char)((value >> 8) & 0xff);
    *q = (unsigned char)(value & 0xff);
    *p += 2;
    return 1;
}

canonical_original_code:
static int cpy_bmp(unsigned long value, void *arg)
{
    unsigned char **p; unsigned char *q;
    p = arg;
    q = *p;
    *q++ = (unsigned char)((value >> 8) & 0xff);
    *q = (unsigned char)(value & 0xff);
    *p += 2;
    return 1;
}


original_code:
static int cpy_univ(unsigned long value, void *arg)
{
    unsigned char **p, *q;
    p = arg;
    q = *p;
    *q++ = (unsigned char)((value >> 24) & 0xff);
    *q++ = (unsigned char)((value >> 16) & 0xff);
    *q++ = (unsigned char)((value >> 8) & 0xff);
    *q = (unsigned char)(value & 0xff);
    *p += 4;
    return 1;
}

canonical_original_code:
static int cpy_univ(unsigned long value, void *arg)
{
    unsigned char **p; unsigned char *q;
    p = arg;
    q = *p;
    *q++ = (unsigned char)((value >> 24) & 0xff);
    *q++ = (unsigned char)((value >> 16) & 0xff);
    *q++ = (unsigned char)((value >> 8) & 0xff);
    *q = (unsigned char)(value & 0xff);
    *p += 4;
    return 1;
}


decompiled_code:
__int64 __fastcall cpy_utf8(__int64 a1, _QWORD *a2)
{
*a2 += (int)UTF8_putc(*a2, 255LL, a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _QWORD *a2)
{
*a2 += (int)UTF8_putc(*a2, 255LL, a1);
return 1LL;
}

original_code:
static int cpy_utf8(unsigned long value, void *arg)
{
    unsigned char **p;
    int ret;
    p = arg;
    /* We already know there is enough room so pass 0xff as the length */
    ret = UTF8_putc(*p, 0xff, value);
    *p += ret;
    return 1;
}

variable_types: ret int


decompiled_code:
__int64 __fastcall out_utf8(__int64 a1, _DWORD *a2)
{
*a2 += UTF8_putc(0LL, 0xFFFFFFFFLL, a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _DWORD *a2)
{
*a2 += UTF8_putc(0LL, 0xFFFFFFFFLL, a1);
return 1LL;
}

original_code:
static int out_utf8(unsigned long value, void *arg)
{
    int *outlen;
    outlen = arg;
    *outlen += UTF8_putc(NULL, -1, value);
    return 1;
}

variable_types:
outlen
int *


decompiled_code:
_BOOL8 __fastcall is_printable(unsigned __int64 c)
{
_BOOL8 result; // rax

result = 0LL;
if ( c <= 0x7F )
{
result = 1LL;
if ( (c & 0xFFFFFFDF) - 65 > 0x19 && (unsigned int)(c - 48) > 9 && (_DWORD)c != 32 )
result = strchr("'()+,-./:=?", c) != 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(unsigned __int64 c)
{
_BOOL8 result; // rax

result = 0LL;
if ( c <= 0x7F )
{
result = 1LL;
if ( (c & 0xFFFFFFDF) - 65 > 0x19 && (unsigned int)(c - 48) > 9 && (_DWORD)c != 32 )
result = strchr("'()+,-./:=?", c) != 0LL;
}
return result;
}

original_code:
static int is_printable(unsigned long value)
{
    int ch;
    if (value > 0x7f)
        return 0;
    ch = (int)value;
    /*
     * Note: we can't use 'isalnum' because certain accented characters may
     * count as alphanumeric in some environments.
     */
#ifndef CHARSET_EBCDIC
    if ((ch >= 'a') && (ch <= 'z'))
        return 1;
    if ((ch >= 'A') && (ch <= 'Z'))
        return 1;
    if ((ch >= '0') && (ch <= '9'))
        return 1;
    if ((ch == ' ') || strchr("'()+,-./:=?", ch))
        return 1;
#else                           /* CHARSET_EBCDIC */
    if ((ch >= os_toascii['a']) && (ch <= os_toascii['z']))
        return 1;
    if ((ch >= os_toascii['A']) && (ch <= os_toascii['Z']))
        return 1;
    if ((ch >= os_toascii['0']) && (ch <= os_toascii['9']))
        return 1;
    if ((ch == os_toascii[' ']) || strchr("'()+,-./:=?", os_toebcdic[ch]))
        return 1;
#endif                          /* CHARSET_EBCDIC */
    return 0;
}

variable_types: ch int


decompiled_code:
__int64 __fastcall type_str(unsigned __int64 a1, __int64 *a2)
{
__int64 v2; // rbx
__int64 v3; // rax
__int64 result; // rax

v2 = *a2;
if ( (*a2 & 2) != 0 && !is_printable(a1) )
v2 &= 0xFFFFFFFFFFFFFFFDLL;
if ( (v2 & 0x10) != 0 && a1 > 0x7F )
v2 &= 0xFFFFFFFFFFFFFFEFLL;
if ( (v2 & 4) != 0 && a1 > 0xFF )
v2 &= 0xFFFFFFFFFFFFFFFBLL;
if ( (v2 & 0x800) != 0 )
{
v3 = v2;
if ( a1 > 0xFFFF )
{
BYTE1(v3) = BYTE1(v2) & 0xF7;
v2 = v3;
}
}
result = 0xFFFFFFFFLL;
if ( v2 )
{
*a2 = v2;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int64 a1, __int64 *a2)
{
__int64 v2; // rbx
__int64 v3; // rax
__int64 result; // rax

v2 = *a2;
if ( (*a2 & 2) != 0 && !func6(a1) )
v2 &= 0xFFFFFFFFFFFFFFFDLL;
if ( (v2 & 0x10) != 0 && a1 > 0x7F )
v2 &= 0xFFFFFFFFFFFFFFEFLL;
if ( (v2 & 4) != 0 && a1 > 0xFF )
v2 &= 0xFFFFFFFFFFFFFFFBLL;
if ( (v2 & 0x800) != 0 )
{
v3 = v2;
if ( a1 > 0xFFFF )
{
BYTE1(v3) = BYTE1(v2) & 0xF7;
v2 = v3;
}
}
result = 0xFFFFFFFFLL;
if ( v2 )
{
*a2 = v2;
result = 1LL;
}
return result;
}

original_code:
static int type_str(unsigned long value, void *arg)
{
    unsigned long types;
    types = *((unsigned long *)arg);
    if ((types & B_ASN1_PRINTABLESTRING) && !is_printable(value))
        types &= ~B_ASN1_PRINTABLESTRING;
    if ((types & B_ASN1_IA5STRING) && (value > 127))
        types &= ~B_ASN1_IA5STRING;
    if ((types & B_ASN1_T61STRING) && (value > 0xff))
        types &= ~B_ASN1_T61STRING;
    if ((types & B_ASN1_BMPSTRING) && (value > 0xffff))
        types &= ~B_ASN1_BMPSTRING;
    if (!types)
        return -1;
    *((unsigned long *)arg) = types;
    return 1;
}

variable_types:
types
unsigned long


decompiled_code:
__int64 __fastcall traverse_string(unsigned __int8 *a1, unsigned int a2, int a3, __int64 (__fastcall *a4)(unsigned __int64, __int64), __int64 a5)
{
unsigned int v6; // ebp
__int64 result; // rax
int v11; // eax
unsigned __int64 v12[6]; // [rsp+8h] [rbp-30h] BYREF

v6 = a2;
if ( !a2 )
return 1LL;
while ( 1 )
{
switch ( a3 )
{
case 4097:
v12[0] = *a1;
--v6;
++a1;
goto LABEL_4;
case 4098:
v12[0] = a1[1] | (unsigned __int64)(*a1 << 8);
v6 -= 2;
a1 += 2;
goto LABEL_4;
case 4100:
v12[0] = (a1[2] << 8) | a1[3] | ((unsigned __int64)a1[1] << 16) | ((unsigned __int64)*a1 << 24);
v6 -= 4;
a1 += 4;
goto LABEL_4;
}
v11 = UTF8_getc(a1, v6, v12);
if ( v11 < 0 )
return 0xFFFFFFFFLL;
v6 -= v11;
a1 += v11;
LABEL_4:
if ( a4 )
{
result = a4(v12[0], a5);
if ( (int)result <= 0 )
return result;
}
if ( !v6 )
return 1LL;
}
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int8 *a1, unsigned int a2, int a3, __int64 (__fastcall *a4)(unsigned __int64, __int64), __int64 a5)
{
unsigned int v6; // ebp
__int64 result; // rax
int v11; // eax
unsigned __int64 v12[6]; // [rsp+8h] [rbp-30h] BYREF

v6 = a2;
if ( !a2 )
return 1LL;
while ( 1 )
{
switch ( a3 )
{
case 4097:
v12[0] = *a1;
--v6;
++a1;
goto LABEL_4;
case 4098:
v12[0] = a1[1] | (unsigned __int64)(*a1 << 8);
v6 -= 2;
a1 += 2;
goto LABEL_4;
case 4100:
v12[0] = (a1[2] << 8) | a1[3] | ((unsigned __int64)a1[1] << 16) | ((unsigned __int64)*a1 << 24);
v6 -= 4;
a1 += 4;
goto LABEL_4;
}
v11 = UTF8_getc(a1, v6, v12);
if ( v11 < 0 )
return 0xFFFFFFFFLL;
v6 -= v11;
a1 += v11;
LABEL_4:
if ( a4 )
{
result = a4(v12[0], a5);
if ( (int)result <= 0 )
return result;
}
if ( !v6 )
return 1LL;
}
}

original_code:
static int traverse_string(const unsigned char *p, int len, int inform,
                           int (*rfunc) (unsigned long value, void *in),
                           void *arg)
{
    unsigned long value;
    int ret;
    while (len) {
        if (inform == MBSTRING_ASC) {
            value = *p++;
            len--;
        } else if (inform == MBSTRING_BMP) {
            value = *p++ << 8;
            value |= *p++;
            len -= 2;
        } else if (inform == MBSTRING_UNIV) {
            value = ((unsigned long)*p++) << 24;
            value |= ((unsigned long)*p++) << 16;
            value |= *p++ << 8;
            value |= *p++;
            len -= 4;
        } else {
            ret = UTF8_getc(p, len, &value);
            if (ret < 0)
                return -1;
            len -= ret;
            p += ret;
        }
        if (rfunc) {
            ret = rfunc(value, arg);
            if (ret <= 0)
                return ret;
        }
    }
    return 1;
}

canonical_original_code:
static int traverse_string(unsigned char *p, int len, int inform, int (*rfunc)(unsigned long value, void *in), void *arg)
{
    unsigned long value;
    int ret;
    while (len) {
        if (inform == MBSTRING_ASC) {
            value = *p++;
            len--;
        } else if (inform == MBSTRING_BMP) {
            value = *p++ << 8;
            value |= *p++;
            len -= 2;
        } else if (inform == MBSTRING_UNIV) {
            value = ((unsigned long)*p++) << 24;
            value |= ((unsigned long)*p++) << 16;
            value |= *p++ << 8;
            value |= *p++;
            len -= 4;
        } else {
            ret = UTF8_getc(p, len, &value);
            if (ret < 0)
                return -1;
            len -= ret;
            p += ret;
        }
        if (rfunc) {
            ret = rfunc(value, arg);
            if (ret <= 0)
                return ret;
        }
    }
    return 1;
}

variable_types:
p
unsigned char *

variable_types: len int

variable_types: inform int

variable_types:
rfunc
int (*)(unsigned long value, void *in)


decompiled_code:
__int64 ERR_load_BUF_strings()
{
__int64 result; // rax

result = ERR_func_error_string(BUF_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &BUF_str_functs);
result = ERR_load_strings(0LL, &BUF_str_reasons);
}
return result;
}

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

result = ERR_func_error_string(BUF_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &BUF_str_functs);
result = ERR_load_strings(0LL, &BUF_str_reasons);
}
return result;
}

original_code:
void ERR_load_BUF_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) {
        ERR_load_strings(0, BUF_str_functs);
        ERR_load_strings(0, BUF_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_BUF_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(BUF_str_functs[0].error) == NULL) {
        ERR_load_strings(0, BUF_str_functs);
        ERR_load_strings(0, BUF_str_reasons);
    }
#endif
}


original_code:
unsigned char *OPENSSL_asc2uni(const char *asc, int asclen,
                               unsigned char **uni, int *unilen)
{
    int ulen, i;
    unsigned char *unitmp;
    if (asclen == -1)
        asclen = strlen(asc);
    ulen = asclen * 2 + 2;
    if (!(unitmp = OPENSSL_malloc(ulen)))
        return NULL;
    for (i = 0; i < ulen - 2; i += 2) {
        unitmp[i] = 0;
        unitmp[i + 1] = asc[i >> 1];
    }
    /* Make result double null terminated */
    unitmp[ulen - 2] = 0;
    unitmp[ulen - 1] = 0;
    if (unilen)
        *unilen = ulen;
    if (uni)
        *uni = unitmp;
    return unitmp;
}

canonical_original_code:
unsigned char *OPENSSL_asc2uni(char *asc, int asclen, unsigned char **uni, int *unilen)
{
    int ulen; int i;
    unsigned char *unitmp;
    if (asclen == -1)
        asclen = strlen(asc);
    ulen = asclen * 2 + 2;
    if (!(unitmp = OPENSSL_malloc(ulen)))
        return NULL;
    for (i = 0; i < ulen - 2; i += 2) {
        unitmp[i] = 0;
        unitmp[i + 1] = asc[i >> 1];
    }
    /* Make result double null terminated */
    unitmp[ulen - 2] = 0;
    unitmp[ulen - 1] = 0;
    if (unilen)
        *unilen = ulen;
    if (uni)
        *uni = unitmp;
    return unitmp;
}

variable_types:
asc
char *

variable_types: asclen int

variable_types:
uni
unsigned char **

variable_types:
unilen
int *

variable_types: ulen int

variable_types: i int

variable_types:
unitmp
unsigned char *

return_type: unsigned char *


original_code:
char *OPENSSL_uni2asc(unsigned char *uni, int unilen)
{
    int asclen, i;
    char *asctmp;
    asclen = unilen / 2;
    /* If no terminating zero allow for one */
    if (!unilen || uni[unilen - 1])
        asclen++;
    uni++;
    if (!(asctmp = OPENSSL_malloc(asclen)))
        return NULL;
    for (i = 0; i < unilen; i += 2)
        asctmp[i >> 1] = uni[i];
    asctmp[asclen - 1] = 0;
    return asctmp;
}

canonical_original_code:
char *OPENSSL_uni2asc(unsigned char *uni, int unilen)
{
    int asclen; int i;
    char *asctmp;
    asclen = unilen / 2;
    /* If no terminating zero allow for one */
    if (!unilen || uni[unilen - 1])
        asclen++;
    uni++;
    if (!(asctmp = OPENSSL_malloc(asclen)))
        return NULL;
    for (i = 0; i < unilen; i += 2)
        asctmp[i >> 1] = uni[i];
    asctmp[asclen - 1] = 0;
    return asctmp;
}

variable_types:
uni
unsigned char *

variable_types: unilen int

variable_types:
asctmp
char *


keyDiversifyCryptoPro

original_code:
void keyDiversifyCryptoPro(gost_ctx * ctx, const unsigned char *inputKey,
                           const unsigned char *ukm, unsigned char *outputKey)
{
    u4 k, s1, s2;
    int i, j, mask;
    unsigned char S[8];
    memcpy(outputKey, inputKey, 32);
    for (i = 0; i < 8; i++) {
        s1 = 0, s2 = 0;
        for (j = 0, mask = 1; j < 8; j++, mask <<= 1) {
            k = ((u4) outputKey[4 * j]) | (outputKey[4 * j + 1] << 8) |
                (outputKey[4 * j + 2] << 16) | (outputKey[4 * j + 3] << 24);
            if (mask & ukm[i]) {
                s1 += k;
            } else {
                s2 += k;
            }
        }
        S[0] = (unsigned char)(s1 & 0xff);
        S[1] = (unsigned char)((s1 >> 8) & 0xff);
        S[2] = (unsigned char)((s1 >> 16) & 0xff);
        S[3] = (unsigned char)((s1 >> 24) & 0xff);
        S[4] = (unsigned char)(s2 & 0xff);
        S[5] = (unsigned char)((s2 >> 8) & 0xff);
        S[6] = (unsigned char)((s2 >> 16) & 0xff);
        S[7] = (unsigned char)((s2 >> 24) & 0xff);
        gost_key(ctx, outputKey);
        gost_enc_cfb(ctx, S, outputKey, outputKey, 4);
    }
}

canonical_original_code:
void keyDiversifyCryptoPro(struct gost_ctx *ctx, unsigned char *inputKey, unsigned char *ukm, unsigned char *outputKey)
{
    unsigned int k; unsigned int s1; unsigned int s2;
    int i; int j; int mask;
    unsigned char S[8];
    memcpy(outputKey, inputKey, 32);
    for (i = 0; i < 8; i++) {
        s1 = 0, s2 = 0;
        for (j = 0, mask = 1; j < 8; j++, mask <<= 1) {
            k = ((unsigned int) outputKey[4 * j]) | (outputKey[4 * j + 1] << 8) |
                (outputKey[4 * j + 2] << 16) | (outputKey[4 * j + 3] << 24);
            if (mask & ukm[i]) {
                s1 += k;
            } else {
                s2 += k;
            }
        }
        S[0] = (unsigned char)(s1 & 0xff);
        S[1] = (unsigned char)((s1 >> 8) & 0xff);
        S[2] = (unsigned char)((s1 >> 16) & 0xff);
        S[3] = (unsigned char)((s1 >> 24) & 0xff);
        S[4] = (unsigned char)(s2 & 0xff);
        S[5] = (unsigned char)((s2 >> 8) & 0xff);
        S[6] = (unsigned char)((s2 >> 16) & 0xff);
        S[7] = (unsigned char)((s2 >> 24) & 0xff);
        gost_key(ctx, outputKey);
        gost_enc_cfb(ctx, S, outputKey, outputKey, 4);
    }
}

variable_types: struct gost_ctx { unsigned int k[8]; unsigned int k87[256]; } *

variable_types:
inputKey
unsigned char *

variable_types:
ukm
unsigned char *

variable_types:
outputKey
unsigned char *

variable_types:
k
unsigned int

variable_types: j int

variable_types: mask int

variable_types:
S
unsigned char [8]


keyWrapCryptoPro

decompiled_code:
__int64 __fastcall keyWrapCryptoPro(__int64 a1, const __m128i *a2, _BYTE *a3, __int64 a4, _QWORD *a5)
{
__int64 v8; // rdx
__int64 v9; // rcx
__m128i v11[4]; // [rsp+0h] [rbp-48h] BYREF

keyDiversifyCryptoPro(a1, a2, a3, v11);
gost_key(a1, v11, v8, v9);
*a5 = *(_QWORD *)a3;
gost_enc(a1, a4, a5 + 1, 4LL);
gost_mac_iv(a1, 32LL, a3, a4, 32LL, a5 + 5);
return 1LL;
}

original_code:
int keyWrapCryptoPro(gost_ctx * ctx, const unsigned char *keyExchangeKey,
                     const unsigned char *ukm,
                     const unsigned char *sessionKey,
                     unsigned char *wrappedKey)
{
    unsigned char kek_ukm[32];
    keyDiversifyCryptoPro(ctx, keyExchangeKey, ukm, kek_ukm);
    gost_key(ctx, kek_ukm);
    memcpy(wrappedKey, ukm, 8);
    gost_enc(ctx, sessionKey, wrappedKey + 8, 4);
    gost_mac_iv(ctx, 32, ukm, sessionKey, 32, wrappedKey + 40);
    return 1;
}

canonical_original_code:
int keyWrapCryptoPro(struct gost_ctx *ctx, unsigned char *keyExchangeKey, unsigned char *ukm, unsigned char *sessionKey, unsigned char *wrappedKey)
{
    unsigned char kek_ukm[32];
    keyDiversifyCryptoPro(ctx, keyExchangeKey, ukm, kek_ukm);
    gost_key(ctx, kek_ukm);
    memcpy(wrappedKey, ukm, 8);
    gost_enc(ctx, sessionKey, wrappedKey + 8, 4);
    gost_mac_iv(ctx, 32, ukm, sessionKey, 32, wrappedKey + 40);
    return 1;
}

variable_types:
keyExchangeKey
unsigned char *

variable_types:
sessionKey
unsigned char *

variable_types:
wrappedKey
unsigned char *

user_defined_types: struct gost_ctx { unsigned int k[8]; unsigned int k87[256]; }


keyUnwrapCryptoPro

decompiled_code:
_BOOL8 __fastcall keyUnwrapCryptoPro(__int64 a1, const __m128i *a2, _BYTE *a3, __int64 a4)
{
__int64 v6; // rdx
__int64 v7; // rcx
char s1[4]; // [rsp+Ch] [rbp-3Ch] BYREF
__m128i v10[3]; // [rsp+10h] [rbp-38h] BYREF

keyDiversifyCryptoPro(a1, a2, a3, v10);
gost_key(a1, v10, v6, v7);
gost_dec(a1, a3 + 8, a4, 4LL);
gost_mac_iv(a1, 32LL, a3, a4, 32LL, s1);
return memcmp(s1, a3 + 40, 4uLL) == 0;
}

original_code:
int keyUnwrapCryptoPro(gost_ctx * ctx, const unsigned char *keyExchangeKey,
                       const unsigned char *wrappedKey,
                       unsigned char *sessionKey)
{
    unsigned char kek_ukm[32], cek_mac[4];
    keyDiversifyCryptoPro(ctx, keyExchangeKey, wrappedKey
                          , kek_ukm);
    gost_key(ctx, kek_ukm);
    gost_dec(ctx, wrappedKey + 8, sessionKey, 4);
    gost_mac_iv(ctx, 32, wrappedKey, sessionKey, 32, cek_mac);
    if (memcmp(cek_mac, wrappedKey + 40, 4)) {
        return 0;
    }
    return 1;
}

canonical_original_code:
int keyUnwrapCryptoPro(struct gost_ctx *ctx, unsigned char *keyExchangeKey, unsigned char *wrappedKey, unsigned char *sessionKey)
{
    unsigned char kek_ukm[32]; unsigned char cek_mac[4];
    keyDiversifyCryptoPro(ctx, keyExchangeKey, wrappedKey
                          , kek_ukm);
    gost_key(ctx, kek_ukm);
    gost_dec(ctx, wrappedKey + 8, sessionKey, 4);
    gost_mac_iv(ctx, 32, wrappedKey, sessionKey, 32, cek_mac);
    if (memcmp(cek_mac, wrappedKey + 40, 4)) {
        return 0;
    }
    return 1;
}


decompiled_code:
__int64 ERR_load_RAND_strings()
{
__int64 result; // rax

result = ERR_func_error_string(RAND_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &RAND_str_functs);
result = ERR_load_strings(0LL, &RAND_str_reasons);
}
return result;
}

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

result = ERR_func_error_string(RAND_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &RAND_str_functs);
result = ERR_load_strings(0LL, &RAND_str_reasons);
}
return result;
}

original_code:
void ERR_load_RAND_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(RAND_str_functs[0].error) == NULL) {
        ERR_load_strings(0, RAND_str_functs);
        ERR_load_strings(0, RAND_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_RAND_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(RAND_str_functs[0].error) == NULL) {
        ERR_load_strings(0, RAND_str_functs);
        ERR_load_strings(0, RAND_str_reasons);
    }
#endif
}


decompiled_code:
__int64 __fastcall RAND_status(__int64 a1, __int64 a2)
{
__int64 v2; // rax
unsigned int v3; // edx
__int64 (__fastcall *v4)(__int64, __int64, _QWORD); // rax

v2 = RAND_get_rand_method();
v3 = 0;
if ( v2 )
{
v4 = *(__int64 (__fastcall **)(__int64, __int64, _QWORD))(v2 + 40);
if ( v4 )
v3 = v4(a1, a2, 0LL);
}
return v3;
}

original_code: char RAND_status(void) {return 0;}

canonical_original_code: char RAND_status() {return 0;}

return_type: char


decompiled_code:
__int64 __fastcall UTF8_getc(unsigned __int8 *a1, int a2, unsigned __int64 *a3)
{
unsigned int v4; // edx
int v5; // eax
unsigned __int64 v6; // rax
__int16 v8; // r8
int v9; // edx
int v10; // esi
int v11; // er9
unsigned __int8 v12; // r10
unsigned __int8 v13; // di
unsigned __int8 v14; // al
unsigned __int8 v15; // si
unsigned __int8 v16; // r8
unsigned __int8 v17; // di
int v18; // edx
int v19; // esi
unsigned __int8 v20; // r9
unsigned __int8 v21; // di

v4 = 0;
if ( a2 > 0 )
{
v5 = *a1;
if ( (v5 & 0x80u) != 0 )
{
v8 = (unsigned __int8)v5;
if ( (v5 & 0xE0) == 0xC0 )
{
if ( a2 <= 1 )
return (unsigned int)-1;
if ( (a1[1] & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = ((unsigned __int8)v5 << 6) & 0x7C0 | (unsigned __int64)(a1[1] & 0x3F);
if ( v6 <= 0x7F )
return (unsigned int)-4;
v4 = 2;
}
else if ( (v5 & 0xF0) == 0xE0 )
{
if ( a2 <= 2 )
return (unsigned int)-1;
v14 = a1[1];
if ( (v14 & 0xC0) != 0x80 )
return (unsigned int)-3;
if ( (a1[2] & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = (v14 << 6) & 0xFC0 | (unsigned int)(unsigned __int16)(v8 << 12) | (unsigned __int64)(a1[2] & 0x3F);
if ( v6 <= 0x7FF )
return (unsigned int)-4;
v4 = 3;
}
else if ( (v5 & 0xF8) == 0xF0 )
{
if ( a2 <= 3 )
return (unsigned int)-1;
v15 = a1[1];
if ( (v15 & 0xC0) != 0x80 )
return (unsigned int)-3;
v16 = a1[2];
if ( (v16 & 0xC0) != 0x80 )
return (unsigned int)-3;
v17 = a1[3];
if ( (v17 & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = (v16 << 6) & 0xFC0 | (v15 << 12) & 0x3F000 | v17 & 0x3F | (unsigned __int64)((v5 << 18) & 0x1C0000);
if ( v6 <= 0xFFFF )
return (unsigned int)-4;
v4 = 4;
}
else if ( (v5 & 0xFC) == 0xF8 )
{
if ( a2 <= 4 )
return (unsigned int)-1;
v18 = a1[1];
if ( (a1[1] & 0xC0) != 0x80 )
return (unsigned int)-3;
v19 = a1[2];
if ( (a1[2] & 0xC0) != 0x80 )
return (unsigned int)-3;
v20 = a1[3];
if ( (v20 & 0xC0) != 0x80 )
return (unsigned int)-3;
v21 = a1[4];
if ( (v21 & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = (v20 << 6) & 0xFC0 | (v19 << 12) & 0x3F000 | v21 & 0x3F | (v5 << 24) & 0x3000000 | (unsigned __int64)((v18 << 18) & 0xFC0000);
if ( v6 <= 0x1FFFFF )
return (unsigned int)-4;
v4 = 5;
}
else
{
if ( (v5 & 0xFE) != 0xFC )
return (unsigned int)-2;
if ( a2 <= 5 )
return (unsigned int)-1;
v9 = a1[1];
if ( (a1[1] & 0xC0) != 0x80 )
return (unsigned int)-3;
v10 = a1[2];
if ( (a1[2] & 0xC0) != 0x80 )
return (unsigned int)-3;
v11 = a1[3];
if ( (a1[3] & 0xC0) != 0x80 )
return (unsigned int)-3;
v12 = a1[4];
if ( (v12 & 0xC0) != 0x80 )
return (unsigned int)-3;
v13 = a1[5];
if ( (v13 & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = (v12 << 6) & 0xFC0 | (v11 << 12) & 0x3F000 | (v10 << 18) & 0xFC0000 | v13 & 0x3F | (v9 << 24) & 0x3F000000 | (unsigned __int64)((v5 << 30) & 0x40000000);
if ( v6 <= 0x3FFFFFF )
return (unsigned int)-4;
v4 = 6;
}
}
else
{
v6 = v5 & 0x7F;
v4 = 1;
}
*a3 = v6;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, int a2, unsigned __int64 *a3)
{
unsigned int v4; // edx
int v5; // eax
unsigned __int64 v6; // rax
__int16 v8; // r8
int v9; // edx
int v10; // esi
int v11; // er9
unsigned __int8 v12; // r10
unsigned __int8 v13; // di
unsigned __int8 v14; // al
unsigned __int8 v15; // si
unsigned __int8 v16; // r8
unsigned __int8 v17; // di
int v18; // edx
int v19; // esi
unsigned __int8 v20; // r9
unsigned __int8 v21; // di

v4 = 0;
if ( a2 > 0 )
{
v5 = *a1;
if ( (v5 & 0x80u) != 0 )
{
v8 = (unsigned __int8)v5;
if ( (v5 & 0xE0) == 0xC0 )
{
if ( a2 <= 1 )
return (unsigned int)-1;
if ( (a1[1] & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = ((unsigned __int8)v5 << 6) & 0x7C0 | (unsigned __int64)(a1[1] & 0x3F);
if ( v6 <= 0x7F )
return (unsigned int)-4;
v4 = 2;
}
else if ( (v5 & 0xF0) == 0xE0 )
{
if ( a2 <= 2 )
return (unsigned int)-1;
v14 = a1[1];
if ( (v14 & 0xC0) != 0x80 )
return (unsigned int)-3;
if ( (a1[2] & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = (v14 << 6) & 0xFC0 | (unsigned int)(unsigned __int16)(v8 << 12) | (unsigned __int64)(a1[2] & 0x3F);
if ( v6 <= 0x7FF )
return (unsigned int)-4;
v4 = 3;
}
else if ( (v5 & 0xF8) == 0xF0 )
{
if ( a2 <= 3 )
return (unsigned int)-1;
v15 = a1[1];
if ( (v15 & 0xC0) != 0x80 )
return (unsigned int)-3;
v16 = a1[2];
if ( (v16 & 0xC0) != 0x80 )
return (unsigned int)-3;
v17 = a1[3];
if ( (v17 & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = (v16 << 6) & 0xFC0 | (v15 << 12) & 0x3F000 | v17 & 0x3F | (unsigned __int64)((v5 << 18) & 0x1C0000);
if ( v6 <= 0xFFFF )
return (unsigned int)-4;
v4 = 4;
}
else if ( (v5 & 0xFC) == 0xF8 )
{
if ( a2 <= 4 )
return (unsigned int)-1;
v18 = a1[1];
if ( (a1[1] & 0xC0) != 0x80 )
return (unsigned int)-3;
v19 = a1[2];
if ( (a1[2] & 0xC0) != 0x80 )
return (unsigned int)-3;
v20 = a1[3];
if ( (v20 & 0xC0) != 0x80 )
return (unsigned int)-3;
v21 = a1[4];
if ( (v21 & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = (v20 << 6) & 0xFC0 | (v19 << 12) & 0x3F000 | v21 & 0x3F | (v5 << 24) & 0x3000000 | (unsigned __int64)((v18 << 18) & 0xFC0000);
if ( v6 <= 0x1FFFFF )
return (unsigned int)-4;
v4 = 5;
}
else
{
if ( (v5 & 0xFE) != 0xFC )
return (unsigned int)-2;
if ( a2 <= 5 )
return (unsigned int)-1;
v9 = a1[1];
if ( (a1[1] & 0xC0) != 0x80 )
return (unsigned int)-3;
v10 = a1[2];
if ( (a1[2] & 0xC0) != 0x80 )
return (unsigned int)-3;
v11 = a1[3];
if ( (a1[3] & 0xC0) != 0x80 )
return (unsigned int)-3;
v12 = a1[4];
if ( (v12 & 0xC0) != 0x80 )
return (unsigned int)-3;
v13 = a1[5];
if ( (v13 & 0xC0) != 0x80 )
return (unsigned int)-3;
v6 = (v12 << 6) & 0xFC0 | (v11 << 12) & 0x3F000 | (v10 << 18) & 0xFC0000 | v13 & 0x3F | (v9 << 24) & 0x3F000000 | (unsigned __int64)((v5 << 30) & 0x40000000);
if ( v6 <= 0x3FFFFFF )
return (unsigned int)-4;
v4 = 6;
}
}
else
{
v6 = v5 & 0x7F;
v4 = 1;
}
*a3 = v6;
}
return v4;
}

variable_types:
str
unsigned char *

variable_types: len int

variable_types:
val
unsigned long *

variable_types:
p
unsigned char *

variable_types:
value
unsigned long

variable_types: ret int


original_code:
int UTF8_putc(unsigned char *str, int len, unsigned long value)
{
    if (!str)
        len = 6;                /* Maximum we will need */
    else if (len <= 0)
        return -1;
    if (value < 0x80) {
        if (str)
            *str = (unsigned char)value;
        return 1;
    }
    if (value < 0x800) {
        if (len < 2)
            return -1;
        if (str) {
            *str++ = (unsigned char)(((value >> 6) & 0x1f) | 0xc0);
            *str = (unsigned char)((value & 0x3f) | 0x80);
        }
        return 2;
    }
    if (value < 0x10000) {
        if (len < 3)
            return -1;
        if (str) {
            *str++ = (unsigned char)(((value >> 12) & 0xf) | 0xe0);
            *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
            *str = (unsigned char)((value & 0x3f) | 0x80);
        }
        return 3;
    }
    if (value < 0x200000) {
        if (len < 4)
            return -1;
        if (str) {
            *str++ = (unsigned char)(((value >> 18) & 0x7) | 0xf0);
            *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
            *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
            *str = (unsigned char)((value & 0x3f) | 0x80);
        }
        return 4;
    }
    if (value < 0x4000000) {
        if (len < 5)
            return -1;
        if (str) {
            *str++ = (unsigned char)(((value >> 24) & 0x3) | 0xf8);
            *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
            *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
            *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
            *str = (unsigned char)((value & 0x3f) | 0x80);
        }
        return 5;
    }
    if (len < 6)
        return -1;
    if (str) {
        *str++ = (unsigned char)(((value >> 30) & 0x1) | 0xfc);
        *str++ = (unsigned char)(((value >> 24) & 0x3f) | 0x80);
        *str++ = (unsigned char)(((value >> 18) & 0x3f) | 0x80);
        *str++ = (unsigned char)(((value >> 12) & 0x3f) | 0x80);
        *str++ = (unsigned char)(((value >> 6) & 0x3f) | 0x80);
        *str = (unsigned char)((value & 0x3f) | 0x80);
    }
    return 6;
}


decompiled_code:
__int64 pad_unknown()
{
__int64 result; // rax

while ( 1 )
{
result = ERR_get_error();
if ( !result )
break;
if ( (result & 0xFFF) == 118 )
return 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax

while ( 1 )
{
result = ERR_get_error();
if ( !result )
break;
if ( (result & 0xFFF) == 118 )
return 1LL;
}
return result;
}

original_code:
static int pad_unknown(void)
{
    unsigned long l;
    while ((l = ERR_get_error()) != 0)
        if ((int)((l)&0xfffL) == 118)
            return (1);
    return (0);
}

canonical_original_code:
static int pad_unknown()
{
    unsigned long l;
    while ((l = ERR_get_error()) != 0)
        if ((int)((l)&0xfffL) == 118)
            return (1);
    return (0);
}

variable_types:
l
unsigned long


SortFnByName

decompiled_code:
int __fastcall SortFnByName(const void *a1, const void *a2)
{
int result; // eax

if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
result = strcmp(*((const char **)a1 + 1), *((const char **)a2 + 1));
else
result = *(_DWORD *)a1 - *(_DWORD *)a2;
return result;
}

canonical_decompiled_code:
int __fastcall func0(const void *a1, const void *a2)
{
int result; // eax

if ( *(_DWORD *)a1 == *(_DWORD *)a2 )
result = strcmp(*((const char **)a1 + 1), *((const char **)a2 + 1));
else
result = *(_DWORD *)a1 - *(_DWORD *)a2;
return result;
}

original_code:
static int SortFnByName(const void *_f1, const void *_f2)
{
    const FUNCTION *f1 = _f1;
    const FUNCTION *f2 = _f2;
    if (f1->type != f2->type)
        return f1->type - f2->type;
    return strcmp(f1->name, f2->name);
}

canonical_original_code:
static int SortFnByName(void *_f1, void *_f2)
{
    struct FUNCTION *f1 = _f1;
    struct FUNCTION *f2 = _f2;
    if (f1->type != f2->type)
        return f1->type - f2->type;
    return strcmp(f1->name, f2->name);
}

variable_types: struct FUNCTION { int type; char *name; int (*func)(int argc, char *argv[]); } *


decompiled_code:
__int64 prog_init()
{
size_t v0; // rsi
_QWORD *v1; // rax
__int64 v2; // rbp
_QWORD *v3; // rbx

if ( *((_QWORD *)&functions + 1) )
{
v0 = 0LL;
v1 = &functions;
do
{
v1 += 3;
++v0;
}
while ( v1[1] );
}
else
{
v0 = 0LL;
}
qsort(&functions, v0, 0x18uLL, SortFnByName);
v2 = lh_new(function_LHASH_HASH, function_LHASH_COMP);
if ( v2 && *((_QWORD *)&functions + 1) )
{
v3 = &functions;
do
{
lh_insert(v2, v3);
v3 += 3;
}
while ( v3[1] );
}
return v2;
}

canonical_decompiled_code:
__int64 func2()
{
size_t v0; // rsi
_QWORD *v1; // rax
__int64 v2; // rbp
_QWORD *v3; // rbx

if ( *((_QWORD *)&functions + 1) )
{
v0 = 0LL;
v1 = &functions;
do
{
v1 += 3;
++v0;
}
while ( v1[1] );
}
else
{
v0 = 0LL;
}
qsort(&functions, v0, 0x18uLL, SortFnByName);
v2 = lh_new(function_LHASH_HASH, function_LHASH_COMP);
if ( v2 && *((_QWORD *)&functions + 1) )
{
v3 = &functions;
do
{
lh_insert(v2, v3);
v3 += 3;
}
while ( v3[1] );
}
return v2;
}

original_code:
static struct lhash_st_FUNCTION *prog_init(void)
{
    struct lhash_st_FUNCTION *ret;
    FUNCTION *f;
    size_t i;
    for (i = 0, f = functions; f->name != ((void *)0); ++f, ++i) ;
    qsort(functions, i, sizeof *functions, SortFnByName);
    if ((ret = ((struct lhash_st_FUNCTION *)lh_new(function_LHASH_HASH, function_LHASH_COMP))) == ((void *)0))
        return (((void *)0));
    for (f = functions; f->name != ((void *)0); f++)
        (void)((FUNCTION *)lh_insert(((_LHASH *)((void*) (1 ? ret : (struct lhash_st_FUNCTION*)0))), ((void*) (1 ? f : (FUNCTION*)0))));
    return (ret);
}

canonical_original_code:
static struct lhash_st_FUNCTION *prog_init()
{
    struct lhash_st_FUNCTION *ret;
    struct FUNCTION *f;
    unsigned long i;
    for (i = 0, f = functions; f->name != ((void *)0); ++f, ++i) ;
    qsort(functions, i, sizeof *functions, SortFnByName);
    if ((ret = ((struct lhash_st_FUNCTION *)lh_new(function_LHASH_HASH, function_LHASH_COMP))) == ((void *)0))
        return (((void *)0));
    for (f = functions; f->name != ((void *)0); f++)
        (void)((struct FUNCTION *)lh_insert(((struct lhash_st *)((void *) (1 ? ret : (struct lhash_st_FUNCTION *)0))), ((void *) (1 ? f : (struct FUNCTION *)0))));
    return (ret);
}

variable_types: struct lhash_st_FUNCTION { int dummy; } *

variable_types:
i
unsigned long

user_defined_types: struct FUNCTION { int type; char *name; int (*func)(int argc, char *argv[]); }

user_defined_types: struct lhash_st { struct lhash_node_st **b; int (*comp)(void *, void *); unsigned long (*hash)(void *); unsigned int num_nodes; unsigned int num_alloc_nodes; unsigned int p; unsigned int pmax; unsigned long up_load; unsigned long down_load; unsigned long num_items; unsigned long num_expands; unsigned long num_expand_reallocs; unsigned long num_contracts; unsigned long num_contract_reallocs; unsigned long num_hash_calls; unsigned long num_comp_calls; unsigned long num_insert; unsigned long num_replace; unsigned long num_delete; unsigned long num_no_delete; unsigned long num_retrieve; unsigned long num_retrieve_miss; unsigned long num_hash_comps; int error; }

user_defined_types: struct lhash_node_st { void *data; struct lhash_node_st *next; unsigned long hash; }


decompiled_code:
int __fastcall function_LHASH_COMP(__int64 a1, __int64 a2)
{
return function_cmp(a1, a2);
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1, __int64 a2)
{
return func3(a1, a2);
}

original_code: static int function_LHASH_COMP(const void *arg1, const void *arg2) { const FUNCTION *a = arg1; const FUNCTION *b = arg2; return function_cmp(a,b); }

canonical_original_code: static int function_LHASH_COMP(void *arg1, void *arg2) { struct FUNCTION *a = arg1; struct FUNCTION *b = arg2; return function_cmp(a,b); }


decompiled_code:
__int64 __fastcall function_LHASH_HASH(__int64 a1)
{
return function_hash(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return func5(a1);
}

original_code: static unsigned long function_LHASH_HASH(const void *arg) { const FUNCTION *a = arg; return function_hash(a); }

canonical_original_code: static unsigned long function_LHASH_HASH(void *arg) { struct FUNCTION *a = arg; return function_hash(a); }

variable_types:
arg
void *

return_type: unsigned long


decompiled_code:
__int64 __fastcall list_md(__int64 a1)
{
return EVP_MD_do_all_sorted(list_md_fn, a1);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return EVP_MD_do_all_sorted(list_md_fn, a1);
}

original_code:
static void list_md(BIO *out)
{
    EVP_MD_do_all_sorted(list_md_fn, out);
}

canonical_original_code:
static void list_md(struct bio_st *out)
{
    EVP_MD_do_all_sorted(list_md_fn, out);
}

variable_types: struct bio_st { struct bio_method_st { int type; char *name; int (*bwrite)(struct bio_st *, char *, int); int (*bread)(struct bio_st *, char *, int); int (*bputs)(struct bio_st *, char *); int (*bgets)(struct bio_st *, char *, int); long (*ctrl)(struct bio_st *, int, long, void *); int (*create)(struct bio_st *); int (*destroy)(struct bio_st *); long (*callback_ctrl)(struct bio_st *, int, void (*)(struct bio_st *, int, char *, int, long, long)); } *method; long (*callback)(struct bio_st *, int, char *, int, long, long); char *cb_arg; int init; int shutdown; int flags; int retry_reason; int num; void *ptr; struct bio_st *next_bio; struct bio_st *prev_bio; int references; unsigned long num_read; unsigned long num_write; struct crypto_ex_data_st { struct stack_st_void { struct stack_st { int num; char **data; int sorted; int num_alloc; int (*comp)(void *, void *); } stack; } *sk; int dummy; } ex_data; } *

user_defined_types: struct bio_st { struct bio_method_st *method; long (*callback)(struct bio_st *, int, char *, int, long, long); char *cb_arg; int init; int shutdown; int flags; int retry_reason; int num; void *ptr; struct bio_st *next_bio; struct bio_st *prev_bio; int references; unsigned long num_read; unsigned long num_write; struct crypto_ex_data_st ex_data; }

user_defined_types: struct crypto_ex_data_st { struct stack_st_void *sk; int dummy; }

user_defined_types: struct stack_st_void { struct stack_st stack; }


decompiled_code:
__int64 __fastcall list_cipher(__int64 a1)
{
return EVP_CIPHER_do_all_sorted(list_cipher_fn, a1);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return EVP_CIPHER_do_all_sorted(list_cipher_fn, a1);
}

original_code:
static void list_cipher(BIO *out)
{
    EVP_CIPHER_do_all_sorted(list_cipher_fn, out);
}

canonical_original_code:
static void list_cipher(struct bio_st *out)
{
    EVP_CIPHER_do_all_sorted(list_cipher_fn, out);
}

user_defined_types: struct bio_method_st { int type; char *name; int (*bwrite)(struct bio_st *, char *, int); int (*bread)(struct bio_st *, char *, int); int (*bputs)(struct bio_st *, char *); int (*bgets)(struct bio_st *, char *, int); long (*ctrl)(struct bio_st *, int, long, void *); int (*create)(struct bio_st *); int (*destroy)(struct bio_st *); long (*callback_ctrl)(struct bio_st *, int, void (*)(struct bio_st *, int, char *, int, long, long)); }

user_defined_types: struct stack_st { int num; char **data; int sorted; int num_alloc; int (*comp)(void *, void *); }


decompiled_code:
__int64 __fastcall do_cmd(__int64 a1, unsigned int a2, const char **a3)
{
_BOOL4 v3; // er12
int *v6; // rax
__int64 v8; // rbp
__int64 v9; // rax
char *i; // rbx
const char *v11; // rdx
int v12; // er12
int v13; // ebp
const char **v14; // rbx
int v15; // er13
int v16; // ebp
__int64 v17; // r13
int v18; // ebp
int v19; // [rsp+0h] [rbp-48h] BYREF
const char *v20; // [rsp+8h] [rbp-40h]
void *v21; // [rsp+10h] [rbp-38h]

v3 = 0;
if ( (int)a2 > 0 && *a3 )
{
v20 = *a3;
v6 = (int *)lh_retrieve(a1, &v19);
if ( v6 )
return (_BOOL4)(*((__int64 (__fastcall **)(_QWORD, const char **))v6 + 2))(a2, a3);
if ( EVP_get_digestbyname(*a3) )
{
v19 = 2;
v21 = &dgst_main;
v6 = &v19;
return (_BOOL4)(*((__int64 (__fastcall **)(_QWORD, const char **))v6 + 2))(a2, a3);
}
if ( EVP_get_cipherbyname(*a3) )
{
v19 = 3;
v21 = &enc_main;
v6 = &v19;
return (_BOOL4)(*((__int64 (__fastcall **)(_QWORD, const char **))v6 + 2))(a2, a3);
}
if ( memcmp(*a3, "no-", 3uLL) )
{
if ( !strcmp(*a3, "quit") )
return -1;
if ( !strcmp(*a3, "q") )
return -1;
if ( !strcmp(*a3, "exit") )
return -1;
if ( !strcmp(*a3, "bye") )
return -1;
if ( !strcmp(*a3, "list-standard-commands") )
{
v18 = 1;
goto LABEL_59;
}
if ( !strcmp(*a3, "list-message-digest-commands") )
{
v18 = 2;
goto LABEL_59;
}
if ( !strcmp(*a3, "list-message-digest-algorithms")
|| !strcmp(*a3, "list-cipher-commands")
|| !strcmp(*a3, "list-cipher-algorithms")
|| !strcmp(*a3, "list-public-key-algorithms") )
{
if ( !strcmp(*a3, "list-message-digest-algorithms") )
{
v17 = BIO_new_fp(stdout, 0LL);
if ( !(unsigned int)load_config(bio_err, 0LL) )
return 1;
list_md(v17);
v18 = 5;
goto LABEL_61;
}
if ( !strcmp(*a3, "list-public-key-algorithms") )
{
v17 = BIO_new_fp(stdout, 0LL);
if ( !(unsigned int)load_config(bio_err, 0LL) )
return 1;
list_pkey(v17);
v18 = 4;
goto LABEL_61;
}
v18 = strcmp(*a3, "list-cipher-algorithms") == 0 ? 6 : 3;
LABEL_59:
v17 = BIO_new_fp(stdout, 0LL);
v3 = 1;
if ( !(unsigned int)load_config(bio_err, 0LL) )
return v3;
if ( v18 == 6 )
{
list_cipher(v17);
LABEL_15:
BIO_free_all(v17);
return 0;
}
LABEL_61:
v11 = (const char *)*((_QWORD *)&functions + 1);
for ( i = (char *)&functions; v11; v11 = (const char *)*((_QWORD *)i + 1) )
{
if ( *(_DWORD *)i == v18 )
BIO_printf(v17, "%s\n", v11);
i += 24;
}
goto LABEL_15;
}
BIO_printf(bio_err, "openssl:Error: '%s' is an invalid command.\n", *a3);
BIO_printf(bio_err, "\nStandard commands");
if ( !*((_QWORD *)&functions + 1) )
{
LABEL_33:
BIO_printf(bio_err, "\n\n");
return 0;
}
v12 = 0;
v13 = 0;
v14 = (const char **)&functions;
while ( 1 )
{
v15 = v13 + 1;
if ( (v13 & 3) != 0 )
{
v16 = *(_DWORD *)v14;
if ( v12 != *(_DWORD *)v14 )
{
BIO_printf(bio_err, "\n");
v12 = v16;
LABEL_23:
if ( v12 == 2 )
{
BIO_printf(bio_err, "\nMessage Digest commands (see the `dgst' command for more details)\n");
v13 = 1;
}
else
{
v13 = v15;
if ( v12 == 3 )
{
BIO_printf(bio_err, "\nCipher commands (see the `enc' command for more details)\n");
v13 = 1;
}
}
goto LABEL_26;
}
v12 = *(_DWORD *)v14;
v13 = v15;
}
else
{
BIO_printf(bio_err, "\n");
if ( v12 != *(_DWORD *)v14 )
{
v12 = *(_DWORD *)v14;
goto LABEL_23;
}
v12 = *(_DWORD *)v14;
++v13;
}
LABEL_26:
BIO_printf(bio_err, "%-18s", v14[1]);
v14 += 3;
if ( !v14[1] )
goto LABEL_33;
}
}
v8 = BIO_new_fp(stdout, 0LL);
v20 = *a3 + 3;
v9 = lh_retrieve(a1, &v19);
v3 = v9 != 0;
if ( v9 )
BIO_printf(v8, "%s\n", *a3 + 3);
else
BIO_printf(v8, "%s\n", *a3);
BIO_free_all(v8);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, unsigned int a2, const char **a3)
{
_BOOL4 v3; // er12
int *v6; // rax
__int64 v8; // rbp
__int64 v9; // rax
char *i; // rbx
const char *v11; // rdx
int v12; // er12
int v13; // ebp
const char **v14; // rbx
int v15; // er13
int v16; // ebp
__int64 v17; // r13
int v18; // ebp
int v19; // [rsp+0h] [rbp-48h] BYREF
const char *v20; // [rsp+8h] [rbp-40h]
void *v21; // [rsp+10h] [rbp-38h]

v3 = 0;
if ( (int)a2 > 0 && *a3 )
{
v20 = *a3;
v6 = (int *)lh_retrieve(a1, &v19);
if ( v6 )
return (_BOOL4)(*((__int64 (__fastcall **)(_QWORD, const char **))v6 + 2))(a2, a3);
if ( EVP_get_digestbyname(*a3) )
{
v19 = 2;
v21 = &dgst_main;
v6 = &v19;
return (_BOOL4)(*((__int64 (__fastcall **)(_QWORD, const char **))v6 + 2))(a2, a3);
}
if ( EVP_get_cipherbyname(*a3) )
{
v19 = 3;
v21 = &enc_main;
v6 = &v19;
return (_BOOL4)(*((__int64 (__fastcall **)(_QWORD, const char **))v6 + 2))(a2, a3);
}
if ( memcmp(*a3, "no-", 3uLL) )
{
if ( !strcmp(*a3, "quit") )
return -1;
if ( !strcmp(*a3, "q") )
return -1;
if ( !strcmp(*a3, "exit") )
return -1;
if ( !strcmp(*a3, "bye") )
return -1;
if ( !strcmp(*a3, "list-standard-commands") )
{
v18 = 1;
goto LABEL_59;
}
if ( !strcmp(*a3, "list-message-digest-commands") )
{
v18 = 2;
goto LABEL_59;
}
if ( !strcmp(*a3, "list-message-digest-algorithms")
|| !strcmp(*a3, "list-cipher-commands")
|| !strcmp(*a3, "list-cipher-algorithms")
|| !strcmp(*a3, "list-public-key-algorithms") )
{
if ( !strcmp(*a3, "list-message-digest-algorithms") )
{
v17 = BIO_new_fp(stdout, 0LL);
if ( !(unsigned int)load_config(bio_err, 0LL) )
return 1;
func8(v17);
v18 = 5;
goto LABEL_61;
}
if ( !strcmp(*a3, "list-public-key-algorithms") )
{
v17 = BIO_new_fp(stdout, 0LL);
if ( !(unsigned int)load_config(bio_err, 0LL) )
return 1;
func7(v17);
v18 = 4;
goto LABEL_61;
}
v18 = strcmp(*a3, "list-cipher-algorithms") == 0 ? 6 : 3;
LABEL_59:
v17 = BIO_new_fp(stdout, 0LL);
v3 = 1;
if ( !(unsigned int)load_config(bio_err, 0LL) )
return v3;
if ( v18 == 6 )
{
func10(v17);
LABEL_15:
BIO_free_all(v17);
return 0;
}
LABEL_61:
v11 = (const char *)*((_QWORD *)&functions + 1);
for ( i = (char *)&functions; v11; v11 = (const char *)*((_QWORD *)i + 1) )
{
if ( *(_DWORD *)i == v18 )
BIO_printf(v17, "%s\n", v11);
i += 24;
}
goto LABEL_15;
}
BIO_printf(bio_err, "openssl:Error: '%s' is an invalid command.\n", *a3);
BIO_printf(bio_err, "\nStandard commands");
if ( !*((_QWORD *)&functions + 1) )
{
LABEL_33:
BIO_printf(bio_err, "\n\n");
return 0;
}
v12 = 0;
v13 = 0;
v14 = (const char **)&functions;
while ( 1 )
{
v15 = v13 + 1;
if ( (v13 & 3) != 0 )
{
v16 = *(_DWORD *)v14;
if ( v12 != *(_DWORD *)v14 )
{
BIO_printf(bio_err, "\n");
v12 = v16;
LABEL_23:
if ( v12 == 2 )
{
BIO_printf(bio_err, "\nMessage Digest commands (see the `dgst' command for more details)\n");
v13 = 1;
}
else
{
v13 = v15;
if ( v12 == 3 )
{
BIO_printf(bio_err, "\nCipher commands (see the `enc' command for more details)\n");
v13 = 1;
}
}
goto LABEL_26;
}
v12 = *(_DWORD *)v14;
v13 = v15;
}
else
{
BIO_printf(bio_err, "\n");
if ( v12 != *(_DWORD *)v14 )
{
v12 = *(_DWORD *)v14;
goto LABEL_23;
}
v12 = *(_DWORD *)v14;
++v13;
}
LABEL_26:
BIO_printf(bio_err, "%-18s", v14[1]);
v14 += 3;
if ( !v14[1] )
goto LABEL_33;
}
}
v8 = BIO_new_fp(stdout, 0LL);
v20 = *a3 + 3;
v9 = lh_retrieve(a1, &v19);
v3 = v9 != 0;
if ( v9 )
BIO_printf(v8, "%s\n", *a3 + 3);
else
BIO_printf(v8, "%s\n", *a3);
BIO_free_all(v8);
}
return v3;
}

original_code:
static int do_cmd(struct lhash_st_FUNCTION *prog, int argc, char *argv[])
{
    FUNCTION f, *fp;
    int i, ret = 1, tp, nl;
    if ((argc <= 0) || (argv[0] == ((void *)0))) {
        ret = 0;
        goto end;
    }
    f.name = argv[0];
    fp = ((FUNCTION *)lh_retrieve(((_LHASH *)((void*) (1 ? prog : (struct lhash_st_FUNCTION*)0))), ((void*) (1 ? &f : (FUNCTION*)0))));
    if (fp == ((void *)0)) {
        if (EVP_get_digestbyname(argv[0])) {
            f.type = 2;
            f.func = dgst_main;
            fp = &f;
        } else if (EVP_get_cipherbyname(argv[0])) {
            f.type = 3;
            f.func = enc_main;
            fp = &f;
        }
    }
    if (fp != ((void *)0)) {
        ret = fp->func(argc, argv);
    } else if ((strncmp(argv[0], "no-", 3)) == 0) {
        BIO *bio_stdout = BIO_new_fp(stdout, 0x00);
        f.name = argv[0] + 3;
        ret = (((FUNCTION *)lh_retrieve(((_LHASH *)((void*) (1 ? prog : (struct lhash_st_FUNCTION*)0))), ((void*) (1 ? &f : (FUNCTION*)0)))) != ((void *)0));
        if (!ret)
            BIO_printf(bio_stdout, "%s\n", argv[0]);
        else
            BIO_printf(bio_stdout, "%s\n", argv[0] + 3);
        BIO_free_all(bio_stdout);
        goto end;
    } else if ((strcmp(argv[0], "quit") == 0) ||
               (strcmp(argv[0], "q") == 0) ||
               (strcmp(argv[0], "exit") == 0) ||
               (strcmp(argv[0], "bye") == 0)) {
        ret = -1;
        goto end;
    } else if ((strcmp(argv[0], "list-standard-commands") == 0) ||
               (strcmp(argv[0], "list-message-digest-commands") == 0) ||
               (strcmp(argv[0], "list-message-digest-algorithms") == 0) ||
               (strcmp(argv[0], "list-cipher-commands") == 0) ||
               (strcmp(argv[0], "list-cipher-algorithms") == 0) ||
               (strcmp(argv[0], "list-public-key-algorithms") == 0)) {
        int list_type;
        BIO *bio_stdout;
        if (strcmp(argv[0], "list-standard-commands") == 0)
            list_type = 1;
        else if (strcmp(argv[0], "list-message-digest-commands") == 0)
            list_type = 2;
        else if (strcmp(argv[0], "list-message-digest-algorithms") == 0)
            list_type = 5;
        else if (strcmp(argv[0], "list-public-key-algorithms") == 0)
            list_type = 4;
        else if (strcmp(argv[0], "list-cipher-algorithms") == 0)
            list_type = 6;
        else
            list_type = 3;
        bio_stdout = BIO_new_fp(stdout, 0x00);
        if (!load_config(bio_err, ((void *)0)))
            goto end;
        if (list_type == 4)
            list_pkey(bio_stdout);
        if (list_type == 5)
            list_md(bio_stdout);
        if (list_type == 6)
            list_cipher(bio_stdout);
        else {
            for (fp = functions; fp->name != ((void *)0); fp++)
                if (fp->type == list_type)
                    BIO_printf(bio_stdout, "%s\n", fp->name);
        }
        BIO_free_all(bio_stdout);
        ret = 0;
        goto end;
    } else {
        BIO_printf(bio_err, "openssl:Error: '%s' is an invalid command.\n",
                   argv[0]);
        BIO_printf(bio_err, "\nStandard commands");
        i = 0;
        tp = 0;
        for (fp = functions; fp->name != ((void *)0); fp++) {
            nl = 0;
            if (((i++) % 4) == 0)
            {
                BIO_printf(bio_err, "\n");
                nl = 1;
            }
            if (fp->type != tp) {
                tp = fp->type;
                if (!nl)
                    BIO_printf(bio_err, "\n");
                if (tp == 2) {
                    i = 1;
                    BIO_printf(bio_err,
                               "\nMessage Digest commands (see the `dgst' command for more details)\n");
                } else if (tp == 3) {
                    i = 1;
                    BIO_printf(bio_err,
                               "\nCipher commands (see the `enc' command for more details)\n");
                }
            }
            BIO_printf(bio_err, "%-18s", fp->name);
        }
        BIO_printf(bio_err, "\n\n");
        ret = 0;
    }
 end:
    return (ret);
}

canonical_original_code:
static int do_cmd(struct lhash_st_FUNCTION *prog, int argc, char *argv[])
{
    struct FUNCTION f; struct FUNCTION *fp;
    int i; int ret = 1; int tp; int nl;
    if ((argc <= 0) || (argv[0] == ((void *)0))) {
        ret = 0;
        goto end;
    }
    f.name = argv[0];
    fp = ((struct FUNCTION *)lh_retrieve(((struct lhash_st *)((void *) (1 ? prog : (struct lhash_st_FUNCTION *)0))), ((void *) (1 ? &f : (struct FUNCTION *)0))));
    if (fp == ((void *)0)) {
        if (EVP_get_digestbyname(argv[0])) {
            f.type = 2;
            f.func = dgst_main;
            fp = &f;
        } else if (EVP_get_cipherbyname(argv[0])) {
            f.type = 3;
            f.func = enc_main;
            fp = &f;
        }
    }
    if (fp != ((void *)0)) {
        ret = fp->func(argc, argv);
    } else if ((strncmp(argv[0], "no-", 3)) == 0) {
        struct bio_st *bio_stdout = BIO_new_fp(stdout, 0x00);
        f.name = argv[0] + 3;
        ret = (((struct FUNCTION *)lh_retrieve(((struct lhash_st *)((void *) (1 ? prog : (struct lhash_st_FUNCTION *)0))), ((void *) (1 ? &f : (struct FUNCTION *)0)))) != ((void *)0));
        if (!ret)
            BIO_printf(bio_stdout, "%s\n", argv[0]);
        else
            BIO_printf(bio_stdout, "%s\n", argv[0] + 3);
        BIO_free_all(bio_stdout);
        goto end;
    } else if ((strcmp(argv[0], "quit") == 0) ||
               (strcmp(argv[0], "q") == 0) ||
               (strcmp(argv[0], "exit") == 0) ||
               (strcmp(argv[0], "bye") == 0)) {
        ret = -1;
        goto end;
    } else if ((strcmp(argv[0], "list-standard-commands") == 0) ||
               (strcmp(argv[0], "list-message-digest-commands") == 0) ||
               (strcmp(argv[0], "list-message-digest-algorithms") == 0) ||
               (strcmp(argv[0], "list-cipher-commands") == 0) ||
               (strcmp(argv[0], "list-cipher-algorithms") == 0) ||
               (strcmp(argv[0], "list-public-key-algorithms") == 0)) {
        int list_type;
        struct bio_st *bio_stdout;
        if (strcmp(argv[0], "list-standard-commands") == 0)
            list_type = 1;
        else if (strcmp(argv[0], "list-message-digest-commands") == 0)
            list_type = 2;
        else if (strcmp(argv[0], "list-message-digest-algorithms") == 0)
            list_type = 5;
        else if (strcmp(argv[0], "list-public-key-algorithms") == 0)
            list_type = 4;
        else if (strcmp(argv[0], "list-cipher-algorithms") == 0)
            list_type = 6;
        else
            list_type = 3;
        bio_stdout = BIO_new_fp(stdout, 0x00);
        if (!load_config(bio_err, ((void *)0)))
            goto end;
        if (list_type == 4)
            list_pkey(bio_stdout);
        if (list_type == 5)
            list_md(bio_stdout);
        if (list_type == 6)
            list_cipher(bio_stdout);
        else {
            for (fp = functions; fp->name != ((void *)0); fp++)
                if (fp->type == list_type)
                    BIO_printf(bio_stdout, "%s\n", fp->name);
        }
        BIO_free_all(bio_stdout);
        ret = 0;
        goto end;
    } else {
        BIO_printf(bio_err, "openssl:Error: '%s' is an invalid command.\n",
                   argv[0]);
        BIO_printf(bio_err, "\nStandard commands");
        i = 0;
        tp = 0;
        for (fp = functions; fp->name != ((void *)0); fp++) {
            nl = 0;
            if (((i++) % 4) == 0)
            {
                BIO_printf(bio_err, "\n");
                nl = 1;
            }
            if (fp->type != tp) {
                tp = fp->type;
                if (!nl)
                    BIO_printf(bio_err, "\n");
                if (tp == 2) {
                    i = 1;
                    BIO_printf(bio_err,
                               "\nMessage Digest commands (see the `dgst' command for more details)\n");
                } else if (tp == 3) {
                    i = 1;
                    BIO_printf(bio_err,
                               "\nCipher commands (see the `enc' command for more details)\n");
                }
            }
            BIO_printf(bio_err, "%-18s", fp->name);
        }
        BIO_printf(bio_err, "\n\n");
        ret = 0;
    }
 end:
    return (ret);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct FUNCTION { int type; char *name; int (*func)(int argc, char *argv[]); }

variable_types: i int

variable_types: tp int

variable_types: nl int


decompiled_code:
int __fastcall lock_dbg_cb(unsigned int a1, unsigned int a2, const char *a3, __int64 a4)
{
int result; // eax
int v6; // edx
const char *v7; // rdx

result = a1 & 0xC;
if ( ((result - 4) & 0xFFFFFFFB) != 0 )
{
v7 = "invalid mode";
}
else if ( a2 > 0x28 )
{
v7 = "type out of bounds";
}
else if ( (a1 & 1) != 0 )
{
if ( !modes_0[a2] )
{
modes_0[a2] = result;
return result;
}
v7 = "already locked";
}
else if ( (a1 & 2) != 0 )
{
v6 = modes_0[a2];
if ( v6 )
{
if ( v6 == result )
{
modes_0[a2] = 0;
return result;
}
v7 = "CRYPTO_r_unlock on write lock";
if ( result != 4 )
v7 = "CRYPTO_w_unlock on read lock";
modes_0[a2] = 0;
}
else
{
v7 = "not locked";
}
}
else
{
v7 = "invalid mode";
}
return fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", v7, a1, a2, a3, a4);
}

canonical_decompiled_code:
int __fastcall func1(unsigned int a1, unsigned int a2, const char *a3, __int64 a4)
{
int result; // eax
int v6; // edx
const char *v7; // rdx

result = a1 & 0xC;
if ( ((result - 4) & 0xFFFFFFFB) != 0 )
{
v7 = "invalid mode";
}
else if ( a2 > 0x28 )
{
v7 = "type out of bounds";
}
else if ( (a1 & 1) != 0 )
{
if ( !modes_0[a2] )
{
modes_0[a2] = result;
return result;
}
v7 = "already locked";
}
else if ( (a1 & 2) != 0 )
{
v6 = modes_0[a2];
if ( v6 )
{
if ( v6 == result )
{
modes_0[a2] = 0;
return result;
}
v7 = "CRYPTO_r_unlock on write lock";
if ( result != 4 )
v7 = "CRYPTO_w_unlock on read lock";
modes_0[a2] = 0;
}
else
{
v7 = "not locked";
}
}
else
{
v7 = "invalid mode";
}
return fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", v7, a1, a2, a3, a4);
}

original_code:
static void lock_dbg_cb(int mode, int type, const char *file, int line)
{
    static int modes[41];
    const char *errstr = ((void *)0);
    int rw;
    rw = mode & (4 | 8);
    if (!((rw == 4) || (rw == 8))) {
        errstr = "invalid mode";
        goto err;
    }
    if (type < 0 || type >= 41) {
        errstr = "type out of bounds";
        goto err;
    }
    if (mode & 1) {
        if (modes[type]) {
            errstr = "already locked";
            goto err;
        }
        modes[type] = rw;
    } else if (mode & 2) {
        if (!modes[type]) {
            errstr = "not locked";
            goto err;
        }
        if (modes[type] != rw) {
            errstr = (rw == 4) ?
                "CRYPTO_r_unlock on write lock" :
                "CRYPTO_w_unlock on read lock";
        }
        modes[type] = 0;
    } else {
        errstr = "invalid mode";
        goto err;
    }
 err:
    if (errstr) {
        fprintf(stderr,
                "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
                errstr, mode, type, file, line);
    }
}

canonical_original_code:
static void lock_dbg_cb(int mode, int type, char *file, int line)
{
    static int modes[41];
    char *errstr = ((void *)0);
    int rw;
    rw = mode & (4 | 8);
    if (!((rw == 4) || (rw == 8))) {
        errstr = "invalid mode";
        goto err;
    }
    if (type < 0 || type >= 41) {
        errstr = "type out of bounds";
        goto err;
    }
    if (mode & 1) {
        if (modes[type]) {
            errstr = "already locked";
            goto err;
        }
        modes[type] = rw;
    } else if (mode & 2) {
        if (!modes[type]) {
            errstr = "not locked";
            goto err;
        }
        if (modes[type] != rw) {
            errstr = (rw == 4) ?
                "CRYPTO_r_unlock on write lock" :
                "CRYPTO_w_unlock on read lock";
        }
        modes[type] = 0;
    } else {
        errstr = "invalid mode";
        goto err;
    }
 err:
    if (errstr) {
        fprintf(stderr,
                "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
                errstr, mode, type, file, line);
    }
}

variable_types: mode int

variable_types: type int

variable_types:
file
char *

variable_types: line int

variable_types:
modes
int [41]

variable_types:
errstr
char *

variable_types: rw int


decompiled_code:
__int64 ERR_load_COMP_strings()
{
__int64 result; // rax

result = ERR_func_error_string(COMP_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &COMP_str_functs);
result = ERR_load_strings(0LL, &COMP_str_reasons);
}
return result;
}

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

result = ERR_func_error_string(COMP_str_functs);
if ( !result )
{
ERR_load_strings(0LL, &COMP_str_functs);
result = ERR_load_strings(0LL, &COMP_str_reasons);
}
return result;
}

original_code:
void ERR_load_COMP_strings(void)
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(COMP_str_functs[0].error) == NULL) {
        ERR_load_strings(0, COMP_str_functs);
        ERR_load_strings(0, COMP_str_reasons);
    }
#endif
}

canonical_original_code:
void ERR_load_COMP_strings()
{
#ifndef OPENSSL_NO_ERR

    if (ERR_func_error_string(COMP_str_functs[0].error) == NULL) {
        ERR_load_strings(0, COMP_str_functs);
        ERR_load_strings(0, COMP_str_reasons);
    }
#endif
}


decompiled_code:
// attributes: thunk
__int64 __fastcall ex_class_item_LHASH_HASH(int *a1)
{
return ex_class_item_hash(a1);
}

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

original_code: static unsigned long ex_class_item_LHASH_HASH(const void *arg) { const EX_CLASS_ITEM *a = arg; return ex_class_item_hash(a); }

canonical_original_code: static unsigned long ex_class_item_LHASH_HASH(void *arg) { struct st_ex_class_item *a = arg; return ex_class_item_hash(a); }

variable_types: struct st_ex_class_item { int class_index; struct stack_st_CRYPTO_EX_DATA_FUNCS { struct stack_st { int num; char **data; int sorted; int num_alloc; int (*comp)(void *, void *); } stack; } *meth; int meth_num; } *

user_defined_types: struct st_ex_class_item { int class_index; struct stack_st_CRYPTO_EX_DATA_FUNCS *meth; int meth_num; }

user_defined_types: struct stack_st_CRYPTO_EX_DATA_FUNCS { struct stack_st stack; }


decompiled_code:
// attributes: thunk
__int64 __fastcall ex_class_item_LHASH_COMP(_DWORD *a1, _DWORD *a2)
{
return ex_class_item_cmp(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(_DWORD *a1, _DWORD *a2)
{
return func2(a1, a2);
}

original_code: static int ex_class_item_LHASH_COMP(const void *arg1, const void *arg2) { const EX_CLASS_ITEM *a = arg1; const EX_CLASS_ITEM *b = arg2; return ex_class_item_cmp(a,b); }

canonical_original_code: static int ex_class_item_LHASH_COMP(void *arg1, void *arg2) { struct st_ex_class_item *a = arg1; struct st_ex_class_item *b = arg2; return ex_class_item_cmp(a,b); }


decompiled_code:
__int64 def_cleanup_util_cb()
{
return CRYPTO_free();
}

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

original_code:
static void def_cleanup_util_cb(CRYPTO_EX_DATA_FUNCS *funcs)
{
    CRYPTO_free(funcs);
}

canonical_original_code:
static void def_cleanup_util_cb(struct crypto_ex_data_func_st *funcs)
{
    CRYPTO_free(funcs);
}

variable_types: struct crypto_ex_data_func_st { long argl; void *argp; int (*new_func)(void *parent, void *ptr, struct crypto_ex_data_st { struct stack_st_void { struct stack_st { int num; char **data; int sorted; int num_alloc; int (*comp)(void *, void *); } stack; } *sk; int dummy; } *ad, int idx, long argl, void *argp); void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp); int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp); } *

user_defined_types: struct crypto_ex_data_func_st { long argl; void *argp; int (*new_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp); void (*free_func)(void *parent, void *ptr, struct crypto_ex_data_st *ad, int idx, long argl, void *argp); int (*dup_func)(struct crypto_ex_data_st *to, struct crypto_ex_data_st *from, void *from_d, int idx, long argl, void *argp); }