// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../external/HyRec2020/wrap_hyrec.c
// Function: thermodynamics_hyrec_init
int thermodynamics_hyrec_init(struct precision* ppr, struct background * pba, struct thermodynamics * pth, double Nnow, double T_cmb, double fHe, double zstart_hyrec, struct thermohyrec* phy){

  /** Summary: */

  if(phy->thermohyrec_verbose > 0){
    printf(" -> Using the hyrec wrapper programmed by Nils Sch. (Oct2020)\n");
    printf("    implements HyRec2 version Oct 2020 by Yacine Ali-Haimoud, Chris Hirata, and Nanoom Lee\n");
  }

  /** - allocate necessary data structures */
  class_alloc(phy->data,
              sizeof(HYREC_DATA),
              phy->error_message);

  phy->zend = 0.;
  phy->zstart = zstart_hyrec;

  if(phy->thermohyrec_verbose > 1){
    printf("    Starting HyRec at z = %.10e until z = %.10e\n",phy->zstart, phy->zend);
  }

  /** - allocate hyrec internally */
  phy->data->path_to_hyrec = ppr->hyrec_path;
  hyrec_allocate(phy->data, phy->zstart, phy->zend);
  /* Error during allocation */
  if(phy->data->error != 0){
    class_call_message(phy->error_message,"hyrec_allocate",phy->data->error_message);
    return _FAILURE_;
  }

  /** - set cosmological parameters for hyrec */
  phy->data->cosmo->T0 = T_cmb;
  phy->data->cosmo->obh2 = pba->Omega0_b*pba->h*pba->h;
  phy->data->cosmo->ocbh2 = pba->Omega0_nfsm*pba->h*pba->h;

  phy->data->cosmo->YHe = pth->YHe;
  phy->data->cosmo->Neff = pba->Neff;
  phy->data->cosmo->fHe = fHe; /* abundance of helium relative to hydrogen by number */
  phy->data->cosmo->fsR = 1.;
  phy->data->cosmo->meR = 1.;
  phy->data->cosmo->nH0 = Nnow*1e-6;

  /** - set other parameters for hyrec */
  /* XEII_MIN = 1e-6 defined in history.h
     HYREC-2 calculates Helium recombinations only until xHeII ~ XEII_MIN */
  phy->xHeII_limit = XHEII_MIN;

  return _SUCCESS_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movq %rcx, %rbx
movsd %xmm3, 0x18(%rsp)
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, (%rsp)
movsd %xmm0, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
cmpl $0x0, 0x820(%rcx)
jle 0xd445e
leaq 0x4de40(%rip), %rdi     # 0x12228d
callq 0x8540
leaq 0x4de72(%rip), %rdi     # 0x1222cb
callq 0x8540
pushq $0x68
popq %rdi
callq 0x8490
movq %rax, (%rbx)
testq %rax, %rax
je 0xd44a8
andq $0x0, 0x10(%rbx)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rbx)
cmpl $0x2, 0x820(%rbx)
jl 0xd44de
leaq 0x4dd7e(%rip), %rdi     # 0x12220c
xorpd %xmm1, %xmm1
movb $0x2, %al
callq 0x8030
movq (%rbx), %rax
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
jmp 0xd44e2
leaq 0x10b55(%rip), %rsi     # 0xe5004
leaq 0x4dd32(%rip), %rdx     # 0x1221e8
leaq 0x20(%rsp), %r14
pushq $0x68
popq %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x20, %rbx
leaq 0x10b61(%rip), %rsi     # 0xe5034
leaq 0x4dd18(%rip), %rdx     # 0x1221f2
pushq $0x20
jmp 0xd4533
xorpd %xmm1, %xmm1
addq $0x2e8, %r12            # imm = 0x2E8
movq %r12, 0x50(%rax)
movq %rax, %rdi
callq 0xd4053
movq (%rbx), %rax
cmpl $0x0, 0x38(%rax)
je 0xd4549
movq 0x48(%rax), %rcx
leaq 0x10ee7(%rip), %rsi     # 0xe53f0
leaq 0x4dd2d(%rip), %rdx     # 0x12223d
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x20, %rbx
leaq 0x10b0a(%rip), %rsi     # 0xe5034
leaq 0x4dcc1(%rip), %rdx     # 0x1221f2
pushq $0x2e
popq %rcx
movq %rbx, %rdi
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
jmp 0xd45e2
movq 0x8(%rax), %rax
movsd (%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movsd 0x8(%r14), %xmm0
movsd 0x20(%r14), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm0, %xmm2
movhpd 0x358(%r14), %xmm2      # xmm2 = xmm2[0],mem[0]
mulpd %xmm1, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm2, %xmm0
movupd %xmm0, 0x10(%rax)
movsd (%r15), %xmm0
movsd %xmm0, 0x90(%rax)
movsd 0x328(%r14), %xmm0
movsd %xmm0, 0x50(%rax)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x80(%rax)
movaps 0x1429b(%rip), %xmm0    # 0xe8850
movups %xmm0, 0x98(%rax)
movsd 0x10(%rsp), %xmm0
mulsd 0x11706(%rip), %xmm0    # 0xe5cd0
movsd %xmm0, 0x88(%rax)
movabsq $0x3eb0c6f7a0b5ed8d, %rax # imm = 0x3EB0C6F7A0B5ED8D
movq %rax, 0x18(%rbx)
xorl %eax, %eax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r14
popq %r15
retq