// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../external/HMcode/hmcode.c
// Function: hmcode_nowiggle
int hmcode_nowiggle(
                    struct fourier *pfo,
                    double * lnpk_l,
                    double * ddlnpk_l,
                    int nw_size,
                    double * ln_k_nw,
                    double * pk_nw,
                    double * pk_w
                    ) {

  // JL: The following parameters define the smoothing algorithm.
  //     In principle, they should be precision parameters rather than hard-coded.
  //     However, the goal is to match exactly other versions of HMcode, so we leave these fixed.
  double wiggle_sigma = 0.25;
  double kmin_wiggle = 5e-3; // Mpc/h
  double logkmin_wiggle = log(kmin_wiggle);
  double kmax_wiggle = 5.; // Mpc/h
  double logkmax_wiggle = log(kmax_wiggle);

  int i;
  int last_index = 0;
  double * lnpk_lin;
  double * lnpk_analytic_nowiggle;
  double * pk_ratio;

  class_alloc(lnpk_lin, nw_size*sizeof(double), pfo->error_message);
  class_alloc(lnpk_analytic_nowiggle, nw_size*sizeof(double), pfo->error_message);
  class_alloc(pk_ratio, nw_size*sizeof(double), pfo->error_message);

  for(i=0; i<nw_size; ++i){

    /* Define a new sampling in k-space, from logkmin_wiggle to
       logkmax_wiggle with nw_size steps */

    ln_k_nw[i] = logkmin_wiggle+i*(logkmax_wiggle-logkmin_wiggle)/(nw_size-1);

    /* Interpolate the linear spectrum to fill lnpk_lin */

    class_call(array_interpolate_spline(pfo->ln_k,
                                        pfo->k_size_extra,
                                        lnpk_l,
                                        ddlnpk_l,
                                        1,
                                        ln_k_nw[i],
                                        &last_index,
                                        &(lnpk_lin[i]),
                                        1,
                                        pfo->error_message),
               pfo->error_message,
               pfo->error_message);

    /* Interpolate the smooth analytic spectrum to populate
       lnpk_analytic_nowiggle. This spectrum is only used to reduce the
       dynamical range before smoothing. */

    class_call(array_interpolate_spline(pfo->ln_k,
                                        pfo->k_size_extra,
                                        pfo->ln_pk_l_an_extra,
                                        pfo->ddln_pk_l_an_extra,
                                        1,
                                        ln_k_nw[i],
                                        &last_index,
                                        &(lnpk_analytic_nowiggle[i]),
                                        1,
                                        pfo->error_message),
               pfo->error_message,
               pfo->error_message);

    /* Compute the ratio P_l / P_analytic_nowiggle */

    pk_ratio[i] = exp(lnpk_lin[i]-lnpk_analytic_nowiggle[i]);

  }

  /* Perform a Gaussian smoothing of this ratio, the result is stored in pk_nw */

  class_call(array_smooth_Gaussian(ln_k_nw,
                                   pk_ratio,
                                   pk_nw,
                                   nw_size,
                                   wiggle_sigma,
                                   pfo->error_message),
             pfo->error_message,
             pfo->error_message);

  /* Multiply the smoothed ratio by the previously used analytic
     approximation to get the actual nowiggle spectrum P_nowiggle, and
     compute the difference P_wiggle = P_l - P_nowiggle */

  for(i=0; i<nw_size; ++i){

    pk_nw[i] = pk_nw[i]*exp(lnpk_analytic_nowiggle[i]);
    pk_w[i] = exp(lnpk_lin[i])-pk_nw[i];
  }

  free(lnpk_lin);
  free(lnpk_analytic_nowiggle);
  free(pk_ratio);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x878, %rsp            # imm = 0x878
movq %r9, %r14
movq %r8, %r13
movq %rdx, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdi, %rbp
movl $0x0, 0x1c(%rsp)
movq %rcx, 0x20(%rsp)
movslq %ecx, %rbx
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x8460
testq %rax, %rax
je 0xe3f29
movq %rax, %r15
movq %rbx, %rdi
callq 0x8460
testq %rax, %rax
je 0xe3f67
movq %rax, %r12
movq %rbx, %rdi
callq 0x8460
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xe3fa5
movq 0x20(%rsp), %rcx
testl %ecx, %ecx
jle 0xe4002
movq %r13, 0x30(%rsp)
movq %r12, 0x28(%rsp)
movq %r14, 0x40(%rsp)
leal -0x1(%rcx), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0x192(%rbp), %r10
movl %ecx, %eax
movq %rax, 0x38(%rsp)
leaq (,%rax,8), %rax
movq %rax, 0x48(%rsp)
xorl %r14d, %r14d
leaq 0x1c(%rsp), %rbx
xorl %eax, %eax
movq %r15, 0x50(%rsp)
movl %eax, 0x10(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x48169(%rip), %xmm0    # 0x12bf00
divsd 0x58(%rsp), %xmm0
addsd 0x48163(%rip), %xmm0    # 0x12bf08
movq 0x30(%rsp), %r13
movsd %xmm0, (%r13,%r14)
movq 0x80(%rbp), %rdi
movl 0x104(%rbp), %esi
addq %r14, %r15
subq $0x8, %rsp
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rcx
movl $0x1, %r8d
movq %rbx, %r9
movq %r10, %r12
pushq %r10
pushq $0x1
pushq %r15
callq 0x18071
addq $0x20, %rsp
cmpl $0x1, %eax
je 0xe4085
movq 0x80(%rbp), %rdi
movl 0x104(%rbp), %esi
movq 0x118(%rbp), %rdx
movq %r13, %rax
movq %rbp, %r13
movq 0x120(%rbp), %rcx
movsd (%rax,%r14), %xmm0
movq 0x28(%rsp), %rax
movq %r12, %r10
leaq (%rax,%r14), %rbp
subq $0x8, %rsp
movl $0x1, %r8d
movq %rbx, %r12
movq %rbx, %r9
movq %r10, %rbx
pushq %r10
pushq $0x1
pushq %rbp
callq 0x18071
addq $0x20, %rsp
cmpl $0x1, %eax
je 0xe40c3
movsd (%r15), %xmm0
subsd (%rbp), %xmm0
callq 0x8670
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax,%r14)
movl 0x10(%rsp), %eax
incl %eax
addq $0x8, %r14
cmpq %r14, 0x48(%rsp)
movq 0x50(%rsp), %r15
movq %rbx, %r10
movq %r13, %rbp
movq 0x8b0(%rsp), %r13
movq %r12, %rbx
jne 0xe3d84
movsd 0xd6e3(%rip), %xmm0     # 0xf1580
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x40(%rsp), %r14
movq %r14, %rdx
movq 0x20(%rsp), %rbx
movl %ebx, %ecx
movq %r10, %r8
movq %r10, %r12
callq 0x1bacd
movq %r12, %rcx
cmpl $0x1, %eax
movq 0x28(%rsp), %r12
movq 0x38(%rsp), %rbp
je 0xe402c
testl %ebx, %ebx
jle 0xe4064
xorl %ebx, %ebx
movsd (%r14,%rbx,8), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r12,%rbx,8), %xmm0
callq 0x8670
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, (%r14,%rbx,8)
movsd (%r15,%rbx,8), %xmm0
callq 0x8670
subsd (%r14,%rbx,8), %xmm0
movsd %xmm0, (%r13,%rbx,8)
incq %rbx
cmpq %rbx, %rbp
jne 0xe3ee1
jmp 0xe4064
leaq 0xa0d4(%rip), %rsi      # 0xee004
leaq 0x49df3(%rip), %rdx     # 0x12dd2a
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbp            # imm = 0x192
leaq 0xa0de(%rip), %rsi      # 0xee034
leaq 0x49dd6(%rip), %rdx     # 0x12dd33
movq %rbp, %rdi
movl $0x853, %ecx            # imm = 0x853
jmp 0xe3fe1
leaq 0xa096(%rip), %rsi      # 0xee004
leaq 0x49dce(%rip), %rdx     # 0x12dd43
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbp            # imm = 0x192
leaq 0xa0a0(%rip), %rsi      # 0xee034
leaq 0x49d98(%rip), %rdx     # 0x12dd33
movq %rbp, %rdi
movl $0x854, %ecx            # imm = 0x854
jmp 0xe3fe1
leaq 0xa058(%rip), %rsi      # 0xee004
leaq 0x49da7(%rip), %rdx     # 0x12dd5a
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbp            # imm = 0x192
leaq 0xa062(%rip), %rsi      # 0xee034
leaq 0x49d5a(%rip), %rdx     # 0x12dd33
movq %rbp, %rdi
movl $0x855, %ecx            # imm = 0x855
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x878, %rsp            # imm = 0x878
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x192, %rbp            # imm = 0x192
movsd 0xd56f(%rip), %xmm0     # 0xf1580
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %r8
callq 0x1bacd
movq %rbp, %rcx
cmpl $0x1, %eax
jne 0xe4064
leaq 0xa3bd(%rip), %rsi      # 0xee3f0
leaq 0x49e6d(%rip), %rdx     # 0x12dea7
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
movq %rcx, %r14
callq 0x30af0
leaq 0x9fe1(%rip), %rsi      # 0xee034
leaq 0x49cd9(%rip), %rdx     # 0x12dd33
movq %r14, %rdi
movl $0x88d, %ecx            # imm = 0x88D
jmp 0xe40bb
movq %r15, %rdi
callq 0x8410
movq %r12, %rdi
callq 0x8410
movq 0x8(%rsp), %rdi
callq 0x8410
xorl %eax, %eax
jmp 0xe3ff0
leaq 0xa364(%rip), %rsi      # 0xee3f0
leaq 0x49cd0(%rip), %rdx     # 0x12dd63
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x9f88(%rip), %rsi      # 0xee034
leaq 0x49c80(%rip), %rdx     # 0x12dd33
movq %r12, %rdi
movl $0x86b, %ecx            # imm = 0x86B
movq %rbx, %r8
jmp 0xe3fe4
leaq 0xa326(%rip), %rsi      # 0xee3f0
leaq 0x49d1e(%rip), %rdx     # 0x12ddef
leaq 0x70(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x9f4a(%rip), %rsi      # 0xee034
leaq 0x49c42(%rip), %rdx     # 0x12dd33
movq %rbx, %rdi
movl $0x87c, %ecx            # imm = 0x87C
movq %r15, %r8
jmp 0xe3fe4