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

  double * tkfull=NULL;  /* array with argument tkfull[(index_k * ppt->ic_size[index_md] + index_ic) * ppt->tp_size[index_md] + index_tp] */

  double * pvecsources;

  double tau;

  int index_md = ppt->index_md_scalars;
  int index_ic;
  int index_k;
  int index_tp;

  /** - allocate tkfull */

  if (ppt->k_size[index_md]*ppt->ic_size[index_md]*ppt->tp_size[index_md] > 0) {
    class_alloc(tkfull,
                ppt->k_size[index_md]*ppt->ic_size[index_md]*ppt->tp_size[index_md]*sizeof(double),
                ppt->error_message);
  }

  /** - compute \f$T_i(k)\f$ for each k (if several ic's, compute it
        for each ic; if z_pk = 0, this is done by directly reading
        inside the pre-computed table; if not, this is done by
        interpolating the table at the correct value of tau. */

  /* if z_pk = 0, no interpolation needed */

  if (z == 0.) {

    for (index_k=0; index_k<ppt->k_size[index_md]; index_k++) {
      for (index_tp=0; index_tp<ppt->tp_size[index_md]; index_tp++) {
        for (index_ic=0; index_ic<ppt->ic_size[index_md]; index_ic++) {
          tkfull[(index_k * ppt->ic_size[index_md] + index_ic) * ppt->tp_size[index_md] + index_tp]
            = ppt->sources[index_md][index_ic * ppt->tp_size[index_md] + index_tp][(ppt->tau_size-1) * ppt->k_size[index_md] + index_k];
        }
      }
    }
  }

  /* if 0 <= z_pk <= z_max_pk, interpolation needed, */
  else {

    /* check the time corresponding to the highest redshift requested in output plus one */
    class_call(background_tau_of_z(pba,
                                   z,
                                   &tau),
               pba->error_message,
               ppt->error_message);

    class_test(log(tau) < ppt->ln_tau[0],
               "Asking sources at a z bigger than z_max_pk, something probably went wrong",
               ppt->error_message);

    class_alloc(pvecsources,
                ppt->k_size[index_md]*sizeof(double),
                ppt->error_message);


    for (index_tp=0; index_tp<ppt->tp_size[index_md]; index_tp++) {
      for (index_ic=0; index_ic<ppt->ic_size[index_md]; index_ic++) {
	class_call(perturbations_sources_at_tau(ppt,
						index_md,
						index_ic,
						index_tp,
						tau,
						pvecsources),
		   ppt->error_message,
		   ppt->error_message);
	for (index_k=0; index_k<ppt->k_size[index_md]; index_k++) {

          tkfull[(index_k * ppt->ic_size[index_md] + index_ic) * ppt->tp_size[index_md] + index_tp] =
            pvecsources[index_k];
        }
      }
    }
    free(pvecsources);
  }

  /** - store data */

  class_call(perturbations_output_data(pba,ppt,output_format,tkfull,number_of_titles,data),
             ppt->error_message,
             ppt->error_message);

  /** - free tkfull */
  // condition necessary because the size could be zero (if ppt->tp_size is zero)
  if (tkfull != NULL)
    free(tkfull);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1048, %rsp           # imm = 0x1048
movq %r8, 0x28(%rsp)
movl %ecx, 0x14(%rsp)
movl %edx, 0x10(%rsp)
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
movslq 0x848(%rsi), %r13
movq 0x9c8(%rsi), %rax
movslq (%rax,%r13,4), %r14
movq 0x870(%rsi), %rax
movq 0x998(%rsi), %rcx
movslq (%rax,%r13,4), %rax
movq %rax, %r15
imull %r14d, %eax
movslq (%rcx,%r13,4), %rbp
movl %ebp, %r12d
imull %eax, %r12d
testl %r12d, %r12d
jle 0x6d79d
movl %r12d, %edi
shlq $0x3, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x8490
movsd 0x8(%rsp), %xmm0
movq %rax, %rcx
testq %rax, %rax
jne 0x6d79f
shll $0x3, %r12d
leaq 0x778a2(%rip), %rsi     # 0xe5004
leaq 0x9c731(%rip), %rdx     # 0x109e9a
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x778ab(%rip), %rsi     # 0xe5034
leaq 0x9c711(%rip), %rdx     # 0x109ea1
movq %rbx, %rdi
movl $0x110, %ecx            # imm = 0x110
jmp 0x6da56
xorl %ecx, %ecx
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq %rcx, (%rsp)
jne 0x6d87a
jp 0x6d87a
xorl %eax, %eax
testl %r15d, %r15d
movl $0x0, %esi
cmovgl %r15d, %esi
testl %ebp, %ebp
movl $0x0, %edx
cmovgl %ebp, %edx
testl %r14d, %r14d
movl $0x0, %edi
cmovgl %r14d, %edi
movq %rdi, 0x38(%rsp)
imulq %rbp, %r15
shlq $0x3, %rbp
shlq $0x3, %r15
movq %r15, 0x30(%rsp)
movq %rcx, %r9
cmpq 0x38(%rsp), %rax
je 0x6dab7
leaq (,%rax,8), %r8
movq %r9, 0x8(%rsp)
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpq %rdx, %r11
je 0x6d864
xorl %r12d, %r12d
movq %rsi, %rcx
subq $0x1, %rcx
jb 0x6d857
movq 0xa38(%rbx), %r15
movq (%r15,%r13,8), %r15
addq %r10, %r15
movslq 0x9f8(%rbx), %rdi
decq %rdi
imulq %r14, %rdi
movq (%r12,%r15), %r15
addq %r8, %r15
movsd (%r15,%rdi,8), %xmm0
movsd %xmm0, (%r9,%r12)
addq %rbp, %r12
jmp 0x6d81d
incq %r11
addq $0x8, %r10
addq $0x8, %r9
jmp 0x6d812
incq %rax
movq 0x8(%rsp), %r9
addq 0x30(%rsp), %r9
movq (%rsp), %rcx
jmp 0x6d7f4
leaq 0x20(%rsp), %rsi
movq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x58adb
cmpl $0x1, %eax
jne 0x6d8da
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0x77b51(%rip), %rsi     # 0xe53f0
leaq 0x9b439(%rip), %rdx     # 0x108cdf
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x7776e(%rip), %rsi     # 0xe5034
leaq 0x9c5d4(%rip), %rdx     # 0x109ea1
movq %rbx, %rdi
movl $0x12e, %ecx            # imm = 0x12E
jmp 0x6da56
movsd 0x20(%rsp), %xmm0
callq 0x82e0
movq 0xa58(%rbx), %rax
movsd (%rax), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x6d954
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2e014
leaq 0x7776c(%rip), %rsi     # 0xe5082
leaq 0x9c5a3(%rip), %rdx     # 0x109ec0
leaq 0x840(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9c5a1(%rip), %rdi     # 0x109eda
leaq 0x776f4(%rip), %rsi     # 0xe5034
leaq 0x9c55a(%rip), %rdx     # 0x109ea1
movl $0x132, %ecx            # imm = 0x132
movq %rbx, %r8
jmp 0x6da59
movq 0x9c8(%rbx), %rax
movslq (%rax,%r13,4), %r14
leaq (,%r14,8), %rdi
callq 0x8490
testq %rax, %rax
je 0x6da65
movq %rax, %rbp
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x998(%rbx), %rax
cmpl (%rax,%r13,4), %r12d
jge 0x6daab
xorl %r14d, %r14d
movq 0x870(%rbx), %rax
cmpl (%rax,%r13,4), %r14d
jge 0x6da11
movsd 0x20(%rsp), %xmm0
movq %rbx, %rdi
movl %r13d, %esi
movl %r14d, %edx
movl %r12d, %ecx
movq %rbp, %r8
callq 0x6d194
testl %eax, %eax
jne 0x6da19
movq 0x9c8(%rbx), %rax
movl (%rax,%r13,4), %eax
testl %eax, %eax
cmovlel %r15d, %eax
xorl %ecx, %ecx
movq (%rsp), %rdi
cmpq %rcx, %rax
je 0x6da0c
movsd (%rbp,%rcx,8), %xmm0
movq 0x870(%rbx), %rdx
movq 0x998(%rbx), %rsi
movl (%rdx,%r13,4), %edx
imull %ecx, %edx
addl %r14d, %edx
imull (%rsi,%r13,4), %edx
addl %r12d, %edx
movslq %edx, %rdx
movsd %xmm0, (%rdi,%rdx,8)
incq %rcx
jmp 0x6d9d4
incl %r14d
jmp 0x6d992
incl %r12d
jmp 0x6d97e
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x779c9(%rip), %rsi     # 0xe53f0
leaq 0x9c502(%rip), %rdx     # 0x109f30
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x775ed(%rip), %rsi     # 0xe5034
leaq 0x9c453(%rip), %rdx     # 0x109ea1
movq %rbx, %rdi
movl $0x142, %ecx            # imm = 0x142
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
jmp 0x6dadf
shll $0x3, %r14d
leaq 0x77594(%rip), %rsi     # 0xe5004
leaq 0x9c4ad(%rip), %rdx     # 0x109f24
leaq 0x40(%rsp), %r15
movq %r15, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x7759d(%rip), %rsi     # 0xe5034
leaq 0x9c403(%rip), %rdx     # 0x109ea1
movq %rbx, %rdi
movl $0x136, %ecx            # imm = 0x136
movq %r15, %r8
jmp 0x6da59
movq %rbp, %rdi
callq 0x8430
movq (%rsp), %rcx
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movl 0x10(%rsp), %edx
movq %rcx, %rbx
movl 0x14(%rsp), %r8d
movq 0x28(%rsp), %r9
callq 0x6daf1
movq %rbx, %rdi
callq 0x8430
xorl %eax, %eax
addq $0x1048, %rsp           # imm = 0x1048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq