// File: /workspace/github_c_makefile_star2_O1/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
movl $0x1, %eax
movq %rax, %rdi
movsd (%rsi,%rax,8), %xmm1
incq %rax
ucomisd %xmm3, %xmm1
jbe 0xb364b
cmpq %rcx, %rdi
jl 0xb3635
cmpq %rcx, %rdi
jge 0xb36d7
movsd -0x10(%rsi,%rax,8), %xmm0
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 0x1abd0
cmpl $0x1, %eax
jne 0xb3760
leaq 0x3dd4a(%rip), %rsi     # 0xf13f0
leaq 0x6fa33(%rip), %rdx     # 0x1230e0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x3d96e(%rip), %rsi     # 0xf1034
leaq 0x6fb4e(%rip), %rdx     # 0x12321b
movq %rbx, %rdi
movl $0xedc, %ecx            # imm = 0xEDC
jmp 0xb374f
movsd -0x10(%rsi,%rax,8), %xmm0
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 0x1abd0
cmpl $0x1, %eax
jne 0xb3760
leaq 0x3dcd0(%rip), %rsi     # 0xf13f0
leaq 0x6fb10(%rip), %rdx     # 0x123237
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x3d8f4(%rip), %rsi     # 0xf1034
leaq 0x6fad4(%rip), %rdx     # 0x12321b
movq %rbx, %rdi
movl $0xeef, %ecx            # imm = 0xEEF
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
jmp 0xb3762
xorl %eax, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r14
retq