// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_interpolate_sources
int transfer_interpolate_sources(
                                 struct perturbations * ppt,
                                 struct transfer * ptr,
                                 double k,
                                 int index_md,
                                 int index_ic,
                                 int index_type,
                                 double * pert_source,       /* array with argument pert_source[index_tau*ppt->k_size[index_md]+index_k] (must be allocated) */
                                 double * pert_source_spline, /* array with argument pert_source_spline[index_tau*ppt->k_size[index_md]+index_k] (must be allocated) */
                                 double * interpolated_sources /* array with argument interpolated_sources[index_tau] (must be allocated) */
                                 ) {

  /** Summary: */

  /** - define local variables */

  /* index running on k values in the original source array */
  int index_k;

  /* index running on time */
  int index_tau;

  /* variables used for spline interpolation algorithm */
  double h, a, b;

  /** - interpolate at each k value using the usual
      spline interpolation algorithm. */

  index_k = 0;
  h = ppt->k[index_md][index_k+1] - ppt->k[index_md][index_k];

  while (((index_k+1) < ppt->k_size[index_md]) &&
         (ppt->k[index_md][index_k+1] < k)) {
    index_k++;
    h = ppt->k[index_md][index_k+1] - ppt->k[index_md][index_k];
  }

  class_test(h==0.,
             ptr->error_message,
             "stop to avoid division by zero");

  b = (k - ppt->k[index_md][index_k])/h;
  a = 1.-b;

  for (index_tau = 0; index_tau < ppt->tau_size; index_tau++) {

    interpolated_sources[index_tau] =
      a * pert_source[index_tau*ppt->k_size[index_md]+index_k]
      + b * pert_source[index_tau*ppt->k_size[index_md]+index_k+1]
      + ((a*a*a-a) * pert_source_spline[index_tau*ppt->k_size[index_md]+index_k]
         +(b*b*b-b) * pert_source_spline[index_tau*ppt->k_size[index_md]+index_k+1])*h*h/6.0;

  }

  return _SUCCESS_;

}

// Assembly:
subq $0x1068, %rsp           # imm = 0x1068
movq 0x1078(%rsp), %rax
movq 0x1070(%rsp), %rax
movq %rdi, 0x1058(%rsp)
movq %rsi, 0x1050(%rsp)
movsd %xmm0, 0x1048(%rsp)
movl %edx, 0x1044(%rsp)
movl %ecx, 0x1040(%rsp)
movl %r8d, 0x103c(%rsp)
movq %r9, 0x1030(%rsp)
movl $0x0, 0x102c(%rsp)
movq 0x1058(%rsp), %rax
movq 0x9d0(%rax), %rax
movslq 0x1044(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x102c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1058(%rsp), %rax
movq 0x9d0(%rax), %rax
movslq 0x1044(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x102c(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x1020(%rsp)
movl 0x102c(%rsp), %ecx
addl $0x1, %ecx
movq 0x1058(%rsp), %rax
movq 0x9c8(%rax), %rdx
movslq 0x1044(%rsp), %rsi
xorl %eax, %eax
cmpl (%rdx,%rsi,4), %ecx
movb %al, 0xf(%rsp)
jge 0x13e1a4
movq 0x1058(%rsp), %rax
movq 0x9d0(%rax), %rax
movslq 0x1044(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x102c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x1048(%rsp), %xmm0
ucomisd %xmm1, %xmm0
seta %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x13e1ae
jmp 0x13e222
movl 0x102c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x102c(%rsp)
movq 0x1058(%rsp), %rax
movq 0x9d0(%rax), %rax
movslq 0x1044(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x102c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1058(%rsp), %rax
movq 0x9d0(%rax), %rax
movslq 0x1044(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x102c(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x1020(%rsp)
jmp 0x13e137
movsd 0x1020(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x13e2ac
jp 0x13e2ac
leaq 0x810(%rsp), %rdi
leaq 0x95adf(%rip), %rsi     # 0x1d3d24
movb $0x0, %al
callq 0x5b9c0
leaq 0x10(%rsp), %rdi
leaq 0x810(%rsp), %rcx
leaq 0x93e22(%rip), %rsi     # 0x1d2082
leaq 0xc57d0(%rip), %rdx     # 0x203a37
movb $0x0, %al
callq 0x5b9c0
movq 0x1050(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x10(%rsp), %r8
leaq 0x93dab(%rip), %rsi     # 0x1d2034
leaq 0xc57ad(%rip), %rdx     # 0x203a3d
movl $0x8d9, %ecx            # imm = 0x8D9
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1064(%rsp)
jmp 0x13e519
movsd 0x1048(%rsp), %xmm0
movq 0x1058(%rsp), %rax
movq 0x9d0(%rax), %rax
movslq 0x1044(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x102c(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
divsd 0x1020(%rsp), %xmm0
movsd %xmm0, 0x1010(%rsp)
movsd 0x93f51(%rip), %xmm0    # 0x1d2248
subsd 0x1010(%rsp), %xmm0
movsd %xmm0, 0x1018(%rsp)
movl $0x0, 0x1028(%rsp)
movl 0x1028(%rsp), %eax
movq 0x1058(%rsp), %rcx
cmpl 0x9f8(%rcx), %eax
jge 0x13e50e
movsd 0x1018(%rsp), %xmm0
movq 0x1030(%rsp), %rax
movl 0x1028(%rsp), %ecx
movq 0x1058(%rsp), %rdx
movq 0x9c8(%rdx), %rdx
movslq 0x1044(%rsp), %rsi
imull (%rdx,%rsi,4), %ecx
addl 0x102c(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x1010(%rsp), %xmm1
movq 0x1030(%rsp), %rax
movl 0x1028(%rsp), %ecx
movq 0x1058(%rsp), %rdx
movq 0x9c8(%rdx), %rdx
movslq 0x1044(%rsp), %rsi
imull (%rdx,%rsi,4), %ecx
addl 0x102c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x1018(%rsp), %xmm1
mulsd 0x1018(%rsp), %xmm1
movsd 0x1018(%rsp), %xmm3
movsd 0x1018(%rsp), %xmm2
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movq 0x1070(%rsp), %rax
movl 0x1028(%rsp), %ecx
movq 0x1058(%rsp), %rdx
movq 0x9c8(%rdx), %rdx
movslq 0x1044(%rsp), %rsi
imull (%rdx,%rsi,4), %ecx
addl 0x102c(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm3
movsd 0x1010(%rsp), %xmm2
mulsd 0x1010(%rsp), %xmm2
movsd 0x1010(%rsp), %xmm5
movsd 0x1010(%rsp), %xmm4
movq %xmm4, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm4
mulsd %xmm5, %xmm2
addsd %xmm4, %xmm2
movq 0x1070(%rsp), %rax
movl 0x1028(%rsp), %ecx
movq 0x1058(%rsp), %rdx
movq 0x9c8(%rdx), %rdx
movslq 0x1044(%rsp), %rsi
imull (%rdx,%rsi,4), %ecx
addl 0x102c(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd 0x1020(%rsp), %xmm1
mulsd 0x1020(%rsp), %xmm1
movsd 0x951ad(%rip), %xmm2    # 0x1d3688
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq 0x1078(%rsp), %rax
movslq 0x1028(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x1028(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1028(%rsp)
jmp 0x13e314
movl $0x0, 0x1064(%rsp)
movl 0x1064(%rsp), %eax
addq $0x1068, %rsp           # imm = 0x1068
retq
nopl (%rax,%rax)