// File: /workspace/github_cpp_makefile_star2_O3/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 0x641c4
movl %ecx, %ecx
leaq 0x9653(%rip), %rdx      # 0x6d810
movsd (%rdx,%rcx,8), %xmm0
jmp 0x641cc
movsd 0x7c64(%rip), %xmm0     # 0x6be30
movsd %xmm0, -0x58(%rbp)
movsd 0x8(%rbx), %xmm2
movsd 0x10(%rbx), %xmm4
subsd 0x8(%rax), %xmm2
subsd 0x10(%rax), %xmm4
movapd 0x4e23(%rip), %xmm3     # 0x69010
movapd %xmm2, -0x40(%rbp)
andpd %xmm3, %xmm2
movsd 0x4e42(%rip), %xmm1     # 0x69040
ucomisd %xmm2, %xmm1
movapd %xmm4, -0x70(%rbp)
jbe 0x64217
andpd %xmm4, %xmm3
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm1
ja 0x6427b
movapd %xmm4, %xmm0
movapd -0x40(%rbp), %xmm1
callq 0x90d0
mulsd 0x4e1b(%rip), %xmm0     # 0x69048
divsd 0x4e1b(%rip), %xmm0     # 0x69050
movsd 0x4e23(%rip), %xmm2     # 0x69060
ucomisd %xmm0, %xmm2
jbe 0x64257
movsd 0x4e25(%rip), %xmm1     # 0x69070
addsd %xmm1, %xmm0
ucomisd %xmm0, %xmm2
ja 0x6424b
jmp 0x6427b
ucomisd 0x4de9(%rip), %xmm0     # 0x69048
jb 0x6427b
movsd 0x4dff(%rip), %xmm2     # 0x69068
movsd 0x4dd7(%rip), %xmm1     # 0x69048
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jae 0x64271
movapd %xmm0, -0x50(%rbp)
movl 0x28(%r14), %ecx
movq 0x8(%r14), %rax
testl %ecx, %ecx
je 0x6433f
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 0x49360
movq %rax, %r15
callq 0x49360
imulq $0x178, %r13, %rcx      # imm = 0x178
movsd -0x38(%rcx,%r12), %xmm1
maxsd 0x3168(%r15), %xmm1
movsd 0x3160(%rax), %xmm0
minsd %xmm1, %xmm0
movslq 0x14(%r14), %rax
movq 0x8(%r14), %rcx
imulq $0x178, %rax, %rax      # imm = 0x178
addsd -0x20(%rcx,%rax), %xmm0
jmp 0x6435a
movslq 0x14(%r14), %rcx
imulq $0x178, %rcx, %rcx      # imm = 0x178
leaq (%rcx,%rax), %rdi
addq $-0xd0, %rdi
callq 0x59a22
movapd -0x50(%rbp), %xmm2
subsd %xmm0, %xmm2
movsd 0x4cf5(%rip), %xmm0     # 0x69060
ucomisd %xmm2, %xmm0
movapd -0x70(%rbp), %xmm3
jbe 0x6438a
movsd 0x4cf2(%rip), %xmm1     # 0x69070
addsd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
ja 0x6437e
jmp 0x643ae
ucomisd 0x4cb6(%rip), %xmm2     # 0x69048
jb 0x643ae
movsd 0x4ccc(%rip), %xmm0     # 0x69068
movsd 0x4ca4(%rip), %xmm1     # 0x69048
addsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jae 0x643a4
andpd 0x4c5a(%rip), %xmm2     # 0x69010
xorps %xmm0, %xmm0
cvtsi2sdl 0x18(%rbx), %xmm0
mulsd %xmm3, %xmm3
movapd -0x40(%rbp), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm3, %xmm1
xorps %xmm3, %xmm3
sqrtsd %xmm1, %xmm3
movsd 0x5f0a(%rip), %xmm1     # 0x6a2e8
mulsd %xmm3, %xmm1
mulsd 0x55d6(%rip), %xmm0     # 0x699c0
addsd %xmm1, %xmm0
divsd %xmm3, %xmm0
ucomisd 0x5ec6(%rip), %xmm0     # 0x6a2c0
jae 0x64435
movsd 0x5ec4(%rip), %xmm1     # 0x6a2c8
ucomisd %xmm0, %xmm1
jae 0x6443f
movapd %xmm2, -0x50(%rbp)
movsd %xmm3, -0x40(%rbp)
callq 0x9840
movsd -0x40(%rbp), %xmm3
movapd -0x50(%rbp), %xmm2
mulsd 0x4c1d(%rip), %xmm0     # 0x69048
divsd 0x4c1d(%rip), %xmm0     # 0x69050
jmp 0x64447
movsd 0x4c73(%rip), %xmm0     # 0x690b0
jmp 0x64447
movsd 0x4c71(%rip), %xmm0     # 0x690b8
subsd %xmm0, %xmm2
movb $0x1, %r14b
movsd -0x58(%rbp), %xmm0
ucomisd %xmm2, %xmm0
ja 0x6458d
movapd %xmm2, -0x50(%rbp)
movsd %xmm3, -0x40(%rbp)
callq 0x49360
movsd 0x3178(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
callq 0x43dce
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 -0x70(%rbp), %xmm0
ucomisd -0x40(%rbp), %xmm0
ja 0x6458d
callq 0x43dce
movsd -0x40(%rbp), %xmm3
movslq 0x114(%rbx), %rcx
movq 0x5c38(%rax), %rax
xorps %xmm1, %xmm1
cvtsi2sdl 0x18(%rbx), %xmm1
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
mulsd 0x3098(%rax,%rcx), %xmm1
divsd %xmm3, %xmm1
xorpd %xmm0, %xmm0
movsd 0x4b64(%rip), %xmm2     # 0x69058
ucomisd %xmm1, %xmm2
jbe 0x64580
callq 0x43dce
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
divsd -0x40(%rbp), %xmm0
ucomisd 0x5d8a(%rip), %xmm0     # 0x6a2c0
jae 0x6455d
movsd 0x5d88(%rip), %xmm1     # 0x6a2c8
ucomisd %xmm0, %xmm1
jae 0x64567
callq 0x9840
mulsd 0x4af5(%rip), %xmm0     # 0x69048
divsd 0x4af5(%rip), %xmm0     # 0x69050
jmp 0x6456f
movsd 0x4b4b(%rip), %xmm0     # 0x690b0
jmp 0x6456f
movsd 0x4b49(%rip), %xmm0     # 0x690b8
movapd -0x50(%rbp), %xmm1
subsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
maxsd %xmm1, %xmm0
movsd -0x58(%rbp), %xmm1
ucomisd %xmm0, %xmm1
seta %r14b
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop