// File: /workspace/github_cpp_makefile_star2_O2/ELD[P]HackAssembler/src/parser.cpp
// Function: hack::Parser::translateAssembly(std::ostream&)
void Parser::translateAssembly(std::ostream& oss)
    {
        collectLabels();
        while (advance()) {
            if (_currentCommand == "GARBAGE") {
                return;
            }

            if (commandType() == A_COMMAND) {
                int value;

                try {
                    value = stoi(getSymbol());
                } catch (std::invalid_argument exc) {
                    if (_symbols.contains(getSymbol())) {
                        value = _symbols.retrieveSymbol(getSymbol());
                    } else {
                        value = _mem;
                        _symbols.addSymbol(getSymbol(), _mem);
                        ++_mem;
                    }
                }

                oss << "0" + translateACode(value) << std::endl;
            } else if (commandType() == C_COMMAND) {
                oss << "111" + getCompBits() + getDestBits() + getJumpBits() << std::endl;
            }
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x776c
leaq 0x8(%r14), %r15
leaq 0x78(%r14), %rax
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rbp
leaq 0x58(%rsp), %r12
movq %r14, %rdi
callq 0x7056
testb %al, %al
je 0x7a79
movq %r15, %rdi
leaq 0xd92c(%rip), %rsi      # 0x15185
callq 0x7bc1
testb %al, %al
jne 0x7a79
movq %r14, %rdi
callq 0x71a2
cmpl $0x1, %eax
jne 0x78db
movq %rbp, %rdi
movq %r14, %rsi
callq 0x7314
movq %rbp, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x7daa
movl %eax, %r13d
movq %rbp, %rdi
callq 0x5170
movq %r12, %rdi
movl %r13d, %edx
callq 0x7724
movq %rbp, %rdi
leaq 0xe791(%rip), %rsi      # 0x1603c
movq %r12, %rdx
callq 0x7ddf
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x52d0
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
callq 0x5170
movq %r12, %rdi
callq 0x5170
jmp 0x783f
movq %r14, %rdi
callq 0x71a2
cmpl $0x2, %eax
jne 0x783f
leaq 0xb8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x74a6
leaq 0x38(%rsp), %rdi
leaq 0xe724(%rip), %rsi      # 0x1602f
movq %r13, %rdx
callq 0x7ddf
leaq 0x98(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x73c2
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
movq %r13, %rdx
callq 0x7e03
leaq 0x78(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x763c
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x7e03
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x52d0
movq %rax, %rdi
callq 0x5190
movq %rbp, %rdi
callq 0x5170
leaq 0x78(%rsp), %rdi
callq 0x5170
movq %r12, %rdi
callq 0x5170
leaq 0x98(%rsp), %rdi
callq 0x5170
leaq 0x38(%rsp), %rdi
callq 0x5170
leaq 0xb8(%rsp), %rdi
callq 0x5170
jmp 0x783f
movq %rdx, %r13
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
callq 0x5170
jmp 0x79c4
movq %rdx, %r13
movq %rax, 0x8(%rsp)
cmpl $0x1, %r13d
jne 0x7b4c
movq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x53c0
movq %r12, %rdi
movq %rax, %rsi
callq 0x7dc6
movq %r13, %rdi
callq 0x5130
movq %rbp, %rdi
movq %r14, %rsi
callq 0x7314
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x1486c
movl %eax, %r13d
movq %rbp, %rdi
callq 0x5170
testb %r13b, %r13b
je 0x7a3b
movq %rbp, %rdi
movq %r14, %rsi
callq 0x7314
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x14882
movl %eax, %r13d
movq %rbp, %rdi
callq 0x5170
jmp 0x7a67
movl 0x74(%r14), %r13d
movq %rbp, %rdi
movq %r14, %rsi
callq 0x7314
movl 0x74(%r14), %edx
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x14818
movq %rbp, %rdi
callq 0x5170
incl 0x74(%r14)
movq %r12, %rdi
callq 0x54d0
callq 0x54c0
jmp 0x7896
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7a93
jmp 0x7aa4
jmp 0x7a93
jmp 0x7aa4
movq %rax, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x5170
jmp 0x7aa9
movq %rax, 0x8(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x54d0
callq 0x54c0
jmp 0x7b4c
movq %rax, %rdi
callq 0x68f0
movq %rax, 0x8(%rsp)
jmp 0x7afe
movq %rax, 0x8(%rsp)
jmp 0x7b08
movq %rax, 0x8(%rsp)
jmp 0x7b12
movq %rax, 0x8(%rsp)
jmp 0x7b1f
movq %rax, 0x8(%rsp)
jmp 0x7b29
movq %rax, 0x8(%rsp)
jmp 0x7b42
movq %rax, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x5170
leaq 0x78(%rsp), %rdi
callq 0x5170
leaq 0x58(%rsp), %rdi
callq 0x5170
leaq 0x98(%rsp), %rdi
callq 0x5170
leaq 0x38(%rsp), %rdi
callq 0x5170
leaq 0xb8(%rsp), %rdi
jmp 0x7b47
movq %rax, 0x8(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x5170
leaq 0x58(%rsp), %rdi
callq 0x5170
movq 0x8(%rsp), %rdi
callq 0x5540