LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/CoinXu[P]reviser-compiler/src/compiler/javascript/javascript_common.h
// Function: reviser::javascript::JavaScriptCommon::DecoraterDefinition[abi:cxx11](reviser::compiler::ReviserSyntaxDefinition, std::vector<reviser::compiler::DecoraterArg, std::allocator<reviser::compiler::DecoraterArg>>*)
const static string DecoraterDefinition(ReviserSyntaxDefinition def, vector<DecoraterArg>* args = nullptr) {
      switch (def.type) {
        case SYNTAX_FUNCTION:
          return def.name;

        case SYNTAX_CALLABLE:
          return DecoraterSyntaxCallable(def, args);

        default:
          return "";
      }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movl 0x20(%rsi), %eax
testl %eax, %eax
je 0x495af
cmpl $0x1, %eax
jne 0x49616
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x2a264
jmp 0x4962f
movq %rdx, %r14
leaq -0x58(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %r12
movq %r12, %rdi
callq 0x2a264
movl 0x20(%r15), %eax
movl %eax, 0x20(%r12)
leaq -0x40(%rbp), %rdi
addq $0x28, %r15
movq %r15, %rsi
callq 0x331f6
leaq -0x68(%rbp), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x49732
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x49606
callq 0x25320
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x4962f
callq 0x25320
jmp 0x4962f
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x8530(%rip), %rdx      # 0x51b54
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x2a2fe
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x3308a
jmp 0x49660
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x49660
callq 0x25320
movq %rbx, %rdi
callq 0x255f0
// File: /workspace/github_cpp_makefile_star2_O1/CoinXu[P]reviser-compiler/src/compiler/typescript/typescript_common.h
// Function: reviser::typescript::TypeScriptCommon::FindReviserSyntaxDefinitionByDataType(reviser::compiler::DataType)
const static vector<ReviserSyntaxDefinition> FindReviserSyntaxDefinitionByDataType(DataType type) {
      vector<ReviserSyntaxDefinition> defs;

      if (TypeScriptDataTypeReviserMap.find(type) == TypeScriptDataTypeReviserMap.end()) {
        return defs;
      }

      for (ReviserType t : TypeScriptDataTypeReviserMap.at(type)) {
        if (ReviserMethodMap.find(t) != ReviserMethodMap.end()) {
          defs.push_back(ReviserMethodMap.at(t));
        }
      }

      return defs;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, -0x30(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x14cd5(%rip), %rdx     # 0x61e08
leaq 0x14cc6(%rip), %rcx     # 0x61e00
movq %rcx, %rax
testq %rdx, %rdx
je 0x4d160
leaq 0x14cb7(%rip), %rax     # 0x61e00
xorl %edi, %edi
cmpl %esi, 0x20(%rdx)
setl %dil
cmovgeq %rdx, %rax
movq 0x10(%rdx,%rdi,8), %rdx
testq %rdx, %rdx
jne 0x4d149
cmpq %rcx, %rax
je 0x4d1ec
cmpl %esi, 0x20(%rax)
jg 0x4d1ec
leaq 0x14c83(%rip), %rdi     # 0x61df8
leaq -0x30(%rbp), %rsi
callq 0x469d4
movq (%rax), %r12
movq 0x8(%rax), %r13
cmpq %r13, %r12
je 0x4d1ec
leaq 0x1495f(%rip), %r14     # 0x61af0
leaq 0x8(%r14), %r15
movl (%r12), %eax
movl %eax, -0x2c(%rbp)
movq 0x10(%r14), %rdx
movq %r15, %rcx
testq %rdx, %rdx
je 0x4d1c2
movq %r15, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x4d1ab
cmpq %r15, %rcx
je 0x4d1e3
cmpl 0x20(%rcx), %eax
jl 0x4d1e3
movq %r14, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x46a5c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x46a24
addq $0x4, %r12
cmpq %r13, %r12
jne 0x4d195
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4d200
movq %rax, %r14
movq %rbx, %rdi
callq 0x4689c
movq %r14, %rdi
callq 0x255f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/overfl0[P]iojack/iojack.cpp
// Function: getArgs(int, char**)
int getArgs(int argc, char **argv)
{
    int opt;
    while((opt = getopt(argc, argv, optString)) != -1)
    {
        switch(opt)
        {
            /*case 'p':
                globalArgs.langCode = optarg;
                break;
            */
            case 'a':
                globalSettings.sendANSI = 1;
                break;

            case 'h':
                displayUsage(argv[0]);
                exit(0);

            case '?':
                displayUsage(argv[0]);
                exit(1);
        }
    }

    if(argc <= optind)
    {
        displayUsage(argv[0]);
        exit(1);
    }

    int firstPid = atoi(argv[optind]);
    if(firstPid <= 1)
        pexit("Can't get correct pid from arguments\n");

    return firstPid;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x3b2a(%rip), %r14      # 0x61e5
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2070
cmpl $0x60, %eax
jle 0x26db
cmpl $0x61, %eax
jne 0x26e7
movb $0x1, 0x8adf(%rip)      # 0xb1b8
jmp 0x26bb
cmpl $-0x1, %eax
je 0x26fb
cmpl $0x3f, %eax
jne 0x26bb
jmp 0x271c
cmpl $0x68, %eax
jne 0x26bb
movq (%rbx), %rdi
callq 0x268c
xorl %edi, %edi
callq 0x21e0
movq 0x88de(%rip), %rax      # 0xafe0
movslq (%rax), %rax
cmpl %ebp, %eax
jge 0x271c
movq (%rbx,%rax,8), %rdi
callq 0x22c0
cmpl $0x1, %eax
jle 0x272e
popq %rbx
popq %r14
popq %rbp
retq
movq (%rbx), %rdi
callq 0x268c
movl $0x1, %edi
callq 0x21e0
leaq 0x3af3(%rip), %rdi      # 0x6228
callq 0x22b0
jmp 0x2724
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
subq $0xa0, %rsp
leaq 0x3b02(%rip), %rdi      # 0x624d
callq 0x22b0
leaq 0x8(%rsp), %rbx
movl $0x98, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20d0
movl $0x10000000, 0x88(%rbx) # imm = 0x10000000
movl $0x2, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2200
callq 0x278b
addq $0xa0, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl $0x1, 0x8a1e(%rip)      # 0xb1bc
leaq 0x3ae0(%rip), %rdi      # 0x6285
callq 0x22b0
movq 0x8a27(%rip), %rbx      # 0xb1d8
leaq 0x8a10(%rip), %r13      # 0xb1c8
cmpq %r13, %rbx
je 0x2838
leaq 0x3900(%rip), %r14      # 0x60c4
leaq 0x3ace(%rip), %r15      # 0x6299
movq 0x28(%rbx), %r12
movl (%r12), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2040
cmpl $0x0, 0x4(%r12)
je 0x27f7
cmpl $-0x1, 0x8(%r12)
je 0x27f7
movq %r15, %rdi
callq 0x22b0
jmp 0x281c
movl $0x1, 0xc(%r12)
movl (%r12), %edi
movl $0x13, %esi
callq 0x2250
testl %eax, %eax
jne 0x282e
movl $0xa, %edi
callq 0x2230
movq %rbx, %rdi
callq 0x20f0
movq %rax, %rbx
cmpq %r13, %rax
jne 0x27cb
jmp 0x2838
movq %r12, %rdi
callq 0x2340
jmp 0x2812
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
subq $0xa0, %rsp
leaq 0x8(%rsp), %rbx
movl $0x98, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20d0
leaq -0x129(%rip), %rax      # 0x273c
movq %rax, (%rbx)
movl $0x10000000, 0x88(%rbx) # imm = 0x10000000
movl $0x2, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2200
addq $0xa0, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/overfl0[P]iojack/iojack.cpp
// Function: stdinPoll(void*)
void *stdinPoll(void *inBuf)
{
    buffer *inputBuffer = (buffer *)inBuf;
    initTerminal();
    while(!wantToExit)
    {
        int c = getTerminalChar();
        if(c != -1)
        {
            // Lock the buffer and read as much data as you can (useful with
            // special sequences of more than one character)
            inputBuffer->lock();
            do
            {
                inputBuffer->add(c);
                c = getTerminalChar();
            }
            while(c != -1);
            inputBuffer->unlock();

            // TODO: Clean up this mess! Possibly move to a separate function
            // Wake up reading processes
            foreach(processes, it)
            {
                if(it->second->inSyscall && it->second->fakingSyscall == -1)
                {
                    //TODO: if possible, check if the syscall is sys_read
                    it->second->sigstopToRestartSyscall = 1;
                    int retval = kill(it->second->pid, SIGSTOP);
                    if(retval)
                    {
                        printf("Error while sending SIGSTOP to %d\n", it->second->pid);
                        perror("Error");
                    }
                }
            }
        }
        //thread_sleep(10);
        struct timespec waitTime;
        waitTime.tv_sec = 0;
        waitTime.tv_nsec = 100000000; // 0.1 sec
        nanosleep(&waitTime, NULL);
    }
    uninitTerminal();

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
callq 0x3a64
cmpl $0x0, 0x8917(%rip)      # 0xb1bc
jne 0x2961
movq %rsp, %r14
leaq 0x8913(%rip), %r12      # 0xb1c8
callq 0x3a80
cmpl $-0x1, %eax
je 0x2939
movl %eax, %ebp
movq %rbx, %rdi
callq 0x3c8e
movsbl %bpl, %esi
movq %rbx, %rdi
callq 0x3ca2
callq 0x3a80
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x28c9
movq %rbx, %rdi
callq 0x3c98
movq 0x88e8(%rip), %r15      # 0xb1d8
cmpq %r12, %r15
je 0x2939
movq 0x28(%r15), %rax
cmpl $0x0, 0x4(%rax)
je 0x291c
cmpl $-0x1, 0x8(%rax)
jne 0x291c
movl $0x1, 0x10(%rax)
movl (%rax), %edi
movl $0x13, %esi
callq 0x2250
testl %eax, %eax
jne 0x292e
movq %r15, %rdi
callq 0x20f0
movq %rax, %r15
cmpq %r12, %rax
jne 0x28f5
jmp 0x2939
leaq 0x28(%r15), %rdi
callq 0x235e
jmp 0x291c
movq $0x0, (%rsp)
movq $0x5f5e100, 0x8(%rsp)   # imm = 0x5F5E100
movq %r14, %rdi
xorl %esi, %esi
callq 0x2090
cmpl $0x0, 0x8861(%rip)      # 0xb1bc
je 0x28b5
callq 0x3a70
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x80(%rsi), %rsi
addq $-0x8, %rsi
callq 0x4270
movq %rax, (%rsp)
movq 0x80(%rbx), %rsi
movq %r14, %rdi
callq 0x4270
movq %rax, 0x8(%rsp)
movq 0x80(%rbx), %rsi
addq $-0x8, %rsi
leaq 0x36a4(%rip), %rdi      # 0x6060
xorl %eax, %eax
callq 0x2040
movl $0x1, %r14d
leaq 0x3696(%rip), %rbx      # 0x6066
movzbl -0x1(%rsp,%r14), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2040
testb $0x1, %r14b
jne 0x29f0
movl $0x20, %edi
callq 0x2230
incq %r14
cmpq $0x11, %r14
jne 0x29d0
movl $0xa, %edi
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x2230
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
subq $0x40, %rsp
movq %rdi, %rbx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x21b0
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups 0x20(%rbx), %xmm2
movups 0x2c(%rbx), %xmm3
movq %rsp, %rdx
movaps %xmm0, (%rdx)
movaps %xmm1, 0x10(%rdx)
movups %xmm3, 0x2c(%rdx)
movaps %xmm2, 0x20(%rdx)
andb $-0xb, 0xc(%rdx)
movw $0x0, 0x16(%rdx)
xorl %edi, %edi
xorl %esi, %esi
callq 0x2210
addq $0x40, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/overfl0[P]iojack/buffer.cpp
// Function: buffer::lockedSize()
int buffer::lockedSize()
{
    lock();
    int retval = data.size();
    unlock();
    return retval;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x50(%rdi), %r14
movq %r14, %rdi
callq 0x2270
movq 0x48(%rbx), %rax
movl 0x28(%rbx), %ecx
movl %eax, %edx
subl %ecx, %edx
shrl $0x3, %edx
cmpq $0x1, %rax
adcl $-0x1, %edx
movl 0x30(%rbx), %ebp
subl 0x38(%rbx), %ebp
addl 0x20(%rbx), %ebp
shll $0x9, %edx
addl %edx, %ebp
subl 0x10(%rbx), %ebp
movq %r14, %rdi
callq 0x2100
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/overfl0[P]iojack/buffer.cpp
// Function: buffer::lockedGet()
unsigned char buffer::lockedGet()
{
    lock();
    unsigned char retval = get();
    unlock();
return retval;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x50(%rdi), %r14
movq %r14, %rdi
callq 0x2270
movq 0x10(%rbx), %rax
movb (%rax), %bpl
movq %rbx, %rdi
callq 0x4224
movq %r14, %rdi
callq 0x2100
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
movq %rsi, %rdx
movl (%rdi), %esi
movl $0x2, %edi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x2140
movq %rax, %rbx
cmpq $-0x1, %rax
jne 0x4297
callq 0x2030
cmpl $0x0, (%rax)
jne 0x429c
movq %rbx, %rax
popq %rbx
retq
movq %rax, %rdi
callq 0x2427
jmp 0x4297
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0x70, %rsp
movq %rdx, %rcx
movq %rsi, %rbx
movl (%rdi), %esi
movl $0x5, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2140
movq %rax, %r14
cmpq $-0x1, %rax
je 0x42dc
movq %r14, %rax
addq $0x70, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x367c(%rip), %rsi      # 0x795f
movq %rsp, %r15
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2060
movq %r15, %rdi
callq 0x2130
jmp 0x42cf
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
cmpl $0x8, %ecx
jb 0x43a3
leaq 0x3626(%rip), %r13      # 0x797a
movl (%r12), %esi
movl $0x2, %edi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x2140
movq %rax, %rbp
cmpq $-0x1, %rax
jne 0x437c
callq 0x2030
cmpl $0x0, (%rax)
jne 0x4397
movq %rbp, (%r14)
addq $0x8, %r14
addq $0x8, %r15
movb $0x1, %al
testb %al, %al
je 0x43e7
addl $-0x8, %ebx
cmpl $0x7, %ebx
ja 0x4354
jmp 0x43a3
movq %r13, %rdi
callq 0x2130
xorl %eax, %eax
jmp 0x4389
testl %ebx, %ebx
je 0x43e7
movl (%r12), %esi
movl $0x2, %edi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x2140
movq %rax, (%rsp)
cmpq $-0x1, %rax
jne 0x43d0
callq 0x2030
cmpl $0x0, (%rax)
jne 0x43f6
cmpl $0x1, %ebx
adcl $0x0, %ebx
xorl %eax, %eax
movb (%rsp,%rax), %cl
movb %cl, (%r14,%rax)
incq %rax
cmpq %rax, %rbx
jne 0x43d8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3596(%rip), %rdi      # 0x7993
callq 0x2130
jmp 0x43e7
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r14d
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r12
cmpl $0x8, %ecx
jb 0x446a
leaq 0x3586(%rip), %r13      # 0x79ad
movl (%r12), %esi
movq (%r15), %rcx
movl $0x5, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2140
movq %rax, %rbp
cmpq $-0x1, %rax
je 0x4460
addq $0x8, %r15
addq $0x8, %rbx
cmpq $-0x1, %rbp
je 0x44ce
addl $-0x8, %r14d
cmpl $0x7, %r14d
ja 0x4427
jmp 0x446a
movq %r13, %rdi
callq 0x2130
jmp 0x444e
testl %r14d, %r14d
je 0x44ce
movl (%r12), %esi
movl $0x2, %edi
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x2140
movq %rax, (%rsp)
cmpq $-0x1, %rax
jne 0x4498
callq 0x2030
cmpl $0x0, (%rax)
jne 0x44e6
cmpl $0x1, %r14d
adcl $0x0, %r14d
xorl %eax, %eax
movb (%r15,%rax), %cl
movb %cl, (%rsp,%rax)
incq %rax
cmpq %rax, %r14
jne 0x44a2
movl (%r12), %esi
movq (%rsp), %rcx
movl $0x5, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2140
cmpq $-0x1, %rax
je 0x44dd
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3500(%rip), %rdi      # 0x79e4
jmp 0x44ed
leaq 0x34dd(%rip), %rdi      # 0x79ca
callq 0x2130
jmp 0x44ce
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x3469(%rip), %r12      # 0x797a
xorl %r13d, %r13d
cmpl %ebp, %r13d
jae 0x45b2
movl (%r15), %esi
movl %r13d, %edx
addq %r14, %rdx
movl $0x2, %edi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x2140
movq %rax, (%rsp)
cmpq $-0x1, %rax
jne 0x4548
callq 0x2030
cmpl $0x0, (%rax)
jne 0x45a8
leal 0x8(%r13), %eax
cmpl %ebp, %r13d
movl %ebp, %ecx
cmoval %r13d, %ecx
movl %ecx, %edi
subl %r13d, %edi
xorl %esi, %esi
movq %rbx, %rdx
cmpq %rsi, %rdi
je 0x4588
movb (%rsp,%rsi), %r8b
movb %r8b, (%rbx,%rsi)
testb %r8b, %r8b
je 0x4592
incq %rdx
incq %rsi
cmpq $0x8, %rsi
jne 0x455f
movb $0x1, %sil
movq %rdx, %rbx
movl %eax, %r13d
jmp 0x459d
xorl %esi, %esi
movq %rdx, %rbx
movl %ecx, %r13d
jmp 0x459d
addl %esi, %r13d
addq %rsi, %rbx
incq %rbx
xorl %esi, %esi
testb %sil, %sil
jne 0x4514
jmp 0x45b2
movq %r12, %rdi
callq 0x2130
jmp 0x459b
cmpl %ebp, %r13d
jae 0x45d1
notl %r13d
addl %ebp, %r13d
leaq 0x1(%r13), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20d0
addq %r13, %rbx
incq %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq 0x100(%rdi), %rdx
leaq 0xf8(%rdi), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x4621
movq %rax, %rcx
xorl %esi, %esi
cmpl %ebp, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x460a
movq %rax, %rdx
cmpq %rax, %rcx
je 0x4633
cmpl %ebp, 0x20(%rcx)
cmovgq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
je 0x4659
leaq 0xf0(%rbx), %r14
leaq 0xc(%rsp), %rsi
movl %ebp, (%rsi)
movq %r14, %rdi
callq 0x4af8
movq %r14, %rdi
movq %rax, %rsi
callq 0x4b70
movq 0x130(%rbx), %rdx
leaq 0x128(%rbx), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x4689
movq %rax, %rcx
xorl %esi, %esi
cmpl %ebp, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x4672
movq %rax, %rdx
cmpq %rax, %rcx
je 0x469b
cmpl %ebp, 0x20(%rcx)
cmovgq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
je 0x46c1
leaq 0x120(%rbx), %r14
leaq 0x8(%rsp), %rsi
movl %ebp, (%rsi)
movq %r14, %rdi
callq 0x4af8
movq %r14, %rdi
movq %rax, %rsi
callq 0x4b70
movq 0x160(%rbx), %rdx
leaq 0x158(%rbx), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x46f1
movq %rax, %rcx
xorl %esi, %esi
cmpl %ebp, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x46da
movq %rax, %rdx
cmpq %rax, %rcx
je 0x4703
cmpl %ebp, 0x20(%rcx)
cmovgq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
je 0x4729
addq $0x150, %rbx            # imm = 0x150
leaq 0x4(%rsp), %rsi
movl %ebp, (%rsi)
movq %rbx, %rdi
callq 0x4af8
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4b70
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movq 0x100(%rdi), %rdx
leaq 0xf8(%rdi), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x4771
movq %rax, %rcx
xorl %esi, %esi
cmpl %ebp, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x475a
movq %rax, %rdx
cmpq %rax, %rcx
je 0x4783
cmpl %ebp, 0x20(%rcx)
cmovgq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
je 0x479b
leaq 0xf0(%r14), %rdi
leaq 0xc(%rsp), %rsi
movl %ebx, (%rsi)
callq 0x4c16
movq 0x130(%r14), %rdx
leaq 0x128(%r14), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x47cb
movq %rax, %rcx
xorl %esi, %esi
cmpl %ebp, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x47b4
movq %rax, %rdx
cmpq %rax, %rcx
je 0x47dd
cmpl %ebp, 0x20(%rcx)
cmovgq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
je 0x47f5
leaq 0x120(%r14), %rdi
leaq 0x8(%rsp), %rsi
movl %ebx, (%rsi)
callq 0x4c16
movq 0x160(%r14), %rdx
leaq 0x158(%r14), %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x4825
movq %rax, %rcx
xorl %esi, %esi
cmpl %ebp, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x480e
movq %rax, %rdx
cmpq %rax, %rcx
je 0x4837
cmpl %ebp, 0x20(%rcx)
cmovgq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
je 0x4852
addq $0x150, %r14            # imm = 0x150
leaq 0x4(%rsp), %rsi
movl %ebx, (%rsi)
movq %r14, %rdi
callq 0x4c16
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
movq %rdi, %rbx
movl (%rdi), %esi
leaq 0x3198(%rip), %rdi      # 0x7a01
xorl %eax, %eax
callq 0x2040
movl (%rbx), %esi
movl $0x11, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x2140
cmpl $-0x1, %eax
je 0x4894
leaq 0x3230(%rip), %rdi      # 0x7abe
popq %rbx
jmp 0x22b0
callq 0x2448
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/overfl0[P]iojack/syscalls.cpp
// Function: setPreHook(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:
testl %edi, %edi
js 0x4e21
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %esi
movq 0x6454(%rip), %rax      # 0xb238
subq 0x6445(%rip), %rax      # 0xb230
sarq $0x3, %rax
movl %edi, %r14d
cmpq %r14, %rax
ja 0x4e0f
incl %esi
movq %rsp, %rdx
movq $0x0, (%rdx)
leaq 0x6426(%rip), %rdi      # 0xb230
callq 0x5924
movq 0x641a(%rip), %rax      # 0xb230
movq %rbx, (%rax,%r14,8)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/overfl0[P]iojack/syscalls.cpp
// Function: getPreHook(int)
inline hookPtr getHook(vector<hookPtr> &v, int syscall)
{
    if(syscall < 0 || v.size() <= (unsigned int)syscall)
        return NULL;
    return v[syscall];
    /* This version, while pretty, REALLY sucks performance-wise!
    try
    {
        return v.at(syscall);
    } catch(std::out_of_range e)
    {
        return NULL;
    }*/
}

// Assembly:
testl %edi, %edi
js 0x4eeb
movq 0x6367(%rip), %rdx      # 0xb238
movq 0x6358(%rip), %rax      # 0xb230
subq %rax, %rdx
sarq $0x3, %rdx
movl %edi, %ecx
cmpq %rcx, %rdx
jbe 0x4eeb
movq (%rax,%rcx,8), %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x62aa(%rip), %r12      # 0xb278
movq %r12, %rdi
callq 0x3d88
movq 0x60(%r14), %rbp
movl %eax, %ecx
cmpq %rcx, %rbp
cmovael %eax, %ebp
movq %r12, %rdi
callq 0x3c8e
movl %ebp, %r13d
testl %ebp, %ebp
je 0x501c
xorl %ebp, %ebp
leaq 0x627e(%rip), %r12      # 0xb278
movq %r12, %rdi
callq 0x3dd0
movq 0x68(%r14), %rsi
addq %rbp, %rsi
movzbl %al, %edx
movq %r15, %rdi
callq 0x42fe
incq %rbp
cmpq %rbp, %r13
jne 0x4ffa
leaq 0x6255(%rip), %rdi      # 0xb278
callq 0x3c98
movq %r13, 0x50(%r14)
movl $0x1, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl 0x70(%rsi), %eax
movq 0x130(%rdi), %rsi
leaq 0x128(%rdi), %rcx
movq %rcx, %rdx
testq %rsi, %rsi
je 0x507e
movq %rcx, %rdx
xorl %edi, %edi
cmpl %eax, 0x20(%rsi)
setl %dil
cmovgeq %rsi, %rdx
movq 0x10(%rsi,%rdi,8), %rsi
testq %rsi, %rsi
jne 0x5067
movq %rcx, %rsi
cmpq %rcx, %rdx
je 0x5090
cmpl %eax, 0x20(%rdx)
cmovgq %rcx, %rdx
movq %rdx, %rsi
cmpq %rcx, %rsi
jne 0x50dc
movq 0x160(%r14), %rsi
leaq 0x158(%r14), %rcx
movq %rcx, %rdx
testq %rsi, %rsi
je 0x50c5
movq %rcx, %rdx
xorl %edi, %edi
cmpl %eax, 0x20(%rsi)
setl %dil
cmovgeq %rsi, %rdx
movq 0x10(%rsi,%rdi,8), %rsi
testq %rsi, %rsi
jne 0x50ae
movq %rcx, %rsi
cmpq %rcx, %rdx
je 0x50d7
cmpl %eax, 0x20(%rdx)
cmovgq %rcx, %rdx
movq %rdx, %rsi
cmpq %rcx, %rsi
je 0x511a
cmpq $0x0, 0x60(%rbx)
je 0x5107
movl $0x1, %ebp
xorl %esi, %esi
addq 0x68(%rbx), %rsi
movq %r14, %rdi
callq 0x4270
movl %eax, %edi
callq 0x2230
movl %ebp, %esi
incl %ebp
cmpq %rsi, 0x60(%rbx)
ja 0x50ea
movq 0x5eba(%rip), %rax      # 0xafc8
movq (%rax), %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x21d0
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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:
cmpq $0x0, 0x68(%rsi)
je 0x51b7
pushq %r15
pushq %r14
pushq %rbx
subq $0x80, %rsp
movq %rcx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x6132(%rip), %rdi      # 0xb278
callq 0x3d88
testl %eax, %eax
je 0x51ab
cmpq $0x0, 0x118(%r14)
je 0x51ab
movq 0x68(%r15), %rdx
movq %rsp, %rsi
movq %r14, %rdi
movl $0x80, %ecx
callq 0x4332
movq 0x108(%r14), %rax
addq $0xf8, %r14
cmpq %r14, %rax
je 0x51ab
movl 0x20(%rax), %ecx
leal 0x3f(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0x6, %edx
movslq %edx, %rdx
movq (%rsp,%rdx,8), %rdx
btq %rcx, %rdx
jb 0x51a5
movq %rax, %rdi
callq 0x21c0
jmp 0x517b
movl $0x1, (%rbx)
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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:
cmpq $0x0, 0x68(%rsi)
je 0x548b
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rsi, %r12
movq %rdi, %r14
leaq 0x5ec1(%rip), %rdi      # 0xb278
callq 0x3d88
testl %eax, %eax
je 0x547d
cmpq $0x0, 0x118(%r14)
je 0x547d
movq %rsp, %r13
movq 0x68(%r12), %rax
movq %rsp, %r15
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq 0x70(%r12), %rdx
movl 0x68(%r12), %ecx
shll $0x3, %ecx
movq %r14, %rdi
movq %r15, %rsi
callq 0x4332
movq 0x68(%r12), %rax
testq %rax, %rax
je 0x547a
movq 0x100(%r14), %rcx
addq $0xf8, %r14
xorl %edx, %edx
movl (%r15,%rdx,8), %esi
movq %r14, %rdi
testq %rcx, %rcx
je 0x544c
movq %rcx, %r8
movq %r14, %rdi
xorl %r9d, %r9d
cmpl %esi, 0x20(%r8)
setl %r9b
cmovgeq %r8, %rdi
movq 0x10(%r8,%r9,8), %r8
testq %r8, %r8
jne 0x5433
movq %r14, %r8
cmpq %r14, %rdi
je 0x545e
cmpl %esi, 0x20(%rdi)
cmovgq %r14, %rdi
movq %rdi, %r8
cmpq %r14, %r8
je 0x546b
testb $0x1, 0x4(%r15,%rdx,8)
jne 0x5474
incl %edx
cmpq %rdx, %rax
ja 0x5421
jmp 0x547a
movl $0x1, (%rbx)
movq %r13, %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq $0x0, 0x50(%rsi)
cmpq $0x0, 0x68(%rsi)
je 0x5597
movq %rsi, %r15
movq %rdi, %r14
leaq 0x5dbb(%rip), %rdi      # 0xb278
callq 0x3d88
testl %eax, %eax
je 0x5597
movq %rsp, %r13
movq 0x68(%r15), %rax
movq %rsp, %r12
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movq 0x70(%r15), %rdx
movl 0x68(%r15), %ecx
shll $0x3, %ecx
movq %r14, %rdi
movq %r12, %rsi
callq 0x4332
movq 0x68(%r15), %rcx
testq %rcx, %rcx
je 0x5582
movq 0x50(%r15), %rax
movq 0x100(%r14), %rdx
leaq 0xf8(%r14), %rsi
xorl %edi, %edi
movw $0x0, 0x6(%r12,%rdi,8)
movl (%r12,%rdi,8), %r8d
movq %rsi, %r9
testq %rdx, %rdx
je 0x554c
movq %rdx, %r10
movq %rsi, %r9
xorl %r11d, %r11d
cmpl %r8d, 0x20(%r10)
setl %r11b
cmovgeq %r10, %r9
movq 0x10(%r10,%r11,8), %r10
testq %r10, %r10
jne 0x5533
movq %rsi, %r10
cmpq %rsi, %r9
je 0x555f
cmpl %r8d, 0x20(%r9)
cmovgq %rsi, %r9
movq %r9, %r10
cmpq %rsi, %r10
je 0x557b
testb $0x1, 0x4(%r12,%rdi,8)
je 0x557b
movw $0x1, 0x6(%r12,%rdi,8)
incq %rax
movq %rax, 0x50(%r15)
incl %edi
cmpq %rdi, %rcx
ja 0x5519
movq 0x70(%r15), %rsi
shll $0x3, %ecx
movq %r14, %rdi
movq %r12, %rdx
callq 0x4404
movq %r13, %rsp
movl $0x1, (%rbx)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
cmpl $-0x1, 0x50(%rsi)
je 0x55ec
movq %rdi, %rbx
movq 0x80(%rdi), %rsi
cmpq %rsi, 0x88(%rdi)
jne 0x55ee
popq %rbx
retq
movq %rbx, %rdi
callq 0x45e4
movl 0x80(%rbx), %edx
movl 0x88(%rbx), %esi
movq %rbx, %rdi
popq %rbx
jmp 0x4732
// File: /workspace/github_cpp_makefile_star2_O1/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:
testb $-0x80, 0x53(%rsi)
jne 0x573f
pushq %r15
pushq %r14
pushq %rbx
subq $0x80, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x88(%rdi), %rdx
leaq 0x10(%rsp), %r15
movq %r15, %rsi
movl $0x64, %ecx
callq 0x44f4
movb $0x0, 0x64(%r15)
movq (%r15), %rax
movabsq $0x7374702f7665642f, %rcx # imm = 0x7374702F7665642F
xorq %rax, %rcx
movzbl 0x8(%r15), %edx
xorq $0x2f, %rdx
orq %rcx, %rdx
je 0x56ca
movabsq $0x7974742f7665642f, %rcx # imm = 0x7974742F7665642F
cmpq %rcx, %rax
jne 0x5733
testb $0x1, 0x80(%rbx)
jne 0x56ea
leaq 0xf0(%rbx), %rdi
movl 0x50(%r14), %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
callq 0x4c16
movq 0x80(%rbx), %rax
andl $0x3, %eax
decq %rax
cmpq $0x1, %rax
ja 0x5733
leaq 0x120(%rbx), %rdi
movl 0x50(%r14), %eax
leaq 0xc(%rsp), %r15
movl %eax, (%r15)
movq %r15, %rsi
callq 0x4c16
addq $0x150, %rbx            # imm = 0x150
movl 0x50(%r14), %eax
movl %eax, (%r15)
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0x4c16
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
leaq -0x7c2(%rip), %rsi      # 0x5041
movl $0x1, %edi
callq 0x4dd0
leaq -0x8d6(%rip), %rsi      # 0x4f3e
xorl %edi, %edi
callq 0x4dd0
leaq -0x86f(%rip), %rsi      # 0x4fb3
xorl %edi, %edi
callq 0x4e22
leaq -0x711(%rip), %rbx      # 0x511f
movl $0x17, %edi
movq %rbx, %rsi
callq 0x4dd0
leaq -0x68c(%rip), %r14      # 0x51b8
movl $0x17, %edi
movq %r14, %rsi
callq 0x4e22
movl $0x10e, %edi            # imm = 0x10E
movq %rbx, %rsi
callq 0x4dd0
movl $0x10e, %edi            # imm = 0x10E
movq %r14, %rsi
callq 0x4e22
leaq -0x4e4(%rip), %rsi      # 0x538e
movl $0x7, %edi
callq 0x4dd0
leaq -0x3f7(%rip), %rsi      # 0x548c
movl $0x7, %edi
callq 0x4e22
leaq -0x2e8(%rip), %rsi      # 0x55ac
movl $0x3, %edi
callq 0x4e74
leaq -0x2e7(%rip), %rsi      # 0x55be
movl $0x20, %edi
callq 0x4e74
leaq -0x2e4(%rip), %rsi      # 0x55d2
movl $0x21, %edi
callq 0x4e74
leaq -0x2bc(%rip), %rsi      # 0x560b
movl $0x124, %edi            # imm = 0x124
callq 0x4e74
leaq -0x2a2(%rip), %rsi      # 0x5636
movl $0x48, %edi
callq 0x4e74
leaq -0x286(%rip), %rsi      # 0x5663
movl $0x2, %edi
callq 0x4e74
leaq -0x1ba(%rip), %rsi      # 0x5740
movl $0x10, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4e74
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r14
pushq %rbx
subq $0x10, %rsp
callq 0x121e
leaq 0x2991(%rip), %rax      # 0x3d58
leaq -0x20(%rbp), %rbx
movq %rax, (%rbx)
leaq 0x29bb(%rip), %rax      # 0x3d90
leaq -0x18(%rbp), %r14
movq %rax, (%r14)
callq 0x11cc
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
callq 0x1362
callq 0x121e
callq 0x12be
callq 0x121e
callq 0x12be
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rbx
subq $0x18, %rsp
leaq 0x1dd8(%rip), %rdi      # 0x3004
xorl %eax, %eax
callq 0x1030
movl $0x40, %edi
callq 0x1080
movq %rax, %rbx
movq %rax, %rdi
callq 0x12a0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x30(%rax)
xorps %xmm0, %xmm0
leaq -0x20(%rbp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movl $0x1, 0x14(%rsi)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x28(%rax)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
nop