// File: /workspace/github_c_makefile_star2_O3/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 $0x1038, %rsp           # imm = 0x1038
movq %r8, 0x28(%rsp)
movl %ecx, 0x1c(%rsp)
movl %edx, 0x18(%rsp)
movq %rdi, %r13
movslq 0x848(%rsi), %rdx
movq 0x9c8(%rsi), %rax
movl (%rax,%rdx,4), %r14d
movq 0x870(%rsi), %rax
movq %rsi, (%rsp)
movq 0x998(%rsi), %rcx
movl (%rax,%rdx,4), %r12d
movl %r12d, %eax
imull %r14d, %eax
movq %rdx, %rbx
movl (%rcx,%rdx,4), %r15d
movl %r15d, %ebp
imull %eax, %ebp
testl %ebp, %ebp
jle 0x71de7
movl %ebp, %edi
shlq $0x3, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x8460
movsd 0x8(%rsp), %xmm0
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0x71df0
shll $0x3, %ebp
leaq 0x7c258(%rip), %rsi     # 0xee004
leaq 0xa1247(%rip), %rdx     # 0x112ffa
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
movq (%rsp), %rdi
addq $0x6c8a, %rdi           # imm = 0x6C8A
leaq 0x7c25e(%rip), %rsi     # 0xee034
leaq 0xa1224(%rip), %rdx     # 0x113001
movl $0x110, %ecx            # imm = 0x110
jmp 0x71f22
movq $0x0, 0x10(%rsp)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x71ecb
jp 0x71ecb
movq %r13, 0x8(%rsp)
testl %r14d, %r14d
jle 0x71e96
leaq (,%r15,8), %rax
xorl %ecx, %ecx
xorl %edx, %edx
testl %r15d, %r15d
jle 0x71e8b
movl %ecx, %esi
imulq %rax, %rsi
addq 0x10(%rsp), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
testl %r12d, %r12d
jle 0x71e7b
movq (%rsp), %r9
movq 0xa38(%r9), %r10
movl 0x9f8(%r9), %r9d
decl %r9d
imull %r14d, %r9d
addl %edx, %r9d
movslq %r9d, %r9
movq (%r10,%rbx,8), %r10
addq %rdi, %r10
movq %r12, %r11
xorl %ebp, %ebp
movq (%r10,%rbp), %r13
movsd (%r13,%r9,8), %xmm0
movsd %xmm0, (%rsi,%rbp)
addq %rax, %rbp
decq %r11
jne 0x71e63
incq %r8
addq $0x8, %rsi
addq $0x8, %rdi
cmpq %r15, %r8
jne 0x71e33
incq %rdx
addl %r12d, %ecx
cmpq %r14, %rdx
jne 0x71e1e
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
movl 0x18(%rsp), %edx
movq 0x10(%rsp), %r14
movq %r14, %rcx
movl 0x1c(%rsp), %r8d
movq 0x28(%rsp), %r9
callq 0x72157
xorl %ebx, %ebx
testq %r14, %r14
je 0x71f31
movq %r14, %rdi
callq 0x8410
jmp 0x71f31
leaq 0x20(%rsp), %rsi
movq %r13, %rdi
callq 0x5c896
cmpl $0x1, %eax
jne 0x71f45
addq $0xd1c, %r13            # imm = 0xD1C
leaq 0x7c505(%rip), %rsi     # 0xee3f0
leaq 0x9ff4d(%rip), %rdx     # 0x111e3f
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30af0
movq (%rsp), %rdi
addq $0x6c8a, %rdi           # imm = 0x6C8A
leaq 0x7c11e(%rip), %rsi     # 0xee034
leaq 0xa10e4(%rip), %rdx     # 0x113001
movl $0x12e, %ecx            # imm = 0x12E
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebx
movl %ebx, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd 0x20(%rsp), %xmm0
callq 0x82c0
movq (%rsp), %r12
movq 0xa58(%r12), %rax
movsd (%rax), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x71fc4
addq $0x6c8a, %r12           # imm = 0x6C8A
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x30af0
leaq 0x7c0fc(%rip), %rsi     # 0xee082
leaq 0xa1093(%rip), %rdx     # 0x113020
leaq 0x830(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xa1091(%rip), %rdi     # 0x11303a
leaq 0x7c084(%rip), %rsi     # 0xee034
leaq 0xa104a(%rip), %rdx     # 0x113001
movl $0x132, %ecx            # imm = 0x132
movq %rbx, %r8
jmp 0x71f25
movq 0x9c8(%r12), %rax
movq %rbx, %r15
movslq (%rax,%rbx,4), %r14
leaq (,%r14,8), %rdi
callq 0x8460
testq %rax, %rax
je 0x720cc
movq %rax, %rbp
movq 0x998(%r12), %rcx
cmpl $0x0, (%rcx,%r15,4)
jle 0x720ba
movq %r12, %rbx
movq 0x870(%r12), %rax
xorl %r12d, %r12d
cmpl $0x0, (%rax,%r15,4)
jle 0x720aa
xorl %r14d, %r14d
movsd 0x20(%rsp), %xmm0
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
movl %r12d, %ecx
movq %rbp, %r8
callq 0x717e4
testl %eax, %eax
jne 0x72115
movq 0x870(%rbx), %rax
movq 0x9c8(%rbx), %rcx
movslq (%rcx,%r15,4), %rdx
movslq (%rax,%r15,4), %rcx
testq %rdx, %rdx
jle 0x72097
movq 0x998(%rbx), %rsi
movslq (%rsi,%r15,4), %rsi
movq %r14, %rdi
imulq %rsi, %rdi
addq %r12, %rdi
movq 0x10(%rsp), %r8
leaq (%r8,%rdi,8), %rdi
imulq %rcx, %rsi
shlq $0x3, %rsi
xorl %r8d, %r8d
movsd (%rbp,%r8,8), %xmm0
movsd %xmm0, (%rdi)
incq %r8
addq %rsi, %rdi
cmpq %r8, %rdx
jne 0x72081
incq %r14
cmpq %rcx, %r14
jl 0x7201b
movq 0x998(%rbx), %rcx
incq %r12
movslq (%rcx,%r15,4), %rdx
cmpq %rdx, %r12
jl 0x7200d
movq %r13, 0x8(%rsp)
movq %rbp, %rdi
callq 0x8410
jmp 0x71e96
shll $0x3, %r14d
leaq 0x7bf2d(%rip), %rsi     # 0xee004
leaq 0xa0fa6(%rip), %rdx     # 0x113084
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %r12           # imm = 0x6C8A
leaq 0x7bf36(%rip), %rsi     # 0xee034
leaq 0xa0efc(%rip), %rdx     # 0x113001
movq %r12, %rdi
movl $0x136, %ecx            # imm = 0x136
movq %r15, %r8
jmp 0x71f25
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x7c2cd(%rip), %rsi     # 0xee3f0
leaq 0xa0f66(%rip), %rdx     # 0x113090
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x7bef1(%rip), %rsi     # 0xee034
leaq 0xa0eb7(%rip), %rdx     # 0x113001
movq %rbx, %rdi
movl $0x142, %ecx            # imm = 0x142
jmp 0x71f22