// File: /workspace/github_c_makefile_star2_O3/983[P]bigint/bigint.c
// Function: bigint_gcd
bigint* bigint_gcd(bigint *dst, const bigint *src_a, const bigint *src_b){
    int shift, shift_a, shift_b;
    bigint a[1], b[1];

    if (src_a->size == 0) return bigint_set_neg(bigint_cpy(dst, src_b), 0);
    if (src_b->size == 0) return bigint_set_neg(bigint_cpy(dst, src_a), 0);

    if (src_a->size == 1 && src_b->size == 1){
        bigint_word word = bigint_word_gcd(src_a->words[0], src_b->words[0]);
        return bigint_from_word(dst, word);
    }

    bigint_init(a);
    bigint_init(b);

    shift_a = bigint_count_trailing_zeros(src_a);
    shift_b = bigint_count_trailing_zeros(src_b);
    shift = BIGINT_MIN(shift_a, shift_b);

    bigint_shift_right(a, src_a, shift_a);
    bigint_shift_right(b, src_b, shift);
    a->neg = 0;
    b->neg = 0;

    do {
        bigint_shift_right(b, b, bigint_count_trailing_zeros(b));

        if (bigint_cmp_abs(a, b) > 0) BIGINT_SWAP(bigint, *a, *b);

        bigint_sub(b, b, a);
    } while (b->size != 0);

    bigint_shift_left(dst, a, shift);

    bigint_free(a);
    bigint_free(b);
    return dst;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r12
movq %rdi, %rbx
movl 0xc(%rsi), %eax
testl %eax, %eax
je 0x33d4
movq %rsi, %r13
movl 0xc(%r12), %ecx
testl %ecx, %ecx
je 0x33dc
xorl $0x1, %eax
xorl $0x1, %ecx
orl %eax, %ecx
jne 0x33ec
movq (%r13), %rax
movl (%rax), %ecx
movq (%r12), %rax
movl (%rax), %ebp
testl %ecx, %ecx
je 0x34f6
movl %ebp, %eax
xorl %edx, %edx
divl %ecx
testl %edx, %edx
je 0x34f4
movl %edx, %ebp
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %ecx
testl %edx, %edx
jne 0x33b3
jmp 0x34f6
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x33e2
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1c42
jmp 0x3512
xorl %eax, %eax
leaq 0x20(%rsp), %r14
movl %eax, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq %rsp, %r15
movaps %xmm0, (%r15)
movl %eax, 0x10(%r15)
movq %r13, %rdi
callq 0x2f6b
movl %eax, %ebp
movq %r12, %rdi
callq 0x2f6b
cmpl %eax, %ebp
cmovll %ebp, %eax
movq %r14, %rdi
movq %r13, %rsi
movl %ebp, %edx
movl %eax, %ebp
callq 0x2ed1
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x2ed1
xorl %eax, %eax
movl %eax, 0x8(%r14)
movl %eax, 0x8(%r15)
movq %r15, %rdi
callq 0x2f6b
movq %r15, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x2ed1
movq 0x20(%rsp), %rdi
movl 0x2c(%rsp), %esi
movq (%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x1ae4
testl %eax, %eax
jle 0x349b
movq 0x30(%rsp), %rax
movaps 0x20(%rsp), %xmm0
movaps (%rsp), %xmm1
movaps %xmm1, 0x20(%rsp)
movq 0x10(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movaps %xmm0, (%rsp)
movq %rax, 0x10(%rsp)
movl 0x8(%rsp), %edx
xorl %r8d, %r8d
cmpl $0x0, 0x28(%rsp)
sete %r8b
movq %r15, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x2a19
cmpl $0x0, 0xc(%rsp)
jne 0x3446
leaq 0x20(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x2e85
movq (%r14), %rdi
callq 0x1030
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movl $0x0, 0x10(%r14)
movq (%rsp), %rdi
callq 0x1030
jmp 0x3519
movl %ecx, %ebp
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1a55
movq (%rbx), %rax
movl %ebp, (%rax)
xorl %eax, %eax
testl %ebp, %ebp
setne %al
movl %eax, 0xc(%rbx)
movl $0x0, 0x8(%rbx)
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq