// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_update_HIS
int transfer_update_HIS(
                        struct precision * ppr,
                        struct transfer * ptr,
                        struct transfer_workspace * ptw,
                        int index_q,
                        double tau0
                        ) {

  double nu,new_nu;
  int int_nu;
  double xmin, xmax, sampling, phiminabs, xtol;
  double sqrt_absK;
  int l_size_max;
  int index_l_left,index_l_right;

  if (ptw->HIS_allocated == _TRUE_) {
    class_call(hyperspherical_HIS_free(&(ptw->HIS),ptr->error_message),
               ptr->error_message,
               ptr->error_message);
    ptw->HIS_allocated = _FALSE_;
  }

  if ((ptw->sgnK!=0) && (index_q < ptr->index_q_flat_approximation)) {

    xmin = ppr->hyper_x_min;

    sqrt_absK = sqrt(ptw->sgnK*ptw->K);

    xmax = sqrt_absK*tau0;
    nu = ptr->q[index_q]/sqrt_absK;

    if (ptw->sgnK == 1) {
      xmax = MIN(xmax,_PI_/2.0-ppr->hyper_x_min); //We only need solution on [0;pi/2]

      int_nu = (int)(nu+0.2);
      new_nu = (double)int_nu;
      class_test(nu-new_nu > 1.e-6,
                 ptr->error_message,
                 "problem in q list definition in closed case for index_q=%d, nu=%e, nu-int(nu)=%e",index_q,nu,nu-new_nu);
      nu = new_nu;

    }

    if (nu > ppr->hyper_nu_sampling_step)
      sampling = ppr->hyper_sampling_curved_high_nu;
    else
      sampling = ppr->hyper_sampling_curved_low_nu;

    /* find the highest value of l such that x_nonzero < xmax = sqrt(|K|) tau0. That will be l_max. */
    l_size_max = ptr->l_size_max;
    if (ptw->sgnK == 1)
      while ((double)ptr->l[l_size_max-1] >= nu)
        l_size_max--;

    if (ptw->sgnK == -1){
      xtol = ppr->hyper_x_tol;
      phiminabs = ppr->hyper_phi_min_abs;

      /* First try to find lmax using fast approximation: */
      index_l_left=0;
      index_l_right=l_size_max-1;
      class_call(transfer_get_lmax(hyperspherical_get_xmin_from_approx,
                                   ptw->sgnK,
                                   nu,
                                   ptr->l,
                                   l_size_max,
                                   phiminabs,
                                   xmax,
                                   xtol,
                                   &index_l_left,
                                   &index_l_right,
                                   ptr->error_message),
                 ptr->error_message,
                 ptr->error_message);

      /* Now use WKB approximation to eventually modify borders: */
      class_call(transfer_get_lmax(hyperspherical_get_xmin_from_Airy,
                                   ptw->sgnK,
                                   nu,
                                   ptr->l,
                                   l_size_max,
                                   phiminabs,
                                   xmax,
                                   xtol,
                                   &index_l_left,
                                   &index_l_right,
                                   ptr->error_message),
                 ptr->error_message,
                 ptr->error_message);
      l_size_max = index_l_right+1;
    }

    class_test(nu <= 0.,
               ptr->error_message,
               "nu=%e when index_q=%d, q=%e, K=%e, sqrt(|K|)=%e; instead nu should always be strictly positive",
               nu,index_q,ptr->q[index_q],ptw->K,sqrt_absK);

    class_call(hyperspherical_HIS_create(ptw->sgnK,
                                         nu,
                                         l_size_max,
                                         ptr->l,
                                         xmin,
                                         xmax,
                                         sampling,
                                         ptr->l[l_size_max-1]+1,
                                         ppr->hyper_phi_min_abs,
                                         &(ptw->HIS),
                                         ptr->error_message),
               ptr->error_message,
               ptr->error_message);

    ptw->HIS_allocated = _TRUE_;

  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1068, %rsp           # imm = 0x1068
movapd %xmm0, %xmm2
movl %ecx, %r13d
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
cmpl $0x1, 0x60(%rdx)
jne 0xab4a1
movsd %xmm2, 0x10(%rsp)
leaq 0x96a(%rbx), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x20f0c
cmpl $0x1, %eax
jne 0xab496
leaq 0x39f91(%rip), %rsi     # 0xe53f0
leaq 0x6c37f(%rip), %rdx     # 0x1177e5
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x39bb5(%rip), %rsi     # 0xe5034
leaq 0x6c3af(%rip), %rdx     # 0x117835
movq %r12, %rdi
movl $0x11e0, %ecx           # imm = 0x11E0
movq %rbx, %r8
jmp 0xab7d8
andl $0x0, 0x60(%r14)
movsd 0x10(%rsp), %xmm2
movl 0xc0(%r14), %eax
xorl %ebp, %ebp
testl %eax, %eax
je 0xab7e2
cmpl %r13d, 0x938(%rbx)
jle 0xab7e2
cvtsi2sd %eax, %xmm0
mulsd 0xb8(%r14), %xmm0
movsd 0x718(%r15), %xmm3
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movsd %xmm3, 0x58(%rsp)
jb 0xab4eb
sqrtsd %xmm0, %xmm5
jmp 0xab500
movsd %xmm2, 0x10(%rsp)
callq 0x82d0
movsd 0x10(%rsp), %xmm2
movapd %xmm0, %xmm5
mulsd %xmm5, %xmm2
movq 0x928(%rbx), %rax
movslq %r13d, %r12
movsd (%rax,%r12,8), %xmm0
divsd %xmm5, %xmm0
movl 0xc0(%r14), %eax
cmpl $0x1, %eax
jne 0xab5c5
movsd 0x39d68(%rip), %xmm1    # 0xe5298
addsd %xmm0, %xmm1
cvttpd2dq %xmm1, %xmm1
cvtdq2pd %xmm1, %xmm4
movapd %xmm0, %xmm1
subsd %xmm4, %xmm1
ucomisd 0x3a784(%rip), %xmm1    # 0xe5cd0
jbe 0xab5ac
leaq 0x6c2f4(%rip), %rsi     # 0x117849
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movl %r13d, %edx
movb $0x2, %al
callq 0x2e014
leaq 0x39b14(%rip), %rsi     # 0xe5082
leaq 0x6c325(%rip), %rdx     # 0x11789a
leaq 0x860(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x39a9c(%rip), %rsi     # 0xe5034
leaq 0x6c296(%rip), %rdx     # 0x117835
movq %rbx, %rdi
movl $0x11f4, %ecx           # imm = 0x11F4
jmp 0xab7d5
movsd 0x3ce94(%rip), %xmm1    # 0xe8448
subsd 0x718(%r15), %xmm1
minsd %xmm1, %xmm2
movapd %xmm4, %xmm0
xorl %ecx, %ecx
ucomisd 0x738(%r15), %xmm0
seta %cl
movl 0x908(%rbx), %r13d
cmpl $0x1, %eax
jne 0xab606
movslq %r13d, %rdx
movq 0x910(%rbx), %rsi
leal 0x1(%rdx), %r13d
leaq (%rsi,%rdx,4), %rdx
addq $-0x4, %rdx
cvtsi2sdl (%rdx), %xmm1
decl %r13d
addq $-0x4, %rdx
ucomisd %xmm0, %xmm1
jae 0xab5f5
movsd 0x728(%r15,%rcx,8), %xmm3
cmpl $-0x1, %eax
je 0xab6a6
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jae 0xab762
movl 0xc0(%r14), %edi
movq 0x910(%rbx), %rdx
movslq %r13d, %rsi
movl -0x4(%rdx,%rsi,4), %ecx
incl %ecx
movsd 0x740(%r15), %xmm4
addq $0x96a, %rbx            # imm = 0x96A
movsd 0x58(%rsp), %xmm1
movq %r14, %r8
movq %rbx, %r9
callq 0x1fe2c
cmpl $0x1, %eax
jne 0xab7f6
leaq 0x39d81(%rip), %rsi     # 0xe53f0
leaq 0x6c3e4(%rip), %rdx     # 0x117a5a
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x399a5(%rip), %rsi     # 0xe5034
leaq 0x6c19f(%rip), %rdx     # 0x117835
movq %rbx, %rdi
movl $0x123b, %ecx           # imm = 0x123B
movq %r14, %r8
jmp 0xab7d8
movsd %xmm3, 0x38(%rsp)
movsd %xmm5, 0x40(%rsp)
movsd 0x740(%r15), %xmm1
movsd 0x748(%r15), %xmm3
leaq 0x2c(%rsp), %r8
andl $0x0, (%r8)
leal -0x1(%r13), %eax
leaq 0x1c(%rsp), %r9
movl %eax, (%r9)
movq 0x910(%rbx), %rdx
leaq 0x96a(%rbx), %rax
movq %rax, 0x20(%rsp)
movq %rax, (%rsp)
leaq -0x8a9c1(%rip), %rdi    # 0x20d36
pushq $-0x1
popq %rsi
movl %r13d, %ecx
movsd %xmm1, 0x48(%rsp)
movsd %xmm2, 0x10(%rsp)
movsd %xmm3, 0x50(%rsp)
movsd %xmm0, 0x30(%rsp)
callq 0xab8b1
testl %eax, %eax
je 0xab800
leaq 0x39cc7(%rip), %rsi     # 0xe53f0
leaq 0x6c17c(%rip), %rdx     # 0x1178ac
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x20(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x398e6(%rip), %rsi     # 0xe5034
leaq 0x6c0e0(%rip), %rdx     # 0x117835
movq %r14, %rdi
movl $0x1217, %ecx           # imm = 0x1217
jmp 0xab48e
movq 0x928(%rbx), %rax
movsd (%rax,%r12,8), %xmm1
movsd 0xb8(%r14), %xmm2
leaq 0x6c273(%rip), %rsi     # 0x1179f2
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movl %r12d, %edx
movapd %xmm5, %xmm3
movb $0x4, %al
callq 0x2e014
leaq 0x398e6(%rip), %rsi     # 0xe5082
leaq 0x6c2ae(%rip), %rdx     # 0x117a51
leaq 0x860(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x3986e(%rip), %rsi     # 0xe5034
leaq 0x6c068(%rip), %rdx     # 0x117835
movq %rbx, %rdi
movl $0x122d, %ecx           # imm = 0x122D
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, 0x60(%r14)
jmp 0xab7e2
movl 0xc0(%r14), %esi
movq 0x910(%rbx), %rdx
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
leaq -0x87d5a(%rip), %rdi    # 0x23ac4
leaq 0x2c(%rsp), %r8
leaq 0x1c(%rsp), %r9
movsd 0x30(%rsp), %xmm0
movl %r13d, %ecx
movsd 0x48(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x50(%rsp), %xmm3
callq 0xab8b1
testl %eax, %eax
je 0xab88c
leaq 0x39b9d(%rip), %rsi     # 0xe53f0
leaq 0x6c0f6(%rip), %rdx     # 0x117950
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x20(%rsp), %r14
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x397bc(%rip), %rsi     # 0xe5034
leaq 0x6bfb6(%rip), %rdx     # 0x117835
movq %r14, %rdi
movl $0x1226, %ecx           # imm = 0x1226
jmp 0xab48e
movl 0x1c(%rsp), %r13d
incl %r13d
movsd 0x10(%rsp), %xmm2
movsd 0x40(%rsp), %xmm5
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm3
jmp 0xab619