// File: /workspace/github_cpp_makefile_star2_O1/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 $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, %rbx
movl $0x0, 0x2b4580(%rdi)
leaq 0x48(%rdi), %r14
movl $0x568bd, %r15d         # imm = 0x568BD
movslq 0x2b4580(%rbx), %r12
movq %r14, %rdi
callq 0xe804
movaps %xmm0, -0x50(%rbp)
movsd (%r14), %xmm0
movsd 0x8(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x39fc1(%rip), %xmm0    # 0x6b090
jb 0x310d7
sqrtsd %xmm0, %xmm0
jmp 0x310dc
callq 0x93c0
movsd %xmm0, -0x30(%rbp)
movaps -0x50(%rbp), %xmm0
andps 0x39f24(%rip), %xmm0    # 0x6b010
movaps %xmm0, -0x50(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
imulq $0x3700, %r12, %r12     # imm = 0x3700
movsd -0x30(%rbp), %xmm0
subsd 0x3038(%rax,%r12), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x4a75c
movsd -0x30(%rbp), %xmm0
subsd 0x30d8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x450ba
movq 0x5c38(%rax), %rax
movsd 0x3068(%rax,%r12), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x39f57(%rip), %xmm0    # 0x6b0a8
movapd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
divsd 0x39efe(%rip), %xmm1    # 0x6b060
addsd 0x39eee(%rip), %xmm1    # 0x6b058
movapd %xmm1, -0x50(%rbp)
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x450ba
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 0x4a75c
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 0x3109d
leaq -0x78(%rbp), %rax
movq $0x0, (%rax)
leaq 0x48(%rbx), %rcx
leaq 0x558(%rbx), %rax
movq %rax, -0x60(%rbp)
leaq 0x2b4870(%rbx), %rax
movq %rax, -0xb8(%rbp)
xorpd %xmm0, %xmm0
leaq -0x90(%rbp), %rax
movapd %xmm0, (%rax)
leaq -0xe6538(%rbx), %rax
movq $0x0, -0x58(%rbp)
movq %rcx, -0x70(%rbp)
movq -0x70(%rbp), %r14
movq %rax, -0x98(%rbp)
movq %rax, -0x68(%rbp)
xorl %edx, %edx
leal (%rdx,%rdx), %eax
leal (%rax,%rax,4), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x78(%rbp)
movq %rdx, -0xa0(%rbp)
imulq $0x6684, %rdx, %rdx     # imm = 0x6684
movq -0x60(%rbp), %rax
movq %rdx, -0xc8(%rbp)
addq %rdx, %rax
movq %rax, -0xa8(%rbp)
xorl %eax, %eax
movq %rax, %rdx
shlq $0x4, %rdx
addq %rcx, %rdx
movq %rdx, -0xd8(%rbp)
movq %rax, -0xb0(%rbp)
imulq $0x144, %rax, %rcx      # imm = 0x144
movq -0xa8(%rbp), %rax
movq %rcx, -0xd0(%rbp)
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0x68(%rbp), %r15
xorl %r12d, %r12d
movq %r12, %r13
shlq $0x4, %r13
movsd (%r14,%r13), %xmm0
movsd 0x8(%r14,%r13), %xmm1
movq -0xd8(%rbp), %rax
subsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
subsd 0x8(%rax), %xmm1
movsd %xmm1, -0x38(%rbp)
callq 0x4a75c
movsd -0x38(%rbp), %xmm3
movsd -0x50(%rbp), %xmm2
movsd 0x30e0(%rax), %xmm0
mulsd %xmm0, %xmm2
mulsd %xmm0, %xmm3
movsd %xmm2, -0x90(%rbp)
movsd %xmm3, -0x88(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x313d7
addq %r14, %r13
addsd (%r13), %xmm2
addsd 0x8(%r13), %xmm3
xorpd %xmm4, %xmm4
xorl %r13d, %r13d
movsd %xmm2, -0x50(%rbp)
movsd %xmm3, -0x38(%rbp)
movsd 0x48(%rbx,%r13,4), %xmm0
subsd %xmm2, %xmm0
movsd 0x50(%rbx,%r13,4), %xmm1
subsd %xmm3, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x39d31(%rip), %xmm0    # 0x6b090
jb 0x31367
sqrtsd %xmm0, %xmm0
jmp 0x31380
movsd %xmm4, -0x30(%rbp)
callq 0x93c0
movsd -0x30(%rbp), %xmm4
movsd -0x38(%rbp), %xmm3
movsd -0x50(%rbp), %xmm2
movsd 0x2b4870(%rbx,%r12,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x313a1
xorps %xmm0, %xmm0
cvtss2sd (%r15,%r13), %xmm0
maxsd %xmm4, %xmm0
movapd %xmm0, %xmm4
addq $0x4, %r13
cmpq $0x144, %r13            # imm = 0x144
jne 0x31335
xorps %xmm0, %xmm0
cvtsd2ss %xmm4, %xmm0
imulq $0xe6a90, -0x58(%rbp), %rax # imm = 0xE6A90
addq -0x60(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
addq %rdx, %rcx
addq %rcx, %rax
jmp 0x31400
movq -0xb8(%rbp), %rax
leaq (%rax,%r12,8), %rcx
movq %rbx, %rdi
leaq -0x90(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x3349a
cvtsd2ss %xmm0, %xmm0
movq -0xc0(%rbp), %rax
movss %xmm0, (%rax,%r12,4)
incq %r12
addq $0x144, %r15            # imm = 0x144
cmpq $0x51, %r12
jne 0x312ad
movq -0xb0(%rbp), %rax
incq %rax
cmpq $0x51, %rax
movq -0x70(%rbp), %rcx
jne 0x3126f
movq -0xa0(%rbp), %rdx
incq %rdx
addq $0x6684, -0x68(%rbp)    # imm = 0x6684
cmpq $0x24, %rdx
jne 0x31238
movq -0x58(%rbp), %rsi
incq %rsi
movq -0x98(%rbp), %rax
addq $0xe6a90, %rax          # imm = 0xE6A90
movq %rsi, -0x58(%rbp)
cmpq $0x3, %rsi
jne 0x3122b
leaq 0x3b4ce(%rip), %rsi     # 0x6c945
leaq -0x2d8(%rbp), %rbx
movq %rbx, %rdi
movl $0x4, %edx
callq 0x9520
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x2b8(%rbp,%rax)
je 0x3157b
movq 0x55b49(%rip), %rdi     # 0x86ff0
leaq 0x3b4a4(%rip), %rsi     # 0x6c952
movl $0x11, %edx
callq 0x9560
movq 0x55b31(%rip), %rdi     # 0x86ff0
leaq 0x3dcfc(%rip), %rsi     # 0x6f1c2
movl $0x1, %edx
callq 0x9560
movq 0x55b19(%rip), %rdi     # 0x86ff0
movl $0x1f8, %esi            # imm = 0x1F8
callq 0x9880
movq %rax, %rbx
leaq 0x3bf94(%rip), %rsi     # 0x6d47f
movl $0x3, %edx
movq %rax, %rdi
callq 0x9560
leaq 0x3b465(%rip), %rsi     # 0x6c964
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 0x55a76(%rip), %rax     # 0x86fb0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x2d0(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x2d8(%rbp,%rcx)
callq 0x9400
leaq -0x1e0(%rbp), %rdi
callq 0x91c0
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x2d8(%rbp), %rdi
movl $0x2b3fb0, %edx         # imm = 0x2B3FB0
movq -0x60(%rbp), %rsi
callq 0x9640
leaq -0x2d8(%rbp), %rdi
callq 0x96c0
movq 0x55a4d(%rip), %rdi     # 0x86ff0
leaq 0x3b3ca(%rip), %rsi     # 0x6c974
movl $0x1d, %edx
callq 0x9560
movq 0x55a35(%rip), %rdi     # 0x86ff0
callq 0x9240
xorl %edi, %edi
callq 0x95d0
movq %rax, %rbx
leaq -0x2d8(%rbp), %rdi
callq 0x9700
movq %rbx, %rdi
callq 0x98b0