// File: /workspace/github_c_makefile_star2_O3/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 0x5c63f
cmpl $0x1, %eax
jne 0x6dbbc
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x80879(%rip), %rsi     # 0xee3f0
leaq 0xa2a78(%rip), %rdx     # 0x1105f6
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x80496(%rip), %rsi     # 0xee034
leaq 0xa2ab2(%rip), %rdx     # 0x110657
movq %rbx, %rdi
movl $0xc6f, %ecx            # imm = 0xC6F
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
jmp 0x6ddbe
movl 0xf08(%rbx), %esi
testl %esi, %esi
jle 0x6dc78
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 0x5c63f
cmpl $0x1, %eax
je 0x6dd6b
movslq 0x390(%r14), %rax
movsd (%r15,%rax,8), %xmm0
mulsd 0x84f43(%rip), %xmm0    # 0xf2b58
movslq 0x38c(%r14), %rax
divsd (%r15,%rax,8), %xmm0
movsd 0x80bbe(%rip), %xmm1    # 0xee7e8
divsd %xmm0, %xmm1
movq 0xf20(%rbx), %rdx
movl 0xe88(%rbx), %r8d
movl 0xf04(%rbx), %ecx
movl %r13d, %eax
imull %ecx, %eax
movslq 0xe80(%rbx), %rsi
cltq
addq %rax, %rsi
mulsd (%rdx,%rsi,8), %xmm1
addl %r8d, %eax
cltq
movsd %xmm1, (%rdx,%rax,8)
incq %r13
movslq 0xf08(%rbx), %rsi
cmpq %rsi, %r13
jl 0x6dbd2
jmp 0x6dc8c
movq 0xf20(%rbx), %rdx
movl 0xe88(%rbx), %r8d
movl 0xf04(%rbx), %ecx
movq 0xf18(%rbx), %rdi
movl 0xe8c(%rbx), %r9d
leaq 0x1064(%rbx), %r14
pushq %r14
pushq $0x1
callq 0x13d65
addq $0x10, %rsp
cmpl $0x1, %eax
jne 0x6dceb
leaq 0x80736(%rip), %rsi     # 0xee3f0
leaq 0xa2a2d(%rip), %rdx     # 0x1106ee
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x8035a(%rip), %rsi     # 0xee034
leaq 0xa2976(%rip), %rdx     # 0x110657
movq %r14, %rdi
movl $0xc8d, %ecx            # imm = 0xC8D
jmp 0x6dd66
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 0x134f5
addq $0x10, %rsp
xorl %ebp, %ebp
cmpl $0x1, %eax
jne 0x6ddbe
leaq 0x806b9(%rip), %rsi     # 0xee3f0
leaq 0xa2a5d(%rip), %rdx     # 0x11079b
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x802dd(%rip), %rsi     # 0xee034
leaq 0xa28f9(%rip), %rdx     # 0x110657
movq %r14, %rdi
movl $0xc99, %ecx            # imm = 0xC99
movq %rbx, %r8
jmp 0x6ddb2
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x80677(%rip), %rsi     # 0xee3f0
leaq 0xa2904(%rip), %rdx     # 0x110684
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x80294(%rip), %rsi     # 0xee034
leaq 0xa28b0(%rip), %rdx     # 0x110657
movq %rbx, %rdi
movl $0xc7a, %ecx            # imm = 0xC7A
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebp
movl %ebp, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq