// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/Kicker.cpp
// Function: Kicker::ComputeUtilityTable()
void Kicker::ComputeUtilityTable() {
  Assert(Parser::IsPlayerTypesReady());

  mInput.mPlayerType = 0; //离线计算只考虑0号类型
  for (int k = 0; k < POINTS_NUM; ++k) {
    mKickRate[k] = GetKickRate(mPoint[k], mInput.mPlayerType);
    mMaxAccel[k] = ServerParam::instance().maxPower() * mKickRate[k];
  }

  AngleDeg kick_angle = 0.0; //踢球角度
  Vector ball_vel = Vector(0.0, 0.0);
  Vector ball_next = Vector(0.0, 0.0);
  double max_speed = 0.0;

  for (int v = 0; v < 3; ++v) // 3次迭代，分别算v[0], v[1], v[2]
  {
    for (int i = 0; i < 36; ++i) //踢球角度
    {
      kick_angle = STEP_KICK_ANGLE * i;

      for (int j = 0; j < POINTS_NUM; ++j) //初始位置，即第1脚kick前的位置
      {
        for (int k = 0; k < POINTS_NUM; ++k) //第1脚kick后的位置
        {
          ball_vel =
              (mPoint[k] - mPoint[j]) * ServerParam::instance().ballDecay();

          if (v == 0) // v[0]直接算即可
          {
            mKickerValue[v][i][j][k] =
                (float)GetOneKickMaxSpeed(ball_vel, kick_angle, mMaxAccel[k]);
          } else // v[1]和v[2]要迭代
          {
            max_speed = 0.0;
            ball_next = mPoint[k] + ball_vel;

            for (int l = 0; l < POINTS_NUM; ++l) //从j踢到k，再踢到l
            {
              if (mPoint[l].Dist(ball_next) <
                  mMaxAccel[k]) //保证理论上可以从k踢到l
              {
                max_speed =
                    Max(max_speed, (double)mKickerValue[v - 1][i][k][l]);
              }
            }

            mKickerValue[v][i][j][k] = (float)max_speed;
          }
        }
      }
    }
  }

  //写文件
  std::ofstream out_file("kicker_value", std::ios::binary);
  if (!out_file) {
    PRINT_ERROR("open file error");
    return;
  }
  out_file.write((char *)mKickerValue, sizeof(mKickerValue));
  out_file.close();

  std::cerr << "compute kicker value over ..." << std::endl;
  exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rdi, %rbx
movl $0x0, 0x2b4580(%rdi)
leaq 0x48(%rdi), %r14
leaq 0x2b4870(%rdi), %rax
movq %rax, -0x60(%rbp)
movl $0x568bd, %r15d         # imm = 0x568BD
movq %r14, %r13
movslq 0x2b4580(%rbx), %r12
movq %r14, %rdi
callq 0xe702
andps 0x38a89(%rip), %xmm0    # 0x69010
movaps %xmm0, -0x50(%rbp)
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
imulq $0x3700, %r12, %r12     # imm = 0x3700
movsd -0x30(%rbp), %xmm0
subsd 0x3038(%rax,%r12), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x49360
movsd -0x30(%rbp), %xmm0
subsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movsd 0x3068(%rax,%r12), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x38a9c(%rip), %xmm0    # 0x690a8
movapd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
divsd 0x38a43(%rip), %xmm1    # 0x69060
addsd 0x38a33(%rip), %xmm1    # 0x69058
movapd %xmm1, -0x50(%rbp)
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x43dce
movq 0x5c38(%rax), %rax
movsd -0x30(%rbp), %xmm0
divsd 0x3040(%rax,%r12), %xmm0
movapd -0x50(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd -0x38(%rbp), %xmm1
movsd %xmm1, (%rbx,%r15,8)
callq 0x49360
movsd 0x3130(%rax), %xmm0
mulsd (%rbx,%r15,8), %xmm0
movsd %xmm0, 0x288(%rbx,%r15,8)
addq $0x10, %r14
incq %r15
cmpq $0x5690e, %r15          # imm = 0x5690E
jne 0x30571
leaq 0x558(%rbx), %rax
movq %rax, -0x40(%rbp)
xorpd %xmm0, %xmm0
leaq -0x70(%rbp), %rax
movapd %xmm0, (%rax)
leaq -0xe6538(%rbx), %rax
movq $0x0, -0x38(%rbp)
movq %r13, %r15
movq %rax, -0x78(%rbp)
movq %rax, -0x58(%rbp)
xorl %ecx, %ecx
leal (%rcx,%rcx), %eax
leal (%rax,%rax,4), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0xb8(%rbp)
movq %rcx, -0x80(%rbp)
imulq $0x6684, %rcx, %rcx     # imm = 0x6684
movq -0x40(%rbp), %rax
movq %rcx, -0xa0(%rbp)
addq %rcx, %rax
movq %rax, -0x88(%rbp)
xorl %eax, %eax
movq %rax, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
movq %rcx, -0xb0(%rbp)
movq %rax, -0x90(%rbp)
imulq $0x144, %rax, %rcx      # imm = 0x144
movq -0x88(%rbp), %rax
movq %rcx, -0xa8(%rbp)
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x58(%rbp), %r14
xorl %r13d, %r13d
movq %r13, %r12
shlq $0x4, %r12
movsd (%r15,%r12), %xmm0
movsd 0x8(%r15,%r12), %xmm1
movq -0xb0(%rbp), %rax
subsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
subsd 0x8(%rax), %xmm1
movsd %xmm1, -0x50(%rbp)
callq 0x49360
movsd -0x50(%rbp), %xmm5
movsd -0x30(%rbp), %xmm4
movsd 0x30e0(%rax), %xmm0
mulsd %xmm0, %xmm4
mulsd %xmm0, %xmm5
movsd %xmm4, -0x70(%rbp)
movsd %xmm5, -0x68(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x30832
addq %r15, %r12
addsd (%r12), %xmm4
addsd 0x8(%r12), %xmm5
movq -0x60(%rbp), %rax
movsd (%rax,%r13,8), %xmm0
xorpd %xmm1, %xmm1
xorl %eax, %eax
movsd 0x48(%rbx,%rax,4), %xmm2
subsd %xmm4, %xmm2
movsd 0x50(%rbx,%rax,4), %xmm3
subsd %xmm5, %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jbe 0x307fd
xorps %xmm2, %xmm2
cvtss2sd (%r14,%rax), %xmm2
maxsd %xmm1, %xmm2
movapd %xmm2, %xmm1
addq $0x4, %rax
cmpq $0x144, %rax            # imm = 0x144
jne 0x307c2
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
imulq $0xe6a90, -0x38(%rbp), %rax # imm = 0xE6A90
addq -0x40(%rbp), %rax
movq -0xa0(%rbp), %rcx
movq -0xa8(%rbp), %rsi
addq %rsi, %rcx
addq %rcx, %rax
jmp 0x30858
movq -0x60(%rbp), %rax
leaq (%rax,%r13,8), %rcx
movq %rbx, %rdi
leaq -0x70(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x326fe
cvtsd2ss %xmm0, %xmm0
movq -0x98(%rbp), %rax
movss %xmm0, (%rax,%r13,4)
incq %r13
addq $0x144, %r14            # imm = 0x144
cmpq $0x51, %r13
jne 0x30740
movq -0x90(%rbp), %rax
incq %rax
cmpq $0x51, %rax
jne 0x30702
movq -0x80(%rbp), %rcx
incq %rcx
addq $0x6684, -0x58(%rbp)    # imm = 0x6684
cmpq $0x24, %rcx
jne 0x306cb
movq -0x38(%rbp), %rsi
incq %rsi
movq -0x78(%rbp), %rax
addq $0xe6a90, %rax          # imm = 0xE6A90
movq %rsi, -0x38(%rbp)
cmpq $0x3, %rsi
jne 0x306c1
leaq 0x3a070(%rip), %rsi     # 0x6a935
leaq -0x2b8(%rbp), %rbx
movq %rbx, %rdi
movl $0x4, %edx
callq 0x9520
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x298(%rbp,%rax)
je 0x309c9
movq 0x536fb(%rip), %rdi     # 0x83ff0
leaq 0x3a046(%rip), %rsi     # 0x6a942
movl $0x11, %edx
callq 0x9560
movq 0x536e3(%rip), %rdi     # 0x83ff0
leaq 0x3c87e(%rip), %rsi     # 0x6d192
movl $0x1, %edx
callq 0x9560
movq 0x536cb(%rip), %rdi     # 0x83ff0
movl $0x1f8, %esi            # imm = 0x1F8
callq 0x9880
movq %rax, %rbx
leaq 0x3ab1e(%rip), %rsi     # 0x6b457
movl $0x3, %edx
movq %rax, %rdi
callq 0x9560
leaq 0x3a007(%rip), %rsi     # 0x6a954
movl $0xf, %edx
movq %rbx, %rdi
callq 0x9560
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %rbx, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
movq 0x53628(%rip), %rax     # 0x83fb0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x2b0(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x2b8(%rbp,%rcx)
callq 0x9400
leaq -0x1c0(%rbp), %rdi
callq 0x91c0
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x2b8(%rbp), %rdi
movl $0x2b3fb0, %edx         # imm = 0x2B3FB0
movq -0x40(%rbp), %rsi
callq 0x9640
leaq -0x2b8(%rbp), %rdi
callq 0x96c0
movq 0x535ff(%rip), %rdi     # 0x83ff0
leaq 0x39f6c(%rip), %rsi     # 0x6a964
movl $0x1d, %edx
callq 0x9560
movq 0x535e7(%rip), %rdi     # 0x83ff0
callq 0x9240
xorl %edi, %edi
callq 0x95d0
movq %rax, %rbx
leaq -0x2b8(%rbp), %rdi
callq 0x9700
movq %rbx, %rdi
callq 0x98b0