// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../external/HMcode/hmcode.c
// Function: hmcode_growint
int hmcode_growint(
                   struct precision *ppr,
                   struct background *pba,
                   struct fourier *pfo,
                   double a,
                   double w0,
                   double wa,
                   double *growth
                   ){

  double z, ainit, amax, scalefactor, gamma, X_de, Hubble2, Omega_m;
  int i, index_scalefactor, index_a, index_growth, index_ddgrowth, index_gcol, ng; // index_scalefactor is a running index while index_a is a column index
  double *pvecback;
  double *integrand;

  ng = 1024; // number of growth values (stepsize of the integral), should not be hardcoded and replaced by a precision parameter
  ainit = a;
  amax = 1.;

  i=0;
  index_a = i;
  i++;
  index_growth = i;
  i++;
  index_ddgrowth = i;
  i++;
  index_gcol = i;

  class_alloc(integrand,ng*index_gcol*sizeof(double),pfo->error_message);
  class_alloc(pvecback,pba->bg_size*sizeof(double),pfo->error_message);

  if (ainit == amax) {
    *growth = 1.;
  }
  else {

    for (index_scalefactor=0;index_scalefactor<ng;index_scalefactor++){

      scalefactor = ainit+(amax-ainit)*(index_scalefactor)/(ng-1);
      z = 1./scalefactor-1.;

      /* This will compute Omega_m(z) for the input values of w0 and wa, to let the user compare the wCDM and LCDM cases. This is why we cannot extract Omega_m(z) fromn the background module in this place. */
      X_de = pow(scalefactor, -3.*(1.+w0+wa))*exp(-3.*wa*(1.-scalefactor));
      Hubble2 = (pba->Omega0_m*pow((1.+z), 3.) + pba->Omega0_k*pow((1.+z), 2.) + pba->Omega0_de*X_de);
      Omega_m = (pba->Omega0_m*pow((1.+z), 3.))/Hubble2;
      /* Samuel brieden: TBC: check that the matching between the
         background quantity and this fitting formula improves by
         using Omega_cb (as it is done in background). Carefull:
         Hubble remains with Omega0_m */

      if (w0 == -1.){
        gamma = 0.55;
      }
      else if (w0 < -1.){
        gamma = 0.55+0.02*(1+w0);
      }
      else {
        gamma = 0.55+0.05*(1+w0);
      }
      integrand[index_scalefactor*index_gcol+index_a] = scalefactor;
      integrand[index_scalefactor*index_gcol+index_growth]= -pow(Omega_m, gamma)/scalefactor;
    }

    class_call(array_spline(integrand,
                            index_gcol,
                            ng,
                            index_a,
                            index_growth,
                            index_ddgrowth,
                            _SPLINE_EST_DERIV_,
                            pfo->error_message),
               pfo->error_message,
               pfo->error_message);

    class_call(array_integrate_all_trapzd_or_spline(integrand,
                                                    index_gcol,
                                                    ng,
                                                    0, //ng-1,
                                                    index_a,
                                                    index_growth,
                                                    index_ddgrowth,
                                                    growth,
                                                    pfo->error_message),
               pfo->error_message,
               pfo->error_message);

    *growth = exp(*growth);

  }
  //fprintf(stdout, "%e %e \n", a, *growth);
  free(pvecback);
  free(integrand);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x858, %rsp            # imm = 0x858
movq %rcx, %r14
movsd %xmm2, 0x8(%rsp)
movapd %xmm1, 0x30(%rsp)
movsd %xmm0, 0x28(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movl $0x6000, %edi           # imm = 0x6000
callq 0x8490
testq %rax, %rax
je 0xd934a
movq %rax, %r15
movsd 0xbf38(%rip), %xmm0     # 0xe5260
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0xd939b
jp 0xd939b
movsd %xmm0, (%r14)
movq %r15, %rdi
callq 0x8430
xorl %ebp, %ebp
jmp 0xd9652
leaq 0xbcb3(%rip), %rsi      # 0xe5004
leaq 0x4bfe0(%rip), %rdx     # 0x125338
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movl $0x6000, %ecx           # imm = 0x6000
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0xbcba(%rip), %rsi      # 0xe5034
leaq 0x4aed7(%rip), %rdx     # 0x124258
movq %rbx, %rdi
movl $0x595, %ecx            # imm = 0x595
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
jmp 0xd9652
movsd 0xbebd(%rip), %xmm2     # 0xe5260
movapd %xmm2, %xmm0
movsd 0xc439(%rip), %xmm4     # 0xe57e8
xorl %eax, %eax
movapd 0x30(%rsp), %xmm3
ucomisd %xmm3, %xmm4
seta %al
subsd %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movapd %xmm3, %xmm0
addsd %xmm2, %xmm0
movapd %xmm0, %xmm5
movsd 0x8(%rsp), %xmm2
addsd %xmm2, %xmm5
movsd 0xf05a(%rip), %xmm1     # 0xe8440
mulsd %xmm1, %xmm5
movsd %xmm5, 0x40(%rsp)
mulsd %xmm1, %xmm2
movsd %xmm2, 0x8(%rsp)
leaq 0x49a8f(%rip), %rcx     # 0x122e90
mulsd (%rcx,%rax,8), %xmm0
movsd 0x46102(%rip), %xmm1    # 0x11f510
addsd %xmm1, %xmm0
cmpeqsd %xmm4, %xmm3
movapd %xmm3, %xmm2
andnpd %xmm0, %xmm2
andpd %xmm1, %xmm3
orpd %xmm2, %xmm3
movapd %xmm3, 0x30(%rsp)
movq %r15, %r13
addq $0x8, %r13
xorl %ebp, %ebp
cmpq $0x400, %rbp            # imm = 0x400
je 0xd9580
cvtsi2sd %ebp, %xmm1
mulsd 0x48(%rsp), %xmm1
divsd 0x498cb(%rip), %xmm1    # 0x122d20
addsd 0x28(%rsp), %xmm1
movsd %xmm1, 0x20(%rsp)
movsd 0xbdf7(%rip), %xmm0     # 0xe5260
divsd %xmm1, %xmm0
addsd 0xc373(%rip), %xmm0     # 0xe57e8
movsd %xmm0, 0x18(%rsp)
movapd %xmm1, %xmm0
movsd 0x40(%rsp), %xmm1
callq 0x8650
movsd %xmm0, (%rsp)
movsd 0xbdc9(%rip), %xmm0     # 0xe5260
subsd 0x20(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
callq 0x86a0
mulsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x340(%r12), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0xbd90(%rip), %xmm0     # 0xe5260
movsd %xmm0, 0x18(%rsp)
movsd 0xd26a(%rip), %xmm1     # 0xe6748
callq 0x8650
movsd 0x18(%rsp), %xmm2
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
mulsd 0x2d0(%r12), %xmm1
mulsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd (%rsp), %xmm1
mulsd 0x350(%r12), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movsd 0x340(%r12), %xmm0
movsd %xmm0, 0x10(%rsp)
movapd %xmm2, %xmm0
movsd 0xd20f(%rip), %xmm1     # 0xe6748
callq 0x8650
mulsd 0x10(%rsp), %xmm0
divsd (%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd %xmm1, -0x8(%r13)
movapd 0x30(%rsp), %xmm1
callq 0x8650
xorpd 0xbcc8(%rip), %xmm0     # 0xe5230
divsd 0x20(%rsp), %xmm0
movsd %xmm0, (%r13)
incq %rbp
addq $0x18, %r13
jmp 0xd9436
addq $0x192, %rbx            # imm = 0x192
pushq $0x3
popq %rsi
pushq $0x1
popq %rbp
pushq $0x2
popq %r9
movq %r15, %rdi
movl $0x400, %edx            # imm = 0x400
xorl %ecx, %ecx
movl %ebp, %r8d
pushq %rbx
pushq $0x1
callq 0x11b09
popq %rcx
popq %rdx
cmpl $0x1, %eax
jne 0xd95e5
leaq 0xbe3c(%rip), %rsi      # 0xe53f0
leaq 0x4acac(%rip), %rdx     # 0x124267
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xba60(%rip), %rsi      # 0xe5034
leaq 0x4ac7d(%rip), %rdx     # 0x124258
movq %rbx, %rdi
movl $0x5c1, %ecx            # imm = 0x5C1
jmp 0xd9648
subq $0x8, %rsp
pushq $0x3
popq %rsi
pushq $0x1
popq %rbp
movq %r15, %rdi
movl $0x400, %edx            # imm = 0x400
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
pushq %rbx
pushq %r14
pushq $0x2
callq 0x1571e
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0xd9666
leaq 0xbdd7(%rip), %rsi      # 0xe53f0
leaq 0x4acad(%rip), %rdx     # 0x1242cd
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xb9fb(%rip), %rsi      # 0xe5034
leaq 0x4ac18(%rip), %rdx     # 0x124258
movq %rbx, %rdi
movl $0x5cd, %ecx            # imm = 0x5CD
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
movl %ebp, %eax
addq $0x858, %rsp            # imm = 0x858
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd (%r14), %xmm0
callq 0x86a0
jmp 0xd9336