// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x1868, %rsp           # imm = 0x1868
movl 0x1888(%rsp), %eax
movq 0x1880(%rsp), %rax
movl 0x1878(%rsp), %eax
movq 0x1870(%rsp), %rax
movq %rdi, 0x1858(%rsp)
movq %rsi, 0x1850(%rsp)
movq %rdx, 0x1848(%rsp)
movq %rcx, 0x1840(%rsp)
movq %r8, 0x1838(%rsp)
movq %r9, 0x1830(%rsp)
movsd %xmm0, 0x1828(%rsp)
cmpl $0x1, 0x1878(%rsp)
jle 0x1426cb
movl $0x0, 0x1824(%rsp)
movl 0x1824(%rsp), %eax
cmpl 0x1878(%rsp), %eax
jge 0x1425dc
movsd 0x1828(%rsp), %xmm0
movq 0x1830(%rsp), %rax
movslq 0x1824(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm0
movsd %xmm0, 0x1818(%rsp)
movq 0x1850(%rsp), %rdi
movsd 0x1818(%rsp), %xmm0
movq 0x1880(%rsp), %r8
movl $0x2, %esi
xorl %edx, %edx
leaq 0x180c(%rsp), %rcx
callq 0x9e9b0
cmpl $0x1, %eax
jne 0x1424a1
leaq 0x1000(%rsp), %rdi
movq 0x1850(%rsp), %rcx
addq $0xd1c, %rcx            # imm = 0xD1C
leaq 0x8ff86(%rip), %rsi     # 0x1d23d8
leaq 0xc1c3c(%rip), %rdx     # 0x204095
movb $0x0, %al
callq 0x5b9c0
movq 0x1840(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x1000(%rsp), %r8
leaq 0x8fbb6(%rip), %rsi     # 0x1d2034
leaq 0xc1c5c(%rip), %rdx     # 0x2040e1
movl $0xc4b, %ecx            # imm = 0xC4B
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1864(%rsp)
jmp 0x1426ea
movq 0x1880(%rsp), %rax
movq 0x1850(%rsp), %rcx
movslq 0x380(%rcx), %rcx
movsd 0x8fd88(%rip), %xmm0    # 0x1d2248
divsd (%rax,%rcx,8), %xmm0
movsd 0x8fd7b(%rip), %xmm1    # 0x1d2248
subsd %xmm1, %xmm0
movsd %xmm0, 0x1800(%rsp)
movq 0x1858(%rsp), %rdi
movq 0x1848(%rsp), %rsi
movq 0x1840(%rsp), %rdx
movl 0x1888(%rsp), %ecx
movsd 0x1800(%rsp), %xmm0
movq 0x1838(%rsp), %r8
movslq 0x1824(%rsp), %rax
shlq $0x3, %rax
addq %rax, %r8
callq 0x141ad0
cmpl $0x1, %eax
jne 0x142590
leaq 0x800(%rsp), %rdi
movq 0x1840(%rsp), %rcx
addq $0x96a, %rcx            # imm = 0x96A
leaq 0x8fe97(%rip), %rsi     # 0x1d23d8
leaq 0xc1bb4(%rip), %rdx     # 0x2040fc
movb $0x0, %al
callq 0x5b9c0
movq 0x1840(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x800(%rsp), %r8
leaq 0x8fac7(%rip), %rsi     # 0x1d2034
leaq 0xc1b6d(%rip), %rdx     # 0x2040e1
movl $0xc58, %ecx            # imm = 0xC58
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1864(%rsp)
jmp 0x1426ea
movq 0x1880(%rsp), %rax
movq 0x1850(%rsp), %rcx
movslq 0x384(%rcx), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1838(%rsp), %rax
movslq 0x1824(%rsp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x1824(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1824(%rsp)
jmp 0x1423c7
movq 0x1838(%rsp), %rdi
movl 0x1878(%rsp), %esi
movq 0x1870(%rsp), %rdx
movq 0x1840(%rsp), %r8
addq $0x96a, %r8             # imm = 0x96A
leaq 0x1810(%rsp), %rcx
callq 0x2ab10
cmpl $0x1, %eax
jne 0x142674
movq %rsp, %rdi
movq 0x1840(%rsp), %rcx
addq $0x96a, %rcx            # imm = 0x96A
leaq 0x8fdab(%rip), %rsi     # 0x1d23d8
leaq 0xc1b14(%rip), %rdx     # 0x204148
movb $0x0, %al
callq 0x5b9c0
movq 0x1840(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
movq %rsp, %r8
leaq 0x8f9e0(%rip), %rsi     # 0x1d2034
leaq 0xc1a86(%rip), %rdx     # 0x2040e1
movl $0xc66, %ecx            # imm = 0xC66
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1864(%rsp)
jmp 0x1426ea
movl $0x0, 0x1824(%rsp)
movl 0x1824(%rsp), %eax
cmpl 0x1878(%rsp), %eax
jge 0x1426c9
movsd 0x1810(%rsp), %xmm1
movq 0x1838(%rsp), %rax
movslq 0x1824(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x1824(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1824(%rsp)
jmp 0x14267f
jmp 0x1426df
movq 0x1838(%rsp), %rax
movsd 0x8fb6d(%rip), %xmm0    # 0x1d2248
movsd %xmm0, (%rax)
movl $0x0, 0x1864(%rsp)
movl 0x1864(%rsp), %eax
addq $0x1868, %rsp           # imm = 0x1868
retq
nopl (%rax)