// File: 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:
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, 0x1a0(%rsp)
movq %rsi, 0x198(%rsp)
movq 0x1a0(%rsp), %rsi
movq %rsi, 0x50(%rsp)
movq %rsi, %rdi
addq $0xd8, %rdi
addq $0xf8, %rsi
callq 0xd2c0
movb %al, %cl
movb $0x0, 0x177(%rsp)
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x5e(%rsp)
jne 0x27151
jmp 0x271a5
movq 0x50(%rsp), %rdi
callq 0xdde0
movq 0x50(%rsp), %rsi
movq %rax, 0x38(%rsp)
addq $0xd8, %rsi
leaq 0x178(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x4180
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
movb $0x1, 0x177(%rsp)
callq 0x213e0
movb %al, 0x4f(%rsp)
jmp 0x2719b
movb 0x4f(%rsp), %al
movb %al, 0x5e(%rsp)
jmp 0x271a5
movb 0x5e(%rsp), %al
movb %al, 0x37(%rsp)
testb $0x1, 0x177(%rsp)
jne 0x271b9
jmp 0x271c6
leaq 0x178(%rsp), %rdi
callq 0x46e8
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x271d3
jmp 0x27447
movq 0x50(%rsp), %rdi
movq %rdi, %rax
addq $0xd8, %rax
movq %rax, 0x28(%rsp)
addq $0xd8, %rdi
leaq 0x2b4db(%rip), %rsi     # 0x526cf
xorl %eax, %eax
movl %eax, %edx
callq 0x46b0
movq 0x28(%rsp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
leaq 0x140(%rsp), %rdi
movq $-0x1, %rcx
callq 0x4350
leaq 0x140(%rsp), %rdi
callq 0x4430
movq 0x198(%rsp), %rsi
leaq 0x140(%rsp), %rdi
callq 0xd2c0
testb $0x1, %al
jne 0x27248
jmp 0x27426
leaq 0xff(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x4600
movq 0x20(%rsp), %rdx
leaq 0x2a24e(%rip), %rsi     # 0x514b4
leaq 0x100(%rsp), %rdi
callq 0x4f10
jmp 0x27275
movq 0x50(%rsp), %rsi
leaq 0x120(%rsp), %rdi
leaq 0x100(%rsp), %rdx
callq 0x3d2e0
jmp 0x27291
leaq 0x100(%rsp), %rdi
callq 0x46e8
leaq 0xff(%rsp), %rdi
callq 0x43b0
leaq 0xd7(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x4600
movq 0x18(%rsp), %rdx
leaq 0x29e34(%rip), %rsi     # 0x510fd
leaq 0xd8(%rsp), %rdi
callq 0x4f10
jmp 0x272d8
movq 0x50(%rsp), %rdi
movq %rdi, %rcx
addq $0xf8, %rcx
leaq 0xd8(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x26fc0
jmp 0x272fe
leaq 0xd8(%rsp), %rdi
callq 0x46e8
leaq 0xd7(%rsp), %rdi
callq 0x43b0
movq 0x50(%rsp), %rdi
addq $0xf8, %rdi
leaq 0x120(%rsp), %rsi
callq 0x4050
jmp 0x27333
leaq 0x120(%rsp), %rdi
callq 0x46e8
jmp 0x27426
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
testb $0x1, 0x177(%rsp)
jne 0x27365
jmp 0x27372
leaq 0x178(%rsp), %rdi
callq 0x46e8
jmp 0x2781b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
jmp 0x273ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x46e8
leaq 0xff(%rsp), %rdi
callq 0x43b0
jmp 0x27435
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
jmp 0x273f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x46e8
leaq 0xd7(%rsp), %rdi
callq 0x43b0
jmp 0x27417
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x46e8
jmp 0x27435
leaq 0x140(%rsp), %rdi
callq 0x46e8
jmp 0x27447
leaq 0x140(%rsp), %rdi
callq 0x46e8
jmp 0x2781b
movq 0x50(%rsp), %rdi
addq $0xb8, %rdi
callq 0x45b0
testb $0x1, %al
jne 0x27461
jmp 0x2751c
leaq 0xaf(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4600
movq 0x10(%rsp), %rdx
leaq 0x2a0e3(%rip), %rsi     # 0x51562
leaq 0xb0(%rsp), %rdi
callq 0x4f10
jmp 0x2748e
movq 0x50(%rsp), %rdi
movq 0x198(%rsp), %rdx
movq %rdi, %rcx
addq $0xd8, %rcx
leaq 0xb0(%rsp), %rsi
callq 0x26fc0
jmp 0x274b4
leaq 0xb0(%rsp), %rdi
callq 0x46e8
leaq 0xaf(%rsp), %rdi
callq 0x43b0
jmp 0x27809
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
jmp 0x2750a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x46e8
leaq 0xaf(%rsp), %rdi
callq 0x43b0
jmp 0x2781b
movq 0x50(%rsp), %rdi
addq $0xb8, %rdi
leaq 0x29bce(%rip), %rsi     # 0x510fd
callq 0xdd10
testb $0x1, %al
jne 0x2753d
jmp 0x275f8
leaq 0x87(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x4600
movq 0x8(%rsp), %rdx
leaq 0x29ba2(%rip), %rsi     # 0x510fd
leaq 0x88(%rsp), %rdi
callq 0x4f10
jmp 0x2756a
movq 0x50(%rsp), %rdi
movq 0x198(%rsp), %rdx
movq %rdi, %rcx
addq $0xd8, %rcx
leaq 0x88(%rsp), %rsi
callq 0x26fc0
jmp 0x27590
leaq 0x88(%rsp), %rdi
callq 0x46e8
leaq 0x87(%rsp), %rdi
callq 0x43b0
jmp 0x27807
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
jmp 0x275e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x46e8
leaq 0x87(%rsp), %rdi
callq 0x43b0
jmp 0x2781b
movq 0x50(%rsp), %rdi
addq $0xf8, %rdi
movq 0x198(%rsp), %rsi
callq 0xd2c0
testb $0x1, %al
jne 0x2761a
jmp 0x276f5
movq 0x50(%rsp), %rdi
addq $0xb8, %rdi
leaq 0x29aad(%rip), %rsi     # 0x510da
callq 0xdd10
testb $0x1, %al
jne 0x27654
movq 0x50(%rsp), %rdi
addq $0xb8, %rdi
leaq 0x29e6f(%rip), %rsi     # 0x514b8
callq 0xdd10
testb $0x1, %al
jne 0x27654
jmp 0x2767c
movq 0x50(%rsp), %rdi
movq %rdi, %rsi
addq $0xb8, %rsi
movq 0x198(%rsp), %rdx
movq %rdi, %rcx
addq $0xd8, %rcx
callq 0x26fc0
jmp 0x276f0
movq 0x50(%rsp), %rdi
addq $0xb8, %rdi
leaq 0x29a3f(%rip), %rsi     # 0x510ce
callq 0xdd10
testb $0x1, %al
jne 0x276d2
movq 0x50(%rsp), %rdi
addq $0xb8, %rdi
leaq 0x29e11(%rip), %rsi     # 0x514bc
callq 0xdd10
testb $0x1, %al
jne 0x276d2
movq 0x50(%rsp), %rdi
addq $0xb8, %rdi
leaq 0x29df9(%rip), %rsi     # 0x514c0
callq 0xdd10
testb $0x1, %al
jne 0x276d2
jmp 0x276ee
movq 0x50(%rsp), %rdi
movq 0x198(%rsp), %rsi
movq %rdi, %rdx
addq $0xb8, %rdx
callq 0x27830
jmp 0x276f0
jmp 0x27805
movq 0x50(%rsp), %rdi
addq $0xd8, %rdi
movq 0x198(%rsp), %rsi
callq 0xd2c0
testb $0x1, %al
jne 0x27714
jmp 0x2773f
movq 0x50(%rsp), %rdi
movq %rdi, %rsi
addq $0xb8, %rsi
movq 0x198(%rsp), %rdx
movq %rdi, %rcx
addq $0xf8, %rcx
callq 0x26fc0
jmp 0x27803
leaq 0x5f(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x4600
movq (%rsp), %rdx
leaq 0x299a5(%rip), %rsi     # 0x510fd
leaq 0x60(%rsp), %rdi
callq 0x4f10
jmp 0x27764
movq 0x50(%rsp), %rdi
movq 0x198(%rsp), %rdx
movq %rdi, %rcx
addq $0xd8, %rcx
leaq 0x60(%rsp), %rsi
callq 0x26fc0
jmp 0x27787
leaq 0x60(%rsp), %rdi
callq 0x46e8
leaq 0x5f(%rsp), %rdi
callq 0x43b0
movq 0x50(%rsp), %rdi
movq %rdi, %rsi
addq $0xb8, %rsi
movq 0x198(%rsp), %rdx
movq %rdi, %rcx
addq $0xf8, %rcx
callq 0x26fc0
jmp 0x27803
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
jmp 0x277f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x46e8
leaq 0x5f(%rsp), %rdi
callq 0x43b0
jmp 0x2781b
jmp 0x27805
jmp 0x27807
jmp 0x27809
movq 0x50(%rsp), %rdi
callq 0x27aa0
addq $0x1a8, %rsp            # imm = 0x1A8
retq
movq 0x168(%rsp), %rdi
callq 0x45f0
nopl (%rax,%rax)