// File: /workspace/github_c_makefile_star2_O0/georgeweigt[P]eigenmath/eigenmath.c
// Function: mmod
uint32_t *
mmod(uint32_t *u, uint32_t *v)
{
	int i, k, nu, nv;
	uint32_t qhat, *w;
	uint64_t a, b, t;
	mnorm(u);
	mnorm(v);
	if (MLENGTH(v) == 1 && v[0] == 0)
		stopf("divide by zero"); // v = 0
	u = mcopy(u);
	nu = MLENGTH(u);
	nv = MLENGTH(v);
	k = nu - nv;
	if (k < 0)
		return u; // u < v
	w = mnew(nv + 1);
	b = v[nv - 1];
	do {
		while (nu >= nv + k) {
			// estimate 32-bit partial quotient
			a = u[nu - 1];
			if (nu > nv + k)
				a = a << 32 | u[nu - 2];
			if (a < b)
				break;
			qhat = (uint32_t) (a / (b + 1));
			if (qhat == 0)
				qhat = 1;
			// w = qhat * v
			t = 0;
			for (i = 0; i < nv; i++) {
				t += (uint64_t) qhat * v[i];
				w[i] = (uint32_t) t;
				t >>= 32;
			}
			w[nv] = (uint32_t) t;
			// u = u - w
			t = 0;
			for (i = k; i < nu; i++) {
				t += (uint64_t) u[i] - w[i - k];
				u[i] = (uint32_t) t;
				t = (int64_t) t >> 32; // cast to extend sign
			}
			if (t) {
				// u is negative, restore u
				t = 0;
				for (i = k; i < nu; i++) {
					t += (uint64_t) u[i] + w[i - k];
					u[i] = (uint32_t) t;
					t >>= 32;
				}
				break;
			}
			mnorm(u);
			nu = MLENGTH(u);
		}
	} while (--k >= 0);
	mfree(w);
	return u;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8270
movq -0x18(%rbp), %rdi
callq 0x8270
movq -0x18(%rbp), %rax
cmpl $0x1, -0x4(%rax)
jne 0x87b1
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x87b1
leaq 0x3c9b2(%rip), %rdi     # 0x4515e
callq 0x78d0
movq -0x10(%rbp), %rdi
callq 0x8170
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl -0x4(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl -0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x87ee
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8a0c
movl -0x28(%rbp), %edi
addl $0x1, %edi
callq 0x82c0
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x48(%rbp)
jmp 0x8813
movl -0x24(%rbp), %eax
movl -0x28(%rbp), %ecx
addl -0x20(%rbp), %ecx
cmpl %ecx, %eax
jl 0x89e7
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x40(%rbp)
movl -0x24(%rbp), %eax
movl -0x28(%rbp), %ecx
addl -0x20(%rbp), %ecx
cmpl %ecx, %eax
jle 0x8864
movq -0x40(%rbp), %rax
shlq $0x20, %rax
movq -0x10(%rbp), %rcx
movl -0x24(%rbp), %edx
subl $0x2, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
orq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0x8873
jmp 0x89e7
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
addq $0x1, %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x8894
movl $0x1, -0x2c(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x88ed
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
imulq %rcx, %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
shrq $0x20, %rax
movq %rax, -0x50(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x88a3
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq $0x0, -0x50(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x8962
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
movl -0x1c(%rbp), %edx
subl -0x20(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
subq %rcx, %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
sarq $0x20, %rax
movq %rax, -0x50(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x890c
cmpq $0x0, -0x50(%rbp)
je 0x89cf
movq $0x0, -0x50(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x89cd
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
movl -0x1c(%rbp), %edx
subl -0x20(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
addq %rcx, %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
shrq $0x20, %rax
movq %rax, -0x50(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x8977
jmp 0x89e7
movq -0x10(%rbp), %rdi
callq 0x8270
movq -0x10(%rbp), %rax
movl -0x4(%rax), %eax
movl %eax, -0x24(%rbp)
jmp 0x8813
jmp 0x89e9
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, %eax
jge 0x8811
movq -0x38(%rbp), %rdi
callq 0x7e70
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)