// File: /workspace/github_c_makefile_star2_O2/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), %rsi
movslq 0xe84(%rdx), %rdx
leaq (%rax,%rdx,8), %rdi
subl %esi, %edx
movq %rsi, %r8
shlq $0x3, %r8
xorl %ecx, %ecx
movsd 0x79f4e(%rip), %xmm1    # 0xe5260
movsd (%rdi), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x6b332
movslq 0xf08(%rbx), %r9
cmpq %r9, %rcx
jge 0x6b332
incq %rcx
addl %esi, %edx
addq %r8, %rdi
jmp 0x6b312
movq 0xf10(%rbx), %rsi
movslq %edx, %rdx
movsd (%rax,%rdx,8), %xmm2
subsd %xmm2, %xmm1
subsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movsd -0x8(%rsi,%rcx,8), %xmm2
movsd (%rsi,%rcx,8), %xmm0
subsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, 0xfa0(%rbx)
leaq 0xfa8(%rbx), %rsi
movq %r14, %rdi
callq 0x58adb
cmpl $0x1, %eax
jne 0x6b3c6
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x7a062(%rip), %rsi     # 0xe53f0
leaq 0x9d71e(%rip), %rdx     # 0x108ab3
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x79c7f(%rip), %rsi     # 0xe5034
leaq 0x9d727(%rip), %rdx     # 0x108ae3
movq %rbx, %rdi
movl $0xf4b, %ecx            # imm = 0xF4B
jmp 0x6b42e
movsd 0xfa0(%rbx), %xmm0
pushq $0x2
popq %rsi
xorl %ebp, %ebp
leaq 0xc(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %r8
callq 0x585e8
cmpl $0x1, %eax
jne 0x6b43d
addq $0xd1c, %r14            # imm = 0xD1C
leaq 0x79ff8(%rip), %rsi     # 0xe53f0
leaq 0x9d70d(%rip), %rdx     # 0x108b0c
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1064, %rbx           # imm = 0x1064
leaq 0x79c15(%rip), %rsi     # 0xe5034
leaq 0x9d6bd(%rip), %rdx     # 0x108ae3
movq %rbx, %rdi
movl $0xf4f, %ecx            # imm = 0xF4F
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
jmp 0x6b46e
movslq 0x420(%r14), %rax
movsd (%r15,%rax,8), %xmm0
movsd %xmm0, 0xfb8(%rbx)
movsd 0xfa0(%rbx), %xmm1
addsd 0x79dfe(%rip), %xmm1    # 0xe5260
divsd %xmm1, %xmm0
movsd %xmm0, 0xfb0(%rbx)
movl %ebp, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r14
popq %r15
popq %rbp
retq