// File: 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
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x80(%rbp)
movq $0x0, -0x20(%rbp)
callq 0xbcea0
movq %rax, %rdi
callq 0x11070
movl %eax, %ecx
movl %ecx, -0x74(%rbp)
subl $0x1, %eax
je 0xb8250
jmp 0xb823c
movl -0x74(%rbp), %eax
subl $0x2, %eax
je 0xb825f
jmp 0xb8246
movl -0x74(%rbp), %eax
subl $0x3, %eax
je 0xb826e
jmp 0xb827d
movsd 0x9a38(%rip), %xmm0     # 0xc1c90
movsd %xmm0, -0x20(%rbp)
jmp 0xb828a
movsd 0xa681(%rip), %xmm0     # 0xc28e8
movsd %xmm0, -0x20(%rbp)
jmp 0xb828a
movsd 0x8db2(%rip), %xmm0     # 0xc1028
movsd %xmm0, -0x20(%rbp)
jmp 0xb828a
movsd 0xa663(%rip), %xmm0     # 0xc28e8
movsd %xmm0, -0x20(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x11090
movq -0x80(%rbp), %rdi
movq %rax, -0xa0(%rbp)
callq 0xbcea0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x110a0
movsd %xmm0, -0x30(%rbp)
movsd %xmm1, -0x28(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x10520
movsd 0x8d53(%rip), %xmm1     # 0xc1030
movsd %xmm1, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x116b0
movq -0x80(%rbp), %rdi
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movl 0x28(%rdi), %esi
callq 0xbd3c0
movaps %xmm0, %xmm1
movsd -0x98(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd 0x8d10(%rip), %xmm1     # 0xc1030
movsd %xmm1, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x116b0
movaps 0x8d2b(%rip), %xmm1     # 0xc1060
pand %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x1ddd0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x90(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x104e0
movaps %xmm0, %xmm2
movsd -0x90(%rbp), %xmm0
movsd 0x9b65(%rip), %xmm1     # 0xc1ed8
mulsd %xmm2, %xmm1
movsd 0x95e9(%rip), %xmm2     # 0xc1968
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x104e0
movaps %xmm0, %xmm1
movsd -0x88(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x32500
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
movsd 0x90d1(%rip), %xmm2     # 0xc14b0
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xb83f2
movb $0x1, -0x1(%rbp)
jmp 0xb8525
leaq -0x30(%rbp), %rdi
callq 0x104e0
movsd %xmm0, -0xb0(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x8b250
movq -0x80(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x18(%rbp), %rsi
callq 0xb8540
movsd -0xb0(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0xa8(%rbp), %xmm0
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xb844f
movb $0x1, -0x1(%rbp)
jmp 0xb8525
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xb8540
movsd %xmm0, -0xb8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x104e0
movaps %xmm0, %xmm1
movsd -0xb8(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0x8b87(%rip), %xmm0     # 0xc1010
ucomisd -0x60(%rbp), %xmm0
jbe 0xb84f7
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xb8540
movsd %xmm0, -0xc0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x104e0
movaps %xmm0, %xmm1
movsd -0xc0(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x32500
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x38(%rbp), %xmm0
jbe 0xb84f5
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0xb84ff
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
movsd 0x8f9f(%rip), %xmm2     # 0xc14b0
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xb8521
movb $0x1, -0x1(%rbp)
jmp 0xb8525
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)