decompiled_code:
int __fastcall run_job(__int64 a1, double a2)
{
__int64 v2; // r12
__int64 v3; // r13
struct passwd *v4; // rbp
_BOOL4 v5; // er14
int v6; // eax
__pid_t v7; // eax
int *v8; // r13
const char *v9; // rsi
double v10; // xmm0_8
double v11; // xmm0_8
int *v12; // rax
double v13; // xmm0_8
int *v14; // rax
double v15; // xmm0_8
const char *v16; // rdx
int *v17; // rax
double v18; // xmm0_8
int *v19; // rax
const char *v20; // rdx
const char *v21; // rdx
struct stat *i; // rax
int *v23; // rax
const char *v24; // rdx
int *v25; // rax
const char *v26; // rsi
int *v27; // rax
const char *v28; // rdx
int *v29; // rax
int v30; // eax
__pid_t v31; // eax
__pid_t v32; // er13
int *v33; // rbp
struct stat v35; // [rsp+0h] [rbp-C8h] BYREF
int pipedes[2]; // [rsp+90h] [rbp-38h] BYREF
int v37[2]; // [rsp+98h] [rbp-30h] BYREF

v2 = *(_QWORD *)(a1 + 8);
if ( *(_BYTE *)(a1 + 83) )
{
if ( rename(*(const char **)(v2 + 8), *(const char **)(v2 + 40)) < 0 )
{
v12 = _errno_location();
if ( *v12 == 2 )
{
need_reload = 1;
}
else
{
strerror(*v12);
v13 = log(a2);
LODWORD(v12) = tab_reschedule(a1, "Can't rename %s: %s\n", v13);
}
return (int)v12;
}
need_reload = 1;
if ( stat(*(const char **)(v2 + 40), &v35) < 0 )
{
v14 = _errno_location();
strerror(*v14);
v15 = log(a2);
LODWORD(v12) = tab_reschedule(a1, "Can't stat %s: %s\n", v15);
return (int)v12;
}
v4 = getpwuid(v35.st_uid);
v5 = 1;
if ( !v4 )
{
v11 = log(a2);
LODWORD(v12) = tab_reschedule(a1, "Unknown owner for uid %lu of AT job %s\n", v11);
return (int)v12;
}
}
else
{
v3 = *(_QWORD *)(v2 + 16);
v4 = *(struct passwd **)(a1 + 56);
if ( v4 )
{
v4 = getpwnam(*(const char **)(a1 + 56));
if ( !v4 )
{
log(a2);
LODWORD(v12) = tab_reschedule(a1, "%s: Unknown user\n", v16);
return (int)v12;
}
}
v5 = v3 != 0;
if ( !v3 )
{
v5 = 0;
if ( pipe(pipedes) < 0 )
{
v29 = _errno_location();
strerror(*v29);
v9 = "pipe() call failed: %s\n";
v10 = log(a2);
goto LABEL_42;
}
goto LABEL_62;
}
}
pipedes[0] = -1;
if ( pipe(pipedes) < 0 || pipe(v37) < 0 )
{
v17 = _errno_location();
strerror(*v17);
v18 = log(a2);
if ( pipedes[0] != -1 )
{
close(pipedes[0]);
close(pipedes[1]);
}
LODWORD(v12) = tab_reschedule(a1, "pipe() call failed: %s\n", v18);
return (int)v12;
}
v6 = fcntl(pipedes[1], 1);
fcntl(pipedes[1], 2, v6 | 1u);
v7 = fork();
if ( v7 == -1 )
{
v19 = _errno_location();
strerror(*v19);
log(a2);
close(pipedes[0]);
close(pipedes[1]);
close(v37[0]);
close(v37[1]);
LODWORD(v12) = tab_reschedule(a1, "fork() call failed: %s\n", v20);
return (int)v12;
}
if ( !v7 )
{
close(pipedes[0]);
close(v37[1]);
if ( v37[0] )
{
dup2(v37[0], 0);
close(v37[0]);
}
memset(&v35, 0, 0x5AuLL);
v21 = "AT";
if ( !*(_BYTE *)(a1 + 83) )
v21 = "cron";
sprintf((char *)&v35, "Output from your %s job: %.50s", v21, *(const char **)(a1 + 64));
if ( BYTE6(v35.st_blocks) )
*(_DWORD *)((char *)&v35.st_blocks + 3) = 3026478;
for ( i = &v35; LOBYTE(i->st_dev); i = (struct stat *)((char *)i + 1) )
{
if ( LOBYTE(i->st_dev) == 10 )
LOBYTE(i->st_dev) = 37;
}
execl("/usr/bin/mail", "mail", "-s", &v35, v4->pw_name, 0LL);
v23 = _errno_location();
write(pipedes[1], v23, 4uLL);
exit(1);
}
close(v37[0]);
close(pipedes[1]);
v8 = _errno_location();
if ( read(pipedes[0], v8, 4uLL) > 0 )
{
strerror(*v8);
log(a2);
close(pipedes[0]);
close(v37[1]);
LODWORD(v12) = tab_reschedule(a1, "can't execute /usr/bin/mail: %s\n", v24);
return (int)v12;
}
close(pipedes[0]);
if ( pipe(pipedes) < 0 )
{
strerror(*v8);
v9 = "pipe() call failed: %s\n";
v10 = log(a2);
if ( !v5 )
goto LABEL_42;
goto LABEL_41;
}
LABEL_62:
v30 = fcntl(pipedes[1], 1);
fcntl(pipedes[1], 2, v30 | 1u);
v31 = fork();
v32 = v31;
if ( v31 == -1 )
{
v25 = _errno_location();
strerror(*v25);
v9 = "fork() call failed: %s\n";
v10 = log(a2);
close(pipedes[0]);
close(pipedes[1]);
if ( !v5 )
{
LABEL_42:
LODWORD(v12) = tab_reschedule(a1, v9, v10);
return (int)v12;
}
LABEL_41:
close(v37[1]);
goto LABEL_42;
}
if ( !v31 )
{
close(pipedes[0]);
if ( v5 )
{
if ( v37[1] != 1 )
{
dup2(v37[1], 1);
close(v37[1]);
}
dup2(1, 2);
}
if ( !v4 )
goto LABEL_72;
initgroups(v4->pw_name, v4->pw_gid);
setgid(v4->pw_gid);
setuid(v4->pw_uid);
chdir(v4->pw_dir);
if ( setenv("USER", v4->pw_name, 1) >= 0
&& setenv("LOGNAME", v4->pw_name, 1) >= 0
&& setenv("HOME", v4->pw_dir, 1) >= 0 )
{
v26 = v4->pw_shell;
if ( !*v26 )
v26 = "/bin/sh";
if ( setenv("SHELL", v26, 1) >= 0 )
{
LABEL_72:
if ( *(_BYTE *)(a1 + 83) )
execl("/bin/sh", "sh", *(_QWORD *)(v2 + 40), 0LL);
else
execl("/bin/sh", "sh", "-c", *(_QWORD *)(a1 + 64), 0LL);
}
}
v27 = _errno_location();
write(pipedes[1], v27, 4uLL);
exit(1);
}
if ( v5 )
close(v37[1]);
close(pipedes[1]);
v33 = _errno_location();
if ( read(pipedes[0], v33, 4uLL) > 0 )
{
strerror(*v33);
log(a2);
close(pipedes[0]);
LODWORD(v12) = tab_reschedule(a1, "can't execute /bin/sh: %s\n", v28);
}
else
{
close(pipedes[0]);
*(_DWORD *)(a1 + 84) = v32;
LODWORD(v12) = debug;
if ( debug > 0 )
LODWORD(v12) = fprintf(stderr, "executing >%s<, pid = %ld\n", *(const char **)(a1 + 64), v32);
}
return (int)v12;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, double a2)
{
__int64 v2; // r12
__int64 v3; // r13
struct passwd *v4; // rbp
_BOOL4 v5; // er14
int v6; // eax
__pid_t v7; // eax
int *v8; // r13
const char *v9; // rsi
double v10; // xmm0_8
double v11; // xmm0_8
int *v12; // rax
double v13; // xmm0_8
int *v14; // rax
double v15; // xmm0_8
const char *v16; // rdx
int *v17; // rax
double v18; // xmm0_8
int *v19; // rax
const char *v20; // rdx
const char *v21; // rdx
struct stat *i; // rax
int *v23; // rax
const char *v24; // rdx
int *v25; // rax
const char *v26; // rsi
int *v27; // rax
const char *v28; // rdx
int *v29; // rax
int v30; // eax
__pid_t v31; // eax
__pid_t v32; // er13
int *v33; // rbp
struct stat v35; // [rsp+0h] [rbp-C8h] BYREF
int pipedes[2]; // [rsp+90h] [rbp-38h] BYREF
int v37[2]; // [rsp+98h] [rbp-30h] BYREF

v2 = *(_QWORD *)(a1 + 8);
if ( *(_BYTE *)(a1 + 83) )
{
if ( rename(*(const char **)(v2 + 8), *(const char **)(v2 + 40)) < 0 )
{
v12 = _errno_location();
if ( *v12 == 2 )
{
need_reload = 1;
}
else
{
strerror(*v12);
v13 = log(a2);
LODWORD(v12) = tab_reschedule(a1, "Can't rename %s: %s\n", v13);
}
return (int)v12;
}
need_reload = 1;
if ( stat(*(const char **)(v2 + 40), &v35) < 0 )
{
v14 = _errno_location();
strerror(*v14);
v15 = log(a2);
LODWORD(v12) = tab_reschedule(a1, "Can't stat %s: %s\n", v15);
return (int)v12;
}
v4 = getpwuid(v35.st_uid);
v5 = 1;
if ( !v4 )
{
v11 = log(a2);
LODWORD(v12) = tab_reschedule(a1, "Unknown owner for uid %lu of AT job %s\n", v11);
return (int)v12;
}
}
else
{
v3 = *(_QWORD *)(v2 + 16);
v4 = *(struct passwd **)(a1 + 56);
if ( v4 )
{
v4 = getpwnam(*(const char **)(a1 + 56));
if ( !v4 )
{
log(a2);
LODWORD(v12) = tab_reschedule(a1, "%s: Unknown user\n", v16);
return (int)v12;
}
}
v5 = v3 != 0;
if ( !v3 )
{
v5 = 0;
if ( pipe(pipedes) < 0 )
{
v29 = _errno_location();
strerror(*v29);
v9 = "pipe() call failed: %s\n";
v10 = log(a2);
goto LABEL_42;
}
goto LABEL_62;
}
}
pipedes[0] = -1;
if ( pipe(pipedes) < 0 || pipe(v37) < 0 )
{
v17 = _errno_location();
strerror(*v17);
v18 = log(a2);
if ( pipedes[0] != -1 )
{
close(pipedes[0]);
close(pipedes[1]);
}
LODWORD(v12) = tab_reschedule(a1, "pipe() call failed: %s\n", v18);
return (int)v12;
}
v6 = fcntl(pipedes[1], 1);
fcntl(pipedes[1], 2, v6 | 1u);
v7 = fork();
if ( v7 == -1 )
{
v19 = _errno_location();
strerror(*v19);
log(a2);
close(pipedes[0]);
close(pipedes[1]);
close(v37[0]);
close(v37[1]);
LODWORD(v12) = tab_reschedule(a1, "fork() call failed: %s\n", v20);
return (int)v12;
}
if ( !v7 )
{
close(pipedes[0]);
close(v37[1]);
if ( v37[0] )
{
dup2(v37[0], 0);
close(v37[0]);
}
memset(&v35, 0, 0x5AuLL);
v21 = "AT";
if ( !*(_BYTE *)(a1 + 83) )
v21 = "cron";
sprintf((char *)&v35, "Output from your %s job: %.50s", v21, *(const char **)(a1 + 64));
if ( BYTE6(v35.st_blocks) )
*(_DWORD *)((char *)&v35.st_blocks + 3) = 3026478;
for ( i = &v35; LOBYTE(i->st_dev); i = (struct stat *)((char *)i + 1) )
{
if ( LOBYTE(i->st_dev) == 10 )
LOBYTE(i->st_dev) = 37;
}
execl("/usr/bin/mail", "mail", "-s", &v35, v4->pw_name, 0LL);
v23 = _errno_location();
write(pipedes[1], v23, 4uLL);
exit(1);
}
close(v37[0]);
close(pipedes[1]);
v8 = _errno_location();
if ( read(pipedes[0], v8, 4uLL) > 0 )
{
strerror(*v8);
log(a2);
close(pipedes[0]);
close(v37[1]);
LODWORD(v12) = tab_reschedule(a1, "can't execute /usr/bin/mail: %s\n", v24);
return (int)v12;
}
close(pipedes[0]);
if ( pipe(pipedes) < 0 )
{
strerror(*v8);
v9 = "pipe() call failed: %s\n";
v10 = log(a2);
if ( !v5 )
goto LABEL_42;
goto LABEL_41;
}
LABEL_62:
v30 = fcntl(pipedes[1], 1);
fcntl(pipedes[1], 2, v30 | 1u);
v31 = fork();
v32 = v31;
if ( v31 == -1 )
{
v25 = _errno_location();
strerror(*v25);
v9 = "fork() call failed: %s\n";
v10 = log(a2);
close(pipedes[0]);
close(pipedes[1]);
if ( !v5 )
{
LABEL_42:
LODWORD(v12) = tab_reschedule(a1, v9, v10);
return (int)v12;
}
LABEL_41:
close(v37[1]);
goto LABEL_42;
}
if ( !v31 )
{
close(pipedes[0]);
if ( v5 )
{
if ( v37[1] != 1 )
{
dup2(v37[1], 1);
close(v37[1]);
}
dup2(1, 2);
}
if ( !v4 )
goto LABEL_72;
initgroups(v4->pw_name, v4->pw_gid);
setgid(v4->pw_gid);
setuid(v4->pw_uid);
chdir(v4->pw_dir);
if ( setenv("USER", v4->pw_name, 1) >= 0
&& setenv("LOGNAME", v4->pw_name, 1) >= 0
&& setenv("HOME", v4->pw_dir, 1) >= 0 )
{
v26 = v4->pw_shell;
if ( !*v26 )
v26 = "/bin/sh";
if ( setenv("SHELL", v26, 1) >= 0 )
{
LABEL_72:
if ( *(_BYTE *)(a1 + 83) )
execl("/bin/sh", "sh", *(_QWORD *)(v2 + 40), 0LL);
else
execl("/bin/sh", "sh", "-c", *(_QWORD *)(a1 + 64), 0LL);
}
}
v27 = _errno_location();
write(pipedes[1], v27, 4uLL);
exit(1);
}
if ( v5 )
close(v37[1]);
close(pipedes[1]);
v33 = _errno_location();
if ( read(pipedes[0], v33, 4uLL) > 0 )
{
strerror(*v33);
log(a2);
close(pipedes[0]);
LODWORD(v12) = tab_reschedule(a1, "can't execute /bin/sh: %s\n", v28);
}
else
{
close(pipedes[0]);
*(_DWORD *)(a1 + 84) = v32;
LODWORD(v12) = debug;
if ( debug > 0 )
LODWORD(v12) = fprintf(stderr, "executing >%s<, pid = %ld\n", *(const char **)(a1 + 64), v32);
}
return (int)v12;
}

original_code:
static void run_job(cronjob_t *job)
{
 pid_t pid;
 int need_mailer;
 int mailfd[2], errfd[2];
 struct passwd *pw;
 crontab_t *tab= job->tab;
 need_mailer= (tab->user != ((void*)0));
 if (job->atjob) {
  struct stat st;
  need_mailer= 1;
  if (rename(tab->file, tab->data) < 0) {
   if ((*__errno_location ()) == 2) {
    need_reload= 1;
   } else {
    log(2, "Can't rename %s: %s\n",
     tab->file, strerror((*__errno_location ())));
    tab_reschedule(job);
   }
   return;
  }
  need_reload= 1;
  if (stat(tab->data, &st) < 0) {
   log(3, "Can't stat %s: %s\n",
      tab->data, strerror((*__errno_location ())));
   tab_reschedule(job);
   return;
  }
  if ((pw= getpwuid(st.st_uid)) == ((void*)0)) {
   log(3, "Unknown owner for uid %lu of AT job %s\n",
    (unsigned long) st.st_uid, job->cmd);
   tab_reschedule(job);
   return;
  }
 } else {
  pw= ((void*)0);
  if (job->user != ((void*)0) && (pw= getpwnam(job->user)) == ((void*)0)) {
   log(3, "%s: Unknown user\n", job->user);
   tab_reschedule(job);
   return;
  }
 }
 if (need_mailer) {
  errfd[0]= -1;
  if (pipe(errfd) < 0 || pipe(mailfd) < 0) {
   log(3, "pipe() call failed: %s\n",
       strerror((*__errno_location ())));
   if (errfd[0] != -1) {
    close(errfd[0]);
    close(errfd[1]);
   }
   tab_reschedule(job);
   return;
  }
  (void) fcntl(errfd[1], 2,
    fcntl(errfd[1], 1) | 1);
  if ((pid= fork()) == -1) {
   log(3, "fork() call failed: %s\n",
       strerror((*__errno_location ())));
   close(errfd[0]);
   close(errfd[1]);
   close(mailfd[0]);
   close(mailfd[1]);
   tab_reschedule(job);
   return;
  }
  if (pid == 0) {
   char subject[70+20], *ps;
   close(errfd[0]);
   close(mailfd[1]);
   if (mailfd[0] != 0) {
    dup2(mailfd[0], 0);
    close(mailfd[0]);
   }
   memset(subject, 0, sizeof(subject));
   sprintf(subject,
    "Output from your %s job: %.50s",
    job->atjob ? "AT" : "cron",
    job->cmd);
   if (subject[70] != 0) {
    strcpy(subject+70-3, "...");
   }
   for (ps= subject; *ps != 0; ps++) {
    if (*ps == '\n') *ps= '%';
   }
   execl("/usr/bin/mail", "mail", "-s", subject,
      pw->pw_name, (char *) ((void*)0));
   write(errfd[1], &(*__errno_location ()), sizeof((*__errno_location ())));
   _exit(1);
  }
  close(mailfd[0]);
  close(errfd[1]);
  if (read(errfd[0], &(*__errno_location ()), sizeof((*__errno_location ()))) > 0) {
   log(3, "can't execute /usr/bin/mail: %s\n",
       strerror((*__errno_location ())));
   close(errfd[0]);
   close(mailfd[1]);
   tab_reschedule(job);
   return;
  }
  close(errfd[0]);
 }
 if (pipe(errfd) < 0) {
  log(3, "pipe() call failed: %s\n", strerror((*__errno_location ())));
  if (need_mailer) close(mailfd[1]);
  tab_reschedule(job);
  return;
 }
 (void) fcntl(errfd[1], 2, fcntl(errfd[1], 1) | 1);
 if ((pid= fork()) == -1) {
  log(3, "fork() call failed: %s\n", strerror((*__errno_location ())));
  close(errfd[0]);
  close(errfd[1]);
  if (need_mailer) close(mailfd[1]);
  tab_reschedule(job);
  return;
 }
 if (pid == 0) {
  close(errfd[0]);
  if (need_mailer) {
   if (mailfd[1] != 1) {
    dup2(mailfd[1], 1);
    close(mailfd[1]);
   }
   dup2(1, 2);
  }
  if (pw != ((void*)0)) {
   initgroups(pw->pw_name, pw->pw_gid);
   setgid(pw->pw_gid);
   setuid(pw->pw_uid);
   chdir(pw->pw_dir);
   if (setenv("USER", pw->pw_name, 1) < 0) goto bad;
   if (setenv("LOGNAME", pw->pw_name, 1) < 0) goto bad;
   if (setenv("HOME", pw->pw_dir, 1) < 0) goto bad;
   if (setenv("SHELL", pw->pw_shell[0] == 0 ? "/bin/sh"
      : pw->pw_shell, 1) < 0) goto bad;
  }
  if (job->atjob) {
   execl("/bin/sh", "sh", tab->data, (char *) ((void*)0));
  } else {
   execl("/bin/sh", "sh", "-c", job->cmd, (char *) ((void*)0));
  }
     bad:
  write(errfd[1], &(*__errno_location ()), sizeof((*__errno_location ())));
  _exit(1);
 }
 if (need_mailer) close(mailfd[1]);
 close(errfd[1]);
 if (read(errfd[0], &(*__errno_location ()), sizeof((*__errno_location ()))) > 0) {
  log(3, "can't execute /bin/sh: %s\n", strerror((*__errno_location ())));
  close(errfd[0]);
  tab_reschedule(job);
  return;
 }
 close(errfd[0]);
 job->pid= pid;
 if (debug >= 1) fprintf(stderr, "executing >%s<, pid = %ld\n",
      job->cmd, (long) job->pid);
}

canonical_original_code:
static void run_job(struct cronjob *job)
{
 int pid;
 int need_mailer;
 int mailfd[2]; int errfd[2];
 struct passwd *pw;
 struct crontab *tab = job->tab;
 need_mailer= (tab->user != ((void *)0));
 if (job->atjob) {
  struct stat st;
  need_mailer= 1;
  if (rename(tab->file, tab->data) < 0) {
   if ((*__errno_location ()) == 2) {
    need_reload= 1;
   } else {
    log(2, "Can't rename %s: %s\n",
     tab->file, strerror((*__errno_location ())));
    tab_reschedule(job);
   }
   return;
  }
  need_reload= 1;
  if (stat(tab->data, &st) < 0) {
   log(3, "Can't stat %s: %s\n",
      tab->data, strerror((*__errno_location ())));
   tab_reschedule(job);
   return;
  }
  if ((pw= getpwuid(st.st_uid)) == ((void *)0)) {
   log(3, "Unknown owner for uid %lu of AT job %s\n",
    (unsigned long) st.st_uid, job->cmd);
   tab_reschedule(job);
   return;
  }
 } else {
  pw= ((void *)0);
  if (job->user != ((void *)0) && (pw= getpwnam(job->user)) == ((void *)0)) {
   log(3, "%s: Unknown user\n", job->user);
   tab_reschedule(job);
   return;
  }
 }
 if (need_mailer) {
  errfd[0]= -1;
  if (pipe(errfd) < 0 || pipe(mailfd) < 0) {
   log(3, "pipe() call failed: %s\n",
       strerror((*__errno_location ())));
   if (errfd[0] != -1) {
    close(errfd[0]);
    close(errfd[1]);
   }
   tab_reschedule(job);
   return;
  }
  (void) fcntl(errfd[1], 2,
    fcntl(errfd[1], 1) | 1);
  if ((pid= fork()) == -1) {
   log(3, "fork() call failed: %s\n",
       strerror((*__errno_location ())));
   close(errfd[0]);
   close(errfd[1]);
   close(mailfd[0]);
   close(mailfd[1]);
   tab_reschedule(job);
   return;
  }
  if (pid == 0) {
   char subject[-1]; char *ps;
   close(errfd[0]);
   close(mailfd[1]);
   if (mailfd[0] != 0) {
    dup2(mailfd[0], 0);
    close(mailfd[0]);
   }
   memset(subject, 0, sizeof(subject));
   sprintf(subject,
    "Output from your %s job: %.50s",
    job->atjob ? "AT" : "cron",
    job->cmd);
   if (subject[70] != 0) {
    strcpy(subject+70-3, "...");
   }
   for (ps= subject; *ps != 0; ps++) {
    if (*ps == '\n') *ps= '%';
   }
   execl("/usr/bin/mail", "mail", "-s", subject,
      pw->pw_name, (char *) ((void *)0));
   write(errfd[1], &(*__errno_location ()), sizeof((*__errno_location ())));
   _exit(1);
  }
  close(mailfd[0]);
  close(errfd[1]);
  if (read(errfd[0], &(*__errno_location ()), sizeof((*__errno_location ()))) > 0) {
   log(3, "can't execute /usr/bin/mail: %s\n",
       strerror((*__errno_location ())));
   close(errfd[0]);
   close(mailfd[1]);
   tab_reschedule(job);
   return;
  }
  close(errfd[0]);
 }
 if (pipe(errfd) < 0) {
  log(3, "pipe() call failed: %s\n", strerror((*__errno_location ())));
  if (need_mailer) close(mailfd[1]);
  tab_reschedule(job);
  return;
 }
 (void) fcntl(errfd[1], 2, fcntl(errfd[1], 1) | 1);
 if ((pid= fork()) == -1) {
  log(3, "fork() call failed: %s\n", strerror((*__errno_location ())));
  close(errfd[0]);
  close(errfd[1]);
  if (need_mailer) close(mailfd[1]);
  tab_reschedule(job);
  return;
 }
 if (pid == 0) {
  close(errfd[0]);
  if (need_mailer) {
   if (mailfd[1] != 1) {
    dup2(mailfd[1], 1);
    close(mailfd[1]);
   }
   dup2(1, 2);
  }
  if (pw != ((void *)0)) {
   initgroups(pw->pw_name, pw->pw_gid);
   setgid(pw->pw_gid);
   setuid(pw->pw_uid);
   chdir(pw->pw_dir);
   if (setenv("USER", pw->pw_name, 1) < 0) goto bad;
   if (setenv("LOGNAME", pw->pw_name, 1) < 0) goto bad;
   if (setenv("HOME", pw->pw_dir, 1) < 0) goto bad;
   if (setenv("SHELL", pw->pw_shell[0] == 0 ? "/bin/sh"
      : pw->pw_shell, 1) < 0) goto bad;
  }
  if (job->atjob) {
   execl("/bin/sh", "sh", tab->data, (char *) ((void *)0));
  } else {
   execl("/bin/sh", "sh", "-c", job->cmd, (char *) ((void *)0));
  }
     bad:
  write(errfd[1], &(*__errno_location ()), sizeof((*__errno_location ())));
  _exit(1);
 }
 if (need_mailer) close(mailfd[1]);
 close(errfd[1]);
 if (read(errfd[0], &(*__errno_location ()), sizeof((*__errno_location ()))) > 0) {
  log(3, "can't execute /bin/sh: %s\n", strerror((*__errno_location ())));
  close(errfd[0]);
  tab_reschedule(job);
  return;
 }
 close(errfd[0]);
 job->pid= pid;
 if (debug >= 1) fprintf(stderr, "executing >%s<, pid = %ld\n",
      job->cmd, (long) job->pid);
}

variable_types: struct cronjob { struct cronjob *next; struct crontab { struct crontab *next; char *file; char *user; long mtime; struct cronjob *jobs; char *data; int current; } *tab; unsigned char min[8]; unsigned char hour[8]; unsigned char mday[8]; unsigned char mon[8]; unsigned char wday[8]; char *user; char *cmd; long rtime; char do_mday; char do_wday; char late; char atjob; int pid; } *

variable_types: pid int

variable_types:
mailfd
int [2]

variable_types:
errfd
int [2]

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

variable_types: struct crontab { struct crontab *next; char *file; char *user; long mtime; struct cronjob { struct cronjob *next; struct crontab *tab; unsigned char min[8]; unsigned char hour[8]; unsigned char mday[8]; unsigned char mon[8]; unsigned char wday[8]; char *user; char *cmd; long rtime; char do_mday; char do_wday; char late; char atjob; int pid; } *jobs; char *data; int current; } *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }

variable_types:
subject
char [-1]

variable_types:
ps
char *


usage

repo: klenovic/nucleos-utils

decompiled_code:
void __noreturn usage()
{
fprintf(stderr, "Usage: %s [-d[#]]\n", prog_name);
exit(1);
}

canonical_decompiled_code:
void __noreturn func0()
{
fprintf(stderr, "Usage: %s [-d[#]]\n", prog_name);
exit(1);
}

original_code:
static void usage(void)
{
 fprintf(stderr, "Usage: %s [-d[#]]\n", prog_name);
 exit(1);
}

canonical_original_code:
static void usage()
{
 fprintf(stderr, "Usage: %s [-d[#]]\n", prog_name);
 exit(1);
}

return_type: void


parselength

decompiled_code:
__int64 __fastcall parselength(char *a1, _QWORD *a2)
{
char *v2; // rbx
int v4; // ebp
const unsigned __int16 *v5; // rsi
__int64 i; // rdx
char v7; // al
__int64 v8; // rax

v2 = a1;
if ( *a1 == 43 )
{
v4 = 1;
goto LABEL_4;
}
v4 = 1;
if ( *a1 == 45 )
{
v4 = -1;
LABEL_4:
v2 = a1 + 1;
}
v5 = *__ctype_b_loc();
for ( i = 0LL; ; i = v8 )
{
v7 = *v2;
if ( (v5[*v2] & 0x800) == 0 )
break;
++v2;
v8 = v7 + 10 * i - 48;
if ( i > v8 )
return -1LL;
}
if ( v7 )
return -1LL;
*a2 = v4 * i;
return 0LL;
}

original_code:
static off_t
parselength(char *ls, off_t *sz)
{
 off_t length, oflow;
 int lsign;
 length = 0;
 lsign = 1;
 switch (*ls) {
 case '-':
  lsign = -1;
 case '+':
  ls++;
 }
 while (((*__ctype_b_loc ())[(int) ((*ls))] & (unsigned short int) _ISdigit)) {
  oflow = length * 10 + *ls++ - '0';
  if (oflow < length) return -1; length = oflow;
 }
 switch (*ls) {
 case 'G':
 case 'g':
  oflow = length * 1024;
  if (oflow < length) return -1; length = oflow;
 case 'M':
 case 'm':
  oflow = length * 1024;
  if (oflow < length) return -1; length = oflow;
 case 'K':
 case 'k':
  if (ls[1] != '\0')
   return -1;
  oflow = length * 1024;
  if (oflow < length) return -1; length = oflow;
 case '\0':
  break;
 default:
  return -1;
 }
 *sz = length * lsign;
 return 0;
}

canonical_original_code:
static long parselength(char *ls, long *sz)
{
 long length; long oflow;
 int lsign;
 length = 0;
 lsign = 1;
 switch (*ls) {
 case '-':
  lsign = -1;
 case '+':
  ls++;
 }
 while (((*__ctype_b_loc ())[(int) ((*ls))] & (unsigned short) _ISdigit)) {
  oflow = length * 10 + *ls++ - '0';
  if (oflow < length) return -1; length = oflow;
 }
 switch (*ls) {
 case 'G':
 case 'g':
  oflow = length * 1024;
  if (oflow < length) return -1; length = oflow;
 case 'M':
 case 'm':
  oflow = length * 1024;
  if (oflow < length) return -1; length = oflow;
 case 'K':
 case 'k':
  if (ls[1] != '\0')
   return -1;
  oflow = length * 1024;
  if (oflow < length) return -1; length = oflow;
 case '\0':
  break;
 default:
  return -1;
 }
 *sz = length * lsign;
 return 0;
}

variable_types:
ls
char *

variable_types:
sz
long *

variable_types: length long

variable_types: oflow long

variable_types: lsign int

return_type: long


usage

decompiled_code:
void __noreturn usage()
{
fprintf(
stderr,
"%s\n%s\n",
"usage: truncate [-c] -s [+|-]size[K|k|M|m|G|g] file ...",
" truncate [-c] -r rfile file ...");
exit(1);
}

canonical_decompiled_code:
void __noreturn func7()
{
fprintf(
stderr,
"%s\n%s\n",
"usage: truncate [-c] -s [+|-]size[K|k|M|m|G|g] file ...",
" truncate [-c] -r rfile file ...");
exit(1);
}

original_code:
static void
usage(void)
{
 fprintf(stderr, "%s\n%s\n",
     "usage: truncate [-c] -s [+|-]size[K|k|M|m|G|g] file ...",
     "       truncate [-c] -r rfile file ...");
 exit(1);
}

canonical_original_code:
static void usage()
{
 fprintf(stderr, "%s\n%s\n",
     "usage: truncate [-c] -s [+|-]size[K|k|M|m|G|g] file ...",
     "       truncate [-c] -r rfile file ...");
 exit(1);
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // r12
int v4; // eax
const char **v5; // rbp
__off_t v6; // r12
int v7; // er14
const char **v8; // r13
const char *v9; // rbp
int v10; // eax
int v11; // ebx
int v13; // [rsp+4h] [rbp-E4h]
__int64 v14; // [rsp+8h] [rbp-E0h]
__int64 v15; // [rsp+18h] [rbp-D0h] BYREF
struct stat v16; // [rsp+20h] [rbp-C8h] BYREF

v3 = 0LL;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "cr:s:");
if ( v4 == -1 )
break;
if ( v4 == 114 )
{
do_refer = 1;
v3 = (char *)optarg;
}
else if ( v4 == 115 )
{
if ( parselength((char *)optarg, &v15) == -1 )
{
fprintf(stderr, "invalid size argument `%s'", (const char *)optarg);
exit(1);
}
if ( ((*(_BYTE *)optarg - 43) & 0xFD) == 0 )
do_relative = 1;
got_size = 1;
}
else
{
if ( v4 != 99 )
usage();
no_create = 1;
}
}
v5 = &argv[optind];
if ( got_size + do_refer != 1 || argc - optind <= 0 )
usage();
if ( do_refer )
{
if ( (unsigned int)stat(v3, &v16) == -1 )
{
fputs(v3, stderr);
exit(1);
}
v6 = v16.st_size;
v14 = 0LL;
}
else if ( do_relative )
{
v14 = v15;
v6 = 0LL;
}
else
{
v6 = v15;
v14 = 0LL;
}
v7 = no_create == 0 ? 65 : 1;
v8 = v5 + 1;
v9 = *v5;
if ( v9 )
{
v13 = 0;
while ( 1 )
{
v10 = open(v9, v7, 420LL);
v11 = v10;
if ( v10 != -1 )
break;
if ( *__errno_location() != 2 )
goto LABEL_27;
LABEL_33:
v9 = *v8++;
if ( !v9 )
return v13 != 0;
}
if ( do_relative )
{
if ( (unsigned int)fstat(v10, &v16) == -1 )
{
LABEL_27:
perror(v9);
++v13;
goto LABEL_33;
}
v6 = v16.st_size + v14;
}
if ( v6 < 0 )
v6 = 0LL;
if ( ftruncate(v11, v6) != -1 )
{
close(v11);
goto LABEL_33;
}
goto LABEL_27;
}
v13 = 0;
return v13 != 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // r12
int v4; // eax
const char **v5; // rbp
__off_t v6; // r12
int v7; // er14
const char **v8; // r13
const char *v9; // rbp
int v10; // eax
int v11; // ebx
int v13; // [rsp+4h] [rbp-E4h]
__int64 v14; // [rsp+8h] [rbp-E0h]
__int64 v15; // [rsp+18h] [rbp-D0h] BYREF
struct stat v16; // [rsp+20h] [rbp-C8h] BYREF

v3 = 0LL;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "cr:s:");
if ( v4 == -1 )
break;
if ( v4 == 114 )
{
do_refer = 1;
v3 = (char *)optarg;
}
else if ( v4 == 115 )
{
if ( func8((char *)optarg, &v15) == -1 )
{
fprintf(stderr, "invalid size argument `%s'", (const char *)optarg);
exit(1);
}
if ( ((*(_BYTE *)optarg - 43) & 0xFD) == 0 )
do_relative = 1;
got_size = 1;
}
else
{
if ( v4 != 99 )
func7();
no_create = 1;
}
}
v5 = &argv[optind];
if ( got_size + do_refer != 1 || argc - optind <= 0 )
func7();
if ( do_refer )
{
if ( (unsigned int)func11(v3, &v16) == -1 )
{
fputs(v3, stderr);
exit(1);
}
v6 = v16.st_size;
v14 = 0LL;
}
else if ( do_relative )
{
v14 = v15;
v6 = 0LL;
}
else
{
v6 = v15;
v14 = 0LL;
}
v7 = no_create == 0 ? 65 : 1;
v8 = v5 + 1;
v9 = *v5;
if ( v9 )
{
v13 = 0;
while ( 1 )
{
v10 = open(v9, v7, 420LL);
v11 = v10;
if ( v10 != -1 )
break;
if ( *__errno_location() != 2 )
goto LABEL_27;
LABEL_33:
v9 = *v8++;
if ( !v9 )
return v13 != 0;
}
if ( do_relative )
{
if ( (unsigned int)func12(v10, &v16) == -1 )
{
LABEL_27:
perror(v9);
++v13;
goto LABEL_33;
}
v6 = v16.st_size + v14;
}
if ( v6 < 0 )
v6 = 0LL;
if ( ftruncate(v11, v6) != -1 )
{
close(v11);
goto LABEL_33;
}
goto LABEL_27;
}
v13 = 0;
return v13 != 0;
}

original_code:
int
main(int argc, char **argv)
{
 struct stat sb;
 mode_t omode;
 off_t oflow, rsize, sz, tsize;
 int ch, error, fd, oflags;
 char *fname, *rname;
 rsize = tsize = 0;
 error = 0;
 rname = ((void *)0);
 while ((ch = getopt(argc, argv, "cr:s:")) != -1)
  switch (ch) {
  case 'c':
   no_create = 1;
   break;
  case 'r':
   do_refer = 1;
   rname = optarg;
   break;
  case 's':
   if (parselength(optarg, &sz) == -1) {
    fprintf(stderr,
        "invalid size argument `%s'", optarg);
       exit(1);
      }
   if (*optarg == '+' || *optarg == '-')
    do_relative = 1;
   got_size = 1;
   break;
  default:
   usage();
  }
 argv += optind;
 argc -= optind;
 if (do_refer + got_size != 1 || argc < 1)
  usage();
 if (do_refer) {
  if (stat(rname, &sb) == -1) {
   fprintf(stderr, "%s", rname);
   exit(1);
  }
  tsize = sb.st_size;
 } else if (do_relative)
  rsize = sz;
 else
  tsize = sz;
 if (no_create)
  oflags = 01;
 else
  oflags = 01 | 0100;
 omode = 0400 | 0200 | (0400 >> 3) | ((0400 >> 3) >> 3);
 while ((fname = *argv++) != ((void *)0)) {
  if ((fd = open(fname, oflags, omode)) == -1) {
   if ((*__errno_location ()) != 2) {
    perror(fname);
    error++;
   }
   continue;
  }
  if (do_relative) {
   if (fstat(fd, &sb) == -1) {
    perror(fname);
    error++;
    continue;
   }
   oflow = sb.st_size + rsize;
   if (oflow < (sb.st_size + rsize)) {
    (*__errno_location ()) = 27;
    perror(fname);
    error++;
    continue;
   }
   tsize = oflow;
  }
  if (tsize < 0)
   tsize = 0;
  if (ftruncate(fd, tsize) == -1) {
   perror(fname);
   error++;
   continue;
  }
  close(fd);
 }
 return error ? 1 : 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct stat sb;
 unsigned int omode;
 long oflow; long rsize; long sz; long tsize;
 int ch; int error; int fd; int oflags;
 char *fname; char *rname;
 rsize = tsize = 0;
 error = 0;
 rname = ((void *)0);
 while ((ch = getopt(argc, argv, "cr:s:")) != -1)
  switch (ch) {
  case 'c':
   no_create = 1;
   break;
  case 'r':
   do_refer = 1;
   rname = optarg;
   break;
  case 's':
   if (parselength(optarg, &sz) == -1) {
    fprintf(stderr,
        "invalid size argument `%s'", optarg);
       exit(1);
      }
   if (*optarg == '+' || *optarg == '-')
    do_relative = 1;
   got_size = 1;
   break;
  default:
   usage();
  }
 argv += optind;
 argc -= optind;
 if (do_refer + got_size != 1 || argc < 1)
  usage();
 if (do_refer) {
  if (stat(rname, &sb) == -1) {
   fprintf(stderr, "%s", rname);
   exit(1);
  }
  tsize = sb.st_size;
 } else if (do_relative)
  rsize = sz;
 else
  tsize = sz;
 if (no_create)
  oflags = 01;
 else
  oflags = 01 | 0100;
 omode = 0400 | 0200 | (0400 >> 3) | ((0400 >> 3) >> 3);
 while ((fname = *argv++) != ((void *)0)) {
  if ((fd = open(fname, oflags, omode)) == -1) {
   if ((*__errno_location ()) != 2) {
    perror(fname);
    error++;
   }
   continue;
  }
  if (do_relative) {
   if (fstat(fd, &sb) == -1) {
    perror(fname);
    error++;
    continue;
   }
   oflow = sb.st_size + rsize;
   if (oflow < (sb.st_size + rsize)) {
    (*__errno_location ()) = 27;
    perror(fname);
    error++;
    continue;
   }
   tsize = oflow;
  }
  if (tsize < 0)
   tsize = 0;
  if (ftruncate(fd, tsize) == -1) {
   perror(fname);
   error++;
   continue;
  }
  close(fd);
 }
 return error ? 1 : 0;
}

variable_types: argc int

variable_types:
argv
char **

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

variable_types:
omode
unsigned int

variable_types: rsize long

variable_types: sz long

variable_types: tsize long

variable_types: ch int

variable_types: error int

variable_types: fd int

variable_types: oflags int

variable_types:
fname
char *

variable_types:
rname
char *

return_type: int

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


repo: kmowery/rdrand

decompiled_code:
__int64 cpu_supports_rdrand()
{
int v1; // [rsp+0h] [rbp-10h] BYREF
int v2; // [rsp+4h] [rbp-Ch] BYREF
int v3; // [rsp+8h] [rbp-8h] BYREF
int v4; // [rsp+Ch] [rbp-4h] BYREF

v4 = 0;
v3 = 0;
v2 = 0;
v1 = 0;
_get_cpuid(1u, &v4, &v3, &v2, &v1);
return v2 & 0x40000000;
}

original_code:
int cpu_supports_rdrand() {
  uint32_t eax=0, ebx=0, ecx=0, edx=0;
  __get_cpuid(1, &eax, &ebx, &ecx, &edx);
  return ecx & 0x40000000;
}

canonical_original_code:
int cpu_supports_rdrand() {
  unsigned int eax = 0; unsigned int ebx = 0; unsigned int ecx = 0; unsigned int edx = 0;
  __get_cpuid(1, &eax, &ebx, &ecx, &edx);
  return ecx & 0x40000000;
}

variable_types:
eax
unsigned int

variable_types:
ebx
unsigned int

variable_types:
ecx
unsigned int

variable_types:
edx
unsigned int


decompiled_code:
__int64 __fastcall rdrand_fill_array(_QWORD *a1, int a2)
{
bool v2; // cf
__int64 result; // rax

result = 0LL;
while ( a2 )
{
__asm { rdrand rsi }
result += v2;
*a1 = _RSI;
v2 = __CFADD__(a1++, 8LL);
--a2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1, int a2)
{
bool v2; // cf
__int64 result; // rax

result = 0LL;
while ( a2 )
{
__asm { rdrand rsi }
result += v2;
*a1 = _RSI;
v2 = __CFADD__(a1++, 8LL);
--a2;
}
return result;
}

original_code:
int rdrand_fill_array(uint64_t* array, int size) {
  uint64_t successes = 0;
  uint64_t temp = 0;
  __asm volatile(
      "top_of_rdrand_loop%=:"
      "jecxz end_of_rdrand_loop%= ;\n"
      "rdrand %1 ;\n"
      "adc $0, %0 ;\n"
      "mov %1, (%2) ;\n "
      "add $8, %2 ;\n "
      "dec %4 ;\n"
      "jmp top_of_rdrand_loop%= ;\n"
      "end_of_rdrand_loop%=:\n"
    : "=r" (successes), "=r" (temp), "=r"(array)
    : "0" (successes), "c" (size), "2"(array)
    );
  return (int)successes;
}

canonical_original_code:
int rdrand_fill_array(unsigned long *array, int size) {
  unsigned long successes = 0;
  unsigned long temp = 0;
  __asm volatile(
      "top_of_rdrand_loop%=:"
      "jecxz end_of_rdrand_loop%= ;\n"
      "rdrand %1 ;\n"
      "adc $0, %0 ;\n"
      "mov %1, (%2) ;\n "
      "add $8, %2 ;\n "
      "dec %4 ;\n"
      "jmp top_of_rdrand_loop%= ;\n"
      "end_of_rdrand_loop%=:\n"
    : "=r" (successes), "=r" (temp), "=r"(array)
    : "0" (successes), "c" (size), "2"(array)
    );
  return (int)successes;
}

variable_types:
array
unsigned long *

variable_types: size int

variable_types:
successes
unsigned long

variable_types:
temp
unsigned long


bilinear

original_code:
void bilinear(
    double a0, double a1, double a2,
    double b0, double b1, double b2,
    double *k,
    double fs,
    double *coef
)
{
    double ad, bd;
    ad = 4. * a2 * fs * fs + 2. * a1 * fs + a0;
    bd = 4. * b2 * fs * fs + 2. * b1* fs + b0;
    *k *= ad/bd;
    *coef++ = (2. * b0 - 8. * b2 * fs * fs)
                           / bd;
    *coef++ = (4. * b2 * fs * fs - 2. * b1 * fs + b0)
                           / bd;
    *coef++ = (2. * a0 - 8. * a2 * fs * fs)
                           / ad;
    *coef = (4. * a2 * fs * fs - 2. * a1 * fs + a0)
                           / ad;
}

canonical_original_code:
void bilinear(double a0, double a1, double a2, double b0, double b1, double b2, double *k, double fs, double *coef)
{
    double ad; double bd;
    ad = 4. * a2 * fs * fs + 2. * a1 * fs + a0;
    bd = 4. * b2 * fs * fs + 2. * b1* fs + b0;
    *k *= ad/bd;
    *coef++ = (2. * b0 - 8. * b2 * fs * fs)
                           / bd;
    *coef++ = (4. * b2 * fs * fs - 2. * b1 * fs + b0)
                           / bd;
    *coef++ = (2. * a0 - 8. * a2 * fs * fs)
                           / ad;
    *coef = (4. * a2 * fs * fs - 2. * a1 * fs + a0)
                           / ad;
}

variable_types:
k
double *

variable_types: fs double

variable_types:
coef
double *

variable_types: ad double

variable_types: bd double


szxform

decompiled_code:
void __fastcall szxform(double *a1, double *a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
double v10; // [rsp+0h] [rbp-58h] BYREF
double v11; // [rsp+8h] [rbp-50h] BYREF
double v12; // [rsp+10h] [rbp-48h] BYREF
double v13; // [rsp+18h] [rbp-40h] BYREF
double v14; // [rsp+20h] [rbp-38h] BYREF
double v15[6]; // [rsp+28h] [rbp-30h] BYREF

v15[0] = a3;
v14 = a4;
v13 = a5;
v12 = a6;
v11 = a7;
v10 = a8;
prewarp(a9, a10, (__int64)v15, &v14, &v13);
prewarp(a9, a10, (__int64)&v12, &v11, &v10);
bilinear(a1, a2, v15[0], v14, v13, v12, v11, v10, a10);
}

canonical_decompiled_code:
void __fastcall func2(double *a1, double *a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
double v10; // [rsp+0h] [rbp-58h] BYREF
double v11; // [rsp+8h] [rbp-50h] BYREF
double v12; // [rsp+10h] [rbp-48h] BYREF
double v13; // [rsp+18h] [rbp-40h] BYREF
double v14; // [rsp+20h] [rbp-38h] BYREF
double v15[6]; // [rsp+28h] [rbp-30h] BYREF

v15[0] = a3;
v14 = a4;
v13 = a5;
v12 = a6;
v11 = a7;
v10 = a8;
func1(a9, a10, (__int64)v15, &v14, &v13);
func1(a9, a10, (__int64)&v12, &v11, &v10);
func0(a1, a2, v15[0], v14, v13, v12, v11, v10, a10);
}

original_code:
void szxform(
    double a0, double a1, double a2,
    double b0, double b1, double b2,
    double fc,
    double fs,
    double *k,
    double *coef )
{
    prewarp(&a0, &a1, &a2, fc, fs);
    prewarp(&b0, &b1, &b2, fc, fs);
    bilinear(a0, a1, a2, b0, b1, b2, k, fs, coef);
}

canonical_original_code:
void szxform(double a0, double a1, double a2, double b0, double b1, double b2, double fc, double fs, double *k, double *coef)
{
    prewarp(&a0, &a1, &a2, fc, fs);
    prewarp(&b0, &b1, &b2, fc, fs);
    bilinear(a0, a1, a2, b0, b1, b2, k, fs, coef);
}

variable_types: fc double


decompiled_code:
__int64 __fastcall hash_string(char *a1)
{
char v1; // dl
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
return 0LL;
LODWORD(result) = 0;
do
{
++a1;
result = (unsigned int)(v1 + 37 * result);
v1 = *a1;
}
while ( *a1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
char v1; // dl
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
return 0LL;
LODWORD(result) = 0;
do
{
++a1;
result = (unsigned int)(v1 + 37 * result);
v1 = *a1;
}
while ( *a1 );
return result;
}

original_code:
static unsigned int hash_string(register const char *key)
{
    register unsigned int hash = 0;
    while(*key)
 hash = hash * 37 + *key++;
    return hash;
}

canonical_original_code:
static unsigned int hash_string(char *key)
{
    register unsigned int hash = 0;
    while(*key)
 hash = hash * 37 + *key++;
    return hash;
}

variable_types:
key
char *

variable_types:
hash
unsigned int

return_type: unsigned int


decompiled_code:
void __fastcall destroy_hash_table(void *ptr, void (__fastcall *a2)(_QWORD))
{
unsigned int v2; // er14
_QWORD *v3; // rax
_QWORD *v4; // rbx
_QWORD *v5; // rbp
_QWORD *v6; // r12

if ( *(_DWORD *)ptr )
{
v2 = 0;
do
{
v6 = (_QWORD *)(*((_QWORD *)ptr + 1) + 16LL * v2);
v4 = (_QWORD *)*v6;
while ( v6 != v4 )
{
v3 = v4;
v4 = (_QWORD *)*v4;
v5 = v3 - 2;
if ( a2 )
a2(*(v3 - 1));
free(v5);
}
++v2;
}
while ( *(_DWORD *)ptr > v2 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func5(void *ptr, void (__fastcall *a2)(_QWORD))
{
unsigned int v2; // er14
_QWORD *v3; // rax
_QWORD *v4; // rbx
_QWORD *v5; // rbp
_QWORD *v6; // r12

if ( *(_DWORD *)ptr )
{
v2 = 0;
do
{
v6 = (_QWORD *)(*((_QWORD *)ptr + 1) + 16LL * v2);
v4 = (_QWORD *)*v6;
while ( v6 != v4 )
{
v3 = v4;
v4 = (_QWORD *)*v4;
v5 = v3 - 2;
if ( a2 )
a2(*(v3 - 1));
free(v5);
}
++v2;
}
while ( *(_DWORD *)ptr > v2 );
}
free(ptr);
}

original_code:
void destroy_hash_table(struct hash_table *tbl, void (*delete_obj)(void *))
{
    struct list_head *head, *next, *tmp;
    struct hash_entry *entry;
    unsigned int i;
    for (i = 0; i < tbl->ht_size; i++)
    {
 head = &tbl->ht_lists[i];
 next = head->next;
 while (next != head)
 {
     tmp = next->next;
     entry = ((struct hash_entry *)((char *)(next)-(unsigned long)(&((struct hash_entry *)0)->he_list)));
     if (delete_obj)
  delete_obj(entry->he_obj);
     free(entry);
     next = tmp;
 }
    }
    free(tbl);
}

canonical_original_code:
void destroy_hash_table(struct hash_table *tbl, void (*delete_obj)(void *))
{
    struct list_head *head; struct list_head *next; struct list_head *tmp;
    struct hash_entry *entry;
    unsigned int i;
    for (i = 0; i < tbl->ht_size; i++)
    {
 head = &tbl->ht_lists[i];
 next = head->next;
 while (next != head)
 {
     tmp = next->next;
     entry = ((struct hash_entry *)((char *)(next)-(unsigned long)(&((struct hash_entry *)0)->he_list)));
     if (delete_obj)
  delete_obj(entry->he_obj);
     free(entry);
     next = tmp;
 }
    }
    free(tbl);
}

variable_types: struct hash_table { int ht_size; struct list_head { struct list_head *next; } *ht_lists; } *

variable_types: struct hash_entry { char *he_key; void *he_obj; struct list_head { struct list_head *next; } he_list; } *

variable_types:
i
unsigned int

user_defined_types: struct hash_table { int ht_size; struct list_head *ht_lists; }

user_defined_types: struct hash_entry { char *he_key; void *he_obj; struct list_head he_list; }


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

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

original_code:
static void destroy_ini_value(void *v_value)
{
    free(v_value);
}


decompiled_code:
void __fastcall destroy_ini_section(void *ptr)
{
destroy_hash_table(*((_QWORD *)ptr + 8), destroy_ini_value);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
destroy_hash_table(*((_QWORD *)ptr + 8), destroy_ini_value);
free(ptr);
}

original_code:
static void destroy_ini_section(void *v_ini_section)
{
    struct ini_section *sect = (struct ini_section *)v_ini_section;
    destroy_hash_table(sect->is_settings, destroy_ini_value);
    free(sect);
}

variable_types: struct ini_section { char is_name[64]; struct hash_table { int ht_size; struct list_head { struct list_head *next; } *ht_lists; } *is_settings; } *

user_defined_types: struct ini_section { char is_name[64]; struct hash_table *is_settings; }


decompiled_code:
void __fastcall destroy_ini_file(void *ptr)
{
if ( ptr )
{
destroy_hash_table(*(_QWORD *)ptr, destroy_ini_section);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
if ( ptr )
{
destroy_hash_table(*(_QWORD *)ptr, destroy_ini_section);
free(ptr);
}
}

original_code:
void destroy_ini_file(struct ini_file *ini)
{
    if (ini)
    {
 destroy_hash_table(ini->if_sections, destroy_ini_section);
 free(ini);
    }
}

variable_types: struct ini_file { struct hash_table { int ht_size; struct list_head { struct list_head *next; } *ht_lists; } *if_sections; } *

user_defined_types: struct ini_file { struct hash_table *if_sections; }


decompiled_code:
__int64 __fastcall get_ini_section(_QWORD *a1, const char *a2)
{
__int64 result; // rax
char _0[88]; // [rsp+0h] [rbp+0h] BYREF

strncpy(_0, a2, 0x3FuLL);
_0[63] = 0;
upper_case(_0);
result = (__int64)a1;
if ( a1 )
result = get_hash_object(*a1, _0);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, const char *a2)
{
__int64 result; // rax
char _0[88]; // [rsp+0h] [rbp+0h] BYREF

strncpy(_0, a2, 0x3FuLL);
_0[63] = 0;
upper_case(_0);
result = (__int64)a1;
if ( a1 )
result = get_hash_object(*a1, _0);
return result;
}

original_code:
struct ini_section *get_ini_section(struct ini_file *ini, const char *sect)
{
    struct ini_section *retval = ((void *)0);
    char sectname[64];
    strncpy(sectname, sect, 64 - 1);
    sectname[64 - 1] = '\0';
    upper_case(sectname);
    if (ini)
 retval = (struct ini_section *)get_hash_object(ini->if_sections, sectname);
    return retval;
}

canonical_original_code:
struct ini_section *get_ini_section(struct ini_file *ini, char *sect)
{
    struct ini_section *retval = ((void *)0);
    char sectname[64];
    strncpy(sectname, sect, 64 - 1);
    sectname[64 - 1] = '\0';
    upper_case(sectname);
    if (ini)
 retval = (struct ini_section *)get_hash_object(ini->if_sections, sectname);
    return retval;
}

variable_types: struct ini_file { struct hash_table *if_sections; } *

variable_types:
sect
char *

variable_types:
sectname
char [64]

return_type: struct ini_section { char is_name[64]; struct hash_table { int ht_size; struct list_head { struct list_head *next; } *ht_lists; } *is_settings; } *


decompiled_code:
__int64 __fastcall get_string_setting(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rax
char v6[88]; // [rsp+0h] [rbp-58h] BYREF

strcpy(v6, a2);
upper_case(v6);
if ( a1 )
{
v4 = get_hash_object(*(_QWORD *)(a1 + 64), v6);
if ( v4 )
a3 = v4;
}
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const char *a2, __int64 a3)
{
__int64 v4; // rax
char v6[88]; // [rsp+0h] [rbp-58h] BYREF

strcpy(v6, a2);
upper_case(v6);
if ( a1 )
{
v4 = get_hash_object(*(_QWORD *)(a1 + 64), v6);
if ( v4 )
a3 = v4;
}
return a3;
}

original_code:
const char *get_string_setting(struct ini_section *sect, const char *s,
          const char *defval)
{
    const char *retval = defval;
    char keybuff[64];
    strcpy(keybuff, s);
    upper_case(keybuff);
    if (sect)
 if (!(retval = (char *)get_hash_object(sect->is_settings, keybuff)))
     retval = defval;
    return retval;
}

canonical_original_code:
char *get_string_setting(struct ini_section *sect, char *s, char *defval)
{
    char *retval = defval;
    char keybuff[64];
    strcpy(keybuff, s);
    upper_case(keybuff);
    if (sect)
 if (!(retval = (char *)get_hash_object(sect->is_settings, keybuff)))
     retval = defval;
    return retval;
}

variable_types:
s
char *

variable_types:
defval
char *

variable_types:
retval
char *

variable_types:
keybuff
char [64]

return_type: char *

user_defined_types: struct list_head { struct list_head *next; }


decompiled_code:
int __fastcall get_int_setting(__int64 a1, const char *a2, int a3)
{
const char *v4; // rdi
int result; // eax

v4 = (const char *)get_string_setting(a1, a2, 0LL);
result = a3;
if ( v4 )
result = atoi(v4);
return result;
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, const char *a2, int a3)
{
const char *v4; // rdi
int result; // eax

v4 = (const char *)func6(a1, a2, 0LL);
result = a3;
if ( v4 )
result = atoi(v4);
return result;
}

original_code:
int get_int_setting(struct ini_section *sect, const char *s, int defval)
{
    const char *val = get_string_setting(sect, s, ((void *)0));
    if (val)
 return atoi(val);
    return defval;
}

canonical_original_code:
int get_int_setting(struct ini_section *sect, char *s, int defval)
{
    char *val = get_string_setting(sect, s, ((void *)0));
    if (val)
 return atoi(val);
    return defval;
}

variable_types: defval int

variable_types:
val
char *


decompiled_code:
_QWORD *juno_patchset_new()
{
_QWORD *v0; // r12
_QWORD *v1; // rbx

v0 = malloc(0x6D60uLL);
v1 = v0;
do
{
init_patch(v1);
v1 += 35;
}
while ( v1 != v0 + 3500 );
return v0;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *v0; // r12
_QWORD *v1; // rbx

v0 = malloc(0x6D60uLL);
v1 = v0;
do
{
func0(v1);
v1 += 35;
}
while ( v1 != v0 + 3500 );
return v0;
}

original_code:
juno_patch* juno_patchset_new()
{
    int i;
    juno_patch* retval = (juno_patch*)malloc(100*sizeof(juno_patch));
    for( i = 0; i < 100; i++ )
    {
 init_patch(&retval[i]);
    }
    return( retval );
}

canonical_original_code:
struct juno_patch *juno_patchset_new()
{
    int i;
    struct juno_patch *retval = (juno_patch*)malloc(100*sizeof(juno_patch));
    for( i = 0; i < 100; i++ )
    {
 init_patch(&retval[i]);
    }
    return( retval );
}

variable_types: i int

variable_types: struct juno_patch { int version; int used; double bender_dco; double bender_vcf; double lfo_trigger; double volume; double octave_transpose; double arpeggio_switch; double arpeggio_mode; double arpeggio_range; double arpeggio_rate; double lfo_rate; double lfo_delay; double lfo_mode; double dco_lfo; double dco_pwm; double dco_pwm_mod; double dco_pulse_switch; double dco_saw_switch; double dco_sub_switch; double dco_sub; double dco_noise; double hpf_frq; double vcf_frq; double vcf_res; double vcf_env_invert; double vcf_env; double vcf_lfo; double vcf_kbd; double vca_mode; double env_attack; double env_decay; double env_sustain; double env_release; double chorus_I_switch; double chorus_II_switch; } *


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

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

original_code:
void juno_patchset_delete( juno_patch* patches )
{
    free( patches );
}

canonical_original_code:
void juno_patchset_delete(struct juno_patch *patches)
{
    free( patches );
}

user_defined_types: struct juno_patch { int version; int used; double bender_dco; double bender_vcf; double lfo_trigger; double volume; double octave_transpose; double arpeggio_switch; double arpeggio_mode; double arpeggio_range; double arpeggio_rate; double lfo_rate; double lfo_delay; double lfo_mode; double dco_lfo; double dco_pwm; double dco_pwm_mod; double dco_pulse_switch; double dco_saw_switch; double dco_sub_switch; double dco_sub; double dco_noise; double hpf_frq; double vcf_frq; double vcf_res; double vcf_env_invert; double vcf_env; double vcf_lfo; double vcf_kbd; double vca_mode; double env_attack; double env_decay; double env_sustain; double env_release; double chorus_I_switch; double chorus_II_switch; }


decompiled_code:
void *__fastcall fast_memcpy(void *a1, const void *a2, size_t a3)
{
return memcpy(a1, a2, a3);
}

canonical_decompiled_code:
void *__fastcall func0(void *a1, const void *a2, size_t a3)
{
return memcpy(a1, a2, a3);
}

original_code:
void * fast_memcpy(void * to, const void * from, size_t len)
{
  memcpy(to, from, len);
 return to;
}

canonical_original_code:
void *fast_memcpy(void *to, void *from, unsigned long len)
{
  memcpy(to, from, len);
 return to;
}

variable_types:
to
void *

variable_types:
from
void *

variable_types:
len
unsigned long

return_type: void *


original_code:
long
umfpack_zl_solve
(
    long sys,
    const long Ap [ ],
    const long Ai [ ],
    const double Ax [ ],
    const double Az [ ],
    double Xx [ ],
    double Xz [ ],
    const double Bx [ ],
    const double Bz [ ],
    void *NumericHandle,
    const double Control [20],
    double User_Info [90]
)
{
    double Info2 [90], stats [2] ;
    double *Info ;
    NumericType *Numeric ;
    long n, i, irstep, status ;
    long *Pattern, wsize ;
    double *W ;
    umfpack_tic (stats) ;
    irstep = ((Control != (double *) ((void *)0)) ? (((Control [7]) != (Control [7])) ? 2 : Control [7]) : 2) ;
    if (User_Info != (double *) ((void *)0))
    {
 Info = User_Info ;
 for (i = 80 ; i <= 85 ; i++)
 {
     Info [i] = (-1) ;
 }
    }
    else
    {
 Info = Info2 ;
 for (i = 0 ; i < 90 ; i++)
 {
     Info [i] = (-1) ;
 }
    }
    Info [0] = (0) ;
    Info [84] = 0 ;
    Numeric = (NumericType *) NumericHandle ;
    if (!umfzl_valid_numeric (Numeric))
    {
 Info [0] = (-3) ;
 return ((-3)) ;
    }
    Info [1] = Numeric->n_row ;
    Info [16] = Numeric->n_col ;
    if (Numeric->n_row != Numeric->n_col)
    {
 Info [0] = (-13) ;
 return ((-13)) ;
    }
    n = Numeric->n_row ;
    if (Numeric->nnzpiv < n
 || ((Numeric->rcond) == 0.) || ((Numeric->rcond) != (Numeric->rcond)))
    {
 irstep = 0 ;
    }
    if (!Xx || !Bx)
    {
 Info [0] = (-5) ;
 return ((-5)) ;
    }
    if (sys >= (3))
    {
 irstep = 0 ;
    }
    if (irstep > 0)
    {
 wsize = 10*n ;
    }
    else
    {
 wsize = 4*n ;
    }
    Pattern = (long *) umf_l_malloc (n, sizeof (long)) ;
    W = (double *) umf_l_malloc (wsize, sizeof (double)) ;
    if (!W || !Pattern)
    {
 ;
 Info [0] = (-1) ;
 (void) umf_l_free ((void *) W) ;
 (void) umf_l_free ((void *) Pattern) ;
 return ((-1)) ;
    }
    status = umfzl_solve (sys, Ap, Ai, Ax, Xx, Bx,
 Az, Xz, Bz,
 Numeric, irstep, Info, Pattern, W) ;
    (void) umf_l_free ((void *) W) ;
    (void) umf_l_free ((void *) Pattern) ;
    ;
    Info [0] = status ;
    if (status >= 0)
    {
 umfpack_toc (stats) ;
 Info [86] = stats [0] ;
 Info [85] = stats [1] ;
    }
    return (status) ;
}

canonical_original_code:
long umfpack_zl_solve(long sys, long Ap[], long Ai[], double Ax[], double Az[], double Xx[], double Xz[], double Bx[], double Bz[], void *NumericHandle, double Control[20], double User_Info[90])
{
    double Info2[90]; double stats[2];
    double *Info;
    struct NumericType *Numeric;
    long n; long i; long irstep; long status;
    long *Pattern; long wsize;
    double *W;
    umfpack_tic (stats) ;
    irstep = ((Control != (double *) ((void *)0)) ? (((Control [7]) != (Control [7])) ? 2 : Control [7]) : 2) ;
    if (User_Info != (double *) ((void *)0))
    {
 Info = User_Info ;
 for (i = 80 ; i <= 85 ; i++)
 {
     Info [i] = (-1) ;
 }
    }
    else
    {
 Info = Info2 ;
 for (i = 0 ; i < 90 ; i++)
 {
     Info [i] = (-1) ;
 }
    }
    Info [0] = (0) ;
    Info [84] = 0 ;
    Numeric = (struct NumericType *) NumericHandle ;
    if (!umfzl_valid_numeric (Numeric))
    {
 Info [0] = (-3) ;
 return ((-3)) ;
    }
    Info [1] = Numeric->n_row ;
    Info [16] = Numeric->n_col ;
    if (Numeric->n_row != Numeric->n_col)
    {
 Info [0] = (-13) ;
 return ((-13)) ;
    }
    n = Numeric->n_row ;
    if (Numeric->nnzpiv < n
 || ((Numeric->rcond) == 0.) || ((Numeric->rcond) != (Numeric->rcond)))
    {
 irstep = 0 ;
    }
    if (!Xx || !Bx)
    {
 Info [0] = (-5) ;
 return ((-5)) ;
    }
    if (sys >= (3))
    {
 irstep = 0 ;
    }
    if (irstep > 0)
    {
 wsize = 10*n ;
    }
    else
    {
 wsize = 4*n ;
    }
    Pattern = (long *) umf_l_malloc (n, sizeof (long)) ;
    W = (double *) umf_l_malloc (wsize, sizeof (double)) ;
    if (!W || !Pattern)
    {
 ;
 Info [0] = (-1) ;
 (void) umf_l_free ((void *) W) ;
 (void) umf_l_free ((void *) Pattern) ;
 return ((-1)) ;
    }
    status = umfzl_solve (sys, Ap, Ai, Ax, Xx, Bx,
 Az, Xz, Bz,
 Numeric, irstep, Info, Pattern, W) ;
    (void) umf_l_free ((void *) W) ;
    (void) umf_l_free ((void *) Pattern) ;
    ;
    Info [0] = status ;
    if (status >= 0)
    {
 umfpack_toc (stats) ;
 Info [86] = stats [0] ;
 Info [85] = stats [1] ;
    }
    return (status) ;
}

variable_types: sys long

variable_types:
Ap
long []

variable_types:
Ai
long []

variable_types:
Ax
double []

variable_types:
Az
double []

variable_types:
Xx
double []

variable_types:
Xz
double []

variable_types:
Bx
double []

variable_types:
Bz
double []

variable_types:
NumericHandle
void *

variable_types:
Control
double [20]

variable_types:
stats
double [2]

variable_types:
Info
double *

variable_types: struct NumericType { double flops; long scale; long valid; union Unit_union { struct { long size; } header; double xxxxxx; } *Memory; long ihead; long *Rperm; long ulen; struct DoubleComplex { double component[2]; } *D; long do_recip; double *Rs; long n_row; long tail_usage; long maxnrows; } *

variable_types: n long

variable_types: i long

variable_types: irstep long

variable_types: status long

variable_types:
Pattern
long *

variable_types: wsize long

variable_types:
W
double *

user_defined_types: struct NumericType { double flops; long scale; long valid; union Unit_union *Memory; long ihead; long *Rperm; long ulen; struct DoubleComplex *D; long do_recip; double *Rs; long n_row; long tail_usage; long maxnrows; }


decompiled_code:
__int64 __fastcall umfpack_di_report_perm(unsigned int a1, __int64 a2, double *a3)
{
int v4; // er13
unsigned int v5; // ebx
bool v6; // cc
__int64 v7; // rdi
__int64 v8; // r14

if ( !a3 )
return 0;
v4 = (int)*a3;
v5 = 0;
if ( v4 > 2 )
{
v6 = (int)a1 <= 0;
v7 = 1LL;
if ( !v6 )
v7 = a1;
v8 = umf_i_malloc(v7, 4LL);
v5 = umf_i_report_perm(a1, a2, v8, (unsigned int)v4, 1LL);
umf_i_free(v8);
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, __int64 a2, double *a3)
{
int v4; // er13
unsigned int v5; // ebx
bool v6; // cc
__int64 v7; // rdi
__int64 v8; // r14

if ( !a3 )
return 0;
v4 = (int)*a3;
v5 = 0;
if ( v4 > 2 )
{
v6 = (int)a1 <= 0;
v7 = 1LL;
if ( !v6 )
v7 = a1;
v8 = umf_i_malloc(v7, 4LL);
v5 = umf_i_report_perm(a1, a2, v8, (unsigned int)v4, 1LL);
umf_i_free(v8);
}
return v5;
}

original_code:
int umfpack_di_report_perm
(
    int np,
    const int Perm [ ],
    const double Control [20]
)
{
    int prl, *W, status ;
    prl = ((Control != (double *) ((void *)0)) ? (((Control [0]) != (Control [0])) ? 1 : Control [0]) : 1) ;
    if (prl <= 2)
    {
 return ((0)) ;
    }
    W = (int *) umf_i_malloc ((((np) > (1)) ? (np) : (1)), sizeof (int)) ;
    status = umf_i_report_perm (np, Perm, W, prl, 1) ;
    (void) umf_i_free ((void *) W) ;
    return (status) ;
}

canonical_original_code:
int umfpack_di_report_perm(int np, int Perm[], double Control[20])
{
    int prl; int *W; int status;
    prl = ((Control != (double *) ((void *)0)) ? (((Control [0]) != (Control [0])) ? 1 : Control [0]) : 1) ;
    if (prl <= 2)
    {
 return ((0)) ;
    }
    W = (int *) umf_i_malloc ((((np) > (1)) ? (np) : (1)), sizeof (int)) ;
    status = umf_i_report_perm (np, Perm, W, prl, 1) ;
    (void) umf_i_free ((void *) W) ;
    return (status) ;
}

variable_types: np int

variable_types:
Perm
int []

variable_types: prl int

variable_types:
W
int *

variable_types: status int


original_code:
int umf_divcomplex
(
    double ar, double ai,
    double br, double bi,
    double *cr, double *ci
)
{
    double tr, ti, r, den ;
    if (((((br) < 0.)) ? -(br) : (br)) >= ((((bi) < 0.)) ? -(bi) : (bi)))
    {
 r = bi / br ;
 den = br + r * bi ;
 tr = (ar + ai * r) / den ;
 ti = (ai - ar * r) / den ;
    }
    else
    {
 r = br / bi ;
 den = r * br + bi ;
 tr = (ar * r + ai) / den ;
 ti = (ai * r - ar) / den ;
    }
    *cr = tr ;
    *ci = ti ;
    return (((den) == 0.)) ;
}

canonical_original_code:
int umf_divcomplex(double ar, double ai, double br, double bi, double *cr, double *ci)
{
    double tr; double ti; double r; double den;
    if (((((br) < 0.)) ? -(br) : (br)) >= ((((bi) < 0.)) ? -(bi) : (bi)))
    {
 r = bi / br ;
 den = br + r * bi ;
 tr = (ar + ai * r) / den ;
 ti = (ai - ar * r) / den ;
    }
    else
    {
 r = br / bi ;
 den = r * br + bi ;
 tr = (ar * r + ai) / den ;
 ti = (ai * r - ar) / den ;
    }
    *cr = tr ;
    *ci = ti ;
    return (((den) == 0.)) ;
}

variable_types: ar double

variable_types: ai double

variable_types: br double

variable_types: bi double

variable_types:
cr
double *

variable_types:
ci
double *

variable_types: tr double

variable_types: ti double

variable_types: r double

variable_types: den double


decompiled_code:
double __fastcall umf_hypot(double a1, double a2)
{
double result; // xmm0_8
double v3; // xmm0_8
double v4; // xmm0_8
double v5; // xmm0_8
double v6; // xmm0_8
double v7; // [rsp+0h] [rbp-18h]
double v8; // [rsp+8h] [rbp-10h]

v8 = a1;
v7 = a2;
if ( a1 < 0.0 )
*(_QWORD *)&v8 = *(_QWORD *)&a1 ^ LC1;
if ( a2 < 0.0 )
*(_QWORD *)&v7 = *(_QWORD *)&a2 ^ LC1;
if ( v8 < v7 )
{
if ( v8 + v7 == v7 )
{
result = v7;
}
else
{
v5 = v8 / v7 * (v8 / v7) + 1.0;
if ( v5 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
result = v6 * v7;
}
}
else if ( v8 + v7 == v8 )
{
result = v8;
}
else
{
v3 = v7 / v8 * (v7 / v8) + 1.0;
if ( v3 < 0.0 )
v4 = sqrt(v3);
else
v4 = sqrt(v3);
result = v4 * v8;
}
return result;
}

canonical_decompiled_code:
double __fastcall func1(double a1, double a2)
{
double result; // xmm0_8
double v3; // xmm0_8
double v4; // xmm0_8
double v5; // xmm0_8
double v6; // xmm0_8
double v7; // [rsp+0h] [rbp-18h]
double v8; // [rsp+8h] [rbp-10h]

v8 = a1;
v7 = a2;
if ( a1 < 0.0 )
*(_QWORD *)&v8 = *(_QWORD *)&a1 ^ LC1;
if ( a2 < 0.0 )
*(_QWORD *)&v7 = *(_QWORD *)&a2 ^ LC1;
if ( v8 < v7 )
{
if ( v8 + v7 == v7 )
{
result = v7;
}
else
{
v5 = v8 / v7 * (v8 / v7) + 1.0;
if ( v5 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
result = v6 * v7;
}
}
else if ( v8 + v7 == v8 )
{
result = v8;
}
else
{
v3 = v7 / v8 * (v7 / v8) + 1.0;
if ( v3 < 0.0 )
v4 = sqrt(v3);
else
v4 = sqrt(v3);
result = v4 * v8;
}
return result;
}

canonical_original_code:
double umf_hypot(double x, double y)
{
    double s; double r;
    x = ((((x) < 0.)) ? -(x) : (x)) ;
    y = ((((y) < 0.)) ? -(y) : (y)) ;
    if (x >= y)
    {
 if (x + y == x)
 {
     s = x ;
 }
 else
 {
     r = y / x ;
     s = x * sqrt (1.0 + r*r) ;
 }
    }
    else
    {
 if (y + x == y)
 {
     s = y ;
 }
 else
 {
     r = x / y ;
     s = y * sqrt (1.0 + r*r) ;
 }
    }
    return (s) ;
}

variable_types: x double

variable_types: y double

variable_types: s double

return_type: double


decompiled_code:
__int64 __fastcall umfpack_dl_report_triplet(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, double *a7)
{
__int64 result; // rax
__int64 v11; // r14
__int64 i; // rbx
__int64 v13; // rbp
__int64 v14; // r12
double v15; // xmm0_8
__int64 v16; // [rsp+18h] [rbp-60h]
__int64 v17; // [rsp+20h] [rbp-58h]
bool v19; // [rsp+37h] [rbp-41h]
__int64 v20; // [rsp+38h] [rbp-40h]

v16 = a4;
v17 = a5;
if ( !a7 )
return 0LL;
v20 = (unsigned int)(int)*a7;
result = 0LL;
if ( (unsigned __int64)v20 > 2 )
{
if ( amd_printf )
{
amd_printf("triplet-form matrix, n_row = %ld, n_col = %ld nz = %ld. ", a1, a2, a3);
if ( !a4 || !a5 )
{
if ( amd_printf )
amd_printf("ERROR: indices not present\n\n");
return -5LL;
}
if ( a1 <= 0 || a2 <= 0 )
{
if ( amd_printf )
amd_printf("ERROR: n_row or n_col is <= 0\n\n");
return -6LL;
}
}
else
{
if ( !a4 || !a5 )
return -5LL;
if ( a1 <= 0 || a2 <= 0 )
return -6LL;
}
if ( a3 < 0 )
{
result = -8LL;
if ( amd_printf )
{
amd_printf("ERROR: nz is < 0\n\n");
result = -8LL;
}
return result;
}
if ( v20 <= 3 )
{
v19 = a6 != 0;
if ( a3 <= 0 )
{
LABEL_49:
if ( amd_printf )
amd_printf("OK\n\n");
return 0LL;
}
}
else
{
if ( amd_printf )
amd_printf("\n");
v19 = a6 != 0;
if ( a3 <= 0 )
goto LABEL_47;
}
v11 = v20;
for ( i = 1LL; ; ++i )
{
v13 = *(_QWORD *)(v16 + 8 * i - 8);
v14 = *(_QWORD *)(v17 + 8 * i - 8);
if ( v11 > 3 )
{
if ( amd_printf )
amd_printf(" %ld : %ld %ld ", i - 1, *(_QWORD *)(v16 + 8 * i - 8), *(_QWORD *)(v17 + 8 * i - 8));
if ( v19 )
{
v15 = *(double *)(a6 + 8 * i - 8);
if ( v15 == 0.0 )
{
if ( amd_printf )
amd_printf(" (0)");
}
else if ( amd_printf )
{
amd_printf(" (%g)", v15);
}
}
if ( amd_printf )
amd_printf("\n");
}
if ( v13 < 0 || a1 <= v13 || v14 < 0 || a2 <= v14 )
{
result = -8LL;
if ( amd_printf )
{
amd_printf("ERROR: invalid triplet\n\n");
result = -8LL;
}
return result;
}
if ( a3 > 10 && v11 == 4 && i == 10 )
{
if ( amd_printf )
amd_printf(" ...\n");
v11 = 3LL;
}
else if ( a3 <= i )
{
if ( v20 <= 3 )
goto LABEL_49;
LABEL_47:
result = 0LL;
if ( amd_printf )
{
amd_printf(" triplet-form matrix ");
goto LABEL_49;
}
return result;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, double *a7)
{
__int64 result; // rax
__int64 v11; // r14
__int64 i; // rbx
__int64 v13; // rbp
__int64 v14; // r12
double v15; // xmm0_8
__int64 v16; // [rsp+18h] [rbp-60h]
__int64 v17; // [rsp+20h] [rbp-58h]
bool v19; // [rsp+37h] [rbp-41h]
__int64 v20; // [rsp+38h] [rbp-40h]

v16 = a4;
v17 = a5;
if ( !a7 )
return 0LL;
v20 = (unsigned int)(int)*a7;
result = 0LL;
if ( (unsigned __int64)v20 > 2 )
{
if ( amd_printf )
{
amd_printf("triplet-form matrix, n_row = %ld, n_col = %ld nz = %ld. ", a1, a2, a3);
if ( !a4 || !a5 )
{
if ( amd_printf )
amd_printf("ERROR: indices not present\n\n");
return -5LL;
}
if ( a1 <= 0 || a2 <= 0 )
{
if ( amd_printf )
amd_printf("ERROR: n_row or n_col is <= 0\n\n");
return -6LL;
}
}
else
{
if ( !a4 || !a5 )
return -5LL;
if ( a1 <= 0 || a2 <= 0 )
return -6LL;
}
if ( a3 < 0 )
{
result = -8LL;
if ( amd_printf )
{
amd_printf("ERROR: nz is < 0\n\n");
result = -8LL;
}
return result;
}
if ( v20 <= 3 )
{
v19 = a6 != 0;
if ( a3 <= 0 )
{
LABEL_49:
if ( amd_printf )
amd_printf("OK\n\n");
return 0LL;
}
}
else
{
if ( amd_printf )
amd_printf("\n");
v19 = a6 != 0;
if ( a3 <= 0 )
goto LABEL_47;
}
v11 = v20;
for ( i = 1LL; ; ++i )
{
v13 = *(_QWORD *)(v16 + 8 * i - 8);
v14 = *(_QWORD *)(v17 + 8 * i - 8);
if ( v11 > 3 )
{
if ( amd_printf )
amd_printf(" %ld : %ld %ld ", i - 1, *(_QWORD *)(v16 + 8 * i - 8), *(_QWORD *)(v17 + 8 * i - 8));
if ( v19 )
{
v15 = *(double *)(a6 + 8 * i - 8);
if ( v15 == 0.0 )
{
if ( amd_printf )
amd_printf(" (0)");
}
else if ( amd_printf )
{
amd_printf(" (%g)", v15);
}
}
if ( amd_printf )
amd_printf("\n");
}
if ( v13 < 0 || a1 <= v13 || v14 < 0 || a2 <= v14 )
{
result = -8LL;
if ( amd_printf )
{
amd_printf("ERROR: invalid triplet\n\n");
result = -8LL;
}
return result;
}
if ( a3 > 10 && v11 == 4 && i == 10 )
{
if ( amd_printf )
amd_printf(" ...\n");
v11 = 3LL;
}
else if ( a3 <= i )
{
if ( v20 <= 3 )
goto LABEL_49;
LABEL_47:
result = 0LL;
if ( amd_printf )
{
amd_printf(" triplet-form matrix ");
goto LABEL_49;
}
return result;
}
}
}
return result;
}

original_code:
long umfpack_dl_report_triplet
(
    long n_row,
    long n_col,
    long nz,
    const long Ti [ ],
    const long Tj [ ],
    const double Tx [ ],
    const double Control [20]
)
{
    double t ;
    long prl, prl1, k, i, j, do_values ;
    prl = ((Control != (double *) ((void *)0)) ? (((Control [0]) != (Control [0])) ? 1 : Control [0]) : 1) ;
    if (prl <= 2)
    {
 return ((0)) ;
    }
    { if (amd_printf != ((void *)0)) (void) amd_printf ("triplet-form matrix, n_row = ""%" "ld"", n_col = ""%" "ld"" nz = ""%" "ld"". ", n_row, n_col, nz) ; } ;
    if (!Ti || !Tj)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: indices not present\n\n") ; } ;
 return ((-5)) ;
    }
    if (n_row <= 0 || n_col <= 0)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: n_row or n_col is <= 0\n\n") ; } ;
 return ((-6)) ;
    }
    if (nz < 0)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: nz is < 0\n\n") ; } ;
 return ((-8)) ;
    }
    { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("\n") ; } ; } } ;
    do_values = Tx != (double *) ((void *)0) ;
    prl1 = prl ;
    for (k = 0 ; k < nz ; k++)
    {
 i = Ti [k] ;
 j = Tj [k] ;
 { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("    ""%" "ld"" : ""%" "ld"" ""%" "ld"" ", (k), (i), (j)) ; } ; } } ;
 if (do_values && prl >= 4)
 {
     { (t) = (Tx)[k] ; } ;
     { if (((t) != 0.)) { { if (amd_printf != ((void *)0)) (void) amd_printf (" (%g)", (t)) ; } ; } else { { if (amd_printf != ((void *)0)) (void) amd_printf (" (0)") ; } ; } } ;
 }
 { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("\n") ; } ; } } ;
 if (i < 0 || i >= n_row || j < 0 || j >= n_col)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: invalid triplet\n\n") ; } ;
     return ((-8)) ;
 }
 if (prl == 4 && k == 9 && nz > 10)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("    ...\n") ; } ;
     prl-- ;
 }
    }
    prl = prl1 ;
    { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("    triplet-form matrix ") ; } ; } } ;
    { if (amd_printf != ((void *)0)) (void) amd_printf ("OK\n\n") ; } ;
    return ((0)) ;
}

canonical_original_code:
long umfpack_dl_report_triplet(long n_row, long n_col, long nz, long Ti[], long Tj[], double Tx[], double Control[20])
{
    double t;
    long prl; long prl1; long k; long i; long j; long do_values;
    prl = ((Control != (double *) ((void *)0)) ? (((Control [0]) != (Control [0])) ? 1 : Control [0]) : 1) ;
    if (prl <= 2)
    {
 return ((0)) ;
    }
    { if (amd_printf != ((void *)0)) (void) amd_printf ("triplet-form matrix, n_row = ""%" "ld"", n_col = ""%" "ld"" nz = ""%" "ld"". ", n_row, n_col, nz) ; } ;
    if (!Ti || !Tj)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: indices not present\n\n") ; } ;
 return ((-5)) ;
    }
    if (n_row <= 0 || n_col <= 0)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: n_row or n_col is <= 0\n\n") ; } ;
 return ((-6)) ;
    }
    if (nz < 0)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: nz is < 0\n\n") ; } ;
 return ((-8)) ;
    }
    { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("\n") ; } ; } } ;
    do_values = Tx != (double *) ((void *)0) ;
    prl1 = prl ;
    for (k = 0 ; k < nz ; k++)
    {
 i = Ti [k] ;
 j = Tj [k] ;
 { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("    ""%" "ld"" : ""%" "ld"" ""%" "ld"" ", (k), (i), (j)) ; } ; } } ;
 if (do_values && prl >= 4)
 {
     { (t) = (Tx)[k] ; } ;
     { if (((t) != 0.)) { { if (amd_printf != ((void *)0)) (void) amd_printf (" (%g)", (t)) ; } ; } else { { if (amd_printf != ((void *)0)) (void) amd_printf (" (0)") ; } ; } } ;
 }
 { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("\n") ; } ; } } ;
 if (i < 0 || i >= n_row || j < 0 || j >= n_col)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: invalid triplet\n\n") ; } ;
     return ((-8)) ;
 }
 if (prl == 4 && k == 9 && nz > 10)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("    ...\n") ; } ;
     prl-- ;
 }
    }
    prl = prl1 ;
    { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("    triplet-form matrix ") ; } ; } } ;
    { if (amd_printf != ((void *)0)) (void) amd_printf ("OK\n\n") ; } ;
    return ((0)) ;
}

variable_types: nz long

variable_types:
Ti
long []

variable_types:
Tj
long []

variable_types:
Tx
double []

variable_types:
Control
double [20]

variable_types: t double

variable_types: prl long

variable_types: k long

variable_types: i long

variable_types: j long


original_code:
double
umfdi_ltsolve
(
    NumericType *Numeric,
    double X [ ],
    int Pattern [ ]
)
{
    double xk ;
    double *xp, *Lval ;
    int k, deg, *ip, j, row, *Lpos, *Lilen, kstart, kend, *Lip, llen,
 lp, pos, npiv, n1, *Li ;
    if (Numeric->n_row != Numeric->n_col) return (0.) ;
    npiv = Numeric->npiv ;
    Lpos = Numeric->Lpos ;
    Lilen = Numeric->Lilen ;
    Lip = Numeric->Lip ;
    kstart = npiv ;
    n1 = Numeric->n1 ;
    for (kend = npiv-1 ; kend >= n1 ; kend = kstart-1)
    {
 kstart = kend ;
 while (kstart >= 0 && Lip [kstart] > 0)
 {
     kstart-- ;
 }
 deg = 0 ;
 ;
 for (k = kstart ; k <= kend ; k++)
 {
     ;
     pos = Lpos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  ;
  ;
  ;
  Pattern [pos] = Pattern [--deg] ;
     }
     lp = Lip [k] ;
     if (k == kstart)
     {
  lp = -lp ;
     }
     ;
     ip = (int *) (Numeric->Memory + lp) ;
     llen = Lilen [k] ;
     for (j = 0 ; j < llen ; j++)
     {
  row = *ip++ ;
  ;
  ;
  Pattern [deg++] = row ;
     }
 }
 ;
 for (k = kend ; k >= kstart ; k--)
 {
     ;
     lp = Lip [k] ;
     if (k == kstart)
     {
  lp = -lp ;
     }
     ;
     llen = Lilen [k] ;
     xp = (double *) (Numeric->Memory + lp + (((((sizeof (int) * (llen))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
     xk = X [k] ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  { (xk) -= (X [Pattern [j]]) * (*xp) ; } ;
  xp++ ;
     }
     X [k] = xk ;
     deg -= llen ;
     pos = Lpos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  ;
  Pattern [deg++] = Pattern [pos] ;
  Pattern [pos] = k ;
     }
 }
    }
    for (k = n1 - 1 ; k >= 0 ; k--)
    {
 ;
 deg = Lilen [k] ;
 if (deg > 0)
 {
     xk = X [k] ;
     lp = Lip [k] ;
     Li = (int *) (Numeric->Memory + lp) ;
     lp += (((((sizeof (int) * (deg))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ;
     Lval = (double *) (Numeric->Memory + lp) ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  { (xk) -= (X [Li [j]]) * (Lval [j]) ; } ;
     }
     X [k] = xk ;
 }
    }
    return (2. * ((double) Numeric->lnz)) ;
}

canonical_original_code:
double umfdi_ltsolve(struct NumericType *Numeric, double X[], int Pattern[])
{
    double xk;
    double *xp; double *Lval;
    int k; int deg; int *ip; int j; int row; int *Lpos; int *Lilen; int kstart; int kend; int *Lip; int llen; int lp; int pos; int npiv; int n1; int *Li;
    if (Numeric->n_row != Numeric->n_col) return (0.) ;
    npiv = Numeric->npiv ;
    Lpos = Numeric->Lpos ;
    Lilen = Numeric->Lilen ;
    Lip = Numeric->Lip ;
    kstart = npiv ;
    n1 = Numeric->n1 ;
    for (kend = npiv-1 ; kend >= n1 ; kend = kstart-1)
    {
 kstart = kend ;
 while (kstart >= 0 && Lip [kstart] > 0)
 {
     kstart-- ;
 }
 deg = 0 ;
 ;
 for (k = kstart ; k <= kend ; k++)
 {
     ;
     pos = Lpos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  ;
  ;
  ;
  Pattern [pos] = Pattern [--deg] ;
     }
     lp = Lip [k] ;
     if (k == kstart)
     {
  lp = -lp ;
     }
     ;
     ip = (int *) (Numeric->Memory + lp) ;
     llen = Lilen [k] ;
     for (j = 0 ; j < llen ; j++)
     {
  row = *ip++ ;
  ;
  ;
  Pattern [deg++] = row ;
     }
 }
 ;
 for (k = kend ; k >= kstart ; k--)
 {
     ;
     lp = Lip [k] ;
     if (k == kstart)
     {
  lp = -lp ;
     }
     ;
     llen = Lilen [k] ;
     xp = (double *) (Numeric->Memory + lp + (((((sizeof (int) * (llen))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
     xk = X [k] ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  { (xk) -= (X [Pattern [j]]) * (*xp) ; } ;
  xp++ ;
     }
     X [k] = xk ;
     deg -= llen ;
     pos = Lpos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  ;
  Pattern [deg++] = Pattern [pos] ;
  Pattern [pos] = k ;
     }
 }
    }
    for (k = n1 - 1 ; k >= 0 ; k--)
    {
 ;
 deg = Lilen [k] ;
 if (deg > 0)
 {
     xk = X [k] ;
     lp = Lip [k] ;
     Li = (int *) (Numeric->Memory + lp) ;
     lp += (((((sizeof (int) * (deg))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ;
     Lval = (double *) (Numeric->Memory + lp) ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  { (xk) -= (X [Li [j]]) * (Lval [j]) ; } ;
     }
     X [k] = xk ;
 }
    }
    return (2. * ((double) Numeric->lnz)) ;
}

variable_types: struct NumericType { double flops; int scale; int valid; union Unit_union { struct { int size; } header; double xxxxxx; } *Memory; int ihead; int *Rperm; int ulen; double *D; int do_recip; double *Rs; int n_row; int tail_usage; int maxnrows; } *

variable_types:
X
double []

variable_types:
Pattern
int []

variable_types: xk double

variable_types:
xp
double *

variable_types:
Lval
double *

variable_types: k int

variable_types: deg int

variable_types:
ip
int *

variable_types: j int

variable_types: row int

variable_types:
Lpos
int *

variable_types:
Lilen
int *

variable_types: kstart int

variable_types: kend int

variable_types:
Lip
int *

variable_types: llen int

variable_types: lp int

variable_types: pos int

variable_types: npiv int

variable_types:
Li
int *

user_defined_types: struct NumericType { double flops; int scale; int valid; union Unit_union *Memory; int ihead; int *Rperm; int ulen; double *D; int do_recip; double *Rs; int n_row; int tail_usage; int maxnrows; }


variable_types: n long

variable_types:
Ap
long []

variable_types:
Ai
long []

variable_types:
Rp
long []

variable_types:
Ri
long []

variable_types:
W
long []

variable_types:
Flag
long []

variable_types: i long

variable_types: j long

variable_types: p long


decompiled_code:
__int64 __fastcall cholmod_l_add_size_t(__int64 a1, __int64 a2, _DWORD *a3)
{
bool v4; // dl
__int64 v5; // rdi
__int64 result; // rax

v4 = !__CFADD__(a2, a1) && *a3 != 0;
*a3 = v4;
v5 = a2 + a1;
result = 0LL;
if ( v4 )
result = v5;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, _DWORD *a3)
{
bool v4; // dl
__int64 v5; // rdi
__int64 result; // rax

v4 = !__CFADD__(a2, a1) && *a3 != 0;
*a3 = v4;
v5 = a2 + a1;
result = 0LL;
if ( v4 )
result = v5;
return result;
}

original_code:
size_t cholmod_l_add_size_t (size_t a, size_t b, int *ok)
{
    size_t s = a + b ;
    (*ok) = (*ok) && (s >= a) ;
    return ((*ok) ? s : 0) ;
}

canonical_original_code:
unsigned long cholmod_l_add_size_t(unsigned long a, unsigned long b, int *ok)
{
    unsigned long s = a + b;
    (*ok) = (*ok) && (s >= a) ;
    return ((*ok) ? s : 0) ;
}

variable_types:
a
unsigned long

variable_types:
b
unsigned long

variable_types:
ok
int *

variable_types:
s
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall cholmod_l_mult_size_t(unsigned __int64 a1, unsigned __int64 a2, _DWORD *a3)
{
__int64 v3; // r8
bool v4; // al
bool v5; // cf

if ( !*a3 )
return 0LL;
v3 = 0LL;
while ( 1 )
{
if ( (a2 & 1) != 0 )
{
v5 = __CFADD__(a1, v3);
v3 += a1;
*a3 = !v5;
}
if ( a2 <= 1 )
break;
v4 = 2 * a1 >= a1 && *a3 != 0;
*a3 = v4;
if ( !v4 )
return 0LL;
a2 >>= 1;
a1 *= 2LL;
}
return v3;
}

original_code:
size_t cholmod_l_mult_size_t (size_t a, size_t k, int *ok)
{
    size_t p = 0, s ;
    while (*ok)
    {
 if (k % 2)
 {
     p = p + a ;
     (*ok) = (*ok) && (p >= a) ;
 }
 k = k / 2 ;
 if (!k) return (p) ;
 s = a + a ;
 (*ok) = (*ok) && (s >= a) ;
 a = s ;
    }
    return (0) ;
}

canonical_original_code:
unsigned long cholmod_l_mult_size_t(unsigned long a, unsigned long k, int *ok)
{
    unsigned long p = 0; unsigned long s;
    while (*ok)
    {
 if (k % 2)
 {
     p = p + a ;
     (*ok) = (*ok) && (p >= a) ;
 }
 k = k / 2 ;
 if (!k) return (p) ;
 s = a + a ;
 (*ok) = (*ok) && (s >= a) ;
 a = s ;
    }
    return (0) ;
}

variable_types:
k
unsigned long

variable_types:
p
unsigned long


decompiled_code:
__int64 __fastcall cholmod_l_malloc(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
bool v5; // zf
unsigned __int64 v6; // rdi
__int64 v7; // rdi
__int64 result; // rax
unsigned __int64 v9; // rbp
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v10[0] = 1;
if ( !a3 )
return 0LL;
if ( *(_QWORD *)(a3 + 2016) == 2LL )
{
if ( a2 )
{
if ( 0xFFFFFFFFFFFFFFFFLL / a2 <= a1 || a1 > 0x7FFFFFFFFFFFFFFELL )
{
cholmod_l_error(4294967293LL, "../Core/cholmod_memory.c", 136LL, "problem too large", a3);
result = 0LL;
}
else
{
v5 = a1 == 0;
v6 = 1LL;
if ( !v5 )
v6 = a1;
v7 = cholmod_l_mult_size_t(v6, a2, v10);
if ( v10[0] && (result = (*(__int64 (__fastcall **)(__int64))(a3 + 1880))(v7)) != 0 )
{
++*(_QWORD *)(a3 + 2064);
v9 = *(_QWORD *)(a3 + 2080) + a1 * a2;
*(_QWORD *)(a3 + 2080) = v9;
if ( *(_QWORD *)(a3 + 2072) >= v9 )
v9 = *(_QWORD *)(a3 + 2072);
*(_QWORD *)(a3 + 2072) = v9;
}
else
{
cholmod_l_error(4294967294LL, "../Core/cholmod_memory.c", 147LL, "out of memory", a3);
result = 0LL;
}
}
}
else
{
cholmod_l_error(4294967292LL, "../Core/cholmod_memory.c", 130LL, "sizeof(item) must be > 0", a3);
result = 0LL;
}
}
else
{
*(_DWORD *)(a3 + 2028) = -4;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
bool v5; // zf
unsigned __int64 v6; // rdi
__int64 v7; // rdi
__int64 result; // rax
unsigned __int64 v9; // rbp
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v10[0] = 1;
if ( !a3 )
return 0LL;
if ( *(_QWORD *)(a3 + 2016) == 2LL )
{
if ( a2 )
{
if ( 0xFFFFFFFFFFFFFFFFLL / a2 <= a1 || a1 > 0x7FFFFFFFFFFFFFFELL )
{
cholmod_l_error(4294967293LL, "../Core/cholmod_memory.c", 136LL, "problem too large", a3);
result = 0LL;
}
else
{
v5 = a1 == 0;
v6 = 1LL;
if ( !v5 )
v6 = a1;
v7 = func1(v6, a2, v10);
if ( v10[0] && (result = (*(__int64 (__fastcall **)(__int64))(a3 + 1880))(v7)) != 0 )
{
++*(_QWORD *)(a3 + 2064);
v9 = *(_QWORD *)(a3 + 2080) + a1 * a2;
*(_QWORD *)(a3 + 2080) = v9;
if ( *(_QWORD *)(a3 + 2072) >= v9 )
v9 = *(_QWORD *)(a3 + 2072);
*(_QWORD *)(a3 + 2072) = v9;
}
else
{
cholmod_l_error(4294967294LL, "../Core/cholmod_memory.c", 147LL, "out of memory", a3);
result = 0LL;
}
}
}
else
{
cholmod_l_error(4294967292LL, "../Core/cholmod_memory.c", 130LL, "sizeof(item) must be > 0", a3);
result = 0LL;
}
}
else
{
*(_DWORD *)(a3 + 2028) = -4;
result = 0LL;
}
return result;
}

original_code:
void *cholmod_l_malloc
(
    size_t n,
    size_t size,
    cholmod_common *Common
)
{
    void *p ;
    size_t s ;
    int ok = 1 ;
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    if (size == 0)
    {
 cholmod_l_error ((-4), "../Core/cholmod_memory.c", 130, "sizeof(item) must be > 0", Common) ;
 p = ((void *)0) ;
    }
    else if (n >= (((size_t) (-1)) / size) || n >= 0x7fffffffffffffffL)
    {
 cholmod_l_error ((-3), "../Core/cholmod_memory.c", 136, "problem too large", Common) ;
 p = ((void *)0) ;
    }
    else
    {
 s = cholmod_l_mult_size_t ((((1) > (n)) ? (1) : (n)), size, &ok) ;
 p = ok ? ((Common->malloc_memory) (s)) : ((void *)0) ;
 if (p == ((void *)0))
 {
     cholmod_l_error ((-2), "../Core/cholmod_memory.c", 147, "out of memory", Common) ;
 }
 else
 {
     Common->malloc_count++ ;
     Common->memory_inuse += (n * size) ;
     Common->memory_usage =
  (((Common->memory_usage) > (Common->memory_inuse)) ? (Common->memory_usage) : (Common->memory_inuse)) ;
     ;
 }
    }
    return (p) ;
}

canonical_original_code:
void *cholmod_l_malloc(unsigned long n, unsigned long size, struct cholmod_common_struct *Common)
{
    void *p;
    unsigned long s;
    int ok = 1;
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    if (size == 0)
    {
 cholmod_l_error ((-4), "../Core/cholmod_memory.c", 130, "sizeof(item) must be > 0", Common) ;
 p = ((void *)0) ;
    }
    else if (n >= (((unsigned long) (-1)) / size) || n >= 0x7fffffffffffffffL)
    {
 cholmod_l_error ((-3), "../Core/cholmod_memory.c", 136, "problem too large", Common) ;
 p = ((void *)0) ;
    }
    else
    {
 s = cholmod_l_mult_size_t ((((1) > (n)) ? (1) : (n)), size, &ok) ;
 p = ok ? ((Common->malloc_memory) (s)) : ((void *)0) ;
 if (p == ((void *)0))
 {
     cholmod_l_error ((-2), "../Core/cholmod_memory.c", 147, "out of memory", Common) ;
 }
 else
 {
     Common->malloc_count++ ;
     Common->memory_inuse += (n * size) ;
     Common->memory_usage =
  (((Common->memory_usage) > (Common->memory_inuse)) ? (Common->memory_usage) : (Common->memory_inuse)) ;
     ;
 }
    }
    return (p) ;
}

variable_types:
n
unsigned long

variable_types:
size
unsigned long

variable_types: struct cholmod_common_struct { double dbound; double grow0; double grow1; unsigned long grow2; unsigned long maxrank; double supernodal_switch; int supernodal; int final_asis; int final_super; int final_ll; int final_pack; int final_monotonic; int final_resymbol; double zrelax[3]; unsigned long nrelax[3]; int prefer_zomplex; int prefer_upper; int quick_return_if_not_posdef; int print; int precise; int (*print_function)(char *, ...); int try_catch; void (*error_handler)(int status, char *file, int line, char *message); int nmethods; int current; int selected; struct cholmod_method_struct { double lnz; double fl; double prune_dense; double prune_dense2; double nd_oksep; double other_1[4]; unsigned long nd_small; unsigned long other_2[4]; int aggressive; int order_for_lu; int nd_compress; int nd_camd; int nd_components; int ordering; unsigned long other_3[4]; } method[-1]; int postorder; void *(*malloc_memory)(unsigned long); void *(*realloc_memory)(void *, unsigned long); void (*free_memory)(void *); void *(*calloc_memory)(unsigned long, unsigned long); int (*complex_divide)(double ax, double az, double bx, double bz, double *cx, double *cz); double (*hypotenuse)(double x, double y); double metis_memory; double metis_dswitch; unsigned long metis_nswitch; unsigned long nrow; long mark; unsigned long iworksize; unsigned long xworksize; void *Flag; void *Head; void *Xwork; void *Iwork; int itype; int dtype; int no_workspace_reallocate; int status; double fl; double lnz; double anz; double modfl; unsigned long malloc_count; unsigned long memory_usage; unsigned long memory_inuse; double nrealloc_col; double nrealloc_factor; double ndbounds_hit; double rowfacfl; double aatfl; double other1[10]; double SPQR_xstat[4]; double SPQR_grain; double SPQR_small; long SPQR_istat[10]; long other2[6]; int other3[10]; int prefer_binary; int default_nesdis; int called_nd; int blas_ok; int SPQR_shrink; int SPQR_nthreads; unsigned long other4[16]; void *other5[16]; } *

variable_types:
p
void *

variable_types: ok int

user_defined_types: struct cholmod_common_struct { double dbound; double grow0; double grow1; unsigned long grow2; unsigned long maxrank; double supernodal_switch; int supernodal; int final_asis; int final_super; int final_ll; int final_pack; int final_monotonic; int final_resymbol; double zrelax[3]; unsigned long nrelax[3]; int prefer_zomplex; int prefer_upper; int quick_return_if_not_posdef; int print; int precise; int (*print_function)(char *, ...); int try_catch; void (*error_handler)(int status, char *file, int line, char *message); int nmethods; int current; int selected; struct cholmod_method_struct method[-1]; int postorder; void *(*malloc_memory)(unsigned long); void *(*realloc_memory)(void *, unsigned long); void (*free_memory)(void *); void *(*calloc_memory)(unsigned long, unsigned long); int (*complex_divide)(double ax, double az, double bx, double bz, double *cx, double *cz); double (*hypotenuse)(double x, double y); double metis_memory; double metis_dswitch; unsigned long metis_nswitch; unsigned long nrow; long mark; unsigned long iworksize; unsigned long xworksize; void *Flag; void *Head; void *Xwork; void *Iwork; int itype; int dtype; int no_workspace_reallocate; int status; double fl; double lnz; double anz; double modfl; unsigned long malloc_count; unsigned long memory_usage; unsigned long memory_inuse; double nrealloc_col; double nrealloc_factor; double ndbounds_hit; double rowfacfl; double aatfl; double other1[10]; double SPQR_xstat[4]; double SPQR_grain; double SPQR_small; long SPQR_istat[10]; long other2[6]; int other3[10]; int prefer_binary; int default_nesdis; int called_nd; int blas_ok; int SPQR_shrink; int SPQR_nthreads; unsigned long other4[16]; void *other5[16]; }


original_code:
void *cholmod_l_free
(
    size_t n,
    size_t size,
    void *p,
    cholmod_common *Common
)
{
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    if (p != ((void *)0))
    {
 (Common->free_memory) (p) ;
 Common->malloc_count-- ;
 Common->memory_inuse -= (n * size) ;
 ;
 ;
    }
    return (((void *)0)) ;
}

canonical_original_code:
void *cholmod_l_free(unsigned long n, unsigned long size, void *p, struct cholmod_common_struct *Common)
{
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    if (p != ((void *)0))
    {
 (Common->free_memory) (p) ;
 Common->malloc_count-- ;
 Common->memory_inuse -= (n * size) ;
 ;
 ;
    }
    return (((void *)0)) ;
}

user_defined_types: struct cholmod_method_struct { double lnz; double fl; double prune_dense; double prune_dense2; double nd_oksep; double other_1[4]; unsigned long nd_small; unsigned long other_2[4]; int aggressive; int order_for_lu; int nd_compress; int nd_camd; int nd_components; int ordering; unsigned long other_3[4]; }


decompiled_code:
__int64 __fastcall cholmod_l_calloc(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
bool v5; // zf
__int64 v6; // rdi
__int64 v7; // r12
unsigned __int64 v8; // rbp

if ( !a3 )
return 0LL;
if ( *(_QWORD *)(a3 + 2016) == 2LL )
{
if ( a2 )
{
if ( 0xFFFFFFFFFFFFFFFFLL / a2 <= a1 || a1 > 0x7FFFFFFFFFFFFFFELL )
{
cholmod_l_error(4294967293LL, "../Core/cholmod_memory.c", 245LL, "problem too large", a3);
v7 = 0LL;
}
else
{
v5 = a1 == 0;
v6 = 1LL;
if ( !v5 )
v6 = a1;
v7 = (*(__int64 (__fastcall **)(__int64, unsigned __int64, unsigned __int64))(a3 + 1904))(
v6,
a2,
0xFFFFFFFFFFFFFFFFLL % a2);
if ( v7 )
{
++*(_QWORD *)(a3 + 2064);
v8 = *(_QWORD *)(a3 + 2080) + a1 * a2;
*(_QWORD *)(a3 + 2080) = v8;
if ( *(_QWORD *)(a3 + 2072) >= v8 )
v8 = *(_QWORD *)(a3 + 2072);
*(_QWORD *)(a3 + 2072) = v8;
}
else
{
cholmod_l_error(4294967294LL, "../Core/cholmod_memory.c", 255LL, "out of memory", a3);
}
}
}
else
{
cholmod_l_error(4294967292LL, "../Core/cholmod_memory.c", 239LL, "sizeof(item) must be > 0", a3);
v7 = 0LL;
}
}
else
{
*(_DWORD *)(a3 + 2028) = -4;
v7 = 0LL;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 a1, unsigned __int64 a2, __int64 a3)
{
bool v5; // zf
__int64 v6; // rdi
__int64 v7; // r12
unsigned __int64 v8; // rbp

if ( !a3 )
return 0LL;
if ( *(_QWORD *)(a3 + 2016) == 2LL )
{
if ( a2 )
{
if ( 0xFFFFFFFFFFFFFFFFLL / a2 <= a1 || a1 > 0x7FFFFFFFFFFFFFFELL )
{
cholmod_l_error(4294967293LL, "../Core/cholmod_memory.c", 245LL, "problem too large", a3);
v7 = 0LL;
}
else
{
v5 = a1 == 0;
v6 = 1LL;
if ( !v5 )
v6 = a1;
v7 = (*(__int64 (__fastcall **)(__int64, unsigned __int64, unsigned __int64))(a3 + 1904))(
v6,
a2,
0xFFFFFFFFFFFFFFFFLL % a2);
if ( v7 )
{
++*(_QWORD *)(a3 + 2064);
v8 = *(_QWORD *)(a3 + 2080) + a1 * a2;
*(_QWORD *)(a3 + 2080) = v8;
if ( *(_QWORD *)(a3 + 2072) >= v8 )
v8 = *(_QWORD *)(a3 + 2072);
*(_QWORD *)(a3 + 2072) = v8;
}
else
{
cholmod_l_error(4294967294LL, "../Core/cholmod_memory.c", 255LL, "out of memory", a3);
}
}
}
else
{
cholmod_l_error(4294967292LL, "../Core/cholmod_memory.c", 239LL, "sizeof(item) must be > 0", a3);
v7 = 0LL;
}
}
else
{
*(_DWORD *)(a3 + 2028) = -4;
v7 = 0LL;
}
return v7;
}

original_code:
void *cholmod_l_calloc
(
    size_t n,
    size_t size,
    cholmod_common *Common
)
{
    void *p ;
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    if (size == 0)
    {
 cholmod_l_error ((-4), "../Core/cholmod_memory.c", 239, "sizeof(item) must be > 0", Common) ;
 p = ((void *)0) ;
    }
    else if (n >= (((size_t) (-1)) / size) || n >= 0x7fffffffffffffffL)
    {
 cholmod_l_error ((-3), "../Core/cholmod_memory.c", 245, "problem too large", Common) ;
 p = ((void *)0) ;
    }
    else
    {
 p = (Common->calloc_memory) ((((1) > (n)) ? (1) : (n)), size) ;
 if (p == ((void *)0))
 {
     cholmod_l_error ((-2), "../Core/cholmod_memory.c", 255, "out of memory", Common) ;
 }
 else
 {
     Common->malloc_count++ ;
     Common->memory_inuse += (n * size) ;
     Common->memory_usage =
  (((Common->memory_usage) > (Common->memory_inuse)) ? (Common->memory_usage) : (Common->memory_inuse)) ;
     ;
 }
    }
    return (p) ;
}

canonical_original_code:
void *cholmod_l_calloc(unsigned long n, unsigned long size, struct cholmod_common_struct *Common)
{
    void *p;
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    if (size == 0)
    {
 cholmod_l_error ((-4), "../Core/cholmod_memory.c", 239, "sizeof(item) must be > 0", Common) ;
 p = ((void *)0) ;
    }
    else if (n >= (((unsigned long) (-1)) / size) || n >= 0x7fffffffffffffffL)
    {
 cholmod_l_error ((-3), "../Core/cholmod_memory.c", 245, "problem too large", Common) ;
 p = ((void *)0) ;
    }
    else
    {
 p = (Common->calloc_memory) ((((1) > (n)) ? (1) : (n)), size) ;
 if (p == ((void *)0))
 {
     cholmod_l_error ((-2), "../Core/cholmod_memory.c", 255, "out of memory", Common) ;
 }
 else
 {
     Common->malloc_count++ ;
     Common->memory_inuse += (n * size) ;
     Common->memory_usage =
  (((Common->memory_usage) > (Common->memory_inuse)) ? (Common->memory_usage) : (Common->memory_inuse)) ;
     ;
 }
    }
    return (p) ;
}


decompiled_code:
__int64 __fastcall cholmod_l_realloc(unsigned __int64 a1, unsigned __int64 a2, __int64 a3, unsigned __int64 *a4, __int64 a5)
{
unsigned __int64 v6; // r15
unsigned __int64 v7; // rbp
__int64 result; // rax
bool v11; // zf
unsigned __int64 v12; // rdi
__int64 v13; // rax
unsigned __int64 v14; // rdx
int v15[15]; // [rsp+Ch] [rbp-3Ch] BYREF

v6 = *a4;
v15[0] = 1;
if ( !a5 )
return 0LL;
v7 = a1;
if ( *(_QWORD *)(a5 + 2016) == 2LL )
{
if ( a2 )
{
if ( a3 )
{
result = a3;
if ( v6 != a1 )
{
if ( 0xFFFFFFFFFFFFFFFFLL / a2 > a1 && a1 <= 0x7FFFFFFFFFFFFFFELL )
{
v11 = a1 == 0;
v12 = 1LL;
if ( !v11 )
v12 = v7;
v13 = cholmod_l_mult_size_t(v12, a2, v15);
if ( v15[0] && (result = (*(__int64 (__fastcall **)(__int64, __int64))(a5 + 1888))(a3, v13)) != 0 )
{
*a4 = v7;
*(_QWORD *)(a5 + 2080) += (v7 - v6) * a2;
}
else
{
if ( v6 < v7 )
{
cholmod_l_error(4294967294LL, "../Core/cholmod_memory.c", 366LL, "out of memory", a5);
}
else
{
*a4 = v7;
*(_QWORD *)(a5 + 2080) += (v7 - v6) * a2;
}
result = a3;
}
v14 = *(_QWORD *)(a5 + 2072);
if ( *(_QWORD *)(a5 + 2080) >= v14 )
v14 = *(_QWORD *)(a5 + 2080);
*(_QWORD *)(a5 + 2072) = v14;
}
else
{
cholmod_l_error(4294967293LL, "../Core/cholmod_memory.c", 331LL, "problem too large", a5);
result = a3;
}
}
}
else
{
result = cholmod_l_malloc(a1, a2, a5);
if ( !result )
v7 = 0LL;
*a4 = v7;
}
}
else
{
cholmod_l_error(4294967292LL, "../Core/cholmod_memory.c", 313LL, "sizeof(item) must be > 0", a5);
result = 0LL;
}
}
else
{
*(_DWORD *)(a5 + 2028) = -4;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int64 a1, unsigned __int64 a2, __int64 a3, unsigned __int64 *a4, __int64 a5)
{
unsigned __int64 v6; // r15
unsigned __int64 v7; // rbp
__int64 result; // rax
bool v11; // zf
unsigned __int64 v12; // rdi
__int64 v13; // rax
unsigned __int64 v14; // rdx
int v15[15]; // [rsp+Ch] [rbp-3Ch] BYREF

v6 = *a4;
v15[0] = 1;
if ( !a5 )
return 0LL;
v7 = a1;
if ( *(_QWORD *)(a5 + 2016) == 2LL )
{
if ( a2 )
{
if ( a3 )
{
result = a3;
if ( v6 != a1 )
{
if ( 0xFFFFFFFFFFFFFFFFLL / a2 > a1 && a1 <= 0x7FFFFFFFFFFFFFFELL )
{
v11 = a1 == 0;
v12 = 1LL;
if ( !v11 )
v12 = v7;
v13 = func1(v12, a2, v15);
if ( v15[0] && (result = (*(__int64 (__fastcall **)(__int64, __int64))(a5 + 1888))(a3, v13)) != 0 )
{
*a4 = v7;
*(_QWORD *)(a5 + 2080) += (v7 - v6) * a2;
}
else
{
if ( v6 < v7 )
{
cholmod_l_error(4294967294LL, "../Core/cholmod_memory.c", 366LL, "out of memory", a5);
}
else
{
*a4 = v7;
*(_QWORD *)(a5 + 2080) += (v7 - v6) * a2;
}
result = a3;
}
v14 = *(_QWORD *)(a5 + 2072);
if ( *(_QWORD *)(a5 + 2080) >= v14 )
v14 = *(_QWORD *)(a5 + 2080);
*(_QWORD *)(a5 + 2072) = v14;
}
else
{
cholmod_l_error(4294967293LL, "../Core/cholmod_memory.c", 331LL, "problem too large", a5);
result = a3;
}
}
}
else
{
result = func2(a1, a2, a5);
if ( !result )
v7 = 0LL;
*a4 = v7;
}
}
else
{
cholmod_l_error(4294967292LL, "../Core/cholmod_memory.c", 313LL, "sizeof(item) must be > 0", a5);
result = 0LL;
}
}
else
{
*(_DWORD *)(a5 + 2028) = -4;
result = 0LL;
}
return result;
}

original_code:
void *cholmod_l_realloc
(
    size_t nnew,
    size_t size,
    void *p,
    size_t *n,
    cholmod_common *Common
)
{
    size_t nold = (*n) ;
    void *pnew ;
    size_t s ;
    int ok = 1 ;
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    if (size == 0)
    {
 cholmod_l_error ((-4), "../Core/cholmod_memory.c", 313, "sizeof(item) must be > 0", Common) ;
 p = ((void *)0) ;
    }
    else if (p == ((void *)0))
    {
 ;
 p = cholmod_l_malloc (nnew, size, Common) ;
 *n = (p == ((void *)0)) ? 0 : nnew ;
    }
    else if (nold == nnew)
    {
 ;
    }
    else if (nnew >= (((size_t) (-1)) / size) || nnew >= 0x7fffffffffffffffL)
    {
 cholmod_l_error ((-3), "../Core/cholmod_memory.c", 331, "problem too large", Common) ;
    }
    else
    {
 ;
 pnew = ((void *)0) ;
 s = cholmod_l_mult_size_t ((((1) > (nnew)) ? (1) : (nnew)), size, &ok) ;
 pnew = ok ? ((Common->realloc_memory) (p, s)) : ((void *)0) ;
 if (pnew == ((void *)0))
 {
     if (nnew <= nold)
     {
  *n = nnew ;
  ;
  ;
  Common->memory_inuse += ((nnew-nold) * size) ;
     }
     else
     {
  cholmod_l_error ((-2), "../Core/cholmod_memory.c", 366, "out of memory", Common) ;
     }
 }
 else
 {
     ;
     p = pnew ;
     *n = nnew ;
     Common->memory_inuse += ((nnew-nold) * size) ;
 }
 Common->memory_usage = (((Common->memory_usage) > (Common->memory_inuse)) ? (Common->memory_usage) : (Common->memory_inuse));
    }
    return (p) ;
}

canonical_original_code:
void *cholmod_l_realloc(unsigned long nnew, unsigned long size, void *p, unsigned long *n, struct cholmod_common_struct *Common)
{
    unsigned long nold = (*n);
    void *pnew;
    unsigned long s;
    int ok = 1;
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    if (size == 0)
    {
 cholmod_l_error ((-4), "../Core/cholmod_memory.c", 313, "sizeof(item) must be > 0", Common) ;
 p = ((void *)0) ;
    }
    else if (p == ((void *)0))
    {
 ;
 p = cholmod_l_malloc (nnew, size, Common) ;
 *n = (p == ((void *)0)) ? 0 : nnew ;
    }
    else if (nold == nnew)
    {
 ;
    }
    else if (nnew >= (((unsigned long) (-1)) / size) || nnew >= 0x7fffffffffffffffL)
    {
 cholmod_l_error ((-3), "../Core/cholmod_memory.c", 331, "problem too large", Common) ;
    }
    else
    {
 ;
 pnew = ((void *)0) ;
 s = cholmod_l_mult_size_t ((((1) > (nnew)) ? (1) : (nnew)), size, &ok) ;
 pnew = ok ? ((Common->realloc_memory) (p, s)) : ((void *)0) ;
 if (pnew == ((void *)0))
 {
     if (nnew <= nold)
     {
  *n = nnew ;
  ;
  ;
  Common->memory_inuse += ((nnew-nold) * size) ;
     }
     else
     {
  cholmod_l_error ((-2), "../Core/cholmod_memory.c", 366, "out of memory", Common) ;
     }
 }
 else
 {
     ;
     p = pnew ;
     *n = nnew ;
     Common->memory_inuse += ((nnew-nold) * size) ;
 }
 Common->memory_usage = (((Common->memory_usage) > (Common->memory_inuse)) ? (Common->memory_usage) : (Common->memory_inuse));
    }
    return (p) ;
}

variable_types:
nnew
unsigned long

variable_types:
n
unsigned long *

variable_types:
nold
unsigned long

variable_types:
pnew
void *