// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_get_k_list
int transfer_get_k_list(
                        struct perturbations * ppt,
                        struct transfer * ptr,
                        double K
                        ) {

  int index_md;
  int index_q;
  double m=0.;

  class_alloc(ptr->k,ptr->md_size*sizeof(double*),ptr->error_message);
  if (ptr->do_lcmb_full_limber == _TRUE_) {
    class_alloc(ptr->k_limber,ptr->md_size*sizeof(double*),ptr->error_message);
  }

  for (index_md = 0; index_md <  ptr->md_size; index_md++) {

    class_alloc(ptr->k[index_md],ptr->q_size*sizeof(double),ptr->error_message);
    if (ptr->do_lcmb_full_limber == _TRUE_) {
      class_alloc(ptr->k_limber[index_md],ptr->q_size_limber*sizeof(double),ptr->error_message);
    }

    if (_scalars_) {
      m=0.;
    }
    if (_vectors_) {
      m=1.;
    }
    if (_tensors_) {
      m=2.;
    }

    for (index_q=0; index_q < ptr->q_size; index_q++) {
      ptr->k[index_md][index_q] = sqrt(ptr->q[index_q]*ptr->q[index_q]-K*(m+1.));
    }
    if (ptr->do_lcmb_full_limber == _TRUE_) {
      for (index_q=0; index_q < ptr->q_size_limber; index_q++) {
        ptr->k_limber[index_md][index_q] = sqrt(ptr->q_limber[index_q]*ptr->q_limber[index_q]-K*(m+1.));
      }
    }

    /* check consistency of the first value of ptr->k */
    if (ptr->k[index_md][0] < ppt->k[index_md][0]){
      /* If ptr->k[index_md][0] < ppt->k[index_md][0] at the level of rounding,
         adjust first value of k_list to avoid interpolation errors: */
      if ((ppt->k[index_md][0]-ptr->k[index_md][0]) < 10.*DBL_EPSILON){
        ptr->k[index_md][0] = ppt->k[index_md][0];
      }
      else{
        class_stop(ptr->error_message,
                   "bug in k_list calculation: in perturbation module k_min=%e, in transfer module k_min[mode=%d]=%e, interpolation impossible",
                   ppt->k[0][0],
                   index_md,
                   ptr->k[index_md][0]);
      }
    }

    /* check consistency of the first value of ptr->k_limber */
    if (ptr->do_lcmb_full_limber == _TRUE_) {
      if (ptr->k_limber[index_md][0] < ppt->k[index_md][0]){
        /* If ptr->k_limber[index_md][0] < ppt->k[index_md][0] at the level of rounding,
           adjust first value of k_list to avoid interpolation errors: */
        if ((ppt->k[index_md][0]-ptr->k_limber[index_md][0]) < 10.*DBL_EPSILON){
          ptr->k_limber[index_md][0] = ppt->k[index_md][0];
        }
        else{
          class_stop(ptr->error_message,
                     "bug in k_list calculation: in perturbation module k_min=%e, in transfer module k_min[mode=%d]=%e, interpolation impossible",
                     ppt->k[0][0],
                     index_md,
                     ptr->k_limber[index_md][0]);
        }
      }
    }

    /* check consistency of the last value of ptr->k compared to the one of ppt->k across all modes (hence the 0 index) */
    class_test(ptr->k[index_md][ptr->q_size-1] > ppt->k[0][ppt->k_size_cl[0]-1],
               ptr->error_message,
               "bug in k_list calculation: in perturbation module k_max=%e, in transfer module k_max[mode=%d]=%e, interpolation impossible",
               ppt->k[0][ppt->k_size_cl[0]-1],
               index_md,
               ptr->k[index_md][ptr->q_size-1]);

    /* check consistency of the last value of ptr->k_limber compared to the one of ppt->k across all modes (hence the 0 index) */
    if (ptr->do_lcmb_full_limber == _TRUE_) {
      class_test(ptr->k_limber[index_md][ptr->q_size_limber-1] > ppt->k[0][ppt->k_size[0]-1],
                 ptr->error_message,
                 "bug in k_list calculation: in perturbation module k_max=%e, in transfer module k_max[mode=%d]=%e, interpolation impossible",
                 ppt->k[0][ppt->k_size[0]-1],
                 index_md,
                 ptr->k_limber[index_md][ptr->q_size_limber-1]);
    }

  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1028, %rsp           # imm = 0x1028
movsd %xmm0, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
movslq 0x8a4(%rsi), %r12
movq %r12, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x8460
movq %rax, 0x930(%rbx)
testq %rax, %rax
je 0xa9874
movq %rax, %r13
movzwl 0x93c(%rbx), %ebp
cmpw $0x1, %bp
jne 0xa959c
movq %r14, %rdi
callq 0x8460
movq %rax, 0x950(%rbx)
testq %rax, %rax
je 0xa98bb
testl %r12d, %r12d
jle 0xa986d
movq 0x920(%rbx), %r12
xorl %r14d, %r14d
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
leaq (,%r12,8), %rdi
callq 0x8460
movq %rax, (%r13,%r14,8)
movq 0x930(%rbx), %rax
cmpq $0x0, (%rax,%r14,8)
je 0xa9902
cmpw $0x1, %bp
jne 0xa9613
movq 0x940(%rbx), %r13
leaq (,%r13,8), %rdi
callq 0x8460
movq 0x950(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x950(%rbx), %rax
cmpq $0x0, (%rax,%r14,8)
je 0xa99a6
cmpw $0x1, 0xe(%r15)
jne 0xa9630
movl 0x848(%r15), %eax
cmpq %rax, %r14
jne 0xa9630
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
cmpw $0x1, 0x10(%r15)
jne 0xa9651
movl 0x850(%r15), %eax
cmpq %rax, %r14
jne 0xa9651
movsd 0x44c14(%rip), %xmm0    # 0xee260
movsd %xmm0, (%rsp)
cmpw $0x1, 0x12(%r15)
jne 0xa9672
movl 0x84c(%r15), %eax
cmpq %rax, %r14
jne 0xa9672
movsd 0x45693(%rip), %xmm0    # 0xeed00
movsd %xmm0, (%rsp)
testq %r12, %r12
je 0xa96ef
movsd (%rsp), %xmm1
addsd 0x44bdc(%rip), %xmm1    # 0xee260
xorpd 0x44ba4(%rip), %xmm1    # 0xee230
mulsd 0x8(%rsp), %xmm1
xorl %r12d, %r12d
movapd %xmm1, 0x10(%rsp)
movq 0x928(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x44ba0(%rip), %xmm0    # 0xee258
jb 0xa96c0
sqrtsd %xmm0, %xmm0
jmp 0xa96cb
callq 0x82b0
movapd 0x10(%rsp), %xmm1
movq 0x930(%rbx), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
cmpq %r12, 0x920(%rbx)
ja 0xa969b
movzwl 0x93c(%rbx), %ebp
cmpw $0x1, %bp
jne 0xa9770
cmpq $0x0, 0x940(%rbx)
je 0xa9770
movsd (%rsp), %xmm1
addsd 0x44b54(%rip), %xmm1    # 0xee260
xorpd 0x44b1c(%rip), %xmm1    # 0xee230
mulsd 0x8(%rsp), %xmm1
xorl %r12d, %r12d
movapd %xmm1, 0x10(%rsp)
movq 0x948(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x44b18(%rip), %xmm0    # 0xee258
jb 0xa9748
sqrtsd %xmm0, %xmm0
jmp 0xa9753
callq 0x82b0
movapd 0x10(%rsp), %xmm1
movq 0x950(%rbx), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
cmpq %r12, 0x940(%rbx)
ja 0xa9723
movq 0x930(%rbx), %r13
movq (%r13,%r14,8), %rcx
movsd (%rcx), %xmm1
movq 0x9d0(%r15), %rax
movq (%rax,%r14,8), %rdx
movsd (%rdx), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xa97b3
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd 0x74ba3(%rip), %xmm3    # 0x11e348
ucomisd %xmm2, %xmm3
jbe 0xa99ec
movsd %xmm0, (%rcx)
movzwl 0x93c(%rbx), %ebp
cmpw $0x1, %bp
jne 0xa97f7
movq 0x950(%rbx), %rsi
movq (%rsi,%r14,8), %rsi
movsd (%rsi), %xmm1
movsd (%rdx), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xa97f7
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd 0x74b5f(%rip), %xmm3    # 0x11e348
ucomisd %xmm2, %xmm3
jbe 0xa9aa5
movsd %xmm0, (%rsi)
movq 0x920(%rbx), %r12
movsd -0x8(%rcx,%r12,8), %xmm1
movq (%rax), %rax
movq 0x9b8(%r15), %rcx
movslq (%rcx), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
ucomisd %xmm0, %xmm1
ja 0xa9948
cmpw $0x1, %bp
jne 0xa985a
movq 0x940(%rbx), %rcx
movq 0x950(%rbx), %rdx
movq (%rdx,%r14,8), %rdx
movsd -0x8(%rdx,%rcx,8), %xmm1
movq 0x9c8(%r15), %rcx
movslq (%rcx), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
ucomisd %xmm0, %xmm1
ja 0xa9a4a
incq %r14
movslq 0x8a4(%rbx), %rax
cmpq %rax, %r14
jl 0xa95b8
xorl %eax, %eax
jmp 0xa9b0d
leal (,%r12,8), %ecx
leaq 0x44781(%rip), %rsi     # 0xee004
leaq 0x75710(%rip), %rdx     # 0x11ef9a
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4478d(%rip), %rsi     # 0xee034
leaq 0x756f3(%rip), %rdx     # 0x11efa1
movq %rbx, %rdi
movl $0x56d, %ecx            # imm = 0x56D
jmp 0xa9afe
leal (,%r12,8), %ecx
leaq 0x4473a(%rip), %rsi     # 0xee004
leaq 0x756e4(%rip), %rdx     # 0x11efb5
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44746(%rip), %rsi     # 0xee034
leaq 0x756ac(%rip), %rdx     # 0x11efa1
movq %rbx, %rdi
movl $0x56f, %ecx            # imm = 0x56F
jmp 0xa9afe
shll $0x3, %r12d
leaq 0x446f7(%rip), %rsi     # 0xee004
leaq 0x756af(%rip), %rdx     # 0x11efc3
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44700(%rip), %rsi     # 0xee034
leaq 0x75666(%rip), %rdx     # 0x11efa1
movq %rbx, %rdi
movl $0x574, %ecx            # imm = 0x574
jmp 0xa9afe
leaq 0x75718(%rip), %rsi     # 0x11f067
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movb $0x2, %al
callq 0x30af0
leaq 0x4471a(%rip), %rsi     # 0xee082
leaq 0x75773(%rip), %rdx     # 0x11f0e2
leaq 0x820(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x446a2(%rip), %rsi     # 0xee034
leaq 0x75608(%rip), %rdx     # 0x11efa1
movq %rbx, %rdi
movl $0x5b4, %ecx            # imm = 0x5B4
jmp 0xa9afe
shll $0x3, %r13d
leaq 0x44653(%rip), %rsi     # 0xee004
leaq 0x7561c(%rip), %rdx     # 0x11efd4
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4465c(%rip), %rsi     # 0xee034
leaq 0x755c2(%rip), %rdx     # 0x11efa1
movq %rbx, %rdi
movl $0x576, %ecx            # imm = 0x576
jmp 0xa9afe
movq (%rax), %rax
movsd (%rax), %xmm0
leaq 0x755f2(%rip), %rsi     # 0x11efec
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movb $0x2, %al
callq 0x30af0
leaq 0x44b72(%rip), %rsi     # 0xee585
leaq 0x820(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x445fe(%rip), %rsi     # 0xee034
leaq 0x75564(%rip), %rdx     # 0x11efa1
movq %rbx, %rdi
movl $0x598, %ecx            # imm = 0x598
jmp 0xa9afe
leaq 0x75616(%rip), %rsi     # 0x11f067
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movb $0x2, %al
callq 0x30af0
leaq 0x44618(%rip), %rsi     # 0xee082
leaq 0x756b2(%rip), %rdx     # 0x11f123
leaq 0x820(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x445a0(%rip), %rsi     # 0xee034
leaq 0x75506(%rip), %rdx     # 0x11efa1
movq %rbx, %rdi
movl $0x5bd, %ecx            # imm = 0x5BD
jmp 0xa9afe
movq (%rax), %rax
movsd (%rax), %xmm0
leaq 0x75539(%rip), %rsi     # 0x11efec
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movb $0x2, %al
callq 0x30af0
leaq 0x44ab9(%rip), %rsi     # 0xee585
leaq 0x820(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44545(%rip), %rsi     # 0xee034
leaq 0x754ab(%rip), %rdx     # 0x11efa1
movq %rbx, %rdi
movl $0x5a9, %ecx            # imm = 0x5A9
movq %r14, %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