// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/IRs/FirstIR.cpp
// Function: FirstIR::handleMathOperation(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void FirstIR::handleMathOperation(cStrRef resultName)
{
    if (_firstExtraParameter == _secondExtraParameter && _symbolTable->isItTable(_firstExtraParameter))
    {
        std::string res = _firstExtraParameter.substr(_firstExtraParameter.find("(") + 1, std::string::npos);
        res.pop_back();
        if (res == resultName)
        {
            std::string var = getVariable("NAN");
            addNewCode("COPY", var, _secondExtraParameter);
            _secondExtraParameter = var;
        }
    }
    if (_operation.empty())
    {
        addNewCode("CONST", resultName, _firstExtraParameter);
    }
    else if (_operation == "COPY")
    {
        addNewCode("COPY", resultName, _firstExtraParameter);      
    }
    else if (_secondExtraParameter == resultName)
    {
        if (_operation == "ADD" || _operation == "MUL")
        {
            addNewCode(_operation, resultName, _firstExtraParameter);
        }
        else if (_operation == "SUB" || _operation == "DIV" || _operation == "MOD")
        {
            handleNonCommutativeOperation(resultName, _operation);
        }
    }
    else
    {
        if (_firstExtraParameter == resultName)
        {
            addNewCode(_operation, resultName, _secondExtraParameter);
        }
        else
        {
            addNewCode("COPY", resultName, _firstExtraParameter);
            addNewCode(_operation, resultName, _secondExtraParameter);
        }  
    }
    reset();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xd8(%rdi), %r12
leaq 0xf8(%rdi), %r14
movq 0xe0(%rdi), %r13
cmpq 0x100(%rdi), %r13
jne 0x1cac7
movq (%r12), %rbp
testq %r13, %r13
je 0x1c906
movq (%r14), %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x42b0
testl %eax, %eax
jne 0x1cac7
movq %r14, 0x28(%rsp)
movq %r12, 0x30(%rsp)
movq (%rbx), %r12
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
addq %rbp, %r13
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0xc7aa
movq %r12, %rdi
movq %r14, %rsi
callq 0x1b0dc
movl %eax, %ebp
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x1c95b
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
testb %bpl, %bpl
movq 0x30(%rsp), %r12
movq 0x28(%rsp), %r14
je 0x1cac7
leaq 0x1bc48(%rip), %rsi     # 0x385bd
movl $0x1, %ecx
movq %r12, %rdi
xorl %edx, %edx
callq 0x44a0
leaq 0x1(%rax), %rdx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq $-0x1, %rcx
callq 0x42c0
movq %r14, %rdi
callq 0x4370
movq 0x8(%r14), %rdx
cmpq 0x8(%r15), %rdx
jne 0x1caa7
testq %rdx, %rdx
je 0x1c9cf
movq (%r15), %rsi
movq 0x8(%rsp), %rdi
callq 0x42b0
testl %eax, %eax
jne 0x1caa7
leaq 0x88(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1aaa2(%rip), %rsi     # 0x37484
leaq 0x1aa9e(%rip), %rdx     # 0x37487
leaq 0x78(%rsp), %rdi
callq 0x53cc
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rdx
movq %rbx, %rsi
callq 0x2b63a
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x1ca22
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1a693(%rip), %rsi     # 0x370c5
leaq 0x1a690(%rip), %rdx     # 0x370c9
leaq 0x58(%rsp), %rdi
callq 0x53cc
leaq 0x58(%rsp), %rsi
leaq 0x98(%rsp), %rdx
movq %rbx, %rdi
movq 0x28(%rsp), %rcx
callq 0x1c778
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x1ca74
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x98(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x4170
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1caa7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1cac2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x28(%rsp), %r14
cmpq $0x0, 0xc0(%rbx)
je 0x1cba7
leaq 0xb8(%rbx), %r13
leaq 0x1a5e2(%rip), %rsi     # 0x370c5
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1cbdd
movq 0x100(%rbx), %rdx
movq 0x8(%r15), %rbp
cmpq %rbp, %rdx
jne 0x1cb1f
testq %rdx, %rdx
je 0x1cc31
movq (%r15), %rsi
movq (%r14), %rdi
callq 0x42b0
testl %eax, %eax
je 0x1cc31
cmpq %rbp, 0xe0(%rbx)
jne 0x1cb48
testq %rbp, %rbp
je 0x1cca0
movq (%r15), %rsi
movq (%r12), %rdi
movq %rbp, %rdx
callq 0x42b0
testl %eax, %eax
je 0x1cca0
movq %r14, %rbp
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1a56a(%rip), %rsi     # 0x370c5
leaq 0x1a567(%rip), %rdx     # 0x370c9
leaq 0x8(%rsp), %rdi
callq 0x53cc
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1c778
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1cb96
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
jmp 0x1ccba
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1a96a(%rip), %rsi     # 0x37521
leaq 0x1a968(%rip), %rdx     # 0x37526
leaq 0x8(%rsp), %rdi
callq 0x53cc
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1c778
jmp 0x1cc11
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1a4d8(%rip), %rsi     # 0x370c5
leaq 0x1a4d5(%rip), %rdx     # 0x370c9
leaq 0x8(%rsp), %rdi
callq 0x53cc
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1c778
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1ccbf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1ccbf
leaq 0x1a46a(%rip), %rsi     # 0x370a2
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1ccae
leaq 0x1a83d(%rip), %rsi     # 0x37488
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1ccae
leaq 0x1a438(%rip), %rsi     # 0x37096
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1cc90
leaq 0x1a81b(%rip), %rsi     # 0x3748c
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1cc90
leaq 0x1a80c(%rip), %rsi     # 0x37490
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
jne 0x1ccbf
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1cd90
jmp 0x1ccbf
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
jmp 0x1ccba
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1c778
movq %rbx, %rdi
callq 0x1cf0a
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1ccf7
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x1ccfa
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1ccfa
movq %rax, %rbx
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1cd37
movq 0xa8(%rsp), %rsi
jmp 0x1cd2a
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x1cd37
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1cd37
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x1cd75
jmp 0x1cd87
jmp 0x1cd68
jmp 0x1cd84
jmp 0x1cd68
jmp 0x1cd84
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x1cd87
movq 0x48(%rsp), %rsi
jmp 0x1cd7a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1cd87
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1cd87
movq %rax, %rbx
movq %rbx, %rdi
callq 0x44c0
nop