// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
cmpl $0x1, %edi
jle 0x12f1e
movq %rsi, %r14
movq 0x8(%rsi), %rsi
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4bc6
movq %rbx, %rdi
callq 0x116f8
leaq 0x22eb(%rip), %rsi      # 0x1506b
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x4fa0
leaq 0xd994(%rip), %rdi      # 0x20728
movq %rsp, %rsi
callq 0x13138
leaq 0x98(%rsp), %rdi
movq %rax, %rsi
callq 0x130e6
movq %rsp, %rdi
callq 0x4130
leaq 0xa0(%rsp), %rbx
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsp, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4fe5
movl %eax, %ebp
movl -0x8(%rbx), %r12d
movq %r15, %rdi
callq 0x4130
testb %bpl, %bpl
jne 0x12f33
cmpl $0x1, %r12d
jne 0x12f33
movq 0x8(%r14), %rsi
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x4fa0
movq %rsp, %r14
pushq $0x2e
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x43c0
leaq 0x78(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x42f0
leaq 0x2333(%rip), %rdx      # 0x15169
leaq 0x20(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x4f80
leaq 0x78(%rsp), %rdi
callq 0x4130
movq 0xd15a(%rip), %rdi      # 0x1ffb0
leaq 0x2310(%rip), %rsi      # 0x1516d
callq 0x42a0
movq %rax, %rdi
movq 0xd8f4(%rip), %rax      # 0x20760
subq 0xd8e5(%rip), %rax      # 0x20758
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x41e0
leaq 0x22f2(%rip), %rsi      # 0x1517c
movq %rax, %rdi
callq 0x42a0
movq %rax, %rdi
callq 0x4150
leaq 0x58(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x43f0
leaq 0xd8a8(%rip), %rsi      # 0x20758
leaq 0x40(%rsp), %rdi
callq 0x1319e
movq 0xc0(%rsp), %rdx
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x4b23
leaq 0x40(%rsp), %rdi
callq 0x1326c
leaq 0x58(%rsp), %rdi
callq 0x4130
leaq 0x20(%rsp), %rdi
callq 0x4130
movq %rsp, %rdi
callq 0x4130
movq %rbx, %rdi
callq 0x4130
leaq 0xc8(%rsp), %rdi
callq 0x1303c
xorl %eax, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0xd093(%rip), %rax      # 0x1ffb8
movq (%rax), %rcx
leaq 0x2204(%rip), %rdi      # 0x15133
pushq $0x1b
jmp 0x12f46
movq 0xd07e(%rip), %rax      # 0x1ffb8
movq (%rax), %rcx
leaq 0x220b(%rip), %rdi      # 0x1514f
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x4540
pushq $-0x1
popq %rdi
callq 0x4360
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x1326c
jmp 0x12f69
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x4130
jmp 0x12f9b
movq %rax, %r14
leaq 0x78(%rsp), %rdi
jmp 0x12fa0
movq %rax, %r14
jmp 0x12fa5
movq %rax, %r14
jmp 0x12fad
jmp 0x12f8b
movq %rax, %r14
jmp 0x12fb5
movq %rax, %r14
movq %rsp, %rdi
jmp 0x12fb0
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x4130
movq %rsp, %rdi
callq 0x4130
movq %rbx, %rdi
callq 0x4130
leaq 0xc8(%rsp), %rdi
callq 0x1303c
movq %r14, %rdi
callq 0x44e0