// File: /workspace/github_cpp_makefile_star2_O3/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 0x2b47a
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 0xc7aa
leaq 0x18c95(%rip), %rsi     # 0x374b4
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 0x1e85f
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 0xc7aa
leaq 0x98(%rsp), %rdi
leaq 0x1b8(%rsp), %rdx
callq 0x1f598
movq 0x1c0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1e8bd
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 0xc7aa
leaq 0x2b0(%rsp), %rdi
leaq 0x190(%rsp), %rdx
callq 0x1f598
movq 0x198(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1e92a
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x78(%r15), %rdx
leaq 0x100(%rsp), %rdi
movq %r12, %rsi
callq 0x1b41c
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 0x1e979
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 0xc7aa
leaq 0x100(%rsp), %rdi
leaq 0x168(%rsp), %rdx
callq 0x1f598
movq 0x170(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1e9d7
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x100(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x186ac(%rip), %rcx     # 0x37096
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 0x18645(%rip), %rcx     # 0x3709e
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 0x1ebd2
leaq 0x2f0(%rsp), %rdi
movq %r13, %rsi
callq 0x41f0
leaq 0x18a43(%rip), %rsi     # 0x37521
leaq 0x2b0(%rsp), %rdi
callq 0x40d0
testl %eax, %eax
jne 0x1ebd2
leaq 0x2b0(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x185bf(%rip), %rcx     # 0x370c5
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 0xc7aa
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
callq 0x2b63a
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x1eb63
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x1e0(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x189ab(%rip), %rcx     # 0x37521
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 0x1ebd2
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x20(%rbp), %r15
leaq 0x98(%rsp), %rsi
movq %r15, %rdi
callq 0x1f6f6
leaq 0x2b0(%rsp), %rsi
movq %r15, %rdi
callq 0x1f6f6
leaq 0x248(%rsp), %rsi
movq %r15, %rdi
callq 0x1f6f6
testb %r12b, %r12b
jne 0x1ec26
cmpq $0x0, 0x1e8(%rsp)
je 0x1ec26
leaq 0x1e0(%rsp), %rsi
movq %r15, %rdi
callq 0x1f6f6
leaq 0x100(%rsp), %rsi
movq %r15, %rdi
callq 0x1f6f6
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 0x18506(%rip), %rcx     # 0x3717c
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 0x1f6f6
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x1ecc3
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
movq 0x8(%rsp), %r15
je 0x1ecdf
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x1ecf6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x220(%rsp), %rdi
cmpq %r14, %rdi
je 0x1ed13
movq 0x230(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x200(%rsp), %rdi
cmpq %rbx, %rdi
leaq 0x110(%rsp), %rbx
je 0x1ed38
movq 0x210(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0x1ed5d
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x288(%rsp), %rdi
leaq 0x298(%rsp), %rax
cmpq %rax, %rdi
je 0x1ed82
movq 0x298(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x268(%rsp), %rdi
leaq 0x278(%rsp), %rax
cmpq %rax, %rdi
je 0x1eda7
movq 0x278(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x248(%rsp), %rdi
leaq 0x258(%rsp), %rax
cmpq %rax, %rdi
je 0x1edcc
movq 0x258(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1eded
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1ee0e
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x100(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1ee2b
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x300(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1ee4c
movq 0x300(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1ee6d
movq 0x2e0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x2c0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1ee8e
movq 0x2c0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1eeaf
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1eed0
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1eef5
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 0x1f01f
movq 0x20(%rsp), %rsi
jmp 0x1ef41
jmp 0x1f01c
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1f01f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1f01f
movq %rax, %r14
movq 0x170(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1f046
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1f046
jmp 0x1ef79
movq %rax, %r14
jmp 0x1f046
movq %rax, %r14
movq 0x198(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1f053
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1f053
jmp 0x1efac
movq %rax, %r14
jmp 0x1f053
movq %rax, %r14
movq 0x1c0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1f060
movq 0x1d0(%rsp), %rsi
jmp 0x1eff4
jmp 0x1effe
movq %rax, %r14
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1f060
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1f060
movq %rax, %r14
jmp 0x1f060
movq %rax, %r14
jmp 0x1f02c
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0xbca2
jmp 0x1f01f
movq %rax, %r14
jmp 0x1f039
movq %rax, %r14
leaq 0x1e0(%rsp), %rdi
callq 0xbca2
leaq 0x248(%rsp), %rdi
callq 0xbca2
leaq 0x100(%rsp), %rdi
callq 0xbca2
leaq 0x2b0(%rsp), %rdi
callq 0xbca2
leaq 0x98(%rsp), %rdi
callq 0xbca2
movq 0x8(%rsp), %rdi
callq 0x1f750
movq %r14, %rdi
callq 0x44c0