// File: /workspace/github_c_makefile_star2_O1/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, 0x10(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movl $0x6000, %edi           # imm = 0x6000
callq 0x8460
testq %rax, %rax
je 0xe496e
movq %rax, %r15
movsd 0xc914(%rip), %xmm0     # 0xf1260
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0xe49c1
jp 0xe49c1
movsd %xmm0, (%r14)
movq %r15, %rdi
callq 0x8410
xorl %ebp, %ebp
jmp 0xe4c8a
leaq 0xc68f(%rip), %rsi      # 0xf1004
leaq 0x4cb1c(%rip), %rdx     # 0x131498
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movl $0x6000, %ecx           # imm = 0x6000
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0xc696(%rip), %rsi      # 0xf1034
leaq 0x4ba13(%rip), %rdx     # 0x1303b8
movq %rbx, %rdi
movl $0x595, %ecx            # imm = 0x595
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %ebp
jmp 0xe4c8a
movsd 0xc897(%rip), %xmm1     # 0xf1260
movapd %xmm1, %xmm0
movsd 0xce13(%rip), %xmm2     # 0xf17e8
xorl %eax, %eax
movapd 0x30(%rsp), %xmm3
ucomisd %xmm3, %xmm2
seta %al
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movapd %xmm3, %xmm0
addsd %xmm1, %xmm0
movapd %xmm0, %xmm4
movsd 0x8(%rsp), %xmm5
addsd %xmm5, %xmm4
movsd 0xfa62(%rip), %xmm1     # 0xf4470
mulsd %xmm1, %xmm4
movsd %xmm4, 0x40(%rsp)
mulsd %xmm1, %xmm5
movsd %xmm5, 0x8(%rsp)
leaq 0x4a5c7(%rip), %rcx     # 0x12eff0
mulsd (%rcx,%rax,8), %xmm0
movsd 0x46bfa(%rip), %xmm1    # 0x12b630
addsd %xmm1, %xmm0
cmpeqsd %xmm2, %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
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
mulsd 0x48(%rsp), %xmm1
divsd 0x4a40d(%rip), %xmm1    # 0x12ee80
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x28(%rsp)
movsd 0xc7d9(%rip), %xmm0     # 0xf1260
divsd %xmm1, %xmm0
addsd 0xcd55(%rip), %xmm0     # 0xf17e8
movsd %xmm0, 0x20(%rsp)
movapd %xmm1, %xmm0
movsd 0x40(%rsp), %xmm1
callq 0x8620
movsd %xmm0, (%rsp)
movsd 0xc7ab(%rip), %xmm0     # 0xf1260
subsd 0x28(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
callq 0x8670
mulsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x340(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x20(%rsp), %xmm0
addsd 0xc772(%rip), %xmm0     # 0xf1260
movsd %xmm0, 0x20(%rsp)
movsd 0xdb84(%rip), %xmm1     # 0xf2680
callq 0x8620
movsd 0x20(%rsp), %xmm2
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
mulsd 0x2d0(%r12), %xmm1
mulsd 0x18(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd (%rsp), %xmm1
mulsd 0x350(%r12), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movsd 0x340(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
movapd %xmm2, %xmm0
movsd 0xdb29(%rip), %xmm1     # 0xf2680
callq 0x8620
mulsd 0x18(%rsp), %xmm0
divsd (%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd %xmm1, -0x8(%r13)
movapd 0x30(%rsp), %xmm1
callq 0x8620
xorpd 0xc6aa(%rip), %xmm0     # 0xf1230
divsd 0x28(%rsp), %xmm0
movsd %xmm0, (%r13)
incq %rbp
addq $0x18, %r13
cmpq $0x400, %rbp            # imm = 0x400
jne 0xe4a5e
addq $0x192, %rbx            # imm = 0x192
movl $0x1, %ebp
movq %r15, %rdi
movl $0x3, %esi
movl $0x400, %edx            # imm = 0x400
xorl %ecx, %ecx
movl $0x1, %r8d
movl $0x2, %r9d
pushq %rbx
pushq $0x1
callq 0x136a5
addq $0x10, %rsp
cmpl $0x1, %eax
jne 0xe4c16
leaq 0xc80b(%rip), %rsi      # 0xf13f0
leaq 0x4b7db(%rip), %rdx     # 0x1303c7
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xc42f(%rip), %rsi      # 0xf1034
leaq 0x4b7ac(%rip), %rdx     # 0x1303b8
movq %rbx, %rdi
movl $0x5c1, %ecx            # imm = 0x5C1
jmp 0xe4c80
subq $0x8, %rsp
movl $0x1, %ebp
movq %r15, %rdi
movl $0x3, %esi
movl $0x400, %edx            # imm = 0x400
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
pushq %rbx
pushq %r14
pushq $0x2
callq 0x17545
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0xe4c9e
leaq 0xc79f(%rip), %rsi      # 0xf13f0
leaq 0x4b7d5(%rip), %rdx     # 0x13042d
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xc3c3(%rip), %rsi      # 0xf1034
leaq 0x4b740(%rip), %rdx     # 0x1303b8
movq %rbx, %rdi
movl $0x5cd, %ecx            # imm = 0x5CD
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
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 0x8670
jmp 0xe495a
nop