// File: /workspace/github_cpp_makefile_star2_O1/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 $0xb8, %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 0x4dfbd
movq -0x88(%rbp), %r8
movq %r8, %r9
shrq $0x20, %r9
cmpl %r9d, 0x4(%rbx)
jne 0x4dfbd
cmpl %r8d, (%rbx)
jne 0x4dfbd
shrq $0x20, %rdi
cmpb %dil, 0xc(%rbx)
je 0x4e602
leaq -0x88(%rbp), %r12
movl %eax, (%r12)
movq %rcx, 0x4(%r12)
movb %dl, 0xc(%r12)
movq (%r12), %rax
movq 0x8(%r12), %rcx
movq %rax, (%rbx)
movl %ecx, 0x8(%rbx)
shrq $0x20, %rcx
movb %cl, 0xc(%rbx)
movq 0x18(%rsi), %r15
movq %rsi, %rdi
callq 0xe85a
movsd 0x38(%r15), %xmm0
subsd 0x8(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x40(%r15), %xmm0
subsd 0x10(%rax), %xmm0
movapd %xmm0, -0x70(%rbp)
movq %rax, -0xa8(%rbp)
movsd 0xb0(%rax), %xmm0
mulsd 0x1d075(%rip), %xmm0    # 0x6b0a0
divsd 0x1d015(%rip), %xmm0    # 0x6b048
leaq -0x78(%rbp), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x92d0
movsd (%r12), %xmm0
movsd (%r14), %xmm1
movsd -0x40(%rbp), %xmm2
movapd %xmm2, %xmm4
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm3
movapd -0x70(%rbp), %xmm2
mulsd %xmm2, %xmm0
mulsd %xmm1, %xmm4
subsd %xmm0, %xmm4
movapd %xmm4, -0x40(%rbp)
mulsd %xmm1, %xmm2
addsd %xmm3, %xmm2
movapd %xmm2, -0x70(%rbp)
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x21e8(%rbx)
leaq 0x2200(%rbx), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x4f17a
callq 0x4a75c
movsd 0x3360(%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
callq 0x4a75c
movapd -0x40(%rbp), %xmm4
movapd -0x70(%rbp), %xmm3
movsd 0x3368(%rax), %xmm0
movsd %xmm0, -0x98(%rbp)
movapd %xmm4, %xmm0
andpd 0x1cf2b(%rip), %xmm0    # 0x6b010
movsd 0x1cf53(%rip), %xmm1    # 0x6b040
ucomisd %xmm0, %xmm1
jbe 0x4e111
movapd %xmm3, %xmm2
andpd 0x1cf11(%rip), %xmm2    # 0x6b010
xorpd %xmm0, %xmm0
movsd 0x1cf35(%rip), %xmm1    # 0x6b040
ucomisd %xmm2, %xmm1
ja 0x4e136
movapd %xmm3, %xmm0
movapd %xmm4, %xmm1
callq 0x90d0
mulsd 0x1cf22(%rip), %xmm0    # 0x6b048
movsd 0x1cf22(%rip), %xmm1    # 0x6b050
divsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
divsd 0x1cf0a(%rip), %xmm0    # 0x6b048
andpd 0x1ceca(%rip), %xmm0    # 0x6b010
divsd 0x1cf02(%rip), %xmm0    # 0x6b050
mulsd 0x1cf32(%rip), %xmm0    # 0x6b088
addsd 0x1cefa(%rip), %xmm0    # 0x6b058
movapd %xmm0, -0xc0(%rbp)
movsd -0x90(%rbp), %xmm0
subsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
leaq 0xb58(%rbx), %r12
movsd 0x20a1b(%rip), %xmm0    # 0x6eba8
leaq -0x88(%rbp), %r14
movsd 0x60(%r15), %xmm1
movsd %xmm1, -0x48(%rbp)
movsd 0x68(%r15), %xmm1
movsd %xmm1, -0x60(%rbp)
movsd %xmm0, -0x70(%rbp)
movsd 0x1ce99(%rip), %xmm2    # 0x6b050
mulsd %xmm2, %xmm0
movsd 0x1ce85(%rip), %xmm1    # 0x6b048
divsd %xmm1, %xmm0
andpd 0x1ce41(%rip), %xmm0    # 0x6b010
divsd %xmm2, %xmm0
movsd 0x1ce7d(%rip), %xmm1    # 0x6b058
subsd %xmm0, %xmm1
mulsd -0x90(%rbp), %xmm1
addsd -0x98(%rbp), %xmm1
movsd %xmm1, -0x40(%rbp)
callq 0x4a75c
movsd -0x40(%rbp), %xmm0
mulsd 0x3328(%rax), %xmm0
mulsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0xa8(%rbp), %rax
movsd 0xb0(%rax), %xmm0
addsd -0x70(%rbp), %xmm0
mulsd 0x1ce21(%rip), %xmm0    # 0x6b050
divsd 0x1ce11(%rip), %xmm0    # 0x6b048
movq %r14, %r13
movq %r14, %rdi
leaq -0x78(%rbp), %rsi
callq 0x92d0
movsd -0x78(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
mulsd %xmm0, %xmm1
addsd -0x48(%rbp), %xmm1
mulsd -0x88(%rbp), %xmm0
addsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
mulsd %xmm0, %xmm0
movsd %xmm1, -0xb0(%rbp)
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
movsd %xmm1, -0x60(%rbp)
ucomisd 0x1cdfd(%rip), %xmm1    # 0x6b090
movsd %xmm0, -0x48(%rbp)
jae 0x4e2a4
movsd -0x60(%rbp), %xmm0
callq 0x93c0
movapd %xmm0, -0xe0(%rbp)
callq 0x4a75c
movq %rax, %r14
movsd 0x30f8(%rax), %xmm0
movaps %xmm0, -0xd0(%rbp)
xorpd %xmm3, %xmm3
movsd -0x60(%rbp), %xmm1
ucomisd %xmm3, %xmm1
movsd -0x48(%rbp), %xmm0
jae 0x4e2e9
movapd %xmm1, %xmm0
callq 0x93c0
movsd -0x60(%rbp), %xmm1
xorpd %xmm3, %xmm3
xorpd %xmm6, %xmm6
ucomisd %xmm6, %xmm0
xorpd %xmm0, %xmm0
movapd %xmm0, -0x60(%rbp)
movsd 0x1cd6e(%rip), %xmm4    # 0x6b070
movsd 0x1cd5e(%rip), %xmm5    # 0x6b068
jbe 0x4e38a
movsd 0x30f8(%r14), %xmm6
ucomisd %xmm3, %xmm1
jb 0x4e324
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x4e34b
movapd %xmm1, %xmm0
movapd %xmm6, -0x60(%rbp)
callq 0x93c0
movapd -0x60(%rbp), %xmm6
movsd 0x1cd29(%rip), %xmm5    # 0x6b068
movsd 0x1cd29(%rip), %xmm4    # 0x6b070
xorpd %xmm3, %xmm3
movapd -0xe0(%rbp), %xmm1
movapd -0xd0(%rbp), %xmm2
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm6
andnpd %xmm1, %xmm2
orpd %xmm6, %xmm2
divsd %xmm0, %xmm2
movsd -0xb0(%rbp), %xmm6
mulsd %xmm2, %xmm6
movsd -0x40(%rbp), %xmm0
mulsd %xmm2, %xmm0
movapd %xmm0, -0x60(%rbp)
movsd -0x70(%rbp), %xmm0
ucomisd %xmm0, %xmm3
jbe 0x4e3a5
movapd %xmm0, %xmm7
addsd %xmm4, %xmm7
ucomisd %xmm7, %xmm3
ja 0x4e399
jmp 0x4e3bd
ucomisd %xmm4, %xmm0
movapd %xmm0, %xmm7
jb 0x4e3bd
movapd %xmm0, %xmm7
addsd %xmm5, %xmm7
ucomisd %xmm4, %xmm7
jae 0x4e3b3
movapd %xmm6, %xmm0
andpd 0x1cc47(%rip), %xmm0    # 0x6b010
movsd 0x1cc6f(%rip), %xmm1    # 0x6b040
ucomisd %xmm0, %xmm1
movapd %xmm6, -0x40(%rbp)
jbe 0x4e3fb
movapd -0x60(%rbp), %xmm1
andpd 0x1cc27(%rip), %xmm1    # 0x6b010
xorpd %xmm0, %xmm0
movsd 0x1cc4b(%rip), %xmm2    # 0x6b040
ucomisd %xmm1, %xmm2
ja 0x4e437
movapd -0x60(%rbp), %xmm0
movapd %xmm6, %xmm1
movsd %xmm7, -0x48(%rbp)
callq 0x90d0
movsd -0x48(%rbp), %xmm7
movsd 0x1cc4d(%rip), %xmm5    # 0x6b068
movsd 0x1cc4d(%rip), %xmm4    # 0x6b070
xorpd %xmm3, %xmm3
mulsd 0x1cc19(%rip), %xmm0    # 0x6b048
divsd 0x1cc19(%rip), %xmm0    # 0x6b050
ucomisd %xmm0, %xmm3
jbe 0x4e4c2
addsd %xmm4, %xmm0
ucomisd %xmm0, %xmm3
ja 0x4e441
cvttsd2si %xmm7, %r14d
callq 0x96b0
cvttsd2si %xmm0, %eax
movl %eax, -0x78(%rbp)
movslq %r14d, %rax
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x10(%rbx,%rax,8)
shlq $0x4, %rax
movaps -0x40(%rbp), %xmm0
movsd %xmm0, (%r12,%rax)
movaps -0x60(%rbp), %xmm0
movsd %xmm0, 0x8(%r12,%rax)
movq -0xa0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4f084
xorpd %xmm1, %xmm1
movsd -0x70(%rbp), %xmm3
addsd 0x1cbb4(%rip), %xmm3    # 0x6b058
ucomisd %xmm3, %xmm1
jbe 0x4e4ce
movapd %xmm3, %xmm0
movsd 0x1cbba(%rip), %xmm2    # 0x6b070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x4e4b6
jmp 0x4e4f6
ucomisd %xmm4, %xmm0
jb 0x4e44b
addsd %xmm5, %xmm0
jmp 0x4e4c2
movsd 0x1cb9a(%rip), %xmm1    # 0x6b070
ucomisd %xmm1, %xmm3
movapd %xmm3, %xmm0
movsd 0x1cb82(%rip), %xmm2    # 0x6b068
jb 0x4e4f6
movapd %xmm3, %xmm0
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jae 0x4e4ec
movsd %xmm3, -0x48(%rbp)
cvttsd2si %xmm0, %ecx
shlq $0x20, %rcx
movl %r14d, %edx
orq %rcx, %rdx
movq %rdx, -0x88(%rbp)
movq %rax, %rdi
movq %r13, %r14
movq %r13, %rsi
callq 0x4f3ce
xorpd %xmm1, %xmm1
movapd -0x60(%rbp), %xmm0
mulsd %xmm0, %xmm0
movapd -0x40(%rbp), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
jb 0x4e547
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x4e55e
movapd %xmm2, %xmm0
movapd %xmm2, -0x40(%rbp)
callq 0x93c0
movapd -0x40(%rbp), %xmm2
xorpd %xmm1, %xmm1
ucomisd 0x21e8(%rbx), %xmm0
jbe 0x4e596
ucomisd %xmm1, %xmm2
jb 0x4e577
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x4e58e
movapd %xmm2, %xmm0
movapd %xmm2, -0x40(%rbp)
callq 0x93c0
movapd -0x40(%rbp), %xmm2
xorpd %xmm1, %xmm1
movsd %xmm0, 0x21e8(%rbx)
ucomisd %xmm1, %xmm2
jb 0x4e5a5
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x4e5ae
movapd %xmm2, %xmm0
callq 0x93c0
movsd %xmm0, -0x40(%rbp)
callq 0x4a75c
movsd -0x40(%rbp), %xmm1
mulsd 0x30e0(%rax), %xmm1
movsd 0x1ca73(%rip), %xmm0    # 0x6b040
ucomisd %xmm1, %xmm0
jbe 0x4e5e7
movb $0x1, 0x21f0(%rbx)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x21f8(%rbx)
movsd 0x205c1(%rip), %xmm0    # 0x6ebb0
movsd -0x48(%rbp), %xmm1
ucomisd %xmm1, %xmm0
movapd %xmm1, %xmm0
jae 0x4e194
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq