// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rsi, %r13
movq %rdi, %rbx
movq (%rdi), %rbp
leaq 0x40(%rsi), %r12
leaq 0xd8(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x4390
movq %rbp, %rdi
movq %r15, %rsi
callq 0x10282
movl %eax, %ebp
leaq 0xd8(%rsp), %rdi
callq 0x4548
testb %bpl, %bpl
je 0x15c55
movq (%rbx), %r15
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4390
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x107fa
leaq 0xf8(%rsp), %rdi
callq 0x4548
leaq 0xda53(%rip), %rsi      # 0x23535
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x8453
testb %al, %al
je 0x15b53
leaq 0xda27(%rip), %rsi      # 0x23521
movq %r13, %rdi
callq 0x44e0
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
callq 0x4390
leaq 0xda1f(%rip), %rsi      # 0x23535
movq %r12, %rdi
callq 0x44e0
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x4390
leaq 0x50(%rsp), %rsi
movq %r14, %rdx
callq 0x15246
leaq 0x50(%rsp), %rdi
callq 0x4548
leaq 0x70(%rsp), %rdi
callq 0x4548
jmp 0x15c4b
leaq 0xd92a(%rip), %rsi      # 0x23484
leaq 0x10(%rsp), %rdi
callq 0x8453
testb %al, %al
jne 0x15c4b
leaq 0x10(%rsp), %rbx
pushq $0xa
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8476
movq %rax, %rbp
decq %rax
testq %rax, %rbp
jne 0x15c4b
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xd5b8(%rip), %rsi      # 0x23187
leaq 0x70(%rsp), %rdi
callq 0x44e0
leaq 0x90(%rsp), %rdi
addq $0x20, %r13
movq %r13, %rsi
callq 0x4180
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x4390
leaq 0x30(%rsp), %rsi
movq %r14, %rdx
callq 0x15246
leaq 0x30(%rsp), %rdi
callq 0x4548
addq $0x20, %r14
imulq $0x68, 0x8(%rsp), %r12
leaq 0x70(%rsp), %r15
cmpq $0x1, %rbp
je 0x15c41
movq (%r14), %rax
leaq (%rax,%r12), %rsi
addq $-0x68, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x166aa
shrq %rbp
jmp 0x15c20
leaq 0x70(%rsp), %rdi
callq 0x81fe
leaq 0x10(%rsp), %rdi
callq 0x4548
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x4548
jmp 0x15cb1
jmp 0x15c9c
jmp 0x15cae
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x4548
jmp 0x15c90
jmp 0x15c9c
jmp 0x15c9c
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x4548
jmp 0x15cbb
movq %rax, %r14
jmp 0x15cbb
movq %rax, %r14
leaq 0xd8(%rsp), %rdi
jmp 0x15cbe
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x81fe
movq %rbx, %rdi
callq 0x4548
movq %r14, %rdi
callq 0x4490
nop