// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x10(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x20af(%rip), %rsi      # 0x542f
leaq 0x20aa(%rip), %rdx      # 0x5431
movq %rsp, %rdi
callq 0x4ade
movslq %ebp, %rax
leaq (%rbx,%rax,8), %r14
movq %rsp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x49e5
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x33bd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
cmpq %r14, %r15
je 0x33ce
movq (%rbx), %rdi
callq 0x31f6
xorl %ebp, %ebp
jmp 0x33f2
cmpl $0x2, %ebp
jl 0x33e5
movl %ebp, %r12d
movq -0x8(%rbx,%r12,8), %rax
testq %rax, %rax
je 0x33e5
cmpb $0x2d, (%rax)
jne 0x3406
movq (%rbx), %rdi
callq 0x31f6
movl $0x1, %ebp
movl %ebp, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdi
movq %r13, (%rdi)
leaq 0x201f(%rip), %rsi      # 0x5432
leaq 0x201a(%rip), %rdx      # 0x5434
callq 0x4ade
movq %rsp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x49e5
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x3446
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
cmpq %r14, %r15
je 0x3452
movb $0x1, 0x4d30(%rip)      # 0x8182
movq %rsp, %rdi
movq %r13, (%rdi)
leaq 0x1fd6(%rip), %rsi      # 0x5435
leaq 0x1fd3(%rip), %rdx      # 0x5439
callq 0x4ade
movq %rsp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x49e5
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x3492
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
cmpq %r14, %r15
je 0x349e
movb $0x1, 0x4ce5(%rip)      # 0x8183
movq %rsp, %rdi
movq %r13, (%rdi)
leaq 0x1f8f(%rip), %rsi      # 0x543a
leaq 0x1f8a(%rip), %rdx      # 0x543c
callq 0x4ade
movq %rsp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x49e5
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x34de
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
cmpq %r14, %r15
je 0x34ea
movb $0x1, 0x4c9a(%rip)      # 0x8184
movq %rsp, %rdi
movq %r13, (%rdi)
leaq 0x1f46(%rip), %rsi      # 0x543d
leaq 0x1f41(%rip), %rdx      # 0x543f
callq 0x4ade
movq %rsp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x49e5
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x352a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
cmpq %r14, %r15
je 0x3543
movb $0x1, %al
movb %al, 0x4c4b(%rip)       # 0x8182
movb %al, 0x4c46(%rip)       # 0x8183
movb %al, 0x4c41(%rip)       # 0x8184
movq %rsp, %rdi
movq %r13, (%rdi)
leaq 0x1ef0(%rip), %rsi      # 0x5440
leaq 0x1ef5(%rip), %rdx      # 0x544c
callq 0x4ade
movq %rsp, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x49e5
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x3583
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
cmpq %r14, %r15
je 0x358f
movb $0x0, 0x4bd9(%rip)      # 0x8168
movq 0x4a22(%rip), %rax      # 0x7fb8
movq (%rax), %rdi
callq 0x2190
movl %eax, %edi
callq 0x2270
testl %eax, %eax
je 0x35b0
movb $0x1, 0x4bd1(%rip)      # 0x8181
movq -0x8(%rbx,%r12,8), %rsi
movq %rsp, %rdi
movl $0x4, %edx
callq 0x22a0
leaq 0x78(%rsp), %rdi
callq 0x2060
testb %al, %al
je 0x369a
movq %rsp, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21f0
movq %rsp, %rdi
callq 0x2260
movq %rax, %r15
movq %rsp, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x21f0
movq %rsp, %rdi
callq 0x2260
movq %rax, %r14
movq %rsp, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21f0
subq %r15, %r14
movq %r14, %rdi
callq 0x2030
movq %rax, %r15
movq %rsp, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x21d0
movq %rsp, %rdi
callq 0x2050
movq %r15, %rdi
movq %r14, %rsi
callq 0x3068
movl %eax, %ebp
movq %r15, %rdi
callq 0x21e0
testl %ebp, %ebp
je 0x37cb
movq 0x4997(%rip), %r14      # 0x7ff0
leaq 0x1e02(%rip), %rsi      # 0x5462
movl $0x1a, %edx
movq %r14, %rdi
callq 0x21a0
movq -0x8(%rbx,%r12,8), %rbx
testq %rbx, %rbx
je 0x3727
movq %rbx, %rdi
callq 0x20c0
movq 0x4966(%rip), %rdi      # 0x7ff0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21a0
jmp 0x373f
movq 0x494f(%rip), %r14      # 0x7ff0
leaq 0x1da5(%rip), %rsi      # 0x544d
movl $0x14, %edx
movq %r14, %rdi
callq 0x21a0
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x36da
movq %rbx, %rdi
callq 0x20c0
movq 0x4923(%rip), %rdi      # 0x7ff0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21a0
jmp 0x36f2
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x2240
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x48e0(%rip), %rdi      # 0x7ff0
callq 0x2040
movl $0x1, %ebp
movq %rax, %rdi
callq 0x2100
jmp 0x37cb
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x2240
movq 0x48aa(%rip), %rbx      # 0x7ff0
leaq 0x1d2e(%rip), %rsi      # 0x547b
movl $0x1, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x4878(%rip), %rdi      # 0x7ff0
callq 0x2040
movq %rax, %rdi
callq 0x2100
movq 0x4864(%rip), %rbx      # 0x7ff0
leaq 0x1cea(%rip), %rsi      # 0x547d
movl $0x28, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x4832(%rip), %rdi      # 0x7ff0
callq 0x2040
movq %rax, %rdi
callq 0x2100
movq %rsp, %rdi
callq 0x2070
jmp 0x33f2
jmp 0x37f6
jmp 0x37f6
jmp 0x3803
jmp 0x381e
jmp 0x3803
jmp 0x381e
jmp 0x3803
jmp 0x381e
jmp 0x3803
jmp 0x381e
jmp 0x3803
jmp 0x381e
jmp 0x37f6
jmp 0x37f6
jmp 0x37f6
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2070
jmp 0x3821
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x3821
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x3821
movq %rax, %rbx
movq %rbx, %rdi
callq 0x2280
nop