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

  uint64_t large_most_sig, small_most_sig, split_point;
  const obint *larger, *smaller;
  obint *x0, *x1, *y0, *y1; /* split versions of a and b */
  obint *z0, *z1, *z1a, *z1b, *z1c, *z1d, *z2; /* partial results of Karatsuba
                                                  algorithm */
  obint *partial_result, *result;

  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);

  /* base case, a and b are single digits */
  if(large_most_sig + small_most_sig < int64_max_digits)
    return obint_new(obint_magnitude(a) * obint_magnitude(b));

  split_point = large_most_sig/2+1;
  obint_split(a, split_point, &x1, &x0);
  obint_split(b, split_point, &y1, &y0);

  z2 = obint_multiply_unsigned(x1, y1);
  z0 = obint_multiply_unsigned(x0, y0);

  z1a = obint_add_unsigned(x1, x0);
  z1b = obint_add_unsigned(y1, y0);
  z1c = obint_multiply_unsigned(z1a, z1b);

  ob_release((obj *)x0);
  ob_release((obj *)x1);
  ob_release((obj *)y0);
  ob_release((obj *)y1);
  ob_release((obj *)z1a);
  ob_release((obj *)z1b);

  z1d = obint_subtract_unsigned(z1c, z2);
  ob_release((obj *)z1c);
  z1 = obint_subtract_unsigned(z1d, z0);
  ob_release((obj *)z1d);

  obint_shift(z2, 2*split_point);
  obint_shift(z1, split_point);
  partial_result = obint_add_unsigned(z2, z1);

  ob_release((obj *) z2);
  ob_release((obj *) z1);

  result = obint_add_unsigned(partial_result, z0);

  ob_release((obj *) partial_result);
  ob_release((obj *) z0);

  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq 0x10(%rdi), %rcx
movq 0x18(%rdi), %rsi
movq %rsi, %rax
leaq -0x1(%rax), %r8
cmpq $0x1, %rax
je 0x2ef3
cmpb $0x0, -0x1(%rcx,%rax)
movq %r8, %rax
je 0x2edf
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rdx
movq %rdx, %r9
leaq -0x1(%r9), %r10
cmpq $0x1, %r9
je 0x2f13
cmpb $0x0, -0x1(%rax,%r9)
movq %r10, %r9
je 0x2efe
movq %rsi, %r11
leaq -0x1(%r11), %r9
cmpq $0x1, %r11
je 0x2f2b
cmpb $0x0, -0x1(%rcx,%r11)
movq %r9, %r11
je 0x2f16
movq %rdx, %r14
leaq -0x1(%r14), %r11
cmpq $0x1, %r14
je 0x2f43
cmpb $0x0, -0x1(%rax,%r14)
movq %r11, %r14
je 0x2f2e
cmpq %r10, %r8
movq %rbx, %r10
cmovaq %rdi, %r10
movq 0x10(%r10), %r8
movq 0x18(%r10), %r10
leaq -0x1(%r10), %r15
cmpq $0x1, %r10
je 0x2f6a
cmpb $0x0, -0x1(%r8,%r10)
movq %r15, %r10
je 0x2f55
cmpq %r11, %r9
movq %rdi, %r8
cmovaq %rbx, %r8
movq 0x10(%r8), %r9
movq 0x18(%r8), %r10
leaq -0x1(%r10), %r8
cmpq $0x1, %r10
je 0x2f91
cmpb $0x0, -0x1(%r9,%r10)
movq %r8, %r10
je 0x2f7c
addq %r15, %r8
movzbl 0x713c(%rip), %r9d      # 0xa0d8
cmpq %r9, %r8
jae 0x3016
leaq -0x1(%rsi), %rdi
cmpq $0x1, %rsi
je 0x2fb5
cmpb $0x0, -0x1(%rcx,%rsi)
movq %rdi, %rsi
je 0x2fa1
xorl %esi, %esi
movq %rdi, %r8
leaq (%rsi,%rsi,4), %rsi
movsbq (%rcx,%r8), %r9
leaq (%r9,%rsi,2), %rsi
decq %r8
cmpq %rdi, %r8
jbe 0x2fba
jmp 0x2fdb
cmpb $0x0, -0x1(%rax,%rdx)
movq %rcx, %rdx
jne 0x2fe5
leaq -0x1(%rdx), %rcx
cmpq $0x1, %rdx
jne 0x2fd1
xorl %edi, %edi
movq %rcx, %rdx
leaq (%rdi,%rdi,4), %rdi
movsbq (%rax,%rdx), %r8
leaq (%r8,%rdi,2), %rdi
decq %rdx
cmpq %rcx, %rdx
jbe 0x2fea
imulq %rsi, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2490
shrq %r15
leaq 0x1(%r15), %r13
movq %r13, 0x20(%rsp)
leaq 0x40(%rsp), %r14
leaq 0x28(%rsp), %rcx
movq %r13, %rsi
movq %r14, %rdx
callq 0x3ae3
leaq 0x30(%rsp), %r12
leaq 0x38(%rsp), %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x3ae3
movq (%r14), %r13
movq (%r12), %r14
movq %r13, %rdi
movq %r14, %rsi
movq %r14, (%rsp)
callq 0x2ec3
movq %rax, 0x10(%rsp)
leaq 0x28(%rsp), %rax
movq (%rax), %rbx
movq (%rbp), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2ec3
movq %rax, 0x18(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2a00
movq %rax, %r12
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2a00
movq %rax, %r14
movq %r12, %rdi
movq %rax, %rsi
callq 0x2ec3
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x51fa
movq %r13, %rdi
callq 0x51fa
movq %rbp, %rdi
callq 0x51fa
movq (%rsp), %rdi
callq 0x51fa
movq %r12, %rdi
callq 0x51fa
movq %r14, %rdi
callq 0x51fa
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0x2c16
movq %rax, %rbx
movq %r14, %rdi
callq 0x51fa
movq %rbx, %rdi
movq 0x18(%rsp), %r12
movq %r12, %rsi
callq 0x2c16
movq %rax, %r14
movq %rbx, %rdi
callq 0x51fa
leaq 0x2(,%r15,2), %rsi
movq %r13, %rdi
callq 0x3b6e
movq %r14, %rdi
movq 0x20(%rsp), %rsi
callq 0x3b6e
movq %r13, %rdi
movq %r14, %rsi
callq 0x2a00
movq %rax, %rbx
movq %r13, %rdi
callq 0x51fa
movq %r14, %rdi
callq 0x51fa
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2a00
movq %rax, %r14
movq %rbx, %rdi
callq 0x51fa
movq %r12, %rdi
callq 0x51fa
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq