// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../external/RecfastCLASS/wrap_recfast.c
// Function: recfast_init
int recfast_init(struct precision* ppr,
                 struct background* pba,
                 struct thermodynamics* pth,
                 struct thermorecfast * pre,
                 enum recfast_photoion_modes recfast_photoion_mode,
                 double fHe) {

  /** Define local quantities */
  double Lalpha,Lalpha_He;

  /** - Import some thermodynamical quantities */
  pre->fHe = fHe;
  pre->photoion_mode = recfast_photoion_mode;

  /** - read a few precision/cosmological parameters */
  pre->AGauss1 = ppr->recfast_AGauss1;
  pre->AGauss2 = ppr->recfast_AGauss2;
  pre->zGauss1 = ppr->recfast_zGauss1;
  pre->zGauss2 = ppr->recfast_zGauss2;
  pre->wGauss1 = ppr->recfast_wGauss1;
  pre->wGauss2 = ppr->recfast_wGauss2;
  pre->Hswitch = ppr->recfast_Hswitch;
  pre->Heswitch = ppr->recfast_Heswitch;
  pre->x_H0_trigger2 = ppr->recfast_x_H0_trigger2;
  pre->x_He0_trigger2 = ppr->recfast_x_He0_trigger2;
  pre->fudge_H = ppr->recfast_fudge_H;
  pre->fudge_He = ppr->recfast_fudge_He;
  pre->x_H_limit_KHe = 0.9999999; /* threshold changed by Antony Lewis in 2008 to get smoother Helium */
  pre->x_H_limit_CfHe_t = 0.99999;
  pre->max_exp_boltz = 680.; /* The actual threshold is more around 709.8, but this leaves some wiggle-room */
  pre->x_He_trigger_small = 5.0e-9;

  pre->z_switch_late = ppr->recfast_z_switch_late;

  /** - Adjust fudging factors if needed */
  if (pre->Hswitch == _TRUE_){
    pre->fudge_H += ppr->recfast_delta_fudge_H;
  }


  /** - Assign quantities that have to be calculated first */
  /* These factors use inverse wavenumbers _L_ since they are most accurately measured */
  /* Lyman alpha wavelengths */
  Lalpha = 1./_L_H_alpha_;
  Lalpha_He = 1./_L_He_2p_;
  /* Ionization-lya temperature differences */
  pre->CDB = _h_P_*_c_*(_L_H_ion_-_L_H_alpha_)/_k_B_;
  pre->CDB_He = _h_P_*_c_*(_L_He1_ion_-_L_He_2s_)/_k_B_;
  /* Ionization temperatures */
  pre->CB1 = _h_P_*_c_*_L_H_ion_/_k_B_;           // equivalent to ptw->const_Tion_H
  pre->CB1_He1 = _h_P_*_c_*_L_He1_ion_/_k_B_;     // equivalent to ptw->const_Tion_HeI
  pre->CB1_He2 = _h_P_*_c_*_L_He2_ion_/_k_B_;     // equivalent to ptw->const_Tion_HeII
  /* Constants defined for the Peeble's factors  */
  pre->CR = 2.*_PI_*(_m_e_/_h_P_)*(_k_B_/_h_P_);  // equivalent to ptw->const_NR_numberdens
  pre->CK = pow(Lalpha,3)/(8.*_PI_);
  pre->CK_He = pow(Lalpha_He,3)/(8.*_PI_);
  /* Lyman alpha temperature */
  pre->CL = _c_*_h_P_/(_k_B_*Lalpha);
  pre->CL_He = _c_*_h_P_/(_k_B_/_L_He_2s_);
  pre->CL_Het = _h_P_*_c_*_L_He_2St_/_k_B_;
  /* Helium 2s->2p transition temperature*/
  pre->CDB_He2s2p = _h_P_*_c_*(_L_He_2p_-_L_He_2s_)/_k_B_;

  /** - Test schemes */
  /* He fudging */
  class_test((ppr->recfast_Heswitch < 0) || (ppr->recfast_Heswitch > 6),
             pre->error_message,
             "RECFAST error: unknown He fudging scheme");
  /* H fudging */
  class_test((ppr->recfast_Hswitch != _TRUE_) && (ppr->recfast_Hswitch != _FALSE_),
             pre->error_message,
             "RECFAST error: unknown H fudging scheme");

  return _SUCCESS_;

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movq %rcx, %rbx
movsd %xmm0, 0x20(%rcx)
movl %r8d, 0x130(%rcx)
movups 0x228(%rdi), %xmm0
movups %xmm0, 0x90(%rcx)
movups 0x238(%rdi), %xmm0
movups %xmm0, 0xa0(%rcx)
movups 0x248(%rdi), %xmm0
movups %xmm0, 0xb0(%rcx)
movl 0x210(%rdi), %ecx
movl %ecx, 0xc4(%rbx)
movl 0x200(%rdi), %eax
movl %eax, 0xc0(%rbx)
movsd 0x2d0(%rdi), %xmm0
movsd %xmm0, 0xc8(%rbx)
movsd 0x2b8(%rdi), %xmm0
movsd %xmm0, 0xd0(%rbx)
movsd 0x218(%rdi), %xmm0
movsd %xmm0, 0xf0(%rbx)
movsd 0x208(%rdi), %xmm1
movsd %xmm1, 0xe8(%rbx)
movaps 0x58e1c(%rip), %xmm1    # 0x11f170
movups %xmm1, 0xf8(%rbx)
movabsq $0x4085400000000000, %rdx # imm = 0x4085400000000000
movq %rdx, 0x108(%rbx)
movabsq $0x3e35798ee2308c3a, %rdx # imm = 0x3E35798EE2308C3A
movq %rdx, 0xe0(%rbx)
movsd 0x2e0(%rdi), %xmm1
movsd %xmm1, 0xd8(%rbx)
cmpl $0x1, %ecx
jne 0xc63a2
addsd 0x220(%rdi), %xmm0
movsd %xmm0, 0xf0(%rbx)
movaps 0x3e287(%rip), %xmm0    # 0x104630
movups %xmm0, 0x78(%rbx)
movaps 0x58dcc(%rip), %xmm0    # 0x11f180
movups %xmm0, (%rbx)
movaps 0x58dd2(%rip), %xmm0    # 0x11f190
movups %xmm0, 0x30(%rbx)
movaps 0x58dd7(%rip), %xmm0    # 0x11f1a0
movups %xmm0, 0x10(%rbx)
movaps 0x58ddc(%rip), %xmm0    # 0x11f1b0
movups %xmm0, 0x40(%rbx)
movaps 0x58de1(%rip), %xmm0    # 0x11f1c0
movups %xmm0, 0x68(%rbx)
cmpl $0x7, %eax
jb 0xc6438
leaq 0x58f09(%rip), %rsi     # 0x11f2f8
leaq 0x800(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x1ec7a(%rip), %rsi     # 0xe5082
leaq 0x58f12(%rip), %rdx     # 0x11f321
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x134, %rbx            # imm = 0x134
leaq 0x1ec07(%rip), %rsi     # 0xe5034
leaq 0x58f28(%rip), %rdx     # 0x11f35c
pushq $0x5f
jmp 0xc648d
xorl %eax, %eax
cmpl $0x2, %ecx
jb 0xc649e
leaq 0x58f23(%rip), %rsi     # 0x11f369
leaq 0x800(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x1ec23(%rip), %rsi     # 0xe5082
leaq 0x58f2b(%rip), %rdx     # 0x11f391
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x134, %rbx            # imm = 0x134
leaq 0x1ebb0(%rip), %rsi     # 0xe5034
leaq 0x58ed1(%rip), %rdx     # 0x11f35c
pushq $0x63
popq %rcx
movq %rbx, %rdi
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r14
popq %r15
retq