// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
cmpl $0x1, 0x28(%rdi)
jne 0x112e8
movq 0x68(%r14), %rsi
testl %ebp, %ebp
jle 0x1123e
movq 0x10(%rsi), %rax
movq 0x18(%rsi), %rcx
xorpd 0xe0052(%rip), %xmm0    # 0xf1230
movq 0x20(%rsi), %rdx
movl %ebp, %edi
xorl %r8d, %r8d
movsd 0xe0071(%rip), %xmm1    # 0xf1260
movslq (%rax,%r8,4), %r9
movslq 0x4(%rax,%r8,4), %r10
cmpl %r10d, %r9d
jge 0x11236
movl (%rcx,%r9,4), %r11d
cmpq %r11, %r8
jne 0x1121a
movq 0x70(%r14), %r11
movsd (%r11,%r9,8), %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
jmp 0x11228
movq 0x70(%r14), %r11
movsd (%r11,%r9,8), %xmm2
mulsd %xmm0, %xmm2
movsd %xmm2, (%rdx,%r9,8)
incq %r9
cmpq %r9, %r10
jne 0x111fd
incq %r8
cmpq %rdi, %r8
jne 0x111ef
cmpl $0x1, 0x44(%r14)
jne 0x113ce
movq %r14, %rdi
callq 0x1198a
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 0xc22a
movq 0x68(%r14), %rsi
movq 0x78(%r14), %rdi
movsd 0xe0ac2(%rip), %xmm0    # 0xf1d48
callq 0xb9f2
cmpl $0x1, %eax
jne 0x113d9
leaq 0xe0ef0(%rip), %rsi     # 0xf218b
leaq 0x810(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xdfdce(%rip), %rsi     # 0xf1082
leaq 0xe0cbc(%rip), %rdx     # 0xf1f77
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xdfd60(%rip), %rsi     # 0xf1034
leaq 0xe0ee0(%rip), %rdx     # 0xf21bb
movq %rbx, %rdi
movl $0x3d4, %ecx            # imm = 0x3D4
jmp 0x113bd
testl %ebp, %ebp
jle 0x11352
xorpd 0xdff3c(%rip), %xmm0    # 0xf1230
movl %ebp, %eax
leaq 0x1(%rax), %rcx
movq (%r14), %rdx
movq 0x10(%r14), %rsi
movl $0x1, %edi
xorl %r8d, %r8d
movsd 0xdff4f(%rip), %xmm1    # 0xf1260
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 0x11338
movapd %xmm2, %xmm3
movsd %xmm3, 0x8(%r10,%r11,8)
incq %r11
cmpq %r11, %rax
jne 0x1131c
incq %rdi
incq %r8
cmpq %rcx, %rdi
jne 0x11311
movq 0x20(%r14), %rdx
movq 0x10(%r14), %rdi
movq 0x18(%r14), %r8
leaq 0x8(%rsp), %rcx
movl %ebp, %esi
callq 0x11dba
testl %eax, %eax
je 0x113e1
leaq 0xe0e58(%rip), %rsi     # 0xf21cd
leaq 0x810(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xdfcf4(%rip), %rsi     # 0xf1082
leaq 0xe0be2(%rip), %rdx     # 0xf1f77
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xdfc86(%rip), %rsi     # 0xf1034
leaq 0xe0e06(%rip), %rdx     # 0xf21bb
movq %rbx, %rdi
movl $0x3e7, %ecx            # imm = 0x3E7
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
jmp 0x113e3
movq 0x78(%r14), %rdi
callq 0xbedf
jmp 0x113e1
movl $0x0, 0x44(%r14)
xorl %eax, %eax
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r14
popq %r15
popq %rbp
retq