// File: /workspace/github_c_makefile_star2_O2/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 0x9e29d
cmpw $0x1, 0x3a(%rbx)
jne 0x9e374
xorpd %xmm1, %xmm1
xorl %ebp, %ebp
movsd 0x888(%r15), %xmm0
cmpl $0x1869f, %ebp          # imm = 0x1869F
ja 0x9e2e2
ucomisd %xmm1, %xmm0
jbe 0x9e2e2
incl %ebp
cvtsi2sd %ebp, %xmm1
divsd 0x540(%r15), %xmm1
movsd 0x4751f(%rip), %xmm0    # 0xe57f0
callq 0x8650
movapd %xmm0, %xmm1
mulsd 0x8(%rsp), %xmm1
jmp 0x9e2a3
cmpl $0x186a0, %ebp          # imm = 0x186A0
jne 0x9e35c
movsd 0x540(%r15), %xmm2
leaq 0x76504(%rip), %rsi     # 0x1147fe
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm1
movl $0x186a0, %edx          # imm = 0x186A0
movb $0x3, %al
callq 0x2e014
leaq 0x46d67(%rip), %rsi     # 0xe5082
leaq 0x76560(%rip), %rdx     # 0x114882
leaq 0x820(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0x46cef(%rip), %rsi     # 0xe5034
leaq 0x76559(%rip), %rdx     # 0x1148a5
movq %rbx, %rdi
movl $0x873, %ecx            # imm = 0x873
movq %r15, %r8
jmp 0x9e5e1
movsd %xmm1, 0x8(%rsp)
movl 0x6c(%rbx), %r14d
addl %r14d, %ebp
movl %ebp, 0x104(%rbx)
movslq %ebp, %r13
jmp 0x9e388
movl %r14d, 0x104(%rbx)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl %r14d, %ebp
shlq $0x3, %r13
movq %r13, %rdi
callq 0x8490
movq %rax, 0x78(%rbx)
testq %rax, %rax
je 0x9e55e
movq %r13, %rdi
callq 0x8490
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0x9e59f
xorl %ebp, %ebp
movslq %r14d, %r13
cmpq %r13, %rbp
jge 0x9e401
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, 0x8(%rsp)
callq 0x82e0
movq 0x80(%rbx), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
movl 0x6c(%rbx), %r14d
jmp 0x9e3bb
incl %r14d
movslq 0x104(%rbx), %rax
cmpq %rax, %r13
jge 0x9e47e
leaq 0x1(%r13), %r12
movl %r14d, %eax
subl 0x6c(%rbx), %eax
cvtsi2sd %eax, %xmm1
divsd 0x540(%r15), %xmm1
movsd %xmm1, 0x18(%rsp)
movsd 0x473bb(%rip), %xmm0    # 0xe57f0
callq 0x8650
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movq 0x78(%rbx), %rax
movsd %xmm0, (%rax,%r13,8)
movapd %xmm1, %xmm0
callq 0x82e0
movsd 0x18(%rsp), %xmm1
mulsd 0x6aec3(%rip), %xmm1    # 0x109328
addsd %xmm0, %xmm1
movq 0x80(%rbx), %rax
movsd %xmm1, (%rax,%r13,8)
incl %r14d
movq %r12, %r13
jmp 0x9e404
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 0x86a0
xorl %eax, %eax
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x9e5eb
cmpl $0x0, 0x18(%r14)
je 0x9e5eb
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 0x86a0
movapd %xmm0, %xmm1
leaq 0x763c5(%rip), %rsi     # 0x1148c9
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movsd 0x8(%rsp), %xmm0
movb $0x2, %al
callq 0x2e014
leaq 0x46b62(%rip), %rsi     # 0xe5082
leaq 0x7649d(%rip), %rdx     # 0x1149c4
leaq 0x820(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0x46aea(%rip), %rsi     # 0xe5034
leaq 0x76354(%rip), %rdx     # 0x1148a5
movq %rbx, %rdi
movl $0x893, %ecx            # imm = 0x893
jmp 0x9e354
shll $0x3, %ebp
leaq 0x46a9c(%rip), %rsi     # 0xe5004
leaq 0x76349(%rip), %rdx     # 0x1148b8
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0x46aa6(%rip), %rsi     # 0xe5034
leaq 0x76310(%rip), %rdx     # 0x1148a5
movq %rbx, %rdi
movl $0x87d, %ecx            # imm = 0x87D
jmp 0x9e5de
shll $0x3, %ebp
leaq 0x46a5b(%rip), %rsi     # 0xe5004
leaq 0x7630f(%rip), %rdx     # 0x1148bf
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0x46a65(%rip), %rsi     # 0xe5034
leaq 0x762cf(%rip), %rdx     # 0x1148a5
movq %rbx, %rdi
movl $0x87e, %ecx            # imm = 0x87E
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq