LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: overfl0[P]iojack/iojack.cpp
// Function: signal_sigint(int)
void signal_sigint(int sig)
{
    printf("Caught Ctrl+C, exiting... Press a second time to force.\n");

    //(void) signal(SIGINT, SIG_DFL);
    struct sigaction sa;
    memset(&sa, 0, sizeof(struct sigaction));
    sa.sa_handler = SIG_DFL;
    sa.sa_flags = SA_RESTART;

    sigaction(SIGINT, &sa, NULL);

    tryDetachFromProcesses();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl %edi, -0x4(%rbp)
leaq 0xb9dd(%rip), %rdi      # 0xe082
movb $0x0, %al
callq 0x2040
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x20e0
movq $0x0, -0xa0(%rbp)
movl $0x10000000, -0x18(%rbp) # imm = 0x10000000
movl $0x2, %edi
leaq -0xa0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2210
callq 0x2700
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/iojack.cpp
// Function: tryDetachFromProcesses()
void tryDetachFromProcesses()
{
    wantToExit = 1;

    printf("Trying to detach...\n");
    foreach(processes, it)
    //for(map<pid_t, processInfo*>::iterator it = processes.begin(); it != processes.end(); it++)
    {
        processInfo *pi = it->second;
        printf("Trying send SIGSTOP to pid %d... ", pi->pid);

        // If we're in the middle of faking a system call, we can't detach from this pid
        if(pi->inSyscall && pi->fakingSyscall != -1)
        {
            printf("faking system call. Aborted.\n");
            continue;
        }

        pi->sigstopToDetach = 1;
        int retval = kill(pi->pid, SIGSTOP);
        if(retval)
        {
            printf("Error while sending SIGSTOP to %d\n", pi->pid);
            perror("Error");
        }
        printf("\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x1, 0x13aaa(%rip)     # 0x161bc
leaq 0xba2f(%rip), %rdi      # 0xe148
movb $0x0, %al
callq 0x2040
leaq 0x13a99(%rip), %rdi     # 0x161c0
callq 0x33d0
movq %rax, -0x8(%rbp)
leaq 0x13a89(%rip), %rdi     # 0x161c0
callq 0x3430
movq %rax, -0x10(%rbp)
leaq -0x8(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x3400
testb $0x1, %al
jne 0x2756
jmp 0x2805
leaq -0x8(%rbp), %rdi
callq 0x3460
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %esi
leaq 0xb9e9(%rip), %rdi      # 0xe15d
movb $0x0, %al
callq 0x2040
movq -0x18(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x279f
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
je 0x279f
leaq 0xb9e9(%rip), %rdi      # 0xe17f
movb $0x0, %al
callq 0x2040
jmp 0x27f1
movq -0x18(%rbp), %rax
movl $0x1, 0xc(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %edi
movl $0x13, %esi
callq 0x2250
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x27e3
movq -0x18(%rbp), %rax
movl (%rax), %esi
leaq 0xb8eb(%rip), %rdi      # 0xe0bb
movb $0x0, %al
callq 0x2040
leaq 0xb900(%rip), %rdi      # 0xe0de
callq 0x2140
leaq 0xcdda(%rip), %rdi      # 0xf5c4
movb $0x0, %al
callq 0x2040
leaq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x3480
movq %rax, -0x28(%rbp)
jmp 0x2730
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: overfl0[P]iojack/iojack.cpp
// Function: setSignalHandlers()
void setSignalHandlers()
{
    struct sigaction sa;
    memset(&sa, 0, sizeof(struct sigaction));

    sa.sa_handler = signal_sigint;
    sa.sa_flags = SA_RESTART;

    sigaction(SIGINT, &sa, NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x20e0
leaq -0x1a5(%rip), %rax      # 0x2690
movq %rax, -0x98(%rbp)
movl $0x10000000, -0x10(%rbp) # imm = 0x10000000
movl $0x2, %edi
leaq -0x98(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2210
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/iojack.cpp
// Function: tmpDump(processInfo*, user_regs_struct*)
void tmpDump(processInfo *pi, user_regs_struct *regs)
{
    unsigned long arr[2];
    arr[0] = pi->getValue(regs->rip - sizeof(long));
    arr[1] = pi->getValue(regs->rip);

    printf("%lX: ", regs->rip - sizeof(long));
    for(unsigned int i = 1; i <= sizeof(long) * 2; i++)
    {
        printf("\\x%02X", ((unsigned char *)arr)[i-1]);
        if(i % 2 == 0) printf(" ");
    }
    printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rsi
subq $0x8, %rsi
callq 0x9700
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rsi
callq 0x9700
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rsi
subq $0x8, %rsi
leaq 0xb69a(%rip), %rdi      # 0xe0e4
movb $0x0, %al
callq 0x2040
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpq $0x10, %rax
ja 0x2aa2
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movzbl -0x20(%rbp,%rax), %esi
leaq 0xb675(%rip), %rdi      # 0xe0ea
movb $0x0, %al
callq 0x2040
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2a95
leaq 0xcb23(%rip), %rdi      # 0xf5b1
movb $0x0, %al
callq 0x2040
jmp 0x2a97
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2a58
leaq 0xcb1b(%rip), %rdi      # 0xf5c4
movb $0x0, %al
callq 0x2040
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/./processes.h
// Function: processInfo::processInfo(int)
processInfo(pid_t newPid)
    {
        pid = newPid;
        inSyscall = 0;
        fakingSyscall = -1;

        sigstopToDetach = 0;
        sigstopToRestartSyscall = 0;
        sigstopNewChild = 0;

        /*stdin.insert(0);
        stdout.insert(1);
        stderr.insert(2);*/

        //orig_regs = 0;
        memset(&orig_regs, 0, sizeof(user_regs_struct));
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x18(%rbp)
addq $0xf0, %rdi
callq 0x3c40
movq -0x18(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0x3c40
movq -0x18(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x3c40
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, (%rdi)
movl $0x0, 0x4(%rdi)
movl $0xffffffff, 0x8(%rdi)  # imm = 0xFFFFFFFF
movl $0x0, 0xc(%rdi)
movl $0x0, 0x10(%rdi)
movl $0x0, 0x14(%rdi)
addq $0x18, %rdi
xorl %esi, %esi
movl $0xd8, %edx
callq 0x20e0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: overfl0[P]iojack/terminal.cpp
// Function: initStdin(termios&)
void initStdin(termios &settings)
{
    tcgetattr(0, &settings);
    termios newSettings = settings;

    newSettings.c_lflag &= (~ICANON);
    newSettings.c_lflag &= (~ECHO);
    //newSettings.c_lflag &= (~ISIG);

    newSettings.c_cc[VTIME] = 0;//1; // timeout (tenths of a second)
    newSettings.c_cc[VMIN] = 0;  // minimum number of characters

    // apply the new settings
    tcsetattr(0, TCSANOW, &newSettings);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
xorl %edi, %edi
callq 0x21c0
movq -0x8(%rbp), %rsi
leaq -0x44(%rbp), %rdi
movl $0x3c, %edx
callq 0x2130
movl -0x38(%rbp), %eax
andl $-0x3, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
andl $-0x9, %eax
movl %eax, -0x38(%rbp)
movb $0x0, -0x2e(%rbp)
movb $0x0, -0x2d(%rbp)
xorl %esi, %esi
leaq -0x44(%rbp), %rdx
movl %esi, %edi
callq 0x2220
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/buffer.cpp
// Function: buffer::lockedSize()
int buffer::lockedSize()
{
    lock();
    int retval = data.size();
    unlock();
    return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x18(%rbp)
callq 0x7ed0
movq -0x18(%rbp), %rdi
callq 0x8150
movq -0x18(%rbp), %rdi
movl %eax, -0xc(%rbp)
callq 0x7ef0
movl -0xc(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: overfl0[P]iojack/buffer.cpp
// Function: buffer::lockedGet()
unsigned char buffer::lockedGet()
{
    lock();
    unsigned char retval = get();
    unlock();
return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x18(%rbp)
callq 0x7ed0
movq -0x18(%rbp), %rdi
callq 0x8060
movq -0x18(%rbp), %rdi
movb %al, -0x9(%rbp)
callq 0x7ef0
movb -0x9(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::getValue(unsigned long)
unsigned long processInfo::getValue(unsigned long addr)
{
    unsigned long retval = ptrace(PTRACE_PEEKDATA, pid, addr, 0);
    if(retval == (unsigned long)-1 && errno != 0)
    {
        perror("ptrace read");
        printf("errno: %d\n", errno);
    }
    //throw "Exception!!!";
    return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rdx
movl $0x2, %edi
xorl %ecx, %ecx
movb $0x0, %al
callq 0x2150
movq %rax, -0x18(%rbp)
cmpq $-0x1, -0x18(%rbp)
jne 0x975e
callq 0x2030
cmpl $0x0, (%rax)
je 0x975e
leaq 0x5ddb(%rip), %rdi      # 0xf51f
callq 0x2140
callq 0x2030
movl (%rax), %esi
leaq 0x5d95(%rip), %rdi      # 0xf4ec
movb $0x0, %al
callq 0x2040
movq -0x18(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::writeLong(unsigned long, unsigned long)
long processInfo::writeLong(unsigned long addr, unsigned long value)
{
    long retval = ptrace(PTRACE_POKEDATA, pid, addr, value);
    if(retval == -1)
    {
        char tmp[100];
        sprintf(tmp, "ptrace write at addr 0x%lx", addr);
        perror(tmp);
    }
    else
        dprintf("Write OK!\n");
    return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movl $0x5, %edi
movb $0x0, %al
callq 0x2150
movq %rax, -0x20(%rbp)
cmpq $-0x1, -0x20(%rbp)
jne 0x97d3
leaq -0x90(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x5d39(%rip), %rsi      # 0xf4f7
movb $0x0, %al
callq 0x2060
leaq -0x90(%rbp), %rdi
callq 0x2140
jmp 0x97d5
jmp 0x97d5
movq -0x20(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::writeChar(unsigned long, unsigned char)
int processInfo::writeChar(unsigned long addr, unsigned char value)
{
    //TODO: Check retval + errno!
    unsigned long origVal = getValue(addr);
    unsigned char *p = (unsigned char *)&origVal;
    *p = value;
    writeLong(addr, origVal);

    return -1; // In case I forget about the TODO
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x30(%rbp)
movq -0x10(%rbp), %rsi
callq 0x9700
movq -0x30(%rbp), %rdi
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movb -0x11(%rbp), %cl
movq -0x28(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x9770
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::readMemcpy(void*, unsigned long, unsigned int)
void processInfo::readMemcpy(void *dest, unsigned long remoteAddr, unsigned int n)
{
    unsigned long *udest = (unsigned long *)dest;
    dprintf("readMemcpy(dest=%lx, remoteAddr=%lx, uint n=%u\n", (unsigned long)dest, remoteAddr, n);
    for(; n >= sizeof(unsigned long); n -= sizeof(unsigned long))
    {
        //dprintf("%u\n", n);
        unsigned long retval = ptrace(PTRACE_PEEKDATA, pid, remoteAddr, 0);
        if(retval == (unsigned long)-1 && errno != 0)
        {
            perror("readMemcpy - ptrace read");
            return;
        }

        *udest++ = retval;
        remoteAddr += sizeof(unsigned long);
    }

    if(n > 0)
    {
        unsigned long retval = ptrace(PTRACE_PEEKDATA, pid, remoteAddr, 0);
        if(retval == (unsigned long)-1 && errno != 0)
        {
            perror("readMemcpy - ptrace read2");
            return;
        }

        char *c = (char *)&retval;
        for(unsigned int i = 0; i < n; i++)
        {
            //dprintf("%d\n", i);
            ((char *)udest)[i] = c[i];
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
cmpq $0x8, %rax
jb 0x98ec
movq -0x50(%rbp), %rax
movl (%rax), %esi
movq -0x18(%rbp), %rdx
movl $0x2, %edi
xorl %ecx, %ecx
movb $0x0, %al
callq 0x2150
movq %rax, -0x30(%rbp)
cmpq $-0x1, -0x30(%rbp)
jne 0x98be
callq 0x2030
cmpl $0x0, (%rax)
je 0x98be
leaq 0x5c5e(%rip), %rdi      # 0xf512
callq 0x2140
jmp 0x9965
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x28(%rbp)
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
subq $0x8, %rax
movl %eax, -0x1c(%rbp)
jmp 0x9877
cmpl $0x0, -0x1c(%rbp)
jbe 0x9965
movq -0x50(%rbp), %rax
movl (%rax), %esi
movq -0x18(%rbp), %rdx
movl $0x2, %edi
xorl %ecx, %ecx
movb $0x0, %al
callq 0x2150
movq %rax, -0x38(%rbp)
cmpq $-0x1, -0x38(%rbp)
jne 0x992d
callq 0x2030
cmpl $0x0, (%rax)
je 0x992d
leaq 0x5c05(%rip), %rdi      # 0xf52b
callq 0x2140
jmp 0x9965
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x9963
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x28(%rbp), %rax
movl -0x44(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x993c
jmp 0x9965
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::writeMemcpy(unsigned long, void*, unsigned int)
void processInfo::writeMemcpy(unsigned long remoteAddr, void *src, unsigned int n)
{
    unsigned long *usrc = (unsigned long *)src;
    dprintf("writeMemcpy(remoteAddr=%lx, src=%lx, uint n=%u\n", remoteAddr, (unsigned long)src, n);

    for(; n >= sizeof(unsigned long); n -= sizeof(unsigned long))
    {
        long retval = ptrace(PTRACE_POKEDATA, pid, remoteAddr, *usrc);
        if(retval == -1)
        {
            perror("writeMemcpy - ptrace write 1");
            return;
        }

        usrc++;
        remoteAddr += sizeof(unsigned long);
    }

    if(n > 0)
    {
        // Read the whole ulong into memory
        unsigned long remoteData = ptrace(PTRACE_PEEKDATA, pid, remoteAddr, 0);
        if(remoteData == (unsigned long)-1 && errno != 0)
        {
            perror("writeMemcpy - ptrace read");
            return;
        }

        // Modify only the requested bits
        char *c = (char *)&remoteData;
        for(unsigned int i = 0; i < n; i++)
        {
            //dprintf("%d\n", i);
            c[i] = ((char *)usrc)[i];
        }

        // Write it back
        long retval = ptrace(PTRACE_POKEDATA, pid, remoteAddr, remoteData);
        if(retval == -1)
        {
            perror("writeMemcpy - ptrace write 2");
            return;
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
cmpq $0x8, %rax
jb 0x99fd
movq -0x58(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movl $0x5, %edi
movb $0x0, %al
callq 0x2150
movq %rax, -0x30(%rbp)
cmpq $-0x1, -0x30(%rbp)
jne 0x99d9
leaq 0x5b76(%rip), %rdi      # 0xf545
callq 0x2140
jmp 0x9aad
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x1c(%rbp), %eax
subq $0x8, %rax
movl %eax, -0x1c(%rbp)
jmp 0x9997
cmpl $0x0, -0x1c(%rbp)
jbe 0x9aad
movq -0x58(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rdx
movl $0x2, %edi
xorl %ecx, %ecx
movb $0x0, %al
callq 0x2150
movq %rax, -0x38(%rbp)
cmpq $-0x1, -0x38(%rbp)
jne 0x9a42
callq 0x2030
cmpl $0x0, (%rax)
je 0x9a42
leaq 0x5b27(%rip), %rdi      # 0xf562
callq 0x2140
jmp 0x9aad
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x9a78
movq -0x28(%rbp), %rax
movl -0x44(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x9a51
movq -0x58(%rbp), %rax
movl (%rax), %esi
movq -0x10(%rbp), %rdx
movq -0x38(%rbp), %rcx
movl $0x5, %edi
movb $0x0, %al
callq 0x2150
movq %rax, -0x50(%rbp)
cmpq $-0x1, -0x50(%rbp)
jne 0x9aab
leaq 0x5ad8(%rip), %rdi      # 0xf57c
callq 0x2140
jmp 0x9aad
jmp 0x9aad
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::readStrncpy(char*, unsigned long, unsigned int)
char *processInfo::readStrncpy(char *dest, unsigned long remoteAddr, unsigned int n)
{
    unsigned int i = 0;
    while(i < n)
    {
        //printf("Reading at %lx...\n", remoteAddr + i);
        unsigned long retval = ptrace(PTRACE_PEEKDATA, pid, remoteAddr + i, 0);
        if(retval == (unsigned long)-1 && errno != 0)
        {
            perror("readMemcpy - ptrace read");
            goto end; //FIXME: throw an exception or sumtin'
        }

        for(unsigned int j = 0; j < sizeof(unsigned long); j++, i++)
        {
            if(i >= n)
                goto end;

            *dest = ((char *)&retval)[j];
            if(*dest++ == '\0')
                goto end;
        }
    }

    end:
    for(;i < n; i++)
        *dest++ = '\0';

    return dest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x9b8e
movq -0x38(%rbp), %rax
movl (%rax), %esi
movq -0x18(%rbp), %rdx
movl -0x20(%rbp), %eax
addq %rax, %rdx
movl $0x2, %edi
xorl %ecx, %ecx
movb $0x0, %al
callq 0x2150
movq %rax, -0x28(%rbp)
cmpq $-0x1, -0x28(%rbp)
jne 0x9b33
callq 0x2030
cmpl $0x0, (%rax)
je 0x9b33
leaq 0x59e6(%rip), %rdi      # 0xf512
callq 0x2140
jmp 0x9b90
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpq $0x8, %rax
jae 0x9b89
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jb 0x9b4d
jmp 0x9b90
movl -0x2c(%rbp), %eax
movb -0x28(%rbp,%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x9b73
jmp 0x9b90
jmp 0x9b75
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x9b3a
jmp 0x9ae6
jmp 0x9b90
jmp 0x9b92
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x9bb7
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb $0x0, (%rax)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x9b92
movq -0x10(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::closeFileDescriptor(unsigned int)
void processInfo::closeFileDescriptor(unsigned int fd)
{
    if(isStdin(fd))
        stdin.erase(fd);

    if(isStdout(fd))
        stdout.erase(fd);

    if(isStderr(fd))
        stderr.erase(fd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movl -0xc(%rbp), %esi
callq 0xa0e0
testb $0x1, %al
jne 0x9bf5
jmp 0x9c0f
movq -0x20(%rbp), %rdi
addq $0xf0, %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq -0x10(%rbp), %rsi
callq 0xa140
movq -0x20(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa170
testb $0x1, %al
jne 0x9c21
jmp 0x9c3b
movq -0x20(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movl -0xc(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq -0x14(%rbp), %rsi
callq 0xa140
movq -0x20(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa1d0
testb $0x1, %al
jne 0x9c4d
jmp 0x9c67
movq -0x20(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
movl -0xc(%rbp), %eax
movl %eax, -0x18(%rbp)
leaq -0x18(%rbp), %rsi
callq 0xa140
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::duplicateFileDescriptor(unsigned int, unsigned int)
void processInfo::duplicateFileDescriptor(unsigned int oldfd, unsigned int newfd)
{
    //printf("[%d] Duplicating descriptor: %u -> %u\n", pid, oldfd, newfd);
    if(isStdin(oldfd))
        stdin.insert(newfd);

    if(isStdout(oldfd))
        stdout.insert(newfd);

    if(isStderr(oldfd))
        stderr.insert(newfd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x60(%rbp)
movl -0xc(%rbp), %esi
callq 0xa0e0
testb $0x1, %al
jne 0x9c98
jmp 0x9cb9
movq -0x60(%rbp), %rdi
addq $0xf0, %rdi
movl -0x10(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq -0x14(%rbp), %rsi
callq 0xa230
movq %rax, -0x28(%rbp)
movb %dl, -0x20(%rbp)
movq -0x60(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa170
testb $0x1, %al
jne 0x9ccb
jmp 0x9cec
movq -0x60(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movl -0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
leaq -0x2c(%rbp), %rsi
callq 0xa230
movq %rax, -0x40(%rbp)
movb %dl, -0x38(%rbp)
movq -0x60(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xa1d0
testb $0x1, %al
jne 0x9cfe
jmp 0x9d1f
movq -0x60(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
movl -0x10(%rbp), %eax
movl %eax, -0x44(%rbp)
leaq -0x44(%rbp), %rsi
callq 0xa230
movq %rax, -0x58(%rbp)
movb %dl, -0x50(%rbp)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: processInfo::detachProcess()
void processInfo::detachProcess()
{
    printf("Detaching %d... ", pid);
    int retval = ptrace(PTRACE_DETACH, pid, NULL, NULL);
    if(retval == -1)
    {
        printf("Failed! ");
        printPtraceError(errno);
        perror("Detach failed");
    }
    else
    {
        printf("OK!\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl (%rax), %esi
leaq 0x584c(%rip), %rdi      # 0xf599
movb $0x0, %al
callq 0x2040
movq -0x18(%rbp), %rax
movl (%rax), %esi
movl $0x11, %edi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
movb $0x0, %al
callq 0x2150
movl %eax, -0xc(%rbp)
cmpl $-0x1, -0xc(%rbp)
jne 0x9d9e
leaq 0x582d(%rip), %rdi      # 0xf5aa
movb $0x0, %al
callq 0x2040
callq 0x2030
movl (%rax), %edi
callq 0x9dc0
leaq 0x581c(%rip), %rdi      # 0xf5b3
callq 0x2140
jmp 0x9dac
leaq 0x581c(%rip), %rdi      # 0xf5c1
movb $0x0, %al
callq 0x2040
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/processes.cpp
// Function: printPtraceError(int)
static void printPtraceError(int error)
{
    switch(error)
    {
        case EBUSY: printf("EBUSY\n"); break;
        case EFAULT: printf("EFAULT\n"); break;
        case EIO: printf("EIO\n"); break;
        case EINVAL: printf("EINVAL\n"); break;
        case EPERM: printf("EPERM\n"); break;
        case ESRCH: printf("ESRCH\n"); break;
        default: printf("Reason: Other\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x10(%rbp)
subl $0x15, %eax
ja 0x9e4f
movq -0x10(%rbp), %rax
leaq 0x56ae(%rip), %rcx      # 0xf494
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x586e(%rip), %rdi      # 0xf664
movb $0x0, %al
callq 0x2040
jmp 0x9e5d
leaq 0x5865(%rip), %rdi      # 0xf66b
movb $0x0, %al
callq 0x2040
jmp 0x9e5d
leaq 0x585d(%rip), %rdi      # 0xf673
movb $0x0, %al
callq 0x2040
jmp 0x9e5d
leaq 0x5852(%rip), %rdi      # 0xf678
movb $0x0, %al
callq 0x2040
jmp 0x9e5d
leaq 0x584a(%rip), %rdi      # 0xf680
movb $0x0, %al
callq 0x2040
jmp 0x9e5d
leaq 0x5841(%rip), %rdi      # 0xf687
movb $0x0, %al
callq 0x2040
jmp 0x9e5d
leaq 0x5838(%rip), %rdi      # 0xf68e
movb $0x0, %al
callq 0x2040
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: fakedReadHook(processInfo*, user_regs_struct&, int&, int&)
void fakedReadHook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &unused)
{
    //ssize_t read(int fd, void *buf, size_t count);
    //eax read(ebx fd, ecx *buf, edx count);
    unsigned int len = inputBuffer.lockedSize();
    if(regs.ARG3 < len)
        len = regs.ARG3;

    inputBuffer.lock();
    for(unsigned int i = 0; i < len; i++)
    {
        char c = inputBuffer.get();
        pi->writeChar(regs.ARG2 + i, c);
    }
    inputBuffer.unlock();
    regs.RAX = len;

    saveRegs = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq 0xaf09(%rip), %rdi      # 0x16278
callq 0x8020
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
jae 0xb392
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movl %eax, -0x24(%rbp)
leaq 0xaedf(%rip), %rdi      # 0x16278
callq 0x7ed0
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0xb3e2
leaq 0xaec4(%rip), %rdi      # 0x16278
callq 0x8060
movb %al, -0x29(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rsi
movl -0x28(%rbp), %eax
addq %rax, %rsi
movzbl -0x29(%rbp), %edx
callq 0x97f0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xb3a5
leaq 0xae8f(%rip), %rdi      # 0x16278
callq 0x7ef0
movl -0x24(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: preWriteHook(processInfo*, user_regs_struct&, int&, int&)
void preWriteHook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &fakeSyscall)
{
    // ssize_t write(int fd, const void *buf, size_t count);
    //ssize_t retval = write(regs.ARG1, regs.ARG2, regs.ARG3);
    //write(stdout, regs.ARG2, regs.ARG3);
    dprintf("Got a write syscall!\n");
    dprintf("fd = %d\n", (int)regs.ARG1);
    if(pi->isStdout(regs.ARG1) || pi->isStderr(regs.ARG1))
    {
        for(unsigned int i = 0; i < regs.ARG3; i++)
        {
            unsigned long c = pi->getValue(regs.ARG2 + i);
            dprintf("Wrote letter: ");
            printf("%c", (int)c);
            //printf("0x%02x (%c)\n", (unsigned char)c, (unsigned char)c);
            dprintf("\n");
        }
        fflush(stdout);
    }

    //return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl %eax, %esi
callq 0xa170
testb $0x1, %al
jne 0xb458
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl %eax, %esi
callq 0xa1d0
testb $0x1, %al
jne 0xb458
jmp 0xb4b5
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x60(%rcx), %rax
jae 0xb4a6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rsi
movl -0x24(%rbp), %eax
addq %rax, %rsi
callq 0x9700
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl %eax, %esi
leaq 0x4209(%rip), %rdi      # 0xf69d
movb $0x0, %al
callq 0x2040
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xb45f
movq 0xab1b(%rip), %rax      # 0x15fc8
movq (%rax), %rdi
callq 0x21e0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: preSelectHook(processInfo*, user_regs_struct&, int&, int&)
void preSelectHook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &fakeSyscall)
{
    //int maxDwords = sizeof(fd_set) / sizeof(__fd_mask);
    //printf("MaxDwords: %d\n", maxDwords);
    fd_set inSet;
    if(regs.ARG2 && inputBuffer.lockedSize() && pi->stdin.size())
    {
        pi->readMemcpy(&inSet, regs.ARG2, sizeof(fd_set));
        foreach(pi->stdin, it)
            if(FD_ISSET(*it, &inSet))
            {
                fakeSyscall = 1;
                return;
            }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0xb604
leaq 0xad87(%rip), %rdi      # 0x16278
callq 0x8020
cmpl $0x0, %eax
je 0xb604
movq -0x8(%rbp), %rdi
addq $0xf0, %rdi
callq 0xc320
cmpq $0x0, %rax
je 0xb604
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdx
leaq -0xa0(%rbp), %rsi
movl $0x80, %ecx
callq 0x9850
movq -0x8(%rbp), %rdi
addq $0xf0, %rdi
callq 0xc340
movq %rax, -0xa8(%rbp)
movq -0x8(%rbp), %rdi
addq $0xf0, %rdi
callq 0xa340
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xa2d0
testb $0x1, %al
jne 0xb580
jmp 0xb602
leaq -0xa8(%rbp), %rdi
callq 0xc370
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
cltq
movq -0xa0(%rbp,%rax,8), %rax
movq %rax, -0xc0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xc370
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xc0(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0xb5e6
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
jmp 0xb604
jmp 0xb5e8
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
callq 0xab20
movq %rax, -0xb8(%rbp)
jmp 0xb54d
jmp 0xb604
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: prePollHook(processInfo*, user_regs_struct&, int&, int&)
void prePollHook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &fakeSyscall)
{
    // int poll(struct pollfd *fds, nfds_t nfds, int timeout);
    if(regs.ARG2 && inputBuffer.lockedSize() && pi->stdin.size())
    {
        pollfd fds[regs.ARG2];
        pi->readMemcpy(&fds, regs.ARG1, regs.ARG2 * sizeof(pollfd));

        for(unsigned int i = 0; i < regs.ARG2; i++)
        {
            if(pi->isStdin(fds[i].fd) && (fds[i].events & POLLIN))
            {
                fakeSyscall = 1;
                return;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0xbadd
leaq 0xa88a(%rip), %rdi      # 0x16278
callq 0x8020
cmpl $0x0, %eax
je 0xbadd
movq -0x8(%rbp), %rdi
addq $0xf0, %rdi
callq 0xc320
cmpq $0x0, %rax
je 0xbadd
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rsi
subq %rcx, %rsi
movq %rsi, -0x40(%rbp)
movq %rsi, %rsp
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
shlq $0x3, %rax
movl %eax, %ecx
callq 0x9850
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x68(%rcx), %rax
jae 0xbac2
movq -0x40(%rbp), %rax
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,8), %esi
callq 0xa0e0
testb $0x1, %al
jne 0xba8e
jmp 0xbab5
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
movswl 0x4(%rax,%rcx,8), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xbab5
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
movl $0x1, -0x38(%rbp)
jmp 0xbac9
jmp 0xbab7
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xba68
movl $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, %rsp
movl -0x38(%rbp), %eax
testl %eax, %eax
je 0xbadb
jmp 0xbad9
jmp 0xbadd
jmp 0xbadd
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: fakePollHook(processInfo*, user_regs_struct&, int&, int&)
void fakePollHook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &unused)
{
    regs.RAX = 0;

    if(regs.ARG2 && inputBuffer.lockedSize())
    {
        pollfd fds[regs.ARG2];
        pi->readMemcpy(&fds, regs.ARG1, regs.ARG2 * sizeof(pollfd));

        for(unsigned int i = 0; i < regs.ARG2; i++)
        {
            fds[i].revents = 0;

            if(pi->isStdin(fds[i].fd) && (fds[i].events & POLLIN))
            {
                fds[i].revents = POLLIN;
                regs.RAX += 1;
                // Maybe force all other revents to 0 now that we've found one valid stdin fd?
            }
        }

        pi->writeMemcpy(regs.ARG1, &fds, regs.ARG2 * sizeof(pollfd));
    }

    saveRegs = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0xbc23
leaq 0xa74e(%rip), %rdi      # 0x16278
callq 0x8020
cmpl $0x0, %eax
je 0xbc23
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rsi
subq %rcx, %rsi
movq %rsi, -0x40(%rbp)
movq %rsi, %rsp
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
shlq $0x3, %rax
movl %eax, %ecx
callq 0x9850
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x68(%rcx), %rax
jae 0xbbf9
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
movw $0x0, 0x6(%rax,%rcx,8)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,8), %esi
callq 0xa0e0
testb $0x1, %al
jne 0xbbba
jmp 0xbbec
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
movswl 0x4(%rax,%rcx,8), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xbbec
movq -0x40(%rbp), %rax
movl -0x34(%rbp), %ecx
movw $0x1, 0x6(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x50(%rax)
jmp 0xbbee
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xbb8a
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
shlq $0x3, %rax
movl %eax, %ecx
callq 0x9970
movq -0x28(%rbp), %rax
movq %rax, %rsp
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: postDup2Hook(processInfo*, user_regs_struct&, int&, int&)
void postDup2Hook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &unused)
{
    //printf("[%d] Got dup2(%lu, %lu) syscall! (returned: %d)\n", pi->pid, pi->orig_regs.ARG1, pi->orig_regs.ARG2, (int)regs.RAX);
    if((int)regs.RAX == -1)
        return;

    if(pi->orig_regs.ARG1 == pi->orig_regs.ARG2)
        return; // Do nothing as per the man page

    pi->closeFileDescriptor(pi->orig_regs.ARG2);

    //TODO: check the man for FD_CLOEXEC
    pi->duplicateFileDescriptor(pi->orig_regs.ARG1, pi->orig_regs.ARG2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpl $-0x1, %eax
jne 0xbd07
jmp 0xbd5a
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x80(%rcx), %rax
jne 0xbd21
jmp 0xbd5a
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl %eax, %esi
callq 0x9bd0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl %eax, %esi
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl %eax, %edx
callq 0x9c70
addq $0x20, %rsp
popq %rbp
retq
// File: overfl0[P]iojack/syscalls.cpp
// Function: postDup3Hook(processInfo*, user_regs_struct&, int&, int&)
void postDup3Hook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &unused)
{
    //printf("[%d] Got dup3(%lu, %lu, %lu) syscall! (returned: %d)\n", pi->pid, pi->orig_regs.ARG1, pi->orig_regs.ARG2, pi->orig_regs.ARG3, (int)regs.RAX);
    if((int)regs.RAX == -1)
        return;

    pi->closeFileDescriptor(pi->orig_regs.ARG2);
    pi->duplicateFileDescriptor(pi->orig_regs.ARG1, pi->orig_regs.ARG2);

    if(pi->orig_regs.ARG3 & FD_CLOEXEC)
    {
        // TODO: Do something
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpl $-0x1, %eax
jne 0xbd87
jmp 0xbdd4
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl %eax, %esi
callq 0x9bd0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl %eax, %esi
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl %eax, %edx
callq 0x9c70
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0xbdd4
jmp 0xbdd4
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: postFcntlHook(processInfo*, user_regs_struct&, int&, int&)
void postFcntlHook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &unused)
{
    //printf("[%d] Got fcntl(%lu, %lu, %lu) syscall! (returned: %d)\n", pi->pid, pi->orig_regs.ARG1, pi->orig_regs.ARG2, pi->orig_regs.ARG3, (int)regs.RAX);
    if((int)regs.RAX == -1)
        return;

    if(pi->orig_regs.ARG2 == F_DUPFD || pi->orig_regs.ARG2 == F_DUPFD_CLOEXEC)
    {
        pi->duplicateFileDescriptor(pi->orig_regs.ARG1, (int)regs.RAX);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpl $-0x1, %eax
jne 0xbe07
jmp 0xbe46
movq -0x8(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0xbe26
movq -0x8(%rbp), %rax
cmpq $0x406, 0x80(%rax) # imm = 0x406
jne 0xbe46
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl %eax, %esi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %eax, %edx
callq 0x9c70
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: postOpenHook(processInfo*, user_regs_struct&, int&, int&)
void postOpenHook(processInfo *pi, user_regs_struct &regs, int &saveRegs, int &unused)
{
    //printf("[%d] Got open(%lx, %lu, %lu) syscall! (returned: %d)\n", pi->pid, pi->orig_regs.ARG1, pi->orig_regs.ARG2, pi->orig_regs.ARG3, (int)regs.RAX);
    if((int)regs.RAX < 0)
        return;

    #define MAX_FILE_LEN 100
    char fileName[MAX_FILE_LEN + 1];
    pi->readStrncpy(fileName, pi->orig_regs.ARG1, MAX_FILE_LEN);
    fileName[MAX_FILE_LEN] = '\0';
    #undef MAX_FILE_LEN

    //printf("[%d] open(%s) = %d\n", pi->pid, fileName, (int)regs.RAX);

    // Check if opening a terminal
    if(!strncmp(fileName, "/dev/pts/", strlen("/dev/pts/"))
    || !strncmp(fileName, "/dev/tty",  strlen("/dev/tty")))
    {
        if((pi->orig_regs.ARG2 & 3) == O_RDONLY || (pi->orig_regs.ARG2 & 3) == O_RDWR)
        {
            pi->stdin.insert(regs.RAX);
        }

        if((pi->orig_regs.ARG2 & 3) == O_WRONLY || (pi->orig_regs.ARG2 & 3) == O_RDWR)
        {
            pi->stdout.insert(regs.RAX);
            pi->stderr.insert(regs.RAX);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpl $0x0, %eax
jge 0xbe7d
jmp 0xbfcb
movq -0x8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rdx
movl $0x64, %ecx
callq 0x9ac0
movb $0x0, -0x2c(%rbp)
leaq -0x90(%rbp), %rdi
leaq 0x3739(%rip), %rsi      # 0xf5e8
movl $0x9, %edx
callq 0x20c0
cmpl $0x0, %eax
je 0xbedf
leaq -0x90(%rbp), %rdi
leaq 0x3726(%rip), %rsi      # 0xf5f2
movl $0x8, %edx
callq 0x20c0
cmpl $0x0, %eax
jne 0xbfcb
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
andq $0x3, %rax
cmpq $0x0, %rax
je 0xbf09
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
andq $0x3, %rax
cmpq $0x2, %rax
jne 0xbf3b
movq -0x8(%rbp), %rdi
addq $0xf0, %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %eax, -0x94(%rbp)
leaq -0x94(%rbp), %rsi
callq 0xa230
movq %rax, -0xa8(%rbp)
movb %dl, -0xa0(%rbp)
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
andq $0x3, %rax
cmpq $0x1, %rax
je 0xbf65
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
andq $0x3, %rax
cmpq $0x2, %rax
jne 0xbfc9
movq -0x8(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %eax, -0xac(%rbp)
leaq -0xac(%rbp), %rsi
callq 0xa230
movq %rax, -0xc0(%rbp)
movb %dl, -0xb8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movl %eax, -0xc4(%rbp)
leaq -0xc4(%rbp), %rsi
callq 0xa230
movq %rax, -0xd8(%rbp)
movb %dl, -0xd0(%rbp)
jmp 0xbfcb
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: overfl0[P]iojack/syscalls.cpp
// Function: initSyscallHooks()
void initSyscallHooks()
{
    setPreHook  (SYS_write,    preWriteHook);
    setPreHook  (SYS_read,     preReadHook);
    setFakedHook(SYS_read,     fakedReadHook);
    setPreHook(SYS_select,     preSelectHook);
    setFakedHook(SYS_select,   fakeSelectHook);
    setPreHook(SYS_pselect6,   preSelectHook);  // like select() but atomically sets and
    setFakedHook(SYS_pselect6, fakeSelectHook); // unsets sigprocmask() before and after select()
    setPreHook  (SYS_poll,     prePollHook);
    setFakedHook(SYS_poll,     fakePollHook);
    setPostHook (SYS_close,    postCloseHook);
    setPostHook (SYS_dup,      postDupHook);
    setPostHook (SYS_dup2,     postDup2Hook);
    setPostHook (SYS_dup3,     postDup3Hook);
    setPostHook (SYS_fcntl,    postFcntlHook);
    setPostHook (SYS_open,     postOpenHook);
    setPostHook (SYS_ioctl,    postIoctlHook);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl $0x1, %edi
leaq -0xcd0(%rip), %rsi      # 0xb410
callq 0xb200
xorl %edi, %edi
leaq -0xdfe(%rip), %rsi      # 0xb2f0
callq 0xb200
xorl %edi, %edi
leaq -0xdac(%rip), %rsi      # 0xb350
callq 0xb230
movl $0x17, %edi
leaq -0xc4d(%rip), %rsi      # 0xb4c0
callq 0xb200
movl $0x17, %edi
leaq -0xb0e(%rip), %rsi      # 0xb610
callq 0xb230
movl $0x10e, %edi            # imm = 0x10E
leaq -0xc6f(%rip), %rsi      # 0xb4c0
callq 0xb200
movl $0x10e, %edi            # imm = 0x10E
leaq -0xb30(%rip), %rsi      # 0xb610
callq 0xb230
movl $0x7, %edi
leaq -0x791(%rip), %rsi      # 0xb9c0
callq 0xb200
movl $0x7, %edi
leaq -0x672(%rip), %rsi      # 0xbaf0
callq 0xb230
movl $0x3, %edi
leaq -0x533(%rip), %rsi      # 0xbc40
callq 0xb260
movl $0x20, %edi
leaq -0x4f4(%rip), %rsi      # 0xbc90
callq 0xb260
movl $0x21, %edi
leaq -0x4b5(%rip), %rsi      # 0xbce0
callq 0xb260
movl $0x124, %edi            # imm = 0x124
leaq -0x446(%rip), %rsi      # 0xbd60
callq 0xb260
movl $0x48, %edi
leaq -0x3d7(%rip), %rsi      # 0xbde0
callq 0xb260
movl $0x2, %edi
leaq -0x378(%rip), %rsi      # 0xbe50
callq 0xb260
movl $0x10, %edi
leaq -0x1f9(%rip), %rsi      # 0xbfe0
callq 0xb260
popq %rbp
retq
// File: overfl0[P]iojack/syscalls.cpp
// Function: setHook(std::vector<void (*)(processInfo*, user_regs_struct&, int&, int&), std::allocator<void (*)(processInfo*, user_regs_struct&, int&, int&)>>&, int, void (*)(processInfo*, user_regs_struct&, int&, int&))
inline void setHook(vector<hookPtr> &v, int syscall, hookPtr ptr)
{
    if(syscall < 0)
        return; // Fail silently. Who told you to hook negative syscalls?

    if(v.size() <= (unsigned int)syscall)
    {
        v.resize(syscall + 1, NULL);
    }
    v[syscall] = ptr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cmpl $0x0, -0xc(%rbp)
jge 0xc27b
jmp 0xc2c6
movq -0x8(%rbp), %rdi
callq 0xc440
movl -0xc(%rbp), %ecx
cmpq %rcx, %rax
ja 0xc2aa
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movq $0x0, -0x20(%rbp)
leaq -0x20(%rbp), %rdx
callq 0xc460
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rsi
callq 0xc510
movq -0x28(%rbp), %rcx
movq %rcx, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: iZhangHui[P]CppPrimer/CH15_ObjectOrientedProgramming/examples/virtualsNscope.cc
// Function: main
int main()
{
    D1 dobj, *dp = &dobj;
    dp->fcn(42); // ok: static call to D1::fcn(int)

    Base bobj;  D1 d1obj; D2 d2obj;

    Base *bp1 = &bobj, *bp2 = &d1obj, *bp3 = &d2obj;
    bp1->fcn(); // virtual call, will call Base::fcn at run time
    bp2->fcn(); // virtual call, will call Base::fcn at run time
    bp3->fcn(); // virtual call, will call D2::fcn at run time

	D1 *d1p = &d1obj; D2 *d2p = &d2obj;
	d1p->f2(); // virtual call, will call D1::f2() at run time
	d2p->f2(); // virtual call, will call D2::f2() at run time
	Base *p1 = &d2obj; D1 *p2 = &d2obj; D2 *p3 =  &d2obj;
	p2->fcn(42);  // statically bound, calls D1::fcn(int)
	p3->fcn(42);  // statically bound, calls D2::fcn(int)

    Base* bp = &d1obj; D1 *dp1 = &d2obj; D2 *dp2 = &d2obj;
    dp1->fcn(10); // static call to D1::fcn(int)
    dp2->fcn(10); // static call to D2::fcn(int)
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
leaq -0x8(%rbp), %rdi
callq 0x1440
leaq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2a, %esi
callq 0x11f0
leaq -0x18(%rbp), %rdi
callq 0x1480
leaq -0x20(%rbp), %rdi
callq 0x1440
leaq -0x28(%rbp), %rdi
callq 0x14a0
leaq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
leaq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x50(%rbp), %rdi
callq 0x12f0
leaq -0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movl $0x2a, %esi
callq 0x11f0
movq -0x68(%rbp), %rdi
movl $0x2a, %esi
callq 0x1270
leaq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
movl $0xa, %esi
callq 0x11f0
movq -0x80(%rbp), %rdi
movl $0xa, %esi
callq 0x1270
xorl %eax, %eax
addq $0x80, %rsp
popq %rbp
retq
nop
// File: syzcch[P]FEC_C_version/fec_rdp.cpp
// Function: main
int main() {

	const int NUM = 6;
	int err[NUM];

	printf("starting");
	rdp *rdpItem = new rdp();

	rdpItem->setData();
	rdpItem->encoding();
	rdpItem->outputData();
	
	for(int i=0;i<NUM;i++){
		err[i] = 0;
	}

	err[5]=1;

	rdpItem->setErrData(err);
	
	// testing one error, error disk sequence number is 3, r checkout disk is not broken
//		rdpItem->decoding(1, 3, -1, false);
//		rdpItem->outputOrigin();
	
	// testing one error, error disk sequence number is 1, r checkout disk is  broken
//	rdpItem->decoding(1, 2, -1, false);
	rdpItem->decoding();
	rdpItem->outputOrigin();
	
	// testing 2 error, the error disks sequence number is 0 and 3, r checkout disk is not broken
//	rdpItem->decoding(2, 1, 3, true);
//	rdpItem->outputOrigin();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl $0x6, -0x8(%rbp)
leaq 0x1cc7(%rip), %rdi      # 0x4004
xorl %eax, %eax
callq 0x2030
movl $0x40, %edi
callq 0x20f0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x40(%rbp)
callq 0x2400
jmp 0x235f
movq -0x40(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl $0x0, -0x38(%rbp)
cmpl $0x6, -0x38(%rbp)
jge 0x23c5
movslq -0x38(%rbp), %rax
movl $0x0, -0x20(%rbp,%rax,4)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x238c
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x40, %esi
callq 0x2100
jmp 0x23f6
movl $0x1, -0xc(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movq (%rdi), %rax
callq *(%rax)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x21a0
nop