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

  const Vector &my_pre_pos = agent.Self().GetPredictedPos(1);
  double dist = my_pre_pos.Dist(target);
  AngleDeg dirdiff =
      inverse
          ? GetNormalizeAngleDeg((my_pre_pos - target).Dir() -
                                 agent.GetSelf().GetBodyDir())
          : GetNormalizeAngleDeg((target - my_pre_pos).Dir() -
                                 agent.GetSelf().GetBodyDir()); //需要转身的角度

  double bufang;

  buffer = Max(0.05, buffer); // TODO: wait test

  if (buffer > FLOAT_EPS) {
    bufang = ASin(buffer / dist / 2) * 2;
    bufang = Max(10.0, bufang);
  } else {
    bufang = 0.0;
  }

  if (fabs(dirdiff) > bufang) {
    TurnDashPlaning(agent, act, target, buffer, power, inverse, turn_first);
  } else {
    power = inverse ? -fabs(power) : fabs(power);
    power = agent.GetSelf().CorrectDashPowerForStamina(power);
    if (fabs(power) > FLOAT_EPS) {
      act.mType = CT_Dash;
      act.mDashPower = AdjustPowerForDash(agent.Self(), target, buffer, power);
      act.mDashPower =
          agent.GetSelf().CorrectDashPowerForStamina(act.mDashPower);
      if (fabs(act.mDashPower) > FLOAT_EPS) {
        act.mSucceed = true;
      } else {
        act.mType = CT_None; // power为零时就不要执行了，没意义
        TurnDashPlaning(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 $0x58, %rsp
movl %r8d, %r13d
movl %ecx, %r12d
movaps %xmm3, -0x50(%rbp)
movsd %xmm2, -0x30(%rbp)
movsd %xmm1, -0x38(%rbp)
movsd %xmm0, -0x58(%rbp)
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, -0x80(%rbp)
movb $0x0, (%rdx)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rdx)
movups %xmm0, 0x14(%rdx)
movups %xmm0, 0x20(%rdx)
movq %rsi, %rdi
callq 0x134ce
movq 0x68(%rax), %r14
movl $0x1, -0x5c(%rbp)
cmpl $0x0, 0x668(%r14)
jle 0x20253
addq $0x18, %r14
jmp 0x20271
leaq -0x5c(%rbp), %rsi
movq %r14, %rdi
callq 0xf062
leaq -0x5c(%rbp), %rax
movslq (%rax), %rax
shlq $0x4, %rax
addq %rax, %r14
addq $0x8, %r14
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
movsd -0x58(%rbp), %xmm2
subsd %xmm2, %xmm0
subsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x202a6
sqrtsd %xmm0, %xmm0
jmp 0x202b0
callq 0x93c0
movsd -0x58(%rbp), %xmm2
movsd %xmm0, -0x78(%rbp)
movsd (%r14), %xmm1
movsd 0x8(%r14), %xmm0
testb %r12b, %r12b
je 0x20363
subsd %xmm2, %xmm1
subsd -0x38(%rbp), %xmm0
movapd 0x4ad36(%rip), %xmm2    # 0x6b010
movapd %xmm1, %xmm4
andpd %xmm2, %xmm4
movsd 0x4ad56(%rip), %xmm3    # 0x6b040
ucomisd %xmm4, %xmm3
jbe 0x202fe
andpd %xmm0, %xmm2
xorpd %xmm4, %xmm4
ucomisd %xmm2, %xmm3
ja 0x20317
callq 0x90d0
movapd %xmm0, %xmm4
mulsd 0x4ad39(%rip), %xmm4    # 0x6b048
divsd 0x4ad39(%rip), %xmm4    # 0x6b050
movapd %xmm4, -0x70(%rbp)
movq %r15, %rdi
callq 0xe85a
movapd -0x70(%rbp), %xmm4
subsd 0xb0(%rax), %xmm4
movsd 0x4ad27(%rip), %xmm0    # 0x6b060
ucomisd %xmm4, %xmm0
jbe 0x203fe
movsd 0x4ad25(%rip), %xmm1    # 0x6b070
movsd -0x30(%rbp), %xmm2
movaps -0x50(%rbp), %xmm3
addsd %xmm1, %xmm4
ucomisd %xmm4, %xmm0
ja 0x20354
jmp 0x2045a
subsd %xmm1, %xmm2
movsd -0x38(%rbp), %xmm1
subsd %xmm0, %xmm1
movapd 0x4ac98(%rip), %xmm5    # 0x6b010
movapd %xmm2, %xmm4
andpd %xmm5, %xmm4
movsd 0x4acb8(%rip), %xmm3    # 0x6b040
ucomisd %xmm4, %xmm3
jbe 0x2039c
andpd %xmm1, %xmm5
xorpd %xmm0, %xmm0
ucomisd %xmm5, %xmm3
ja 0x203b9
movapd %xmm1, %xmm0
movapd %xmm2, %xmm1
callq 0x90d0
mulsd 0x4ac97(%rip), %xmm0    # 0x6b048
divsd 0x4ac97(%rip), %xmm0    # 0x6b050
movapd %xmm0, -0x70(%rbp)
movq %r15, %rdi
callq 0xe85a
movapd -0x70(%rbp), %xmm4
subsd 0xb0(%rax), %xmm4
movsd 0x4ac85(%rip), %xmm0    # 0x6b060
ucomisd %xmm4, %xmm0
jbe 0x2042d
movsd 0x4ac87(%rip), %xmm1    # 0x6b070
movsd -0x30(%rbp), %xmm2
movaps -0x50(%rbp), %xmm3
addsd %xmm1, %xmm4
ucomisd %xmm4, %xmm0
ja 0x203f2
jmp 0x2045a
ucomisd 0x4ac42(%rip), %xmm4    # 0x6b048
movsd -0x30(%rbp), %xmm2
movaps -0x50(%rbp), %xmm3
jb 0x2045a
movsd 0x4ac4f(%rip), %xmm0    # 0x6b068
movsd 0x4ac27(%rip), %xmm1    # 0x6b048
addsd %xmm0, %xmm4
ucomisd %xmm1, %xmm4
jae 0x20421
jmp 0x2045a
ucomisd 0x4ac13(%rip), %xmm4    # 0x6b048
movsd -0x30(%rbp), %xmm2
movaps -0x50(%rbp), %xmm3
jb 0x2045a
movsd 0x4ac20(%rip), %xmm0    # 0x6b068
movsd 0x4abf8(%rip), %xmm1    # 0x6b048
addsd %xmm0, %xmm4
ucomisd %xmm1, %xmm4
jae 0x20450
maxsd 0x4be96(%rip), %xmm2    # 0x6c2f8
xorpd %xmm0, %xmm0
ucomisd 0x4abd2(%rip), %xmm2    # 0x6b040
jbe 0x204e6
movapd %xmm2, %xmm0
divsd -0x78(%rbp), %xmm0
mulsd 0x4b3f7(%rip), %xmm0    # 0x6b878
ucomisd 0x4be47(%rip), %xmm0    # 0x6c2d0
jae 0x204cc
movsd 0x4be45(%rip), %xmm1    # 0x6c2d8
ucomisd %xmm0, %xmm1
jae 0x204d6
movsd %xmm2, -0x30(%rbp)
movapd %xmm4, -0x70(%rbp)
callq 0x9840
movapd -0x70(%rbp), %xmm4
movaps -0x50(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
mulsd 0x4ab8a(%rip), %xmm0    # 0x6b048
divsd 0x4ab8a(%rip), %xmm0    # 0x6b050
addsd %xmm0, %xmm0
jmp 0x204de
movsd 0x4ab74(%rip), %xmm0    # 0x6b048
jmp 0x204de
movsd 0x4ab82(%rip), %xmm0    # 0x6b060
maxsd 0x4b27a(%rip), %xmm0    # 0x6b760
andpd 0x4ab22(%rip), %xmm4    # 0x6b010
ucomisd %xmm0, %xmm4
jbe 0x2051a
movzbl %r12b, %ecx
movzbl %r13b, %r8d
movq -0x80(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movsd -0x58(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
callq 0x20606
jmp 0x205c6
testb %r12b, %r12b
movsd %xmm2, -0x30(%rbp)
jne 0x2052d
andps 0x4aae5(%rip), %xmm3    # 0x6b010
jmp 0x20534
orps 0x4aaec(%rip), %xmm3    # 0x6b020
movaps %xmm3, -0x50(%rbp)
movq %r15, %rdi
callq 0xe85a
movq %rax, %rdi
movapd -0x50(%rbp), %xmm0
callq 0x470e2
movapd %xmm0, -0x50(%rbp)
movapd 0x4aab6(%rip), %xmm1    # 0x6b010
andpd %xmm0, %xmm1
ucomisd 0x4aada(%rip), %xmm1    # 0x6b040
jbe 0x205c6
movl $0x2, 0x4(%rbx)
movq %r15, %rdi
callq 0x134ce
movq %rax, %rsi
movsd -0x58(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movaps -0x50(%rbp), %xmm3
callq 0x2129a
movsd %xmm0, 0x20(%rbx)
movq %r15, %rdi
callq 0xe85a
movsd 0x20(%rbx), %xmm0
movq %rax, %rdi
callq 0x470e2
movsd %xmm0, 0x20(%rbx)
andpd 0x4aa57(%rip), %xmm0    # 0x6b010
ucomisd 0x4aa7f(%rip), %xmm0    # 0x6b040
jbe 0x205d5
movb $0x1, (%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x4(%rbx)
movzbl %r12b, %ecx
movzbl %r13b, %r8d
movq -0x80(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movsd -0x58(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movaps -0x50(%rbp), %xmm3
jmp 0x20510