// File: /workspace/github_cpp_makefile_star2_O3/johan-bjareholt[P]lua-compiler/src/convert.cc
// Function: outBlock(BBlock&, std::ostream&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, bool, bool)
std::string outBlock(BBlock& block, std::ostream& ss, std::set<std::string>& outputSymbols, std::set<std::string>& inputSymbols, bool exit, bool localScope){
    if (!block.label.empty()){
        return block.label;
    }
    else {
        block.label = newLabel();
        ss << std::endl;
        ss << pre_in << block.label << ":" << post_in;
        ThreeAd* last_op = nullptr;
        for (ThreeAd& op : block.instructions){
            convertThreeAd(op, ss, outputSymbols, inputSymbols, localScope);
            last_op = &op;
        }

        std::stringstream falseblock;
        std::stringstream trueblock;
        std::string bname;
        if (block.falseExit != nullptr && last_op){
            bname = outBlock(*block.falseExit, falseblock, outputSymbols, inputSymbols, exit, localScope);
            switch (last_op->op){
                case '=':
                    ss << pre_in << "jne " << bname << post_in;
                    break;
                case 'e':
                    ss << pre_in << "je " << bname << post_in;
                    break;
                case '<':
                    ss << pre_in << "jle " << bname << post_in;
                    break;
                case '>':
                    ss << pre_in << "jge " << bname << post_in;
                    break;
                default:
                    std::cout << "Unreachable block: " << bname << std::endl;
                    break;
            }
        }
        if (block.trueExit != nullptr){
            bname = outBlock(*block.trueExit, trueblock, outputSymbols, inputSymbols, exit, localScope);
            ss << pre_in << "jmp " << bname << post_in;
        }
        else if (exit){
            ss << pre_in << "jmp label_end" << post_in;
        }
        else {
            // Free local var space
            ss << pre_in << "addq $" << varoffset << ", %%rsp" << post_in;
            // Pop bp
            ss << pre_in << "popq %%rbp" << post_in;
            // Return
            ss << pre_in << "ret" << post_in;
        }
        if (block.falseExit != nullptr)
            ss << falseblock.str();
        if (block.trueExit != nullptr)
            ss << trueblock.str();

    }
    return block.label;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x398, %rsp            # imm = 0x398
movq %rdx, %r12
movq %rdi, %r14
leaq 0x28(%rsi), %rbx
movq 0x30(%rsi), %rdx
testq %rdx, %rdx
je 0xa45a
leaq 0x10(%r14), %rax
movq %rax, (%r14)
movq (%rbx), %rsi
addq %rsi, %rdx
movq %r14, %rdi
callq 0x4baa
movq %r14, %rax
jmp 0xaa1d
movl %r9d, -0x3c(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %rsi, -0x38(%rbp)
movq %r14, -0xa0(%rbp)
leaq -0x228(%rbp), %r15
movq %r15, %rdi
callq 0x8fd4
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3320
movq (%r15), %rdi
leaq -0x218(%rbp), %rax
cmpq %rax, %rdi
je 0xa49f
callq 0x3230
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq 0x12ed2(%rip), %rsi     # 0x1d3a0
movq 0x12ed3(%rip), %rdx     # 0x1d3a8
movq %r12, -0x78(%rbp)
movq %r12, %rdi
callq 0x32b0
movq -0x38(%rbp), %r15
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rdx
movq %rax, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xafda(%rip), %rsi      # 0x154d9
movl $0x1, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x12ead(%rip), %rsi     # 0x1d3c0
movq 0x12eae(%rip), %rdx     # 0x1d3c8
movq %rbx, %rdi
callq 0x32b0
movq (%r15), %r14
cmpq %r15, %r14
je 0xa561
movzbl 0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x78(%rbp), %r13
movq -0x50(%rbp), %r15
movq -0x48(%rbp), %r12
leaq 0x10(%r14), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
movl -0x2c(%rbp), %r8d
callq 0xaeb1
movq (%r14), %r14
cmpq -0x38(%rbp), %r14
jne 0xa53d
jmp 0xa563
xorl %ebx, %ebx
leaq -0x228(%rbp), %r13
movq %r13, %rdi
callq 0x31a0
leaq -0x3b0(%rbp), %rdi
callq 0x31a0
leaq -0x88(%rbp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
movq -0x38(%rbp), %r15
movq 0x20(%r15), %rsi
testq %rsi, %rsi
sete %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
movzbl -0x3c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x78(%rbp), %r14
jne 0xa77f
leaq -0x218(%rbp), %rdx
movzbl 0x10(%rbp), %eax
movl %eax, (%rsp)
leaq -0x70(%rbp), %rdi
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movl -0x2c(%rbp), %r9d
callq 0xa416
leaq -0x98(%rbp), %rdi
leaq -0x70(%rbp), %r15
movq %r15, %rsi
callq 0x3320
movq (%r15), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xa606
callq 0x3230
movzbl (%rbx), %eax
cmpl $0x3d, %eax
jg 0xa652
cmpl $0x3c, %eax
movq -0x38(%rbp), %r15
je 0xa6f7
cmpl $0x3d, %eax
jne 0xa696
movq 0x12d79(%rip), %rsi     # 0x1d3a0
movq 0x12d7a(%rip), %rdx     # 0x1d3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xafa5(%rip), %rsi      # 0x155e5
movl $0x4, %edx
movq %rax, %rdi
callq 0x32b0
jmp 0xa753
cmpl $0x3e, %eax
movq -0x38(%rbp), %r15
je 0xa726
cmpl $0x65, %eax
jne 0xa696
movq 0x12d35(%rip), %rsi     # 0x1d3a0
movq 0x12d36(%rip), %rdx     # 0x1d3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xaf66(%rip), %rsi      # 0x155ea
movl $0x3, %edx
movq %rax, %rdi
callq 0x32b0
jmp 0xa753
movq 0x12933(%rip), %rdi     # 0x1cfd0
leaq 0xaf54(%rip), %rsi      # 0x155f8
movl $0x13, %edx
callq 0x32b0
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq 0x1290d(%rip), %rdi     # 0x1cfd0
callq 0x32b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
jmp 0xa77f
movq 0x12ca2(%rip), %rsi     # 0x1d3a0
movq 0x12ca3(%rip), %rdx     # 0x1d3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xaed7(%rip), %rsi      # 0x155ee
movl $0x4, %edx
movq %rax, %rdi
callq 0x32b0
jmp 0xa753
movq 0x12c73(%rip), %rsi     # 0x1d3a0
movq 0x12c74(%rip), %rdx     # 0x1d3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xaead(%rip), %rsi      # 0x155f3
movl $0x4, %edx
movq %rax, %rdi
callq 0x32b0
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq %rbx, %rdi
callq 0x32b0
movq 0x12c50(%rip), %rsi     # 0x1d3c0
movq 0x12c51(%rip), %rdx     # 0x1d3c8
movq %rax, %rdi
callq 0x32b0
movq 0x18(%r15), %rsi
testq %rsi, %rsi
je 0xa81e
leaq -0x3a0(%rbp), %rdx
movzbl 0x10(%rbp), %eax
movl %eax, (%rsp)
leaq -0x70(%rbp), %rdi
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movl -0x2c(%rbp), %r9d
callq 0xa416
leaq -0x98(%rbp), %rdi
leaq -0x70(%rbp), %rbx
movq %rbx, %rsi
callq 0x3320
movq (%rbx), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xa7d3
callq 0x3230
movq 0x12bc6(%rip), %rsi     # 0x1d3a0
movq 0x12bc7(%rip), %rdx     # 0x1d3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xae19(%rip), %rsi      # 0x1560c
movl $0x4, %edx
movq %rax, %rdi
callq 0x32b0
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq %rbx, %rdi
callq 0x32b0
movq %rax, %rbx
jmp 0xa920
movq 0x12b7b(%rip), %rsi     # 0x1d3a0
movq 0x12b7c(%rip), %rdx     # 0x1d3a8
cmpb $0x0, -0x3c(%rbp)
je 0xa856
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xadcd(%rip), %rsi      # 0x15611
movl $0xd, %edx
movq %rax, %rdi
callq 0x32b0
jmp 0xa920
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xadb7(%rip), %rsi      # 0x1561f
movl $0x6, %edx
movq %rax, %rdi
callq 0x32b0
movl 0x12b99(%rip), %esi     # 0x1d414
movq %rbx, %rdi
callq 0x3450
movq %rax, %rbx
leaq 0xad99(%rip), %rsi      # 0x15626
movl $0x7, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x12b1f(%rip), %rsi     # 0x1d3c0
movq 0x12b20(%rip), %rdx     # 0x1d3c8
movq %rbx, %rdi
callq 0x32b0
movq 0x12ae9(%rip), %rsi     # 0x1d3a0
movq 0x12aea(%rip), %rdx     # 0x1d3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xad5e(%rip), %rsi      # 0x1562e
movl $0xa, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x12adc(%rip), %rsi     # 0x1d3c0
movq 0x12add(%rip), %rdx     # 0x1d3c8
movq %rbx, %rdi
callq 0x32b0
movq 0x12aa6(%rip), %rsi     # 0x1d3a0
movq 0x12aa7(%rip), %rdx     # 0x1d3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xad26(%rip), %rsi      # 0x15639
movl $0x3, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x12a99(%rip), %rsi     # 0x1d3c0
movq 0x12a9a(%rip), %rdx     # 0x1d3c8
movq %rbx, %rdi
callq 0x32b0
cmpq $0x0, 0x20(%r15)
je 0xa96f
leaq -0x210(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x3400
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %r14, %rdi
callq 0x32b0
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa96f
callq 0x3230
cmpq $0x0, 0x18(%r15)
je 0xa9a8
leaq -0x398(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x3400
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %r14, %rdi
callq 0x32b0
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa9a8
callq 0x3230
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0xa9b9
callq 0x3230
movq 0x125d8(%rip), %rbx     # 0x1cf98
leaq -0x3b0(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x31c0
movl $0x80, %r14d
addq %r14, %r12
movq %r12, %rdi
callq 0x30c0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x31c0
addq %r14, %r13
movq %r13, %rdi
callq 0x30c0
movq -0xa0(%rbp), %rbx
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x4baa
movq %rbx, %rax
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xaa55
jmp 0xaa35
jmp 0xaa55
movq %rax, %rbx
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xaa58
callq 0x3230
jmp 0xaa58
jmp 0xaa55
jmp 0xaa55
movq %rax, %rbx
jmp 0xaa88
movq %rax, %rbx
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0xaa69
callq 0x3230
movq 0x12528(%rip), %rsi     # 0x1cf98
leaq -0x3b0(%rbp), %rdi
callq 0x31c0
leaq -0x330(%rbp), %rdi
callq 0x30c0
movq 0x12509(%rip), %rsi     # 0x1cf98
leaq -0x228(%rbp), %rdi
callq 0x31c0
leaq -0x1a8(%rbp), %rdi
callq 0x30c0
movq %rbx, %rdi
callq 0x3470