// File: /workspace/github_c_makefile_star2_O3/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, %r12d
movsd %xmm1, (%rsp)
movsd %xmm0, 0x18(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rbp
movslq 0x8a4(%rdx), %r15
leaq (,%r15,4), %r13
movq %r13, %rdi
callq 0x8460
movq %rax, 0x8f0(%rbx)
testq %rax, %rax
je 0xa48f8
movzwl 0x28(%r14), %esi
testw %si, %si
je 0xa493e
movl $0x0, 0x8b0(%rbx)
movl $0x1, %ecx
jmp 0xa4940
shll $0x2, %r15d
leaq 0x49701(%rip), %rsi     # 0xee004
leaq 0x7a15a(%rip), %rdx     # 0x11ea64
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4970a(%rip), %rsi     # 0xee034
leaq 0x7a140(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x1f7, %ecx            # imm = 0x1F7
jmp 0xa4e1f
xorl %ecx, %ecx
movzwl 0x2a(%r14), %edx
testw %dx, %dx
je 0xa4952
movl %ecx, 0x8b4(%rbx)
incl %ecx
cmpw $0x1, 0xe(%r14)
jne 0xa4a28
movl %ecx, %edi
testw %si, %si
je 0xa4977
movl %ecx, 0x8a8(%rbx)
leal 0x1(%rcx), %edi
movl %edi, 0x8ac(%rbx)
leal 0x2(%rcx), %edi
cmpw $0x0, 0x2c(%r14)
je 0xa4987
movl %edi, 0x8bc(%rbx)
incl %edi
cmpw $0x0, 0x3e(%r14)
je 0xa4999
movl %edi, 0x8c0(%rbx)
addl 0x64(%r14), %edi
cmpw $0x0, 0x40(%r14)
je 0xa49c0
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 0xa49d2
movl %edi, 0x8d4(%rbx)
addl 0x64(%r14), %edi
cmpw $0x0, 0x44(%r14)
je 0xa4a0b
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 0xa4a1d
movl %edi, 0x8c4(%rbx)
addl 0x64(%r14), %edi
movslq 0x848(%r14), %r8
movl %edi, (%rax,%r8,4)
cmpw $0x1, 0x10(%r14)
jne 0xa4a57
movl %ecx, %edi
testw %si, %si
je 0xa4a40
movl %ecx, 0x8ac(%rbx)
leal 0x1(%rcx), %edi
testw %dx, %dx
je 0xa4a4d
movl %edi, 0x8b8(%rbx)
incl %edi
movslq 0x850(%r14), %rsi
movl %edi, (%rax,%rsi,4)
cmpw $0x1, 0x12(%r14)
jne 0xa4a76
testw %dx, %dx
je 0xa4a6c
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 0xa4b9c
movl %r12d, 0xc(%rsp)
leaq (,%r15,8), %r13
movq %r13, %rdi
callq 0x8460
movq %rax, 0x8f8(%rbx)
testq %rax, %rax
je 0xa4be2
movq %rbp, 0x10(%rsp)
testl %r15d, %r15d
jle 0xa4af4
movq %rax, %r12
xorl %ebp, %ebp
movq 0x8f0(%rbx), %rax
movslq (%rax,%rbp,4), %rdi
shlq $0x2, %rdi
callq 0x8460
movq %rax, (%r12,%rbp,8)
movq 0x8f8(%rbx), %r12
cmpq $0x0, (%r12,%rbp,8)
je 0xa4c28
incq %rbp
cmpq %rbp, %r15
jne 0xa4ac2
movq %r13, %rdi
callq 0x8460
movq %rax, 0x958(%rbx)
testq %rax, %rax
je 0xa4c74
cmpw $0x1, 0x93c(%rbx)
jne 0xa4b2e
movq %r13, %rdi
callq 0x8460
movq %rax, 0x960(%rbx)
testq %rax, %rax
je 0xa4d2c
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movsd 0x18(%rsp), %xmm0
movsd (%rsp), %xmm1
movl 0xc(%rsp), %ebp
movl %ebp, %ecx
callq 0xa8520
testl %eax, %eax
je 0xa4cba
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49888(%rip), %rsi     # 0xee3f0
leaq 0x79f6a(%rip), %rdx     # 0x11ead9
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x494ac(%rip), %rsi     # 0xee034
leaq 0x79ee2(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x24d, %ecx            # imm = 0x24D
jmp 0xa4e1f
shll $0x2, %r15d
leaq 0x4945d(%rip), %rsi     # 0xee004
leaq 0x79ed4(%rip), %rdx     # 0x11ea82
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49466(%rip), %rsi     # 0xee034
leaq 0x79e9c(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x23a, %ecx            # imm = 0x23A
jmp 0xa4e1f
shll $0x3, %r15d
leaq 0x49417(%rip), %rsi     # 0xee004
leaq 0x79e9a(%rip), %rdx     # 0x11ea8e
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49420(%rip), %rsi     # 0xee034
leaq 0x79e56(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x23c, %ecx            # imm = 0x23C
jmp 0xa4e1f
movq 0x8f0(%rbx), %rax
movl (%rax,%rbp,4), %ecx
shll $0x2, %ecx
leaq 0x493c8(%rip), %rsi     # 0xee004
leaq 0x79e5a(%rip), %rdx     # 0x11ea9d
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x493d4(%rip), %rsi     # 0xee034
leaq 0x79e0a(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x23f, %ecx            # imm = 0x23F
jmp 0xa4e1f
shll $0x3, %r15d
leaq 0x49385(%rip), %rsi     # 0xee004
leaq 0x79e30(%rip), %rdx     # 0x11eab6
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4938e(%rip), %rsi     # 0xee034
leaq 0x79dc4(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x244, %ecx            # imm = 0x244
jmp 0xa4e1f
cmpw $0x1, 0x93c(%rbx)
jne 0xa4d72
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movsd (%rsp), %xmm0
movl %ebp, %ecx
callq 0xa9172
movsd (%rsp), %xmm0
testl %eax, %eax
je 0xa4d82
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x496f8(%rip), %rsi     # 0xee3f0
leaq 0x79e0b(%rip), %rdx     # 0x11eb0a
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x4931c(%rip), %rsi     # 0xee034
leaq 0x79d52(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x254, %ecx            # imm = 0x254
jmp 0xa4e1f
shll $0x3, %r15d
leaq 0x492cd(%rip), %rsi     # 0xee004
leaq 0x79d86(%rip), %rdx     # 0x11eac4
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x492d6(%rip), %rsi     # 0xee034
leaq 0x79d0c(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x246, %ecx            # imm = 0x246
jmp 0xa4e1f
movq $0x0, 0x940(%rbx)
movsd (%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa9531
testl %eax, %eax
je 0xa4dd0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49651(%rip), %rsi     # 0xee3f0
leaq 0x79d93(%rip), %rdx     # 0x11eb39
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x49275(%rip), %rsi     # 0xee034
leaq 0x79cab(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x25e, %ecx            # imm = 0x25E
jmp 0xa4e1f
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xa9b1f
testl %eax, %eax
je 0xa4e40
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49600(%rip), %rsi     # 0xee3f0
leaq 0x79d61(%rip), %rdx     # 0x11eb58
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x49224(%rip), %rsi     # 0xee034
leaq 0x79c5a(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x277, %ecx            # imm = 0x277
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
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 0xa4f2d
movq 0x920(%rbx), %rax
movq %rax, (%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 0xa4f34
cmpw $0x1, 0x93c(%rbx)
jne 0xa4f19
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 0xa4f9e
addq $0x4, %r13
xorl %eax, %eax
cmpq %r13, %rbp
jne 0xa4e6a
jmp 0xa4e2e
xorl %eax, %eax
jmp 0xa4e2e
movq 0x870(%r14), %rax
movq 0x8f0(%rbx), %rdx
movq (%rsp), %rcx
imull (%rax,%r13), %ecx
imull (%rdx,%r13), %ecx
movq 0x900(%rbx), %rax
imull (%rax,%r13), %ecx
shll $0x3, %ecx
leaq 0x4909e(%rip), %rsi     # 0xee004
leaq 0x79c0c(%rip), %rdx     # 0x11eb79
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x490aa(%rip), %rsi     # 0xee034
leaq 0x79ae0(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x280, %ecx            # imm = 0x280
jmp 0xa4e1f
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 0x49037(%rip), %rsi     # 0xee004
leaq 0x79bbd(%rip), %rdx     # 0x11eb91
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x49040(%rip), %rsi     # 0xee034
leaq 0x79a76(%rip), %rdx     # 0x11ea71
movq %rbx, %rdi
movl $0x285, %ecx            # imm = 0x285
jmp 0xa4e1f