// File: /workspace/github_c_makefile_star2_O2/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 %rdi, %r14
movq %rsi, 0x50(%rsp)
movslq (%rsi), %r9
movq 0x8(%rdi), %rax
movq 0x10(%rdi), %rcx
movq 0x10(%rax), %rdx
movq 0x18(%rax), %r8
movq 0x20(%rax), %r10
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rcx), %r11
movq 0x20(%rcx), %rax
movq %rax, 0x18(%rsp)
movq 0x38(%rdi), %rcx
movq 0x48(%rdi), %r15
movq 0x28(%rdi), %r13
movq 0x30(%rdi), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
testl %r9d, %r9d
movl $0x0, %esi
cmovgl %r9d, %esi
cmpq %rax, %rsi
je 0xa89b
andq $0x0, (%r15,%rax,8)
incq %rax
jmp 0xa88c
xorl %eax, %eax
cmpq %r9, %rax
jg 0xa8ab
andl $0x0, (%rdx,%rax,4)
incq %rax
jmp 0xa89d
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r8, 0x60(%rsp)
movq %r9, 0x58(%rsp)
movq %rdx, 0x48(%rsp)
movq %r10, 0x40(%rsp)
movq %r11, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %rsi, 0x20(%rsp)
cmpq %rsi, %rbp
je 0xa9f0
movl %r12d, (%rdx,%rbp,4)
movq 0x10(%rsp), %rax
movl %ebx, (%rax,%rbp,4)
movl %ebp, %edx
testq %rcx, %rcx
je 0xa8f4
movl (%rcx,%rbp,4), %edx
movq 0x20(%r14), %rax
movl (%rax,%rbp,4), %r8d
movl %r8d, 0xc(%rsp)
movq 0x8(%r14), %rdi
movq 0x18(%r14), %rax
movq (%rax,%rbp,8), %rcx
movq %r13, (%rsp)
movq 0x50(%rsp), %rsi
movq %r15, %r9
callq 0xa34f
movq 0x28(%rsp), %rax
movslq (%rax,%rbp,4), %rax
movsd (%r15,%rax,8), %xmm0
movslq %r12d, %rcx
movq 0x60(%rsp), %r8
movl %eax, (%r8,%rcx,4)
movq 0x40(%rsp), %r10
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%r10,%rcx,8)
incl %r12d
movslq 0xc(%rsp), %rax
movq 0x58(%rsp), %r9
movq 0x38(%rsp), %r11
movslq %ebx, %rdx
cmpq %r9, %rax
jge 0xa9c7
movq 0x18(%r14), %rcx
movq (%rcx,%rbp,8), %rcx
movl (%rcx,%rax,4), %ecx
movslq %ecx, %rcx
movl (%r13,%rcx,4), %edi
movslq %edi, %rsi
cmpq %rsi, %rbp
jle 0xa99e
movl %edi, (%r11,%rdx,4)
movsd (%r15,%rcx,8), %xmm1
movq 0x18(%rsp), %rsi
movsd %xmm1, (%rsi,%rdx,8)
incl %edx
movslq (%r13,%rcx,4), %rsi
movl %edx, %ebx
cmpq %rbp, %rsi
jle 0xa9bd
movslq %r12d, %r12
movl %ecx, (%r8,%r12,4)
movsd (%r15,%rcx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%r10,%r12,8)
incl %r12d
andq $0x0, (%r15,%rcx,8)
incq %rax
jmp 0xa95e
movl %ebp, (%r11,%rdx,4)
movq 0x18(%rsp), %rax
movsd %xmm0, (%rax,%rdx,8)
incl %edx
incq %rbp
movl %edx, %ebx
movq 0x48(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x20(%rsp), %rsi
jmp 0xa8d5
movl %r12d, (%rdx,%r9,4)
movq 0x10(%rsp), %rax
movl %ebx, (%rax,%r9,4)
xorl %eax, %eax
testl %r12d, %r12d
cmovlel %eax, %r12d
cmpq %rax, %r12
je 0xaa1d
movslq (%r8,%rax,4), %rcx
movl (%r13,%rcx,4), %ecx
movl %ecx, (%r8,%rax,4)
incq %rax
jmp 0xaa06
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq