// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_selection_function
int transfer_selection_function(
                                struct precision * ppr,
                                struct perturbations * ppt,
                                struct transfer * ptr,
                                int bin,
                                double z,
                                double * selection) {

  double x;
  double dNdz;
  double dln_dNdz_dz;
  int last_index;

  /* trivial dirac case */
  if (ppt->selection==dirac) {

    *selection=1.;

    return _SUCCESS_;
  }

  /* difference between z and the bin center (we can take the absolute
     value as long as all selection functions are symmetric around
     x=0) */
  x=fabs(z-ppt->selection_mean[bin]);

  /* gaussian case (the function is anyway normalized later
     automatically, but could not resist to normalize it already
     here) */
  if (ppt->selection==gaussian) {

    *selection = exp(-0.5*pow(x/ppt->selection_width[bin],2))
      /ppt->selection_width[bin]/sqrt(2.*_PI_);

    if ((ptr->has_nz_file == _TRUE_) || (ptr->has_nz_analytic == _TRUE_)) {

      if (ptr->has_nz_file == _TRUE_) {

        class_test((z<ptr->nz_z[0]) || (z>ptr->nz_z[ptr->nz_size-1]),
                   ptr->error_message,
                   "Your input file for the selection function only covers the redshift range [%f : %f]. However, your input for the selection function requires z=%f",
                   ptr->nz_z[0],
                   ptr->nz_z[ptr->nz_size-1],
                   z);

        class_call(array_interpolate_spline(
                                            ptr->nz_z,
                                            ptr->nz_size,
                                            ptr->nz_nz,
                                            ptr->nz_ddnz,
                                            1,
                                            z,
                                            &last_index,
                                            &dNdz,
                                            1,
                                            ptr->error_message),
                   ptr->error_message,
                   ptr->error_message);
      }
      else {

        class_call(transfer_dNdz_analytic(ptr,
                                          z,
                                          &dNdz,
                                          &dln_dNdz_dz),
                   ptr->error_message,
                   ptr->error_message);
      }

      *selection *= dNdz;
    }

    return _SUCCESS_;
  }

  /* top-hat case, with smoothed edges. The problem with sharp edges
     is that the final result will be affected by random
     noise. Indeed, the values of k at which the transfer functions
     Delta_l(k) are sampled will never coincide with the actual edges
     of the true transfer function (computed with or even without the
     Limber approximation). Hence the integral Cl=\int dk
     Delta_l(k)**2 (...) will be imprecise and will fluctuate randomly
     with the resolution along k. With smooth edges, the problem is
     solved, and the final Cls become mildly dependent on the
     resolution along k. */

  if (ppt->selection==tophat) {

    /* selection function, centered on z=mean (i.e. on x=0), equal to
       one around x=0, with tanh step centered on x=width, of width
       delta x = 0.1*width
    */
    *selection=(1.-tanh((x-ppt->selection_width[bin])/(ppr->selection_tophat_edge*ppt->selection_width[bin])))/2.;

    if ((ptr->has_nz_file == _TRUE_) || (ptr->has_nz_analytic == _TRUE_)) {

      if (ptr->has_nz_file == _TRUE_) {

        class_call(array_interpolate_spline(
                                            ptr->nz_z,
                                            ptr->nz_size,
                                            ptr->nz_nz,
                                            ptr->nz_ddnz,
                                            1,
                                            z,
                                            &last_index,
                                            &dNdz,
                                            1,
                                            ptr->error_message),
                   ptr->error_message,
                   ptr->error_message);
      }
      else {

        class_call(transfer_dNdz_analytic(ptr,
                                          z,
                                          &dNdz,
                                          &dln_dNdz_dz),
                   ptr->error_message,
                   ptr->error_message);
      }

      *selection *= dNdz;
    }

    return _SUCCESS_;
  }

  /* get here only if selection type was recognized */
  class_stop(ptr->error_message,
             "invalid choice of selection function");

  return _SUCCESS_;
}

// Assembly:
subq $0x4078, %rsp           # imm = 0x4078
movq %rdi, 0x4068(%rsp)
movq %rsi, 0x4060(%rsp)
movq %rdx, 0x4058(%rsp)
movl %ecx, 0x4054(%rsp)
movsd %xmm0, 0x4048(%rsp)
movq %r8, 0x4040(%rsp)
movq 0x4060(%rsp), %rax
cmpl $0x2, 0x68(%rax)
jne 0x141b39
movq 0x4040(%rsp), %rax
movsd 0x90723(%rip), %xmm0    # 0x1d2248
movsd %xmm0, (%rax)
movl $0x0, 0x4074(%rsp)
jmp 0x142208
movsd 0x4048(%rsp), %xmm0
movq 0x4060(%rsp), %rax
movslq 0x4054(%rsp), %rcx
subsd 0x70(%rax,%rcx,8), %xmm0
movaps 0x906d1(%rip), %xmm1    # 0x1d2230
pand %xmm1, %xmm0
movsd %xmm0, 0x4038(%rsp)
movq 0x4060(%rsp), %rax
cmpl $0x0, 0x68(%rax)
jne 0x141f18
movsd 0x4038(%rsp), %xmm0
movq 0x4060(%rsp), %rax
movslq 0x4054(%rsp), %rcx
divsd 0x390(%rax,%rcx,8), %xmm0
movl $0x2, %edi
callq 0x5b970
movaps %xmm0, %xmm1
movsd 0x91aeb(%rip), %xmm0    # 0x1d36a0
mulsd %xmm1, %xmm0
callq 0x8670
movq 0x4060(%rsp), %rax
movslq 0x4054(%rsp), %rcx
divsd 0x390(%rax,%rcx,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x938a3(%rip), %xmm0    # 0x1d5488
callq 0x82e0
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
divsd %xmm1, %xmm0
movq 0x4040(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x4058(%rsp), %rax
movswl 0x658(%rax), %eax
cmpl $0x1, %eax
je 0x141c2f
movq 0x4058(%rsp), %rax
movswl 0x65a(%rax), %eax
cmpl $0x1, %eax
jne 0x141f08
movq 0x4058(%rsp), %rax
movswl 0x658(%rax), %eax
cmpl $0x1, %eax
jne 0x141e55
movsd 0x4048(%rsp), %xmm1
movq 0x4058(%rsp), %rax
movq 0x760(%rax), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
ja 0x141ca0
movsd 0x4048(%rsp), %xmm0
movq 0x4058(%rsp), %rax
movq 0x760(%rax), %rax
movq 0x4058(%rsp), %rcx
movl 0x75c(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x141d60
leaq 0x3820(%rsp), %rdi
movq 0x4058(%rsp), %rax
movq 0x760(%rax), %rax
movsd (%rax), %xmm0
movq 0x4058(%rsp), %rax
movq 0x760(%rax), %rax
movq 0x4058(%rsp), %rcx
movl 0x75c(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x4048(%rsp), %xmm2
leaq 0xc1ffc(%rip), %rsi     # 0x203cef
movb $0x3, %al
callq 0x5b9c0
leaq 0x3020(%rsp), %rdi
leaq 0x3820(%rsp), %rcx
leaq 0x90371(%rip), %rsi     # 0x1d2082
leaq 0xc2069(%rip), %rdx     # 0x203d81
movb $0x0, %al
callq 0x5b9c0
movq 0x4058(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x3020(%rsp), %r8
leaq 0x902f7(%rip), %rsi     # 0x1d2034
leaq 0xc206f(%rip), %rdx     # 0x203db3
movl $0xa7d, %ecx            # imm = 0xA7D
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x4074(%rsp)
jmp 0x142208
movq 0x4058(%rsp), %rax
movq 0x760(%rax), %rdi
movq 0x4058(%rsp), %rax
movl 0x75c(%rax), %esi
movq 0x4058(%rsp), %rax
movq 0x768(%rax), %rdx
movq 0x4058(%rsp), %rax
movq 0x770(%rax), %rcx
movsd 0x4048(%rsp), %xmm0
movq 0x4058(%rsp), %rax
addq $0x96a, %rax            # imm = 0x96A
movl $0x1, %r8d
leaq 0x4024(%rsp), %r9
leaq 0x4030(%rsp), %r10
movq %r10, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x24220
cmpl $0x1, %eax
jne 0x141e50
leaq 0x2820(%rsp), %rdi
movq 0x4058(%rsp), %rcx
addq $0x96a, %rcx            # imm = 0x96A
leaq 0x905d7(%rip), %rsi     # 0x1d23d8
leaq 0xc1fc7(%rip), %rdx     # 0x203dcf
movb $0x0, %al
callq 0x5b9c0
movq 0x4058(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x2820(%rsp), %r8
leaq 0x90207(%rip), %rsi     # 0x1d2034
leaq 0xc1f7f(%rip), %rdx     # 0x203db3
movl $0xa8b, %ecx            # imm = 0xA8B
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x4074(%rsp)
jmp 0x142208
jmp 0x141eef
movq 0x4058(%rsp), %rdi
movsd 0x4048(%rsp), %xmm0
leaq 0x4030(%rsp), %rsi
leaq 0x4028(%rsp), %rdx
callq 0x142220
cmpl $0x1, %eax
jne 0x141eed
leaq 0x2020(%rsp), %rdi
movq 0x4058(%rsp), %rcx
addq $0x96a, %rcx            # imm = 0x96A
leaq 0x9053a(%rip), %rsi     # 0x1d23d8
leaq 0xc1fa8(%rip), %rdx     # 0x203e4d
movb $0x0, %al
callq 0x5b9c0
movq 0x4058(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x2020(%rsp), %r8
leaq 0x9016a(%rip), %rsi     # 0x1d2034
leaq 0xc1ee2(%rip), %rdx     # 0x203db3
movl $0xa94, %ecx            # imm = 0xA94
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x4074(%rsp)
jmp 0x142208
jmp 0x141eef
movsd 0x4030(%rsp), %xmm0
movq 0x4040(%rsp), %rax
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl $0x0, 0x4074(%rsp)
jmp 0x142208
movq 0x4060(%rsp), %rax
cmpl $0x1, 0x68(%rax)
jne 0x14219e
movsd 0x4038(%rsp), %xmm0
movq 0x4060(%rsp), %rax
movslq 0x4054(%rsp), %rcx
subsd 0x390(%rax,%rcx,8), %xmm0
movq 0x4068(%rsp), %rax
movsd 0x828(%rax), %xmm1
movq 0x4060(%rsp), %rax
movslq 0x4054(%rsp), %rcx
mulsd 0x390(%rax,%rcx,8), %xmm1
divsd %xmm1, %xmm0
callq 0x80d0
movaps %xmm0, %xmm1
movsd 0x902bf(%rip), %xmm0    # 0x1d2248
subsd %xmm1, %xmm0
movsd 0x90ceb(%rip), %xmm1    # 0x1d2c80
divsd %xmm1, %xmm0
movq 0x4040(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x4058(%rsp), %rax
movswl 0x658(%rax), %eax
cmpl $0x1, %eax
je 0x141fd1
movq 0x4058(%rsp), %rax
movswl 0x65a(%rax), %eax
cmpl $0x1, %eax
jne 0x142191
movq 0x4058(%rsp), %rax
movswl 0x658(%rax), %eax
cmpl $0x1, %eax
jne 0x1420de
movq 0x4058(%rsp), %rax
movq 0x760(%rax), %rdi
movq 0x4058(%rsp), %rax
movl 0x75c(%rax), %esi
movq 0x4058(%rsp), %rax
movq 0x768(%rax), %rdx
movq 0x4058(%rsp), %rax
movq 0x770(%rax), %rcx
movsd 0x4048(%rsp), %xmm0
movq 0x4058(%rsp), %rax
addq $0x96a, %rax            # imm = 0x96A
movl $0x1, %r8d
leaq 0x4024(%rsp), %r9
leaq 0x4030(%rsp), %r10
movq %r10, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x24220
cmpl $0x1, %eax
jne 0x1420d9
leaq 0x1820(%rsp), %rdi
movq 0x4058(%rsp), %rcx
addq $0x96a, %rcx            # imm = 0x96A
leaq 0x9034e(%rip), %rsi     # 0x1d23d8
leaq 0xc1d3e(%rip), %rdx     # 0x203dcf
movb $0x0, %al
callq 0x5b9c0
movq 0x4058(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x1820(%rsp), %r8
leaq 0x8ff7e(%rip), %rsi     # 0x1d2034
leaq 0xc1cf6(%rip), %rdx     # 0x203db3
movl $0xac0, %ecx            # imm = 0xAC0
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x4074(%rsp)
jmp 0x142208
jmp 0x142178
movq 0x4058(%rsp), %rdi
movsd 0x4048(%rsp), %xmm0
leaq 0x4030(%rsp), %rsi
leaq 0x4028(%rsp), %rdx
callq 0x142220
cmpl $0x1, %eax
jne 0x142176
leaq 0x1020(%rsp), %rdi
movq 0x4058(%rsp), %rcx
addq $0x96a, %rcx            # imm = 0x96A
leaq 0x902b1(%rip), %rsi     # 0x1d23d8
leaq 0xc1d1f(%rip), %rdx     # 0x203e4d
movb $0x0, %al
callq 0x5b9c0
movq 0x4058(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x1020(%rsp), %r8
leaq 0x8fee1(%rip), %rsi     # 0x1d2034
leaq 0xc1c59(%rip), %rdx     # 0x203db3
movl $0xac9, %ecx            # imm = 0xAC9
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x4074(%rsp)
jmp 0x142208
jmp 0x142178
movsd 0x4030(%rsp), %xmm0
movq 0x4040(%rsp), %rax
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl $0x0, 0x4074(%rsp)
jmp 0x142208
leaq 0x820(%rsp), %rdi
leaq 0xc1cd4(%rip), %rsi     # 0x203e81
movb $0x0, %al
callq 0x5b9c0
leaq 0x20(%rsp), %rdi
leaq 0x820(%rsp), %rdx
leaq 0x903a5(%rip), %rsi     # 0x1d256d
movb $0x0, %al
callq 0x5b9c0
movq 0x4058(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x20(%rsp), %r8
leaq 0x8fe4a(%rip), %rsi     # 0x1d2034
leaq 0xc1bc2(%rip), %rdx     # 0x203db3
movl $0xad4, %ecx            # imm = 0xAD4
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x4074(%rsp)
movl 0x4074(%rsp), %eax
addq $0x4078, %rsp           # imm = 0x4078
retq
nopw (%rax,%rax)