// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/fourier.c
// Function: fourier_get_k_list
int fourier_get_k_list(
                       struct precision *ppr,
                       struct primordial * ppm,
                       struct perturbations * ppt,
                       struct fourier * pfo
                       ) {

  double k=0;
  double k_max,exponent;
  int index_k;

  pfo->k_size = ppt->k_size[pfo->index_md_scalars];
  pfo->k_size_pk = ppt->k_size_pk;
  k_max = ppt->k[pfo->index_md_scalars][pfo->k_size-1];

  /** - if k extrapolation necessary, compute number of required extra values */
  if ((pfo->method == nl_HMcode) || (pfo->has_pk_numerical_nowiggle == _TRUE_)){
    index_k=0;
    while(k < ppr->hmcode_max_k_extra && index_k < _MAX_NUM_EXTRAPOLATION_){
      index_k++;
      k = k_max * pow(10,(double)index_k/ppr->k_per_decade_for_pk);
    }
    class_test(index_k == _MAX_NUM_EXTRAPOLATION_,
               pfo->error_message,
               "could not reach extrapolated value k = %.10e starting from k = %.10e with k_per_decade of %.10e in _MAX_NUM_INTERPOLATION_=%i steps",
               ppr->hmcode_max_k_extra,k_max,ppr->k_per_decade_for_pk,_MAX_NUM_EXTRAPOLATION_
               );

    pfo->k_size_extra = pfo->k_size+index_k;
  }
  /** - otherwise, same number of values as in perturbation module */
  else {
    pfo->k_size_extra = pfo->k_size;
  }

  /** - allocate array of k */
  class_alloc(pfo->k,   pfo->k_size_extra*sizeof(double),pfo->error_message);
  class_alloc(pfo->ln_k,pfo->k_size_extra*sizeof(double),pfo->error_message);

  /** - fill array of k (not extrapolated) */
  for (index_k=0; index_k<pfo->k_size; index_k++) {
    k = ppt->k[pfo->index_md_scalars][index_k];
    pfo->k[index_k] = k;
    pfo->ln_k[index_k] = log(k);
  }

  /** - fill additional values of k (extrapolated) */
  for (index_k=pfo->k_size; index_k<pfo->k_size_extra; index_k++) {
    exponent = (double)(index_k-(pfo->k_size-1))/ppr->k_per_decade_for_pk;
    pfo->k[index_k] = k * pow(10,exponent);
    pfo->ln_k[index_k] = log(k) + exponent*log(10.);
  }

  class_test(pfo->k[pfo->k_size_extra-1]>exp(ppm->lnk[ppm->lnk_size-1]) && ppm->primordial_spec_type != analytic_Pk,
             pfo->error_message,
             "Setting the output to HMcode with a large 'hmcode_max_k_extra' and using the primordial spectrum to not analytic is incompatible. Either use the analytic power spectrum or set a smaller 'hmcode_max_k_extra' (k_max_hmcode=%.5e , k_max_primordial=%.5e)",
             pfo->k[pfo->k_size_extra-1],
             exp(ppm->lnk[ppm->lnk_size-1])
             );

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1028, %rsp           # imm = 0x1028
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
movq 0x9c8(%rdx), %rax
movslq 0x3c(%rcx), %rcx
movl (%rax,%rcx,4), %r14d
movl %r14d, 0x6c(%rbx)
movl 0x9c0(%rdx), %eax
movl %eax, 0x70(%rbx)
movq 0x9d0(%rdx), %rax
movq (%rax,%rcx,8), %rax
movslq %r14d, %r13
movsd -0x8(%rax,%r13,8), %xmm0
movsd %xmm0, 0x8(%rsp)
cmpl $0x2, (%rbx)
je 0xa3431
cmpw $0x1, 0x3a(%rbx)
jne 0xa3521
movsd 0x888(%r15), %xmm0
xorl %ebp, %ebp
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa3509
xorl %ebp, %ebp
movl %ebp, %r14d
leal 0x1(%r14), %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
divsd 0x540(%r15), %xmm1
movsd 0x4b385(%rip), %xmm0    # 0xee7f0
callq 0x8620
movapd %xmm0, %xmm1
mulsd 0x8(%rsp), %xmm1
movsd 0x888(%r15), %xmm0
cmpl $0x1869e, %r14d         # imm = 0x1869E
ja 0xa3492
ucomisd %xmm1, %xmm0
ja 0xa344c
cmpl $0x186a0, %ebp          # imm = 0x186A0
jne 0xa3509
movsd 0x540(%r15), %xmm2
leaq 0x7a4b4(%rip), %rsi     # 0x11d95e
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm1
movl $0x186a0, %edx          # imm = 0x186A0
movb $0x3, %al
callq 0x30af0
leaq 0x4abb7(%rip), %rsi     # 0xee082
leaq 0x7a510(%rip), %rdx     # 0x11d9e2
leaq 0x820(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0x4ab3f(%rip), %rsi     # 0xee034
leaq 0x7a509(%rip), %rdx     # 0x11da05
movq %rbx, %rdi
movl $0x873, %ecx            # imm = 0x873
jmp 0xa37ae
movsd %xmm1, 0x8(%rsp)
movl 0x6c(%rbx), %r14d
addl %r14d, %ebp
movl %ebp, 0x104(%rbx)
movslq %ebp, %r13
jmp 0xa3535
movl %r14d, 0x104(%rbx)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl %r14d, %ebp
shlq $0x3, %r13
movq %r13, %rdi
callq 0x8460
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0xa3648
movq %r13, %rdi
callq 0x8460
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0xa3689
testl %r14d, %r14d
jle 0xa35b8
xorl %r13d, %r13d
movq 0x9d0(%r12), %rax
movslq 0x3c(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%r13,8), %xmm0
movq 0x78(%rbx), %rax
movsd %xmm0, (%rax,%r13,8)
movsd %xmm0, 0x8(%rsp)
callq 0x82c0
movq 0x80(%rbx), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
movslq 0x6c(%rbx), %r14
cmpq %r14, %r13
jl 0xa356e
movl 0x104(%rbx), %ebp
cmpl %ebp, %r14d
jge 0xa36d0
movslq %r14d, %r12
incl %r14d
leaq 0x1(%r12), %r13
movl %r14d, %eax
subl 0x6c(%rbx), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd 0x540(%r15), %xmm1
movsd %xmm1, 0x18(%rsp)
movsd 0x4b200(%rip), %xmm0    # 0xee7f0
callq 0x8620
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movq 0x78(%rbx), %rax
movsd %xmm0, (%rax,%r12,8)
movapd %xmm1, %xmm0
callq 0x82c0
movsd 0x18(%rsp), %xmm1
mulsd 0x6ee68(%rip), %xmm1    # 0x112488
addsd %xmm0, %xmm1
movq 0x80(%rbx), %rax
movsd %xmm1, (%rax,%r12,8)
movslq 0x104(%rbx), %rax
incl %r14d
movq %r13, %r12
cmpq %rax, %r13
jl 0xa35c7
jmp 0xa36d3
shll $0x3, %ebp
leaq 0x4a9b2(%rip), %rsi     # 0xee004
leaq 0x7a3bf(%rip), %rdx     # 0x11da18
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0x4a9bc(%rip), %rsi     # 0xee034
leaq 0x7a386(%rip), %rdx     # 0x11da05
movq %rbx, %rdi
movl $0x87d, %ecx            # imm = 0x87D
jmp 0xa36c8
shll $0x3, %ebp
leaq 0x4a971(%rip), %rsi     # 0xee004
leaq 0x7a385(%rip), %rdx     # 0x11da1f
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0x4a97b(%rip), %rsi     # 0xee034
leaq 0x7a345(%rip), %rdx     # 0x11da05
movq %rbx, %rdi
movl $0x87e, %ecx            # imm = 0x87E
movq %r14, %r8
jmp 0xa37b1
movslq %ebp, %rax
movq 0x78(%rbx), %rcx
movsd -0x8(%rcx,%rax,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x10(%rsp), %r14
movq 0x298(%r14), %rax
movslq 0x290(%r14), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
callq 0x8670
xorl %eax, %eax
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xa37bd
cmpl $0x0, 0x18(%r14)
je 0xa37bd
movq 0x78(%rbx), %rax
movslq 0x104(%rbx), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x298(%r14), %rax
movslq 0x290(%r14), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
callq 0x8670
movapd %xmm0, %xmm1
leaq 0x7a2d0(%rip), %rsi     # 0x11da29
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x30af0
leaq 0x4a90d(%rip), %rsi     # 0xee082
leaq 0x7a3a8(%rip), %rdx     # 0x11db24
leaq 0x820(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0x4a895(%rip), %rsi     # 0xee034
leaq 0x7a25f(%rip), %rdx     # 0x11da05
movq %rbx, %rdi
movl $0x893, %ecx            # imm = 0x893
movq %r15, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq