// File: /workspace/github_cpp_makefile_star2_O1/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, 0x8(%rsp)
movq %rdi, %r12
leaq 0xd8(%rdi), %rbx
leaq 0xf8(%rdi), %r15
movq 0xe0(%rdi), %r13
cmpq 0x100(%rdi), %r13
jne 0x1cba4
testq %r13, %r13
je 0x1cba9
movq (%r15), %rsi
movq (%rbx), %rdi
movq %r13, %rdx
callq 0x42b0
testl %eax, %eax
sete %r14b
jmp 0x1cbac
xorl %r14d, %r14d
jmp 0x1cbac
movb $0x1, %r14b
testb %r14b, %r14b
je 0x1cbfe
movq %r15, 0x30(%rsp)
movq (%r12), %rbp
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r12, %r15
movq 0xd8(%r12), %rsi
addq %rsi, %r13
leaq 0x98(%rsp), %r12
movq %r12, %rdi
movq %r13, %rdx
callq 0xca12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1b39a
movl %eax, %ebp
movq %r15, %r12
movq 0x30(%rsp), %r15
jmp 0x1cc00
xorl %ebp, %ebp
testb %r14b, %r14b
je 0x1cc26
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1cc26
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
testb %bpl, %bpl
movq %rbx, %rbp
je 0x1cd87
movq %r12, %r13
leaq 0x1c981(%rip), %rsi     # 0x395bd
movl $0x1, %ecx
movq %rbp, %rdi
xorl %edx, %edx
callq 0x44a0
leaq 0x1(%rax), %rdx
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
movq $-0x1, %rcx
callq 0x42c0
movq %r12, %rdi
callq 0x4370
movq 0x8(%r12), %rdx
movq 0x8(%rsp), %rax
cmpq 0x8(%rax), %rdx
jne 0x1cd69
testq %rdx, %rdx
je 0x1cca1
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x10(%rsp), %rdi
callq 0x42b0
testl %eax, %eax
jne 0x1cd69
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1b7d3(%rip), %rsi     # 0x38484
leaq 0x1b7cf(%rip), %rdx     # 0x38487
leaq 0x58(%rsp), %rdi
callq 0x54fc
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq %r13, %rbx
movq %r13, %rsi
callq 0x2b8d6
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x1ccee
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1b3c7(%rip), %rsi     # 0x380c5
leaq 0x1b3c4(%rip), %rdx     # 0x380c9
leaq 0x38(%rsp), %rdi
callq 0x54fc
leaq 0x38(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rcx
callq 0x1ca1c
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x1cd3b
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x78(%rsp), %rsi
movq %r15, %rdi
callq 0x4170
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1cd69
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1cd84
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %r13, %r12
cmpq $0x0, 0xc0(%r12)
je 0x1ce73
leaq 0xb8(%r12), %r13
leaq 0x1b320(%rip), %rsi     # 0x380c5
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1ceab
movq 0x100(%r12), %rdx
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r14
cmpq %r14, %rdx
jne 0x1cdec
testq %rdx, %rdx
je 0x1cf01
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq (%r15), %rdi
callq 0x42b0
testl %eax, %eax
je 0x1cf01
movq 0xe0(%r12), %rdx
cmpq %r14, %rdx
jne 0x1ce13
testq %rdx, %rdx
je 0x1ce60
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq (%rbp), %rdi
callq 0x42b0
testl %eax, %eax
je 0x1ce60
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1b2a2(%rip), %rsi     # 0x380c5
leaq 0x1b29f(%rip), %rdx     # 0x380c9
leaq 0x10(%rsp), %rdi
callq 0x54fc
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
callq 0x1ca1c
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x1ce60
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %r12, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rcx
jmp 0x1cf80
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1b69e(%rip), %rsi     # 0x38521
leaq 0x1b69c(%rip), %rdx     # 0x38526
leaq 0x10(%rsp), %rdi
callq 0x54fc
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
callq 0x1ca1c
jmp 0x1cee1
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1b20a(%rip), %rsi     # 0x380c5
leaq 0x1b207(%rip), %rdx     # 0x380c9
leaq 0x10(%rsp), %rdi
callq 0x54fc
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
callq 0x1ca1c
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x1cf85
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1cf85
leaq 0x1b19a(%rip), %rsi     # 0x380a2
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1cf72
leaq 0x1b56d(%rip), %rsi     # 0x38488
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1cf72
leaq 0x1b168(%rip), %rsi     # 0x38096
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1cf60
leaq 0x1b54b(%rip), %rsi     # 0x3848c
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
je 0x1cf60
leaq 0x1b53c(%rip), %rsi     # 0x38490
movq %r13, %rdi
callq 0x40d0
testl %eax, %eax
jne 0x1cf85
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x1d05c
jmp 0x1cf85
movq %r12, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
callq 0x1ca1c
movq %r12, %rdi
callq 0x1d1d6
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1cfbd
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x1cfc0
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1cfc0
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1cffa
movq 0x88(%rsp), %rsi
jmp 0x1cfed
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x1cffa
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x1cffa
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x1d01f
jmp 0x1d053
jmp 0x1d012
jmp 0x1d026
jmp 0x1d012
jmp 0x1d026
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x1d053
movq 0x20(%rsp), %rsi
jmp 0x1d04b
movq %rax, %rbx
jmp 0x1d053
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1d053
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0
nop