// File: /workspace/github_cpp_makefile_star2_O2/aadityanaik[P]LongNums/src/longnums.cpp
// Function: LongNumber::operator+(LongNumber)
LongNumber LongNumber::operator+(LongNumber X) {                             //Addition
	LongNumber answer;
	answer.digits.pop_back();
	int carryover = 0;
	//std::vector<int> big, small;
	if (this->negative == X.negative) {
		//one must add
		if (this->negative) {
			answer.negative = true;
			//the ans will be negative
		}

		long int temp = 0;

		for (int i = 0, j = 0;; i++, j++) {  //following algorithm is the traditional digit-by-digit method of addition
			temp = carryover;
			if(i < digits.size() && j < X.digits.size()) {
				temp += digits[i] + X.digits[j];
			} else if(i < digits.size()) {
				temp += digits[i];
			} else if(j < X.digits.size()) {
				temp += X.digits[j];
			} else {
				break;
			}

			carryover = temp / BASE;
			temp %= BASE;

			answer.digits.push_back(temp);
		}

		if (carryover > 0) {                                 //if the carryover is 1
			answer.digits.push_back(carryover);
		}
	}

	else {
		//one must subtract the numbers
		LongNumber temp;
		if (negative) {                 //for cases like -1 + 2 == 2 + (-1) == 2 - 1
			temp = this->absolute();
			answer = (X - temp);
		}

		else if (X.negative) {                    //for cases like 1 + (-2) == 1 - 2
			temp = X.absolute();
			answer = ((*this) - temp);
		}
	}

	return answer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
callq 0x2720
addq $-0x4, 0x8(%rbx)
andl $0x0, 0x4(%rsp)
movb 0x18(%r15), %al
cmpb 0x18(%r14), %al
jne 0x2da4
testb %al, %al
je 0x2d2f
movb $0x1, 0x18(%rbx)
xorl %r13d, %r13d
leaq 0x28(%rsp), %r12
xorl %ebp, %ebp
movq (%r15), %rcx
movq 0x8(%r15), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
movq (%r14), %rax
movq 0x8(%r14), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbp, %rsi
jbe 0x2d67
movl (%rcx,%rbp,4), %ecx
cmpq %rbp, %rdx
jbe 0x2d73
addl (%rax,%rbp,4), %ecx
jmp 0x2d73
cmpq %rbp, %rdx
jbe 0x2e21
movl (%rax,%rbp,4), %ecx
movslq %r13d, %rdx
movslq %ecx, %rax
addq %rdx, %rax
movslq 0x6375(%rip), %rcx      # 0x90f8
cqto
idivq %rcx
movq %rax, %r13
movl %r13d, 0x4(%rsp)
movl %edx, 0x28(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4da8
incq %rbp
jmp 0x2d39
leaq 0x28(%rsp), %rdi
callq 0x2720
cmpb $0x1, 0x18(%r15)
jne 0x2e39
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2a18
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4bdc
leaq 0x8(%rsp), %rdi
callq 0x4d9a
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x2764
leaq 0x8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %r14, %rsi
callq 0x2f36
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4bdc
leaq 0x8(%rsp), %rdi
callq 0x4d9a
leaq 0x68(%rsp), %rdi
jmp 0x2ea3
testl %r13d, %r13d
jle 0x2eb2
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0x4ae6
jmp 0x2eb2
cmpb $0x1, 0x18(%r14)
jne 0x2ea8
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x2a18
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4bdc
leaq 0x8(%rsp), %rdi
callq 0x4d9a
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x2764
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
movq %r15, %rsi
callq 0x2f36
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4bdc
leaq 0x8(%rsp), %rdi
callq 0x4d9a
leaq 0x48(%rsp), %rdi
callq 0x4d9a
leaq 0x28(%rsp), %rdi
callq 0x4d9a
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4d9a
jmp 0x2ed9
movq %rax, %r14
leaq 0x48(%rsp), %rdi
jmp 0x2f09
jmp 0x2f10
jmp 0x2f01
jmp 0x2f10
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4d9a
jmp 0x2ef8
movq %rax, %r14
leaq 0x68(%rsp), %rdi
jmp 0x2f09
jmp 0x2f10
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4d9a
jmp 0x2f13
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x4d9a
jmp 0x2f26
jmp 0x2f23
jmp 0x2f23
movq %rax, %r14
movq %rbx, %rdi
callq 0x4d9a
movq %r14, %rdi
callq 0x2190