decompiled_code:
__int64 etc_passwd()
{
struct passwd *v0; // rdi
__int64 result; // rax

rb_secure(4LL);
if ( (unsigned int)rb_block_given_p() )
{
if ( passwd_blocking )
{
rb_raise(rb_eRuntimeError, "parallel passwd iteration");
return passwd_iterate();
}
passwd_blocking = 2;
rb_ensure(passwd_iterate, 0LL, passwd_ensure, 0LL);
}
v0 = getpwent();
result = 4LL;
if ( v0 )
result = setup_passwd((__int64)v0);
return result;
}

canonical_decompiled_code:
__int64 func15()
{
struct passwd *v0; // rdi
__int64 result; // rax

rb_secure(4LL);
if ( (unsigned int)rb_block_given_p() )
{
if ( passwd_blocking )
{
rb_raise(rb_eRuntimeError, "parallel passwd iteration");
return func16();
}
passwd_blocking = 2;
rb_ensure(passwd_iterate, 0LL, passwd_ensure, 0LL);
}
v0 = getpwent();
result = 4LL;
if ( v0 )
result = func14((__int64)v0);
return result;
}

original_code:
static VALUE
etc_passwd(VALUE obj)
{
    struct passwd *pw;
    rb_secure(4);
    if (rb_block_given_p()) {
 if (passwd_blocking) {
     rb_raise(rb_eRuntimeError, "parallel passwd iteration");
 }
 passwd_blocking = ((VALUE)RUBY_Qtrue);
 rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
    }
    if (pw = getpwent()) {
 return setup_passwd(pw);
    }
    return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long etc_passwd(unsigned long obj)
{
    struct passwd *pw;
    rb_secure(4);
    if (rb_block_given_p()) {
 if (passwd_blocking) {
     rb_raise(rb_eRuntimeError, "parallel passwd iteration");
 }
 passwd_blocking = ((unsigned long)RUBY_Qtrue);
 rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
    }
    if (pw = getpwent()) {
 return setup_passwd(pw);
    }
    return ((unsigned long)RUBY_Qnil);
}

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


decompiled_code:
__int64 passwd_iterate()
{
__int64 v0; // rax
struct passwd *v1; // rdi

setpwent();
while ( 1 )
{
v1 = getpwent();
if ( !v1 )
break;
v0 = setup_passwd((__int64)v1);
rb_yield(v0);
}
endpwent();
return 4LL;
}

canonical_decompiled_code:
__int64 func16()
{
__int64 v0; // rax
struct passwd *v1; // rdi

setpwent();
while ( 1 )
{
v1 = getpwent();
if ( !v1 )
break;
v0 = func14((__int64)v1);
rb_yield(v0);
}
endpwent();
return 4LL;
}

original_code:
static VALUE
passwd_iterate(void)
{
    struct passwd *pw;
    setpwent();
    while (pw = getpwent()) {
 rb_yield(setup_passwd(pw));
    }
    endpwent();
    return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long passwd_iterate()
{
    struct passwd *pw;
    setpwent();
    while (pw = getpwent()) {
 rb_yield(setup_passwd(pw));
    }
    endpwent();
    return ((unsigned long)RUBY_Qnil);
}

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

return_type: unsigned long


decompiled_code:
__int64 etc_getpwent()
{
struct passwd *v0; // rdi
__int64 result; // rax

v0 = getpwent();
result = 4LL;
if ( v0 )
result = setup_passwd((__int64)v0);
return result;
}

canonical_decompiled_code:
__int64 func17()
{
struct passwd *v0; // rdi
__int64 result; // rax

v0 = getpwent();
result = 4LL;
if ( v0 )
result = func14((__int64)v0);
return result;
}

original_code:
static VALUE
etc_getpwent(VALUE obj)
{
    struct passwd *pw;
    if (pw = getpwent()) {
 return setup_passwd(pw);
    }
    return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long etc_getpwent(unsigned long obj)
{
    struct passwd *pw;
    if (pw = getpwent()) {
 return setup_passwd(pw);
    }
    return ((unsigned long)RUBY_Qnil);
}

variable_types:
obj
unsigned long


decompiled_code:
__int64 __fastcall etc_getpwnam(__int64 a1, _QWORD *a2)
{
const char *v2; // rdi
struct passwd *v3; // rdi
const char *v5; // rdx
_QWORD *v6; // [rsp+8h] [rbp-10h] BYREF

v6 = a2;
rb_string_value(&v6);
rb_check_safe_obj(v6);
if ( (*v6 & 0x2000LL) != 0 )
v2 = (const char *)v6[3];
else
v2 = (const char *)(v6 + 2);
v3 = getpwnam(v2);
if ( v3 )
return setup_passwd((__int64)v3);
v5 = (const char *)(v6 + 2);
if ( (*v6 & 0x2000LL) != 0 )
v5 = (const char *)v6[3];
rb_raise(rb_eArgError, "can't find user for %s", v5);
return etc_getpwuid();
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, _QWORD *a2)
{
const char *v2; // rdi
struct passwd *v3; // rdi
const char *v5; // rdx
_QWORD *v6; // [rsp+8h] [rbp-10h] BYREF

v6 = a2;
rb_string_value(&v6);
rb_check_safe_obj(v6);
if ( (*v6 & 0x2000LL) != 0 )
v2 = (const char *)v6[3];
else
v2 = (const char *)(v6 + 2);
v3 = getpwnam(v2);
if ( v3 )
return func14((__int64)v3);
v5 = (const char *)(v6 + 2);
if ( (*v6 & 0x2000LL) != 0 )
v5 = (const char *)v6[3];
rb_raise(rb_eArgError, "can't find user for %s", v5);
return func19();
}

original_code:
static VALUE
etc_getpwnam(VALUE obj, VALUE nam)
{
    struct passwd *pwd;
    do { rb_string_value(&(nam)); rb_check_safe_obj(nam);} while (0);
    pwd = getpwnam((!(((struct RBasic*)(nam))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(nam))->as.ary : ((struct RString*)(nam))->as.heap.ptr));
    if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", (!(((struct RBasic*)(nam))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(nam))->as.ary : ((struct RString*)(nam))->as.heap.ptr));
    return setup_passwd(pwd);
}

canonical_original_code:
static unsigned long etc_getpwnam(unsigned long obj, unsigned long nam)
{
    struct passwd *pwd;
    do { rb_string_value(&(nam)); rb_check_safe_obj(nam);} while (0);
    pwd = getpwnam((!(((struct RBasic *)(nam))->flags & (((unsigned long)1)<<(12 +1))) ? ((struct RString *)(nam))->as.ary : ((struct RString *)(nam))->as.heap.ptr));
    if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", (!(((struct RBasic *)(nam))->flags & (((unsigned long)1)<<(12 +1))) ? ((struct RString *)(nam))->as.ary : ((struct RString *)(nam))->as.heap.ptr));
    return setup_passwd(pwd);
}

variable_types:
nam
unsigned long

user_defined_types: struct RBasic { unsigned long flags; unsigned long klass; }

user_defined_types: struct RString { struct RBasic basic; union { struct { long len; char *ptr; union { long capa; unsigned long shared; } aux; } heap; char ary[-1]; } as; }


decompiled_code:
__int64 __fastcall etc_getpwuid(unsigned int a1, __int64 a2)
{
__uid_t v2; // ebx
struct passwd *v3; // rdi
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

rb_secure(4LL);
if ( (unsigned int)rb_scan_args(a1, a2, "01", v5) == 1 )
v2 = rb_num2ulong(v5[0]);
else
v2 = getuid();
v3 = getpwuid(v2);
if ( v3 )
return setup_passwd((__int64)v3);
rb_raise(rb_eArgError, "can't find user for %d", v2);
return etc_getlogin();
}

canonical_decompiled_code:
__int64 __fastcall func19(unsigned int a1, __int64 a2)
{
__uid_t v2; // ebx
struct passwd *v3; // rdi
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

rb_secure(4LL);
if ( (unsigned int)rb_scan_args(a1, a2, "01", v5) == 1 )
v2 = rb_num2ulong(v5[0]);
else
v2 = getuid();
v3 = getpwuid(v2);
if ( v3 )
return func14((__int64)v3);
rb_raise(rb_eArgError, "can't find user for %d", v2);
return func20();
}

original_code:
static VALUE
etc_getpwuid(int argc, VALUE *argv, VALUE obj)
{
    VALUE id;
    int uid;
    struct passwd *pwd;
    rb_secure(4);
    if (rb_scan_args(argc, argv, "01", &id) == 1) {
 uid = rb_num2ulong((VALUE)id);
    }
    else {
 uid = getuid();
    }
    pwd = getpwuid(uid);
    if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %d", (int)uid);
    return setup_passwd(pwd);
}

canonical_original_code:
static unsigned long etc_getpwuid(int argc, unsigned long *argv, unsigned long obj)
{
    unsigned long id;
    int uid;
    struct passwd *pwd;
    rb_secure(4);
    if (rb_scan_args(argc, argv, "01", &id) == 1) {
 uid = rb_num2ulong((unsigned long)id);
    }
    else {
 uid = getuid();
    }
    pwd = getpwuid(uid);
    if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %d", (int)uid);
    return setup_passwd(pwd);
}

variable_types: argc int

variable_types:
argv
unsigned long *

variable_types:
id
unsigned long

variable_types: uid int


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

rb_secure(4LL);
v0 = getlogin();
if ( v0 || (v0 = getenv("USER")) != 0LL )
result = rb_tainted_str_new_cstr(v0);
else
result = 4LL;
return result;
}

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

rb_secure(4LL);
v0 = getlogin();
if ( v0 || (v0 = getenv("USER")) != 0LL )
result = rb_tainted_str_new_cstr(v0);
else
result = 4LL;
return result;
}

original_code:
static VALUE
etc_getlogin(VALUE obj)
{
    char *login;
    rb_secure(4);
    login = getlogin();
    if (!login) login = getenv("USER");
    if (login)
 return __extension__ ( { (__builtin_constant_p(login)) ? rb_tainted_str_new(login, strlen(login)) : rb_tainted_str_new_cstr(login); });
    return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long etc_getlogin(unsigned long obj)
{
    char *login;
    rb_secure(4);
    login = getlogin();
    if (!login) login = getenv("USER");
    if (login)
 return __extension__ ( { (__builtin_constant_p(login)) ? rb_tainted_str_new(login, strlen(login)) : rb_tainted_str_new_cstr(login); });
    return ((unsigned long)RUBY_Qnil);
}

variable_types:
login
char *


decompiled_code:
__int64 __fastcall INT2NUM(int a1)
{
return 2LL * a1 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return 2LL * a1 + 1;
}

original_code:
static inline VALUE
INT2NUM(int v)
{
    if (!(((v) < (0x7fffffffffffffffL>>1)+1) && ((v) >= (((long)(-0x7fffffffffffffffL - 1L))>>(int)1))))
 return rb_int2big(v);
    return ((VALUE)(((long)(v))<<1 | RUBY_FIXNUM_FLAG));
}

canonical_original_code:
static inline unsigned long INT2NUM(int v)
{
    if (!(((v) < (0x7fffffffffffffffL>>1)+1) && ((v) >= (((long)(-0x7fffffffffffffffL - 1L))>>(int)1))))
 return rb_int2big(v);
    return ((VALUE)(((long)(v))<<1 | RUBY_FIXNUM_FLAG));
}

variable_types: v int


decompiled_code:
__int64 Init_fcntl()
{
__int64 v0; // rbx
__int64 v1; // r13
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // r12
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // r14

v0 = rb_define_module("Fcntl");
v1 = INT2NUM(0);
rb_define_const(v0, "F_DUPFD", v1);
v2 = INT2NUM(1);
rb_define_const(v0, "F_GETFD", v2);
v3 = INT2NUM(5);
rb_define_const(v0, "F_GETLK", v3);
v4 = INT2NUM(2);
rb_define_const(v0, "F_SETFD", v4);
v5 = INT2NUM(3);
rb_define_const(v0, "F_GETFL", v5);
v6 = INT2NUM(4);
rb_define_const(v0, "F_SETFL", v6);
v7 = INT2NUM(6);
rb_define_const(v0, "F_SETLK", v7);
v8 = INT2NUM(7);
rb_define_const(v0, "F_SETLKW", v8);
rb_define_const(v0, "FD_CLOEXEC", v2);
rb_define_const(v0, "F_RDLCK", v1);
rb_define_const(v0, "F_UNLCK", v4);
rb_define_const(v0, "F_WRLCK", v2);
v9 = INT2NUM(64);
rb_define_const(v0, "O_CREAT", v9);
v10 = INT2NUM(128);
rb_define_const(v0, "O_EXCL", v10);
v11 = INT2NUM(256);
rb_define_const(v0, "O_NOCTTY", v11);
v12 = INT2NUM(512);
rb_define_const(v0, "O_TRUNC", v12);
v13 = INT2NUM(1024);
rb_define_const(v0, "O_APPEND", v13);
v14 = INT2NUM(2048);
rb_define_const(v0, "O_NONBLOCK", v14);
rb_define_const(v0, "O_NDELAY", v14);
rb_define_const(v0, "O_RDONLY", v1);
rb_define_const(v0, "O_RDWR", v4);
rb_define_const(v0, "O_WRONLY", v2);
return rb_define_const(v0, "O_ACCMODE", 7LL);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbx
__int64 v1; // r13
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // r12
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // r14

v0 = rb_define_module("Fcntl");
v1 = func0(0);
rb_define_const(v0, "F_DUPFD", v1);
v2 = func0(1);
rb_define_const(v0, "F_GETFD", v2);
v3 = func0(5);
rb_define_const(v0, "F_GETLK", v3);
v4 = func0(2);
rb_define_const(v0, "F_SETFD", v4);
v5 = func0(3);
rb_define_const(v0, "F_GETFL", v5);
v6 = func0(4);
rb_define_const(v0, "F_SETFL", v6);
v7 = func0(6);
rb_define_const(v0, "F_SETLK", v7);
v8 = func0(7);
rb_define_const(v0, "F_SETLKW", v8);
rb_define_const(v0, "FD_CLOEXEC", v2);
rb_define_const(v0, "F_RDLCK", v1);
rb_define_const(v0, "F_UNLCK", v4);
rb_define_const(v0, "F_WRLCK", v2);
v9 = func0(64);
rb_define_const(v0, "O_CREAT", v9);
v10 = func0(128);
rb_define_const(v0, "O_EXCL", v10);
v11 = func0(256);
rb_define_const(v0, "O_NOCTTY", v11);
v12 = func0(512);
rb_define_const(v0, "O_TRUNC", v12);
v13 = func0(1024);
rb_define_const(v0, "O_APPEND", v13);
v14 = func0(2048);
rb_define_const(v0, "O_NONBLOCK", v14);
rb_define_const(v0, "O_NDELAY", v14);
rb_define_const(v0, "O_RDONLY", v1);
rb_define_const(v0, "O_RDWR", v4);
rb_define_const(v0, "O_WRONLY", v2);
return rb_define_const(v0, "O_ACCMODE", 7LL);
}

original_code:
void
Init_fcntl()
{
    VALUE mFcntl = rb_define_module("Fcntl");
    rb_define_const(mFcntl, "F_DUPFD", INT2NUM(0));
    rb_define_const(mFcntl, "F_GETFD", INT2NUM(1));
    rb_define_const(mFcntl, "F_GETLK", INT2NUM(5));
    rb_define_const(mFcntl, "F_SETFD", INT2NUM(2));
    rb_define_const(mFcntl, "F_GETFL", INT2NUM(3));
    rb_define_const(mFcntl, "F_SETFL", INT2NUM(4));
    rb_define_const(mFcntl, "F_SETLK", INT2NUM(6));
    rb_define_const(mFcntl, "F_SETLKW", INT2NUM(7));
    rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(1));
    rb_define_const(mFcntl, "F_RDLCK", INT2NUM(0));
    rb_define_const(mFcntl, "F_UNLCK", INT2NUM(2));
    rb_define_const(mFcntl, "F_WRLCK", INT2NUM(1));
    rb_define_const(mFcntl, "O_CREAT", INT2NUM(0100));
    rb_define_const(mFcntl, "O_EXCL", INT2NUM(0200));
    rb_define_const(mFcntl, "O_NOCTTY", INT2NUM(0400));
    rb_define_const(mFcntl, "O_TRUNC", INT2NUM(01000));
    rb_define_const(mFcntl, "O_APPEND", INT2NUM(02000));
    rb_define_const(mFcntl, "O_NONBLOCK", INT2NUM(04000));
    rb_define_const(mFcntl, "O_NDELAY", INT2NUM(04000));
    rb_define_const(mFcntl, "O_RDONLY", INT2NUM(00));
    rb_define_const(mFcntl, "O_RDWR", INT2NUM(02));
    rb_define_const(mFcntl, "O_WRONLY", INT2NUM(01));
    rb_define_const(mFcntl, "O_ACCMODE", ((VALUE)(((long)(0003))<<1 | RUBY_FIXNUM_FLAG)));
}

canonical_original_code:
void Init_fcntl()
{
    unsigned long mFcntl = rb_define_module("Fcntl");
    rb_define_const(mFcntl, "F_DUPFD", INT2NUM(0));
    rb_define_const(mFcntl, "F_GETFD", INT2NUM(1));
    rb_define_const(mFcntl, "F_GETLK", INT2NUM(5));
    rb_define_const(mFcntl, "F_SETFD", INT2NUM(2));
    rb_define_const(mFcntl, "F_GETFL", INT2NUM(3));
    rb_define_const(mFcntl, "F_SETFL", INT2NUM(4));
    rb_define_const(mFcntl, "F_SETLK", INT2NUM(6));
    rb_define_const(mFcntl, "F_SETLKW", INT2NUM(7));
    rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(1));
    rb_define_const(mFcntl, "F_RDLCK", INT2NUM(0));
    rb_define_const(mFcntl, "F_UNLCK", INT2NUM(2));
    rb_define_const(mFcntl, "F_WRLCK", INT2NUM(1));
    rb_define_const(mFcntl, "O_CREAT", INT2NUM(0100));
    rb_define_const(mFcntl, "O_EXCL", INT2NUM(0200));
    rb_define_const(mFcntl, "O_NOCTTY", INT2NUM(0400));
    rb_define_const(mFcntl, "O_TRUNC", INT2NUM(01000));
    rb_define_const(mFcntl, "O_APPEND", INT2NUM(02000));
    rb_define_const(mFcntl, "O_NONBLOCK", INT2NUM(04000));
    rb_define_const(mFcntl, "O_NDELAY", INT2NUM(04000));
    rb_define_const(mFcntl, "O_RDONLY", INT2NUM(00));
    rb_define_const(mFcntl, "O_RDWR", INT2NUM(02));
    rb_define_const(mFcntl, "O_WRONLY", INT2NUM(01));
    rb_define_const(mFcntl, "O_ACCMODE", ((VALUE)(((long)(0003))<<1 | RUBY_FIXNUM_FLAG)));
}

variable_types:
mFcntl
unsigned long

return_type: void


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

result = *(_QWORD *)a1;
if ( *(_QWORD *)a1 && *(_DWORD *)(a1 + 8) )
{
if ( *(_DWORD *)(a1 + 12) )
result = sub_1E();
}
return result;
}

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

result = *(_QWORD *)a1;
if ( *(_QWORD *)a1 && *(_DWORD *)(a1 + 8) )
{
if ( *(_DWORD *)(a1 + 12) )
result = sub_1E();
}
return result;
}

original_code:
void
dlhandle_free(struct dl_handle *dlhandle)
{
  if( dlhandle->ptr && dlhandle->open && dlhandle->enable_close ){
    dlclose(dlhandle->ptr);
  }
}

variable_types: struct dl_handle { void *ptr; int open; int enable_close; } *


decompiled_code:
__int64 __fastcall rb_dlhandle_close(__int64 a1)
{
__int64 v1; // rax
int v2; // eax

rb_check_type(a1, 12LL);
v1 = *(_QWORD *)(a1 + 32);
*(_DWORD *)(v1 + 8) = 0;
v2 = dlclose(*(void **)v1);
return INT2NUM(v2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rax
int v2; // eax

rb_check_type(a1, 12LL);
v1 = *(_QWORD *)(a1 + 32);
*(_DWORD *)(v1 + 8) = 0;
v2 = dlclose(*(void **)v1);
return func0(v2);
}

original_code:
VALUE
rb_dlhandle_close(VALUE self)
{
  struct dl_handle *dlhandle;
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle*)(((struct RData*)(self))->data);} while (0);
  dlhandle->open = 0;
  return INT2NUM(dlclose(dlhandle->ptr));
}

canonical_original_code:
unsigned long rb_dlhandle_close(unsigned long self)
{
  struct dl_handle *dlhandle;
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle *)(((struct RData *)(self))->data);} while (0);
  dlhandle->open = 0;
  return INT2NUM(dlclose(dlhandle->ptr));
}

variable_types:
self
unsigned long

user_defined_types: struct dl_handle { void *ptr; int open; int enable_close; }

user_defined_types: struct RData { struct RBasic basic; void (*dmark)(void *); void (*dfree)(void *); void *data; }


decompiled_code:
__int64 __fastcall rb_dlhandle_enable_close(__int64 a1)
{
rb_check_type(a1, 12LL);
*(_DWORD *)(*(_QWORD *)(a1 + 32) + 12LL) = 1;
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
rb_check_type(a1, 12LL);
*(_DWORD *)(*(_QWORD *)(a1 + 32) + 12LL) = 1;
return 4LL;
}

original_code:
VALUE
rb_dlhandle_enable_close(VALUE self)
{
  struct dl_handle *dlhandle;
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle*)(((struct RData*)(self))->data);} while (0);
  dlhandle->enable_close = 1;
  return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
unsigned long rb_dlhandle_enable_close(unsigned long self)
{
  struct dl_handle *dlhandle;
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle *)(((struct RData *)(self))->data);} while (0);
  dlhandle->enable_close = 1;
  return ((unsigned long)RUBY_Qnil);
}


decompiled_code:
__int64 __fastcall rb_dlhandle_disable_close(__int64 a1)
{
rb_check_type(a1, 12LL);
*(_DWORD *)(*(_QWORD *)(a1 + 32) + 12LL) = 0;
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
rb_check_type(a1, 12LL);
*(_DWORD *)(*(_QWORD *)(a1 + 32) + 12LL) = 0;
return 4LL;
}

original_code:
VALUE
rb_dlhandle_disable_close(VALUE self)
{
  struct dl_handle *dlhandle;
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle*)(((struct RData*)(self))->data);} while (0);
  dlhandle->enable_close = 0;
  return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
unsigned long rb_dlhandle_disable_close(unsigned long self)
{
  struct dl_handle *dlhandle;
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle *)(((struct RData *)(self))->data);} while (0);
  dlhandle->enable_close = 0;
  return ((unsigned long)RUBY_Qnil);
}


decompiled_code:
__int64 rb_dlhandle_s_allocate()
{
__int64 v0; // rbx
__int64 result; // rax

v0 = ruby_xmalloc(16LL);
*(_QWORD *)v0 = 0LL;
*(_QWORD *)(v0 + 8) = 0LL;
result = rb_data_object_alloc(rb_cDLHandle, v0, 0LL, dlhandle_free);
*(_QWORD *)v0 = 0LL;
*(_DWORD *)(v0 + 8) = 0;
*(_DWORD *)(v0 + 12) = 0;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rbx
__int64 result; // rax

v0 = ruby_xmalloc(16LL);
*(_QWORD *)v0 = 0LL;
*(_QWORD *)(v0 + 8) = 0LL;
result = rb_data_object_alloc(rb_cDLHandle, v0, 0LL, dlhandle_free);
*(_QWORD *)v0 = 0LL;
*(_DWORD *)(v0 + 8) = 0;
*(_DWORD *)(v0 + 12) = 0;
return result;
}

original_code:
VALUE
rb_dlhandle_s_allocate(VALUE klass)
{
  VALUE obj;
  struct dl_handle *dlhandle;
  obj = ( dlhandle = (struct dl_handle*)ruby_xmalloc(sizeof(struct dl_handle)), memset(dlhandle, 0, sizeof(struct dl_handle)), rb_data_object_alloc(rb_cDLHandle,dlhandle,(RUBY_DATA_FUNC)0,(RUBY_DATA_FUNC)dlhandle_free));
  dlhandle->ptr = 0;
  dlhandle->open = 0;
  dlhandle->enable_close = 0;
  return obj;
}

canonical_original_code:
unsigned long rb_dlhandle_s_allocate(unsigned long klass)
{
  unsigned long obj;
  struct dl_handle *dlhandle;
  obj = ( dlhandle = (struct dl_handle *)ruby_xmalloc(sizeof(struct dl_handle)), memset(dlhandle, 0, sizeof(struct dl_handle)), rb_data_object_alloc(rb_cDLHandle,dlhandle,(void (*)(void *))0,(void (*)(void *))dlhandle_free));
  dlhandle->ptr = 0;
  dlhandle->open = 0;
  dlhandle->enable_close = 0;
  return obj;
}

variable_types:
klass
unsigned long


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

if ( (a1 & 1) != 0 )
result = a1 >> 1;
else
result = sub_125();
return result;
}

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

if ( (a1 & 1) != 0 )
result = a1 >> 1;
else
result = sub_125();
return result;
}

original_code:
static inline long
NUM2LONG(VALUE x)
{
    return (((long)(x))&RUBY_FIXNUM_FLAG) ? (((long)x)>>(int)1) : rb_num2long(x);
}

canonical_original_code:
static inline long NUM2LONG(unsigned long x)
{
    return (((long)(x))&RUBY_FIXNUM_FLAG) ? (((long)x)>>(int)1) : rb_num2long(x);
}

variable_types:
x
unsigned long

return_type: long


decompiled_code:
__int64 __fastcall rb_dlhandle_initialize(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // eax
int v5; // esi
__int64 v6; // rbx
void *v7; // r13
void *v8; // rdi
char *v10; // rax
__int64 v11; // [rsp+0h] [rbp-30h] BYREF
__int64 v12[5]; // [rsp+8h] [rbp-28h] BYREF

v4 = rb_scan_args(a1, a2, &LC0, v12, &v11);
if ( v4 == 1 )
{
LABEL_5:
if ( v12[0] == 4 )
{
v5 = 257;
v6 = 0LL;
}
else
{
rb_string_value(v12);
rb_check_safe_obj(v12[0]);
if ( (*(_QWORD *)v12[0] & 0x2000LL) != 0 )
v6 = *(_QWORD *)(v12[0] + 24);
else
v6 = v12[0] + 16;
v5 = 257;
}
goto LABEL_17;
}
if ( v4 != 2 )
{
if ( !v4 )
{
v5 = 257;
v6 = 0LL;
goto LABEL_17;
}
rb_bug("rb_dlhandle_new");
goto LABEL_5;
}
v6 = 0LL;
if ( v12[0] != 4 )
{
rb_string_value(v12);
rb_check_safe_obj(v12[0]);
if ( (*(_QWORD *)v12[0] & 0x2000LL) != 0 )
v6 = *(_QWORD *)(v12[0] + 24);
else
v6 = v12[0] + 16;
}
v5 = NUM2LONG(v11);
LABEL_17:
v7 = dlopen((const char *)v6, v5);
if ( !v7 )
{
v10 = dlerror();
if ( v10 )
{
v8 = (void *)rb_eDLError;
rb_raise(rb_eDLError, "%s", v10);
LABEL_26:
dlclose(v8);
goto LABEL_21;
}
}
rb_check_type(a3, 12LL);
v6 = *(_QWORD *)(a3 + 32);
v8 = *(void **)v6;
if ( *(_QWORD *)v6 && *(_DWORD *)(v6 + 8) && *(_DWORD *)(v6 + 12) )
goto LABEL_26;
LABEL_21:
*(_QWORD *)v6 = v7;
*(_DWORD *)(v6 + 8) = 1;
*(_DWORD *)(v6 + 12) = 0;
if ( (unsigned int)rb_block_given_p() )
rb_ensure(&rb_yield, a3, rb_dlhandle_close, a3);
return 4LL;
}

original_code:
VALUE
rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
{
  void *ptr;
  struct dl_handle *dlhandle;
  VALUE lib, flag;
  char *clib;
  int cflag;
  const char *err;
  switch( rb_scan_args(argc, argv, "02", &lib, &flag) ){
  case 0:
    clib = ((void *)0);
    cflag = 0x00001 | 0x00100;
    break;
  case 1:
    clib = ((VALUE)(lib) == ((VALUE)RUBY_Qnil)) ? ((void *)0) : (rb_string_value(&lib), rb_check_safe_obj(lib), (!(((struct RBasic*)(lib))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(lib))->as.ary : ((struct RString*)(lib))->as.heap.ptr));
    cflag = 0x00001 | 0x00100;
    break;
  case 2:
    clib = ((VALUE)(lib) == ((VALUE)RUBY_Qnil)) ? ((void *)0) : (rb_string_value(&lib), rb_check_safe_obj(lib), (!(((struct RBasic*)(lib))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(lib))->as.ary : ((struct RString*)(lib))->as.heap.ptr));
    cflag = ((int)NUM2LONG(flag));
    break;
  default:
    rb_bug("rb_dlhandle_new");
  }
  ptr = dlopen(clib, cflag);
  if( !ptr && (err = dlerror()) ){
    rb_raise(rb_eDLError, "%s", err);
  }
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle*)(((struct RData*)(self))->data);} while (0);
  if( dlhandle->ptr && dlhandle->open && dlhandle->enable_close ){
    dlclose(dlhandle->ptr);
  }
  dlhandle->ptr = ptr;
  dlhandle->open = 1;
  dlhandle->enable_close = 0;
  if( rb_block_given_p() ){
    rb_ensure(rb_yield, self, rb_dlhandle_close, self);
  }
  return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
unsigned long rb_dlhandle_initialize(int argc, unsigned long argv[], unsigned long self)
{
  void *ptr;
  struct dl_handle *dlhandle;
  unsigned long lib; unsigned long flag;
  char *clib;
  int cflag;
  char *err;
  switch( rb_scan_args(argc, argv, "02", &lib, &flag) ){
  case 0:
    clib = ((void *)0);
    cflag = 0x00001 | 0x00100;
    break;
  case 1:
    clib = ((VALUE)(lib) == ((unsigned long)RUBY_Qnil)) ? ((void *)0) : (rb_string_value(&lib), rb_check_safe_obj(lib), (!(((struct RBasic *)(lib))->flags & (((unsigned long)1)<<(12 +1))) ? ((struct RString *)(lib))->as.ary : ((struct RString *)(lib))->as.heap.ptr));
    cflag = 0x00001 | 0x00100;
    break;
  case 2:
    clib = ((VALUE)(lib) == ((unsigned long)RUBY_Qnil)) ? ((void *)0) : (rb_string_value(&lib), rb_check_safe_obj(lib), (!(((struct RBasic *)(lib))->flags & (((unsigned long)1)<<(12 +1))) ? ((struct RString *)(lib))->as.ary : ((struct RString *)(lib))->as.heap.ptr));
    cflag = ((int)NUM2LONG(flag));
    break;
  default:
    rb_bug("rb_dlhandle_new");
  }
  ptr = dlopen(clib, cflag);
  if( !ptr && (err = dlerror()) ){
    rb_raise(rb_eDLError, "%s", err);
  }
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle *)(((struct RData *)(self))->data);} while (0);
  if( dlhandle->ptr && dlhandle->open && dlhandle->enable_close ){
    dlclose(dlhandle->ptr);
  }
  dlhandle->ptr = ptr;
  dlhandle->open = 1;
  dlhandle->enable_close = 0;
  if( rb_block_given_p() ){
    rb_ensure(rb_yield, self, rb_dlhandle_close, self);
  }
  return ((unsigned long)RUBY_Qnil);
}

variable_types:
argv
unsigned long []

variable_types:
ptr
void *

variable_types:
lib
unsigned long

variable_types:
flag
unsigned long

variable_types:
clib
char *

variable_types: cflag int

variable_types:
err
char *


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

if ( a1 > 0x3FFFFFFFFFFFFFFFLL )
result = sub_2D4();
else
result = 2 * a1 + 1;
return result;
}

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

if ( a1 > 0x3FFFFFFFFFFFFFFFLL )
result = sub_2D4();
else
result = 2 * a1 + 1;
return result;
}

original_code:
static inline VALUE
ULONG2NUM(unsigned long v)
{
    if (((v) < (0x7fffffffffffffffL>>1)+1)) return ((VALUE)(((long)(v))<<1 | RUBY_FIXNUM_FLAG));
    return rb_uint2big(v);
}

canonical_original_code:
static inline unsigned long ULONG2NUM(unsigned long v)
{
    if (((v) < (0x7fffffffffffffffL>>1)+1)) return ((VALUE)(((long)(v))<<1 | RUBY_FIXNUM_FLAG));
    return rb_uint2big(v);
}

variable_types:
v
unsigned long


decompiled_code:
__int64 __fastcall rb_dlhandle_to_i(__int64 a1)
{
rb_check_type(a1, 12LL);
return ULONG2NUM(*(_QWORD *)(a1 + 32));
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
rb_check_type(a1, 12LL);
return func8(*(_QWORD *)(a1 + 32));
}

original_code:
VALUE
rb_dlhandle_to_i(VALUE self)
{
  struct dl_handle *dlhandle;
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle*)(((struct RData*)(self))->data);} while (0);
  return (ULONG2NUM((unsigned long)(dlhandle)));
}

canonical_original_code:
unsigned long rb_dlhandle_to_i(unsigned long self)
{
  struct dl_handle *dlhandle;
  do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle *)(((struct RData *)(self))->data);} while (0);
  return (ULONG2NUM((unsigned long)(dlhandle)));
}


decompiled_code:
__int64 __fastcall rb_dlhandle_sym(_QWORD *a1, _QWORD *a2)
{
void *v2; // r14
void *v3; // rbx
char *v4; // rax
__int64 v5; // rax
char *v6; // r13
unsigned int v7; // ebx
char *v8; // r15
void *v9; // r12
unsigned int v11; // ebx
void *v12; // r12
int v13; // [rsp+8h] [rbp-58h]
char *v14; // [rsp+10h] [rbp-50h]
char *name; // [rsp+18h] [rbp-48h]
unsigned __int64 v16; // [rsp+20h] [rbp-40h]
__int64 v17[7]; // [rsp+28h] [rbp-38h] BYREF

v3 = a1;
v17[0] = (__int64)a2;
rb_secure(2LL);
rb_string_value(v17);
rb_check_safe_obj(v17[0]);
if ( (*(_QWORD *)v17[0] & 0x2000LL) != 0 )
v4 = *(char **)(v17[0] + 24);
else
v4 = (char *)(v17[0] + 16);
name = v4;
rb_check_type(a1, 12LL);
v5 = a1[4];
if ( !*(_DWORD *)(v5 + 8) )
{
rb_raise(rb_eDLError, "closed handle");
LABEL_8:
v16 = (unsigned __int64)v3;
if ( v3 )
return ULONG2NUM(v16);
goto LABEL_5;
}
v2 = *(void **)v5;
v3 = dlsym(*(void **)v5, name);
if ( !dlerror() )
goto LABEL_8;
LABEL_5:
v13 = strlen(name);
v6 = (char *)ruby_xmalloc(v13 + 6);
memcpy(v6, name, v13);
v14 = &v6[v13];
*v14 = 64;
v7 = 0;
v8 = &v6[v13 + 1];
while ( 1 )
{
sprintf(v8, "%d", v7);
v9 = dlsym(v2, v6);
if ( !dlerror() )
{
v16 = (unsigned __int64)v9;
if ( v9 )
break;
}
v7 += 4;
if ( v7 == 256 )
{
*v14 = 65;
*v8 = 64;
v11 = 0;
while ( 1 )
{
sprintf(&v6[v13 + 2], "%d", v11);
v12 = dlsym(v2, v6);
if ( !dlerror() )
{
v16 = (unsigned __int64)v12;
if ( v12 )
break;
}
v11 += 4;
if ( v11 == 256 )
{
ruby_xfree(v6);
rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
return Init_dlhandle();
}
}
break;
}
}
ruby_xfree(v6);
return ULONG2NUM(v16);
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1, _QWORD *a2)
{
void *v2; // r14
void *v3; // rbx
char *v4; // rax
__int64 v5; // rax
char *v6; // r13
unsigned int v7; // ebx
char *v8; // r15
void *v9; // r12
unsigned int v11; // ebx
void *v12; // r12
int v13; // [rsp+8h] [rbp-58h]
char *v14; // [rsp+10h] [rbp-50h]
char *name; // [rsp+18h] [rbp-48h]
unsigned __int64 v16; // [rsp+20h] [rbp-40h]
__int64 v17[7]; // [rsp+28h] [rbp-38h] BYREF

v3 = a1;
v17[0] = (__int64)a2;
rb_secure(2LL);
rb_string_value(v17);
rb_check_safe_obj(v17[0]);
if ( (*(_QWORD *)v17[0] & 0x2000LL) != 0 )
v4 = *(char **)(v17[0] + 24);
else
v4 = (char *)(v17[0] + 16);
name = v4;
rb_check_type(a1, 12LL);
v5 = a1[4];
if ( !*(_DWORD *)(v5 + 8) )
{
rb_raise(rb_eDLError, "closed handle");
LABEL_8:
v16 = (unsigned __int64)v3;
if ( v3 )
return func8(v16);
goto LABEL_5;
}
v2 = *(void **)v5;
v3 = dlsym(*(void **)v5, name);
if ( !dlerror() )
goto LABEL_8;
LABEL_5:
v13 = strlen(name);
v6 = (char *)ruby_xmalloc(v13 + 6);
memcpy(v6, name, v13);
v14 = &v6[v13];
*v14 = 64;
v7 = 0;
v8 = &v6[v13 + 1];
while ( 1 )
{
sprintf(v8, "%d", v7);
v9 = dlsym(v2, v6);
if ( !dlerror() )
{
v16 = (unsigned __int64)v9;
if ( v9 )
break;
}
v7 += 4;
if ( v7 == 256 )
{
*v14 = 65;
*v8 = 64;
v11 = 0;
while ( 1 )
{
sprintf(&v6[v13 + 2], "%d", v11);
v12 = dlsym(v2, v6);
if ( !dlerror() )
{
v16 = (unsigned __int64)v12;
if ( v12 )
break;
}
v11 += 4;
if ( v11 == 256 )
{
ruby_xfree(v6);
rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
return func11();
}
}
break;
}
}
ruby_xfree(v6);
return func8(v16);
}

original_code:
VALUE
rb_dlhandle_sym(VALUE self, VALUE sym)
{
    void (*func)();
    struct dl_handle *dlhandle;
    void *handle;
    const char *name;
    const char *err;
    int i;
    rb_secure(2);
    name = (rb_string_value(&sym), rb_check_safe_obj(sym), (!(((struct RBasic*)(sym))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(sym))->as.ary : ((struct RString*)(sym))->as.heap.ptr));
    do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle*)(((struct RData*)(self))->data);} while (0);
    if( ! dlhandle->open ){
 rb_raise(rb_eDLError, "closed handle");
    }
    handle = dlhandle->ptr;
    func = dlsym(handle, name);
    if( err = dlerror() ){ func = 0; };
    if( !func ){
 int len = strlen(name);
 char *name_n;
 name_n = (char*)ruby_xmalloc(len+6);
 memcpy(name_n, name, len);
 name_n[len++] = '@';
 for( i = 0; i < 256; i += 4 ){
     sprintf(name_n + len, "%d", i);
     func = dlsym(handle, name_n);
     if( err = dlerror() ){ func = 0; };
     if( func ) break;
 }
 if( func ) goto found;
 name_n[len-1] = 'A';
 name_n[len++] = '@';
 for( i = 0; i < 256; i += 4 ){
     sprintf(name_n + len, "%d", i);
     func = dlsym(handle, name_n);
     if( err = dlerror() ){ func = 0; };
     if( func ) break;
 }
      found:
 ruby_xfree(name_n);
    }
    if( !func ){
 rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
    }
    return (ULONG2NUM((unsigned long)(func)));
}

canonical_original_code:
unsigned long rb_dlhandle_sym(unsigned long self, unsigned long sym)
{
    void (*func)();
    struct dl_handle *dlhandle;
    void *handle;
    char *name;
    char *err;
    int i;
    rb_secure(2);
    name = (rb_string_value(&sym), rb_check_safe_obj(sym), (!(((struct RBasic *)(sym))->flags & (((unsigned long)1)<<(12 +1))) ? ((struct RString *)(sym))->as.ary : ((struct RString *)(sym))->as.heap.ptr));
    do { rb_check_type((VALUE)(self),RUBY_T_DATA); dlhandle = (struct dl_handle *)(((struct RData *)(self))->data);} while (0);
    if( ! dlhandle->open ){
 rb_raise(rb_eDLError, "closed handle");
    }
    handle = dlhandle->ptr;
    func = dlsym(handle, name);
    if( err = dlerror() ){ func = 0; };
    if( !func ){
 int len = strlen(name);
 char *name_n;
 name_n = (char *)ruby_xmalloc(len+6);
 memcpy(name_n, name, len);
 name_n[len++] = '@';
 for( i = 0; i < 256; i += 4 ){
     sprintf(name_n + len, "%d", i);
     func = dlsym(handle, name_n);
     if( err = dlerror() ){ func = 0; };
     if( func ) break;
 }
 if( func ) goto found;
 name_n[len-1] = 'A';
 name_n[len++] = '@';
 for( i = 0; i < 256; i += 4 ){
     sprintf(name_n + len, "%d", i);
     func = dlsym(handle, name_n);
     if( err = dlerror() ){ func = 0; };
     if( func ) break;
 }
      found:
 ruby_xfree(name_n);
    }
    if( !func ){
 rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
    }
    return (ULONG2NUM((unsigned long)(func)));
}

variable_types:
sym
unsigned long

variable_types:
func
void (*)()

variable_types:
handle
void *

variable_types:
name
char *

variable_types: i int

variable_types: len int


decompiled_code:
__int64 Init_dlhandle()
{
rb_cDLHandle = rb_define_class_under(rb_mDL, "Handle", rb_cObject);
rb_define_alloc_func(rb_cDLHandle, rb_dlhandle_s_allocate);
rb_define_method(rb_cDLHandle, "initialize", rb_dlhandle_initialize, 0xFFFFFFFFLL);
rb_define_method(rb_cDLHandle, "to_i", rb_dlhandle_to_i, 0LL);
rb_define_method(rb_cDLHandle, "close", rb_dlhandle_close, 0LL);
rb_define_method(rb_cDLHandle, "sym", rb_dlhandle_sym, 1LL);
rb_define_method(rb_cDLHandle, "[]", rb_dlhandle_sym, 1LL);
rb_define_method(rb_cDLHandle, "disable_close", rb_dlhandle_disable_close, 0LL);
return rb_define_method(rb_cDLHandle, "enable_close", rb_dlhandle_enable_close, 0LL);
}

canonical_decompiled_code:
__int64 func11()
{
rb_cDLHandle = rb_define_class_under(rb_mDL, "Handle", rb_cObject);
rb_define_alloc_func(rb_cDLHandle, rb_dlhandle_s_allocate);
rb_define_method(rb_cDLHandle, "initialize", rb_dlhandle_initialize, 0xFFFFFFFFLL);
rb_define_method(rb_cDLHandle, "to_i", rb_dlhandle_to_i, 0LL);
rb_define_method(rb_cDLHandle, "close", rb_dlhandle_close, 0LL);
rb_define_method(rb_cDLHandle, "sym", rb_dlhandle_sym, 1LL);
rb_define_method(rb_cDLHandle, "[]", rb_dlhandle_sym, 1LL);
rb_define_method(rb_cDLHandle, "disable_close", rb_dlhandle_disable_close, 0LL);
return rb_define_method(rb_cDLHandle, "enable_close", rb_dlhandle_enable_close, 0LL);
}

original_code:
void
Init_dlhandle()
{
    rb_cDLHandle = rb_define_class_under(rb_mDL, "Handle", rb_cObject);
    rb_define_alloc_func(rb_cDLHandle, rb_dlhandle_s_allocate);
    rb_define_method(rb_cDLHandle, "initialize", rb_dlhandle_initialize, -1);
    rb_define_method(rb_cDLHandle, "to_i", rb_dlhandle_to_i, 0);
    rb_define_method(rb_cDLHandle, "close", rb_dlhandle_close, 0);
    rb_define_method(rb_cDLHandle, "sym", rb_dlhandle_sym, 1);
    rb_define_method(rb_cDLHandle, "[]", rb_dlhandle_sym, 1);
    rb_define_method(rb_cDLHandle, "disable_close", rb_dlhandle_disable_close, 0);
    rb_define_method(rb_cDLHandle, "enable_close", rb_dlhandle_enable_close, 0);
}


original_code:
long
syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
{
    char *beg;
    long len = 0;
    ((void)0);
    beg = str->ptr;
    if ( max_size >= 0 )
    {
        max_size -= skip;
        if ( max_size <= 0 ) max_size = 0;
        else str->ptr += max_size;
        if ( str->ptr > str->end )
        {
            str->ptr = str->end;
        }
    }
    else
    {
        while ( str->ptr < str->end ) {
            if (*(str->ptr++) == '\n') break;
        }
    }
    if ( beg < str->ptr )
    {
        len = ( str->ptr - beg );
        memcpy((buf + skip), (beg), sizeof(char)*(len));
    }
    len += skip;
    buf[len] = '\0';
    return len;
}

canonical_original_code:
long syck_io_str_read(char *buf, struct _syck_str *str, long max_size, long skip)
{
    char *beg;
    long len = 0;
    ((void)0);
    beg = str->ptr;
    if ( max_size >= 0 )
    {
        max_size -= skip;
        if ( max_size <= 0 ) max_size = 0;
        else str->ptr += max_size;
        if ( str->ptr > str->end )
        {
            str->ptr = str->end;
        }
    }
    else
    {
        while ( str->ptr < str->end ) {
            if (*(str->ptr++) == '\n') break;
        }
    }
    if ( beg < str->ptr )
    {
        len = ( str->ptr - beg );
        memcpy((buf + skip), (beg), sizeof(char)*(len));
    }
    len += skip;
    buf[len] = '\0';
    return len;
}

variable_types:
buf
char *

variable_types: struct _syck_str { char *beg; long (*read)(char *, struct _syck_str *, long, long); } *

variable_types: skip long

variable_types:
beg
char *

variable_types: len long


decompiled_code:
__int64 __fastcall syck_st_free_nodes(__int64 a1, __int64 a2)
{
if ( a2 != 1 )
syck_free_node(a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
if ( a2 != 1 )
syck_free_node(a2);
return 0LL;
}

original_code:
int
syck_st_free_nodes( char *key, SyckNode *n, char *arg )
{
    if ( n != (void *)1 ) syck_free_node( n );
    n = ((void *)0);
    return ST_CONTINUE;
}

canonical_original_code:
int syck_st_free_nodes(char *key, struct _syck_node *n, char *arg)
{
    if ( n != (void *)1 ) syck_free_node( n );
    n = ((void *)0);
    return ST_CONTINUE;
}

variable_types:
key
char *

variable_types: struct _syck_node { unsigned long id; enum syck_kind_tag { syck_map_kind=0, syck_seq_kind=1, syck_str_kind=2 } kind; char *type_id; char *anchor; union { struct SyckMap { enum map_style { map_none=0, map_inline=1 } style; unsigned long *keys; unsigned long *values; long capa; long idx; } *pairs; struct SyckSeq { enum seq_style { seq_none=0, seq_inline=1 } style; unsigned long *items; long capa; long idx; } *list; struct SyckStr { enum scalar_style { scalar_none=0, scalar_1quote=1, scalar_2quote=2, scalar_fold=3, scalar_literal=4, scalar_plain=5 } style; char *ptr; long len; } *str; } data; void *shortcut; } *

variable_types:
arg
char *

return_type: int

user_defined_types: struct _syck_node { unsigned long id; enum syck_kind_tag kind; char *type_id; char *anchor; union { struct SyckMap *pairs; struct SyckSeq *list; struct SyckStr *str; } data; void *shortcut; }

user_defined_types: struct SyckMap { enum map_style style; unsigned long *keys; unsigned long *values; long capa; long idx; }

user_defined_types: struct SyckSeq { enum seq_style style; unsigned long *items; long capa; long idx; }

user_defined_types: struct SyckStr { enum scalar_style style; char *ptr; long len; }


decompiled_code:
__int64 __fastcall syck_st_free_syms(__int64 a1, _QWORD *a2)
{
void *v2; // rdi

v2 = (void *)a2[1];
if ( v2 )
free(v2);
free(a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _QWORD *a2)
{
void *v2; // rdi

v2 = (void *)a2[1];
if ( v2 )
free(v2);
free(a2);
return 0LL;
}

original_code:
int
syck_st_free_syms( void *key, bytestring_t *sav, void *dummy )
{
    if (sav->buffer) { free(sav->buffer); sav->buffer = ((void *)0); };
    if (sav) { free(sav); sav = ((void *)0); };
    return ST_CONTINUE;
}

canonical_original_code:
int syck_st_free_syms(void *key, struct bytestring_t *sav, void *dummy)
{
    if (sav->buffer) { free(sav->buffer); sav->buffer = ((void *)0); };
    if (sav) { free(sav); sav = ((void *)0); };
    return ST_CONTINUE;
}

variable_types:
key
void *

variable_types: struct bytestring_t { long hash; char *buffer; long length; long remaining; int printed; } *

variable_types:
dummy
void *


decompiled_code:
void __fastcall __noreturn syck_assert(const char *a1, unsigned int a2, const char *a3)
{
fflush(0LL);
fprintf(stderr, "\nAssertion failed: %s, line %u: %s\n", a1, a2, a3);
fflush(stderr);
abort();
}

canonical_decompiled_code:
void __fastcall __noreturn func4(const char *a1, unsigned int a2, const char *a3)
{
fflush(0LL);
fprintf(stderr, "\nAssertion failed: %s, line %u: %s\n", a1, a2, a3);
fflush(stderr);
abort();
}

original_code:
void
syck_assert( const char *file_name, unsigned line_num, const char *expr )
{
    fflush( ((void *)0) );
    fprintf( stderr, "\nAssertion failed: %s, line %u: %s\n",
             file_name, line_num, expr );
    fflush( stderr );
    abort();
}

canonical_original_code:
void syck_assert(char *file_name, unsigned int line_num, char *expr)
{
    fflush( ((void *)0) );
    fprintf( stderr, "\nAssertion failed: %s, line %u: %s\n",
             file_name, line_num, expr );
    fflush( stderr );
    abort();
}

variable_types:
expr
char *


decompiled_code:
void *__fastcall syck_strndup(void *src, size_t n)
{
void *v2; // rbx

v2 = malloc(n + 1);
memset(v2, 0, n + 1);
return memcpy(v2, src, n);
}

canonical_decompiled_code:
void *__fastcall func5(void *src, size_t n)
{
void *v2; // rbx

v2 = malloc(n + 1);
memset(v2, 0, n + 1);
return memcpy(v2, src, n);
}

original_code:
char *
syck_strndup( const char *buf, long len )
{
    char *new = (char*)malloc(sizeof(char)*(len + 1));
    memset((new), 0, sizeof(char)*(len + 1));
    memcpy((new), (buf), sizeof(char)*(len));
    return new;
}

canonical_original_code:
char *syck_strndup(char *buf, long len)
{
    char *new = (char*)malloc(sizeof(char)*(len + 1));
    memset((new), 0, sizeof(char)*(len + 1));
    memcpy((new), (buf), sizeof(char)*(len));
    return new;
}

variable_types:
new
char *

return_type: char *


decompiled_code:
__int64 Init_md5()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rbp

rb_require("digest");
v0 = rb_path2class("Digest");
v1 = rb_path2class("Digest::Base");
v2 = rb_define_class_under(v0, "MD5", v1);
v3 = rb_data_object_alloc(rb_cObject, &md5, 0LL, 0LL);
if ( !rb_intern_id_cache_0 )
rb_intern_id_cache_0 = rb_intern2("metadata", 8LL);
return rb_ivar_set(v2, rb_intern_id_cache_0, v3);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rbp

rb_require("digest");
v0 = rb_path2class("Digest");
v1 = rb_path2class("Digest::Base");
v2 = rb_define_class_under(v0, "MD5", v1);
v3 = rb_data_object_alloc(rb_cObject, &md5, 0LL, 0LL);
if ( !rb_intern_id_cache_0 )
rb_intern_id_cache_0 = rb_intern2("metadata", 8LL);
return rb_ivar_set(v2, rb_intern_id_cache_0, v3);
}

original_code:
void
Init_md5()
{
    VALUE mDigest, cDigest_Base, cDigest_MD5;
    rb_require("digest");
    mDigest = rb_path2class("Digest");
    cDigest_Base = rb_path2class("Digest::Base");
    cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
    rb_ivar_set(cDigest_MD5, (__builtin_constant_p("metadata") ? __extension__ ({ static ID rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("metadata", strlen("metadata")); rb_intern_id_cache; }) : rb_intern("metadata")),
      rb_data_object_alloc(rb_cObject,(void *)&md5,(RUBY_DATA_FUNC)0,(RUBY_DATA_FUNC)0));
}

canonical_original_code:
void Init_md5()
{
    unsigned long mDigest; unsigned long cDigest_Base; unsigned long cDigest_MD5;
    rb_require("digest");
    mDigest = rb_path2class("Digest");
    cDigest_Base = rb_path2class("Digest::Base");
    cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
    rb_ivar_set(cDigest_MD5, (__builtin_constant_p("metadata") ? __extension__ ({ static unsigned long rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("metadata", strlen("metadata")); rb_intern_id_cache; }) : rb_intern("metadata")),
      rb_data_object_alloc(rb_cObject,(void *)&md5,(void (*)(void *))0,(void (*)(void *))0));
}

variable_types:
mDigest
unsigned long


decompiled_code:
void __fastcall syck_add_transfer(void *ptr, __int64 a2, int a3)
{
void *v5; // rdi

v5 = *(void **)(a2 + 16);
if ( v5 )
{
free(v5);
*(_QWORD *)(a2 + 16) = 0LL;
}
if ( a3 )
{
*(_QWORD *)(a2 + 16) = syck_type_id_to_uri(ptr);
if ( ptr )
free(ptr);
}
else
{
*(_QWORD *)(a2 + 16) = ptr;
}
}

canonical_decompiled_code:
void __fastcall func4(void *ptr, __int64 a2, int a3)
{
void *v5; // rdi

v5 = *(void **)(a2 + 16);
if ( v5 )
{
free(v5);
*(_QWORD *)(a2 + 16) = 0LL;
}
if ( a3 )
{
*(_QWORD *)(a2 + 16) = syck_type_id_to_uri(ptr);
if ( ptr )
free(ptr);
}
else
{
*(_QWORD *)(a2 + 16) = ptr;
}
}

original_code:
void
syck_add_transfer( char *uri, SyckNode *n, int taguri )
{
    if ( n->type_id != ((void *)0) )
    {
        if (n->type_id) { free(n->type_id); n->type_id = ((void *)0); };
    }
    if ( taguri == 0 )
    {
        n->type_id = uri;
        return;
    }
    n->type_id = syck_type_id_to_uri( uri );
    if (uri) { free(uri); uri = ((void *)0); };
}

canonical_original_code:
void syck_add_transfer(char *uri, struct _syck_node *n, int taguri)
{
    if ( n->type_id != ((void *)0) )
    {
        if (n->type_id) { free(n->type_id); n->type_id = ((void *)0); };
    }
    if ( taguri == 0 )
    {
        n->type_id = uri;
        return;
    }
    n->type_id = syck_type_id_to_uri( uri );
    if (uri) { free(uri); uri = ((void *)0); };
}

variable_types:
uri
char *

variable_types: taguri int

user_defined_types: enum syck_kind_tag { syck_map_kind=0, syck_seq_kind=1, syck_str_kind=2 }

user_defined_types: enum map_style { map_none=0, map_inline=1 }

user_defined_types: enum seq_style { seq_none=0, seq_inline=1 }

user_defined_types: enum scalar_style { scalar_none=0, scalar_1quote=1, scalar_2quote=2, scalar_fold=3, scalar_literal=4, scalar_plain=5 }


decompiled_code:
char *__fastcall syck_xprivate(char *src, int a2)
{
char *v2; // rbx

v2 = (char *)malloc(a2 + 14);
*v2 = 0;
strcat(v2, "x-private:");
return strncat(v2, src, a2);
}

canonical_decompiled_code:
char *__fastcall func5(char *src, int a2)
{
char *v2; // rbx

v2 = (char *)malloc(a2 + 14);
*v2 = 0;
strcat(v2, "x-private:");
return strncat(v2, src, a2);
}

original_code:
char *
syck_xprivate( const char *type_id, int type_len )
{
    char *uri = (char*)malloc(sizeof(char)*(type_len + 14));
    uri[0] = '\0';
    strcat( uri, "x-private:" );
    strncat( uri, type_id, type_len );
    return uri;
}

canonical_original_code:
char *syck_xprivate(char *type_id, int type_len)
{
    char *uri = (char*)malloc(sizeof(char)*(type_len + 14));
    uri[0] = '\0';
    strcat( uri, "x-private:" );
    strncat( uri, type_id, type_len );
    return uri;
}


decompiled_code:
char *__fastcall syck_taguri(char *src, char *a2, int a3)
{
size_t v4; // rax
char *v5; // rbx

v4 = strlen(src);
v5 = (char *)malloc(a3 + v4 + 14);
*v5 = 0;
strcat(v5, "tag:");
strcat(v5, src);
*(_WORD *)&v5[strlen(v5)] = 58;
return strncat(v5, a2, a3);
}

canonical_decompiled_code:
char *__fastcall func6(char *src, char *a2, int a3)
{
size_t v4; // rax
char *v5; // rbx

v4 = strlen(src);
v5 = (char *)malloc(a3 + v4 + 14);
*v5 = 0;
strcat(v5, "tag:");
strcat(v5, src);
*(_WORD *)&v5[strlen(v5)] = 58;
return strncat(v5, a2, a3);
}

original_code:
char *
syck_taguri( const char *domain, const char *type_id, int type_len )
{
    char *uri = (char*)malloc(sizeof(char)*(strlen( domain ) + type_len + 14));
    uri[0] = '\0';
    strcat( uri, "tag:" );
    strcat( uri, domain );
    strcat( uri, ":" );
    strncat( uri, type_id, type_len );
    return uri;
}

canonical_original_code:
char *syck_taguri(char *domain, char *type_id, int type_len)
{
    char *uri = (char*)malloc(sizeof(char)*(strlen( domain ) + type_len + 14));
    uri[0] = '\0';
    strcat( uri, "tag:" );
    strcat( uri, domain );
    strcat( uri, ":" );
    strncat( uri, type_id, type_len );
    return uri;
}

variable_types:
domain
char *


decompiled_code:
__int64 syck_try_implicit()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func7()
{
return 1LL;
}

original_code:
int
syck_try_implicit( SyckNode *n )
{
    return 1;
}

canonical_original_code:
int syck_try_implicit(struct _syck_node *n)
{
    return 1;
}


decompiled_code:
__int64 __fastcall INT2NUM(int a1)
{
return 2LL * a1 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return 2LL * a1 + 1;
}

original_code:
static inline VALUE
INT2NUM(int v)
{
    if (!(((v) < (0x7fffffffffffffffL>>1)+1) && ((v) >= (((long)(-0x7fffffffffffffffL - 1L))>>(int)1))))
 return rb_int2big(v);
    return ((VALUE)(((long)(v))<<1 | RUBY_FIXNUM_FLAG));
}

canonical_original_code:
static inline unsigned long INT2NUM(int v)
{
    if (!(((v) < (0x7fffffffffffffffL>>1)+1) && ((v) >= (((long)(-0x7fffffffffffffffL - 1L))>>(int)1))))
 return rb_int2big(v);
    return ((VALUE)(((long)(v))<<1 | RUBY_FIXNUM_FLAG));
}

variable_types: v int


decompiled_code:
__int64 __fastcall wait_readable(unsigned int *a1)
{
return (int)rb_thread_select(*a1, *((_QWORD *)a1 + 1), 0LL, 0LL, *((_QWORD *)a1 + 2));
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int *a1)
{
return (int)rb_thread_select(*a1, *((_QWORD *)a1 + 1), 0LL, 0LL, *((_QWORD *)a1 + 2));
}

original_code:
static VALUE
wait_readable(VALUE p)
{
    struct wait_readable_arg *arg = (struct wait_readable_arg *)p;
    rb_fdset_t *fds = &arg->fds;
    return (VALUE)rb_thread_select(((fds)->maxfd), ((fds)->fdset), ((void *)0), ((void *)0), arg->timeout);
}

canonical_original_code:
static unsigned long wait_readable(unsigned long p)
{
    struct wait_readable_arg *arg = (struct wait_readable_arg *)p;
    struct rb_fdset_t *fds = &arg->fds;
    return (unsigned long)rb_thread_select(((fds)->maxfd), ((fds)->fdset), ((void *)0), ((void *)0), arg->timeout);
}

variable_types:
p
unsigned long

variable_types: struct wait_readable_arg { struct rb_fdset_t { int maxfd; struct fd_set { long fds_bits[-1]; } *fdset; } fds; struct timeval { long tv_sec; long tv_usec; } *timeout; } *

variable_types: struct rb_fdset_t { int maxfd; struct fd_set { long fds_bits[-1]; } *fdset; } *

user_defined_types: struct wait_readable_arg { struct rb_fdset_t fds; struct timeval *timeout; }

user_defined_types: struct rb_fdset_t { int maxfd; struct fd_set *fdset; }


decompiled_code:
__int64 Init_wait()
{
rb_define_method(rb_cIO, "ready?", io_ready_p, 0LL);
return rb_define_method(rb_cIO, "wait", io_wait, 0xFFFFFFFFLL);
}

canonical_decompiled_code:
__int64 func4()
{
rb_define_method(rb_cIO, "ready?", io_ready_p, 0LL);
return rb_define_method(rb_cIO, "wait", io_wait, 0xFFFFFFFFLL);
}

original_code:
void
Init_wait()
{
    rb_define_method(rb_cIO, "ready?", io_ready_p, 0);
    rb_define_method(rb_cIO, "wait", io_wait, -1);
}


decompiled_code:
__int64 __fastcall JSON_convert_UTF16_to_UTF8(__int64 a1, const char *a2, unsigned __int64 a3, int a4)
{
const char *v6; // rax
__int64 v7; // r15
char *v8; // rbp
unsigned __int64 v9; // rdi
unsigned __int64 v10; // rbx
_WORD *v11; // r13
unsigned __int16 *v12; // rbp
unsigned __int64 v13; // rax
unsigned __int16 v14; // cx
int v15; // edx
const char *v16; // rsi
__int64 v17; // rdx
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v22; // [rsp+10h] [rbp-58h]
char v24; // [rsp+2Bh] [rbp-3Dh] BYREF
char v25; // [rsp+2Ch] [rbp-3Ch]
char v26; // [rsp+2Dh] [rbp-3Bh]
char v27; // [rsp+2Eh] [rbp-3Ah]
char v28; // [rsp+2Fh] [rbp-39h]

v6 = a2 - 1;
v7 = 0LL;
if ( (unsigned __int64)(a2 - 1) >= a3 )
{
v28 = 0;
v22 = ruby_xmalloc2(0LL, 2LL);
v7 = 0LL;
}
else
{
do
{
if ( *v6 != 92 )
break;
if ( v6[1] != 117 )
break;
v6 += 6;
++v7;
}
while ( a3 > (unsigned __int64)v6 );
v8 = (char *)(a2 + 1);
v28 = 0;
v9 = ruby_xmalloc2(v7, 2LL);
v22 = v9;
v10 = v9 + 2 * v7;
if ( v7 > 0 )
{
v11 = (_WORD *)v9;
do
{
v24 = *v8;
v25 = v8[1];
v26 = v8[2];
v27 = v8[3];
*v11 = strtol(&v24, 0LL, 16);
v8 += 6;
++v11;
}
while ( (_WORD *)(v9 + 2 * v7) != v11 );
}
if ( v9 < v10 )
{
v12 = (unsigned __int16 *)v9;
while ( 1 )
{
v16 = (const char *)(v12 + 1);
v13 = *v12;
if ( v13 - 55296 > 0x3FF )
goto LABEL_21;
if ( v10 <= (unsigned __int64)v16 )
goto LABEL_20;
v17 = v12[1];
if ( (unsigned __int64)(v17 - 56320) > 0x3FF )
break;
v12 += 2;
v27 = v17 & 0x3F | 0x80;
v13 = (v17 + ((v13 - 55296) << 10) + 9216) >> 6;
v14 = 4;
v15 = 4;
LABEL_11:
v26 = v13 & 0x3F | 0x80;
v13 >>= 6;
LABEL_12:
v25 = v13 & 0x3F | 0x80;
v13 >>= 6;
LABEL_13:
v24 = firstByteMark[v15] | v13;
rb_str_buf_cat(a1, &v24, v14);
if ( v10 <= (unsigned __int64)v12 )
goto LABEL_29;
}
if ( !a4 )
{
ruby_xfree(v9);
v18 = rb_path2class("JSON::ParserError");
rb_raise(v18, "source sequence is illegal/malformed near %s", a2);
LABEL_20:
ruby_xfree(v9);
v19 = rb_path2class("JSON::ParserError");
v16 = "partial character in source, but hit end near %s";
v13 = rb_raise(v19, "partial character in source, but hit end near %s", a2);
LABEL_21:
if ( a4 || v13 - 56320 > 0x3FF )
{
if ( v13 <= 0x7F )
{
v25 = 0;
v26 = 0;
v27 = 0;
v12 = (unsigned __int16 *)v16;
v14 = 1;
v15 = 1;
goto LABEL_13;
}
}
else
{
ruby_xfree(v9);
v20 = rb_path2class("JSON::ParserError");
v16 = "source sequence is illegal/malformed near %s";
v13 = rb_raise(v20, "source sequence is illegal/malformed near %s", a2);
}
if ( v13 <= 0x7FF )
{
v26 = 0;
v27 = 0;
v12 = (unsigned __int16 *)v16;
v14 = 2;
v15 = 2;
goto LABEL_12;
}
}
v27 = 0;
v12 = (unsigned __int16 *)v16;
v14 = 3;
v15 = 3;
goto LABEL_11;
}
}
LABEL_29:
ruby_xfree(v22);
return (__int64)&a2[6 * v7 - 1];
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2, unsigned __int64 a3, int a4)
{
const char *v6; // rax
__int64 v7; // r15
char *v8; // rbp
unsigned __int64 v9; // rdi
unsigned __int64 v10; // rbx
_WORD *v11; // r13
unsigned __int16 *v12; // rbp
unsigned __int64 v13; // rax
unsigned __int16 v14; // cx
int v15; // edx
const char *v16; // rsi
__int64 v17; // rdx
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v22; // [rsp+10h] [rbp-58h]
char v24; // [rsp+2Bh] [rbp-3Dh] BYREF
char v25; // [rsp+2Ch] [rbp-3Ch]
char v26; // [rsp+2Dh] [rbp-3Bh]
char v27; // [rsp+2Eh] [rbp-3Ah]
char v28; // [rsp+2Fh] [rbp-39h]

v6 = a2 - 1;
v7 = 0LL;
if ( (unsigned __int64)(a2 - 1) >= a3 )
{
v28 = 0;
v22 = ruby_xmalloc2(0LL, 2LL);
v7 = 0LL;
}
else
{
do
{
if ( *v6 != 92 )
break;
if ( v6[1] != 117 )
break;
v6 += 6;
++v7;
}
while ( a3 > (unsigned __int64)v6 );
v8 = (char *)(a2 + 1);
v28 = 0;
v9 = ruby_xmalloc2(v7, 2LL);
v22 = v9;
v10 = v9 + 2 * v7;
if ( v7 > 0 )
{
v11 = (_WORD *)v9;
do
{
v24 = *v8;
v25 = v8[1];
v26 = v8[2];
v27 = v8[3];
*v11 = strtol(&v24, 0LL, 16);
v8 += 6;
++v11;
}
while ( (_WORD *)(v9 + 2 * v7) != v11 );
}
if ( v9 < v10 )
{
v12 = (unsigned __int16 *)v9;
while ( 1 )
{
v16 = (const char *)(v12 + 1);
v13 = *v12;
if ( v13 - 55296 > 0x3FF )
goto LABEL_21;
if ( v10 <= (unsigned __int64)v16 )
goto LABEL_20;
v17 = v12[1];
if ( (unsigned __int64)(v17 - 56320) > 0x3FF )
break;
v12 += 2;
v27 = v17 & 0x3F | 0x80;
v13 = (v17 + ((v13 - 55296) << 10) + 9216) >> 6;
v14 = 4;
v15 = 4;
LABEL_11:
v26 = v13 & 0x3F | 0x80;
v13 >>= 6;
LABEL_12:
v25 = v13 & 0x3F | 0x80;
v13 >>= 6;
LABEL_13:
v24 = firstByteMark[v15] | v13;
rb_str_buf_cat(a1, &v24, v14);
if ( v10 <= (unsigned __int64)v12 )
goto LABEL_29;
}
if ( !a4 )
{
ruby_xfree(v9);
v18 = rb_path2class("JSON::ParserError");
rb_raise(v18, "source sequence is illegal/malformed near %s", a2);
LABEL_20:
ruby_xfree(v9);
v19 = rb_path2class("JSON::ParserError");
v16 = "partial character in source, but hit end near %s";
v13 = rb_raise(v19, "partial character in source, but hit end near %s", a2);
LABEL_21:
if ( a4 || v13 - 56320 > 0x3FF )
{
if ( v13 <= 0x7F )
{
v25 = 0;
v26 = 0;
v27 = 0;
v12 = (unsigned __int16 *)v16;
v14 = 1;
v15 = 1;
goto LABEL_13;
}
}
else
{
ruby_xfree(v9);
v20 = rb_path2class("JSON::ParserError");
v16 = "source sequence is illegal/malformed near %s";
v13 = rb_raise(v20, "source sequence is illegal/malformed near %s", a2);
}
if ( v13 <= 0x7FF )
{
v26 = 0;
v27 = 0;
v12 = (unsigned __int16 *)v16;
v14 = 2;
v15 = 2;
goto LABEL_12;
}
}
v27 = 0;
v12 = (unsigned __int16 *)v16;
v14 = 3;
v15 = 3;
goto LABEL_11;
}
}
LABEL_29:
ruby_xfree(v22);
return (__int64)&a2[6 * v7 - 1];
}

original_code:
char *JSON_convert_UTF16_to_UTF8 (
        VALUE buffer,
        char *source,
        char *sourceEnd,
        ConversionFlags flags)
{
    UTF16 *tmp, *tmpPtr, *tmpEnd;
    char buf[5];
    long n = 0, i;
    char *p = source - 1;
    while (p < sourceEnd && p[0] == '\\' && p[1] == 'u') {
        p += 6;
        n++;
    }
    p = source + 1;
    buf[4] = 0;
    tmpPtr = tmp = (UTF16*)ruby_xmalloc2((n),sizeof(UTF16));
    tmpEnd = tmp + n;
    for (i = 0; i < n; i++) {
        buf[0] = *p++;
        buf[1] = *p++;
        buf[2] = *p++;
        buf[3] = *p++;
        tmpPtr[i] = strtol(buf, ((void *)0), 16);
        p += 2;
    }
    while (tmpPtr < tmpEnd) {
        UTF32 ch;
        unsigned short bytesToWrite = 0;
        const UTF32 byteMask = 0xBF;
        const UTF32 byteMark = 0x80;
        ch = *tmpPtr++;
        if (ch >= (UTF32)0xD800 && ch <= (UTF32)0xDBFF) {
            if (tmpPtr < tmpEnd) {
                UTF32 ch2 = *tmpPtr;
                if (ch2 >= (UTF32)0xDC00 && ch2 <= (UTF32)0xDFFF) {
                    ch = ((ch - (UTF32)0xD800) << halfShift)
                        + (ch2 - (UTF32)0xDC00) + halfBase;
                    ++tmpPtr;
                } else if (flags == strictConversion) {
                    ruby_xfree(tmp);
                    rb_raise(rb_path2class("JSON::ParserError"),
                            "source sequence is illegal/malformed near %s", source);
                }
            } else {
                ruby_xfree(tmp);
                rb_raise(rb_path2class("JSON::ParserError"),
                    "partial character in source, but hit end near %s", source);
                break;
            }
        } else if (flags == strictConversion) {
            if (ch >= (UTF32)0xDC00 && ch <= (UTF32)0xDFFF) {
                ruby_xfree(tmp);
                rb_raise(rb_path2class("JSON::ParserError"),
                    "source sequence is illegal/malformed near %s", source);
            }
        }
        if (ch < (UTF32) 0x80) {
            bytesToWrite = 1;
        } else if (ch < (UTF32) 0x800) {
            bytesToWrite = 2;
        } else if (ch < (UTF32) 0x10000) {
            bytesToWrite = 3;
        } else if (ch < (UTF32) 0x110000) {
            bytesToWrite = 4;
        } else {
            bytesToWrite = 3;
            ch = (UTF32)0x0000FFFD;
        }
        buf[0] = 0;
        buf[1] = 0;
        buf[2] = 0;
        buf[3] = 0;
        p = buf + bytesToWrite;
        switch (bytesToWrite) {
            case 4: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
            case 3: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
            case 2: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
            case 1: *--p = (UTF8) (ch | firstByteMark[bytesToWrite]);
        }
        rb_str_buf_cat(buffer, p, bytesToWrite);
    }
    ruby_xfree(tmp);
    source += 5 + (n - 1) * 6;
    return source;
}

canonical_original_code:
char *JSON_convert_UTF16_to_UTF8(unsigned long buffer, char *source, char *sourceEnd, enum ConversionFlags flags)
{
    unsigned short *tmp; unsigned short *tmpPtr; unsigned short *tmpEnd;
    char buf[5];
    long n = 0; long i;
    char *p = source - 1;
    while (p < sourceEnd && p[0] == '\\' && p[1] == 'u') {
        p += 6;
        n++;
    }
    p = source + 1;
    buf[4] = 0;
    tmpPtr = tmp = (unsigned short *)ruby_xmalloc2((n),sizeof(UTF16));
    tmpEnd = tmp + n;
    for (i = 0; i < n; i++) {
        buf[0] = *p++;
        buf[1] = *p++;
        buf[2] = *p++;
        buf[3] = *p++;
        tmpPtr[i] = strtol(buf, ((void *)0), 16);
        p += 2;
    }
    while (tmpPtr < tmpEnd) {
        unsigned long ch;
        unsigned short bytesToWrite = 0;
        unsigned long byteMask = 0xBF;
        unsigned long byteMark = 0x80;
        ch = *tmpPtr++;
        if (ch >= (unsigned long)0xD800 && ch <= (unsigned long)0xDBFF) {
            if (tmpPtr < tmpEnd) {
                unsigned long ch2 = *tmpPtr;
                if (ch2 >= (unsigned long)0xDC00 && ch2 <= (unsigned long)0xDFFF) {
                    ch = ((ch - (unsigned long)0xD800) << halfShift)
                        + (ch2 - (unsigned long)0xDC00) + halfBase;
                    ++tmpPtr;
                } else if (flags == strictConversion) {
                    ruby_xfree(tmp);
                    rb_raise(rb_path2class("JSON::ParserError"),
                            "source sequence is illegal/malformed near %s", source);
                }
            } else {
                ruby_xfree(tmp);
                rb_raise(rb_path2class("JSON::ParserError"),
                    "partial character in source, but hit end near %s", source);
                break;
            }
        } else if (flags == strictConversion) {
            if (ch >= (unsigned long)0xDC00 && ch <= (unsigned long)0xDFFF) {
                ruby_xfree(tmp);
                rb_raise(rb_path2class("JSON::ParserError"),
                    "source sequence is illegal/malformed near %s", source);
            }
        }
        if (ch < (unsigned long) 0x80) {
            bytesToWrite = 1;
        } else if (ch < (unsigned long) 0x800) {
            bytesToWrite = 2;
        } else if (ch < (unsigned long) 0x10000) {
            bytesToWrite = 3;
        } else if (ch < (unsigned long) 0x110000) {
            bytesToWrite = 4;
        } else {
            bytesToWrite = 3;
            ch = (unsigned long)0x0000FFFD;
        }
        buf[0] = 0;
        buf[1] = 0;
        buf[2] = 0;
        buf[3] = 0;
        p = buf + bytesToWrite;
        switch (bytesToWrite) {
            case 4: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
            case 3: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
            case 2: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
            case 1: *--p = (UTF8) (ch | firstByteMark[bytesToWrite]);
        }
        rb_str_buf_cat(buffer, p, bytesToWrite);
    }
    ruby_xfree(tmp);
    source += 5 + (n - 1) * 6;
    return source;
}

variable_types:
buffer
unsigned long

variable_types:
source
char *

variable_types:
sourceEnd
char *

variable_types: enum ConversionFlags { strictConversion=0, lenientConversion=1 }

variable_types:
tmp
unsigned short *

variable_types:
tmpPtr
unsigned short *

variable_types:
tmpEnd
unsigned short *

variable_types:
buf
char [5]

variable_types: n long

variable_types: i long

variable_types:
p
char *

variable_types:
ch
unsigned long

variable_types:
bytesToWrite
unsigned short

variable_types:
byteMask
unsigned long

variable_types:
byteMark
unsigned long


decompiled_code:
__int64 rb_coverage_result()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
__int64 result; // rax

v0 = rb_get_coverages();
if ( (v0 & 0xFFFFFFFFFFFFFFFBLL) != 0 )
{
v1 = v0;
*(_QWORD *)(v0 + 8) = rb_cHash;
v2 = rb_hash_tbl(v0);
st_foreach(v2, coverage_result_i, 0LL);
rb_hash_freeze(v1);
rb_reset_coverages();
result = v1;
}
else
{
rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
result = coverage_result_i();
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
__int64 result; // rax

v0 = rb_get_coverages();
if ( (v0 & 0xFFFFFFFFFFFFFFFBLL) != 0 )
{
v1 = v0;
*(_QWORD *)(v0 + 8) = rb_cHash;
v2 = rb_hash_tbl(v0);
st_foreach(v2, coverage_result_i, 0LL);
rb_hash_freeze(v1);
rb_reset_coverages();
result = v1;
}
else
{
rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
result = func1();
}
return result;
}

original_code:
static VALUE
rb_coverage_result(VALUE klass)
{
    VALUE coverages = rb_get_coverages();
    if (!(((VALUE)(coverages) & ~((VALUE)RUBY_Qnil)) != 0)) {
 rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
    }
    ((struct RBasic*)(coverages))->klass = rb_cHash;
    st_foreach(rb_hash_tbl(coverages), coverage_result_i, 0);
    rb_hash_freeze(coverages);
    rb_reset_coverages();
    return coverages;
}

canonical_original_code:
static unsigned long rb_coverage_result(unsigned long klass)
{
    unsigned long coverages = rb_get_coverages();
    if (!(((VALUE)(coverages) & ~((unsigned long)RUBY_Qnil)) != 0)) {
 rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
    }
    ((struct RBasic *)(coverages))->klass = rb_cHash;
    st_foreach(rb_hash_tbl(coverages), coverage_result_i, 0);
    rb_hash_freeze(coverages);
    rb_reset_coverages();
    return coverages;
}

variable_types:
klass
unsigned long

variable_types:
coverages
unsigned long


decompiled_code:
__int64 __fastcall coverage_result_i(__int64 a1, __int64 a2)
{
*(_QWORD *)(a2 + 8) = rb_cArray;
rb_ary_freeze(a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
*(_QWORD *)(a2 + 8) = rb_cArray;
rb_ary_freeze(a2);
return 0LL;
}

original_code:
static int
coverage_result_i(st_data_t key, st_data_t val, st_data_t dummy)
{
    VALUE coverage = (VALUE)val;
    ((struct RBasic*)(coverage))->klass = rb_cArray;
    rb_ary_freeze(coverage);
    return ST_CONTINUE;
}

canonical_original_code:
static int coverage_result_i(unsigned long key, unsigned long val, unsigned long dummy)
{
    unsigned long coverage = (VALUE)val;
    ((struct RBasic *)(coverage))->klass = rb_cArray;
    rb_ary_freeze(coverage);
    return ST_CONTINUE;
}

variable_types:
key
unsigned long

variable_types:
val
unsigned long

variable_types:
dummy
unsigned long

variable_types:
coverage
unsigned long


decompiled_code:
__int64 rb_coverage_start()
{
__int64 v1; // rax

if ( (rb_get_coverages() & 0xFFFFFFFFFFFFFFFBLL) == 0 )
{
v1 = rb_hash_new();
*(_QWORD *)(v1 + 8) = 0LL;
rb_set_coverages(v1);
}
return 4LL;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v1; // rax

if ( (rb_get_coverages() & 0xFFFFFFFFFFFFFFFBLL) == 0 )
{
v1 = rb_hash_new();
*(_QWORD *)(v1 + 8) = 0LL;
rb_set_coverages(v1);
}
return 4LL;
}

original_code:
static VALUE
rb_coverage_start(VALUE klass)
{
    if (!(((VALUE)(rb_get_coverages()) & ~((VALUE)RUBY_Qnil)) != 0)) {
 VALUE coverages = rb_hash_new();
 ((struct RBasic*)(coverages))->klass = 0;
 rb_set_coverages(coverages);
    }
    return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long rb_coverage_start(unsigned long klass)
{
    if (!(((VALUE)(rb_get_coverages()) & ~((unsigned long)RUBY_Qnil)) != 0)) {
 unsigned long coverages = rb_hash_new();
 ((struct RBasic *)(coverages))->klass = 0;
 rb_set_coverages(coverages);
    }
    return ((unsigned long)RUBY_Qnil);
}


decompiled_code:
__int64 Init_coverage()
{
__int64 v0; // rbx

v0 = rb_define_module("Coverage");
rb_define_module_function(v0, "start", rb_coverage_start, 0LL);
return rb_define_module_function(v0, "result", rb_coverage_result, 0LL);
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx

v0 = rb_define_module("Coverage");
rb_define_module_function(v0, "start", rb_coverage_start, 0LL);
return rb_define_module_function(v0, "result", rb_coverage_result, 0LL);
}

original_code:
void
Init_coverage(void)
{
    VALUE rb_mCoverage = rb_define_module("Coverage");
    rb_define_module_function(rb_mCoverage, "start", rb_coverage_start, 0);
    rb_define_module_function(rb_mCoverage, "result", rb_coverage_result, 0);
}

canonical_original_code:
void Init_coverage()
{
    unsigned long rb_mCoverage = rb_define_module("Coverage");
    rb_define_module_function(rb_mCoverage, "start", rb_coverage_start, 0);
    rb_define_module_function(rb_mCoverage, "result", rb_coverage_result, 0);
}


decompiled_code:
__int64 __fastcall isLegalUTF8(unsigned __int8 *a1, int a2)
{
unsigned __int8 *v2; // rdx
char v3; // dl
__int64 result; // rax
unsigned __int8 v5; // al
int v6; // edx
int v7; // eax

v2 = &a1[a2];
if ( a2 == 3 )
{
LABEL_16:
result = 0LL;
if ( (unsigned __int8)(*(v2 - 1) + 0x80) > 0x3Fu )
return result;
--v2;
goto LABEL_5;
}
if ( a2 > 3 )
{
result = 0LL;
if ( a2 != 4 )
return result;
result = 0LL;
if ( (unsigned __int8)(*(v2 - 1) + 0x80) > 0x3Fu )
return result;
--v2;
goto LABEL_16;
}
if ( a2 == 1 )
goto LABEL_22;
if ( a2 != 2 )
return 0LL;
LABEL_5:
v3 = *(v2 - 1);
result = 0LL;
if ( (unsigned __int8)v3 > 0xBFu )
return result;
v5 = *a1;
if ( *a1 == 0xF0 )
{
result = 0LL;
if ( (unsigned __int8)v3 > 0x8Fu )
goto LABEL_22;
}
else
{
if ( v5 > 0xF0u )
{
if ( v5 == 0xF4 )
{
result = 0LL;
if ( (unsigned __int8)v3 > 0x8Fu )
return result;
goto LABEL_22;
}
LABEL_27:
result = 0LL;
if ( v3 >= 0 )
return result;
goto LABEL_22;
}
if ( v5 != 0xE0 )
{
if ( v5 == 0xED )
{
result = 0LL;
if ( (unsigned __int8)v3 > 0x9Fu )
return result;
goto LABEL_22;
}
goto LABEL_27;
}
result = 0LL;
if ( (unsigned __int8)v3 > 0x9Fu )
{
LABEL_22:
v6 = *a1;
v7 = v6 - 128;
LOBYTE(v7) = (unsigned __int8)(v6 + 0x80) <= 0x41u;
return (((unsigned __int8)v6 > 0xF4u) | v7) ^ 1u;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, int a2)
{
unsigned __int8 *v2; // rdx
char v3; // dl
__int64 result; // rax
unsigned __int8 v5; // al
int v6; // edx
int v7; // eax

v2 = &a1[a2];
if ( a2 == 3 )
{
LABEL_16:
result = 0LL;
if ( (unsigned __int8)(*(v2 - 1) + 0x80) > 0x3Fu )
return result;
--v2;
goto LABEL_5;
}
if ( a2 > 3 )
{
result = 0LL;
if ( a2 != 4 )
return result;
result = 0LL;
if ( (unsigned __int8)(*(v2 - 1) + 0x80) > 0x3Fu )
return result;
--v2;
goto LABEL_16;
}
if ( a2 == 1 )
goto LABEL_22;
if ( a2 != 2 )
return 0LL;
LABEL_5:
v3 = *(v2 - 1);
result = 0LL;
if ( (unsigned __int8)v3 > 0xBFu )
return result;
v5 = *a1;
if ( *a1 == 0xF0 )
{
result = 0LL;
if ( (unsigned __int8)v3 > 0x8Fu )
goto LABEL_22;
}
else
{
if ( v5 > 0xF0u )
{
if ( v5 == 0xF4 )
{
result = 0LL;
if ( (unsigned __int8)v3 > 0x8Fu )
return result;
goto LABEL_22;
}
LABEL_27:
result = 0LL;
if ( v3 >= 0 )
return result;
goto LABEL_22;
}
if ( v5 != 0xE0 )
{
if ( v5 == 0xED )
{
result = 0LL;
if ( (unsigned __int8)v3 > 0x9Fu )
return result;
goto LABEL_22;
}
goto LABEL_27;
}
result = 0LL;
if ( (unsigned __int8)v3 > 0x9Fu )
{
LABEL_22:
v6 = *a1;
v7 = v6 - 128;
LOBYTE(v7) = (unsigned __int8)(v6 + 0x80) <= 0x41u;
return (((unsigned __int8)v6 > 0xF4u) | v7) ^ 1u;
}
}
return result;
}

original_code:
inline static unsigned char isLegalUTF8(const UTF8 *source, int length)
{
    UTF8 a;
    const UTF8 *srcptr = source+length;
    switch (length) {
        default: return 0;
        case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
        case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
        case 2: if ((a = (*--srcptr)) > 0xBF) return 0;
                    switch (*source) {
                        case 0xE0: if (a < 0xA0) return 0; break;
                        case 0xED: if (a > 0x9F) return 0; break;
                        case 0xF0: if (a < 0x90) return 0; break;
                        case 0xF4: if (a > 0x8F) return 0; break;
                        default: if (a < 0x80) return 0;
                    }
        case 1: if (*source >= 0x80 && *source < 0xC2) return 0;
    }
    if (*source > 0xF4) return 0;
    return 1;
}

canonical_original_code:
inline static unsigned char isLegalUTF8(unsigned char *source, int length)
{
    unsigned char a;
    unsigned char *srcptr = source+length;
    switch (length) {
        default: return 0;
        case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
        case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
        case 2: if ((a = (*--srcptr)) > 0xBF) return 0;
                    switch (*source) {
                        case 0xE0: if (a < 0xA0) return 0; break;
                        case 0xED: if (a > 0x9F) return 0; break;
                        case 0xF0: if (a < 0x90) return 0; break;
                        case 0xF4: if (a > 0x8F) return 0; break;
                        default: if (a < 0x80) return 0;
                    }
        case 1: if (*source >= 0x80 && *source < 0xC2) return 0;
    }
    if (*source > 0xF4) return 0;
    return 1;
}

variable_types:
source
unsigned char *

variable_types: length int

variable_types:
a
unsigned char

variable_types:
srcptr
unsigned char *

return_type: unsigned char


decompiled_code:
void __fastcall JSON_convert_UTF8_to_JSON(__int64 a1, _QWORD *a2, int a3)
{
char *v3; // rbp
unsigned __int8 *v4; // rbx
__int64 v5; // r14
unsigned __int8 *v6; // r14
unsigned __int8 v7; // r13
char v8; // r12
__int64 v9; // rax
__int64 v10; // rax
unsigned __int64 v11; // r13
unsigned __int64 v12; // r12
unsigned __int8 *v13; // rdx
unsigned __int64 v14; // r12
unsigned __int64 v15; // rax
unsigned __int8 *v16; // rdx
__int64 v17; // rax
__int64 v18; // r12
unsigned __int64 v19; // r12
__int64 v20; // rax
__int64 v21; // rax
unsigned __int64 v22; // r12
char s[63]; // [rsp+19h] [rbp-3Fh] BYREF

if ( (*a2 & 0x2000) != 0 )
{
v4 = (unsigned __int8 *)a2[3];
v5 = a2[2];
}
else
{
v4 = (unsigned __int8 *)(a2 + 2);
v5 = (*a2 >> 14) & 0x1FLL;
}
v6 = &v4[v5];
if ( v6 > v4 )
{
v7 = *v4;
v8 = trailingBytesForUTF8[*v4];
LOWORD(v3) = v8;
if ( v6 > &v4[(unsigned __int16)v8] )
goto LABEL_50;
LABEL_7:
v9 = rb_path2class("JSON::GeneratorError");
rb_raise(v9, "partial character in source, but hit end");
LABEL_8:
v10 = rb_path2class("JSON::GeneratorError");
rb_raise(v10, "source sequence is illegal/malformed");
LABEL_9:
++v4;
v11 = (unsigned __int64)v7 << 6;
LABEL_11:
v12 = (v11 + *v4++) << 6;
LABEL_12:
v13 = v4 + 1;
v14 = (v12 + *v4) << 6;
LABEL_13:
v4 = v13 + 1;
v15 = (v14 + *v13) << 6;
LABEL_14:
v16 = v4 + 1;
v17 = (v15 + *v4) << 6;
LABEL_15:
v4 = v16 + 1;
v18 = v17 + *v16;
while ( 1 )
{
v19 = v18 - offsetsFromUTF8[(int)v3];
if ( v19 > 0xFFFF )
{
if ( v19 > 0x10FFFF )
{
if ( a3 )
{
LABEL_47:
v3 = s;
snprintf(s, 7uLL, "\\u%04x", 65533LL);
rb_str_buf_cat(a1, s, 6LL);
goto LABEL_48;
}
v21 = rb_path2class("JSON::GeneratorError");
rb_raise(v21, "source sequence is illegal/malformed");
}
v22 = v19 - 0x10000;
v3 = s;
snprintf(s, 7uLL, "\\u%04x", (unsigned __int16)((v22 >> 10) - 10240));
rb_str_buf_cat(a1, s, 6LL);
snprintf(s, 7uLL, "\\u%04x", (unsigned __int16)((v22 & 0x3FF) - 9216));
rb_str_buf_cat(a1, s, 6LL);
}
else
{
if ( v19 - 55296 <= 0x7FF )
{
if ( a3 )
goto LABEL_47;
v20 = rb_path2class("JSON::GeneratorError");
rb_raise(v20, "source sequence is illegal/malformed");
}
switch ( v19 )
{
case '"':
rb_str_buf_cat(a1, "\\\"", 2LL);
break;
case '\\':
rb_str_buf_cat(a1, "\\\\", 2LL);
break;
case '/':
rb_str_buf_cat(a1, "\\/", 2LL);
break;
default:
if ( v19 - 32 <= 0x5F )
{
rb_str_buf_cat(a1, v4 - 1, 1LL);
}
else
{
switch ( v19 )
{
case 0xAuLL:
rb_str_buf_cat(a1, "\\n", 2LL);
break;
case 0xDuLL:
rb_str_buf_cat(a1, "\\r", 2LL);
break;
case 9uLL:
rb_str_buf_cat(a1, "\\t", 2LL);
break;
case 0xCuLL:
rb_str_buf_cat(a1, "\\f", 2LL);
break;
case 8uLL:
rb_str_buf_cat(a1, "\\b", 2LL);
break;
default:
v3 = s;
snprintf(s, 7uLL, "\\u%04x", (unsigned __int16)v19);
rb_str_buf_cat(a1, s, 6LL);
break;
}
}
break;
}
}
LABEL_48:
if ( v4 >= v6 )
return;
v7 = *v4;
v8 = trailingBytesForUTF8[*v4];
LOWORD(v3) = v8;
if ( v6 <= &v4[(unsigned __int16)v8] )
goto LABEL_7;
LABEL_50:
LODWORD(v3) = (unsigned __int16)v3;
if ( !(unsigned __int8)isLegalUTF8(v4, (unsigned int)(unsigned __int16)v3 + 1) )
goto LABEL_8;
switch ( v8 )
{
case 0:
v16 = v4;
v17 = 0LL;
goto LABEL_15;
case 1:
v15 = 0LL;
goto LABEL_14;
case 2:
v13 = v4;
v14 = 0LL;
goto LABEL_13;
case 3:
v12 = 0LL;
goto LABEL_12;
case 4:
v11 = 0LL;
goto LABEL_11;
case 5:
goto LABEL_9;
default:
v18 = 0LL;
break;
}
}
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, _QWORD *a2, int a3)
{
char *v3; // rbp
unsigned __int8 *v4; // rbx
__int64 v5; // r14
unsigned __int8 *v6; // r14
unsigned __int8 v7; // r13
char v8; // r12
__int64 v9; // rax
__int64 v10; // rax
unsigned __int64 v11; // r13
unsigned __int64 v12; // r12
unsigned __int8 *v13; // rdx
unsigned __int64 v14; // r12
unsigned __int64 v15; // rax
unsigned __int8 *v16; // rdx
__int64 v17; // rax
__int64 v18; // r12
unsigned __int64 v19; // r12
__int64 v20; // rax
__int64 v21; // rax
unsigned __int64 v22; // r12
char s[63]; // [rsp+19h] [rbp-3Fh] BYREF

if ( (*a2 & 0x2000) != 0 )
{
v4 = (unsigned __int8 *)a2[3];
v5 = a2[2];
}
else
{
v4 = (unsigned __int8 *)(a2 + 2);
v5 = (*a2 >> 14) & 0x1FLL;
}
v6 = &v4[v5];
if ( v6 > v4 )
{
v7 = *v4;
v8 = trailingBytesForUTF8[*v4];
LOWORD(v3) = v8;
if ( v6 > &v4[(unsigned __int16)v8] )
goto LABEL_50;
LABEL_7:
v9 = rb_path2class("JSON::GeneratorError");
rb_raise(v9, "partial character in source, but hit end");
LABEL_8:
v10 = rb_path2class("JSON::GeneratorError");
rb_raise(v10, "source sequence is illegal/malformed");
LABEL_9:
++v4;
v11 = (unsigned __int64)v7 << 6;
LABEL_11:
v12 = (v11 + *v4++) << 6;
LABEL_12:
v13 = v4 + 1;
v14 = (v12 + *v4) << 6;
LABEL_13:
v4 = v13 + 1;
v15 = (v14 + *v13) << 6;
LABEL_14:
v16 = v4 + 1;
v17 = (v15 + *v4) << 6;
LABEL_15:
v4 = v16 + 1;
v18 = v17 + *v16;
while ( 1 )
{
v19 = v18 - offsetsFromUTF8[(int)v3];
if ( v19 > 0xFFFF )
{
if ( v19 > 0x10FFFF )
{
if ( a3 )
{
LABEL_47:
v3 = s;
snprintf(s, 7uLL, "\\u%04x", 65533LL);
rb_str_buf_cat(a1, s, 6LL);
goto LABEL_48;
}
v21 = rb_path2class("JSON::GeneratorError");
rb_raise(v21, "source sequence is illegal/malformed");
}
v22 = v19 - 0x10000;
v3 = s;
snprintf(s, 7uLL, "\\u%04x", (unsigned __int16)((v22 >> 10) - 10240));
rb_str_buf_cat(a1, s, 6LL);
snprintf(s, 7uLL, "\\u%04x", (unsigned __int16)((v22 & 0x3FF) - 9216));
rb_str_buf_cat(a1, s, 6LL);
}
else
{
if ( v19 - 55296 <= 0x7FF )
{
if ( a3 )
goto LABEL_47;
v20 = rb_path2class("JSON::GeneratorError");
rb_raise(v20, "source sequence is illegal/malformed");
}
switch ( v19 )
{
case '"':
rb_str_buf_cat(a1, "\\\"", 2LL);
break;
case '\\':
rb_str_buf_cat(a1, "\\\\", 2LL);
break;
case '/':
rb_str_buf_cat(a1, "\\/", 2LL);
break;
default:
if ( v19 - 32 <= 0x5F )
{
rb_str_buf_cat(a1, v4 - 1, 1LL);
}
else
{
switch ( v19 )
{
case 0xAuLL:
rb_str_buf_cat(a1, "\\n", 2LL);
break;
case 0xDuLL:
rb_str_buf_cat(a1, "\\r", 2LL);
break;
case 9uLL:
rb_str_buf_cat(a1, "\\t", 2LL);
break;
case 0xCuLL:
rb_str_buf_cat(a1, "\\f", 2LL);
break;
case 8uLL:
rb_str_buf_cat(a1, "\\b", 2LL);
break;
default:
v3 = s;
snprintf(s, 7uLL, "\\u%04x", (unsigned __int16)v19);
rb_str_buf_cat(a1, s, 6LL);
break;
}
}
break;
}
}
LABEL_48:
if ( v4 >= v6 )
return;
v7 = *v4;
v8 = trailingBytesForUTF8[*v4];
LOWORD(v3) = v8;
if ( v6 <= &v4[(unsigned __int16)v8] )
goto LABEL_7;
LABEL_50:
LODWORD(v3) = (unsigned __int16)v3;
if ( !(unsigned __int8)func0(v4, (unsigned int)(unsigned __int16)v3 + 1) )
goto LABEL_8;
switch ( v8 )
{
case 0:
v16 = v4;
v17 = 0LL;
goto LABEL_15;
case 1:
v15 = 0LL;
goto LABEL_14;
case 2:
v13 = v4;
v14 = 0LL;
goto LABEL_13;
case 3:
v12 = 0LL;
goto LABEL_12;
case 4:
v11 = 0LL;
goto LABEL_11;
case 5:
goto LABEL_9;
default:
v18 = 0LL;
break;
}
}
}
}

original_code:
void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags)
{
    char buf[7];
    const UTF8* source = (UTF8 *) (!(((struct RBasic*)(string))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(string))->as.ary : ((struct RString*)(string))->as.heap.ptr);
    const UTF8* sourceEnd = source + (!(((struct RBasic*)(string))->flags & (((VALUE)1)<<(12 +1))) ? (long)((((struct RBasic*)(string))->flags >> (12 +2)) & (((((VALUE)1)<<(12 +2))|(((VALUE)1)<<(12 +3))|(((VALUE)1)<<(12 +4))|(((VALUE)1)<<(12 +5))|(((VALUE)1)<<(12 +6))) >> (12 +2))) : ((struct RString*)(string))->as.heap.len);
    while (source < sourceEnd) {
        UTF32 ch = 0;
        unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
        if (source + extraBytesToRead >= sourceEnd) {
            rb_raise(rb_path2class("JSON::GeneratorError"),
                    "partial character in source, but hit end");
        }
        if (!isLegalUTF8(source, extraBytesToRead+1)) {
            rb_raise(rb_path2class("JSON::GeneratorError"),
                    "source sequence is illegal/malformed");
        }
        switch (extraBytesToRead) {
            case 5: ch += *source++; ch <<= 6;
            case 4: ch += *source++; ch <<= 6;
            case 3: ch += *source++; ch <<= 6;
            case 2: ch += *source++; ch <<= 6;
            case 1: ch += *source++; ch <<= 6;
            case 0: ch += *source++;
        }
        ch -= offsetsFromUTF8[extraBytesToRead];
        if (ch <= (UTF32)0x0000FFFF) {
            if (ch >= (UTF32)0xD800 && ch <= (UTF32)0xDFFF) {
                if (flags == strictConversion) {
                    source -= (extraBytesToRead+1);
                    rb_raise(rb_path2class("JSON::GeneratorError"),
                        "source sequence is illegal/malformed");
                } else {
                    snprintf(buf, 7, "\\u%04x", (unsigned int) ((UTF32)0x0000FFFD)); rb_str_buf_cat(buffer, buf, 6);;
                }
            } else {
                if (ch == '"') {
                    __extension__ ( { (__builtin_constant_p("\\\"")) ? rb_str_buf_cat(buffer, "\\\"", strlen("\\\"")) : rb_str_buf_cat2(buffer, "\\\""); });
                } else if (ch == '\\') {
                    __extension__ ( { (__builtin_constant_p("\\\\")) ? rb_str_buf_cat(buffer, "\\\\", strlen("\\\\")) : rb_str_buf_cat2(buffer, "\\\\"); });
                } else if (ch == '/') {
                    __extension__ ( { (__builtin_constant_p("\\/")) ? rb_str_buf_cat(buffer, "\\/", strlen("\\/")) : rb_str_buf_cat2(buffer, "\\/"); });
                } else if (ch >= 0x20 && ch <= 0x7f) {
                    rb_str_buf_cat(buffer, (char *) source - 1, 1);
                } else if (ch == '\n') {
                    __extension__ ( { (__builtin_constant_p("\\n")) ? rb_str_buf_cat(buffer, "\\n", strlen("\\n")) : rb_str_buf_cat2(buffer, "\\n"); });
                } else if (ch == '\r') {
                    __extension__ ( { (__builtin_constant_p("\\r")) ? rb_str_buf_cat(buffer, "\\r", strlen("\\r")) : rb_str_buf_cat2(buffer, "\\r"); });
                } else if (ch == '\t') {
                    __extension__ ( { (__builtin_constant_p("\\t")) ? rb_str_buf_cat(buffer, "\\t", strlen("\\t")) : rb_str_buf_cat2(buffer, "\\t"); });
                } else if (ch == '\f') {
                    __extension__ ( { (__builtin_constant_p("\\f")) ? rb_str_buf_cat(buffer, "\\f", strlen("\\f")) : rb_str_buf_cat2(buffer, "\\f"); });
                } else if (ch == '\b') {
                    __extension__ ( { (__builtin_constant_p("\\b")) ? rb_str_buf_cat(buffer, "\\b", strlen("\\b")) : rb_str_buf_cat2(buffer, "\\b"); });
                } else if (ch < 0x20) {
                    snprintf(buf, 7, "\\u%04x", (unsigned int) ((UTF16) ch)); rb_str_buf_cat(buffer, buf, 6);;
                } else {
                    snprintf(buf, 7, "\\u%04x", (unsigned int) ((UTF16) ch)); rb_str_buf_cat(buffer, buf, 6);;
                }
            }
        } else if (ch > (UTF32)0x0010FFFF) {
            if (flags == strictConversion) {
                source -= (extraBytesToRead+1);
                rb_raise(rb_path2class("JSON::GeneratorError"),
                        "source sequence is illegal/malformed");
            } else {
                snprintf(buf, 7, "\\u%04x", (unsigned int) ((UTF32)0x0000FFFD)); rb_str_buf_cat(buffer, buf, 6);;
            }
        } else {
            ch -= halfBase;
            snprintf(buf, 7, "\\u%04x", (unsigned int) ((UTF16)((ch >> halfShift) + (UTF32)0xD800))); rb_str_buf_cat(buffer, buf, 6);;
            snprintf(buf, 7, "\\u%04x", (unsigned int) ((UTF16)((ch & halfMask) + (UTF32)0xDC00))); rb_str_buf_cat(buffer, buf, 6);;
        }
    }
}

canonical_original_code:
void JSON_convert_UTF8_to_JSON(unsigned long buffer, unsigned long string, enum ConversionFlags flags)
{
    char buf[7];
    unsigned char *source = (UTF8 *) (!(((struct RBasic*)(string))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(string))->as.ary : ((struct RString*)(string))->as.heap.ptr);
    unsigned char *sourceEnd = source + (!(((struct RBasic*)(string))->flags & (((VALUE)1)<<(12 +1))) ? (long)((((struct RBasic*)(string))->flags >> (12 +2)) & (((((VALUE)1)<<(12 +2))|(((VALUE)1)<<(12 +3))|(((VALUE)1)<<(12 +4))|(((VALUE)1)<<(12 +5))|(((VALUE)1)<<(12 +6))) >> (12 +2))) : ((struct RString*)(string))->as.heap.len);
    while (source < sourceEnd) {
        unsigned long ch = 0;
        unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
        if (source + extraBytesToRead >= sourceEnd) {
            rb_raise(rb_path2class("JSON::GeneratorError"),
                    "partial character in source, but hit end");
        }
        if (!isLegalUTF8(source, extraBytesToRead+1)) {
            rb_raise(rb_path2class("JSON::GeneratorError"),
                    "source sequence is illegal/malformed");
        }
        switch (extraBytesToRead) {
            case 5: ch += *source++; ch <<= 6;
            case 4: ch += *source++; ch <<= 6;
            case 3: ch += *source++; ch <<= 6;
            case 2: ch += *source++; ch <<= 6;
            case 1: ch += *source++; ch <<= 6;
            case 0: ch += *source++;
        }
        ch -= offsetsFromUTF8[extraBytesToRead];
        if (ch <= (unsigned long)0x0000FFFF) {
            if (ch >= (unsigned long)0xD800 && ch <= (unsigned long)0xDFFF) {
                if (flags == strictConversion) {
                    source -= (extraBytesToRead+1);
                    rb_raise(rb_path2class("JSON::GeneratorError"),
                        "source sequence is illegal/malformed");
                } else {
                    snprintf(buf, 7, "\\u%04x", (unsigned int) ((unsigned long)0x0000FFFD)); rb_str_buf_cat(buffer, buf, 6);;
                }
            } else {
                if (ch == '"') {
                    __extension__ ( { (__builtin_constant_p("\\\"")) ? rb_str_buf_cat(buffer, "\\\"", strlen("\\\"")) : rb_str_buf_cat2(buffer, "\\\""); });
                } else if (ch == '\\') {
                    __extension__ ( { (__builtin_constant_p("\\\\")) ? rb_str_buf_cat(buffer, "\\\\", strlen("\\\\")) : rb_str_buf_cat2(buffer, "\\\\"); });
                } else if (ch == '/') {
                    __extension__ ( { (__builtin_constant_p("\\/")) ? rb_str_buf_cat(buffer, "\\/", strlen("\\/")) : rb_str_buf_cat2(buffer, "\\/"); });
                } else if (ch >= 0x20 && ch <= 0x7f) {
                    rb_str_buf_cat(buffer, (char *) source - 1, 1);
                } else if (ch == '\n') {
                    __extension__ ( { (__builtin_constant_p("\\n")) ? rb_str_buf_cat(buffer, "\\n", strlen("\\n")) : rb_str_buf_cat2(buffer, "\\n"); });
                } else if (ch == '\r') {
                    __extension__ ( { (__builtin_constant_p("\\r")) ? rb_str_buf_cat(buffer, "\\r", strlen("\\r")) : rb_str_buf_cat2(buffer, "\\r"); });
                } else if (ch == '\t') {
                    __extension__ ( { (__builtin_constant_p("\\t")) ? rb_str_buf_cat(buffer, "\\t", strlen("\\t")) : rb_str_buf_cat2(buffer, "\\t"); });
                } else if (ch == '\f') {
                    __extension__ ( { (__builtin_constant_p("\\f")) ? rb_str_buf_cat(buffer, "\\f", strlen("\\f")) : rb_str_buf_cat2(buffer, "\\f"); });
                } else if (ch == '\b') {
                    __extension__ ( { (__builtin_constant_p("\\b")) ? rb_str_buf_cat(buffer, "\\b", strlen("\\b")) : rb_str_buf_cat2(buffer, "\\b"); });
                } else if (ch < 0x20) {
                    snprintf(buf, 7, "\\u%04x", (unsigned int) ((unsigned short) ch)); rb_str_buf_cat(buffer, buf, 6);;
                } else {
                    snprintf(buf, 7, "\\u%04x", (unsigned int) ((unsigned short) ch)); rb_str_buf_cat(buffer, buf, 6);;
                }
            }
        } else if (ch > (unsigned long)0x0010FFFF) {
            if (flags == strictConversion) {
                source -= (extraBytesToRead+1);
                rb_raise(rb_path2class("JSON::GeneratorError"),
                        "source sequence is illegal/malformed");
            } else {
                snprintf(buf, 7, "\\u%04x", (unsigned int) ((unsigned long)0x0000FFFD)); rb_str_buf_cat(buffer, buf, 6);;
            }
        } else {
            ch -= halfBase;
            snprintf(buf, 7, "\\u%04x", (unsigned int) ((UTF16)((ch >> halfShift) + (unsigned long)0xD800))); rb_str_buf_cat(buffer, buf, 6);;
            snprintf(buf, 7, "\\u%04x", (unsigned int) ((UTF16)((ch & halfMask) + (unsigned long)0xDC00))); rb_str_buf_cat(buffer, buf, 6);;
        }
    }
}

variable_types:
buffer
unsigned long

variable_types:
string
unsigned long

variable_types: enum ConversionFlags { strictConversion=0, lenientConversion=1 }

variable_types:
buf
char [7]

variable_types:
sourceEnd
unsigned char *

variable_types:
extraBytesToRead
unsigned short


decompiled_code:
__int64 Init_sha2()
{
__int64 v0; // r12
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // r14
__int64 v4; // rax
__int64 v5; // r14
__int64 v6; // rax
__int64 v7; // rbx
__int64 v8; // rax

rb_require("digest");
if ( !rb_intern_id_cache_0 )
rb_intern_id_cache_0 = rb_intern2("metadata", 8LL);
v0 = rb_intern_id_cache_0;
v1 = rb_path2class("Digest");
v2 = rb_path2class("Digest::Base");
v3 = rb_define_class_under(v1, "SHA256", v2);
v4 = rb_data_object_alloc(rb_cObject, &sha256, 0LL, 0LL);
rb_ivar_set(v3, v0, v4);
v5 = rb_define_class_under(v1, "SHA384", v2);
v6 = rb_data_object_alloc(rb_cObject, &sha384, 0LL, 0LL);
rb_ivar_set(v5, v0, v6);
v7 = rb_define_class_under(v1, "SHA512", v2);
v8 = rb_data_object_alloc(rb_cObject, &sha512, 0LL, 0LL);
return rb_ivar_set(v7, v0, v8);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // r12
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // r14
__int64 v4; // rax
__int64 v5; // r14
__int64 v6; // rax
__int64 v7; // rbx
__int64 v8; // rax

rb_require("digest");
if ( !rb_intern_id_cache_0 )
rb_intern_id_cache_0 = rb_intern2("metadata", 8LL);
v0 = rb_intern_id_cache_0;
v1 = rb_path2class("Digest");
v2 = rb_path2class("Digest::Base");
v3 = rb_define_class_under(v1, "SHA256", v2);
v4 = rb_data_object_alloc(rb_cObject, &sha256, 0LL, 0LL);
rb_ivar_set(v3, v0, v4);
v5 = rb_define_class_under(v1, "SHA384", v2);
v6 = rb_data_object_alloc(rb_cObject, &sha384, 0LL, 0LL);
rb_ivar_set(v5, v0, v6);
v7 = rb_define_class_under(v1, "SHA512", v2);
v8 = rb_data_object_alloc(rb_cObject, &sha512, 0LL, 0LL);
return rb_ivar_set(v7, v0, v8);
}

original_code:
void
Init_sha2()
{
    VALUE mDigest, cDigest_Base;
    ID id_metadata;
    VALUE cDigest_SHA256; VALUE cDigest_SHA384; VALUE cDigest_SHA512;
    rb_require("digest");
    id_metadata = (__builtin_constant_p("metadata") ? __extension__ ({ static ID rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("metadata", strlen("metadata")); rb_intern_id_cache; }) : rb_intern("metadata"));
    mDigest = rb_path2class("Digest");
    cDigest_Base = rb_path2class("Digest::Base");
    cDigest_SHA256 = rb_define_class_under(mDigest, "SHA" "256", cDigest_Base); rb_ivar_set(cDigest_SHA256, id_metadata, rb_data_object_alloc(rb_cObject,(void *)&sha256,(RUBY_DATA_FUNC)0,(RUBY_DATA_FUNC)0)); cDigest_SHA384 = rb_define_class_under(mDigest, "SHA" "384", cDigest_Base); rb_ivar_set(cDigest_SHA384, id_metadata, rb_data_object_alloc(rb_cObject,(void *)&sha384,(RUBY_DATA_FUNC)0,(RUBY_DATA_FUNC)0)); cDigest_SHA512 = rb_define_class_under(mDigest, "SHA" "512", cDigest_Base); rb_ivar_set(cDigest_SHA512, id_metadata, rb_data_object_alloc(rb_cObject,(void *)&sha512,(RUBY_DATA_FUNC)0,(RUBY_DATA_FUNC)0));
}

canonical_original_code:
void Init_sha2()
{
    unsigned long mDigest; unsigned long cDigest_Base;
    unsigned long id_metadata;
    unsigned long cDigest_SHA256; unsigned long cDigest_SHA384; unsigned long cDigest_SHA512;
    rb_require("digest");
    id_metadata = (__builtin_constant_p("metadata") ? __extension__ ({ static unsigned long rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("metadata", strlen("metadata")); rb_intern_id_cache; }) : rb_intern("metadata"));
    mDigest = rb_path2class("Digest");
    cDigest_Base = rb_path2class("Digest::Base");
    cDigest_SHA256 = rb_define_class_under(mDigest, "SHA" "256", cDigest_Base); rb_ivar_set(cDigest_SHA256, id_metadata, rb_data_object_alloc(rb_cObject,(void *)&sha256,(void (*)(void *))0,(void (*)(void *))0)); cDigest_SHA384 = rb_define_class_under(mDigest, "SHA" "384", cDigest_Base); rb_ivar_set(cDigest_SHA384, id_metadata, rb_data_object_alloc(rb_cObject,(void *)&sha384,(void (*)(void *))0,(void (*)(void *))0)); cDigest_SHA512 = rb_define_class_under(mDigest, "SHA" "512", cDigest_Base); rb_ivar_set(cDigest_SHA512, id_metadata, rb_data_object_alloc(rb_cObject,(void *)&sha512,(void (*)(void *))0,(void (*)(void *))0));
}

variable_types:
mDigest
unsigned long


decompiled_code:
__int64 Init_rational()
{
return nurat_canonicalization(1LL);
}

canonical_decompiled_code:
__int64 func0()
{
return nurat_canonicalization(1LL);
}

original_code:
void
Init_rational(void)
{
    nurat_canonicalization(1);
}

canonical_original_code:
void Init_rational()
{
    nurat_canonicalization(1);
}


decompiled_code:
__int64 Init_bubblebabble()
{
__int64 v0; // r12
__int64 v1; // rbx
__int64 v2; // rbp
__int64 result; // rax

rb_require("digest");
v0 = rb_path2class("Digest");
v1 = rb_path2class("Digest::Instance");
v2 = rb_path2class("Digest::Class");
rb_define_module_function(v0, "bubblebabble", rb_digest_s_bubblebabble, 1LL);
rb_define_singleton_method(v2, "bubblebabble", rb_digest_class_s_bubblebabble, 0xFFFFFFFFLL);
rb_define_method(v1, "bubblebabble", rb_digest_instance_bubblebabble, 0LL);
if ( !rb_intern_id_cache_2 )
rb_intern_id_cache_2 = rb_intern2("digest", 6LL);
result = rb_intern_id_cache_2;
id_digest = rb_intern_id_cache_2;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // r12
__int64 v1; // rbx
__int64 v2; // rbp
__int64 result; // rax

rb_require("digest");
v0 = rb_path2class("Digest");
v1 = rb_path2class("Digest::Instance");
v2 = rb_path2class("Digest::Class");
rb_define_module_function(v0, "bubblebabble", rb_digest_s_bubblebabble, 1LL);
rb_define_singleton_method(v2, "bubblebabble", rb_digest_class_s_bubblebabble, 0xFFFFFFFFLL);
rb_define_method(v1, "bubblebabble", rb_digest_instance_bubblebabble, 0LL);
if ( !rb_intern_id_cache_2 )
rb_intern_id_cache_2 = rb_intern2("digest", 6LL);
result = rb_intern_id_cache_2;
id_digest = rb_intern_id_cache_2;
return result;
}

original_code:
void
Init_bubblebabble(void)
{
    VALUE mDigest, mDigest_Instance, cDigest_Class;
    rb_require("digest");
    mDigest = rb_path2class("Digest");
    mDigest_Instance = rb_path2class("Digest::Instance");
    cDigest_Class = rb_path2class("Digest::Class");
    rb_define_module_function(mDigest, "bubblebabble", rb_digest_s_bubblebabble, 1);
    rb_define_singleton_method(cDigest_Class, "bubblebabble", rb_digest_class_s_bubblebabble, -1);
    rb_define_method(mDigest_Instance, "bubblebabble", rb_digest_instance_bubblebabble, 0);
    id_digest = (__builtin_constant_p("digest") ? __extension__ ({ static ID rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("digest", strlen("digest")); rb_intern_id_cache; }) : rb_intern("digest"));
}

canonical_original_code:
void Init_bubblebabble()
{
    unsigned long mDigest; unsigned long mDigest_Instance; unsigned long cDigest_Class;
    rb_require("digest");
    mDigest = rb_path2class("Digest");
    mDigest_Instance = rb_path2class("Digest::Instance");
    cDigest_Class = rb_path2class("Digest::Class");
    rb_define_module_function(mDigest, "bubblebabble", rb_digest_s_bubblebabble, 1);
    rb_define_singleton_method(cDigest_Class, "bubblebabble", rb_digest_class_s_bubblebabble, -1);
    rb_define_method(mDigest_Instance, "bubblebabble", rb_digest_instance_bubblebabble, 0);
    id_digest = (__builtin_constant_p("digest") ? __extension__ ({ static unsigned long rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("digest", strlen("digest")); rb_intern_id_cache; }) : rb_intern("digest"));
}


decompiled_code:
__int64 Init_complex()
{
return nucomp_canonicalization(1LL);
}

canonical_decompiled_code:
__int64 func0()
{
return nucomp_canonicalization(1LL);
}

original_code:
void
Init_complex(void)
{
    nucomp_canonicalization(1);
}

canonical_original_code:
void Init_complex()
{
    nucomp_canonicalization(1);
}


original_code:
void
rb_Digest_MD5_Update(MD5_CTX *pms, const uint8_t *data, size_t nbytes)
{
    const uint8_t *p = data;
    size_t left = nbytes;
    size_t offset = (pms->count[0] >> 3) & 63;
    uint32_t nbits = (uint32_t)(nbytes << 3);
    if (nbytes <= 0)
 return;
    pms->count[1] += nbytes >> 29;
    pms->count[0] += nbits;
    if (pms->count[0] < nbits)
 pms->count[1]++;
    if (offset) {
 size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
 memcpy(pms->buffer + offset, p, copy);
 if (offset + copy < 64)
     return;
 p += copy;
 left -= copy;
 md5_process(pms, pms->buffer);
    }
    for (; left >= 64; p += 64, left -= 64)
 md5_process(pms, p);
    if (left)
 memcpy(pms->buffer, p, left);
}

canonical_original_code:
void rb_Digest_MD5_Update(struct md5_state_s *pms, unsigned char *data, unsigned long nbytes)
{
    unsigned char *p = data;
    unsigned long left = nbytes;
    unsigned long offset = (pms->count[0] >> 3) & 63;
    unsigned int nbits = (uint32_t)(nbytes << 3);
    if (nbytes <= 0)
 return;
    pms->count[1] += nbytes >> 29;
    pms->count[0] += nbits;
    if (pms->count[0] < nbits)
 pms->count[1]++;
    if (offset) {
 unsigned long copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
 memcpy(pms->buffer + offset, p, copy);
 if (offset + copy < 64)
     return;
 p += copy;
 left -= copy;
 md5_process(pms, pms->buffer);
    }
    for (; left >= 64; p += 64, left -= 64)
 md5_process(pms, p);
    if (left)
 memcpy(pms->buffer, p, left);
}

variable_types: struct md5_state_s { unsigned int count[2]; unsigned int state[4]; unsigned char buffer[64]; } *

variable_types:
data
unsigned char *

variable_types:
nbytes
unsigned long

variable_types:
p
unsigned char *

variable_types:
left
unsigned long

variable_types:
offset
unsigned long

variable_types:
nbits
unsigned int

variable_types:
copy
unsigned long