// File: /workspace/github_c_makefile_star2_O2/azhai[P]mlite/mlite.c
// Function: x_bignum_subtract
cell x_bignum_subtract(cell a, cell b) {
	cell	fa, fb, result, r;
	int	borrow;

	if (x_bignum_negative_p(a)) {
		if (x_bignum_negative_p(b)) {
			/* -A--B --> -A+|B| --> |B|-|A| */
			a = bignum_abs(a);
			save(a);
			a = bignum_subtract(bignum_abs(b), a);
			unsave(1);
			return a;
		}
		else {
			/* -A-B --> -(|A|+B) */
			return bignum_negate(bignum_add(bignum_abs(a), b));
		}
	}
	else if (x_bignum_negative_p(b)) {
		/* A--B --> A+|B| */
		return bignum_add(a, bignum_abs(b));
	}
	/* A-B, A<B --> -(B-A) */
	if (bignum_less_p(a, b))
		return bignum_negate(bignum_subtract(b, a));
	/* A-B, A>=B */
	a = reverse_segments(cdr(a));
	save(a);
	b = reverse_segments(cdr(b));
	save(b);
	borrow = 0;
	result = NIL;
	save(result);
	while (a != NIL || b != NIL || borrow) {
		fa = a == NIL? 0: car(a);
		fb = b == NIL? 0: car(b);
		r = fa - fb - borrow;
		borrow = 0;
		if (r < 0) {
			r += INT_SEG_LIMIT;
			borrow = 1;
		}
		result = new_atom(r, result);
		car(Stack) = result;
		if (a != NIL) a = cdr(a);
		if (b != NIL) b = cdr(b);
	}
	unsave(3);
	while (car(result) == 0 && cdr(result) != NIL)
		result = cdr(result);
	return new_atom(T_INTEGER, result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x17a32(%rip), %rax     # 0x1c170
movq 0x17e7b(%rip), %rcx     # 0x1c5c0
movq (%rcx,%rdi,8), %rdx
cmpq $0x0, (%rax,%rdx,8)
movq (%rcx,%rsi,8), %rcx
movq (%rax,%rcx,8), %r15
js 0x4779
testq %r15, %r15
js 0x47ae
movq %rbx, %rdi
movq %r14, %rsi
callq 0x45c4
testl %eax, %eax
je 0x47cf
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4561
jmp 0x4798
movq %rbx, %rdi
callq 0x4228
movq %rax, %rbx
testq %r15, %r15
js 0x493e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x44fe
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x426f
movq %r14, %rdi
callq 0x4228
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x44fe
movq 0x17dea(%rip), %rax     # 0x1c5c0
movq (%rax,%rbx,8), %rdi
callq 0x42ae
movq %rax, %rbx
movq 0x1793f(%rip), %rsi     # 0x1c128
xorl %r12d, %r12d
movq %rax, %rdi
xorl %edx, %edx
callq 0x3613
movq %rax, 0x1792b(%rip)     # 0x1c128
movq 0x17dbc(%rip), %rax     # 0x1c5c0
movq (%rax,%r14,8), %rdi
callq 0x42ae
movq %rax, %r14
movq 0x17911(%rip), %rsi     # 0x1c128
movq %rax, %rdi
xorl %edx, %edx
callq 0x3613
movq %rax, 0x17900(%rip)     # 0x1c128
pushq $-0x1
popq %r15
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x3613
movq %rax, 0x178e8(%rip)     # 0x1c128
movq %r14, %r13
cmpq $-0x1, %rbx
jne 0x4858
cmpq $-0x1, %r13
jne 0x4858
testl %r12d, %r12d
je 0x48fb
cmpq $-0x1, %rbx
je 0x486b
movq 0x1790b(%rip), %rax     # 0x1c170
movq (%rax,%rbx,8), %r14
jmp 0x486e
xorl %r14d, %r14d
cmpq $-0x1, %r13
je 0x4881
movq 0x178f5(%rip), %rax     # 0x1c170
movq (%rax,%r13,8), %rax
jmp 0x4883
xorl %eax, %eax
movl %r12d, %ecx
addq %rax, %rcx
subq %rcx, %r14
leaq 0x3b9aca00(%r14), %rdi
testq %r14, %r14
cmovnsq %r14, %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x3613
movq %rax, %r15
movq 0x178c1(%rip), %rax     # 0x1c170
movq 0x17872(%rip), %rcx     # 0x1c128
movq %r15, (%rax,%rcx,8)
pushq $-0x1
popq %rcx
movq %rcx, %rax
cmpq $-0x1, %rbx
je 0x48d1
movq 0x17cf3(%rip), %rax     # 0x1c5c0
movq (%rax,%rbx,8), %rax
shrq $0x3f, %r14
movl %r14d, %r12d
movq %rcx, %r14
movq %rax, %rbx
cmpq $-0x1, %r13
je 0x4840
movq 0x17cd1(%rip), %rcx     # 0x1c5c0
movq (%rcx,%r13,8), %r14
movq %rax, %rbx
jmp 0x4840
pushq $0x3
popq %rdi
callq 0x3775
movq 0x17866(%rip), %rax     # 0x1c170
movq 0x17caf(%rip), %rcx     # 0x1c5c0
movq %r15, %rsi
cmpq $0x0, (%rax,%r15,8)
jne 0x4925
movq (%rcx,%rsi,8), %r15
cmpq $-0x1, %r15
jne 0x4911
pushq $-0x18
popq %rdi
pushq $0x1
popq %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3613
movq 0x177e3(%rip), %rsi     # 0x1c128
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3613
movq %rax, 0x177d2(%rip)     # 0x1c128
movq %r14, %rdi
callq 0x4228
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4561
movq %rax, %rbx
pushq $0x1
popq %rdi
callq 0x3775
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq