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

	if (x_bignum_negative_p(a)) {
		if (x_bignum_negative_p(b)) {
			/* -A+-B --> -(|A|+|B|) */
			a = bignum_abs(a);
			save(a);
			a = bignum_add(a, bignum_abs(b));
			unsave(1);
			return bignum_negate(a);
		}
		else {
			/* -A+B --> B-|A| */
			return bignum_subtract(b, bignum_abs(a));
		}
	}
	else if (x_bignum_negative_p(b)) {
		/* A+-B --> A-|B| */
		return bignum_subtract(a, bignum_abs(b));
	}
	/* A+B */
	a = reverse_segments(cdr(a));
	save(a);
	b = reverse_segments(cdr(b));
	save(b);
	carry = 0;
	result = NIL;
	save(result);
	while (a != NIL || b != NIL || carry) {
		fa = a == NIL? 0: car(a);
		fb = b == NIL? 0: car(b);
		r = fa + fb + carry;
		carry = 0;
		if (r >= INT_SEG_LIMIT) {
			r -= INT_SEG_LIMIT;
			carry = 1;
		}
		result = new_atom(r, result);
		car(Stack) = result;
		if (a != NIL) a = cdr(a);
		if (b != NIL) b = cdr(b);
	}
	unsave(3);
	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, %r15
movq %rdi, %rbx
movq 0x19cef(%rip), %rax     # 0x1e170
movq 0x1a138(%rip), %rcx     # 0x1e5c0
movq (%rcx,%rdi,8), %r12
cmpq $0x0, (%rax,%r12,8)
movq (%rcx,%rsi,8), %rcx
movq (%rax,%rcx,8), %r14
js 0x46a7
testq %r14, %r14
js 0x46bf
movq $-0x1, %rbx
movq $-0x1, %r14
cmpq $-0x1, %r12
je 0x44e4
movq 0x19cad(%rip), %rax     # 0x1e170
movq (%rax,%r12,8), %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x36e8
movq %rax, %r14
movq 0x1a0e2(%rip), %rax     # 0x1e5c0
movq (%rax,%r12,8), %r12
jmp 0x44b6
movq 0x19c3d(%rip), %rsi     # 0x1e128
movq %r14, %rdi
xorl %edx, %edx
callq 0x36e8
movq %rax, 0x19c2c(%rip)     # 0x1e128
movq 0x1a0bd(%rip), %rcx     # 0x1e5c0
movq (%rcx,%r15,8), %r15
cmpq $-0x1, %r15
je 0x4547
movq $-0x1, %rbx
movq 0x19c55(%rip), %rax     # 0x1e170
movq (%rax,%r15,8), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x36e8
movq %rax, %rbx
movq 0x1a08a(%rip), %rax     # 0x1e5c0
movq (%rax,%r15,8), %r15
cmpq $-0x1, %r15
jne 0x4514
movq 0x19be1(%rip), %rax     # 0x1e128
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x36e8
movq %rax, 0x19bcd(%rip)     # 0x1e128
movq $-0x1, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x36e8
movq $-0x1, %rsi
movq %rax, 0x19bae(%rip)     # 0x1e128
movq %r14, %rax
andq %rbx, %rax
cmpq $-0x1, %rax
je 0x4678
cmpq $-0x1, %rbx
setne %dl
cmpq $-0x1, %r14
setne %r12b
xorl %edi, %edi
cmpq $-0x1, %r14
je 0x45ae
movq 0x19bc8(%rip), %rax     # 0x1e170
movq (%rax,%r14,8), %rax
jmp 0x45b0
xorl %eax, %eax
cmpq $-0x1, %rbx
movb %dl, -0x29(%rbp)
je 0x45c6
movq 0x19bb0(%rip), %rcx     # 0x1e170
movq (%rcx,%rbx,8), %rcx
jmp 0x45c8
xorl %ecx, %ecx
addq %rdi, %rax
leaq (%rax,%rcx), %r13
cmpq $0x3b9aca00, %r13       # imm = 0x3B9ACA00
setge %r15b
leaq -0x3b9aca00(%rcx,%rax), %rdi
cmovlq %r13, %rdi
movl $0x1, %edx
callq 0x36e8
movq %rax, %rsi
movq 0x19b76(%rip), %rax     # 0x1e170
movq 0x19b27(%rip), %rcx     # 0x1e128
movq %rsi, (%rax,%rcx,8)
movq $-0x1, %rax
movq $-0x1, %rcx
testb $0x1, %r12b
je 0x4624
movq 0x19fa0(%rip), %rcx     # 0x1e5c0
movq (%rcx,%r14,8), %rcx
testb $0x1, -0x29(%rbp)
je 0x4635
movq 0x19f8f(%rip), %rax     # 0x1e5c0
movq (%rax,%rbx,8), %rax
xorl %edi, %edi
movb %r15b, %dil
cmpq $-0x1, %rax
setne %dl
movq %rcx, %r14
movq %rax, %rbx
cmpq $-0x1, %rcx
setne %r12b
jne 0x459b
movq %rcx, %r14
movq %rax, %rbx
cmpq $-0x1, %rax
jne 0x459b
movq %rcx, %r14
movq %rax, %rbx
cmpq $0x3b9ac9ff, %r13       # imm = 0x3B9AC9FF
jg 0x459b
movl $0x3, %edi
movq %rsi, %rbx
callq 0x384f
movq $-0x18, %rdi
movq %rbx, %rsi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36e8
movq %rbx, %rdi
callq 0x4392
movq %rax, %rbx
testq %r14, %r14
js 0x46e0
movq %r15, %rdi
movq %rbx, %rsi
jmp 0x46cd
movq %r15, %rdi
callq 0x4392
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4796
movq 0x19a41(%rip), %rsi     # 0x1e128
movq %rbx, %rdi
xorl %edx, %edx
callq 0x36e8
movq %rax, 0x19a30(%rip)     # 0x1e128
movq %r15, %rdi
callq 0x4392
movq %rbx, %rdi
movq %rax, %rsi
callq 0x472e
movq %rax, %rbx
movl $0x1, %edi
callq 0x384f
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x43d9