// File: /workspace/github_c_makefile_star2_O2/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 0x62eda
movsd 0x1050(%rbx), %xmm1
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
movw %ax, 0x36(%rbx)
cmpw $0x0, 0x4c6(%r14)
je 0x62ee2
movsd 0x1018(%rbx), %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
jmp 0x62ee4
andl $0x0, 0x36(%rbx)
xorl %eax, %eax
jmp 0x62ef9
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 0x62f2c
movl 0x10(%rbx), %edx
testl %edx, %edx
je 0x62f20
cmpl $0x1, %edx
jne 0x62fa9
leaq 0xa6294(%rip), %rdi     # 0x1091b2
jmp 0x62f27
leaq 0xa62b5(%rip), %rdi     # 0x1091dc
callq 0x8540
movzwl 0x4ca(%r14), %eax
movw %ax, 0xe78(%rbx)
movsd (%rbx), %xmm0
ucomisd 0x828a1(%rip), %xmm0    # 0xe57e8
jne 0x63002
jp 0x63002
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6351c
testl %eax, %eax
je 0x62ffe
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x82479(%rip), %rsi     # 0xe53f0
leaq 0xa1a0b(%rip), %rdx     # 0x104989
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x8209f(%rip), %rsi     # 0xe5034
leaq 0xa19d9(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x158, %ecx            # imm = 0x158
jmp 0x630c7
leaq 0x8fae5(%rip), %rsi     # 0xf2a95
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x825c1(%rip), %rsi     # 0xe5585
leaq 0x800(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2e014
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x8204d(%rip), %rsi     # 0xe5034
leaq 0xa1987(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x14b, %ecx            # imm = 0x14B
movq %r15, %r8
jmp 0x630ca
movsd (%rbx), %xmm0
cmpw $0x0, 0x1060(%rbx)
jle 0x6301e
leaq 0xa19a2(%rip), %rdi     # 0x1049b5
movb $0x1, %al
callq 0x8030
movsd (%rbx), %xmm0
movsd 0x8223a(%rip), %xmm1    # 0xe5260
subsd %xmm0, %xmm1
movsd 0xa151e(%rip), %xmm2    # 0x104550
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, 0x1000(%rbx)
movsd (%r14), %xmm0
mulsd 0x86a61(%rip), %xmm0    # 0xe9ab0
divsd 0x86951(%rip), %xmm0    # 0xe99a8
mulsd %xmm0, %xmm0
mulsd 0x836e5(%rip), %xmm0    # 0xe6748
mulsd 0x20(%r14), %xmm0
divsd 0xa14e7(%rip), %xmm0    # 0x104558
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1008(%rbx)
movq %r15, %rdi
movq %rbx, %rdx
callq 0x63f1d
testl %eax, %eax
je 0x630e6
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x82356(%rip), %rsi     # 0xe53f0
leaq 0xa194a(%rip), %rdx     # 0x1049eb
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81f7c(%rip), %rsi     # 0xe5034
leaq 0xa18b6(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x168, %ecx            # imm = 0x168
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x90, %edi
callq 0x8490
testq %rax, %rax
je 0x63151
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x6409d
testl %eax, %eax
je 0x63193
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x822d1(%rip), %rsi     # 0xe53f0
leaq 0xa18ec(%rip), %rdx     # 0x104a12
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81ef7(%rip), %rsi     # 0xe5034
leaq 0xa1831(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x172, %ecx            # imm = 0x172
jmp 0x630c7
leaq 0x81eac(%rip), %rsi     # 0xe5004
leaq 0xa18af(%rip), %rdx     # 0x104a0e
movq %rsp, %r14
movq %r14, %rdi
movl $0x90, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x81eb5(%rip), %rsi     # 0xe5034
leaq 0xa17ef(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x16b, %ecx            # imm = 0x16B
jmp 0x630c7
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x647f5
testl %eax, %eax
je 0x631e8
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x8223a(%rip), %rsi     # 0xe53f0
leaq 0xa1883(%rip), %rdx     # 0x104a40
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81e60(%rip), %rsi     # 0xe5034
leaq 0xa179a(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x176, %ecx            # imm = 0x176
jmp 0x630c7
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x64f14
testl %eax, %eax
je 0x6323a
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x821e8(%rip), %rsi     # 0xe53f0
leaq 0xa1860(%rip), %rdx     # 0x104a6f
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81e0e(%rip), %rsi     # 0xe5034
leaq 0xa1748(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x17a, %ecx            # imm = 0x17A
jmp 0x630c7
movslq 0x43c(%r14), %rbp
leaq (,%rbp,8), %rdi
callq 0x8490
testq %rax, %rax
je 0x632af
movq %rax, %r13
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x65180
testl %eax, %eax
je 0x632f4
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x82173(%rip), %rsi     # 0xe53f0
leaq 0xa180f(%rip), %rdx     # 0x104a93
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81d99(%rip), %rsi     # 0xe5034
leaq 0xa16d3(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x180, %ecx            # imm = 0x180
jmp 0x630c7
shll $0x3, %ebp
leaq 0x81d4b(%rip), %rsi     # 0xe5004
leaq 0xa8e72(%rip), %rdx     # 0x10c132
movq %rsp, %rbx
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x81d57(%rip), %rsi     # 0xe5034
leaq 0xa1691(%rip), %rdx     # 0x104975
movq %r14, %rdi
movl $0x17c, %ecx            # imm = 0x17C
movq %rbx, %r8
jmp 0x630ca
cmpw $0x1, 0xb8(%rbx)
jne 0x63355
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xc75c0
cmpl $0x1, %eax
jne 0x63355
leaq 0x630(%rbx), %rcx
leaq 0x820d1(%rip), %rsi     # 0xe53f0
leaq 0xa1793(%rip), %rdx     # 0x104ab9
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x81cf3(%rip), %rsi     # 0xe5034
leaq 0xa162d(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x188, %ecx            # imm = 0x188
jmp 0x630c7
movq 0x88(%r12), %rcx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6555b
testl %eax, %eax
je 0x633af
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x82073(%rip), %rsi     # 0xe53f0
leaq 0xa1753(%rip), %rdx     # 0x104ad7
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81c99(%rip), %rsi     # 0xe5034
leaq 0xa15d3(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x191, %ecx            # imm = 0x191
jmp 0x630c7
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0x6636f
testl %eax, %eax
je 0x63407
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x8201b(%rip), %rsi     # 0xe53f0
leaq 0xa1740(%rip), %rdx     # 0x104b1c
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81c41(%rip), %rsi     # 0xe5034
leaq 0xa157b(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x196, %ecx            # imm = 0x196
jmp 0x630c7
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x66863
testl %eax, %eax
je 0x6345c
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x81fc6(%rip), %rsi     # 0xe53f0
leaq 0xa171a(%rip), %rdx     # 0x104b4b
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81bec(%rip), %rsi     # 0xe5034
leaq 0xa1526(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x19d, %ecx            # imm = 0x19D
jmp 0x630c7
cmpw $0x0, 0x1060(%rbx)
jle 0x634b5
movq %r14, %rdi
movq %rbx, %rsi
callq 0x66b1e
testl %eax, %eax
je 0x634b5
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x81f6d(%rip), %rsi     # 0xe53f0
leaq 0xa1705(%rip), %rdx     # 0x104b8f
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81b93(%rip), %rsi     # 0xe5034
leaq 0xa14cd(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x1a3, %ecx            # imm = 0x1A3
jmp 0x630c7
movq %rbx, %rdi
movq %r12, %rsi
callq 0x66dbd
testl %eax, %eax
je 0x63504
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x81f1e(%rip), %rsi     # 0xe53f0
leaq 0xa16dd(%rip), %rdx     # 0x104bb6
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x81b44(%rip), %rsi     # 0xe5034
leaq 0xa147e(%rip), %rdx     # 0x104975
movq %rbx, %rdi
movl $0x1a9, %ecx            # imm = 0x1A9
jmp 0x630c7
movq %r13, %rdi
callq 0x8430
movw $0x1, 0x1864(%rbx)
xorl %eax, %eax
jmp 0x630d4