// File: /workspace/github_c_makefile_star2_O1/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 0xe59e1
movq %rdx, %rbx
movq %rsi, %r15
movslq 0x43c(%rsi), %r13
leaq (,%r13,8), %rdi
callq 0x8460
testq %rax, %rax
je 0xe59f6
movq %rax, %r12
movsd 0x20(%rbx), %xmm0
leaq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0x5efb7
cmpl $0x1, %eax
jne 0xe5a3c
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xba4a(%rip), %rsi      # 0xf13f0
leaq 0x4a629(%rip), %rdx     # 0x12ffd6
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0xb667(%rip), %rsi      # 0xf1034
leaq 0x4a5e4(%rip), %rdx     # 0x12ffb8
movq %rbx, %rdi
movl $0x417, %ecx            # imm = 0x417
jmp 0xe5c02
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x50(%r14)
xorl %ebp, %ebp
jmp 0xe5c11
shll $0x3, %r13d
leaq 0xb603(%rip), %rsi      # 0xf1004
leaq 0x3284a(%rip), %rdx     # 0x118252
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0xb60c(%rip), %rsi      # 0xf1034
leaq 0x4a589(%rip), %rdx     # 0x12ffb8
movq %rbx, %rdi
movl $0x413, %ecx            # imm = 0x413
jmp 0xe5c02
movsd 0x50(%rsp), %xmm0
leaq 0x14(%rsp), %rcx
movq %r15, %rdi
movl $0x2, %esi
xorl %edx, %edx
movq %r12, %r8
callq 0x5ed53
cmpl $0x1, %eax
jne 0xe5aa7
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xb984(%rip), %rsi      # 0xf13f0
leaq 0x4a598(%rip), %rdx     # 0x13000b
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0xb5a1(%rip), %rsi      # 0xf1034
leaq 0x4a51e(%rip), %rdx     # 0x12ffb8
movq %rbx, %rdi
movl $0x41b, %ecx            # imm = 0x41B
jmp 0xe5c02
movsd 0xb7b1(%rip), %xmm0     # 0xf1260
leaq 0x40(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x58(%rsp), %rcx
movq %r15, %rdi
callq 0x6074e
cmpl $0x1, %eax
jne 0xe5b14
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xb917(%rip), %rsi      # 0xf13f0
leaq 0x4a579(%rip), %rdx     # 0x130059
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0xb534(%rip), %rsi      # 0xf1034
leaq 0x4a4b1(%rip), %rdx     # 0x12ffb8
movq %rbx, %rdi
movl $0x41f, %ecx            # imm = 0x41F
jmp 0xe5c02
movsd 0x20(%rbx), %xmm1
movsd 0xb73f(%rip), %xmm0     # 0xf1260
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd 0xbcb7(%rip), %xmm1     # 0xf17e8
leaq 0x18(%rsp), %rcx
xorpd %xmm2, %xmm2
movq %r15, %rsi
movq %rbx, %rdx
callq 0xe4906
testl %eax, %eax
je 0xe5b88
addq $0x192, %rbx            # imm = 0x192
leaq 0xb899(%rip), %rsi      # 0xf13f0
leaq 0x4a536(%rip), %rdx     # 0x130094
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xb4bd(%rip), %rsi      # 0xf1034
leaq 0x4a43a(%rip), %rdx     # 0x12ffb8
movq %rbx, %rdi
movl $0x422, %ecx            # imm = 0x422
jmp 0xe5c02
movsd 0x20(%rbx), %xmm1
movsd 0xb6cb(%rip), %xmm0     # 0xf1260
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
xorpd 0xb67f(%rip), %xmm2     # 0xf1230
leaq 0x48(%rsp), %rcx
movq %r15, %rsi
movq %rbx, %rdx
callq 0xe4906
testl %eax, %eax
je 0xe5c25
addq $0x192, %rbx            # imm = 0x192
leaq 0xb81d(%rip), %rsi      # 0xf13f0
leaq 0x4a4fd(%rip), %rdx     # 0x1300d7
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xb441(%rip), %rsi      # 0xf1034
leaq 0x4a3be(%rip), %rdx     # 0x12ffb8
movq %rbx, %rdi
movl $0x426, %ecx            # imm = 0x426
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
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 0xe5cc1
movq 0x70(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
movsd 0x20(%rbx), %xmm1
movsd 0xb60b(%rip), %xmm0     # 0xf1260
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 0x19cfd
cmpl $0x1, %eax
jne 0xe5ced
leaq 0xb763(%rip), %rsi      # 0xf13f0
leaq 0x4a497(%rip), %rdx     # 0x13012b
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xb387(%rip), %rsi      # 0xf1034
leaq 0x4a304(%rip), %rdx     # 0x12ffb8
movq %rbx, %rdi
movl $0x43c, %ecx            # imm = 0x43C
jmp 0xe5c02
testl %eax, %eax
jne 0xe5c11
movsd 0x48(%rsp), %xmm0
divsd 0x18(%rsp), %xmm0
movsd 0xe2db(%rip), %xmm1     # 0xf3fb8
callq 0x8620
movsd %xmm0, 0x50(%r14)
jmp 0xe5c11
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 0xc90a(%rip), %xmm2     # 0xf2670
addsd %xmm3, %xmm2
divsd 0x18(%rsp), %xmm2
movsd %xmm2, 0x50(%r14)
jmp 0xe5c11