// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/thermodynamics.c
// Function: thermodynamics_init
int thermodynamics_init(
                        struct precision * ppr,
                        struct background * pba,
                        struct thermodynamics * pth
                        ) {

  /** Summary: */

  /** - define local variables */

  /* vector of background values for calling background_at_tau */
  double * pvecback;

  /* structures for storing temporarily information on recombination and reionization */
  struct thermo_workspace * ptw;

  pth->has_idm_g = pba->has_idm && (pth->u_idm_g > 0.);
  pth->has_idm_dr = pba->has_idm && (pba->has_idr && pth->a_idm_dr > 0.);
  pth->has_idm_b = pba->has_idm && (pth->cross_idm_b > 0.);

  /** - update the user about which recombination code is being run */
  if (pth->thermodynamics_verbose > 0) {
    switch (pth->recombination) {

    case recfast:
      printf("Computing thermodynamics using RecFastCLASS (based on v1.5)\n");
      break;

    case hyrec:
      printf("Computing thermodynamics using HyRec 2020\n");
      break;

    default:
      class_stop(pth->error_message,"pth->recombination=%d different from all known cases",pth->recombination);
      break;
    }
  }

  /** - set flag for varying constants */
  pth->has_varconst = pba->has_varconst;

  /** - compute and check primordial Helium mass fraction rho_He/(rho_H+rho_He) */

  if (pth->YHe == _YHE_BBN_) {
    class_call(thermodynamics_helium_from_bbn(ppr,pba,pth),
               pth->error_message,
               pth->error_message);
  }
  if (pth->thermodynamics_verbose > 0) {
    printf(" -> with primordial helium mass fraction Y_He = %.4f\n",pth->YHe);
  }

  /** - infer primordial helium-to-hydrogen nucleon ratio n_He/n_H
   * It is calculated via n_He/n_H = rho_He/(m_He/m_H * rho_H) = YHe * rho_b / (m_He/m_H * (1-YHe) rho_b) = YHe / (m_He/m_H * (1-YHe))*/
  pth->fHe = pth->YHe/(_not4_ *(1.-pth->YHe));

  /** - infer number of hydrogen nuclei today in m**-3 */
  pth->n_e = 3.*pow(pba->H0 * _c_ / _Mpc_over_m_,2)*pba->Omega0_b/(8.*_PI_*_G_*_m_H_)*(1.-pth->YHe);

  /** - test whether all parameters are in the correct regime */
  class_call(thermodynamics_checks(ppr,pba,pth),
             pth->error_message,
             pth->error_message);

  /** - allocate and assign all temporary structures and indices */
  class_alloc(ptw, sizeof(struct thermo_workspace), pth->error_message);

  /*  in the case of idm, we need to adapt the start of integration time,
      to be sure we capture the time at which the two species are still coupled.
      This is after thermo_workspace was allocated to set the has_ap_idmtca flag*/
  class_call(thermodynamics_obtain_z_ini(ppr,pba,pth, ptw),
             pth->error_message,
             pth->error_message);

  class_call(thermodynamics_workspace_init(ppr,pba,pth,ptw),
             pth->error_message,
             pth->error_message);

  class_call(thermodynamics_indices(pba,pth,ptw),
             pth->error_message,
             pth->error_message);

  class_alloc(pvecback,pba->bg_size*sizeof(double),pba->error_message);

  class_call(thermodynamics_lists(ppr,pba,pth,ptw),
             pth->error_message,
             pth->error_message);

  /** - initialize injection struct (not temporary) */
  if (pth->has_exotic_injection == _TRUE_) {
    class_call(injection_init(ppr,
                              pba,
                              pth),
               (pth->in).error_message,
               pth->error_message);
  }

  /** - assign reionisation parameters */
  class_call(thermodynamics_set_parameters_reionization(ppr,
                                                        pba,
                                                        pth,
                                                        ptw->ptrp),
             pth->error_message,
             pth->error_message);

  /** - solve recombination and reionization and store values of \f$ z, x_e, d \kappa / d \tau, T_b, c_b^2 \f$  */
  class_call(thermodynamics_solve(ppr,pba,pth,ptw,pvecback),
             pth->error_message,
             pth->error_message);

  /** - the differential equation system is now completely solved  */

  /** - fill missing columns (quantities not computed during the differential evolution but related) */
  class_call(thermodynamics_calculate_remaining_quantities(ppr,pba,pth,pvecback),
             pth->error_message,
             pth->error_message);

  /** - write information on thermal history in standard output */
  if (pth->thermodynamics_verbose > 0) {
    class_call(thermodynamics_output_summary(pba,pth),
               pth->error_message,
               pth->error_message);
  }

  /** - free workspace and local variables */
  class_call(thermodynamics_workspace_free(pth,ptw),
             pth->error_message,
             pth->error_message);

  free(pvecback);

  pth->is_allocated = _TRUE_;

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1008, %rsp           # imm = 0x1008
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
cmpw $0x0, 0x4b6(%rsi)
je 0x671ac
movsd 0x1050(%rbx), %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
movw %ax, 0x36(%rbx)
cmpw $0x0, 0x4c6(%r14)
je 0x671b7
movsd 0x1018(%rbx), %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
jmp 0x671b9
movl $0x0, 0x36(%rbx)
xorl %eax, %eax
jmp 0x671ce
xorl %eax, %eax
movw %ax, 0x38(%rbx)
movsd 0x1030(%rbx), %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
movw %ax, 0x34(%rbx)
cmpw $0x0, 0x1060(%rbx)
jle 0x67201
movl 0x10(%rbx), %edx
testl %edx, %edx
je 0x671f5
cmpl $0x1, %edx
jne 0x6727e
leaq 0xab11f(%rip), %rdi     # 0x112312
jmp 0x671fc
leaq 0xab140(%rip), %rdi     # 0x11233c
callq 0x8510
movzwl 0x4ca(%r14), %eax
movw %ax, 0xe78(%rbx)
movsd (%rbx), %xmm0
ucomisd 0x875cc(%rip), %xmm0    # 0xee7e8
jne 0x672d7
jp 0x672d7
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x677f3
testl %eax, %eax
je 0x672d3
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x871a4(%rip), %rsi     # 0xee3f0
leaq 0xa6896(%rip), %rdx     # 0x10dae9
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x86dca(%rip), %rsi     # 0xee034
leaq 0xa6864(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x158, %ecx            # imm = 0x158
jmp 0x6739c
leaq 0x94948(%rip), %rsi     # 0xfbbcd
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
leaq 0x872ec(%rip), %rsi     # 0xee585
leaq 0x800(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30af0
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86d78(%rip), %rsi     # 0xee034
leaq 0xa6812(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x14b, %ecx            # imm = 0x14B
movq %r15, %r8
jmp 0x6739f
movsd (%rbx), %xmm0
cmpw $0x0, 0x1060(%rbx)
jle 0x672f3
leaq 0xa682d(%rip), %rdi     # 0x10db15
movb $0x1, %al
callq 0x8030
movsd (%rbx), %xmm0
movsd 0x86f65(%rip), %xmm1    # 0xee260
subsd %xmm0, %xmm1
movsd 0xa6389(%rip), %xmm2    # 0x10d690
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, 0x1000(%rbx)
movsd (%r14), %xmm0
mulsd 0x8b8cc(%rip), %xmm0    # 0xf2bf0
divsd 0x8b7bc(%rip), %xmm0    # 0xf2ae8
mulsd %xmm0, %xmm0
mulsd 0x88348(%rip), %xmm0    # 0xef680
mulsd 0x20(%r14), %xmm0
divsd 0xa6352(%rip), %xmm0    # 0x10d698
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1008(%rbx)
movq %r15, %rdi
movq %rbx, %rdx
callq 0x68248
testl %eax, %eax
je 0x673bd
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87081(%rip), %rsi     # 0xee3f0
leaq 0xa67d5(%rip), %rdx     # 0x10db4b
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x86ca7(%rip), %rsi     # 0xee034
leaq 0xa6741(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x168, %ecx            # imm = 0x168
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x90, %edi
callq 0x8460
testq %rax, %rax
je 0x67428
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x683ca
testl %eax, %eax
je 0x6746a
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86ffa(%rip), %rsi     # 0xee3f0
leaq 0xa6775(%rip), %rdx     # 0x10db72
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x86c20(%rip), %rsi     # 0xee034
leaq 0xa66ba(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x172, %ecx            # imm = 0x172
jmp 0x6739c
leaq 0x86bd5(%rip), %rsi     # 0xee004
leaq 0xa6738(%rip), %rdx     # 0x10db6e
movq %rsp, %r14
movq %r14, %rdi
movl $0x90, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86bde(%rip), %rsi     # 0xee034
leaq 0xa6678(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x16b, %ecx            # imm = 0x16B
jmp 0x6739c
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x68b3a
testl %eax, %eax
je 0x674bf
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86f63(%rip), %rsi     # 0xee3f0
leaq 0xa670c(%rip), %rdx     # 0x10dba0
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x86b89(%rip), %rsi     # 0xee034
leaq 0xa6623(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x176, %ecx            # imm = 0x176
jmp 0x6739c
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x6928b
testl %eax, %eax
je 0x67511
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86f11(%rip), %rsi     # 0xee3f0
leaq 0xa66e9(%rip), %rdx     # 0x10dbcf
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x86b37(%rip), %rsi     # 0xee034
leaq 0xa65d1(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x17a, %ecx            # imm = 0x17A
jmp 0x6739c
movslq 0x43c(%r14), %rbp
leaq (,%rbp,8), %rdi
callq 0x8460
testq %rax, %rax
je 0x67586
movq %rax, %r13
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x69509
testl %eax, %eax
je 0x675cb
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86e9c(%rip), %rsi     # 0xee3f0
leaq 0xa6698(%rip), %rdx     # 0x10dbf3
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x86ac2(%rip), %rsi     # 0xee034
leaq 0xa655c(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x180, %ecx            # imm = 0x180
jmp 0x6739c
shll $0x3, %ebp
leaq 0x86a74(%rip), %rsi     # 0xee004
leaq 0xadcfb(%rip), %rdx     # 0x115292
movq %rsp, %rbx
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x86a80(%rip), %rsi     # 0xee034
leaq 0xa651a(%rip), %rdx     # 0x10dad5
movq %r14, %rdi
movl $0x17c, %ecx            # imm = 0x17C
movq %rbx, %r8
jmp 0x6739f
cmpw $0x1, 0xb8(%rbx)
jne 0x6762c
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xcecc8
cmpl $0x1, %eax
jne 0x6762c
leaq 0x630(%rbx), %rcx
leaq 0x86dfa(%rip), %rsi     # 0xee3f0
leaq 0xa661c(%rip), %rdx     # 0x10dc19
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86a1c(%rip), %rsi     # 0xee034
leaq 0xa64b6(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x188, %ecx            # imm = 0x188
jmp 0x6739c
movq 0x88(%r12), %rcx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x69910
testl %eax, %eax
je 0x67686
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86d9c(%rip), %rsi     # 0xee3f0
leaq 0xa65dc(%rip), %rdx     # 0x10dc37
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x869c2(%rip), %rsi     # 0xee034
leaq 0xa645c(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x191, %ecx            # imm = 0x191
jmp 0x6739c
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0x6a750
testl %eax, %eax
je 0x676de
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86d44(%rip), %rsi     # 0xee3f0
leaq 0xa65c9(%rip), %rdx     # 0x10dc7c
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x8696a(%rip), %rsi     # 0xee034
leaq 0xa6404(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x196, %ecx            # imm = 0x196
jmp 0x6739c
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x6ac38
testl %eax, %eax
je 0x67733
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86cef(%rip), %rsi     # 0xee3f0
leaq 0xa65a3(%rip), %rdx     # 0x10dcab
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x86915(%rip), %rsi     # 0xee034
leaq 0xa63af(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x19d, %ecx            # imm = 0x19D
jmp 0x6739c
cmpw $0x0, 0x1060(%rbx)
jle 0x6778c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6aefd
testl %eax, %eax
je 0x6778c
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86c96(%rip), %rsi     # 0xee3f0
leaq 0xa658e(%rip), %rdx     # 0x10dcef
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x868bc(%rip), %rsi     # 0xee034
leaq 0xa6356(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x1a3, %ecx            # imm = 0x1A3
jmp 0x6739c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6b1a5
testl %eax, %eax
je 0x677db
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x86c47(%rip), %rsi     # 0xee3f0
leaq 0xa6566(%rip), %rdx     # 0x10dd16
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x8686d(%rip), %rsi     # 0xee034
leaq 0xa6307(%rip), %rdx     # 0x10dad5
movq %rbx, %rdi
movl $0x1a9, %ecx            # imm = 0x1A9
jmp 0x6739c
movq %r13, %rdi
callq 0x8410
movw $0x1, 0x1864(%rbx)
xorl %eax, %eax
jmp 0x673ab