// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../external/Halofit/halofit.c
// Function: halofit_integrate
int halofit_integrate(
                      struct fourier *pfo,
                      double *integrand_array,
                      int integrand_size,
                      int ia_size,
                      int index_ia_k,
                      int index_ia_pk,
                      int index_ia_sum,
                      int index_ia_ddsum,
                      double R,
                      enum halofit_integral_type type,
                      double *sum
                      ) {

  double k,pk,x2,integrand;
  int index_k;
  double anorm = 1./(2*pow(_PI_,2));

  for (index_k=0; index_k < integrand_size; index_k++) {
    k = integrand_array[index_k*ia_size + index_ia_k];
    pk = integrand_array[index_k*ia_size + index_ia_pk];
    x2 = k*k*R*R;

    integrand = pk*k*k*anorm*exp(-x2);
    if (type == halofit_integral_two) integrand *= 2.*x2;
    if (type == halofit_integral_three) integrand *= 4.*x2*(1.-x2);

    integrand_array[index_k*ia_size + index_ia_sum] = integrand;
  }

  /* fill in second derivatives */
  class_call(array_spline(integrand_array,
                          ia_size,
                          integrand_size,
                          index_ia_k,
                          index_ia_sum,
                          index_ia_ddsum,
                          _SPLINE_NATURAL_,
                          pfo->error_message),
             pfo->error_message,
             pfo->error_message);

  /* integrate */
  class_call(array_integrate_all_spline(integrand_array,
                                        ia_size,
                                        integrand_size,
                                        index_ia_k,
                                        index_ia_sum,
                                        index_ia_ddsum,
                                        sum,
                                        pfo->error_message),
             pfo->error_message,
             pfo->error_message);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x868, %rsp            # imm = 0x868
movapd %xmm0, 0x30(%rsp)
movl %r8d, 0xc(%rsp)
movl %ecx, 0x4(%rsp)
movq %rsi, %r15
movq %rdi, 0x18(%rsp)
movl %edx, 0x8(%rsp)
testl %edx, %edx
jle 0xe20ff
movl 0x8b0(%rsp), %r12d
movslq 0x4(%rsp), %rbp
movslq 0xc(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movslq %r9d, %rcx
movq %rcx, 0x20(%rsp)
movslq 0x8a0(%rsp), %r14
movl 0x8(%rsp), %ebx
shlq $0x3, %rbp
movapd 0x30(%rsp), %xmm0
movhpd 0x4c5f0(%rip), %xmm0    # xmm0 = xmm0[0],mem[0]
movapd %xmm0, 0x40(%rsp)
movq %r15, %r13
movq 0x28(%rsp), %rcx
movsd (%r13,%rcx,8), %xmm2
movapd %xmm2, %xmm0
unpcklpd %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
movapd 0x30(%rsp), %xmm1
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
movq 0x20(%rsp), %rcx
movhpd (%r13,%rcx,8), %xmm2    # xmm2 = xmm2[0],mem[0]
mulpd %xmm0, %xmm2
mulpd %xmm1, %xmm2
mulpd 0x40(%rsp), %xmm2
movapd %xmm2, 0x50(%rsp)
movapd %xmm2, %xmm0
xorpd 0xf19d(%rip), %xmm0     # 0xf1230
callq 0x8670
movapd 0x50(%rsp), %xmm3
movapd 0x3337a(%rip), %xmm1    # 0x115420
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
cmpl $0x1, %r12d
je 0xe20c2
movapd %xmm0, %xmm1
jmp 0xe20c6
mulsd %xmm0, %xmm1
movapd %xmm3, %xmm0
mulsd 0x12356(%rip), %xmm0    # 0xf4428
cmpl $0x2, %r12d
jne 0xe20ec
movsd 0xf180(%rip), %xmm2     # 0xf1260
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, (%r13,%r14,8)
addq %rbp, %r13
decq %rbx
jne 0xe2049
movq %r15, 0x10(%rsp)
movq 0x18(%rsp), %rbx
addq $0x192, %rbx            # imm = 0x192
movq %r15, %rdi
movl 0x4(%rsp), %r15d
movl %r15d, %esi
movl 0x8(%rsp), %r14d
movl %r14d, %edx
movl 0xc(%rsp), %ebp
movl %ebp, %ecx
movl 0x8a0(%rsp), %r13d
movl %r13d, %r8d
movl 0x8a8(%rsp), %r12d
movl %r12d, %r9d
pushq %rbx
pushq $0x0
callq 0x136a5
addq $0x10, %rsp
cmpl $0x1, %eax
jne 0xe2188
leaq 0xf299(%rip), %rsi      # 0xf13f0
leaq 0x4cab6(%rip), %rdx     # 0x12ec14
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xeebd(%rip), %rsi      # 0xf1034
leaq 0x4cb0e(%rip), %rdx     # 0x12ec8c
movq %rbx, %rdi
movl $0x217, %ecx            # imm = 0x217
jmp 0xe21eb
movq 0x10(%rsp), %rdi
movl %r15d, %esi
movl %r14d, %edx
movl %ebp, %ecx
movl %r13d, %r8d
movl %r12d, %r9d
pushq %rbx
pushq 0x8c0(%rsp)
callq 0x17400
addq $0x10, %rsp
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0xe21fa
leaq 0xf234(%rip), %rsi      # 0xf13f0
leaq 0x4cadb(%rip), %rdx     # 0x12ec9e
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xee58(%rip), %rsi      # 0xf1034
leaq 0x4caa9(%rip), %rdx     # 0x12ec8c
movq %rbx, %rdi
movl $0x223, %ecx            # imm = 0x223
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x868, %rsp            # imm = 0x868
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq