// File: /workspace/github_c_makefile_star2_O1/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 0xdf9f2
leaq 0x4ea0c(%rip), %rdi     # 0x12e3ed
callq 0x8510
leaq 0x4ea3e(%rip), %rdi     # 0x12e42b
callq 0x8510
movl $0x68, %edi
callq 0x8460
movq %rax, (%rbx)
testq %rax, %rax
je 0xdfa9d
movq $0x0, 0x10(%rbx)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rbx)
cmpl $0x2, 0x820(%rbx)
jl 0xdfa36
leaq 0x4e941(%rip), %rdi     # 0x12e36c
xorpd %xmm1, %xmm1
movb $0x2, %al
callq 0x8030
addq $0x2e8, %r12            # imm = 0x2E8
movq (%rbx), %rdi
movq %r12, 0x50(%rdi)
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
callq 0xdf649
movq (%rbx), %rax
cmpl $0x0, 0x38(%rax)
je 0xdfaed
movq 0x48(%rax), %rcx
leaq 0x11985(%rip), %rsi     # 0xf13f0
leaq 0x4e92b(%rip), %rdx     # 0x12e39d
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x20, %rbx
leaq 0x115a8(%rip), %rsi     # 0xf1034
leaq 0x4e8bf(%rip), %rdx     # 0x12e352
movq %rbx, %rdi
movl $0x2e, %ecx
jmp 0xdfad9
leaq 0x11560(%rip), %rsi     # 0xf1004
leaq 0x4e89d(%rip), %rdx     # 0x12e348
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl $0x68, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x20, %rbx
leaq 0x1156a(%rip), %rsi     # 0xf1034
leaq 0x4e881(%rip), %rdx     # 0x12e352
movq %rbx, %rdi
movl $0x20, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
jmp 0xdfb86
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 0x14dc7(%rip), %xmm0    # 0xf4920
movups %xmm0, 0x98(%rax)
movsd 0x10(%rsp), %xmm0
mulsd 0x12182(%rip), %xmm0    # 0xf1cf0
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