decompiled_code:
int __fastcall shell_loop(__int64 a1, unsigned __int64 a2)
{
FILE *v2; // rdi

while ( 1 )
{
printf("[minishell]$ ");
v2 = _bss_start;
fflush(_bss_start);
init();
if ( (unsigned int)read_command() == -1 )
break;
if ( (unsigned int)parse_command((__int64)v2, a2) != -1 )
execute_command();
}
return puts("\nexit");
}

canonical_decompiled_code:
int __fastcall func13(__int64 a1, unsigned __int64 a2)
{
FILE *v2; // rdi

while ( 1 )
{
printf("[minishell]$ ");
v2 = _bss_start;
fflush(_bss_start);
func17();
if ( (unsigned int)func7() == -1 )
break;
if ( (unsigned int)func12((__int64)v2, a2) != -1 )
func8();
}
return puts("\nexit");
}

original_code:
void shell_loop(void)
{
 while(1)
 {
  printf("[minishell]$ ");
  fflush(stdout);
  init();
  if(read_command() == -1)
   break;
  if (parse_command() != -1)
  {
   execute_command();
  }
 }
 printf("\nexit\n");
}

canonical_original_code:
void shell_loop()
{
 while(1)
 {
  printf("[minishell]$ ");
  fflush(stdout);
  init();
  if(read_command() == -1)
   break;
  if (parse_command() != -1)
  {
   execute_command();
  }
 }
 printf("\nexit\n");
}


repo: JnuSimba/APUE

decompiled_code:
int print_command()
{
int result; // eax
_QWORD *v1; // rbp
int v2; // er12
const char *v3; // rsi
_QWORD *i; // rbx

result = printf("cmd_count=%d\n", (unsigned int)cmd_count);
if ( cmd_count > 0 )
{
v1 = &unk_404128;
v2 = 0;
do
{
v3 = (const char *)*(v1 - 1);
for ( i = v1; v3; v3 = (const char *)*(i - 1) )
{
printf("[%s] ", v3);
++i;
}
result = putchar(10);
++v2;
v1 += 22;
}
while ( cmd_count > v2 );
}
if ( infile[0] )
result = printf("infile=[%s]\n", infile);
if ( outfile[0] )
result = printf("outfile=[%s]\n", outfile);
return result;
}

canonical_decompiled_code:
int func14()
{
int result; // eax
_QWORD *v1; // rbp
int v2; // er12
const char *v3; // rsi
_QWORD *i; // rbx

result = printf("cmd_count=%d\n", (unsigned int)cmd_count);
if ( cmd_count > 0 )
{
v1 = &unk_404128;
v2 = 0;
do
{
v3 = (const char *)*(v1 - 1);
for ( i = v1; v3; v3 = (const char *)*(i - 1) )
{
printf("[%s] ", v3);
++i;
}
result = putchar(10);
++v2;
v1 += 22;
}
while ( cmd_count > v2 );
}
if ( infile[0] )
result = printf("infile=[%s]\n", infile);
if ( outfile[0] )
result = printf("outfile=[%s]\n", outfile);
return result;
}

original_code:
void print_command(void)
{
 printf("cmd_count=%d\n", cmd_count);
 int i, j;
 for (i = 0; i < cmd_count ; i++ )
 {
  j = 0;
  while (cmd[i].args[j] != ((void *)0))
  {
   printf("[%s] ", cmd[i].args[j]);
   j++;
  }
  printf("\n");
 }
 if(infile[0] != '\0')
  printf("infile=[%s]\n", infile);
 if(outfile[0] != '\0')
  printf("outfile=[%s]\n", outfile);
}

canonical_original_code:
void print_command()
{
 printf("cmd_count=%d\n", cmd_count);
 int i; int j;
 for (i = 0; i < cmd_count ; i++ )
 {
  j = 0;
  while (cmd[i].args[j] != ((void *)0))
  {
   printf("[%s] ", cmd[i].args[j]);
   j++;
  }
  printf("\n");
 }
 if(infile[0] != '\0')
  printf("infile=[%s]\n", infile);
 if(outfile[0] != '\0')
  printf("outfile=[%s]\n", outfile);
}

variable_types: i int

variable_types: j int

return_type: void


decompiled_code:
void int_handler()
{
printf("\n[minishell]$ ");
fflush(_bss_start);
}

canonical_decompiled_code:
void func15()
{
printf("\n[minishell]$ ");
fflush(_bss_start);
}

original_code:
void int_handler(int sig)
{
 printf("\n[minishell]$ ");
 fflush(stdout);
}

variable_types: sig int


setup

decompiled_code:
__sighandler_t setup()
{
signal(2, (__sighandler_t)int_handler);
return signal(3, (__sighandler_t)1);
}

canonical_decompiled_code:
__sighandler_t func16()
{
signal(2, (__sighandler_t)int_handler);
return signal(3, (__sighandler_t)1);
}

original_code:
void setup(void)
{
 signal(2, int_handler);
 signal(3, ((__sighandler_t) 1));
}

canonical_original_code:
void setup()
{
 signal(2, int_handler);
 signal(3, ((void (*)(int)) 1));
}


init

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

result = 0LL;
*(_QWORD *)cmdline = 0LL;
qword_404DD9 = 0LL;
memset(
(void *)((unsigned __int64)&unk_4049E8 & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)cmdline - (unsigned int)((unsigned __int64)&unk_4049E8 & 0xFFFFFFFFFFFFFFF8LL) + 1025) >> 3));
memset(cmd, 0, 0x370uLL);
avgline = 0LL;
qword_4049B9 = 0LL;
memset(
(void *)((unsigned __int64)&unk_4045C8 & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)&avgline - (unsigned int)((unsigned __int64)&unk_4045C8 & 0xFFFFFFFFFFFFFFF8LL) + 1025) >> 3));
lineptr = (__int64)cmdline;
avptr = (__int64)&avgline;
cmd_count = 0;
backgnd = 0;
append = 0;
*(_QWORD *)outfile = 0LL;
qword_40451D = 0LL;
memset(
(void *)((unsigned __int64)&unk_4044C8 & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)outfile - (unsigned int)((unsigned __int64)&unk_4044C8 & 0xFFFFFFFFFFFFFFF8LL) + 101) >> 3));
*(_QWORD *)infile = 0LL;
qword_40459D = 0LL;
memset(
(void *)((unsigned __int64)&unk_404548 & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)infile - (unsigned int)((unsigned __int64)&unk_404548 & 0xFFFFFFFFFFFFFFF8LL) + 101) >> 3));
dword_4041C8 = 0;
dword_4041CC = 1;
dword_404278 = 0;
dword_40427C = 1;
dword_404328 = 0;
dword_40432C = 1;
dword_4043D8 = 0;
dword_4043DC = 1;
dword_404488 = 0;
dword_40448C = 1;
lastpid = 0;
return result;
}

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

result = 0LL;
*(_QWORD *)cmdline = 0LL;
qword_404DD9 = 0LL;
memset(
(void *)((unsigned __int64)&unk_4049E8 & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)cmdline - (unsigned int)((unsigned __int64)&unk_4049E8 & 0xFFFFFFFFFFFFFFF8LL) + 1025) >> 3));
memset(cmd, 0, 0x370uLL);
avgline = 0LL;
qword_4049B9 = 0LL;
memset(
(void *)((unsigned __int64)&unk_4045C8 & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)&avgline - (unsigned int)((unsigned __int64)&unk_4045C8 & 0xFFFFFFFFFFFFFFF8LL) + 1025) >> 3));
lineptr = (__int64)cmdline;
avptr = (__int64)&avgline;
cmd_count = 0;
backgnd = 0;
append = 0;
*(_QWORD *)outfile = 0LL;
qword_40451D = 0LL;
memset(
(void *)((unsigned __int64)&unk_4044C8 & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)outfile - (unsigned int)((unsigned __int64)&unk_4044C8 & 0xFFFFFFFFFFFFFFF8LL) + 101) >> 3));
*(_QWORD *)infile = 0LL;
qword_40459D = 0LL;
memset(
(void *)((unsigned __int64)&unk_404548 & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)infile - (unsigned int)((unsigned __int64)&unk_404548 & 0xFFFFFFFFFFFFFFF8LL) + 101) >> 3));
dword_4041C8 = 0;
dword_4041CC = 1;
dword_404278 = 0;
dword_40427C = 1;
dword_404328 = 0;
dword_40432C = 1;
dword_4043D8 = 0;
dword_4043DC = 1;
dword_404488 = 0;
dword_40448C = 1;
lastpid = 0;
return result;
}

original_code:
void init(void)
{
 memset(cmdline, 0, sizeof(cmdline));
 memset(cmd, 0, sizeof(cmd));
 memset(avgline, 0, sizeof(avgline));
 lineptr = cmdline;
 avptr = avgline;
 cmd_count = 0;
 backgnd = 0;
 append = 0;
 memset(outfile, 0, sizeof(outfile));
 memset(infile, 0, sizeof(infile));
 int i;
 for (i = 0;i < 5 ; ++i )
 {
  cmd[i].infd = 0;
  cmd[i].outfd = 1;
 }
 lastpid = 0;
}

canonical_original_code:
void init()
{
 memset(cmdline, 0, sizeof(cmdline));
 memset(cmd, 0, sizeof(cmd));
 memset(avgline, 0, sizeof(avgline));
 lineptr = cmdline;
 avptr = avgline;
 cmd_count = 0;
 backgnd = 0;
 append = 0;
 memset(outfile, 0, sizeof(outfile));
 memset(infile, 0, sizeof(infile));
 int i;
 for (i = 0;i < 5 ; ++i )
 {
  cmd[i].infd = 0;
  cmd[i].outfd = 1;
 }
 lastpid = 0;
}


forkexec

decompiled_code:
__pid_t __fastcall forkexec(int a1)
{
__pid_t result; // eax
int i; // ebp
int v3; // eax

result = fork();
if ( result == -1 )
{
perror("fork");
exit(1);
}
if ( result > 0 )
{
lastpid = result;
}
else if ( !result )
{
if ( dword_4041C8[44 * a1] || backgnd == 1 && (v3 = open("/dev/null", 0), (dword_4041C8[44 * a1] = v3) != 0) )
{
close(0);
dup(dword_4041C8[44 * a1]);
}
if ( dword_4041CC[44 * a1] != 1 )
{
close(1);
dup(dword_4041CC[44 * a1]);
}
for ( i = 3; i != 16; ++i )
close(i);
if ( !backgnd )
{
signal(2, 0LL);
signal(3, 0LL);
}
execvp((const char *)cmd[22 * a1], (char *const *)&cmd[22 * a1]);
exit(1);
}
return result;
}

canonical_decompiled_code:
__pid_t __fastcall func18(int a1)
{
__pid_t result; // eax
int i; // ebp
int v3; // eax

result = fork();
if ( result == -1 )
{
perror("fork");
exit(1);
}
if ( result > 0 )
{
lastpid = result;
}
else if ( !result )
{
if ( dword_4041C8[44 * a1] || backgnd == 1 && (v3 = open("/dev/null", 0), (dword_4041C8[44 * a1] = v3) != 0) )
{
close(0);
dup(dword_4041C8[44 * a1]);
}
if ( dword_4041CC[44 * a1] != 1 )
{
close(1);
dup(dword_4041CC[44 * a1]);
}
for ( i = 3; i != 16; ++i )
close(i);
if ( !backgnd )
{
signal(2, 0LL);
signal(3, 0LL);
}
execvp((const char *)cmd[22 * a1], (char *const *)&cmd[22 * a1]);
exit(1);
}
return result;
}

original_code:
void forkexec(int num)
{
 int i;
 pid_t pid;
 pid = fork();
 if (pid == -1)
  do{ perror("fork"); exit(1);} while (0);
 if (pid > 0)
 {
  lastpid = pid;
  return;
 }
 else if(pid == 0)
 {
  if (cmd[num].infd == 0 && backgnd == 1)
   cmd[num].infd = open("/dev/null", 00);
  if(cmd[num].infd != 0)
  {
   close(0);
   dup(cmd[num].infd);
  }
  if (cmd[num].outfd != 1)
  {
   close(1);
   dup(cmd[num].outfd);
  }
  for (i = 3; i < 16; ++i )
   close(i);
  if (backgnd == 0)
  {
   signal(2, ((__sighandler_t) 0));
   signal(3, ((__sighandler_t) 0));
  }
  execvp(cmd[num].args[0], cmd[num].args);
  exit(1);
 }
}

canonical_original_code:
void forkexec(int num)
{
 int i;
 int pid;
 pid = fork();
 if (pid == -1)
  do{ perror("fork"); exit(1);} while (0);
 if (pid > 0)
 {
  lastpid = pid;
  return;
 }
 else if(pid == 0)
 {
  if (cmd[num].infd == 0 && backgnd == 1)
   cmd[num].infd = open("/dev/null", 00);
  if(cmd[num].infd != 0)
  {
   close(0);
   dup(cmd[num].infd);
  }
  if (cmd[num].outfd != 1)
  {
   close(1);
   dup(cmd[num].outfd);
  }
  for (i = 3; i < 16; ++i )
   close(i);
  if (backgnd == 0)
  {
   signal(2, ((void (*)(int)) 0));
   signal(3, ((void (*)(int)) 0));
  }
  execvp(cmd[num].args[0], cmd[num].args);
  exit(1);
 }
}

variable_types: num int

variable_types: pid int


decompiled_code:
__pid_t execute_disk_command()
{
int v0; // ebx
__pid_t result; // eax
__int64 *v2; // rbp
int i; // ebx
int v4; // edi
int v5; // edi
int pipedes[2]; // [rsp+8h] [rbp-20h] BYREF

if ( backgnd )
signal(17, (__sighandler_t)1);
else
signal(17, 0LL);
if ( infile[0] )
dword_4041C8[0] = open(infile, 0);
if ( outfile[0] )
{
v0 = cmd_count - 1;
if ( append )
dword_4041CC[44 * v0] = open(outfile, 1089);
else
dword_4041CC[44 * v0] = open(outfile, 577);
}
result = cmd_count;
v2 = cmd;
for ( i = 0; cmd_count > i; v2 += 22 )
{
if ( result - 1 > i )
{
pipe(pipedes);
*((_DWORD *)v2 + 43) = pipedes[1];
*((_DWORD *)v2 + 86) = pipedes[0];
}
forkexec(i);
v4 = *((_DWORD *)v2 + 42);
if ( v4 )
close(v4);
v5 = *((_DWORD *)v2 + 43);
if ( v5 != 1 )
close(v5);
++i;
result = cmd_count;
}
if ( !backgnd )
{
do
result = wait(0LL);
while ( result != lastpid );
}
return result;
}

canonical_decompiled_code:
__pid_t func19()
{
int v0; // ebx
__pid_t result; // eax
__int64 *v2; // rbp
int i; // ebx
int v4; // edi
int v5; // edi
int pipedes[2]; // [rsp+8h] [rbp-20h] BYREF

if ( backgnd )
signal(17, (__sighandler_t)1);
else
signal(17, 0LL);
if ( infile[0] )
dword_4041C8[0] = open(infile, 0);
if ( outfile[0] )
{
v0 = cmd_count - 1;
if ( append )
dword_4041CC[44 * v0] = open(outfile, 1089);
else
dword_4041CC[44 * v0] = open(outfile, 577);
}
result = cmd_count;
v2 = cmd;
for ( i = 0; cmd_count > i; v2 += 22 )
{
if ( result - 1 > i )
{
pipe(pipedes);
*((_DWORD *)v2 + 43) = pipedes[1];
*((_DWORD *)v2 + 86) = pipedes[0];
}
func18(i);
v4 = *((_DWORD *)v2 + 42);
if ( v4 )
close(v4);
v5 = *((_DWORD *)v2 + 43);
if ( v5 != 1 )
close(v5);
++i;
result = cmd_count;
}
if ( !backgnd )
{
do
result = wait(0LL);
while ( result != lastpid );
}
return result;
}

original_code:
void execute_disk_command(void)
{
 int i;
 int fds[2];
 int fd;
 if (backgnd)
  signal(17, ((__sighandler_t) 1));
 else
  signal(17, ((__sighandler_t) 0));
 if (infile[0] != '\0')
  cmd[0].infd = open(infile, 00);
 if (outfile[0] != '\0')
 {
  if (append)
   cmd[cmd_count-1].outfd = open(outfile, 01 | 0100 | 02000);
  else
   cmd[cmd_count-1].outfd = open(outfile, 01 | 0100 | 01000);
 }
 for (i = 0; i < cmd_count ; ++i)
 {
  if (i < cmd_count-1)
  {
   pipe(fds);
   cmd[i].outfd = fds[1];
   cmd[i+1].infd = fds[0];
  }
  forkexec(i);
  if((fd = cmd[i].infd) != 0)
   close(fd);
  if((fd = cmd[i].outfd) != 1)
   close(fd);
 }
 if (backgnd == 0)
 {
  while (wait(((void *)0)) != lastpid)
   ;
 }
}

canonical_original_code:
void execute_disk_command()
{
 int i;
 int fds[2];
 int fd;
 if (backgnd)
  signal(17, ((void (*)(int)) 1));
 else
  signal(17, ((void (*)(int)) 0));
 if (infile[0] != '\0')
  cmd[0].infd = open(infile, 00);
 if (outfile[0] != '\0')
 {
  if (append)
   cmd[cmd_count-1].outfd = open(outfile, 01 | 0100 | 02000);
  else
   cmd[cmd_count-1].outfd = open(outfile, 01 | 0100 | 01000);
 }
 for (i = 0; i < cmd_count ; ++i)
 {
  if (i < cmd_count-1)
  {
   pipe(fds);
   cmd[i].outfd = fds[1];
   cmd[i+1].infd = fds[0];
  }
  forkexec(i);
  if((fd = cmd[i].infd) != 0)
   close(fd);
  if((fd = cmd[i].outfd) != 1)
   close(fd);
 }
 if (backgnd == 0)
 {
  while (wait(((void *)0)) != lastpid)
   ;
 }
}

variable_types:
fds
int [2]

variable_types: fd int


decompiled_code:
void __noreturn do_exit()
{
puts("exit");
exit(0);
}

canonical_decompiled_code:
void __noreturn func20()
{
puts("exit");
exit(0);
}

original_code:
void do_exit(void)
{
 printf("exit\n");
 exit(0);
}

canonical_original_code:
void do_exit()
{
 printf("exit\n");
 exit(0);
}


builtins

decompiled_code:
__int64 builtins()
{
__int64 result; // rax
int v1; // eax

if ( !builtins_arr )
return 0LL;
result = check((char *)builtins_arr);
if ( (_DWORD)result )
{
v1 = 0;
}
else
{
if ( !qword_4040D0 )
return result;
check((char *)qword_4040D0);
v1 = 1;
}
(*(&off_4040C8 + 2 * v1))();
return 1LL;
}

canonical_decompiled_code:
__int64 func21()
{
__int64 result; // rax
int v1; // eax

if ( !builtins_arr )
return 0LL;
result = func11((char *)builtins_arr);
if ( (_DWORD)result )
{
v1 = 0;
}
else
{
if ( !qword_4040D0 )
return result;
func11((char *)qword_4040D0);
v1 = 1;
}
(*(&off_4040C8 + 2 * v1))();
return 1LL;
}

original_code:
int builtins(void)
{
 int i = 0;
 int found = 0;
 while(builtins_arr[i].name != ((void *)0))
 {
  if(check(builtins_arr[i].name))
  {
   builtins_arr[i].handler();
   found = 1;
   break;
  }
  i++;
 }
 return found;
}

canonical_original_code:
int builtins()
{
 int i = 0;
 int found = 0;
 while(builtins_arr[i].name != ((void *)0))
 {
  if(check(builtins_arr[i].name))
  {
   builtins_arr[i].handler();
   found = 1;
   break;
  }
  i++;
 }
 return found;
}

variable_types: found int

return_type: int


printsigset

decompiled_code:
int __fastcall printsigset(sigset_t *set)
{
int i; // ebx

for ( i = 1; i != 65; ++i )
{
if ( sigismember(set, i) )
putchar(49);
else
putchar(48);
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(sigset_t *set)
{
int i; // ebx

for ( i = 1; i != 65; ++i )
{
if ( sigismember(set, i) )
putchar(49);
else
putchar(48);
}
return putchar(10);
}

original_code:
void printsigset(sigset_t* set)
{
 int i;
 for (i = 1; i < (64 + 1); i++) {
  if (sigismember(set, i))
    putchar('1');
  else
   putchar('0');
 }
 printf("\n");
}

canonical_original_code:
void printsigset(struct __sigset_t *set)
{
 int i;
 for (i = 1; i < (64 + 1); i++) {
  if (sigismember(set, i))
    putchar('1');
  else
   putchar('0');
 }
 printf("\n");
}

variable_types: struct __sigset_t { unsigned long __val[-1]; } *


decompiled_code:
int __fastcall set_flag(int fd, int a2)
{
int v2; // eax
int result; // eax

v2 = fcntl(fd, 3, 0LL);
if ( v2 == -1 )
{
perror("fcntl get flag error");
exit(1);
}
result = fcntl(fd, 4, a2 | (unsigned int)v2);
if ( result < 0 )
{
perror("fcntl set flag error");
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(int fd, int a2)
{
int v2; // eax
int result; // eax

v2 = fcntl(fd, 3, 0LL);
if ( v2 == -1 )
{
perror("fcntl get flag error");
exit(1);
}
result = fcntl(fd, 4, a2 | (unsigned int)v2);
if ( result < 0 )
{
perror("fcntl set flag error");
exit(1);
}
return result;
}

original_code:
void set_flag(int fd, int flags)
{
 int val;
 val = fcntl(fd, 3, 0);
 if (val == -1)
  do { perror("fcntl get flag error"); exit(1); } while(0);
 val |= flags;
 if (fcntl(fd, 4, val) < 0)
  do { perror("fcntl set flag error"); exit(1); } while(0);
}

variable_types: flags int

variable_types: val int


decompiled_code:
int __fastcall clr_flag(int fd, int a2)
{
int v2; // eax
int result; // eax

v2 = fcntl(fd, 3, 0LL);
if ( v2 == -1 )
{
perror("fcntl get flag error");
exit(1);
}
result = fcntl(fd, 4, ~a2 & (unsigned int)v2);
if ( result < 0 )
{
perror("fcntl set flag error");
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(int fd, int a2)
{
int v2; // eax
int result; // eax

v2 = fcntl(fd, 3, 0LL);
if ( v2 == -1 )
{
perror("fcntl get flag error");
exit(1);
}
result = fcntl(fd, 4, ~a2 & (unsigned int)v2);
if ( result < 0 )
{
perror("fcntl set flag error");
exit(1);
}
return result;
}

original_code:
void clr_flag(int fd, int flags)
{
 int val;
 val = fcntl(fd, 3, 0);
 if (val == -1)
  do { perror("fcntl get flag error"); exit(1); } while(0);
 val &= ~flags;
 if (fcntl(fd, 4, val) < 0)
  do { perror("fcntl set flag error"); exit(1); } while(0);
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4[2]; // [rsp+0h] [rbp-408h] BYREF
char v5[1008]; // [rsp+10h] [rbp-3F8h] BYREF

v4[0] = 0LL;
v4[1] = 0LL;
memset(v5, 0, sizeof(v5));
set_flag(0, 2048);
if ( (unsigned int)read(0, v4, 0x400uLL) == -1 )
{
perror("read error");
exit(1);
}
printf("buf=%s\n", (const char *)v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4[2]; // [rsp+0h] [rbp-408h] BYREF
char v5[1008]; // [rsp+10h] [rbp-3F8h] BYREF

v4[0] = 0LL;
v4[1] = 0LL;
memset(v5, 0, sizeof(v5));
func7(0, 2048);
if ( (unsigned int)read(0, v4, 0x400uLL) == -1 )
{
perror("read error");
exit(1);
}
printf("buf=%s\n", (const char *)v4);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 char buf[1024] = {0};
 int ret;
 set_flag(0, 04000);
 ret = read(0, buf, 1024);
 if (ret == -1)
  do { perror("read error"); exit(1); } while(0);
 printf("buf=%s\n", buf);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
buf
char [1024]

variable_types: ret int


filetype

decompiled_code:
__int64 __fastcall filetype(__int64 a1)
{
unsigned int v1; // eax

printf("Filetype:");
v1 = *(_DWORD *)(a1 + 24) & 0xF000;
if ( v1 == 24576 )
{
puts("block device");
return 1LL;
}
if ( v1 > 0x6000 )
{
switch ( v1 )
{
case 0xA000u:
puts("symbolic link");
return 0LL;
case 0xC000u:
puts("socket");
return 0LL;
case 0x8000u:
puts("regular file");
return 0LL;
}
}
else
{
switch ( v1 )
{
case 0x2000u:
puts("character device");
return 1LL;
case 0x4000u:
puts("directory");
return 0LL;
case 0x1000u:
puts("FIFO");
return 0LL;
}
}
puts("unknown file type");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
unsigned int v1; // eax

printf("Filetype:");
v1 = *(_DWORD *)(a1 + 24) & 0xF000;
if ( v1 == 24576 )
{
puts("block device");
return 1LL;
}
if ( v1 > 0x6000 )
{
switch ( v1 )
{
case 0xA000u:
puts("symbolic link");
return 0LL;
case 0xC000u:
puts("socket");
return 0LL;
case 0x8000u:
puts("regular file");
return 0LL;
}
}
else
{
switch ( v1 )
{
case 0x2000u:
puts("character device");
return 1LL;
case 0x4000u:
puts("directory");
return 0LL;
case 0x1000u:
puts("FIFO");
return 0LL;
}
}
puts("unknown file type");
return 0LL;
}

original_code:
int filetype(struct stat *buf)
{
    int flag = 0;
    printf("Filetype:");
    mode_t mode;
    mode = buf->st_mode;
    switch (mode & 0170000) {
    case 0140000:
  printf("socket\n");
  break;
    case 0120000:
  printf("symbolic link\n");
  break;
    case 0100000:
  printf("regular file\n");
  break;
    case 0060000:
  printf("block device\n");
  flag = 1;
  break;
    case 0040000:
  printf("directory\n");
  break;
    case 0020000:
  printf("character device\n");
  flag = 1;
  break;
    case 0010000:
  printf("FIFO\n");
  break;
    default:
  printf("unknown file type\n");
  break;
    }
    return flag;
}

canonical_original_code:
int filetype(struct stat *buf)
{
    int flag = 0;
    printf("Filetype:");
    unsigned int mode;
    mode = buf->st_mode;
    switch (mode & 0170000) {
    case 0140000:
  printf("socket\n");
  break;
    case 0120000:
  printf("symbolic link\n");
  break;
    case 0100000:
  printf("regular file\n");
  break;
    case 0060000:
  printf("block device\n");
  flag = 1;
  break;
    case 0040000:
  printf("directory\n");
  break;
    case 0020000:
  printf("character device\n");
  flag = 1;
  break;
    case 0010000:
  printf("FIFO\n");
  break;
    default:
  printf("unknown file type\n");
  break;
    }
    return flag;
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; } *

variable_types: flag int

variable_types:
mode
unsigned int

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


fileperm

variable_types:
perm
char []

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4; // [rsp+5h] [rbp-A3h] BYREF
__int16 v5; // [rsp+Dh] [rbp-9Bh]
char v6; // [rsp+Fh] [rbp-99h]
struct stat stat_buf; // [rsp+10h] [rbp-98h] BYREF

if ( argc != 2 )
{
fprintf(stderr, "Usage %s file\n", *argv);
exit(1);
}
printf("Filename:%s\n", argv[1]);
if ( (unsigned int)lstat((char *)argv[1], &stat_buf) == -1 )
{
perror("stat error");
exit(1);
}
printf("file in Dev number:major %d, minor %d\n", BYTE1(stat_buf.st_dev), LOBYTE(stat_buf.st_dev));
printf("File inode:%d\n", LODWORD(stat_buf.st_ino));
if ( (unsigned int)filetype((__int64)&stat_buf) )
printf("Device number:major %d, minor %d\n", BYTE1(stat_buf.st_rdev), LOBYTE(stat_buf.st_rdev));
v4 = 0LL;
v5 = 0;
v6 = 0;
fileperm((__int64)&stat_buf, (char *)&v4);
printf("File permission bits=%o %s\n", stat_buf.st_mode & 0x1FF, (const char *)&v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4; // [rsp+5h] [rbp-A3h] BYREF
__int16 v5; // [rsp+Dh] [rbp-9Bh]
char v6; // [rsp+Fh] [rbp-99h]
struct stat stat_buf; // [rsp+10h] [rbp-98h] BYREF

if ( argc != 2 )
{
fprintf(stderr, "Usage %s file\n", *argv);
exit(1);
}
printf("Filename:%s\n", argv[1]);
if ( (unsigned int)func11((char *)argv[1], &stat_buf) == -1 )
{
perror("stat error");
exit(1);
}
printf("file in Dev number:major %d, minor %d\n", BYTE1(stat_buf.st_dev), LOBYTE(stat_buf.st_dev));
printf("File inode:%d\n", LODWORD(stat_buf.st_ino));
if ( (unsigned int)func7((__int64)&stat_buf) )
printf("Device number:major %d, minor %d\n", BYTE1(stat_buf.st_rdev), LOBYTE(stat_buf.st_rdev));
v4 = 0LL;
v5 = 0;
v6 = 0;
func8((__int64)&stat_buf, (char *)&v4);
printf("File permission bits=%o %s\n", stat_buf.st_mode & 0x1FF, (const char *)&v4);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 if (argc != 2) {
     fprintf(stderr, "Usage %s file\n", argv[0]);
     exit(1);
 }
 printf("Filename:%s\n", argv[1]);
 struct stat sbuf;
 if (lstat(argv[1], &sbuf) == -1)
     do { perror("stat error"); exit(1); } while(0);
 printf("file in Dev number:major %d, minor %d\n",
        (int)((unsigned short)sbuf.st_dev >> 8), (int)((unsigned short)sbuf.st_dev & 0xFF));
 printf("File inode:%d\n", (int) sbuf.st_ino);
 if (filetype(&sbuf)) {
     printf("Device number:major %d, minor %d\n",
     (int)((unsigned short)sbuf.st_rdev >> 8), (int)((unsigned short)sbuf.st_rdev & 0xFF));
 }
 char perm[11] = {0};
 fileperm(&sbuf, perm);
 printf("File permission bits=%o %s\n", sbuf.st_mode & 0777, perm);
 return 0;
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types:
perm
char [11]


decompiled_code:
__int64 __fastcall setup_daemon(int a1, int a2)
{
__pid_t v2; // eax

v2 = fork();
if ( v2 == -1 )
{
perror("fork error");
exit(1);
}
if ( v2 > 0 )
exit(0);
setsid();
if ( !a1 )
chdir("/");
if ( !a2 )
{
close(0);
close(1);
close(2);
open("/dev/null", 2);
dup(0);
dup(0);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2)
{
__pid_t v2; // eax

v2 = fork();
if ( v2 == -1 )
{
perror("fork error");
exit(1);
}
if ( v2 > 0 )
exit(0);
setsid();
if ( !a1 )
chdir("/");
if ( !a2 )
{
close(0);
close(1);
close(2);
open("/dev/null", 2);
dup(0);
dup(0);
}
return 0LL;
}

original_code:
int setup_daemon(int nochdir, int noclose)
{
 pid_t pid;
 pid = fork();
 if (pid == -1)
  do { perror("fork error"); exit(1); } while(0);
 if (pid > 0)
  exit(0);
 setsid();
 if (nochdir == 0)
  chdir("/");
 if (noclose == 0) {
  int i;
  for (i = 0; i < 3; ++i)
   close(i);
  open("/dev/null", 02);
  dup(0);
  dup(0);
 }
 return 0;
}

canonical_original_code:
int setup_daemon(int nochdir, int noclose)
{
 int pid;
 pid = fork();
 if (pid == -1)
  do { perror("fork error"); exit(1); } while(0);
 if (pid > 0)
  exit(0);
 setsid();
 if (nochdir == 0)
  chdir("/");
 if (noclose == 0) {
  int i;
  for (i = 0; i < 3; ++i)
   close(i);
  open("/dev/null", 02);
  dup(0);
  dup(0);
 }
 return 0;
}

variable_types: nochdir int

variable_types: noclose int

variable_types: pid int

variable_types: i int


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
setup_daemon(0, 0);
puts("test ... ");
while ( 1 )
;
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
func7(0, 0);
puts("test ... ");
while ( 1 )
;
}

original_code:
int main(int argc, char *argv[])
{
 setup_daemon(0, 0);
 printf("test ... \n");
 for(;;) ;
 return 0;
}


decompiled_code:
int unsafe_func()
{
return printf("%d %d\n", (unsigned int)g_data, (unsigned int)dword_40405C);
}

canonical_decompiled_code:
int func7()
{
return printf("%d %d\n", (unsigned int)g_data, (unsigned int)dword_40405C);
}

original_code:
void unsafe_func(void)
{
 printf("%d %d\n", g_data.a, g_data.b);
}

canonical_original_code:
void unsafe_func()
{
 printf("%d %d\n", g_data.a, g_data.b);
}


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
if ( signal(14, handler) != (__sighandler_t)-1LL )
{
g_data = 0;
dword_40405C = 0;
alarm(1u);
while ( 1 )
;
}
perror("signal error");
exit(1);
}

original_code:
int main(int argc, char *argv[])
{
 TEST zeros = {0, 0};
 TEST ones = {1, 1};
 if (signal(14, handler) == ((__sighandler_t) -1))
  do { perror("signal error"); exit(1); } while(0);
 g_data = zeros;
 alarm(1);
 for (; ;) {
  g_data = zeros;
  g_data = ones;
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct TEST zeros = {0, 0};
 struct TEST ones = {1, 1};
 if (signal(14, handler) == ((__sighandler_t) -1))
  do { perror("signal error"); exit(1); } while(0);
 g_data = zeros;
 alarm(1);
 for (; ;) {
  g_data = zeros;
  g_data = ones;
 }
 return 0;
}

variable_types:
zeros
struct TEST { int a; int b; }

variable_types:
ones
struct TEST { int a; int b; }


handler

decompiled_code:
void __fastcall handler(unsigned int a1)
{
printf("recv a sig=%d\n", a1);
unsafe_func();
alarm(1u);
}

canonical_decompiled_code:
void __fastcall func8(unsigned int a1)
{
printf("recv a sig=%d\n", a1);
func7();
alarm(1u);
}

original_code:
void handler(int sig)
{
 printf("recv a sig=%d\n", sig);
 unsafe_func();
 alarm(1);
}

variable_types: sig int


main

decompiled_code:
// local variable allocation has failed, the output may be wrong!
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
__int16 v4; // bp
unsigned int v5; // eax
int v6; // ebx
__int64 *v7; // r12
int v8; // ebp
int v9; // eax
char *endptr; // [rsp+8h] [rbp-70h] BYREF
pthread_t v12; // [rsp+10h] [rbp-68h] BYREF
pthread_t newthread; // [rsp+18h] [rbp-60h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-58h] BYREF
__int64 v15; // [rsp+38h] [rbp-40h] BYREF
__int64 arg[2]; // [rsp+40h] [rbp-38h] BYREF
int v17; // [rsp+50h] [rbp-28h]

arg[0] = 0LL;
arg[1] = 0LL;
v17 = 0;
v15 = -1LL;
if ( argc > 2 )
{
puts("servidor: error argumento incorrecto");
}
else
{
v3 = argv;
v4 = 8000;
if ( argc == 2
&& ((*(_QWORD *)&argc = argv[1],
argv = (const char **)&endptr,
v9 = strtol(*(const char **)&argc, &endptr, 10),
v4 = v9,
v3[1] == endptr)
|| !v9) )
{
puts("servidor: error argumento incorrecto");
}
else
{
descriptores = crear_lista_descriptores(*(_QWORD *)&argc, argv, envp);
pthread_barrier_init(&barrier, 0LL, 5u);
bitmap_worker = (__int64)calloc(5uLL, 1uLL);
v5 = time(0LL);
srand(v5);
v6 = socket(2, 1, 0);
if ( v6 < 0 )
{
fwrite("ECHOSERV: Error creating listening socket.\n", 1uLL, 0x2BuLL, stderr);
}
else
{
*(_QWORD *)&addr.sa_data[6] = 0LL;
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[2] = (unsigned int)_bswap_32(0);
*(_WORD *)addr.sa_data = _bswap_16(v4);
if ( bind(v6, &addr, 0x10u) < 0 )
{
fwrite("ECHOSERV: Error calling bind()\n", 1uLL, 0x1FuLL, stderr);
}
else if ( listen(v6, 10) < 0 )
{
fwrite("ECHOSERV: Error calling listen()\n", 1uLL, 0x21uLL, stderr);
}
else
{
v7 = arg;
v8 = 0;
do
{
*(_DWORD *)v7 = ++v8;
pthread_create(&newthread, 0LL, (void *(*)(void *))&start_routine, v7);
v7 = (__int64 *)((char *)v7 + 4);
}
while ( v8 != 5 );
puts("Servidor aceptando clientes");
while ( 1 )
{
v15 = accept(v6, 0LL, 0LL);
if ( v15 < 0 )
break;
pthread_create(&v12, 0LL, (void *(*)(void *))&proceso_socket, &v15);
}
fwrite("ECHOSERV: Error calling accept()\n", 1uLL, 0x21uLL, stderr);
}
}
}
}
return -1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
__int16 v4; // bp
unsigned int v5; // eax
int v6; // ebx
__int64 *v7; // r12
int v8; // ebp
int v9; // eax
char *endptr; // [rsp+8h] [rbp-70h] BYREF
pthread_t v12; // [rsp+10h] [rbp-68h] BYREF
pthread_t newthread; // [rsp+18h] [rbp-60h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-58h] BYREF
__int64 v15; // [rsp+38h] [rbp-40h] BYREF
__int64 arg[2]; // [rsp+40h] [rbp-38h] BYREF
int v17; // [rsp+50h] [rbp-28h]

arg[0] = 0LL;
arg[1] = 0LL;
v17 = 0;
v15 = -1LL;
if ( argc > 2 )
{
puts("servidor: error argumento incorrecto");
}
else
{
v3 = argv;
v4 = 8000;
if ( argc == 2
&& ((*(_QWORD *)&argc = argv[1],
argv = (const char **)&endptr,
v9 = strtol(*(const char **)&argc, &endptr, 10),
v4 = v9,
v3[1] == endptr)
|| !v9) )
{
puts("servidor: error argumento incorrecto");
}
else
{
descriptores = crear_lista_descriptores(*(_QWORD *)&argc, argv, envp);
pthread_barrier_init(&barrier, 0LL, 5u);
bitmap_worker = (__int64)calloc(5uLL, 1uLL);
v5 = time(0LL);
srand(v5);
v6 = socket(2, 1, 0);
if ( v6 < 0 )
{
fwrite("ECHOSERV: Error creating listening socket.\n", 1uLL, 0x2BuLL, stderr);
}
else
{
*(_QWORD *)&addr.sa_data[6] = 0LL;
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[2] = (unsigned int)func0(0);
*(_WORD *)addr.sa_data = func1(v4);
if ( bind(v6, &addr, 0x10u) < 0 )
{
fwrite("ECHOSERV: Error calling bind()\n", 1uLL, 0x1FuLL, stderr);
}
else if ( listen(v6, 10) < 0 )
{
fwrite("ECHOSERV: Error calling listen()\n", 1uLL, 0x21uLL, stderr);
}
else
{
v7 = arg;
v8 = 0;
do
{
*(_DWORD *)v7 = ++v8;
pthread_create(&newthread, 0LL, (void *(*)(void *))&start_routine, v7);
v7 = (__int64 *)((char *)v7 + 4);
}
while ( v8 != 5 );
puts("Servidor aceptando clientes");
while ( 1 )
{
v15 = accept(v6, 0LL, 0LL);
if ( v15 < 0 )
break;
pthread_create(&v12, 0LL, (void *(*)(void *))&proceso_socket, &v15);
}
fwrite("ECHOSERV: Error calling accept()\n", 1uLL, 0x21uLL, stderr);
}
}
}
}
return -1;
}

original_code:
int main(int argc, char **argv)
{
  int i,list_s;
  int num[5] = {0};
  long conn_s = -1;
  struct sockaddr_in servaddr;
  pthread_t work, clientes;
  char * pEnd;
  unsigned port;
  if(argc > 2) {
    printf("servidor: error argumento incorrecto\n");
    return -1;
  }
  if(argc == 2) {
    port = strtol(argv[1],&pEnd,10);
    if ((pEnd == argv[1]) || (port <= 0)) {
      printf("servidor: error argumento incorrecto\n");
      return -1;
    }
  }
  else
    port = 8000;
  descriptores = crear_lista_descriptores();
  pthread_barrier_init(&barrier,((void *)0),5);
  bitmap_worker = (char *) calloc(5, sizeof(char));
  srand(time(((void *)0)));
  if((list_s = socket(2, SOCK_STREAM, 0)) < 0 ) {
    fprintf(stderr, "ECHOSERV: Error creating listening socket.\n");
    return -1;
  }
  memset(&servaddr, 0, sizeof(servaddr));
  servaddr.sin_family = 2;
  servaddr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
  servaddr.sin_port = htons(port);
  if(bind(list_s, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ) {
    fprintf(stderr, "ECHOSERV: Error calling bind()\n");
    return -1;
  }
  if( listen(list_s, 10) < 0 ) {
    fprintf(stderr, "ECHOSERV: Error calling listen()\n");
    return -1;
  }
  for(i=0;i<5;i++) {
    num[i] = i+1;
    pthread_create(&work, ((void *)0), fs, num+i);
  }
  printf("Servidor aceptando clientes\n");
  while (1) {
    if((conn_s = accept(list_s, ((void *)0), ((void *)0)) ) < 0 ) {
      fprintf(stderr, "ECHOSERV: Error calling accept()\n");
      return -1;
    }
    pthread_create(&clientes, ((void *)0), proceso_socket,(void *)&conn_s);
  }
  pthread_join(clientes, ((void *)0));
  close(list_s);
  pthread_barrier_destroy(&barrier);
  return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
  int i; int list_s;
  int num[5] = {0};
  long conn_s = -1;
  struct sockaddr_in servaddr;
  unsigned long work; unsigned long clientes;
  char *pEnd;
  unsigned int port;
  if(argc > 2) {
    printf("servidor: error argumento incorrecto\n");
    return -1;
  }
  if(argc == 2) {
    port = strtol(argv[1],&pEnd,10);
    if ((pEnd == argv[1]) || (port <= 0)) {
      printf("servidor: error argumento incorrecto\n");
      return -1;
    }
  }
  else
    port = 8000;
  descriptores = crear_lista_descriptores();
  pthread_barrier_init(&barrier,((void *)0),5);
  bitmap_worker = (char *) calloc(5, sizeof(char));
  srand(time(((void *)0)));
  if((list_s = socket(2, SOCK_STREAM, 0)) < 0 ) {
    fprintf(stderr, "ECHOSERV: Error creating listening socket.\n");
    return -1;
  }
  memset(&servaddr, 0, sizeof(servaddr));
  servaddr.sin_family = 2;
  servaddr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
  servaddr.sin_port = htons(port);
  if(bind(list_s, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ) {
    fprintf(stderr, "ECHOSERV: Error calling bind()\n");
    return -1;
  }
  if( listen(list_s, 10) < 0 ) {
    fprintf(stderr, "ECHOSERV: Error calling listen()\n");
    return -1;
  }
  for(i=0;i<5;i++) {
    num[i] = i+1;
    pthread_create(&work, ((void *)0), fs, num+i);
  }
  printf("Servidor aceptando clientes\n");
  while (1) {
    if((conn_s = accept(list_s, ((void *)0), ((void *)0)) ) < 0 ) {
      fprintf(stderr, "ECHOSERV: Error calling accept()\n");
      return -1;
    }
    pthread_create(&clientes, ((void *)0), proceso_socket,(void *)&conn_s);
  }
  pthread_join(clientes, ((void *)0));
  close(list_s);
  pthread_barrier_destroy(&barrier);
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
num
int [5]

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types:
work
unsigned long

variable_types:
clientes
unsigned long

variable_types:
pEnd
char *

variable_types:
port
unsigned int

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


decompiled_code:
__int64 __fastcall nuevo_archivo(__int64 a1, const char *a2)
{
char **v2; // rax
char **v3; // rbx
char *v4; // r12
char *v5; // rax

v2 = (char **)malloc(0x28uLL);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = v2;
v4 = (char *)calloc(0x200uLL, 1uLL);
*v3 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = (char *)calloc(0x200uLL, 1uLL);
v3[1] = v5;
if ( !v5 )
return 0xFFFFFFFFLL;
strcpy(v4, a2);
*((_DWORD *)v3 + 4) = 0;
*((_DWORD *)v3 + 5) = 0;
*((_DWORD *)v3 + 6) = 0;
v3[4] = *(char **)a1;
*(_QWORD *)a1 = v3;
++*(_DWORD *)(a1 + 8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2)
{
char **v2; // rax
char **v3; // rbx
char *v4; // r12
char *v5; // rax

v2 = (char **)malloc(0x28uLL);
if ( !v2 )
return 0xFFFFFFFFLL;
v3 = v2;
v4 = (char *)calloc(0x200uLL, 1uLL);
*v3 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = (char *)calloc(0x200uLL, 1uLL);
v3[1] = v5;
if ( !v5 )
return 0xFFFFFFFFLL;
strcpy(v4, a2);
*((_DWORD *)v3 + 4) = 0;
*((_DWORD *)v3 + 5) = 0;
*((_DWORD *)v3 + 6) = 0;
v3[4] = *(char **)a1;
*(_QWORD *)a1 = v3;
++*(_DWORD *)(a1 + 8);
return 0LL;
}

original_code:
int nuevo_archivo(ListaArchivos *lista, char *nombre)
{
  Archivo *ptr;
  if((ptr = (Archivo*)malloc(sizeof(Archivo)))== ((void *)0))
    return -1;
  if ((ptr->nombre = (char *)calloc(512, sizeof (char))) == ((void *)0))
    return -1;
  if ((ptr->texto = (char *)calloc(512, sizeof (char))) == ((void *)0))
    return -1;
  strcpy(ptr->nombre, nombre);
  ptr->estado = 0;
  ptr->indice = 0;
  ptr->tam = 0;
  ptr->proximo = lista->inicio;
  lista->inicio = ptr;
  lista->t++;
  return 0;
}

canonical_original_code:
int nuevo_archivo(struct lista_ *lista, char *nombre)
{
  struct archivo_ *ptr;
  if((ptr = (struct archivo_ *)malloc(sizeof(Archivo)))== ((void *)0))
    return -1;
  if ((ptr->nombre = (char *)calloc(512, sizeof (char))) == ((void *)0))
    return -1;
  if ((ptr->texto = (char *)calloc(512, sizeof (char))) == ((void *)0))
    return -1;
  strcpy(ptr->nombre, nombre);
  ptr->estado = 0;
  ptr->indice = 0;
  ptr->tam = 0;
  ptr->proximo = lista->inicio;
  lista->inicio = ptr;
  lista->t++;
  return 0;
}

variable_types: struct lista_ { struct archivo_ { char *nombre; char *texto; int estado; int indice; int tam; struct archivo_ *proximo; } *inicio; int t; char worker; } *

variable_types:
nombre
char *

user_defined_types: struct lista_ { struct archivo_ *inicio; int t; char worker; }


original_code:
int eliminar_archivo(ListaArchivos *lista, char *nombre)
{
  Archivo *ptr = lista->inicio;
  Archivo *tmp = ((void *)0);
  int existe = 0;
  while(ptr != ((void *)0)) {
    if(strcmp(nombre, ptr->nombre) == 0) {
      existe = 1;
      break;
    }
    else {
      tmp = ptr;
      ptr = ptr->proximo;
    }
  }
  if(existe == 0)
    return -1;
  if(lista->t==1) {
    lista->inicio = ((void *)0);
    lista->t--;
  }
  else {
    if(ptr->proximo == ((void *)0)) {
      tmp->proximo = ((void *)0);
      lista->t--;
    } else if(tmp == ((void *)0)) {
      lista->inicio = lista->inicio->proximo;
      lista->t--;
    } else {
      tmp->proximo = tmp->proximo->proximo;
      lista->t--;
    }
  }
  free(ptr->nombre);
  free(ptr->texto);
  free(ptr);
  return 0;
}

canonical_original_code:
int eliminar_archivo(struct lista_ *lista, char *nombre)
{
  struct archivo_ *ptr = lista->inicio;
  struct archivo_ *tmp = ((void *)0);
  int existe = 0;
  while(ptr != ((void *)0)) {
    if(strcmp(nombre, ptr->nombre) == 0) {
      existe = 1;
      break;
    }
    else {
      tmp = ptr;
      ptr = ptr->proximo;
    }
  }
  if(existe == 0)
    return -1;
  if(lista->t==1) {
    lista->inicio = ((void *)0);
    lista->t--;
  }
  else {
    if(ptr->proximo == ((void *)0)) {
      tmp->proximo = ((void *)0);
      lista->t--;
    } else if(tmp == ((void *)0)) {
      lista->inicio = lista->inicio->proximo;
      lista->t--;
    } else {
      tmp->proximo = tmp->proximo->proximo;
      lista->t--;
    }
  }
  free(ptr->nombre);
  free(ptr->texto);
  free(ptr);
  return 0;
}

variable_types: struct archivo_ { char *nombre; char *texto; int estado; int indice; int tam; struct archivo_ *proximo; } *

variable_types: existe int


decompiled_code:
__int64 __fastcall buscar_archivo(__int64 *a1, const char *a2)
{
__int64 i; // rbx

for ( i = *a1; i; i = *(_QWORD *)(i + 32) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, const char *a2)
{
__int64 i; // rbx

for ( i = *a1; i; i = *(_QWORD *)(i + 32) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

original_code:
Archivo *buscar_archivo(ListaArchivos *lista, char *nombre)
{
  Archivo *ptr = lista->inicio;
  while(ptr != ((void *)0)) {
    if(strcmp(nombre, ptr->nombre) == 0) {
      return ptr;
    }
    ptr = ptr->proximo;
  }
  return ((void *)0);
}

canonical_original_code:
struct archivo_ *buscar_archivo(struct lista_ *lista, char *nombre)
{
  struct archivo_ *ptr = lista->inicio;
  while(ptr != ((void *)0)) {
    if(strcmp(nombre, ptr->nombre) == 0) {
      return ptr;
    }
    ptr = ptr->proximo;
  }
  return ((void *)0);
}

variable_types: struct lista_ { struct archivo_ *inicio; int t; char worker; } *

return_type: struct archivo_ { char *nombre; char *texto; int estado; int indice; int tam; struct archivo_ *proximo; } *


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

result = 0LL;
if ( !*(_DWORD *)(a1 + 16) )
{
*(_DWORD *)(a1 + 16) = 1;
result = 1LL;
}
return result;
}

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

result = 0LL;
if ( !*(_DWORD *)(a1 + 16) )
{
*(_DWORD *)(a1 + 16) = 1;
result = 1LL;
}
return result;
}

original_code:
int modificar_estado(Archivo *elem)
{
  if(elem->estado == 0) {
    elem->estado = 1;
    return 1;
  }
  return 0;
}

canonical_original_code:
int modificar_estado(struct archivo_ *elem)
{
  if(elem->estado == 0) {
    elem->estado = 1;
    return 1;
  }
  return 0;
}

user_defined_types: struct archivo_ { char *nombre; char *texto; int estado; int indice; int tam; struct archivo_ *proximo; }


decompiled_code:
void *__fastcall sacar_nueva_linea(void *src)
{
int v1; // eax
int v2; // er12
void *v3; // rbx
void *result; // rax

v1 = strlen((const char *)src);
v2 = v1 - 2;
v3 = malloc(v1 - 1);
if ( !v3 )
puts("Error al eliminar nueva linea");
result = memcpy(v3, src, v2);
*((_BYTE *)v3 + v2) = 0;
return result;
}

canonical_decompiled_code:
void *__fastcall func4(void *src)
{
int v1; // eax
int v2; // er12
void *v3; // rbx
void *result; // rax

v1 = strlen((const char *)src);
v2 = v1 - 2;
v3 = malloc(v1 - 1);
if ( !v3 )
puts("Error al eliminar nueva linea");
result = memcpy(v3, src, v2);
*((_BYTE *)v3 + v2) = 0;
return result;
}

original_code:
char *sacar_nueva_linea(char *nombre)
{
  char *copia;
  int n;
  n = strlen(nombre)-2;
  if((copia = (char *)malloc((n+1) * sizeof (char))) == ((void *)0))
    printf("Error al eliminar nueva linea\n");
  memcpy(copia, nombre, n);
  copia[n] = '\0';
  return copia;
}

variable_types:
copia
char *

variable_types: n int

return_type: char *


decompiled_code:
char *__fastcall concatenar_archivos(__int64 *a1)
{
__int64 v1; // rbx
char *v2; // rbp
const char *v4; // r12

v1 = *a1;
v2 = (char *)calloc(0x200uLL, 1uLL);
if ( !v2 )
puts(aErrorEnLaConca);
for ( ; v1; v1 = *(_QWORD *)(v1 + 32) )
{
if ( *(_QWORD *)v1 )
{
v4 = (const char *)sacar_nueva_linea(*(void **)v1);
*(_WORD *)&v2[strlen(v2)] = 32;
strcat(v2, v4);
}
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func5(__int64 *a1)
{
__int64 v1; // rbx
char *v2; // rbp
const char *v4; // r12

v1 = *a1;
v2 = (char *)calloc(0x200uLL, 1uLL);
if ( !v2 )
puts(aErrorEnLaConca);
for ( ; v1; v1 = *(_QWORD *)(v1 + 32) )
{
if ( *(_QWORD *)v1 )
{
v4 = (const char *)func4(*(void **)v1);
*(_WORD *)&v2[strlen(v2)] = 32;
strcat(v2, v4);
}
}
return v2;
}

original_code:
char* concatenar_archivos(ListaArchivos *lista)
{
  Archivo *ptr = lista->inicio;
  char *nombres, *aux;
  if((nombres = (char *) calloc(512, sizeof(char))) == ((void *)0))
    printf("Error en la concatenación de nombres de archivos\n");
  while(ptr != ((void *)0)) {
    if(ptr->nombre != ((void *)0)) {
      aux = sacar_nueva_linea(ptr->nombre);
      strcat(nombres," ");
      strcat(nombres,aux);
    }
    ptr = ptr->proximo;
  }
  return nombres;
}

canonical_original_code:
char *concatenar_archivos(struct lista_ *lista)
{
  struct archivo_ *ptr = lista->inicio;
  char *nombres; char *aux;
  if((nombres = (char *) calloc(512, sizeof(char))) == ((void *)0))
    printf("Error en la concatenación de nombres de archivos\n");
  while(ptr != ((void *)0)) {
    if(ptr->nombre != ((void *)0)) {
      aux = sacar_nueva_linea(ptr->nombre);
      strcat(nombres," ");
      strcat(nombres,aux);
    }
    ptr = ptr->proximo;
  }
  return nombres;
}

variable_types:
nombres
char *

variable_types:
aux
char *


decompiled_code:
char *__fastcall cola_cadena(void *src)
{
char *v1; // r12
char *v2; // rbx
char *v3; // rbp
const char *v4; // rax
const char *v5; // rax
char delim[2]; // [rsp+Eh] [rbp-1Ah] BYREF

v1 = (char *)src;
strcpy(delim, " ");
v2 = (char *)calloc(0x200uLL, 1uLL);
if ( !v2 )
puts("Error");
v3 = strtok(0LL, delim);
if ( !v3 )
return (char *)sacar_nueva_linea(src);
while ( 1 )
{
strcat(v2, v1);
v1 = strtok(0LL, delim);
if ( !v1 )
break;
*(_WORD *)&v2[strlen(v2)] = 32;
strcat(v2, v3);
*(_WORD *)&v2[strlen(v2)] = 32;
v3 = strtok(0LL, delim);
if ( !v3 )
{
v4 = (const char *)sacar_nueva_linea(v1);
strcat(v2, v4);
return v2;
}
}
*(_WORD *)&v2[strlen(v2)] = 32;
v5 = (const char *)sacar_nueva_linea(v3);
strcat(v2, v5);
return v2;
}

canonical_decompiled_code:
char *__fastcall func6(void *src)
{
char *v1; // r12
char *v2; // rbx
char *v3; // rbp
const char *v4; // rax
const char *v5; // rax
char delim[2]; // [rsp+Eh] [rbp-1Ah] BYREF

v1 = (char *)src;
strcpy(delim, " ");
v2 = (char *)calloc(0x200uLL, 1uLL);
if ( !v2 )
puts("Error");
v3 = strtok(0LL, delim);
if ( !v3 )
return (char *)func4(src);
while ( 1 )
{
strcat(v2, v1);
v1 = strtok(0LL, delim);
if ( !v1 )
break;
*(_WORD *)&v2[strlen(v2)] = 32;
strcat(v2, v3);
*(_WORD *)&v2[strlen(v2)] = 32;
v3 = strtok(0LL, delim);
if ( !v3 )
{
v4 = (const char *)func4(v1);
strcat(v2, v4);
return v2;
}
}
*(_WORD *)&v2[strlen(v2)] = 32;
v5 = (const char *)func4(v3);
strcat(v2, v5);
return v2;
}

original_code:
char *cola_cadena(char *token)
{
  char *buff, *buff0, *buff1, *buff2;
  char delims[] = " ";
  if((buff = (char *) calloc(512, sizeof (char))) == ((void *)0))
    printf("Error\n");
  if((buff0 = strtok(((void *)0), delims)) == ((void *)0))
    return sacar_nueva_linea(token);
  strcat(buff,token);
  buff2 = buff0;
  while((buff1 = strtok(((void *)0), delims))!= ((void *)0)) {
      strcat(buff, " ");
      strcat(buff, buff0);
      strcat(buff, " ");
    if((buff2 = strtok(((void *)0), delims)) == ((void *)0)) {
      strcat(buff,sacar_nueva_linea(buff1));
      break;
    }
    strcat(buff, buff1);
    buff0 = buff2;
  }
  if(buff1 == ((void *)0)) {
    strcat(buff, " ");
    strcat(buff,sacar_nueva_linea(buff2));
  }
  return buff;
}

canonical_original_code:
char *cola_cadena(char *token)
{
  char *buff; char *buff0; char *buff1; char *buff2;
  char delims[] = " ";
  if((buff = (char *) calloc(512, sizeof (char))) == ((void *)0))
    printf("Error\n");
  if((buff0 = strtok(((void *)0), delims)) == ((void *)0))
    return sacar_nueva_linea(token);
  strcat(buff,token);
  buff2 = buff0;
  while((buff1 = strtok(((void *)0), delims))!= ((void *)0)) {
      strcat(buff, " ");
      strcat(buff, buff0);
      strcat(buff, " ");
    if((buff2 = strtok(((void *)0), delims)) == ((void *)0)) {
      strcat(buff,sacar_nueva_linea(buff1));
      break;
    }
    strcat(buff, buff1);
    buff0 = buff2;
  }
  if(buff1 == ((void *)0)) {
    strcat(buff, " ");
    strcat(buff,sacar_nueva_linea(buff2));
  }
  return buff;
}

variable_types:
token
char *

variable_types:
buff
char *

variable_types:
delims
char []


decompiled_code:
int __fastcall imprimir_un_archivo(const char **a1)
{
const char *v2; // rdi

if ( a1 )
{
printf("Imprimir archivo:\n%p\n", a1);
puts(*a1);
v2 = a1[1];
if ( v2 )
puts(v2);
else
puts("sin texto");
printf("%d\n", *((unsigned int *)a1 + 4));
printf("%d\n", *((unsigned int *)a1 + 5));
printf("%d\n", *((unsigned int *)a1 + 6));
}
else
{
puts("sin archivo");
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(const char **a1)
{
const char *v2; // rdi

if ( a1 )
{
printf("Imprimir archivo:\n%p\n", a1);
puts(*a1);
v2 = a1[1];
if ( v2 )
puts(v2);
else
puts("sin texto");
printf("%d\n", *((unsigned int *)a1 + 4));
printf("%d\n", *((unsigned int *)a1 + 5));
printf("%d\n", *((unsigned int *)a1 + 6));
}
else
{
puts("sin archivo");
}
return putchar(10);
}

original_code:
void imprimir_un_archivo(Archivo *arch)
{
  if(arch == ((void *)0))
    printf("sin archivo\n");
  else {
    printf ("Imprimir archivo:\n%p\n", arch);
    printf ("%s\n", arch->nombre);
    if(arch->texto == ((void *)0))
      printf("sin texto\n");
    else
      printf ("%s\n", arch->texto);
    printf("%d\n", arch->estado);
    printf("%d\n", arch->indice);
    printf("%d\n", arch->tam);
  }
    printf("\n");
}

canonical_original_code:
void imprimir_un_archivo(struct archivo_ *arch)
{
  if(arch == ((void *)0))
    printf("sin archivo\n");
  else {
    printf ("Imprimir archivo:\n%p\n", arch);
    printf ("%s\n", arch->nombre);
    if(arch->texto == ((void *)0))
      printf("sin texto\n");
    else
      printf ("%s\n", arch->texto);
    printf("%d\n", arch->estado);
    printf("%d\n", arch->indice);
    printf("%d\n", arch->tam);
  }
    printf("\n");
}


decompiled_code:
int __fastcall imprimir_archivos(const char ***a1)
{
const char **v1; // rbx
int result; // eax

v1 = *a1;
if ( !*a1 )
return puts("Buffer Vacio");
do
{
printf("%p - %s\n", v1, *v1);
result = imprimir_un_archivo(v1);
v1 = (const char **)v1[4];
}
while ( v1 );
return result;
}

canonical_decompiled_code:
int __fastcall func8(const char ***a1)
{
const char **v1; // rbx
int result; // eax

v1 = *a1;
if ( !*a1 )
return puts("Buffer Vacio");
do
{
printf("%p - %s\n", v1, *v1);
result = func7(v1);
v1 = (const char **)v1[4];
}
while ( v1 );
return result;
}

original_code:
void imprimir_archivos (ListaArchivos *lista)
{
  Archivo *actual = lista->inicio;
  if(actual == ((void *)0))
    printf("Buffer Vacio\n");
  while (actual != ((void *)0)){
    printf ("%p - %s\n", actual, actual->nombre);
    imprimir_un_archivo(actual);
    actual = actual->proximo;
  }
}

canonical_original_code:
void imprimir_archivos(struct lista_ *lista)
{
  struct archivo_ *actual = lista->inicio;
  if(actual == ((void *)0))
    printf("Buffer Vacio\n");
  while (actual != ((void *)0)){
    printf ("%p - %s\n", actual, actual->nombre);
    imprimir_un_archivo(actual);
    actual = actual->proximo;
  }
}


decompiled_code:
__int64 __fastcall nuevo_descriptor(__int64 a1, const char *a2, unsigned int a3, unsigned int a4)
{
unsigned int *v7; // rax
unsigned int *v8; // rbx
char *v9; // rdi
int v10; // eax

v7 = (unsigned int *)malloc(0x20uLL);
if ( !v7 )
return 0xFFFFFFFFLL;
v8 = v7;
v9 = (char *)malloc(0x200uLL);
*(_QWORD *)v8 = v9;
if ( !v9 )
return 0xFFFFFFFFLL;
strcpy(v9, a2);
v8[2] = a3;
v8[3] = a4;
pthread_mutex_lock(&m);
v10 = fd;
v8[4] = fd;
fd = v10 + 1;
*((_QWORD *)v8 + 3) = *(_QWORD *)a1;
*(_QWORD *)a1 = v8;
++*(_DWORD *)(a1 + 8);
pthread_mutex_unlock(&m);
return v8[4];
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, const char *a2, unsigned int a3, unsigned int a4)
{
unsigned int *v7; // rax
unsigned int *v8; // rbx
char *v9; // rdi
int v10; // eax

v7 = (unsigned int *)malloc(0x20uLL);
if ( !v7 )
return 0xFFFFFFFFLL;
v8 = v7;
v9 = (char *)malloc(0x200uLL);
*(_QWORD *)v8 = v9;
if ( !v9 )
return 0xFFFFFFFFLL;
strcpy(v9, a2);
v8[2] = a3;
v8[3] = a4;
pthread_mutex_lock(&m);
v10 = fd;
v8[4] = fd;
fd = v10 + 1;
*((_QWORD *)v8 + 3) = *(_QWORD *)a1;
*(_QWORD *)a1 = v8;
++*(_DWORD *)(a1 + 8);
pthread_mutex_unlock(&m);
return v8[4];
}

original_code:
int nuevo_descriptor(ListaDescriptores *des, char *nombre, int worker_c, int worker_a)
{
  DescriptorArchivo *ptr;
  if((ptr = (DescriptorArchivo*)malloc(sizeof(DescriptorArchivo)))== ((void *)0))
    return -1;
  if ((ptr->nombre = (char *) malloc(512 * sizeof (char))) == ((void *)0))
   return -1;
  strcpy(ptr->nombre, nombre);
  ptr->worker_c = worker_c;
  ptr->worker_a = worker_a;
  pthread_mutex_lock(&m);
  ptr->fd = fd;
  fd++;
  ptr->proximo = des->inicio;
  des->inicio = ptr;
  des->t++;
  pthread_mutex_unlock(&m);
  return ptr->fd;
}

canonical_original_code:
int nuevo_descriptor(struct ListaDes *des, char *nombre, int worker_c, int worker_a)
{
  struct des_ *ptr;
  if((ptr = (struct des_ *)malloc(sizeof(DescriptorArchivo)))== ((void *)0))
    return -1;
  if ((ptr->nombre = (char *) malloc(512 * sizeof (char))) == ((void *)0))
   return -1;
  strcpy(ptr->nombre, nombre);
  ptr->worker_c = worker_c;
  ptr->worker_a = worker_a;
  pthread_mutex_lock(&m);
  ptr->fd = fd;
  fd++;
  ptr->proximo = des->inicio;
  des->inicio = ptr;
  des->t++;
  pthread_mutex_unlock(&m);
  return ptr->fd;
}

variable_types: struct ListaDes { struct des_ { char *nombre; int worker_c; int worker_a; int fd; struct des_ *proximo; } *inicio; int t; } *

user_defined_types: struct ListaDes { struct des_ *inicio; int t; }


decompiled_code:
__int64 __fastcall borrar_descriptor(_DWORD *a1, const char *a2)
{
__int64 v2; // rbx
int v3; // er14
__int64 v4; // r12
__int64 v6; // rax

v2 = *(_QWORD *)a1;
pthread_mutex_lock(&m);
v3 = a1[2];
if ( v3 == 1 )
{
*(_QWORD *)a1 = 0LL;
a1[2] = 0;
free(*(void **)v2);
free((void *)v2);
pthread_mutex_unlock(&m);
return 0LL;
}
v4 = 0LL;
if ( !v2 )
{
LABEL_8:
pthread_mutex_unlock(&m);
return 0LL;
}
while ( strcmp(a2, *(const char **)v2) )
{
v4 = v2;
if ( !*(_QWORD *)(v2 + 24) )
goto LABEL_8;
v2 = *(_QWORD *)(v2 + 24);
}
v6 = *(_QWORD *)(v2 + 24);
if ( !v6 )
{
*(_QWORD *)(v4 + 24) = 0LL;
--a1[2];
goto LABEL_12;
}
if ( v4 )
{
*(_QWORD *)(v4 + 24) = v6;
--a1[2];
LABEL_12:
free(*(void **)v2);
free((void *)v2);
pthread_mutex_unlock(&m);
return *(_QWORD *)(v4 + 24);
}
*(_QWORD *)a1 = *(_QWORD *)(*(_QWORD *)a1 + 24LL);
a1[2] = v3 - 1;
free(*(void **)v2);
free((void *)v2);
pthread_mutex_unlock(&m);
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func10(_DWORD *a1, const char *a2)
{
__int64 v2; // rbx
int v3; // er14
__int64 v4; // r12
__int64 v6; // rax

v2 = *(_QWORD *)a1;
pthread_mutex_lock(&m);
v3 = a1[2];
if ( v3 == 1 )
{
*(_QWORD *)a1 = 0LL;
a1[2] = 0;
free(*(void **)v2);
free((void *)v2);
pthread_mutex_unlock(&m);
return 0LL;
}
v4 = 0LL;
if ( !v2 )
{
LABEL_8:
pthread_mutex_unlock(&m);
return 0LL;
}
while ( strcmp(a2, *(const char **)v2) )
{
v4 = v2;
if ( !*(_QWORD *)(v2 + 24) )
goto LABEL_8;
v2 = *(_QWORD *)(v2 + 24);
}
v6 = *(_QWORD *)(v2 + 24);
if ( !v6 )
{
*(_QWORD *)(v4 + 24) = 0LL;
--a1[2];
goto LABEL_12;
}
if ( v4 )
{
*(_QWORD *)(v4 + 24) = v6;
--a1[2];
LABEL_12:
free(*(void **)v2);
free((void *)v2);
pthread_mutex_unlock(&m);
return *(_QWORD *)(v4 + 24);
}
*(_QWORD *)a1 = *(_QWORD *)(*(_QWORD *)a1 + 24LL);
a1[2] = v3 - 1;
free(*(void **)v2);
free((void *)v2);
pthread_mutex_unlock(&m);
return *(_QWORD *)a1;
}

original_code:
DescriptorArchivo *borrar_descriptor(ListaDescriptores *des, char *nombre)
{
  DescriptorArchivo *ptr = des->inicio;
  DescriptorArchivo *tmp = ((void *)0);
  pthread_mutex_lock(&m);
  if(des->t == 1) {
    des->inicio = ((void *)0);
    des->t--;
    free(ptr->nombre);
    free(ptr);
    pthread_mutex_unlock(&m);
    return ((void *)0);
  }
  while(ptr != ((void *)0)) {
    if(strcmp(nombre, ptr->nombre) == 0) {
      if(ptr->proximo == ((void *)0)) {
        tmp->proximo = ((void *)0);
        des->t--;
      }
      else if(tmp == ((void *)0)) {
        des->inicio = des->inicio->proximo;
        des->t--;
        free(ptr->nombre);
        free(ptr);
        pthread_mutex_unlock(&m);
        return des->inicio;
      }
      else {
        tmp->proximo = ptr->proximo;
        des->t--;
      }
      free(ptr->nombre);
      free(ptr);
      pthread_mutex_unlock(&m);
      return tmp->proximo;
    }
    else {
      tmp = ptr;
      ptr = ptr->proximo;
    }
  }
  pthread_mutex_unlock(&m);
  return ((void *)0);
}

canonical_original_code:
struct des_ *borrar_descriptor(struct ListaDes *des, char *nombre)
{
  struct des_ *ptr = des->inicio;
  struct des_ *tmp = ((void *)0);
  pthread_mutex_lock(&m);
  if(des->t == 1) {
    des->inicio = ((void *)0);
    des->t--;
    free(ptr->nombre);
    free(ptr);
    pthread_mutex_unlock(&m);
    return ((void *)0);
  }
  while(ptr != ((void *)0)) {
    if(strcmp(nombre, ptr->nombre) == 0) {
      if(ptr->proximo == ((void *)0)) {
        tmp->proximo = ((void *)0);
        des->t--;
      }
      else if(tmp == ((void *)0)) {
        des->inicio = des->inicio->proximo;
        des->t--;
        free(ptr->nombre);
        free(ptr);
        pthread_mutex_unlock(&m);
        return des->inicio;
      }
      else {
        tmp->proximo = ptr->proximo;
        des->t--;
      }
      free(ptr->nombre);
      free(ptr);
      pthread_mutex_unlock(&m);
      return tmp->proximo;
    }
    else {
      tmp = ptr;
      ptr = ptr->proximo;
    }
  }
  pthread_mutex_unlock(&m);
  return ((void *)0);
}

variable_types: struct ListaDes { struct des_ *inicio; int t; } *

variable_types: struct des_ { char *nombre; int worker_c; int worker_a; int fd; struct des_ *proximo; } *


decompiled_code:
__int64 __fastcall buscar_descriptor(__int64 *a1, const char *a2, int a3, int a4)
{
__int64 v6; // rbx

v6 = *a1;
pthread_mutex_lock(&m);
if ( a4 )
{
if ( v6 )
{
while ( *(_DWORD *)(v6 + 16) != a3 )
{
v6 = *(_QWORD *)(v6 + 24);
if ( !v6 )
goto LABEL_9;
}
goto LABEL_11;
}
}
else if ( v6 )
{
while ( strcmp(a2, *(const char **)v6) )
{
v6 = *(_QWORD *)(v6 + 24);
if ( !v6 )
goto LABEL_9;
}
LABEL_11:
pthread_mutex_unlock(&m);
return v6;
}
LABEL_9:
pthread_mutex_unlock(&m);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 *a1, const char *a2, int a3, int a4)
{
__int64 v6; // rbx

v6 = *a1;
pthread_mutex_lock(&m);
if ( a4 )
{
if ( v6 )
{
while ( *(_DWORD *)(v6 + 16) != a3 )
{
v6 = *(_QWORD *)(v6 + 24);
if ( !v6 )
goto LABEL_9;
}
goto LABEL_11;
}
}
else if ( v6 )
{
while ( strcmp(a2, *(const char **)v6) )
{
v6 = *(_QWORD *)(v6 + 24);
if ( !v6 )
goto LABEL_9;
}
LABEL_11:
pthread_mutex_unlock(&m);
return v6;
}
LABEL_9:
pthread_mutex_unlock(&m);
return 0LL;
}

original_code:
DescriptorArchivo *buscar_descriptor(ListaDescriptores *des, char *dato, int descript, int tipo)
{
  DescriptorArchivo *ptr = des->inicio;
  pthread_mutex_lock(&m);
  if(tipo) {
    while(ptr != ((void *)0)) {
      if(descript == ptr->fd) {
        pthread_mutex_unlock(&m);
        return ptr;
      }
      ptr = ptr->proximo;
    }
  }
  else {
    while(ptr != ((void *)0)) {
      if(strcmp(dato, ptr->nombre) == 0) {
        pthread_mutex_unlock(&m);
        return ptr;
      }
      ptr = ptr->proximo;
    }
  }
  pthread_mutex_unlock(&m);
  return ((void *)0);
}

canonical_original_code:
struct des_ *buscar_descriptor(struct ListaDes *des, char *dato, int descript, int tipo)
{
  struct des_ *ptr = des->inicio;
  pthread_mutex_lock(&m);
  if(tipo) {
    while(ptr != ((void *)0)) {
      if(descript == ptr->fd) {
        pthread_mutex_unlock(&m);
        return ptr;
      }
      ptr = ptr->proximo;
    }
  }
  else {
    while(ptr != ((void *)0)) {
      if(strcmp(dato, ptr->nombre) == 0) {
        pthread_mutex_unlock(&m);
        return ptr;
      }
      ptr = ptr->proximo;
    }
  }
  pthread_mutex_unlock(&m);
  return ((void *)0);
}

variable_types:
dato
char *

variable_types: descript int

variable_types: tipo int

return_type: struct des_ { char *nombre; int worker_c; int worker_a; int fd; struct des_ *proximo; } *


decompiled_code:
_DWORD *crear_lista_descriptores()
{
_DWORD *v0; // rbx

v0 = malloc(0x10uLL);
if ( !v0 )
puts("error al crear el buffer de descriptores");
*(_QWORD *)v0 = 0LL;
v0[2] = 0;
return v0;
}

canonical_decompiled_code:
_DWORD *func12()
{
_DWORD *v0; // rbx

v0 = malloc(0x10uLL);
if ( !v0 )
puts("error al crear el buffer de descriptores");
*(_QWORD *)v0 = 0LL;
v0[2] = 0;
return v0;
}

original_code:
ListaDescriptores *crear_lista_descriptores()
{
  ListaDescriptores *des;
  if ((des = (ListaDescriptores *)malloc (sizeof(ListaDescriptores))) == ((void *)0))
    printf("error al crear el buffer de descriptores\n");
  des->inicio = ((void *)0);
  des->t = 0;
  return des;
}

canonical_original_code:
struct ListaDes *crear_lista_descriptores()
{
  struct ListaDes *des;
  if ((des = (struct ListaDes *)malloc (sizeof(ListaDescriptores))) == ((void *)0))
    printf("error al crear el buffer de descriptores\n");
  des->inicio = ((void *)0);
  des->t = 0;
  return des;
}

return_type: struct ListaDes { struct des_ { char *nombre; int worker_c; int worker_a; int fd; struct des_ *proximo; } *inicio; int t; } *


decompiled_code:
int __fastcall imprimir_descriptores(const char ***a1)
{
const char **v1; // rbx

v1 = *a1;
puts("Estado buff del descriptor:");
if ( v1 )
{
do
{
printf("%p\n", v1);
printf("%s", *v1);
printf("%d\n", *((unsigned int *)v1 + 2));
printf("%d\n", *((unsigned int *)v1 + 3));
printf("%d\n", *((unsigned int *)v1 + 4));
v1 = (const char **)v1[3];
}
while ( v1 );
}
else
{
puts("Buffer del descriptor vacio");
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func13(const char ***a1)
{
const char **v1; // rbx

v1 = *a1;
puts("Estado buff del descriptor:");
if ( v1 )
{
do
{
printf("%p\n", v1);
printf("%s", *v1);
printf("%d\n", *((unsigned int *)v1 + 2));
printf("%d\n", *((unsigned int *)v1 + 3));
printf("%d\n", *((unsigned int *)v1 + 4));
v1 = (const char **)v1[3];
}
while ( v1 );
}
else
{
puts("Buffer del descriptor vacio");
}
return putchar(10);
}

original_code:
void imprimir_descriptores(ListaDescriptores *des)
{
  DescriptorArchivo *actual = des->inicio;
  printf("Estado buff del descriptor:\n");
  if(actual == ((void *)0))
    printf("Buffer del descriptor vacio\n");
  while (actual != ((void *)0)){
    printf ("%p\n", actual);
    printf ("%s", actual->nombre);
    printf ("%d\n", actual->worker_c);
    printf ("%d\n", actual->worker_a);
    printf ("%d\n", actual->fd);
    actual = actual->proximo;
  }
  printf("\n");
}

canonical_original_code:
void imprimir_descriptores(struct ListaDes *des)
{
  struct des_ *actual = des->inicio;
  printf("Estado buff del descriptor:\n");
  if(actual == ((void *)0))
    printf("Buffer del descriptor vacio\n");
  while (actual != ((void *)0)){
    printf ("%p\n", actual);
    printf ("%s", actual->nombre);
    printf ("%d\n", actual->worker_c);
    printf ("%d\n", actual->worker_a);
    printf ("%d\n", actual->fd);
    actual = actual->proximo;
  }
  printf("\n");
}

user_defined_types: struct des_ { char *nombre; int worker_c; int worker_a; int fd; struct des_ *proximo; }


decompiled_code:
__int64 __fastcall escribir_archivo(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = buscar_archivo(a1, *(_QWORD *)(a2 + 8));
strcat(*(char **)(v2 + 8), *(const char **)(a2 + 16));
result = *(unsigned int *)(a2 + 4);
*(_DWORD *)(v2 + 24) += result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = buscar_archivo(a1, *(_QWORD *)(a2 + 8));
strcat(*(char **)(v2 + 8), *(const char **)(a2 + 16));
result = *(unsigned int *)(a2 + 4);
*(_DWORD *)(v2 + 24) += result;
return result;
}

original_code:
void escribir_archivo(ListaArchivos *lista, Msj *msj)
{
  Archivo *arch;
  arch = buscar_archivo(lista, msj->nombre);
  strcat(arch->texto, msj->texto);
  arch->tam += msj->otrodato;
}

canonical_original_code:
void escribir_archivo(struct lista_ *lista, struct msj_ *msj)
{
  struct archivo_ *arch;
  arch = buscar_archivo(lista, msj->nombre);
  strcat(arch->texto, msj->texto);
  arch->tam += msj->otrodato;
}

variable_types: struct lista_ { struct archivo_ { char *nombre; char *texto; int estado; int indice; int tam; struct archivo_ *proximo; } *inicio; int t; char worker; } *

variable_types: struct msj_ { char tipo; char contador; char dato; int otrodato; char *nombre; char *texto; } *


decompiled_code:
__int64 __fastcall leer_archivo(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
int v5; // eax
int v6; // er8
__int64 result; // rax
int v8; // er8
unsigned int v9; // er13
void *v10; // r14

v4 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
v5 = *(_DWORD *)(v4 + 20);
v6 = *(_DWORD *)(v4 + 24);
if ( v5 <= v6 )
{
v8 = v6 - v5;
v9 = *(_DWORD *)(a3 + 4);
if ( v8 <= (int)v9 )
v9 = v8;
v10 = malloc((int)(v9 + 1));
if ( !v10 )
puts("REA: error");
memcpy(v10, (const void *)(*(_QWORD *)(v4 + 8) + *(int *)(v4 + 20)), (int)v9);
*((_BYTE *)v10 + (int)v9) = 0;
*(_DWORD *)(v4 + 20) += v9;
if ( *(_BYTE *)(a3 + 2) == 109 )
result = enviarWR(*(unsigned int *)(a1 + 4), 114LL, 48LL, 48LL, v9, v10, 0LL);
else
result = enviarWR(
*(unsigned int *)(a1 + 8),
114LL,
(unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1),
116LL,
v9,
v10,
0LL);
}
else if ( *(_BYTE *)(a3 + 2) == 109 )
{
result = enviar(*(unsigned int *)(a1 + 4), 114LL, 48LL, 48LL, 0LL);
}
else
{
result = enviar(*(unsigned int *)(a1 + 8), 114LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, 0LL);
}
return result;
}

original_code:
void leer_archivo(DescriptorColas *cola, ListaArchivos *lista, Msj *msj)
{
  int size;
  char *texto;
  Archivo *arch;
  arch = buscar_archivo(lista, msj->nombre);
  if(arch->indice > arch->tam) {
    if(msj->dato == 'm')
      enviar(cola->disp, 'r', '0', '0', ((void *)0));
    else {
      enviar(cola->anillo, 'r', msj->contador-1, 't', ((void *)0));
    }
  }
  else {
    size = ((msj->otrodato) < (arch->tam - arch->indice) ? (msj->otrodato) : (arch->tam - arch->indice));
    if((texto = (char *) malloc((size+1) * sizeof (char))) == ((void *)0))
      printf("REA: error\n");
    memcpy(texto, &(arch->texto)[arch->indice], size);
    texto[size] = '\0';
    arch->indice += size;
    if(msj->dato == 'm')
      enviarWR(cola->disp,'r', '0', '0', size, texto, ((void *)0));
    else
      enviarWR(cola->anillo, 'r', msj->contador-1, 't', size, texto, ((void *)0));
  }
}

canonical_original_code:
void leer_archivo(struct colas *cola, struct lista_ *lista, struct msj_ *msj)
{
  int size;
  char *texto;
  struct archivo_ *arch;
  arch = buscar_archivo(lista, msj->nombre);
  if(arch->indice > arch->tam) {
    if(msj->dato == 'm')
      enviar(cola->disp, 'r', '0', '0', ((void *)0));
    else {
      enviar(cola->anillo, 'r', msj->contador-1, 't', ((void *)0));
    }
  }
  else {
    size = ((msj->otrodato) < (arch->tam - arch->indice) ? (msj->otrodato) : (arch->tam - arch->indice));
    if((texto = (char *) malloc((size+1) * sizeof (char))) == ((void *)0))
      printf("REA: error\n");
    memcpy(texto, &(arch->texto)[arch->indice], size);
    texto[size] = '\0';
    arch->indice += size;
    if(msj->dato == 'm')
      enviarWR(cola->disp,'r', '0', '0', size, texto, ((void *)0));
    else
      enviarWR(cola->anillo, 'r', msj->contador-1, 't', size, texto, ((void *)0));
  }
}

variable_types: struct colas { int worker; int disp; int anillo; } *

variable_types: size int

variable_types:
texto
char *

variable_types: struct archivo_ { char *nombre; char *texto; int estado; int indice; int tam; struct archivo_ *proximo; } *

user_defined_types: struct msj_ { char tipo; char contador; char dato; int otrodato; char *nombre; char *texto; }


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

result = buscar_archivo(a1, *(_QWORD *)(a2 + 8));
*(_DWORD *)(result + 16) = 0;
*(_DWORD *)(result + 20) = 0;
return result;
}

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

result = buscar_archivo(a1, *(_QWORD *)(a2 + 8));
*(_DWORD *)(result + 16) = 0;
*(_DWORD *)(result + 20) = 0;
return result;
}

original_code:
void cerrar_archivo(ListaArchivos *lista, Msj *msj)
{
  Archivo *arch;
  arch = buscar_archivo(lista, msj->nombre);
  arch->estado = 0;
  arch->indice = 0;
}

canonical_original_code:
void cerrar_archivo(struct lista_ *lista, struct msj_ *msj)
{
  struct archivo_ *arch;
  arch = buscar_archivo(lista, msj->nombre);
  arch->estado = 0;
  arch->indice = 0;
}


decompiled_code:
__int64 __fastcall esperar_respuesta(unsigned int *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax

do
v4 = recibir(*a1);
while ( !(unsigned int)evaluar_msj(a1, v4, a2, a3) );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax

do
v4 = recibir(*a1);
while ( !(unsigned int)func12(a1, v4, a2, a3) );
return 0LL;
}

original_code:
int esperar_respuesta(DescriptorColas *cola, ListaArchivos *lista, char *candidato)
{
  Msj *msj;
  while(1) {
    msj = recibir(cola->worker);
    if(evaluar_msj(cola, msj, lista, candidato))
      break;
  }
  return 0;
}

canonical_original_code:
int esperar_respuesta(struct colas *cola, struct lista_ *lista, char *candidato)
{
  struct msj_ *msj;
  while(1) {
    msj = recibir(cola->worker);
    if(evaluar_msj(cola, msj, lista, candidato))
      break;
  }
  return 0;
}

variable_types:
candidato
char *

user_defined_types: struct colas { int worker; int disp; int anillo; }


operadorLSD

decompiled_code:
void __fastcall operadorLSD(unsigned int *a1, __int64 a2, __int64 a3)
{
char *v4; // rax
char *v5; // rbp

if ( !malloc(0x200uLL) )
puts("LSD: error");
v4 = (char *)concatenar_archivos(a2);
v5 = v4;
if ( *(_BYTE *)(a3 + 2) == 109 )
{
enviar(a1[2], 108LL, 53LL, 102LL, v4);
esperar_respuesta(a1, a2, 0LL);
free(v5);
}
else
{
strcat(v4, *(const char **)(a3 + 8));
enviar(a1[2], 108LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 102LL, v5);
}
}

canonical_decompiled_code:
void __fastcall func4(unsigned int *a1, __int64 a2, __int64 a3)
{
char *v4; // rax
char *v5; // rbp

if ( !malloc(0x200uLL) )
puts("LSD: error");
v4 = (char *)concatenar_archivos(a2);
v5 = v4;
if ( *(_BYTE *)(a3 + 2) == 109 )
{
enviar(a1[2], 108LL, 53LL, 102LL, v4);
func3(a1, a2, 0LL);
free(v5);
}
else
{
strcat(v4, *(const char **)(a3 + 8));
enviar(a1[2], 108LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 102LL, v5);
}
}

original_code:
void operadorLSD(DescriptorColas *cola, ListaArchivos *lista, Msj *msj)
{
  char *nombres;
  if((nombres = (char *) malloc(512 * sizeof (char))) == ((void *)0))
    printf("LSD: error\n");
  nombres = concatenar_archivos(lista);
  if(msj->dato != 'm') {
    strcat(nombres, msj->nombre);
    enviar(cola->anillo, 'l', msj->contador-1, 'f', nombres);
  }
  else {
    enviar(cola->anillo,'l',workers,'f', nombres);
    esperar_respuesta(cola, lista, ((void *)0));
    free(nombres);
  }
}

canonical_original_code:
void operadorLSD(struct colas *cola, struct lista_ *lista, struct msj_ *msj)
{
  char *nombres;
  if((nombres = (char *) malloc(512 * sizeof (char))) == ((void *)0))
    printf("LSD: error\n");
  nombres = concatenar_archivos(lista);
  if(msj->dato != 'm') {
    strcat(nombres, msj->nombre);
    enviar(cola->anillo, 'l', msj->contador-1, 'f', nombres);
  }
  else {
    enviar(cola->anillo,'l',workers,'f', nombres);
    esperar_respuesta(cola, lista, ((void *)0));
    free(nombres);
  }
}

variable_types:
nombres
char *


operadorDEL

decompiled_code:
__int64 __fastcall operadorDEL(unsigned int *a1, __int64 a2, __int64 a3)
{
char v4; // al
__int64 v5; // rax
__int64 result; // rax
__int64 v7; // rax

v4 = *(_BYTE *)(a3 + 2);
if ( v4 == 102 )
{
v7 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
if ( v7 )
{
if ( *(_DWORD *)(v7 + 16) )
{
result = enviar(a1[2], 100LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 101LL, *(_QWORD *)(a3 + 8));
}
else
{
eliminar_archivo(a2, *(_QWORD *)(a3 + 8));
result = enviar(a1[2], 100LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, *(_QWORD *)(a3 + 8));
}
}
else
{
result = reenvio_msj(a1[2], a3, 100LL);
}
}
else if ( v4 == 109 )
{
v5 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
if ( v5 )
{
if ( *(_DWORD *)(v5 + 16) )
{
result = enviar(a1[1], 100LL, 48LL, 101LL, 0LL);
}
else
{
eliminar_archivo(a2, *(_QWORD *)(a3 + 8));
result = enviar(a1[1], 100LL, 48LL, 48LL, 0LL);
}
}
else
{
enviar(a1[2], 100LL, 53LL, 102LL, *(_QWORD *)(a3 + 8));
result = esperar_respuesta(a1, a2, 0LL);
}
}
else
{
result = reenvio_msj(a1[2], a3, 100LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int *a1, __int64 a2, __int64 a3)
{
char v4; // al
__int64 v5; // rax
__int64 result; // rax
__int64 v7; // rax

v4 = *(_BYTE *)(a3 + 2);
if ( v4 == 102 )
{
v7 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
if ( v7 )
{
if ( *(_DWORD *)(v7 + 16) )
{
result = enviar(a1[2], 100LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 101LL, *(_QWORD *)(a3 + 8));
}
else
{
eliminar_archivo(a2, *(_QWORD *)(a3 + 8));
result = enviar(a1[2], 100LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, *(_QWORD *)(a3 + 8));
}
}
else
{
result = reenvio_msj(a1[2], a3, 100LL);
}
}
else if ( v4 == 109 )
{
v5 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
if ( v5 )
{
if ( *(_DWORD *)(v5 + 16) )
{
result = enviar(a1[1], 100LL, 48LL, 101LL, 0LL);
}
else
{
eliminar_archivo(a2, *(_QWORD *)(a3 + 8));
result = enviar(a1[1], 100LL, 48LL, 48LL, 0LL);
}
}
else
{
enviar(a1[2], 100LL, 53LL, 102LL, *(_QWORD *)(a3 + 8));
result = func3(a1, a2, 0LL);
}
}
else
{
result = reenvio_msj(a1[2], a3, 100LL);
}
return result;
}

original_code:
void operadorDEL(DescriptorColas *cola, ListaArchivos *lista, Msj *msj)
{
  Archivo *arch;
  switch(msj->dato) {
    case 'm':
      if((arch = buscar_archivo(lista, msj->nombre)) != ((void *)0)) {
        if(arch->estado == 0) {
          eliminar_archivo(lista, msj->nombre);
          enviar(cola->disp, 'd', '0', '0', ((void *)0));
        }
        else
          enviar(cola->disp, 'd', '0', 'e', ((void *)0));
      }
      else {
        enviar(cola->anillo,'d',workers,'f',msj->nombre);
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 'f':
      if((arch = buscar_archivo(lista, msj->nombre)) != ((void *)0)) {
        if(arch->estado == 0) {
          eliminar_archivo(lista,msj->nombre);
          enviar(cola->anillo, 'd', msj->contador-1, 't', msj->nombre);
        }
        else {
          enviar(cola->anillo, 'd', msj->contador-1, 'e', msj->nombre);
        }
      }
      else
        reenvio_msj(cola->anillo, msj, 'd');
      break;
    default:
      reenvio_msj(cola->anillo, msj, 'd');
      break;
  }
}

canonical_original_code:
void operadorDEL(struct colas *cola, struct lista_ *lista, struct msj_ *msj)
{
  struct archivo_ *arch;
  switch(msj->dato) {
    case 'm':
      if((arch = buscar_archivo(lista, msj->nombre)) != ((void *)0)) {
        if(arch->estado == 0) {
          eliminar_archivo(lista, msj->nombre);
          enviar(cola->disp, 'd', '0', '0', ((void *)0));
        }
        else
          enviar(cola->disp, 'd', '0', 'e', ((void *)0));
      }
      else {
        enviar(cola->anillo,'d',workers,'f',msj->nombre);
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 'f':
      if((arch = buscar_archivo(lista, msj->nombre)) != ((void *)0)) {
        if(arch->estado == 0) {
          eliminar_archivo(lista,msj->nombre);
          enviar(cola->anillo, 'd', msj->contador-1, 't', msj->nombre);
        }
        else {
          enviar(cola->anillo, 'd', msj->contador-1, 'e', msj->nombre);
        }
      }
      else
        reenvio_msj(cola->anillo, msj, 'd');
      break;
    default:
      reenvio_msj(cola->anillo, msj, 'd');
      break;
  }
}


operadorCRE

decompiled_code:
__int64 __fastcall operadorCRE(unsigned int *a1, __int64 a2, __int64 a3, const char *a4)
{
char v5; // al
__int64 result; // rax
const char *v8; // r12

v5 = *(_BYTE *)(a3 + 2);
if ( v5 == 102 )
{
if ( buscar_archivo(a2, *(_QWORD *)(a3 + 8)) )
{
if ( a4 )
{
v8 = *(const char **)(a3 + 8);
if ( !strcmp(a4, v8) )
result = enviar(a1[2], 99LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 101LL, v8);
else
result = enviar(a1[2], 99LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, v8);
}
else
{
result = enviar(a1[2], 99LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, *(_QWORD *)(a3 + 8));
}
}
else
{
result = reenvio_msj(a1[2], a3, 99LL);
}
}
else if ( v5 == 109 )
{
if ( buscar_archivo(a2, *(_QWORD *)(a3 + 8)) )
{
result = enviar(a1[1], 99LL, 48LL, 49LL, 0LL);
}
else
{
enviar(a1[2], 99LL, 53LL, 102LL, *(_QWORD *)(a3 + 8));
result = esperar_respuesta(a1, a2, *(_QWORD *)(a3 + 8));
}
}
else
{
result = reenvio_msj(a1[2], a3, 99LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int *a1, __int64 a2, __int64 a3, const char *a4)
{
char v5; // al
__int64 result; // rax
const char *v8; // r12

v5 = *(_BYTE *)(a3 + 2);
if ( v5 == 102 )
{
if ( buscar_archivo(a2, *(_QWORD *)(a3 + 8)) )
{
if ( a4 )
{
v8 = *(const char **)(a3 + 8);
if ( !strcmp(a4, v8) )
result = enviar(a1[2], 99LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 101LL, v8);
else
result = enviar(a1[2], 99LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, v8);
}
else
{
result = enviar(a1[2], 99LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, *(_QWORD *)(a3 + 8));
}
}
else
{
result = reenvio_msj(a1[2], a3, 99LL);
}
}
else if ( v5 == 109 )
{
if ( buscar_archivo(a2, *(_QWORD *)(a3 + 8)) )
{
result = enviar(a1[1], 99LL, 48LL, 49LL, 0LL);
}
else
{
enviar(a1[2], 99LL, 53LL, 102LL, *(_QWORD *)(a3 + 8));
result = func3(a1, a2, *(_QWORD *)(a3 + 8));
}
}
else
{
result = reenvio_msj(a1[2], a3, 99LL);
}
return result;
}

original_code:
void operadorCRE(DescriptorColas *cola, ListaArchivos *lista, Msj *msj, char *candidato)
{
  switch(msj->dato) {
    case 'm':
      if(buscar_archivo(lista, msj->nombre) != ((void *)0)) {
        enviar(cola->disp, 'c', '0', '1', ((void *)0));
      }
      else {
        enviar(cola->anillo,'c',workers,'f',msj->nombre);
        esperar_respuesta(cola, lista, msj->nombre);
      }
      break;
    case 'f':
      if(buscar_archivo(lista, msj->nombre) != ((void *)0)) {
        if(candidato == ((void *)0))
          enviar(cola->anillo, 'c',msj->contador-1,'t',msj->nombre);
        else {
          if(strcmp(candidato, msj->nombre) == 0)
            enviar(cola->anillo,'c',msj->contador-1,'e',msj->nombre);
          else
            enviar(cola->anillo,'c',msj->contador-1,'t',msj->nombre);
        }
      }
      else {
        reenvio_msj(cola->anillo, msj, 'c');
      }
      break;
    default:
      reenvio_msj(cola->anillo, msj, 'c');
      break;
  }
}

canonical_original_code:
void operadorCRE(struct colas *cola, struct lista_ *lista, struct msj_ *msj, char *candidato)
{
  switch(msj->dato) {
    case 'm':
      if(buscar_archivo(lista, msj->nombre) != ((void *)0)) {
        enviar(cola->disp, 'c', '0', '1', ((void *)0));
      }
      else {
        enviar(cola->anillo,'c',workers,'f',msj->nombre);
        esperar_respuesta(cola, lista, msj->nombre);
      }
      break;
    case 'f':
      if(buscar_archivo(lista, msj->nombre) != ((void *)0)) {
        if(candidato == ((void *)0))
          enviar(cola->anillo, 'c',msj->contador-1,'t',msj->nombre);
        else {
          if(strcmp(candidato, msj->nombre) == 0)
            enviar(cola->anillo,'c',msj->contador-1,'e',msj->nombre);
          else
            enviar(cola->anillo,'c',msj->contador-1,'t',msj->nombre);
        }
      }
      else {
        reenvio_msj(cola->anillo, msj, 'c');
      }
      break;
    default:
      reenvio_msj(cola->anillo, msj, 'c');
      break;
  }
}


operadorOPN

decompiled_code:
__int64 __fastcall operadorOPN(unsigned int *a1, __int64 a2, __int64 a3)
{
char v5; // al
__int64 v6; // rdi
__int64 result; // rax
__int64 v8; // rdi

v5 = *(_BYTE *)(a3 + 2);
if ( v5 == 102 )
{
v8 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
if ( v8 )
{
if ( (unsigned int)modificar_estado(v8) )
result = enviar(
a1[2],
111LL,
(unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1),
(unsigned int)*(char *)(a2 + 12),
*(_QWORD *)(a3 + 8));
else
result = enviar(a1[2], 111LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 101LL, *(_QWORD *)(a3 + 8));
}
else
{
result = enviar(
a1[2],
111LL,
(unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1),
(unsigned int)*(char *)(a3 + 2),
*(_QWORD *)(a3 + 8));
}
}
else if ( v5 == 109 )
{
v6 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
if ( v6 )
{
if ( (unsigned int)modificar_estado(v6) )
result = enviar(a1[1], 111LL, (unsigned int)*(char *)(a2 + 12), 48LL, 0LL);
else
result = enviar(a1[1], 111LL, 48LL, 49LL, 0LL);
}
else
{
enviar(a1[2], 111LL, 53LL, 102LL, *(_QWORD *)(a3 + 8));
result = esperar_respuesta(a1, a2, 0LL);
}
}
else
{
result = reenvio_msj(a1[2], a3, 111LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int *a1, __int64 a2, __int64 a3)
{
char v5; // al
__int64 v6; // rdi
__int64 result; // rax
__int64 v8; // rdi

v5 = *(_BYTE *)(a3 + 2);
if ( v5 == 102 )
{
v8 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
if ( v8 )
{
if ( (unsigned int)modificar_estado(v8) )
result = enviar(
a1[2],
111LL,
(unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1),
(unsigned int)*(char *)(a2 + 12),
*(_QWORD *)(a3 + 8));
else
result = enviar(a1[2], 111LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 101LL, *(_QWORD *)(a3 + 8));
}
else
{
result = enviar(
a1[2],
111LL,
(unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1),
(unsigned int)*(char *)(a3 + 2),
*(_QWORD *)(a3 + 8));
}
}
else if ( v5 == 109 )
{
v6 = buscar_archivo(a2, *(_QWORD *)(a3 + 8));
if ( v6 )
{
if ( (unsigned int)modificar_estado(v6) )
result = enviar(a1[1], 111LL, (unsigned int)*(char *)(a2 + 12), 48LL, 0LL);
else
result = enviar(a1[1], 111LL, 48LL, 49LL, 0LL);
}
else
{
enviar(a1[2], 111LL, 53LL, 102LL, *(_QWORD *)(a3 + 8));
result = func3(a1, a2, 0LL);
}
}
else
{
result = reenvio_msj(a1[2], a3, 111LL);
}
return result;
}

original_code:
void operadorOPN(DescriptorColas *cola, ListaArchivos *lista, Msj *msj)
{
  Archivo *arch;
  switch(msj->dato) {
    case 'm':
      if((arch = buscar_archivo(lista, msj->nombre)) != ((void *)0)) {
        if(modificar_estado(arch))
          enviar(cola->disp, 'o', lista->worker, '0', ((void *)0));
        else
          enviar(cola->disp, 'o', '0', '1', ((void *)0));
      }
      else {
        enviar(cola->anillo,'o',workers,'f',msj->nombre);
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 'f':
      if((arch = buscar_archivo(lista, msj->nombre)) != ((void *)0)) {
        if(modificar_estado(arch))
          enviar(cola->anillo,'o',msj->contador-1,lista->worker,msj->nombre);
        else
          enviar(cola->anillo,'o',msj->contador-1,'e',msj->nombre);
      }
      else
        enviar(cola->anillo,'o',msj->contador-1,msj->dato,msj->nombre);
      break;
    default:
      reenvio_msj(cola->anillo, msj, 'o');
      break;
  }
}

canonical_original_code:
void operadorOPN(struct colas *cola, struct lista_ *lista, struct msj_ *msj)
{
  struct archivo_ *arch;
  switch(msj->dato) {
    case 'm':
      if((arch = buscar_archivo(lista, msj->nombre)) != ((void *)0)) {
        if(modificar_estado(arch))
          enviar(cola->disp, 'o', lista->worker, '0', ((void *)0));
        else
          enviar(cola->disp, 'o', '0', '1', ((void *)0));
      }
      else {
        enviar(cola->anillo,'o',workers,'f',msj->nombre);
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 'f':
      if((arch = buscar_archivo(lista, msj->nombre)) != ((void *)0)) {
        if(modificar_estado(arch))
          enviar(cola->anillo,'o',msj->contador-1,lista->worker,msj->nombre);
        else
          enviar(cola->anillo,'o',msj->contador-1,'e',msj->nombre);
      }
      else
        enviar(cola->anillo,'o',msj->contador-1,msj->dato,msj->nombre);
      break;
    default:
      reenvio_msj(cola->anillo, msj, 'o');
      break;
  }
}


operadorWRT

decompiled_code:
__int64 __fastcall operadorWRT(unsigned int *a1, __int64 a2, __int64 a3)
{
char v4; // dl
char v5; // al
__int64 result; // rax
char v7; // cl

v4 = *(_BYTE *)(a2 + 12);
v5 = *(_BYTE *)(a3 + 2);
if ( v5 == 109 )
{
v7 = *(_BYTE *)(a3 + 1);
if ( v7 == v4 )
{
escribir_archivo(a2, a3);
result = enviar(a1[1], 119LL, 48LL, 48LL, 0LL);
}
else
{
enviarWR(
a1[2],
119LL,
53LL,
(unsigned int)v7,
*(unsigned int *)(a3 + 4),
*(_QWORD *)(a3 + 8),
*(_QWORD *)(a3 + 16));
result = esperar_respuesta(a1, a2, 0LL);
}
}
else if ( v5 != 116 && v5 == v4 )
{
escribir_archivo(a2, a3);
result = enviar(a1[2], 119LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, 0LL);
}
else
{
result = reenvio_msj(a1[2], a3, 119LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int *a1, __int64 a2, __int64 a3)
{
char v4; // dl
char v5; // al
__int64 result; // rax
char v7; // cl

v4 = *(_BYTE *)(a2 + 12);
v5 = *(_BYTE *)(a3 + 2);
if ( v5 == 109 )
{
v7 = *(_BYTE *)(a3 + 1);
if ( v7 == v4 )
{
func0(a2, a3);
result = enviar(a1[1], 119LL, 48LL, 48LL, 0LL);
}
else
{
enviarWR(
a1[2],
119LL,
53LL,
(unsigned int)v7,
*(unsigned int *)(a3 + 4),
*(_QWORD *)(a3 + 8),
*(_QWORD *)(a3 + 16));
result = func3(a1, a2, 0LL);
}
}
else if ( v5 != 116 && v5 == v4 )
{
func0(a2, a3);
result = enviar(a1[2], 119LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, 0LL);
}
else
{
result = reenvio_msj(a1[2], a3, 119LL);
}
return result;
}

original_code:
void operadorWRT(DescriptorColas *cola, ListaArchivos *lista, Msj *msj)
{
  char worker = lista->worker;
  switch(msj->dato) {
    case 'm':
      if(msj->contador == worker) {
        escribir_archivo(lista, msj);
        enviar(cola->disp, 'w', '0', '0', ((void *)0));
      }
      else {
        enviarWR(cola->anillo,'w',workers,msj->contador, msj->otrodato, msj->nombre, msj->texto);
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 't':
      reenvio_msj(cola->anillo, msj, 'w');
      break;
    default:
      if(worker == msj->dato) {
        escribir_archivo(lista, msj);
        enviar(cola->anillo, 'w', msj->contador-1, 't', ((void *)0));
      }
      else
        reenvio_msj(cola->anillo, msj, 'w');
      break;
  }
}

canonical_original_code:
void operadorWRT(struct colas *cola, struct lista_ *lista, struct msj_ *msj)
{
  char worker = lista->worker;
  switch(msj->dato) {
    case 'm':
      if(msj->contador == worker) {
        escribir_archivo(lista, msj);
        enviar(cola->disp, 'w', '0', '0', ((void *)0));
      }
      else {
        enviarWR(cola->anillo,'w',workers,msj->contador, msj->otrodato, msj->nombre, msj->texto);
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 't':
      reenvio_msj(cola->anillo, msj, 'w');
      break;
    default:
      if(worker == msj->dato) {
        escribir_archivo(lista, msj);
        enviar(cola->anillo, 'w', msj->contador-1, 't', ((void *)0));
      }
      else
        reenvio_msj(cola->anillo, msj, 'w');
      break;
  }
}

variable_types: worker char


operadorREA

decompiled_code:
__int64 __fastcall operadorREA(unsigned int *a1, __int64 a2, __int64 a3)
{
char v5; // dl
char v6; // al
char v8; // cl

v5 = *(_BYTE *)(a2 + 12);
v6 = *(_BYTE *)(a3 + 2);
if ( v6 == 109 )
{
v8 = *(_BYTE *)(a3 + 1);
if ( v8 != v5 )
{
enviarWR(a1[2], 114LL, 53LL, (unsigned int)v8, *(unsigned int *)(a3 + 4), *(_QWORD *)(a3 + 8), 0LL);
return esperar_respuesta(a1, a2, 0LL);
}
}
else if ( v6 == 116 || v6 != v5 )
{
return reenvio_msj(a1[2], a3, 114LL);
}
return leer_archivo((__int64)a1, a2, a3);
}

original_code:
void operadorREA(DescriptorColas *cola, ListaArchivos *lista, Msj *msj)
{
  char worker = lista->worker;
  switch(msj->dato) {
    case 'm':
      if(msj->contador == worker)
        leer_archivo(cola, lista, msj);
      else {
        enviarWR(cola->anillo,'r',workers,msj->contador, msj->otrodato, msj->nombre, ((void *)0));
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 't':
      reenvio_msj(cola->anillo, msj, 'r');
      break;
    default:
      if(msj->dato == worker)
        leer_archivo(cola, lista, msj);
      else
        reenvio_msj(cola->anillo, msj, 'r');
      break;
  }
}

canonical_original_code:
void operadorREA(struct colas *cola, struct lista_ *lista, struct msj_ *msj)
{
  char worker = lista->worker;
  switch(msj->dato) {
    case 'm':
      if(msj->contador == worker)
        leer_archivo(cola, lista, msj);
      else {
        enviarWR(cola->anillo,'r',workers,msj->contador, msj->otrodato, msj->nombre, ((void *)0));
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 't':
      reenvio_msj(cola->anillo, msj, 'r');
      break;
    default:
      if(msj->dato == worker)
        leer_archivo(cola, lista, msj);
      else
        reenvio_msj(cola->anillo, msj, 'r');
      break;
  }
}


operadorCLO

decompiled_code:
__int64 __fastcall operadorCLO(unsigned int *a1, __int64 a2, __int64 a3)
{
char v4; // dl
char v5; // al
__int64 result; // rax
char v7; // cl

v4 = *(_BYTE *)(a2 + 12);
v5 = *(_BYTE *)(a3 + 2);
if ( v5 == 109 )
{
v7 = *(_BYTE *)(a3 + 1);
if ( v7 == v4 )
{
cerrar_archivo(a2, a3);
result = enviar(a1[1], 115LL, 48LL, 48LL, 0LL);
}
else
{
enviar(a1[2], 115LL, 53LL, (unsigned int)v7, *(_QWORD *)(a3 + 8));
result = esperar_respuesta(a1, a2, 0LL);
}
}
else if ( v5 != 116 && v5 == v4 )
{
cerrar_archivo(a2, a3);
result = enviar(a1[2], 115LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, 0LL);
}
else
{
result = reenvio_msj(a1[2], a3, 115LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int *a1, __int64 a2, __int64 a3)
{
char v4; // dl
char v5; // al
__int64 result; // rax
char v7; // cl

v4 = *(_BYTE *)(a2 + 12);
v5 = *(_BYTE *)(a3 + 2);
if ( v5 == 109 )
{
v7 = *(_BYTE *)(a3 + 1);
if ( v7 == v4 )
{
func2(a2, a3);
result = enviar(a1[1], 115LL, 48LL, 48LL, 0LL);
}
else
{
enviar(a1[2], 115LL, 53LL, (unsigned int)v7, *(_QWORD *)(a3 + 8));
result = func3(a1, a2, 0LL);
}
}
else if ( v5 != 116 && v5 == v4 )
{
func2(a2, a3);
result = enviar(a1[2], 115LL, (unsigned int)(char)(*(_BYTE *)(a3 + 1) - 1), 116LL, 0LL);
}
else
{
result = reenvio_msj(a1[2], a3, 115LL);
}
return result;
}

original_code:
void operadorCLO(DescriptorColas *cola, ListaArchivos *lista, Msj *msj)
{
  char worker = lista->worker;
  switch(msj->dato) {
    case 'm':
      if(msj->contador == worker) {
        cerrar_archivo(lista, msj);
        enviar(cola->disp, 's', '0', '0', ((void *)0));
      }
      else {
        enviar(cola->anillo,'s',workers,msj->contador,msj->nombre);
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 't':
      reenvio_msj(cola->anillo, msj, 's');
      break;
    default:
      if(msj->dato == worker) {
        cerrar_archivo(lista, msj);
        enviar(cola->anillo,'s',msj->contador-1,'t',((void *)0));
      }
      else
        reenvio_msj(cola->anillo, msj, 's');
      break;
  }
}

canonical_original_code:
void operadorCLO(struct colas *cola, struct lista_ *lista, struct msj_ *msj)
{
  char worker = lista->worker;
  switch(msj->dato) {
    case 'm':
      if(msj->contador == worker) {
        cerrar_archivo(lista, msj);
        enviar(cola->disp, 's', '0', '0', ((void *)0));
      }
      else {
        enviar(cola->anillo,'s',workers,msj->contador,msj->nombre);
        esperar_respuesta(cola, lista, ((void *)0));
      }
      break;
    case 't':
      reenvio_msj(cola->anillo, msj, 's');
      break;
    default:
      if(msj->dato == worker) {
        cerrar_archivo(lista, msj);
        enviar(cola->anillo,'s',msj->contador-1,'t',((void *)0));
      }
      else
        reenvio_msj(cola->anillo, msj, 's');
      break;
  }
}


decompiled_code:
void __fastcall envio_por_anillo(unsigned int *a1, _BYTE *a2, __int64 a3, const char *a4)
{
switch ( *a2 )
{
case 'c':
operadorCRE(a1, a3, (__int64)a2, a4);
break;
case 'd':
operadorDEL(a1, a3, (__int64)a2);
break;
case 'l':
operadorLSD(a1, a3, (__int64)a2);
break;
case 'o':
operadorOPN(a1, a3, (__int64)a2);
break;
case 'r':
operadorREA(a1, a3, (__int64)a2);
break;
case 's':
operadorCLO(a1, a3, (__int64)a2);
break;
case 'w':
operadorWRT(a1, a3, (__int64)a2);
break;
default:
return;
}
}

canonical_decompiled_code:
void __fastcall func11(unsigned int *a1, _BYTE *a2, __int64 a3, const char *a4)
{
switch ( *a2 )
{
case 'c':
func6(a1, a3, (__int64)a2, a4);
break;
case 'd':
func5(a1, a3, (__int64)a2);
break;
case 'l':
func4(a1, a3, (__int64)a2);
break;
case 'o':
func7(a1, a3, (__int64)a2);
break;
case 'r':
func9(a1, a3, (__int64)a2);
break;
case 's':
func10(a1, a3, (__int64)a2);
break;
case 'w':
func8(a1, a3, (__int64)a2);
break;
default:
return;
}
}

original_code:
void envio_por_anillo(DescriptorColas *cola, Msj *msj, ListaArchivos *lista, char *candidato)
{
  switch(msj->tipo) {
    case 'l':
      operadorLSD(cola, lista, msj);
      break;
    case 'd':
      operadorDEL(cola, lista, msj);
      break;
    case 'c':
      operadorCRE(cola, lista, msj, candidato);
      break;
    case 'o':
      operadorOPN(cola, lista, msj);
      break;
    case 'w':
      operadorWRT(cola, lista, msj);
      break;
    case 'r':
      operadorREA(cola, lista, msj);
      break;
    case 's':
      operadorCLO(cola, lista, msj);
      break;
  }
}

canonical_original_code:
void envio_por_anillo(struct colas *cola, struct msj_ *msj, struct lista_ *lista, char *candidato)
{
  switch(msj->tipo) {
    case 'l':
      operadorLSD(cola, lista, msj);
      break;
    case 'd':
      operadorDEL(cola, lista, msj);
      break;
    case 'c':
      operadorCRE(cola, lista, msj, candidato);
      break;
    case 'o':
      operadorOPN(cola, lista, msj);
      break;
    case 'w':
      operadorWRT(cola, lista, msj);
      break;
    case 'r':
      operadorREA(cola, lista, msj);
      break;
    case 's':
      operadorCLO(cola, lista, msj);
      break;
  }
}