// File: /workspace/github_c_makefile_star2_O1/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 $0x1018, %rsp           # imm = 0x1018
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
movq 0x9c8(%rdx), %rax
movslq 0x3c(%rcx), %rcx
movslq (%rax,%rcx,4), %r13
movl %r13d, 0x6c(%rbx)
movl 0x9c0(%rdx), %eax
movl %eax, 0x70(%rbx)
movq 0x9d0(%rdx), %rax
movq (%rax,%rcx,8), %rax
movsd -0x8(%rax,%r13,8), %xmm0
movsd %xmm0, (%rsp)
cmpl $0x2, (%rbx)
je 0xa62f7
xorpd %xmm1, %xmm1
cmpw $0x1, 0x3a(%rbx)
jne 0xa63d3
movsd 0x888(%r15), %xmm0
xorpd %xmm1, %xmm1
xorl %r13d, %r13d
ucomisd %xmm1, %xmm0
jbe 0xa6355
xorl %r13d, %r13d
movl %r13d, %ebp
leal 0x1(%rbp), %r13d
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
divsd 0x540(%r15), %xmm1
movsd 0x4b4c0(%rip), %xmm0    # 0xf17f0
callq 0x8620
movapd %xmm0, %xmm1
mulsd (%rsp), %xmm1
movsd 0x888(%r15), %xmm0
cmpl $0x1869e, %ebp          # imm = 0x1869E
ja 0xa6355
ucomisd %xmm1, %xmm0
ja 0xa6310
cmpl $0x186a0, %r13d         # imm = 0x186A0
jne 0xa63cf
movsd 0x540(%r15), %xmm2
leaq 0x7a5b0(%rip), %rsi     # 0x12091e
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movsd (%rsp), %xmm1
movl $0x186a0, %edx          # imm = 0x186A0
movb $0x3, %al
callq 0x30c2c
leaq 0x4acf4(%rip), %rsi     # 0xf1082
leaq 0x7a60d(%rip), %rdx     # 0x1209a2
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0x4ac7c(%rip), %rsi     # 0xf1034
leaq 0x7a606(%rip), %rdx     # 0x1209c5
movq %rbx, %rdi
movl $0x873, %ecx            # imm = 0x873
movq %r15, %r8
jmp 0xa664e
addl 0x6c(%rbx), %r13d
movsd %xmm1, (%rsp)
movl %r13d, 0x104(%rbx)
movslq %r13d, %rbp
shlq $0x3, %rbp
movq %rbp, %rdi
callq 0x8460
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0xa65c7
movq %rbp, %rdi
callq 0x8460
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0xa660a
movl 0x6c(%rbx), %r13d
testl %r13d, %r13d
jle 0xa645e
xorl %ebp, %ebp
movq 0x9d0(%r12), %rax
movslq 0x3c(%rbx), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%rbp,8), %xmm0
movq 0x78(%rbx), %rax
movsd %xmm0, (%rax,%rbp,8)
movsd %xmm0, (%rsp)
callq 0x82c0
movq 0x80(%rbx), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
movslq 0x6c(%rbx), %r13
cmpq %r13, %rbp
jl 0xa641e
movl 0x104(%rbx), %eax
cmpl %eax, %r13d
jge 0xa64ee
movslq %r13d, %r12
incl %r13d
leaq 0x1(%r12), %rbp
movl %r13d, %eax
subl 0x6c(%rbx), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd 0x540(%r15), %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x4b354(%rip), %xmm0    # 0xf17f0
callq 0x8620
movsd (%rsp), %xmm1
mulsd %xmm1, %xmm0
movq 0x78(%rbx), %rax
movsd %xmm0, (%rax,%r12,8)
movapd %xmm1, %xmm0
callq 0x82c0
movsd 0x8(%rsp), %xmm1
mulsd 0x6ef7d(%rip), %xmm1    # 0x115448
addsd %xmm0, %xmm1
movq 0x80(%rbx), %rax
movsd %xmm1, (%rax,%r12,8)
movslq 0x104(%rbx), %rax
incl %r13d
movq %rbp, %r12
cmpq %rax, %rbp
jl 0xa6473
movq 0x78(%rbx), %rcx
cltq
movsd -0x8(%rcx,%rax,8), %xmm0
movsd %xmm0, (%rsp)
movq 0x298(%r14), %rax
movslq 0x290(%r14), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
callq 0x8670
xorl %eax, %eax
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xa665a
cmpl $0x0, 0x18(%r14)
je 0xa665a
movq 0x78(%rbx), %rax
movslq 0x104(%rbx), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
movsd %xmm0, (%rsp)
movq 0x298(%r14), %rax
movslq 0x290(%r14), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
callq 0x8670
movapd %xmm0, %xmm1
leaq 0x7a47b(%rip), %rsi     # 0x1209e9
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movsd (%rsp), %xmm0
movb $0x2, %al
callq 0x30c2c
leaq 0x4aaf9(%rip), %rsi     # 0xf1082
leaq 0x7a554(%rip), %rdx     # 0x120ae4
leaq 0x810(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0x4aa81(%rip), %rsi     # 0xf1034
leaq 0x7a40b(%rip), %rdx     # 0x1209c5
movq %rbx, %rdi
movl $0x893, %ecx            # imm = 0x893
jmp 0xa63c7
shll $0x3, %r13d
leaq 0x4aa32(%rip), %rsi     # 0xf1004
leaq 0x7a3ff(%rip), %rdx     # 0x1209d8
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0x4aa3b(%rip), %rsi     # 0xf1034
leaq 0x7a3c5(%rip), %rdx     # 0x1209c5
movq %rbx, %rdi
movl $0x87d, %ecx            # imm = 0x87D
jmp 0xa664b
shll $0x3, %r13d
leaq 0x4a9ef(%rip), %rsi     # 0xf1004
leaq 0x7a3c3(%rip), %rdx     # 0x1209df
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0x4a9f8(%rip), %rsi     # 0xf1034
leaq 0x7a382(%rip), %rdx     # 0x1209c5
movq %rbx, %rdi
movl $0x87e, %ecx            # imm = 0x87E
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq