// File: /workspace/github_cpp_makefile_star2_O1/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 0x1de4c
leaq 0x168(%rbx), %r13
movq 0x198(%rbx), %rsi
cmpq 0x1a0(%rbx), %rsi
jne 0x1e24a
movq 0x1b0(%rbx), %rax
movl $0x1e0, %esi            # imm = 0x1E0
addq -0x8(%rax), %rsi
addq $-0xa0, %rsi
leaq 0x198(%rsp), %rdi
callq 0x1fa8a
movq %r13, %rdi
callq 0x20488
movq 0x198(%rbx), %rsi
cmpq 0x1a0(%rbx), %rsi
jne 0x1e286
movq 0x1b0(%rbx), %rax
movl $0x1e0, %esi            # imm = 0x1E0
addq -0x8(%rax), %rsi
addq $-0xa0, %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1fa8a
movq %r13, %rdi
callq 0x20488
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x2bb26
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xca12
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 0xca12
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 0xca12
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 0xca12
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 0x1ea86
movq 0xb0(%rsp), %rdi
cmpq %r13, %rdi
je 0x1e393
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
leaq 0x18(%rsp), %r15
leaq 0x60(%rsp), %r12
je 0x1e3ba
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x1e3d1
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1e3e8
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 0xca12
leaq 0x80(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0xca12
leaq 0x238(%rsp), %rdi
leaq 0x90(%rsp), %rdx
leaq 0x70(%rsp), %r8
movq %rbx, %rsi
movl %ebp, %ecx
callq 0x1f33a
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e491
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x1e4ae
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
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %r13
movabsq $-0x3333333333333333, %r12 # imm = 0xCCCCCCCCCCCCCCCD
subq %r15, %r13
je 0x1e538
sarq $0x5, %r13
imulq %r12, %r13
movq 0xf8(%rsp), %r14
movq 0x100(%rsp), %rbp
cmpq $0x1, %r13
adcq $0x0, %r13
movq 0x8(%r15), %rdx
cmpq %rbp, %rdx
jne 0x1e52c
testq %rdx, %rdx
je 0x1e53e
movq (%r15), %rdi
movq %r14, %rsi
callq 0x42b0
testl %eax, %eax
je 0x1e53e
addq $0xa0, %r15
decq %r13
jne 0x1e50f
leaq 0x10(%rbx), %r14
jmp 0x1e555
leaq 0x10(%rbx), %r14
leaq 0x2d8(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x1fbba
movq 0x58(%rbx), %rsi
cmpq 0x60(%rbx), %rsi
jne 0x1e56c
movq 0x70(%rbx), %rax
movl $0x1e0, %esi            # imm = 0x1E0
addq -0x8(%rax), %rsi
addq $-0xa0, %rsi
movq %r14, %rdi
callq 0x1f9e8
leaq 0x28(%rbx), %r15
movq %r15, %rdi
callq 0x20488
leaq 0x378(%rsp), %rdi
movq %rbx, %rsi
callq 0x2b716
leaq 0x378(%rsp), %rsi
movq %r15, %rdi
callq 0x201dc
movq 0x10(%rbx), %r15
movq 0x18(%rbx), %r13
subq %r15, %r13
je 0x1e612
sarq $0x5, %r13
imulq %r12, %r13
movq 0x198(%rsp), %rbx
movq 0x1a0(%rsp), %r12
cmpq $0x1, %r13
adcq $0x0, %r13
movq 0x8(%r15), %rdx
cmpq %r12, %rdx
jne 0x1e5f1
testq %rdx, %rdx
je 0x1e5ff
movq (%r15), %rdi
movq %rbx, %rsi
callq 0x42b0
testl %eax, %eax
je 0x1e5ff
addq $0xa0, %r15
decq %r13
jne 0x1e5d4
jmp 0x1e612
leaq 0x238(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x1fbba
leaq 0x400(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e633
movq 0x400(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x3e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e654
movq 0x3e0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x3c0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e675
movq 0x3c0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x398(%rsp), %rbx
movq %rbx, %rdi
callq 0xbf5e
movq -0x20(%rbx), %rdi
leaq 0x388(%rsp), %rax
cmpq %rax, %rdi
je 0x1e6a6
movq 0x388(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2c0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e6c7
movq 0x2c0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e6e8
movq 0x2a0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x280(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e709
movq 0x280(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x258(%rsp), %rbx
movq %rbx, %rdi
callq 0xbf5e
movq -0x20(%rbx), %rdi
leaq 0x248(%rsp), %rax
cmpq %rax, %rdi
je 0x1e73a
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x360(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e75b
movq 0x360(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x340(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e77c
movq 0x340(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x320(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e79d
movq 0x320(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2f8(%rsp), %rbx
movq %rbx, %rdi
callq 0xbf5e
movq -0x20(%rbx), %rdi
leaq 0x2e8(%rsp), %rax
cmpq %rax, %rdi
je 0x1e7ce
movq 0x2e8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e7e9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x180(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e80a
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x160(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e82b
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x140(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e84c
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x118(%rsp), %rbx
movq %rbx, %rdi
callq 0xbf5e
movq -0x20(%rbx), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x1e87d
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x220(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e89e
movq 0x220(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x200(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e8bf
movq 0x200(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x1e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1e8e0
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x1b8(%rsp), %rbx
movq %rbx, %rdi
callq 0xbf5e
movq -0x20(%rbx), %rdi
leaq 0x1a8(%rsp), %rax
cmpq %rax, %rdi
je 0x1e911
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 0x1e92a
jmp 0x1ea2b
movq %rax, %rbx
leaq 0x378(%rsp), %rdi
callq 0x1fa18
jmp 0x1ea2e
jmp 0x1ea2b
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x1e966
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e966
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x1ea3b
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1ea3b
jmp 0x1ea26
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r13, %rdi
je 0x1e9b6
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e9b6
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1e9d8
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e9d8
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1e9f9
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1e9f9
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1ea48
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1ea48
movq %rax, %rbx
jmp 0x1ea48
movq %rax, %rbx
jmp 0x1ea63
movq %rax, %rbx
jmp 0x1ea70
movq %rax, %rbx
jmp 0x1ea3b
movq %rax, %rbx
leaq 0x238(%rsp), %rdi
callq 0x1fa18
leaq 0x2d8(%rsp), %rdi
callq 0x1fa18
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1ea63
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xf8(%rsp), %rdi
callq 0x1fa18
leaq 0x198(%rsp), %rdi
callq 0x1fa18
movq %rbx, %rdi
callq 0x44c0
nop