// File: /workspace/github_c_makefile_star2_O2/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 $0x838, %rsp            # imm = 0x838
movl %ecx, %r12d
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, 0x28(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rbp
movslq 0x8a4(%rdx), %r15
leaq (,%r15,4), %r13
movq %r13, %rdi
callq 0x8490
movq %rax, 0x8f0(%rbx)
testq %rax, %rax
je 0x9f9a7
movzwl 0x28(%r14), %esi
testw %si, %si
je 0x9f9ed
pushq $0x1
popq %rcx
andl $0x0, 0x8b0(%rbx)
jmp 0x9f9ef
shll $0x2, %r15d
leaq 0x45652(%rip), %rsi     # 0xe5004
leaq 0x75f3b(%rip), %rdx     # 0x1158f4
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4565b(%rip), %rsi     # 0xe5034
leaq 0x75f21(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x1f7, %ecx            # imm = 0x1F7
jmp 0x9fee6
xorl %ecx, %ecx
movzwl 0x2a(%r14), %edx
testw %dx, %dx
je 0x9fa01
movl %ecx, 0x8b4(%rbx)
incl %ecx
cmpw $0x1, 0xe(%r14)
jne 0x9fad7
movl %ecx, %edi
testw %si, %si
je 0x9fa26
movl %ecx, 0x8a8(%rbx)
leal 0x1(%rcx), %edi
movl %edi, 0x8ac(%rbx)
leal 0x2(%rcx), %edi
cmpw $0x0, 0x2c(%r14)
je 0x9fa36
movl %edi, 0x8bc(%rbx)
incl %edi
cmpw $0x0, 0x3e(%r14)
je 0x9fa48
movl %edi, 0x8c0(%rbx)
addl 0x64(%r14), %edi
cmpw $0x0, 0x40(%r14)
je 0x9fa6f
movl %edi, 0x8c8(%rbx)
movl 0x64(%r14), %r8d
addl %r8d, %edi
movl %edi, 0x8cc(%rbx)
addl %r8d, %edi
movl %edi, 0x8d0(%rbx)
addl %r8d, %edi
cmpw $0x0, 0x42(%r14)
je 0x9fa81
movl %edi, 0x8d4(%rbx)
addl 0x64(%r14), %edi
cmpw $0x0, 0x44(%r14)
je 0x9faba
movl %edi, 0x8d8(%rbx)
movl 0x64(%r14), %r8d
addl %r8d, %edi
movl %edi, 0x8dc(%rbx)
addl %r8d, %edi
movl %edi, 0x8e0(%rbx)
addl %r8d, %edi
movl %edi, 0x8e4(%rbx)
addl %r8d, %edi
movl %edi, 0x8e8(%rbx)
addl %r8d, %edi
cmpw $0x0, 0x2e(%r14)
je 0x9facc
movl %edi, 0x8c4(%rbx)
addl 0x64(%r14), %edi
movslq 0x848(%r14), %r8
movl %edi, (%rax,%r8,4)
cmpw $0x1, 0x10(%r14)
jne 0x9fb06
movl %ecx, %edi
testw %si, %si
je 0x9faef
movl %ecx, 0x8ac(%rbx)
leal 0x1(%rcx), %edi
testw %dx, %dx
je 0x9fafc
movl %edi, 0x8b8(%rbx)
incl %edi
movslq 0x850(%r14), %rsi
movl %edi, (%rax,%rsi,4)
cmpw $0x1, 0x12(%r14)
jne 0x9fb25
testw %dx, %dx
je 0x9fb1b
movl %ecx, 0x8b8(%rbx)
incl %ecx
movslq 0x84c(%r14), %rdx
movl %ecx, (%rax,%rdx,4)
movq %r13, %rdi
callq 0x8490
movq %rax, 0x900(%rbx)
testq %rax, %rax
je 0x9fc01
movl %r12d, 0x14(%rsp)
leaq (,%r15,8), %r13
movq %r13, %rdi
callq 0x8490
movq %rax, 0x8f8(%rbx)
testq %rax, %rax
je 0x9fc47
movq %rax, %r12
movq %r13, 0x20(%rsp)
movq %rbp, 0x18(%rsp)
xorl %r13d, %r13d
testl %r15d, %r15d
movl $0x0, %ebp
cmovgl %r15d, %ebp
cmpq %r13, %rbp
je 0x9fc8d
movq 0x8f0(%rbx), %rax
movslq (%rax,%r13,4), %rdi
shlq $0x2, %rdi
callq 0x8490
movq %rax, (%r12,%r13,8)
movq 0x8f8(%rbx), %r12
leaq 0x1(%r13), %rax
cmpq $0x0, (%r12,%r13,8)
movq %rax, %r13
jne 0x9fb7e
movq 0x8f0(%rbx), %rcx
movl -0x4(%rcx,%rax,4), %ecx
shll $0x2, %ecx
leaq 0x4543b(%rip), %rsi     # 0xe5004
leaq 0x75d5d(%rip), %rdx     # 0x11592d
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x45447(%rip), %rsi     # 0xe5034
leaq 0x75d0d(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x23f, %ecx            # imm = 0x23F
jmp 0x9fee6
shll $0x2, %r15d
leaq 0x453f8(%rip), %rsi     # 0xe5004
leaq 0x75cff(%rip), %rdx     # 0x115912
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x45401(%rip), %rsi     # 0xe5034
leaq 0x75cc7(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x23a, %ecx            # imm = 0x23A
jmp 0x9fee6
shll $0x3, %r15d
leaq 0x453b2(%rip), %rsi     # 0xe5004
leaq 0x75cc5(%rip), %rdx     # 0x11591e
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x453bb(%rip), %rsi     # 0xe5034
leaq 0x75c81(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x23c, %ecx            # imm = 0x23C
jmp 0x9fee6
movq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x8490
movq %rax, 0x958(%rbx)
testq %rax, %rax
je 0x9fd3b
cmpw $0x1, 0x93c(%rbx)
jne 0x9fccc
movq %r12, %rdi
callq 0x8490
movq %rax, 0x960(%rbx)
testq %rax, %rax
je 0x9fdf5
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movl 0x14(%rsp), %ebp
movl %ebp, %ecx
callq 0xa3265
testl %eax, %eax
je 0x9fd81
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x456e9(%rip), %rsi     # 0xe53f0
leaq 0x75c5b(%rip), %rdx     # 0x115969
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x4530d(%rip), %rsi     # 0xe5034
leaq 0x75bd3(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x24d, %ecx            # imm = 0x24D
jmp 0x9fee6
shll $0x3, %r15d
leaq 0x452be(%rip), %rsi     # 0xe5004
leaq 0x75bf9(%rip), %rdx     # 0x115946
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x452c7(%rip), %rsi     # 0xe5034
leaq 0x75b8d(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x244, %ecx            # imm = 0x244
jmp 0x9fee6
cmpw $0x1, 0x93c(%rbx)
jne 0x9fe3b
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movsd 0x8(%rsp), %xmm0
movl %ebp, %ecx
callq 0xa3e2a
movsd 0x8(%rsp), %xmm0
testl %eax, %eax
je 0x9fe49
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4562f(%rip), %rsi     # 0xe53f0
leaq 0x75bd2(%rip), %rdx     # 0x11599a
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x45253(%rip), %rsi     # 0xe5034
leaq 0x75b19(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x254, %ecx            # imm = 0x254
jmp 0x9fee6
shll $0x3, %r15d
leaq 0x45204(%rip), %rsi     # 0xe5004
leaq 0x75b4d(%rip), %rdx     # 0x115954
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4520d(%rip), %rsi     # 0xe5034
leaq 0x75ad3(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x246, %ecx            # imm = 0x246
jmp 0x9fee6
andq $0x0, 0x940(%rbx)
movsd 0x8(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa41c3
testl %eax, %eax
je 0x9fe97
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4558a(%rip), %rsi     # 0xe53f0
leaq 0x75b5c(%rip), %rdx     # 0x1159c9
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x451ae(%rip), %rsi     # 0xe5034
leaq 0x75a74(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x25e, %ecx            # imm = 0x25E
jmp 0x9fee6
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xa479d
testl %eax, %eax
je 0x9ff09
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x45539(%rip), %rsi     # 0xe53f0
leaq 0x75b2a(%rip), %rdx     # 0x1159e8
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x4515d(%rip), %rsi     # 0xe5034
leaq 0x75a23(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x277, %ecx            # imm = 0x277
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %r15
movl %r15d, %eax
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8a4(%rbx), %ebp
xorl %r15d, %r15d
testl %ebp, %ebp
cmovlel %r15d, %ebp
shlq $0x2, %rbp
xorl %r13d, %r13d
cmpq %r13, %rbp
je 0x9fef4
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 0x920(%rbx), %r12
imulq %r12, %rdi
imulq %rcx, %rdi
shlq $0x3, %rdi
callq 0x8490
movq 0x958(%rbx), %rcx
movq %rax, (%rcx,%r13,2)
movq 0x958(%rbx), %rax
cmpq $0x0, (%rax,%r13,2)
je 0x9ffe3
cmpw $0x1, 0x93c(%rbx)
jne 0x9ffda
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 0x8490
movq 0x960(%rbx), %rcx
movq %rax, (%rcx,%r13,2)
movq 0x960(%rbx), %rax
cmpq $0x0, (%rax,%r13,2)
je 0xa004d
addq $0x4, %r13
jmp 0x9ff1f
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 0x44ff2(%rip), %rsi     # 0xe5004
leaq 0x759f0(%rip), %rdx     # 0x115a09
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44ffb(%rip), %rsi     # 0xe5034
leaq 0x758c1(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x280, %ecx            # imm = 0x280
jmp 0x9fee6
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 0x44f88(%rip), %rsi     # 0xe5004
leaq 0x7599e(%rip), %rdx     # 0x115a21
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x44f91(%rip), %rsi     # 0xe5034
leaq 0x75857(%rip), %rdx     # 0x115901
movq %rbx, %rdi
movl $0x285, %ecx            # imm = 0x285
jmp 0x9fee6