// File: /workspace/github_c_makefile_star2_O3/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 0xdebe4
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 0x4cb3b(%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 0xf6b8(%rip), %xmm0     # 0xee230
callq 0x8670
movapd 0x50(%rsp), %xmm3
movapd 0x2ec45(%rip), %xmm1    # 0x10d7d0
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 0xdeba7
movapd %xmm0, %xmm1
jmp 0xdebab
mulsd %xmm0, %xmm1
movapd %xmm3, %xmm0
mulsd 0x12881(%rip), %xmm0    # 0xf1438
cmpl $0x2, %r12d
jne 0xdebd1
movsd 0xf69b(%rip), %xmm2     # 0xee260
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, (%r13,%r14,8)
addq %rbp, %r13
decq %rbx
jne 0xdeb2e
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 0x1381e
addq $0x10, %rsp
cmpl $0x1, %eax
jne 0xdec6d
leaq 0xf7b4(%rip), %rsi      # 0xee3f0
leaq 0x4d001(%rip), %rdx     # 0x12bc44
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xf3d8(%rip), %rsi      # 0xee034
leaq 0x4d059(%rip), %rdx     # 0x12bcbc
movq %rbx, %rdi
movl $0x217, %ecx            # imm = 0x217
jmp 0xdecd0
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 0x1758f
addq $0x10, %rsp
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0xdecdf
leaq 0xf74f(%rip), %rsi      # 0xee3f0
leaq 0x4d026(%rip), %rdx     # 0x12bcce
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xf373(%rip), %rsi      # 0xee034
leaq 0x4cff4(%rip), %rdx     # 0x12bcbc
movq %rbx, %rdi
movl $0x223, %ecx            # imm = 0x223
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x868, %rsp            # imm = 0x868
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)