// File: /workspace/github_c_makefile_star2_O2/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 $0x1038, %rsp           # imm = 0x1038
movsd %xmm0, 0x18(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
movslq 0x8a4(%rsi), %rbp
movq %rbp, %r15
shlq $0x3, %r15
movq %r15, %rdi
callq 0x8490
movq %rax, 0x930(%rbx)
testq %rax, %rax
je 0xa44f1
movq %rax, %r13
movq %r14, 0x10(%rsp)
movzwl 0x93c(%rbx), %r14d
cmpw $0x1, %r14w
jne 0xa4235
movq %r15, %rdi
callq 0x8490
movq %rax, 0x950(%rbx)
testq %rax, %rax
je 0xa4537
xorl %r15d, %r15d
xorl %r12d, %r12d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movslq %ebp, %rax
cmpq %rax, %r12
jge 0xa4788
movq 0x920(%rbx), %rbp
leaq (,%rbp,8), %rdi
callq 0x8490
movq %rax, (%r13,%r12,8)
movq 0x930(%rbx), %rax
cmpq $0x0, (%rax,%r12,8)
je 0xa457d
cmpw $0x1, %r14w
jne 0xa42b4
movq 0x940(%rbx), %r13
leaq (,%r13,8), %rdi
callq 0x8490
movq 0x950(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x950(%rbx), %rax
cmpq $0x0, (%rax,%r12,8)
je 0xa461f
movq 0x10(%rsp), %rcx
cmpw $0x1, 0xe(%rcx)
jne 0xa42d5
movl 0x848(%rcx), %eax
cmpq %rax, %r12
jne 0xa42d5
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
cmpw $0x1, 0x10(%rcx)
jne 0xa42f5
movl 0x850(%rcx), %eax
cmpq %rax, %r12
jne 0xa42f5
movsd 0x40f71(%rip), %xmm0    # 0xe5260
movsd %xmm0, 0x8(%rsp)
cmpw $0x1, 0x12(%rcx)
jne 0xa4315
movl 0x84c(%rcx), %eax
cmpq %rax, %r12
jne 0xa4315
movsd 0x419d1(%rip), %xmm0    # 0xe5ce0
movsd %xmm0, 0x8(%rsp)
movsd 0x8(%rsp), %xmm1
addsd 0x40f3d(%rip), %xmm1    # 0xe5260
xorpd 0x40f05(%rip), %xmm1    # 0xe5230
mulsd 0x18(%rsp), %xmm1
xorl %r14d, %r14d
movapd %xmm1, 0x20(%rsp)
cmpq %r14, %rbp
jbe 0xa438c
movq 0x928(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x40efc(%rip), %xmm0    # 0xe5258
jb 0xa4364
sqrtsd %xmm0, %xmm0
jmp 0xa436f
callq 0x82d0
movapd 0x20(%rsp), %xmm1
movq 0x930(%rbx), %rax
movq (%rax,%r12,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
movq 0x920(%rbx), %rbp
jmp 0xa433a
cmpw $0x1, 0x93c(%rbx)
jne 0xa43e8
xorl %r14d, %r14d
cmpq %r14, 0x940(%rbx)
jbe 0xa43e8
movq 0x948(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x40e99(%rip), %xmm0    # 0xe5258
jb 0xa43c7
sqrtsd %xmm0, %xmm0
jmp 0xa43d2
callq 0x82d0
movapd 0x20(%rsp), %xmm1
movq 0x950(%rbx), %rax
movq (%rax,%r12,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0xa4399
movq 0x930(%rbx), %r13
movq (%r13,%r12,8), %rcx
movsd (%rcx), %xmm1
movq 0x10(%rsp), %rax
movq 0x9d0(%rax), %rax
movq (%rax,%r12,8), %rdx
movsd (%rdx), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xa4430
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd 0x70dc6(%rip), %xmm3    # 0x1151e8
ucomisd %xmm2, %xmm3
jbe 0xa4668
movsd %xmm0, (%rcx)
movzwl 0x93c(%rbx), %r14d
cmpw $0x1, %r14w
jne 0xa4476
movq 0x950(%rbx), %rsi
movq (%rsi,%r12,8), %rsi
movsd (%rsi), %xmm1
movsd (%rdx), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xa4476
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd 0x70d80(%rip), %xmm3    # 0x1151e8
ucomisd %xmm2, %xmm3
jbe 0xa4721
movsd %xmm0, (%rsi)
movq 0x920(%rbx), %rdx
movsd -0x8(%rcx,%rdx,8), %xmm1
movq (%rax), %rax
movq 0x10(%rsp), %rcx
movq 0x9b8(%rcx), %rcx
movslq (%rcx), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
ucomisd %xmm0, %xmm1
ja 0xa45c1
cmpw $0x1, %r14w
jne 0xa44e3
movq 0x940(%rbx), %rcx
movq 0x950(%rbx), %rdx
movq (%rdx,%r12,8), %rdx
movsd -0x8(%rdx,%rcx,8), %xmm1
movq 0x10(%rsp), %rcx
movq 0x9c8(%rcx), %rcx
movslq (%rcx), %rcx
movsd -0x8(%rax,%rcx,8), %xmm0
ucomisd %xmm0, %xmm1
ja 0xa46c6
incq %r12
movl 0x8a4(%rbx), %ebp
jmp 0xa4245
leal (,%rbp,8), %ecx
leaq 0x40b05(%rip), %rsi     # 0xe5004
leaq 0x71924(%rip), %rdx     # 0x115e2a
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x40b11(%rip), %rsi     # 0xe5034
leaq 0x71907(%rip), %rdx     # 0x115e31
movq %rbx, %rdi
movl $0x56d, %ecx            # imm = 0x56D
jmp 0xa4660
leal (,%rbp,8), %ecx
leaq 0x40abf(%rip), %rsi     # 0xe5004
leaq 0x718f9(%rip), %rdx     # 0x115e45
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x40acb(%rip), %rsi     # 0xe5034
leaq 0x718c1(%rip), %rdx     # 0x115e31
movq %rbx, %rdi
movl $0x56f, %ecx            # imm = 0x56F
jmp 0xa4660
shll $0x3, %ebp
leaq 0x40a7d(%rip), %rsi     # 0xe5004
leaq 0x718c5(%rip), %rdx     # 0x115e53
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x40a87(%rip), %rsi     # 0xe5034
leaq 0x7187d(%rip), %rdx     # 0x115e31
movq %rbx, %rdi
movl $0x574, %ecx            # imm = 0x574
jmp 0xa4660
leaq 0x7192f(%rip), %rsi     # 0x115ef7
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r12d, %edx
movb $0x2, %al
callq 0x2e014
leaq 0x40aa1(%rip), %rsi     # 0xe5082
leaq 0x7198a(%rip), %rdx     # 0x115f72
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x40a29(%rip), %rsi     # 0xe5034
leaq 0x7181f(%rip), %rdx     # 0x115e31
movq %rbx, %rdi
movl $0x5b4, %ecx            # imm = 0x5B4
jmp 0xa477a
shll $0x3, %r13d
leaq 0x409da(%rip), %rsi     # 0xe5004
leaq 0x71833(%rip), %rdx     # 0x115e64
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x409e3(%rip), %rsi     # 0xe5034
leaq 0x717d9(%rip), %rdx     # 0x115e31
movq %rbx, %rdi
movl $0x576, %ecx            # imm = 0x576
movq %r14, %r8
jmp 0xa477d
movq (%rax), %rax
movsd (%rax), %xmm0
leaq 0x71806(%rip), %rsi     # 0x115e7c
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r12d, %edx
movb $0x2, %al
callq 0x2e014
leaq 0x40ef6(%rip), %rsi     # 0xe5585
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x40982(%rip), %rsi     # 0xe5034
leaq 0x71778(%rip), %rdx     # 0x115e31
movq %rbx, %rdi
movl $0x598, %ecx            # imm = 0x598
jmp 0xa477a
leaq 0x7182a(%rip), %rsi     # 0x115ef7
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r12d, %edx
movb $0x2, %al
callq 0x2e014
leaq 0x4099c(%rip), %rsi     # 0xe5082
leaq 0x718c6(%rip), %rdx     # 0x115fb3
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x40924(%rip), %rsi     # 0xe5034
leaq 0x7171a(%rip), %rdx     # 0x115e31
movq %rbx, %rdi
movl $0x5bd, %ecx            # imm = 0x5BD
jmp 0xa477a
movq (%rax), %rax
movsd (%rax), %xmm0
leaq 0x7174d(%rip), %rsi     # 0x115e7c
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r12d, %edx
movb $0x2, %al
callq 0x2e014
leaq 0x40e3d(%rip), %rsi     # 0xe5585
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x408c9(%rip), %rsi     # 0xe5034
leaq 0x716bf(%rip), %rdx     # 0x115e31
movq %rbx, %rdi
movl $0x5a9, %ecx            # imm = 0x5A9
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %r15
movl %r15d, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq