// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_selection_compute
int transfer_selection_compute(
                               struct precision * ppr,
                               struct background * pba,
                               struct perturbations * ppt,
                               struct transfer * ptr,
                               double * selection,
                               double * tau0_minus_tau,
                               double * w_trapz,
                               int tau_size,
                               double * pvecback,
                               double tau0,
                               int bin) {

  /* running index over time */
  int index_tau;

  /* running value of time */
  double tau;

  /* used for normalizing the selection to one */
  double norm;

  /* used for calling background_at_tau() */
  int last_index;

  /* running value of redshift */
  double z;

  if (tau_size > 1) {

    /* loop over time */
    for (index_tau = 0; index_tau < tau_size; index_tau++) {

      /* running value of time */
      tau = tau0 - tau0_minus_tau[index_tau];

      /* get background quantities at this time */
      class_call(background_at_tau(pba,
                                   tau,
                                   long_info,
                                   inter_normal,
                                   &last_index,
                                   pvecback),
                 pba->error_message,
                 ptr->error_message);

      /* infer redshift (remember that a in the code is in fact a/a_0) */
      z = 1./pvecback[pba->index_bg_a]-1.;

      /* get corresponding dN/dz(z,bin) */
      class_call(transfer_selection_function(ppr,
                                             ppt,
                                             ptr,
                                             bin,
                                             z,
                                             &(selection[index_tau])),
                 ptr->error_message,
                 ptr->error_message);

      /* get corresponding dN/dtau = dN/dz * dz/dtau = dN/dz * H */
      selection[index_tau] *= pvecback[pba->index_bg_H];

    }

    /* compute norm = \int W(tau) dtau */
    class_call(array_trapezoidal_integral(selection,
                                          tau_size,
                                          w_trapz,
                                          &norm,
                                          ptr->error_message),
               ptr->error_message,
               ptr->error_message);


    /* divide W by norm so that \int W(tau) dtau = 1 */
    for (index_tau = 0; index_tau < tau_size; index_tau++) {
      selection[index_tau]/=norm;
    }

  }

  /* trivial case: dirac distribution */
  else {
    selection[0] = 1.;
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x848, %rsp            # imm = 0x848
movsd %xmm0, 0x28(%rsp)
movq %r9, 0x20(%rsp)
movq %r8, %r14
movq %rdx, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movl 0x888(%rsp), %eax
cmpl $0x2, %eax
jl 0xa7f10
movq %rsi, %r15
movq %rcx, (%rsp)
movq 0x890(%rsp), %rbx
movl %eax, %eax
movq %rax, 0x8(%rsp)
leaq (,%rax,8), %r13
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0xa7f24
movsd 0x28(%rsp), %xmm0
movq 0x20(%rsp), %rax
subsd (%rax,%rbp), %xmm0
movq %r15, %rdi
pushq $0x2
popq %rsi
xorl %edx, %edx
leaq 0x3c(%rsp), %rcx
movq %rbx, %r8
callq 0x5887d
cmpl $0x1, %eax
je 0xa7f92
movslq 0x380(%r15), %rax
movsd 0x3d3a7(%rip), %xmm0    # 0xe5260
divsd (%rbx,%rax,8), %xmm0
addsd 0x3d922(%rip), %xmm0    # 0xe57e8
leaq (%r14,%rbp), %r12
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq (%rsp), %rdx
movl 0x898(%rsp), %ecx
movq %r12, %r8
callq 0xa7a60
testl %eax, %eax
jne 0xa7fd9
movslq 0x384(%r15), %rax
movsd (%rbx,%rax,8), %xmm0
mulsd (%r12), %xmm0
movsd %xmm0, (%r12)
addq $0x8, %rbp
jmp 0xa7e73
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%r14)
xorl %eax, %eax
jmp 0xa8027
movq (%rsp), %r15
addq $0x96a, %r15            # imm = 0x96A
leaq 0x30(%rsp), %rcx
movq %r14, %rdi
movl 0x888(%rsp), %esi
movq 0x880(%rsp), %rdx
movq %r15, %r8
callq 0x19292
cmpl $0x1, %eax
jne 0xa8039
leaq 0x3d492(%rip), %rsi     # 0xe53f0
leaq 0x6eb09(%rip), %rdx     # 0x116a6e
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x3d0b6(%rip), %rsi     # 0xe5034
leaq 0x6ea82(%rip), %rdx     # 0x116a07
movq %r15, %rdi
movl $0xc66, %ecx            # imm = 0xC66
jmp 0xa801a
addq $0xd1c, %r15            # imm = 0xD1C
leaq 0x3d450(%rip), %rsi     # 0xe53f0
leaq 0x6ea14(%rip), %rdx     # 0x1169bb
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
movq (%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x3d069(%rip), %rsi     # 0xe5034
leaq 0x6ea35(%rip), %rdx     # 0x116a07
movl $0xc4b, %ecx            # imm = 0xC4B
jmp 0xa801a
movq (%rsp), %r14
addq $0x96a, %r14            # imm = 0x96A
leaq 0x3d405(%rip), %rsi     # 0xe53f0
leaq 0x6ea30(%rip), %rdx     # 0x116a22
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x3d029(%rip), %rsi     # 0xe5034
leaq 0x6e9f5(%rip), %rdx     # 0x116a07
movq %r14, %rdi
movl $0xc58, %ecx            # imm = 0xC58
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x848, %rsp            # imm = 0x848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd 0x30(%rsp), %xmm0
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x8(%rsp), %rdx
cmpq %rcx, %rdx
je 0xa8027
movsd (%r14,%rcx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%r14,%rcx,8)
incq %rcx
jmp 0xa8048