// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_limber_interpolate
int transfer_limber_interpolate(
                                struct transfer * ptr,
                                double * tau0_minus_tau,
                                double * sources,
                                int tau_size,
                                double tau0_minus_tau_limber,
                                double * S
                                ){

  int index_tau;
  double dS,ddS;

  /** - find  bracketing indices.
      index_tau must be at least 1 (so that index_tau-1 is at least 0)
      and at most tau_size-2 (so that index_tau+1 is at most tau_size-1).
  */
  index_tau=1;
  while ((tau0_minus_tau[index_tau] > tau0_minus_tau_limber) && (index_tau<tau_size-2))
    index_tau++;

  /** - interpolate by fitting a polynomial of order two; get source
      and its first two derivatives. Note that we are not
      interpolating S, but the product S*(tau0-tau). Indeed this
      product is regular in tau=tau0, while S alone diverges for
      lensing. */

  /* the case where the last of the three point is the edge (tau0=tau) must be treated separately, see below */
  if (index_tau < tau_size-2) {

    class_call(array_interpolate_parabola(tau0_minus_tau[index_tau-1],
                                          tau0_minus_tau[index_tau],
                                          tau0_minus_tau[index_tau+1],
                                          tau0_minus_tau_limber,
                                          sources[index_tau-1]*tau0_minus_tau[index_tau-1],
                                          sources[index_tau]*tau0_minus_tau[index_tau],
                                          sources[index_tau+1]*tau0_minus_tau[index_tau+1],
                                          S,
                                          &dS,
                                          &ddS,
                                          ptr->error_message),
               ptr->error_message,
               ptr->error_message);

  }

  /* in this case, we have stored a zero for sources[index_k*tau_size+index_tau+1]. But we can use in very good approximation the fact that S*(tau0-tau) is constant near tau=tau0 and replace sources[index_k*tau_size+index_tau+1]*tau0_minus_tau[index_tau+1] by sources[index_k*tau_size+index_tau]*tau0_minus_tau[index_tau] */
  else {

    class_call(array_interpolate_parabola(tau0_minus_tau[index_tau-1],
                                          tau0_minus_tau[index_tau],
                                          tau0_minus_tau[index_tau+1],
                                          tau0_minus_tau_limber,
                                          sources[index_tau-1]*tau0_minus_tau[index_tau-1],
                                          sources[index_tau]*tau0_minus_tau[index_tau],
                                          sources[index_tau]*tau0_minus_tau[index_tau],
                                          S,
                                          &dS,
                                          &ddS,
                                          ptr->error_message),
               ptr->error_message,
               ptr->error_message);
  }

  return _SUCCESS_;

}

// Assembly:
pushq %r14
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movapd %xmm0, %xmm3
movq %rdi, %rbx
addl $-0x2, %ecx
movslq %ecx, %rcx
pushq $0x1
popq %rax
movq %rax, %rdi
movsd (%rsi,%rax,8), %xmm1
incq %rax
ucomisd %xmm3, %xmm1
jbe 0xaada2
cmpq %rcx, %rdi
jl 0xaad8c
movsd -0x10(%rsi,%rax,8), %xmm0
cmpq %rcx, %rdi
jge 0xaae2a
movsd (%rsi,%rax,8), %xmm2
movsd -0x10(%rdx,%rax,8), %xmm4
mulsd %xmm0, %xmm4
movsd -0x8(%rdx,%rax,8), %xmm5
mulsd %xmm1, %xmm5
movsd (%rdx,%rax,8), %xmm6
mulsd %xmm2, %xmm6
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
movq %r8, %rdi
movq %rbx, %rcx
callq 0x18aef
cmpl $0x1, %eax
jne 0xaaeab
leaq 0x3a5f7(%rip), %rsi     # 0xe53f0
leaq 0x6c1b0(%rip), %rdx     # 0x116fb0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x3a21b(%rip), %rsi     # 0xe5034
leaq 0x6c2cb(%rip), %rdx     # 0x1170eb
movq %rbx, %rdi
movl $0xedc, %ecx            # imm = 0xEDC
jmp 0xaae9c
movsd (%rsi,%rax,8), %xmm2
movsd -0x10(%rdx,%rax,8), %xmm4
mulsd %xmm0, %xmm4
movsd -0x8(%rdx,%rax,8), %xmm5
mulsd %xmm1, %xmm5
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x8(%rsp), %rsi
movq %rsp, %rdx
movapd %xmm5, %xmm6
movq %r8, %rdi
movq %rbx, %rcx
callq 0x18aef
cmpl $0x1, %eax
jne 0xaaeab
leaq 0x3a583(%rip), %rsi     # 0xe53f0
leaq 0x6c293(%rip), %rdx     # 0x117107
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x3a1a7(%rip), %rsi     # 0xe5034
leaq 0x6c257(%rip), %rdx     # 0x1170eb
movq %rbx, %rdi
movl $0xeef, %ecx            # imm = 0xEEF
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
jmp 0xaaead
xorl %eax, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r14
retq