// File: /workspace/github_c_makefile_star2_O2/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, -0x20(%rsp)
movq %rcx, -0x8(%rsp)
movslq 0x848(%rsi), %rax
movq 0x870(%rsi), %rcx
movslq (%rcx,%rax,4), %r9
movl %r8d, -0x24(%rsp)
movslq %r8d, %rcx
movq %rcx, -0x10(%rsp)
testl %r9d, %r9d
movl $0x0, %r8d
movq %r9, %rcx
cmovgl %r9d, %r8d
movq %r8, -0x18(%rsp)
movapd 0x776ef(%rip), %xmm0    # 0xe5230
xorl %r12d, %r12d
cmpq -0x18(%rsp), %r12
je 0x6e211
movq 0x9c8(%rsi), %r8
movl (%r8,%rax,4), %r13d
movl %r12d, %r8d
imull -0x24(%rsp), %r8d
imull %r13d, %r8d
movslq %r8d, %r8
movq -0x20(%rsp), %r9
leaq (%r9,%r8,8), %r14
testl %r13d, %r13d
movl $0x0, %r8d
cmovlel %r8d, %r13d
xorl %r9d, %r9d
cmpq %r13, %r9
je 0x6e209
movq %r9, %r8
imulq -0x10(%rsp), %r8
leaq (%r14,%r8,8), %r8
movq %r9, %r10
imulq %rcx, %r10
addq %r12, %r10
movq 0x998(%rsi), %rbx
movq 0x9d0(%rsi), %rbp
movslq (%rbx,%rax,4), %rbx
imulq %r10, %rbx
movq -0x8(%rsp), %r10
leaq (%r10,%rbx,8), %r15
movq (%rbp,%rax,8), %r10
movsd (%r10,%r9,8), %xmm1
movapd %xmm1, %xmm2
divsd 0x8(%rdi), %xmm2
movsd %xmm2, (%r8)
cmpl $0x1, %edx
je 0x6dd40
testl %edx, %edx
jne 0x6e201
cmpw $0x1, 0x34(%rsi)
movl $0x1, %ebp
jne 0x6e034
cmpw $0x1, 0x882(%rsi)
jne 0x6dc1e
movslq 0x8e4(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movsd %xmm1, 0x8(%r8)
movl $0x2, %ebp
cmpw $0x1, 0x884(%rsi)
jne 0x6dc40
movslq 0x8e8(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movl %ebp, %r10d
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x886(%rsi)
jne 0x6dc62
movslq 0x8ec(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movl %ebp, %r10d
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x888(%rsi)
jne 0x6dc84
movslq 0x8f0(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movl %ebp, %r10d
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x88e(%rsi)
jne 0x6dca6
movslq 0x8f8(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movl %ebp, %r10d
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x894(%rsi)
jne 0x6dcc8
movslq 0x920(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movl %ebp, %r10d
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x88a(%rsi)
jne 0x6dcea
movslq 0x924(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movl %ebp, %r10d
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x4be(%rdi)
jne 0x6de31
movl 0x248(%rdi), %ebx
testl %ebx, %ebx
movl $0x0, %r10d
cmovlel %r10d, %ebx
xorl %r10d, %r10d
cmpl %r10d, %ebx
je 0x6de31
cmpw $0x1, 0x896(%rsi)
jne 0x6dd3b
movslq 0x928(%rsi), %r11
addq %r10, %r11
movsd (%r15,%r11,8), %xmm1
movslq %ebp, %r11
incl %ebp
movsd %xmm1, (%r8,%r11,8)
incq %r10
jmp 0x6dd0d
mulsd %xmm1, %xmm1
xorpd %xmm2, %xmm2
cmpw $0x1, 0x886(%rsi)
xorpd %xmm3, %xmm3
jne 0x6dd6b
movslq 0x8ec(%rsi), %r10
movsd (%r15,%r10,8), %xmm3
xorpd %xmm0, %xmm3
divsd %xmm1, %xmm3
movsd %xmm3, 0x8(%r8)
cmpw $0x1, 0x884(%rsi)
jne 0x6dd90
movslq 0x8e8(%rsi), %r10
movsd (%r15,%r10,8), %xmm2
xorpd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x10(%r8)
xorpd %xmm2, %xmm2
cmpw $0x1, 0x882(%rsi)
xorpd %xmm3, %xmm3
jne 0x6ddbd
movslq 0x8e4(%rsi), %r10
movsd (%r15,%r10,8), %xmm3
xorpd %xmm0, %xmm3
divsd %xmm1, %xmm3
movsd %xmm3, 0x18(%r8)
cmpw $0x1, 0x894(%rsi)
jne 0x6dde2
movslq 0x920(%rsi), %r10
movsd (%r15,%r10,8), %xmm2
xorpd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x20(%r8)
xorpd %xmm2, %xmm2
cmpw $0x1, 0x896(%rsi)
jne 0x6de0b
movslq 0x928(%rsi), %r10
movsd (%r15,%r10,8), %xmm2
xorpd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x28(%r8)
movslq 0x8e0(%rsi), %r10
movsd (%r15,%r10,8), %xmm2
xorpd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x30(%r8)
jmp 0x6e201
cmpw $0x1, 0x88c(%rsi)
jne 0x6de53
movslq 0x8f4(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x892(%rsi)
jne 0x6de75
movslq 0x91c(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x890(%rsi)
jne 0x6de97
movslq 0x8fc(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8(%rsi)
jne 0x6dee0
movslq 0x900(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
movsd %xmm1, (%r8,%r10,8)
movslq 0x904(%rsi), %r11
movsd (%r15,%r11,8), %xmm1
movsd %xmm1, 0x8(%r8,%r10,8)
movslq 0x908(%rsi), %r11
movsd (%r15,%r11,8), %xmm1
leal 0x3(%r10), %ebp
movsd %xmm1, 0x10(%r8,%r10,8)
cmpw $0x1, 0x880(%rsi)
jne 0x6df02
movslq 0x8e0(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8b4(%rsi)
jne 0x6df24
movslq 0x970(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8ba(%rsi)
jne 0x6df46
movslq 0x97c(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8b6(%rsi)
jne 0x6df68
movslq 0x974(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8bc(%rsi)
jne 0x6df8a
movslq 0x980(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8be(%rsi)
jne 0x6dfac
movslq 0x984(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8c0(%rsi)
jne 0x6dfce
movslq 0x988(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8c2(%rsi)
jne 0x6dff0
movslq 0x98c(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8c4(%rsi)
jne 0x6e012
movslq 0x990(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8c6(%rsi)
jne 0x6e034
movslq 0x994(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x36(%rsi)
jne 0x6e201
cmpw $0x1, 0x89e(%rsi)
jne 0x6e061
movslq 0x940(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8a0(%rsi)
jne 0x6e083
movslq 0x944(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8a2(%rsi)
jne 0x6e0a5
movslq 0x948(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8a4(%rsi)
jne 0x6e0c7
movslq 0x960(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8aa(%rsi)
jne 0x6e0e9
movslq 0x950(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8b0(%rsi)
jne 0x6e10b
movslq 0x958(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8a6(%rsi)
jne 0x6e12d
movslq 0x95c(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x4be(%rdi)
jne 0x6e17b
movl 0x248(%rdi), %ebx
testl %ebx, %ebx
movl $0x0, %r10d
cmovlel %r10d, %ebx
xorl %r10d, %r10d
cmpl %r10d, %ebx
je 0x6e17b
cmpw $0x1, 0x8b2(%rsi)
jne 0x6e176
movslq 0x968(%rsi), %r11
addq %r10, %r11
movsd (%r15,%r11,8), %xmm1
movslq %ebp, %r11
incl %ebp
movsd %xmm1, (%r8,%r11,8)
incq %r10
jmp 0x6e14c
cmpw $0x1, 0x8a8(%rsi)
jne 0x6e19d
movslq 0x94c(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8ae(%rsi)
jne 0x6e1bf
movslq 0x964(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x8ac(%rsi)
jne 0x6e1e1
movslq 0x954(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
incl %ebp
movsd %xmm1, (%r8,%r10,8)
cmpw $0x1, 0x89c(%rsi)
jne 0x6e201
movslq 0x93c(%rsi), %r10
movsd (%r15,%r10,8), %xmm1
movslq %ebp, %r10
movsd %xmm1, (%r8,%r10,8)
incq %r9
jmp 0x6db83
incq %r12
jmp 0x6db44
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq