// File: /workspace/github_cpp_makefile_star2_O2/aadityanaik[P]LongNums/src/longnums.cpp
// Function: LongNumber::operator-(LongNumber)
LongNumber LongNumber::operator-(LongNumber X) {
	if(negative ==  X.negative) {
		LongNumber answer;
		if(this->absolute() >= X.absolute()) {
			int temp;
			bool borrow = false;
			answer.digits.erase(answer.digits.begin(), answer.digits.end());
			for(int i = 0, j = 0;i < digits.size();i++, j++) {
				temp = digits[i];
				if(borrow) {
					temp--;
				}
				if(j < X.digits.size()) {
					temp -= X.digits[j];
				}
				if(temp < 0) {
					temp += BASE;
					borrow = true;
				} else {
					borrow = false;
				}
				answer.digits.push_back(temp);
			}

			while(*(answer.digits.end()-1) == 0 && answer.digits.size() > 1) {
				answer.digits.erase(answer.digits.end()-1);
			}

			if(answer != 0) {
				answer.negative = negative;
			}
		} else {
			answer = X - (*this);
			if(answer != 0) {
				answer.negative=!negative;
			}
		}

		return answer;
	} else {
		//add
		LongNumber number, answer;
		number.digits = X.digits;
		number.negative = !X.negative;

		answer = (*this) + number;
		return answer;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movb 0x18(%rsi), %al
cmpb 0x18(%rdx), %al
jne 0x3088
movq %rbx, %rdi
callq 0x2720
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x2a18
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x2a18
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x2cba
movl %eax, %ebp
leaq 0x28(%rsp), %rdi
callq 0x4d9a
leaq 0x8(%rsp), %rdi
callq 0x4d9a
testb %bpl, %bpl
je 0x30fe
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %rbx, %rdi
callq 0x4ae0
xorl %r13d, %r13d
leaq 0x4(%rsp), %r12
xorl %eax, %eax
movq (%r14), %rcx
movq 0x8(%r14), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x3040
movl (%rcx,%r13,4), %ebp
movzbl %al, %eax
andl $0x1, %eax
subl %eax, %ebp
movl %ebp, 0x4(%rsp)
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
jbe 0x3003
subl (%rax,%r13,4), %ebp
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
jns 0x3013
movl 0x60eb(%rip), %eax      # 0x90f8
addl %ebp, %eax
movl %eax, 0x4(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4ae6
shrl $0x1f, %ebp
incq %r13
movl %ebp, %eax
jmp 0x2fc5
movq %rsi, %rax
subq (%rbx), %rax
cmpq $0x5, %rax
jb 0x304a
addq $-0x4, %rsi
movq %rbx, %rdi
callq 0x4b04
movq 0x8(%rbx), %rsi
cmpl $0x0, -0x4(%rsi)
je 0x3028
leaq 0x28(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x295e
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x2cea
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x4d9a
testb %bpl, %bpl
je 0x3178
movb 0x18(%r14), %al
jmp 0x3175
leaq 0x8(%rsp), %rdi
callq 0x2720
movq %rbx, %rdi
callq 0x2720
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x49be
movb 0x18(%r15), %al
xorb $0x1, %al
leaq 0x8(%rsp), %rsi
movb %al, 0x18(%rsi)
leaq 0x48(%rsp), %rdi
callq 0x2764
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rdx
movq %r14, %rsi
callq 0x2cf4
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x4bdc
leaq 0x28(%rsp), %rdi
callq 0x4d9a
leaq 0x48(%rsp), %rdi
callq 0x4d9a
leaq 0x8(%rsp), %rdi
callq 0x4d9a
jmp 0x3178
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x2764
leaq 0x8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %r15, %rsi
callq 0x2f36
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4bdc
leaq 0x8(%rsp), %rdi
callq 0x4d9a
leaq 0x68(%rsp), %rdi
callq 0x4d9a
leaq 0x28(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x295e
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x2cea
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x4d9a
testb %bpl, %bpl
je 0x3178
movb 0x18(%r14), %al
xorb $0x1, %al
movb %al, 0x18(%rbx)
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x31ee
jmp 0x320b
jmp 0x31ee
jmp 0x320b
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4d9a
jmp 0x31a7
movq %rax, %r14
leaq 0x68(%rsp), %rdi
jmp 0x31f6
jmp 0x320b
jmp 0x320b
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x4d9a
jmp 0x31c4
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x4d9a
jmp 0x31e4
jmp 0x31e1
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x4d9a
jmp 0x31f1
movq %rax, %r14
movq %rbx, %rdi
callq 0x4d9a
jmp 0x3200
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4d9a
jmp 0x320e
movq %rax, %r14
leaq 0x8(%rsp), %rdi
jmp 0x3211
jmp 0x320b
jmp 0x320b
movq %rax, %r14
movq %rbx, %rdi
callq 0x4d9a
movq %r14, %rdi
callq 0x2190