// File: /workspace/github_c_makefile_star2_O3/theck01[P]offbrand_lib/src/classes/obint.c
// Function: obint_add_unsigned
obint * obint_add_unsigned(const obint *a, const obint *b){

  uint64_t i, large_most_sig, small_most_sig;
  int8_t carry = 0;
  obint *result;
  const obint *larger, *smaller;

  larger = obint_most_sig(a) > obint_most_sig(b) ? a : b;
  smaller = obint_most_sig(a) <= obint_most_sig(b) ? a : b;

  large_most_sig = obint_most_sig(larger);
  small_most_sig = obint_most_sig(smaller);

  /* reserve enough space for the result, +2 required for actual size of larger
   * and possible extra digit needed to catch any addition overflow */
  result = obint_create_default(large_most_sig+2);

  for(i=0; i<= small_most_sig; i++){
    result->digits[i] = (larger->digits[i] + smaller->digits[i] + carry)%10;
    carry = (larger->digits[i] + smaller->digits[i] + carry)/10;
  }

  for( ; i<= large_most_sig; i++){
    result->digits[i] = (larger->digits[i] + carry)%10;
    carry = (larger->digits[i] + carry)/10;
  }

  result->digits[i] = carry;

  return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %rcx
movq 0x18(%rdi), %r8
movq %r8, %rdx
leaq -0x1(%rdx), %rax
cmpq $0x1, %rdx
je 0x2a20
cmpb $0x0, -0x1(%rcx,%rdx)
movq %rax, %rdx
je 0x2a0c
movq 0x10(%rsi), %rdi
movq 0x18(%rsi), %r9
movq %r9, %rdx
leaq -0x1(%rdx), %r10
cmpq $0x1, %rdx
je 0x2a3f
cmpb $0x0, -0x1(%rdi,%rdx)
movq %r10, %rdx
je 0x2a2b
leaq -0x1(%r8), %rdx
cmpq $0x1, %r8
je 0x2a61
cmpb $0x0, -0x1(%rcx,%r8)
movq %rdx, %r8
je 0x2a3f
jmp 0x2a61
cmpb $0x0, -0x1(%rdi,%r9)
movq %rcx, %r9
jne 0x2a6b
leaq -0x1(%r9), %rcx
cmpq $0x1, %r9
jne 0x2a56
cmpq %r10, %rax
movq %rsi, %r14
cmovaq %rbx, %r14
movq 0x10(%r14), %rax
movq 0x18(%r14), %rdi
leaq -0x1(%rdi), %r15
cmpq $0x1, %rdi
je 0x2a91
cmpb $0x0, -0x1(%rax,%rdi)
movq %r15, %rdi
je 0x2a7d
cmpq %rcx, %rdx
cmovaq %rsi, %rbx
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
leaq -0x1(%rcx), %r12
cmpq $0x1, %rcx
je 0x2ab4
cmpb $0x0, -0x1(%rax,%rcx)
movq %r12, %rcx
je 0x2aa0
leaq 0x2(%r15), %rdi
callq 0x2541
movq 0x10(%r14), %rdx
movq 0x10(%rbx), %r8
xorl %ecx, %ecx
xorl %esi, %esi
movq %rcx, %rdi
movsbl (%rdx,%rcx), %ecx
movsbl (%r8,%rdi), %edx
movsbl %sil, %esi
addl %esi, %ecx
addl %edx, %ecx
imull $0x6667, %ecx, %edx     # imm = 0x6667
movl %edx, %r8d
shrl $0x1f, %r8d
shrl $0x12, %edx
addl %r8d, %edx
addl %edx, %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %ecx
movq 0x10(%rax), %rdx
movb %cl, (%rdx,%rdi)
movq 0x10(%r14), %rdx
movsbl (%rdx,%rdi), %ecx
movq 0x10(%rbx), %r8
movsbl (%r8,%rdi), %r9d
addl %esi, %ecx
addl %r9d, %ecx
imull $0x6667, %ecx, %esi     # imm = 0x6667
movl %esi, %ecx
shrl $0x1f, %ecx
shrl $0x12, %esi
addl %ecx, %esi
leaq 0x1(%rdi), %rcx
cmpq %r12, %rdi
jb 0x2ac9
leaq -0x1(%rcx), %rdi
cmpq %r15, %rdi
jae 0x2b83
movsbl (%rdx,%rcx), %edx
movsbl %sil, %esi
addl %esi, %edx
imull $0x6667, %edx, %edi     # imm = 0x6667
movl %edi, %r8d
shrl $0x1f, %r8d
shrl $0x12, %edi
addl %r8d, %edi
addl %edi, %edi
leal (%rdi,%rdi,4), %edi
subl %edi, %edx
movq 0x10(%rax), %rdi
movb %dl, (%rdi,%rcx)
movq 0x10(%r14), %rdx
movsbl (%rdx,%rcx), %edi
addl %esi, %edi
imull $0x6667, %edi, %esi     # imm = 0x6667
movl %esi, %edi
shrl $0x1f, %edi
shrl $0x12, %esi
addl %edi, %esi
incq %rcx
cmpq %r15, %rcx
jbe 0x2b36
movq 0x10(%rax), %rdx
movb %sil, (%rdx,%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq