// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/Tackler.cpp
// Function: Tackler::UpdateTackleData(Agent const&)
void Tackler::UpdateTackleData(const Agent &agent) {
  if (mAgentID == agent.GetAgentID()) {
    return; /** no need to update */
  }

  mAgentID = agent.GetAgentID();

  const BallState &ball_state = agent.GetWorldState().GetBall();
  const PlayerState &player_state = agent.GetSelf();
  Vector ball_2_player = (ball_state.GetPos() - player_state.GetPos())
                             .Rotate(-player_state.GetBodyDir());

  Vector ball_vel;
  mMaxTackleSpeed = -1.0;
  mDirMap.clear();

  const double max_tackle_power = ServerParam::instance().maxTacklePower();
  const double min_back_tackle_power =
      ServerParam::instance().maxBackTacklePower();

  double factor = 1.0 - 0.5 * (fabs(Deg2Rad(ball_2_player.Dir())) / M_PI);

  for (AngleDeg tackle_angle = -180.0 + FLOAT_EPS;
       tackle_angle <= 180.0 + FLOAT_EPS; tackle_angle += 1.0) {
    Vector ball_vel(ball_state.GetVel());
    double eff_power =
        (min_back_tackle_power + ((max_tackle_power - min_back_tackle_power) *
                                  (1.0 - fabs(Deg2Rad(tackle_angle)) / M_PI))) *
        ServerParam::instance().tacklePowerRate();
    eff_power *= factor;
    ball_vel +=
        Polar2Vector(eff_power, tackle_angle + player_state.GetBodyDir());
    ball_vel = ball_vel.SetLength(
        Min(ball_vel.Mod(), ServerParam::instance().ballSpeedMax()));

    int angle_idx = ang2idx(tackle_angle);
    int dir_idx = dir2idx(ball_vel.Dir());

    mTackleAngle[angle_idx] = tackle_angle;
    mBallVelAfterTackle[angle_idx] = ball_vel;
    mDirMap[dir_idx].push_back(
        std::make_pair(angle_idx, ang2idx(tackle_angle + 1.0)));

    if (ball_vel.Mod() > mMaxTackleSpeed) {
      mMaxTackleSpeed = ball_vel.Mod();
    }

    if (ball_vel.Mod() * ServerParam::instance().ballDecay() < FLOAT_EPS) {
      mCanTackleStopBall = true;
      mTackleStopBallAngle = tackle_angle;
    }
  }
  //
  //
  //    for (AngleDeg tackle_angle = -180.0 + 0.3; tackle_angle <= 180.0 +
  //    FLOAT_EPS; tackle_angle += 1.0) { 	Vector ball_vel =
  //    GetBallVelAfterTackle(agent, tackle_angle); 	AngleDeg tackle_angle2 =
  //    0.0; 	GetTackleAngleToDir(agent, ball_vel.Dir(), & tackle_angle2);
  //
  //    	std::cout << tackle_angle << " " << tackle_angle2 << std::endl;
  //    }
  //
  //    exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movl 0x8(%rsi), %eax
movq 0x18(%rsi), %rcx
movq 0x10(%rcx), %rcx
movb 0xc(%rsi), %dl
movl %eax, -0x88(%rbp)
movq %rcx, -0x84(%rbp)
movb %dl, -0x7c(%rbp)
movq -0x80(%rbp), %rdi
cmpl %edi, 0x8(%rbx)
jne 0x4ca81
movq -0x88(%rbp), %r8
movq %r8, %r9
shrq $0x20, %r9
cmpl %r9d, 0x4(%rbx)
jne 0x4ca81
cmpl %r8d, (%rbx)
jne 0x4ca81
shrq $0x20, %rdi
cmpb %dil, 0xc(%rbx)
je 0x4cfcf
leaq -0x88(%rbp), %r15
movl %eax, (%r15)
movq %rcx, 0x4(%r15)
movb %dl, 0xc(%r15)
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rax, (%rbx)
movl %ecx, 0x8(%rbx)
shrq $0x20, %rcx
movb %cl, 0xc(%rbx)
movq 0x18(%rsi), %r14
movq %rsi, %rdi
callq 0xe75a
movsd 0x38(%r14), %xmm0
subsd 0x8(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd 0x40(%r14), %xmm0
subsd 0x10(%rax), %xmm0
movapd %xmm0, -0x40(%rbp)
movq %rax, -0xa8(%rbp)
movsd 0xb0(%rax), %xmm0
mulsd 0x1c5b6(%rip), %xmm0    # 0x690a0
divsd 0x1c556(%rip), %xmm0    # 0x69048
leaq -0x78(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x92d0
movsd (%r15), %xmm0
movsd (%r12), %xmm1
movsd -0x70(%rbp), %xmm2
movapd %xmm2, %xmm4
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm3
movapd -0x40(%rbp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm1, %xmm4
subsd %xmm0, %xmm4
movapd %xmm4, -0x70(%rbp)
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
movapd %xmm2, -0x40(%rbp)
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x21e8(%rbx)
leaq 0x2200(%rbx), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x4db12
callq 0x49360
movsd 0x3360(%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
callq 0x49360
movapd -0x70(%rbp), %xmm4
movapd -0x40(%rbp), %xmm3
movsd 0x3368(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
movapd %xmm4, %xmm0
andpd 0x1c46c(%rip), %xmm0    # 0x69010
movsd 0x1c494(%rip), %xmm1    # 0x69040
ucomisd %xmm0, %xmm1
jbe 0x4cbd0
movapd %xmm3, %xmm2
andpd 0x1c452(%rip), %xmm2    # 0x69010
xorpd %xmm0, %xmm0
movsd 0x1c476(%rip), %xmm1    # 0x69040
ucomisd %xmm2, %xmm1
ja 0x4cbf5
movapd %xmm3, %xmm0
movapd %xmm4, %xmm1
callq 0x90d0
mulsd 0x1c463(%rip), %xmm0    # 0x69048
movsd 0x1c463(%rip), %xmm1    # 0x69050
divsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
divsd 0x1c44b(%rip), %xmm0    # 0x69048
andpd 0x1c40b(%rip), %xmm0    # 0x69010
divsd 0x1c443(%rip), %xmm0    # 0x69050
mulsd 0x1c473(%rip), %xmm0    # 0x69088
addsd 0x1c43b(%rip), %xmm0    # 0x69058
movapd %xmm0, -0xc0(%rbp)
movsd -0x90(%rbp), %xmm0
subsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
leaq 0xb58(%rbx), %r15
movsd 0x1ff2c(%rip), %xmm1    # 0x6cb78
leaq -0x88(%rbp), %r13
movsd %xmm1, -0x70(%rbp)
movsd 0x60(%r14), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0x68(%r14), %xmm0
movsd %xmm0, -0x48(%rbp)
movapd %xmm1, %xmm0
movsd 0x1c3d6(%rip), %xmm2    # 0x69050
mulsd %xmm2, %xmm0
movsd 0x1c3c2(%rip), %xmm1    # 0x69048
divsd %xmm1, %xmm0
andpd 0x1c37e(%rip), %xmm0    # 0x69010
divsd %xmm2, %xmm0
movsd 0x1c3ba(%rip), %xmm1    # 0x69058
subsd %xmm0, %xmm1
mulsd -0x90(%rbp), %xmm1
addsd -0x98(%rbp), %xmm1
movapd %xmm1, -0x40(%rbp)
callq 0x49360
movapd -0x40(%rbp), %xmm0
mulsd 0x3328(%rax), %xmm0
mulsd -0xc0(%rbp), %xmm0
movapd %xmm0, -0x40(%rbp)
movq -0xa8(%rbp), %rax
movsd 0xb0(%rax), %xmm0
addsd -0x70(%rbp), %xmm0
mulsd 0x1c35e(%rip), %xmm0    # 0x69050
divsd 0x1c34e(%rip), %xmm0    # 0x69048
movq %r13, %rdi
leaq -0x78(%rbp), %rsi
callq 0x92d0
movsd -0x78(%rbp), %xmm1
movapd -0x40(%rbp), %xmm0
mulsd %xmm0, %xmm1
mulsd -0x88(%rbp), %xmm0
addsd -0x60(%rbp), %xmm1
movapd %xmm1, -0x60(%rbp)
addsd -0x48(%rbp), %xmm0
movapd %xmm0, -0x40(%rbp)
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
callq 0x49360
movsd -0xb0(%rbp), %xmm6
movapd -0x60(%rbp), %xmm5
movsd 0x30f8(%rax), %xmm0
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm6
minsd %xmm6, %xmm0
divsd %xmm6, %xmm0
mulsd %xmm0, %xmm5
xorpd %xmm1, %xmm1
movsd %xmm1, -0x48(%rbp)
jbe 0x4cd89
movsd %xmm5, -0x48(%rbp)
movsd -0x70(%rbp), %xmm1
ucomisd %xmm1, %xmm3
movsd 0x1c2d6(%rip), %xmm2    # 0x69070
jbe 0x4cdac
movapd %xmm1, %xmm4
addsd %xmm2, %xmm4
ucomisd %xmm4, %xmm3
ja 0x4cda0
jmp 0x4cdcc
ucomisd %xmm2, %xmm1
movapd %xmm1, %xmm4
movsd 0x1c2ac(%rip), %xmm3    # 0x69068
jb 0x4cdcc
movapd %xmm1, %xmm4
addsd %xmm3, %xmm4
ucomisd %xmm2, %xmm4
jae 0x4cdc2
movapd -0x40(%rbp), %xmm2
mulsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
cmpnltsd %xmm6, %xmm0
andnpd %xmm2, %xmm0
movapd %xmm0, -0x40(%rbp)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm6
jbe 0x4ce8e
movapd 0x1c213(%rip), %xmm1    # 0x69010
andpd %xmm1, %xmm5
andpd %xmm1, %xmm2
movsd 0x1c233(%rip), %xmm1    # 0x69040
cmpltpd %xmm1, %xmm5
cmpltpd %xmm1, %xmm2
andpd %xmm5, %xmm2
movd %xmm2, %eax
testb $0x1, %al
jne 0x4ce8e
movsd %xmm4, -0x60(%rbp)
movapd -0x40(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
callq 0x90d0
xorpd %xmm2, %xmm2
mulsd 0x1c205(%rip), %xmm0    # 0x69048
divsd 0x1c205(%rip), %xmm0    # 0x69050
movsd 0x1c21d(%rip), %xmm1    # 0x69070
ucomisd %xmm0, %xmm2
jbe 0x4ce6a
movsd -0x60(%rbp), %xmm4
addsd %xmm1, %xmm0
ucomisd %xmm0, %xmm2
ja 0x4ce5e
jmp 0x4ce8e
ucomisd %xmm1, %xmm0
jae 0x4ce77
movsd -0x60(%rbp), %xmm4
jmp 0x4ce8e
movsd 0x1c1e9(%rip), %xmm2    # 0x69068
movsd -0x60(%rbp), %xmm4
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jae 0x4ce84
cvttsd2si %xmm4, %r12d
callq 0x96b0
cvttsd2si %xmm0, %eax
movl %eax, -0x78(%rbp)
movslq %r12d, %rax
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x10(%rbx,%rax,8)
shlq $0x4, %rax
movsd -0x48(%rbp), %xmm0
movsd %xmm0, (%r15,%rax)
movaps -0x40(%rbp), %xmm0
movsd %xmm0, 0x8(%r15,%rax)
movq -0xa0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4da1c
xorpd %xmm2, %xmm2
movsd -0x70(%rbp), %xmm3
addsd 0x1c170(%rip), %xmm3    # 0x69058
ucomisd %xmm3, %xmm2
jbe 0x4cf06
movapd %xmm3, %xmm0
movsd 0x1c176(%rip), %xmm1    # 0x69070
addsd %xmm1, %xmm0
ucomisd %xmm0, %xmm2
ja 0x4cefa
jmp 0x4cf2e
movsd 0x1c162(%rip), %xmm1    # 0x69070
ucomisd %xmm1, %xmm3
movapd %xmm3, %xmm0
movsd 0x1c14a(%rip), %xmm2    # 0x69068
jb 0x4cf2e
movapd %xmm3, %xmm0
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jae 0x4cf24
movsd %xmm3, -0x60(%rbp)
cvttsd2si %xmm0, %ecx
shlq $0x20, %rcx
movl %r12d, %edx
orq %rcx, %rdx
movq %rdx, -0x88(%rbp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x4dd5a
movapd -0x40(%rbp), %xmm1
mulsd %xmm1, %xmm1
movsd -0x48(%rbp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
ucomisd 0x21e8(%rbx), %xmm0
jbe 0x4cf7f
movsd %xmm0, 0x21e8(%rbx)
movsd %xmm0, -0x40(%rbp)
callq 0x49360
movsd -0x40(%rbp), %xmm1
mulsd 0x30e0(%rax), %xmm1
movsd 0x1c0a2(%rip), %xmm0    # 0x69040
ucomisd %xmm1, %xmm0
jbe 0x4cfb8
movb $0x1, 0x21f0(%rbx)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x21f8(%rbx)
movsd 0x1fbc0(%rip), %xmm0    # 0x6cb80
movsd -0x60(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jae 0x4cc53
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop