// File: /workspace/github_c_makefile_star2_O1/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 0x748ab
movl %ebp, %edi
shlq $0x3, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x8460
movsd 0x8(%rsp), %xmm0
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0x748b4
shll $0x3, %ebp
leaq 0x7c794(%rip), %rsi     # 0xf1004
leaq 0xa1743(%rip), %rdx     # 0x115fba
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30c2c
movq (%rsp), %rdi
addq $0x6c8a, %rdi           # imm = 0x6C8A
leaq 0x7c79a(%rip), %rsi     # 0xf1034
leaq 0xa1720(%rip), %rdx     # 0x115fc1
movl $0x110, %ecx            # imm = 0x110
jmp 0x749e6
movq $0x0, 0x10(%rsp)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x7498f
jp 0x7498f
movq %r13, 0x8(%rsp)
testl %r14d, %r14d
jle 0x7495a
leaq (,%r15,8), %rax
xorl %ecx, %ecx
xorl %edx, %edx
testl %r15d, %r15d
jle 0x7494f
movl %ecx, %esi
imulq %rax, %rsi
addq 0x10(%rsp), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
testl %r12d, %r12d
jle 0x7493f
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 0x74927
incq %r8
addq $0x8, %rsi
addq $0x8, %rdi
cmpq %r15, %r8
jne 0x748f7
incq %rdx
addl %r12d, %ecx
cmpq %r14, %rdx
jne 0x748e2
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 0x74c23
xorl %ebx, %ebx
testq %r14, %r14
je 0x749f5
movq %r14, %rdi
callq 0x8410
jmp 0x749f5
leaq 0x20(%rsp), %rsi
movq %r13, %rdi
callq 0x5efb7
cmpl $0x1, %eax
jne 0x74a09
addq $0xd1c, %r13            # imm = 0xD1C
leaq 0x7ca41(%rip), %rsi     # 0xf13f0
leaq 0xa0439(%rip), %rdx     # 0x114def
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30c2c
movq (%rsp), %rdi
addq $0x6c8a, %rdi           # imm = 0x6C8A
leaq 0x7c65a(%rip), %rsi     # 0xf1034
leaq 0xa15e0(%rip), %rdx     # 0x115fc1
movl $0x12e, %ecx            # imm = 0x12E
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
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 0x74a88
addq $0x6c8a, %r12           # imm = 0x6C8A
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x30c2c
leaq 0x7c638(%rip), %rsi     # 0xf1082
leaq 0xa158f(%rip), %rdx     # 0x115fe0
leaq 0x830(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xa158d(%rip), %rdi     # 0x115ffa
leaq 0x7c5c0(%rip), %rsi     # 0xf1034
leaq 0xa1546(%rip), %rdx     # 0x115fc1
movl $0x132, %ecx            # imm = 0x132
movq %rbx, %r8
jmp 0x749e9
movq 0x9c8(%r12), %rax
movq %rbx, %r15
movslq (%rax,%rbx,4), %r14
leaq (,%r14,8), %rdi
callq 0x8460
testq %rax, %rax
je 0x74b98
movq %rax, %rbp
movq 0x998(%r12), %rax
cmpl $0x0, (%rax,%r15,4)
jle 0x74b86
movq %r12, %rbx
xorl %r12d, %r12d
movq 0x870(%rbx), %rax
cmpl $0x0, (%rax,%r15,4)
jle 0x74b6f
xorl %r14d, %r14d
movsd 0x20(%rsp), %xmm0
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
movl %r12d, %ecx
movq %rbp, %r8
callq 0x742a8
testl %eax, %eax
jne 0x74be1
movq 0x9c8(%rbx), %rax
movslq (%rax,%r15,4), %rax
testq %rax, %rax
jle 0x74b58
movq 0x870(%rbx), %rcx
movq 0x998(%rbx), %rdx
movslq (%rcx,%r15,4), %rcx
movslq (%rdx,%r15,4), %rsi
movq %r14, %rdx
imulq %rsi, %rdx
addq %r12, %rdx
movq 0x10(%rsp), %rdi
leaq (%rdi,%rdx,8), %rdx
imulq %rsi, %rcx
shlq $0x3, %rcx
xorl %esi, %esi
movsd (%rbp,%rsi,8), %xmm0
movsd %xmm0, (%rdx)
incq %rsi
addq %rcx, %rdx
cmpq %rsi, %rax
jne 0x74b43
incq %r14
movq 0x870(%rbx), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r14
jl 0x74ade
incq %r12
movq 0x998(%rbx), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r12
jl 0x74ac9
movq %r13, 0x8(%rsp)
movq %rbp, %rdi
callq 0x8410
jmp 0x7495a
shll $0x3, %r14d
leaq 0x7c461(%rip), %rsi     # 0xf1004
leaq 0xa149a(%rip), %rdx     # 0x116044
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x6c8a, %r12           # imm = 0x6C8A
leaq 0x7c46a(%rip), %rsi     # 0xf1034
leaq 0xa13f0(%rip), %rdx     # 0x115fc1
movq %r12, %rdi
movl $0x136, %ecx            # imm = 0x136
movq %r15, %r8
jmp 0x749e9
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x7c801(%rip), %rsi     # 0xf13f0
leaq 0xa145a(%rip), %rdx     # 0x116050
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x7c425(%rip), %rsi     # 0xf1034
leaq 0xa13ab(%rip), %rdx     # 0x115fc1
movq %rbx, %rdi
movl $0x142, %ecx            # imm = 0x142
jmp 0x749e6