// File: /workspace/github_c_makefile_star2_O1/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 0x26363(%rip), %xmm0    # 0xf5be8
callq 0x8170
divsd 0x26356(%rip), %xmm0    # 0xf5be8
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 0x19cfd
cmpl $0x1, %eax
jne 0xcf911
leaq 0x21b22(%rip), %rsi     # 0xf13f0
leaq 0x5b61b(%rip), %rdx     # 0x12aef0
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x21746(%rip), %rsi     # 0xf1034
leaq 0x5b65d(%rip), %rdx     # 0x12af52
movq %r12, %rdi
movl $0x71f, %ecx            # imm = 0x71F
movq %rbx, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
jmp 0xcfadc
movsd 0x30(%rsp), %xmm0
movslq 0x14(%rsp), %rax
movsd 0x28(%rsp), %xmm1
movq 0xc80(%r15), %rcx
movq 0xc88(%r15), %rdx
movsd 0x8(%rcx,%rax,8), %xmm2
mulsd %xmm1, %xmm2
movsd (%rcx,%rax,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(%rdx,%rax,8), %xmm4
mulsd %xmm3, %xmm4
movsd (%rdx,%rax,8), %xmm7
mulsd %xmm2, %xmm7
addsd %xmm4, %xmm7
movsd 0x38(%rsp), %xmm4
mulsd %xmm4, %xmm7
mulsd %xmm4, %xmm7
movsd 0x22cdc(%rip), %xmm5    # 0xf2670
divsd %xmm5, %xmm7
addsd %xmm6, %xmm7
movsd %xmm7, (%rbp)
movq 0xc90(%r15), %rcx
movq 0xc98(%r15), %rdx
movsd 0x8(%rcx,%rax,8), %xmm6
mulsd %xmm1, %xmm6
movsd (%rcx,%rax,8), %xmm7
mulsd %xmm0, %xmm7
addsd %xmm6, %xmm7
movsd 0x8(%rdx,%rax,8), %xmm6
mulsd %xmm3, %xmm6
movsd (%rdx,%rax,8), %xmm8
mulsd %xmm2, %xmm8
addsd %xmm6, %xmm8
mulsd %xmm4, %xmm8
mulsd %xmm4, %xmm8
divsd %xmm5, %xmm8
addsd %xmm7, %xmm8
movq 0x18(%rsp), %rcx
movsd %xmm8, (%rcx)
movq 0xca0(%r15), %rcx
movq 0xca8(%r15), %rdx
movsd 0x8(%rcx,%rax,8), %xmm6
mulsd %xmm1, %xmm6
movsd (%rcx,%rax,8), %xmm7
mulsd %xmm0, %xmm7
addsd %xmm6, %xmm7
movsd 0x8(%rdx,%rax,8), %xmm6
mulsd %xmm3, %xmm6
movsd (%rdx,%rax,8), %xmm8
mulsd %xmm2, %xmm8
addsd %xmm6, %xmm8
mulsd %xmm4, %xmm8
mulsd %xmm4, %xmm8
divsd %xmm5, %xmm8
addsd %xmm7, %xmm8
movq 0x20(%rsp), %rcx
movsd %xmm8, (%rcx)
movslq 0x4(%r15), %rcx
testq %rcx, %rcx
jle 0xcfad8
movq %rax, %rdx
incq %rdx
movq 0xcb0(%r15), %rsi
movq 0xcb8(%r15), %rdi
movslq 0xc78(%r15), %r8
xorl %r9d, %r9d
movsd (%rsi,%rdx,8), %xmm6
movsd (%rdi,%rdx,8), %xmm7
mulsd %xmm3, %xmm7
movsd -0x8(%rdi,%rdx,8), %xmm8
mulsd %xmm2, %xmm8
mulsd %xmm1, %xmm6
addsd %xmm7, %xmm8
movsd -0x8(%rsi,%rdx,8), %xmm7
mulsd %xmm0, %xmm7
addsd %xmm6, %xmm7
mulsd %xmm4, %xmm8
mulsd %xmm4, %xmm8
divsd %xmm5, %xmm8
addsd %xmm7, %xmm8
movsd %xmm8, (%r14,%r9,8)
incq %r9
addq %r8, %rdx
cmpq %r9, %rcx
jne 0xcfa82
movl %eax, (%rbx)
xorl %eax, %eax
addq $0x848, %rsp            # imm = 0x848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq