// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/PositionInfo.cpp
// Function: PositionInfo::GetShootAngle(double, double, PlayerState const&, double&)
AngleDeg PositionInfo::GetShootAngle(AngleDeg left, AngleDeg right,
                                     const PlayerState &state,
                                     AngleDeg &interval) {
  vector<pair<Unum, AngleDeg>> tmp;
  for (vector<PlayerState *>::const_iterator it =
           mpWorldState->GetPlayerList().begin();
       it != mpWorldState->GetPlayerList().end(); ++it) {
    if ((*it)->IsAlive() && (*it)->GetPosConf() > FLOAT_EPS &&
        (*it)->GetUnum() != state.GetUnum() &&
        ((*it)->GetPos() - state.GetPos()).Dir() + Rad2Deg(1 / 10) > left &&
        ((*it)->GetPos() - state.GetPos()).Dir() - Rad2Deg(1 / 10) <
            right) { //介于左右门柱之间
      tmp.push_back(pair<Unum, AngleDeg>(
          (*it)->GetUnum(), ((*it)->GetPos() - state.GetPos()).Dir()));
    }
  }
  if (tmp.size() != 0) {
    sort(tmp.begin(), tmp.end(), PlayerDirCompare());
    vector<pair<int, AngleDeg>> dis;
    int i = 0;
    vector<pair<int, AngleDeg>>::const_iterator it;
    for (it = tmp.begin(); it != tmp.end(); ++it) {
      if (i == 0) {
        dis.push_back(pair<int, AngleDeg>(
            i++, ((*it).second - left /* - Rad2Deg(1/10) - Rad2Deg(1/3)*/)));
      } else {
        dis.push_back(pair<int, AngleDeg>(
            i++, ((*it).second -
                  (*(it - 1)).second) /*- 2*Rad2Deg(1/10) - Rad2Deg(1/3)*/));
      }
    }
    dis.push_back(pair<int, AngleDeg>(
        i, (right - (*(it - 1)).second) /*- Rad2Deg(1/10) - Rad2Deg(1/3)*/));
    sort(dis.begin(), dis.end(), PlayerDirCompare());

    if (dis.back().first == 0) {
      interval = dis.back().second - Rad2Deg(1.0 / 10.0) - Rad2Deg(1.0 / 4.0);
      return MinMax(left + 1,
                    dis.back().second / 2 + left - Rad2Deg(1.0 / 10.0) -
                        Rad2Deg(1.0 / 4.0),
                    right - 1);
    } else if (dis.back().first == i) {
      interval = dis.back().second - Rad2Deg(1.0 / 10.0) - Rad2Deg(1.0 / 4.0);
      return MinMax(left + 1,
                    right - dis.back().second / 2 + Rad2Deg(1.0 / 10.0) +
                        Rad2Deg(1.0 / 4.0),
                    right - 1);
    } else {
      interval =
          dis.back().second - 2 * Rad2Deg(1.0 / 10.0) - Rad2Deg(1.0 / 4.0);
      return MinMax(left + 1,
                    (*(tmp.begin() + dis.back().first - 1)).second +
                        dis.back().second / 2,
                    right - 1);
    }
  } else {
    interval = right - left;
    return (left + right) / 2;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, -0x50(%rbp)
movq %rsi, %r14
movsd %xmm1, -0x30(%rbp)
movsd %xmm0, -0x38(%rbp)
movq %rdi, %r15
xorpd %xmm0, %xmm0
leaq -0x90(%rbp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq 0x10(%rdi), %rax
movq 0x20f8(%rax), %r12
movsd 0x1b3bc(%rip), %xmm1    # 0x57040
leaq -0x70(%rbp), %r13
leaq -0x48(%rbp), %rbx
cmpq 0x2100(%rax), %r12
je 0x3bdab
movq (%r12), %rax
cmpb $0x1, 0x112(%rax)
jne 0x3bd9e
movsd 0x20(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3bd9e
movl 0x11c(%rax), %ecx
cmpl 0x11c(%r14), %ecx
je 0x3bd9e
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
subsd 0x8(%r14), %xmm0
subsd 0x10(%r14), %xmm1
movsd %xmm0, -0x70(%rbp)
movsd %xmm1, -0x68(%rbp)
movq %r13, %rdi
callq 0xcd30
ucomisd -0x38(%rbp), %xmm0
movsd 0x1b33f(%rip), %xmm1    # 0x57040
jbe 0x3bd9e
movq (%r12), %rax
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
subsd 0x8(%r14), %xmm0
subsd 0x10(%r14), %xmm1
movsd %xmm0, -0x48(%rbp)
movsd %xmm1, -0x40(%rbp)
movq %rbx, %rdi
callq 0xcd30
movsd -0x30(%rbp), %xmm1
ucomisd %xmm0, %xmm1
movsd 0x1b2fc(%rip), %xmm1    # 0x57040
jbe 0x3bd9e
movq (%r12), %rax
movq %rbx, %rdi
movl 0x11c(%rax), %r13d
movsd 0x8(%rax), %xmm0
movsd 0x10(%rax), %xmm1
subsd 0x8(%r14), %xmm0
subsd 0x10(%r14), %xmm1
movsd %xmm0, -0x48(%rbp)
movsd %xmm1, -0x40(%rbp)
callq 0xcd30
movl %r13d, -0x70(%rbp)
movsd %xmm0, -0x68(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x18440
movsd 0x1b2a6(%rip), %xmm1    # 0x57040
leaq -0x70(%rbp), %r13
addq $0x8, %r12
movq 0x10(%r15), %rax
jmp 0x3bc8c
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rsi
cmpq %rdi, %rsi
je 0x3bede
callq 0x3cdac
xorpd %xmm0, %xmm0
leaq -0x70(%rbp), %rbx
andq $0x0, 0x10(%rbx)
movapd %xmm0, (%rbx)
xorl %r15d, %r15d
movq -0x90(%rbp), %r12
leaq -0x48(%rbp), %r14
cmpq -0x88(%rbp), %r12
je 0x3be41
testl %r15d, %r15d
je 0x3be18
movsd 0x8(%r12), %xmm0
subsd -0x8(%r12), %xmm0
movl %r15d, -0x48(%rbp)
movsd %xmm0, -0x40(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x18440
jmp 0x3be38
movsd 0x8(%r12), %xmm0
subsd -0x38(%rbp), %xmm0
andl $0x0, -0x48(%rbp)
movsd %xmm0, -0x40(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x18440
addq $0x10, %r12
incl %r15d
jmp 0x3bde6
movsd -0x30(%rbp), %xmm0
subsd -0x8(%r12), %xmm0
leaq -0x48(%rbp), %rsi
movl %r15d, (%rsi)
movsd %xmm0, 0x8(%rsi)
leaq -0x70(%rbp), %rdi
callq 0x18440
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x3cdac
movq -0x68(%rbp), %rax
movslq -0x10(%rax), %rcx
testq %rcx, %rcx
je 0x3bf0e
movsd -0x8(%rax), %xmm0
movsd -0x38(%rbp), %xmm2
addsd 0x1b1b6(%rip), %xmm2    # 0x57048
cmpl %r15d, %ecx
jne 0x3bf79
addsd 0x1df35(%rip), %xmm0    # 0x59dd8
addsd 0x1df25(%rip), %xmm0    # 0x59dd0
movq -0x50(%rbp), %rcx
movsd %xmm0, (%rcx)
movsd -0x8(%rax), %xmm0
mulsd 0x1b1a0(%rip), %xmm0    # 0x57060
movsd -0x30(%rbp), %xmm1
addsd %xmm1, %xmm0
addsd 0x1df0f(%rip), %xmm0    # 0x59de0
addsd 0x1df0f(%rip), %xmm0    # 0x59de8
jmp 0x3bfb4
movsd -0x30(%rbp), %xmm1
movapd %xmm1, %xmm0
movsd -0x38(%rbp), %xmm2
subsd %xmm2, %xmm0
movq -0x50(%rbp), %rax
movsd %xmm0, (%rax)
addsd %xmm1, %xmm2
mulsd 0x1b944(%rip), %xmm2    # 0x57848
movsd %xmm2, -0x30(%rbp)
jmp 0x3bfd2
movsd 0x1dec2(%rip), %xmm0    # 0x59dd8
movsd -0x8(%rax), %xmm1
addsd %xmm0, %xmm1
movsd 0x1dea9(%rip), %xmm2    # 0x59dd0
addsd %xmm2, %xmm1
movq -0x50(%rbp), %rcx
movsd %xmm1, (%rcx)
movsd 0x1b10d(%rip), %xmm1    # 0x57048
movsd -0x8(%rax), %xmm3
mulsd 0x1b900(%rip), %xmm3    # 0x57848
movsd -0x38(%rbp), %xmm4
addsd %xmm4, %xmm1
addsd %xmm4, %xmm3
addsd %xmm0, %xmm3
addsd %xmm2, %xmm3
maxsd %xmm1, %xmm3
movsd -0x30(%rbp), %xmm0
addsd 0x1b102(%rip), %xmm0    # 0x57070
minsd %xmm3, %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x3bfc9
addsd 0x1de47(%rip), %xmm0    # 0x59dc8
addsd 0x1de47(%rip), %xmm0    # 0x59dd0
movq -0x50(%rbp), %rdx
movsd %xmm0, (%rdx)
movq -0x90(%rbp), %rdx
shlq $0x4, %rcx
movsd -0x8(%rax), %xmm0
mulsd 0x1b89f(%rip), %xmm0    # 0x57848
addsd -0x8(%rdx,%rcx), %xmm0
movsd -0x30(%rbp), %xmm1
addsd 0x1b0b4(%rip), %xmm1    # 0x57070
maxsd %xmm2, %xmm0
minsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x18402
leaq -0x90(%rbp), %rdi
callq 0x18402
movsd -0x30(%rbp), %xmm0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3c003
jmp 0x3c003
jmp 0x3bffc
jmp 0x3bffc
jmp 0x3bffc
movq %rax, %rbx
jmp 0x3c00f
jmp 0x3c003
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x18402
leaq -0x90(%rbp), %rdi
callq 0x18402
movq %rbx, %rdi
callq 0x98b0
nop