// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/IRs/FourthIR.cpp
// Function: FourthIR::parse(std::vector<Block, std::allocator<Block>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
void FourthIR::parse(std::vector<Block> bs, std::string fileName, bool useEmulator)
{
    for(auto& b : bs)
    {
        Pair p;
        p.block = b;
        _notYetConvertedBlocks.push_back(p);
    }

    if (isDeterministic() && useEmulator)
    {
        _blocks = bs;
        std::string tmpFile = "tmp.ir";
        print(tmpFile);
        EmulatorRunner er;
        bool value = er.emulate(tmpFile, fileName);
        _blocks = {};
        if (value)
        {
            exit(0);
        }
    }

    _symbolTable->assignMemory();
    convertToAssembler();

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movl %ecx, 0xc(%rsp)
movq %rdx, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movq (%rsi), %r12
movq %rsi, 0x20(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r12
je 0x2444e
leaq 0x80(%rsp), %rbx
leaq 0x90(%rsp), %r13
movq 0x10(%rsp), %rax
leaq 0xb8(%rax), %r15
xorl %ebp, %ebp
leaq 0x70(%rsp), %r14
movq %rbx, 0x70(%rsp)
movq %rbp, 0x78(%rsp)
movb %bpl, 0x80(%rsp)
movq %rbp, 0x10(%r13)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq %rbp, 0xb0(%rsp)
movb %bpl, 0xb8(%rsp)
leaq 0xd8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq %rbp, 0xd0(%rsp)
movb %bpl, 0xd8(%rsp)
leaq 0xf8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq %rbp, 0xf0(%rsp)
movb %bpl, 0xf8(%rsp)
movb %bpl, 0x108(%rsp)
movups %xmm0, 0x90(%rbx)
leaq 0x140(%rsp), %rax
movq %rax, 0x130(%rsp)
movq %rbp, 0x138(%rsp)
movb %bpl, 0x140(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x150(%rsp)
movq %rbp, 0x158(%rsp)
movb %bpl, 0x160(%rsp)
movb %bpl, 0x170(%rsp)
callq 0x40b0
cltq
movq %rax, 0x128(%rsp)
movl %ebp, 0x120(%rsp)
movq %rbp, 0x108(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xf8(%rbx)
movups %xmm0, 0x118(%rbx)
leaq 0x1c8(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movq %rbp, 0x1c0(%rsp)
movb %bpl, 0x1c8(%rsp)
leaq 0x1e8(%rsp), %rax
movq %rax, 0x1d8(%rsp)
movq %rbp, 0x1e0(%rsp)
movb %bpl, 0x1e8(%rsp)
movb %bpl, 0x1f8(%rsp)
callq 0x40b0
cltq
movq %rax, 0x1b0(%rsp)
movl %ebp, 0x1a8(%rsp)
movq %rbp, 0x190(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x180(%rbx)
movb %bpl, 0x220(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x4170
addq $0x20, %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x29ef4
addq $0x18, %r12
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x4170
addq $0x20, %r12
leaq 0xc8(%rsp), %rdi
movq %r12, %rsi
callq 0x4170
addq $0x20, %r12
leaq 0xe8(%rsp), %rdi
movq %r12, %rsi
callq 0x4170
movb 0x20(%r12), %al
movb %al, 0x108(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x29b84
movq %r14, %rdi
callq 0x29bb0
addq $0x28, %r12
cmpq 0x28(%rsp), %r12
jne 0x24250
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x245f6
testb %al, 0xc(%rsp)
je 0x24559
leaq 0x10(%r13), %rbx
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x29cd4
leaq 0x80(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x13082(%rip), %rsi     # 0x3750b
leaq 0x13081(%rip), %rdx     # 0x37511
leaq 0x70(%rsp), %rdi
callq 0x53cc
leaq 0x70(%rsp), %rsi
movq %r13, %rdi
callq 0x2bd5c
leaq 0x60(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0xc7aa
leaq 0x40(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x18(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xc7aa
leaq 0xb(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x505c
movl %eax, %ebp
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x24517
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x2452e
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2abfe
testb %bpl, %bpl
jne 0x2457c
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x24559
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%r13), %rdi
callq 0x1a616
movq %r13, %rdi
callq 0x24662
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x4360
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x245a2
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x245a2
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x245c5
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x245c5
jmp 0x245c2
movq %rax, %rbx
jmp 0x245ee
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x245ee
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x245ee
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x29bb0
movq %rbx, %rdi
callq 0x44c0