// File: 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
subq $0x380, %rsp            # imm = 0x380
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x318(%rbp)
movl $0x0, 0x2b4580(%rax)
movl $0x0, -0xc(%rbp)
cmpl $0x51, -0xc(%rbp)
jge 0x544ee
movq -0x318(%rbp), %rdi
addq $0x48, %rdi
movslq -0xc(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rsi
callq 0x56650
movq %rax, %rdi
movq -0x318(%rbp), %rax
movl 0x2b4580(%rax), %esi
callq 0x111b0
movq -0x318(%rbp), %rdi
movsd %xmm0, -0x330(%rbp)
addq $0x2b45e8, %rdi         # imm = 0x2B45E8
movslq -0xc(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0x568c0
movsd -0x330(%rbp), %xmm0
movsd %xmm0, (%rax)
callq 0x855e0
movq %rax, %rdi
callq 0x10f10
movq -0x318(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x328(%rbp)
addq $0x2b45e8, %rdi         # imm = 0x2B45E8
movslq -0xc(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rsi
callq 0x568c0
movsd -0x328(%rbp), %xmm0
movq -0x318(%rbp), %rdi
mulsd (%rax), %xmm0
movsd %xmm0, -0x320(%rbp)
addq $0x2b4870, %rdi         # imm = 0x2B4870
movslq -0xc(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x568c0
movsd -0x320(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x543fb
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x11a10
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x11a10
xorps %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
cmpl $0x3, -0x84(%rbp)
jge 0x54921
movl $0x0, -0x88(%rbp)
cmpl $0x24, -0x88(%rbp)
jge 0x5490b
imull $0xa, -0x88(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x8c(%rbp)
cmpl $0x51, -0x8c(%rbp)
jge 0x548f5
movl $0x0, -0x90(%rbp)
cmpl $0x51, -0x90(%rbp)
jge 0x548df
movq -0x318(%rbp), %rdi
addq $0x48, %rdi
movslq -0x90(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %rsi
callq 0x56650
movq -0x318(%rbp), %rdi
movq %rax, -0x338(%rbp)
addq $0x48, %rdi
movslq -0x8c(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xc0(%rbp), %rsi
callq 0x56650
movq -0x338(%rbp), %rdi
movq %rax, %rsi
callq 0x110a0
movsd %xmm0, -0xb0(%rbp)
movsd %xmm1, -0xa8(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x113d0
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x13320
movsd %xmm0, -0xa0(%rbp)
movsd %xmm1, -0x98(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x84(%rbp)
jne 0x546ff
movq -0x318(%rbp), %rdi
addq $0x2b4870, %rdi         # imm = 0x2B4870
movslq -0x90(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0xc8(%rbp), %rsi
callq 0x568c0
movq -0x318(%rbp), %rdi
movq %rax, %rcx
leaq -0x48(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x569c0
movq -0x318(%rbp), %rax
cvtsd2ss %xmm0, %xmm0
addq $0x558, %rax            # imm = 0x558
movslq -0x84(%rbp), %rcx
imulq $0xe6a90, %rcx, %rcx    # imm = 0xE6A90
addq %rcx, %rax
movslq -0x88(%rbp), %rcx
imulq $0x6684, %rcx, %rcx     # imm = 0x6684
addq %rcx, %rax
movslq -0x8c(%rbp), %rcx
imulq $0x144, %rcx, %rcx      # imm = 0x144
addq %rcx, %rax
movslq -0x90(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x548c9
movq -0x318(%rbp), %rdi
xorps %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
addq $0x48, %rdi
movslq -0x90(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x56650
movq %rax, %rdi
leaq -0x48(%rbp), %rsi
callq 0x11360
movsd %xmm0, -0xd8(%rbp)
movsd %xmm1, -0xd0(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0xe4(%rbp)
cmpl $0x51, -0xe4(%rbp)
jge 0x54874
movq -0x318(%rbp), %rdi
addq $0x48, %rdi
movslq -0xe4(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0xf0(%rbp), %rsi
callq 0x56650
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x1d6d0
movq -0x318(%rbp), %rdi
movsd %xmm0, -0x340(%rbp)
addq $0x2b4870, %rdi         # imm = 0x2B4870
movslq -0x90(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xf8(%rbp), %rsi
callq 0x568c0
movsd -0x340(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5485e
movq -0x318(%rbp), %rax
addq $0x558, %rax            # imm = 0x558
movl -0x84(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xe6a90, %rcx, %rcx    # imm = 0xE6A90
addq %rcx, %rax
movslq -0x88(%rbp), %rcx
imulq $0x6684, %rcx, %rcx     # imm = 0x6684
addq %rcx, %rax
movslq -0x90(%rbp), %rcx
imulq $0x144, %rcx, %rcx      # imm = 0x144
addq %rcx, %rax
movslq -0xe4(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x100(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x12a90
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
jmp 0x54860
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x54768
movq -0x318(%rbp), %rax
movsd -0x80(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
addq $0x558, %rax            # imm = 0x558
movslq -0x84(%rbp), %rcx
imulq $0xe6a90, %rcx, %rcx    # imm = 0xE6A90
addq %rcx, %rax
movslq -0x88(%rbp), %rcx
imulq $0x6684, %rcx, %rcx     # imm = 0x6684
addq %rcx, %rax
movslq -0x8c(%rbp), %rcx
imulq $0x144, %rcx, %rcx      # imm = 0x144
addq %rcx, %rax
movslq -0x90(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x548cb
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x5459f
jmp 0x548e1
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x54588
jmp 0x548f7
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x54561
jmp 0x5490d
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x5454a
leaq 0x6df5d(%rip), %rsi     # 0xc2885
leaq -0x300(%rbp), %rdi
movl $0x4, %edx
callq 0xa660
movq -0x300(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x300(%rbp,%rax), %rdi
callq 0xa2a0
movb %al, -0x341(%rbp)
jmp 0x54959
movb -0x341(%rbp), %al
testb $0x1, %al
jne 0x54968
jmp 0x54a42
jmp 0x5496a
movq 0xa967f(%rip), %rdi     # 0xfdff0
leaq 0x6df1a(%rip), %rsi     # 0xc2892
callq 0xa5a0
movq %rax, -0x350(%rbp)
jmp 0x54986
movq -0x350(%rbp), %rdi
leaq 0x708bd(%rip), %rsi     # 0xc5251
callq 0xa5a0
movq %rax, -0x358(%rbp)
jmp 0x549a2
movq -0x358(%rbp), %rdi
movl $0x1f8, %esi            # imm = 0x1F8
callq 0xaa40
movq %rax, -0x360(%rbp)
jmp 0x549bc
movq -0x360(%rbp), %rdi
leaq 0x6eb95(%rip), %rsi     # 0xc355f
callq 0xa5a0
movq %rax, -0x368(%rbp)
jmp 0x549d8
movq -0x368(%rbp), %rdi
leaq 0x6debe(%rip), %rsi     # 0xc28a4
callq 0xa5a0
movq %rax, -0x370(%rbp)
jmp 0x549f4
movq -0x370(%rbp), %rdi
movq 0xa95ae(%rip), %rsi     # 0xfdfb0
callq 0xa630
jmp 0x54a09
jmp 0x54a0b
jmp 0x54a0d
leaq -0x300(%rbp), %rdi
callq 0xa8c0
addq $0x380, %rsp            # imm = 0x380
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x308(%rbp)
movl %eax, -0x30c(%rbp)
leaq -0x300(%rbp), %rdi
callq 0xa8c0
jmp 0x54aa9
movq -0x318(%rbp), %rsi
addq $0x558, %rsi            # imm = 0x558
leaq -0x300(%rbp), %rdi
movl $0x2b3fb0, %edx         # imm = 0x2B3FB0
callq 0xa7d0
jmp 0x54a63
leaq -0x300(%rbp), %rdi
callq 0xa880
jmp 0x54a71
movq 0xa9578(%rip), %rdi     # 0xfdff0
leaq 0x6de35(%rip), %rsi     # 0xc28b4
callq 0xa5a0
movq %rax, -0x378(%rbp)
jmp 0x54a8d
movq -0x378(%rbp), %rdi
movq 0xa9515(%rip), %rsi     # 0xfdfb0
callq 0xa630
jmp 0x54aa2
xorl %edi, %edi
callq 0xa740
movq -0x308(%rbp), %rdi
callq 0xaa60
nopw %cs:(%rax,%rax)