// File: /workspace/github_c_makefile_star2_O2/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, %r15
movq %rdi, %r12
callq 0x2455
movq %rax, %rbx
movq %r15, %rdi
callq 0x2455
cmpq %rax, %rbx
movq %r15, %rdi
cmovaq %r12, %rdi
movq %r12, %r14
cmovaq %r15, %r14
callq 0x2455
movq %rax, %rbx
movq %r14, %rdi
callq 0x2455
addq %rbx, %rax
movzbl 0x651f(%rip), %ecx      # 0x90e0
cmpq %rcx, %rax
jae 0x2bf3
movq %r12, %rdi
callq 0x359d
movq %rax, %rbx
movq %r15, %rdi
callq 0x359d
imulq %rax, %rbx
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22e0
shrq %rbx
leaq 0x1(%rbx), %rbp
movq %rbp, 0x20(%rsp)
leaq 0x40(%rsp), %r13
leaq 0x28(%rsp), %rcx
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x35ca
leaq 0x30(%rsp), %r12
leaq 0x38(%rsp), %r14
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x35ca
movq (%r13), %rbp
movq (%r12), %r15
movq %rbp, %rdi
movq %r15, %rsi
movq %r15, (%rsp)
callq 0x2b72
movq %rax, 0x10(%rsp)
leaq 0x28(%rsp), %rax
movq (%rax), %r12
movq (%r14), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x2b72
movq %rax, 0x18(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x27a5
movq %rax, %r13
movq %r15, %rdi
movq %r14, %rsi
callq 0x27a5
movq %rax, %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0x2b72
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x4c7e
movq %rbp, %rdi
callq 0x4c7e
movq %r14, %rdi
callq 0x4c7e
movq (%rsp), %rdi
callq 0x4c7e
movq %r13, %rdi
callq 0x4c7e
movq %r15, %rdi
callq 0x4c7e
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq 0x10(%rsp), %r13
movq %r13, %rsi
callq 0x28f8
movq %rax, %r14
movq %r15, %rdi
callq 0x4c7e
movq %r14, %rdi
movq 0x18(%rsp), %r12
movq %r12, %rsi
callq 0x28f8
movq %rax, %r15
movq %r14, %rdi
callq 0x4c7e
leaq 0x2(,%rbx,2), %rsi
movq %r13, %rdi
callq 0x3653
movq %r15, %rdi
movq 0x20(%rsp), %rsi
callq 0x3653
movq %r13, %rdi
movq %r15, %rsi
callq 0x27a5
movq %rax, %rbx
movq %r13, %rdi
callq 0x4c7e
movq %r15, %rdi
callq 0x4c7e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x27a5
movq %rax, %r14
movq %rbx, %rdi
callq 0x4c7e
movq %r12, %rdi
callq 0x4c7e
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq