// File: /workspace/github_cpp_makefile_star2_O3/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 0xc7aa
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x20(%r13), %rsi
movq 0x28(%r13), %rdx
addq %rsi, %rdx
callq 0xc7aa
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 0xc7aa
leaq 0x20(%r14), %rbx
movl 0x60(%r13), %eax
leaq 0x8(%rsp), %rdi
movl %eax, 0x60(%rdi)
movq 0x28(%r14), %r13
leaq 0x159e0(%rip), %rsi     # 0x37521
callq 0x40d0
testl %eax, %eax
je 0x21b6c
addq $-0x90, %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x4170
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x24050
jmp 0x21e0b
movq (%rbx), %r13
leaq 0x68(%r13), %rbp
leaq 0x1554b(%rip), %rsi     # 0x370c5
movq %rbp, %rdi
callq 0x40d0
testl %eax, %eax
jne 0x21bb3
movq 0x70(%r13), %rdx
leaq 0x15990(%rip), %rcx     # 0x37521
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 0x154d0(%rip), %rsi     # 0x37096
movq %r14, %rdi
callq 0x40d0
testl %eax, %eax
leaq 0x18(%rsp), %rbp
jne 0x21e00
movq -0x88(%r12), %rdx
cmpq 0x30(%rsp), %rdx
jne 0x21e00
testq %rdx, %rdx
je 0x21c0d
movq 0x28(%rsp), %rsi
movq -0x90(%r12), %rdi
callq 0x42b0
testl %eax, %eax
jne 0x21e00
leaq 0x100(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0xf0(%rsp), %rdi
callq 0xc7aa
leaq 0x70(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
movq %r15, %rsi
callq 0x2b63a
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0x21c66
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xe0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x158a8(%rip), %rsi     # 0x37521
leaq 0x158a6(%rip), %rdx     # 0x37526
leaq 0xd0(%rsp), %rdi
callq 0x53cc
leaq 0xc0(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %rdi
callq 0xc7aa
leaq 0xa0(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0xc7aa
leaq 0x110(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0xbbea
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0x21d1c
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x21d39
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
je 0x21d56
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x110(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x23d72
addq $0xa8, %rax
leaq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x4170
leaq 0x160(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x21d9d
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x140(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x21dbe
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x21ddf
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x21e00
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x24050
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
leaq 0x38(%rsp), %rbx
je 0x21e2c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x21e43
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x21e5a
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 0x21e6e
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0xbca2
jmp 0x21ee9
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0x21ea5
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x21ea5
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x21ec7
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x21ec7
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
je 0x21ee9
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x21ee9
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x21f31
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x21f31
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0x21f31
movq 0x100(%rsp), %rsi
jmp 0x21f02
jmp 0x21f2e
jmp 0x21f2e
jmp 0x21f2e
jmp 0x21f2e
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xbca2
jmp 0x21f78
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x21f61
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x21f61
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x21f78
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0