decompiled_code:
int __fastcall print_aflist(int a1)
{
_QWORD *v1; // rax
unsigned __int64 v2; // rbx
int v3; // ebp
const char *v4; // rsi
__int64 v5; // rax
const char *v6; // rdx

if ( !sVafinit )
afinit();
v1 = aftypes;
if ( aftypes )
{
v2 = (unsigned int)((_DWORD)&aftypes + 8);
v3 = 0;
do
{
while ( a1 == 1 && !v1[7] )
{
v1 = *(_QWORD **)v2;
v2 += 8LL;
if ( !v1 )
return fputc(10, stderr);
}
if ( *((_DWORD *)v1 + 4) )
{
if ( (unsigned int)(-1431655765 * v3) <= 0x55555555 )
{
v4 = "\n ";
if ( !v3 )
v4 = " ";
fprintf(stderr, v4);
}
v5 = *(_QWORD *)(v2 - 8);
v6 = *(const char **)v5;
if ( !*(_QWORD *)v5 )
v6 = "..";
++v3;
fprintf(stderr, "%s (%s) ", v6, *(_QWORD *)(v5 + 8));
}
v1 = *(_QWORD **)v2;
v2 += 8LL;
}
while ( v1 );
}
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func5(int a1)
{
_QWORD *v1; // rax
unsigned __int64 v2; // rbx
int v3; // ebp
const char *v4; // rsi
__int64 v5; // rax
const char *v6; // rdx

if ( !sVafinit )
func0();
v1 = aftypes;
if ( aftypes )
{
v2 = (unsigned int)((_DWORD)&aftypes + 8);
v3 = 0;
do
{
while ( a1 == 1 && !v1[7] )
{
v1 = *(_QWORD **)v2;
v2 += 8LL;
if ( !v1 )
return fputc(10, stderr);
}
if ( *((_DWORD *)v1 + 4) )
{
if ( (unsigned int)(-1431655765 * v3) <= 0x55555555 )
{
v4 = "\n ";
if ( !v3 )
v4 = " ";
fprintf(stderr, v4);
}
v5 = *(_QWORD *)(v2 - 8);
v6 = *(const char **)v5;
if ( !*(_QWORD *)v5 )
v6 = "..";
++v3;
fprintf(stderr, "%s (%s) ", v6, *(_QWORD *)(v5 + 8));
}
v1 = *(_QWORD **)v2;
v2 += 8LL;
}
while ( v1 );
}
return fputc(10, stderr);
}

original_code:
void print_aflist(int type) {
    int count = 0;
    char * txt;
    struct aftype **afp;
    if (!sVafinit)
 afinit();
    afp = aftypes;
    while (*afp != ((void *)0)) {
 if ((type == 1 && ((*afp)->rprint == ((void *)0))) || ((*afp)->af == 0)) {
  afp++; continue;
 }
 if ((count % 3) == 0) fprintf(stderr,count?"\n    ":"    ");
        txt = (*afp)->name; if (!txt) txt = "..";
 fprintf(stderr,"%s (%s) ",txt,(*afp)->title);
 count++;
 afp++;
    }
    fprintf(stderr,"\n");
}

canonical_original_code:
void print_aflist(int type) {
    int count = 0;
    char *txt;
    struct aftype **afp;
    if (!sVafinit)
 afinit();
    afp = aftypes;
    while (*afp != ((void *)0)) {
 if ((type == 1 && ((*afp)->rprint == ((void *)0))) || ((*afp)->af == 0)) {
  afp++; continue;
 }
 if ((count % 3) == 0) fprintf(stderr,count?"\n    ":"    ");
        txt = (*afp)->name; if (!txt) txt = "..";
 fprintf(stderr,"%s (%s) ",txt,(*afp)->title);
 count++;
 afp++;
    }
    fprintf(stderr,"\n");
}

variable_types: type int

variable_types: count int

variable_types:
txt
char *


repo: fmertz/sdeclcd

decompiled_code:
__int64 __fastcall get_connection(const char *a1, __int16 a2)
{
struct hostent *v2; // rbp
int v3; // edx
int v4; // eax
unsigned int v5; // er12
int v7; // eax
struct sockaddr v8; // [rsp+0h] [rbp-28h] BYREF

v2 = gethostbyname(a1);
if ( !v2 )
{
v7 = *_h_errno_location();
if ( v7 == 3 )
{
v5 = -1;
puts("Name service error.");
return v5;
}
if ( v7 > 3 )
{
if ( v7 == 4 )
{
v5 = -1;
puts("No IP found for valid hostname.");
return v5;
}
}
else
{
if ( v7 == 1 )
{
v5 = -1;
puts("Host not found.");
return v5;
}
if ( v7 == 2 )
{
v5 = -1;
puts("Temporary error in name resolution.");
return v5;
}
}
}
v8 = 0LL;
v8.sa_family = 2;
*(_WORD *)v8.sa_data = _bswap_16(a2);
*(_DWORD *)&v8.sa_data[2] = **(_DWORD **)v2->h_addr_list;
v4 = socket(2, 1, v3);
v5 = v4;
if ( v4 == -1 )
{
puts("Error creating socket");
}
else if ( connect(v4, &v8, 0x10u) == -1 )
{
v5 = -1;
perror("Error connecting");
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, __int16 a2)
{
struct hostent *v2; // rbp
int v3; // edx
int v4; // eax
unsigned int v5; // er12
int v7; // eax
struct sockaddr v8; // [rsp+0h] [rbp-28h] BYREF

v2 = gethostbyname(a1);
if ( !v2 )
{
v7 = *_h_errno_location();
if ( v7 == 3 )
{
v5 = -1;
puts("Name service error.");
return v5;
}
if ( v7 > 3 )
{
if ( v7 == 4 )
{
v5 = -1;
puts("No IP found for valid hostname.");
return v5;
}
}
else
{
if ( v7 == 1 )
{
v5 = -1;
puts("Host not found.");
return v5;
}
if ( v7 == 2 )
{
v5 = -1;
puts("Temporary error in name resolution.");
return v5;
}
}
}
v8 = 0LL;
v8.sa_family = 2;
*(_WORD *)v8.sa_data = func0(a2);
*(_DWORD *)&v8.sa_data[2] = **(_DWORD **)v2->h_addr_list;
v4 = socket(2, 1, v3);
v5 = v4;
if ( v4 == -1 )
{
puts("Error creating socket");
}
else if ( connect(v4, &v8, 0x10u) == -1 )
{
v5 = -1;
perror("Error connecting");
}
return v5;
}

original_code:
int get_connection(char *peername, int peerport)
{
    struct sockaddr_in peeraddr;
    int SocketDescriptor;
    struct hostent *HostEntry;
    HostEntry=gethostbyname(peername);
    if (HostEntry==((void *)0))
    {
        switch ((*__h_errno_location ()))
        {
        case 1:
            printf("Host not found.\n");
            return -1;
            break;
        case 4:
            printf("No IP found for valid hostname.\n");
            return -1;
            break;
        case 3:
            printf("Name service error.\n");
            return -1;
            break;
        case 2:
            printf("Temporary error in name resolution.\n");
            return -1;
            break;
        default:
            break;
        }
    }
    memset(&peeraddr, 0, sizeof(peeraddr));
    peeraddr.sin_family = 2;
    peeraddr.sin_port = htons(peerport);
    peeraddr.sin_addr = *(struct in_addr *) HostEntry->h_addr_list[0];
    SocketDescriptor=socket(2, SOCK_STREAM, 0);
    if (SocketDescriptor==-1)
    {
        printf("Error creating socket\n");
        return -1;
    }
    if (connect(SocketDescriptor, (struct sockaddr *) &peeraddr, sizeof(peeraddr))==-1)
    {
        perror("Error connecting");
        return -1;
    }
    return SocketDescriptor;
}

variable_types:
peername
char *

variable_types: peerport int

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

variable_types: SocketDescriptor int

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *

return_type: int

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

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


OnCtrlC

decompiled_code:
ssize_t OnCtrlC()
{
ssize_t result; // rax

if ( forkPid )
result = write(2, "Parent - Ctrl-c\n", 0x10uLL);
else
result = write(2, "Child - Ctrl-c\n", 0xFuLL);
return result;
}

canonical_decompiled_code:
ssize_t func7()
{
ssize_t result; // rax

if ( forkPid )
result = write(2, "Parent - Ctrl-c\n", 0x10uLL);
else
result = write(2, "Child - Ctrl-c\n", 0xFuLL);
return result;
}

original_code:
void OnCtrlC(int signum)
{
 char *childMsg = "Child - Ctrl-c\n";
 char *parentMsg = "Parent - Ctrl-c\n";
 if(_forkPid == 0)
  write(2, childMsg, strlen(childMsg));
 else
  write(2, parentMsg, strlen(parentMsg));
}

variable_types: signum int

variable_types:
childMsg
char *

variable_types:
parentMsg
char *

return_type: void


decompiled_code:
ssize_t Parent_onUsr1()
{
sigReceived = 1;
return write(2, "**** Parent SIGUSR1 handler - handler - Recieved a 'task started' signal from child ****\n", 0x59uLL);
}

canonical_decompiled_code:
ssize_t func8()
{
sigReceived = 1;
return write(2, "**** Parent SIGUSR1 handler - handler - Recieved a 'task started' signal from child ****\n", 0x59uLL);
}

original_code:
void Parent_onUsr1( int sig )
{
 _sigReceived = 1;
 char *msg = "**** Parent SIGUSR1 handler - handler - Recieved a 'task started' signal from child ****\n";
 write( 2, msg, strlen(msg) );
}

canonical_original_code:
void Parent_onUsr1(int sig)
{
 _sigReceived = 1;
 char *msg = "**** Parent SIGUSR1 handler - handler - Recieved a 'task started' signal from child ****\n";
 write( 2, msg, strlen(msg) );
}

variable_types: sig int

variable_types:
msg
char *


decompiled_code:
ssize_t Parent_onUsr2()
{
sigReceived = 1;
return write(2, "**** Parent SIGUSR2 handler - Received a 'task completed' signal from the child ****\n", 0x55uLL);
}

canonical_decompiled_code:
ssize_t func9()
{
sigReceived = 1;
return write(2, "**** Parent SIGUSR2 handler - Received a 'task completed' signal from the child ****\n", 0x55uLL);
}

original_code:
void Parent_onUsr2( int sig )
{
 _sigReceived = 1;
 char *msg = "**** Parent SIGUSR2 handler - Received a 'task completed' signal from the child ****\n";
 write( 2, msg, strlen(msg) );
}

canonical_original_code:
void Parent_onUsr2(int sig)
{
 _sigReceived = 1;
 char *msg = "**** Parent SIGUSR2 handler - Received a 'task completed' signal from the child ****\n";
 write( 2, msg, strlen(msg) );
}


decompiled_code:
ssize_t Child_onUsr1()
{
sigReceived = 1;
return write(2, "**** Child SIGUSR1 handler - Received a 'task start' signal from the parent process ****\n", 0x59uLL);
}

canonical_decompiled_code:
ssize_t func10()
{
sigReceived = 1;
return write(2, "**** Child SIGUSR1 handler - Received a 'task start' signal from the parent process ****\n", 0x59uLL);
}

original_code:
void Child_onUsr1(int signum)
{
 _sigReceived = 1;
 char *msg = "**** Child SIGUSR1 handler - Received a 'task start' signal from the parent process ****\n";
 write(2, msg, strlen(msg));
}


decompiled_code:
ssize_t Child_onUsr2()
{
sigReceived = 1;
return write(
2,
"**** Child SIGUSR2 handler - Received a 'task complete verification' signal from the parent ****\n",
0x61uLL);
}

canonical_decompiled_code:
ssize_t func11()
{
sigReceived = 1;
return write(
2,
"**** Child SIGUSR2 handler - Received a 'task complete verification' signal from the parent ****\n",
0x61uLL);
}

original_code:
void Child_onUsr2(int signum)
{
 _sigReceived = 1;
 char *msg = "**** Child SIGUSR2 handler - Received a 'task complete verification' signal from the parent ****\n";
 write(2, msg, strlen(msg));
}


SetupHandler

decompiled_code:
int __fastcall SetupHandler(int signo, void (*a2)(int))
{
sigset_t v3; // [rsp+0h] [rbp-138h] BYREF
struct sigaction v4; // [rsp+80h] [rbp-B8h] BYREF

sigfillset(&v4.sa_mask);
v4.sa_flags = 0x10000000;
v4.sa_handler = a2;
if ( sigaction(signo, &v4, 0LL) )
{
fprintf(stderr, "%s%d\n", "Couldn't setup handler for: ", (unsigned int)signo);
perror("");
exit(1);
}
sigemptyset(&v3);
sigaddset(&v3, signo);
return sigprocmask(1, &v3, 0LL);
}

canonical_decompiled_code:
int __fastcall func12(int signo, void (*a2)(int))
{
sigset_t v3; // [rsp+0h] [rbp-138h] BYREF
struct sigaction v4; // [rsp+80h] [rbp-B8h] BYREF

sigfillset(&v4.sa_mask);
v4.sa_flags = 0x10000000;
v4.sa_handler = a2;
if ( sigaction(signo, &v4, 0LL) )
{
fprintf(stderr, "%s%d\n", "Couldn't setup handler for: ", (unsigned int)signo);
perror("");
exit(1);
}
sigemptyset(&v3);
sigaddset(&v3, signo);
return sigprocmask(1, &v3, 0LL);
}

original_code:
void SetupHandler(int signum, void (*funcPtr)(int))
{
 struct sigaction act;
 sigset_t signalMask;
 sigfillset(&act.sa_mask);
 act.sa_flags = 0x10000000;
 act.__sigaction_handler.sa_handler = funcPtr;
 if(sigaction(signum, &act, ((void *)0)) != 0)
 {
  fprintf(stderr, "%s%d\n", "Couldn't setup handler for: ", signum);
  perror("");
  exit(1);
 }
 sigemptyset(&signalMask);
 sigaddset(&signalMask, signum);
 sigprocmask(1, &signalMask, ((void *)0));
}

canonical_original_code:
void SetupHandler(int signum, void (*funcPtr)(int))
{
 struct sigaction act;
 struct __sigset_t signalMask;
 sigfillset(&act.sa_mask);
 act.sa_flags = 0x10000000;
 act.__sigaction_handler.sa_handler = funcPtr;
 if(sigaction(signum, &act, ((void *)0)) != 0)
 {
  fprintf(stderr, "%s%d\n", "Couldn't setup handler for: ", signum);
  perror("");
  exit(1);
 }
 sigemptyset(&signalMask);
 sigaddset(&signalMask, signum);
 sigprocmask(1, &signalMask, ((void *)0));
}

variable_types:
funcPtr
void (*)(int)

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


Error

decompiled_code:
void __fastcall __noreturn Error(const char *a1)
{
fprintf(stderr, "%s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func13(const char *a1)
{
fprintf(stderr, "%s\n", a1);
exit(1);
}

original_code:
void Error(const char *msg)
{
 fprintf(stderr, "%s\n", msg);
 exit(1);
}

canonical_original_code:
void Error(char *msg)
{
 fprintf(stderr, "%s\n", msg);
 exit(1);
}


Parent

decompiled_code:
int Parent()
{
sigset_t v1; // [rsp+0h] [rbp-108h] BYREF
sigset_t set; // [rsp+80h] [rbp-88h] BYREF

puts("Parent - Child process has been created.");
sleep(3u);
sigfillset(&v1);
sigfillset(&set);
sigdelset(&v1, 10);
sigdelset(&set, 12);
SetupHandler(10, (void (*)(int))Parent_onUsr1);
SetupHandler(12, (void (*)(int))Parent_onUsr2);
puts("Parent - Start the child working.");
kill(forkPid, 10);
if ( sigReceived )
Error("_sigReceived != 0: SIGUSR1");
sigsuspend(&v1);
sigReceived = 0;
sleep(3u);
puts("Parent - Sending SIGUSR2...");
kill(forkPid, 12);
if ( sigReceived )
Error("_sigReceived != 0: SIGUSR2");
sigsuspend(&set);
sigReceived = 0;
return puts("Parent - Terminating...");
}

canonical_decompiled_code:
int func14()
{
sigset_t v1; // [rsp+0h] [rbp-108h] BYREF
sigset_t set; // [rsp+80h] [rbp-88h] BYREF

puts("Parent - Child process has been created.");
sleep(3u);
sigfillset(&v1);
sigfillset(&set);
sigdelset(&v1, 10);
sigdelset(&set, 12);
func12(10, (void (*)(int))Parent_onUsr1);
func12(12, (void (*)(int))Parent_onUsr2);
puts("Parent - Start the child working.");
kill(forkPid, 10);
if ( sigReceived )
func13("_sigReceived != 0: SIGUSR1");
sigsuspend(&v1);
sigReceived = 0;
sleep(3u);
puts("Parent - Sending SIGUSR2...");
kill(forkPid, 12);
if ( sigReceived )
func13("_sigReceived != 0: SIGUSR2");
sigsuspend(&set);
sigReceived = 0;
return puts("Parent - Terminating...");
}

original_code:
void Parent()
{
 printf("%s", "Parent - Child process has been created.\n");
 sleep((3));
 sigset_t maskAllUsr1;
 sigset_t maskAllUsr2;
 sigfillset( &maskAllUsr1 );
 sigfillset( &maskAllUsr2 );
 sigdelset( &maskAllUsr1, 10 );
 sigdelset( &maskAllUsr2, 12 );
 SetupHandler( 10, Parent_onUsr1 );
 SetupHandler( 12, Parent_onUsr2 );
 printf("%s", "Parent - Start the child working.\n");
 kill(_forkPid, 10);
 if( _sigReceived == 0 )
  sigsuspend(&maskAllUsr1);
 else
  Error(("_sigReceived != 0: SIGUSR1"));
 _sigReceived = 0;
 sleep((3));
 printf("%s", "Parent - Sending SIGUSR2...\n");
 kill(_forkPid, 12);
 if( _sigReceived == 0 )
  sigsuspend( &maskAllUsr2 );
 else
  Error(("_sigReceived != 0: SIGUSR2"));
 _sigReceived = 0;
 printf("%s", "Parent - Terminating...\n");
}

canonical_original_code:
void Parent()
{
 printf("%s", "Parent - Child process has been created.\n");
 sleep((3));
 struct __sigset_t maskAllUsr1;
 struct __sigset_t maskAllUsr2;
 sigfillset( &maskAllUsr1 );
 sigfillset( &maskAllUsr2 );
 sigdelset( &maskAllUsr1, 10 );
 sigdelset( &maskAllUsr2, 12 );
 SetupHandler( 10, Parent_onUsr1 );
 SetupHandler( 12, Parent_onUsr2 );
 printf("%s", "Parent - Start the child working.\n");
 kill(_forkPid, 10);
 if( _sigReceived == 0 )
  sigsuspend(&maskAllUsr1);
 else
  Error(("_sigReceived != 0: SIGUSR1"));
 _sigReceived = 0;
 sleep((3));
 printf("%s", "Parent - Sending SIGUSR2...\n");
 kill(_forkPid, 12);
 if( _sigReceived == 0 )
  sigsuspend( &maskAllUsr2 );
 else
  Error(("_sigReceived != 0: SIGUSR2"));
 _sigReceived = 0;
 printf("%s", "Parent - Terminating...\n");
}

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


Child

decompiled_code:
int Child()
{
__pid_t v0; // eax
__pid_t v1; // eax
sigset_t v3; // [rsp+0h] [rbp-108h] BYREF
sigset_t set; // [rsp+80h] [rbp-88h] BYREF

sigfillset(&v3);
sigfillset(&set);
sigdelset(&v3, 10);
sigdelset(&set, 12);
SetupHandler(10, (void (*)(int))Child_onUsr1);
SetupHandler(12, (void (*)(int))Child_onUsr2);
printf("\n%s\n\n", "Child - Child is running.\nWaiting for 'task start' signal from parent.");
if ( sigReceived )
Error("_sigReceived != 0: SIGUSR1");
sigsuspend(&v3);
sigReceived = 0;
puts("Child - Notifying parent that I'm starting my task.");
sleep(3u);
v0 = getppid();
kill(v0, 10);
printf("Child - WORKING HARD: %d\n", 1LL);
printf("Child - WORKING HARD: %d\n", 2LL);
printf("Child - WORKING HARD: %d\n", 3LL);
printf("%s\n\n", "Child - Done working! Waiting for SIGUSR2 from parent.");
if ( sigReceived )
Error("_sigReceived != 0: SIGUSR2");
sigsuspend(&set);
sigReceived = 0;
printf("%s\n\n", "Child - Notifying parent that our work is done.");
v1 = getppid();
kill(v1, 12);
return printf("%s\n\n", "Child - Termination is imminent!");
}

canonical_decompiled_code:
int func15()
{
__pid_t v0; // eax
__pid_t v1; // eax
sigset_t v3; // [rsp+0h] [rbp-108h] BYREF
sigset_t set; // [rsp+80h] [rbp-88h] BYREF

sigfillset(&v3);
sigfillset(&set);
sigdelset(&v3, 10);
sigdelset(&set, 12);
func12(10, (void (*)(int))Child_onUsr1);
func12(12, (void (*)(int))Child_onUsr2);
printf("\n%s\n\n", "Child - Child is running.\nWaiting for 'task start' signal from parent.");
if ( sigReceived )
func13("_sigReceived != 0: SIGUSR1");
sigsuspend(&v3);
sigReceived = 0;
puts("Child - Notifying parent that I'm starting my task.");
sleep(3u);
v0 = getppid();
kill(v0, 10);
printf("Child - WORKING HARD: %d\n", 1LL);
printf("Child - WORKING HARD: %d\n", 2LL);
printf("Child - WORKING HARD: %d\n", 3LL);
printf("%s\n\n", "Child - Done working! Waiting for SIGUSR2 from parent.");
if ( sigReceived )
func13("_sigReceived != 0: SIGUSR2");
sigsuspend(&set);
sigReceived = 0;
printf("%s\n\n", "Child - Notifying parent that our work is done.");
v1 = getppid();
kill(v1, 12);
return printf("%s\n\n", "Child - Termination is imminent!");
}

original_code:
void Child()
{
 sigset_t maskAllUsr1;
 sigset_t maskAllUsr2;
 sigfillset(&maskAllUsr1);
 sigfillset(&maskAllUsr2);
 sigdelset(&maskAllUsr1, 10);
 sigdelset(&maskAllUsr2, 12);
 SetupHandler(10, Child_onUsr1);
 SetupHandler(12, Child_onUsr2);
 printf("\n%s\n\n", "Child - Child is running.\nWaiting for 'task start' signal from parent.");
 if(_sigReceived == 0)
  sigsuspend(&maskAllUsr1);
 else
  Error(("_sigReceived != 0: SIGUSR1"));
 _sigReceived = 0;
 printf("%s\n", "Child - Notifying parent that I'm starting my task.");
 sleep((3));
 kill(getppid(), 10);
 int count = 0;
 while(count++ < (3))
 {
  printf("Child - WORKING HARD: %d\n", count);
 }
 printf("%s\n\n", "Child - Done working! Waiting for SIGUSR2 from parent.");
 if(_sigReceived == 0)
  sigsuspend(&maskAllUsr2);
 else
  Error(("_sigReceived != 0: SIGUSR2"));
 _sigReceived = 0;
 printf("%s\n\n", "Child - Notifying parent that our work is done.");
 kill(getppid(), 12);
 printf("%s\n\n", "Child - Termination is imminent!");
}

canonical_original_code:
void Child()
{
 struct __sigset_t maskAllUsr1;
 struct __sigset_t maskAllUsr2;
 sigfillset(&maskAllUsr1);
 sigfillset(&maskAllUsr2);
 sigdelset(&maskAllUsr1, 10);
 sigdelset(&maskAllUsr2, 12);
 SetupHandler(10, Child_onUsr1);
 SetupHandler(12, Child_onUsr2);
 printf("\n%s\n\n", "Child - Child is running.\nWaiting for 'task start' signal from parent.");
 if(_sigReceived == 0)
  sigsuspend(&maskAllUsr1);
 else
  Error(("_sigReceived != 0: SIGUSR1"));
 _sigReceived = 0;
 printf("%s\n", "Child - Notifying parent that I'm starting my task.");
 sleep((3));
 kill(getppid(), 10);
 int count = 0;
 while(count++ < (3))
 {
  printf("Child - WORKING HARD: %d\n", count);
 }
 printf("%s\n\n", "Child - Done working! Waiting for SIGUSR2 from parent.");
 if(_sigReceived == 0)
  sigsuspend(&maskAllUsr2);
 else
  Error(("_sigReceived != 0: SIGUSR2"));
 _sigReceived = 0;
 printf("%s\n\n", "Child - Notifying parent that our work is done.");
 kill(getppid(), 12);
 printf("%s\n\n", "Child - Termination is imminent!");
}

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


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
sigset_t v4; // [rsp+0h] [rbp-88h] BYREF

puts("Frank Nielson and Caleb Kruger\nCS 3060-001 Project 5");
sigfillset(&v4);
sigprocmask(0, &v4, 0LL);
SetupHandler(2);
forkPid = fork();
if ( forkPid >= 0 )
{
if ( forkPid )
Parent(2LL, OnCtrlC);
else
Child(2LL, OnCtrlC);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
sigset_t v4; // [rsp+0h] [rbp-88h] BYREF

puts("Frank Nielson and Caleb Kruger\nCS 3060-001 Project 5");
sigfillset(&v4);
sigprocmask(0, &v4, 0LL);
func12(2);
forkPid = fork();
if ( forkPid >= 0 )
{
if ( forkPid )
func14(2LL, OnCtrlC);
else
func15(2LL, OnCtrlC);
}
return 0;
}

original_code:
int main()
{
 printf("Frank Nielson and Caleb Kruger\nCS 3060-001 Project 5\n");
 sigset_t maskAll;
 sigfillset(&maskAll);
 sigprocmask(0, &maskAll, ((void *)0));
 SetupHandler(2, OnCtrlC);
 _forkPid = fork();
 if(_forkPid >= 0)
 {
  if(_forkPid == 0)
  {
   Child();
  }
  else
  {
   Parent();
  }
 }
 return 0;
}

canonical_original_code:
int main()
{
 printf("Frank Nielson and Caleb Kruger\nCS 3060-001 Project 5\n");
 struct __sigset_t maskAll;
 sigfillset(&maskAll);
 sigprocmask(0, &maskAll, ((void *)0));
 SetupHandler(2, OnCtrlC);
 _forkPid = fork();
 if(_forkPid >= 0)
 {
  if(_forkPid == 0)
  {
   Child();
  }
  else
  {
   Parent();
  }
 }
 return 0;
}


IncrementCounter

decompiled_code:
void *__fastcall IncrementCounter(void *a1)
{
int v1; // ebx
int v2; // ebp

v1 = count + 1;
v2 = count + 11;
do
{
sleep(1u);
count = v1++;
}
while ( v1 != v2 );
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func7(void *a1)
{
int v1; // ebx
int v2; // ebp

v1 = count + 1;
v2 = count + 11;
do
{
sleep(1u);
count = v1++;
}
while ( v1 != v2 );
return 0LL;
}

original_code:
void* IncrementCounter( void* m )
{
    int i;
    for (i = 0; i < 10; ++i)
    {
        int tempValue = _count;
        sleep(1);
        tempValue = tempValue + 1;
        _count = tempValue;
    }
 return ((void *)0);
}

canonical_original_code:
void *IncrementCounter(void *m)
{
    int i;
    for (i = 0; i < 10; ++i)
    {
        int tempValue = _count;
        sleep(1);
        tempValue = tempValue + 1;
        _count = tempValue;
    }
 return ((void *)0);
}

variable_types:
m
void *

variable_types: i int

variable_types: tempValue int

return_type: void *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
pthread_t v4; // [rsp+0h] [rbp-28h] BYREF
pthread_t newthread; // [rsp+8h] [rbp-20h] BYREF
pthread_t v6; // [rsp+10h] [rbp-18h] BYREF
pthread_t v7[2]; // [rsp+18h] [rbp-10h] BYREF

count = 0;
pthread_create(&v4, 0LL, IncrementCounter, 0LL);
pthread_create(&newthread, 0LL, IncrementCounter, 0LL);
pthread_create(&v6, 0LL, IncrementCounter, 0LL);
pthread_create(v7, 0LL, IncrementCounter, 0LL);
printf("%s%d\n", "COUNT: ", (unsigned int)count);
return 0;
}

original_code:
int main()
{
 pthread_t thr1, thr2, thr3, thr4;
 _count = 0;
 pthread_create(&thr1, ((void *)0), IncrementCounter, ((void *)0));
 pthread_create(&thr2, ((void *)0), IncrementCounter, ((void *)0));
 pthread_create(&thr3, ((void *)0), IncrementCounter, ((void *)0));
 pthread_create(&thr4, ((void *)0), IncrementCounter, ((void *)0));
 printf("%s%d\n", "COUNT: ", _count);
 return 0;
}

canonical_original_code:
int main()
{
 unsigned long thr1; unsigned long thr2; unsigned long thr3; unsigned long thr4;
 _count = 0;
 pthread_create(&thr1, ((void *)0), IncrementCounter, ((void *)0));
 pthread_create(&thr2, ((void *)0), IncrementCounter, ((void *)0));
 pthread_create(&thr3, ((void *)0), IncrementCounter, ((void *)0));
 pthread_create(&thr4, ((void *)0), IncrementCounter, ((void *)0));
 printf("%s%d\n", "COUNT: ", _count);
 return 0;
}


repo: fnl/ungreek

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er12
int v4; // eax

v3 = 0;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "h");
if ( v4 == -1 )
break;
if ( v4 != 63 )
{
if ( v4 != 104 )
main_cold();
v3 = 1;
}
}
if ( v3 )
help(*argv);
run(&argv[optind], (unsigned int)(argc - optind));
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er12
int v4; // eax

v3 = 0;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "h");
if ( v4 == -1 )
break;
if ( v4 != 63 )
{
if ( v4 != 104 )
func1();
v3 = 1;
}
}
if ( v3 )
func8(*argv);
func12(&argv[optind], (unsigned int)(argc - optind));
exit(0);
}

original_code:
int main(int argc, char **argv) {
 int show_help = 0;
 int c;
 while ((c = getopt(argc, argv, "h")) != -1)
  switch (c) {
   case 'h': show_help = 1; break;
   case '?': break;
   default: abort();
  }
 if (show_help) help(argv[0]);
 run(argv + optind, argc - optind);
 exit(0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: c int


help

decompiled_code:
void __fastcall __noreturn help(char *a1)
{
char *v1; // rax

v1 = __xpg_basename(a1);
fprintf(stderr, "usage: %s [-h] [file ...]\n", v1);
fwrite("expand Greeek letters to Latin names\n", 1uLL, 0x25uLL, stderr);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(char *a1)
{
char *v1; // rax

v1 = __xpg_basename(a1);
fprintf(stderr, "usage: %s [-h] [file ...]\n", v1);
fwrite("expand Greeek letters to Latin names\n", 1uLL, 0x25uLL, stderr);
exit(0);
}

original_code:
static void help(char *name) {
 fprintf(stderr, "usage: %s [-h] [file ...]\n", __xpg_basename(name));
 fputs("expand Greeek letters to Latin names\n", stderr);
 exit(0);
}

variable_types:
name
char *


repo: fogleman/HelloGL

decompiled_code:
__int64 __fastcall gen_buffer(int a1, __int64 a2)
{
unsigned int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

_glewGenBuffers(1LL, v3);
_glewBindBuffer(34962LL, v3[0]);
_glewBufferData(34962LL, a1, a2, 35044LL);
_glewBindBuffer(34962LL, 0LL);
return v3[0];
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2)
{
unsigned int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

_glewGenBuffers(1LL, v3);
_glewBindBuffer(34962LL, v3[0]);
_glewBufferData(34962LL, a1, a2, 35044LL);
_glewBindBuffer(34962LL, 0LL);
return v3[0];
}

original_code:
GLuint gen_buffer(GLsizei size, GLfloat *data) {
    GLuint buffer;
    __glewGenBuffers(1, &buffer);
    __glewBindBuffer(0x8892, buffer);
    __glewBufferData(0x8892, size, data, 0x88E4);
    __glewBindBuffer(0x8892, 0);
    return buffer;
}

canonical_original_code:
unsigned int gen_buffer(int size, float *data) {
    unsigned int buffer;
    __glewGenBuffers(1, &buffer);
    __glewBindBuffer(0x8892, buffer);
    __glewBufferData(0x8892, size, data, 0x88E4);
    __glewBindBuffer(0x8892, 0);
    return buffer;
}

variable_types: size int

variable_types:
data
float *

variable_types:
buffer
unsigned int

return_type: unsigned int


decompiled_code:
__int64 __fastcall del_buffer(int a1)
{
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2[0] = a1;
return _glewDeleteBuffers(1LL, v2);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2[0] = a1;
return _glewDeleteBuffers(1LL, v2);
}

original_code:
void del_buffer(GLuint buffer) {
    __glewDeleteBuffers(1, &buffer);
}

canonical_original_code:
void del_buffer(unsigned int buffer) {
    __glewDeleteBuffers(1, &buffer);
}


decompiled_code:
__int64 __fastcall make_shader(__int64 a1, __int64 a2)
{
__int64 v2; // r12
unsigned int v3; // er13
char *v4; // rbp
__int64 v6; // [rsp+8h] [rbp-30h] BYREF
int v7; // [rsp+18h] [rbp-20h] BYREF
int v8[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

v6 = a2;
v2 = (unsigned int)_glewCreateShader();
_glewShaderSource(v2, 1LL, &v6, 0LL);
_glewCompileShader((unsigned int)v2);
_glewGetShaderiv((unsigned int)v2, 35713LL, &v7);
if ( !v7 )
{
_glewGetShaderiv((unsigned int)v2, 35716LL, v8);
v3 = v8[0];
v4 = (char *)calloc(v8[0], 1uLL);
_glewGetShaderInfoLog((unsigned int)v2, v3, 0LL, v4);
fprintf(stderr, "glCompileShader failed:\n%s\n", v4);
free(v4);
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // r12
unsigned int v3; // er13
char *v4; // rbp
__int64 v6; // [rsp+8h] [rbp-30h] BYREF
int v7; // [rsp+18h] [rbp-20h] BYREF
int v8[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

v6 = a2;
v2 = (unsigned int)_glewCreateShader();
_glewShaderSource(v2, 1LL, &v6, 0LL);
_glewCompileShader((unsigned int)v2);
_glewGetShaderiv((unsigned int)v2, 35713LL, &v7);
if ( !v7 )
{
_glewGetShaderiv((unsigned int)v2, 35716LL, v8);
v3 = v8[0];
v4 = (char *)calloc(v8[0], 1uLL);
_glewGetShaderInfoLog((unsigned int)v2, v3, 0LL, v4);
fprintf(stderr, "glCompileShader failed:\n%s\n", v4);
free(v4);
}
return (unsigned int)v2;
}

original_code:
GLuint make_shader(GLenum type, const char *source) {
    GLuint shader = __glewCreateShader(type);
    __glewShaderSource(shader, 1, &source, ((void *)0));
    __glewCompileShader(shader);
    GLint status;
    __glewGetShaderiv(shader, 0x8B81, &status);
    if (status == 0) {
        GLint length;
        __glewGetShaderiv(shader, 0x8B84, &length);
        GLchar *info = calloc(length, sizeof(GLchar));
        __glewGetShaderInfoLog(shader, length, ((void *)0), info);
        fprintf(stderr, "glCompileShader failed:\n%s\n", info);
        free(info);
    }
    return shader;
}

canonical_original_code:
unsigned int make_shader(unsigned int type, char *source) {
    unsigned int shader = __glewCreateShader(type);
    __glewShaderSource(shader, 1, &source, ((void *)0));
    __glewCompileShader(shader);
    int status;
    __glewGetShaderiv(shader, 0x8B81, &status);
    if (status == 0) {
        int length;
        __glewGetShaderiv(shader, 0x8B84, &length);
        char *info = calloc(length, sizeof(GLchar));
        __glewGetShaderInfoLog(shader, length, ((void *)0), info);
        fprintf(stderr, "glCompileShader failed:\n%s\n", info);
        free(info);
    }
    return shader;
}

variable_types:
type
unsigned int

variable_types:
source
char *

variable_types:
shader
unsigned int

variable_types: status int

variable_types: length int

variable_types:
info
char *


decompiled_code:
__int64 __fastcall load_shader(unsigned int a1, const char *a2)
{
void *v2; // rbp
unsigned int v3; // er12

v2 = load_file(a2);
v3 = make_shader(a1, (__int64)v2);
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, const char *a2)
{
void *v2; // rbp
unsigned int v3; // er12

v2 = func0(a2);
v3 = func1(a1, (__int64)v2);
free(v2);
return v3;
}

original_code:
GLuint load_shader(GLenum type, const char *path) {
    char *data = load_file(path);
    GLuint result = make_shader(type, data);
    free(data);
    return result;
}

canonical_original_code:
unsigned int load_shader(unsigned int type, char *path) {
    char *data = load_file(path);
    unsigned int result = make_shader(type, data);
    free(data);
    return result;
}

variable_types:
path
char *

variable_types:
data
char *

variable_types:
result
unsigned int


decompiled_code:
__int64 __fastcall make_program(unsigned int a1, unsigned int a2)
{
__int64 v2; // r12
unsigned int v3; // er15
char *v4; // r14
int v6; // [rsp+8h] [rbp-30h] BYREF
int v7[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v2 = (unsigned int)_glewCreateProgram();
_glewAttachShader(v2, a1);
_glewAttachShader((unsigned int)v2, a2);
_glewLinkProgram((unsigned int)v2);
_glewGetProgramiv((unsigned int)v2, 35714LL, &v6);
if ( !v6 )
{
_glewGetProgramiv((unsigned int)v2, 35716LL, v7);
v3 = v7[0];
v4 = (char *)calloc(v7[0], 1uLL);
_glewGetProgramInfoLog((unsigned int)v2, v3, 0LL, v4);
fprintf(stderr, "glLinkProgram failed: %s\n", v4);
free(v4);
}
_glewDetachShader((unsigned int)v2, a1);
_glewDetachShader((unsigned int)v2, a2);
_glewDeleteShader(a1);
_glewDeleteShader(a2);
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1, unsigned int a2)
{
__int64 v2; // r12
unsigned int v3; // er15
char *v4; // r14
int v6; // [rsp+8h] [rbp-30h] BYREF
int v7[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v2 = (unsigned int)_glewCreateProgram();
_glewAttachShader(v2, a1);
_glewAttachShader((unsigned int)v2, a2);
_glewLinkProgram((unsigned int)v2);
_glewGetProgramiv((unsigned int)v2, 35714LL, &v6);
if ( !v6 )
{
_glewGetProgramiv((unsigned int)v2, 35716LL, v7);
v3 = v7[0];
v4 = (char *)calloc(v7[0], 1uLL);
_glewGetProgramInfoLog((unsigned int)v2, v3, 0LL, v4);
fprintf(stderr, "glLinkProgram failed: %s\n", v4);
free(v4);
}
_glewDetachShader((unsigned int)v2, a1);
_glewDetachShader((unsigned int)v2, a2);
_glewDeleteShader(a1);
_glewDeleteShader(a2);
return (unsigned int)v2;
}

original_code:
GLuint make_program(GLuint shader1, GLuint shader2) {
    GLuint program = __glewCreateProgram();
    __glewAttachShader(program, shader1);
    __glewAttachShader(program, shader2);
    __glewLinkProgram(program);
    GLint status;
    __glewGetProgramiv(program, 0x8B82, &status);
    if (status == 0) {
        GLint length;
        __glewGetProgramiv(program, 0x8B84, &length);
        GLchar *info = calloc(length, sizeof(GLchar));
        __glewGetProgramInfoLog(program, length, ((void *)0), info);
        fprintf(stderr, "glLinkProgram failed: %s\n", info);
        free(info);
    }
    __glewDetachShader(program, shader1);
    __glewDetachShader(program, shader2);
    __glewDeleteShader(shader1);
    __glewDeleteShader(shader2);
    return program;
}

canonical_original_code:
unsigned int make_program(unsigned int shader1, unsigned int shader2) {
    unsigned int program = __glewCreateProgram();
    __glewAttachShader(program, shader1);
    __glewAttachShader(program, shader2);
    __glewLinkProgram(program);
    int status;
    __glewGetProgramiv(program, 0x8B82, &status);
    if (status == 0) {
        int length;
        __glewGetProgramiv(program, 0x8B84, &length);
        char *info = calloc(length, sizeof(GLchar));
        __glewGetProgramInfoLog(program, length, ((void *)0), info);
        fprintf(stderr, "glLinkProgram failed: %s\n", info);
        free(info);
    }
    __glewDetachShader(program, shader1);
    __glewDetachShader(program, shader2);
    __glewDeleteShader(shader1);
    __glewDeleteShader(shader2);
    return program;
}

variable_types:
program
unsigned int


decompiled_code:
__int64 __fastcall load_program(const char *a1, const char *a2)
{
unsigned int v2; // ebp
unsigned int v3; // eax

v2 = load_shader(0x8B31u, a1);
v3 = load_shader(0x8B30u, a2);
return make_program(v2, v3);
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, const char *a2)
{
unsigned int v2; // ebp
unsigned int v3; // eax

v2 = func2(0x8B31u, a1);
v3 = func2(0x8B30u, a2);
return func3(v2, v3);
}

original_code:
GLuint load_program(const char *path1, const char *path2) {
    GLuint shader1 = load_shader(0x8B31, path1);
    GLuint shader2 = load_shader(0x8B30, path2);
    GLuint program = make_program(shader1, shader2);
    return program;
}

canonical_original_code:
unsigned int load_program(char *path1, char *path2) {
    unsigned int shader1 = load_shader(0x8B31, path1);
    unsigned int shader2 = load_shader(0x8B30, path2);
    unsigned int program = make_program(shader1, shader2);
    return program;
}


accept

repo: folays/flexelf

decompiled_code:
void __noreturn accept()
{
puts("ACCEPT HOOKED!");
flex_elf_test();
exit(1);
}

canonical_decompiled_code:
void __noreturn func14()
{
puts("ACCEPT HOOKED!");
func13();
exit(1);
}

original_code:
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
  printf("ACCEPT HOOKED!\n");
  _flex_elf_test();
  exit(1);
}

canonical_original_code:
int accept(int sockfd, struct sockaddr *addr, unsigned int *addrlen)
{
  printf("ACCEPT HOOKED!\n");
  _flex_elf_test();
  exit(1);
}

variable_types: sockfd int

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

variable_types:
addrlen
unsigned int *


main

repo: foo-script/tuxpaint-szluug

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
return 0;
}

original_code:
int main(int argc __attribute__ ((__unused__)), char *argv[] __attribute__ ((__unused__))){
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


repo: foolswood/Physyn

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

if ( runbefore_0 )
{
puts("Shan't! (you tried to set the dimensions twice, bad)");
result = 0LL;
dimensions = 0;
}
else
{
dimensions = a1;
result = a1;
runbefore_0 = 1;
}
return result;
}

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

if ( runbefore_0 )
{
puts("Shan't! (you tried to set the dimensions twice, bad)");
result = 0LL;
dimensions = 0;
}
else
{
dimensions = a1;
result = a1;
runbefore_0 = 1;
}
return result;
}

original_code:
short set_dimensions(unsigned int i) {
 static int runbefore;
 if (!runbefore) {
  dimensions = i;
  runbefore = 1;
 }
 else {
  printf("Shan't! (you tried to set the dimensions twice, bad)\n");
  dimensions = 0;
 }
 return dimensions;
}

variable_types:
i
unsigned int

variable_types: runbefore int

return_type: short


Vheap

decompiled_code:
__int64 __fastcall Vheap(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // ecx
__int64 v3; // r8
int v4; // eax
__int64 v5; // rdx

v1 = Vmk();
v2 = dimensions;
v3 = v1;
if ( dimensions )
{
v4 = 0;
do
{
v5 = (unsigned __int16)v4++;
*(_DWORD *)(v3 + 4 * v5) = *(_DWORD *)(a1 + 4 * v5);
}
while ( (unsigned __int16)v4 < v2 );
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // ecx
__int64 v3; // r8
int v4; // eax
__int64 v5; // rdx

v1 = Vmk();
v2 = dimensions;
v3 = v1;
if ( dimensions )
{
v4 = 0;
do
{
v5 = (unsigned __int16)v4++;
*(_DWORD *)(v3 + 4 * v5) = *(_DWORD *)(a1 + 4 * v5);
}
while ( (unsigned __int16)v4 < v2 );
}
return v3;
}

original_code:
vector Vheap(const vector const a) {
 vector v = Vmk();
 unsigned short d;
 for (d=0; d < dimensions; d++) {
  v[d] = a[d];
 }
 return v;
}

canonical_original_code:
float *Vheap(float *a) {
 float *v = Vmk();
 unsigned short d;
 for (d=0; d < dimensions; d++) {
  v[d] = a[d];
 }
 return v;
}

variable_types:
a
float *

variable_types:
v
float *

variable_types:
d
unsigned short

return_type: float *


Vzero

decompiled_code:
void __fastcall Vzero(__int64 a1)
{
unsigned int v1; // ecx
int v2; // eax
__int64 v3; // rdx

v1 = dimensions;
if ( dimensions )
{
v2 = 0;
do
{
v3 = (unsigned __int16)v2++;
*(_DWORD *)(a1 + 4 * v3) = 0;
}
while ( (unsigned __int16)v2 < v1 );
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
unsigned int v1; // ecx
int v2; // eax
__int64 v3; // rdx

v1 = dimensions;
if ( dimensions )
{
v2 = 0;
do
{
v3 = (unsigned __int16)v2++;
*(_DWORD *)(a1 + 4 * v3) = 0;
}
while ( (unsigned __int16)v2 < v1 );
}
}

original_code:
void Vzero(vector const a) {
 unsigned short d;
 for (d = 0; d < dimensions; d++) {
  a[d] = 0.0;
 }
}

canonical_original_code:
void Vzero(float *a) {
 unsigned short d;
 for (d = 0; d < dimensions; d++) {
  a[d] = 0.0;
 }
}


Vadd

decompiled_code:
void __fastcall Vadd(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // er8
int v5; // eax
__int64 v6; // rdx

v3 = dimensions;
if ( dimensions )
{
v5 = 0;
do
{
v6 = (unsigned __int16)v5++;
*(float *)(a1 + 4 * v6) = *(float *)(a2 + 4 * v6) + *(float *)(a3 + 4 * v6);
}
while ( (unsigned __int16)v5 < v3 );
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // er8
int v5; // eax
__int64 v6; // rdx

v3 = dimensions;
if ( dimensions )
{
v5 = 0;
do
{
v6 = (unsigned __int16)v5++;
*(float *)(a1 + 4 * v6) = *(float *)(a2 + 4 * v6) + *(float *)(a3 + 4 * v6);
}
while ( (unsigned __int16)v5 < v3 );
}
}

original_code:
void Vadd(vector const a, const vector const b, const vector const c) {
 unsigned short d;
 for (d = 0; d < dimensions; d++)
  a[d] = b[d] + c[d];
}

canonical_original_code:
void Vadd(float *a, float *b, float *c) {
 unsigned short d;
 for (d = 0; d < dimensions; d++)
  a[d] = b[d] + c[d];
}

variable_types:
b
float *

variable_types:
c
float *


Vsub

decompiled_code:
void __fastcall Vsub(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // er8
int v5; // eax
__int64 v6; // rdx

v3 = dimensions;
if ( dimensions )
{
v5 = 0;
do
{
v6 = (unsigned __int16)v5++;
*(float *)(a1 + 4 * v6) = *(float *)(a2 + 4 * v6) - *(float *)(a3 + 4 * v6);
}
while ( (unsigned __int16)v5 < v3 );
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // er8
int v5; // eax
__int64 v6; // rdx

v3 = dimensions;
if ( dimensions )
{
v5 = 0;
do
{
v6 = (unsigned __int16)v5++;
*(float *)(a1 + 4 * v6) = *(float *)(a2 + 4 * v6) - *(float *)(a3 + 4 * v6);
}
while ( (unsigned __int16)v5 < v3 );
}
}

original_code:
void Vsub(vector const a, const vector const b, const vector const c) {
 unsigned short d;
 for (d = 0; d < dimensions; d++)
  a[d] = b[d] - c[d];
}

canonical_original_code:
void Vsub(float *a, float *b, float *c) {
 unsigned short d;
 for (d = 0; d < dimensions; d++)
  a[d] = b[d] - c[d];
}


decompiled_code:
void __fastcall Vtimes_scalar(__int64 a1, __int64 a2, float a3)
{
unsigned int v3; // ecx
int v4; // eax
__int64 v5; // rdx

v3 = dimensions;
if ( dimensions )
{
v4 = 0;
do
{
v5 = (unsigned __int16)v4++;
*(float *)(a1 + 4 * v5) = *(float *)(a2 + 4 * v5) * a3;
}
while ( (unsigned __int16)v4 < v3 );
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, __int64 a2, float a3)
{
unsigned int v3; // ecx
int v4; // eax
__int64 v5; // rdx

v3 = dimensions;
if ( dimensions )
{
v4 = 0;
do
{
v5 = (unsigned __int16)v4++;
*(float *)(a1 + 4 * v5) = *(float *)(a2 + 4 * v5) * a3;
}
while ( (unsigned __int16)v4 < v3 );
}
}

original_code:
void Vtimes_scalar(vector const a, const vector const b, const float c) {
 unsigned short d;
 for (d = 0; d < dimensions; d++) {
  a[d] = b[d]*c;
 }
}

canonical_original_code:
void Vtimes_scalar(float *a, float *b, float c) {
 unsigned short d;
 for (d = 0; d < dimensions; d++) {
  a[d] = b[d]*c;
 }
}

variable_types: c float


Vmodulus

decompiled_code:
void __fastcall Vmodulus(__int64 a1)
{
int v1; // eax
float v2; // xmm1_4
__int64 v3; // rdx

if ( dimensions )
{
v1 = 0;
v2 = 0.0;
do
{
v3 = (unsigned __int16)v1++;
v2 = v2 + *(float *)(a1 + 4 * v3) * *(float *)(a1 + 4 * v3);
}
while ( (unsigned __int16)v1 < (unsigned int)dimensions );
if ( v2 < 0.0 )
sqrtf(v2);
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1)
{
int v1; // eax
float v2; // xmm1_4
__int64 v3; // rdx

if ( dimensions )
{
v1 = 0;
v2 = 0.0;
do
{
v3 = (unsigned __int16)v1++;
v2 = v2 + *(float *)(a1 + 4 * v3) * *(float *)(a1 + 4 * v3);
}
while ( (unsigned __int16)v1 < (unsigned int)dimensions );
if ( v2 < 0.0 )
sqrtf(v2);
}
}

original_code:
float Vmodulus(const vector const a) {
 unsigned short d;
 float sum = 0.0;
 for (d = 0; d < dimensions; d++) {
  sum += pow(a[d], 2.0);
 }
 return sqrt(sum);
}

canonical_original_code:
float Vmodulus(float *a) {
 unsigned short d;
 float sum = 0.0;
 for (d = 0; d < dimensions; d++) {
  sum += pow(a[d], 2.0);
 }
 return sqrt(sum);
}

variable_types: sum float

return_type: float


decompiled_code:
__int64 __fastcall is_float_char(int a1)
{
__int64 v1; // rdx
__int64 result; // rax

if ( (unsigned __int8)(a1 - 43) <= 0x3Au && (v1 = 0x40000000400000DLL, _bittest64(&v1, (unsigned int)(a1 - 43))) )
result = 1LL;
else
result = ((*_ctype_b_loc())[(char)a1] >> 11) & 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 v1; // rdx
__int64 result; // rax

if ( (unsigned __int8)(a1 - 43) <= 0x3Au && (v1 = 0x40000000400000DLL, _bittest64(&v1, (unsigned int)(a1 - 43))) )
result = 1LL;
else
result = ((*_ctype_b_loc())[(char)a1] >> 11) & 1;
return result;
}

original_code:
static short is_float_char(char c) {
 switch (c) {
  case '.':
  case '-':
  case '+':
  case 'e':
  case 'E':
   break;
  default:
   if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISdigit))
    return 0;
 }
 return 1;
}

canonical_original_code:
static short is_float_char(char c) {
 switch (c) {
  case '.':
  case '-':
  case '+':
  case 'e':
  case 'E':
   break;
  default:
   if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISdigit))
    return 0;
 }
 return 1;
}

variable_types: c char


original_code:
char *get_word(const char *str, unsigned int *pos) {
 unsigned int i = *pos;
 char c = str[i];
 char_list *tail, *cl;
 while (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISspace))
  c = str[++i];
 if (c == '\0')
  return ((void *)0);
 if ((!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISspace)) && (c != '\0')) {
  cl = tail = clmk(c);
  c = str[++i];
 }
 else
  return ((void *)0);
 while ((!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISspace)) && (c != '\0')) {
  tail = clappend(tail, c);
  c = str[++i];
 }
 *pos = i;
 return clconvert(cl);
}

canonical_original_code:
char *get_word(char *str, unsigned int *pos) {
 unsigned int i = *pos;
 char c = str[i];
 struct char_list *tail; struct char_list *cl;
 while (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISspace))
  c = str[++i];
 if (c == '\0')
  return ((void *)0);
 if ((!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISspace)) && (c != '\0')) {
  cl = tail = clmk(c);
  c = str[++i];
 }
 else
  return ((void *)0);
 while ((!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISspace)) && (c != '\0')) {
  tail = clappend(tail, c);
  c = str[++i];
 }
 *pos = i;
 return clconvert(cl);
}

variable_types:
str
char *

variable_types:
pos
unsigned int *

variable_types: struct char_list { char c; struct char_list *next; } *

return_type: char *


decompiled_code:
char *__fastcall read_vector(__int64 a1, unsigned int *a2)
{
__int64 v3; // rax
unsigned int v4; // er14
char *v5; // r12
const unsigned __int16 **v6; // rax
const unsigned __int16 *v7; // rsi
const unsigned __int16 **v8; // rbx
char v9; // al
char v10; // r13
void *v11; // rdi
int v13; // eax
unsigned int v14; // [rsp+4h] [rbp-44h]
char *v15; // [rsp+8h] [rbp-40h]

v3 = Vmk();
v4 = *a2;
v5 = (char *)v3;
v6 = _ctype_b_loc();
v7 = *v6;
v8 = v6;
v9 = *(_BYTE *)(a1 + v4);
while ( 1 )
{
++v4;
if ( (v7[v9] & 0x2000) == 0 )
break;
v9 = *(_BYTE *)(a1 + v4);
if ( !v9 )
goto LABEL_10;
}
if ( v9 != 40 )
goto LABEL_10;
v14 = 0;
if ( !dimensions )
goto LABEL_10;
while ( 1 )
{
v15 = (char *)(a1 + v4);
v10 = *v15;
while ( (unsigned __int16)is_float_char(v10) || ((*v8)[v10] & 0x2000) != 0 )
{
v10 = *(_BYTE *)(a1 + ++v4);
if ( !v10 )
goto LABEL_10;
}
if ( v10 != 44 )
break;
if ( !(unsigned int)_isoc99_sscanf(v15, &unk_6A7, &v5[4 * v14]) )
goto LABEL_10;
++v14;
++v4;
LABEL_14:
if ( v14 >= dimensions )
goto LABEL_10;
}
if ( !*(_BYTE *)(a1 + (v4 == 41)) )
goto LABEL_14;
v13 = _isoc99_sscanf(v15, &unk_6A7, &v5[4 * v14]);
if ( v14 + 1 == dimensions && v13 )
{
*a2 = v4 + 1;
return v5;
}
LABEL_10:
v11 = v5;
v5 = 0LL;
free(v11);
return v5;
}

canonical_decompiled_code:
char *__fastcall func2(__int64 a1, unsigned int *a2)
{
__int64 v3; // rax
unsigned int v4; // er14
char *v5; // r12
const unsigned __int16 **v6; // rax
const unsigned __int16 *v7; // rsi
const unsigned __int16 **v8; // rbx
char v9; // al
char v10; // r13
void *v11; // rdi
int v13; // eax
unsigned int v14; // [rsp+4h] [rbp-44h]
char *v15; // [rsp+8h] [rbp-40h]

v3 = Vmk();
v4 = *a2;
v5 = (char *)v3;
v6 = _ctype_b_loc();
v7 = *v6;
v8 = v6;
v9 = *(_BYTE *)(a1 + v4);
while ( 1 )
{
++v4;
if ( (v7[v9] & 0x2000) == 0 )
break;
v9 = *(_BYTE *)(a1 + v4);
if ( !v9 )
goto LABEL_10;
}
if ( v9 != 40 )
goto LABEL_10;
v14 = 0;
if ( !dimensions )
goto LABEL_10;
while ( 1 )
{
v15 = (char *)(a1 + v4);
v10 = *v15;
while ( (unsigned __int16)func0(v10) || ((*v8)[v10] & 0x2000) != 0 )
{
v10 = *(_BYTE *)(a1 + ++v4);
if ( !v10 )
goto LABEL_10;
}
if ( v10 != 44 )
break;
if ( !(unsigned int)_isoc99_sscanf(v15, &unk_6A7, &v5[4 * v14]) )
goto LABEL_10;
++v14;
++v4;
LABEL_14:
if ( v14 >= dimensions )
goto LABEL_10;
}
if ( !*(_BYTE *)(a1 + (v4 == 41)) )
goto LABEL_14;
v13 = _isoc99_sscanf(v15, &unk_6A7, &v5[4 * v14]);
if ( v14 + 1 == dimensions && v13 )
{
*a2 = v4 + 1;
return v5;
}
LABEL_10:
v11 = v5;
v5 = 0LL;
free(v11);
return v5;
}

original_code:
vector read_vector(const char *line, unsigned int *pos) {
 unsigned int i, start, d;
 vector v = Vmk();
 i = *pos;
 d = 0;
 while (((*__ctype_b_loc ())[(int) ((line[i]))] & (unsigned short int) _ISspace))
  if (line[++i] == '\0') {
   free(v);
   return ((void *)0);
  }
 if (line[i++] == '(') {
  while (d < dimensions) {
   start = i;
   while (is_float_char(line[i]) || ((*__ctype_b_loc ())[(int) ((line[i]))] & (unsigned short int) _ISspace))
    if (line[++i] == '\0') {
     free(v);
     return ((void *)0);
    }
   if (line[i] == ',') {
    if (sscanf(line+start, "%f", v+(d++)))
     i++;
    else
     break;
   }
   else {
    if (line[i == ')']) {
     if ((sscanf(line+start, "%f", v+(d++))) && (d == dimensions)) {
      *pos = ++i;
      return v;
     }
     else
      break;
    }
   }
  }
 }
 free(v);
 return ((void *)0);
}

canonical_original_code:
float *read_vector(char *line, unsigned int *pos) {
 unsigned int i; unsigned int start; unsigned int d;
 float *v = Vmk();
 i = *pos;
 d = 0;
 while (((*__ctype_b_loc ())[(int) ((line[i]))] & (unsigned short) _ISspace))
  if (line[++i] == '\0') {
   free(v);
   return ((void *)0);
  }
 if (line[i++] == '(') {
  while (d < dimensions) {
   start = i;
   while (is_float_char(line[i]) || ((*__ctype_b_loc ())[(int) ((line[i]))] & (unsigned short) _ISspace))
    if (line[++i] == '\0') {
     free(v);
     return ((void *)0);
    }
   if (line[i] == ',') {
    if (sscanf(line+start, "%f", v+(d++)))
     i++;
    else
     break;
   }
   else {
    if (line[i == ')']) {
     if ((sscanf(line+start, "%f", v+(d++))) && (d == dimensions)) {
      *pos = ++i;
      return v;
     }
     else
      break;
    }
   }
  }
 }
 free(v);
 return ((void *)0);
}

variable_types:
line
char *

variable_types:
start
unsigned int

variable_types:
d
unsigned int


original_code:
short extract_curly_braces(line_list **hd, line_list **sl, unsigned int * const i) {
 line_list *before, *start, *end, *head = *hd;
 char c, *str;
 unsigned int j, bcounter = 1;
 if (head == ((void *)0))
  return 4;
 while (1) {
  c = head->str[*i];
  if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISspace)) {
   (*i)++;
  }
  else {
   if (c == '{')
    break;
   else {
    if (c == '\0') {
     head = head->next;
     if (head == ((void *)0))
      return 1;
     (*i) = 0;
    }
    else
     return 2;
   }
  }
 }
 if (head == *hd) {
  j = *i;
  do {
   c = head->str[--j];
  } while (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISspace));
  j++;
  str = calloc(j+1, sizeof(char));
  strncpy(str, head->str, j*sizeof(char));
  str[j] = '\0';
  start = head->next;
  before = llappend(head->prev, str, head->lineno);
  *hd = before;
  j = *i;
  do {
   c = head->str[++j];
  } while(((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISspace));
  if (c != '\0') {
   str = calloc(strlen(head->str)-j, sizeof(char));
   strncpy(str, (head->str)+j, (strlen(head->str)-j)*sizeof(char));
   end = llmk(str, head->lineno);
   end->next = start;
   start->prev = end;
   start = end;
  }
  else {
   start->prev = ((void *)0);
  }
  free((char*) head->str);
  free(head);
 }
 else {
  before = *hd;
  start = head;
  if (start->prev != before) {
   printf("memory leaking here, either fix your wierd ass config file or give me a prod and I'll fix this; fools\n");
  }
 }
 *sl = start;
 *i = 0;
 end = start;
 while (1) {
  c = end->str[*i];
  switch (c) {
   case '{':
    bcounter++;
    (*i)++;
    break;
   case '}':
    bcounter--;
    (*i)++;
    break;
   case '\0':
    end = end->next;
    *i = 0;
    if (end == ((void *)0))
     return 3;
    break;
   default:
    (*i)++;
    break;
  }
  if (bcounter == 0)
   break;
 }
 j = *i;
 do {
  c = (end->str)[j++];
 } while(((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISspace));
 if (c == '\0') {
  if (end->next == ((void *)0))
   before->next = ((void *)0);
  else {
   end->next->prev = before;
   before->next = end->next;
   end->next = ((void *)0);
  }
 }
 else {
  j = (*i) + 1;
  while (((*__ctype_b_loc ())[(int) (((end->str)[j++]))] & (unsigned short int) _ISspace)) {
  }
  str = calloc(strlen(end->str) - j, sizeof(char));
  strncpy(str, end->str, strlen(end->str) - j - 2);
  str[strlen(end->str) - j - 2] = '\0';
  head = llmk(str, end->lineno);
  head->prev = before;
  before->next = head;
  head->next = end->next;
 }
 j = (*i) - 1;
 while (j) {
  if (!((*__ctype_b_loc ())[(int) (((end->str)[j--]))] & (unsigned short int) _ISspace)) {
   str = calloc(j+2, sizeof(char));
   strncpy(str, end->str, j+1);
   str[j+1] = '\0';
   head = llmk(str, end->lineno);
   end->prev->next = head;
   head->prev = end->prev;
   break;
  }
 }
 if (!j)
  end->prev->next = ((void *)0);
 free((char*) end->str);
 free(end);
 return 0;
}

canonical_original_code:
short extract_curly_braces(struct line_list **hd, struct line_list **sl, unsigned int *i) {
 struct line_list *before; struct line_list *start; struct line_list *end; struct line_list *head = *hd;
 char c; char *str;
 unsigned int j; unsigned int bcounter = 1;
 if (head == ((void *)0))
  return 4;
 while (1) {
  c = head->str[*i];
  if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISspace)) {
   (*i)++;
  }
  else {
   if (c == '{')
    break;
   else {
    if (c == '\0') {
     head = head->next;
     if (head == ((void *)0))
      return 1;
     (*i) = 0;
    }
    else
     return 2;
   }
  }
 }
 if (head == *hd) {
  j = *i;
  do {
   c = head->str[--j];
  } while (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISspace));
  j++;
  str = calloc(j+1, sizeof(char));
  strncpy(str, head->str, j*sizeof(char));
  str[j] = '\0';
  start = head->next;
  before = llappend(head->prev, str, head->lineno);
  *hd = before;
  j = *i;
  do {
   c = head->str[++j];
  } while(((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISspace));
  if (c != '\0') {
   str = calloc(strlen(head->str)-j, sizeof(char));
   strncpy(str, (head->str)+j, (strlen(head->str)-j)*sizeof(char));
   end = llmk(str, head->lineno);
   end->next = start;
   start->prev = end;
   start = end;
  }
  else {
   start->prev = ((void *)0);
  }
  free((char *) head->str);
  free(head);
 }
 else {
  before = *hd;
  start = head;
  if (start->prev != before) {
   printf("memory leaking here, either fix your wierd ass config file or give me a prod and I'll fix this; fools\n");
  }
 }
 *sl = start;
 *i = 0;
 end = start;
 while (1) {
  c = end->str[*i];
  switch (c) {
   case '{':
    bcounter++;
    (*i)++;
    break;
   case '}':
    bcounter--;
    (*i)++;
    break;
   case '\0':
    end = end->next;
    *i = 0;
    if (end == ((void *)0))
     return 3;
    break;
   default:
    (*i)++;
    break;
  }
  if (bcounter == 0)
   break;
 }
 j = *i;
 do {
  c = (end->str)[j++];
 } while(((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISspace));
 if (c == '\0') {
  if (end->next == ((void *)0))
   before->next = ((void *)0);
  else {
   end->next->prev = before;
   before->next = end->next;
   end->next = ((void *)0);
  }
 }
 else {
  j = (*i) + 1;
  while (((*__ctype_b_loc ())[(int) (((end->str)[j++]))] & (unsigned short) _ISspace)) {
  }
  str = calloc(strlen(end->str) - j, sizeof(char));
  strncpy(str, end->str, strlen(end->str) - j - 2);
  str[strlen(end->str) - j - 2] = '\0';
  head = llmk(str, end->lineno);
  head->prev = before;
  before->next = head;
  head->next = end->next;
 }
 j = (*i) - 1;
 while (j) {
  if (!((*__ctype_b_loc ())[(int) (((end->str)[j--]))] & (unsigned short) _ISspace)) {
   str = calloc(j+2, sizeof(char));
   strncpy(str, end->str, j+1);
   str[j+1] = '\0';
   head = llmk(str, end->lineno);
   end->prev->next = head;
   head->prev = end->prev;
   break;
  }
 }
 if (!j)
  end->prev->next = ((void *)0);
 free((char *) end->str);
 free(end);
 return 0;
}

