// File: /workspace/github_cpp_makefile_star2_O2/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 $0x388, %rsp            # imm = 0x388
movq %rdi, %r14
leaq 0x28(%rsi), %r15
cmpq $0x0, 0x30(%rsi)
je 0x8b77
movq %r14, %rdi
movq %r15, %rsi
callq 0x32f0
movq %r14, %rax
jmp 0x8f60
movq %rdx, %r12
movq %rsi, %r13
movl %r9d, -0x34(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, %rbx
movq %r14, -0x78(%rbp)
leaq -0x220(%rbp), %r14
movq %r14, %rdi
callq 0x8070
movq %r15, %rdi
movq %r14, %rsi
callq 0x32b0
movq %r14, %rdi
callq 0x3448
movq %r12, %rdi
callq 0x3100
leaq 0x137a3(%rip), %rsi     # 0x1c360
movq %r13, %r14
movq %r12, %r13
movq %r12, %rdi
callq 0x31d0
movq %rax, %rdi
movq %r15, -0x70(%rbp)
movq %r15, %rsi
callq 0x31d0
leaq 0x98dd(%rip), %rsi      # 0x124be
movq %rax, %rdi
callq 0x31f0
leaq 0x13790(%rip), %rsi     # 0x1c380
movq %rax, %rdi
callq 0x31d0
xorl %r15d, %r15d
movzbl 0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq %r14, %r12
movq (%r12), %r12
cmpq %r14, %r12
je 0x8c2b
leaq 0x10(%r12), %r15
movq %r15, %rdi
movq %r13, %rsi
movq -0x48(%rbp), %rdx
movq %rbx, %rcx
movl -0x2c(%rbp), %r8d
callq 0x928c
jmp 0x8c05
leaq -0x220(%rbp), %rdi
callq 0x3180
leaq -0x3a8(%rbp), %rdi
callq 0x3180
leaq -0x88(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %r14, -0x40(%rbp)
movq 0x20(%r14), %rsi
testq %rsi, %rsi
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
movzbl -0x34(%rbp), %eax
movl %eax, -0x30(%rbp)
movq %rbx, %r14
movq -0x48(%rbp), %rbx
jne 0x8d87
leaq -0x210(%rbp), %rdx
movl -0x2c(%rbp), %eax
movl %eax, (%rsp)
leaq -0x68(%rbp), %rdi
movq %rbx, %rcx
movq %r14, %r8
movl -0x30(%rbp), %r9d
callq 0x8b42
leaq -0x98(%rbp), %rdi
leaq -0x68(%rbp), %r12
movq %r12, %rsi
callq 0x32b0
movq %r12, %rdi
callq 0x3448
movzbl (%r15), %eax
cmpl $0x3c, %eax
je 0x8d1f
cmpl $0x3d, %eax
je 0x8cef
cmpl $0x3e, %eax
je 0x8d07
cmpl $0x65, %eax
jne 0x8d5d
leaq 0x13682(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x98e2(%rip), %rsi      # 0x125cf
jmp 0x8d35
leaq 0x1366a(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x98c5(%rip), %rsi      # 0x125ca
jmp 0x8d35
leaq 0x13652(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x98bb(%rip), %rsi      # 0x125d8
jmp 0x8d35
leaq 0x1363a(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x989e(%rip), %rsi      # 0x125d3
movq %rax, %rdi
callq 0x31f0
leaq -0x98(%rbp), %rsi
movq %rax, %rdi
callq 0x31d0
leaq 0x1362d(%rip), %rsi     # 0x1c380
movq %rax, %rdi
callq 0x31d0
jmp 0x8d87
movq 0x13264(%rip), %rdi     # 0x1bfc8
leaq 0x9872(%rip), %rsi      # 0x125dd
callq 0x31f0
leaq -0x98(%rbp), %rsi
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x3100
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rsi
testq %rsi, %rsi
je 0x8e01
leaq -0x398(%rbp), %rdx
movl -0x2c(%rbp), %eax
movl %eax, (%rsp)
leaq -0x68(%rbp), %rdi
movq %rbx, %rcx
movq %r14, %r8
movl -0x30(%rbp), %r9d
callq 0x8b42
leaq -0x98(%rbp), %rdi
leaq -0x68(%rbp), %rbx
movq %rbx, %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x3448
leaq 0x1358a(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x980c(%rip), %rsi      # 0x125f1
movq %rax, %rdi
callq 0x31f0
leaq -0x98(%rbp), %rsi
movq %rax, %rdi
callq 0x31d0
jmp 0x8eb7
cmpb $0x0, -0x34(%rbp)
je 0x8e22
leaq 0x13552(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x97d9(%rip), %rsi      # 0x125f6
jmp 0x8eaf
leaq 0x13537(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x97cc(%rip), %rsi      # 0x12604
movq %rax, %rdi
callq 0x31f0
movl 0x1358e(%rip), %esi     # 0x1c3d4
movq %rax, %rdi
callq 0x33d0
leaq 0x97b6(%rip), %rsi      # 0x1260b
movq %rax, %rdi
callq 0x31f0
leaq 0x1351c(%rip), %rsi     # 0x1c380
movq %rax, %rdi
callq 0x31d0
leaq 0x134ed(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x9791(%rip), %rsi      # 0x12613
movq %rax, %rdi
callq 0x31f0
leaq 0x134ef(%rip), %rsi     # 0x1c380
movq %rax, %rdi
callq 0x31d0
leaq 0x134c0(%rip), %rsi     # 0x1c360
movq %r13, %rdi
callq 0x31d0
leaq 0x976f(%rip), %rsi      # 0x1261e
movq %rax, %rdi
callq 0x31f0
leaq 0x134c2(%rip), %rsi     # 0x1c380
movq %rax, %rdi
callq 0x31d0
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
movq -0x78(%rbp), %rbx
movq -0x70(%rbp), %r14
je 0x8efe
leaq -0x208(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x3380
leaq -0x68(%rbp), %rsi
movq %r13, %rdi
callq 0x31d0
leaq -0x68(%rbp), %rdi
callq 0x3448
movq -0x40(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x8f2e
leaq -0x390(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x3380
leaq -0x68(%rbp), %rsi
movq %r13, %rdi
callq 0x31d0
leaq -0x68(%rbp), %rdi
callq 0x3448
leaq -0x98(%rbp), %rdi
callq 0x3448
leaq -0x3a8(%rbp), %rdi
callq 0x3190
leaq -0x220(%rbp), %rdi
callq 0x3190
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32f0
movq %rbx, %rax
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8f8f
jmp 0x8f78
jmp 0x8f8f
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x3448
jmp 0x8f92
jmp 0x8f8f
jmp 0x8f8f
movq %rax, %rbx
jmp 0x8faa
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x3448
leaq -0x3a8(%rbp), %rdi
callq 0x3190
leaq -0x220(%rbp), %rdi
callq 0x3190
movq %rbx, %rdi
callq 0x33f0