// File: /workspace/github_c_makefile_star2_O1/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 0x8733
cmpl $0x0, (%rdi)
je 0x8926
cmpl $0x1, -0x4(%r14)
jne 0x8744
cmpl $0x0, (%r14)
je 0x8929
callq 0x7e34
movq %rax, %rbx
movq %r14, %rdi
callq 0x7e34
movq %rax, %r15
movl (%rbx), %eax
xorl %r14d, %r14d
testb $0x1, %al
sete %al
jne 0x87a7
xorl %r14d, %r14d
testb $0x1, (%r15)
jne 0x8790
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x8615
movq %r15, %rdi
callq 0x8615
incl %r14d
testb $0x1, (%rbx)
sete %al
jne 0x87a7
testb $0x1, (%r15)
je 0x876f
testb %al, %al
je 0x87a7
movq %rbx, %rdi
callq 0x7e34
movq %rax, %r12
movl $0x1, %r13d
jmp 0x87b8
movq %r15, %rdi
callq 0x7e34
movq %rax, %r12
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb $0x1, (%r12)
jne 0x87c9
movq %r12, %rdi
callq 0x8615
jmp 0x87b8
cmpl $0x1, %r13d
jne 0x87ee
addq $-0x4, %rbx
movq %rbx, %rdi
callq 0x7040
decl 0x3597b(%rip)           # 0x3e15c
movq %r12, %rdi
callq 0x7e34
movq %rax, %rbx
jmp 0x880b
addq $-0x4, %r15
movq %r15, %rdi
callq 0x7040
decl 0x3595c(%rip)           # 0x3e15c
movq %r12, %rdi
callq 0x7e34
movq %rax, %r15
addq $-0x4, %r12
movq %r12, %rdi
callq 0x7040
decl 0x3593f(%rip)           # 0x3e15c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x866a
testl %eax, %eax
js 0x8842
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7f39
movq %rax, %r12
movl $0x1, %r13d
jmp 0x8856
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7f39
movq %rax, %r12
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $0x1, -0x4(%r12)
jne 0x87b8
cmpl $0x0, (%r12)
jne 0x87b8
addq $-0x4, %r12
movq %r12, %rdi
callq 0x7040
decl 0x358dd(%rip)           # 0x3e15c
addq $-0x4, %r15
movq %r15, %rdi
callq 0x7040
decl 0x358cb(%rip)           # 0x3e15c
movl %r14d, %r13d
shrl $0x5, %r13d
leal 0x1(%r13), %r12d
leal 0x8(,%r13,4), %edi
callq 0x7810
incl 0x358ad(%rip)           # 0x3e15c
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 0x7b16
movq %rax, %r14
addq $-0x4, %rbx
movq %rbx, %rdi
callq 0x7040
movl 0x35862(%rip), %ebx     # 0x3e15c
leal -0x1(%rbx), %eax
movl %eax, 0x35859(%rip)     # 0x3e15c
movq %r15, %rdi
callq 0x7040
addl $-0x2, %ebx
movl %ebx, 0x35848(%rip)     # 0x3e15c
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7e34