// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_indices
int transfer_indices(
                     struct precision * ppr,
                     struct perturbations * ppt,
                     struct transfer * ptr,
                     double q_period,
                     double K,
                     int sgnK
                     ) {

  /** Summary: */

  /** - define local variables */

  int index_md,index_tt,index_tt_common;

  /** - define indices for transfer types */

  class_alloc(ptr->tt_size,ptr->md_size * sizeof(int),ptr->error_message);

  /** - type indices common to scalars and tensors */

  index_tt = 0;

  class_define_index(ptr->index_tt_t2,ppt->has_cl_cmb_temperature, index_tt,1);
  class_define_index(ptr->index_tt_e, ppt->has_cl_cmb_polarization,index_tt,1);

  index_tt_common=index_tt;

  /** - type indices for scalars */

  if (ppt->has_scalars == _TRUE_) {

    index_tt = index_tt_common;

    class_define_index(ptr->index_tt_t0,     ppt->has_cl_cmb_temperature,      index_tt,1);
    class_define_index(ptr->index_tt_t1,     ppt->has_cl_cmb_temperature,      index_tt,1);
    class_define_index(ptr->index_tt_lcmb,   ppt->has_cl_cmb_lensing_potential,index_tt,1);
    class_define_index(ptr->index_tt_density,ppt->has_nc_density,              index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_rsd,    ppt->has_nc_rsd,                  index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_d0,     ppt->has_nc_rsd,                  index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_d1,     ppt->has_nc_rsd,                  index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_nc_lens,ppt->has_nc_lens,                 index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_nc_g1,  ppt->has_nc_gr,                   index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_nc_g2,  ppt->has_nc_gr,                   index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_nc_g3,  ppt->has_nc_gr,                   index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_nc_g4,  ppt->has_nc_gr,                   index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_nc_g5,  ppt->has_nc_gr,                   index_tt,ppt->selection_num);
    class_define_index(ptr->index_tt_lensing,ppt->has_cl_lensing_potential,    index_tt,ppt->selection_num);

    ptr->tt_size[ppt->index_md_scalars]=index_tt;

  }

  /** - type indices for vectors */

  if (ppt->has_vectors == _TRUE_) {

    index_tt = index_tt_common;

    class_define_index(ptr->index_tt_t1,ppt->has_cl_cmb_temperature, index_tt,1);
    class_define_index(ptr->index_tt_b, ppt->has_cl_cmb_polarization,index_tt,1);

    ptr->tt_size[ppt->index_md_vectors]=index_tt;

  }

  /** - type indices for tensors */

  if (ppt->has_tensors == _TRUE_) {

    index_tt = index_tt_common;

    class_define_index(ptr->index_tt_b, ppt->has_cl_cmb_polarization,index_tt,1);

    ptr->tt_size[ppt->index_md_tensors]=index_tt;

  }

  /** - allocate arrays of (k, l) values and transfer functions */

  /* number of l values for each mode and type,
     l_size_tt[index_md][index_tt], and maximized for each mode,
     l_size[index_md] */

  class_alloc(ptr->l_size,ptr->md_size * sizeof(int),ptr->error_message);

  class_alloc(ptr->l_size_tt,ptr->md_size * sizeof(int *),ptr->error_message);

  for (index_md = 0; index_md < ptr->md_size; index_md++) {
    class_alloc(ptr->l_size_tt[index_md],ptr->tt_size[index_md] * sizeof(int),ptr->error_message);
  }

  /* array (of array) of transfer functions for each mode, transfer[index_md] */

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

  /** - get q values using transfer_get_q_list() */

  class_call(transfer_get_q_list(ppr,ppt,ptr,q_period,K,sgnK),
             ptr->error_message,
             ptr->error_message);

  /** - get q values in full Limber case using transfer_get_q_limber_list() */

  if (ptr->do_lcmb_full_limber == _TRUE_) {
    class_call(transfer_get_q_limber_list(ppr,ppt,ptr,K,sgnK),
               ptr->error_message,
               ptr->error_message);
  }
  else {
    ptr->q_size_limber=0;
  }

  /** - get k values using transfer_get_k_list() */

  class_call(transfer_get_k_list(ppt,ptr,K),
             ptr->error_message,
             ptr->error_message);

  /* for testing, it can be useful to print the q list in a file: */

  /*
    FILE * out=fopen("output/q","w");
    int index_q;

    for (index_q=0; index_q < ptr->q_size; index_q++) {

    fprintf(out,"%d %e %e %e %e\n",
    index_q,
    ptr->q[index_q],
    ptr->k[0][index_q],
    ptr->q[index_q]/sqrt(sgnK*K),
    ptr->q[index_q+1]-ptr->q[index_q]);

    }

    fclose(out);
  */

  /** - get l values using transfer_get_l_list() */
  class_call(transfer_get_l_list(ppr,ppt,ptr),
             ptr->error_message,
             ptr->error_message);

  /** - loop over modes (scalar, etc). For each mode: */

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

    /** - allocate arrays of transfer functions, (ptr->transfer[index_md])[index_ic][index_tt][index_l][index_k] */
    class_alloc(ptr->transfer[index_md],
                ppt->ic_size[index_md] * ptr->tt_size[index_md] * ptr->l_size[index_md] * ptr->q_size * sizeof(double),
                ptr->error_message);

    if (ptr->do_lcmb_full_limber == _TRUE_) {
      class_alloc(ptr->transfer_limber[index_md],
                  ppt->ic_size[index_md] * ptr->tt_size[index_md] * ptr->l_size[index_md] * ptr->q_size_limber * sizeof(double),
                  ptr->error_message);
    }

  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movl %ecx, %ebp
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, 0x18(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movslq 0x8a4(%rdx), %r15
leaq (,%r15,4), %r13
movq %r13, %rdi
callq 0x8460
movq %rax, 0x8f0(%rbx)
testq %rax, %rax
je 0xa7794
movzwl 0x28(%r14), %esi
testw %si, %si
je 0xa77da
movl $0x0, 0x8b0(%rbx)
movl $0x1, %ecx
jmp 0xa77dc
shll $0x2, %r15d
leaq 0x49865(%rip), %rsi     # 0xf1004
leaq 0x7a27e(%rip), %rdx     # 0x121a24
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4986e(%rip), %rsi     # 0xf1034
leaq 0x7a264(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x1f7, %ecx            # imm = 0x1F7
jmp 0xa7cee
xorl %ecx, %ecx
movzwl 0x2a(%r14), %edx
testw %dx, %dx
je 0xa77ee
movl %ecx, 0x8b4(%rbx)
incl %ecx
cmpw $0x1, 0xe(%r14)
jne 0xa78f2
movl %ecx, %edi
testw %si, %si
je 0xa780a
movl %ecx, 0x8a8(%rbx)
leal 0x1(%rcx), %edi
testw %si, %si
je 0xa7817
movl %edi, 0x8ac(%rbx)
incl %edi
cmpw $0x0, 0x2c(%r14)
je 0xa7827
movl %edi, 0x8bc(%rbx)
incl %edi
cmpw $0x0, 0x3e(%r14)
je 0xa7839
movl %edi, 0x8c0(%rbx)
addl 0x64(%r14), %edi
movzwl 0x40(%r14), %r8d
testw %r8w, %r8w
je 0xa784e
movl %edi, 0x8c8(%rbx)
addl 0x64(%r14), %edi
testw %r8w, %r8w
je 0xa785e
movl %edi, 0x8cc(%rbx)
addl 0x64(%r14), %edi
testw %r8w, %r8w
je 0xa786e
movl %edi, 0x8d0(%rbx)
addl 0x64(%r14), %edi
cmpw $0x0, 0x42(%r14)
je 0xa7880
movl %edi, 0x8d4(%rbx)
addl 0x64(%r14), %edi
movzwl 0x44(%r14), %r8d
testw %r8w, %r8w
je 0xa7895
movl %edi, 0x8d8(%rbx)
addl 0x64(%r14), %edi
testw %r8w, %r8w
je 0xa78a5
movl %edi, 0x8dc(%rbx)
addl 0x64(%r14), %edi
testw %r8w, %r8w
je 0xa78b5
movl %edi, 0x8e0(%rbx)
addl 0x64(%r14), %edi
testw %r8w, %r8w
je 0xa78c5
movl %edi, 0x8e4(%rbx)
addl 0x64(%r14), %edi
testw %r8w, %r8w
je 0xa78d5
movl %edi, 0x8e8(%rbx)
addl 0x64(%r14), %edi
cmpw $0x0, 0x2e(%r14)
je 0xa78e7
movl %edi, 0x8c4(%rbx)
addl 0x64(%r14), %edi
movslq 0x848(%r14), %r8
movl %edi, (%rax,%r8,4)
cmpw $0x1, 0x10(%r14)
jne 0xa7921
movl %ecx, %edi
testw %si, %si
je 0xa790a
movl %ecx, 0x8ac(%rbx)
leal 0x1(%rcx), %edi
testw %dx, %dx
je 0xa7917
movl %edi, 0x8b8(%rbx)
incl %edi
movslq 0x850(%r14), %rsi
movl %edi, (%rax,%rsi,4)
cmpw $0x1, 0x12(%r14)
jne 0xa7940
testw %dx, %dx
je 0xa7936
movl %ecx, 0x8b8(%rbx)
incl %ecx
movslq 0x84c(%r14), %rdx
movl %ecx, (%rax,%rdx,4)
movq %r13, %rdi
callq 0x8460
movq %rax, 0x900(%rbx)
testq %rax, %rax
je 0xa7a67
leaq (,%r15,8), %r13
movq %r13, %rdi
callq 0x8460
movq %rax, 0x8f8(%rbx)
testq %rax, %rax
je 0xa7aad
movl %ebp, 0x14(%rsp)
movq %r12, %rbp
testl %r15d, %r15d
jle 0xa79c0
xorl %r12d, %r12d
movq 0x8f0(%rbx), %rax
movslq (%rax,%r12,4), %rdi
shlq $0x2, %rdi
callq 0x8460
movq 0x8f8(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x8f8(%rbx), %rax
cmpq $0x0, (%rax,%r12,8)
je 0xa7af3
incq %r12
cmpq %r12, %r15
jne 0xa7987
movq %r13, %rdi
callq 0x8460
movq %rax, 0x958(%rbx)
testq %rax, %rax
je 0xa7b40
cmpw $0x1, 0x93c(%rbx)
jne 0xa79fa
movq %r13, %rdi
callq 0x8460
movq %rax, 0x960(%rbx)
testq %rax, %rax
je 0xa7bfa
movq %rbp, %r15
movq %rbp, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movsd 0x18(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movl 0x14(%rsp), %ebp
movl %ebp, %ecx
callq 0xab544
testl %eax, %eax
je 0xa7b86
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x499bd(%rip), %rsi     # 0xf13f0
leaq 0x7a05f(%rip), %rdx     # 0x121a99
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x495e1(%rip), %rsi     # 0xf1034
leaq 0x79fd7(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x24d, %ecx            # imm = 0x24D
jmp 0xa7cee
shll $0x2, %r15d
leaq 0x49592(%rip), %rsi     # 0xf1004
leaq 0x79fc9(%rip), %rdx     # 0x121a42
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4959b(%rip), %rsi     # 0xf1034
leaq 0x79f91(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x23a, %ecx            # imm = 0x23A
jmp 0xa7cee
shll $0x3, %r15d
leaq 0x4954c(%rip), %rsi     # 0xf1004
leaq 0x79f8f(%rip), %rdx     # 0x121a4e
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49555(%rip), %rsi     # 0xf1034
leaq 0x79f4b(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x23c, %ecx            # imm = 0x23C
jmp 0xa7cee
movq 0x8f0(%rbx), %rax
movl (%rax,%r12,4), %ecx
shll $0x2, %ecx
leaq 0x494fc(%rip), %rsi     # 0xf1004
leaq 0x79f4e(%rip), %rdx     # 0x121a5d
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49508(%rip), %rsi     # 0xf1034
leaq 0x79efe(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x23f, %ecx            # imm = 0x23F
jmp 0xa7cee
shll $0x3, %r15d
leaq 0x494b9(%rip), %rsi     # 0xf1004
leaq 0x79f24(%rip), %rdx     # 0x121a76
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x494c2(%rip), %rsi     # 0xf1034
leaq 0x79eb8(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x244, %ecx            # imm = 0x244
jmp 0xa7cee
cmpw $0x1, 0x93c(%rbx)
jne 0xa7c40
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movsd 0x8(%rsp), %xmm0
movl %ebp, %ecx
callq 0xac16c
movsd 0x8(%rsp), %xmm0
testl %eax, %eax
je 0xa7c51
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4982a(%rip), %rsi     # 0xf13f0
leaq 0x79efd(%rip), %rdx     # 0x121aca
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x4944e(%rip), %rsi     # 0xf1034
leaq 0x79e44(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x254, %ecx            # imm = 0x254
jmp 0xa7cee
shll $0x3, %r15d
leaq 0x493ff(%rip), %rsi     # 0xf1004
leaq 0x79e78(%rip), %rdx     # 0x121a84
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49408(%rip), %rsi     # 0xf1034
leaq 0x79dfe(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x246, %ecx            # imm = 0x246
jmp 0xa7cee
movq $0x0, 0x940(%rbx)
movsd 0x8(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0xac52b
testl %eax, %eax
je 0xa7c9f
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49782(%rip), %rsi     # 0xf13f0
leaq 0x79e84(%rip), %rdx     # 0x121af9
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x493a6(%rip), %rsi     # 0xf1034
leaq 0x79d9c(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x25e, %ecx            # imm = 0x25E
jmp 0xa7cee
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xacb53
testl %eax, %eax
je 0xa7d0f
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49731(%rip), %rsi     # 0xf13f0
leaq 0x79e52(%rip), %rdx     # 0x121b18
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x49355(%rip), %rsi     # 0xf1034
leaq 0x79d4b(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x277, %ecx            # imm = 0x277
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %eax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x8a4(%rbx), %rbp
testq %rbp, %rbp
jle 0xa7dfd
movq 0x920(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq (,%rax,8), %r15
shlq $0x2, %rbp
xorl %r13d, %r13d
movq 0x870(%r14), %rax
movslq (%rax,%r13), %rax
movq 0x8f0(%rbx), %rcx
movq 0x900(%rbx), %rdx
movslq (%rcx,%r13), %rcx
imulq %rax, %rcx
movslq (%rdx,%r13), %rdi
imulq %r15, %rdi
imulq %rcx, %rdi
callq 0x8460
movq 0x958(%rbx), %rcx
movq %rax, (%rcx,%r13,2)
movq 0x958(%rbx), %rax
cmpq $0x0, (%rax,%r13,2)
je 0xa7e04
cmpw $0x1, 0x93c(%rbx)
jne 0xa7de9
movq 0x870(%r14), %rax
movslq (%rax,%r13), %rax
movq 0x8f0(%rbx), %rcx
movq 0x900(%rbx), %rdx
movslq (%rcx,%r13), %rcx
imulq %rax, %rcx
movslq (%rdx,%r13), %rdi
movq 0x940(%rbx), %r12
imulq %r12, %rdi
imulq %rcx, %rdi
shlq $0x3, %rdi
callq 0x8460
movq 0x960(%rbx), %rcx
movq %rax, (%rcx,%r13,2)
movq 0x960(%rbx), %rax
cmpq $0x0, (%rax,%r13,2)
je 0xa7e6f
addq $0x4, %r13
xorl %eax, %eax
cmpq %r13, %rbp
jne 0xa7d3a
jmp 0xa7cfd
xorl %eax, %eax
jmp 0xa7cfd
movq 0x870(%r14), %rax
movq 0x8f0(%rbx), %rdx
movq 0x8(%rsp), %rcx
imull (%rax,%r13), %ecx
imull (%rdx,%r13), %ecx
movq 0x900(%rbx), %rax
imull (%rax,%r13), %ecx
shll $0x3, %ecx
leaq 0x491cd(%rip), %rsi     # 0xf1004
leaq 0x79cfb(%rip), %rdx     # 0x121b39
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x491d9(%rip), %rsi     # 0xf1034
leaq 0x79bcf(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x280, %ecx            # imm = 0x280
jmp 0xa7cee
movq 0x870(%r14), %rax
movq 0x8f0(%rbx), %rcx
imull (%rax,%r13), %r12d
imull (%rcx,%r13), %r12d
movq 0x900(%rbx), %rax
imull (%rax,%r13), %r12d
shll $0x3, %r12d
leaq 0x49166(%rip), %rsi     # 0xf1004
leaq 0x79cac(%rip), %rdx     # 0x121b51
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4916f(%rip), %rsi     # 0xf1034
leaq 0x79b65(%rip), %rdx     # 0x121a31
movq %rbx, %rdi
movl $0x285, %ecx            # imm = 0x285
jmp 0xa7cee