// File: /workspace/github_c_makefile_star2_O2/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 0xda13b
movq %rdx, %rbx
movq %rsi, %r15
movslq 0x43c(%rsi), %r13
leaq (,%r13,8), %rdi
callq 0x8490
testq %rax, %rax
je 0xda150
movq %rax, %r12
movsd 0x20(%rbx), %xmm0
leaq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0x58adb
cmpl $0x1, %eax
jne 0xda196
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xb2f0(%rip), %rsi      # 0xe53f0
leaq 0x49d6f(%rip), %rdx     # 0x123e76
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0xaf0d(%rip), %rsi      # 0xe5034
leaq 0x49d2a(%rip), %rdx     # 0x123e58
movq %rbx, %rdi
movl $0x417, %ecx            # imm = 0x417
jmp 0xda35a
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x50(%r14)
xorl %ebp, %ebp
jmp 0xda367
shll $0x3, %r13d
leaq 0xaea9(%rip), %rsi      # 0xe5004
leaq 0x31fd0(%rip), %rdx     # 0x10c132
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0xaeb2(%rip), %rsi      # 0xe5034
leaq 0x49ccf(%rip), %rdx     # 0x123e58
movq %rbx, %rdi
movl $0x413, %ecx            # imm = 0x413
jmp 0xda35a
movsd 0x50(%rsp), %xmm0
pushq $0x2
popq %rsi
leaq 0x14(%rsp), %rcx
movq %r15, %rdi
xorl %edx, %edx
movq %r12, %r8
callq 0x5887d
cmpl $0x1, %eax
jne 0xda1ff
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xb22c(%rip), %rsi      # 0xe53f0
leaq 0x49ce0(%rip), %rdx     # 0x123eab
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0xae49(%rip), %rsi      # 0xe5034
leaq 0x49c66(%rip), %rdx     # 0x123e58
movq %rbx, %rdi
movl $0x41b, %ecx            # imm = 0x41B
jmp 0xda35a
movsd 0xb059(%rip), %xmm0     # 0xe5260
leaq 0x40(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x58(%rsp), %rcx
movq %r15, %rdi
callq 0x5a0e7
cmpl $0x1, %eax
jne 0xda26c
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0xb1bf(%rip), %rsi      # 0xe53f0
leaq 0x49cc1(%rip), %rdx     # 0x123ef9
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0xaddc(%rip), %rsi      # 0xe5034
leaq 0x49bf9(%rip), %rdx     # 0x123e58
movq %rbx, %rdi
movl $0x41f, %ecx            # imm = 0x41F
jmp 0xda35a
movsd 0x20(%rbx), %xmm1
movsd 0xafe7(%rip), %xmm0     # 0xe5260
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd 0xb55f(%rip), %xmm1     # 0xe57e8
leaq 0x18(%rsp), %rcx
xorpd %xmm2, %xmm2
movq %r15, %rsi
movq %rbx, %rdx
callq 0xd92e2
testl %eax, %eax
je 0xda2e0
addq $0x192, %rbx            # imm = 0x192
leaq 0xb141(%rip), %rsi      # 0xe53f0
leaq 0x49c7e(%rip), %rdx     # 0x123f34
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xad65(%rip), %rsi      # 0xe5034
leaq 0x49b82(%rip), %rdx     # 0x123e58
movq %rbx, %rdi
movl $0x422, %ecx            # imm = 0x422
jmp 0xda35a
movsd 0x20(%rbx), %xmm1
movsd 0xaf73(%rip), %xmm0     # 0xe5260
addsd %xmm0, %xmm1
divsd %xmm1, %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
xorpd 0xaf27(%rip), %xmm2     # 0xe5230
leaq 0x48(%rsp), %rcx
movq %r15, %rsi
movq %rbx, %rdx
callq 0xd92e2
testl %eax, %eax
je 0xda37b
addq $0x192, %rbx            # imm = 0x192
leaq 0xb0c5(%rip), %rsi      # 0xe53f0
leaq 0x49c45(%rip), %rdx     # 0x123f77
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xace9(%rip), %rsi      # 0xe5034
leaq 0x49b06(%rip), %rdx     # 0x123e58
movq %rbx, %rdi
movl $0x426, %ecx            # imm = 0x426
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
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 0x8430
movl 0xc(%rbx), %eax
xorl %ebp, %ebp
leal -0x1(%rax), %ecx
cmpl $0x3, %ecx
jae 0xda417
movq 0x70(%r14), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
movsd 0x20(%rbx), %xmm1
movsd 0xaeb5(%rip), %xmm0     # 0xe5260
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 0x17d10
cmpl $0x1, %eax
jne 0xda443
leaq 0xb00d(%rip), %rsi      # 0xe53f0
leaq 0x49be1(%rip), %rdx     # 0x123fcb
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xac31(%rip), %rsi      # 0xe5034
leaq 0x49a4e(%rip), %rdx     # 0x123e58
movq %rbx, %rdi
movl $0x43c, %ecx            # imm = 0x43C
jmp 0xda35a
testl %eax, %eax
jne 0xda367
movsd 0x48(%rsp), %xmm0
divsd 0x18(%rsp), %xmm0
movsd 0xdb55(%rip), %xmm1     # 0xe7f88
callq 0x8650
movsd %xmm0, 0x50(%r14)
jmp 0xda367
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 0xc194(%rip), %xmm2     # 0xe6650
addsd %xmm3, %xmm2
divsd 0x18(%rsp), %xmm2
movsd %xmm2, 0x50(%r14)
jmp 0xda367