// File: /workspace/github_c_makefile_star2_O3/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 0xdc4a6
leaq 0x4ef88(%rip), %rdi     # 0x12b41d
callq 0x8510
leaq 0x4efba(%rip), %rdi     # 0x12b45b
callq 0x8510
movl $0x68, %edi
callq 0x8460
movq %rax, (%rbx)
testq %rax, %rax
je 0xdc4f5
movq $0x0, 0x10(%rbx)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rbx)
cmpl $0x2, 0x820(%rbx)
jl 0xdc533
leaq 0x4eec1(%rip), %rdi     # 0x12b39c
xorpd %xmm1, %xmm1
movb $0x2, %al
callq 0x8030
movq (%rbx), %rax
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
jmp 0xdc537
leaq 0x11b08(%rip), %rsi     # 0xee004
leaq 0x4ee75(%rip), %rdx     # 0x12b378
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl $0x68, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x20, %rbx
leaq 0x11b12(%rip), %rsi     # 0xee034
leaq 0x4ee59(%rip), %rdx     # 0x12b382
movq %rbx, %rdi
movl $0x20, %ecx
jmp 0xdc58e
xorpd %xmm1, %xmm1
addq $0x2e8, %r12            # imm = 0x2E8
movq %r12, 0x50(%rax)
movq %rax, %rdi
callq 0xdc0fd
movq (%rbx), %rax
cmpl $0x0, 0x38(%rax)
je 0xdc5a2
movq 0x48(%rax), %rcx
leaq 0x11e92(%rip), %rsi     # 0xee3f0
leaq 0x4ee68(%rip), %rdx     # 0x12b3cd
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x20, %rbx
leaq 0x11ab5(%rip), %rsi     # 0xee034
leaq 0x4edfc(%rip), %rdx     # 0x12b382
movq %rbx, %rdi
movl $0x2e, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
jmp 0xdc63b
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 0x15322(%rip), %xmm0    # 0xf1930
movups %xmm0, 0x98(%rax)
movsd 0x10(%rsp), %xmm0
mulsd 0x126cd(%rip), %xmm0    # 0xeecf0
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