// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../tools/sparse.c
// Function: sp_refactor
int sp_refactor(sp_num *N, sp_mat *A){
	double pivot, *Lx, *Ux, *x;
	int *Lp, *Li, *Up, *Ui, *pinv, *pvec, *q;
	int n, ipiv, k, top, p, i, col, lnz, unz;
	n = A->ncols;
	Li = N->L->Ai; Lp = N->L->Ap; Lx = N->L->Ax;
	Ui = N->U->Ai; Up = N->U->Ap; Ux = N->U->Ax;
	q = N->q;
	lnz = 0; unz = 0;
	x = N->w; pinv = N->pinv; pvec = N->p;
	for (i=0; i<n; i++) x[i]=0;
	for (k=0; k<=n; k++) Lp[k] = 0;
	for(k=0; k<n; k++){
		/* Triangular solve: */
		Lp[k] = lnz;
		Up[k] = unz;
		col = q ? (q[k]) : k;

		top = N->topvec[k];
		sp_splsolve(N->L, A, col, N->xi[k], top, x, pinv);
		/* Assign values to U and L: */
		ipiv = pvec[k];
		pivot = x[ipiv];
		Li[lnz] = ipiv;
		Lx[lnz] = 1;
		lnz++;
		for (p=top; p<n; p++){
			i = N->xi[k][p];
			if (pinv[i]<k){
				Ui[unz] = pinv[i];
				Ux[unz] = x[i];
				unz++;
			}
			if (pinv[i]>k){
				Li[lnz] = i;
				Lx[lnz] = x[i]/pivot;
				lnz++;
			}
			x[i] = 0;
		}
		Ui[unz] = k;
		Ux[unz] = pivot;
		unz++;
	}
	Lp[n] = lnz;
	Up[n] = unz;
	for(p=0; p<lnz; p++) Li[p] = pinv[Li[p]];
	return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, 0x60(%rsp)
movslq (%rsi), %rsi
movl %esi, %r14d
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
movq 0x10(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq 0x18(%rax), %rdx
movq %rdx, 0x40(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x10(%rcx), %rax
movq %rax, 0x48(%rsp)
movq 0x18(%rcx), %rax
movq %rax, 0x38(%rsp)
movq 0x20(%rcx), %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rdi), %rcx
movq 0x48(%rdi), %r12
movq 0x28(%rdi), %rbx
movq %rdi, %r8
movq 0x30(%rdi), %rax
movq %rax, 0x50(%rsp)
movq %rsi, 0x18(%rsp)
testq %rsi, %rsi
movq %rcx, 0x8(%rsp)
jle 0xbf7a
leaq (,%r14,8), %rdx
movq %r12, %rdi
xorl %esi, %esi
movq %r8, %r15
callq 0x8200
movq 0x8(%rsp), %rcx
movq %r15, %r8
testl %r14d, %r14d
js 0xbf9e
leaq 0x4(,%r14,4), %rdx
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %r8, %r15
callq 0x8200
movq 0x8(%rsp), %rcx
movq %r15, %r8
cmpl $0x0, 0x18(%rsp)
jle 0xc0e1
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r15d, %r15d
movq %r8, 0x28(%rsp)
movq 0x10(%rsp), %rax
movl %r15d, (%rax,%rbp,4)
movq 0x48(%rsp), %rax
movl %r13d, (%rax,%rbp,4)
testq %rcx, %rcx
je 0xbfd2
movl (%rcx,%rbp,4), %edx
jmp 0xbfd4
movl %ebp, %edx
movq %r8, %r9
movq 0x20(%r8), %rax
movl (%rax,%rbp,4), %r8d
movl %r8d, 0x24(%rsp)
movq 0x8(%r9), %rdi
movq 0x18(%r9), %rax
movq (%rax,%rbp,8), %rcx
movq %rbx, (%rsp)
movq 0x60(%rsp), %rsi
movq %r12, %r9
callq 0xb90e
movl 0x24(%rsp), %edx
movq 0x50(%rsp), %rax
movslq (%rax,%rbp,4), %rax
movsd (%r12,%rax,8), %xmm0
movslq %r15d, %rcx
movq 0x40(%rsp), %rdi
movl %eax, (%rdi,%rcx,4)
movq 0x58(%rsp), %r9
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%r9,%rcx,8)
incl %r15d
cmpl 0x18(%rsp), %edx
jge 0xc0af
movslq %edx, %rax
movq 0x28(%rsp), %r8
movq 0x18(%r8), %rcx
movq (%rcx,%rbp,8), %rcx
movq 0x38(%rsp), %r10
movq 0x30(%rsp), %r11
movl (%rcx,%rax,4), %edx
movslq %edx, %rdx
movslq (%rbx,%rdx,4), %rsi
cmpq %rsi, %rbp
jle 0xc07a
movslq %r13d, %r13
movl %esi, (%r10,%r13,4)
movsd (%r12,%rdx,8), %xmm1
movsd %xmm1, (%r11,%r13,8)
incl %r13d
movslq (%rbx,%rdx,4), %rsi
cmpq %rsi, %rbp
jge 0xc09d
movslq %r15d, %r15
movl %edx, (%rdi,%r15,4)
movsd (%r12,%rdx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%r9,%r15,8)
incl %r15d
movq $0x0, (%r12,%rdx,8)
incq %rax
cmpq %rax, %r14
jne 0xc055
jmp 0xc0be
movq 0x28(%rsp), %r8
movq 0x38(%rsp), %r10
movq 0x30(%rsp), %r11
movslq %r13d, %r13
movl %ebp, (%r10,%r13,4)
movsd %xmm0, (%r11,%r13,8)
incl %r13d
incq %rbp
cmpq %r14, %rbp
movq 0x8(%rsp), %rcx
jne 0xbfb6
jmp 0xc0ec
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movl %r15d, (%rcx,%rax,4)
movq 0x48(%rsp), %rcx
movl %r13d, (%rcx,%rax,4)
testl %r15d, %r15d
jle 0xc11f
movl %r15d, %eax
xorl %ecx, %ecx
movslq (%rdi,%rcx,4), %rdx
movl (%rbx,%rdx,4), %edx
movl %edx, (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0xc10d
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq