// File: /workspace/github_c_makefile_star2_O1/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 0x33d5
movq %rsi, %r13
movl 0xc(%r12), %ecx
testl %ecx, %ecx
je 0x33dd
xorl $0x1, %eax
xorl $0x1, %ecx
orl %eax, %ecx
jne 0x33ed
movq (%r13), %rax
movl (%rax), %ecx
movq (%r12), %rax
movl (%rax), %ebp
testl %ecx, %ecx
je 0x3500
movl %ebp, %eax
xorl %edx, %edx
divl %ecx
testl %edx, %edx
je 0x34fe
movl %edx, %ebp
movl %ecx, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %ecx
testl %edx, %edx
jne 0x33b4
jmp 0x3500
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x33e3
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1c5e
jmp 0x351c
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 0x2f3d
movl %eax, %ebp
movq %r12, %rdi
callq 0x2f3d
cmpl %eax, %ebp
cmovll %ebp, %eax
movq %r14, %rdi
movq %r13, %rsi
movl %ebp, %edx
movl %eax, %ebp
callq 0x2ea3
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x2ea3
xorl %eax, %eax
movl %eax, 0x8(%r14)
movl %eax, 0x8(%r15)
movq %r15, %rdi
callq 0x2f3d
movq %r15, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x2ea3
movq 0x20(%rsp), %rdi
movl 0x2c(%rsp), %esi
movq (%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x1b00
testl %eax, %eax
jle 0x349c
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 0x2a04
cmpl $0x0, 0xc(%rsp)
jne 0x3447
leaq 0x20(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x2e57
movq (%r14), %rdi
callq 0x1030
xorl %ebp, %ebp
movl %ebp, 0x10(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq (%rsp), %rdi
callq 0x1030
movl %ebp, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
jmp 0x3523
movl %ecx, %ebp
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1a71
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