// File: /workspace/github_c_makefile_star2_O3/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 0xe1448
movq %rax, %r15
movsd 0xce3a(%rip), %xmm0     # 0xee260
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jne 0xe149b
jp 0xe149b
movsd %xmm0, (%r14)
movq %r15, %rdi
callq 0x8410
xorl %ebp, %ebp
jmp 0xe1764
leaq 0xcbb5(%rip), %rsi      # 0xee004
leaq 0x4d072(%rip), %rdx     # 0x12e4c8
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movl $0x6000, %ecx           # imm = 0x6000
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0xcbbc(%rip), %rsi      # 0xee034
leaq 0x4bf69(%rip), %rdx     # 0x12d3e8
movq %rbx, %rdi
movl $0x595, %ecx            # imm = 0x595
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebp
jmp 0xe1764
movsd 0xcdbd(%rip), %xmm1     # 0xee260
movapd %xmm1, %xmm0
movsd 0xd339(%rip), %xmm2     # 0xee7e8
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 0xff98(%rip), %xmm1     # 0xf1480
mulsd %xmm1, %xmm4
movsd %xmm4, 0x40(%rsp)
mulsd %xmm1, %xmm5
movsd %xmm5, 0x8(%rsp)
leaq 0x4ab1d(%rip), %rcx     # 0x12c020
mulsd (%rcx,%rax,8), %xmm0
movsd 0x47150(%rip), %xmm1    # 0x128660
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 0x4a963(%rip), %xmm1    # 0x12beb0
addsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x28(%rsp)
movsd 0xccff(%rip), %xmm0     # 0xee260
divsd %xmm1, %xmm0
addsd 0xd27b(%rip), %xmm0     # 0xee7e8
movsd %xmm0, 0x20(%rsp)
movapd %xmm1, %xmm0
movsd 0x40(%rsp), %xmm1
callq 0x8620
movsd %xmm0, (%rsp)
movsd 0xccd1(%rip), %xmm0     # 0xee260
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 0xcc98(%rip), %xmm0     # 0xee260
movsd %xmm0, 0x20(%rsp)
movsd 0xe0aa(%rip), %xmm1     # 0xef680
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 0xe04f(%rip), %xmm1     # 0xef680
callq 0x8620
mulsd 0x18(%rsp), %xmm0
divsd (%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd %xmm1, -0x8(%r13)
movapd 0x30(%rsp), %xmm1
callq 0x8620
xorpd 0xcbd0(%rip), %xmm0     # 0xee230
divsd 0x28(%rsp), %xmm0
movsd %xmm0, (%r13)
incq %rbp
addq $0x18, %r13
cmpq $0x400, %rbp            # imm = 0x400
jne 0xe1538
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 0x1381e
addq $0x10, %rsp
cmpl $0x1, %eax
jne 0xe16f0
leaq 0xcd31(%rip), %rsi      # 0xee3f0
leaq 0x4bd31(%rip), %rdx     # 0x12d3f7
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xc955(%rip), %rsi      # 0xee034
leaq 0x4bd02(%rip), %rdx     # 0x12d3e8
movq %rbx, %rdi
movl $0x5c1, %ecx            # imm = 0x5C1
jmp 0xe175a
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 0x176d4
addq $0x20, %rsp
cmpl $0x1, %eax
jne 0xe1778
leaq 0xccc5(%rip), %rsi      # 0xee3f0
leaq 0x4bd2b(%rip), %rdx     # 0x12d45d
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xc8e9(%rip), %rsi      # 0xee034
leaq 0x4bc96(%rip), %rdx     # 0x12d3e8
movq %rbx, %rdi
movl $0x5cd, %ecx            # imm = 0x5CD
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
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 0xe1434
nop