// File: /workspace/github_c_makefile_star2_O2/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
movq %rsi, %r12
movq %rdi, 0x18(%rsp)
movl 0x8b0(%rsp), %r13d
movl 0x8a0(%rsp), %eax
movl %ecx, 0x4(%rsp)
movslq %ecx, %rbp
movl %r8d, 0xc(%rsp)
movslq %r8d, %rcx
movq %rcx, 0x28(%rsp)
movslq %r9d, %rcx
movq %rcx, 0x20(%rsp)
movslq %eax, %r14
xorl %ebx, %ebx
testl %edx, %edx
movl %edx, 0x8(%rsp)
cmovgl %edx, %ebx
shlq $0x3, %rbp
movapd %xmm0, 0x40(%rsp)
movhpd 0x4bcda(%rip), %xmm0    # xmm0 = xmm0[0],mem[0]
movapd %xmm0, 0x30(%rsp)
movq %rsi, 0x10(%rsp)
subq $0x1, %rbx
jb 0xd68c0
movl %eax, %r15d
movq 0x28(%rsp), %rax
movsd (%r12,%rax,8), %xmm2
movapd %xmm2, %xmm0
unpcklpd %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
movapd 0x40(%rsp), %xmm1
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
movq 0x20(%rsp), %rax
movhpd (%r12,%rax,8), %xmm2    # xmm2 = xmm2[0],mem[0]
mulpd %xmm0, %xmm2
mulpd %xmm1, %xmm2
mulpd 0x30(%rsp), %xmm2
movapd %xmm2, 0x50(%rsp)
movapd %xmm2, %xmm0
xorpd 0xe9da(%rip), %xmm0     # 0xe5230
callq 0x86a0
movapd 0x50(%rsp), %xmm3
movapd 0x2de07(%rip), %xmm1    # 0x104670
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
cmpl $0x1, %r13d
je 0xd6885
movapd %xmm0, %xmm1
jmp 0xd6889
mulsd %xmm0, %xmm1
movapd %xmm3, %xmm0
mulsd 0x11b63(%rip), %xmm0    # 0xe83f8
cmpl $0x2, %r13d
movl %r15d, %eax
jne 0xd68b2
movsd 0xe9ba(%rip), %xmm2     # 0xe5260
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, (%r12,%r14,8)
addq %rbp, %r12
jmp 0xd6801
movq 0x18(%rsp), %rbx
addq $0x192, %rbx            # imm = 0x192
movq 0x10(%rsp), %r13
movq %r13, %rdi
movl 0x4(%rsp), %r15d
movl %r15d, %esi
movl 0x8(%rsp), %r14d
movl %r14d, %edx
movl 0xc(%rsp), %ebp
movl %ebp, %ecx
movl %eax, %r8d
movl 0x8a8(%rsp), %r9d
pushq %rbx
pushq $0x0
movl %eax, %r12d
callq 0x11b09
popq %rcx
popq %rdx
cmpl $0x1, %eax
jne 0xd693f
leaq 0xeae2(%rip), %rsi      # 0xe53f0
leaq 0x4c19f(%rip), %rdx     # 0x122ab4
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xe706(%rip), %rsi      # 0xe5034
leaq 0x4c1f7(%rip), %rdx     # 0x122b2c
movq %rbx, %rdi
movl $0x217, %ecx            # imm = 0x217
jmp 0xd69a3
movq %r13, %rdi
movl %r15d, %esi
movl %r14d, %edx
movl %ebp, %ecx
movl %r12d, %r8d
movl 0x8a8(%rsp), %r9d
pushq %rbx
pushq 0x8c0(%rsp)
callq 0x155e5
popq %rcx
popq %rdx
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0xd69b0
leaq 0xea7c(%rip), %rsi      # 0xe53f0
leaq 0x4c1c3(%rip), %rdx     # 0x122b3e
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xe6a0(%rip), %rsi      # 0xe5034
leaq 0x4c191(%rip), %rdx     # 0x122b2c
movq %rbx, %rdi
movl $0x223, %ecx            # imm = 0x223
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x868, %rsp            # imm = 0x868
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop