// File: /workspace/github_cpp_makefile_star2_O2/Merulo[P]CompilerJFTT/src/IRs/FirstIR.cpp
// Function: FirstIR::createSecondControlBlock(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Block FirstIR::createSecondControlBlock(std::string iterator, bool isForTo, std::string name)
{
    Block b = generateBlock();
    b.blockName = name + "_exitFor";    
    Line incLine;
    incLine.operation = "INC";
    incLine.one = iterator;

    Line decLine;
    decLine.operation = "DEC";
    decLine.one = iterator + forControlName;

    Line writeLine;
    writeLine.operation = "WRITE";
    writeLine.one = iterator + forControlName;    

    Line line;
    line.operation = "JZERO";
    line.one = iterator + forControlName;

    if (!isForTo)
    {
        incLine.operation = "DEC";
    }

    b.lines.push_back(incLine);
    b.lines.push_back(decLine);
    b.lines.push_back(line);    

    return b;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1c0, %rsp            # imm = 0x1C0
movq %r8, %r12
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1af06
leaq 0xfe10(%rip), %rdx      # 0x234c7
movq %rsp, %rdi
movq %r12, %rsi
callq 0x13a99
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4340
movq %r12, %rdi
callq 0x4548
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xf98d(%rip), %rsi      # 0x2309e
movq %rsp, %rdi
callq 0x44e0
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x4180
leaq 0x148(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x168(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x188(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xf932(%rip), %rsi      # 0x2309a
leaq 0x138(%rsp), %rdi
callq 0x44e0
addq $0x78, %r14
leaq 0xd0(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x10ba6
leaq 0x158(%rsp), %rdi
leaq 0xd0(%rsp), %r12
movq %r12, %rsi
callq 0x4340
movq %r12, %rdi
callq 0x4548
leaq 0xe0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x100(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x120(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xfce2(%rip), %rsi      # 0x234d0
leaq 0xd0(%rsp), %rdi
callq 0x44e0
leaq 0x68(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x10ba6
leaq 0xf0(%rsp), %rdi
leaq 0x68(%rsp), %r12
movq %r12, %rsi
callq 0x4340
movq %r12, %rdi
callq 0x4548
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xf915(%rip), %rsi      # 0x2317c
leaq 0x68(%rsp), %rdi
callq 0x44e0
leaq 0x1a0(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x10ba6
leaq 0x88(%rsp), %rdi
leaq 0x1a0(%rsp), %r14
movq %r14, %rsi
callq 0x4340
movq %r14, %rdi
callq 0x4548
testb %bpl, %bpl
jne 0x138b8
leaq 0xf7ea(%rip), %rsi      # 0x2309a
movq %rsp, %rdi
callq 0x44e0
leaq 0x20(%rbx), %r14
movq %rsp, %rsi
movq %r14, %rdi
callq 0x13a3e
leaq 0x138(%rsp), %rsi
movq %r14, %rdi
callq 0x13a3e
leaq 0x68(%rsp), %rsi
movq %r14, %rdi
callq 0x13a3e
leaq 0x68(%rsp), %rdi
callq 0x81fe
leaq 0xd0(%rsp), %rdi
callq 0x81fe
leaq 0x138(%rsp), %rdi
callq 0x81fe
movq %rsp, %rdi
callq 0x81fe
movq %rbx, %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1393d
jmp 0x13927
movq %rax, %r14
jmp 0x1394a
jmp 0x1392e
movq %rax, %r14
jmp 0x13957
movq %rax, %r14
jmp 0x1396c
movq %rax, %r14
jmp 0x13964
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x81fe
leaq 0xd0(%rsp), %rdi
callq 0x81fe
leaq 0x138(%rsp), %rdi
callq 0x81fe
movq %rsp, %rdi
callq 0x81fe
movq %rbx, %rdi
callq 0x13ad2
movq %r14, %rdi
callq 0x4490