// File: /workspace/github_c_makefile_star2_O1/generot[P]VM-0/src/lang/vc.cc
// Function: main
int main(int argc, char **argv) {
    if(argc < 2)
        ISSUE_ERROR("Usage: ./vc <vm0_src_file>");

    lexer lx = lex_file(argv[1]);
    program(lx);

    symbol entry = symbol_table["main"];

    if(entry.ident == string() || entry.stype != SYM_FUNCTION)
        ISSUE_ERROR("No entry point provided.");

    string filepath = string(argv[1]);
    size_t off = filepath.find_first_of('.', 0);

    string output_filename = filepath.substr(0, off) + ".bc";

    cout << "Program size: " << bytecode.size() << " instructions" << endl;
    dump_program(output_filename, bytecode, entry.addr);

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
cmpl $0x1, %edi
jle 0x15f8a
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
callq 0x50f4
movq %r14, %rdi
callq 0x1386c
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x23a0(%rip), %rsi      # 0x1806b
leaq 0x239d(%rip), %rdx      # 0x1806f
movq %rsp, %rdi
callq 0x59ce
leaq 0xba47(%rip), %rdi      # 0x21728
movq %rsp, %rsi
callq 0x16132
movq %rax, %r14
movl (%rax), %eax
leaq 0x80(%rsp), %rdi
movl %eax, -0x8(%rdi)
leaq 0x90(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
addq %rsi, %rdx
callq 0x585e
movq 0x28(%r14), %rax
movq %rax, 0xa0(%rsp)
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x15d37
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
cmpq $0x0, 0x88(%rsp)
je 0x15f8f
cmpl $0x1, 0x78(%rsp)
jne 0x15f8f
movq 0x8(%rbx), %rsi
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x5614
movq %rsp, %rbx
movq %rbx, %rdi
movl $0x2e, %esi
xorl %edx, %edx
callq 0x43e0
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x4300
leaq 0x23d9(%rip), %rsi      # 0x18169
leaq 0xa8(%rsp), %rdi
callq 0x4540
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15dc4
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x15dcb
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15e04
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xb1ad(%rip), %rdi      # 0x20fb8
leaq 0x235b(%rip), %rsi      # 0x1816d
movl $0xe, %edx
callq 0x4360
movq 0xb93d(%rip), %rax      # 0x21760
subq 0xb92e(%rip), %rax      # 0x21758
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
movq 0xb175(%rip), %rdi      # 0x20fb8
callq 0x41e0
movq %rax, %rbx
leaq 0x232a(%rip), %rsi      # 0x1817c
movl $0xd, %edx
movq %rax, %rdi
callq 0x4360
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x42b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41f0
leaq 0x68(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x585e
leaq 0xb8ab(%rip), %rsi      # 0x21758
leaq 0x40(%rsp), %rdi
callq 0x161ae
movq 0xa0(%rsp), %rdx
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x501b
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x15ee5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0x15efc
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x15f13
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x15f29
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f46
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
callq 0x57d8
movq -0x20(%rbx), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x15f77
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x42d0
xorl %eax, %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x4861
callq 0x483c
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x15fb3
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
jmp 0x15fb3
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0x16011
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x16011
movq %rax, %rbx
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x16028
movq 0xb8(%rsp), %rsi
jmp 0x16020
movq %rax, %rbx
jmp 0x16028
movq %rax, %rbx
jmp 0x1603e
jmp 0x15ff6
movq %rax, %rbx
jmp 0x1605b
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1605b
movq 0x10(%rsp), %rsi
jmp 0x16053
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x16028
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1603e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
cmpq %r15, %rdi
je 0x1605b
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0xc8(%rsp), %rdi
callq 0x1608e
movq %rbx, %rdi
callq 0x44e0