// File: /workspace/github_c_makefile_star2_O1/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
movzwl 0x4b6(%rsi), %eax
testw %ax, %ax
je 0x69af2
movsd 0x1050(%rbx), %xmm1
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
seta %cl
movw %cx, 0x36(%rbx)
cmpw $0x0, 0x4c6(%r14)
je 0x69af8
movsd 0x1018(%rbx), %xmm1
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
seta %cl
jmp 0x69afa
movw $0x0, 0x36(%rbx)
xorl %ecx, %ecx
movw %cx, 0x38(%rbx)
testw %ax, %ax
je 0x69b1a
movsd 0x1030(%rbx), %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
jmp 0x69b1c
xorl %eax, %eax
movw %ax, 0x34(%rbx)
cmpw $0x0, 0x1060(%rbx)
jle 0x69b4f
movl 0x10(%rbx), %edx
testl %edx, %edx
je 0x69b43
cmpl $0x1, %edx
jne 0x69c92
leaq 0xab781(%rip), %rdi     # 0x1152c2
jmp 0x69b4a
leaq 0xab7a2(%rip), %rdi     # 0x1152ec
callq 0x8510
movzwl 0x4ca(%r14), %eax
movw %ax, 0xe78(%rbx)
movsd (%rbx), %xmm0
ucomisd 0x87c7e(%rip), %xmm0    # 0xf17e8
jne 0x69bc0
jp 0x69bc0
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6a136
testl %eax, %eax
je 0x69bc0
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87862(%rip), %rsi     # 0xf13f0
leaq 0xa6f04(%rip), %rdx     # 0x110a99
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x87488(%rip), %rsi     # 0xf1034
leaq 0xa6ed2(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x158, %ecx            # imm = 0x158
jmp 0x69c8d
cmpw $0x0, 0x1060(%rbx)
jle 0x69bdc
movsd (%rbx), %xmm0
leaq 0xa6ef0(%rip), %rdi     # 0x110ac5
movb $0x1, %al
callq 0x8030
movsd (%rbx), %xmm0
movsd 0x87678(%rip), %xmm1    # 0xf1260
subsd %xmm0, %xmm1
movsd 0xa6a7c(%rip), %xmm2    # 0x110670
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, 0x1000(%rbx)
movsd (%r14), %xmm0
mulsd 0x8bfaf(%rip), %xmm0    # 0xf5bc0
divsd 0x8be9f(%rip), %xmm0    # 0xf5ab8
mulsd %xmm0, %xmm0
mulsd 0x88a5b(%rip), %xmm0    # 0xf2680
mulsd 0x20(%r14), %xmm0
divsd 0xa6a45(%rip), %xmm0    # 0x110678
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1008(%rbx)
movq %r15, %rdi
movq %rbx, %rdx
callq 0x6ab8b
testl %eax, %eax
je 0x69d00
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87790(%rip), %rsi     # 0xf13f0
leaq 0xa6e94(%rip), %rdx     # 0x110afb
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x873b6(%rip), %rsi     # 0xf1034
leaq 0xa6e00(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x168, %ecx            # imm = 0x168
movq %r14, %r8
jmp 0x69ce2
leaq 0x94f0c(%rip), %rsi     # 0xfeba5
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0x878d8(%rip), %rsi     # 0xf1585
leaq 0x800(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30c2c
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87364(%rip), %rsi     # 0xf1034
leaq 0xa6dae(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x14b, %ecx            # imm = 0x14B
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
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 0x69d6b
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x6ad0d
testl %eax, %eax
je 0x69dad
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x876b7(%rip), %rsi     # 0xf13f0
leaq 0xa6de2(%rip), %rdx     # 0x110b22
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x872dd(%rip), %rsi     # 0xf1034
leaq 0xa6d27(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x172, %ecx            # imm = 0x172
jmp 0x69c8d
leaq 0x87292(%rip), %rsi     # 0xf1004
leaq 0xa6da5(%rip), %rdx     # 0x110b1e
movq %rsp, %r14
movq %r14, %rdi
movl $0x90, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x8729b(%rip), %rsi     # 0xf1034
leaq 0xa6ce5(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x16b, %ecx            # imm = 0x16B
jmp 0x69c8d
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x6b483
testl %eax, %eax
je 0x69e02
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87620(%rip), %rsi     # 0xf13f0
leaq 0xa6d79(%rip), %rdx     # 0x110b50
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x87246(%rip), %rsi     # 0xf1034
leaq 0xa6c90(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x176, %ecx            # imm = 0x176
jmp 0x69c8d
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x6bbcd
testl %eax, %eax
je 0x69e54
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x875ce(%rip), %rsi     # 0xf13f0
leaq 0xa6d56(%rip), %rdx     # 0x110b7f
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x871f4(%rip), %rsi     # 0xf1034
leaq 0xa6c3e(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x17a, %ecx            # imm = 0x17A
jmp 0x69c8d
movslq 0x43c(%r14), %rbp
leaq (,%rbp,8), %rdi
callq 0x8460
testq %rax, %rax
je 0x69ec9
movq %rax, %r13
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x6be7f
testl %eax, %eax
je 0x69f0e
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87559(%rip), %rsi     # 0xf13f0
leaq 0xa6d05(%rip), %rdx     # 0x110ba3
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x8717f(%rip), %rsi     # 0xf1034
leaq 0xa6bc9(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x180, %ecx            # imm = 0x180
jmp 0x69c8d
shll $0x3, %ebp
leaq 0x87131(%rip), %rsi     # 0xf1004
leaq 0xae378(%rip), %rdx     # 0x118252
movq %rsp, %rbx
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x8713d(%rip), %rsi     # 0xf1034
leaq 0xa6b87(%rip), %rdx     # 0x110a85
movq %r14, %rdi
movl $0x17c, %ecx            # imm = 0x17C
movq %rbx, %r8
jmp 0x69ce2
cmpw $0x1, 0xb8(%rbx)
jne 0x69f6f
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xd2554
cmpl $0x1, %eax
jne 0x69f6f
leaq 0x630(%rbx), %rcx
leaq 0x874b7(%rip), %rsi     # 0xf13f0
leaq 0xa6c89(%rip), %rdx     # 0x110bc9
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x870d9(%rip), %rsi     # 0xf1034
leaq 0xa6b23(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x188, %ecx            # imm = 0x188
jmp 0x69c8d
movq 0x88(%r12), %rcx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6c279
testl %eax, %eax
je 0x69fc9
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87459(%rip), %rsi     # 0xf13f0
leaq 0xa6c49(%rip), %rdx     # 0x110be7
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x8707f(%rip), %rsi     # 0xf1034
leaq 0xa6ac9(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x191, %ecx            # imm = 0x191
jmp 0x69c8d
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0x6d0d7
testl %eax, %eax
je 0x6a021
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87401(%rip), %rsi     # 0xf13f0
leaq 0xa6c36(%rip), %rdx     # 0x110c2c
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x87027(%rip), %rsi     # 0xf1034
leaq 0xa6a71(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x196, %ecx            # imm = 0x196
jmp 0x69c8d
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x6d5a0
testl %eax, %eax
je 0x6a076
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x873ac(%rip), %rsi     # 0xf13f0
leaq 0xa6c10(%rip), %rdx     # 0x110c5b
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x86fd2(%rip), %rsi     # 0xf1034
leaq 0xa6a1c(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x19d, %ecx            # imm = 0x19D
jmp 0x69c8d
cmpw $0x0, 0x1060(%rbx)
jle 0x6a0cf
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6d865
testl %eax, %eax
je 0x6a0cf
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87353(%rip), %rsi     # 0xf13f0
leaq 0xa6bfb(%rip), %rdx     # 0x110c9f
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x86f79(%rip), %rsi     # 0xf1034
leaq 0xa69c3(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x1a3, %ecx            # imm = 0x1A3
jmp 0x69c8d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6db0d
testl %eax, %eax
je 0x6a11e
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x87304(%rip), %rsi     # 0xf13f0
leaq 0xa6bd3(%rip), %rdx     # 0x110cc6
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x86f2a(%rip), %rsi     # 0xf1034
leaq 0xa6974(%rip), %rdx     # 0x110a85
movq %rbx, %rdi
movl $0x1a9, %ecx            # imm = 0x1A9
jmp 0x69c8d
movq %r13, %rdi
callq 0x8410
movw $0x1, 0x1864(%rbx)
xorl %eax, %eax
jmp 0x69cee