// File: Mariotti94[P]BigFloat/BigFloat.cc
// Function: operator+(BigFloat const&, BigFloat const&)
BigFloat operator+(const BigFloat& left_, const BigFloat& right_)
{
    BigFloat tmp;
    if((left_.error) || (right_.error)) {
        return tmp;
    }

    BigFloat left, right;
    left = left_;
    right = right_;

    if(left.decimals > right.decimals)
        while(left.decimals > right.decimals) {
            right.decimals++;
            right.number.push_front('0');
        }
    else if(left.decimals < right.decimals)
        while(left.decimals < right.decimals) {
            left.decimals++;
            left.number.push_front('0');
        }

    if((left.sign == '+') && (right.sign == '-')) {
        int check = BigFloat::CompareNum(left, right);
        if(check == 0) {
            tmp = 0;
            return tmp;
        }
        if(check == 1) {
            tmp = BigFloat::Subtract(left, right);
            tmp.sign = '+';
            tmp.decimals = left.decimals;
            tmp.LeadTrim();
            tmp.error = 0;
            return tmp;
        }
        if(check == 2) {
            tmp = BigFloat::Subtract(right, left);
            tmp.sign = '-';
            tmp.decimals = left.decimals;
            tmp.LeadTrim();
            tmp.error = 0;
            return tmp;
        }
    }
    if((left.sign == '-') && (right.sign == '+')) {
        int check = BigFloat::CompareNum(left, right);
        if(check == 0) {
            tmp = 0;
            return tmp;
        }
        if(check == 1) {
            tmp = BigFloat::Subtract(left, right);
            tmp.sign = '-';
            tmp.decimals = left.decimals;
            tmp.LeadTrim();
            tmp.error = 0;
            return tmp;
        }
        if(check == 2) {
            tmp = BigFloat::Subtract(right, left);
            tmp.sign = '+';
            tmp.decimals = left.decimals;
            tmp.LeadTrim();
            tmp.error = 0;
            return tmp;
        }
    }

    if((left.sign == '+') && (right.sign == '+')) {
        tmp = BigFloat::Sum(left, right);
        tmp.sign = '+';
        tmp.decimals = left.decimals;
        tmp.error = 0;
        return tmp;
    }
    if((left.sign == '-') && (right.sign == '-')) {
        tmp = BigFloat::Sum(left, right);
        tmp.sign = '-';
        tmp.decimals = left.decimals;
        tmp.error = 0;
        return tmp;
    }

    return tmp; //all cases are covered above, this is only to prevent compiler warnings
}

// Assembly:
subq $0x488, %rsp            # imm = 0x488
movq %rdi, 0x38(%rsp)
movq %rdi, %rax
movq %rax, 0x40(%rsp)
movq %rdi, 0x480(%rsp)
movq %rsi, 0x478(%rsp)
movq %rdx, 0x470(%rsp)
movb $0x0, 0x46f(%rsp)
callq 0x28c0
movq 0x478(%rsp), %rax
testb $0x1, 0x5c(%rax)
jne 0x5f35
movq 0x470(%rsp), %rax
testb $0x1, 0x5c(%rax)
je 0x5f4d
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64e7
leaq 0x3e8(%rsp), %rdi
callq 0x28c0
jmp 0x5f5c
leaq 0x358(%rsp), %rdi
callq 0x28c0
jmp 0x5f6b
movq 0x478(%rsp), %rsi
leaq 0x3e8(%rsp), %rdi
callq 0xb470
jmp 0x5f82
movq 0x470(%rsp), %rsi
leaq 0x358(%rsp), %rdi
callq 0xb470
jmp 0x5f99
movl 0x440(%rsp), %eax
cmpl 0x3b0(%rsp), %eax
jle 0x604e
jmp 0x5faf
movl 0x440(%rsp), %eax
cmpl 0x3b0(%rsp), %eax
jle 0x604c
movl 0x3b0(%rsp), %eax
incl %eax
movl %eax, 0x3b0(%rsp)
leaq 0x360(%rsp), %rdi
movb $0x30, 0x357(%rsp)
leaq 0x357(%rsp), %rsi
callq 0xb4e0
jmp 0x5ff2
jmp 0x5faf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e0(%rsp)
movl %eax, 0x3dc(%rsp)
jmp 0x6508
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e0(%rsp)
movl %eax, 0x3dc(%rsp)
jmp 0x64d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e0(%rsp)
movl %eax, 0x3dc(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x2780
jmp 0x64d8
jmp 0x60a5
movl 0x440(%rsp), %eax
cmpl 0x3b0(%rsp), %eax
jge 0x60a3
jmp 0x6060
movl 0x440(%rsp), %eax
cmpl 0x3b0(%rsp), %eax
jge 0x60a1
movl 0x440(%rsp), %eax
incl %eax
movl %eax, 0x440(%rsp)
leaq 0x3f0(%rsp), %rdi
movb $0x30, 0x356(%rsp)
leaq 0x356(%rsp), %rsi
callq 0xb4e0
jmp 0x609f
jmp 0x6060
jmp 0x60a3
jmp 0x60a5
movsbl 0x3e8(%rsp), %eax
cmpl $0x2b, %eax
jne 0x6227
movsbl 0x358(%rsp), %eax
cmpl $0x2d, %eax
jne 0x6227
leaq 0x3e8(%rsp), %rdi
leaq 0x358(%rsp), %rsi
callq 0x4590
movl %eax, 0x34(%rsp)
jmp 0x60e2
movl 0x34(%rsp), %eax
movl %eax, 0x350(%rsp)
cmpl $0x0, 0x350(%rsp)
jne 0x611d
movq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x5de0
jmp 0x6105
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64bc
cmpl $0x1, 0x350(%rsp)
jne 0x61a1
leaq 0x2d0(%rsp), %rdi
leaq 0x3e8(%rsp), %rsi
leaq 0x358(%rsp), %rdx
callq 0x4de0
jmp 0x6146
movq 0x38(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
movq %rsi, 0x28(%rsp)
callq 0x2950
movq 0x28(%rsp), %rdi
callq 0x2780
movq 0x38(%rsp), %rdi
movb $0x2b, (%rdi)
movl 0x440(%rsp), %eax
movl %eax, 0x58(%rdi)
callq 0x5d20
jmp 0x6180
movq 0x38(%rsp), %rax
movb $0x0, 0x5c(%rax)
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64bc
cmpl $0x2, 0x350(%rsp)
jne 0x6225
leaq 0x250(%rsp), %rdi
leaq 0x358(%rsp), %rsi
leaq 0x3e8(%rsp), %rdx
callq 0x4de0
jmp 0x61ca
movq 0x38(%rsp), %rdi
leaq 0x250(%rsp), %rsi
movq %rsi, 0x20(%rsp)
callq 0x2950
movq 0x20(%rsp), %rdi
callq 0x2780
movq 0x38(%rsp), %rdi
movb $0x2d, (%rdi)
movl 0x440(%rsp), %eax
movl %eax, 0x58(%rdi)
callq 0x5d20
jmp 0x6204
movq 0x38(%rsp), %rax
movb $0x0, 0x5c(%rax)
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64bc
jmp 0x6227
movsbl 0x3e8(%rsp), %eax
cmpl $0x2d, %eax
jne 0x63a9
movsbl 0x358(%rsp), %eax
cmpl $0x2b, %eax
jne 0x63a9
leaq 0x3e8(%rsp), %rdi
leaq 0x358(%rsp), %rsi
callq 0x4590
movl %eax, 0x1c(%rsp)
jmp 0x6264
movl 0x1c(%rsp), %eax
movl %eax, 0x24c(%rsp)
cmpl $0x0, 0x24c(%rsp)
jne 0x629f
movq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x5de0
jmp 0x6287
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64bc
cmpl $0x1, 0x24c(%rsp)
jne 0x6323
leaq 0x1c8(%rsp), %rdi
leaq 0x3e8(%rsp), %rsi
leaq 0x358(%rsp), %rdx
callq 0x4de0
jmp 0x62c8
movq 0x38(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
movq %rsi, 0x10(%rsp)
callq 0x2950
movq 0x10(%rsp), %rdi
callq 0x2780
movq 0x38(%rsp), %rdi
movb $0x2d, (%rdi)
movl 0x440(%rsp), %eax
movl %eax, 0x58(%rdi)
callq 0x5d20
jmp 0x6302
movq 0x38(%rsp), %rax
movb $0x0, 0x5c(%rax)
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64bc
cmpl $0x2, 0x24c(%rsp)
jne 0x63a7
leaq 0x148(%rsp), %rdi
leaq 0x358(%rsp), %rsi
leaq 0x3e8(%rsp), %rdx
callq 0x4de0
jmp 0x634c
movq 0x38(%rsp), %rdi
leaq 0x148(%rsp), %rsi
movq %rsi, 0x8(%rsp)
callq 0x2950
movq 0x8(%rsp), %rdi
callq 0x2780
movq 0x38(%rsp), %rdi
movb $0x2b, (%rdi)
movl 0x440(%rsp), %eax
movl %eax, 0x58(%rdi)
callq 0x5d20
jmp 0x6386
movq 0x38(%rsp), %rax
movb $0x0, 0x5c(%rax)
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64bc
jmp 0x63a9
movsbl 0x3e8(%rsp), %eax
cmpl $0x2b, %eax
jne 0x642f
movsbl 0x358(%rsp), %eax
cmpl $0x2b, %eax
jne 0x642f
leaq 0xc8(%rsp), %rdi
leaq 0x3e8(%rsp), %rsi
leaq 0x358(%rsp), %rdx
callq 0x4af0
jmp 0x63e2
movq 0x38(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x2950
leaq 0xc8(%rsp), %rdi
callq 0x2780
movq 0x38(%rsp), %rax
movb $0x2b, (%rax)
movl 0x440(%rsp), %ecx
movl %ecx, 0x58(%rax)
movb $0x0, 0x5c(%rax)
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64bc
movsbl 0x3e8(%rsp), %eax
cmpl $0x2d, %eax
jne 0x64a9
movsbl 0x358(%rsp), %eax
cmpl $0x2d, %eax
jne 0x64a9
leaq 0x48(%rsp), %rdi
leaq 0x3e8(%rsp), %rsi
leaq 0x358(%rsp), %rdx
callq 0x4af0
jmp 0x6465
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x2950
leaq 0x48(%rsp), %rdi
callq 0x2780
movq 0x38(%rsp), %rax
movb $0x2d, (%rax)
movl 0x440(%rsp), %ecx
movl %ecx, 0x58(%rax)
movb $0x0, 0x5c(%rax)
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
jmp 0x64bc
movb $0x1, 0x46f(%rsp)
movl $0x1, 0x468(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x2780
leaq 0x3e8(%rsp), %rdi
callq 0x2780
jmp 0x64e7
leaq 0x3e8(%rsp), %rdi
callq 0x2780
jmp 0x6508
testb $0x1, 0x46f(%rsp)
jne 0x64fb
movq 0x38(%rsp), %rdi
callq 0x2780
movq 0x40(%rsp), %rax
addq $0x488, %rsp            # imm = 0x488
retq
movq 0x38(%rsp), %rdi
callq 0x2780
movq 0x3e0(%rsp), %rdi
callq 0x2300
nop