// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x35341
movq 0x1ec9a(%rip), %rax     # 0x53fc0
movq (%rax), %rdi
leaq 0x4e83(%rip), %rsi      # 0x3a1b3
movb $0x0, %al
callq 0x55e0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x54f0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x6440
movq -0x190(%rbp), %rdi
callq 0x32840
jmp 0x35367
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x56e0
movq -0x198(%rbp), %rdx
leaq 0x4d63(%rip), %rsi      # 0x3a0eb
leaq -0xb8(%rbp), %rdi
callq 0x6b50
jmp 0x35396
leaq 0x1f48b(%rip), %rdi     # 0x54828
leaq -0xb8(%rbp), %rsi
callq 0x35b70
movq %rax, -0x1a0(%rbp)
jmp 0x353b2
movq -0x1a0(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x35a90
jmp 0x353c7
leaq -0xb8(%rbp), %rdi
callq 0x5260
leaq -0xb9(%rbp), %rdi
callq 0x5460
leaq -0x98(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x1b0(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5590
movq -0x1b0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x6d10
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1a1(%rbp)
jne 0x3542f
cmpl $0x1, -0x98(%rbp)
setne %al
movb %al, -0x1a1(%rbp)
movb -0x1a1(%rbp), %al
movb %al, -0x1b1(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5260
movb -0x1b1(%rbp), %al
testb $0x1, %al
jne 0x35453
jmp 0x354bd
movq 0x1eb66(%rip), %rax     # 0x53fc0
movq (%rax), %rdi
leaq 0x4d6b(%rip), %rsi      # 0x3a1cf
movb $0x0, %al
callq 0x55e0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x54f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x35731
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x354ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x5260
leaq -0xb9(%rbp), %rdi
callq 0x5460
jmp 0x35731
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x1c8(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x56e0
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
leaq -0x100(%rbp), %rdi
callq 0x6b50
jmp 0x354fb
leaq -0x101(%rbp), %rdi
callq 0x5460
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x1d0(%rbp)
leaq -0x100(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
movl $0x2e, %esi
callq 0x5290
movq -0x1d8(%rbp), %rsi
movq -0x1d0(%rbp), %rdx
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rcx
leaq -0x150(%rbp), %rdi
callq 0x5410
jmp 0x35554
leaq 0x4c8e(%rip), %rdx      # 0x3a1e9
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x6b00
jmp 0x35570
leaq -0x150(%rbp), %rdi
callq 0x5260
movq 0x1ea35(%rip), %rdi     # 0x53fb8
leaq 0x4c63(%rip), %rsi      # 0x3a1ed
callq 0x53d0
movq %rax, -0x1e0(%rbp)
jmp 0x35598
leaq 0x1f2b9(%rip), %rdi     # 0x54858
callq 0x6e60
movq -0x1e0(%rbp), %rdi
movq %rax, %rsi
callq 0x50e0
movq %rax, -0x1e8(%rbp)
jmp 0x355bc
movq -0x1e8(%rbp), %rdi
leaq 0x4c32(%rip), %rsi      # 0x3a1fc
callq 0x53d0
movq %rax, -0x1f0(%rbp)
jmp 0x355d8
movq -0x1f0(%rbp), %rdi
movq 0x1e9aa(%rip), %rsi     # 0x53f90
callq 0x5430
jmp 0x355ed
leaq -0x170(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x5190
jmp 0x35602
leaq 0x1f24f(%rip), %rsi     # 0x54858
leaq -0x188(%rbp), %rdi
callq 0x35c50
jmp 0x35617
movq -0x70(%rbp), %rdx
leaq -0x170(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x6300
jmp 0x35630
leaq -0x188(%rbp), %rdi
callq 0x357b0
leaq -0x170(%rbp), %rdi
callq 0x5260
movl $0x0, -0x4(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x5260
leaq -0x100(%rbp), %rdi
callq 0x5260
leaq -0x98(%rbp), %rdi
callq 0x35a40
leaq -0x58(%rbp), %rdi
callq 0x358e0
movl -0x4(%rbp), %eax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x101(%rbp), %rdi
callq 0x5460
jmp 0x35725
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x35719
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x5260
jmp 0x35719
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x3570d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x35701
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x357b0
leaq -0x170(%rbp), %rdi
callq 0x5260
leaq -0x130(%rbp), %rdi
callq 0x5260
leaq -0x100(%rbp), %rdi
callq 0x5260
leaq -0x98(%rbp), %rdi
callq 0x35a40
leaq -0x58(%rbp), %rdi
callq 0x358e0
movq -0x60(%rbp), %rdi
callq 0x56d0
nopw %cs:(%rax,%rax)
nopl (%rax)