// File: /workspace/github_cpp_makefile_star2_O1/Merulo[P]CompilerJFTT/src/IRs/FirstIR.cpp
// Function: FirstIR::createBeforeForBlock(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Data, Data, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Block FirstIR::createBeforeForBlock(std::string iterator, Data from, Data to, bool isForTo, std::string name)
{
    Block b = generateBlock();
    b.blockName = name + "_initialForControl";
    Line iteratorInit = getLine(from);
    iteratorInit.one = iterator;

    Line counterInit = getLine(to);
    counterInit.one = iterator + forControlName;

    Line counterFinal = getLine(from);
    counterFinal.operation = "SUB";
    counterFinal.one = counterInit.one;
    counterFinal.two = iterator;

    Line inclusiveFor;
    inclusiveFor.operation = "INC";
    inclusiveFor.one = counterInit.one;

    Line l;
    if (!isForTo)
    {
        std::swap(counterInit.two, counterFinal.two);
        if (counterInit.operation == "CONST")
        {
            counterInit.operation = "COPY";
            
            std::string var = getVariable(counterFinal.two);
            l.operation = "CONST";
            l.one = var;
            l.two = counterFinal.two;
            counterFinal.two = var;
        }
    }

    b.lines.push_back(iteratorInit);
    b.lines.push_back(counterInit);
    b.lines.push_back(inclusiveFor);

    if (!isForTo && !l.operation.empty())
    {
        b.lines.push_back(l);
    }
    
    b.lines.push_back(counterFinal);
    
    Line jump;
    jump.operation = "JZERO";
    jump.one = counterInit.one;
    b.lines.push_back(jump);
    return b;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movl %r9d, 0x4(%rsp)
movq %r8, %r14
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbp
movq 0x350(%rsp), %rbx
callq 0x2b716
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
movq %rbp, 0x8(%rsp)
callq 0xca12
leaq 0x199cd(%rip), %rsi     # 0x384b4
leaq 0x98(%rsp), %rdi
callq 0x4510
leaq 0x98(%rsp), %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x4380
movq (%rbx), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1eb27
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%r13), %rax
leaq 0x1c0(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x1d0(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
addq %rsi, %rdx
callq 0xca12
leaq 0x98(%rsp), %rdi
leaq 0x1b8(%rsp), %rdx
callq 0x1f860
movq 0x1c0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1eb85
movq 0x1d0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
callq 0x4170
movq (%r14), %rax
leaq 0x198(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x1a8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
addq %rsi, %rdx
callq 0xca12
leaq 0x2b0(%rsp), %rdi
leaq 0x190(%rsp), %rdx
callq 0x1f860
movq 0x198(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1ebf2
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x78(%r15), %rdx
leaq 0x100(%rsp), %rdi
movq %r12, %rsi
callq 0x1b6da
leaq 0x2d0(%rsp), %r14
leaq 0x100(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4380
movq (%rbx), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0x1ec41
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%r13), %rax
leaq 0x170(%rsp), %rdi
movq %rax, -0x8(%rdi)
leaq 0x180(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
addq %rsi, %rdx
callq 0xca12
leaq 0x100(%rsp), %rdi
leaq 0x168(%rsp), %rdx
callq 0x1f860
movq 0x170(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1ec9f
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x100(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x193e4(%rip), %rcx     # 0x38096
movl $0x3, %r8d
xorl %esi, %esi
callq 0x4440
leaq 0x120(%rsp), %rdi
movq %r14, %rsi
callq 0x4170
leaq 0x140(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x4170
leaq 0x258(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x278(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x298(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x1937d(%rip), %rcx     # 0x3809e
leaq 0x248(%rsp), %rdi
movl $0x3, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4440
leaq 0x268(%rsp), %rdi
movq %r14, %rsi
callq 0x4170
leaq 0x1f0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x210(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq %rax, -0x8(%rbx)
movb %al, (%rbx)
leaq 0x230(%rsp), %r14
movq %r14, -0x10(%r14)
movq %rax, -0x8(%r14)
movb %al, (%r14)
movl 0x4(%rsp), %r12d
testb %r12b, %r12b
jne 0x1ee9a
leaq 0x2f0(%rsp), %rdi
movq %r13, %rsi
callq 0x41f0
leaq 0x1977b(%rip), %rsi     # 0x38521
leaq 0x2b0(%rsp), %rdi
callq 0x40d0
testl %eax, %eax
jne 0x1ee9a
leaq 0x2b0(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x192f7(%rip), %rcx     # 0x380c5
movl $0x4, %r8d
xorl %esi, %esi
callq 0x4440
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x140(%rsp), %rsi
movq 0x148(%rsp), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0xca12
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
callq 0x2b8d6
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x1ee2b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x1e0(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x196e3(%rip), %rcx     # 0x38521
movl $0x5, %r8d
xorl %esi, %esi
callq 0x4440
movl 0x4(%rsp), %r12d
leaq 0x200(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x4170
leaq 0x220(%rsp), %rdi
movq %r13, %rsi
callq 0x4170
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
callq 0x4170
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1ee9a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x20(%rbp), %r15
leaq 0x98(%rsp), %rsi
movq %r15, %rdi
callq 0x1f9be
leaq 0x2b0(%rsp), %rsi
movq %r15, %rdi
callq 0x1f9be
leaq 0x248(%rsp), %rsi
movq %r15, %rdi
callq 0x1f9be
testb %r12b, %r12b
jne 0x1eeee
cmpq $0x0, 0x1e8(%rsp)
je 0x1eeee
leaq 0x1e0(%rsp), %rsi
movq %r15, %rdi
callq 0x1f9be
leaq 0x100(%rsp), %rsi
movq %r15, %rdi
callq 0x1f9be
leaq 0x40(%rsp), %r13
movq %r13, -0x10(%r13)
xorl %eax, %eax
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x80(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0x1923e(%rip), %rcx     # 0x3817c
leaq 0x30(%rsp), %rdi
movl $0x5, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4440
leaq 0x50(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x4170
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0x1f9be
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x1ef8b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
movq 0x8(%rsp), %r15
je 0x1efa7
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x1efbe
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x220(%rsp), %rdi
cmpq %r14, %rdi
je 0x1efdb
movq 0x230(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x200(%rsp), %rdi
cmpq %rbx, %rdi
leaq 0x110(%rsp), %rbx
je 0x1f000
movq 0x210(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0x1f025
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x288(%rsp), %rdi
leaq 0x298(%rsp), %rax
cmpq %rax, %rdi
je 0x1f04a
movq 0x298(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x268(%rsp), %rdi
leaq 0x278(%rsp), %rax
cmpq %rax, %rdi
je 0x1f06f
movq 0x278(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x248(%rsp), %rdi
leaq 0x258(%rsp), %rax
cmpq %rax, %rdi
je 0x1f094
movq 0x258(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f0b5
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f0d6
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1f0f3
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x300(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f114
movq 0x300(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f135
movq 0x2e0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2c0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f156
movq 0x2c0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f177
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f198
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1f1bd
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %r15, %rax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x1f2e7
movq 0x20(%rsp), %rsi
jmp 0x1f209
jmp 0x1f2e4
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f2e7
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1f2e7
movq %rax, %r14
movq 0x170(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1f30e
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1f30e
jmp 0x1f241
movq %rax, %r14
jmp 0x1f30e
movq %rax, %r14
movq 0x198(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1f31b
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1f31b
jmp 0x1f274
movq %rax, %r14
jmp 0x1f31b
movq %rax, %r14
movq 0x1c0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1f328
movq 0x1d0(%rsp), %rsi
jmp 0x1f2bc
jmp 0x1f2c6
movq %rax, %r14
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1f328
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1f328
movq %rax, %r14
jmp 0x1f328
movq %rax, %r14
jmp 0x1f2f4
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0xbf10
jmp 0x1f2e7
movq %rax, %r14
jmp 0x1f301
movq %rax, %r14
leaq 0x1e0(%rsp), %rdi
callq 0xbf10
leaq 0x248(%rsp), %rdi
callq 0xbf10
leaq 0x100(%rsp), %rdi
callq 0xbf10
leaq 0x2b0(%rsp), %rdi
callq 0xbf10
leaq 0x98(%rsp), %rdi
callq 0xbf10
movq 0x8(%rsp), %rdi
callq 0x1fa18
movq %r14, %rdi
callq 0x44c0