// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/Dasher.cpp
// Function: Dasher::GoToPoint(Agent&, AtomicAction&, Vector, double, double, bool, bool)
void Dasher::GoToPoint(Agent &agent, AtomicAction &act, Vector target,
                       double buffer, double power, bool can_inverse,
                       bool turn_first) {
  act.Clear();

  const Vector &my_pre_pos = agent.Self().GetPredictedPos(1);
  double dist = my_pre_pos.Dist(target);

  if (dist < buffer) {
    act.mSucceed = true;
    return;
  }
  AngleDeg dirdiff = GetNormalizeAngleDeg((target - my_pre_pos).Dir() -
                                          agent.GetSelf().GetBodyDir());

  if (fabs(dirdiff) < 90.0) {
    can_inverse = false; //不需要倒着跑
  }

  bool inverse = false;
  if (can_inverse) {
    int cycle = CycleNeedToPointWithCertainPosture(agent.Self(), target, true);
    if (cycle < 9 && cycle < CycleNeedToPointWithCertainPosture(
                                 agent.Self(), target, false)) {
      inverse = true;
    }
  }

  GoToPointWithCertainPosture(agent, act, target, buffer, power, inverse,
                              turn_first);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %ebx
movl %ecx, %r13d
movsd %xmm3, -0x58(%rbp)
movsd %xmm2, -0x48(%rbp)
movsd %xmm1, -0x38(%rbp)
movsd %xmm0, -0x30(%rbp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movb $0x0, (%rdx)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rdx)
movups %xmm0, 0x14(%rdx)
movups %xmm0, 0x20(%rdx)
movq %rsi, %rdi
callq 0x10d5e
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0xd4c0
movsd -0x30(%rbp), %xmm5
movsd -0x38(%rbp), %xmm4
movsd (%rax), %xmm1
movsd 0x8(%rax), %xmm0
movapd %xmm1, %xmm2
subsd %xmm5, %xmm2
movapd %xmm0, %xmm3
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm2
movsd -0x48(%rbp), %xmm3
ucomisd %xmm2, %xmm3
jbe 0x1a874
movb $0x1, (%r14)
jmp 0x1a964
movl %ebx, -0x3c(%rbp)
movapd %xmm5, %xmm2
subsd %xmm1, %xmm2
movapd %xmm4, %xmm1
subsd %xmm0, %xmm1
leaq -0x70(%rbp), %rdi
movsd %xmm2, (%rdi)
movsd %xmm1, 0x8(%rdi)
callq 0xcd30
movsd %xmm0, -0x50(%rbp)
movq %r15, %rdi
callq 0xcd42
movsd -0x50(%rbp), %xmm0
subsd 0xb0(%rax), %xmm0
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
leaq -0x60(%rbp), %rdi
movq %rax, (%rdi)
callq 0xd305
andpd 0x3c73f(%rip), %xmm0    # 0x57010
movsd 0x3c7af(%rip), %xmm1    # 0x57088
ucomisd %xmm0, %xmm1
seta %al
xorb $0x1, %r13b
orb %al, %r13b
jne 0x1a938
movq %r15, %rdi
callq 0x10d5e
xorl %ebx, %ebx
pushq $0x1
popq %rdx
movq %rax, %rsi
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
xorl %ecx, %ecx
callq 0x1a974
cmpl $0x8, %eax
jg 0x1a93a
movl %eax, %r13d
movq %r15, %rdi
callq 0x10d5e
movq %rax, %rsi
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1a974
cmpl %eax, %r13d
setl %bl
jmp 0x1a93a
xorl %ebx, %ebx
movzbl %bl, %ecx
movzbl -0x3c(%rbp), %r8d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movsd -0x30(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x48(%rbp), %xmm2
movsd -0x58(%rbp), %xmm3
callq 0x1b0a0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop