// File: /workspace/github_cpp_makefile_star2_O1/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 0x6e59
movq 0x1b1e2(%rip), %rbx     # 0x21fb8
leaq 0x11227(%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 0x11203(%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 0x700a
movq 0x8(%rsi), %rsi
leaq 0x48(%rsp), %rbx
leaq 0x310(%rsp), %rdx
movq %rbx, %rdi
callq 0x70ac
leaq 0x310(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x5470
leaq 0x68(%rsp), %rdi
leaq 0x310(%rsp), %rsi
callq 0x79a4
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 0x7236
leaq 0x11153(%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 0x6f23
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x68(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x85be
leaq 0x110(%rsp), %rdi
callq 0x53f0
movq 0x1b047(%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 0x6f95
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0xe0(%rsp), %rdi
callq 0x7144
leaq 0xb0(%rsp), %rdi
callq 0x7124
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
callq 0x7124
movq -0x20(%rbx), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x6fe0
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 0x7008
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x52c0
xorl %eax, %eax
addq $0x518, %rsp            # imm = 0x518
popq %rbx
popq %r14
retq
jmp 0x7017
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x7057
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x52c0
jmp 0x7057
movq %rax, %rbx
jmp 0x7057
movq %rax, %rbx
jmp 0x7072
movq %rax, %rbx
jmp 0x707c
movq %rax, %rbx
jmp 0x7089
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x5430
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7072
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x52c0
leaq 0x68(%rsp), %rdi
callq 0x70ea
leaq 0x310(%rsp), %rdi
callq 0x5090
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x70a4
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x52c0
movq %rbx, %rdi
callq 0x5530