// File: /workspace/github_cpp_makefile_star2_O1/Merulo[P]CompilerJFTT/src/IRs/SecondIR.cpp
// Function: SecondIR::stripForIterator(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Block&)
void SecondIR::stripForIterator(std::string variable, Block& b)
{
    auto firstLine = b.lines.front();
    auto lineToChange = b.lines.end();
    lineToChange--;
    lineToChange--;

    if (firstLine.operation == "CONST")
    {
        auto nextLine = b.lines.begin() + 1;
        if (nextLine->operation == "COPY")
        {
            nextLine->operation = "CONST";
            nextLine->two = firstLine.two;
        }
        auto prevprev = b.lines.end() - 2;
        if (prevprev->operation == "SUB" && prevprev->two == firstLine.one)
        {
            std::string var = getVariable(firstLine.two);
            Line line = {"CONST", var, firstLine.two};
            prevprev = b.lines.insert(prevprev, line);
            prevprev++;
            prevprev->two = var;
        }
        b.lines.erase(b.lines.begin());
    }
    else
    {
        lineToChange->two = firstLine.two;
        b.lines.erase(b.lines.begin());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdx, %r14
movq %rdi, %r15
movq 0x20(%rdx), %r13
leaq 0x18(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xca12
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x20(%r13), %rsi
movq 0x28(%r13), %rdx
addq %rsi, %rdx
callq 0xca12
leaq 0x48(%rsp), %r12
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x40(%r13), %rsi
movq 0x48(%r13), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xca12
leaq 0x20(%r14), %rbx
movl 0x60(%r13), %eax
leaq 0x8(%rsp), %rdi
movl %eax, 0x60(%rdi)
movq 0x28(%r14), %r13
leaq 0x16746(%rip), %rsi     # 0x38521
callq 0x40d0
testl %eax, %eax
je 0x21e06
addq $-0x90, %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x4170
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x242a4
jmp 0x220a5
movq (%rbx), %r13
leaq 0x68(%r13), %rbp
leaq 0x162b1(%rip), %rsi     # 0x380c5
movq %rbp, %rdi
callq 0x40d0
testl %eax, %eax
jne 0x21e4d
movq 0x70(%r13), %rdx
leaq 0x166f6(%rip), %rcx     # 0x38521
movl $0x5, %r8d
movq %rbp, %rdi
xorl %esi, %esi
callq 0x4440
addq $0xa8, %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x4170
movq 0x28(%r14), %r12
leaq -0xd0(%r12), %r14
leaq 0x16236(%rip), %rsi     # 0x38096
movq %r14, %rdi
callq 0x40d0
testl %eax, %eax
leaq 0x18(%rsp), %rbp
jne 0x2209a
movq -0x88(%r12), %rdx
cmpq 0x30(%rsp), %rdx
jne 0x2209a
testq %rdx, %rdx
je 0x21ea7
movq 0x28(%rsp), %rsi
movq -0x90(%r12), %rdi
callq 0x42b0
testl %eax, %eax
jne 0x2209a
leaq 0x100(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0xf0(%rsp), %rdi
callq 0xca12
leaq 0x70(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
movq %r15, %rsi
callq 0x2b8d6
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0x21f00
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xe0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1660e(%rip), %rsi     # 0x38521
leaq 0x1660c(%rip), %rdx     # 0x38526
leaq 0xd0(%rsp), %rdi
callq 0x54fc
leaq 0xc0(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %rdi
callq 0xca12
leaq 0xa0(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0xca12
leaq 0x110(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0xbe58
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0x21fb6
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x21fd3
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
je 0x21ff0
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x110(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x24010
addq $0xa8, %rax
leaq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x4170
leaq 0x160(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x22037
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x140(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x22058
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x22079
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2209a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x242a4
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
leaq 0x38(%rsp), %rbx
je 0x220c6
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x220dd
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x220f4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x22108
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0xbf10
jmp 0x22183
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0x2213f
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2213f
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x22161
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x22161
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
je 0x22183
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x22183
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x221cb
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x221cb
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0x221cb
movq 0x100(%rsp), %rsi
jmp 0x2219c
jmp 0x221c8
jmp 0x221c8
jmp 0x221c8
jmp 0x221c8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xbf10
jmp 0x22212
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x221fb
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x221fb
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x22212
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0