// File: /workspace/github_cpp_makefile_star2_O2/Merulo[P]CompilerJFTT/src/IRs/SecondIR.cpp
// Function: SecondIR::checkPowerOfTwoMul(Line&, Block&, unsigned long)
void SecondIR::checkPowerOfTwoMul(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;
    }
    unsigned long long number = std::stoull(value);
    if ((number & (number - 1)) != 0)
    {
        return;
    }

    Line addLine;
    addLine.operation = "ADD";
    addLine.one = l.one;
    addLine.two = 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 0x159d3
movq (%rbx), %r15
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4390
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x107fa
leaq 0xf8(%rsp), %rdi
callq 0x4548
leaq 0xdcd2(%rip), %rsi      # 0x23535
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
callq 0x8453
testb %al, %al
je 0x158e0
leaq 0xdca3(%rip), %rsi      # 0x23521
movq %r13, %rdi
callq 0x44e0
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x4390
leaq 0xdc9b(%rip), %rsi      # 0x23535
movq %r12, %rdi
callq 0x44e0
leaq 0x98(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x4390
leaq 0x98(%rsp), %rsi
movq %r14, %rdx
callq 0x15246
leaq 0x98(%rsp), %rdi
callq 0x4548
leaq 0x30(%rsp), %rdi
callq 0x4548
jmp 0x159c6
leaq 0xb8(%rsp), %rbx
pushq $0xa
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8476
movq %rax, %rbp
decq %rax
testq %rax, %rbp
jne 0x159c6
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xd762(%rip), %rsi      # 0x230a2
leaq 0x30(%rsp), %rdi
callq 0x44e0
leaq 0x50(%rsp), %rdi
addq $0x20, %r13
movq %r13, %rsi
callq 0x4180
leaq 0x70(%rsp), %rdi
movq %r13, %rsi
callq 0x4180
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x4390
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x15246
leaq 0x10(%rsp), %rdi
callq 0x4548
addq $0x20, %r14
imulq $0x68, 0x8(%rsp), %r12
leaq 0x30(%rsp), %r15
cmpq $0x1, %rbp
je 0x159bc
movq (%r14), %rax
leaq (%rax,%r12), %rsi
addq $-0x68, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x166aa
shrq %rbp
jmp 0x1599b
leaq 0x30(%rsp), %rdi
callq 0x81fe
leaq 0xb8(%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 0x10(%rsp), %rdi
callq 0x4548
jmp 0x15a32
movq %rax, %r14
leaq 0x98(%rsp), %rdi
callq 0x4548
jmp 0x15a11
jmp 0x15a1d
jmp 0x15a1d
jmp 0x15a1d
jmp 0x15a2f
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x4548
jmp 0x15a3c
movq %rax, %r14
jmp 0x15a3c
movq %rax, %r14
leaq 0xd8(%rsp), %rdi
jmp 0x15a3f
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x81fe
movq %rbx, %rdi
callq 0x4548
movq %r14, %rdi
callq 0x4490