// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/IRs/SecondIR.cpp
// Function: SecondIR::checkPowerOfTwoDiv(Line&, Block&, unsigned long)
void SecondIR::checkPowerOfTwoDiv(Line& l, Block& b, size_t i)
{
    if (!_symbolTable->isConst(l.two))
    {
        return;
    }
    std::string value = _symbolTable->getConstValue(l.two);
    if (value == "0")
    {
        l.operation = "CONST";
        std::string arg = l.two;
        l.two = "0";
        stripVariable(arg, b);
        return;
    }
    if (value == "NAN")
    {
        return;
    }
    unsigned long long number = std::stoull(value);
    if ((number & (number - 1)) != 0)
    {
        return;
    }

    Line addLine;
    addLine.operation = "HALF";
    addLine.one = l.one;

    stripVariable(l.two, b);

    while (number != 1)
    {
        b.lines.insert(b.lines.begin() + i - 1, addLine);
        number = number / 2;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rcx, 0x8(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movq (%rdi), %r13
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x40(%rsi), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rbp
movq %rbp, %rdi
callq 0xc7aa
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1a6f8
movl %eax, %ebp
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x228d5
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
testb %bpl, %bpl
je 0x22be3
movq (%r12), %r12
leaq 0x108(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0xf8(%rsp), %r13
movq %r13, %rdi
callq 0xc7aa
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1afb8
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x22939
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x14bf5(%rip), %rsi     # 0x37535
leaq 0xb8(%rsp), %rdi
callq 0x40d0
testl %eax, %eax
je 0x229cd
leaq 0x14b2c(%rip), %rsi     # 0x37484
leaq 0xb8(%rsp), %rdi
callq 0x40d0
testl %eax, %eax
je 0x22bc2
movq 0xb8(%rsp), %rbp
callq 0x4050
movq %rax, %r13
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movl $0x0, (%r13)
leaq 0x10(%rsp), %r15
movq %rbp, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x43c0
cmpq %rbp, (%r15)
je 0x22bf5
movq %rax, %r12
movl (%r13), %eax
testl %eax, %eax
je 0x22a8b
cmpl $0x22, %eax
jne 0x22a93
leaq 0x1475a(%rip), %rdi     # 0x37122
callq 0x43f0
movq 0x8(%r14), %rdx
leaq 0x14b49(%rip), %rcx     # 0x37521
movl $0x5, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0x4440
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0xc7aa
movq 0x48(%r14), %rdx
addq $0x40, %r14
leaq 0x14b20(%rip), %rcx     # 0x37535
movl $0x1, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0x4440
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0xc7aa
leaq 0x98(%rsp), %rsi
movq %rbx, %rdx
callq 0x21a1e
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x22a78
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
jne 0x22bb5
jmp 0x22bc2
movl 0x4(%rsp), %eax
movl %eax, (%r13)
leaq -0x1(%r12), %rax
testq %rax, %r12
jne 0x22bc2
leaq 0x20(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x40(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0x60(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0x146ad(%rip), %rcx     # 0x37187
leaq 0x10(%rsp), %rdi
movl $0x4, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4440
leaq 0x30(%rsp), %rdi
leaq 0x20(%r14), %rsi
callq 0x4170
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0xc7aa
leaq 0x78(%rsp), %rsi
movq %rbx, %rdx
callq 0x21a1e
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x22b44
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $0x1, %r12
je 0x22b78
addq $0x20, %rbx
imulq $0x68, 0x8(%rsp), %r15
leaq 0x10(%rsp), %r14
movq (%rbx), %rax
leaq (%rax,%r15), %rsi
addq $-0x68, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x23d72
shrq %r12
cmpq $0x1, %r12
jne 0x22b59
movq 0x50(%rsp), %rdi
cmpq %rbp, %rdi
je 0x22b8f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x22ba6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x22bc2
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x22be3
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14526(%rip), %rdi     # 0x37122
callq 0x41a0
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x22cac
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x22cac
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x22c69
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x22c69
jmp 0x22c4b
movq %rax, %rbx
jmp 0x22cb6
jmp 0x22ca9
movq %rax, %rbx
cmpl $0x0, (%r13)
jne 0x22cb6
movl 0x4(%rsp), %eax
movl %eax, (%r13)
jmp 0x22cb6
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x22cb6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x22cb6
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
jmp 0x22cc2
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x22cd2
movq 0xe8(%rsp), %rsi
jmp 0x22cca
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xbca2
leaq 0xc8(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x22cd2
movq (%r15), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0