// File: /workspace/github_c_makefile_star2_O3/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 $0x110, %rsp            # imm = 0x110
cmpl $0x1, %edi
jle 0x15e6d
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
callq 0x50cb
movq %r14, %rdi
callq 0x1386c
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24bd(%rip), %rsi      # 0x1806b
leaq 0x24ba(%rip), %rdx      # 0x1806f
movq %rsp, %rdi
callq 0x59aa
leaq 0xbb64(%rip), %rdi      # 0x21728
movq %rsp, %rsi
callq 0x16016
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 0x5834
movq 0x28(%r14), %rax
movq %rax, 0xa0(%rsp)
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x15c1a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
cmpq $0x0, 0x88(%rsp)
je 0x15e72
cmpl $0x1, 0x78(%rsp)
jne 0x15e72
movq 0x8(%rbx), %rsi
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x55ec
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 0x24f6(%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 0x15ca7
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x15cae
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 0x15ce7
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xb2ca(%rip), %rdi      # 0x20fb8
leaq 0x2478(%rip), %rsi      # 0x1816d
movl $0xe, %edx
callq 0x4360
movq 0xba5a(%rip), %rax      # 0x21760
subq 0xba4b(%rip), %rax      # 0x21758
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
movq 0xb292(%rip), %rdi      # 0x20fb8
callq 0x41e0
movq %rax, %rbx
leaq 0x2447(%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 0x5834
leaq 0xb9c8(%rip), %rsi      # 0x21758
leaq 0x40(%rsp), %rdi
callq 0x16092
movq 0xa0(%rsp), %rdx
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x4ff2
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x15dc8
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0x15ddf
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x15df6
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x15e0c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
cmpq %r15, %rdi
je 0x15e29
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
callq 0x57ac
movq -0x20(%rbx), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x15e5a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x42d0
xorl %eax, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x485f
callq 0x483a
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x15e96
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
jmp 0x15e96
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0x15ef4
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x15ef4
movq %rax, %rbx
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15f0b
movq 0xb8(%rsp), %rsi
jmp 0x15f03
movq %rax, %rbx
jmp 0x15f0b
movq %rax, %rbx
jmp 0x15f21
jmp 0x15ed9
movq %rax, %rbx
jmp 0x15f3e
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x15f3e
movq 0x10(%rsp), %rsi
jmp 0x15f36
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x15f0b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x15f21
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f3e
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0xc8(%rsp), %rdi
callq 0x15f72
movq %rbx, %rdi
callq 0x44e0
nop