// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/Kicker.h
// Function: Kicker::NearestPoint(Vector const&)
inline int NearestPoint(const Vector &p) {
    double ang = 0.0;
    double value = p.Mod();
    int idxA;
    if (value < mD1) {
      double fix = 180.0 / mNlayer[0];
      ang = p.Dir() + fix;
      ang = GetNormalizeAngleDeg(ang, 0.0);
      idxA = int(ang * mNlayer[0] / 360.0);
      return idxA;
    } else if (value > mD2) {
      double fix = 180.0 / mNlayer[2];
      ang = p.Dir() + fix;
      ang = GetNormalizeAngleDeg(ang, 0.0);
      idxA = int(ang * mNlayer[2] / 360.0);
      return mNlayer[0] + mNlayer[1] + idxA;
    } else {
      double fix = 180.0 / mNlayer[1];
      ang = p.Dir() + fix;
      ang = GetNormalizeAngleDeg(ang, 0.0);
      idxA = int(ang * mNlayer[1] / 360.0);
      return mNlayer[0] + idxA;
    }
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x104e0
movq -0xb0(%rbp), %rax
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm1
movsd 0x20(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x57215
movq -0xb0(%rbp), %rdi
addq $0x10, %rdi
movq $0x0, -0x40(%rbp)
leaq -0x40(%rbp), %rsi
callq 0x4aaa0
cvtsi2sdl (%rax), %xmm1
movsd 0x69ea1(%rip), %xmm0    # 0xc1028
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10520
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
movsd %xmm1, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x116b0
movq -0xb0(%rbp), %rdi
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
addq $0x10, %rdi
movq $0x0, -0x50(%rbp)
leaq -0x50(%rbp), %rsi
callq 0x4aaa0
movsd -0xb8(%rbp), %xmm0
cvtsi2sdl (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x69e49(%rip), %xmm1    # 0xc1048
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5741a
movq -0xb0(%rbp), %rax
movsd -0x28(%rbp), %xmm0
ucomisd 0x28(%rax), %xmm0
jbe 0x5732d
movq -0xb0(%rbp), %rdi
addq $0x10, %rdi
movq $0x2, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
callq 0x4aaa0
cvtsi2sdl (%rax), %xmm1
movsd 0x69dd4(%rip), %xmm0    # 0xc1028
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10520
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
movsd %xmm1, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x116b0
movq -0xb0(%rbp), %rdi
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
addq $0x10, %rdi
movq $0x2, -0x70(%rbp)
leaq -0x70(%rbp), %rsi
callq 0x4aaa0
movsd -0xc8(%rbp), %xmm0
movq -0xb0(%rbp), %rdi
cvtsi2sdl (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x69d75(%rip), %xmm1    # 0xc1048
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2c(%rbp)
addq $0x10, %rdi
movq $0x0, -0x78(%rbp)
leaq -0x78(%rbp), %rsi
callq 0x4aaa0
movq -0xb0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xbc(%rbp)
addq $0x10, %rdi
movq $0x1, -0x80(%rbp)
leaq -0x80(%rbp), %rsi
callq 0x4aaa0
movq %rax, %rcx
movl -0xbc(%rbp), %eax
addl (%rcx), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5741a
movq -0xb0(%rbp), %rdi
addq $0x10, %rdi
movq $0x1, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x4aaa0
cvtsi2sdl (%rax), %xmm1
movsd 0x69ccd(%rip), %xmm0    # 0xc1028
divsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10520
addsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
movsd %xmm1, -0x98(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x116b0
movq -0xb0(%rbp), %rdi
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
addq $0x10, %rdi
movq $0x1, -0xa0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x4aaa0
movsd -0xd0(%rbp), %xmm0
movq -0xb0(%rbp), %rdi
cvtsi2sdl (%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x69c5c(%rip), %xmm1    # 0xc1048
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2c(%rbp)
addq $0x10, %rdi
movq $0x0, -0xa8(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x4aaa0
movl (%rax), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)