// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/WorldState.cpp
// Function: WorldStateUpdater::ComputePlayerMaySeeOrNot(PlayerState const&)
bool WorldStateUpdater::ComputePlayerMaySeeOrNot(const PlayerState &state) {
  double view_angle = 0;
  switch (GetSelf().GetViewWidth()) {
  case VW_Narrow:
    view_angle = 60;
    break;
  case VW_Normal:
    view_angle = 120;
    break;
  case VW_Wide:
    view_angle = 180;
    break;
  default:
    view_angle = 120;
    break;
  }

  Vector dist_vec = state.GetPos() - GetSelf().GetPos();
  double angle = GetNormalizeAngleDeg(dist_vec.Dir());
  angle = ::fabs(::GetNormalizeAngleDeg(
      angle - GetNeckGlobalDirFromSightDelay(mSightDelay)));

  double anglebuf = ASin((state.GetPosDelay() * 0.6 + 0.05 * dist_vec.Mod()) /
                         dist_vec.Mod());

  angle -= anglebuf;

  if (angle < view_angle / 2) {
    return true;
  }

  if (dist_vec.Mod() <
      ServerParam::instance().visibleDistance() + ComputePlayerMaxDist(state)) {
    return true;
  }

  double dist = ComputePlayerMaxDist(state) / dist_vec.Mod();
  if (dist < 1) {
    double delta_angle = ASin(ComputePlayerMaxDist(state) / dist_vec.Mod());
    angle -= delta_angle;

    if (angle < 0) {
      angle = 0;
    }
  } else {
    angle = 0;
  }

  if (angle < view_angle / 2) {
    return true;
  }

  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movslq 0x14(%rdi), %rax
movq 0x8(%rdi), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addq %rcx, %rax
addq $-0xd0, %rax
movl 0x118(%rax), %ecx
decl %ecx
cmpl $0x2, %ecx
ja 0x530d2
movl %ecx, %ecx
leaq 0x8725(%rip), %rdx      # 0x5b7f0
movsd (%rdx,%rcx,8), %xmm0
jmp 0x530da
movsd 0x6d36(%rip), %xmm0     # 0x59e10
movsd %xmm0, -0x30(%rbp)
movsd 0x8(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
subsd 0x8(%rax), %xmm0
subsd 0x10(%rax), %xmm1
leaq -0x48(%rbp), %r15
movsd %xmm0, (%r15)
movsd %xmm1, 0x8(%r15)
movq %r15, %rdi
callq 0xcd30
movabsq $-0x3f99800000000000, %r13 # imm = 0xC066800000000000
leaq -0x38(%rbp), %r12
movq %r13, (%r12)
movq %r12, %rdi
callq 0xd305
movsd %xmm0, -0x60(%rbp)
movl 0x28(%r14), %esi
movq %r14, %rdi
callq 0x5593e
movsd -0x60(%rbp), %xmm1
subsd %xmm0, %xmm1
movq %r13, (%r12)
leaq -0x38(%rbp), %r14
movapd %xmm1, %xmm0
movq %r14, %rdi
callq 0xd305
andpd 0x3eb6(%rip), %xmm0     # 0x57010
movapd %xmm0, -0x60(%rbp)
cvtsi2sdl 0x18(%rbx), %xmm0
movsd (%r15), %xmm1
movsd 0x8(%r15), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
sqrtsd %xmm1, %xmm1
movsd 0x5111(%rip), %xmm2     # 0x58298
mulsd 0x4801(%rip), %xmm0     # 0x57990
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%r14)
leaq -0x38(%rbp), %rdi
callq 0x1cba1
movapd -0x60(%rbp), %xmm1
subsd %xmm0, %xmm1
movb $0x1, %r14b
movapd %xmm1, -0x60(%rbp)
movsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x5329b
movsd -0x48(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
callq 0x3db2c
movsd 0x3178(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq %rbx, %rsi
callq 0x532ae
addsd -0x68(%rbp), %xmm0
ucomisd -0x70(%rbp), %xmm0
ja 0x5329b
movq %rbx, %rsi
callq 0x532ae
movsd -0x48(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
sqrtsd %xmm1, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
movsd 0x3e04(%rip), %xmm2     # 0x57048
ucomisd %xmm0, %xmm2
jbe 0x5328e
movq %rbx, %rsi
callq 0x532ae
movsd -0x48(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
sqrtsd %xmm1, %xmm1
divsd %xmm1, %xmm0
leaq -0x38(%rbp), %rdi
movsd %xmm0, (%rdi)
callq 0x1cba1
movapd -0x60(%rbp), %xmm2
subsd %xmm0, %xmm2
xorpd %xmm1, %xmm1
maxsd %xmm2, %xmm1
movsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
seta %r14b
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop