// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, -0x4(%rax)
jne 0x8d0d
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x8d0d
movq -0x18(%rbp), %rdi
callq 0x8170
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8f2d
movq -0x18(%rbp), %rax
cmpl $0x1, -0x4(%rax)
jne 0x8d3a
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x8d3a
movq -0x10(%rbp), %rdi
callq 0x8170
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8f2d
movq -0x10(%rbp), %rdi
callq 0x8170
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rdi
callq 0x8170
movq %rax, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0x1, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x31(%rbp)
jne 0x8d80
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x8d89
jmp 0x8da6
movq -0x10(%rbp), %rdi
callq 0x8af0
movq -0x18(%rbp), %rdi
callq 0x8af0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x8d5b
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x8dca
movq -0x18(%rbp), %rdi
callq 0x8170
movq %rax, -0x30(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
jmp 0x8dde
movq -0x10(%rbp), %rdi
callq 0x8170
movq %rax, -0x30(%rbp)
movl $0x1, -0x28(%rbp)
jmp 0x8de0
jmp 0x8de2
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x8dfb
movq -0x30(%rbp), %rdi
callq 0x8af0
jmp 0x8de2
cmpl $0x1, -0x28(%rbp)
jne 0x8e19
movq -0x10(%rbp), %rdi
callq 0x7e70
movq -0x30(%rbp), %rdi
callq 0x8170
movq %rax, -0x10(%rbp)
jmp 0x8e2f
movq -0x18(%rbp), %rdi
callq 0x7e70
movq -0x30(%rbp), %rdi
callq 0x8170
movq %rax, -0x18(%rbp)
movq -0x30(%rbp), %rdi
callq 0x7e70
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8b80
cmpl $0x0, %eax
jge 0x8e64
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x8310
movq %rax, -0x30(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
jmp 0x8e7c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8310
movq %rax, -0x30(%rbp)
movl $0x1, -0x28(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x1, -0x4(%rax)
jne 0x8f28
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x8f28
movq -0x30(%rbp), %rdi
callq 0x7e70
movq -0x18(%rbp), %rdi
callq 0x7e70
movl -0x20(%rbp), %eax
movl $0x20, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edi
callq 0x82c0
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x8eef
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x8ecd
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x7b40
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x7d40
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7e70
movq -0x18(%rbp), %rdi
callq 0x7e70
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8f2d
jmp 0x8de0
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)