LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/elf.c
// Function: parseElf
void parseElf(FILE* fp, long fileSize) {

    // ELF Header
    unsigned char* buffer = (unsigned char*)malloc(0x05);
    fread(buffer, sizeof(unsigned char), 0x05, fp);

    if (buffer[4] == 1) {
        printf("Determined 32-bit.\n\n");
        if (fseek(fp, 0l, SEEK_SET) != 0) {
            printf("[ELF] Error seeking back to zero (parse).\n");
        }
        free(buffer);
        parseElf32(fp, fileSize);
    } else if (buffer[4] == 2) {
        printf("Determined 64-bit.\n");
        if (fseek(fp, 0l, SEEK_SET) != 0) {
            printf("[ELF] Error seeking back to zero (parse).\n");
        }
        free(buffer);
        parseElf64(fp, fileSize);
    } else {
        printf("Failed to determine 32-bit or 64-bit.\n");
        return;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x5, %edi
callq 0x10b0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x1, %esi
movl $0x5, %edx
callq 0x1040
movq -0x18(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x1, %eax
jne 0x127a
leaq 0xbdcb(%rip), %rdi      # 0xd004
movb $0x0, %al
callq 0x1050
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x10c0
cmpl $0x0, %eax
je 0x1262
leaq 0xbdbe(%rip), %rdi      # 0xd019
movb $0x0, %al
callq 0x1050
movq -0x18(%rbp), %rdi
callq 0x1030
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x12f0
jmp 0x12e1
movq -0x18(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x2, %eax
jne 0x12cf
leaq 0xbdb6(%rip), %rdi      # 0xd044
movb $0x0, %al
callq 0x1050
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x10c0
cmpl $0x0, %eax
je 0x12b7
leaq 0xbd69(%rip), %rdi      # 0xd019
movb $0x0, %al
callq 0x1050
movq -0x18(%rbp), %rdi
callq 0x1030
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2160
jmp 0x12df
leaq 0xbd82(%rip), %rdi      # 0xd058
movb $0x0, %al
callq 0x1050
jmp 0x12e1
jmp 0x12e1
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/elfstructs.c
// Function: printElfHeader32
void printElfHeader32(struct ELF_Header_32 header)
{
    printf("32-bit ELF Header:\n\
      \tei_mag =\t%c%c%c%c\n\
      \tei_class =\t%d\n\
      \tei_data =\t%d\n\
      \tei_version =\t%d\n\
      \tei_osabi =\t%d\n\
      \tei_abiversion =\t%d\n\
      \tei_pad =\t0\n\
      \te_type =\t%d\n\
      \te_machine =\t%d\n\
      \te_version =\t%d\n\
      \te_entry =\t0x%x\n\
      \te_phoff =\t0x%x\n\
      \te_shoff =\t0x%x\n\
      \te_flags =\t%d\n\
      \te_ehsize =\t%d\n\
      \te_phentsize =\t%d\n\
      \te_phnum =\t%d\n\
      \te_shentsize =\t%d\n\
      \te_shnum =\t%d\n\
      \te_shstrndx =\t%d\n",
      header.ei_mag[0], header.ei_mag[1], header.ei_mag[2],
      header.ei_mag[3], header.ei_class, header.ei_data,
      header.ei_version, header.ei_osabi, header.ei_abiversion,
      header.e_type, header.e_machine, header.e_version,
      header.e_entry, header.e_phoff, header.e_shoff, header.e_flags,
      header.e_ehsize, header.e_phentsize, header.e_phnum,
      header.e_shentsize, header.e_shnum, header.e_shstrndx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
leaq 0x10(%rbp), %rdi
movzbl (%rdi), %esi
movzbl 0x1(%rdi), %edx
movzbl 0x2(%rdi), %ecx
movzbl 0x3(%rdi), %r8d
movzbl 0x4(%rdi), %r9d
movzbl 0x5(%rdi), %eax
movzbl 0x6(%rdi), %r10d
movl %r10d, -0x4c(%rbp)
movzbl 0x7(%rdi), %r10d
movl %r10d, -0x48(%rbp)
movzbl 0x8(%rdi), %r10d
movl %r10d, -0x44(%rbp)
movzwl 0x10(%rdi), %r10d
movl %r10d, -0x40(%rbp)
movzwl 0x12(%rdi), %r10d
movl %r10d, -0x3c(%rbp)
movl 0x14(%rdi), %r10d
movl %r10d, -0x38(%rbp)
movl 0x18(%rdi), %r10d
movl %r10d, -0x34(%rbp)
movl 0x1c(%rdi), %r10d
movl %r10d, -0x30(%rbp)
movl 0x20(%rdi), %r13d
movl 0x24(%rdi), %r12d
movzwl 0x28(%rdi), %r15d
movzwl 0x2a(%rdi), %r14d
movzwl 0x2c(%rdi), %ebx
movzwl 0x2e(%rdi), %r11d
movzwl 0x30(%rdi), %r10d
movzwl 0x32(%rdi), %edi
movl %edi, -0x2c(%rbp)
leaq 0x9ece(%rip), %rdi      # 0xd2f2
movl %eax, (%rsp)
movl -0x4c(%rbp), %eax
movl %eax, 0x8(%rsp)
movl -0x48(%rbp), %eax
movl %eax, 0x10(%rsp)
movl -0x44(%rbp), %eax
movl %eax, 0x18(%rsp)
movl -0x40(%rbp), %eax
movl %eax, 0x20(%rsp)
movl -0x3c(%rbp), %eax
movl %eax, 0x28(%rsp)
movl -0x38(%rbp), %eax
movl %eax, 0x30(%rsp)
movl -0x34(%rbp), %eax
movl %eax, 0x38(%rsp)
movl -0x30(%rbp), %eax
movl %eax, 0x40(%rsp)
movl -0x2c(%rbp), %eax
movl %r13d, 0x48(%rsp)
movl %r12d, 0x50(%rsp)
movl %r15d, 0x58(%rsp)
movl %r14d, 0x60(%rsp)
movl %ebx, 0x68(%rsp)
movl %r11d, 0x70(%rsp)
movl %r10d, 0x78(%rsp)
movl %eax, 0x80(%rsp)
movb $0x0, %al
callq 0x1050
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/elfstructs.c
// Function: printElfHeader64
void printElfHeader64(struct ELF_Header_64 header)
{
    printf("64-bit ELF Header:\n\
        \tei_mag =\t%c%c%c%c\n\
        \tei_class =\t%d\n\
        \tei_data =\t%d\n\
        \tei_version =\t%d\n\
        \tei_osabi =\t%d\n\
        \tei_abiversion =\t%d\n\
        \tei_pad =\t0\n\
        \te_type =\t%d\n\
        \te_machine =\t%d\n\
        \te_version =\t%d\n\
        \te_entry =\t0x%llX\n\
        \te_phoff =\t0x%llX\n\
        \te_shoff =\t0x%llX\n\
        \te_flags =\t%d\n\
        \te_ehsize =\t%d\n\
        \te_phentsize =\t%d\n\
        \te_phnum =\t%d\n\
        \te_shentsize =\t%d\n\
        \te_shnum =\t%d\n\
        \te_shstrndx =\t%d\n",
        header.ei_mag[0], header.ei_mag[1], header.ei_mag[2],
        header.ei_mag[3], header.ei_class, header.ei_data,
        header.ei_version, header.ei_osabi, header.ei_abiversion,
        header.e_type, header.e_machine, header.e_version,
        header.e_entry, header.e_phoff, header.e_shoff, header.e_flags,
        header.e_ehsize, header.e_phentsize, header.e_phnum,
        header.e_shentsize, header.e_shnum, header.e_shstrndx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
leaq 0x10(%rbp), %rdi
movzbl (%rdi), %esi
movzbl 0x1(%rdi), %edx
movzbl 0x2(%rdi), %ecx
movzbl 0x3(%rdi), %r8d
movzbl 0x4(%rdi), %r9d
movzbl 0x5(%rdi), %eax
movzbl 0x6(%rdi), %r10d
movl %r10d, -0x58(%rbp)
movzbl 0x7(%rdi), %r10d
movl %r10d, -0x54(%rbp)
movzbl 0x8(%rdi), %r10d
movl %r10d, -0x50(%rbp)
movzwl 0x10(%rdi), %r10d
movl %r10d, -0x4c(%rbp)
movzwl 0x12(%rdi), %r10d
movl %r10d, -0x48(%rbp)
movl 0x14(%rdi), %r10d
movl %r10d, -0x44(%rbp)
movq 0x18(%rdi), %r10
movq %r10, -0x40(%rbp)
movq 0x20(%rdi), %r10
movq %r10, -0x38(%rbp)
movq 0x28(%rdi), %r13
movl 0x30(%rdi), %r12d
movzwl 0x34(%rdi), %r15d
movzwl 0x36(%rdi), %r14d
movzwl 0x38(%rdi), %ebx
movzwl 0x3a(%rdi), %r11d
movzwl 0x3c(%rdi), %r10d
movzwl 0x3e(%rdi), %edi
movl %edi, -0x2c(%rbp)
leaq 0x9f65(%rip), %rdi      # 0xd4b9
movl %eax, (%rsp)
movl -0x58(%rbp), %eax
movl %eax, 0x8(%rsp)
movl -0x54(%rbp), %eax
movl %eax, 0x10(%rsp)
movl -0x50(%rbp), %eax
movl %eax, 0x18(%rsp)
movl -0x4c(%rbp), %eax
movl %eax, 0x20(%rsp)
movl -0x48(%rbp), %eax
movl %eax, 0x28(%rsp)
movl -0x44(%rbp), %eax
movl %eax, 0x30(%rsp)
movq -0x40(%rbp), %rax
movq %rax, 0x38(%rsp)
movq -0x38(%rbp), %rax
movq %rax, 0x40(%rsp)
movl -0x2c(%rbp), %eax
movq %r13, 0x48(%rsp)
movl %r12d, 0x50(%rsp)
movl %r15d, 0x58(%rsp)
movl %r14d, 0x60(%rsp)
movl %ebx, 0x68(%rsp)
movl %r11d, 0x70(%rsp)
movl %r10d, 0x78(%rsp)
movl %eax, 0x80(%rsp)
movb $0x0, %al
callq 0x1050
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/elfstructs.c
// Function: printProgramHeader32
void printProgramHeader32(struct Program_Header_32 header)
{
    printf("Program Header:\n\
        \tp_type =\t0x%X\n\
        \tp_offset =\t0x%X\n\
        \tp_vaddr =\t0x%X\n\
        \tp_paddr =\t0x%X\n\
        \tp_filesz =\t0x%X\n\
        \tp_memsz =\t0x%X\n\
        \tp_flags =\t0x%X\n\
        \tp_align =\t0x%X\n",
        header.p_type, header.p_offset, header.p_vaddr,
        header.p_paddr, header.p_filesz, header.p_memsz,
        header.p_flags, header.p_align);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0x10(%rbp), %rax
movl (%rax), %esi
movl 0x4(%rax), %edx
movl 0x8(%rax), %ecx
movl 0xc(%rax), %r8d
movl 0x10(%rax), %r9d
movl 0x14(%rax), %r11d
movl 0x18(%rax), %r10d
movl 0x1c(%rax), %eax
leaq 0xa0a0(%rip), %rdi      # 0xd6ae
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x1050
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/elfstructs.c
// Function: printProgramHeader64
void printProgramHeader64(struct Program_Header_64 header)
{
    printf("Program Header:\n\
        \tp_type =\t0x%X\n\
        \tp_offset =\t0x%llX\n\
        \tp_vaddr =\t0x%llX\n\
        \tp_paddr =\t0x%llX\n\
        \tp_filesz =\t0x%llX\n\
        \tp_memsz =\t0x%llX\n\
        \tp_flags =\t0x%X\n\
        \tp_align =\t0x%llX\n",
        header.p_type, header.p_offset, header.p_vaddr,
        header.p_paddr, header.p_filesz, header.p_memsz,
        header.p_flags, header.p_align);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0x10(%rbp), %rax
movl (%rax), %esi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x18(%rax), %r8
movq 0x20(%rax), %r9
movq 0x28(%rax), %r11
movl 0x4(%rax), %r10d
movq 0x30(%rax), %rax
leaq 0xa11f(%rip), %rdi      # 0xd780
movq %r11, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x1050
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/elfstructs.c
// Function: printSectionHeader32
void printSectionHeader32(struct Section_Header_32 header,
    char* shstrtab)
{
    if (!shstrtab) {
        printf("Section Header:\n\
            \tsh_name(off.) =\t0x%X\n", header.sh_name);
    } else {
        // TODO: This behavior may be risky
        printf("Section Header:\n\
            \tsh_name =\t");
        int i;
        for (i = 0; shstrtab[header.sh_name+i] != '\0'; i++) {
            printf("%c", shstrtab[header.sh_name+i]);
        }
        printf("\n");
    }

    printf("\
        \tsh_type =\t0x%X\n\
        \tsh_flags =\t0x%X\n\
        \tsh_address =\t0x%X\n\
        \tsh_offset =\t0x%X\n\
        \tsh_size =\t0x%X\n\
        \tsh_link =\t0x%X\n\
        \tsh_info =\t0x%X\n\
        \tsh_addralign =\t0x%X\n\
        \tsh_entsize =\t0x%X\n",
        header.sh_type, header.sh_flags, header.sh_address,
        header.sh_offset, header.sh_size, header.sh_link, header.sh_info,
        header.sh_addralign, header.sh_entsize);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x38, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x36b2
movq -0x20(%rbp), %rax
movl (%rax), %esi
leaq 0xa1b5(%rip), %rdi      # 0xd85e
movb $0x0, %al
callq 0x1050
jmp 0x3719
leaq 0xa1d8(%rip), %rdi      # 0xd891
movb $0x0, %al
callq 0x1050
movl $0x0, -0x14(%rbp)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movl (%rcx), %ecx
addl -0x14(%rbp), %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x370b
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movl (%rcx), %ecx
addl -0x14(%rbp), %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %esi
leaq 0xa1c0(%rip), %rdi      # 0xd8b9
movb $0x0, %al
callq 0x1050
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x36c7
leaq 0xb83a(%rip), %rdi      # 0xef4c
movb $0x0, %al
callq 0x1050
movq -0x20(%rbp), %rax
movl 0x4(%rax), %esi
movl 0x8(%rax), %edx
movl 0xc(%rax), %ecx
movl 0x10(%rax), %r8d
movl 0x14(%rax), %r9d
movl 0x18(%rax), %ebx
movl 0x1c(%rax), %r11d
movl 0x20(%rax), %r10d
movl 0x24(%rax), %eax
leaq 0xa179(%rip), %rdi      # 0xd8bc
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x1050
addq $0x38, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/elfstructs.c
// Function: printSectionHeader64
void printSectionHeader64(struct Section_Header_64 header,
    char* shstrtab)
{
    if (!shstrtab) {
        printf("Section Header:\n\
            \tsh_name(off.) =\t0x%X\n", header.sh_name);
    } else {
        // TODO: This behavior may be risky
        printf("Section Header:\n\
            \tsh_name =\t");
        int i;
        for (i = 0; shstrtab[header.sh_name+i] != '\0'; i++) {
            printf("%c", shstrtab[header.sh_name+i]);
        }
        printf("\n");
    }

    printf("\
        \tsh_type =\t0x%X\n\
        \tsh_flags =\t0x%llX\n\
        \tsh_address =\t0x%llX\n\
        \tsh_offset =\t0x%llX\n\
        \tsh_size =\t0x%llX\n\
        \tsh_link =\t0x%X\n\
        \tsh_info =\t0x%X\n\
        \tsh_addralign =\t0x%llX\n\
        \tsh_entsize =\t0x%llX\n",
        header.sh_type, header.sh_flags, header.sh_address,
        header.sh_offset, header.sh_size, header.sh_link, header.sh_info,
        header.sh_addralign, header.sh_entsize);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x38, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x37a2
movq -0x20(%rbp), %rax
movl (%rax), %esi
leaq 0xa0c5(%rip), %rdi      # 0xd85e
movb $0x0, %al
callq 0x1050
jmp 0x3809
leaq 0xa0e8(%rip), %rdi      # 0xd891
movb $0x0, %al
callq 0x1050
movl $0x0, -0x14(%rbp)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movl (%rcx), %ecx
addl -0x14(%rbp), %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x37fb
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movl (%rcx), %ecx
addl -0x14(%rbp), %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %esi
leaq 0xa0d0(%rip), %rdi      # 0xd8b9
movb $0x0, %al
callq 0x1050
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x37b7
leaq 0xb74a(%rip), %rdi      # 0xef4c
movb $0x0, %al
callq 0x1050
movq -0x20(%rbp), %rax
movl 0x4(%rax), %esi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x18(%rax), %r8
movq 0x20(%rax), %r9
movl 0x28(%rax), %ebx
movl 0x2c(%rax), %r11d
movq 0x30(%rax), %r10
movq 0x38(%rax), %rax
leaq 0xa16d(%rip), %rdi      # 0xd9a3
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x1050
addq $0x38, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/pestructs.c
// Function: printDOSHeader
void printDOSHeader(struct DOS_Header header)
{
    printf("DOS Header:\n\
      \tsignature =\t%s\n\
      \tlastsize =\t0x%X\n\
      \tnblocks =\t0x%X\n\
      \tnreloc =\t0x%X\n\
      \thdrsize =\t0x%X\n\
      \tminalloc =\t0x%X\n\
      \tmaxalloc =\t0%X\n\
      \tss =\t[not implemented]\n\
      \tsp =\t[not implemented]\n\
      \tchecksum =\t0x%X\n\
      \tip =\t[not implemented]\n\
      \tcs =\t[not implemented]\n\
      \trelocpos =\t0x%X\n\
      \tnoverlay =\t0x%X\n\
      \treserved1 =\t0\n\
      \toem_id =\t0x%X\n\
      \toem_info =\t0x%X\n\
      \treserved2 =\t0\n\
      \te_lfanew =\t0x%X\n",
      header.signature, header.lastsize, header.nblocks,
      header.nreloc, header.hdrsize, header.minalloc,
      header.maxalloc, header.checksum, header.relocpos,
      header.noverlay, header.oem_id, header.oem_info,
      header.e_lfanew);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
leaq 0x10(%rbp), %rax
movq (%rax), %rsi
movswl 0x8(%rax), %edx
movswl 0xa(%rax), %ecx
movswl 0xc(%rax), %r8d
movswl 0xe(%rax), %r9d
movswl 0x10(%rax), %r13d
movswl 0x12(%rax), %r12d
movswl 0x28(%rax), %r15d
movswl 0x40(%rax), %r14d
movswl 0x42(%rax), %ebx
movswl 0x4c(%rax), %r11d
movswl 0x4e(%rax), %r10d
movl 0x64(%rax), %eax
leaq 0x8ca6(%rip), %rdi      # 0xdcdc
movl %r13d, (%rsp)
movl %r12d, 0x8(%rsp)
movl %r15d, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movl %ebx, 0x20(%rsp)
movl %r11d, 0x28(%rsp)
movl %r10d, 0x30(%rsp)
movl %eax, 0x38(%rsp)
movb $0x0, %al
callq 0x1050
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/pestructs.c
// Function: printCOFFHeader
void printCOFFHeader(struct COFFHeader header)
{
    printf("COFF Header:\n\
      \tMachine \t\t= 0x%X\n\
      \tNumberOfSections \t= %d\n\
      \tTimeDateStamp \t\t= 0x%X\n\
      \tPointerToSymbolTable \t= 0x%X\n\
      \tNumberOfSymbols \t= 0x%X\n\
      \tSizeOfOptionalHeader \t= %d\n\
      \tCharacteristics \t= %d\n",
      header.Machine, header.NumberOfSections, header.TimeDateStamp,
      header.PointerToSymbolTable, header.NumberOfSymbols,
      header.SizeOfOptionalHeader,
      header.Characteristics);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x10(%rbp), %rax
movswl (%rax), %esi
movswl 0x2(%rax), %edx
movl 0x4(%rax), %ecx
movl 0x8(%rax), %r8d
movl 0xc(%rax), %r9d
movswl 0x10(%rax), %r10d
movswl 0x12(%rax), %eax
leaq 0x8e00(%rip), %rdi      # 0xdeae
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x1050
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/fileformat/pestructs.c
// Function: printFCSection
void printFCSection(struct FCSection section)
{
    printf("FCSection:\n\
      \tSectionName \t\t= %s\n\
      \tSectionSize \t\t= 0x%X\n\
      \tRVA \t\t\t= 0x%X\n\
      \tPhysicalSize \t\t= 0x%X\n\
      \tPhysicalLocation \t= 0x%X\n\
      \tReserved \t\t= 0x%X\n\
      \tSectionFlags \t\t= 0x%X\n",
      section.SectionName, section.SectionSize, section.RVA,
      section.PhysicalSize, section.PhysicalLocation, *section.Reserved,
      section.SectionFlags);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x10(%rbp), %rsi
movl 0x8(%rsi), %edx
movl 0xc(%rsi), %ecx
movl 0x10(%rsi), %r8d
movl 0x14(%rsi), %r9d
movl 0x18(%rsi), %r10d
movl 0x24(%rsi), %eax
leaq 0x90b7(%rip), %rdi      # 0xe3af
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x1050
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/main.c
// Function: printHexWithAscii
void printHexWithAscii(FILE* fp, long fileSize, unsigned int width) {
    printf("Offset\t 00 01 02 03  04 05 06 07  08 09 0A 0B  0C 0D 0E 0F\n");
    unsigned int dataRead = 0;

    int endOfFile = 0;
    while (!endOfFile) {
        unsigned char* buffer = (unsigned char*)malloc(width);
        if (fread(buffer, sizeof(unsigned char), width, fp) < width) {
            endOfFile = 1;
        }

        printf("%08X ", dataRead*width);
        int i;
        for (i = 0; i < width; i++) {
            printf("%02X ", buffer[i]);
            if (i==3 || i==7 || i==11) printf(" ");
        }
        printf(" ");

        for (i = 0; i < width; i++) {
            if (buffer[i] < 16) {
                printf(".");
            } else {
                printf("%c", buffer[i]);
            }
        }

        dataRead++;

        //if (dataRead == 128) break;

        printf("\n");
        free(buffer);
    }

    printf("\nFile read.\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq 0x2e45(%rip), %rdi      # 0xef7f
movb $0x0, %al
callq 0x1050
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xc161
jmp 0xc28a
movl -0x14(%rbp), %eax
movl %eax, %edi
callq 0x10b0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %edx
movq -0x8(%rbp), %rcx
movl $0x1, %esi
callq 0x1040
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jae 0xc195
movl $0x1, -0x1c(%rbp)
movl -0x18(%rbp), %esi
imull -0x14(%rbp), %esi
leaq 0x2e18(%rip), %rdi      # 0xefbb
movb $0x0, %al
callq 0x1050
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0xc200
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %esi
leaq 0x2b3b(%rip), %rdi      # 0xed07
movb $0x0, %al
callq 0x1050
cmpl $0x3, -0x2c(%rbp)
je 0xc1e5
cmpl $0x7, -0x2c(%rbp)
je 0xc1e5
cmpl $0xb, -0x2c(%rbp)
jne 0xc1f3
leaq 0x2b23(%rip), %rdi      # 0xed0f
movb $0x0, %al
callq 0x1050
jmp 0xc1f5
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xc1b1
leaq 0x2b08(%rip), %rdi      # 0xed0f
movb $0x0, %al
callq 0x1050
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0xc265
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x10, %eax
jge 0xc23e
leaq 0x2d8c(%rip), %rdi      # 0xefc1
movb $0x0, %al
callq 0x1050
jmp 0xc258
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %esi
leaq 0x1668(%rip), %rdi      # 0xd8b9
movb $0x0, %al
callq 0x1050
jmp 0xc25a
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xc215
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
leaq 0x2cd7(%rip), %rdi      # 0xef4c
movb $0x0, %al
callq 0x1050
movq -0x28(%rbp), %rdi
callq 0x1030
jmp 0xc14f
leaq 0x2ce1(%rip), %rdi      # 0xef72
movb $0x0, %al
callq 0x1050
addq $0x30, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/Jesskas[P]decompisas/source/main.c
// Function: parse
void parse(FILE* fp, long fileSize) {
    unsigned char* buffer = (unsigned char*)malloc(0x06);
    fread(buffer, sizeof(unsigned char), 0x06, fp);

    if (buffer[0] == 'M' && buffer[1] == 'Z') {
        if (fseek(fp, 0l, SEEK_SET) != 0) {
            printf("Error seeking back to zero (parse).\n");
        }
        free(buffer);
        printf("MS-DOS header detected, decompiling Win32 program.\n");
        parseWin32(fp, fileSize);
    } else if (buffer[0] == 0x7F && buffer[1] == 'E' &&
        buffer[2] == 'L' && buffer[3] == 'F') {
        if (fseek(fp, 0l, SEEK_SET) != 0) {
            printf("Error seeking back to zero (parse).\n");
        }
        free(buffer);
        printf("ELF header detected, decompiling ELF program.\n");
        parseElf(fp, fileSize);
    } else {
        free(buffer);
        printf("Could not detect type of executable. Is this binary?\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x6, %edi
callq 0x10b0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x1, %esi
movl $0x6, %edx
callq 0x1040
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x4d, %eax
jne 0xc339
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x5a, %eax
jne 0xc339
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x10c0
cmpl $0x0, %eax
je 0xc310
leaq 0xd16(%rip), %rdi       # 0xd01f
movb $0x0, %al
callq 0x1050
movq -0x18(%rbp), %rdi
callq 0x1030
leaq 0x2ca3(%rip), %rdi      # 0xefc3
movb $0x0, %al
callq 0x1050
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3860
jmp 0xc3cd
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x7f, %eax
jne 0xc3b4
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x45, %eax
jne 0xc3b4
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x4c, %eax
jne 0xc3b4
movq -0x18(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x46, %eax
jne 0xc3b4
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x10c0
cmpl $0x0, %eax
je 0xc38e
leaq 0xc98(%rip), %rdi       # 0xd01f
movb $0x0, %al
callq 0x1050
movq -0x18(%rbp), %rdi
callq 0x1030
leaq 0x2c59(%rip), %rdi      # 0xeff7
movb $0x0, %al
callq 0x1050
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x11f0
jmp 0xc3cb
movq -0x18(%rbp), %rdi
callq 0x1030
leaq 0x2c62(%rip), %rdi      # 0xf026
movb $0x0, %al
callq 0x1050
jmp 0xc3cd
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/./utils.h
// Function: ppl_node_unlink
void ppl_node_unlink(struct ppl_list_node * node){
    struct ppl_list_node * FD = node->fd;
    struct ppl_list_node * BK = node->bk;
    BK->fd = FD;
    FD->bk = BK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/./utils.h
// Function: list_insert
void list_insert(struct ppl_list_node * head,  struct ppl_list_node * node){
    struct ppl_list_node * FD = head->fd;
    //struct ppl_list_node * BK = head->bk;
    head->fd = node;
    node->fd = FD;
    node->bk = head;
    FD->bk = node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/./utils.h
// Function: recv_until
int recv_until(char* buf,int size,char end){
    char tmp;
    int i;
    for(i=0;i<size;i++){
        read(0,&tmp,1);
        if(tmp==end){
            break;
        }
        buf[i]=tmp;
    }
    buf[i+1]=='\x00';
    return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movb %al, -0xd(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x141a
xorl %edi, %edi
leaq -0xe(%rbp), %rsi
movl $0x1, %edx
callq 0x1120
movsbl -0xe(%rbp), %eax
movsbl -0xd(%rbp), %ecx
cmpl %ecx, %eax
jne 0x1401
jmp 0x141a
movb -0xe(%rbp), %dl
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x13db
movl -0x14(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: elf_executor_free
void elf_executor_free(struct executor_queue* eq){
    short buffer_size=0;
    free(eq);
    ppl_node_unlink(&eq->list);
    puts("feedback?");
    read(0, &buffer_size, 2);
    char *buffer = malloc((unsigned int)buffer_size);
    read(0, buffer, buffer_size);
    puts("thanks for the feedback, we will definitely read it");
    free(buffer);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movw $0x0, -0xa(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1030
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
callq 0x1330
leaq 0x5069(%rip), %rdi      # 0x64c8
callq 0x1070
xorl %edi, %edi
leaq -0xa(%rbp), %rsi
movl $0x2, %edx
callq 0x1120
movswl -0xa(%rbp), %eax
movl %eax, %eax
movl %eax, %edi
callq 0x1170
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rsi
movswq -0xa(%rbp), %rdx
xorl %edi, %edi
callq 0x1120
leaq 0x5036(%rip), %rdi      # 0x64d2
callq 0x1070
movq -0x18(%rbp), %rdi
callq 0x1030
addq $0x20, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: elf_push_elem
int elf_push_elem(struct executor_queue* eq, void* value){
    void * dst;
    dst = &eq->elements[eq->head * eq->value_size];
    memcpy(dst, value, eq->value_size);
    if(++eq->head > eq->max_queue_entries){
        eq->head = 0;
    }
#ifdef DEBUG
    printf("succesfully pushed new element of %d bytes to: %p \n", eq->value_size, dst);
#endif
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x38, %rax
movq -0x8(%rbp), %rcx
movl 0x18(%rcx), %ecx
movq -0x8(%rbp), %rdx
imull 0x14(%rdx), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, %edx
callq 0x1160
movq -0x8(%rbp), %rcx
movl 0x18(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x18(%rcx)
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jbe 0x1517
movq -0x8(%rbp), %rax
movl $0x0, 0x18(%rax)
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: elf_pop_elem
int elf_pop_elem(struct executor_queue* eq, void* value){
    if(eq->head==0){
        return -1 ;
    }
    eq->head -= 1;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x153f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1553
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
subl $0x1, %ecx
movl %ecx, 0x18(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: elf_get_elem
int elf_get_elem(struct executor_queue* eq, void* value){
    if(eq->tail == eq->head){
        return -1;
    }
    memcpy(value, (char*)eq->elements + eq->tail * eq->value_size, eq->value_size);
    //eq->tail += 1;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x1589
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x15be
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x38, %rsi
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x14(%rcx), %eax
movl %eax, %eax
addq %rax, %rsi
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, %edx
callq 0x1160
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: elf_check_patch
int elf_check_patch(struct executor_queue* eq, void* value){
    // get different size
    int i;
    int diff = 0;
    int fail = 0;
    char* pv = (char*)value; // patched version

    for(i = 0; i < elf_unpatched_size; i++){
        if(pv[i] != elf_unpatched[i]){
            diff++;
        }
        if(diff > 0x100){
            break;
        }
    }

#ifdef DEBUG
    printf("diff: %d\n",diff);
#endif
    if(diff > 0x100){
        fail = 1;
    }

    // check elf header        
    // todo
    ELF64_FileRef file;
    ELF64_HeaderRef header;
    file = ELF64_ReadFromData(pv);
    header = ELF64_FileGetHeader(file);
    if( ELF64_FileIsValid(file) == false){
        puts("bad elf :(");
        fail = 1;
    }
    dump_program_header_entry(file, header);
    if(fail){
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x8bfe(%rip), %eax      # 0xa204
jae 0x1648
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movq 0x8bed(%rip), %rcx      # 0xa208
movslq -0x1c(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x1630
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x100, -0x20(%rbp)     # imm = 0x100
jle 0x163b
jmp 0x1648
jmp 0x163d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x15fd
cmpl $0x100, -0x20(%rbp)     # imm = 0x100
jle 0x1658
movl $0x1, -0x24(%rbp)
movq -0x30(%rbp), %rdi
callq 0x38c0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3930
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x38d0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x1698
leaq 0x4dea(%rip), %rdi      # 0x6476
callq 0x1070
movl $0x1, -0x24(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1970
cmpl $0x0, -0x24(%rbp)
je 0x16b4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x16bb
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: safe_read
int safe_read(int fd, char* buffer, unsigned int size){
    int total, tmp;
    total = 0;
    tmp = 0;
    while(total < size){
        tmp = read(fd, buffer+total,size-total);
        if(tmp<0){
            exit(0);
        }
        total+=tmp;
        if(total==size){
            break;
        }
    }
    return total;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x195a
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movslq -0x18(%rbp), %rax
addq %rax, %rsi
movl -0x14(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1120
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x1945
xorl %edi, %edi
callq 0x11d0
movl -0x1c(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x1958
jmp 0x195a
jmp 0x1910
movl -0x18(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: rand_str
void rand_str(char *dest, unsigned char* seed, unsigned int size){
    int i;
    unsigned char index;
    for(i=0; i < size; i++){
        index = seed[i] % 62;
#ifdef DEBUG
        //printf("%d,%c ",index, charset[index]);
#endif
        dest[i] = charset[index];
    }
    dest[size]='\x00';
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x1c4d
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl $0x3e, %ecx
cltd
idivl %ecx
movb %dl, %al
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
movl %eax, %ecx
leaq 0x443c(%rip), %rax      # 0x6070
movb (%rax,%rcx), %dl
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1c06
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movb $0x0, (%rax,%rcx)
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: check_patch_attr
int check_patch_attr(struct patch_attr* attr){

    /* check the whether these arguments are valid */

    if(attr->queue_type > BRAINFUCK_EXECUTOR){
        return -2;
    }

    if(attr->value_size > 0x100000){
        return -1;
    }

    if(total_ppl > 3)
    {
        printf("too many:(\n");
        return -3;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jbe 0x1c7e
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1cbb
movq -0x10(%rbp), %rax
cmpl $0x100000, 0x8(%rax)    # imm = 0x100000
jbe 0x1c94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1cbb
cmpl $0x3, 0x8575(%rip)      # 0xa210
jbe 0x1cb4
leaq 0x4862(%rip), %rdi      # 0x6506
movb $0x0, %al
callq 0x10e0
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x1cbb
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: init_executor_queue
void init_executor_queue(struct executor_queue* eq, struct patch_attr *attr){
    eq->queue_type = attr->queue_type;
    eq->max_queue_entries = attr->max_queue_entries;
    eq->value_size = attr->value_size;
    eq->executor_idx = global_executor_idx;
    eq->head = 0;
    eq->tail = 0;
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x14(%rax)
movl 0x84f5(%rip), %ecx      # 0xa200
movq -0x8(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x1c(%rax)
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: safe_read_flag
unsigned int* safe_read_flag()
{
    flag_fp = fopen(FLAGPATH,"rb");
	if(flag_fp<0){
		perror("fopen");
		exit(1);
	}
	unsigned int *p = (unsigned int *)sha3_hash;
	sha3_ctx ctx;
	memset(sha3_hash,0,65);
	fread(flag, FLAGLENGTH, 1, flag_fp);
	flag[FLAGLENGTH]='\x00';
#ifdef DEBUG
	printf("%s\n",flag);
#endif
	rhash_sha3_256_init(&ctx);
	rhash_sha3_update(&ctx, (const unsigned char*)flag, FLAGLENGTH);
	rhash_sha3_final(&ctx,(unsigned char*)sha3_hash);
	printf("sha3 of flag: %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);

	memset(flag,0,FLAGLENGTH);
    return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
leaq 0x47d0(%rip), %rdi      # 0x6512
leaq 0x47dd(%rip), %rsi      # 0x6526
callq 0x11a0
movq %rax, 0x84c3(%rip)      # 0xa218
cmpq $0x0, 0x84bb(%rip)      # 0xa218
jae 0x1d75
leaq 0x473d(%rip), %rdi      # 0x64a3
callq 0x11b0
movl $0x1, %edi
callq 0x11d0
leaq 0x84a4(%rip), %rax      # 0xa220
movq %rax, -0x8(%rbp)
leaq 0x8499(%rip), %rdi      # 0xa220
xorl %esi, %esi
movl $0x41, %edx
callq 0x1100
movq 0x847e(%rip), %rcx      # 0xa218
leaq 0x84cf(%rip), %rdi      # 0xa270
movl $0x4f, %esi
movl $0x1, %edx
callq 0x1080
movb $0x0, 0x8508(%rip)      # 0xa2bf
leaq -0x198(%rbp), %rdi
callq 0x2b00
leaq -0x198(%rbp), %rdi
leaq 0x849f(%rip), %rsi      # 0xa270
movl $0x4f, %edx
callq 0x2b60
leaq -0x198(%rbp), %rdi
leaq 0x8437(%rip), %rsi      # 0xa220
callq 0x2ed0
movq -0x8(%rbp), %rax
movl (%rax), %esi
movq -0x8(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movl 0xc(%rax), %r8d
movq -0x8(%rbp), %rax
movl 0x10(%rax), %r9d
movq -0x8(%rbp), %rax
movl 0x14(%rax), %r11d
movq -0x8(%rbp), %rax
movl 0x18(%rax), %r10d
movq -0x8(%rbp), %rax
movl 0x1c(%rax), %eax
leaq 0x46f9(%rip), %rdi      # 0x6529
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x10e0
leaq 0x8425(%rip), %rdi      # 0xa270
xorl %esi, %esi
movl $0x4f, %edx
callq 0x1100
movq -0x8(%rbp), %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: print_options
void print_options(){
    puts("[u] upload patches");
    puts("[c] complain");
    puts("[a] add patch pipeline");
    puts("[s] swap a patch");
    puts("[e] exit");
    puts("[r] run patches");
    puts("[d] remove a pipeline");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x47ec(%rip), %rdi      # 0x6687
callq 0x1070
leaq 0x47f3(%rip), %rdi      # 0x669a
callq 0x1070
leaq 0x47f4(%rip), %rdi      # 0x66a7
callq 0x1070
leaq 0x47ff(%rip), %rdi      # 0x66be
callq 0x1070
leaq 0x4804(%rip), %rdi      # 0x66cf
callq 0x1070
leaq 0x4801(%rip), %rdi      # 0x66d8
callq 0x1070
leaq 0x4805(%rip), %rdi      # 0x66e8
callq 0x1070
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: read_original_program
void read_original_program(){
    struct stat st;
    elf_unpatched=NULL;
    py_unpatched=NULL;
    int elfsize = 0;
    int ret = stat(ELF_PROGRAM_NAME, &st);
    if(ret<0){
        puts("elf file not exist");
        exit(0);
    }

    elfsize = st.st_size; 
    elf_unpatched_size = elfsize;
    FILE *fp = fopen(ELF_PROGRAM_NAME, "rb");
    elf_unpatched = malloc(elfsize);
    fread(elf_unpatched, 1, elfsize , fp);
    fclose(fp);
#ifdef DEBUG
    printf("%d, %s\n",elfsize, elf_unpatched);
#endif
    return; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq $0x0, 0x8302(%rip) # 0xa208
movq $0x0, 0x83af(%rip) # 0xa2c0
movl $0x0, -0x94(%rbp)
leaq 0x47dc(%rip), %rdi      # 0x66fe
leaq -0x90(%rbp), %rsi
callq 0x1150
movl %eax, -0x98(%rbp)
cmpl $0x0, -0x98(%rbp)
jge 0x1f50
leaq 0x47cf(%rip), %rdi      # 0x6713
callq 0x1070
xorl %edi, %edi
callq 0x11d0
movq -0x60(%rbp), %rax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, 0x829e(%rip)      # 0xa204
leaq 0x4791(%rip), %rdi      # 0x66fe
leaq 0x45b2(%rip), %rsi      # 0x6526
callq 0x11a0
movq %rax, -0xa0(%rbp)
movslq -0x94(%rbp), %rdi
callq 0x1170
movq %rax, 0x8275(%rip)      # 0xa208
movq 0x826e(%rip), %rdi      # 0xa208
movslq -0x94(%rbp), %rdx
movq -0xa0(%rbp), %rcx
movl $0x1, %esi
callq 0x1080
movq -0xa0(%rbp), %rdi
callq 0x10b0
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: add_complain
int add_complain(){
    char option_buffer[16];
    char *message;
    memset(option_buffer, 0, 16);
    puts("Anything to complain about your patch?");
    puts("1. My patch is checked down but it should work.");
    puts("2. My patch seems not effective against some team.") ;
    puts("3. other complains");
    recv_until(option_buffer, 16, '\n');
    switch(option_buffer[0]){
        case '1':
            puts("We have a checker to check the function of the target program, your patch should not change those basic behaviors, also we disallow too many change over the original program.");
            break;
        case '2':
            puts("Maybe they are attacking your service with a deeper vulnerability, come on bro");
            break;
        case '3':
            message = malloc(0x200);
            read(0,message,0x200);
            puts("thanks for the complain, we will get back to you in a second");
            sleep(1);
            if(strstr(message,"flag") > 0){
                printf("%s, Your complain looks reasonable, let us give you a stack overflow as reward :n\n",message);
                free(message);
                read(0, option_buffer, 0x200);
                exit(0);
            }
            break;
        default:
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, -0x20(%rbp)
leaq 0x4560(%rip), %rdi      # 0x6786
callq 0x1070
leaq 0x457b(%rip), %rdi      # 0x67ad
callq 0x1070
leaq 0x459f(%rip), %rdi      # 0x67dd
callq 0x1070
leaq 0x45c6(%rip), %rdi      # 0x6810
callq 0x1070
leaq -0x20(%rbp), %rdi
movl $0x10, %esi
movl $0xa, %edx
callq 0x13c0
movsbl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $0x31, %eax
je 0x2287
jmp 0x2270
movl -0x2c(%rbp), %eax
subl $0x32, %eax
je 0x2298
jmp 0x227a
movl -0x2c(%rbp), %eax
subl $0x33, %eax
je 0x22a9
jmp 0x2327
leaq 0x4595(%rip), %rdi      # 0x6823
callq 0x1070
jmp 0x2329
leaq 0x4633(%rip), %rdi      # 0x68d2
callq 0x1070
jmp 0x2329
movl $0x200, %edi            # imm = 0x200
callq 0x1170
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
xorl %edi, %edi
movl $0x200, %edx            # imm = 0x200
callq 0x1120
leaq 0x4653(%rip), %rdi      # 0x6921
callq 0x1070
movl $0x1, %edi
callq 0x11f0
movq -0x28(%rbp), %rdi
leaq 0x4676(%rip), %rsi      # 0x695e
callq 0x1220
cmpq $0x0, %rax
jbe 0x2325
movq -0x28(%rbp), %rsi
leaq 0x4665(%rip), %rdi      # 0x6963
movb $0x0, %al
callq 0x10e0
movq -0x28(%rbp), %rdi
callq 0x1030
leaq -0x20(%rbp), %rsi
xorl %edi, %edi
movl $0x200, %edx            # imm = 0x200
callq 0x1120
xorl %edi, %edi
callq 0x11d0
jmp 0x2329
jmp 0x2329
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: do_patch_pipeline_alloc
struct executor_queue * do_patch_pipeline_alloc(struct patch_attr* attr){
    unsigned int size, value_size; 
    unsigned long queue_size, cost;

    struct executor_queue * eq;
    size = attr->max_queue_entries + 1;
    value_size = attr->value_size;
    queue_size = sizeof(*eq) + (unsigned long) value_size * size;
    cost = queue_size + (0x1000 - (queue_size % 0x1000));
    if (cost >= 0x10000000){
        return NULL;
    }
    eq = malloc(queue_size);
    if(eq<0){
        return NULL;
    }
    eq->ops = &elf_executor_ops;
    init_executor_queue(eq, attr);
    eq->size = size;
    return eq;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl -0x14(%rbp), %ecx
imulq %rcx, %rax
addq $0x38, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x20(%rbp), %rdx
andq $0xfff, %rdx            # imm = 0xFFF
movl $0x1000, %ecx           # imm = 0x1000
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpq $0x10000000, -0x28(%rbp) # imm = 0x10000000
jb 0x23a7
movq $0x0, -0x8(%rbp)
jmp 0x23f2
movq -0x20(%rbp), %rdi
callq 0x1170
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jae 0x23c5
movq $0x0, -0x8(%rbp)
jmp 0x23f2
movq -0x30(%rbp), %rax
leaq 0x79e8(%rip), %rcx      # 0x9db8
movq %rcx, (%rax)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1cd0
movl -0x14(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/ww9210[P]xnuca_final_ssp/main.c
// Function: add_patch_pipeline
int add_patch_pipeline(){
    struct patch_attr* attr; int res = 0;
    struct executor_queue *eq;
    puts(">");
    attr = malloc(sizeof(struct patch_attr));
    read(0, attr, sizeof(struct patch_attr));
#ifdef DEBUG
    puts("o");
#endif

    res=check_patch_attr(attr);
    if(res<0){
#ifdef DEBUG
        printf("check patach attr error code: %d\n",res);
#endif
        return res;
    }

    eq = do_patch_pipeline_alloc(attr);
    if(!eq){
#ifdef DEBUG
        printf("pipeline alloc error\n");
#endif
        return res;
    }

    list_insert(&head, &eq->list);
    total_ppl+=1;
    global_executor_idx+=1;
#ifdef DEBUG
    printf("successfully added pipeline\n");
#endif

    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0x14(%rbp)
leaq 0x49fd(%rip), %rdi      # 0x6e13
callq 0x1070
movl $0x18, %edi
callq 0x1170
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rsi
xorl %edi, %edi
movl $0x18, %edx
callq 0x1120
movq -0x10(%rbp), %rdi
callq 0x1c60
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x2453
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x24a7
movq -0x10(%rbp), %rdi
callq 0x2340
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x246f
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x24a7
movq -0x20(%rbp), %rsi
addq $0x28, %rsi
leaq 0x7e4a(%rip), %rdi      # 0xa2c8
callq 0x1370
movl 0x7d87(%rip), %eax      # 0xa210
addl $0x1, %eax
movl %eax, 0x7d7e(%rip)      # 0xa210
movl 0x7d68(%rip), %eax      # 0xa200
addl $0x1, %eax
movl %eax, 0x7d5f(%rip)      # 0xa200
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq