// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../tools/evolver_ndf15.c
// Function: new_linearisation
int new_linearisation(struct jacobian *jac,double hinvGak,int neq,ErrorMsg error_message){
  double luparity, *Ax;
  int i,j,*Ap,*Ai,funcreturn;
  if(jac->use_sparse==1){
    Ap = jac->spJ->Ap; Ai = jac->spJ->Ai; Ax = jac->spJ->Ax;
    /* Construct jac->spJ->Ax from jac->xjac, the jacobian:*/
    for(j=0;j<neq;j++){
      for(i=Ap[j];i<Ap[j+1];i++){
        if(Ai[i]==j){
          /* I'm at the diagonal */
          Ax[i] = 1.0-hinvGak*jac->xjac[i];
        }
        else{
          Ax[i] = -hinvGak*jac->xjac[i];
        }
      }
    }
    /* Matrix constructed... */
    if(jac->new_jacobian==_TRUE_){
      /*I have a new pattern, and I have not done a LU decomposition
        since the last jacobian calculation, so    I need to do a full
        sparse LU-decomposition: */
      /* Find the sparsity pattern C = J + J':*/
      calc_C(jac);
      /* Calculate the optimal ordering: */
      sp_amd(jac->Cp, jac->Ci, neq, jac->cnzmax,
         jac->Numerical->q,jac->Numerical->wamd);
      /* if the next line is uncomented, the code uses natural ordering instead of AMD ordering */
      /*jac->Numerical->q = NULL;*/
      funcreturn = sp_ludcmp(jac->Numerical, jac->spJ, 1e-3);
      class_test(funcreturn == _FAILURE_,error_message,
         "Failure in sp_ludcmp. Possibly singular matrix!");
      jac->new_jacobian = _FALSE_;
    }
    else{
      /* I have a repeated pattern, so I can just refactor:*/
      sp_refactor(jac->Numerical, jac->spJ);
    }
  }
  else{
    /* Normal calculation: */
    for(i=1;i<=neq;i++){
      for(j=1;j<=neq;j++){
    jac->LU[i][j] = - hinvGak * jac->dfdy[i][j];
    if(i==j) jac->LU[i][j] +=1.0;
      }
    }
    /*Dense LU decomposition: */
    funcreturn = ludcmp(jac->LU,neq,jac->luidx,&luparity,jac->LUw);
    class_test(funcreturn == _FAILURE_,error_message,
           "Failure in ludcmp. Possibly singular matrix!");
  }
  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1010, %rsp           # imm = 0x1010
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
cmpl $0x1, 0x28(%rdi)
jne 0x11447
movq 0x68(%r14), %rsi
testl %ebp, %ebp
jle 0x1139d
movq 0x10(%rsi), %rax
movq 0x18(%rsi), %rcx
movq 0x20(%rsi), %rdx
xorpd 0xdceef(%rip), %xmm0    # 0xee230
movl %ebp, %edi
movl (%rax), %r8d
xorl %r9d, %r9d
movsd 0xdcf0f(%rip), %xmm1    # 0xee260
movl %r8d, %r11d
movl 0x4(%rax,%r9,4), %r8d
cmpl %r8d, %r11d
jge 0x11395
movslq %r8d, %r10
movslq %r11d, %r11
movq 0x70(%r14), %r15
movl (%rcx,%r11,4), %r12d
movsd (%r15,%r11,8), %xmm2
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm3
addsd %xmm1, %xmm3
cmpq %r12, %r9
je 0x11387
movapd %xmm2, %xmm3
movsd %xmm3, (%rdx,%r11,8)
incq %r11
cmpq %r11, %r10
jne 0x11368
incq %r9
cmpq %rdi, %r9
jne 0x11351
cmpl $0x1, 0x44(%r14)
jne 0x1152d
movq %r14, %rdi
callq 0x11ad5
movq 0x80(%r14), %rdi
movq 0x88(%r14), %rsi
movl 0x48(%r14), %ecx
movq 0x78(%r14), %rax
movq 0x38(%rax), %r8
movq 0x40(%rax), %r9
movl %ebp, %edx
callq 0xc1ad
movq 0x68(%r14), %rsi
movq 0x78(%r14), %rdi
movsd 0xdd963(%rip), %xmm0    # 0xeed48
callq 0xb9e4
cmpl $0x1, %eax
jne 0x11538
leaq 0xddd91(%rip), %rsi     # 0xef18b
leaq 0x810(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0xdcc6f(%rip), %rsi     # 0xee082
leaq 0xddb5d(%rip), %rdx     # 0xeef77
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xdcc01(%rip), %rsi     # 0xee034
leaq 0xddd81(%rip), %rdx     # 0xef1bb
movq %rbx, %rdi
movl $0x3d4, %ecx            # imm = 0x3D4
jmp 0x1151c
testl %ebp, %ebp
jle 0x114b1
xorpd 0xdcddd(%rip), %xmm0    # 0xee230
movl %ebp, %eax
leaq 0x1(%rax), %rcx
movq (%r14), %rdx
movq 0x10(%r14), %rsi
movl $0x1, %edi
xorl %r8d, %r8d
movsd 0xdcdf0(%rip), %xmm1    # 0xee260
movq (%rdx,%rdi,8), %r9
movq (%rsi,%rdi,8), %r10
xorl %r11d, %r11d
movsd 0x8(%r9,%r11,8), %xmm2
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm3
addsd %xmm1, %xmm3
cmpq %r11, %r8
je 0x11497
movapd %xmm2, %xmm3
movsd %xmm3, 0x8(%r10,%r11,8)
incq %r11
cmpq %r11, %rax
jne 0x1147b
incq %rdi
incq %r8
cmpq %rcx, %rdi
jne 0x11470
movq 0x20(%r14), %rdx
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r8
leaq 0x8(%rsp), %rcx
movl %ebp, %esi
callq 0x11eef
testl %eax, %eax
je 0x11540
leaq 0xddcf9(%rip), %rsi     # 0xef1cd
leaq 0x810(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0xdcb95(%rip), %rsi     # 0xee082
leaq 0xdda83(%rip), %rdx     # 0xeef77
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xdcb27(%rip), %rsi     # 0xee034
leaq 0xddca7(%rip), %rdx     # 0xef1bb
movq %rbx, %rdi
movl $0x3e7, %ecx            # imm = 0x3E7
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
jmp 0x11542
movq 0x78(%r14), %rdi
callq 0xbe87
jmp 0x11540
movl $0x0, 0x44(%r14)
xorl %eax, %eax
addq $0x1010, %rsp           # imm = 0x1010
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq