// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/HMcode/hmcode.c
// Function: hmcode_dark_energy_correction
int hmcode_dark_energy_correction(
                                  struct precision *ppr,
                                  struct background *pba,
                                  struct fourier *pfo,
                                  struct hmcode_workspace *phw
                                  ) {

  int last_index;
  double *pvecback;
  double tau_growth;
  double g_lcdm,g_wcdm;
  double w0,dw_over_da_fld,integral_fld;
  double h,a,b;
  double growth;

  /** - if there is dynamical Dark Energy (w is not -1) modeled as a fluid */

  if (pba->has_fld==_TRUE_){

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

    class_call(background_tau_of_z(pba,pfo->z_infinity,&tau_growth),
               pba->error_message,
               pfo->error_message);

    class_call(background_at_tau(pba,tau_growth,long_info,inter_normal,&last_index,pvecback),
               pba->error_message,
               pfo->error_message);

    class_call(background_w_fld(pba,1.,&w0,&dw_over_da_fld,&integral_fld),
               pba->error_message,
               pfo->error_message);

    class_call(hmcode_growint(ppr,pba,pfo,1./(1.+pfo->z_infinity),-1.,0.,&g_lcdm),
               pfo->error_message, pfo->error_message);

    class_call(hmcode_growint(ppr,pba,pfo,1./(1.+pfo->z_infinity),w0,dw_over_da_fld*(-1.),&g_wcdm),
               pfo->error_message,
               pfo->error_message);

    free(pvecback);

    switch( pfo->hm_version ){
    case hmcode_version_2015:
      phw->dark_energy_correction = pow(g_wcdm/g_lcdm, 1.5);
      break;
    case hmcode_version_2020:
    case hmcode_version_2020_unfitted:
    case hmcode_version_2020_baryonic:
      //phw->dark_energy_correction = g_wcdm/g_lcdm; //Here, we are missing the redshift dependence, which we include only within the respective function
      //hmcode_norad(phw->phg,1./(pfo->z_infinity+1.));
      class_call(array_spline_hunt(phw->phg->a_table,
                                   phw->phg->a_size,
                                   1./(pfo->z_infinity+1.),
                                   &last_index,
                                   &h,
                                   &a,
                                   &b,
                                   pfo->error_message),
                 pfo->error_message,
                 pfo->error_message);

      growth = array_spline_eval(phw->phg->normgrowth_table,phw->phg->ddnormgrowth_table,last_index,last_index+1,h,a,b);
      phw->dark_energy_correction = growth/g_lcdm;
      break;
    }
  }

  /** - otherwise, we assume no dynamical Dark Energy (w is -1) */

  else {
    phw->dark_energy_correction = 1.;
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x868, %rsp            # imm = 0x868
movq %rcx, %r14
cmpw $0x1, 0x4c2(%rsi)
jne 0xe24ad
movq %rdx, %rbx
movq %rsi, %r15
movslq 0x43c(%rsi), %r13
leaq (,%r13,8), %rdi
callq 0x8460
testq %rax, %rax
je 0xe24c2
movq %rax, %r12
movsd 0x20(%rbx), %xmm0
leaq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0x5c896
cmpl $0x1, %eax
jne 0xe2508
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xbf7e(%rip), %rsi      # 0xee3f0
leaq 0x4ab8d(%rip), %rdx     # 0x12d006
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0xbb9b(%rip), %rsi      # 0xee034
leaq 0x4ab48(%rip), %rdx     # 0x12cfe8
movq %rbx, %rdi
movl $0x417, %ecx            # imm = 0x417
jmp 0xe26ce
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x50(%r14)
xorl %ebp, %ebp
jmp 0xe26dd
shll $0x3, %r13d
leaq 0xbb37(%rip), %rsi      # 0xee004
leaq 0x32dbe(%rip), %rdx     # 0x115292
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0xbb40(%rip), %rsi      # 0xee034
leaq 0x4aaed(%rip), %rdx     # 0x12cfe8
movq %rbx, %rdi
movl $0x413, %ecx            # imm = 0x413
jmp 0xe26ce
movsd 0x50(%rsp), %xmm0
leaq 0x14(%rsp), %rcx
movq %r15, %rdi
movl $0x2, %esi
xorl %edx, %edx
movq %r12, %r8
callq 0x5c63f
cmpl $0x1, %eax
jne 0xe2573
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xbeb8(%rip), %rsi      # 0xee3f0
leaq 0x4aafc(%rip), %rdx     # 0x12d03b
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0xbad5(%rip), %rsi      # 0xee034
leaq 0x4aa82(%rip), %rdx     # 0x12cfe8
movq %rbx, %rdi
movl $0x41b, %ecx            # imm = 0x41B
jmp 0xe26ce
movsd 0xbce5(%rip), %xmm0     # 0xee260
leaq 0x40(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x58(%rsp), %rcx
movq %r15, %rdi
callq 0x5e095
cmpl $0x1, %eax
jne 0xe25e0
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xbe4b(%rip), %rsi      # 0xee3f0
leaq 0x4aadd(%rip), %rdx     # 0x12d089
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0xba68(%rip), %rsi      # 0xee034
leaq 0x4aa15(%rip), %rdx     # 0x12cfe8
movq %rbx, %rdi
movl $0x41f, %ecx            # imm = 0x41F
jmp 0xe26ce
movsd 0x20(%rbx), %xmm1
movsd 0xbc73(%rip), %xmm0     # 0xee260
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd 0xc1eb(%rip), %xmm1     # 0xee7e8
leaq 0x18(%rsp), %rcx
xorpd %xmm2, %xmm2
movq %r15, %rsi
movq %rbx, %rdx
callq 0xe13e0
testl %eax, %eax
je 0xe2654
addq $0x192, %rbx            # imm = 0x192
leaq 0xbdcd(%rip), %rsi      # 0xee3f0
leaq 0x4aa9a(%rip), %rdx     # 0x12d0c4
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xb9f1(%rip), %rsi      # 0xee034
leaq 0x4a99e(%rip), %rdx     # 0x12cfe8
movq %rbx, %rdi
movl $0x422, %ecx            # imm = 0x422
jmp 0xe26ce
movsd 0x20(%rbx), %xmm1
movsd 0xbbff(%rip), %xmm0     # 0xee260
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
xorpd 0xbbb3(%rip), %xmm2     # 0xee230
leaq 0x48(%rsp), %rcx
movq %r15, %rsi
movq %rbx, %rdx
callq 0xe13e0
testl %eax, %eax
je 0xe26f1
addq $0x192, %rbx            # imm = 0x192
leaq 0xbd51(%rip), %rsi      # 0xee3f0
leaq 0x4aa61(%rip), %rdx     # 0x12d107
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xb975(%rip), %rsi      # 0xee034
leaq 0x4a922(%rip), %rdx     # 0x12cfe8
movq %rbx, %rdi
movl $0x426, %ecx            # imm = 0x426
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebp
movl %ebp, %eax
addq $0x868, %rsp            # imm = 0x868
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x8410
movl 0xc(%rbx), %eax
xorl %ebp, %ebp
leal -0x1(%rax), %ecx
cmpl $0x3, %ecx
jae 0xe278d
movq 0x70(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
movsd 0x20(%rbx), %xmm1
movsd 0xbb3f(%rip), %xmm0     # 0xee260
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
addq $0x192, %rbx            # imm = 0x192
movq %rbx, (%rsp)
leaq 0x14(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x28(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0x19e56
cmpl $0x1, %eax
jne 0xe27b9
leaq 0xbc97(%rip), %rsi      # 0xee3f0
leaq 0x4a9fb(%rip), %rdx     # 0x12d15b
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xb8bb(%rip), %rsi      # 0xee034
leaq 0x4a868(%rip), %rdx     # 0x12cfe8
movq %rbx, %rdi
movl $0x43c, %ecx            # imm = 0x43C
jmp 0xe26ce
testl %eax, %eax
jne 0xe26dd
movsd 0x48(%rsp), %xmm0
divsd 0x18(%rsp), %xmm0
movsd 0xe81f(%rip), %xmm1     # 0xf0fc8
callq 0x8620
movsd %xmm0, 0x50(%r14)
jmp 0xe26dd
movsd 0x28(%rsp), %xmm0
movq 0x70(%r14), %rax
movslq 0x14(%rsp), %rcx
movsd 0x20(%rsp), %xmm1
movq 0x18(%rax), %rdx
movq 0x20(%rax), %rax
movsd 0x8(%rdx,%rcx,8), %xmm2
mulsd %xmm1, %xmm2
movsd (%rdx,%rcx,8), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
subsd %xmm0, %xmm2
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
subsd %xmm1, %xmm0
mulsd 0x8(%rax,%rcx,8), %xmm0
mulsd (%rax,%rcx,8), %xmm2
addsd %xmm0, %xmm2
movsd 0x30(%rsp), %xmm0
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
divsd 0xce3e(%rip), %xmm2     # 0xef670
addsd %xmm3, %xmm2
divsd 0x18(%rsp), %xmm2
movsd %xmm2, 0x50(%r14)
jmp 0xe26dd