variable_types: struct line_list { char *str; unsigned int lineno; struct line_list *next; } **

variable_types:
sl
struct line_list **

variable_types:
i
unsigned int *

variable_types:
j
unsigned int

variable_types:
bcounter
unsigned int


decompiled_code:
void __fastcall free_point(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void free_point(point *p) {
 free(p->x);
 free(p->v);
 free(p->F);
 free(p);
}

canonical_original_code:
void free_point(struct point *p) {
 free(p->x);
 free(p->v);
 free(p->F);
 free(p);
}

variable_types: struct point { float *x; unsigned short connections; float b; } *


decompiled_code:
__int64 __fastcall apply_forces(int a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = a2;
v3 = a2 + 40LL * (unsigned int)(a1 - 1) + 40;
do
{
v4 = v2;
v2 += 40LL;
result = apply_force(v4);
}
while ( v3 != v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rbp
__int64 v4; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = a2;
v3 = a2 + 40LL * (unsigned int)(a1 - 1) + 40;
do
{
v4 = v2;
v2 += 40LL;
result = apply_force(v4);
}
while ( v3 != v2 );
}
return result;
}

original_code:
void apply_forces(pointset a) {
 unsigned int p;
 for (p = 0; p < a.no; p++) {
  apply_force((a.pts)+p);
 }
}

canonical_original_code:
void apply_forces(struct pointset a) {
 unsigned int p;
 for (p = 0; p < a.no; p++) {
  apply_force((a.pts)+p);
 }
}

variable_types: struct pointset { unsigned int no; struct point { float *x; unsigned short connections; float b; } *pts; }

variable_types:
p
unsigned int

user_defined_types: struct pointset { unsigned int no; struct point *pts; }


original_code:
static unsigned int mk_fast_pts(temp_point *tree, point *pts, unsigned int i) {
 unsigned int j;
 if (tree->left != ((void *)0))
  i = mk_fast_pts(tree->left, pts, i);
 if (tree->right != ((void *)0))
  i = mk_fast_pts(tree->right, pts, i);
 point *p = pts+i;
 p->x = tree->position;
 p->v = Vmk();
 p->F = calloc(tree->no_springs, sizeof(vector*));
 for (j = 0; j < tree->no_springs; j++)
  (p->F)[j] = Vmk();
 p->connections = tree->no_springs;
 p->mass = tree->mass;
 p->b = tree->damping;
 tree->fast = p;
 i++;
 return i;
}

canonical_original_code:
static unsigned int mk_fast_pts(struct temp_point *tree, struct point *pts, unsigned int i) {
 unsigned int j;
 if (tree->left != ((void *)0))
  i = mk_fast_pts(tree->left, pts, i);
 if (tree->right != ((void *)0))
  i = mk_fast_pts(tree->right, pts, i);
 struct point *p = pts+i;
 p->x = tree->position;
 p->v = Vmk();
 p->F = calloc(tree->no_springs, sizeof(float **));
 for (j = 0; j < tree->no_springs; j++)
  (p->F)[j] = Vmk();
 p->connections = tree->no_springs;
 p->mass = tree->mass;
 p->b = tree->damping;
 tree->fast = p;
 i++;
 return i;
}

variable_types: struct temp_point { char *pt_id; float mass; float damping; float *position; unsigned int no_springs; struct point { float *x; unsigned short connections; float b; } *fast; struct temp_point *left; } *

variable_types:
pts
struct point *

variable_types:
i
unsigned int

user_defined_types: struct temp_point { char *pt_id; float mass; float damping; float *position; unsigned int no_springs; struct point *fast; struct temp_point *left; }


decompiled_code:
void __fastcall free_tempoint(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void free_tempoint(temp_point *a) {
 free(a->pt_id);
 free(a->position);
 free(a);
}

canonical_original_code:
void free_tempoint(struct temp_point *a) {
 free(a->pt_id);
 free(a->position);
 free(a);
}

user_defined_types: struct point { float *x; unsigned short connections; float b; }


decompiled_code:
__int64 __fastcall add_point(float **a1, char *a2, __int64 a3, __m128i a4, __m128i a5)
{
float v5; // er15
float v6; // er14
float *v8; // rbx
int v9; // eax
unsigned int v10; // er8
float *v11; // rax
float **v13; // r12

v5 = COERCE_FLOAT(_mm_cvtsi128_si32(a5));
v6 = COERCE_FLOAT(_mm_cvtsi128_si32(a4));
v8 = *a1;
if ( *a1 )
{
while ( 1 )
{
v9 = strcmp(*(const char **)v8, a2);
v10 = v9;
if ( !(_WORD)v9 )
break;
if ( (v9 & 0x8000u) == 0 )
{
v13 = (float **)(v8 + 12);
v8 = (float *)*((_QWORD *)v8 + 6);
if ( !v8 )
goto LABEL_7;
}
else
{
v13 = (float **)(v8 + 10);
v8 = (float *)*((_QWORD *)v8 + 5);
if ( !v8 )
goto LABEL_7;
}
}
}
else
{
v13 = a1;
LABEL_7:
v11 = mktPt(a2, a3, v6, v5);
v10 = 1;
*v13 = v11;
}
return v10;
}

original_code:
short add_point(temp_point **tree, char *id, float mass, float damping, vector pos) {
 temp_point *p = *tree;
 while (p != ((void *)0)) {
  short c = strcmp(p->pt_id, id);
  if (c == 0)
   return 0;
  if (c < 0)
   tree = &(p->left);
  else
   tree = &(p->right);
  p = *tree;
 }
 *tree = mktPt(id, mass, damping, pos);
 return 1;
}

canonical_original_code:
short add_point(struct temp_point **tree, char *id, float mass, float damping, float *pos) {
 struct temp_point *p = *tree;
 while (p != ((void *)0)) {
  short c = strcmp(p->pt_id, id);
  if (c == 0)
   return 0;
  if (c < 0)
   tree = &(p->left);
  else
   tree = &(p->right);
  p = *tree;
 }
 *tree = mktPt(id, mass, damping, pos);
 return 1;
}

variable_types: struct temp_point { char *pt_id; float mass; float damping; float *position; unsigned int no_springs; struct point { float *x; unsigned short connections; float b; } *fast; struct temp_point *left; } **

variable_types:
id
char *

variable_types: mass float

variable_types: damping float

variable_types:
pos
float *

variable_types: c short


treemunch

decompiled_code:
void __fastcall treemunch(_QWORD *a1)
{
if ( a1 )
{
if ( a1[5] )
treemunch();
if ( a1[6] )
treemunch();
free(a1);
}
}

canonical_decompiled_code:
void __fastcall func4(_QWORD *a1)
{
if ( a1 )
{
if ( a1[5] )
func4();
if ( a1[6] )
func4();
free(a1);
}
}

original_code:
void treemunch(temp_point *tree) {
 if (tree == ((void *)0))
  free(tree);
 else {
  if (tree->left != ((void *)0))
   treemunch(tree->left);
  if (tree->right != ((void *)0))
   treemunch(tree->right);
  free(tree);
 }
}

canonical_original_code:
void treemunch(struct temp_point *tree) {
 if (tree == ((void *)0))
  free(tree);
 else {
  if (tree->left != ((void *)0))
   treemunch(tree->left);
  if (tree->right != ((void *)0))
   treemunch(tree->right);
  free(tree);
 }
}


decompiled_code:
__int64 __fastcall find_pt(__int64 a1, const char *a2)
{
__int64 v2; // rbx
__int64 v3; // rax
int v4; // eax
bool v5; // sf

if ( !a1 )
return 0LL;
v2 = a1;
do
{
v4 = strcmp(*(const char **)v2, a2);
v5 = v4 < 0;
if ( !v4 )
return v2;
v3 = *(_QWORD *)(v2 + 40);
if ( !v5 )
v3 = *(_QWORD *)(v2 + 48);
v2 = v3;
}
while ( v3 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char *a2)
{
__int64 v2; // rbx
__int64 v3; // rax
int v4; // eax
bool v5; // sf

if ( !a1 )
return 0LL;
v2 = a1;
do
{
v4 = strcmp(*(const char **)v2, a2);
v5 = v4 < 0;
if ( !v4 )
return v2;
v3 = *(_QWORD *)(v2 + 40);
if ( !v5 )
v3 = *(_QWORD *)(v2 + 48);
v2 = v3;
}
while ( v3 );
return 0LL;
}

original_code:
temp_point *find_pt(temp_point *tree, char *id) {
 int i;
 while (tree != ((void *)0)) {
  i = strcmp(tree->pt_id, id);
  if (i == 0)
   return tree;
  if (i < 0)
   tree = tree->left;
  else
   tree = tree->right;
 }
 return ((void *)0);
}

canonical_original_code:
struct temp_point *find_pt(struct temp_point *tree, char *id) {
 int i;
 while (tree != ((void *)0)) {
  i = strcmp(tree->pt_id, id);
  if (i == 0)
   return tree;
  if (i < 0)
   tree = tree->left;
  else
   tree = tree->right;
 }
 return ((void *)0);
}

variable_types:
tree
struct temp_point *

variable_types: i int

return_type: struct temp_point { char *pt_id; float mass; float damping; float *position; unsigned int no_springs; struct point { float *x; unsigned short connections; float b; } *fast; struct temp_point *left; } *


decompiled_code:
__int64 __fastcall tree_items(__int64 a1)
{
unsigned int v1; // er12
__int64 v2; // rbx
int v3; // eax

v1 = 0;
if ( a1 )
{
v2 = a1;
do
{
v3 = tree_items(*(_QWORD *)(v2 + 40));
v2 = *(_QWORD *)(v2 + 48);
v1 += v3 + 1;
}
while ( v2 );
}
return v1;
}

original_code:
unsigned int tree_items(temp_point *tree) {
 unsigned int counter = 1;
 if (tree == ((void *)0))
  return 0;
 counter += tree_items(tree->left);
 counter += tree_items(tree->right);
 return counter;
}

canonical_original_code:
unsigned int tree_items(struct temp_point *tree) {
 unsigned int counter = 1;
 if (tree == ((void *)0))
  return 0;
 counter += tree_items(tree->left);
 counter += tree_items(tree->right);
 return counter;
}

variable_types:
counter
unsigned int


listlen

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

for ( result = 0LL; a1; result = (unsigned int)(result + 1) )
a1 = *(_QWORD *)(a1 + 40);
return result;
}

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

for ( result = 0LL; a1; result = (unsigned int)(result + 1) )
a1 = *(_QWORD *)(a1 + 40);
return result;
}

original_code:
unsigned int listlen(temp_spring *springlist) {
 unsigned int counter = 0;
 while (springlist != ((void *)0)) {
  counter++;
  springlist = springlist->next;
 }
 return counter;
}

canonical_original_code:
unsigned int listlen(struct temp_spring *springlist) {
 unsigned int counter = 0;
 while (springlist != ((void *)0)) {
  counter++;
  springlist = springlist->next;
 }
 return counter;
}

variable_types: struct temp_spring { struct temp_point { char *pt_id; float mass; float damping; float *position; unsigned int no_springs; struct point { float *x; unsigned short connections; float b; } *fast; struct temp_point *left; } *a; unsigned int connection_no_a; struct temp_point *b; unsigned int connection_no_b; float restlength; float k; struct temp_spring *next; } *

user_defined_types: struct temp_spring { struct temp_point *a; unsigned int connection_no_a; struct temp_point *b; unsigned int connection_no_b; float restlength; float k; struct temp_spring *next; }


process

decompiled_code:
__int64 __fastcall process(unsigned int a1)
{
n_mevents = 0;
pm_called = 0;
mb_1 = midi_buffer;
do
{
jack_port_get_buffer();
if ( (unsigned int)jack_midi_event_get() )
break;
++*(_DWORD *)mb_1;
mb_1 = midi_buffer + 24LL * (unsigned __int16)n_0;
++n_mevents;
}
while ( n_mevents != 4 );
n_0 = 0;
if ( !n_outputs )
return 0LL;
while ( jack_ringbuffer_read_space() >= 4 * (unsigned __int64)a1 )
{
jack_port_get_buffer();
jack_ringbuffer_read();
if ( (unsigned __int16)++n_0 >= (unsigned __int16)n_outputs )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
n_mevents = 0;
pm_called = 0;
mb_1 = midi_buffer;
do
{
jack_port_get_buffer();
if ( (unsigned int)jack_midi_event_get() )
break;
++*(_DWORD *)mb_1;
mb_1 = midi_buffer + 24LL * (unsigned __int16)n_0;
++n_mevents;
}
while ( n_mevents != 4 );
n_0 = 0;
if ( !n_outputs )
return 0LL;
while ( jack_ringbuffer_read_space() >= 4 * (unsigned __int64)a1 )
{
jack_port_get_buffer();
jack_ringbuffer_read();
if ( (unsigned __int16)++n_0 >= (unsigned __int16)n_outputs )
return 0LL;
}
return 1LL;
}

original_code:
static int process(jack_nframes_t nframes, void *voidptr) {
 static unsigned short n;
 static jack_midi_event_t *mb;
 pm_called = 0;
 n_mevents = 0;
 mb = midi_buffer;
 while (jack_midi_event_get(mb, jack_port_get_buffer(midi_port, nframes), n_mevents) == 0) {
  mb->time++;
  mb = &(midi_buffer[n]);
  n_mevents++;
  if (n_mevents == 4)
   break;
 }
 for (n = 0; n < n_outputs; n++) {
  if (jack_ringbuffer_read_space(output_buffers[n]) < nframes*sizeof(float))
   return 1;
  jack_ringbuffer_read(output_buffers[n], jack_port_get_buffer(output_ports[n], nframes), nframes*sizeof(float));
 }
 return 0;
}

canonical_original_code:
static int process(unsigned int nframes, void *voidptr) {
 static unsigned short n;
 static struct _jack_midi_event *mb;
 pm_called = 0;
 n_mevents = 0;
 mb = midi_buffer;
 while (jack_midi_event_get(mb, jack_port_get_buffer(midi_port, nframes), n_mevents) == 0) {
  mb->time++;
  mb = &(midi_buffer[n]);
  n_mevents++;
  if (n_mevents == 4)
   break;
 }
 for (n = 0; n < n_outputs; n++) {
  if (jack_ringbuffer_read_space(output_buffers[n]) < nframes*sizeof(float))
   return 1;
  jack_ringbuffer_read(output_buffers[n], jack_port_get_buffer(output_ports[n], nframes), nframes*sizeof(float));
 }
 return 0;
}

variable_types:
nframes
unsigned int

variable_types:
voidptr
void *

variable_types:
n
unsigned short

variable_types: struct _jack_midi_event { unsigned int time; unsigned long size; unsigned char *buffer; } *


decompiled_code:
__int64 __fastcall set_buffersize(int a1)
{
__int16 v1; // r14
int v2; // ebx
unsigned __int16 v3; // r12
__int64 v4; // r15

v1 = n_outputs;
framesize = a1;
if ( output_buffers )
{
v2 = 0;
if ( !n_outputs )
goto LABEL_9;
do
{
++v2;
jack_ringbuffer_free();
v1 = n_outputs;
}
while ( (unsigned __int16)n_outputs > (unsigned __int16)v2 );
}
else
{
output_buffers = (__int64)calloc((unsigned __int16)n_outputs, 8uLL);
}
v3 = 0;
if ( v1 )
{
do
{
v4 = output_buffers;
*(_QWORD *)(8LL * v3 + v4) = jack_ringbuffer_create();
jack_ringbuffer_mlock();
while ( (unsigned __int64)jack_ringbuffer_write_space() > 3 )
jack_ringbuffer_write();
++v3;
}
while ( (unsigned __int16)n_outputs > v3 );
}
LABEL_9:
midi_buffer = (__int64)calloc(4uLL, 0x18uLL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
__int16 v1; // r14
int v2; // ebx
unsigned __int16 v3; // r12
__int64 v4; // r15

v1 = n_outputs;
framesize = a1;
if ( output_buffers )
{
v2 = 0;
if ( !n_outputs )
goto LABEL_9;
do
{
++v2;
jack_ringbuffer_free();
v1 = n_outputs;
}
while ( (unsigned __int16)n_outputs > (unsigned __int16)v2 );
}
else
{
output_buffers = (__int64)calloc((unsigned __int16)n_outputs, 8uLL);
}
v3 = 0;
if ( v1 )
{
do
{
v4 = output_buffers;
*(_QWORD *)(8LL * v3 + v4) = jack_ringbuffer_create();
jack_ringbuffer_mlock();
while ( (unsigned __int64)jack_ringbuffer_write_space() > 3 )
jack_ringbuffer_write();
++v3;
}
while ( (unsigned __int16)n_outputs > v3 );
}
LABEL_9:
midi_buffer = (__int64)calloc(4uLL, 0x18uLL);
return 0LL;
}

original_code:
static int set_buffersize(jack_nframes_t nframes, void *voidptr) {
 unsigned short n;
 float zf = 0.0;
 framesize = nframes;
 if (output_buffers == ((void *)0))
  output_buffers = calloc(n_outputs, sizeof(jack_ringbuffer_t*));
 else {
  for (n = 0; n < n_outputs; n++)
   jack_ringbuffer_free(output_buffers[n]);
 }
 for (n = 0; n < n_outputs; n++) {
  output_buffers[n] = jack_ringbuffer_create(nframes*sizeof(float)*2);
  jack_ringbuffer_mlock(output_buffers[n]);
  while (jack_ringbuffer_write_space(output_buffers[n]) >= sizeof(float))
   jack_ringbuffer_write(output_buffers[n], (char*) &zf, sizeof(float));
 }
 midi_buffer = calloc(4, sizeof(jack_midi_event_t));
 return 0;
}

canonical_original_code:
static int set_buffersize(unsigned int nframes, void *voidptr) {
 unsigned short n;
 float zf = 0.0;
 framesize = nframes;
 if (output_buffers == ((void *)0))
  output_buffers = calloc(n_outputs, sizeof(struct jack_ringbuffer_t *));
 else {
  for (n = 0; n < n_outputs; n++)
   jack_ringbuffer_free(output_buffers[n]);
 }
 for (n = 0; n < n_outputs; n++) {
  output_buffers[n] = jack_ringbuffer_create(nframes*sizeof(float)*2);
  jack_ringbuffer_mlock(output_buffers[n]);
  while (jack_ringbuffer_write_space(output_buffers[n]) >= sizeof(float))
   jack_ringbuffer_write(output_buffers[n], (char *) &zf, sizeof(float));
 }
 midi_buffer = calloc(4, sizeof(jack_midi_event_t));
 return 0;
}

variable_types: zf float

user_defined_types: struct jack_ringbuffer_t { char *buf; unsigned long write_ptr; unsigned long read_ptr; unsigned long size; unsigned long size_mask; int mlocked; }


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

result = jack_port_register();
midi_handler = a1;
midi_port = result;
return result;
}

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

result = jack_port_register();
midi_handler = a1;
midi_port = result;
return result;
}

original_code:
void create_midi_in(short (*mh)(unsigned char*, size_t)) {
 midi_port = jack_port_register(client, "in", "8 bit raw midi", JackPortIsInput, 0);
 midi_handler = mh;
}

canonical_original_code:
void create_midi_in(short (*mh)(unsigned char *, unsigned long)) {
 midi_port = jack_port_register(client, "in", "8 bit raw midi", JackPortIsInput, 0);
 midi_handler = mh;
}

variable_types: short (*)(unsigned char *, unsigned long)


decompiled_code:
__int64 push_audio()
{
if ( !output_buffers )
return 1LL;
while ( jack_ringbuffer_write_space() < 4 * (unsigned __int64)framesize - 1 )
usleep(0x1F4u);
jack_ringbuffer_write();
return 0LL;
}

canonical_decompiled_code:
__int64 func11()
{
if ( !output_buffers )
return 1LL;
while ( jack_ringbuffer_write_space() < 4 * (unsigned __int64)framesize - 1 )
usleep(0x1F4u);
jack_ringbuffer_write();
return 0LL;
}

original_code:
short push_audio(const float const *sample, const unsigned short out_id) {
 const char *sc = (const char *) sample;
 if (output_buffers == ((void *)0))
  return 1;
 while (jack_ringbuffer_write_space(output_buffers[out_id]) < (framesize*sizeof(float))-1) {
  usleep(500);
 }
 jack_ringbuffer_write(output_buffers[out_id], sc, sizeof(float));
 return 0;
}

canonical_original_code:
short push_audio(float *sample, unsigned short out_id) {
 char *sc = (const char *) sample;
 if (output_buffers == ((void *)0))
  return 1;
 while (jack_ringbuffer_write_space(output_buffers[out_id]) < (framesize*sizeof(float))-1) {
  usleep(500);
 }
 jack_ringbuffer_write(output_buffers[out_id], sc, sizeof(float));
 return 0;
}

variable_types:
sample
float *

variable_types:
sc
char *


decompiled_code:
__int64 pull_midi()
{
__int16 v0; // ax
__int64 v1; // rdx
int v2; // eax
__int64 result; // rax

++pm_called;
n_4 = 0;
if ( !n_mevents )
return 0LL;
v0 = 0;
while ( 1 )
{
v1 = midi_buffer + 24LL * v0;
if ( *(_DWORD *)v1 )
{
v2 = *(_DWORD *)v1 - 1;
*(_DWORD *)v1 = v2;
if ( !v2 )
{
result = midi_handler(*(_QWORD *)(v1 + 16), *(_QWORD *)(v1 + 8));
if ( (_WORD)result )
break;
}
}
v0 = ++n_4;
if ( n_4 >= (int)(unsigned __int16)n_mevents )
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func12()
{
__int16 v0; // ax
__int64 v1; // rdx
int v2; // eax
__int64 result; // rax

++pm_called;
n_4 = 0;
if ( !n_mevents )
return 0LL;
v0 = 0;
while ( 1 )
{
v1 = midi_buffer + 24LL * v0;
if ( *(_DWORD *)v1 )
{
v2 = *(_DWORD *)v1 - 1;
*(_DWORD *)v1 = v2;
if ( !v2 )
{
result = midi_handler(*(_QWORD *)(v1 + 16), *(_QWORD *)(v1 + 8));
if ( (_WORD)result )
break;
}
}
v0 = ++n_4;
if ( n_4 >= (int)(unsigned __int16)n_mevents )
return 0LL;
}
return result;
}

original_code:
short pull_midi(void) {
 static short rcode, n;
 static jack_midi_event_t *mb;
 pm_called++;
 for (n=0; n<n_mevents; n++) {
  mb = &(midi_buffer[n]);
  if (mb->time) {
   mb->time--;
   if (!mb->time) {
    rcode = midi_handler((unsigned char*) mb->buffer, mb->size);
    if (rcode)
     return rcode;
   }
  }
 }
 return 0;
}

canonical_original_code:
short pull_midi() {
 static short rcode; static short n;
 static struct _jack_midi_event *mb;
 pm_called++;
 for (n=0; n<n_mevents; n++) {
  mb = &(midi_buffer[n]);
  if (mb->time) {
   mb->time--;
   if (!mb->time) {
    rcode = midi_handler((unsigned char *) mb->buffer, mb->size);
    if (rcode)
     return rcode;
   }
  }
 }
 return 0;
}

variable_types: rcode short

variable_types: n short

user_defined_types: struct _jack_midi_event { unsigned int time; unsigned long size; unsigned char *buffer; }


pull

decompiled_code:
_BOOL8 pull()
{
_BOOL8 result; // rax

if ( midi_port )
result = (unsigned __int16)pull_midi() != 0;
else
result = 1LL;
return result;
}

canonical_decompiled_code:
_BOOL8 func13()
{
_BOOL8 result; // rax

if ( midi_port )
result = (unsigned __int16)func12() != 0;
else
result = 1LL;
return result;
}

original_code:
short pull(void) {
 if (midi_port != ((void *)0))
  if (pull_midi() == 0)
   return 0;
 return 1;
}

canonical_original_code:
short pull() {
 if (midi_port != ((void *)0))
  if (pull_midi() == 0)
   return 0;
 return 1;
}


go

decompiled_code:
__int64 go()
{
int v0; // eax

v0 = jack_get_buffer_size();
set_buffersize(v0);
jack_set_buffer_size_callback();
jack_set_process_callback();
return jack_activate();
}

canonical_decompiled_code:
__int64 func14()
{
int v0; // eax

v0 = jack_get_buffer_size();
func7(v0);
jack_set_buffer_size_callback();
jack_set_process_callback();
return jack_activate();
}

original_code:
void go(void) {
 set_buffersize(jack_get_buffer_size(client), ((void *)0));
 jack_set_buffer_size_callback(client, set_buffersize, ((void *)0));
 jack_set_process_callback(client, process, ((void *)0));
 jack_activate(client);
}

canonical_original_code:
void go() {
 set_buffersize(jack_get_buffer_size(client), ((void *)0));
 jack_set_buffer_size_callback(client, set_buffersize, ((void *)0));
 jack_set_process_callback(client, process, ((void *)0));
 jack_activate(client);
}


init

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

client = jack_client_open();
if ( client )
result = jack_get_sample_rate();
else
result = 0LL;
return result;
}

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

client = jack_client_open();
if ( client )
result = jack_get_sample_rate();
else
result = 0LL;
return result;
}

original_code:
unsigned int init(const char const *name) {
 client = jack_client_open(name, JackNoStartServer, ((void *)0));
 if (client == ((void *)0))
  return 0;
 return (unsigned int) jack_get_sample_rate(client);
}

canonical_original_code:
unsigned int init(char *name) {
 client = jack_client_open(name, JackNoStartServer, ((void *)0));
 if (client == ((void *)0))
  return 0;
 return (unsigned int) jack_get_sample_rate(client);
}

variable_types:
name
char *


decompiled_code:
__int64 do_action()
{
Vadd();
return 1LL;
}

canonical_decompiled_code:
__int64 func6()
{
Vadd();
return 1LL;
}

original_code:
unsigned short do_action(void *data) {
 move_data *md = (move_data*) data;
 Vadd(md->x, md->x, md->loc);
 return 1;
}

canonical_original_code:
unsigned short do_action(void *data) {
 struct move_data *md = (move_data*) data;
 Vadd(md->x, md->x, md->loc);
 return 1;
}

variable_types:
data
void *

variable_types:
md
struct move_data { float *x; } *

return_type: unsigned short


decompiled_code:
void __fastcall action_free_data(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func7(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void action_free_data(void *data) {
 move_data *md = (move_data*) data;
 free(md->loc);
 free(md);
}

canonical_original_code:
void action_free_data(void *data) {
 struct move_data *md = (move_data*) data;
 free(md->loc);
 free(md);
}


decompiled_code:
__int64 __fastcall on_midi(_BYTE *a1, __int64 a2, _QWORD *a3)
{
_QWORD *v5; // r12

if ( (*a1 & 0xF0) == 0x90 )
{
v5 = malloc(0x10uLL);
*v5 = *a3;
v5[1] = Vmk();
Vtimes_scalar();
add_action();
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(_BYTE *a1, __int64 a2, _QWORD *a3)
{
_QWORD *v5; // r12

if ( (*a1 & 0xF0) == 0x90 )
{
v5 = malloc(0x10uLL);
*v5 = *a3;
v5[1] = Vmk();
Vtimes_scalar();
add_action();
}
return 0LL;
}

original_code:
short on_midi(unsigned char* buffer, size_t size, void *data) {
 move_data *d, *md;
 unsigned short velocity;
 if ((0xF0 & buffer[0]) == 0x90) {
  velocity = buffer[2];
  md = malloc(sizeof(move_data));
  d = (move_data*) data;
  md->x = d->x;
  md->loc = Vmk();
  Vtimes_scalar(md->loc, d->loc, (velocity + 1)/128.0);
  add_action(ACT_START, &do_action, (void*) md, action_free_data);
 }
 return 0;
}

canonical_original_code:
short on_midi(unsigned char *buffer, unsigned long size, void *data) {
 struct move_data *d; struct move_data *md;
 unsigned short velocity;
 if ((0xF0 & buffer[0]) == 0x90) {
  velocity = buffer[2];
  md = malloc(sizeof(move_data));
  d = (struct move_data *) data;
  md->x = d->x;
  md->loc = Vmk();
  Vtimes_scalar(md->loc, d->loc, (velocity + 1)/128.0);
  add_action(ACT_START, &do_action, (void *) md, action_free_data);
 }
 return 0;
}

variable_types:
buffer
unsigned char *

variable_types:
size
unsigned long

variable_types:
d
struct move_data { float *x; } *

variable_types:
velocity
unsigned short


decompiled_code:
__int64 setup_action()
{
void *v0; // rbp
__int64 v1; // r12
__int64 v2; // rbx
_QWORD *v3; // rsi
__int64 v4; // rax

v0 = (void *)get_word();
v1 = find_pt();
free(v0);
v2 = read_vector();
v3 = malloc(0x10uLL);
v4 = **(_QWORD **)(v1 + 32);
v3[1] = v2;
*v3 = v4;
register_midi_handler();
return 0LL;
}

canonical_decompiled_code:
__int64 func9()
{
void *v0; // rbp
__int64 v1; // r12
__int64 v2; // rbx
_QWORD *v3; // rsi
__int64 v4; // rax

v0 = (void *)get_word();
v1 = find_pt();
free(v0);
v2 = read_vector();
v3 = malloc(0x10uLL);
v4 = **(_QWORD **)(v1 + 32);
v3[1] = v2;
*v3 = v4;
register_midi_handler();
return 0LL;
}

original_code:
short setup_action(line_list *ll, temp_point *tree) {
 unsigned int i = 0;
 vector pos;
 move_data *md;
 char *w = get_word(ll->str, &i);
 tree = find_pt(tree, w);
 free(w);
 pos = read_vector(ll->str, &i);
 md = malloc(sizeof(move_data));
 md->x = tree->fast->x;
 md->loc = pos;
 register_midi_handler(&on_midi, (void*) md);
 return 0;
}

canonical_original_code:
short setup_action(struct line_list *ll, struct temp_point *tree) {
 unsigned int i = 0;
 float *pos;
 struct move_data *md;
 char *w = get_word(ll->str, &i);
 tree = find_pt(tree, w);
 free(w);
 pos = read_vector(ll->str, &i);
 md = malloc(sizeof(move_data));
 md->x = tree->fast->x;
 md->loc = pos;
 register_midi_handler(&on_midi, (void *) md);
 return 0;
}

variable_types: struct line_list { char *str; unsigned int lineno; struct line_list *next; } *

variable_types: struct temp_point { char *pt_id; float mass; float damping; float *position; unsigned int no_springs; struct point { float *x; unsigned short connections; float b; } *fast; struct temp_point *left; } *

variable_types:
i
unsigned int

variable_types:
pos
float *

variable_types:
w
char *


argparse

decompiled_code:
__int64 __fastcall argparse(int argc, char **argv, _QWORD *a3)
{
int v4; // eax
__int64 result; // rax
int longind[7]; // [rsp+Ch] [rbp-1Ch] BYREF

*a3 = 0LL;
longind[0] = 0;
a3[1] = "jack";
while ( 1 )
{
v4 = getopt_long(argc, argv, "ho:", &long_options_0, longind);
if ( v4 == -1 )
break;
if ( v4 == 104 )
{
puts("usage is: physyn [-o output_device] filepath\n");
}
else if ( v4 == 111 )
{
a3[1] = optarg;
}
else
{
if ( v4 )
return 1LL;
if ( !*((_QWORD *)&long_options_0.flag + 4 * longind[0]) )
{
printf("option %s", *(&long_options_0.name + 4 * longind[0]));
if ( optarg )
printf(" with arg %s", optarg);
putchar(10);
}
}
}
if ( argc - optind == 1 )
{
*a3 = argv[optind];
result = 0LL;
}
else
{
puts("no file (or too many files) specified, error!");
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int argc, char **argv, _QWORD *a3)
{
int v4; // eax
__int64 result; // rax
int longind[7]; // [rsp+Ch] [rbp-1Ch] BYREF

*a3 = 0LL;
longind[0] = 0;
a3[1] = "jack";
while ( 1 )
{
v4 = getopt_long(argc, argv, "ho:", &long_options_0, longind);
if ( v4 == -1 )
break;
if ( v4 == 104 )
{
puts("usage is: physyn [-o output_device] filepath\n");
}
else if ( v4 == 111 )
{
a3[1] = optarg;
}
else
{
if ( v4 )
return 1LL;
if ( !*((_QWORD *)&long_options_0.flag + 4 * longind[0]) )
{
printf("option %s", *(&long_options_0.name + 4 * longind[0]));
if ( optarg )
printf(" with arg %s", optarg);
putchar(10);
}
}
}
if ( argc - optind == 1 )
{
*a3 = argv[optind];
result = 0LL;
}
else
{
puts("no file (or too many files) specified, error!");
result = 1LL;
}
return result;
}

original_code:
int argparse(int argc, char **argv, args_t *args) {
 static struct option long_options[] = {
  {"help", 0, 0, 'h'},
  {"output", 1, 0, 'o'}
 };
 int c;
 int option_index = 0;
 args->fpath = ((void *)0);
 args->io_module = "jack";
 while (1) {
  c = getopt_long(argc, argv, "ho:", long_options, &option_index);
  if (c == -1)
   break;
  switch (c) {
   case 0:
    if (long_options[option_index].flag != 0)
     break;
    printf("option %s", long_options[option_index].name);
    if (optarg)
     printf (" with arg %s", optarg);
    printf("\n");
    break;
   case 'h':
    puts(usage);
    break;
   case 'o':
    args->io_module = optarg;
    break;
   case '?':
    return 1;
   default:
    return 1;
  }
 }
 if (argc - optind == 1) {
  args->fpath = argv[optind];
 } else {
  puts("no file (or too many files) specified, error!");
  return 1;
 }
 return 0;
}

canonical_original_code:
int argparse(int argc, char **argv, struct args_t *args) {
 static struct option long_options[] = {
  {"help", 0, 0, 'h'},
  {"output", 1, 0, 'o'}
 };
 int c;
 int option_index = 0;
 args->fpath = ((void *)0);
 args->io_module = "jack";
 while (1) {
  c = getopt_long(argc, argv, "ho:", long_options, &option_index);
  if (c == -1)
   break;
  switch (c) {
   case 0:
    if (long_options[option_index].flag != 0)
     break;
    printf("option %s", long_options[option_index].name);
    if (optarg)
     printf (" with arg %s", optarg);
    printf("\n");
    break;
   case 'h':
    puts(usage);
    break;
   case 'o':
    args->io_module = optarg;
    break;
   case '?':
    return 1;
   default:
    return 1;
  }
 }
 if (argc - optind == 1) {
  args->fpath = argv[optind];
 } else {
  puts("no file (or too many files) specified, error!");
  return 1;
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct args_t { char *fpath; char *io_module; } *

variable_types: struct option { char *name; int has_arg; int *flag; int val; } []

variable_types: c int


decompiled_code:
__int64 get_output()
{
int v0; // ebx
__int64 v1; // rbp
__int64 result; // rax
float v3[7]; // [rsp+0h] [rbp-1Ch] BYREF

if ( no_devices )
{
v0 = 0;
do
{
v1 = (unsigned __int16)v0++;
v3[0] = (**((float (__fastcall ***)(_QWORD))capdevs + v1))(*(_QWORD *)(*((_QWORD *)capdevs + v1) + 16LL));
result = push_audio(v3, *(unsigned __int16 *)(*((_QWORD *)capdevs + v1) + 8LL));
}
while ( (unsigned __int16)no_devices > (unsigned __int16)v0 );
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // ebx
__int64 v1; // rbp
__int64 result; // rax
float v3[7]; // [rsp+0h] [rbp-1Ch] BYREF

if ( no_devices )
{
v0 = 0;
do
{
v1 = (unsigned __int16)v0++;
v3[0] = (**((float (__fastcall ***)(_QWORD))capdevs + v1))(*(_QWORD *)(*((_QWORD *)capdevs + v1) + 16LL));
result = push_audio(v3, *(unsigned __int16 *)(*((_QWORD *)capdevs + v1) + 8LL));
}
while ( (unsigned __int16)no_devices > (unsigned __int16)v0 );
}
return result;
}

original_code:
void get_output(void) {
 unsigned short device_no;
 float output;
 for (device_no=0; device_no<no_devices; device_no++) {
  output = (capdevs[device_no]->get_output)((void*) capdevs[device_no]->data);
  (*push_audio)(&output, capdevs[device_no]->out_id);
 }
}

canonical_original_code:
void get_output() {
 unsigned short device_no;
 float output;
 for (device_no=0; device_no<no_devices; device_no++) {
  output = (capdevs[device_no]->get_output)((void *) capdevs[device_no]->data);
  (*push_audio)(&output, capdevs[device_no]->out_id);
 }
}

variable_types: output float


decompiled_code:
__int64 __fastcall init_capture(__int64 a1)
{
__int16 v2; // bx
char *v3; // rax
const char **v4; // rbp
char *v5; // r13
unsigned __int16 v6; // r12
__int64 (__fastcall *v7)(_QWORD, __int64); // r8
__int64 *v8; // rax
__int64 v9; // r13
void *v10; // rax
_QWORD **v11; // rbx
void *v12; // rax
_QWORD *v13; // rbx
void *v14; // r13
void *v15; // rax
const char *v16; // rdi
__int64 v17; // rbx
size_t v18; // rax
char *v19; // r13
void *v20; // rbp
char *v21; // rax
__int64 (__fastcall *v23)(_QWORD); // [rsp+8h] [rbp-40h]

v23 = (__int64 (__fastcall *)(_QWORD))io_func("create_audio_out");
push_audio = (__int64 (__fastcall *)(_QWORD, _QWORD))io_func("push_audio");
v2 = no_devices;
v3 = (char *)calloc((unsigned __int16)no_devices, 8uLL);
capdevs = v3;
if ( !v2 )
return 0LL;
v4 = (const char **)devices;
v5 = v3;
v6 = 0;
while ( 1 )
{
v15 = malloc(0x20uLL);
v16 = v4[1];
v17 = 8LL * v6;
*(_QWORD *)&v5[v17] = v15;
v18 = strlen(v16);
v19 = (char *)calloc(v18 + 12, 1uLL);
strcpy(v19, "capture/");
*(_DWORD *)stpcpy(v19 + 8, v4[1]) = 7303982;
v20 = dlopen(v19, 2);
if ( !v20 )
break;
++v6;
free(v19);
v7 = (__int64 (__fastcall *)(_QWORD, __int64))dlsym(v20, "init");
v8 = (__int64 *)((char *)capdevs + v17);
*(_QWORD *)(*(_QWORD *)((char *)capdevs + v17) + 16LL) = 0LL;
v9 = *v8;
*(_QWORD *)(v9 + 16) = v7(*(_QWORD *)devices, a1);
v10 = dlsym(v20, "get_out");
v11 = (_QWORD **)((char *)capdevs + v17);
**v11 = v10;
v12 = dlsym(v20, "free_data");
v13 = *v11;
v13[3] = v12;
*((_WORD *)v13 + 4) = v23(*((_QWORD *)devices + 2));
llfree(*(_QWORD *)devices);
v14 = devices;
free(*((void **)devices + 1));
free(*((void **)v14 + 2));
v4 = (const char **)*((_QWORD *)v14 + 3);
free(v14);
devices = v4;
if ( (unsigned __int16)no_devices <= v6 )
return 0LL;
v5 = (char *)capdevs;
}
v21 = dlerror();
printf("error in dlopen(%s)\n%s\n", v19, v21);
free(v19);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int16 v2; // bx
char *v3; // rax
const char **v4; // rbp
char *v5; // r13
unsigned __int16 v6; // r12
__int64 (__fastcall *v7)(_QWORD, __int64); // r8
__int64 *v8; // rax
__int64 v9; // r13
void *v10; // rax
_QWORD **v11; // rbx
void *v12; // rax
_QWORD *v13; // rbx
void *v14; // r13
void *v15; // rax
const char *v16; // rdi
__int64 v17; // rbx
size_t v18; // rax
char *v19; // r13
void *v20; // rbp
char *v21; // rax
__int64 (__fastcall *v23)(_QWORD); // [rsp+8h] [rbp-40h]

v23 = (__int64 (__fastcall *)(_QWORD))io_func("create_audio_out");
push_audio = (__int64 (__fastcall *)(_QWORD, _QWORD))io_func("push_audio");
v2 = no_devices;
v3 = (char *)calloc((unsigned __int16)no_devices, 8uLL);
capdevs = v3;
if ( !v2 )
return 0LL;
v4 = (const char **)devices;
v5 = v3;
v6 = 0;
while ( 1 )
{
v15 = malloc(0x20uLL);
v16 = v4[1];
v17 = 8LL * v6;
*(_QWORD *)&v5[v17] = v15;
v18 = strlen(v16);
v19 = (char *)calloc(v18 + 12, 1uLL);
strcpy(v19, "capture/");
*(_DWORD *)stpcpy(v19 + 8, v4[1]) = 7303982;
v20 = dlopen(v19, 2);
if ( !v20 )
break;
++v6;
free(v19);
v7 = (__int64 (__fastcall *)(_QWORD, __int64))dlsym(v20, "init");
v8 = (__int64 *)((char *)capdevs + v17);
*(_QWORD *)(*(_QWORD *)((char *)capdevs + v17) + 16LL) = 0LL;
v9 = *v8;
*(_QWORD *)(v9 + 16) = v7(*(_QWORD *)devices, a1);
v10 = dlsym(v20, "get_out");
v11 = (_QWORD **)((char *)capdevs + v17);
**v11 = v10;
v12 = dlsym(v20, "free_data");
v13 = *v11;
v13[3] = v12;
*((_WORD *)v13 + 4) = v23(*((_QWORD *)devices + 2));
llfree(*(_QWORD *)devices);
v14 = devices;
free(*((void **)devices + 1));
free(*((void **)v14 + 2));
v4 = (const char **)*((_QWORD *)v14 + 3);
free(v14);
devices = v4;
if ( (unsigned __int16)no_devices <= v6 )
return 0LL;
v5 = (char *)capdevs;
}
v21 = dlerror();
printf("error in dlopen(%s)\n%s\n", v19, v21);
free(v19);
return 1LL;
}

original_code:
short init_capture(temp_point *tree) {
 unsigned short i;
 char *str;
 void *libhandle;
 cdil *nxtdev;
 void *(*fptr)(line_list*, temp_point*);
 unsigned short (*create_audio_out)(char*) = io_func("create_audio_out");
 push_audio = io_func("push_audio");
 capdevs = calloc(no_devices, sizeof(capture_device*));
 for (i=0; i<no_devices; i++) {
  capdevs[i] = malloc(sizeof(capture_device));
  str = calloc(strlen(devices->device)+12, sizeof(char));
  strcpy(str, "capture/");
  strcat(str, devices->device);
  strcat(str, ".so");
  libhandle = dlopen(str, 0x00002);
  if (!libhandle) {
   printf("error in dlopen(%s)\n%s\n", str, dlerror());
   free(str);
   return 1;
  }
  free(str);
  fptr = dlsym(libhandle, "init");
  capdevs[i]->data = ((void *)0);
  capdevs[i]->data = (*fptr)(devices->ll, tree);
  capdevs[i]->get_output = dlsym(libhandle, "get_out");
  capdevs[i]->free_data = dlsym(libhandle, "free_data");
  capdevs[i]->out_id = (*create_audio_out)(devices->portname);
  llfree(devices->ll);
  free(devices->device);
  free(devices->portname);
  nxtdev = devices->next;
  free(devices);
  devices = nxtdev;
 }
 return 0;
}

canonical_original_code:
short init_capture(struct temp_point *tree) {
 unsigned short i;
 char *str;
 void *libhandle;
 struct cdil *nxtdev;
 void *(*fptr)(struct line_list *, struct temp_point *);
 unsigned short (*create_audio_out)(char *) = io_func("create_audio_out");
 push_audio = io_func("push_audio");
 capdevs = calloc(no_devices, sizeof(struct capture_device *));
 for (i=0; i<no_devices; i++) {
  capdevs[i] = malloc(sizeof(capture_device));
  str = calloc(strlen(devices->device)+12, sizeof(char));
  strcpy(str, "capture/");
  strcat(str, devices->device);
  strcat(str, ".so");
  libhandle = dlopen(str, 0x00002);
  if (!libhandle) {
   printf("error in dlopen(%s)\n%s\n", str, dlerror());
   free(str);
   return 1;
  }
  free(str);
  fptr = dlsym(libhandle, "init");
  capdevs[i]->data = ((void *)0);
  capdevs[i]->data = (*fptr)(devices->ll, tree);
  capdevs[i]->get_output = dlsym(libhandle, "get_out");
  capdevs[i]->free_data = dlsym(libhandle, "free_data");
  capdevs[i]->out_id = (*create_audio_out)(devices->portname);
  llfree(devices->ll);
  free(devices->device);
  free(devices->portname);
  nxtdev = devices->next;
  free(devices);
  devices = nxtdev;
 }
 return 0;
}

variable_types:
i
unsigned short

variable_types:
str
char *

variable_types:
libhandle
void *

variable_types: struct cdil { struct line_list { char *str; unsigned int lineno; struct line_list *next; } *ll; char *device; char *portname; struct cdil *next; } *

variable_types: void *(*)(struct line_list { char *str; unsigned int lineno; struct line_list *next; } *, struct temp_point { char *pt_id; float mass; float damping; float *position; unsigned int no_springs; struct point { float *x; unsigned short connections; float b; } *fast; struct temp_point *left; } *)

user_defined_types: struct cdil { struct line_list *ll; char *device; char *portname; struct cdil *next; }

user_defined_types: struct capture_device { float (*get_output)(void *); unsigned short out_id; void *data; void (*free_data)(void *); }


decompiled_code:
void free_capture()
{
_QWORD *v0; // rbp
int v1; // ebx
__int64 v2; // r12

v0 = capdevs;
if ( no_devices )
{
v1 = 0;
do
{
v2 = (unsigned __int16)v1++;
(*(void (__fastcall **)(_QWORD))(v0[v2] + 24LL))(*(_QWORD *)(v0[v2] + 16LL));
v0 = capdevs;
free(*((void **)capdevs + v2));
}
while ( (unsigned __int16)no_devices > (unsigned __int16)v1 );
}
free(v0);
}

canonical_decompiled_code:
void func2()
{
_QWORD *v0; // rbp
int v1; // ebx
__int64 v2; // r12

v0 = capdevs;
if ( no_devices )
{
v1 = 0;
do
{
v2 = (unsigned __int16)v1++;
(*(void (__fastcall **)(_QWORD))(v0[v2] + 24LL))(*(_QWORD *)(v0[v2] + 16LL));
v0 = capdevs;
free(*((void **)capdevs + v2));
}
while ( (unsigned __int16)no_devices > (unsigned __int16)v1 );
}
free(v0);
}

original_code:
void free_capture(void) {
 unsigned short device_no;
 for (device_no=0; device_no<no_devices; device_no++) {
  (capdevs[device_no]->free_data)((void*) capdevs[device_no]->data);
  free(capdevs[device_no]);
 }
 free(capdevs);
}

canonical_original_code:
void free_capture() {
 unsigned short device_no;
 for (device_no=0; device_no<no_devices; device_no++) {
  (capdevs[device_no]->free_data)((void *) capdevs[device_no]->data);
  free(capdevs[device_no]);
 }
 free(capdevs);
}


decompiled_code:
void __fastcall apply_springs(unsigned int a1, __int64 a2)
{
unsigned int v2; // er13
__int64 v4; // rax
unsigned int v5; // edi
void *v6; // r12

v2 = a1;
v4 = Vmk();
v5 = 0;
i_0 = 0;
v6 = (void *)v4;
if ( v2 )
{
do
{
apply_spring(a2 + 32LL * v5, v6);
v5 = i_0 + 1;
i_0 = v5;
}
while ( v5 < a1 );
}
free(v6);
}

canonical_decompiled_code:
void __fastcall func0(unsigned int a1, __int64 a2)
{
unsigned int v2; // er13
__int64 v4; // rax
unsigned int v5; // edi
void *v6; // r12

v2 = a1;
v4 = Vmk();
v5 = 0;
i_0 = 0;
v6 = (void *)v4;
if ( v2 )
{
do
{
apply_spring(a2 + 32LL * v5, v6);
v5 = i_0 + 1;
i_0 = v5;
}
while ( v5 < a1 );
}
free(v6);
}

original_code:
void apply_springs(springset s) {
 static unsigned int i;
 vector v = Vmk();
 for (i=0; i<(s.no); i++) {
  apply_spring((s.springs)+i, v);
 }
 free(v);
}

canonical_original_code:
void apply_springs(struct springset s) {
 static unsigned int i;
 float *v = Vmk();
 for (i=0; i<(s.no); i++) {
  apply_spring((s.springs)+i, v);
 }
 free(v);
}

variable_types: struct springset { unsigned int no; struct spring { struct point { float *x; unsigned short connections; float b; } *a; unsigned int a_no; float restlength; } *springs; }

variable_types:
v
float *

user_defined_types: struct springset { unsigned int no; struct spring *springs; }

user_defined_types: struct spring { struct point *a; unsigned int a_no; float restlength; }