// File: Mariotti94[P]BigFloat/BigFloat.cc
// Function: BigFloat::Sum(BigFloat const&, BigFloat const&)
BigFloat BigFloat::Sum(const BigFloat& left, const BigFloat& right)
{
    BigFloat tmp;
    int carry = 0;
    size_t loopsize = (left.number.size() > right.number.size()) ? left.number.size() : right.number.size();

    for(size_t i = 0; i < loopsize; ++i) {
        int val1, val2;
        val1 = (i > left.number.size() - 1) ? 0 : CharToInt(left.number[i]);
        val2 = (i > right.number.size() - 1) ? 0 : CharToInt(right.number[i]);

        int aus = val1 + val2 + carry;

        carry = 0;
        if(aus > 9) {
            carry = 1;
            aus = aus - 10;
        }

        tmp.number.push_back(IntToChar(aus));
    }
    if(carry != 0)
        tmp.number.push_back(IntToChar(carry));

    return tmp;
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0x50(%rsp)
movq %rdi, %rax
movq %rax, 0x58(%rsp)
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq %rdx, 0xa0(%rsp)
movb $0x0, 0x9f(%rsp)
callq 0x28c0
movl $0x0, 0x98(%rsp)
movq 0xa8(%rsp), %rdi
addq $0x8, %rdi
callq 0x35c0
movq %rax, 0x60(%rsp)
movq 0xa0(%rsp), %rdi
addq $0x8, %rdi
callq 0x35c0
movq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
jbe 0x4b80
movq 0xa8(%rsp), %rdi
addq $0x8, %rdi
callq 0x35c0
movq %rax, 0x48(%rsp)
jmp 0x4b96
movq 0xa0(%rsp), %rdi
addq $0x8, %rdi
callq 0x35c0
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x90(%rsp)
movq $0x0, 0x88(%rsp)
movq 0x88(%rsp), %rax
cmpq 0x90(%rsp), %rax
jae 0x4d5d
movq 0x88(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xa8(%rsp), %rdi
addq $0x8, %rdi
callq 0x35c0
movq %rax, %rcx
movq 0x40(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x4bfc
xorl %eax, %eax
movl %eax, 0x3c(%rsp)
jmp 0x4c2d
movq 0xa8(%rsp), %rdi
addq $0x8, %rdi
movq 0x88(%rsp), %rsi
callq 0xb510
movq %rax, %rdi
callq 0xb570
movl %eax, 0x38(%rsp)
jmp 0x4c23
movl 0x38(%rsp), %eax
movl %eax, 0x3c(%rsp)
jmp 0x4c2d
movl 0x3c(%rsp), %eax
movl %eax, 0x84(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xa0(%rsp), %rdi
addq $0x8, %rdi
callq 0x35c0
movq %rax, %rcx
movq 0x30(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x4c6f
xorl %eax, %eax
movl %eax, 0x2c(%rsp)
jmp 0x4ca0
movq 0xa0(%rsp), %rdi
addq $0x8, %rdi
movq 0x88(%rsp), %rsi
callq 0xb510
movq %rax, %rdi
callq 0xb570
movl %eax, 0x28(%rsp)
jmp 0x4c96
movl 0x28(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0x4ca0
movl 0x2c(%rsp), %eax
movl %eax, 0x80(%rsp)
movl 0x84(%rsp), %eax
addl 0x80(%rsp), %eax
addl 0x98(%rsp), %eax
movl %eax, 0x70(%rsp)
movl $0x0, 0x98(%rsp)
cmpl $0x9, 0x70(%rsp)
jle 0x4d0b
movl $0x1, 0x98(%rsp)
movl 0x70(%rsp), %eax
subl $0xa, %eax
movl %eax, 0x70(%rsp)
jmp 0x4d0b
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
callq 0x2780
jmp 0x4dcc
movq 0x50(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x18(%rsp)
leaq 0x70(%rsp), %rdi
callq 0xb5c0
movb %al, 0x27(%rsp)
jmp 0x4d29
movq 0x18(%rsp), %rdi
movb 0x27(%rsp), %al
movb %al, 0x6f(%rsp)
leaq 0x6f(%rsp), %rsi
callq 0xb590
jmp 0x4d42
jmp 0x4d44
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
jmp 0x4baf
cmpl $0x0, 0x98(%rsp)
je 0x4da3
movq 0x50(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
leaq 0x98(%rsp), %rdi
callq 0xb5c0
movb %al, 0x17(%rsp)
jmp 0x4d88
movq 0x8(%rsp), %rdi
movb 0x17(%rsp), %al
movb %al, 0x6e(%rsp)
leaq 0x6e(%rsp), %rsi
callq 0xb590
jmp 0x4da1
jmp 0x4da3
movb $0x1, 0x9f(%rsp)
testb $0x1, 0x9f(%rsp)
jne 0x4dbf
movq 0x50(%rsp), %rdi
callq 0x2780
movq 0x58(%rsp), %rax
addq $0xb8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0x2300
nopw %cs:(%rax,%rax)