// File: 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
subq $0x100, %rsp            # imm = 0x100
movb %r8b, %al
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movsd %xmm2, -0x30(%rbp)
movsd %xmm3, -0x38(%rbp)
andb $0x1, %cl
movb %cl, -0x39(%rbp)
andb $0x1, %al
movb %al, -0x3a(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x32480
movq -0x20(%rbp), %rdi
callq 0x1a3d0
movq %rax, %rdi
movl $0x1, %esi
callq 0x11fc0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x1d6d0
movsd %xmm0, -0x50(%rbp)
testb $0x1, -0x39(%rbp)
je 0x2fd64
movq -0x48(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x110a0
movsd %xmm0, -0x68(%rbp)
movsd %xmm1, -0x60(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x10520
movsd %xmm0, -0xf0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x10590
movq %rax, %rdi
callq 0x11170
movsd -0xf0(%rbp), %xmm0
subsd (%rax), %xmm0
movsd 0x912e4(%rip), %xmm1    # 0xc1030
movsd %xmm1, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x116b0
movsd %xmm0, -0xe8(%rbp)
jmp 0x2fdcd
movq -0x48(%rbp), %rsi
leaq -0x10(%rbp), %rdi
callq 0x110a0
movsd %xmm0, -0x80(%rbp)
movsd %xmm1, -0x78(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x10520
movsd %xmm0, -0xf8(%rbp)
movq -0x20(%rbp), %rdi
callq 0x10590
movq %rax, %rdi
callq 0x11170
movsd -0xf8(%rbp), %xmm0
subsd (%rax), %xmm0
movsd 0x9127f(%rip), %xmm1    # 0xc1030
movsd %xmm1, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x116b0
movsd %xmm0, -0xe8(%rbp)
movsd -0xe8(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd 0x920f6(%rip), %xmm0    # 0xc1ed8
movsd %xmm0, -0x98(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x12a90
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0x911f8(%rip), %xmm1    # 0xc1008
ucomisd %xmm1, %xmm0
jbe 0x2fe85
movsd -0x30(%rbp), %xmm0
divsd -0x50(%rbp), %xmm0
movsd 0x91688(%rip), %xmm1    # 0xc14b0
divsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x32500
movsd 0x91668(%rip), %xmm1    # 0xc14b0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd 0x9189c(%rip), %xmm0    # 0xc16f8
movsd %xmm0, -0xa8(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x12a90
movsd (%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x2fe90
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x58(%rbp), %xmm0
movaps 0x911c4(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
ucomisd -0x90(%rbp), %xmm0
jbe 0x2ff05
movq -0xe0(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movsd -0x30(%rbp), %xmm2
movsd -0x38(%rbp), %xmm3
movb -0x39(%rbp), %cl
movb -0x3a(%rbp), %al
movsd -0xb8(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm1
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %ecx
movzbl %al, %r8d
callq 0x300c0
jmp 0x300ad
testb $0x1, -0x39(%rbp)
je 0x2ff3c
movsd -0x38(%rbp), %xmm0
movaps 0x91149(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x100(%rbp)
jmp 0x2ff54
movsd -0x38(%rbp), %xmm0
movaps 0x91118(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x100(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x20(%rbp), %rdi
callq 0x10590
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x7c940
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
movaps 0x910d8(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
movsd 0x91074(%rip), %xmm1    # 0xc1008
ucomisd %xmm1, %xmm0
jbe 0x300ab
movq -0x28(%rbp), %rax
movl $0x2, 0x4(%rax)
movq -0x20(%rbp), %rdi
callq 0x1a3d0
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movsd -0x30(%rbp), %xmm2
movsd -0x38(%rbp), %xmm3
movsd -0xc8(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm1
callq 0x30d00
movq -0x28(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq -0x20(%rbp), %rdi
callq 0x10590
movq %rax, %rdi
movq -0x28(%rbp), %rax
movsd 0x20(%rax), %xmm0
callq 0x7c940
movq -0x28(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movq -0x28(%rbp), %rax
movsd 0x20(%rax), %xmm0
movaps 0x91033(%rip), %xmm1    # 0xc1060
pand %xmm1, %xmm0
movsd 0x90fcf(%rip), %xmm1    # 0xc1008
ucomisd %xmm1, %xmm0
jbe 0x30048
movq -0x28(%rbp), %rax
movb $0x1, (%rax)
jmp 0x300a9
movq -0xe0(%rbp), %rdi
movq -0x28(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movsd -0x30(%rbp), %xmm2
movsd -0x38(%rbp), %xmm3
movb -0x39(%rbp), %cl
movb -0x3a(%rbp), %al
movsd -0xd8(%rbp), %xmm0
movsd -0xd0(%rbp), %xmm1
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %ecx
movzbl %al, %r8d
callq 0x300c0
jmp 0x300ab
jmp 0x300ad
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)