// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/distortions.c
// Function: distortions_interpolate_sd_data
int distortions_interpolate_sd_data(struct distortions* psd,
                                    double nu,
                                    double * G_T,
                                    double * Y_SZ,
                                    double * M_mu,
                                    double * S,
                                    int * index){

  /** Define local variables */
  int last_index = *index;
  int index_k;
  double h,a,b;
  double nu_round;

  /** Find z position */
  nu_round = round(nu*pow(10.,3))/pow(10.,3); // The rounding is necessary for the interpolation with the external file
  class_call(array_spline_hunt(psd->PCA_nu,
                               psd->PCA_Nnu,
                               nu_round,
                               &last_index,
                               &h,&a,&b,
                               psd->error_message),
             psd->error_message,
             psd->error_message);

  /** Evaluate corresponding values for the branching ratios */
  *G_T = array_spline_eval(psd->PCA_G_T,
                           psd->ddPCA_G_T,
                           last_index,
                           last_index+1,
                           h,a,b);
  *Y_SZ = array_spline_eval(psd->PCA_Y_SZ,
                            psd->ddPCA_Y_SZ,
                            last_index,
                            last_index+1,
                            h,a,b);
  *M_mu = array_spline_eval(psd->PCA_M_mu,
                            psd->ddPCA_M_mu,
                            last_index,
                            last_index+1,
                            h,a,b);

  for (index_k=0; index_k<psd->sd_PCA_size; ++index_k){
    S[index_k] = array_spline_eval(psd->S_vec+index_k*psd->PCA_Nnu,
                                   psd->ddS_vec+index_k*psd->PCA_Nnu,
                                   last_index,
                                   last_index+1,
                                   h,a,b);
  }

  *index = last_index;

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x848, %rsp            # imm = 0x848
movq %r9, %rbx
movq %r8, %r14
movq %rcx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %rbp
movq %rdi, %r15
movl (%r9), %eax
leaq 0x14(%rsp), %r13
movl %eax, (%r13)
mulsd 0x2513b(%rip), %xmm0    # 0xe9ad8
callq 0x8180
divsd 0x2512e(%rip), %xmm0    # 0xe9ad8
movq 0xc70(%r15), %rdi
movl 0xc78(%r15), %esi
leaq 0x1602(%r15), %r12
movq %r12, (%rsp)
leaq 0x38(%rsp), %rcx
leaq 0x30(%rsp), %r8
leaq 0x28(%rsp), %r9
movq %r13, %rdx
callq 0x17d10
cmpl $0x1, %eax
jne 0xc4a27
leaq 0x20a0a(%rip), %rsi     # 0xe53f0
leaq 0x5a3db(%rip), %rdx     # 0x11edc8
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x2062e(%rip), %rsi     # 0xe5034
leaq 0x5a41d(%rip), %rdx     # 0x11ee2a
movq %r12, %rdi
movl $0x71f, %ecx            # imm = 0x71F
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
jmp 0xc4bf6
movsd 0x30(%rsp), %xmm0
movl 0x14(%rsp), %eax
movslq %eax, %rcx
movsd 0x28(%rsp), %xmm1
movq 0xc80(%r15), %rdx
movq 0xc88(%r15), %rsi
movsd 0x8(%rdx,%rcx,8), %xmm2
mulsd %xmm1, %xmm2
movsd (%rdx,%rcx,8), %xmm6
mulsd %xmm0, %xmm6
addsd %xmm2, %xmm6
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm2
subsd %xmm0, %xmm2
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm3
subsd %xmm1, %xmm3
movsd 0x8(%rsi,%rcx,8), %xmm4
mulsd %xmm3, %xmm4
movsd (%rsi,%rcx,8), %xmm7
mulsd %xmm2, %xmm7
addsd %xmm4, %xmm7
movsd 0x38(%rsp), %xmm4
mulsd %xmm4, %xmm7
mulsd %xmm4, %xmm7
movsd 0x21ba4(%rip), %xmm5    # 0xe6650
divsd %xmm5, %xmm7
addsd %xmm6, %xmm7
movsd %xmm7, (%rbp)
movq 0xc90(%r15), %rdx
movq 0xc98(%r15), %rsi
movsd 0x8(%rdx,%rcx,8), %xmm6
mulsd %xmm1, %xmm6
movsd (%rdx,%rcx,8), %xmm7
mulsd %xmm0, %xmm7
addsd %xmm6, %xmm7
movsd 0x8(%rsi,%rcx,8), %xmm6
mulsd %xmm3, %xmm6
movsd (%rsi,%rcx,8), %xmm8
mulsd %xmm2, %xmm8
addsd %xmm6, %xmm8
mulsd %xmm4, %xmm8
mulsd %xmm4, %xmm8
divsd %xmm5, %xmm8
addsd %xmm7, %xmm8
movq 0x18(%rsp), %rdx
movsd %xmm8, (%rdx)
movq 0xca0(%r15), %rdx
movq 0xca8(%r15), %rsi
movsd 0x8(%rdx,%rcx,8), %xmm6
mulsd %xmm1, %xmm6
movsd (%rdx,%rcx,8), %xmm7
mulsd %xmm0, %xmm7
addsd %xmm6, %xmm7
movsd 0x8(%rsi,%rcx,8), %xmm6
mulsd %xmm3, %xmm6
movsd (%rsi,%rcx,8), %xmm8
mulsd %xmm2, %xmm8
addsd %xmm6, %xmm8
mulsd %xmm4, %xmm8
mulsd %xmm4, %xmm8
divsd %xmm5, %xmm8
addsd %xmm7, %xmm8
movq 0x20(%rsp), %rdx
movsd %xmm8, (%rdx)
movslq 0x4(%r15), %rdx
xorl %esi, %esi
cmpq %rdx, %rsi
jge 0xc4bf2
movslq 0xc78(%r15), %rdi
movslq %esi, %r8
imulq %rdi, %r8
shlq $0x3, %r8
movq 0xcb0(%r15), %rdi
addq %r8, %rdi
movsd 0x8(%rdi,%rcx,8), %xmm6
mulsd %xmm1, %xmm6
movsd (%rdi,%rcx,8), %xmm7
mulsd %xmm0, %xmm7
addq 0xcb8(%r15), %r8
addsd %xmm6, %xmm7
movsd 0x8(%r8,%rcx,8), %xmm6
mulsd %xmm3, %xmm6
movsd (%r8,%rcx,8), %xmm8
mulsd %xmm2, %xmm8
addsd %xmm6, %xmm8
mulsd %xmm4, %xmm8
mulsd %xmm4, %xmm8
divsd %xmm5, %xmm8
addsd %xmm7, %xmm8
movsd %xmm8, (%r14,%rsi,8)
incq %rsi
jmp 0xc4b79
movl %eax, (%rbx)
xorl %eax, %eax
addq $0x848, %rsp            # imm = 0x848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq