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

  /** Summary: */

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

  /** - find baryon drag time (when tau_d crosses one, using linear interpolation) and sound horizon at that time */
  index_tau=0;
  while ((pth->thermodynamics_table[(index_tau)*pth->th_size+pth->index_th_tau_d] < 1.) && (index_tau < pth->tt_size)) {
    index_tau++;
  }

  pth->z_d = pth->z_table[index_tau-1]+
    (1.-pth->thermodynamics_table[(index_tau-1)*pth->th_size+pth->index_th_tau_d])
    /(pth->thermodynamics_table[(index_tau)*pth->th_size+pth->index_th_tau_d]-pth->thermodynamics_table[(index_tau-1)*pth->th_size+pth->index_th_tau_d])
    *(pth->z_table[index_tau]-pth->z_table[index_tau-1]);

  class_call(background_tau_of_z(pba,pth->z_d,&(pth->tau_d)),
             pba->error_message,
             pth->error_message);

  class_call(background_at_z(pba,pth->z_d, long_info, inter_normal, &last_index_back, pvecback),
             pba->error_message,
             pth->error_message);

  pth->rs_d=pvecback[pba->index_bg_rs];
  pth->ds_d=pth->rs_d/(1.+pth->z_d);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
movq 0xf20(%rdx), %rax
movslq 0xf04(%rdx), %rdx
movslq 0xe84(%rbx), %rcx
movsd (%rax,%rcx,8), %xmm0
xorl %esi, %esi
movsd 0x7e954(%rip), %xmm1    # 0xee260
ucomisd %xmm0, %xmm1
jbe 0x6f94e
movl 0xf08(%rbx), %edi
xorl %esi, %esi
testl %edi, %edi
cmovgl %edi, %esi
jle 0x6f94e
leaq (,%rdx,8), %r8
leaq (%r8,%rcx,8), %r9
addq %rax, %r9
xorl %edi, %edi
movsd (%r9), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x6f94a
incq %rdi
addq %r8, %r9
cmpq %rdi, %rsi
jne 0x6f932
jmp 0x6f94e
incl %edi
movl %edi, %esi
movq 0xf10(%rbx), %rdi
movslq %esi, %r8
decl %esi
movsd -0x8(%rdi,%r8,8), %xmm2
imull %edx, %esi
addl %ecx, %esi
movslq %esi, %rcx
movsd (%rax,%rcx,8), %xmm3
subsd %xmm3, %xmm1
subsd %xmm3, %xmm0
divsd %xmm0, %xmm1
movl %r8d, %eax
movsd (%rdi,%rax,8), %xmm0
subsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, 0xfa0(%rbx)
leaq 0xfa8(%rbx), %rsi
movq %r14, %rdi
callq 0x5c896
cmpl $0x1, %eax
jne 0x6f9f0
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x7ea38(%rip), %rsi     # 0xee3f0
leaq 0xa2254(%rip), %rdx     # 0x111c13
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x7e655(%rip), %rsi     # 0xee034
leaq 0xa225d(%rip), %rdx     # 0x111c43
movq %rbx, %rdi
movl $0xf4b, %ecx            # imm = 0xF4B
jmp 0x6fa5a
movsd 0xfa0(%rbx), %xmm0
xorl %ebp, %ebp
leaq 0xc(%rsp), %rcx
movq %r14, %rdi
movl $0x2, %esi
xorl %edx, %edx
movq %r15, %r8
callq 0x5c3a8
cmpl $0x1, %eax
jne 0x6fa6b
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x7e9cc(%rip), %rsi     # 0xee3f0
leaq 0xa2241(%rip), %rdx     # 0x111c6c
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x7e5e9(%rip), %rsi     # 0xee034
leaq 0xa21f1(%rip), %rdx     # 0x111c43
movq %rbx, %rdi
movl $0xf4f, %ecx            # imm = 0xF4F
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebp
jmp 0x6fa9c
movslq 0x420(%r14), %rax
movsd (%r15,%rax,8), %xmm0
movsd %xmm0, 0xfb8(%rbx)
movsd 0xfa0(%rbx), %xmm1
addsd 0x7e7d0(%rip), %xmm1    # 0xee260
divsd %xmm1, %xmm0
movsd %xmm0, 0xfb0(%rbx)
movl %ebp, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r14
popq %r15
popq %rbp
retq