// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movl %ecx, %r12d
movq %rdx, 0x68(%rsp)
andl $0x0, 0x2c(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdi, %r13
movslq %ecx, %rbp
shlq $0x3, %rbp
movq %rbp, %rdi
callq 0x8490
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0xdbaf0
movq %rbp, %rdi
callq 0x8490
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0xdbb2e
movq %rbp, %rdi
callq 0x8490
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xdbb6c
movq %r14, 0x40(%rsp)
leal -0x1(%r12), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x50(%rsp)
leaq 0x192(%r13), %r15
xorl %ecx, %ecx
testl %r12d, %r12d
movl $0x0, %eax
movq %r12, 0x38(%rsp)
cmovgl %r12d, %eax
movq %rax, 0x30(%rsp)
leaq (,%rax,8), %rax
movq %rax, 0x58(%rsp)
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
leaq 0x2c(%rsp), %r14
xorl %r12d, %r12d
movq %r13, 0x48(%rsp)
cmpq %r12, 0x58(%rsp)
je 0xdbbbe
movq %rcx, 0x20(%rsp)
cvtsi2sd %ecx, %xmm0
mulsd 0x47358(%rip), %xmm0    # 0x122d70
divsd 0x50(%rsp), %xmm0
addsd 0x47352(%rip), %xmm0    # 0x122d78
movsd %xmm0, (%rbx,%r12)
movq 0x80(%r13), %rdi
movl 0x104(%r13), %esi
movq 0x18(%rsp), %rax
leaq (%rax,%r12), %rbp
subq $0x8, %rsp
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rcx
pushq $0x1
popq %r8
movq %r14, %r9
pushq %r15
pushq $0x1
pushq %rbp
callq 0x1604b
addq $0x20, %rsp
cmpl $0x1, %eax
je 0xdbc24
movq 0x80(%r13), %rdi
movl 0x104(%r13), %esi
movq 0x118(%r13), %rdx
movq %r14, %r9
movq 0x120(%r13), %rcx
movq %rbx, %r13
movsd (%rbx,%r12), %xmm0
movq 0x10(%rsp), %rax
leaq (%rax,%r12), %rbx
subq $0x8, %rsp
pushq $0x1
popq %r8
pushq %r15
pushq $0x1
pushq %rbx
callq 0x1604b
addq $0x20, %rsp
cmpl $0x1, %eax
je 0xdbc5f
movsd (%rbp), %xmm0
subsd (%rbx), %xmm0
callq 0x86a0
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax,%r12)
addq $0x8, %r12
movq 0x20(%rsp), %rcx
incl %ecx
movq %r13, %rbx
movq 0x48(%rsp), %r13
jmp 0xdb9fc
leaq 0x950d(%rip), %rsi      # 0xe5004
leaq 0x4909c(%rip), %rdx     # 0x124b9a
leaq 0x70(%rsp), %r15
movq %r15, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %r13            # imm = 0x192
leaq 0x9517(%rip), %rsi      # 0xe5034
leaq 0x4907f(%rip), %rdx     # 0x124ba3
movq %r13, %rdi
movl $0x853, %ecx            # imm = 0x853
jmp 0xdbba8
leaq 0x94cf(%rip), %rsi      # 0xe5004
leaq 0x49077(%rip), %rdx     # 0x124bb3
leaq 0x70(%rsp), %r15
movq %r15, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %r13            # imm = 0x192
leaq 0x94d9(%rip), %rsi      # 0xe5034
leaq 0x49041(%rip), %rdx     # 0x124ba3
movq %r13, %rdi
movl $0x854, %ecx            # imm = 0x854
jmp 0xdbba8
leaq 0x9491(%rip), %rsi      # 0xe5004
leaq 0x49050(%rip), %rdx     # 0x124bca
leaq 0x70(%rsp), %r15
movq %r15, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %r13            # imm = 0x192
leaq 0x949b(%rip), %rsi      # 0xe5034
leaq 0x49003(%rip), %rdx     # 0x124ba3
movq %r13, %rdi
movl $0x855, %ecx            # imm = 0x855
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
jmp 0xdbc9f
movsd 0xc93a(%rip), %xmm0     # 0xe8500
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
movq 0x40(%rsp), %r14
movq %r14, %rdx
movq 0x38(%rsp), %rcx
movq %r15, %r8
callq 0x19808
cmpl $0x1, %eax
jne 0xdbcb5
leaq 0x97fd(%rip), %rsi      # 0xe53f0
leaq 0x4911d(%rip), %rdx     # 0x124d17
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9421(%rip), %rsi      # 0xe5034
leaq 0x48f89(%rip), %rdx     # 0x124ba3
movq %r15, %rdi
movl $0x88d, %ecx            # imm = 0x88D
jmp 0xdbc5a
leaq 0x97c5(%rip), %rsi      # 0xe53f0
leaq 0x48fa1(%rip), %rdx     # 0x124bd3
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x93e9(%rip), %rsi      # 0xe5034
leaq 0x48f51(%rip), %rdx     # 0x124ba3
movq %r15, %rdi
movl $0x86b, %ecx            # imm = 0x86B
movq %r14, %r8
jmp 0xdbc98
leaq 0x978a(%rip), %rsi      # 0xe53f0
leaq 0x48ff2(%rip), %rdx     # 0x124c5f
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x93ae(%rip), %rsi      # 0xe5034
leaq 0x48f16(%rip), %rdx     # 0x124ba3
movq %r15, %rdi
movl $0x87c, %ecx            # imm = 0x87C
movq %r12, %r8
xorl %eax, %eax
callq 0x2e014
movl 0x4(%rsp), %eax
addq $0x878, %rsp            # imm = 0x878
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
movq 0x8b0(%rsp), %r15
movq 0x30(%rsp), %r12
cmpq %rbx, %r12
je 0xdbd10
movsd (%r14,%rbx,8), %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x10(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
callq 0x86a0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, (%r14,%rbx,8)
movq 0x18(%rsp), %rax
movsd (%rax,%rbx,8), %xmm0
callq 0x86a0
subsd (%r14,%rbx,8), %xmm0
movsd %xmm0, (%r15,%rbx,8)
incq %rbx
jmp 0xdbcc4
movq 0x18(%rsp), %rdi
callq 0x8430
movq 0x10(%rsp), %rdi
callq 0x8430
movq 0x8(%rsp), %rdi
callq 0x8430
movl $0x0, 0x4(%rsp)
jmp 0xdbc9f