main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // er12
__off_t v5; // rax
int v7; // edi
char buf; // [rsp+7h] [rbp-21h] BYREF
unsigned int v9; // [rsp+8h] [rbp-20h]

v3 = open("/dev/nvram", 2, envp);
v4 = v3;
if ( v3 == -1 )
{
perror("open");
return v4;
}
v5 = lseek(v3, 0LL, 2);
if ( v5 <= 0 )
{
perror("lseek");
goto LABEL_10;
}
fprintf(stderr, "NVRAM size is 0x%x bytes\n", (unsigned int)v5);
fwrite("Testing data bus: ", 1uLL, 0x12uLL, stdout);
if ( (unsigned int)test_data_bus(v4, &buf) )
{
fwrite("FAILED\n", 1uLL, 7uLL, stdout);
fprintf(stderr, "Data bus test failed with pattern 0x%x\n", (unsigned int)buf);
LABEL_10:
v7 = v4;
v4 = -1;
close(v7);
return v4;
}
fwrite("PASSED\n", 1uLL, 7uLL, stdout);
fwrite("Testing address bus: ", 1uLL, 0x15uLL, stdout);
if ( (unsigned int)test_address_bus(v4) )
{
fwrite("FAILED\n", 1uLL, 7uLL, stdout);
fprintf(stderr, "Address bus test failed at offset 0x%x\n", v9);
goto LABEL_10;
}
fwrite("PASSED\n", 1uLL, 7uLL, stdout);
fwrite("Testing memory: ", 1uLL, 0x10uLL, stdout);
if ( (unsigned int)test_memory(v4) )
{
fwrite("FAILED\n", 1uLL, 7uLL, stdout);
fprintf(stderr, "Memory test failed at offset 0x%x\n", v9);
goto LABEL_10;
}
fwrite("PASSED\n", 1uLL, 7uLL, stdout);
v4 = close(v4);
if ( v4 )
{
v4 = -1;
perror("close");
}
return v4;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // er12
__off_t v5; // rax
int v7; // edi
char buf; // [rsp+7h] [rbp-21h] BYREF
unsigned int v9; // [rsp+8h] [rbp-20h]

v3 = open("/dev/nvram", 2, envp);
v4 = v3;
if ( v3 == -1 )
{
perror("open");
return v4;
}
v5 = lseek(v3, 0LL, 2);
if ( v5 <= 0 )
{
perror("lseek");
goto LABEL_10;
}
fprintf(stderr, "NVRAM size is 0x%x bytes\n", (unsigned int)v5);
fwrite("Testing data bus: ", 1uLL, 0x12uLL, stdout);
if ( (unsigned int)func7(v4, &buf) )
{
fwrite("FAILED\n", 1uLL, 7uLL, stdout);
fprintf(stderr, "Data bus test failed with pattern 0x%x\n", (unsigned int)buf);
LABEL_10:
v7 = v4;
v4 = -1;
close(v7);
return v4;
}
fwrite("PASSED\n", 1uLL, 7uLL, stdout);
fwrite("Testing address bus: ", 1uLL, 0x15uLL, stdout);
if ( (unsigned int)func8(v4) )
{
fwrite("FAILED\n", 1uLL, 7uLL, stdout);
fprintf(stderr, "Address bus test failed at offset 0x%x\n", v9);
goto LABEL_10;
}
fwrite("PASSED\n", 1uLL, 7uLL, stdout);
fwrite("Testing memory: ", 1uLL, 0x10uLL, stdout);
if ( (unsigned int)func9(v4) )
{
fwrite("FAILED\n", 1uLL, 7uLL, stdout);
fprintf(stderr, "Memory test failed at offset 0x%x\n", v9);
goto LABEL_10;
}
fwrite("PASSED\n", 1uLL, 7uLL, stdout);
v4 = close(v4);
if ( v4 )
{
v4 = -1;
perror("close");
}
return v4;
}

original_code:
int main()
{
 off_t size;
 int fd;
 char error_data;
 off_t error_offset;
 fd = open("/dev/nvram", 02);
 if (-1 == fd) {
  perror("open");
  return -1;
 }
 size = lseek(fd, 0, 2);
 if (0 >= size) {
  perror("lseek");
  goto err_out;
 }
 fprintf(stderr, "NVRAM size is 0x%x bytes\n", (int) size);
 fprintf(stdout, "Testing data bus: ");
 if (test_data_bus(fd, &error_data)) {
  fprintf(stdout, "FAILED\n");
  fprintf(stderr, "Data bus test failed with pattern 0x%x\n",
   error_data);
  goto err_out;
 }
 fprintf(stdout, "PASSED\n");
 fprintf(stdout, "Testing address bus: ");
 if (test_address_bus(fd, size, &error_offset)) {
  fprintf(stdout, "FAILED\n");
  fprintf(stderr, "Address bus test failed at offset 0x%x\n",
   (int) error_offset);
  goto err_out;
 }
 fprintf(stdout, "PASSED\n");
 fprintf(stdout, "Testing memory: ");
 if (test_memory(fd, size, &error_offset)) {
  fprintf(stdout, "FAILED\n");
  fprintf(stderr, "Memory test failed at offset 0x%x\n",
   (int) error_offset);
  goto err_out;
 }
 fprintf(stdout, "PASSED\n");
 if (close(fd)) {
  perror("close");
  return -1;
 }
 return 0;
      err_out:
 close(fd);
 return -1;
}

canonical_original_code:
int main()
{
 long size;
 int fd;
 char error_data;
 long error_offset;
 fd = open("/dev/nvram", 02);
 if (-1 == fd) {
  perror("open");
  return -1;
 }
 size = lseek(fd, 0, 2);
 if (0 >= size) {
  perror("lseek");
  goto err_out;
 }
 fprintf(stderr, "NVRAM size is 0x%x bytes\n", (int) size);
 fprintf(stdout, "Testing data bus: ");
 if (test_data_bus(fd, &error_data)) {
  fprintf(stdout, "FAILED\n");
  fprintf(stderr, "Data bus test failed with pattern 0x%x\n",
   error_data);
  goto err_out;
 }
 fprintf(stdout, "PASSED\n");
 fprintf(stdout, "Testing address bus: ");
 if (test_address_bus(fd, size, &error_offset)) {
  fprintf(stdout, "FAILED\n");
  fprintf(stderr, "Address bus test failed at offset 0x%x\n",
   (int) error_offset);
  goto err_out;
 }
 fprintf(stdout, "PASSED\n");
 fprintf(stdout, "Testing memory: ");
 if (test_memory(fd, size, &error_offset)) {
  fprintf(stdout, "FAILED\n");
  fprintf(stderr, "Memory test failed at offset 0x%x\n",
   (int) error_offset);
  goto err_out;
 }
 fprintf(stdout, "PASSED\n");
 if (close(fd)) {
  perror("close");
  return -1;
 }
 return 0;
      err_out:
 close(fd);
 return -1;
}


repo: maryheintz/vme

decompiled_code:
char *__fastcall vme_mmap_phys(int fd, unsigned __int64 a2, __int64 a3)
{
int v5; // eax
size_t v6; // rsi
unsigned __int64 v7; // rbp
unsigned __int64 v8; // rt2
size_t v9; // rcx
char *result; // rax
char *v11; // rbp

v5 = getpagesize();
v6 = a2 % v5 + a3;
v7 = a2 % v5;
v8 = v6 % v5;
v9 = v6 + v5 - v8;
if ( v8 )
v6 = v9;
result = (char *)mmap(0LL, v6, 3, 1, fd, a2 - v7);
v11 = &result[v7];
if ( result )
result = v11;
return result;
}

canonical_decompiled_code:
char *__fastcall func0(int fd, unsigned __int64 a2, __int64 a3)
{
int v5; // eax
size_t v6; // rsi
unsigned __int64 v7; // rbp
unsigned __int64 v8; // rt2
size_t v9; // rcx
char *result; // rax
char *v11; // rbp

v5 = getpagesize();
v6 = a2 % v5 + a3;
v7 = a2 % v5;
v8 = v6 % v5;
v9 = v6 + v5 - v8;
if ( v8 )
v6 = v9;
result = (char *)mmap(0LL, v6, 3, 1, fd, a2 - v7);
v11 = &result[v7];
if ( result )
result = v11;
return result;
}

original_code:
void *vme_mmap_phys(int fd, unsigned long paddr, size_t size)
{
 unsigned long mapaddr, off, mapsize;
 size_t ps = getpagesize();
 char *ptr;
 off = paddr % ps;
 mapaddr = paddr - off;
 mapsize = size + off;
 mapsize += (mapsize % ps) ? ps - (mapsize % ps) : 0;
 ptr = mmap(0, mapsize, 0x1 | 0x2, 0x01, fd, mapaddr);
 if (!ptr)
  return ((void *)0);
 return ptr + off;
}

canonical_original_code:
void *vme_mmap_phys(int fd, unsigned long paddr, unsigned long size)
{
 unsigned long mapaddr; unsigned long off; unsigned long mapsize;
 unsigned long ps = getpagesize();
 char *ptr;
 off = paddr % ps;
 mapaddr = paddr - off;
 mapsize = size + off;
 mapsize += (mapsize % ps) ? ps - (mapsize % ps) : 0;
 ptr = mmap(0, mapsize, 0x1 | 0x2, 0x01, fd, mapaddr);
 if (!ptr)
  return ((void *)0);
 return ptr + off;
}

variable_types: fd int

variable_types:
paddr
unsigned long

variable_types:
size
unsigned long

variable_types:
mapaddr
unsigned long

variable_types:
off
unsigned long

variable_types:
mapsize
unsigned long

variable_types:
ps
unsigned long

variable_types:
ptr
char *

return_type: void *


decompiled_code:
int __fastcall vme_unmap_phys(unsigned __int64 a1, __int64 a2)
{
int v3; // eax
unsigned __int64 v4; // rdx
size_t v5; // rsi
void *v6; // rdi
unsigned __int64 v7; // rt2
size_t v8; // rcx

v3 = getpagesize();
v4 = a1 % v3;
v5 = v4 + a2;
v6 = (void *)(a1 - v4);
v7 = (v4 + a2) % v3;
v8 = v5 + v3 - v7;
if ( v7 )
v5 = v8;
return munmap(v6, v5);
}

canonical_decompiled_code:
int __fastcall func1(unsigned __int64 a1, __int64 a2)
{
int v3; // eax
unsigned __int64 v4; // rdx
size_t v5; // rsi
void *v6; // rdi
unsigned __int64 v7; // rt2
size_t v8; // rcx

v3 = getpagesize();
v4 = a1 % v3;
v5 = v4 + a2;
v6 = (void *)(a1 - v4);
v7 = (v4 + a2) % v3;
v8 = v5 + v3 - v7;
if ( v7 )
v5 = v8;
return munmap(v6, v5);
}

original_code:
int vme_unmap_phys(unsigned long vaddr, size_t size)
{
 unsigned long mapaddr, off, mapsize;
 size_t ps = getpagesize();
 off = vaddr % ps;
 mapaddr = vaddr - off;
 mapsize = size + off;
 mapsize += (mapsize % ps) ? ps - (mapsize % ps) : 0;
 return munmap((void *) mapaddr, mapsize);
}

canonical_original_code:
int vme_unmap_phys(unsigned long vaddr, unsigned long size)
{
 unsigned long mapaddr; unsigned long off; unsigned long mapsize;
 unsigned long ps = getpagesize();
 off = vaddr % ps;
 mapaddr = vaddr - off;
 mapsize = size + off;
 mapsize += (mapsize % ps) ? ps - (mapsize % ps) : 0;
 return munmap((void *) mapaddr, mapsize);
}

variable_types:
vaddr
unsigned long

return_type: int


strtoam

decompiled_code:
int __fastcall strtoam(char *s1, _DWORD *a2)
{
__int64 v3; // rbx
const char *v4; // rsi
int result; // eax
char *s2[69]; // [rsp+0h] [rbp+0h] BYREF

v3 = 0LL;
qmemcpy(s2, &unk_F80, 0x200uLL);
do
{
v4 = s2[v3];
if ( v4 )
{
result = strcmp(s1, v4);
if ( !result )
{
*a2 = v3;
return result;
}
}
++v3;
}
while ( v3 != 64 );
return -1;
}

canonical_decompiled_code:
int __fastcall func0(char *s1, _DWORD *a2)
{
__int64 v3; // rbx
const char *v4; // rsi
int result; // eax
char *s2[69]; // [rsp+0h] [rbp+0h] BYREF

v3 = 0LL;
qmemcpy(s2, &unk_F80, 0x200uLL);
do
{
v4 = s2[v3];
if ( v4 )
{
result = strcmp(s1, v4);
if ( !result )
{
*a2 = v3;
return result;
}
}
++v3;
}
while ( v3 != 64 );
return -1;
}

variable_types:
str
char *

variable_types:
am
int *

variable_types:
table
char *[]

variable_types: ii int


strtoas

decompiled_code:
int __fastcall strtoas(char *s1, _DWORD *a2)
{
__int64 v3; // rbx
int result; // eax
const char *v5; // rsi
char *s2[7]; // [rsp+0h] [rbp-38h]

v3 = 0LL;
s2[1] = "VME_A24";
s2[2] = "VME_A32";
if ( "VME_A16" && (result = strcmp(s1, "VME_A16")) == 0 )
{
LABEL_6:
*a2 = v3;
}
else
{
while ( ++v3 != 3 )
{
v5 = s2[v3];
if ( v5 )
{
result = strcmp(s1, v5);
if ( !result )
goto LABEL_6;
}
}
result = -1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(char *s1, _DWORD *a2)
{
__int64 v3; // rbx
int result; // eax
const char *v5; // rsi
char *s2[7]; // [rsp+0h] [rbp-38h]

v3 = 0LL;
s2[1] = "VME_A24";
s2[2] = "VME_A32";
if ( "VME_A16" && (result = strcmp(s1, "VME_A16")) == 0 )
{
LABEL_6:
*a2 = v3;
}
else
{
while ( ++v3 != 3 )
{
v5 = s2[v3];
if ( v5 )
{
result = strcmp(s1, v5);
if ( !result )
goto LABEL_6;
}
}
result = -1;
}
return result;
}

original_code:
int strtoas(const char *str, int *as)
{
 char *table[] = {
  "VME_A16", "VME_A24", "VME_A32"
 };
 int ii;
 for (ii = 0; ii <= VME_A32; ++ii)
  if (table[ii]) {
   if (0 == strcmp(str, table[ii])) {
    *as = ii;
    return 0;
   }
  }
 return -1;
}

canonical_original_code:
int strtoas(char *str, int *as)
{
 char *table[] = {
  "VME_A16", "VME_A24", "VME_A32"
 };
 int ii;
 for (ii = 0; ii <= VME_A32; ++ii)
  if (table[ii]) {
   if (0 == strcmp(str, table[ii])) {
    *as = ii;
    return 0;
   }
  }
 return -1;
}

variable_types:
as
int *


strtodw

decompiled_code:
int __fastcall strtodw(char *s1, _DWORD *a2)
{
__int64 v3; // rbx
const char *v4; // rsi
int result; // eax
char *s2[13]; // [rsp+0h] [rbp-68h]

v3 = 1LL;
s2[1] = "VME_D8";
s2[2] = "VME_D16";
s2[3] = 0LL;
s2[4] = "VME_D32";
s2[5] = 0LL;
s2[6] = 0LL;
s2[7] = 0LL;
s2[8] = "VME_D64";
while ( 1 )
{
if ( v3 == 9 )
return -1;
v4 = s2[v3];
if ( v4 )
{
result = strcmp(s1, v4);
if ( !result )
break;
}
++v3;
}
*a2 = v3;
return result;
}

original_code:
int strtodw(const char *str, int *dw)
{
 char *table[] = {
  ((void *)0), "VME_D8", "VME_D16", ((void *)0), "VME_D32", ((void *)0), ((void *)0), ((void *)0),
  "VME_D64"
 };
 int ii;
 for (ii = 0; ii <= VME_D64; ++ii)
  if (table[ii]) {
   if (0 == strcmp(str, table[ii])) {
    *dw = ii;
    return 0;
   }
  }
 return -1;
}

canonical_original_code:
int strtodw(char *str, int *dw)
{
 char *table[] = {
  ((void *)0), "VME_D8", "VME_D16", ((void *)0), "VME_D32", ((void *)0), ((void *)0), ((void *)0),
  "VME_D64"
 };
 int ii;
 for (ii = 0; ii <= VME_D64; ++ii)
  if (table[ii]) {
   if (0 == strcmp(str, table[ii])) {
    *dw = ii;
    return 0;
   }
  }
 return -1;
}

variable_types:
dw
int *


strtolvl

decompiled_code:
int __fastcall strtolvl(char *s1, _DWORD *a2)
{
const char *v3; // rsi
__int64 v4; // rbx
int result; // eax
char *s2[27]; // [rsp+0h] [rbp-D8h]

v3 = "VME_INTERRUPT_VOWN";
v4 = 0LL;
s2[1] = "VME_INTERRUPT_VIRQ1";
s2[2] = "VME_INTERRUPT_VIRQ2";
s2[3] = "VME_INTERRUPT_VIRQ3";
s2[4] = "VME_INTERRUPT_VIRQ4";
s2[5] = "VME_INTERRUPT_VIRQ5";
s2[6] = "VME_INTERRUPT_VIRQ6";
s2[7] = "VME_INTERRUPT_VIRQ7";
s2[8] = "VME_INTERRUPT_DMA";
s2[9] = "VME_INTERRUPT_LERR";
s2[10] = "VME_INTERRUPT_BERR";
s2[11] = 0LL;
s2[12] = "VME_INTERRUPT_SW_IACK";
s2[13] = "VME_INTERRUPT_SW_INT";
s2[14] = "VME_INTERRUPT_SYSFAIL";
s2[15] = "VME_INTERRUPT_ACFAIL";
s2[16] = "VME_INTERRUPT_MBOX0";
s2[17] = "VME_INTERRUPT_MBOX1";
s2[18] = "VME_INTERRUPT_MBOX2";
s2[19] = "VME_INTERRUPT_MBOX3";
s2[20] = "VME_INTERRUPT_LM0";
s2[21] = "VME_INTERRUPT_LM1";
s2[22] = "VME_INTERRUPT_LM2";
s2[23] = "VME_INTERRUPT_LM3";
while ( 1 )
{
if ( v3 )
{
result = strcmp(s1, v3);
if ( !result )
break;
}
if ( ++v4 == 24 )
return -1;
v3 = s2[v4];
}
*a2 = v4;
return result;
}

canonical_decompiled_code:
int __fastcall func3(char *s1, _DWORD *a2)
{
const char *v3; // rsi
__int64 v4; // rbx
int result; // eax
char *s2[27]; // [rsp+0h] [rbp-D8h]

v3 = "VME_INTERRUPT_VOWN";
v4 = 0LL;
s2[1] = "VME_INTERRUPT_VIRQ1";
s2[2] = "VME_INTERRUPT_VIRQ2";
s2[3] = "VME_INTERRUPT_VIRQ3";
s2[4] = "VME_INTERRUPT_VIRQ4";
s2[5] = "VME_INTERRUPT_VIRQ5";
s2[6] = "VME_INTERRUPT_VIRQ6";
s2[7] = "VME_INTERRUPT_VIRQ7";
s2[8] = "VME_INTERRUPT_DMA";
s2[9] = "VME_INTERRUPT_LERR";
s2[10] = "VME_INTERRUPT_BERR";
s2[11] = 0LL;
s2[12] = "VME_INTERRUPT_SW_IACK";
s2[13] = "VME_INTERRUPT_SW_INT";
s2[14] = "VME_INTERRUPT_SYSFAIL";
s2[15] = "VME_INTERRUPT_ACFAIL";
s2[16] = "VME_INTERRUPT_MBOX0";
s2[17] = "VME_INTERRUPT_MBOX1";
s2[18] = "VME_INTERRUPT_MBOX2";
s2[19] = "VME_INTERRUPT_MBOX3";
s2[20] = "VME_INTERRUPT_LM0";
s2[21] = "VME_INTERRUPT_LM1";
s2[22] = "VME_INTERRUPT_LM2";
s2[23] = "VME_INTERRUPT_LM3";
while ( 1 )
{
if ( v3 )
{
result = strcmp(s1, v3);
if ( !result )
break;
}
if ( ++v4 == 24 )
return -1;
v3 = s2[v4];
}
*a2 = v4;
return result;
}

original_code:
int strtolvl(const char *str, int *level)
{
 char *table[] = {
  "VME_INTERRUPT_VOWN", "VME_INTERRUPT_VIRQ1",
  "VME_INTERRUPT_VIRQ2", "VME_INTERRUPT_VIRQ3",
  "VME_INTERRUPT_VIRQ4", "VME_INTERRUPT_VIRQ5",
  "VME_INTERRUPT_VIRQ6", "VME_INTERRUPT_VIRQ7",
  "VME_INTERRUPT_DMA", "VME_INTERRUPT_LERR",
  "VME_INTERRUPT_BERR", ((void *)0), "VME_INTERRUPT_SW_IACK",
  "VME_INTERRUPT_SW_INT", "VME_INTERRUPT_SYSFAIL",
  "VME_INTERRUPT_ACFAIL", "VME_INTERRUPT_MBOX0",
  "VME_INTERRUPT_MBOX1", "VME_INTERRUPT_MBOX2",
  "VME_INTERRUPT_MBOX3", "VME_INTERRUPT_LM0",
  "VME_INTERRUPT_LM1", "VME_INTERRUPT_LM2",
  "VME_INTERRUPT_LM3"
 };
 int ii;
 for (ii = 0; ii <= VME_INTERRUPT_LM3; ++ii)
  if (table[ii]) {
   if (0 == strcmp(str, table[ii])) {
    *level = ii;
    return 0;
   }
  }
 return -1;
}

canonical_original_code:
int strtolvl(char *str, int *level)
{
 char *table[] = {
  "VME_INTERRUPT_VOWN", "VME_INTERRUPT_VIRQ1",
  "VME_INTERRUPT_VIRQ2", "VME_INTERRUPT_VIRQ3",
  "VME_INTERRUPT_VIRQ4", "VME_INTERRUPT_VIRQ5",
  "VME_INTERRUPT_VIRQ6", "VME_INTERRUPT_VIRQ7",
  "VME_INTERRUPT_DMA", "VME_INTERRUPT_LERR",
  "VME_INTERRUPT_BERR", ((void *)0), "VME_INTERRUPT_SW_IACK",
  "VME_INTERRUPT_SW_INT", "VME_INTERRUPT_SYSFAIL",
  "VME_INTERRUPT_ACFAIL", "VME_INTERRUPT_MBOX0",
  "VME_INTERRUPT_MBOX1", "VME_INTERRUPT_MBOX2",
  "VME_INTERRUPT_MBOX3", "VME_INTERRUPT_LM0",
  "VME_INTERRUPT_LM1", "VME_INTERRUPT_LM2",
  "VME_INTERRUPT_LM3"
 };
 int ii;
 for (ii = 0; ii <= VME_INTERRUPT_LM3; ++ii)
  if (table[ii]) {
   if (0 == strcmp(str, table[ii])) {
    *level = ii;
    return 0;
   }
  }
 return -1;
}

variable_types:
level
int *


decompiled_code:
_DWORD *syck_alloc_map()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x28uLL);
*(_DWORD *)v0 = 0;
v1 = v0;
v0[4] = 0LL;
v0[3] = 8LL;
v0[1] = malloc(0x40uLL);
v1[2] = malloc(0x40uLL);
result = syck_alloc_node(0);
*((_QWORD *)result + 4) = v1;
return result;
}

canonical_decompiled_code:
_DWORD *func0()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x28uLL);
*(_DWORD *)v0 = 0;
v1 = v0;
v0[4] = 0LL;
v0[3] = 8LL;
v0[1] = malloc(0x40uLL);
v1[2] = malloc(0x40uLL);
result = syck_alloc_node(0);
*((_QWORD *)result + 4) = v1;
return result;
}

original_code:
SyckNode *
syck_alloc_map(void)
{
    SyckNode *n;
    struct SyckMap *m;
    m = (struct SyckMap*)malloc(sizeof(struct SyckMap));
    m->style = map_none;
    m->idx = 0;
    m->capa = 8;
    m->keys = (unsigned long*)malloc(sizeof(unsigned long)*(m->capa));
    m->values = (unsigned long*)malloc(sizeof(unsigned long)*(m->capa));
    n = syck_alloc_node( syck_map_kind );
    n->data.pairs = m;
    return n;
}

canonical_original_code:
struct _syck_node *syck_alloc_map()
{
    struct _syck_node *n;
    struct SyckMap *m;
    m = (struct SyckMap *)malloc(sizeof(struct SyckMap));
    m->style = map_none;
    m->idx = 0;
    m->capa = 8;
    m->keys = (unsigned long *)malloc(sizeof(unsigned long)*(m->capa));
    m->values = (unsigned long *)malloc(sizeof(unsigned long)*(m->capa));
    n = syck_alloc_node( syck_map_kind );
    n->data.pairs = m;
    return n;
}

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

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

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 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:
_DWORD *syck_alloc_seq()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x20uLL);
*(_DWORD *)v0 = 0;
v1 = v0;
v0[3] = 0LL;
v0[2] = 8LL;
v0[1] = malloc(0x40uLL);
result = syck_alloc_node(1);
*((_QWORD *)result + 4) = v1;
return result;
}

canonical_decompiled_code:
_DWORD *func1()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x20uLL);
*(_DWORD *)v0 = 0;
v1 = v0;
v0[3] = 0LL;
v0[2] = 8LL;
v0[1] = malloc(0x40uLL);
result = syck_alloc_node(1);
*((_QWORD *)result + 4) = v1;
return result;
}

original_code:
SyckNode *
syck_alloc_seq(void)
{
    SyckNode *n;
    struct SyckSeq *s;
    s = (struct SyckSeq*)malloc(sizeof(struct SyckSeq));
    s->style = seq_none;
    s->idx = 0;
    s->capa = 8;
    s->items = (unsigned long*)malloc(sizeof(unsigned long)*(s->capa));
    n = syck_alloc_node( syck_seq_kind );
    n->data.list = s;
    return n;
}

canonical_original_code:
struct _syck_node *syck_alloc_seq()
{
    struct _syck_node *n;
    struct SyckSeq *s;
    s = (struct SyckSeq *)malloc(sizeof(struct SyckSeq));
    s->style = seq_none;
    s->idx = 0;
    s->capa = 8;
    s->items = (unsigned long *)malloc(sizeof(unsigned long)*(s->capa));
    n = syck_alloc_node( syck_seq_kind );
    n->data.list = s;
    return n;
}

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


decompiled_code:
_DWORD *syck_alloc_str()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x18uLL);
v0[2] = 0LL;
v1 = v0;
v0[1] = 0LL;
*(_DWORD *)v0 = 0;
result = syck_alloc_node(2);
*((_QWORD *)result + 4) = v1;
return result;
}

canonical_decompiled_code:
_DWORD *func2()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx
_DWORD *result; // rax

v0 = malloc(0x18uLL);
v0[2] = 0LL;
v1 = v0;
v0[1] = 0LL;
*(_DWORD *)v0 = 0;
result = syck_alloc_node(2);
*((_QWORD *)result + 4) = v1;
return result;
}

original_code:
SyckNode *
syck_alloc_str(void)
{
    SyckNode *n;
    struct SyckStr *s;
    s = (struct SyckStr*)malloc(sizeof(struct SyckStr));
    s->len = 0;
    s->ptr = ((void *)0);
    s->style = scalar_none;
    n = syck_alloc_node( syck_str_kind );
    n->data.str = s;
    return n;
}

canonical_original_code:
struct _syck_node *syck_alloc_str()
{
    struct _syck_node *n;
    struct SyckStr *s;
    s = (struct SyckStr *)malloc(sizeof(struct SyckStr));
    s->len = 0;
    s->ptr = ((void *)0);
    s->style = scalar_none;
    n = syck_alloc_node( syck_str_kind );
    n->data.str = s;
    return n;
}

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

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 }


decompiled_code:
__int64 __fastcall syck_replace_str(__int64 a1, const char *a2, int a3)
{
size_t v4; // rax

v4 = strlen(a2);
return syck_replace_str2(a1, a2, v4, a3);
}

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

v4 = strlen(a2);
return func3(a1, a2, v4, a3);
}

original_code:
void
syck_replace_str( SyckNode *n, char *str, enum scalar_style style )
{
    syck_replace_str2( n, str, strlen( str ), style );
}

canonical_original_code:
void syck_replace_str(struct _syck_node *n, char *str, enum scalar_style style)
{
    syck_replace_str2( n, str, strlen( str ), style );
}

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

return_type: void


decompiled_code:
__int64 __fastcall syck_str_blow_away_commas(__int64 a1)
{
__int64 v2; // rdx
__int64 v3; // rax
unsigned __int8 *v4; // rdi
__int64 v5; // rbp
__int64 result; // rax
unsigned __int8 *v7; // rbx
__int64 v8; // rdx

v2 = *(_QWORD *)(a1 + 32);
v3 = *(_QWORD *)(v2 + 8);
v4 = (unsigned __int8 *)(v3 + 1);
v5 = v3 + *(_QWORD *)(v2 + 16);
for ( result = *(unsigned __int8 *)(v3 + 1); (_BYTE)result; ++v4 )
{
while ( 1 )
{
v7 = v4 + 1;
if ( (_BYTE)result == 44 )
break;
result = *v7;
++v4;
if ( !(_BYTE)result )
return result;
}
v8 = v5--;
--*(_QWORD *)(*(_QWORD *)(a1 + 32) + 16LL);
memmove(v4, v4 + 1, v8 - (_QWORD)v4);
result = *v7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v2; // rdx
__int64 v3; // rax
unsigned __int8 *v4; // rdi
__int64 v5; // rbp
__int64 result; // rax
unsigned __int8 *v7; // rbx
__int64 v8; // rdx

v2 = *(_QWORD *)(a1 + 32);
v3 = *(_QWORD *)(v2 + 8);
v4 = (unsigned __int8 *)(v3 + 1);
v5 = v3 + *(_QWORD *)(v2 + 16);
for ( result = *(unsigned __int8 *)(v3 + 1); (_BYTE)result; ++v4 )
{
while ( 1 )
{
v7 = v4 + 1;
if ( (_BYTE)result == 44 )
break;
result = *v7;
++v4;
if ( !(_BYTE)result )
return result;
}
v8 = v5--;
--*(_QWORD *)(*(_QWORD *)(a1 + 32) + 16LL);
memmove(v4, v4 + 1, v8 - (_QWORD)v4);
result = *v7;
}
return result;
}

original_code:
void
syck_str_blow_away_commas( SyckNode *n )
{
    char *go, *end;
    go = n->data.str->ptr;
    end = go + n->data.str->len;
    while ( *(++go) != '\0' )
    {
        if ( *go == ',' )
        {
            n->data.str->len -= 1;
            memmove( go, go + 1, end - go );
            end -= 1;
        }
    }
}

canonical_original_code:
void syck_str_blow_away_commas(struct _syck_node *n)
{
    char *go; char *end;
    go = n->data.str->ptr;
    end = go + n->data.str->len;
    while ( *(++go) != '\0' )
    {
        if ( *go == ',' )
        {
            n->data.str->len -= 1;
            memmove( go, go + 1, end - go );
            end -= 1;
        }
    }
}

variable_types:
go
char *

variable_types:
end
char *

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:
__int64 __fastcall syck_str_read(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL);
}

original_code:
char *
syck_str_read( SyckNode *n )
{
    ((void)0);
    return n->data.str->ptr;
}

canonical_original_code:
char *syck_str_read(struct _syck_node *n)
{
    ((void)0);
    return n->data.str->ptr;
}

return_type: char *


original_code:
void
syck_map_update( SyckNode *map1, SyckNode *map2 )
{
    struct SyckMap *m1, *m2;
    long new_idx, new_capa;
    ((void)0);
    ((void)0);
    m1 = map1->data.pairs;
    m2 = map2->data.pairs;
    if ( m2->idx < 1 ) return;
    new_idx = m1->idx;
    new_idx += m2->idx;
    new_capa = m1->capa;
    while ( new_idx > new_capa )
    {
        new_capa += 8;
    }
    if ( new_capa > m1->capa )
    {
        m1->capa = new_capa;
        (m1->keys)=(unsigned long*)realloc((char*)(m1->keys),sizeof(unsigned long)*(m1->capa));
        (m1->values)=(unsigned long*)realloc((char*)(m1->values),sizeof(unsigned long)*(m1->capa));
    }
    for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ )
    {
        m1->keys[m1->idx] = m2->keys[new_idx];
        m1->values[m1->idx] = m2->values[new_idx];
    }
}

canonical_original_code:
void syck_map_update(struct _syck_node *map1, struct _syck_node *map2)
{
    struct SyckMap *m1; struct SyckMap *m2;
    long new_idx; long new_capa;
    ((void)0);
    ((void)0);
    m1 = map1->data.pairs;
    m2 = map2->data.pairs;
    if ( m2->idx < 1 ) return;
    new_idx = m1->idx;
    new_idx += m2->idx;
    new_capa = m1->capa;
    while ( new_idx > new_capa )
    {
        new_capa += 8;
    }
    if ( new_capa > m1->capa )
    {
        m1->capa = new_capa;
        (m1->keys)=(unsigned long *)realloc((char *)(m1->keys),sizeof(unsigned long)*(m1->capa));
        (m1->values)=(unsigned long *)realloc((char *)(m1->values),sizeof(unsigned long)*(m1->capa));
    }
    for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ )
    {
        m1->keys[m1->idx] = m2->keys[new_idx];
        m1->values[m1->idx] = m2->values[new_idx];
    }
}

variable_types: struct SyckMap { enum map_style { map_none=0, map_inline=1 } style; unsigned long *keys; unsigned long *values; long capa; long idx; } *


decompiled_code:
__int64 __fastcall syck_map_count(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 32LL);
}

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

original_code:
long
syck_map_count( SyckNode *map )
{
    ((void)0);
    ((void)0);
    return map->data.pairs->idx;
}

canonical_original_code:
long syck_map_count(struct _syck_node *map)
{
    ((void)0);
    ((void)0);
    return map->data.pairs->idx;
}

return_type: long


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

v4 = *(_QWORD *)(a1 + 32);
if ( a2 )
result = *(_QWORD *)(v4 + 16);
else
result = *(_QWORD *)(v4 + 8);
*(_QWORD *)(result + 8 * a3) = a4;
return result;
}

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

v4 = *(_QWORD *)(a1 + 32);
if ( a2 )
result = *(_QWORD *)(v4 + 16);
else
result = *(_QWORD *)(v4 + 8);
*(_QWORD *)(result + 8 * a3) = a4;
return result;
}

original_code:
void
syck_map_assign( SyckNode *map, enum map_part p, long idx, unsigned long id )
{
    struct SyckMap *m;
    ((void)0);
    m = map->data.pairs;
    ((void)0);
    if ( p == map_key )
    {
        m->keys[idx] = id;
    }
    else
    {
        m->values[idx] = id;
    }
}

canonical_original_code:
void syck_map_assign(struct _syck_node *map, enum map_part p, long idx, unsigned long id)
{
    struct SyckMap *m;
    ((void)0);
    m = map->data.pairs;
    ((void)0);
    if ( p == map_key )
    {
        m->keys[idx] = id;
    }
    else
    {
        m->values[idx] = id;
    }
}

variable_types: enum map_part { map_key=0, map_value=1 }

variable_types: idx long

variable_types:
id
unsigned long


decompiled_code:
__int64 __fastcall syck_map_read(__int64 a1, int a2, __int64 a3)
{
__int64 v3; // rax
__int64 result; // rax

v3 = *(_QWORD *)(a1 + 32);
if ( a2 )
result = *(_QWORD *)(*(_QWORD *)(v3 + 16) + 8 * a3);
else
result = *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2, __int64 a3)
{
__int64 v3; // rax
__int64 result; // rax

v3 = *(_QWORD *)(a1 + 32);
if ( a2 )
result = *(_QWORD *)(*(_QWORD *)(v3 + 16) + 8 * a3);
else
result = *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * a3);
return result;
}

original_code:
unsigned long
syck_map_read( SyckNode *map, enum map_part p, long idx )
{
    struct SyckMap *m;
    ((void)0);
    m = map->data.pairs;
    ((void)0);
    if ( p == map_key )
    {
        return m->keys[idx];
    }
    else
    {
        return m->values[idx];
    }
}

canonical_original_code:
unsigned long syck_map_read(struct _syck_node *map, enum map_part p, long idx)
{
    struct SyckMap *m;
    ((void)0);
    m = map->data.pairs;
    ((void)0);
    if ( p == map_key )
    {
        return m->keys[idx];
    }
    else
    {
        return m->values[idx];
    }
}

return_type: unsigned long

user_defined_types: enum map_part { map_key=0, map_value=1 }


decompiled_code:
__int64 __fastcall syck_seq_count(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 32) + 24LL);
}

original_code:
long
syck_seq_count( SyckNode *seq )
{
    ((void)0);
    ((void)0);
    return seq->data.list->idx;
}

canonical_original_code:
long syck_seq_count(struct _syck_node *seq)
{
    ((void)0);
    ((void)0);
    return seq->data.list->idx;
}


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

result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL);
*(_QWORD *)(result + 8 * a2) = a3;
return result;
}

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

result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL);
*(_QWORD *)(result + 8 * a2) = a3;
return result;
}

original_code:
void
syck_seq_assign( SyckNode *seq, long idx, unsigned long id )
{
    struct SyckSeq *s;
    ((void)0);
    s = seq->data.list;
    ((void)0);
    s->items[idx] = id;
}

canonical_original_code:
void syck_seq_assign(struct _syck_node *seq, long idx, unsigned long id)
{
    struct SyckSeq *s;
    ((void)0);
    s = seq->data.list;
    ((void)0);
    s->items[idx] = id;
}

variable_types: struct SyckSeq { enum seq_style { seq_none=0, seq_inline=1 } style; unsigned long *items; long capa; long idx; } *


decompiled_code:
__int64 __fastcall syck_seq_read(__int64 a1, __int64 a2)
{
return *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL) + 8 * a2);
}

original_code:
unsigned long
syck_seq_read( SyckNode *seq, long idx )
{
    struct SyckSeq *s;
    ((void)0);
    s = seq->data.list;
    ((void)0);
    return s->items[idx];
}

canonical_original_code:
unsigned long syck_seq_read(struct _syck_node *seq, long idx)
{
    struct SyckSeq *s;
    ((void)0);
    s = seq->data.list;
    ((void)0);
    return s->items[idx];
}


original_code:
void
syck_free_members( SyckNode *n )
{
    if ( n == ((void *)0) ) return;
    switch ( n->kind )
    {
        case syck_str_kind:
            if ( n->data.str != ((void *)0) )
            {
                if (n->data.str->ptr) { free(n->data.str->ptr); n->data.str->ptr = ((void *)0); };
                n->data.str->ptr = ((void *)0);
                n->data.str->len = 0;
                if (n->data.str) { free(n->data.str); n->data.str = ((void *)0); };
                n->data.str = ((void *)0);
            }
        break;
        case syck_seq_kind:
            if ( n->data.list != ((void *)0) )
            {
                if (n->data.list->items) { free(n->data.list->items); n->data.list->items = ((void *)0); };
                if (n->data.list) { free(n->data.list); n->data.list = ((void *)0); };
                n->data.list = ((void *)0);
            }
        break;
        case syck_map_kind:
            if ( n->data.pairs != ((void *)0) )
            {
                if (n->data.pairs->keys) { free(n->data.pairs->keys); n->data.pairs->keys = ((void *)0); };
                if (n->data.pairs->values) { free(n->data.pairs->values); n->data.pairs->values = ((void *)0); };
                if (n->data.pairs) { free(n->data.pairs); n->data.pairs = ((void *)0); };
                n->data.pairs = ((void *)0);
            }
        break;
    }
}

canonical_original_code:
void syck_free_members(struct _syck_node *n)
{
    if ( n == ((void *)0) ) return;
    switch ( n->kind )
    {
        case syck_str_kind:
            if ( n->data.str != ((void *)0) )
            {
                if (n->data.str->ptr) { free(n->data.str->ptr); n->data.str->ptr = ((void *)0); };
                n->data.str->ptr = ((void *)0);
                n->data.str->len = 0;
                if (n->data.str) { free(n->data.str); n->data.str = ((void *)0); };
                n->data.str = ((void *)0);
            }
        break;
        case syck_seq_kind:
            if ( n->data.list != ((void *)0) )
            {
                if (n->data.list->items) { free(n->data.list->items); n->data.list->items = ((void *)0); };
                if (n->data.list) { free(n->data.list); n->data.list = ((void *)0); };
                n->data.list = ((void *)0);
            }
        break;
        case syck_map_kind:
            if ( n->data.pairs != ((void *)0) )
            {
                if (n->data.pairs->keys) { free(n->data.pairs->keys); n->data.pairs->keys = ((void *)0); };
                if (n->data.pairs->values) { free(n->data.pairs->values); n->data.pairs->values = ((void *)0); };
                if (n->data.pairs) { free(n->data.pairs); n->data.pairs = ((void *)0); };
                n->data.pairs = ((void *)0);
            }
        break;
    }
}


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

syck_free_members((__int64)ptr);
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 3);
if ( v3 )
free(v3);
free(ptr);
}

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

func16((__int64)ptr);
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 3);
if ( v3 )
free(v3);
free(ptr);
}

original_code:
void
syck_free_node( SyckNode *n )
{
    syck_free_members( n );
    if ( n->type_id != ((void *)0) )
    {
        if (n->type_id) { free(n->type_id); n->type_id = ((void *)0); };
        n->type_id = ((void *)0);
    }
    if ( n->anchor != ((void *)0) )
    {
        if (n->anchor) { free(n->anchor); n->anchor = ((void *)0); };
        n->anchor = ((void *)0);
    }
    if (n) { free(n); n = ((void *)0); };
}

canonical_original_code:
void syck_free_node(struct _syck_node *n)
{
    syck_free_members( n );
    if ( n->type_id != ((void *)0) )
    {
        if (n->type_id) { free(n->type_id); n->type_id = ((void *)0); };
        n->type_id = ((void *)0);
    }
    if ( n->anchor != ((void *)0) )
    {
        if (n->anchor) { free(n->anchor); n->anchor = ((void *)0); };
        n->anchor = ((void *)0);
    }
    if (n) { free(n); n = ((void *)0); };
}


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 rb_class_of(__int64 a1)
{
__int64 result; // rax

if ( (a1 & 3) != 0 )
{
if ( (a1 & 1) != 0 )
{
result = rb_cFixnum;
}
else if ( a1 == 2 )
{
result = rb_cTrueClass;
}
else
{
if ( (_BYTE)a1 != 14 )
return *(_QWORD *)(a1 + 8);
result = rb_cSymbol;
}
}
else
{
if ( (a1 & 0xFFFFFFFFFFFFFFFBLL) != 0 )
return *(_QWORD *)(a1 + 8);
if ( a1 == 4 )
{
result = rb_cNilClass;
}
else
{
if ( a1 )
return *(_QWORD *)(a1 + 8);
result = rb_cFalseClass;
}
}
return result;
}

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

if ( (a1 & 3) != 0 )
{
if ( (a1 & 1) != 0 )
{
result = rb_cFixnum;
}
else if ( a1 == 2 )
{
result = rb_cTrueClass;
}
else
{
if ( (_BYTE)a1 != 14 )
return *(_QWORD *)(a1 + 8);
result = rb_cSymbol;
}
}
else
{
if ( (a1 & 0xFFFFFFFFFFFFFFFBLL) != 0 )
return *(_QWORD *)(a1 + 8);
if ( a1 == 4 )
{
result = rb_cNilClass;
}
else
{
if ( a1 )
return *(_QWORD *)(a1 + 8);
result = rb_cFalseClass;
}
}
return result;
}

original_code:
static inline VALUE
rb_class_of(VALUE obj)
{
    if (((VALUE)(obj) & RUBY_IMMEDIATE_MASK)) {
 if ((((long)(obj))&RUBY_FIXNUM_FLAG)) return rb_cFixnum;
 if (obj == ((VALUE)RUBY_Qtrue)) return rb_cTrueClass;
 if ((((VALUE)(obj)&~(~(VALUE)0<<RUBY_SPECIAL_SHIFT))==RUBY_SYMBOL_FLAG)) return rb_cSymbol;
    }
    else if (!(((VALUE)(obj) & ~((VALUE)RUBY_Qnil)) != 0)) {
 if (obj == ((VALUE)RUBY_Qnil)) return rb_cNilClass;
 if (obj == ((VALUE)RUBY_Qfalse)) return rb_cFalseClass;
    }
    return ((struct RBasic*)(obj))->klass;
}

canonical_original_code:
static inline unsigned long rb_class_of(unsigned long obj)
{
    if (((VALUE)(obj) & RUBY_IMMEDIATE_MASK)) {
 if ((((long)(obj))&RUBY_FIXNUM_FLAG)) return rb_cFixnum;
 if (obj == ((unsigned long)RUBY_Qtrue)) return rb_cTrueClass;
 if ((((VALUE)(obj)&~(~(unsigned long)0<<RUBY_SPECIAL_SHIFT))==RUBY_SYMBOL_FLAG)) return rb_cSymbol;
    }
    else if (!(((VALUE)(obj) & ~((unsigned long)RUBY_Qnil)) != 0)) {
 if (obj == ((unsigned long)RUBY_Qnil)) return rb_cNilClass;
 if (obj == ((unsigned long)RUBY_Qfalse)) return rb_cFalseClass;
    }
    return ((struct RBasic *)(obj))->klass;
}

variable_types:
obj
unsigned long

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


decompiled_code:
__int64 mSyslog_isopen()
{
return 2LL * (syslog_opened != 0);
}

canonical_decompiled_code:
__int64 func2()
{
return 2LL * (syslog_opened != 0);
}

original_code:
static VALUE mSyslog_isopen(VALUE self)
{
    return syslog_opened ? ((VALUE)RUBY_Qtrue) : ((VALUE)RUBY_Qfalse);
}

canonical_original_code:
static unsigned long mSyslog_isopen(unsigned long self)
{
    return syslog_opened ? ((unsigned long)RUBY_Qtrue) : ((unsigned long)RUBY_Qfalse);
}

variable_types:
self
unsigned long


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

if ( syslog_opened )
result = INT2NUM(syslog_options);
else
result = 4LL;
return result;
}

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

if ( syslog_opened )
result = func0(syslog_options);
else
result = 4LL;
return result;
}

original_code:
static VALUE mSyslog_options(VALUE self)
{
    return syslog_opened ? INT2NUM(syslog_options) : ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long mSyslog_options(unsigned long self)
{
    return syslog_opened ? INT2NUM(syslog_options) : ((unsigned long)RUBY_Qnil);
}


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

if ( syslog_opened )
result = INT2NUM(syslog_facility);
else
result = 4LL;
return result;
}

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

if ( syslog_opened )
result = func0(syslog_facility);
else
result = 4LL;
return result;
}

original_code:
static VALUE mSyslog_facility(VALUE self)
{
    return syslog_opened ? INT2NUM(syslog_facility) : ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long mSyslog_facility(unsigned long self)
{
    return syslog_opened ? INT2NUM(syslog_facility) : ((unsigned long)RUBY_Qnil);
}


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

if ( syslog_opened )
result = INT2NUM(syslog_mask);
else
result = 4LL;
return result;
}

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

if ( syslog_opened )
result = func0(syslog_mask);
else
result = 4LL;
return result;
}

original_code:
static VALUE mSyslog_get_mask(VALUE self)
{
    return syslog_opened ? INT2NUM(syslog_mask) : ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long mSyslog_get_mask(unsigned long self)
{
    return syslog_opened ? INT2NUM(syslog_mask) : ((unsigned long)RUBY_Qnil);
}


decompiled_code:
__int64 __fastcall mSyslog_instance(__int64 a1)
{
return a1;
}

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

original_code:
static VALUE mSyslog_instance(VALUE self)
{
    return self;
}

canonical_original_code:
static unsigned long mSyslog_instance(unsigned long self)
{
    return self;
}


decompiled_code:
void __fastcall syslog_write(int pri, int a2, __int64 a3)
{
_QWORD *v4; // rax
const char *v5; // rdx

rb_secure(4LL);
if ( a2 <= 0 )
goto LABEL_7;
if ( !syslog_opened )
{
rb_raise(rb_eRuntimeError, "must open syslog before write");
LABEL_7:
rb_raise(rb_eArgError, "no log message supplied");
mSyslog_debug();
return;
}
v4 = (_QWORD *)rb_f_sprintf((unsigned int)a2, a3);
v5 = (const char *)(v4 + 2);
if ( (*v4 & 0x2000LL) != 0 )
v5 = (const char *)v4[3];
syslog(pri, "%s", v5);
}

canonical_decompiled_code:
void __fastcall func7(int pri, int a2, __int64 a3)
{
_QWORD *v4; // rax
const char *v5; // rdx

rb_secure(4LL);
if ( a2 <= 0 )
goto LABEL_7;
if ( !syslog_opened )
{
rb_raise(rb_eRuntimeError, "must open syslog before write");
LABEL_7:
rb_raise(rb_eArgError, "no log message supplied");
func8();
return;
}
v4 = (_QWORD *)rb_f_sprintf((unsigned int)a2, a3);
v5 = (const char *)(v4 + 2);
if ( (*v4 & 0x2000LL) != 0 )
v5 = (const char *)v4[3];
syslog(pri, "%s", v5);
}

original_code:
static void syslog_write(int pri, int argc, VALUE *argv)
{
    VALUE str;
    rb_secure(4);
    if (argc < 1) {
        rb_raise(rb_eArgError, "no log message supplied");
    }
    if (!syslog_opened) {
        rb_raise(rb_eRuntimeError, "must open syslog before write");
    }
    str = rb_f_sprintf(argc, argv);
    syslog(pri, "%s", (!(((struct RBasic*)(str))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(str))->as.ary : ((struct RString*)(str))->as.heap.ptr));
}

canonical_original_code:
static void syslog_write(int pri, int argc, unsigned long *argv)
{
    unsigned long str;
    rb_secure(4);
    if (argc < 1) {
        rb_raise(rb_eArgError, "no log message supplied");
    }
    if (!syslog_opened) {
        rb_raise(rb_eRuntimeError, "must open syslog before write");
    }
    str = rb_f_sprintf(argc, argv);
    syslog(pri, "%s", (!(((struct RBasic *)(str))->flags & (((unsigned long)1)<<(12 +1))) ? ((struct RString *)(str))->as.ary : ((struct RString *)(str))->as.heap.ptr));
}

variable_types: pri int

variable_types: argc int

variable_types:
argv
unsigned long *

variable_types:
str
unsigned long

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 mSyslog_debug(int a1, __int64 a2, __int64 a3)
{
syslog_write(7, a1, a2);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, __int64 a2, __int64 a3)
{
func7(7, a1, a2);
return a3;
}

original_code: static VALUE mSyslog_debug(int argc, VALUE *argv, VALUE self) { syslog_write(7, argc, argv); return self; }

canonical_original_code: static unsigned long mSyslog_debug(int argc, unsigned long *argv, unsigned long self) { syslog_write(7, argc, argv); return self; }


decompiled_code:
__int64 __fastcall mSyslog_info(int a1, __int64 a2, __int64 a3)
{
syslog_write(6, a1, a2);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, __int64 a2, __int64 a3)
{
func7(6, a1, a2);
return a3;
}

original_code: static VALUE mSyslog_info(int argc, VALUE *argv, VALUE self) { syslog_write(6, argc, argv); return self; }

canonical_original_code: static unsigned long mSyslog_info(int argc, unsigned long *argv, unsigned long self) { syslog_write(6, argc, argv); return self; }


decompiled_code:
__int64 __fastcall mSyslog_notice(int a1, __int64 a2, __int64 a3)
{
syslog_write(5, a1, a2);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, __int64 a2, __int64 a3)
{
func7(5, a1, a2);
return a3;
}

original_code: static VALUE mSyslog_notice(int argc, VALUE *argv, VALUE self) { syslog_write(5, argc, argv); return self; }

canonical_original_code: static unsigned long mSyslog_notice(int argc, unsigned long *argv, unsigned long self) { syslog_write(5, argc, argv); return self; }


decompiled_code:
__int64 __fastcall mSyslog_warning(int a1, __int64 a2, __int64 a3)
{
syslog_write(4, a1, a2);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, __int64 a2, __int64 a3)
{
func7(4, a1, a2);
return a3;
}

original_code: static VALUE mSyslog_warning(int argc, VALUE *argv, VALUE self) { syslog_write(4, argc, argv); return self; }

canonical_original_code: static unsigned long mSyslog_warning(int argc, unsigned long *argv, unsigned long self) { syslog_write(4, argc, argv); return self; }


decompiled_code:
__int64 __fastcall mSyslog_err(int a1, __int64 a2, __int64 a3)
{
syslog_write(3, a1, a2);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, __int64 a2, __int64 a3)
{
func7(3, a1, a2);
return a3;
}

original_code: static VALUE mSyslog_err(int argc, VALUE *argv, VALUE self) { syslog_write(3, argc, argv); return self; }

canonical_original_code: static unsigned long mSyslog_err(int argc, unsigned long *argv, unsigned long self) { syslog_write(3, argc, argv); return self; }


decompiled_code:
__int64 __fastcall mSyslog_crit(int a1, __int64 a2, __int64 a3)
{
syslog_write(2, a1, a2);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, __int64 a2, __int64 a3)
{
func7(2, a1, a2);
return a3;
}

original_code: static VALUE mSyslog_crit(int argc, VALUE *argv, VALUE self) { syslog_write(2, argc, argv); return self; }

canonical_original_code: static unsigned long mSyslog_crit(int argc, unsigned long *argv, unsigned long self) { syslog_write(2, argc, argv); return self; }


decompiled_code:
__int64 __fastcall mSyslog_alert(int a1, __int64 a2, __int64 a3)
{
syslog_write(1, a1, a2);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1, __int64 a2, __int64 a3)
{
func7(1, a1, a2);
return a3;
}

original_code: static VALUE mSyslog_alert(int argc, VALUE *argv, VALUE self) { syslog_write(1, argc, argv); return self; }

canonical_original_code: static unsigned long mSyslog_alert(int argc, unsigned long *argv, unsigned long self) { syslog_write(1, argc, argv); return self; }


decompiled_code:
__int64 __fastcall mSyslog_emerg(int a1, __int64 a2, __int64 a3)
{
syslog_write(0, a1, a2);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func15(int a1, __int64 a2, __int64 a3)
{
func7(0, a1, a2);
return a3;
}

original_code: static VALUE mSyslog_emerg(int argc, VALUE *argv, VALUE self) { syslog_write(0, argc, argv); return self; }

canonical_original_code: static unsigned long mSyslog_emerg(int argc, unsigned long *argv, unsigned long self) { syslog_write(0, argc, argv); return self; }


decompiled_code:
__int64 __fastcall mSyslog_log(int a1, __int64 *a2, __int64 a3)
{
unsigned __int64 v4; // rsi
__int64 v6; // rdi
__int64 v8; // rdx
__int64 v9; // rax
const char *v10; // rax

if ( a1 <= 1 )
{
v8 = (unsigned int)a1;
v4 = (unsigned __int64)"wrong number of arguments (%d for 2+)";
v6 = rb_eArgError;
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", v8);
}
else
{
v4 = (unsigned int)(a1 - 1);
v6 = *a2;
if ( (*a2 & 1) != 0 )
{
syslog_write(v6 >> 1, v4, (__int64)(a2 + 1));
return a3;
}
}
v9 = rb_class_of(v6);
v10 = (const char *)rb_class2name(v9, v4);
rb_raise(rb_eTypeError, "type mismatch: %s given", v10);
return mSyslog_inspect();
}

canonical_decompiled_code:
__int64 __fastcall func16(int a1, __int64 *a2, __int64 a3)
{
unsigned __int64 v4; // rsi
__int64 v6; // rdi
__int64 v8; // rdx
__int64 v9; // rax
const char *v10; // rax

if ( a1 <= 1 )
{
v8 = (unsigned int)a1;
v4 = (unsigned __int64)"wrong number of arguments (%d for 2+)";
v6 = rb_eArgError;
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", v8);
}
else
{
v4 = (unsigned int)(a1 - 1);
v6 = *a2;
if ( (*a2 & 1) != 0 )
{
func7(v6 >> 1, v4, (__int64)(a2 + 1));
return a3;
}
}
v9 = func1(v6);
v10 = (const char *)rb_class2name(v9, v4);
rb_raise(rb_eTypeError, "type mismatch: %s given", v10);
return func17();
}

original_code:
static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
{
    VALUE pri;
    if (argc < 2) {
        rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
    }
    argc--;
    pri = *argv++;
    if (!(((long)(pri))&RUBY_FIXNUM_FLAG)) {
      rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(rb_class_of((VALUE)(pri))));
    }
    syslog_write(((int)(((long)pri)>>(int)1)), argc, argv);
    return self;
}

canonical_original_code:
static unsigned long mSyslog_log(int argc, unsigned long *argv, unsigned long self)
{
    unsigned long pri;
    if (argc < 2) {
        rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
    }
    argc--;
    pri = *argv++;
    if (!(((long)(pri))&RUBY_FIXNUM_FLAG)) {
      rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(rb_class_of((VALUE)(pri))));
    }
    syslog_write(((int)(((long)pri)>>(int)1)), argc, argv);
    return self;
}

variable_types:
pri
unsigned long


decompiled_code:
__int64 __fastcall mSyslog_inspect(__int64 a1, __int64 a2)
{
__int64 v2; // r14
__int64 v3; // r13
unsigned int v4; // er12
const char *v5; // rbx
const char *v6; // rax
const char *v8; // rax
char v9[1064]; // [rsp+0h] [rbp-428h] BYREF

if ( syslog_opened )
{
v2 = (unsigned int)syslog_mask;
v3 = (unsigned int)syslog_facility;
v4 = syslog_options;
v5 = syslog_ident;
v6 = (const char *)rb_class2name(a1, a2);
snprintf(v9, 0x400uLL, "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>", v6, v5, v4, v3, v2);
}
else
{
v8 = (const char *)rb_class2name(a1, a2);
snprintf(v9, 0x400uLL, "<#%s: opened=false>", v8);
}
return rb_str_new_cstr(v9);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2)
{
__int64 v2; // r14
__int64 v3; // r13
unsigned int v4; // er12
const char *v5; // rbx
const char *v6; // rax
const char *v8; // rax
char v9[1064]; // [rsp+0h] [rbp-428h] BYREF

if ( syslog_opened )
{
v2 = (unsigned int)syslog_mask;
v3 = (unsigned int)syslog_facility;
v4 = syslog_options;
v5 = syslog_ident;
v6 = (const char *)rb_class2name(a1, a2);
snprintf(v9, 0x400uLL, "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>", v6, v5, v4, v3, v2);
}
else
{
v8 = (const char *)rb_class2name(a1, a2);
snprintf(v9, 0x400uLL, "<#%s: opened=false>", v8);
}
return rb_str_new_cstr(v9);
}

original_code:
static VALUE mSyslog_inspect(VALUE self)
{
    char buf[1024];
    if (syslog_opened) {
 snprintf(buf, sizeof(buf),
   "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
   rb_class2name(self),
   syslog_ident,
   syslog_options,
   syslog_facility,
   syslog_mask);
    } else {
 snprintf(buf, sizeof(buf),
   "<#%s: opened=false>", rb_class2name(self));
    }
    return __extension__ ( { (__builtin_constant_p(buf)) ? rb_str_new(buf, strlen(buf)) : rb_str_new_cstr(buf); });
}

canonical_original_code:
static unsigned long mSyslog_inspect(unsigned long self)
{
    char buf[1024];
    if (syslog_opened) {
 snprintf(buf, sizeof(buf),
   "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
   rb_class2name(self),
   syslog_ident,
   syslog_options,
   syslog_facility,
   syslog_mask);
    } else {
 snprintf(buf, sizeof(buf),
   "<#%s: opened=false>", rb_class2name(self));
    }
    return __extension__ ( { (__builtin_constant_p(buf)) ? rb_str_new(buf, strlen(buf)) : rb_str_new_cstr(buf); });
}

variable_types:
buf
char [1024]


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

if ( syslog_opened )
result = rb_str_new_cstr(syslog_ident);
else
result = 4LL;
return result;
}

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

if ( syslog_opened )
result = rb_str_new_cstr(syslog_ident);
else
result = 4LL;
return result;
}

original_code:
static VALUE mSyslog_ident(VALUE self)
{
    return syslog_opened ? __extension__ ( { (__builtin_constant_p(syslog_ident)) ? rb_str_new(syslog_ident, strlen(syslog_ident)) : rb_str_new_cstr(syslog_ident); }) : ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long mSyslog_ident(unsigned long self)
{
    return syslog_opened ? __extension__ ( { (__builtin_constant_p(syslog_ident)) ? rb_str_new(syslog_ident, strlen(syslog_ident)) : rb_str_new_cstr(syslog_ident); }) : ((unsigned long)RUBY_Qnil);
}


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

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

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

if ( (a1 & 1) != 0 )
result = a1 >> 1;
else
result = rb_num2long();
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


decompiled_code:
__int64 __fastcall mSyslogConstants_LOG_UPTO(__int64 a1, __int64 a2)
{
return 2LL * ((1 << (NUM2LONG(a2) + 1)) - 1) + 1;
}

original_code:
static VALUE mSyslogConstants_LOG_UPTO(VALUE klass, VALUE pri)
{
    return ((VALUE)(((long)(((1 << ((((int)NUM2LONG(pri)))+1)) - 1)))<<1 | RUBY_FIXNUM_FLAG));
}

canonical_original_code:
static unsigned long mSyslogConstants_LOG_UPTO(unsigned long klass, unsigned long pri)
{
    return ((VALUE)(((long)(((1 << ((((int)NUM2LONG(pri)))+1)) - 1)))<<1 | RUBY_FIXNUM_FLAG));
}

variable_types:
klass
unsigned long


decompiled_code:
__int64 __fastcall mSyslogConstants_LOG_MASK(__int64 a1, __int64 a2)
{
return 2LL * (1 << NUM2LONG(a2)) + 1;
}

original_code:
static VALUE mSyslogConstants_LOG_MASK(VALUE klass, VALUE pri)
{
    return ((VALUE)(((long)((1 << (((int)NUM2LONG(pri))))))<<1 | RUBY_FIXNUM_FLAG));
}

canonical_original_code:
static unsigned long mSyslogConstants_LOG_MASK(unsigned long klass, unsigned long pri)
{
    return ((VALUE)(((long)((1 << (((int)NUM2LONG(pri))))))<<1 | RUBY_FIXNUM_FLAG));
}


decompiled_code:
__int64 __fastcall mSyslog_set_mask(__int64 a1, __int64 a2)
{
__int64 result; // rax

rb_secure(4LL);
if ( syslog_opened )
{
syslog_mask = NUM2LONG(a2);
setlogmask(syslog_mask);
result = a2;
}
else
{
rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
result = mSyslog_close();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, __int64 a2)
{
__int64 result; // rax

rb_secure(4LL);
if ( syslog_opened )
{
syslog_mask = func19(a2);
setlogmask(syslog_mask);
result = a2;
}
else
{
rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
result = func23();
}
return result;
}

original_code:
static VALUE mSyslog_set_mask(VALUE self, VALUE mask)
{
    rb_secure(4);
    if (!syslog_opened) {
        rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
    }
    setlogmask(syslog_mask = ((int)NUM2LONG(mask)));
    return mask;
}

canonical_original_code:
static unsigned long mSyslog_set_mask(unsigned long self, unsigned long mask)
{
    rb_secure(4);
    if (!syslog_opened) {
        rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
    }
    setlogmask(syslog_mask = ((int)NUM2LONG(mask)));
    return mask;
}

variable_types:
mask
unsigned long


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

rb_secure(4LL);
if ( syslog_opened )
{
closelog();
free(syslog_ident);
result = 4LL;
syslog_ident = 0LL;
syslog_mask = -1;
syslog_facility = -1;
syslog_options = -1;
syslog_opened = 0;
}
else
{
rb_raise(rb_eRuntimeError, "syslog not opened");
result = mSyslog_open();
}
return result;
}

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

rb_secure(4LL);
if ( syslog_opened )
{
closelog();
free(syslog_ident);
result = 4LL;
syslog_ident = 0LL;
syslog_mask = -1;
syslog_facility = -1;
syslog_options = -1;
syslog_opened = 0;
}
else
{
rb_raise(rb_eRuntimeError, "syslog not opened");
result = func24();
}
return result;
}

original_code:
static VALUE mSyslog_close(VALUE self)
{
    rb_secure(4);
    if (!syslog_opened) {
        rb_raise(rb_eRuntimeError, "syslog not opened");
    }
    closelog();
    free((void *)syslog_ident);
    syslog_ident = ((void *)0);
    syslog_options = syslog_facility = syslog_mask = -1;
    syslog_opened = 0;
    return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long mSyslog_close(unsigned long self)
{
    rb_secure(4);
    if (!syslog_opened) {
        rb_raise(rb_eRuntimeError, "syslog not opened");
    }
    closelog();
    free((void *)syslog_ident);
    syslog_ident = ((void *)0);
    syslog_options = syslog_facility = syslog_mask = -1;
    syslog_opened = 0;
    return ((unsigned long)RUBY_Qnil);
}


decompiled_code:
__int64 __fastcall mSyslog_open(__int64 a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rdi
int v5; // edx
__int64 result; // rax
_QWORD *v7; // [rsp+8h] [rbp-30h] BYREF
__int64 v8; // [rsp+10h] [rbp-28h] BYREF
__int64 v9[4]; // [rsp+18h] [rbp-20h] BYREF

if ( syslog_opened )
{
rb_raise(rb_eRuntimeError, "syslog already open");
result = mSyslog_reopen();
}
else
{
rb_scan_args(a1, a2, "03", &v7, &v8, v9);
if ( v7 == (_QWORD *)((char *)&loc_3 + 1) )
v7 = (_QWORD *)rb_gv_get("$0");
rb_string_value(&v7);
rb_check_safe_obj(v7);
if ( (*v7 & 0x2000LL) != 0 )
v4 = (_QWORD *)v7[3];
else
v4 = v7 + 2;
syslog_ident = (char *)ruby_strdup(v4);
if ( v8 == 4 )
syslog_options = 3;
else
syslog_options = NUM2LONG(v8);
if ( v9[0] == 4 )
{
syslog_facility = 8;
v5 = 8;
}
else
{
syslog_facility = NUM2LONG(v9[0]);
v5 = syslog_facility;
}
openlog(syslog_ident, syslog_options, v5);
syslog_opened = 1;
syslog_mask = setlogmask(0);
setlogmask(syslog_mask);
if ( (unsigned int)rb_block_given_p() )
rb_ensure(&rb_yield, a3, mSyslog_close, a3);
result = a3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rdi
int v5; // edx
__int64 result; // rax
_QWORD *v7; // [rsp+8h] [rbp-30h] BYREF
__int64 v8; // [rsp+10h] [rbp-28h] BYREF
__int64 v9[4]; // [rsp+18h] [rbp-20h] BYREF

if ( syslog_opened )
{
rb_raise(rb_eRuntimeError, "syslog already open");
result = func25();
}
else
{
rb_scan_args(a1, a2, "03", &v7, &v8, v9);
if ( v7 == (_QWORD *)((char *)&loc_3 + 1) )
v7 = (_QWORD *)rb_gv_get("$0");
rb_string_value(&v7);
rb_check_safe_obj(v7);
if ( (*v7 & 0x2000LL) != 0 )
v4 = (_QWORD *)v7[3];
else
v4 = v7 + 2;
syslog_ident = (char *)ruby_strdup(v4);
if ( v8 == 4 )
syslog_options = 3;
else
syslog_options = func19(v8);
if ( v9[0] == 4 )
{
syslog_facility = 8;
v5 = 8;
}
else
{
syslog_facility = func19(v9[0]);
v5 = syslog_facility;
}
openlog(syslog_ident, syslog_options, v5);
syslog_opened = 1;
syslog_mask = setlogmask(0);
setlogmask(syslog_mask);
if ( (unsigned int)rb_block_given_p() )
rb_ensure(&rb_yield, a3, mSyslog_close, a3);
result = a3;
}
return result;
}

original_code:
static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
{
    VALUE ident, opt, fac;
    if (syslog_opened) {
        rb_raise(rb_eRuntimeError, "syslog already open");
    }
    rb_scan_args(argc, argv, "03", &ident, &opt, &fac);
    if (((VALUE)(ident) == ((VALUE)RUBY_Qnil))) {
        ident = rb_gv_get("$0");
    }
    do { rb_string_value(&(ident)); rb_check_safe_obj(ident);} while (0);
    syslog_ident = ruby_strdup((!(((struct RBasic*)(ident))->flags & (((VALUE)1)<<(12 +1))) ? ((struct RString*)(ident))->as.ary : ((struct RString*)(ident))->as.heap.ptr));
    if (((VALUE)(opt) == ((VALUE)RUBY_Qnil))) {
 syslog_options = 0x01 | 0x02;
    } else {
 syslog_options = ((int)NUM2LONG(opt));
    }
    if (((VALUE)(fac) == ((VALUE)RUBY_Qnil))) {
 syslog_facility = (1<<3);
    } else {
 syslog_facility = ((int)NUM2LONG(fac));
    }
    openlog(syslog_ident, syslog_options, syslog_facility);
    syslog_opened = 1;
    setlogmask(syslog_mask = setlogmask(0));
    if (rb_block_given_p()) {
        rb_ensure(rb_yield, self, mSyslog_close, self);
    }
    return self;
}

canonical_original_code:
static unsigned long mSyslog_open(int argc, unsigned long *argv, unsigned long self)
{
    unsigned long ident; unsigned long opt; unsigned long fac;
    if (syslog_opened) {
        rb_raise(rb_eRuntimeError, "syslog already open");
    }
    rb_scan_args(argc, argv, "03", &ident, &opt, &fac);
    if (((VALUE)(ident) == ((unsigned long)RUBY_Qnil))) {
        ident = rb_gv_get("$0");
    }
    do { rb_string_value(&(ident)); rb_check_safe_obj(ident);} while (0);
    syslog_ident = ruby_strdup((!(((struct RBasic *)(ident))->flags & (((unsigned long)1)<<(12 +1))) ? ((struct RString *)(ident))->as.ary : ((struct RString *)(ident))->as.heap.ptr));
    if (((VALUE)(opt) == ((unsigned long)RUBY_Qnil))) {
 syslog_options = 0x01 | 0x02;
    } else {
 syslog_options = ((int)NUM2LONG(opt));
    }
    if (((VALUE)(fac) == ((unsigned long)RUBY_Qnil))) {
 syslog_facility = (1<<3);
    } else {
 syslog_facility = ((int)NUM2LONG(fac));
    }
    openlog(syslog_ident, syslog_options, syslog_facility);
    syslog_opened = 1;
    setlogmask(syslog_mask = setlogmask(0));
    if (rb_block_given_p()) {
        rb_ensure(rb_yield, self, mSyslog_close, self);
    }
    return self;
}

variable_types:
ident
unsigned long

variable_types:
opt
unsigned long

variable_types:
fac
unsigned long


decompiled_code:
__int64 __fastcall mSyslog_reopen(unsigned int a1, __int64 a2, __int64 a3)
{
mSyslog_close();
return mSyslog_open(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func25(unsigned int a1, __int64 a2, __int64 a3)
{
func23();
return func24(a1, a2, a3);
}

original_code:
static VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self)
{
    mSyslog_close(self);
    return mSyslog_open(argc, argv, self);
}

canonical_original_code:
static unsigned long mSyslog_reopen(int argc, unsigned long *argv, unsigned long self)
{
    mSyslog_close(self);
    return mSyslog_open(argc, argv, self);
}


decompiled_code:
__int64 Init_syslog()
{
__int64 v0; // r14
__int64 v1; // r13
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // rbp
__int64 v5; // r15
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // r15
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rax

mSyslog = rb_define_module("Syslog");
mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
rb_include_module(mSyslog, mSyslogConstants);
rb_define_module_function(mSyslog, "open", mSyslog_open, 0xFFFFFFFFLL);
rb_define_module_function(mSyslog, "reopen", mSyslog_reopen, 0xFFFFFFFFLL);
rb_define_module_function(mSyslog, "open!", mSyslog_reopen, 0xFFFFFFFFLL);
rb_define_module_function(mSyslog, "opened?", mSyslog_isopen, 0LL);
rb_define_module_function(mSyslog, "ident", mSyslog_ident, 0LL);
rb_define_module_function(mSyslog, "options", mSyslog_options, 0LL);
rb_define_module_function(mSyslog, "facility", mSyslog_facility, 0LL);
rb_define_module_function(mSyslog, "log", mSyslog_log, 0xFFFFFFFFLL);
rb_define_module_function(mSyslog, "close", mSyslog_close, 0LL);
rb_define_module_function(mSyslog, "mask", mSyslog_get_mask, 0LL);
rb_define_module_function(mSyslog, "mask=", mSyslog_set_mask, 1LL);
rb_define_module_function(mSyslog, "LOG_MASK", mSyslogConstants_LOG_MASK, 1LL);
rb_define_module_function(mSyslog, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1LL);
rb_define_module_function(mSyslog, "inspect", mSyslog_inspect, 0LL);
rb_define_module_function(mSyslog, "instance", mSyslog_instance, 0LL);
rb_define_module_function(mSyslogConstants, "LOG_MASK", mSyslogConstants_LOG_MASK, 1LL);
rb_define_module_function(mSyslogConstants, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1LL);
v0 = INT2NUM(1);
rb_define_const(mSyslogConstants, "LOG_PID", v0);
v1 = INT2NUM(2);
rb_define_const(mSyslogConstants, "LOG_CONS", v1);
v2 = INT2NUM(4);
rb_define_const(mSyslogConstants, "LOG_ODELAY", v2);
v3 = INT2NUM(8);
rb_define_const(mSyslogConstants, "LOG_NDELAY", v3);
v4 = INT2NUM(16);
rb_define_const(mSyslogConstants, "LOG_NOWAIT", v4);
v5 = INT2NUM(32);
rb_define_const(mSyslogConstants, "LOG_PERROR", v5);
rb_define_const(mSyslogConstants, "LOG_AUTH", v5);
v6 = INT2NUM(80);
rb_define_const(mSyslogConstants, "LOG_AUTHPRIV", v6);
v7 = INT2NUM(72);
rb_define_const(mSyslogConstants, "LOG_CRON", v7);
v8 = INT2NUM(24);
rb_define_const(mSyslogConstants, "LOG_DAEMON", v8);
v9 = INT2NUM(88);
rb_define_const(mSyslogConstants, "LOG_FTP", v9);
v10 = INT2NUM(0);
rb_define_const(mSyslogConstants, "LOG_KERN", v10);
v11 = INT2NUM(48);
rb_define_const(mSyslogConstants, "LOG_LPR", v11);
rb_define_const(mSyslogConstants, "LOG_MAIL", v4);
v12 = INT2NUM(56);
rb_define_const(mSyslogConstants, "LOG_NEWS", v12);
v13 = INT2NUM(40);
rb_define_const(mSyslogConstants, "LOG_SYSLOG", v13);
rb_define_const(mSyslogConstants, "LOG_USER", v3);
v14 = INT2NUM(64);
rb_define_const(mSyslogConstants, "LOG_UUCP", v14);
v15 = INT2NUM(128);
rb_define_const(mSyslogConstants, "LOG_LOCAL0", v15);
v16 = INT2NUM(136);
rb_define_const(mSyslogConstants, "LOG_LOCAL1", v16);
v17 = INT2NUM(144);
rb_define_const(mSyslogConstants, "LOG_LOCAL2", v17);
v18 = INT2NUM(152);
rb_define_const(mSyslogConstants, "LOG_LOCAL3", v18);
v19 = INT2NUM(160);
rb_define_const(mSyslogConstants, "LOG_LOCAL4", v19);
v20 = INT2NUM(168);
rb_define_const(mSyslogConstants, "LOG_LOCAL5", v20);
v21 = INT2NUM(176);
rb_define_const(mSyslogConstants, "LOG_LOCAL6", v21);
v22 = INT2NUM(184);
rb_define_const(mSyslogConstants, "LOG_LOCAL7", v22);
rb_define_const(mSyslogConstants, "LOG_EMERG", v10);
rb_define_module_function(mSyslog, "emerg", mSyslog_emerg, 0xFFFFFFFFLL);
rb_define_const(mSyslogConstants, "LOG_ALERT", v0);
rb_define_module_function(mSyslog, "alert", mSyslog_alert, 0xFFFFFFFFLL);
rb_define_const(mSyslogConstants, "LOG_CRIT", v1);
rb_define_module_function(mSyslog, "crit", mSyslog_crit, 0xFFFFFFFFLL);
v23 = INT2NUM(3);
rb_define_const(mSyslogConstants, "LOG_ERR", v23);
rb_define_module_function(mSyslog, "err", mSyslog_err, 0xFFFFFFFFLL);
rb_define_const(mSyslogConstants, "LOG_WARNING", v2);
rb_define_module_function(mSyslog, "warning", mSyslog_warning, 0xFFFFFFFFLL);
v24 = INT2NUM(5);
rb_define_const(mSyslogConstants, "LOG_NOTICE", v24);
rb_define_module_function(mSyslog, "notice", mSyslog_notice, 0xFFFFFFFFLL);
v25 = INT2NUM(6);
rb_define_const(mSyslogConstants, "LOG_INFO", v25);
rb_define_module_function(mSyslog, "info", mSyslog_info, 0xFFFFFFFFLL);
v26 = INT2NUM(7);
rb_define_const(mSyslogConstants, "LOG_DEBUG", v26);
return rb_define_module_function(mSyslog, "debug", mSyslog_debug, 0xFFFFFFFFLL);
}

canonical_decompiled_code:
__int64 func26()
{
__int64 v0; // r14
__int64 v1; // r13
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // rbp
__int64 v5; // r15
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // r15
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rax

mSyslog = rb_define_module("Syslog");
mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
rb_include_module(mSyslog, mSyslogConstants);
rb_define_module_function(mSyslog, "open", mSyslog_open, 0xFFFFFFFFLL);
rb_define_module_function(mSyslog, "reopen", mSyslog_reopen, 0xFFFFFFFFLL);
rb_define_module_function(mSyslog, "open!", mSyslog_reopen, 0xFFFFFFFFLL);
rb_define_module_function(mSyslog, "opened?", mSyslog_isopen, 0LL);
rb_define_module_function(mSyslog, "ident", mSyslog_ident, 0LL);
rb_define_module_function(mSyslog, "options", mSyslog_options, 0LL);
rb_define_module_function(mSyslog, "facility", mSyslog_facility, 0LL);
rb_define_module_function(mSyslog, "log", mSyslog_log, 0xFFFFFFFFLL);
rb_define_module_function(mSyslog, "close", mSyslog_close, 0LL);
rb_define_module_function(mSyslog, "mask", mSyslog_get_mask, 0LL);
rb_define_module_function(mSyslog, "mask=", mSyslog_set_mask, 1LL);
rb_define_module_function(mSyslog, "LOG_MASK", mSyslogConstants_LOG_MASK, 1LL);
rb_define_module_function(mSyslog, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1LL);
rb_define_module_function(mSyslog, "inspect", mSyslog_inspect, 0LL);
rb_define_module_function(mSyslog, "instance", mSyslog_instance, 0LL);
rb_define_module_function(mSyslogConstants, "LOG_MASK", mSyslogConstants_LOG_MASK, 1LL);
rb_define_module_function(mSyslogConstants, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1LL);
v0 = func0(1);
rb_define_const(mSyslogConstants, "LOG_PID", v0);
v1 = func0(2);
rb_define_const(mSyslogConstants, "LOG_CONS", v1);
v2 = func0(4);
rb_define_const(mSyslogConstants, "LOG_ODELAY", v2);
v3 = func0(8);
rb_define_const(mSyslogConstants, "LOG_NDELAY", v3);
v4 = func0(16);
rb_define_const(mSyslogConstants, "LOG_NOWAIT", v4);
v5 = func0(32);
rb_define_const(mSyslogConstants, "LOG_PERROR", v5);
rb_define_const(mSyslogConstants, "LOG_AUTH", v5);
v6 = func0(80);
rb_define_const(mSyslogConstants, "LOG_AUTHPRIV", v6);
v7 = func0(72);
rb_define_const(mSyslogConstants, "LOG_CRON", v7);
v8 = func0(24);
rb_define_const(mSyslogConstants, "LOG_DAEMON", v8);
v9 = func0(88);
rb_define_const(mSyslogConstants, "LOG_FTP", v9);
v10 = func0(0);
rb_define_const(mSyslogConstants, "LOG_KERN", v10);
v11 = func0(48);
rb_define_const(mSyslogConstants, "LOG_LPR", v11);
rb_define_const(mSyslogConstants, "LOG_MAIL", v4);
v12 = func0(56);
rb_define_const(mSyslogConstants, "LOG_NEWS", v12);
v13 = func0(40);
rb_define_const(mSyslogConstants, "LOG_SYSLOG", v13);
rb_define_const(mSyslogConstants, "LOG_USER", v3);
v14 = func0(64);
rb_define_const(mSyslogConstants, "LOG_UUCP", v14);
v15 = func0(128);
rb_define_const(mSyslogConstants, "LOG_LOCAL0", v15);
v16 = func0(136);
rb_define_const(mSyslogConstants, "LOG_LOCAL1", v16);
v17 = func0(144);
rb_define_const(mSyslogConstants, "LOG_LOCAL2", v17);
v18 = func0(152);
rb_define_const(mSyslogConstants, "LOG_LOCAL3", v18);
v19 = func0(160);
rb_define_const(mSyslogConstants, "LOG_LOCAL4", v19);
v20 = func0(168);
rb_define_const(mSyslogConstants, "LOG_LOCAL5", v20);
v21 = func0(176);
rb_define_const(mSyslogConstants, "LOG_LOCAL6", v21);
v22 = func0(184);
rb_define_const(mSyslogConstants, "LOG_LOCAL7", v22);
rb_define_const(mSyslogConstants, "LOG_EMERG", v10);
rb_define_module_function(mSyslog, "emerg", mSyslog_emerg, 0xFFFFFFFFLL);
rb_define_const(mSyslogConstants, "LOG_ALERT", v0);
rb_define_module_function(mSyslog, "alert", mSyslog_alert, 0xFFFFFFFFLL);
rb_define_const(mSyslogConstants, "LOG_CRIT", v1);
rb_define_module_function(mSyslog, "crit", mSyslog_crit, 0xFFFFFFFFLL);
v23 = func0(3);
rb_define_const(mSyslogConstants, "LOG_ERR", v23);
rb_define_module_function(mSyslog, "err", mSyslog_err, 0xFFFFFFFFLL);
rb_define_const(mSyslogConstants, "LOG_WARNING", v2);
rb_define_module_function(mSyslog, "warning", mSyslog_warning, 0xFFFFFFFFLL);
v24 = func0(5);
rb_define_const(mSyslogConstants, "LOG_NOTICE", v24);
rb_define_module_function(mSyslog, "notice", mSyslog_notice, 0xFFFFFFFFLL);
v25 = func0(6);
rb_define_const(mSyslogConstants, "LOG_INFO", v25);
rb_define_module_function(mSyslog, "info", mSyslog_info, 0xFFFFFFFFLL);
v26 = func0(7);
rb_define_const(mSyslogConstants, "LOG_DEBUG", v26);
return rb_define_module_function(mSyslog, "debug", mSyslog_debug, 0xFFFFFFFFLL);
}

original_code:
void Init_syslog()
{
    mSyslog = rb_define_module("Syslog");
    mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
    rb_include_module(mSyslog, mSyslogConstants);
    rb_define_module_function(mSyslog, "open", mSyslog_open, -1);
    rb_define_module_function(mSyslog, "reopen", mSyslog_reopen, -1);
    rb_define_module_function(mSyslog, "open!", mSyslog_reopen, -1);
    rb_define_module_function(mSyslog, "opened?", mSyslog_isopen, 0);
    rb_define_module_function(mSyslog, "ident", mSyslog_ident, 0);
    rb_define_module_function(mSyslog, "options", mSyslog_options, 0);
    rb_define_module_function(mSyslog, "facility", mSyslog_facility, 0);
    rb_define_module_function(mSyslog, "log", mSyslog_log, -1);
    rb_define_module_function(mSyslog, "close", mSyslog_close, 0);
    rb_define_module_function(mSyslog, "mask", mSyslog_get_mask, 0);
    rb_define_module_function(mSyslog, "mask=", mSyslog_set_mask, 1);
    rb_define_module_function(mSyslog, "LOG_MASK", mSyslogConstants_LOG_MASK, 1);
    rb_define_module_function(mSyslog, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1);
    rb_define_module_function(mSyslog, "inspect", mSyslog_inspect, 0);
    rb_define_module_function(mSyslog, "instance", mSyslog_instance, 0);
    rb_define_module_function(mSyslogConstants, "LOG_MASK", mSyslogConstants_LOG_MASK, 1);
    rb_define_module_function(mSyslogConstants, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1);
    rb_define_const(mSyslogConstants, "LOG_PID", INT2NUM(0x01));
    rb_define_const(mSyslogConstants, "LOG_CONS", INT2NUM(0x02));
    rb_define_const(mSyslogConstants, "LOG_ODELAY", INT2NUM(0x04));
    rb_define_const(mSyslogConstants, "LOG_NDELAY", INT2NUM(0x08));
    rb_define_const(mSyslogConstants, "LOG_NOWAIT", INT2NUM(0x10));
    rb_define_const(mSyslogConstants, "LOG_PERROR", INT2NUM(0x20));
    rb_define_const(mSyslogConstants, "LOG_AUTH", INT2NUM((4<<3)));
    rb_define_const(mSyslogConstants, "LOG_AUTHPRIV", INT2NUM((10<<3)));
    rb_define_const(mSyslogConstants, "LOG_CRON", INT2NUM((9<<3)));
    rb_define_const(mSyslogConstants, "LOG_DAEMON", INT2NUM((3<<3)));
    rb_define_const(mSyslogConstants, "LOG_FTP", INT2NUM((11<<3)));
    rb_define_const(mSyslogConstants, "LOG_KERN", INT2NUM((0<<3)));
    rb_define_const(mSyslogConstants, "LOG_LPR", INT2NUM((6<<3)));
    rb_define_const(mSyslogConstants, "LOG_MAIL", INT2NUM((2<<3)));
    rb_define_const(mSyslogConstants, "LOG_NEWS", INT2NUM((7<<3)));
    rb_define_const(mSyslogConstants, "LOG_SYSLOG", INT2NUM((5<<3)));
    rb_define_const(mSyslogConstants, "LOG_USER", INT2NUM((1<<3)));
    rb_define_const(mSyslogConstants, "LOG_UUCP", INT2NUM((8<<3)));
    rb_define_const(mSyslogConstants, "LOG_LOCAL0", INT2NUM((16<<3)));
    rb_define_const(mSyslogConstants, "LOG_LOCAL1", INT2NUM((17<<3)));
    rb_define_const(mSyslogConstants, "LOG_LOCAL2", INT2NUM((18<<3)));
    rb_define_const(mSyslogConstants, "LOG_LOCAL3", INT2NUM((19<<3)));
    rb_define_const(mSyslogConstants, "LOG_LOCAL4", INT2NUM((20<<3)));
    rb_define_const(mSyslogConstants, "LOG_LOCAL5", INT2NUM((21<<3)));
    rb_define_const(mSyslogConstants, "LOG_LOCAL6", INT2NUM((22<<3)));
    rb_define_const(mSyslogConstants, "LOG_LOCAL7", INT2NUM((23<<3)));
    rb_define_const(mSyslogConstants, "LOG_EMERG", INT2NUM(0));
    rb_define_module_function(mSyslog, "emerg", mSyslog_emerg, -1);
    rb_define_const(mSyslogConstants, "LOG_ALERT", INT2NUM(1));
    rb_define_module_function(mSyslog, "alert", mSyslog_alert, -1);
    rb_define_const(mSyslogConstants, "LOG_CRIT", INT2NUM(2));
    rb_define_module_function(mSyslog, "crit", mSyslog_crit, -1);
    rb_define_const(mSyslogConstants, "LOG_ERR", INT2NUM(3));
    rb_define_module_function(mSyslog, "err", mSyslog_err, -1);
    rb_define_const(mSyslogConstants, "LOG_WARNING", INT2NUM(4));
    rb_define_module_function(mSyslog, "warning", mSyslog_warning, -1);
    rb_define_const(mSyslogConstants, "LOG_NOTICE", INT2NUM(5));
    rb_define_module_function(mSyslog, "notice", mSyslog_notice, -1);
    rb_define_const(mSyslogConstants, "LOG_INFO", INT2NUM(6));
    rb_define_module_function(mSyslog, "info", mSyslog_info, -1);
    rb_define_const(mSyslogConstants, "LOG_DEBUG", INT2NUM(7));
    rb_define_module_function(mSyslog, "debug", mSyslog_debug, -1);
}


decompiled_code:
__int64 __fastcall echild_status(__int64 a1)
{
if ( !rb_intern_id_cache_2 )
rb_intern_id_cache_2 = rb_intern2("status", 6LL);
return rb_ivar_get(a1, rb_intern_id_cache_2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( !rb_intern_id_cache_2 )
rb_intern_id_cache_2 = rb_intern2("status", 6LL);
return rb_ivar_get(a1, rb_intern_id_cache_2);
}

original_code:
static VALUE
echild_status(VALUE self)
{
    return rb_ivar_get(self, (__builtin_constant_p("status") ? __extension__ ({ static ID rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("status", strlen("status")); rb_intern_id_cache; }) : rb_intern("status")));
}

canonical_original_code:
static unsigned long echild_status(unsigned long self)
{
    return rb_ivar_get(self, (__builtin_constant_p("status") ? __extension__ ({ static unsigned long rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("status", strlen("status")); rb_intern_id_cache; }) : rb_intern("status")));
}


decompiled_code:
__int64 __fastcall pty_reset_signal(__int64 a1)
{
rb_warn("PTY::reset_signal is no longer needed");
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
rb_warn("PTY::reset_signal is no longer needed");
return a1;
}

original_code:
static VALUE
pty_reset_signal(VALUE self)
{
    rb_warn("PTY::reset_signal is no longer needed");
    return self;
}

canonical_original_code:
static unsigned long pty_reset_signal(unsigned long self)
{
    rb_warn("PTY::reset_signal is no longer needed");
    return self;
}


decompiled_code:
__int64 __fastcall pty_protect(__int64 a1)
{
rb_warn("PTY::protect_signal is no longer needed");
rb_yield(4LL);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
rb_warn("PTY::protect_signal is no longer needed");
rb_yield(4LL);
return a1;
}

original_code:
static VALUE
pty_protect(VALUE self)
{
    rb_warn("PTY::protect_signal is no longer needed");
    rb_yield(((VALUE)RUBY_Qnil));
    return self;
}

canonical_original_code:
static unsigned long pty_protect(unsigned long self)
{
    rb_warn("PTY::protect_signal is no longer needed");
    rb_yield(((unsigned long)RUBY_Qnil));
    return self;
}


decompiled_code:
__int64 __fastcall pty_finalize_syswait(__int64 a1)
{
__int64 v1; // rsi

rb_thread_kill(*(_QWORD *)(a1 + 8));
v1 = rb_intern_id_cache_1;
if ( !rb_intern_id_cache_1 )
{
rb_intern_id_cache_1 = rb_intern2("value", 5LL);
v1 = rb_intern_id_cache_1;
}
rb_funcall(*(_QWORD *)(a1 + 8), v1, 0LL);
rb_detach_process(*(unsigned int *)(a1 + 4));
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rsi

rb_thread_kill(*(_QWORD *)(a1 + 8));
v1 = rb_intern_id_cache_1;
if ( !rb_intern_id_cache_1 )
{
rb_intern_id_cache_1 = rb_intern2("value", 5LL);
v1 = rb_intern_id_cache_1;
}
rb_funcall(*(_QWORD *)(a1 + 8), v1, 0LL);
rb_detach_process(*(unsigned int *)(a1 + 4));
return 4LL;
}

original_code:
static VALUE
pty_finalize_syswait(struct pty_info *info)
{
    rb_thread_kill(info->thread);
    rb_funcall(info->thread, (__builtin_constant_p("value") ? __extension__ ({ static ID rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("value", strlen("value")); rb_intern_id_cache; }) : rb_intern("value")), 0);
    rb_detach_process(info->child_pid);
    return ((VALUE)RUBY_Qnil);
}

canonical_original_code:
static unsigned long pty_finalize_syswait(struct pty_info *info)
{
    rb_thread_kill(info->thread);
    rb_funcall(info->thread, (__builtin_constant_p("value") ? __extension__ ({ static unsigned long rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("value", strlen("value")); rb_intern_id_cache; }) : rb_intern("value")), 0);
    rb_detach_process(info->child_pid);
    return ((unsigned long)RUBY_Qnil);
}

variable_types: struct pty_info { int fd; int child_pid; unsigned long thread; } *


decompiled_code:
__int64 __fastcall raise_from_wait(const char *a1, __int64 a2)
{
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // rsi
char v7[1048]; // [rsp+0h] [rbp-418h] BYREF

snprintf(v7, 0x400uLL, "pty - %s: %ld", a1, *(int *)(a2 + 4));
v3 = rb_exc_new2(eChildExited, v7);
v4 = rb_last_status_get();
rb_iv_set(v3, "status", v4);
v5 = rb_intern_id_cache_0;
if ( !rb_intern_id_cache_0 )
{
rb_intern_id_cache_0 = rb_intern2("raise", 5LL);
v5 = rb_intern_id_cache_0;
}
return rb_funcall(*(_QWORD *)(a2 + 8), v5, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, __int64 a2)
{
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // rsi
char v7[1048]; // [rsp+0h] [rbp-418h] BYREF

snprintf(v7, 0x400uLL, "pty - %s: %ld", a1, *(int *)(a2 + 4));
v3 = rb_exc_new2(eChildExited, v7);
v4 = rb_last_status_get();
rb_iv_set(v3, "status", v4);
v5 = rb_intern_id_cache_0;
if ( !rb_intern_id_cache_0 )
{
rb_intern_id_cache_0 = rb_intern2("raise", 5LL);
v5 = rb_intern_id_cache_0;
}
return rb_funcall(*(_QWORD *)(a2 + 8), v5, 1LL);
}

original_code:
static void
raise_from_wait(const char *state, const struct pty_info *info)
{
    char buf[1024];
    VALUE exc;
    snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)info->child_pid);
    exc = rb_exc_new2(eChildExited, buf);
    rb_iv_set(exc, "status", rb_last_status_get());
    rb_funcall(info->thread, (__builtin_constant_p("raise") ? __extension__ ({ static ID rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("raise", strlen("raise")); rb_intern_id_cache; }) : rb_intern("raise")), 1, exc);
}

canonical_original_code:
static void raise_from_wait(char *state, struct pty_info *info)
{
    char buf[1024];
    unsigned long exc;
    snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)info->child_pid);
    exc = rb_exc_new2(eChildExited, buf);
    rb_iv_set(exc, "status", rb_last_status_get());
    rb_funcall(info->thread, (__builtin_constant_p("raise") ? __extension__ ({ static unsigned long rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2("raise", strlen("raise")); rb_intern_id_cache; }) : rb_intern("raise")), 1, exc);
}

variable_types:
state
char *

variable_types:
exc
unsigned long

user_defined_types: struct pty_info { int fd; int child_pid; unsigned long thread; }


decompiled_code:
__int64 __fastcall pty_syswait(__int64 a1)
{
char v2[28]; // [rsp+Ch] [rbp-1Ch] BYREF

while ( (unsigned int)rb_waitpid(*(unsigned int *)(a1 + 4), v2, 2LL) != -1 )
{
if ( v2[0] == 127 )
{
raise_from_wait("stopped", a1);
}
else
{
if ( kill(*(_DWORD *)(a1 + 4), 0) )
{
raise_from_wait("exited", a1);
return 4LL;
}
raise_from_wait("changed", a1);
}
}
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
char v2[28]; // [rsp+Ch] [rbp-1Ch] BYREF

while ( (unsigned int)rb_waitpid(*(unsigned int *)(a1 + 4), v2, 2LL) != -1 )
{
if ( v2[0] == 127 )
{
func4("stopped", a1);
}
else
{
if ( kill(*(_DWORD *)(a1 + 4), 0) )
{
func4("exited", a1);
return 4LL;
}
func4("changed", a1);
}
}
return 4LL;
}

original_code:
static VALUE
pty_syswait(void *arg)
{
    const struct pty_info *const info = arg;
    pid_t cpid;
    int status;
    for (;;) {
 cpid = rb_waitpid(info->child_pid, &status, 2);
 if (cpid == -1) return ((VALUE)RUBY_Qnil);
 if ((((status) & 0xff) == 0x7f)) {
     raise_from_wait("stopped", info);
 }
 else if (kill(info->child_pid, 0) == 0) {
     raise_from_wait("changed", info);
 }
 else {
     raise_from_wait("exited", info);
     return ((VALUE)RUBY_Qnil);
 }
    }
}

canonical_original_code:
static unsigned long pty_syswait(void *arg)
{
    struct pty_info *info = arg;
    int cpid;
    int status;
    for (;;) {
 cpid = rb_waitpid(info->child_pid, &status, 2);
 if (cpid == -1) return ((unsigned long)RUBY_Qnil);
 if ((((status) & 0xff) == 0x7f)) {
     raise_from_wait("stopped", info);
 }
 else if (kill(info->child_pid, 0) == 0) {
     raise_from_wait("changed", info);
 }
 else {
     raise_from_wait("exited", info);
     return ((unsigned long)RUBY_Qnil);
 }
    }
}

variable_types:
arg
void *

variable_types: cpid int

variable_types: status int


chfunc

decompiled_code:
void __fastcall __noreturn chfunc(__int64 a1)
{
int v1; // er13
int v2; // ebp
int v3; // er12
__int64 v4; // rbx
__uid_t v5; // eax
char v6[4]; // [rsp+Ch] [rbp-3Ch] BYREF
int v7; // [rsp+10h] [rbp-38h] BYREF
__int64 v8; // [rsp+18h] [rbp-30h]

v1 = *(_DWORD *)a1;
v2 = *(_DWORD *)(a1 + 4);
v3 = *(_DWORD *)(a1 + 16);
v4 = *(_QWORD *)(a1 + 24);
setsid();
close(v1);
ioctl(v2, 0x540EuLL, 0LL);
write(v2, &LC9, 1uLL);
dup2(v2, 0);
dup2(v2, 1);
dup2(v2, 2);
close(v2);
v5 = getuid();
seteuid(v5);
v7 = v3;
v8 = v4;
rb_protect(pty_exec, &v7, v6);
sleep(1u);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func6(__int64 a1)
{
int v1; // er13
int v2; // ebp
int v3; // er12
__int64 v4; // rbx
__uid_t v5; // eax
char v6[4]; // [rsp+Ch] [rbp-3Ch] BYREF
int v7; // [rsp+10h] [rbp-38h] BYREF
__int64 v8; // [rsp+18h] [rbp-30h]

v1 = *(_DWORD *)a1;
v2 = *(_DWORD *)(a1 + 4);
v3 = *(_DWORD *)(a1 + 16);
v4 = *(_QWORD *)(a1 + 24);
setsid();
close(v1);
ioctl(v2, 0x540EuLL, 0LL);
write(v2, &LC9, 1uLL);
dup2(v2, 0);
dup2(v2, 1);
dup2(v2, 2);
close(v2);
v5 = getuid();
seteuid(v5);
v7 = v3;
v8 = v4;
rb_protect(pty_exec, &v7, v6);
sleep(1u);
exit(1);
}

original_code:
static int
chfunc(void *data)
{
    struct child_info *carg = data;
    int master = carg->master;
    int slave = carg->slave;
    int argc = carg->argc;
    VALUE *argv = carg->argv;
    struct exec_info arg;
    int status;
    (void) setsid();
    close(master);
    (void) ioctl(slave, 0x540E, (char *)0);
    write(slave, "", 1);
    dup2(slave,0);
    dup2(slave,1);
    dup2(slave,2);
    close(slave);
    seteuid(getuid());
    arg.argc = argc;
    arg.argv = argv;
    rb_protect(pty_exec, (VALUE)&arg, &status);
    sleep(1);
    _exit(1);
}

canonical_original_code:
static int chfunc(void *data)
{
    struct child_info *carg = data;
    int master = carg->master;
    int slave = carg->slave;
    int argc = carg->argc;
    unsigned long *argv = carg->argv;
    struct exec_info arg;
    int status;
    (void) setsid();
    close(master);
    (void) ioctl(slave, 0x540E, (char *)0);
    write(slave, "", 1);
    dup2(slave,0);
    dup2(slave,1);
    dup2(slave,2);
    close(slave);
    seteuid(getuid());
    arg.argc = argc;
    arg.argv = argv;
    rb_protect(pty_exec, (VALUE)&arg, &status);
    sleep(1);
    _exit(1);
}

variable_types:
data
void *

variable_types: struct child_info { int master; char *slavename; int argc; unsigned long *argv; } *

variable_types: master int

variable_types: slave int

variable_types: argc int

variable_types: struct exec_info { int argc; unsigned long *argv; }


decompiled_code:
__int64 __fastcall pty_exec(unsigned int *a1)
{
return rb_f_exec(*a1, *((_QWORD *)a1 + 1));
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int *a1)
{
return rb_f_exec(*a1, *((_QWORD *)a1 + 1));
}

original_code:
static VALUE
pty_exec(VALUE v)
{
    struct exec_info *arg = (struct exec_info *)v;
    return rb_f_exec(arg->argc, arg->argv);
}

canonical_original_code:
static unsigned long pty_exec(unsigned long v)
{
    struct exec_info *arg = (struct exec_info *)v;
    return rb_f_exec(arg->argc, arg->argv);
}

variable_types:
v
unsigned long

variable_types: struct exec_info { int argc; unsigned long *argv; } *


decompiled_code:
int __fastcall get_device_once(int *a1, int *a2, char *a3, int a4)
{
int result; // eax

result = openpty(a1, a2, a3, 0LL, 0LL);
if ( result != -1 )
return 0;
if ( a4 )
{
rb_raise(rb_eRuntimeError, "openpty() failed");
result = getDevice();
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(int *a1, int *a2, char *a3, int a4)
{
int result; // eax

result = openpty(a1, a2, a3, 0LL, 0LL);
if ( result != -1 )
return 0;
if ( a4 )
{
rb_raise(rb_eRuntimeError, "openpty() failed");
result = func9();
}
return result;
}

original_code:
static int
get_device_once(int *master, int *slave, char SlaveName[16], int fail)
{
    if (openpty(master, slave, SlaveName,
  (struct termios *)0, (struct winsize *)0) == -1) {
 if (!fail) return -1;
 rb_raise(rb_eRuntimeError, "openpty() failed");
    }
    return 0;
}

variable_types:
master
int *

variable_types:
slave
int *

variable_types:
SlaveName
char [16]

variable_types: fail int

user_defined_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

user_defined_types: struct winsize { unsigned short ws_row; unsigned short ws_col; unsigned short ws_xpixel; unsigned short ws_ypixel; }


getDevice

decompiled_code:
int __fastcall getDevice(int *a1, int *a2, char *a3)
{
int result; // eax

result = get_device_once(a1, a2, a3, 0);
if ( result )
{
rb_gc();
result = get_device_once(a1, a2, a3, 1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(int *a1, int *a2, char *a3)
{
int result; // eax

result = func8(a1, a2, a3, 0);
if ( result )
{
rb_gc();
result = func8(a1, a2, a3, 1);
}
return result;
}

original_code:
static void
getDevice(int *master, int *slave, char SlaveName[16])
{
    if (get_device_once(master, slave, SlaveName, 0)) {
 rb_gc();
 get_device_once(master, slave, SlaveName, 1);
    }
    return;
}


establishShell

decompiled_code:
__int64 __fastcall establishShell(int a1, __int64 *a2, __int64 a3, char *a4)
{
int v6; // ebp
int v8; // ebp
__int64 result; // rax
char *v10; // rdi
__uid_t v11; // eax
struct passwd *v12; // rax
char buf; // [rsp+Fh] [rbp-59h] BYREF
int fd; // [rsp+10h] [rbp-58h] BYREF
int v15; // [rsp+14h] [rbp-54h] BYREF
__int64 v16; // [rsp+18h] [rbp-50h] BYREF
int v17[2]; // [rsp+20h] [rbp-48h] BYREF
char *v18; // [rsp+28h] [rbp-40h]
int v19; // [rsp+30h] [rbp-38h]
__int64 *v20; // [rsp+38h] [rbp-30h]

v6 = a1;
if ( !a1 )
{
v10 = getenv("SHELL");
if ( !v10 )
{
v11 = getuid();
v12 = getpwuid(v11);
v10 = "/bin/sh";
if ( v12 )
{
v10 = v12->pw_shell;
if ( !v10 )
v10 = "/bin/sh";
}
}
a2 = &v16;
v6 = 1;
v16 = rb_str_new_cstr(v10);
}
getDevice(&fd, &v15, a4);
v19 = v6;
v17[0] = fd;
v18 = a4;
v17[1] = v15;
v20 = a2;
v8 = rb_fork(0LL, chfunc, v17, 4LL);
*(_QWORD *)(a3 + 8) = rb_thread_current();
if ( v8 < 0 )
{
close(fd);
close(v15);
rb_sys_fail("fork failed");
result = LONG2NUM();
}
else
{
read(fd, &buf, 1uLL);
close(v15);
result = (unsigned int)fd;
*(_DWORD *)(a3 + 4) = v8;
*(_DWORD *)a3 = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, __int64 *a2, __int64 a3, char *a4)
{
int v6; // ebp
int v8; // ebp
__int64 result; // rax
char *v10; // rdi
__uid_t v11; // eax
struct passwd *v12; // rax
char buf; // [rsp+Fh] [rbp-59h] BYREF
int fd; // [rsp+10h] [rbp-58h] BYREF
int v15; // [rsp+14h] [rbp-54h] BYREF
__int64 v16; // [rsp+18h] [rbp-50h] BYREF
int v17[2]; // [rsp+20h] [rbp-48h] BYREF
char *v18; // [rsp+28h] [rbp-40h]
int v19; // [rsp+30h] [rbp-38h]
__int64 *v20; // [rsp+38h] [rbp-30h]

v6 = a1;
if ( !a1 )
{
v10 = getenv("SHELL");
if ( !v10 )
{
v11 = getuid();
v12 = getpwuid(v11);
v10 = "/bin/sh";
if ( v12 )
{
v10 = v12->pw_shell;
if ( !v10 )
v10 = "/bin/sh";
}
}
a2 = &v16;
v6 = 1;
v16 = rb_str_new_cstr(v10);
}
func9(&fd, &v15, a4);
v19 = v6;
v17[0] = fd;
v18 = a4;
v17[1] = v15;
v20 = a2;
v8 = rb_fork(0LL, chfunc, v17, 4LL);
*(_QWORD *)(a3 + 8) = rb_thread_current();
if ( v8 < 0 )
{
close(fd);
close(v15);
rb_sys_fail("fork failed");
result = func11();
}
else
{
read(fd, &buf, 1uLL);
close(v15);
result = (unsigned int)fd;
*(_DWORD *)(a3 + 4) = v8;
*(_DWORD *)a3 = result;
}
return result;
}

original_code:
static void
establishShell(int argc, VALUE *argv, struct pty_info *info,
        char SlaveName[16])
{
    int master,slave;
    pid_t pid;
    char *p, tmp, *getenv();
    struct passwd *pwent;
    VALUE v;
    struct child_info carg;
    if (argc == 0) {
 const char *shellname;
 if ((p = getenv("SHELL")) != ((void *)0)) {
     shellname = p;
 }
 else {
     pwent = getpwuid(getuid());
     if (pwent && pwent->pw_shell)
  shellname = pwent->pw_shell;
     else
  shellname = "/bin/sh";
 }
 v = __extension__ ( { (__builtin_constant_p(shellname)) ? rb_str_new(shellname, strlen(shellname)) : rb_str_new_cstr(shellname); });
 argc = 1;
 argv = &v;
    }
    getDevice(&master, &slave, SlaveName);
    carg.master = master;
    carg.slave = slave;
    carg.slavename = SlaveName;
    carg.argc = argc;
    carg.argv = argv;
    pid = rb_fork(0, chfunc, &carg, ((VALUE)RUBY_Qnil));
    info->thread = rb_thread_current();
    if (pid < 0) {
 close(master);
 close(slave);
 rb_sys_fail("fork failed");
    }
    read(master, &tmp, 1);
    close(slave);
    info->child_pid = pid;
    info->fd = master;
}

canonical_original_code:
static void establishShell(int argc, unsigned long *argv, struct pty_info *info, char SlaveName[16])
{
    int master; int slave;
    int pid;
    char *p; char tmp; char *getenv();
    struct passwd *pwent;
    unsigned long v;
    struct child_info carg;
    if (argc == 0) {
 char *shellname;
 if ((p = getenv("SHELL")) != ((void *)0)) {
     shellname = p;
 }
 else {
     pwent = getpwuid(getuid());
     if (pwent && pwent->pw_shell)
  shellname = pwent->pw_shell;
     else
  shellname = "/bin/sh";
 }
 v = __extension__ ( { (__builtin_constant_p(shellname)) ? rb_str_new(shellname, strlen(shellname)) : rb_str_new_cstr(shellname); });
 argc = 1;
 argv = &v;
    }
    getDevice(&master, &slave, SlaveName);
    carg.master = master;
    carg.slave = slave;
    carg.slavename = SlaveName;
    carg.argc = argc;
    carg.argv = argv;
    pid = rb_fork(0, chfunc, &carg, ((unsigned long)RUBY_Qnil));
    info->thread = rb_thread_current();
    if (pid < 0) {
 close(master);
 close(slave);
 rb_sys_fail("fork failed");
    }
    read(master, &tmp, 1);
    close(slave);
    info->child_pid = pid;
    info->fd = master;
}

variable_types:
argv
unsigned long *

variable_types: struct pty_info { int fd; int child_pid; unsigned long thread; } *

variable_types: pid int

variable_types:
p
char *

variable_types: tmp char

variable_types:
getenv
char *()

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

variable_types: struct child_info { int master; char *slavename; int argc; unsigned long *argv; }

variable_types:
shellname
char *


decompiled_code:
__int64 __fastcall LONG2NUM(__int64 a1)
{
return 2 * a1 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return 2 * a1 + 1;
}

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

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

variable_types: v long


decompiled_code:
__int64 Init_pty()
{
cPTY = rb_define_module("PTY");
rb_define_module_function(cPTY, "getpty", pty_getpty, 0xFFFFFFFFLL);
rb_define_module_function(cPTY, "spawn", pty_getpty, 0xFFFFFFFFLL);
rb_define_module_function(cPTY, "protect_signal", pty_protect, 0LL);
rb_define_module_function(cPTY, "reset_signal", pty_reset_signal, 0LL);
eChildExited = rb_define_class_under(cPTY, "ChildExited", rb_eRuntimeError);
return rb_define_method(eChildExited, "status", echild_status, 0LL);
}

canonical_decompiled_code:
__int64 func13()
{
cPTY = rb_define_module("PTY");
rb_define_module_function(cPTY, "getpty", pty_getpty, 0xFFFFFFFFLL);
rb_define_module_function(cPTY, "spawn", pty_getpty, 0xFFFFFFFFLL);
rb_define_module_function(cPTY, "protect_signal", pty_protect, 0LL);
rb_define_module_function(cPTY, "reset_signal", pty_reset_signal, 0LL);
eChildExited = rb_define_class_under(cPTY, "ChildExited", rb_eRuntimeError);
return rb_define_method(eChildExited, "status", echild_status, 0LL);
}

original_code:
void
Init_pty()
{
    cPTY = rb_define_module("PTY");
    rb_define_module_function(cPTY,"getpty",pty_getpty,-1);
    rb_define_module_function(cPTY,"spawn",pty_getpty,-1);
    rb_define_module_function(cPTY,"protect_signal",pty_protect,0);
    rb_define_module_function(cPTY,"reset_signal",pty_reset_signal,0);
    eChildExited = rb_define_class_under(cPTY,"ChildExited",rb_eRuntimeError);
    rb_define_method(eChildExited,"status",echild_status,0);
}


original_code:
bytestring_t *bytestring_alloc(void) {
    bytestring_t *ret;
    ret = (bytestring_t*)malloc(sizeof(bytestring_t));
    ret->hash = ((long)0xCAFECAFE);
    ret->length = 64;
    ret->remaining = ret->length;
    ret->buffer = (char*)malloc(sizeof(char)*(ret->length + 1));
    ret->buffer[0] = 0;
    ret->printed = 0;
    return ret;
}

canonical_original_code:
struct bytestring_t *bytestring_alloc() {
    struct bytestring_t *ret;
    ret = (struct bytestring_t *)malloc(sizeof(bytestring_t));
    ret->hash = ((long)0xCAFECAFE);
    ret->length = 64;
    ret->remaining = ret->length;
    ret->buffer = (char *)malloc(sizeof(char)*(ret->length + 1));
    ret->buffer[0] = 0;
    ret->printed = 0;
    return ret;
}

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