// File: /workspace/github_cpp_makefile_star2_O2/coduin[P]epiphany-bin-info/epiphany-bin-info.cpp
// Function: main
int main(int argc, char* argv[]) {
    if (cmdOptionExists(argv, argv + argc, "-h")) {
        showHelp(argv[0]);
        return 0;
    }

    // Retrieve the filename
    if ((argc <= 1) || (argv[argc - 1] == NULL) || (argv[argc - 1][0] == '-')) {
        showHelp(argv[0]);
        return 1;
    }

    if (cmdOptionExists(argv, argv + argc, "-p"))
        showProgramHeaders = true;

    if (cmdOptionExists(argv, argv + argc, "-sec"))
        showSections = true;

    if (cmdOptionExists(argv, argv + argc, "-s"))
        showSymbols = true;

    if (cmdOptionExists(argv, argv + argc, "-a")) {
        showProgramHeaders = true;
        showSections = true;
        showSymbols = true;
    }

    if (cmdOptionExists(argv, argv + argc, "--nodemangle")) {
        demangleNames = false;
    }

    if (isatty(fileno(stdout)))
        colorOutput = true;

    std::ifstream file(argv[argc - 1], ios::binary);

    if (!file.is_open()) {
        cerr << "Could not open file " << argv[1] << endl;
        return 1;
    }

    streampos fsize = 0;
    file.seekg(0, ios::beg);
    fsize = file.tellg();
    file.seekg(0, ios::end);
    fsize = file.tellg() - fsize;
    file.seekg(0, ios::beg);

    char* buffer = new char[fsize];
    file.read(buffer, fsize);
    file.close();

    int ret = parseFile(buffer, fsize);
    delete[] buffer;

    if (ret) {
        cerr << "Error while parsing file '" << argv[argc - 1] << "'" << endl;
        cerr << "File is not a valid Epiphany executable." << endl;
    }

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x156a(%rip), %rsi      # 0x442f
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3278
movslq %ebp, %rax
leaq (%rbx,%rax,8), %r14
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dbd
movl %eax, %r15d
leaq 0x8(%rsp), %rdi
callq 0x20c0
testb %r15b, %r15b
je 0x2f09
movq (%rbx), %rdi
callq 0x2dce
xorl %ebp, %ebp
jmp 0x2f2b
cmpl $0x2, %ebp
jl 0x2f20
movl %ebp, %r12d
movq -0x8(%rbx,%r12,8), %rax
testq %rax, %rax
je 0x2f20
cmpb $0x2d, (%rax)
jne 0x2f3d
movq (%rbx), %rdi
callq 0x2dce
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14ee(%rip), %rsi      # 0x4432
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3278
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dbd
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
je 0x2f7b
movb $0x1, 0x421f(%rip)      # 0x719a
leaq 0x14b3(%rip), %rsi      # 0x4435
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3278
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dbd
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
je 0x2fb9
movb $0x1, 0x41e2(%rip)      # 0x719b
leaq 0x147a(%rip), %rsi      # 0x443a
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3278
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dbd
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
je 0x2ff7
movb $0x1, 0x41a5(%rip)      # 0x719c
leaq 0x143f(%rip), %rsi      # 0x443d
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3278
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dbd
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
je 0x3042
movb $0x1, %al
movb %al, 0x4164(%rip)       # 0x719a
movb %al, 0x415f(%rip)       # 0x719b
movb %al, 0x415a(%rip)       # 0x719c
leaq 0x13f7(%rip), %rsi      # 0x4440
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3278
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2dbd
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x20c0
testb %bpl, %bpl
je 0x3080
movb $0x0, 0x4100(%rip)      # 0x7180
movq 0x3f31(%rip), %rax      # 0x6fb8
movq (%rax), %rdi
callq 0x21a0
movl %eax, %edi
callq 0x2290
testl %eax, %eax
je 0x30a1
movb $0x1, 0x40f8(%rip)      # 0x7199
movq -0x8(%rbx,%r12,8), %rsi
leaq 0x8(%rsp), %rdi
pushq $0x4
popq %rdx
callq 0x22c0
leaq 0x80(%rsp), %rdi
callq 0x2050
testb %al, %al
je 0x31a6
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2210
leaq 0x8(%rsp), %rdi
callq 0x2280
movq %rax, %r15
leaq 0x8(%rsp), %rdi
pushq $0x2
popq %rdx
xorl %esi, %esi
callq 0x2210
leaq 0x8(%rsp), %rdi
callq 0x2280
movq %rax, %r14
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2210
subq %r15, %r14
movq %r14, %rdi
callq 0x2030
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x21e0
leaq 0x8(%rsp), %rdi
callq 0x2040
movq %r15, %rdi
movq %r14, %rsi
callq 0x2c60
movl %eax, %ebp
movq %r15, %rdi
callq 0x21f0
testl %ebp, %ebp
je 0x31d2
movq 0x3e97(%rip), %rdi      # 0x6ff0
leaq 0x1302(%rip), %rsi      # 0x4462
callq 0x2170
movq -0x8(%rbx,%r12,8), %rsi
movq %rax, %rdi
callq 0x2170
leaq 0x1302(%rip), %rsi      # 0x447b
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20d0
movq 0x3e60(%rip), %rdi      # 0x6ff0
leaq 0x12e6(%rip), %rsi      # 0x447d
callq 0x2170
movq %rax, %rdi
callq 0x20d0
jmp 0x31d4
movq 0x3e43(%rip), %rdi      # 0x6ff0
leaq 0x1299(%rip), %rsi      # 0x444d
callq 0x2170
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20d0
pushq $0x1
popq %rbp
jmp 0x31d4
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdi
callq 0x2060
jmp 0x2f2b
jmp 0x3201
jmp 0x3201
jmp 0x3210
jmp 0x321f
jmp 0x3210
jmp 0x321f
jmp 0x3210
jmp 0x321f
jmp 0x3210
jmp 0x321f
jmp 0x3210
jmp 0x321f
jmp 0x3201
jmp 0x3201
jmp 0x3201
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2060
jmp 0x3222
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20c0
jmp 0x3222
movq %rax, %rbx
movq %rbx, %rdi
callq 0x22a0