// File: /workspace/github_c_makefile_star2_O2/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, %r12
movq %rsi, %r14
movq %rdi, %r15
movq 0xf18(%rsi), %rax
movsd (%rax), %xmm0
pushq $0x1
popq %rbp
leaq 0xc(%rsp), %rcx
movl %ebp, %esi
xorl %edx, %edx
movq %r12, %r8
callq 0x5887d
cmpl $0x1, %eax
jne 0x6967a
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0x7bdbb(%rip), %rsi     # 0xe53f0
leaq 0x9de5a(%rip), %rdx     # 0x107496
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1064, %r14           # imm = 0x1064
leaq 0x7b9d8(%rip), %rsi     # 0xe5034
leaq 0x9de94(%rip), %rdx     # 0x1074f7
movq %r14, %rdi
movl $0xc6f, %ecx            # imm = 0xC6F
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
jmp 0x69866
xorl %ebp, %ebp
pushq $0x1
popq %rbx
leaq 0xc(%rsp), %r13
movslq 0xf08(%r14), %rsi
movq 0xf18(%r14), %rdi
cmpq %rsi, %rbp
jge 0x69727
movsd (%rdi,%rbp,8), %xmm0
movq %r15, %rdi
movl %ebx, %esi
movl %ebx, %edx
movq %r13, %rcx
movq %r12, %r8
callq 0x5887d
cmpl $0x1, %eax
je 0x69799
movslq 0x390(%r15), %rax
movsd (%r12,%rax,8), %xmm0
mulsd 0x80348(%rip), %xmm0    # 0xe9a18
movslq 0x38c(%r15), %rax
divsd (%r12,%rax,8), %xmm0
movsd 0x7c103(%rip), %xmm1    # 0xe57e8
divsd %xmm0, %xmm1
movq 0xf20(%r14), %rax
movslq 0xf04(%r14), %rcx
movslq %ebp, %rdx
imulq %rcx, %rdx
movslq 0xe80(%r14), %rcx
addq %rdx, %rcx
mulsd (%rax,%rcx,8), %xmm1
movslq 0xe88(%r14), %rcx
movslq %edx, %rdx
addq %rcx, %rdx
movsd %xmm1, (%rax,%rdx,8)
incq %rbp
jmp 0x69684
movq 0xf20(%r14), %rdx
movl 0xf04(%r14), %ecx
movl 0xe88(%r14), %r8d
movl 0xe8c(%r14), %r9d
leaq 0x1064(%r14), %r15
pushq %r15
pushq $0x1
callq 0x12065
popq %rcx
popq %rdx
cmpl $0x1, %eax
jne 0x697e2
leaq 0x7bc8b(%rip), %rsi     # 0xe53f0
leaq 0x9de22(%rip), %rdx     # 0x10758e
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x7b8af(%rip), %rsi     # 0xe5034
leaq 0x9dd6b(%rip), %rdx     # 0x1074f7
movq %r15, %rdi
movl $0xc8d, %ecx            # imm = 0xC8D
jmp 0x6985a
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0x7bc49(%rip), %rsi     # 0xe53f0
leaq 0x9dd76(%rip), %rdx     # 0x107524
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1064, %r14           # imm = 0x1064
leaq 0x7b866(%rip), %rsi     # 0xe5034
leaq 0x9dd22(%rip), %rdx     # 0x1074f7
movq %r14, %rdi
movl $0xc7a, %ecx            # imm = 0xC7A
movq %r12, %r8
jmp 0x6985d
movq 0xf18(%r14), %rdi
movl 0xf08(%r14), %esi
movq 0xf20(%r14), %rdx
movl 0xf04(%r14), %ecx
movl 0xe84(%r14), %eax
movl 0xe88(%r14), %r8d
movl 0xe8c(%r14), %r9d
pushq %r15
pushq %rax
callq 0x117fe
popq %rcx
popq %rdx
xorl %ebp, %ebp
cmpl $0x1, %eax
jne 0x69866
leaq 0x7bbc5(%rip), %rsi     # 0xe53f0
leaq 0x9de09(%rip), %rdx     # 0x10763b
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x7b7e9(%rip), %rsi     # 0xe5034
leaq 0x9dca5(%rip), %rdx     # 0x1074f7
movq %r15, %rdi
movl $0xc99, %ecx            # imm = 0xC99
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
movl %ebx, %ebp
movl %ebp, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq