// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
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 0xac86f
cmpw $0x1, 0x93c(%rbx)
jne 0xac58d
movq %r14, %rdi
callq 0x8460
movq %rax, 0x950(%rbx)
testq %rax, %rax
je 0xac8b6
cmpl $0x0, 0x8a4(%rbx)
jle 0xac868
xorl %r14d, %r14d
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
movq 0x920(%rbx), %r12
leaq (,%r12,8), %rdi
callq 0x8460
movq 0x930(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x930(%rbx), %rax
cmpq $0x0, (%rax,%r14,8)
je 0xac8fd
cmpw $0x1, 0x93c(%rbx)
jne 0xac612
movq 0x940(%rbx), %r12
leaq (,%r12,8), %rdi
callq 0x8460
movq 0x950(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x950(%rbx), %rax
cmpq $0x0, (%rax,%r14,8)
je 0xac9b7
cmpw $0x1, 0xe(%r15)
jne 0xac62f
movl 0x848(%r15), %eax
cmpq %rax, %r14
jne 0xac62f
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
cmpw $0x1, 0x10(%r15)
jne 0xac650
movl 0x850(%r15), %eax
cmpq %rax, %r14
jne 0xac650
movsd 0x44c15(%rip), %xmm0    # 0xf1260
movsd %xmm0, (%rsp)
cmpw $0x1, 0x12(%r15)
jne 0xac671
movl 0x84c(%r15), %eax
cmpq %rax, %r14
jne 0xac671
movsd 0x45694(%rip), %xmm0    # 0xf1d00
movsd %xmm0, (%rsp)
cmpq $0x0, 0x920(%rbx)
je 0xac6ec
movsd (%rsp), %xmm1
addsd 0x44bd8(%rip), %xmm1    # 0xf1260
xorpd 0x44ba0(%rip), %xmm1    # 0xf1230
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 0x44b9c(%rip), %xmm0    # 0xf1258
jb 0xac6c4
sqrtsd %xmm0, %xmm0
jmp 0xac6cf
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 0xac69f
cmpw $0x1, 0x93c(%rbx)
jne 0xac771
cmpq $0x0, 0x940(%rbx)
je 0xac771
movsd (%rsp), %xmm1
addsd 0x44b53(%rip), %xmm1    # 0xf1260
xorpd 0x44b1b(%rip), %xmm1    # 0xf1230
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 0x44b17(%rip), %xmm0    # 0xf1258
jb 0xac749
sqrtsd %xmm0, %xmm0
jmp 0xac754
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 0xac724
movq 0x930(%rbx), %rcx
movq (%rcx,%r14,8), %rdx
movsd (%rdx), %xmm1
movq 0x9d0(%r15), %rax
movq (%rax,%r14,8), %rdi
movsd (%rdi), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xac7b3
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd 0x74b63(%rip), %xmm1    # 0x121308
ucomisd %xmm2, %xmm1
jbe 0xac9fd
movsd %xmm0, (%rdx)
movzwl 0x93c(%rbx), %esi
cmpw $0x1, %si
jne 0xac7f9
movq 0x950(%rbx), %r8
movq (%r8,%r14,8), %r9
movsd (%r9), %xmm1
movsd (%rdi), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xac7f9
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd 0x74b1e(%rip), %xmm1    # 0x121308
ucomisd %xmm2, %xmm1
jbe 0xacad4
movsd %xmm0, (%r9)
movq 0x920(%rbx), %rdi
movsd -0x8(%rdx,%rdi,8), %xmm0
movq (%rax), %rdx
movq 0x9b8(%r15), %r8
movslq (%r8), %r9
ucomisd -0x8(%rdx,%r9,8), %xmm0
ja 0xac943
cmpw $0x1, %si
jne 0xac855
movq 0x940(%rbx), %rcx
movq 0x950(%rbx), %rsi
movq (%rsi,%r14,8), %rdi
movsd -0x8(%rdi,%rcx,8), %xmm0
movq 0x9c8(%r15), %rdi
movslq (%rdi), %r8
ucomisd -0x8(%rdx,%r8,8), %xmm0
ja 0xaca63
incq %r14
movslq 0x8a4(%rbx), %rax
cmpq %rax, %r14
jl 0xac5a6
xorl %eax, %eax
jmp 0xacb44
leal (,%r12,8), %ecx
leaq 0x44786(%rip), %rsi     # 0xf1004
leaq 0x756d5(%rip), %rdx     # 0x121f5a
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44792(%rip), %rsi     # 0xf1034
leaq 0x756b8(%rip), %rdx     # 0x121f61
movq %rbx, %rdi
movl $0x56d, %ecx            # imm = 0x56D
jmp 0xacb35
leal (,%r12,8), %ecx
leaq 0x4473f(%rip), %rsi     # 0xf1004
leaq 0x756a9(%rip), %rdx     # 0x121f75
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4474b(%rip), %rsi     # 0xf1034
leaq 0x75671(%rip), %rdx     # 0x121f61
movq %rbx, %rdi
movl $0x56f, %ecx            # imm = 0x56F
jmp 0xacb35
shll $0x3, %r12d
leaq 0x446fc(%rip), %rsi     # 0xf1004
leaq 0x75674(%rip), %rdx     # 0x121f83
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44705(%rip), %rsi     # 0xf1034
leaq 0x7562b(%rip), %rdx     # 0x121f61
movq %rbx, %rdi
movl $0x574, %ecx            # imm = 0x574
jmp 0xacb35
movq (%rax), %rax
movslq (%r8), %rdx
movsd -0x8(%rax,%rdx,8), %xmm0
movq (%rcx,%r14,8), %rax
movsd -0x8(%rax,%rdi,8), %xmm1
leaq 0x756c7(%rip), %rsi     # 0x122027
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movb $0x2, %al
callq 0x30c2c
leaq 0x44709(%rip), %rsi     # 0xf1082
leaq 0x75722(%rip), %rdx     # 0x1220a2
leaq 0x820(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44691(%rip), %rsi     # 0xf1034
leaq 0x755b7(%rip), %rdx     # 0x121f61
movq %rbx, %rdi
movl $0x5b4, %ecx            # imm = 0x5B4
jmp 0xacb35
shll $0x3, %r12d
leaq 0x44642(%rip), %rsi     # 0xf1004
leaq 0x755cb(%rip), %rdx     # 0x121f94
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4464b(%rip), %rsi     # 0xf1034
leaq 0x75571(%rip), %rdx     # 0x121f61
movq %rbx, %rdi
movl $0x576, %ecx            # imm = 0x576
jmp 0xacb35
movq (%rax), %rax
movsd (%rax), %xmm0
movq (%rcx,%r14,8), %rax
movsd (%rax), %xmm1
leaq 0x75599(%rip), %rsi     # 0x121fac
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movb $0x2, %al
callq 0x30c2c
leaq 0x44b59(%rip), %rsi     # 0xf1585
leaq 0x820(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x445e5(%rip), %rsi     # 0xf1034
leaq 0x7550b(%rip), %rdx     # 0x121f61
movq %rbx, %rdi
movl $0x598, %ecx            # imm = 0x598
jmp 0xacb35
movq (%rax), %rax
movslq (%rdi), %rdx
movsd -0x8(%rax,%rdx,8), %xmm0
movq (%rsi,%r14,8), %rax
movsd -0x8(%rax,%rcx,8), %xmm1
leaq 0x755a7(%rip), %rsi     # 0x122027
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movb $0x2, %al
callq 0x30c2c
leaq 0x445e9(%rip), %rsi     # 0xf1082
leaq 0x75643(%rip), %rdx     # 0x1220e3
leaq 0x820(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44571(%rip), %rsi     # 0xf1034
leaq 0x75497(%rip), %rdx     # 0x121f61
movq %rbx, %rdi
movl $0x5bd, %ecx            # imm = 0x5BD
jmp 0xacb35
movq (%rax), %rax
movsd (%rax), %xmm0
movq (%r8,%r14,8), %rax
movsd (%rax), %xmm1
leaq 0x754c2(%rip), %rsi     # 0x121fac
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl %r14d, %edx
movb $0x2, %al
callq 0x30c2c
leaq 0x44a82(%rip), %rsi     # 0xf1585
leaq 0x820(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4450e(%rip), %rsi     # 0xf1034
leaq 0x75434(%rip), %rdx     # 0x121f61
movq %rbx, %rdi
movl $0x5a9, %ecx            # imm = 0x5A9
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r14
popq %r15
retq