// File: 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:
subq $0x228, %rsp            # imm = 0x228
movq %rdx, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
movq %rdi, %rax
movq %rax, 0x48(%rsp)
movq %rdi, 0x220(%rsp)
movq %rsi, 0x218(%rsp)
movq %rdx, 0x210(%rsp)
movq 0x218(%rsp), %rax
movq %rax, 0x50(%rsp)
movb 0x18(%rax), %al
andb $0x1, %al
movzbl %al, %eax
movb 0x18(%rdx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x43d0
movq 0x40(%rsp), %rdi
movb $0x0, 0x20f(%rsp)
callq 0x2a10
movq 0x50(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0x3240
jmp 0x3e9d
movq 0x38(%rsp), %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x3240
jmp 0x3eb1
leaq 0x1e8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x3840
movb %al, 0x37(%rsp)
jmp 0x3ecc
leaq 0x1b8(%rsp), %rdi
callq 0x2a80
leaq 0x1e8(%rsp), %rdi
callq 0x2a80
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x3ef3
jmp 0x426a
movq 0x40(%rsp), %rdi
movb $0x0, 0x1b3(%rsp)
callq 0x7b90
movq %rax, 0x1a0(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x7d20
movq 0x40(%rsp), %rdi
callq 0x7c00
movq %rax, 0x190(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x7d20
movq 0x40(%rsp), %rdi
movq 0x1a8(%rsp), %rsi
movq 0x198(%rsp), %rdx
callq 0x7c80
movq %rax, 0x28(%rsp)
jmp 0x3f6a
movq 0x28(%rsp), %rax
movq %rax, 0x188(%rsp)
movl $0x0, 0x184(%rsp)
movl $0x0, 0x180(%rsp)
movq 0x50(%rsp), %rdi
movslq 0x184(%rsp), %rax
movq %rax, 0x20(%rsp)
callq 0x7fb0
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x4104
movq 0x50(%rsp), %rdi
movslq 0x184(%rsp), %rsi
callq 0x8120
movl (%rax), %eax
movl %eax, 0x1b4(%rsp)
testb $0x1, 0x1b3(%rsp)
je 0x404f
movl 0x1b4(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x1b4(%rsp)
jmp 0x404f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x43c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x403d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x2a80
leaq 0x1e8(%rsp), %rdi
callq 0x2a80
jmp 0x43c1
movq 0x38(%rsp), %rdi
movslq 0x180(%rsp), %rax
movq %rax, 0x18(%rsp)
callq 0x7fb0
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0x4097
movq 0x38(%rsp), %rdi
movslq 0x180(%rsp), %rsi
callq 0x8120
movl (%rax), %ecx
movl 0x1b4(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x1b4(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jge 0x40bf
movl 0xb0d1(%rip), %eax      # 0xf178
addl 0x1b4(%rsp), %eax
movl %eax, 0x1b4(%rsp)
movb $0x1, 0x1b3(%rsp)
jmp 0x40c7
movb $0x0, 0x1b3(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x1b4(%rsp), %rsi
callq 0x7d60
jmp 0x40db
jmp 0x40dd
movl 0x184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
movl 0x180(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x180(%rsp)
jmp 0x3f8d
jmp 0x4106
movq 0x40(%rsp), %rdi
callq 0x7c00
movq %rax, 0x170(%rsp)
leaq 0x170(%rsp), %rdi
movl $0x1, %esi
callq 0x7e60
movq %rax, 0x178(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x7c30
movq %rax, %rcx
xorl %eax, %eax
cmpl $0x0, (%rcx)
movb %al, 0x17(%rsp)
jne 0x4162
movq 0x40(%rsp), %rdi
callq 0x7fb0
cmpq $0x1, %rax
seta %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x416c
jmp 0x41d8
movq 0x40(%rsp), %rdi
callq 0x7c00
movq %rax, 0x158(%rsp)
leaq 0x158(%rsp), %rdi
movl $0x1, %esi
callq 0x7e60
movq %rax, 0x160(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x7d20
movq 0x40(%rsp), %rdi
movq 0x168(%rsp), %rsi
callq 0x7eb0
movq %rax, 0x8(%rsp)
jmp 0x41c6
movq 0x8(%rsp), %rax
movq %rax, 0x150(%rsp)
jmp 0x4106
movq $0x0, 0x128(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x30a0
jmp 0x41fb
movq 0x40(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x3890
movb %al, 0x7(%rsp)
jmp 0x4213
leaq 0x130(%rsp), %rdi
callq 0x2a80
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x422a
jmp 0x4265
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
movb 0x18(%rcx), %cl
andb $0x1, %cl
movb %cl, 0x18(%rax)
jmp 0x4265
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x2a80
jmp 0x43c1
jmp 0x43a0
movq 0x50(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x2a90
jmp 0x427e
movq 0x38(%rsp), %rsi
leaq 0x108(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
callq 0x3e20
jmp 0x429a
movq 0x40(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x81f0
jmp 0x42ae
leaq 0x108(%rsp), %rdi
callq 0x2a80
leaq 0xe8(%rsp), %rdi
callq 0x2a80
movq $0x0, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x30a0
jmp 0x42eb
movq 0x40(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x3890
movb %al, 0x6(%rsp)
jmp 0x4303
leaq 0xc8(%rsp), %rdi
callq 0x2a80
movb 0x6(%rsp), %al
testb $0x1, %al
jne 0x431d
jmp 0x439e
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
movb 0x18(%rcx), %cl
xorb $-0x1, %cl
andb $0x1, %cl
movb %cl, 0x18(%rax)
jmp 0x439e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x436c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x2a80
leaq 0xe8(%rsp), %rdi
callq 0x2a80
jmp 0x43c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x2a80
jmp 0x43c1
jmp 0x43a0
movb $0x1, 0x20f(%rsp)
testb $0x1, 0x20f(%rsp)
jne 0x43bc
movq 0x40(%rsp), %rdi
callq 0x2a80
jmp 0x4519
movq 0x40(%rsp), %rdi
callq 0x2a80
jmp 0x4526
leaq 0xa0(%rsp), %rdi
callq 0x2a10
movq 0x40(%rsp), %rdi
movb $0x0, 0x9f(%rsp)
callq 0x2a10
jmp 0x43f1
movq 0x38(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x7780
jmp 0x4405
movq 0x38(%rsp), %rax
movb 0x18(%rax), %al
notb %al
andb $0x1, %al
movb %al, 0xb8(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2a90
jmp 0x442c
movq 0x50(%rsp), %rsi
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x38c0
jmp 0x4442
movq 0x40(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x81f0
jmp 0x4453
leaq 0x78(%rsp), %rdi
callq 0x2a80
leaq 0x58(%rsp), %rdi
callq 0x2a80
movb $0x1, 0x9f(%rsp)
testb $0x1, 0x9f(%rsp)
jne 0x44f1
jmp 0x44e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x450a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x4500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x44db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x2a80
leaq 0x58(%rsp), %rdi
callq 0x2a80
jmp 0x4500
movq 0x40(%rsp), %rdi
callq 0x2a80
leaq 0xa0(%rsp), %rdi
callq 0x2a80
jmp 0x4519
movq 0x40(%rsp), %rdi
callq 0x2a80
leaq 0xa0(%rsp), %rdi
callq 0x2a80
jmp 0x4526
movq 0x48(%rsp), %rax
addq $0x228, %rsp            # imm = 0x228
retq
movq 0x1e0(%rsp), %rdi
callq 0x2260
nopw %cs:(%rax,%rax)