// File: /workspace/github_cpp_makefile_star2_O1/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 0xa49e
leaq 0x10(%r14), %rax
movq %rax, (%r14)
movq (%rbx), %rsi
addq %rsi, %rdx
movq %r14, %rdi
callq 0x4baa
movq %r14, %rax
jmp 0xaa61
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 0x9010
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3320
movq (%r15), %rdi
leaq -0x218(%rbp), %rax
cmpq %rax, %rdi
je 0xa4e3
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 0x14e8e(%rip), %rsi     # 0x1f3a0
movq 0x14e8f(%rip), %rdx     # 0x1f3a8
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 0xbf96(%rip), %rsi      # 0x164d9
movl $0x1, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x14e69(%rip), %rsi     # 0x1f3c0
movq 0x14e6a(%rip), %rdx     # 0x1f3c8
movq %rbx, %rdi
callq 0x32b0
movq (%r15), %r14
cmpq %r15, %r14
je 0xa5a5
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 0xaef5
movq (%r14), %r14
cmpq -0x38(%rbp), %r14
jne 0xa581
jmp 0xa5a7
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 0xa7c3
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 0xa45a
leaq -0x98(%rbp), %rdi
leaq -0x70(%rbp), %r15
movq %r15, %rsi
callq 0x3320
movq (%r15), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xa64a
callq 0x3230
movzbl (%rbx), %eax
cmpl $0x3d, %eax
jg 0xa696
cmpl $0x3c, %eax
movq -0x38(%rbp), %r15
je 0xa73b
cmpl $0x3d, %eax
jne 0xa6da
movq 0x14d35(%rip), %rsi     # 0x1f3a0
movq 0x14d36(%rip), %rdx     # 0x1f3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbf61(%rip), %rsi      # 0x165e5
movl $0x4, %edx
movq %rax, %rdi
callq 0x32b0
jmp 0xa797
cmpl $0x3e, %eax
movq -0x38(%rbp), %r15
je 0xa76a
cmpl $0x65, %eax
jne 0xa6da
movq 0x14cf1(%rip), %rsi     # 0x1f3a0
movq 0x14cf2(%rip), %rdx     # 0x1f3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbf22(%rip), %rsi      # 0x165ea
movl $0x3, %edx
movq %rax, %rdi
callq 0x32b0
jmp 0xa797
movq 0x148ef(%rip), %rdi     # 0x1efd0
leaq 0xbf10(%rip), %rsi      # 0x165f8
movl $0x13, %edx
callq 0x32b0
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq 0x148c9(%rip), %rdi     # 0x1efd0
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 0xa7c3
movq 0x14c5e(%rip), %rsi     # 0x1f3a0
movq 0x14c5f(%rip), %rdx     # 0x1f3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbe93(%rip), %rsi      # 0x165ee
movl $0x4, %edx
movq %rax, %rdi
callq 0x32b0
jmp 0xa797
movq 0x14c2f(%rip), %rsi     # 0x1f3a0
movq 0x14c30(%rip), %rdx     # 0x1f3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbe69(%rip), %rsi      # 0x165f3
movl $0x4, %edx
movq %rax, %rdi
callq 0x32b0
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq %rbx, %rdi
callq 0x32b0
movq 0x14c0c(%rip), %rsi     # 0x1f3c0
movq 0x14c0d(%rip), %rdx     # 0x1f3c8
movq %rax, %rdi
callq 0x32b0
movq 0x18(%r15), %rsi
testq %rsi, %rsi
je 0xa862
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 0xa45a
leaq -0x98(%rbp), %rdi
leaq -0x70(%rbp), %rbx
movq %rbx, %rsi
callq 0x3320
movq (%rbx), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xa817
callq 0x3230
movq 0x14b82(%rip), %rsi     # 0x1f3a0
movq 0x14b83(%rip), %rdx     # 0x1f3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbdd5(%rip), %rsi      # 0x1660c
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 0xa964
movq 0x14b37(%rip), %rsi     # 0x1f3a0
movq 0x14b38(%rip), %rdx     # 0x1f3a8
cmpb $0x0, -0x3c(%rbp)
je 0xa89a
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbd89(%rip), %rsi      # 0x16611
movl $0xd, %edx
movq %rax, %rdi
callq 0x32b0
jmp 0xa964
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbd73(%rip), %rsi      # 0x1661f
movl $0x6, %edx
movq %rax, %rdi
callq 0x32b0
movl 0x14b55(%rip), %esi     # 0x1f414
movq %rbx, %rdi
callq 0x3450
movq %rax, %rbx
leaq 0xbd55(%rip), %rsi      # 0x16626
movl $0x7, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x14adb(%rip), %rsi     # 0x1f3c0
movq 0x14adc(%rip), %rdx     # 0x1f3c8
movq %rbx, %rdi
callq 0x32b0
movq 0x14aa5(%rip), %rsi     # 0x1f3a0
movq 0x14aa6(%rip), %rdx     # 0x1f3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbd1a(%rip), %rsi      # 0x1662e
movl $0xa, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x14a98(%rip), %rsi     # 0x1f3c0
movq 0x14a99(%rip), %rdx     # 0x1f3c8
movq %rbx, %rdi
callq 0x32b0
movq 0x14a62(%rip), %rsi     # 0x1f3a0
movq 0x14a63(%rip), %rdx     # 0x1f3a8
movq %r14, %rdi
callq 0x32b0
movq %rax, %rbx
leaq 0xbce2(%rip), %rsi      # 0x16639
movl $0x3, %edx
movq %rax, %rdi
callq 0x32b0
movq 0x14a55(%rip), %rsi     # 0x1f3c0
movq 0x14a56(%rip), %rdx     # 0x1f3c8
movq %rbx, %rdi
callq 0x32b0
cmpq $0x0, 0x20(%r15)
je 0xa9b3
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 0xa9b3
callq 0x3230
cmpq $0x0, 0x18(%r15)
je 0xa9ec
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 0xa9ec
callq 0x3230
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0xa9fd
callq 0x3230
movq 0x14594(%rip), %rbx     # 0x1ef98
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 0xaa99
jmp 0xaa79
jmp 0xaa99
movq %rax, %rbx
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xaa9c
callq 0x3230
jmp 0xaa9c
jmp 0xaa99
jmp 0xaa99
movq %rax, %rbx
jmp 0xaacc
movq %rax, %rbx
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0xaaad
callq 0x3230
movq 0x144e4(%rip), %rsi     # 0x1ef98
leaq -0x3b0(%rbp), %rdi
callq 0x31c0
leaq -0x330(%rbp), %rdi
callq 0x30c0
movq 0x144c5(%rip), %rsi     # 0x1ef98
leaq -0x228(%rbp), %rdi
callq 0x31c0
leaq -0x1a8(%rbp), %rdi
callq 0x30c0
movq %rbx, %rdi
callq 0x3470