// File: /workspace/github_cpp_makefile_star2_O1/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 0x664ae
movl %ecx, %ecx
leaq 0x93a9(%rip), %rdx      # 0x6f850
movsd (%rdx,%rcx,8), %xmm0
jmp 0x664b6
movsd 0x79aa(%rip), %xmm0     # 0x6de60
movsd %xmm0, -0x70(%rbp)
movsd 0x8(%rbx), %xmm2
movsd 0x10(%rbx), %xmm4
subsd 0x8(%rax), %xmm2
subsd 0x10(%rax), %xmm4
movapd 0x4b39(%rip), %xmm3     # 0x6b010
movapd %xmm2, -0x60(%rbp)
andpd %xmm3, %xmm2
movsd 0x4b58(%rip), %xmm1     # 0x6b040
ucomisd %xmm2, %xmm1
movapd %xmm4, -0x50(%rbp)
jbe 0x66501
andpd %xmm4, %xmm3
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm1
ja 0x6651f
movapd %xmm4, %xmm0
movapd -0x60(%rbp), %xmm1
callq 0x90d0
mulsd 0x4b31(%rip), %xmm0     # 0x6b048
divsd 0x4b31(%rip), %xmm0     # 0x6b050
movsd 0x4b39(%rip), %xmm2     # 0x6b060
ucomisd %xmm0, %xmm2
jbe 0x66541
movsd 0x4b3b(%rip), %xmm1     # 0x6b070
addsd %xmm1, %xmm0
ucomisd %xmm0, %xmm2
ja 0x66535
jmp 0x66565
ucomisd 0x4aff(%rip), %xmm0     # 0x6b048
jb 0x66565
movsd 0x4b15(%rip), %xmm2     # 0x6b068
movsd 0x4aed(%rip), %xmm1     # 0x6b048
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jae 0x6655b
movapd %xmm0, -0x40(%rbp)
movl 0x28(%r14), %ecx
movq 0x8(%r14), %rax
testl %ecx, %ecx
je 0x66629
cmpl $0xa, %ecx
movl $0xa, %edx
cmovll %ecx, %edx
movq 0x8(%rax), %rax
movslq %edx, %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rdx
addl %esi, %edx
addl %edx, %edx
leal (%rdx,%rdx,4), %edx
movl 0x14b90(%rax), %esi
subl %ecx, %edx
leal (%rsi,%rdx), %ecx
addl $0xa, %ecx
movslq %ecx, %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rdx
addl %esi, %edx
addl %edx, %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %ecx
movslq %ecx, %rcx
imulq $0x2128, %rcx, %r12     # imm = 0x2128
addq %rax, %r12
movslq 0x14(%r14), %r13
callq 0x4a75c
movq %rax, %r15
callq 0x4a75c
imulq $0x178, %r13, %rcx      # imm = 0x178
movsd -0x38(%rcx,%r12), %xmm1
movsd 0x3160(%rax), %xmm0
maxsd 0x3168(%r15), %xmm1
minsd %xmm1, %xmm0
movslq 0x14(%r14), %rax
movq 0x8(%r14), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addsd -0x20(%rcx,%rax), %xmm0
jmp 0x66644
movslq 0x14(%r14), %rcx
imulq $0x178, %rcx, %rcx      # imm = 0x178
leaq (%rcx,%rax), %rdi
addq $-0xd0, %rdi
callq 0x5b2be
movapd -0x40(%rbp), %xmm2
subsd %xmm0, %xmm2
movsd 0x4a0b(%rip), %xmm1     # 0x6b060
ucomisd %xmm2, %xmm1
movapd -0x50(%rbp), %xmm3
jbe 0x66674
movsd 0x4a08(%rip), %xmm0     # 0x6b070
addsd %xmm0, %xmm2
ucomisd %xmm2, %xmm1
ja 0x66668
jmp 0x66698
ucomisd 0x49cc(%rip), %xmm2     # 0x6b048
jb 0x66698
movsd 0x49e2(%rip), %xmm0     # 0x6b068
movsd 0x49ba(%rip), %xmm1     # 0x6b048
addsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jae 0x6668e
xorps %xmm4, %xmm4
cvtsi2sdl 0x18(%rbx), %xmm4
mulsd %xmm3, %xmm3
movapd -0x60(%rbp), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm3, %xmm1
xorps %xmm3, %xmm3
sqrtsd %xmm1, %xmm3
xorpd %xmm5, %xmm5
ucomisd %xmm5, %xmm1
movapd %xmm3, %xmm0
movapd %xmm1, -0x60(%rbp)
jae 0x666fb
movapd %xmm1, %xmm0
movapd %xmm2, -0x40(%rbp)
movsd %xmm4, -0x50(%rbp)
movsd %xmm3, -0x68(%rbp)
callq 0x93c0
xorpd %xmm5, %xmm5
movsd -0x68(%rbp), %xmm3
movsd -0x50(%rbp), %xmm4
movapd -0x60(%rbp), %xmm1
movapd -0x40(%rbp), %xmm2
andpd 0x490d(%rip), %xmm2     # 0x6b010
mulsd 0x5bed(%rip), %xmm0     # 0x6c2f8
mulsd 0x52ad(%rip), %xmm4     # 0x6b9c0
addsd %xmm0, %xmm4
ucomisd %xmm5, %xmm1
jae 0x66743
movapd %xmm1, %xmm0
movapd %xmm2, -0x40(%rbp)
movsd %xmm4, -0x50(%rbp)
callq 0x93c0
movsd -0x50(%rbp), %xmm4
movapd -0x60(%rbp), %xmm1
movapd -0x40(%rbp), %xmm2
movapd %xmm0, %xmm3
divsd %xmm3, %xmm4
ucomisd 0x5b81(%rip), %xmm4     # 0x6c2d0
jae 0x66789
movsd 0x5b7f(%rip), %xmm0     # 0x6c2d8
ucomisd %xmm4, %xmm0
jae 0x66793
movapd %xmm4, %xmm0
movapd %xmm2, -0x40(%rbp)
callq 0x9840
movapd -0x60(%rbp), %xmm1
movapd -0x40(%rbp), %xmm2
mulsd 0x48c9(%rip), %xmm0     # 0x6b048
divsd 0x48c9(%rip), %xmm0     # 0x6b050
jmp 0x6679b
movsd 0x491f(%rip), %xmm0     # 0x6b0b0
jmp 0x6679b
movsd 0x491d(%rip), %xmm0     # 0x6b0b8
subsd %xmm0, %xmm2
movb $0x1, %r14b
movsd -0x70(%rbp), %xmm0
ucomisd %xmm2, %xmm0
ja 0x66948
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
movapd %xmm2, -0x40(%rbp)
jb 0x667c9
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x667d2
movapd %xmm1, %xmm0
callq 0x93c0
movsd %xmm0, -0x50(%rbp)
callq 0x4a75c
movsd 0x3178(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
callq 0x450ba
movslq 0x114(%rbx), %rcx
movq 0x5c38(%rax), %rax
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
xorps %xmm0, %xmm0
cvtsi2sdl 0x18(%rbx), %xmm0
mulsd 0x3098(%rax,%rcx), %xmm0
addsd -0x68(%rbp), %xmm0
ucomisd -0x50(%rbp), %xmm0
ja 0x66948
callq 0x450ba
movslq 0x114(%rbx), %rcx
movq 0x5c38(%rax), %rax
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
xorps %xmm1, %xmm1
cvtsi2sdl 0x18(%rbx), %xmm1
mulsd 0x3098(%rax,%rcx), %xmm1
xorpd %xmm2, %xmm2
movapd -0x60(%rbp), %xmm0
ucomisd %xmm2, %xmm0
jb 0x66864
sqrtsd %xmm0, %xmm0
jmp 0x66877
movsd %xmm1, -0x50(%rbp)
callq 0x93c0
movsd -0x50(%rbp), %xmm1
xorpd %xmm2, %xmm2
divsd %xmm0, %xmm1
movsd 0x47d5(%rip), %xmm0     # 0x6b058
ucomisd %xmm1, %xmm0
jbe 0x6693b
callq 0x450ba
movslq 0x114(%rbx), %rcx
movq 0x5c38(%rax), %rax
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
xorps %xmm2, %xmm2
cvtsi2sdl 0x18(%rbx), %xmm2
mulsd 0x3098(%rax,%rcx), %xmm2
xorpd %xmm1, %xmm1
movapd -0x60(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x668cd
sqrtsd %xmm0, %xmm0
jmp 0x668dc
movsd %xmm2, -0x60(%rbp)
callq 0x93c0
movsd -0x60(%rbp), %xmm2
movapd -0x40(%rbp), %xmm1
divsd %xmm0, %xmm2
ucomisd 0x59e3(%rip), %xmm2     # 0x6c2d0
jae 0x6691d
movsd 0x59e1(%rip), %xmm0     # 0x6c2d8
ucomisd %xmm2, %xmm0
jae 0x66927
movapd %xmm2, %xmm0
callq 0x9840
movapd -0x40(%rbp), %xmm1
mulsd 0x4735(%rip), %xmm0     # 0x6b048
divsd 0x4735(%rip), %xmm0     # 0x6b050
jmp 0x6692f
movsd 0x478b(%rip), %xmm0     # 0x6b0b0
jmp 0x6692f
movsd 0x4789(%rip), %xmm0     # 0x6b0b8
subsd %xmm0, %xmm1
xorpd %xmm2, %xmm2
maxsd %xmm1, %xmm2
movsd -0x70(%rbp), %xmm0
ucomisd %xmm2, %xmm0
seta %r14b
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq