// File: /workspace/github_cpp_makefile_star2_O1/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 0x35d7
movq %rbx, %rdi
callq 0x27ac
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x2cde
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x2cde
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x303c
movb $0x1, %bpl
testb %al, %al
jne 0x3471
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x3098
movl %eax, %ebp
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3480
callq 0x20b0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x348f
callq 0x20b0
testb %bpl, %bpl
je 0x366a
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq %rcx, %rax
je 0x34ba
movq 0x8(%rbx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
addq %rsi, %rax
cmpq %rax, %rdx
je 0x34ba
movq %rax, 0x8(%rbx)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x354f
xorl %r13d, %r13d
leaq 0x4(%rsp), %r12
xorl %ebp, %ebp
movl (%rax,%r13,4), %eax
movzbl %bpl, %ecx
andl $0x1, %ecx
subl %ecx, %eax
movl %eax, 0x4(%rsp)
movq (%r15), %rcx
movq 0x8(%r15), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x34fd
subl (%rcx,%r13,4), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %ebp
testl %ebp, %ebp
jns 0x3511
movl 0x5bdd(%rip), %eax      # 0x90e8
addl %ebp, %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x352b
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x3536
movq %rbx, %rdi
movq %r12, %rdx
callq 0x58f8
shrl $0x1f, %ebp
incq %r13
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
ja 0x34d1
movq 0x8(%rbx), %rdx
cmpl $0x0, -0x4(%rdx)
jne 0x3590
leaq -0x4(%rdx), %rdi
movq %rdx, %rax
subq (%rbx), %rax
cmpq $0x5, %rax
jb 0x3590
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0x357a
subq %rsi, %rdx
callq 0x2140
movq 0x8(%rbx), %rax
leaq -0x4(%rax), %rdx
movq %rdx, 0x8(%rbx)
leaq -0x8(%rax), %rdi
cmpl $0x0, -0x8(%rax)
je 0x355d
leaq 0x28(%rsp), %rsi
movq $0x0, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x2b68
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3098
movl %eax, %ebp
movq (%r15), %rdi
testq %rdi, %rdi
je 0x35c5
callq 0x20b0
testb %bpl, %bpl
jne 0x36fe
movb 0x18(%r14), %al
jmp 0x36fb
leaq 0x8(%rsp), %rdi
callq 0x27ac
movq %rbx, %rdi
callq 0x27ac
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x551e
movb 0x18(%r15), %al
xorb $0x1, %al
leaq 0x8(%rsp), %rsi
movb %al, 0x18(%rsi)
leaq 0x48(%rsp), %rdi
callq 0x2822
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rdx
movq %r14, %rsi
callq 0x3118
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x551e
movb 0x40(%rsp), %al
movb %al, 0x18(%rbx)
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3643
callq 0x20b0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x3652
callq 0x20b0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x36fe
callq 0x20b0
jmp 0x36fe
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x2822
leaq 0x8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %r15, %rsi
callq 0x3402
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x551e
movb 0x20(%rsp), %al
movb %al, 0x18(%rbx)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x36ac
callq 0x20b0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x36bb
callq 0x20b0
leaq 0x28(%rsp), %rsi
movq $0x0, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x2b68
leaq 0x8(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3098
movl %eax, %ebp
movq (%r15), %rdi
testq %rdi, %rdi
je 0x36f0
callq 0x20b0
testb %bpl, %bpl
jne 0x36fe
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 0x3793
jmp 0x3793
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x372e
callq 0x20b0
jmp 0x372e
movq %rax, %r14
movq 0x68(%rsp), %rdi
jmp 0x377b
jmp 0x3793
movq %rax, %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x374e
callq 0x20b0
jmp 0x374e
movq %rax, %r14
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x3764
callq 0x20b0
jmp 0x3764
jmp 0x3761
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x378a
callq 0x20b0
jmp 0x378a
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3796
callq 0x20b0
jmp 0x3796
movq %rax, %r14
movq 0x8(%rsp), %rdi
jmp 0x3799
jmp 0x3793
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x37a3
callq 0x20b0
movq %r14, %rdi
callq 0x2180
nop