decompiled_code:
int setup_sigmask()
{
_BYTE savedregs[136]; // [rsp+0h] [rbp+0h] BYREF

sigfillset((sigset_t *)savedregs);
sigdelset((sigset_t *)savedregs, 3);
sigdelset((sigset_t *)savedregs, 4);
sigdelset((sigset_t *)savedregs, 5);
sigdelset((sigset_t *)savedregs, 6);
sigdelset((sigset_t *)savedregs, 8);
sigdelset((sigset_t *)savedregs, 11);
sigdelset((sigset_t *)savedregs, 7);
return sigprocmask(0, (const sigset_t *)savedregs, 0LL);
}

canonical_decompiled_code:
int func1()
{
_BYTE savedregs[136]; // [rsp+0h] [rbp+0h] BYREF

sigfillset((sigset_t *)savedregs);
sigdelset((sigset_t *)savedregs, 3);
sigdelset((sigset_t *)savedregs, 4);
sigdelset((sigset_t *)savedregs, 5);
sigdelset((sigset_t *)savedregs, 6);
sigdelset((sigset_t *)savedregs, 8);
sigdelset((sigset_t *)savedregs, 11);
sigdelset((sigset_t *)savedregs, 7);
return sigprocmask(0, (const sigset_t *)savedregs, 0LL);
}

original_code:
static int
setup_sigmask(void)
{
 sigset_t set;
 sigfillset(&set);
 sigdelset(&set, 3);
 sigdelset(&set, 4);
 sigdelset(&set, 5);
 sigdelset(&set, 6);
 sigdelset(&set, 8);
 sigdelset(&set, 11);
 sigdelset(&set, 7);
 return (sigprocmask(0, &set, ((void *)0)));
}

canonical_original_code:
static int setup_sigmask()
{
 struct __sigset_t set;
 sigfillset(&set);
 sigdelset(&set, 3);
 sigdelset(&set, 4);
 sigdelset(&set, 5);
 sigdelset(&set, 6);
 sigdelset(&set, 8);
 sigdelset(&set, 11);
 sigdelset(&set, 7);
 return (sigprocmask(0, &set, ((void *)0)));
}

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


repo: lhh/cpglock

decompiled_code:
int __fastcall daemon_init(char *path)
{
int result; // eax
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( getuid() )
{
fwrite("daemon_init: Sorry, only root wants to run this.\n", 1uLL, 0x31uLL, stderr);
exit(1);
}
if ( (unsigned int)check_process_running(path, v2) && getpid() != v2[0] )
{
fprintf(stderr, "daemon_init: Process \"%s\" already running.\n", path);
exit(1);
}
if ( setup_sigmask() < 0 )
{
fwrite("daemon_init: Unable to set signal mask.\n", 1uLL, 0x28uLL, stderr);
exit(1);
}
if ( daemon(0, 0) )
{
fwrite("daemon_init: Unable to daemonize.\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
update_pidfile(path);
result = nice(-1);
if ( result < 0 )
result = fwrite("daemon_init: Unable to renice.\n", 1uLL, 0x1FuLL, stderr);
return result;
}

canonical_decompiled_code:
int __fastcall func4(char *path)
{
int result; // eax
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( getuid() )
{
fwrite("daemon_init: Sorry, only root wants to run this.\n", 1uLL, 0x31uLL, stderr);
exit(1);
}
if ( (unsigned int)func3(path, v2) && getpid() != v2[0] )
{
fprintf(stderr, "daemon_init: Process \"%s\" already running.\n", path);
exit(1);
}
if ( func1() < 0 )
{
fwrite("daemon_init: Unable to set signal mask.\n", 1uLL, 0x28uLL, stderr);
exit(1);
}
if ( daemon(0, 0) )
{
fwrite("daemon_init: Unable to daemonize.\n", 1uLL, 0x22uLL, stderr);
exit(1);
}
func0(path);
result = nice(-1);
if ( result < 0 )
result = fwrite("daemon_init: Unable to renice.\n", 1uLL, 0x1FuLL, stderr);
return result;
}

original_code:
void
daemon_init(char *prog)
{
 uid_t uid;
 pid_t pid;
 uid = getuid();
 if (uid) {
  fprintf(stderr,
   "daemon_init: Sorry, only root wants to run this.\n");
  exit(1);
 }
 if (check_process_running(prog, &pid) && (pid != getpid())) {
  fprintf(stderr,
   "daemon_init: Process \"%s\" already running.\n",
   prog);
  exit(1);
 }
 if (setup_sigmask() < 0) {
  fprintf(stderr, "daemon_init: Unable to set signal mask.\n");
  exit(1);
 }
 if (daemon(0, 0)) {
  fprintf(stderr, "daemon_init: Unable to daemonize.\n");
  exit(1);
 }
 update_pidfile(prog);
 if (nice(-1) < 0)
  fprintf(stderr, "daemon_init: Unable to renice.\n");
}

canonical_original_code:
void daemon_init(char *prog)
{
 unsigned int uid;
 int pid;
 uid = getuid();
 if (uid) {
  fprintf(stderr,
   "daemon_init: Sorry, only root wants to run this.\n");
  exit(1);
 }
 if (check_process_running(prog, &pid) && (pid != getpid())) {
  fprintf(stderr,
   "daemon_init: Process \"%s\" already running.\n",
   prog);
  exit(1);
 }
 if (setup_sigmask() < 0) {
  fprintf(stderr, "daemon_init: Unable to set signal mask.\n");
  exit(1);
 }
 if (daemon(0, 0)) {
  fprintf(stderr, "daemon_init: Unable to daemonize.\n");
  exit(1);
 }
 update_pidfile(prog);
 if (nice(-1) < 0)
  fprintf(stderr, "daemon_init: Unable to renice.\n");
}

variable_types:
prog
char *

variable_types:
uid
unsigned int

variable_types: pid int

return_type: void


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

if ( pid_filename )
{
unlink(&pid_filename);
result = 0LL;
memset(&pid_filename, 0, 0x1000uLL);
}
return result;
}

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

if ( pid_filename )
{
unlink(&pid_filename);
result = 0LL;
memset(&pid_filename, 0, 0x1000uLL);
}
return result;
}

original_code:
void
daemon_cleanup(void)
{
 if (!strlen(pid_filename))
  return;
 unlink(pid_filename);
 memset(pid_filename, 0, sizeof(pid_filename));
}

canonical_original_code:
void daemon_cleanup()
{
 if (!strlen(pid_filename))
  return;
 unlink(pid_filename);
 memset(pid_filename, 0, sizeof(pid_filename));
}


original_code:
static int
check_pending(struct pending_node **l,
       struct cpg_lock_msg *exp,
       struct cpg_lock_msg *ret)
{
 struct pending_node *p;
 int x;
 if (((x=0) == 0) && (*l != ((void *)0))) for (p = *l; (x == 0) || (p != *l); p = (void*)(&((*p)._list_head))->le_next, x++) {
  if (!strcmp(exp->resource, p->m.resource) &&
      exp->owner_tid == p->m.owner_tid) {
   do { if ((&((*p)._list_head)) == (&((**l)._list_head))) { *l = (void *)(&((**l)._list_head))->le_next; } if ((&((*p)._list_head)) == (&((**l)._list_head))) { (&((*p)._list_head))->le_next = ((void *)0); (&((*p)._list_head))->le_prev = ((void *)0); *l = ((void *)0); } else { (&((*p)._list_head))->le_next->le_prev = (&((*p)._list_head))->le_prev; (&((*p)._list_head))->le_prev->le_next = (&((*p)._list_head))->le_next; (&((*p)._list_head))->le_prev = ((void *)0); (&((*p)._list_head))->le_next = ((void *)0); } } while (0);
   memcpy(ret, &p->m, sizeof(*ret));
   free(p);
   return 0;
  }
 }
 return 1;
}

canonical_original_code:
static int check_pending(struct pending_node **l, struct cpg_lock_msg *exp, struct cpg_lock_msg *ret)
{
 struct pending_node *p;
 int x;
 if (((x=0) == 0) && (*l != ((void *)0))) for (p = *l; (x == 0) || (p != *l); p = (void *)(&((*p)._list_head))->le_next, x++) {
  if (!strcmp(exp->resource, p->m.resource) &&
      exp->owner_tid == p->m.owner_tid) {
   do { if ((&((*p)._list_head)) == (&((**l)._list_head))) { *l = (void *)(&((**l)._list_head))->le_next; } if ((&((*p)._list_head)) == (&((**l)._list_head))) { (&((*p)._list_head))->le_next = ((void *)0); (&((*p)._list_head))->le_prev = ((void *)0); *l = ((void *)0); } else { (&((*p)._list_head))->le_next->le_prev = (&((*p)._list_head))->le_prev; (&((*p)._list_head))->le_prev->le_next = (&((*p)._list_head))->le_next; (&((*p)._list_head))->le_prev = ((void *)0); (&((*p)._list_head))->le_next = ((void *)0); } } while (0);
   memcpy(ret, &p->m, sizeof(*ret));
   free(p);
   return 0;
  }
 }
 return 1;
}

variable_types: struct pending_node { struct list_entry { struct list_entry *le_next; } _list_head; struct cpg_lock_msg { char resource[96]; int request; unsigned int owner_nodeid; unsigned int owner_pid; unsigned int flags; unsigned int lockid; unsigned int owner_tid; char pad[8]; } m; } **

variable_types:
exp
struct cpg_lock_msg *

variable_types:
ret
struct cpg_lock_msg *

variable_types: x int

return_type: int

user_defined_types: struct pending_node { struct list_entry _list_head; struct cpg_lock_msg m; }


decompiled_code:
__int64 __fastcall cpg_lock_init(pthread_mutex_t **a1)
{
__int64 v1; // rax
pthread_mutex_t *v2; // rbp
int v3; // eax
__int64 result; // rax
int *v5; // rax
int v6; // er12
int *v7; // rbx

v1 = do_alloc(64LL);
if ( !v1 )
return 0xFFFFFFFFLL;
v2 = (pthread_mutex_t *)v1;
v3 = sock_connect("/var/run/cpglockd.sk", 3LL);
v2[1].__owner = v3;
if ( v3 < 0 )
{
v5 = _errno_location();
v6 = *v5;
v7 = v5;
free(v2);
result = 0xFFFFFFFFLL;
*v7 = v6;
}
else
{
v2[1].__nusers = getpid();
pthread_mutex_init(v2, 0LL);
*a1 = v2;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(pthread_mutex_t **a1)
{
__int64 v1; // rax
pthread_mutex_t *v2; // rbp
int v3; // eax
__int64 result; // rax
int *v5; // rax
int v6; // er12
int *v7; // rbx

v1 = do_alloc(64LL);
if ( !v1 )
return 0xFFFFFFFFLL;
v2 = (pthread_mutex_t *)v1;
v3 = sock_connect("/var/run/cpglockd.sk", 3LL);
v2[1].__owner = v3;
if ( v3 < 0 )
{
v5 = _errno_location();
v6 = *v5;
v7 = v5;
free(v2);
result = 0xFFFFFFFFLL;
*v7 = v6;
}
else
{
v2[1].__nusers = getpid();
pthread_mutex_init(v2, 0LL);
*a1 = v2;
result = 0LL;
}
return result;
}

original_code:
int
cpg_lock_init(void **handle)
{
 struct cpg_lock_handle *h;
 int esv;
 h = do_alloc(sizeof (*h));
 if (!h)
  return -1;
 h->fd = sock_connect("/var/run/cpglockd.sk", 3);
 if (h->fd < 0) {
  esv = (*__errno_location ());
  free(h);
  (*__errno_location ()) = esv;
  return -1;
 }
 h->pid = getpid();
 pthread_mutex_init(&h->mutex, ((void *)0));
 *handle = (void *)h;
 return 0;
}

variable_types:
handle
void **

variable_types: struct cpg_lock_handle { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; struct pending_node { struct list_entry { struct list_entry *le_next; } _list_head; struct cpg_lock_msg { char resource[96]; int request; unsigned int owner_nodeid; unsigned int owner_pid; unsigned int flags; unsigned int lockid; unsigned int owner_tid; char pad[8]; } m; } *pending; int fd; int pid; int seq; } *

variable_types: esv int

user_defined_types: struct cpg_lock_handle { union pthread_mutex_t mutex; struct pending_node *pending; int fd; int pid; int seq; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
__int64 __fastcall cpg_lock(pthread_mutex_t *mutex, char *src, unsigned int a3, __int64 a4)
{
unsigned int v7; // er14
unsigned int v8; // er12
unsigned int v10; // eax
__int64 v11; // rdi
int v12; // eax
__int16 v13; // ax
__int64 v14; // rdi
unsigned int v15; // eax
__int16 v16; // ax
__int64 v17[2]; // [rsp+0h] [rbp-148h] BYREF
char dest[96]; // [rsp+10h] [rbp-138h] BYREF
__int128 v19; // [rsp+70h] [rbp-D8h]
__int128 v20; // [rsp+80h] [rbp-C8h]
__m128i s1[11]; // [rsp+90h] [rbp-B8h] BYREF

if ( !mutex )
{
v8 = -1;
*_errno_location() = 22;
return v8;
}
pthread_mutex_lock(mutex);
v7 = mutex[1].__nusers;
if ( v7 == getpid() )
{
if ( strlen(src) <= 0x5F )
{
v19 = 0LL;
memset(s1, 0, 0x80uLL);
v20 = 0LL;
strncpy(dest, src, 0x60uLL);
strncpy((char *)a4, src, 0x60uLL);
v10 = mutex[1].__nusers;
v11 = (unsigned int)mutex[1].__owner;
*((_QWORD *)&v19 + 1) = __PAIR64__(a3, v10);
v12 = mutex[1].__kind;
LODWORD(v19) = 1;
mutex[1].__kind = ++v12;
DWORD1(v20) = v12;
if ( write_retry(v11, dest, 128LL, 0LL) >= 0 )
{
while ( (unsigned int)check_pending((__m128i **)&mutex[1], (__int64)dest, s1) )
{
v17[0] = 0LL;
v13 = random();
v14 = (unsigned int)mutex[1].__owner;
v17[1] = v13 & 0x3FFF;
if ( read_retry(v14, s1, 128LL, v17) < 0 )
{
if ( *_errno_location() != 110 )
goto LABEL_18;
}
else
{
if ( !strcmp((const char *)s1, dest) && s1[7].m128i_i32[1] == DWORD1(v20) )
break;
add_pending((__m128i **)&mutex[1], s1);
}
pthread_mutex_unlock(mutex);
v16 = random();
usleep(v16 & 0x3FFF);
pthread_mutex_lock(mutex);
}
if ( s1[6].m128i_i32[1] )
{
if ( s1[6].m128i_i32[0] == 2 )
{
*_errno_location() = 11;
}
else if ( s1[6].m128i_i32[0] == 3 )
{
*(_DWORD *)(a4 + 108) = s1[6].m128i_i32[1];
v15 = mutex[1].__nusers;
v8 = 0;
*(_DWORD *)(a4 + 104) = 2;
*(_DWORD *)(a4 + 112) = v15;
*(_DWORD *)(a4 + 100) = s1[7].m128i_i32[0];
goto LABEL_5;
}
}
}
LABEL_18:
v8 = -1;
goto LABEL_5;
}
v8 = -1;
*_errno_location() = 36;
}
else
{
v8 = -1;
*_errno_location() = 9;
}
LABEL_5:
pthread_mutex_unlock(mutex);
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func2(pthread_mutex_t *mutex, char *src, unsigned int a3, __int64 a4)
{
unsigned int v7; // er14
unsigned int v8; // er12
unsigned int v10; // eax
__int64 v11; // rdi
int v12; // eax
__int16 v13; // ax
__int64 v14; // rdi
unsigned int v15; // eax
__int16 v16; // ax
__int64 v17[2]; // [rsp+0h] [rbp-148h] BYREF
char dest[96]; // [rsp+10h] [rbp-138h] BYREF
__int128 v19; // [rsp+70h] [rbp-D8h]
__int128 v20; // [rsp+80h] [rbp-C8h]
__m128i s1[11]; // [rsp+90h] [rbp-B8h] BYREF

if ( !mutex )
{
v8 = -1;
*_errno_location() = 22;
return v8;
}
pthread_mutex_lock(mutex);
v7 = mutex[1].__nusers;
if ( v7 == getpid() )
{
if ( strlen(src) <= 0x5F )
{
v19 = 0LL;
memset(s1, 0, 0x80uLL);
v20 = 0LL;
strncpy(dest, src, 0x60uLL);
strncpy((char *)a4, src, 0x60uLL);
v10 = mutex[1].__nusers;
v11 = (unsigned int)mutex[1].__owner;
*((_QWORD *)&v19 + 1) = __PAIR64__(a3, v10);
v12 = mutex[1].__kind;
LODWORD(v19) = 1;
mutex[1].__kind = ++v12;
DWORD1(v20) = v12;
if ( write_retry(v11, dest, 128LL, 0LL) >= 0 )
{
while ( (unsigned int)func0((__m128i **)&mutex[1], (__int64)dest, s1) )
{
v17[0] = 0LL;
v13 = random();
v14 = (unsigned int)mutex[1].__owner;
v17[1] = v13 & 0x3FFF;
if ( read_retry(v14, s1, 128LL, v17) < 0 )
{
if ( *_errno_location() != 110 )
goto LABEL_18;
}
else
{
if ( !strcmp((const char *)s1, dest) && s1[7].m128i_i32[1] == DWORD1(v20) )
break;
add_pending((__m128i **)&mutex[1], s1);
}
pthread_mutex_unlock(mutex);
v16 = random();
usleep(v16 & 0x3FFF);
pthread_mutex_lock(mutex);
}
if ( s1[6].m128i_i32[1] )
{
if ( s1[6].m128i_i32[0] == 2 )
{
*_errno_location() = 11;
}
else if ( s1[6].m128i_i32[0] == 3 )
{
*(_DWORD *)(a4 + 108) = s1[6].m128i_i32[1];
v15 = mutex[1].__nusers;
v8 = 0;
*(_DWORD *)(a4 + 104) = 2;
*(_DWORD *)(a4 + 112) = v15;
*(_DWORD *)(a4 + 100) = s1[7].m128i_i32[0];
goto LABEL_5;
}
}
}
LABEL_18:
v8 = -1;
goto LABEL_5;
}
v8 = -1;
*_errno_location() = 36;
}
else
{
v8 = -1;
*_errno_location() = 9;
}
LABEL_5:
pthread_mutex_unlock(mutex);
return v8;
}

original_code:
int
cpg_lock(void *handle, const char *resource, lock_flag_t flags, struct cpg_lock *lock)
{
 struct cpg_lock_handle *h = handle;
 struct cpg_lock_msg l, r;
 struct timeval tv;
 int ret = -1;
 if (!h) {
  (*__errno_location ()) = 22;
  return -1;
 }
 pthread_mutex_lock(&h->mutex);
 if (h->pid != (int)getpid()) {
  (*__errno_location ()) = 9;
  goto out;
 }
 if (strlen(resource) > sizeof(l.resource)-1) {
  (*__errno_location ()) = 36;
  goto out;
 }
 memset(&l, 0, sizeof(l));
 memset(&r, 0, sizeof(r));
 strncpy(l.resource, resource, sizeof(l.resource));
 strncpy(lock->resource, resource, sizeof(lock->resource));
 l.owner_pid = h->pid;
 ++h->seq;
 l.owner_tid = h->seq;
 l.request = MSG_LOCK;
 l.flags = (uint32_t)flags;
 if (write_retry(h->fd, &l, sizeof(l), 0) < 0)
  goto out;
 do {
  if (check_pending(&h->pending, &l, &r) == 0)
   break;
  tv.tv_sec = 0;
  tv.tv_usec = random() & 16383;
  if (read_retry(h->fd, &r, sizeof(r), &tv) < 0) {
   if ((*__errno_location ()) == 110) {
    pthread_mutex_unlock(&h->mutex);
    usleep(random() & 16383);
    pthread_mutex_lock(&h->mutex);
    continue;
   }
   goto out;
  }
  if (strcmp(r.resource, l.resource)) {
   do { } while (0);
   add_pending(&h->pending, &r);
   pthread_mutex_unlock(&h->mutex);
   usleep(random() & 16383);
   pthread_mutex_lock(&h->mutex);
   continue;
  }
  if (r.owner_tid != l.owner_tid) {
   do { } while (0);
   add_pending(&h->pending, &r);
   pthread_mutex_unlock(&h->mutex);
   usleep(random() & 16383);
   pthread_mutex_lock(&h->mutex);
   continue;
  }
  break;
 } while (1);
 if (r.owner_nodeid == 0)
  goto out;
 if (r.request == MSG_NAK) {
  (*__errno_location ()) = 11;
  ret = -1;
  goto out;
 }
 if (r.request != MSG_GRANT) {
  goto out;
 }
 lock->state = LOCK_HELD;
 lock->owner_nodeid = r.owner_nodeid;
 lock->owner_pid = h->pid;
 lock->local_id = r.lockid;
 ret = 0;
out:
 pthread_mutex_unlock(&h->mutex);
 return ret;
}

canonical_original_code:
int cpg_lock(void *handle, char *resource, enum lock_flag_t flags, struct cpg_lock *lock)
{
 struct cpg_lock_handle *h = handle;
 struct cpg_lock_msg l; struct cpg_lock_msg r;
 struct timeval tv;
 int ret = -1;
 if (!h) {
  (*__errno_location ()) = 22;
  return -1;
 }
 pthread_mutex_lock(&h->mutex);
 if (h->pid != (int)getpid()) {
  (*__errno_location ()) = 9;
  goto out;
 }
 if (strlen(resource) > sizeof(l.resource)-1) {
  (*__errno_location ()) = 36;
  goto out;
 }
 memset(&l, 0, sizeof(l));
 memset(&r, 0, sizeof(r));
 strncpy(l.resource, resource, sizeof(l.resource));
 strncpy(lock->resource, resource, sizeof(lock->resource));
 l.owner_pid = h->pid;
 ++h->seq;
 l.owner_tid = h->seq;
 l.request = MSG_LOCK;
 l.flags = (unsigned int)flags;
 if (write_retry(h->fd, &l, sizeof(l), 0) < 0)
  goto out;
 do {
  if (check_pending(&h->pending, &l, &r) == 0)
   break;
  tv.tv_sec = 0;
  tv.tv_usec = random() & 16383;
  if (read_retry(h->fd, &r, sizeof(r), &tv) < 0) {
   if ((*__errno_location ()) == 110) {
    pthread_mutex_unlock(&h->mutex);
    usleep(random() & 16383);
    pthread_mutex_lock(&h->mutex);
    continue;
   }
   goto out;
  }
  if (strcmp(r.resource, l.resource)) {
   do { } while (0);
   add_pending(&h->pending, &r);
   pthread_mutex_unlock(&h->mutex);
   usleep(random() & 16383);
   pthread_mutex_lock(&h->mutex);
   continue;
  }
  if (r.owner_tid != l.owner_tid) {
   do { } while (0);
   add_pending(&h->pending, &r);
   pthread_mutex_unlock(&h->mutex);
   usleep(random() & 16383);
   pthread_mutex_lock(&h->mutex);
   continue;
  }
  break;
 } while (1);
 if (r.owner_nodeid == 0)
  goto out;
 if (r.request == MSG_NAK) {
  (*__errno_location ()) = 11;
  ret = -1;
  goto out;
 }
 if (r.request != MSG_GRANT) {
  goto out;
 }
 lock->state = LOCK_HELD;
 lock->owner_nodeid = r.owner_nodeid;
 lock->owner_pid = h->pid;
 lock->local_id = r.lockid;
 ret = 0;
out:
 pthread_mutex_unlock(&h->mutex);
 return ret;
}

variable_types:
handle
void *

variable_types:
resource
char *

variable_types:
flags
enum lock_flag_t { FL_TRY=1 }

variable_types: struct cpg_lock { char resource[96]; int local_fd; int local_id; enum lock_state_t { LOCK_FREE=0, LOCK_PENDING=1, LOCK_HELD=2 } state; int owner_nodeid; int owner_pid; int owner_tid; } *

variable_types: struct cpg_lock_msg { char resource[96]; int request; unsigned int owner_nodeid; unsigned int owner_pid; unsigned int flags; unsigned int lockid; unsigned int owner_tid; char pad[8]; }

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: ret int

user_defined_types: struct cpg_lock { char resource[96]; int local_fd; int local_id; enum lock_state_t state; int owner_nodeid; int owner_pid; int owner_tid; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

user_defined_types: struct list_entry { struct list_entry *le_next; }


original_code:
int
cpg_unlock(void *handle, struct cpg_lock *lock)
{
 struct cpg_lock_handle *h = handle;
 struct cpg_lock_msg l;
 int ret = -1;
 if (!h) {
  (*__errno_location ()) = 22;
  goto out;
 }
 if (h->pid != (int)getpid()) {
  (*__errno_location ()) = 9;
  goto out;
 }
 if (lock->state != LOCK_HELD) {
  (*__errno_location ()) = 22;
  goto out;
 }
 if (!lock->local_id) {
  (*__errno_location ()) = 22;
  goto out;
 }
 strncpy(l.resource, lock->resource, sizeof(l.resource));
 l.request = MSG_UNLOCK;
 l.owner_nodeid = lock->owner_nodeid;
 l.owner_pid = lock->owner_pid;
 l.lockid = lock->local_id;
 l.owner_tid = 0;
 lock->state = LOCK_FREE;
 ret = write_retry(h->fd, &l, sizeof(l), 0);
out:
 return ret;
}

user_defined_types: struct cpg_lock_msg { char resource[96]; int request; unsigned int owner_nodeid; unsigned int owner_pid; unsigned int flags; unsigned int lockid; unsigned int owner_tid; char pad[8]; }

user_defined_types: enum lock_state_t { LOCK_FREE=0, LOCK_PENDING=1, LOCK_HELD=2 }


decompiled_code:
__int64 __fastcall cpg_lock_fin(pthread_mutex_t *mutex)
{
unsigned int v1; // ebx
__int64 result; // rax

if ( mutex )
{
pthread_mutex_lock(mutex);
v1 = mutex[1].__nusers;
if ( v1 == getpid() )
{
close(mutex[1].__owner);
pthread_mutex_destroy(mutex);
free(mutex);
result = 0LL;
}
else
{
*_errno_location() = 9;
result = 0xFFFFFFFFLL;
}
}
else
{
*_errno_location() = 22;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(pthread_mutex_t *mutex)
{
unsigned int v1; // ebx
__int64 result; // rax

if ( mutex )
{
pthread_mutex_lock(mutex);
v1 = mutex[1].__nusers;
if ( v1 == getpid() )
{
close(mutex[1].__owner);
pthread_mutex_destroy(mutex);
free(mutex);
result = 0LL;
}
else
{
*_errno_location() = 9;
result = 0xFFFFFFFFLL;
}
}
else
{
*_errno_location() = 22;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
cpg_lock_fin(void *handle)
{
 struct cpg_lock_handle *h = handle;
 if (!h) {
  (*__errno_location ()) = 22;
  return -1;
 }
 pthread_mutex_lock(&h->mutex);
 if (h->pid != (int)getpid()) {
  (*__errno_location ()) = 9;
  return -1;
 }
 close(h->fd);
 pthread_mutex_destroy(&h->mutex);
 free(h);
 return 0;
}


main

canonical_name: main

repo: libbybeer/graphstats

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
printf("Int is %d bits on this system.\n", 32LL);
process_file();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
printf("Int is %d bits on this system.\n", 32LL);
func15();
return 0;
}

original_code:
int main(int argc, char **argv){
  printf("Int is %d bits on this system.\n",8*sizeof(int));
  process_file();
  return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
void *__fastcall init_stretchy_bin(_QWORD *a1, unsigned int a2)
{
void *result; // rax

result = calloc(a2, 4uLL);
*a1 = result;
if ( !result )
{
fprintf(stderr, "Can't calloc memory for %s.\n", "bin->elts");
exit(1);
}
a1[1] = a2;
return result;
}

canonical_decompiled_code:
void *__fastcall func7(_QWORD *a1, unsigned int a2)
{
void *result; // rax

result = calloc(a2, 4uLL);
*a1 = result;
if ( !result )
{
fprintf(stderr, "Can't calloc memory for %s.\n", "bin->elts");
exit(1);
}
a1[1] = a2;
return result;
}

original_code:
void init_stretchy_bin(stretchy_bin_t *bin, uint32_t capacity){
  if (( (bin->elts) = (uint32_t *)calloc(capacity,sizeof(uint32_t))) == ((void *)0)){ fprintf( stderr, "Can't calloc memory for %s.\n", "bin->elts"); exit(1); };
  bin->capacity = capacity;
  bin->fill = 0;
}

canonical_original_code:
void init_stretchy_bin(struct stretchy_bin_t *bin, unsigned int capacity){
  if (( (bin->elts) = (unsigned int *)calloc(capacity,sizeof(unsigned int))) == ((void *)0)){ fprintf( stderr, "Can't calloc memory for %s.\n", "bin->elts"); exit(1); };
  bin->capacity = capacity;
  bin->fill = 0;
}

variable_types: struct stretchy_bin_t { unsigned int *elts; unsigned int capacity; unsigned int fill; } *

variable_types:
capacity
unsigned int


decompiled_code:
__int64 __fastcall find_in_stretchy_bin(_DWORD *a1, __int64 a2, int a3)
{
int v4; // esi
_DWORD *v6; // rdx
__int64 result; // rax

v4 = *(_DWORD *)(a2 + 12);
if ( v4 )
{
v6 = *(_DWORD **)a2;
result = 0LL;
while ( *v6 != a3 )
{
result = (unsigned int)(result + 1);
++v6;
if ( (_DWORD)result == v4 )
goto LABEL_7;
}
*a1 = result;
a1[1] = 1;
}
else
{
result = 0LL;
LABEL_7:
*a1 = result;
a1[1] = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_DWORD *a1, __int64 a2, int a3)
{
int v4; // esi
_DWORD *v6; // rdx
__int64 result; // rax

v4 = *(_DWORD *)(a2 + 12);
if ( v4 )
{
v6 = *(_DWORD **)a2;
result = 0LL;
while ( *v6 != a3 )
{
result = (unsigned int)(result + 1);
++v6;
if ( (_DWORD)result == v4 )
goto LABEL_7;
}
*a1 = result;
a1[1] = 1;
}
else
{
result = 0LL;
LABEL_7:
*a1 = result;
a1[1] = 0;
}
return result;
}

original_code:
void find_in_stretchy_bin(int *ret,stretchy_bin_t *bin, uint32_t value){
  int i,j;
  j=0;
  for(i=0;i<bin->fill;i++){
    if(bin->elts[i]==value){
 j=1;
 break;
    }
  }
  ret[0] = i;
  ret[1] = j;
}

canonical_original_code:
void find_in_stretchy_bin(int *ret, struct stretchy_bin_t *bin, unsigned int value){
  int i; int j;
  j=0;
  for(i=0;i<bin->fill;i++){
    if(bin->elts[i]==value){
 j=1;
 break;
    }
  }
  ret[0] = i;
  ret[1] = j;
}

variable_types:
ret
int *

variable_types:
value
unsigned int

variable_types: i int

variable_types: j int

user_defined_types: struct stretchy_bin_t { unsigned int *elts; unsigned int capacity; unsigned int fill; }


decompiled_code:
void *__fastcall add_to_stretchy_bin(__int64 a1, int a2)
{
_DWORD *v3; // rdi
__int64 v4; // rax
void *result; // rax
__int64 v6; // rax

v3 = *(_DWORD **)a1;
v4 = *(unsigned int *)(a1 + 12);
*(_DWORD *)(a1 + 12) = v4 + 1;
v3[v4] = a2;
result = (void *)*(unsigned int *)(a1 + 8);
if ( *(_DWORD *)(a1 + 12) == (_DWORD)result )
{
v6 = (unsigned int)(2 * (_DWORD)result);
*(_DWORD *)(a1 + 8) = v6;
result = realloc(v3, 4 * v6);
*(_QWORD *)a1 = result;
if ( !result )
{
fprintf(stderr, "Can't realloc memory for %s.\n", "bin->elts");
exit(1);
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func9(__int64 a1, int a2)
{
_DWORD *v3; // rdi
__int64 v4; // rax
void *result; // rax
__int64 v6; // rax

v3 = *(_DWORD **)a1;
v4 = *(unsigned int *)(a1 + 12);
*(_DWORD *)(a1 + 12) = v4 + 1;
v3[v4] = a2;
result = (void *)*(unsigned int *)(a1 + 8);
if ( *(_DWORD *)(a1 + 12) == (_DWORD)result )
{
v6 = (unsigned int)(2 * (_DWORD)result);
*(_DWORD *)(a1 + 8) = v6;
result = realloc(v3, 4 * v6);
*(_QWORD *)a1 = result;
if ( !result )
{
fprintf(stderr, "Can't realloc memory for %s.\n", "bin->elts");
exit(1);
}
}
return result;
}

original_code:
void add_to_stretchy_bin(stretchy_bin_t *bin, uint32_t item){
  bin->elts[bin->fill++] = item;
  if (bin->fill==bin->capacity){
    bin->capacity *= 2;
    if (( (bin->elts) = (uint32_t *)realloc((bin->elts),bin->capacity*sizeof(uint32_t))) == ((void *)0)){ fprintf( stderr, "Can't realloc memory for %s.\n", "bin->elts"); exit(1); };
  }
}

canonical_original_code:
void add_to_stretchy_bin(struct stretchy_bin_t *bin, unsigned int item){
  bin->elts[bin->fill++] = item;
  if (bin->fill==bin->capacity){
    bin->capacity *= 2;
    if (( (bin->elts) = (unsigned int *)realloc((bin->elts),bin->capacity*sizeof(unsigned int))) == ((void *)0)){ fprintf( stderr, "Can't realloc memory for %s.\n", "bin->elts"); exit(1); };
  }
}

variable_types:
item
unsigned int


decompiled_code:
int __fastcall print_stretchy_bin(__int64 a1, const char *a2)
{
__int64 v2; // rbx
__int64 v3; // rsi

printf("Bin (%s) has capacity %d and %d items.\n", a2, *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12));
printf("In bin:");
if ( *(_DWORD *)(a1 + 12) )
{
v2 = 0LL;
do
{
v3 = *(unsigned int *)(*(_QWORD *)a1 + 4 * v2++);
printf(" %u", v3);
}
while ( *(_DWORD *)(a1 + 12) > (unsigned int)v2 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, const char *a2)
{
__int64 v2; // rbx
__int64 v3; // rsi

printf("Bin (%s) has capacity %d and %d items.\n", a2, *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12));
printf("In bin:");
if ( *(_DWORD *)(a1 + 12) )
{
v2 = 0LL;
do
{
v3 = *(unsigned int *)(*(_QWORD *)a1 + 4 * v2++);
printf(" %u", v3);
}
while ( *(_DWORD *)(a1 + 12) > (unsigned int)v2 );
}
return putchar(10);
}

original_code:
void print_stretchy_bin(stretchy_bin_t *bin,char *desc){
  int i;
  printf("Bin (%s) has capacity %d and %d items.\n",desc,bin->capacity,bin->fill);
  printf("In bin:");
  for (i=0;i<bin->fill;i++){
    printf(" %u",bin->elts[i]);
  }
  printf("\n");
}

canonical_original_code:
void print_stretchy_bin(struct stretchy_bin_t *bin, char *desc){
  int i;
  printf("Bin (%s) has capacity %d and %d items.\n",desc,bin->capacity,bin->fill);
  printf("In bin:");
  for (i=0;i<bin->fill;i++){
    printf(" %u",bin->elts[i]);
  }
  printf("\n");
}

variable_types:
desc
char *


decompiled_code:
int __fastcall print_stretchy_bin_of_bins(__int64 a1, const char *a2)
{
int result; // eax
__int64 v4; // rbx
__int64 v5; // rdi
char v6[2072]; // [rsp+0h] [rbp-818h] BYREF

printf("Bin (%s) has capacity %d and %d items.\n", a2, *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12));
result = *(_DWORD *)(a1 + 12);
if ( result )
{
v4 = 0LL;
do
{
sprintf(v6, "%s (part %d)", a2, (unsigned int)v4);
v5 = *(unsigned int *)(*(_QWORD *)a1 + 4 * v4++);
result = print_stretchy_bin(v5, v6);
}
while ( *(_DWORD *)(a1 + 12) > (unsigned int)v4 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1, const char *a2)
{
int result; // eax
__int64 v4; // rbx
__int64 v5; // rdi
char v6[2072]; // [rsp+0h] [rbp-818h] BYREF

printf("Bin (%s) has capacity %d and %d items.\n", a2, *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12));
result = *(_DWORD *)(a1 + 12);
if ( result )
{
v4 = 0LL;
do
{
sprintf(v6, "%s (part %d)", a2, (unsigned int)v4);
v5 = *(unsigned int *)(*(_QWORD *)a1 + 4 * v4++);
result = func10(v5, v6);
}
while ( *(_DWORD *)(a1 + 12) > (unsigned int)v4 );
}
return result;
}

original_code:
void print_stretchy_bin_of_bins(stretchy_bin_t *bin,char *desc){
  int i;
  char newdesc[2048];
  printf("Bin (%s) has capacity %d and %d items.\n",desc,bin->capacity,bin->fill);
  for (i=0;i<bin->fill;i++){
    sprintf(newdesc,"%s (part %d)",desc,i);
    print_stretchy_bin((stretchy_bin_t *)bin->elts[i],newdesc);
  }
}

canonical_original_code:
void print_stretchy_bin_of_bins(struct stretchy_bin_t *bin, char *desc){
  int i;
  char newdesc[2048];
  printf("Bin (%s) has capacity %d and %d items.\n",desc,bin->capacity,bin->fill);
  for (i=0;i<bin->fill;i++){
    sprintf(newdesc,"%s (part %d)",desc,i);
    print_stretchy_bin((struct stretchy_bin_t *)bin->elts[i],newdesc);
  }
}

variable_types:
newdesc
char [2048]


decompiled_code:
void __fastcall free_stretchy_bin(void **a1)
{
free(*a1);
}

canonical_decompiled_code:
void __fastcall func12(void **a1)
{
free(*a1);
}

original_code:
void free_stretchy_bin(stretchy_bin_t *bin){
  free(bin->elts);
}

canonical_original_code:
void free_stretchy_bin(struct stretchy_bin_t *bin){
  free(bin->elts);
}


decompiled_code:
void __fastcall free_stretchy_bin_of_bins(__int64 a1)
{
__int64 v2; // rbx
void *v3; // rdi

if ( *(_DWORD *)(a1 + 12) )
{
v2 = 0LL;
do
{
free_stretchy_bin((void **)*(unsigned int *)(*(_QWORD *)a1 + 4 * v2));
v3 = (void *)*(unsigned int *)(*(_QWORD *)a1 + 4 * v2++);
free(v3);
}
while ( *(_DWORD *)(a1 + 12) > (unsigned int)v2 );
}
free(*(void **)a1);
}

canonical_decompiled_code:
void __fastcall func13(__int64 a1)
{
__int64 v2; // rbx
void *v3; // rdi

if ( *(_DWORD *)(a1 + 12) )
{
v2 = 0LL;
do
{
func12((void **)*(unsigned int *)(*(_QWORD *)a1 + 4 * v2));
v3 = (void *)*(unsigned int *)(*(_QWORD *)a1 + 4 * v2++);
free(v3);
}
while ( *(_DWORD *)(a1 + 12) > (unsigned int)v2 );
}
free(*(void **)a1);
}

original_code:
void free_stretchy_bin_of_bins(stretchy_bin_t *bin){
  int i;
  for(i=0;i<bin->fill;i++){
    free_stretchy_bin((stretchy_bin_t *)(bin->elts[i]));
    free((stretchy_bin_t *)bin->elts[i]);
  }
  free(bin->elts);
}

canonical_original_code:
void free_stretchy_bin_of_bins(struct stretchy_bin_t *bin){
  int i;
  for(i=0;i<bin->fill;i++){
    free_stretchy_bin((struct stretchy_bin_t *)(bin->elts[i]));
    free((struct stretchy_bin_t *)bin->elts[i]);
  }
  free(bin->elts);
}


decompiled_code:
void test_stretchy_bin()
{
int v0; // ebx
int v1; // esi
void *v2[3]; // [rsp+0h] [rbp-18h] BYREF

v0 = 0;
init_stretchy_bin(v2, 1u);
do
{
v1 = v0++;
add_to_stretchy_bin((__int64)v2, v1);
}
while ( v0 != 10 );
print_stretchy_bin((__int64)v2, "testbin");
free_stretchy_bin(v2);
}

original_code:
void test_stretchy_bin(){
  stretchy_bin_t testbin;
  uint32_t i;
  init_stretchy_bin(&testbin,1);
  for (i=0;i<10;i++){
    add_to_stretchy_bin(&testbin,i);
  }
  print_stretchy_bin(&testbin,"testbin");
  free_stretchy_bin(&testbin);
}

canonical_original_code:
void test_stretchy_bin(){
  struct stretchy_bin_t testbin;
  unsigned int i;
  init_stretchy_bin(&testbin,1);
  for (i=0;i<10;i++){
    add_to_stretchy_bin(&testbin,i);
  }
  print_stretchy_bin(&testbin,"testbin");
  free_stretchy_bin(&testbin);
}

variable_types: struct stretchy_bin_t { unsigned int *elts; unsigned int capacity; unsigned int fill; }

variable_types:
i
unsigned int


repo: libdx/AigDownloader

decompiled_code:
__int64 dl_download_widget_get_type_once()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("DLDownloadWidget");
v1 = gtk_vbox_get_type();
return g_type_register_static_simple(
v1,
v0,
824LL,
dl_download_widget_class_intern_init,
136LL,
dl_download_widget_init,
0LL);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("DLDownloadWidget");
v1 = gtk_vbox_get_type();
return g_type_register_static_simple(
v1,
v0,
824LL,
dl_download_widget_class_intern_init,
136LL,
dl_download_widget_init,
0LL);
}

original_code: __attribute__((noinline)) static GType dl_download_widget_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((gtk_vbox_get_type ()), g_intern_static_string ("DLDownloadWidget"), sizeof (DLDownloadWidgetClass), (GClassInitFunc)(void (*)(void)) dl_download_widget_class_intern_init, sizeof (DLDownloadWidget), (GInstanceInitFunc)(void (*)(void)) dl_download_widget_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long dl_download_widget_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple ((gtk_vbox_get_type ()), g_intern_static_string ("DLDownloadWidget"), sizeof (DLDownloadWidgetClass), (GClassInitFunc)(void (*)(void)) dl_download_widget_class_intern_init, sizeof (DLDownloadWidget), (GInstanceInitFunc)(void (*)(void)) dl_download_widget_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

return_type: unsigned long


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

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = dl_download_widget_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

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

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = func1();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

original_code: GType dl_download_widget_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = dl_download_widget_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long dl_download_widget_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = dl_download_widget_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 dl_download_widget_controller_get_type_once()
{
__int64 v0; // rax

v0 = g_intern_static_string("DLDownloadWidgetController");
return g_type_register_static_simple(
80LL,
v0,
24LL,
dl_download_widget_controller_class_intern_init,
24LL,
dl_download_widget_controller_init,
0LL);
}

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

v0 = g_intern_static_string("DLDownloadWidgetController");
return g_type_register_static_simple(
80LL,
v0,
24LL,
dl_download_widget_controller_class_intern_init,
24LL,
dl_download_widget_controller_init,
0LL);
}

original_code: __attribute__((noinline)) static GType dl_download_widget_controller_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple (((GType) ((20) << (2))), g_intern_static_string ("DLDownloadWidgetController"), sizeof (DLDownloadWidgetControllerClass), (GClassInitFunc)(void (*)(void)) dl_download_widget_controller_class_intern_init, sizeof (DLDownloadWidgetController), (GInstanceInitFunc)(void (*)(void)) dl_download_widget_controller_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long dl_download_widget_controller_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple (((GType) ((20) << (2))), g_intern_static_string ("DLDownloadWidgetController"), sizeof (DLDownloadWidgetControllerClass), (GClassInitFunc)(void (*)(void)) dl_download_widget_controller_class_intern_init, sizeof (DLDownloadWidgetController), (GInstanceInitFunc)(void (*)(void)) dl_download_widget_controller_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }


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

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = dl_download_widget_controller_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

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

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = func2();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

original_code: GType dl_download_widget_controller_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = dl_download_widget_controller_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long dl_download_widget_controller_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = dl_download_widget_controller_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 dl_application_get_type_once()
{
__int64 v0; // rax

v0 = g_intern_static_string("DLApplication");
return g_type_register_static_simple(
80LL,
v0,
144LL,
dl_application_class_intern_init,
32LL,
dl_application_init,
0LL);
}

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

v0 = g_intern_static_string("DLApplication");
return g_type_register_static_simple(
80LL,
v0,
144LL,
dl_application_class_intern_init,
32LL,
dl_application_init,
0LL);
}

original_code: __attribute__((noinline)) static GType dl_application_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple (((GType) ((20) << (2))), g_intern_static_string ("DLApplication"), sizeof (DLApplicationClass), (GClassInitFunc)(void (*)(void)) dl_application_class_intern_init, sizeof (DLApplication), (GInstanceInitFunc)(void (*)(void)) dl_application_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long dl_application_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple (((GType) ((20) << (2))), g_intern_static_string ("DLApplication"), sizeof (DLApplicationClass), (GClassInitFunc)(void (*)(void)) dl_application_class_intern_init, sizeof (DLApplication), (GInstanceInitFunc)(void (*)(void)) dl_application_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }


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

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = dl_application_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

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

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = func0();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

original_code: GType dl_application_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = dl_application_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long dl_application_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = dl_application_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


original_code:
int m3l_cat_data(node_t *Tmpnode, size_t tot_dim)
{
 size_t i;
  if (strncmp(Tmpnode->type,"LD",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%.16Lf ", Tmpnode->data.ldf[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"D",1) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%.16lf ", Tmpnode->data.df[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"F",1) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%.8f ", Tmpnode->data.f[i] ) < 0) Perror("printf");;
  }
  else if (strncmp(Tmpnode->type,"SC",2) == 0){
   for (i=0; i<tot_dim; i++)
    printf("%c", Tmpnode->data.sc[i]);
  }
  else if(strncmp(Tmpnode->type,"UC",2) == 0){
   for (i=0; i<tot_dim; i++)
    printf("%c", Tmpnode->data.uc[i]);
  }
  else if(strncmp(Tmpnode->type,"C",1) == 0){
   for (i=0; i<tot_dim; i++)
    printf("%c", Tmpnode->data.c[i]);
  }
  else if(strncmp(Tmpnode->type,"ULLI",4) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%ulld ", Tmpnode->data.ulli[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"SLLI",4) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%lld " , Tmpnode->data.slli[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"LLI",3) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%lld " , Tmpnode->data.lli[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"ULI",3) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%lu " , Tmpnode->data.uli[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"USI",3) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%u ", Tmpnode->data.usi[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"SI",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%d ", Tmpnode->data.si[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"UI",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%u ", Tmpnode->data.ui[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"LI",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%ld ", Tmpnode->data.li[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"I",1) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%d ", Tmpnode->data.i[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"ST",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%zd ", Tmpnode->data.st[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"PTRDF",1) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%td ", Tmpnode->data.ptrdf[i] ) < 0) Perror("printf");;
  }
  else
  {
   Error("Unknown type");
   return -1;
  }
  return 0;
}

canonical_original_code:
int m3l_cat_data(struct node *Tmpnode, unsigned long tot_dim)
{
 unsigned long i;
  if (strncmp(Tmpnode->type,"LD",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%.16Lf ", Tmpnode->data.ldf[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"D",1) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%.16lf ", Tmpnode->data.df[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"F",1) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%.8f ", Tmpnode->data.f[i] ) < 0) Perror("printf");;
  }
  else if (strncmp(Tmpnode->type,"SC",2) == 0){
   for (i=0; i<tot_dim; i++)
    printf("%c", Tmpnode->data.sc[i]);
  }
  else if(strncmp(Tmpnode->type,"UC",2) == 0){
   for (i=0; i<tot_dim; i++)
    printf("%c", Tmpnode->data.uc[i]);
  }
  else if(strncmp(Tmpnode->type,"C",1) == 0){
   for (i=0; i<tot_dim; i++)
    printf("%c", Tmpnode->data.c[i]);
  }
  else if(strncmp(Tmpnode->type,"ULLI",4) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%ulld ", Tmpnode->data.ulli[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"SLLI",4) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%lld " , Tmpnode->data.slli[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"LLI",3) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%lld " , Tmpnode->data.lli[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"ULI",3) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%lu " , Tmpnode->data.uli[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"USI",3) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%u ", Tmpnode->data.usi[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"SI",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%d ", Tmpnode->data.si[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"UI",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%u ", Tmpnode->data.ui[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"LI",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%ld ", Tmpnode->data.li[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"I",1) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%d ", Tmpnode->data.i[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"ST",2) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%zd ", Tmpnode->data.st[i] ) < 0) Perror("printf");;
  }
  else if(strncmp(Tmpnode->type,"PTRDF",1) == 0){
   for (i=0; i<tot_dim; i++)
    if( printf("%td ", Tmpnode->data.ptrdf[i] ) < 0) Perror("printf");;
  }
  else
  {
   Error("Unknown type");
   return -1;
  }
  return 0;
}

variable_types: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str { struct node *List; } **linknode; unsigned long lcounter; char no_malloc; int ap; } *

variable_types:
i
unsigned long

user_defined_types: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t data; long create_time; struct node *next; struct find_str **linknode; unsigned long lcounter; char no_malloc; int ap; }


original_code:
int m3l_AllocateLinkInfo(node_t **Slist, node_t *Tlist){
 size_t lcounter;
 struct find_str **realloc_linknode;
 if( (*Slist)->linknode == ((void *)0)){
  if( ( (*Slist)->linknode = (find_str_t **)malloc(sizeof(find_str_t *))) == ((void *)0))
   Perror("linknode malloc");
  if( ( (*Slist)->linknode[0] = (find_str_t *)malloc(sizeof(find_str_t))) == ((void *)0))
   Perror("linknode malloc");
  (*Slist)->linknode[0]->List = Tlist;
  (*Slist)->lcounter = 1;
  return 1;
 }
 else{
  lcounter = (*Slist)->lcounter;
  realloc_linknode = ((void *)0);
  if( ( realloc_linknode = (find_str_t **)realloc( (*Slist)->linknode, (lcounter+1) * sizeof(find_str_t *))) == ((void *)0)){
   Perror("linknode malloc");}
  else
   (*Slist)->linknode = realloc_linknode;
  if( ( (*Slist)->linknode[lcounter] = (find_str_t *)malloc(sizeof(find_str_t))) == ((void *)0))
   Perror("linknode malloc");
  (*Slist)->linknode[lcounter]->List = Tlist;
  (*Slist)->lcounter++;
  return 1;
 }
 return -1;
}

canonical_original_code:
int m3l_AllocateLinkInfo(struct node **Slist, struct node *Tlist){
 unsigned long lcounter;
 struct find_str **realloc_linknode;
 if( (*Slist)->linknode == ((void *)0)){
  if( ( (*Slist)->linknode = (struct find_str **)malloc(sizeof(struct find_str *))) == ((void *)0))
   Perror("linknode malloc");
  if( ( (*Slist)->linknode[0] = (struct find_str *)malloc(sizeof(find_str_t))) == ((void *)0))
   Perror("linknode malloc");
  (*Slist)->linknode[0]->List = Tlist;
  (*Slist)->lcounter = 1;
  return 1;
 }
 else{
  lcounter = (*Slist)->lcounter;
  realloc_linknode = ((void *)0);
  if( ( realloc_linknode = (struct find_str **)realloc( (*Slist)->linknode, (lcounter+1) * sizeof(struct find_str *))) == ((void *)0)){
   Perror("linknode malloc");}
  else
   (*Slist)->linknode = realloc_linknode;
  if( ( (*Slist)->linknode[lcounter] = (struct find_str *)malloc(sizeof(find_str_t))) == ((void *)0))
   Perror("linknode malloc");
  (*Slist)->linknode[lcounter]->List = Tlist;
  (*Slist)->lcounter++;
  return 1;
 }
 return -1;
}

variable_types: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str { struct node *List; } **linknode; unsigned long lcounter; char no_malloc; int ap; } **

variable_types:
Tlist
struct node *

variable_types:
lcounter
unsigned long

variable_types: struct find_str { struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str **linknode; unsigned long lcounter; char no_malloc; int ap; } *List; } **


decompiled_code:
__int64 __fastcall m3l_ln_recrt_list(char ***a1, __int64 *a2, const char *a3)
{
char *v4; // rax
char *v5; // rax
const char *v6; // rcx
char **v7; // rsi
int v8; // er8
__int64 result; // rax

v4 = (*a1)[1];
*(_OWORD *)v4 = 0LL;
*((_OWORD *)v4 + 1) = 0LL;
*((_OWORD *)v4 + 2) = 0LL;
v5 = **a1;
*(_DWORD *)v5 = 0;
v5[4] = 0;
if ( a3 )
v6 = a3;
else
v6 = *(const char **)(*a2 + 8);
if ( snprintf((*a1)[1], 0x30uLL, "%s", v6) < 0 )
{
Perror("snprintf");
result = 0xFFFFFFFFLL;
}
else
{
strcpy(**a1, "LINK");
if ( (unsigned int)m3l_Free_data_str(a1) )
{
Error("Free_data_str");
result = 0xFFFFFFFFLL;
}
else
{
(*a1)[9] = (char *)*a2;
v7 = *a1;
v7[3] = (_BYTE *)(m3l_AllocateLinkInfo + 1);
v8 = m3l_AllocateLinkInfo(a2, (__int64)v7);
result = 1LL;
if ( v8 < 0 )
{
Error("AllocateLinkInfo");
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char ***a1, __int64 *a2, const char *a3)
{
char *v4; // rax
char *v5; // rax
const char *v6; // rcx
char **v7; // rsi
int v8; // er8
__int64 result; // rax

v4 = (*a1)[1];
*(_OWORD *)v4 = 0LL;
*((_OWORD *)v4 + 1) = 0LL;
*((_OWORD *)v4 + 2) = 0LL;
v5 = **a1;
*(_DWORD *)v5 = 0;
v5[4] = 0;
if ( a3 )
v6 = a3;
else
v6 = *(const char **)(*a2 + 8);
if ( snprintf((*a1)[1], 0x30uLL, "%s", v6) < 0 )
{
Perror("snprintf");
result = 0xFFFFFFFFLL;
}
else
{
strcpy(**a1, "LINK");
if ( (unsigned int)m3l_Free_data_str(a1) )
{
Error("Free_data_str");
result = 0xFFFFFFFFLL;
}
else
{
(*a1)[9] = (char *)*a2;
v7 = *a1;
v7[3] = (_BYTE *)(m3l_AllocateLinkInfo + 1);
v8 = func0(a2, (__int64)v7);
result = 1LL;
if ( v8 < 0 )
{
Error("AllocateLinkInfo");
result = 0xFFFFFFFFLL;
}
}
}
return result;
}

original_code:
int m3l_ln_recrt_list(node_t ** Tlist, node_t **Slist, char *NewName){
 bzero( (*Tlist)->name, 48);
 bzero( (*Tlist)->type, 5);
 if(NewName != ((void *)0)){
  if( snprintf((*Tlist)->name, 48,"%s",NewName) < 0){
   Perror("snprintf");
   return -1;
  }
 }
 else{
  if( snprintf((*Tlist)->name, 48,"%s", (*Slist)->name) < 0){
   Perror("snprintf");
   return -1;
  }
 }
 if( snprintf( (*Tlist)->type, 5,"%s", "LINK") < 0){
  Perror("snprintf");
  return -1;
 }
 if ( m3l_Free_data_str(Tlist) != 0){
  Error("Free_data_str");
  return -1;
 }
 (*Tlist)->child = (*Slist);
 (*Tlist)->ndim = 1;
 if( m3l_AllocateLinkInfo(Slist, (*Tlist)) < 0){
  Error("AllocateLinkInfo");
  return -1;
 }
 return 1;
}

canonical_original_code:
int m3l_ln_recrt_list(struct node **Tlist, struct node **Slist, char *NewName){
 bzero( (*Tlist)->name, 48);
 bzero( (*Tlist)->type, 5);
 if(NewName != ((void *)0)){
  if( snprintf((*Tlist)->name, 48,"%s",NewName) < 0){
   Perror("snprintf");
   return -1;
  }
 }
 else{
  if( snprintf((*Tlist)->name, 48,"%s", (*Slist)->name) < 0){
   Perror("snprintf");
   return -1;
  }
 }
 if( snprintf( (*Tlist)->type, 5,"%s", "LINK") < 0){
  Perror("snprintf");
  return -1;
 }
 if ( m3l_Free_data_str(Tlist) != 0){
  Error("Free_data_str");
  return -1;
 }
 (*Tlist)->child = (*Slist);
 (*Tlist)->ndim = 1;
 if( m3l_AllocateLinkInfo(Slist, (*Tlist)) < 0){
  Error("AllocateLinkInfo");
  return -1;
 }
 return 1;
}

variable_types:
Slist
struct node **

variable_types:
NewName
char *

user_defined_types: union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; }


decompiled_code:
__int64 __fastcall m3l_ln_crt_list(__int64 *a1, const char *a2, __int64 a3)
{
const char *v4; // rcx
__int64 v5; // r12
__int64 result; // rax
char s[8]; // [rsp+0h] [rbp-68h] BYREF
__int64 v8; // [rsp+38h] [rbp-30h]
__int64 v9; // [rsp+40h] [rbp-28h]

if ( a2 )
v4 = a2;
else
v4 = *(const char **)(*a1 + 8);
if ( snprintf(&s[5], 0x30uLL, "%s", v4) < 0 )
{
Perror("m3l_ln_crt_list: snprintf");
result = 0LL;
}
else
{
strcpy(s, "LINK");
v8 = 1LL;
v9 = 0LL;
v5 = m3l_AllocateNode(a3);
if ( v5 )
{
*(_QWORD *)(v5 + 72) = *a1;
if ( (int)m3l_AllocateLinkInfo(a1, v5) < 0 )
{
v5 = 0LL;
Error("m3l_ln_crt_list: AllocateLinkInfo");
}
}
else
{
Error("m3l_ln_crt_list: Allocate");
}
result = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, const char *a2, __int64 a3)
{
const char *v4; // rcx
__int64 v5; // r12
__int64 result; // rax
char s[8]; // [rsp+0h] [rbp-68h] BYREF
__int64 v8; // [rsp+38h] [rbp-30h]
__int64 v9; // [rsp+40h] [rbp-28h]

if ( a2 )
v4 = a2;
else
v4 = *(const char **)(*a1 + 8);
if ( snprintf(&s[5], 0x30uLL, "%s", v4) < 0 )
{
Perror("m3l_ln_crt_list: snprintf");
result = 0LL;
}
else
{
strcpy(s, "LINK");
v8 = 1LL;
v9 = 0LL;
v5 = m3l_AllocateNode(a3);
if ( v5 )
{
*(_QWORD *)(v5 + 72) = *a1;
if ( (int)func0(a1, v5) < 0 )
{
v5 = 0LL;
Error("m3l_ln_crt_list: AllocateLinkInfo");
}
}
else
{
Error("m3l_ln_crt_list: Allocate");
}
result = v5;
}
return result;
}

original_code:
node_t *m3l_ln_crt_list(node_t **Slist, char *NewName, opts_t *Popts){
 node_t *Pnode;
 tmpstruct_t TMPSTR;
 if(NewName != ((void *)0)){
  if( snprintf(TMPSTR.Name_Of_List, sizeof(TMPSTR.Name_Of_List),"%s",NewName) < 0){
   Perror("m3l_ln_crt_list: snprintf");
   return (node_t *) ((void *)0);
  }
 }
 else{
  if( snprintf(TMPSTR.Name_Of_List, sizeof(TMPSTR.Name_Of_List),"%s", (*Slist)->name) < 0){
   Perror("m3l_ln_crt_list: snprintf");
   return (node_t *) ((void *)0);
  }
 }
 if( snprintf(TMPSTR.Type, sizeof(TMPSTR.Type),"LINK") < 0){
  Perror("m3l_ln_crt_list: snprintf");
  return (node_t *) ((void *)0);
 }
 TMPSTR.ndim = 1;
 TMPSTR.dim = ((void *)0);
 if( (Pnode = m3l_AllocateNode(TMPSTR, Popts)) == ((void *)0)){
  Error("m3l_ln_crt_list: Allocate");
  return (node_t *)((void *)0);
 }
 Pnode->child = (*Slist);
 if( m3l_AllocateLinkInfo(Slist, Pnode) < 0){
  Error("m3l_ln_crt_list: AllocateLinkInfo");
  return (node_t *) ((void *)0);
 }
 return Pnode;
}

canonical_original_code:
struct node *m3l_ln_crt_list(struct node **Slist, char *NewName, struct opts *Popts){
 struct node *Pnode;
 struct tmpstruct TMPSTR;
 if(NewName != ((void *)0)){
  if( snprintf(TMPSTR.Name_Of_List, sizeof(TMPSTR.Name_Of_List),"%s",NewName) < 0){
   Perror("m3l_ln_crt_list: snprintf");
   return (struct node *) ((void *)0);
  }
 }
 else{
  if( snprintf(TMPSTR.Name_Of_List, sizeof(TMPSTR.Name_Of_List),"%s", (*Slist)->name) < 0){
   Perror("m3l_ln_crt_list: snprintf");
   return (struct node *) ((void *)0);
  }
 }
 if( snprintf(TMPSTR.Type, sizeof(TMPSTR.Type),"LINK") < 0){
  Perror("m3l_ln_crt_list: snprintf");
  return (struct node *) ((void *)0);
 }
 TMPSTR.ndim = 1;
 TMPSTR.dim = ((void *)0);
 if( (Pnode = m3l_AllocateNode(TMPSTR, Popts)) == ((void *)0)){
  Error("m3l_ln_crt_list: Allocate");
  return (struct node *)((void *)0);
 }
 Pnode->child = (*Slist);
 if( m3l_AllocateLinkInfo(Slist, Pnode) < 0){
  Error("m3l_ln_crt_list: AllocateLinkInfo");
  return (struct node *) ((void *)0);
 }
 return Pnode;
}

variable_types: struct opts { char opt_a; char opt_b; char opt_c; char opt_d; char opt_e; char opt_f; char opt_i; char opt_k; char opt_l; char opt_m; char opt_n; char opt_p; char opt_r; char opt_s; char opt_u; char opt_linkscleanemptrefs; char opt_nomalloc; char opt_tcpencoding; char opt_tcpheader; char opt_shutdown; char opt_add; char opt_MEMCP; char opt_EOBseq; char opt_REOBseq; char opt_format; char opt_xformat; } *

variable_types: struct tmpstruct { char Type[5]; unsigned long ndim; }

return_type: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str { struct node *List; } **linknode; unsigned long lcounter; char no_malloc; int ap; } *


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

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

original_code:
int m3l_ln_cleanemptylinksref(node_t **List, opts_t *Popt){
 size_t i, counter;
 counter = 0;
 find_str_t **TMP;
 return 0;
 if( (*List) == ((void *)0)){
  Warning("ln_cleanemptylinksref: Empty node");
  return -1;
 }
 if((*List)->lcounter > 0 ){
  for(i=0; i< (*List)->lcounter; i++)
   if( (*List)->linknode[i]->List != ((void *)0))counter++;
 }
 else{
  return 0;
 }
 if(counter > 0){
  if( (TMP = (find_str_t **)malloc( (*List)->lcounter * sizeof(find_str_t *))) == ((void *)0))
   Perror("ln_cleanemptylinksref malloc");
  for(i=0; i< (*List)->lcounter; i++){
   TMP[i] = ((void *)0);
   if( (*List)->linknode[i]->List != ((void *)0)){
    if( (TMP[i] = (find_str_t *)malloc( sizeof(find_str_t))) == ((void *)0))
     Perror("ln_cleanemptylinksref malloc");
    TMP[i]->List = (*List)->linknode[i]->List;
   }
  }
  if(counter < (*List)->lcounter){
   for(i=0; i< (*List)->lcounter; i++)
    free((*List)->linknode[i]);
   free((*List)->linknode);
   if( ((*List)->linknode = (find_str_t **)malloc( counter * sizeof(find_str_t *))) == ((void *)0))
    Perror("ln_cleanemptylinksref malloc");
   for(i=0; i< counter; i++){
    if( ((*List)->linknode[i] = (find_str_t *)malloc( sizeof(find_str_t))) == ((void *)0))
     Perror("ln_cleanemptylinksref malloc");
    (*List)->linknode[i]->List = TMP[i]->List ;
   }
   (*List)->lcounter = counter;
   for(i=0; i< (*List)->lcounter; i++){
    if(TMP[i] != ((void *)0))free(TMP[i]);
   }
   free(TMP);
   return 1;
  }
  else if(counter > (*List)->lcounter){
   return -2;
  }
  else{
   for(i=0; i< (*List)->lcounter; i++){
    if(TMP[i] != ((void *)0))free(TMP[i]);
   }
   free(TMP);
   return -3;
  }
 }
 else if(counter == 0){
  for(i=0; i< (*List)->lcounter; i++){
   free((*List)->linknode[i]);
   if(TMP[i] != ((void *)0))free(TMP[i]);
  }
  free((*List)->linknode);
  free(TMP);
  (*List)->lcounter = 0;
  return 1;
 }
 return -1;
}

canonical_original_code:
int m3l_ln_cleanemptylinksref(struct node **List, struct opts *Popt){
 unsigned long i; unsigned long counter;
 counter = 0;
 struct find_str **TMP;
 return 0;
 if( (*List) == ((void *)0)){
  Warning("ln_cleanemptylinksref: Empty node");
  return -1;
 }
 if((*List)->lcounter > 0 ){
  for(i=0; i< (*List)->lcounter; i++)
   if( (*List)->linknode[i]->List != ((void *)0))counter++;
 }
 else{
  return 0;
 }
 if(counter > 0){
  if( (TMP = (struct find_str **)malloc( (*List)->lcounter * sizeof(struct find_str *))) == ((void *)0))
   Perror("ln_cleanemptylinksref malloc");
  for(i=0; i< (*List)->lcounter; i++){
   TMP[i] = ((void *)0);
   if( (*List)->linknode[i]->List != ((void *)0)){
    if( (TMP[i] = (struct find_str *)malloc( sizeof(find_str_t))) == ((void *)0))
     Perror("ln_cleanemptylinksref malloc");
    TMP[i]->List = (*List)->linknode[i]->List;
   }
  }
  if(counter < (*List)->lcounter){
   for(i=0; i< (*List)->lcounter; i++)
    free((*List)->linknode[i]);
   free((*List)->linknode);
   if( ((*List)->linknode = (struct find_str **)malloc( counter * sizeof(struct find_str *))) == ((void *)0))
    Perror("ln_cleanemptylinksref malloc");
   for(i=0; i< counter; i++){
    if( ((*List)->linknode[i] = (struct find_str *)malloc( sizeof(find_str_t))) == ((void *)0))
     Perror("ln_cleanemptylinksref malloc");
    (*List)->linknode[i]->List = TMP[i]->List ;
   }
   (*List)->lcounter = counter;
   for(i=0; i< (*List)->lcounter; i++){
    if(TMP[i] != ((void *)0))free(TMP[i]);
   }
   free(TMP);
   return 1;
  }
  else if(counter > (*List)->lcounter){
   return -2;
  }
  else{
   for(i=0; i< (*List)->lcounter; i++){
    if(TMP[i] != ((void *)0))free(TMP[i]);
   }
   free(TMP);
   return -3;
  }
 }
 else if(counter == 0){
  for(i=0; i< (*List)->lcounter; i++){
   free((*List)->linknode[i]);
   if(TMP[i] != ((void *)0))free(TMP[i]);
  }
  free((*List)->linknode);
  free(TMP);
  (*List)->lcounter = 0;
  return 1;
 }
 return -1;
}

variable_types:
counter
unsigned long

user_defined_types: struct opts { char opt_a; char opt_b; char opt_c; char opt_d; char opt_e; char opt_f; char opt_i; char opt_k; char opt_l; char opt_m; char opt_n; char opt_p; char opt_r; char opt_s; char opt_u; char opt_linkscleanemptrefs; char opt_nomalloc; char opt_tcpencoding; char opt_tcpheader; char opt_shutdown; char opt_add; char opt_MEMCP; char opt_EOBseq; char opt_REOBseq; char opt_format; char opt_xformat; }


decompiled_code:
__int64 __fastcall m3l_ln(__int64 *a1, __int64 a2, __int64 a3, __int64 *a4, __int64 a5, const char *a6, _BYTE *a7)
{
__int64 v7; // rdi
_QWORD *v10; // rbp
size_t v11; // rdx
int v12; // eax
__int64 v13; // rax
char *****v14; // rdx
const char *v15; // rdi
_QWORD *v16; // rax
unsigned __int64 v17; // r12
char ***v18; // rsi
char *v19; // rdx
__int64 v20; // r12
unsigned __int64 v21; // rdx
char v22; // al
__int64 v23; // rbp
size_t v24; // rdi
_BYTE *v25; // r14
_BYTE *v26; // r8
char v27; // cl
__int64 v28; // rsi
__int64 v29; // rax
char v30; // r10
char v31; // cl
__int64 v32; // rax
_BYTE *v33; // rax
char v34; // bl
unsigned __int8 *v35; // r12
__int64 v36; // rdi
char *v37; // rax
char *v38; // r8
char *v39; // rbp
__int64 v40; // rax
__int64 v41; // rcx
char *v42; // rsi
char *****v43; // rax
const char *v44; // r8
char ***v45; // rsi
char *v46; // rdx
_QWORD *v47; // rax
unsigned __int64 v48; // rbx
__int64 *v49; // rdi
__int64 v50; // rax
unsigned __int64 i; // r14
__int64 v53; // rdx
unsigned __int64 v54; // rbx
__int64 *v55; // rdi
char *v56; // rax
void *v57; // rdi
const char *ptrb; // [rsp+0h] [rbp-A8h]
char *ptrc; // [rsp+0h] [rbp-A8h]
char *ptra; // [rsp+0h] [rbp-A8h]
unsigned __int64 v62; // [rsp+8h] [rbp-A0h]
char *v63; // [rsp+8h] [rbp-A0h]
char *v64; // [rsp+8h] [rbp-A0h]
char v65; // [rsp+10h] [rbp-98h]
char *v66; // [rsp+10h] [rbp-98h]
_QWORD *v67; // [rsp+28h] [rbp-80h] BYREF
__int64 v68; // [rsp+30h] [rbp-78h] BYREF
char *****v69; // [rsp+38h] [rbp-70h] BYREF
char v70[12]; // [rsp+40h] [rbp-68h] BYREF
__int16 v71; // [rsp+4Ch] [rbp-5Ch]
char v72; // [rsp+4Eh] [rbp-5Ah]
char v73; // [rsp+50h] [rbp-58h]
char v74; // [rsp+58h] [rbp-50h]
__int16 v75; // [rsp+5Eh] [rbp-4Ah]
char v76; // [rsp+60h] [rbp-48h]

if ( !*a4 )
{
v17 = -1LL;
Warning("Cp: NULL target list");
return v17;
}
if ( a7[31] == 101 || a7[30] == 99 )
return m3l_ln_cleanemptylinks_localalias(a4, (__int64)a7);
v7 = *a1;
if ( !v7 )
{
v17 = -1LL;
Warning("Cp: NULL source list");
return v17;
}
v67 = (_QWORD *)m3l_locate(v7, a2, a3, a7);
v10 = v67;
if ( !v67 )
{
v17 = 0LL;
Warning("Cp: NULL SFounds");
return v17;
}
v70[6] = 0;
v75 = 0;
v70[10] = 0;
v74 = 114;
v71 = 0;
v72 = 0;
v70[2] = 0;
v73 = 0;
v76 = 0;
v11 = strlen(a6);
v12 = *(unsigned __int8 *)a6 - 46;
if ( *a6 == 46 )
{
v12 = *((unsigned __int8 *)a6 + 1) - 47;
if ( v11 != 2 )
goto LABEL_9;
}
else if ( v11 != 2 )
{
goto LABEL_9;
}
if ( !v12 )
{
v17 = v67[1];
if ( v17 )
{
for ( i = 0LL; i < v17; ++i )
{
v53 = *(_QWORD *)(*v10 + 8 * i);
v69 = *(char ******)(*(_QWORD *)v53 + 64LL);
if ( v69 )
{
v68 = *(_QWORD *)v53;
m3l_ln_list_constprop_0(&v68, (char ***)&v69, (const char *)a5, (__int64)a7);
}
else
{
Warning("can not copy to NULL dir");
}
v10 = v67;
v17 = v67[1];
}
}
goto LABEL_70;
}
LABEL_9:
if ( a7[36] == 97 || (v13 = m3l_locate(*a4, a5, a6, v70), v69 = (char *****)v13, (v14 = (char *****)v13) == 0LL) )
{
v20 = 0LL;
v21 = 0LL;
v22 = *(_BYTE *)a5;
if ( !*(_BYTE *)a5 )
goto LABEL_17;
while ( 1 )
{
v23 = v20 + 1;
v21 += v22 == 47;
v22 = *(_BYTE *)(a5 + v20 + 1);
if ( !v22 )
break;
++v20;
}
v65 = *(_BYTE *)a5;
v62 = v21;
if ( v21 <= 1 )
goto LABEL_17;
v24 = v20 + 2;
v25 = malloc(v20 + 2);
if ( !v25 || (v26 = malloc(v24)) == 0LL )
{
v17 = -1LL;
Perror("malloc");
return v17;
}
v27 = v65;
v28 = 0LL;
v29 = 0LL;
while ( 1 )
{
v29 += v27 == 47;
v30 = *(_BYTE *)(a5 + 1);
if ( v62 == v29 )
break;
++v28;
++a5;
v25[v28 - 1] = v27;
if ( !v30 )
break;
v27 = v30;
}
v31 = *(_BYTE *)(a5 + 1);
v25[v28] = 0;
if ( v31 )
{
v32 = 0LL;
do
{
v26[v32++] = v31;
v31 = *(_BYTE *)(a5 + v32 + 1);
}
while ( v31 );
v33 = &v26[v32];
}
else
{
v33 = v26;
}
v34 = *a6;
*v33 = 0;
if ( v34 )
{
v35 = (unsigned __int8 *)&a6[~v20];
do
v36 = v23++;
while ( v35[v23] );
v66 = v26;
v37 = (char *)malloc(v36 + 2);
v38 = v66;
v39 = v37;
if ( v37 )
{
v40 = 0LL;
v41 = 0LL;
while ( 1 )
{
v41 += v34 == 47;
v42 = &v39[v40];
if ( v62 == v41 )
goto LABEL_42;
v39[v40++] = v34;
v34 = a6[v40];
if ( !v34 )
{
v42 = &v39[v40];
goto LABEL_42;
}
}
}
}
else
{
v64 = v26;
v56 = (char *)malloc(v24);
v38 = v64;
v39 = v56;
v42 = v56;
if ( v56 )
{
LABEL_42:
*v42 = 0;
v63 = v38;
v43 = (char *****)m3l_locate(*a4, v25, v39, v70);
v44 = v63;
v69 = v43;
if ( v43 )
{
v45 = **v43;
v46 = **v45;
if ( *v46 == 68 && v46[1] == 73 && v46[2] == 82 && (unsigned __int64)v43[1] <= 1 )
{
v47 = v67;
v17 = v67[1];
if ( v17 )
{
v17 = 0LL;
v48 = 0LL;
while ( 1 )
{
ptrb = v44;
v49 = *(__int64 **)(*v47 + 8 * v48++);
v50 = m3l_ln_list_constprop_0(v49, v45, v44, (__int64)a7);
v44 = ptrb;
v17 += v50;
v47 = v67;
if ( v67[1] <= v48 )
break;
v45 = **v69;
}
}
ptrc = (char *)v44;
free(v25);
free(v39);
free(ptrc);
m3l_DestroyFound(&v67);
m3l_DestroyFound(&v69);
}
else
{
v17 = -1LL;
Warning("Wrong or not existing target");
free(v25);
free(v39);
free(v63);
m3l_DestroyFound(&v67);
m3l_DestroyFound(&v69);
}
return v17;
}
ptra = v63;
free(v25);
v57 = v39;
goto LABEL_75;
}
}
ptra = v38;
Perror("malloc");
v57 = v25;
LABEL_75:
free(v57);
free(ptra);
goto LABEL_17;
}
v15 = "cp: multiple target nodes";
if ( *(_QWORD *)(v13 + 8) == 1LL )
{
v16 = v67;
v17 = v67[1];
if ( v17 <= 1 )
{
if ( !v17 )
{
LABEL_69:
m3l_DestroyFound(&v69);
LABEL_70:
m3l_DestroyFound(&v67);
return v17;
}
v18 = **v14;
}
else
{
v18 = **v14;
v19 = **v18;
if ( *v19 != 68 || v19[1] != 73 || v19[2] != 82 )
{
v15 = "cp: target node is not DIR";
goto LABEL_16;
}
}
v17 = 0LL;
v54 = 0LL;
while ( 1 )
{
v55 = *(__int64 **)(*v16 + 8 * v54++);
v17 += m3l_ln_list_constprop_0(v55, v18, 0LL, (__int64)a7);
v16 = v67;
if ( v67[1] <= v54 )
break;
v18 = **v69;
}
goto LABEL_69;
}
LABEL_16:
Warning(v15);
m3l_DestroyFound(&v69);
LABEL_17:
v17 = -1LL;
m3l_DestroyFound(&v67);
return v17;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1, __int64 a2, __int64 a3, __int64 *a4, __int64 a5, const char *a6, _BYTE *a7)
{
__int64 v7; // rdi
_QWORD *v10; // rbp
size_t v11; // rdx
int v12; // eax
__int64 v13; // rax
char *****v14; // rdx
const char *v15; // rdi
_QWORD *v16; // rax
unsigned __int64 v17; // r12
char ***v18; // rsi
char *v19; // rdx
__int64 v20; // r12
unsigned __int64 v21; // rdx
char v22; // al
__int64 v23; // rbp
size_t v24; // rdi
_BYTE *v25; // r14
_BYTE *v26; // r8
char v27; // cl
__int64 v28; // rsi
__int64 v29; // rax
char v30; // r10
char v31; // cl
__int64 v32; // rax
_BYTE *v33; // rax
char v34; // bl
unsigned __int8 *v35; // r12
__int64 v36; // rdi
char *v37; // rax
char *v38; // r8
char *v39; // rbp
__int64 v40; // rax
__int64 v41; // rcx
char *v42; // rsi
char *****v43; // rax
const char *v44; // r8
char ***v45; // rsi
char *v46; // rdx
_QWORD *v47; // rax
unsigned __int64 v48; // rbx
__int64 *v49; // rdi
__int64 v50; // rax
unsigned __int64 i; // r14
__int64 v53; // rdx
unsigned __int64 v54; // rbx
__int64 *v55; // rdi
char *v56; // rax
void *v57; // rdi
const char *ptrb; // [rsp+0h] [rbp-A8h]
char *ptrc; // [rsp+0h] [rbp-A8h]
char *ptra; // [rsp+0h] [rbp-A8h]
unsigned __int64 v62; // [rsp+8h] [rbp-A0h]
char *v63; // [rsp+8h] [rbp-A0h]
char *v64; // [rsp+8h] [rbp-A0h]
char v65; // [rsp+10h] [rbp-98h]
char *v66; // [rsp+10h] [rbp-98h]
_QWORD *v67; // [rsp+28h] [rbp-80h] BYREF
__int64 v68; // [rsp+30h] [rbp-78h] BYREF
char *****v69; // [rsp+38h] [rbp-70h] BYREF
char v70[12]; // [rsp+40h] [rbp-68h] BYREF
__int16 v71; // [rsp+4Ch] [rbp-5Ch]
char v72; // [rsp+4Eh] [rbp-5Ah]
char v73; // [rsp+50h] [rbp-58h]
char v74; // [rsp+58h] [rbp-50h]
__int16 v75; // [rsp+5Eh] [rbp-4Ah]
char v76; // [rsp+60h] [rbp-48h]

if ( !*a4 )
{
v17 = -1LL;
Warning("Cp: NULL target list");
return v17;
}
if ( a7[31] == 101 || a7[30] == 99 )
return func5(a4, (__int64)a7);
v7 = *a1;
if ( !v7 )
{
v17 = -1LL;
Warning("Cp: NULL source list");
return v17;
}
v67 = (_QWORD *)m3l_locate(v7, a2, a3, a7);
v10 = v67;
if ( !v67 )
{
v17 = 0LL;
Warning("Cp: NULL SFounds");
return v17;
}
v70[6] = 0;
v75 = 0;
v70[10] = 0;
v74 = 114;
v71 = 0;
v72 = 0;
v70[2] = 0;
v73 = 0;
v76 = 0;
v11 = strlen(a6);
v12 = *(unsigned __int8 *)a6 - 46;
if ( *a6 == 46 )
{
v12 = *((unsigned __int8 *)a6 + 1) - 47;
if ( v11 != 2 )
goto LABEL_9;
}
else if ( v11 != 2 )
{
goto LABEL_9;
}
if ( !v12 )
{
v17 = v67[1];
if ( v17 )
{
for ( i = 0LL; i < v17; ++i )
{
v53 = *(_QWORD *)(*v10 + 8 * i);
v69 = *(char ******)(*(_QWORD *)v53 + 64LL);
if ( v69 )
{
v68 = *(_QWORD *)v53;
func3(&v68, (char ***)&v69, (const char *)a5, (__int64)a7);
}
else
{
Warning("can not copy to NULL dir");
}
v10 = v67;
v17 = v67[1];
}
}
goto LABEL_70;
}
LABEL_9:
if ( a7[36] == 97 || (v13 = m3l_locate(*a4, a5, a6, v70), v69 = (char *****)v13, (v14 = (char *****)v13) == 0LL) )
{
v20 = 0LL;
v21 = 0LL;
v22 = *(_BYTE *)a5;
if ( !*(_BYTE *)a5 )
goto LABEL_17;
while ( 1 )
{
v23 = v20 + 1;
v21 += v22 == 47;
v22 = *(_BYTE *)(a5 + v20 + 1);
if ( !v22 )
break;
++v20;
}
v65 = *(_BYTE *)a5;
v62 = v21;
if ( v21 <= 1 )
goto LABEL_17;
v24 = v20 + 2;
v25 = malloc(v20 + 2);
if ( !v25 || (v26 = malloc(v24)) == 0LL )
{
v17 = -1LL;
Perror("malloc");
return v17;
}
v27 = v65;
v28 = 0LL;
v29 = 0LL;
while ( 1 )
{
v29 += v27 == 47;
v30 = *(_BYTE *)(a5 + 1);
if ( v62 == v29 )
break;
++v28;
++a5;
v25[v28 - 1] = v27;
if ( !v30 )
break;
v27 = v30;
}
v31 = *(_BYTE *)(a5 + 1);
v25[v28] = 0;
if ( v31 )
{
v32 = 0LL;
do
{
v26[v32++] = v31;
v31 = *(_BYTE *)(a5 + v32 + 1);
}
while ( v31 );
v33 = &v26[v32];
}
else
{
v33 = v26;
}
v34 = *a6;
*v33 = 0;
if ( v34 )
{
v35 = (unsigned __int8 *)&a6[~v20];
do
v36 = v23++;
while ( v35[v23] );
v66 = v26;
v37 = (char *)malloc(v36 + 2);
v38 = v66;
v39 = v37;
if ( v37 )
{
v40 = 0LL;
v41 = 0LL;
while ( 1 )
{
v41 += v34 == 47;
v42 = &v39[v40];
if ( v62 == v41 )
goto LABEL_42;
v39[v40++] = v34;
v34 = a6[v40];
if ( !v34 )
{
v42 = &v39[v40];
goto LABEL_42;
}
}
}
}
else
{
v64 = v26;
v56 = (char *)malloc(v24);
v38 = v64;
v39 = v56;
v42 = v56;
if ( v56 )
{
LABEL_42:
*v42 = 0;
v63 = v38;
v43 = (char *****)m3l_locate(*a4, v25, v39, v70);
v44 = v63;
v69 = v43;
if ( v43 )
{
v45 = **v43;
v46 = **v45;
if ( *v46 == 68 && v46[1] == 73 && v46[2] == 82 && (unsigned __int64)v43[1] <= 1 )
{
v47 = v67;
v17 = v67[1];
if ( v17 )
{
v17 = 0LL;
v48 = 0LL;
while ( 1 )
{
ptrb = v44;
v49 = *(__int64 **)(*v47 + 8 * v48++);
v50 = func3(v49, v45, v44, (__int64)a7);
v44 = ptrb;
v17 += v50;
v47 = v67;
if ( v67[1] <= v48 )
break;
v45 = **v69;
}
}
ptrc = (char *)v44;
free(v25);
free(v39);
free(ptrc);
m3l_DestroyFound(&v67);
m3l_DestroyFound(&v69);
}
else
{
v17 = -1LL;
Warning("Wrong or not existing target");
free(v25);
free(v39);
free(v63);
m3l_DestroyFound(&v67);
m3l_DestroyFound(&v69);
}
return v17;
}
ptra = v63;
free(v25);
v57 = v39;
goto LABEL_75;
}
}
ptra = v38;
Perror("malloc");
v57 = v25;
LABEL_75:
free(v57);
free(ptra);
goto LABEL_17;
}
v15 = "cp: multiple target nodes";
if ( *(_QWORD *)(v13 + 8) == 1LL )
{
v16 = v67;
v17 = v67[1];
if ( v17 <= 1 )
{
if ( !v17 )
{
LABEL_69:
m3l_DestroyFound(&v69);
LABEL_70:
m3l_DestroyFound(&v67);
return v17;
}
v18 = **v14;
}
else
{
v18 = **v14;
v19 = **v18;
if ( *v19 != 68 || v19[1] != 73 || v19[2] != 82 )
{
v15 = "cp: target node is not DIR";
goto LABEL_16;
}
}
v17 = 0LL;
v54 = 0LL;
while ( 1 )
{
v55 = *(__int64 **)(*v16 + 8 * v54++);
v17 += func3(v55, v18, 0LL, (__int64)a7);
v16 = v67;
if ( v67[1] <= v54 )
break;
v18 = **v69;
}
goto LABEL_69;
}
LABEL_16:
Warning(v15);
m3l_DestroyFound(&v69);
LABEL_17:
v17 = -1LL;
m3l_DestroyFound(&v67);
return v17;
}

original_code:
size_t m3l_ln(node_t **SList, const char *s_path, const char *s_path_loc, node_t **TList, const char *t_path, const char *t_path_loc, opts_t *Popts)
{
 size_t i,j,k,l , ln_tot_nodes, ln_nodes,len;
 find_t *SFounds, *TFounds;
 int init_call;
 char *path, *path_loc, *newname;
 const char *pc;
 node_t *Tmpnode, *TmpnodePar;
 opts_t *Popts_Tlist, opts;
 init_call = 1;
 if(*TList == ((void *)0)){
  Warning("Cp: NULL target list");
  return -1;
 }
 if (Popts->opt_linkscleanemptlinks == 'e' || Popts->opt_linkscleanemptrefs == 'c'){
   ln_tot_nodes = m3l_ln_cleanemptylinks(TList, Popts);
  return ln_tot_nodes;
 }
 if(*SList == ((void *)0)){
  Warning("Cp: NULL source list");
  return -1;
 }
 if ( (SFounds = m3l_locate( *SList, s_path, s_path_loc, Popts)) == ((void *)0)){
  Warning("Cp: NULL SFounds");
  return 0;
 }
 opts.opt_i = '\0'; opts.opt_d = '\0'; opts.opt_f = '\0'; opts.opt_r = 'r'; opts.opt_I = '\0'; opts.opt_k = '\0'; opts.opt_b = '\0'; opts.opt_l = '\0';
 opts.opt_linkscleanemptrefs = '\0'; opts.opt_linkscleanemptlinks = '\0'; opts.opt_nomalloc = '\0';
 Popts_Tlist = &opts;
 len = strlen(t_path_loc);
 if(strncmp(t_path_loc, "./", 2) == 0 && len == 2){
  for(i=0; i< SFounds->founds; i++){
   TmpnodePar = SFounds->Found_Nodes[i]->List->parent;
   if(TmpnodePar == ((void *)0)){
    Warning("can not copy to NULL dir");
   }
   else{
    Tmpnode = SFounds->Found_Nodes[i]->List;
    if( (ln_nodes = m3l_ln_list(init_call, &Tmpnode, &TmpnodePar, (char *)t_path, Popts ) ) < 0){
     Warning("problem in ln_list");
    }
    else{
    ln_tot_nodes += ln_nodes;
    }
   }
  }
  i = SFounds->founds;
  m3l_DestroyFound(&SFounds);
  return i;
 }
 else{
  if ( Popts->opt_add == 'a' || (TFounds = m3l_locate( *TList, t_path, t_path_loc, Popts_Tlist)) == ((void *)0)){
   pc = t_path;
   i = 0;
   k = 0;
   while(*pc != '\0'){
    if(*pc++ == '/')i++;
    k++;
    }
   if(i > 1){
    pc = t_path;
    if( ( path = (char *)malloc( (k+1)*sizeof(char))) == ((void *)0)){
     Perror("malloc");
     return -1;
    }
    if( (newname = (char *)malloc( (k+1)*sizeof(char))) == ((void *)0)){
     Perror("malloc");
     return -1;
    }
    j = 0;
    l = 0;
    while(*pc != '\0'){
     if(*pc == '/')j++;
     if(j == i )break;
     path[l++] = *pc++;
    }
    path[l] = '\0';
    l = 0;
    pc++;
    while(*pc != '\0'){
     newname[l++] = *pc++;}
    newname[l] = '\0';
    pc = t_path_loc;
    while(*pc++ != '\0')k++;
    if( ( path_loc= (char *)malloc( (k+1)*sizeof(char))) == ((void *)0)){
     Perror("malloc");
     free(path);
     free(path_loc);
     free(newname);
     m3l_DestroyFound(&SFounds);
     return -1;
    }
    j = 0;
    l = 0;
    pc = t_path_loc;
    while(*pc != '\0'){
     if(*pc == '/')j++;
     if(j == i )break;
     path_loc[l++] = *pc++;
    }
    path_loc[l] = '\0';
    if ( (TFounds = m3l_locate( *TList, path, path_loc, Popts_Tlist)) == ((void *)0)){
     free(path);
     free(path_loc);
     free(newname);
     m3l_DestroyFound(&SFounds);
     return -1;
    }
    pc = TFounds->Found_Nodes[0]->List->type;
    if(strncmp(pc, "DIR", 3) != 0 || TFounds->founds > 1){
     Warning("Wrong or not existing target");
     free(path);
     free(path_loc);
     free(newname);
     m3l_DestroyFound(&SFounds);
     m3l_DestroyFound(&TFounds);
     return -1;
    }
    ln_tot_nodes = 0;
    for(i=0; i< SFounds->founds; i++){
     if( (ln_nodes = m3l_ln_list(init_call, &SFounds->Found_Nodes[i]->List, &TFounds->Found_Nodes[0]->List, newname, Popts ) ) < 0){
      Warning("problem in ln_list");
     }
     else{
      ln_tot_nodes += ln_nodes;
     }
    }
    free(path);
    free(path_loc);
    free(newname);
    m3l_DestroyFound(&SFounds);
    m3l_DestroyFound(&TFounds);
    return ln_tot_nodes;
   }
   else{
    m3l_DestroyFound(&SFounds);
    return -1;
   }
  }
  else{
   if(TFounds->founds != 1){
    Warning("cp: multiple target nodes");
    m3l_DestroyFound(&TFounds);
    m3l_DestroyFound(&SFounds);
    return -1;
   }
   if( SFounds->founds > 1 && strncmp(TFounds->Found_Nodes[0]->List->type, "DIR", 3) != 0){
    Warning("cp: target node is not DIR");
    m3l_DestroyFound(&TFounds);
    m3l_DestroyFound(&SFounds);
    return -1;
   }
   ln_tot_nodes = 0;
   for(i=0; i< SFounds->founds; i++){
    if( (ln_nodes = m3l_ln_list(init_call, &SFounds->Found_Nodes[i]->List, &TFounds->Found_Nodes[0]->List, (char *) ((void *)0), Popts )) < 0){
     Warning("problem in ln_list");
    }
    else{
     ln_tot_nodes += ln_nodes;
    }
   }
   m3l_DestroyFound(&TFounds);
   m3l_DestroyFound(&SFounds);
   return ln_tot_nodes;
  }
 }
}

canonical_original_code:
unsigned long m3l_ln(struct node **SList, char *s_path, char *s_path_loc, struct node **TList, char *t_path, char *t_path_loc, struct opts *Popts)
{
 unsigned long i; unsigned long j; unsigned long k; unsigned long l; unsigned long ln_tot_nodes; unsigned long ln_nodes; unsigned long len;
 struct find *SFounds; struct find *TFounds;
 int init_call;
 char *path; char *path_loc; char *newname;
 char *pc;
 struct node *Tmpnode; struct node *TmpnodePar;
 struct opts *Popts_Tlist; struct opts opts;
 init_call = 1;
 if(*TList == ((void *)0)){
  Warning("Cp: NULL target list");
  return -1;
 }
 if (Popts->opt_linkscleanemptlinks == 'e' || Popts->opt_linkscleanemptrefs == 'c'){
   ln_tot_nodes = m3l_ln_cleanemptylinks(TList, Popts);
  return ln_tot_nodes;
 }
 if(*SList == ((void *)0)){
  Warning("Cp: NULL source list");
  return -1;
 }
 if ( (SFounds = m3l_locate( *SList, s_path, s_path_loc, Popts)) == ((void *)0)){
  Warning("Cp: NULL SFounds");
  return 0;
 }
 opts.opt_i = '\0'; opts.opt_d = '\0'; opts.opt_f = '\0'; opts.opt_r = 'r'; opts.opt_I = '\0'; opts.opt_k = '\0'; opts.opt_b = '\0'; opts.opt_l = '\0';
 opts.opt_linkscleanemptrefs = '\0'; opts.opt_linkscleanemptlinks = '\0'; opts.opt_nomalloc = '\0';
 Popts_Tlist = &opts;
 len = strlen(t_path_loc);
 if(strncmp(t_path_loc, "./", 2) == 0 && len == 2){
  for(i=0; i< SFounds->founds; i++){
   TmpnodePar = SFounds->Found_Nodes[i]->List->parent;
   if(TmpnodePar == ((void *)0)){
    Warning("can not copy to NULL dir");
   }
   else{
    Tmpnode = SFounds->Found_Nodes[i]->List;
    if( (ln_nodes = m3l_ln_list(init_call, &Tmpnode, &TmpnodePar, (char *)t_path, Popts ) ) < 0){
     Warning("problem in ln_list");
    }
    else{
    ln_tot_nodes += ln_nodes;
    }
   }
  }
  i = SFounds->founds;
  m3l_DestroyFound(&SFounds);
  return i;
 }
 else{
  if ( Popts->opt_add == 'a' || (TFounds = m3l_locate( *TList, t_path, t_path_loc, Popts_Tlist)) == ((void *)0)){
   pc = t_path;
   i = 0;
   k = 0;
   while(*pc != '\0'){
    if(*pc++ == '/')i++;
    k++;
    }
   if(i > 1){
    pc = t_path;
    if( ( path = (char *)malloc( (k+1)*sizeof(char))) == ((void *)0)){
     Perror("malloc");
     return -1;
    }
    if( (newname = (char *)malloc( (k+1)*sizeof(char))) == ((void *)0)){
     Perror("malloc");
     return -1;
    }
    j = 0;
    l = 0;
    while(*pc != '\0'){
     if(*pc == '/')j++;
     if(j == i )break;
     path[l++] = *pc++;
    }
    path[l] = '\0';
    l = 0;
    pc++;
    while(*pc != '\0'){
     newname[l++] = *pc++;}
    newname[l] = '\0';
    pc = t_path_loc;
    while(*pc++ != '\0')k++;
    if( ( path_loc= (char *)malloc( (k+1)*sizeof(char))) == ((void *)0)){
     Perror("malloc");
     free(path);
     free(path_loc);
     free(newname);
     m3l_DestroyFound(&SFounds);
     return -1;
    }
    j = 0;
    l = 0;
    pc = t_path_loc;
    while(*pc != '\0'){
     if(*pc == '/')j++;
     if(j == i )break;
     path_loc[l++] = *pc++;
    }
    path_loc[l] = '\0';
    if ( (TFounds = m3l_locate( *TList, path, path_loc, Popts_Tlist)) == ((void *)0)){
     free(path);
     free(path_loc);
     free(newname);
     m3l_DestroyFound(&SFounds);
     return -1;
    }
    pc = TFounds->Found_Nodes[0]->List->type;
    if(strncmp(pc, "DIR", 3) != 0 || TFounds->founds > 1){
     Warning("Wrong or not existing target");
     free(path);
     free(path_loc);
     free(newname);
     m3l_DestroyFound(&SFounds);
     m3l_DestroyFound(&TFounds);
     return -1;
    }
    ln_tot_nodes = 0;
    for(i=0; i< SFounds->founds; i++){
     if( (ln_nodes = m3l_ln_list(init_call, &SFounds->Found_Nodes[i]->List, &TFounds->Found_Nodes[0]->List, newname, Popts ) ) < 0){
      Warning("problem in ln_list");
     }
     else{
      ln_tot_nodes += ln_nodes;
     }
    }
    free(path);
    free(path_loc);
    free(newname);
    m3l_DestroyFound(&SFounds);
    m3l_DestroyFound(&TFounds);
    return ln_tot_nodes;
   }
   else{
    m3l_DestroyFound(&SFounds);
    return -1;
   }
  }
  else{
   if(TFounds->founds != 1){
    Warning("cp: multiple target nodes");
    m3l_DestroyFound(&TFounds);
    m3l_DestroyFound(&SFounds);
    return -1;
   }
   if( SFounds->founds > 1 && strncmp(TFounds->Found_Nodes[0]->List->type, "DIR", 3) != 0){
    Warning("cp: target node is not DIR");
    m3l_DestroyFound(&TFounds);
    m3l_DestroyFound(&SFounds);
    return -1;
   }
   ln_tot_nodes = 0;
   for(i=0; i< SFounds->founds; i++){
    if( (ln_nodes = m3l_ln_list(init_call, &SFounds->Found_Nodes[i]->List, &TFounds->Found_Nodes[0]->List, (char *) ((void *)0), Popts )) < 0){
     Warning("problem in ln_list");
    }
    else{
     ln_tot_nodes += ln_nodes;
    }
   }
   m3l_DestroyFound(&TFounds);
   m3l_DestroyFound(&SFounds);
   return ln_tot_nodes;
  }
 }
}

variable_types:
TList
struct node **

variable_types:
j
unsigned long

variable_types:
k
unsigned long

variable_types:
l
unsigned long

variable_types:
len
unsigned long

variable_types: struct find { struct find_str { struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str **linknode; unsigned long lcounter; char no_malloc; int ap; } *List; } **Found_Nodes; unsigned long founds; struct node *Home_Node; } *

variable_types:
path
char *

variable_types:
newname
char *

variable_types:
pc
char *

variable_types: struct opts { char opt_a; char opt_b; char opt_c; char opt_d; char opt_e; char opt_f; char opt_i; char opt_k; char opt_l; char opt_m; char opt_n; char opt_p; char opt_r; char opt_s; char opt_u; char opt_linkscleanemptrefs; char opt_nomalloc; char opt_tcpencoding; char opt_tcpheader; char opt_shutdown; char opt_add; char opt_MEMCP; char opt_EOBseq; char opt_REOBseq; char opt_format; char opt_xformat; }

user_defined_types: struct find { struct find_str **Found_Nodes; unsigned long founds; struct node *Home_Node; }


original_code:
int Check_EOFbuff(char *buff, char *eofbuff, ssize_t n, size_t eoblen, char *EOFBUFF)
{
 size_t counter,i;
 counter = 0;
 if(eoblen < n)
  counter = eoblen ;
 else
  counter = n;
 for (i=counter; i<eoblen; i++)
  *(eofbuff+i-counter) = *(eofbuff+i);
 for (i=0; i<counter; i++)
  *(eofbuff+i+eoblen-counter) = *(buff+n-counter+i);
 eofbuff[eoblen]='\0';
 if(strncmp(eofbuff, EOFBUFF, eoblen) == 0){
  return 1;
 }
 else{
  return 0;
 }
}

canonical_original_code:
int Check_EOFbuff(char *buff, char *eofbuff, long n, unsigned long eoblen, char *EOFBUFF)
{
 unsigned long counter; unsigned long i;
 counter = 0;
 if(eoblen < n)
  counter = eoblen ;
 else
  counter = n;
 for (i=counter; i<eoblen; i++)
  *(eofbuff+i-counter) = *(eofbuff+i);
 for (i=0; i<counter; i++)
  *(eofbuff+i+eoblen-counter) = *(buff+n-counter+i);
 eofbuff[eoblen]='\0';
 if(strncmp(eofbuff, EOFBUFF, eoblen) == 0){
  return 1;
 }
 else{
  return 0;
 }
}

variable_types:
buff
char *

variable_types:
eofbuff
char *

variable_types: n long

variable_types:
eoblen
unsigned long

variable_types:
EOFBUFF
char *

variable_types:
i
unsigned long


original_code:
int Check_EOFfile(char *buff, char *eofbuff, ssize_t n, size_t eoblen, char *EOFBUFF)
{
 size_t i, tecount, count1;
 char *pcloc;
 tecount = 0;
 count1 = 0;
 pcloc = &buff[n-1];
 for(i=0; i<n ; i++)
  if( *(buff+n-i-1) == ' ' || *(buff+n-i-1) == '\t' || *(buff+n-i-1) == '\n'){
   pcloc--;
   tecount++;
  }
  else
   break;
 if(eoblen < n-tecount)
  count1 = eoblen;
 else
  count1 = n-tecount;
 for (i=count1; i<eoblen; i++)
  *(eofbuff+i-count1) = *(eofbuff+i);
 for (i=0; i<count1; i++)
  *(eofbuff+eoblen-i-1) = *pcloc--;
 eofbuff[eoblen]='\0';
 if(strncmp(eofbuff, EOFBUFF, eoblen) == 0){
  return 1;}
 else{
  return 0;
 }
}

canonical_original_code:
int Check_EOFfile(char *buff, char *eofbuff, long n, unsigned long eoblen, char *EOFBUFF)
{
 unsigned long i; unsigned long tecount; unsigned long count1;
 char *pcloc;
 tecount = 0;
 count1 = 0;
 pcloc = &buff[n-1];
 for(i=0; i<n ; i++)
  if( *(buff+n-i-1) == ' ' || *(buff+n-i-1) == '\t' || *(buff+n-i-1) == '\n'){
   pcloc--;
   tecount++;
  }
  else
   break;
 if(eoblen < n-tecount)
  count1 = eoblen;
 else
  count1 = n-tecount;
 for (i=count1; i<eoblen; i++)
  *(eofbuff+i-count1) = *(eofbuff+i);
 for (i=0; i<count1; i++)
  *(eofbuff+eoblen-i-1) = *pcloc--;
 eofbuff[eoblen]='\0';
 if(strncmp(eofbuff, EOFBUFF, eoblen) == 0){
  return 1;}
 else{
  return 0;
 }
}

variable_types:
tecount
unsigned long

variable_types:
pcloc
char *


original_code:
int m3l_Free_data_str(node_t **Lnode)
{
 if(strncmp((*Lnode)->type,"DIR",3) != 0 && strncmp((*Lnode)->type,"LINK",4) != 0 ){
  free((*Lnode)->fdim);
  (*Lnode)->fdim = ((void *)0);
  (*Lnode)->ndim = 0;
  if((*Lnode)->no_malloc == 'n') return 0;
  if (strncmp((*Lnode)->type,"LD",2) == 0){
   free( (*Lnode)->data.ldf);
   (*Lnode)->data.ldf = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"D",1) == 0){
   free( (*Lnode)->data.df);
   (*Lnode)->data.df = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"F",1) == 0){
   free( (*Lnode)->data.f);
   (*Lnode)->data.f = ((void *)0);
  }
  else if (strncmp((*Lnode)->type,"SC",2) == 0){
   free( (*Lnode)->data.sc);
   (*Lnode)->data.sc = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"UC",2) == 0){
   free( (*Lnode)->data.uc);
   (*Lnode)->data.uc = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"C",1) == 0){
   free( (*Lnode)->data.c);
   (*Lnode)->data.c = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"ULLI",4) == 0){
   free( (*Lnode)->data.ulli);
   (*Lnode)->data.ulli = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"SLLI",4) == 0){
   free( (*Lnode)->data.slli);
   (*Lnode)->data.slli = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"LLI",3) == 0){
   free( (*Lnode)->data.lli);
   (*Lnode)->data.lli = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"ULI",3) == 0){
   free( (*Lnode)->data.uli);
   (*Lnode)->data.uli = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"USI",3) == 0){
   free( (*Lnode)->data.usi);
   (*Lnode)->data.usi = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"SI",2) == 0){
   free( (*Lnode)->data.si);
   (*Lnode)->data.si = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"UI",2) == 0){
   free( (*Lnode)->data.ui);
   (*Lnode)->data.ui = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"LI",2) == 0){
   free( (*Lnode)->data.li);
   (*Lnode)->data.li = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"I",1) == 0){
   free( (*Lnode)->data.i);
   (*Lnode)->data.i = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"ST",2) == 0){
   free( (*Lnode)->data.st);
   (*Lnode)->data.st = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"PTRDF",1) == 0){
   free( (*Lnode)->data.ptrdf);
   (*Lnode)->data.ptrdf = ((void *)0);
  }
 }
 return 0;
}

canonical_original_code:
int m3l_Free_data_str(struct node **Lnode)
{
 if(strncmp((*Lnode)->type,"DIR",3) != 0 && strncmp((*Lnode)->type,"LINK",4) != 0 ){
  free((*Lnode)->fdim);
  (*Lnode)->fdim = ((void *)0);
  (*Lnode)->ndim = 0;
  if((*Lnode)->no_malloc == 'n') return 0;
  if (strncmp((*Lnode)->type,"LD",2) == 0){
   free( (*Lnode)->data.ldf);
   (*Lnode)->data.ldf = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"D",1) == 0){
   free( (*Lnode)->data.df);
   (*Lnode)->data.df = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"F",1) == 0){
   free( (*Lnode)->data.f);
   (*Lnode)->data.f = ((void *)0);
  }
  else if (strncmp((*Lnode)->type,"SC",2) == 0){
   free( (*Lnode)->data.sc);
   (*Lnode)->data.sc = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"UC",2) == 0){
   free( (*Lnode)->data.uc);
   (*Lnode)->data.uc = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"C",1) == 0){
   free( (*Lnode)->data.c);
   (*Lnode)->data.c = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"ULLI",4) == 0){
   free( (*Lnode)->data.ulli);
   (*Lnode)->data.ulli = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"SLLI",4) == 0){
   free( (*Lnode)->data.slli);
   (*Lnode)->data.slli = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"LLI",3) == 0){
   free( (*Lnode)->data.lli);
   (*Lnode)->data.lli = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"ULI",3) == 0){
   free( (*Lnode)->data.uli);
   (*Lnode)->data.uli = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"USI",3) == 0){
   free( (*Lnode)->data.usi);
   (*Lnode)->data.usi = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"SI",2) == 0){
   free( (*Lnode)->data.si);
   (*Lnode)->data.si = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"UI",2) == 0){
   free( (*Lnode)->data.ui);
   (*Lnode)->data.ui = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"LI",2) == 0){
   free( (*Lnode)->data.li);
   (*Lnode)->data.li = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"I",1) == 0){
   free( (*Lnode)->data.i);
   (*Lnode)->data.i = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"ST",2) == 0){
   free( (*Lnode)->data.st);
   (*Lnode)->data.st = ((void *)0);
  }
  else if(strncmp((*Lnode)->type,"PTRDF",1) == 0){
   free( (*Lnode)->data.ptrdf);
   (*Lnode)->data.ptrdf = ((void *)0);
  }
 }
 return 0;
}

variable_types: struct node { char *type; char *name; unsigned long *fdim; unsigned long ndim; union data_t { void *v; float *f; double *df; long double *ldf; char *c; char *sc; unsigned char *uc; short *si; unsigned short *usi; int *i; unsigned int *ui; long *li; unsigned long *uli; long long *lli; long long *slli; unsigned long long *ulli; unsigned long *st; long *ptrdf; } data; long create_time; struct node *next; struct find_str { struct node *List; } **linknode; unsigned long lcounter; char no_malloc; int ap; } **


original_code:
int m3l_Free(node_t **Lnode)
{
 size_t i;
 if( m3l_Free_data_str(Lnode) != 0)
  Perror("Free_data_str");
 if((*Lnode)->type != ((void *)0)) {
  free((*Lnode)->type);
  (*Lnode)->type = ((void *)0);
 }
 if((*Lnode)->name != ((void *)0)) {
  free((*Lnode)->name);
  (*Lnode)->name = ((void *)0);
 }
 (*Lnode)->next=((void *)0); (*Lnode)->prev=((void *)0); (*Lnode)->parent=((void *)0); (*Lnode)->child=((void *)0); (*Lnode)->fdim=((void *)0);
 if((*Lnode)->lcounter > 0){
  for (i=0; i<(*Lnode)->lcounter; i++)
   free((*Lnode)->linknode[i]);
  free((*Lnode)->linknode);
 }
 free(*Lnode);
 (*Lnode) = ((void *)0);
 return 0;
}

canonical_original_code:
int m3l_Free(struct node **Lnode)
{
 unsigned long i;
 if( m3l_Free_data_str(Lnode) != 0)
  Perror("Free_data_str");
 if((*Lnode)->type != ((void *)0)) {
  free((*Lnode)->type);
  (*Lnode)->type = ((void *)0);
 }
 if((*Lnode)->name != ((void *)0)) {
  free((*Lnode)->name);
  (*Lnode)->name = ((void *)0);
 }
 (*Lnode)->next=((void *)0); (*Lnode)->prev=((void *)0); (*Lnode)->parent=((void *)0); (*Lnode)->child=((void *)0); (*Lnode)->fdim=((void *)0);
 if((*Lnode)->lcounter > 0){
  for (i=0; i<(*Lnode)->lcounter; i++)
   free((*Lnode)->linknode[i]);
  free((*Lnode)->linknode);
 }
 free(*Lnode);
 (*Lnode) = ((void *)0);
 return 0;
}