// File: /workspace/github_cpp_makefile_star2_O3/ELD[P]HackAssembler/src/main.cpp
// Function: main
int main(int argc, char* argv[])
{
    if (argc <= 1) {
        std::cout << "No target file specified!" << std::endl << "Example usage: ./hackasm [file]" << std::endl;
        return -1;
    }

    std::string file(argv[1]);
    std::ifstream fileHandle(file);

    hack::Parser parser(fileHandle);
    std::string outFileName = file.substr(0, file.find_last_of('.'));
    std::ofstream ofs(outFileName + ".hack");
    parser.translateAssembly(ofs);
    ofs.close();

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x518, %rsp            # imm = 0x518
cmpl $0x1, %edi
jg 0x6e39
movq 0x1b202(%rip), %rbx     # 0x21fb8
leaq 0x11247(%rip), %rsi     # 0x18004
movl $0x19, %edx
movq %rbx, %rdi
callq 0x5340
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x52a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51e0
movq %rax, %rbx
leaq 0x11223(%rip), %rsi     # 0x1801e
movl $0x1f, %edx
movq %rax, %rdi
callq 0x5340
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x52a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51e0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6fea
movq 0x8(%rsi), %rsi
leaq 0x48(%rsp), %rbx
leaq 0x310(%rsp), %rdx
movq %rbx, %rdi
callq 0x708c
leaq 0x310(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x5470
leaq 0x68(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x7990
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x55c0
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x52f0
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x7216
leaq 0x11173(%rip), %rsi     # 0x1803e
leaq 0x8(%rsp), %rdi
callq 0x55a0
leaq 0x110(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x10, %edx
callq 0x55b0
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6f03
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x68(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x8580
leaq 0x110(%rsp), %rdi
callq 0x53f0
movq 0x1b067(%rip), %rax     # 0x21f90
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x118(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x110(%rsp,%rcx)
callq 0x5250
leaq 0x208(%rsp), %rdi
callq 0x50e0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6f75
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0xe0(%rsp), %rdi
callq 0x7124
leaq 0xb0(%rsp), %rdi
callq 0x7104
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
callq 0x7104
movq -0x20(%rbx), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x6fc0
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x310(%rsp), %rdi
callq 0x5090
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6fe8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x52c0
xorl %eax, %eax
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r14
retq
jmp 0x6ff7
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x7037
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x7037
movq %rax, %rbx
jmp 0x7037
movq %rax, %rbx
jmp 0x7052
movq %rax, %rbx
jmp 0x705c
movq %rax, %rbx
jmp 0x7069
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x5430
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7052
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x68(%rsp), %rdi
callq 0x70ca
leaq 0x310(%rsp), %rdi
callq 0x5090
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7084
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x52c0
movq %rbx, %rdi
callq 0x5530