// File: 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:
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rdi, 0x2a0(%rsp)
movq %rsi, 0x298(%rsp)
movq %rdx, 0x290(%rsp)
movq 0x2a0(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
callq 0x30e40
movq %rax, %rsi
leaq 0x228(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0xfb20
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
callq 0xe380
movq %rax, 0x220(%rsp)
leaq 0x220(%rsp), %rdi
movq %rdi, 0x68(%rsp)
xorl %esi, %esi
movl %esi, 0x74(%rsp)
callq 0x30dc0
movq 0x68(%rsp), %rdi
movl 0x74(%rsp), %esi
movq %rax, 0x218(%rsp)
callq 0x30dc0
movq 0x78(%rsp), %rdi
movq %rax, 0x210(%rsp)
leaq 0x233a5(%rip), %rsi     # 0x51562
callq 0xdd10
movb %al, 0x87(%rsp)
jmp 0x2e1cb
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0x2e1db
jmp 0x2e628
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
callq 0xe3f0
movq %rax, 0x1f0(%rsp)
leaq 0x1f0(%rsp), %rdi
movl $0x1, %esi
callq 0xe510
movq %rax, 0x1f8(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x30d40
movq %rax, %rdi
leaq 0x22ed8(%rip), %rsi     # 0x510fd
callq 0xdd10
movb %al, 0x5f(%rsp)
jmp 0x2e230
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0x2e23a
jmp 0x2e2a0
leaq 0x1f8(%rsp), %rdi
callq 0x30d40
movq %rax, %rdi
leaq 0x23311(%rip), %rsi     # 0x51562
callq 0x44a0
jmp 0x2e258
leaq 0x268(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x30d40
movq 0x50(%rsp), %rsi
movq %rax, %rdi
addq $0x40, %rdi
callq 0x4050
jmp 0x2e285
jmp 0x2e2a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x2e6c1
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
callq 0xe380
movq %rax, 0x1e0(%rsp)
leaq 0x1e0(%rsp), %rdi
movl $0x2, %esi
callq 0x118b0
movq %rax, 0x1e8(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0x30d40
movq %rax, %rdi
leaq 0x22de4(%rip), %rsi     # 0x510ce
callq 0xdd10
movb %al, 0x4f(%rsp)
jmp 0x2e2f5
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x2e302
jmp 0x2e5ca
leaq 0x1e8(%rsp), %rdi
callq 0x30d40
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x228(%rsp), %rsi
addq $0x20, %rsi
callq 0xd2c0
testb $0x1, %al
jne 0x2e330
jmp 0x2e5ca
leaq 0x268(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x4180
jmp 0x2e347
movq 0x60(%rsp), %rsi
leaq 0x1c0(%rsp), %rdi
leaq 0x1a0(%rsp), %rdx
callq 0x3d2e0
jmp 0x2e363
leaq 0x1a0(%rsp), %rdi
callq 0x46e8
leaq 0x117(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x4600
movq 0x40(%rsp), %rdx
leaq 0x231d4(%rip), %rsi     # 0x51562
leaq 0x118(%rsp), %rdi
callq 0x4f10
jmp 0x2e39d
leaq 0xf0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x4180
jmp 0x2e3b4
leaq 0x268(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x4180
jmp 0x2e3cb
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
leaq 0xd0(%rsp), %rcx
callq 0xd3b0
jmp 0x2e3f2
leaq 0xd0(%rsp), %rdi
callq 0x46e8
leaq 0xf0(%rsp), %rdi
callq 0x46e8
leaq 0x118(%rsp), %rdi
callq 0x46e8
leaq 0x117(%rsp), %rdi
callq 0x43b0
movq 0x290(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x30(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0xe3b0
movq 0x30(%rsp), %rdi
movq 0xc0(%rsp), %rsi
leaq 0x138(%rsp), %rdx
callq 0x30e70
movq %rax, 0x38(%rsp)
jmp 0x2e46d
movq 0x38(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x1e8(%rsp)
leaq 0x1e8(%rsp), %rdi
movq %rdi, 0x28(%rsp)
xorl %esi, %esi
callq 0x30e00
movq 0x28(%rsp), %rdi
movq %rax, 0xb8(%rsp)
callq 0x30d40
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x4050
jmp 0x2e4c6
leaq 0x138(%rsp), %rdi
callq 0xd490
leaq 0x1c0(%rsp), %rdi
callq 0x46e8
jmp 0x2e5ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x46e8
jmp 0x2e6c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x2e588
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x2e57b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
jmp 0x2e56e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x46e8
leaq 0xf0(%rsp), %rdi
callq 0x46e8
leaq 0x118(%rsp), %rdi
callq 0x46e8
leaq 0x117(%rsp), %rdi
callq 0x43b0
jmp 0x2e5b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x208(%rsp)
movl %eax, 0x204(%rsp)
leaq 0x138(%rsp), %rdi
callq 0xd490
leaq 0x1c0(%rsp), %rdi
callq 0x46e8
jmp 0x2e6c1
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
movq %rdi, 0x18(%rsp)
callq 0xe3f0
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xe3b0
movq 0x18(%rsp), %rdi
movq 0xb0(%rsp), %rsi
callq 0x30d50
movq %rax, 0x20(%rsp)
jmp 0x2e616
movq 0x20(%rsp), %rax
movq %rax, 0xa0(%rsp)
jmp 0x2e6ac
leaq 0x268(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x30d40
movq 0x10(%rsp), %rsi
movq %rax, %rdi
addq $0x40, %rdi
callq 0x4050
jmp 0x2e655
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
movq %rdi, (%rsp)
callq 0xe3f0
movq %rax, 0x90(%rsp)
leaq 0x98(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xe3b0
movq (%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0x30d50
movq %rax, 0x8(%rsp)
jmp 0x2e69f
movq 0x8(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x228(%rsp), %rdi
callq 0xd490
addq $0x2a8, %rsp            # imm = 0x2A8
retq
leaq 0x228(%rsp), %rdi
callq 0xd490
movq 0x208(%rsp), %rdi
callq 0x45f0
nopl (%rax,%rax)