// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/thermodynamics.c
// Function: thermodynamics_calculate_conformal_drag_time
int thermodynamics_calculate_conformal_drag_time(
                                                 struct background* pba,
                                                 struct thermodynamics* pth,
                                                 double* pvecback
                                                 ) {

  /** Summary: */

  /** Define local variables */
  double R;
  int index_tau;
  int last_index_back;

  /** - compute minus the baryon drag interaction rate time, -dkappa_d/dtau = -[1/R * kappa'], with R = 3 rho_b / 4 rho_gamma,
      stored temporarily in column ddkappa */

  /* find the value of last_index_back for tau_table[0] in order to speed up subsequent interpolations in the loop */
  class_call(background_at_tau(pba,
                               pth->tau_table[0],
                               normal_info,
                               inter_normal,
                               &last_index_back,
                               pvecback),
             pba->error_message,
             pth->error_message);

  for (index_tau=0; index_tau < pth->tt_size; index_tau++) {

    class_call(background_at_tau(pba,
                                 pth->tau_table[index_tau],
                                 normal_info,
                                 inter_closeby,
                                 &last_index_back,
                                 pvecback),
               pba->error_message,
               pth->error_message);

    R = 3./4.*pvecback[pba->index_bg_rho_b]/pvecback[pba->index_bg_rho_g];

    pth->thermodynamics_table[index_tau*pth->th_size+pth->index_th_ddkappa] =
      -1./R*pth->thermodynamics_table[index_tau*pth->th_size+pth->index_th_dkappa];

  }

  /** - compute second derivative of this rate, -[1/R * kappa']'', stored temporarily in column dddkappa */
  class_call(array_spline_table_line_to_line(pth->tau_table,
                                             pth->tt_size,
                                             pth->thermodynamics_table,
                                             pth->th_size,
                                             pth->index_th_ddkappa,
                                             pth->index_th_dddkappa,
                                             _SPLINE_EST_DERIV_,
                                             pth->error_message),
             pth->error_message,
             pth->error_message);

  /** - compute tau_d = [int_{tau_today}^{tau} dtau -dkappa_d/dtau] */
  class_call(array_integrate_spline_table_line_to_line(pth->tau_table,
                                                       pth->tt_size,
                                                       pth->thermodynamics_table,
                                                       pth->th_size,
                                                       pth->index_th_ddkappa,
                                                       pth->index_th_dddkappa,
                                                       pth->index_th_tau_d,
                                                       pth->error_message),
             pth->error_message,
             pth->error_message);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq 0xf18(%rsi), %rax
movsd (%rax), %xmm0
movl $0x1, %ebp
leaq 0xc(%rsp), %rcx
movl $0x1, %esi
xorl %edx, %edx
movq %r15, %r8
callq 0x5ed53
cmpl $0x1, %eax
jne 0x70647
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x80dee(%rip), %rsi     # 0xf13f0
leaq 0xa2f9d(%rip), %rdx     # 0x1135a6
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x80a0b(%rip), %rsi     # 0xf1034
leaq 0xa2fd7(%rip), %rdx     # 0x113607
movq %rbx, %rdi
movl $0xc6f, %ecx            # imm = 0xC6F
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
jmp 0x70848
movl 0xf08(%rbx), %esi
testl %esi, %esi
jle 0x70702
xorl %r13d, %r13d
leaq 0xc(%rsp), %r12
movq 0xf18(%rbx), %rax
movsd (%rax,%r13,8), %xmm0
movq %r14, %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %r12, %rcx
movq %r15, %r8
callq 0x5ed53
cmpl $0x1, %eax
je 0x707f5
movslq 0x390(%r14), %rax
movsd (%r15,%rax,8), %xmm0
mulsd 0x85488(%rip), %xmm0    # 0xf5b28
movslq 0x38c(%r14), %rax
divsd (%r15,%rax,8), %xmm0
movsd 0x81133(%rip), %xmm1    # 0xf17e8
divsd %xmm0, %xmm1
movq 0xf20(%rbx), %rax
movslq 0xf04(%rbx), %rcx
movslq %r13d, %rdx
imulq %rcx, %rdx
movslq 0xe80(%rbx), %rcx
addq %rdx, %rcx
mulsd (%rax,%rcx,8), %xmm1
movslq 0xe88(%rbx), %rcx
movslq %edx, %rdx
addq %rcx, %rdx
movsd %xmm1, (%rax,%rdx,8)
incq %r13
movslq 0xf08(%rbx), %rsi
cmpq %rsi, %r13
jl 0x7065d
movq 0xf18(%rbx), %rdi
movq 0xf20(%rbx), %rdx
movl 0xf04(%rbx), %ecx
movl 0xe88(%rbx), %r8d
movl 0xe8c(%rbx), %r9d
leaq 0x1064(%rbx), %r14
pushq %r14
pushq $0x1
callq 0x13c30
addq $0x10, %rsp
cmpl $0x1, %eax
jne 0x70775
leaq 0x80cac(%rip), %rsi     # 0xf13f0
leaq 0xa2f53(%rip), %rdx     # 0x11369e
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x808d0(%rip), %rsi     # 0xf1034
leaq 0xa2e9c(%rip), %rdx     # 0x113607
movq %r14, %rdi
movl $0xc8d, %ecx            # imm = 0xC8D
jmp 0x707f0
movq 0xf18(%rbx), %rdi
movl 0xf08(%rbx), %esi
movq 0xf20(%rbx), %rdx
movl 0xf04(%rbx), %ecx
movl 0xe84(%rbx), %eax
movl 0xe88(%rbx), %r8d
movl 0xe8c(%rbx), %r9d
pushq %r14
pushq %rax
callq 0x1337c
addq $0x10, %rsp
xorl %ebp, %ebp
cmpl $0x1, %eax
jne 0x70848
leaq 0x80c2f(%rip), %rsi     # 0xf13f0
leaq 0xa2f83(%rip), %rdx     # 0x11374b
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x80853(%rip), %rsi     # 0xf1034
leaq 0xa2e1f(%rip), %rdx     # 0x113607
movq %r14, %rdi
movl $0xc99, %ecx            # imm = 0xC99
movq %rbx, %r8
jmp 0x7083c
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x80bed(%rip), %rsi     # 0xf13f0
leaq 0xa2e2a(%rip), %rdx     # 0x113634
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x8080a(%rip), %rsi     # 0xf1034
leaq 0xa2dd6(%rip), %rdx     # 0x113607
movq %rbx, %rdi
movl $0xc7a, %ecx            # imm = 0xC7A
movq %r15, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %ebp
movl %ebp, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq