// File: /workspace/github_c_makefile_star2_O3/983[P]bigint/bigint.c
// Function: bigint_raw_mul_karatsuba
int bigint_raw_mul_karatsuba(
    bigint_word *dst,
    const bigint_word *a, int na,
    const bigint_word *b, int nb,
    bigint_word *tmp
){
    /* so many */
    int n, k, m, m2;
    const bigint_word *lo1, *hi1, *lo2, *hi2;
    int nlo1, nhi1, nlo2, nhi2;
    bigint_word *lo1hi1, *lo2hi2, *z0, *z1, *z2;
    int nlo1hi1, nlo2hi2, nz0, nz1, nz2;

    if (
        na < BIGINT_KARATSUBA_WORD_THRESHOLD &&
        nb < BIGINT_KARATSUBA_WORD_THRESHOLD
    ){
        bigint_raw_zero(dst, 0, na + nb);
        return bigint_raw_mul_add(dst, a, na, b, nb);
    }

    m = BIGINT_MAX(na, nb);
    m2 = m / 2;
    k = m2 + 2;

    lo1 = a;
    lo2 = b;
    hi1 = a + m2;
    hi2 = b + m2;

    nlo1 = bigint_raw_truncate(lo1, BIGINT_MIN(m2, na));
    nlo2 = bigint_raw_truncate(lo2, BIGINT_MIN(m2, nb));
    nhi1 = bigint_raw_truncate(hi1, BIGINT_MAX(na - m2, 0));
    nhi2 = bigint_raw_truncate(hi2, BIGINT_MAX(nb - m2, 0));

    lo1hi1 = tmp; tmp += k;
    lo2hi2 = tmp; tmp += k;
    z0 = tmp; tmp += k*2;
    z1 = tmp; tmp += k*2;
    z2 = tmp; tmp += k*2;

    nlo1hi1 = bigint_raw_add(lo1hi1, lo1, nlo1, hi1, nhi1);
    nlo2hi2 = bigint_raw_add(lo2hi2, lo2, nlo2, hi2, nhi2);

    nz0 = bigint_raw_mul_karatsuba(z0, lo1   , nlo1   , lo2   , nlo2   , tmp);
    nz1 = bigint_raw_mul_karatsuba(z1, lo1hi1, nlo1hi1, lo2hi2, nlo2hi2, tmp);
    nz2 = bigint_raw_mul_karatsuba(z2,    hi1, nhi1   ,    hi2,    nhi2, tmp);

    nz1 = bigint_raw_sub(z1, z1, nz1, z0, nz0);
    nz1 = bigint_raw_sub(z1, z1, nz1, z2, nz2);

    n = nz0;

    bigint_raw_cpy(dst, z0, n);
    bigint_raw_zero(dst, n, na + nb);

    n = bigint_raw_add(dst + m2*1, dst + m2*1, BIGINT_MAX(n - m2, 0), z1, nz1);
    n = bigint_raw_add(dst + m2*2, dst + m2*2, BIGINT_MAX(n - m2, 0), z2, nz2);

    return bigint_raw_truncate(dst, n + m2*2);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, %r15
movl %edx, %r10d
movq %rsi, %r12
movq %rdi, %rbx
cmpl $0x14, %edx
setge %al
cmpl $0x14, %r8d
setge %cl
orb %al, %cl
jne 0x2388
movl %r8d, %eax
addl %r10d, %eax
jle 0x2369
movl %eax, %edx
shlq $0x2, %rdx
movq %rbx, %rdi
xorl %esi, %esi
movl %r8d, %ebp
movl %r10d, %r14d
callq 0x1070
movl %r14d, %r10d
movl %ebp, %r8d
movq %rbx, %rdi
movq %r12, %rsi
movl %r10d, %edx
movq %r15, %rcx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1f4b
movq %rbx, 0x70(%rsp)
cmpl %r8d, %r10d
movl %r8d, %eax
cmovgl %r10d, %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
cmpl %r10d, %esi
movl %r10d, %r13d
cmovll %esi, %r13d
testl %r13d, %r13d
jle 0x23ca
movl %r13d, %eax
cmpl $0x0, -0x4(%r12,%rax,4)
jne 0x23ca
leal -0x1(%r13), %eax
cmpl $0x1, %r13d
movl %eax, %r13d
jg 0x23af
xorl %r13d, %r13d
movslq %esi, %rdi
cmpl %r8d, %esi
movl %r8d, %r14d
cmovll %esi, %r14d
testl %r14d, %r14d
jle 0x23f7
movl %r14d, %eax
cmpl $0x0, -0x4(%r15,%rax,4)
jne 0x23f7
leal -0x1(%r14), %eax
cmpl $0x1, %r14d
movl %eax, %r14d
jg 0x23dc
xorl %r14d, %r14d
leaq (%r12,%rdi,4), %rbx
movl %r10d, %eax
movl $0x0, %r11d
subl %esi, %eax
jle 0x2423
movl %eax, %ecx
cmpl $0x0, -0x4(%rbx,%rcx,4)
jne 0x2420
leal -0x1(%rax), %ecx
cmpl $0x1, %eax
movl %ecx, %eax
jg 0x2408
xorl %r11d, %r11d
jmp 0x2423
movl %eax, %r11d
leal 0x2(%rdi), %eax
leaq (%r15,%rdi,4), %rbp
movl %r8d, %ecx
subl %esi, %ecx
movl %r8d, 0x2c(%rsp)
movq %rsi, 0x68(%rsp)
movl %r10d, 0x28(%rsp)
movq %rdi, 0x60(%rsp)
movq %r15, 0x10(%rsp)
jle 0x245d
movl %ecx, %edx
cmpl $0x0, -0x4(%rbp,%rdx,4)
jne 0x246a
leal -0x1(%rcx), %edx
cmpl $0x1, %ecx
movl %edx, %ecx
jg 0x244a
movq %r12, %rdx
movl $0x0, 0x8(%rsp)
jmp 0x2471
movq %r12, %rdx
movl %ecx, 0x8(%rsp)
cltq
leaq (%r9,%rax,4), %r12
leaq (%r12,%rax,4), %rcx
movq %r12, 0x48(%rsp)
movq %rcx, 0x30(%rsp)
addl %eax, %eax
cltq
leaq (%rcx,%rax,4), %r15
leaq (%r15,%rax,4), %rcx
movq %rcx, 0x38(%rsp)
leaq (%rcx,%rax,4), %rax
movq %rax, 0x50(%rsp)
movq %r9, %rdi
movq %rdx, %rsi
movq %rdx, 0x40(%rsp)
movl %r13d, %edx
movq %rbx, %rcx
movl %r11d, %r8d
movq %r9, 0x58(%rsp)
movl %r11d, 0x24(%rsp)
callq 0x213c
movl %eax, 0x20(%rsp)
movq %r12, %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
movl %r14d, %edx
movq %rbp, %rcx
movl 0x8(%rsp), %r8d
callq 0x213c
movl %eax, 0x1c(%rsp)
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl %r13d, %edx
movq %r12, %rcx
movl %r14d, %r8d
movq 0x50(%rsp), %r13
movq %r13, %r9
callq 0x231a
movl %eax, %r14d
movq %r15, %rdi
movq 0x58(%rsp), %rsi
movl 0x20(%rsp), %edx
movq 0x48(%rsp), %rcx
movl 0x1c(%rsp), %r8d
movq %r13, %r9
callq 0x231a
movl %eax, 0x10(%rsp)
movq 0x38(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movl 0x24(%rsp), %edx
movq %rbp, %rcx
movl 0x8(%rsp), %r8d
movq %r13, %r9
callq 0x231a
movl %eax, %ebx
movq %r15, %rdi
movq %r15, %rsi
movl 0x10(%rsp), %edx
movq 0x30(%rsp), %r13
movq %r13, %rcx
movl %r14d, %r8d
callq 0x21f6
movq %r15, %rdi
movq %r15, 0x8(%rsp)
movq %r15, %rsi
movl %eax, %edx
movq %r12, %rcx
movl %ebx, %r8d
callq 0x21f6
movl %eax, %ebp
movslq %r14d, %r15
leaq (,%r15,4), %rdx
movq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x10a0
movl 0x2c(%rsp), %eax
addl 0x28(%rsp), %eax
cmpl %eax, %r15d
jge 0x25bc
leaq (%r12,%r15,4), %rdi
subl %r14d, %eax
movslq %eax, %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x1070
movq 0x60(%rsp), %rax
leaq (%r12,%rax,4), %rdi
movq 0x68(%rsp), %r13
subl %r13d, %r14d
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
movq %rdi, %rsi
movl %r14d, %edx
movq 0x8(%rsp), %rcx
movl %ebp, %r8d
callq 0x213c
leal (,%r13,2), %ecx
movslq %ecx, %r14
leaq (%r12,%r14,4), %rdi
subl %r13d, %eax
testl %eax, %eax
cmovgl %eax, %r15d
movq %rdi, %rsi
movl %r15d, %edx
movq 0x38(%rsp), %rcx
movl %ebx, %r8d
callq 0x213c
addl %eax, %r14d
jle 0x2635
movl %r14d, %eax
cmpl $0x0, -0x4(%r12,%rax,4)
jne 0x2635
leal -0x1(%r14), %eax
cmpl $0x1, %r14d
movl %eax, %r14d
jg 0x261a
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq