// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/perturbations.c
// Function: perturbations_output_data
int perturbations_output_data(
                              struct background * pba,
                              struct perturbations * ppt,
                              enum file_format output_format,
                              double * tkfull,
                              int number_of_titles,
                              double *data
                              ) {

  int n_ncdm;
  double k, k_over_h, k2;
  double *tk;
  double *dataptr;
  int index_md = ppt->index_md_scalars;
  int index_ic;
  int index_k;
  int storeidx;

  /** - store data */

  for (index_ic = 0; index_ic < ppt->ic_size[index_md]; index_ic++) {

    for (index_k=0; index_k<ppt->k_size[index_md]; index_k++) {

      storeidx = 0;
      dataptr = data+index_ic*(ppt->k_size[index_md]*number_of_titles)+index_k*number_of_titles;
      tk = &(tkfull[(index_k * ppt->ic_size[index_md] + index_ic) * ppt->tp_size[index_md]]);
      k = ppt->k[index_md][index_k];
      k2 = k*k;
      k_over_h = k/pba->h;

      class_store_double(dataptr, k_over_h, _TRUE_,storeidx);

      /* indices for species associated with a velocity transfer function in Fourier space */

      if (output_format == class_format) {

        if (ppt->has_density_transfers == _TRUE_) {
          class_store_double(dataptr,tk[ppt->index_tp_delta_g],ppt->has_source_delta_g,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_b],ppt->has_source_delta_b,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_cdm],ppt->has_source_delta_cdm,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_idm],ppt->has_source_delta_idm,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_fld],ppt->has_source_delta_fld,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_ur],ppt->has_source_delta_ur,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_idr],ppt->has_source_delta_idr,storeidx);
          if (pba->has_ncdm == _TRUE_){
            for (n_ncdm = 0; n_ncdm < pba->N_ncdm; n_ncdm++){
              class_store_double(dataptr,tk[ppt->index_tp_delta_ncdm1+n_ncdm],ppt->has_source_delta_ncdm,storeidx);
            }
          }
          class_store_double(dataptr,tk[ppt->index_tp_delta_dcdm],ppt->has_source_delta_dcdm,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_dr],ppt->has_source_delta_dr,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_scf],ppt->has_source_delta_scf,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_phi_scf],ppt->has_scf,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_phi_over_phi_scf],ppt->has_scf,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_phi_prime_scf],ppt->has_scf,storeidx);
          // class_store_double(dataptr,tk[ppt->index_tp_delta_m],ppt->has_source_delta_m,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_delta_tot],ppt->has_source_delta_tot,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_phi],ppt->has_source_phi,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_psi],ppt->has_source_psi,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_phi_prime],ppt->has_source_phi_prime,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_h],ppt->has_source_h,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_h_prime],ppt->has_source_h_prime,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_eta],ppt->has_source_eta,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_eta_prime],ppt->has_source_eta_prime,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_H_T_Nb_prime],ppt->has_source_H_T_Nb_prime,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_k2gamma_Nb],ppt->has_source_k2gamma_Nb,storeidx);
        }
        if (ppt->has_velocity_transfers == _TRUE_) {

          class_store_double(dataptr,tk[ppt->index_tp_theta_g],ppt->has_source_theta_g,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_b],ppt->has_source_theta_b,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_cdm],ppt->has_source_theta_cdm,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_idm],ppt->has_source_theta_idm,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_fld],ppt->has_source_theta_fld,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_ur],ppt->has_source_theta_ur,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_idr],ppt->has_source_theta_idr,storeidx);
          if (pba->has_ncdm == _TRUE_){
            for (n_ncdm = 0; n_ncdm < pba->N_ncdm; n_ncdm++){
              class_store_double(dataptr,tk[ppt->index_tp_theta_ncdm1+n_ncdm],ppt->has_source_theta_ncdm,storeidx);
            }
          }
          class_store_double(dataptr,tk[ppt->index_tp_theta_dcdm],ppt->has_source_theta_dcdm,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_dr],ppt->has_source_theta_dr,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_scf],ppt->has_source_theta_scf,storeidx);
          class_store_double(dataptr,tk[ppt->index_tp_theta_tot],ppt->has_source_theta_tot,storeidx);

        }

      }
      else if (output_format == camb_format) {

        /* rescale and reorder the matter transfer functions following the CMBFAST/CAMB convention */
        class_store_double_or_default(dataptr,-tk[ppt->index_tp_delta_cdm]/k2,ppt->has_source_delta_cdm,storeidx,0.0);
        class_store_double_or_default(dataptr,-tk[ppt->index_tp_delta_b]/k2,ppt->has_source_delta_b,storeidx,0.0);
        class_store_double_or_default(dataptr,-tk[ppt->index_tp_delta_g]/k2,ppt->has_source_delta_g,storeidx,0.0);
        class_store_double_or_default(dataptr,-tk[ppt->index_tp_delta_ur]/k2,ppt->has_source_delta_ur,storeidx,0.0);
        class_store_double_or_default(dataptr,-tk[ppt->index_tp_delta_ncdm1]/k2,ppt->has_source_delta_ncdm,storeidx,0.0);
        class_store_double_or_default(dataptr,-tk[ppt->index_tp_delta_tot]/k2,_TRUE_,storeidx,0.0);
      }
    }
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r9, -0x10(%rsp)
movq %rcx, %r10
movslq 0x848(%rsi), %rcx
movq 0x870(%rsi), %rax
movq %rcx, -0x18(%rsp)
movslq (%rax,%rcx,4), %rax
movq %rax, -0x38(%rsp)
testq %rax, %rax
jle 0x75345
movq 0x9c8(%rsi), %rax
movq -0x18(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
movl %ecx, %eax
imull %r8d, %eax
movl %eax, -0x1c(%rsp)
movslq %r8d, %rax
movq %rax, -0x8(%rsp)
xorl %r14d, %r14d
movapd 0x7c5aa(%rip), %xmm0    # 0xf1230
movq %r10, -0x28(%rsp)
movq %rcx, -0x30(%rsp)
testl %ecx, %ecx
movq -0x38(%rsp), %r8
jle 0x75339
movl -0x1c(%rsp), %eax
imull %r14d, %eax
cltq
movq -0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
movq 0x998(%rsi), %rax
movq 0x9d0(%rsi), %rcx
movq -0x18(%rsp), %r8
movslq (%rax,%r8,4), %r12
movq (%rcx,%r8,8), %r13
movq -0x30(%rsp), %rcx
movq -0x38(%rsp), %r8
xorl %ebp, %ebp
movq %rbp, %rax
imulq -0x8(%rsp), %rax
leaq (%r15,%rax,8), %rbx
movq %rbp, %rax
imulq %r8, %rax
addq %r14, %rax
imulq %r12, %rax
leaq (%r10,%rax,8), %r9
movsd (%r13,%rbp,8), %xmm1
movapd %xmm1, %xmm2
divsd 0x8(%rdi), %xmm2
movsd %xmm2, (%rbx)
cmpl $0x1, %edx
je 0x75247
testl %edx, %edx
jne 0x7532d
movl $0x1, %eax
cmpw $0x1, 0x34(%rsi)
jne 0x7506e
cmpw $0x1, 0x882(%rsi)
jne 0x74d4c
movslq 0x8e4(%rsi), %rax
movsd (%r9,%rax,8), %xmm1
movsd %xmm1, 0x8(%rbx)
movl $0x2, %eax
cmpw $0x1, 0x884(%rsi)
jne 0x74d6c
movslq 0x8e8(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movl %eax, %ecx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x886(%rsi)
jne 0x74d8c
movslq 0x8ec(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movl %eax, %ecx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x888(%rsi)
jne 0x74dac
movslq 0x8f0(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movl %eax, %ecx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x88e(%rsi)
jne 0x74dcc
movslq 0x8f8(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movl %eax, %ecx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x894(%rsi)
jne 0x74dec
movslq 0x920(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movl %eax, %ecx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x88a(%rsi)
jne 0x74e0c
movslq 0x924(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movl %eax, %ecx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x4be(%rdi)
jne 0x74e55
movl 0x248(%rdi), %r8d
testl %r8d, %r8d
jle 0x74e55
movzwl 0x896(%rsi), %ecx
xorl %r10d, %r10d
cmpw $0x1, %cx
jne 0x74e4d
movslq 0x928(%rsi), %r11
addq %r10, %r11
movsd (%r9,%r11,8), %xmm1
movslq %eax, %r11
incl %eax
movsd %xmm1, (%rbx,%r11,8)
incq %r10
cmpl %r10d, %r8d
jne 0x74e2c
cmpw $0x1, 0x88c(%rsi)
jne 0x74e76
movslq 0x8f4(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x892(%rsi)
jne 0x74e97
movslq 0x91c(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
movq -0x28(%rsp), %r10
cmpw $0x1, 0x890(%rsi)
jne 0x74ebd
movslq 0x8fc(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
movzwl 0x8(%rsi), %ecx
cmpw $0x1, %cx
jne 0x74edf
movslq 0x900(%rsi), %r8
movsd (%r9,%r8,8), %xmm1
movslq %eax, %r8
incl %eax
movsd %xmm1, (%rbx,%r8,8)
cmpw $0x1, %cx
jne 0x74efd
movslq 0x904(%rsi), %r8
movsd (%r9,%r8,8), %xmm1
movslq %eax, %r8
incl %eax
movsd %xmm1, (%rbx,%r8,8)
movq -0x38(%rsp), %r8
cmpw $0x1, %cx
jne 0x74f1f
movslq 0x908(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x880(%rsi)
jne 0x74f40
movslq 0x8e0(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8b4(%rsi)
jne 0x74f61
movslq 0x970(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8ba(%rsi)
jne 0x74f82
movslq 0x97c(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8b6(%rsi)
jne 0x74fa3
movslq 0x974(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8bc(%rsi)
jne 0x74fc4
movslq 0x980(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8be(%rsi)
jne 0x74fe5
movslq 0x984(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8c0(%rsi)
jne 0x75006
movslq 0x988(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8c2(%rsi)
jne 0x75027
movslq 0x98c(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8c4(%rsi)
jne 0x75048
movslq 0x990(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8c6(%rsi)
jne 0x75069
movslq 0x994(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
movq -0x30(%rsp), %rcx
cmpw $0x1, 0x36(%rsi)
jne 0x7532d
cmpw $0x1, 0x89e(%rsi)
jne 0x7509a
movslq 0x940(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8a0(%rsi)
jne 0x750bb
movslq 0x944(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8a2(%rsi)
jne 0x750dc
movslq 0x948(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8a4(%rsi)
jne 0x750fd
movslq 0x960(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8aa(%rsi)
jne 0x7511e
movslq 0x950(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8b0(%rsi)
jne 0x7513f
movslq 0x958(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8a6(%rsi)
jne 0x75160
movslq 0x95c(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x4be(%rdi)
jne 0x751a9
movl 0x248(%rdi), %r8d
testl %r8d, %r8d
jle 0x751a9
movzwl 0x8b2(%rsi), %ecx
xorl %r10d, %r10d
cmpw $0x1, %cx
jne 0x751a1
movslq 0x968(%rsi), %r11
addq %r10, %r11
movsd (%r9,%r11,8), %xmm1
movslq %eax, %r11
incl %eax
movsd %xmm1, (%rbx,%r11,8)
incq %r10
cmpl %r10d, %r8d
jne 0x75180
cmpw $0x1, 0x8a8(%rsi)
jne 0x751ca
movslq 0x94c(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
movq -0x28(%rsp), %r10
movq -0x38(%rsp), %r8
cmpw $0x1, 0x8ae(%rsi)
jne 0x751f5
movslq 0x964(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
cmpw $0x1, 0x8ac(%rsi)
jne 0x75216
movslq 0x954(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movslq %eax, %rcx
incl %eax
movsd %xmm1, (%rbx,%rcx,8)
movq -0x30(%rsp), %rcx
cmpw $0x1, 0x89c(%rsi)
jne 0x7532d
movslq 0x93c(%rsi), %rcx
movsd (%r9,%rcx,8), %xmm1
movq -0x30(%rsp), %rcx
cltq
movsd %xmm1, (%rbx,%rax,8)
jmp 0x7532d
mulsd %xmm1, %xmm1
xorpd %xmm2, %xmm2
cmpw $0x1, 0x886(%rsi)
xorpd %xmm3, %xmm3
jne 0x75272
movslq 0x8ec(%rsi), %rax
movsd (%r9,%rax,8), %xmm3
xorpd %xmm0, %xmm3
divsd %xmm1, %xmm3
movsd %xmm3, 0x8(%rbx)
cmpw $0x1, 0x884(%rsi)
jne 0x75296
movslq 0x8e8(%rsi), %rax
movsd (%r9,%rax,8), %xmm2
xorpd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x10(%rbx)
xorpd %xmm2, %xmm2
cmpw $0x1, 0x882(%rsi)
xorpd %xmm3, %xmm3
jne 0x752c2
movslq 0x8e4(%rsi), %rax
movsd (%r9,%rax,8), %xmm3
xorpd %xmm0, %xmm3
divsd %xmm1, %xmm3
movsd %xmm3, 0x18(%rbx)
cmpw $0x1, 0x894(%rsi)
jne 0x752e6
movslq 0x920(%rsi), %rax
movsd (%r9,%rax,8), %xmm2
xorpd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x20(%rbx)
xorpd %xmm2, %xmm2
cmpw $0x1, 0x896(%rsi)
jne 0x7530e
movslq 0x928(%rsi), %rax
movsd (%r9,%rax,8), %xmm2
xorpd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x28(%rbx)
movslq 0x8e0(%rsi), %rax
movsd (%r9,%rax,8), %xmm2
xorpd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x30(%rbx)
incq %rbp
cmpq %rcx, %rbp
jne 0x74cd7
incq %r14
cmpq %r8, %r14
jne 0x74c90
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq