// File: /workspace/github_c_makefile_star2_O3/georgeweigt[P]eigenmath/eigenmath.c
// Function: mgcd
uint32_t *
mgcd(uint32_t *u, uint32_t *v)
{
	int i, k, n, sign;
	uint32_t *t;

	if (MZERO(u)) {
		t = mcopy(v);
		return t;
	}

	if (MZERO(v)) {
		t = mcopy(u);
		return t;
	}

	u = mcopy(u);
	v = mcopy(v);

	k = 0;

	while ((u[0] & 1) == 0 && (v[0] & 1) == 0) {
		mshr(u);
		mshr(v);
		k++;
	}

	if (u[0] & 1) {
		t = mcopy(v);
		sign = -1;
	} else {
		t = mcopy(u);
		sign = 1;
	}

	while (1) {

		while ((t[0] & 1) == 0)
			mshr(t);

		if (sign == 1) {
			mfree(u);
			u = mcopy(t);
		} else {
			mfree(v);
			v = mcopy(t);
		}

		mfree(t);

		if (mcmp(u, v) < 0) {
			t = msub(v, u);
			sign = -1;
		} else {
			t = msub(u, v);
			sign = 1;
		}

		if (MZERO(t)) {
			mfree(t);
			mfree(v);
			n = (k / 32) + 1;
			v = mnew(n);
			for (i = 0; i < n; i++)
				v[i] = 0;
			msetbit(v, k);
			t = mmul(u, v);
			mfree(u);
			mfree(v);
			return t;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
cmpl $0x1, -0x4(%rdi)
jne 0x87d0
cmpl $0x0, (%rdi)
je 0x882c
cmpl $0x1, -0x4(%r14)
jne 0x87dd
cmpl $0x0, (%r14)
je 0x882f
callq 0x7e97
movq %rax, %rbx
movq %r14, %rdi
callq 0x7e97
movq %rax, %r15
xorl %r14d, %r14d
testb $0x1, (%rbx)
jne 0x8819
xorl %r14d, %r14d
testb $0x1, (%r15)
jne 0x8842
movq %rbx, %rdi
callq 0x86a4
movq %r15, %rdi
callq 0x86a4
incl %r14d
testb $0x1, (%rbx)
je 0x87fb
movq %r15, %rdi
callq 0x7e97
movq %rax, %r12
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x8853
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7e97
movq %rbx, %rdi
callq 0x7e97
movq %rax, %r12
movl $0x1, %r13d
testb $0x1, (%r12)
jne 0x8864
movq %r12, %rdi
callq 0x86a4
jmp 0x8853
cmpl $0x1, %r13d
jne 0x8889
addq $-0x4, %rbx
movq %rbx, %rdi
callq 0x7040
decl 0x3a8e0(%rip)           # 0x4315c
movq %r12, %rdi
callq 0x7e97
movq %rax, %rbx
jmp 0x88a6
addq $-0x4, %r15
movq %r15, %rdi
callq 0x7040
decl 0x3a8c1(%rip)           # 0x4315c
movq %r12, %rdi
callq 0x7e97
movq %rax, %r15
addq $-0x4, %r12
movq %r12, %rdi
callq 0x7040
decl 0x3a8a4(%rip)           # 0x4315c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8704
testl %eax, %eax
js 0x88dd
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7f9c
movq %rax, %r12
movl $0x1, %r13d
jmp 0x88f1
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7f9c
movq %rax, %r12
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $0x1, -0x4(%r12)
jne 0x8853
cmpl $0x0, (%r12)
jne 0x8853
addq $-0x4, %r12
movq %r12, %rdi
callq 0x7040
decl 0x3a842(%rip)           # 0x4315c
addq $-0x4, %r15
movq %r15, %rdi
callq 0x7040
decl 0x3a830(%rip)           # 0x4315c
movl %r14d, %r13d
shrl $0x5, %r13d
leal 0x1(%r13), %r12d
leal 0x8(,%r13,4), %edi
callq 0x7853
incl 0x3a812(%rip)           # 0x4315c
movq %rax, %r15
movl %r12d, (%rax)
leaq 0x4(%rax), %r12
leal 0x4(,%r13,4), %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x7130
movl $0x1, %eax
movl %r14d, %ecx
shll %cl, %eax
orl %eax, 0x4(%r15,%r13,4)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7b60
movq %rax, %r14
addq $-0x4, %rbx
movq %rbx, %rdi
callq 0x7040
movl 0x3a7c7(%rip), %ebx     # 0x4315c
movq %r15, %rdi
callq 0x7040
addl $-0x2, %ebx
movl %ebx, 0x3a7b6(%rip)     # 0x4315c
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq