// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/IRs/FirstIR.cpp
// Function: FirstIR::insertFor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Data, Data, bool)
void FirstIR::insertFor(std::string iterator, Data from, Data to, bool isForTo)
{
    closeForBlock();
    Block b1 = _forBlocks.top();
    _forBlocks.pop();
    Block b2 = _forBlocks.top();
    _forBlocks.pop();

    std::string name = generateForName();
    Block firstControlBlock = createBeforeForBlock(iterator, from, to, isForTo, name);
    firstControlBlock.blockIfFalse = b2.blockName;
    firstControlBlock.blockIfTrue = b1.blockName;

    Block secondControlBlock = createSecondControlBlock(iterator, isForTo, name);
    secondControlBlock.blockIfFalse = b2.blockName;
    secondControlBlock.blockIfTrue = b1.blockName;        
    
    for(size_t i = 0; i < _blocks.size(); i++)
    {
        if (_blocks[i] == b2)
        {
            _blocks.insert(_blocks.begin() + i, firstControlBlock);
            break;
        }
    }

    _blocks.push_back(_currentBlock.top());
    _currentBlock.pop();
    Block testing = generateBlock();
    _currentBlock.push(testing);

    for(size_t i = 0; i < _blocks.size(); i++)
    {
        if (_blocks[i] == b1)
        {
            _blocks.insert(_blocks.begin() + i, secondControlBlock);
            return;
        }
    }        

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movl %r8d, %ebp
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1db80
leaq 0x168(%rbx), %r13
movq 0x198(%rbx), %rsi
cmpq 0x1a0(%rbx), %rsi
jne 0x1df7c
movq 0x1b0(%rbx), %rax
movl $0x1e0, %esi            # imm = 0x1E0
addq -0x8(%rax), %rsi
addq $-0xa0, %rsi
leaq 0x198(%rsp), %rdi
callq 0x1f7c2
movq %r13, %rdi
callq 0x201c0
movq 0x198(%rbx), %rsi
cmpq 0x1a0(%rbx), %rsi
jne 0x1dfb8
movq 0x1b0(%rbx), %rax
movl $0x1e0, %esi            # imm = 0x1E0
addq -0x8(%rax), %rsi
addq $-0xa0, %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f7c2
movq %r13, %rdi
callq 0x201c0
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x2b88a
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xc7aa
movq (%r12), %rax
leaq 0x50(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
callq 0xc7aa
movq (%r15), %rax
leaq 0xd8(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0xe8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
callq 0xc7aa
leaq 0xc0(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
callq 0xc7aa
movq %r15, (%rsp)
movzbl %bpl, %ebp
leaq 0x2d8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x48(%rsp), %rcx
leaq 0xd0(%rsp), %r8
movq %rbx, %rsi
movl %ebp, %r9d
callq 0x1e7be
movq 0xb0(%rsp), %rdi
cmpq %r13, %rdi
je 0x1e0c5
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
leaq 0x18(%rsp), %r15
leaq 0x60(%rsp), %r12
je 0x1e0ec
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1e103
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1e11a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x330(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x4170
leaq 0x310(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x4170
leaq 0xa0(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0xc7aa
leaq 0x80(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0xc7aa
leaq 0x238(%rsp), %rdi
leaq 0x90(%rsp), %rdx
leaq 0x70(%rsp), %r8
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x1f072
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e1c3
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x1e1e0
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x290(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x4170
leaq 0x270(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x4170
leaq 0x10(%rbx), %r14
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %rbp
subq %r15, %rbp
je 0x1e283
sarq $0x5, %rbp
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rbp
movq 0xf8(%rsp), %r12
movq 0x100(%rsp), %r13
cmpq $0x1, %rbp
adcq $0x0, %rbp
cmpq %r13, 0x8(%r15)
jne 0x1e262
testq %r13, %r13
je 0x1e270
movq (%r15), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x42b0
testl %eax, %eax
je 0x1e270
addq $0xa0, %r15
decq %rbp
jne 0x1e245
jmp 0x1e283
leaq 0x2d8(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x1f8f2
movq 0x58(%rbx), %rsi
cmpq 0x60(%rbx), %rsi
jne 0x1e29a
movq 0x70(%rbx), %rax
movl $0x1e0, %esi            # imm = 0x1E0
addq -0x8(%rax), %rsi
addq $-0xa0, %rsi
movq %r14, %rdi
callq 0x1f720
leaq 0x28(%rbx), %r15
movq %r15, %rdi
callq 0x201c0
leaq 0x378(%rsp), %rdi
movq %rbx, %rsi
callq 0x2b47a
leaq 0x378(%rsp), %rsi
movq %r15, %rdi
callq 0x1ff14
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %r13
subq %r15, %r13
je 0x1e34a
sarq $0x5, %r13
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %r13
movq 0x198(%rsp), %rbx
movq 0x1a0(%rsp), %r12
cmpq $0x1, %r13
adcq $0x0, %r13
cmpq %r12, 0x8(%r15)
jne 0x1e329
testq %r12, %r12
je 0x1e337
movq (%r15), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x42b0
testl %eax, %eax
je 0x1e337
addq $0xa0, %r15
decq %r13
jne 0x1e30c
jmp 0x1e34a
leaq 0x238(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x1f8f2
leaq 0x400(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e36b
movq 0x400(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x3e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e38c
movq 0x3e0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x3c0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e3ad
movq 0x3c0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x398(%rsp), %rbx
movq %rbx, %rdi
callq 0xbcf0
movq -0x20(%rbx), %rdi
leaq 0x388(%rsp), %rax
cmpq %rax, %rdi
je 0x1e3de
movq 0x388(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2c0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e3ff
movq 0x2c0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e420
movq 0x2a0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x280(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e441
movq 0x280(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x258(%rsp), %rbx
movq %rbx, %rdi
callq 0xbcf0
movq -0x20(%rbx), %rdi
leaq 0x248(%rsp), %rax
cmpq %rax, %rdi
je 0x1e472
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x360(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e493
movq 0x360(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x340(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e4b4
movq 0x340(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x320(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e4d5
movq 0x320(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2f8(%rsp), %rbx
movq %rbx, %rdi
callq 0xbcf0
movq -0x20(%rbx), %rdi
leaq 0x2e8(%rsp), %rax
cmpq %rax, %rdi
je 0x1e506
movq 0x2e8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e521
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x180(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e542
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x160(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e563
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x140(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e584
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x118(%rsp), %rbx
movq %rbx, %rdi
callq 0xbcf0
movq -0x20(%rbx), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x1e5b5
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x220(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e5d6
movq 0x220(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x200(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e5f7
movq 0x200(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x1e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e618
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x1b8(%rsp), %rbx
movq %rbx, %rdi
callq 0xbcf0
movq -0x20(%rbx), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x1e649
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1e662
jmp 0x1e763
movq %rax, %rbx
leaq 0x378(%rsp), %rdi
callq 0x1f750
jmp 0x1e766
jmp 0x1e763
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e69e
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e69e
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x1e773
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e773
jmp 0x1e75e
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r13, %rdi
je 0x1e6ee
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e6ee
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1e710
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e710
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1e731
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e731
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1e780
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e780
movq %rax, %rbx
jmp 0x1e780
movq %rax, %rbx
jmp 0x1e79b
movq %rax, %rbx
jmp 0x1e7a8
movq %rax, %rbx
jmp 0x1e773
movq %rax, %rbx
leaq 0x238(%rsp), %rdi
callq 0x1f750
leaq 0x2d8(%rsp), %rdi
callq 0x1f750
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e79b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xf8(%rsp), %rdi
callq 0x1f750
leaq 0x198(%rsp), %rdi
callq 0x1f750
movq %rbx, %rdi
callq 0x44c0
nop