// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movl %r8d, %r13d
movl %ecx, %r12d
movaps %xmm3, -0x60(%rbp)
movsd %xmm2, -0x30(%rbp)
movsd %xmm1, -0x38(%rbp)
movsd %xmm0, -0x48(%rbp)
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, -0x88(%rbp)
movb $0x0, (%rdx)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rdx)
movups %xmm0, 0x14(%rdx)
movups %xmm0, 0x20(%rdx)
movq %rsi, %rdi
callq 0x13392
movq 0x68(%rax), %r14
movl $0x1, -0x3c(%rbp)
movl $0x1, %eax
cmpl $0x0, 0x668(%r14)
jg 0x1fd12
leaq -0x3c(%rbp), %rsi
movq %r14, %rdi
callq 0xef58
leaq -0x3c(%rbp), %rax
movslq (%rax), %rax
shlq $0x4, %rax
movsd 0x8(%r14,%rax), %xmm0
movsd 0x10(%r14,%rax), %xmm2
movapd %xmm0, %xmm4
movsd -0x48(%rbp), %xmm5
subsd %xmm5, %xmm4
movapd %xmm2, %xmm1
movsd -0x38(%rbp), %xmm3
subsd %xmm3, %xmm1
movapd %xmm1, -0xa0(%rbp)
testb %r12b, %r12b
movapd %xmm4, -0x70(%rbp)
je 0x1fdf8
movapd 0x492b4(%rip), %xmm3    # 0x69010
movapd %xmm4, %xmm2
andpd %xmm3, %xmm2
movsd 0x492d4(%rip), %xmm1    # 0x69040
ucomisd %xmm2, %xmm1
jbe 0x1fd84
andpd -0xa0(%rbp), %xmm3
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm1
ja 0x1fda6
movapd -0xa0(%rbp), %xmm0
movapd -0x70(%rbp), %xmm1
callq 0x90d0
mulsd 0x492aa(%rip), %xmm0    # 0x69048
divsd 0x492aa(%rip), %xmm0    # 0x69050
movapd %xmm0, -0x80(%rbp)
movq %r15, %rdi
callq 0xe75a
movapd -0x80(%rbp), %xmm5
subsd 0xb0(%rax), %xmm5
movsd 0x49298(%rip), %xmm0    # 0x69060
ucomisd %xmm5, %xmm0
jbe 0x1fe98
movsd 0x49296(%rip), %xmm3    # 0x69070
movsd -0x30(%rbp), %xmm2
movsd -0x38(%rbp), %xmm1
movapd -0x70(%rbp), %xmm4
addsd %xmm3, %xmm5
ucomisd %xmm5, %xmm0
ja 0x1fde9
jmp 0x1ff0c
movapd %xmm5, %xmm1
subsd %xmm0, %xmm1
movapd %xmm3, %xmm0
subsd %xmm2, %xmm0
movapd 0x49200(%rip), %xmm2    # 0x69010
movapd %xmm1, %xmm4
andpd %xmm2, %xmm4
movsd 0x49220(%rip), %xmm3    # 0x69040
ucomisd %xmm4, %xmm3
jbe 0x1fe34
andpd %xmm0, %xmm2
xorpd %xmm4, %xmm4
ucomisd %xmm2, %xmm3
ja 0x1fe4d
callq 0x90d0
movapd %xmm0, %xmm4
mulsd 0x49203(%rip), %xmm4    # 0x69048
divsd 0x49203(%rip), %xmm4    # 0x69050
movapd %xmm4, -0x80(%rbp)
movq %r15, %rdi
callq 0xe75a
movapd -0x80(%rbp), %xmm5
subsd 0xb0(%rax), %xmm5
movsd 0x491f1(%rip), %xmm0    # 0x69060
ucomisd %xmm5, %xmm0
jbe 0x1feb3
movsd 0x491f3(%rip), %xmm3    # 0x69070
movsd -0x30(%rbp), %xmm2
movsd -0x38(%rbp), %xmm1
movapd -0x70(%rbp), %xmm4
addsd %xmm3, %xmm5
ucomisd %xmm5, %xmm0
ja 0x1fe8c
jmp 0x1ff0c
ucomisd 0x491a8(%rip), %xmm5    # 0x69048
movsd -0x30(%rbp), %xmm2
jae 0x1fee8
movsd -0x38(%rbp), %xmm1
movapd -0x70(%rbp), %xmm4
jmp 0x1ff0c
ucomisd 0x4918d(%rip), %xmm5    # 0x69048
movsd -0x30(%rbp), %xmm2
movsd -0x38(%rbp), %xmm1
movapd -0x70(%rbp), %xmm4
jb 0x1ff0c
movsd 0x49194(%rip), %xmm0    # 0x69068
movsd 0x4916c(%rip), %xmm3    # 0x69048
addsd %xmm0, %xmm5
ucomisd %xmm3, %xmm5
jae 0x1fedc
jmp 0x1ff0c
movsd 0x49178(%rip), %xmm0    # 0x69068
movsd 0x49150(%rip), %xmm3    # 0x69048
movsd -0x38(%rbp), %xmm1
movapd -0x70(%rbp), %xmm4
addsd %xmm0, %xmm5
ucomisd %xmm3, %xmm5
jae 0x1ff02
maxsd 0x4a3d4(%rip), %xmm2    # 0x6a2e8
xorpd %xmm0, %xmm0
ucomisd 0x49120(%rip), %xmm2    # 0x69040
jbe 0x1ffb7
movapd -0xa0(%rbp), %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm4, %xmm4
addsd %xmm0, %xmm4
xorps %xmm3, %xmm3
sqrtsd %xmm4, %xmm3
movapd %xmm2, %xmm0
divsd %xmm3, %xmm0
mulsd 0x49927(%rip), %xmm0    # 0x69878
ucomisd 0x4a367(%rip), %xmm0    # 0x6a2c0
jae 0x1ff9d
movsd 0x4a365(%rip), %xmm3    # 0x6a2c8
ucomisd %xmm0, %xmm3
jae 0x1ffa7
movsd %xmm2, -0x30(%rbp)
movapd %xmm5, -0x80(%rbp)
callq 0x9840
movapd -0x80(%rbp), %xmm5
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
mulsd 0x490b9(%rip), %xmm0    # 0x69048
divsd 0x490b9(%rip), %xmm0    # 0x69050
addsd %xmm0, %xmm0
jmp 0x1ffaf
movsd 0x490a3(%rip), %xmm0    # 0x69048
jmp 0x1ffaf
movsd 0x490b1(%rip), %xmm0    # 0x69060
maxsd 0x497a9(%rip), %xmm0    # 0x69760
andpd 0x49051(%rip), %xmm5    # 0x69010
ucomisd %xmm0, %xmm5
movaps -0x60(%rbp), %xmm3
jbe 0x1ffed
movzbl %r12b, %ecx
movzbl %r13b, %r8d
movq -0x88(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movsd -0x48(%rbp), %xmm0
callq 0x200dc
jmp 0x20099
testb %r12b, %r12b
movsd %xmm2, -0x30(%rbp)
jne 0x20000
andps 0x49012(%rip), %xmm3    # 0x69010
jmp 0x20007
orps 0x49019(%rip), %xmm3    # 0x69020
movaps %xmm3, -0x60(%rbp)
movq %r15, %rdi
callq 0xe75a
movq %rax, %rdi
movapd -0x60(%rbp), %xmm0
callq 0x45d84
movapd %xmm0, -0x60(%rbp)
movapd 0x48fe3(%rip), %xmm1    # 0x69010
andpd %xmm0, %xmm1
ucomisd 0x49007(%rip), %xmm1    # 0x69040
jbe 0x20099
movl $0x2, 0x4(%rbx)
movq %r15, %rdi
callq 0x13392
movq %rax, %rsi
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
callq 0x20cb4
movsd %xmm0, 0x20(%rbx)
movq %r15, %rdi
callq 0xe75a
movsd 0x20(%rbx), %xmm0
movq %rax, %rdi
callq 0x45d84
movsd %xmm0, 0x20(%rbx)
andpd 0x48f84(%rip), %xmm0    # 0x69010
ucomisd 0x48fac(%rip), %xmm0    # 0x69040
jbe 0x200a8
movb $0x1, (%rbx)
addq $0x78, %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 -0x88(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
jmp 0x1ffe3