// File: /workspace/github_c_makefile_star2_O3/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)
movl (%rsi), %r13d
movq 0x8(%rdi), %rcx
movq 0x10(%rdi), %rax
movq 0x10(%rcx), %r15
movq 0x10(%rax), %rdx
movq %rdx, 0x10(%rsp)
testl %r13d, %r13d
jle 0xc087
movq %rdi, %rbp
movq 0x18(%rcx), %rdx
movq %rdx, 0x58(%rsp)
movq 0x20(%rcx), %rcx
movq %rcx, 0x50(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x20(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rdi), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rdi), %r12
movq 0x28(%rdi), %r14
movq 0x30(%rdi), %rax
movq %rax, 0x40(%rsp)
leaq (,%r13,8), %rdx
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x8200
leaq 0x4(,%r13,4), %rdx
movq %r15, 0x30(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x8200
movq %rbp, %r9
xorl %ebp, %ebp
xorl %r15d, %r15d
movq %r9, 0x20(%rsp)
movq 0x30(%rsp), %rax
movl %r15d, (%rax,%rbx,4)
movq 0x10(%rsp), %rax
movl %ebp, (%rax,%rbx,4)
movl %ebx, %edx
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0xbf54
movl (%rax,%rbx,4), %edx
movq 0x20(%r9), %rax
movl (%rax,%rbx,4), %r8d
movl %r8d, 0x1c(%rsp)
movq 0x8(%r9), %rdi
movq 0x18(%r9), %rax
movq (%rax,%rbx,8), %rcx
movq %r14, (%rsp)
movq 0x60(%rsp), %rsi
movq %r12, %r9
callq 0xb900
movq 0x40(%rsp), %rax
movslq (%rax,%rbx,4), %rax
movsd (%r12,%rax,8), %xmm0
movslq %r15d, %rcx
movq 0x58(%rsp), %r8
movl %eax, (%r8,%rcx,4)
movq 0x50(%rsp), %r10
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%r10,%rcx,8)
movl 0x1c(%rsp), %eax
incl %r15d
cmpl %r13d, %eax
jge 0xc02c
cltq
movq 0x20(%rsp), %r9
movq 0x18(%r9), %rcx
movq (%rcx,%rbx,8), %rcx
movq 0x28(%rsp), %r11
movl (%rcx,%rax,4), %edx
movslq %edx, %rdx
movl (%r14,%rdx,4), %edi
movslq %edi, %rsi
cmpq %rsi, %rbx
jle 0xbffb
movslq %ebp, %rbp
movl %edi, (%r11,%rbp,4)
movsd (%r12,%rdx,8), %xmm1
movq 0x38(%rsp), %rsi
movsd %xmm1, (%rsi,%rbp,8)
incl %ebp
movslq (%r14,%rdx,4), %rsi
cmpq %rbx, %rsi
jle 0xc01a
movslq %r15d, %r15
movl %edx, (%r8,%r15,4)
movsd (%r12,%rdx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%r10,%r15,8)
incl %r15d
movq $0x0, (%r12,%rdx,8)
incq %rax
cmpq %rax, %r13
jne 0xbfcc
jmp 0xc036
movq 0x20(%rsp), %r9
movq 0x28(%rsp), %r11
movslq %ebp, %rbp
movl %ebx, (%r11,%rbp,4)
movq 0x38(%rsp), %rax
movsd %xmm0, (%rax,%rbp,8)
incl %ebp
incq %rbx
cmpq %r13, %rbx
jne 0xbf34
movq 0x30(%rsp), %rax
movl %r15d, (%rax,%r13,4)
movq 0x10(%rsp), %rax
movl %ebp, (%rax,%r13,4)
testl %r15d, %r15d
jle 0xc0af
movl %r15d, %eax
xorl %ecx, %ecx
movslq (%r8,%rcx,4), %rdx
movl (%r14,%rdx,4), %edx
movl %edx, (%r8,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0xc071
jmp 0xc0af
testl %r13d, %r13d
js 0xc09e
leaq 0x4(,%r13,4), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x8200
movslq %r13d, %rax
xorl %ecx, %ecx
movl %ecx, (%r15,%rax,4)
movq 0x10(%rsp), %rdx
movl %ecx, (%rdx,%rax,4)
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq