// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/CommunicateSystem.cpp
// Function: CommunicateSystem::CommunicateSystem()
CommunicateSystem::CommunicateSystem() {
  memset(CODE_TO_INT, 0, sizeof(CODE_TO_INT));
  for (int i = 0; i < CODE_SIZE; ++i) {
    CODE_TO_INT[CODE[i]] = i;
  }

  memset(mCodecBitCount, 0, sizeof(mCodecBitCount));
  memset(mCodecMask, 0, sizeof(mCodecMask));

  mCommuFlagBitCount =
      static_cast<int>(ceil(log(static_cast<double>(COMMU_MAX)) / log(2.0)));
  mCommuFlagMask = (1 << mCommuFlagBitCount) - 1;

  mFreeFormFlagBitCount = static_cast<int>(
      ceil(log(static_cast<double>(FREE_FORM_MAX)) / log(2.0)));
  mFreeFormFlagMask = (1 << mFreeFormFlagBitCount) - 1;

  mUnumBitCount =
      static_cast<int>(ceil(log(static_cast<double>(TEAMSIZE)) / log(2.0)));
  mUnumMask = (1 << mUnumBitCount) - 1;

  mTacticsBitCount = 5;
  mTacticsFlagMask = (1 << mTacticsBitCount) - 1;

  mCodecBitCount[FREE_FORM][POS_X] =
      BitCountOfEps(PlayerParam::instance().sayPosXEps(), POS_X);
  mCodecMask[FREE_FORM][POS_X] = (1 << mCodecBitCount[FREE_FORM][POS_X]) - 1;
  mCodecBitCount[FREE_FORM][POS_Y] =
      BitCountOfEps(PlayerParam::instance().sayPosYEps(), POS_Y);
  mCodecMask[FREE_FORM][POS_Y] = (1 << mCodecBitCount[FREE_FORM][POS_Y]) - 1;
  mCodecBitCount[FREE_FORM][BALL_SPEED] =
      BitCountOfEps(PlayerParam::instance().sayBallSpeedEps(), BALL_SPEED);
  mCodecMask[FREE_FORM][BALL_SPEED] =
      (1 << mCodecBitCount[FREE_FORM][BALL_SPEED]) - 1;
  mCodecBitCount[FREE_FORM][PLAYER_SPEED] =
      BitCountOfEps(PlayerParam::instance().sayPlayerSpeedEps(), BALL_SPEED);
  mCodecMask[FREE_FORM][PLAYER_SPEED] =
      (1 << mCodecBitCount[FREE_FORM][PLAYER_SPEED]) - 1;
  mCodecBitCount[FREE_FORM][DIR] =
      BitCountOfEps(PlayerParam::instance().sayDirEps(), DIR);
  mCodecMask[FREE_FORM][DIR] = (1 << mCodecBitCount[FREE_FORM][DIR]) - 1;

  mFreeFormCodecBitCount[BALL_WITH_SPEED] =
      mCodecBitCount[FREE_FORM][POS_X] + mCodecBitCount[FREE_FORM][POS_Y] +
      mCodecBitCount[FREE_FORM][BALL_SPEED] + mCodecBitCount[FREE_FORM][DIR] +
      mFreeFormFlagBitCount;
  mFreeFormCodecBitCount[BALL_WITH_ZERO_SPEED] =
      mCodecBitCount[FREE_FORM][POS_X] + mCodecBitCount[FREE_FORM][POS_Y] +
      mFreeFormFlagBitCount;
  mFreeFormCodecBitCount[BALL_ONLY_POS] = mCodecBitCount[FREE_FORM][POS_X] +
                                          mCodecBitCount[FREE_FORM][POS_Y] +
                                          mFreeFormFlagBitCount;
  mFreeFormCodecBitCount[TEAMMATE_ONLY_POS] = mCodecBitCount[FREE_FORM][POS_X] +
                                              mCodecBitCount[FREE_FORM][POS_Y] +
                                              mFreeFormFlagBitCount;
  mFreeFormCodecBitCount[OPPONENT_ONLY_POS] = mCodecBitCount[FREE_FORM][POS_X] +
                                              mCodecBitCount[FREE_FORM][POS_Y] +
                                              mFreeFormFlagBitCount;

  MAX_BITS_USED -= mCommuFlagBitCount; //这个是一定要用的位
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x5d97c(%rip), %rax     # 0x766d0
movq %rax, (%rdi)
leaq 0x64dc2(%rip), %r14     # 0x7db20
xorl %r15d, %r15d
movl $0x200, %edx            # imm = 0x200
movq %r14, %rdi
xorl %esi, %esi
callq 0x92c0
movq 0x5e791(%rip), %rax     # 0x77508
cmpq $0x49, %r15
je 0x18d8b
movzbl (%rax,%r15), %ecx
movl %r15d, (%r14,%rcx,4)
incq %r15
jmp 0x18d77
xorps %xmm0, %xmm0
movups %xmm0, 0x80(%rbx)
andl $0x0, 0x90(%rbx)
movups %xmm0, 0x98(%rbx)
andq $0x0, 0xb8(%rbx)
movups %xmm0, 0xa8(%rbx)
andl $0x0, 0x40(%rbx)
andq $0x0, 0x48(%rbx)
movl $0x3, 0x50(%rbx)
movq $0x7, 0x58(%rbx)
movl $0x4, 0x70(%rbx)
movq $0xf, 0x78(%rbx)
movl $0x5, 0x60(%rbx)
movq $0x1f, 0x68(%rbx)
callq 0x38d94
movsd 0x31b8(%rax), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x18f20
pushq $-0x1
popq %r15
movl %r15d, %edx
movl %eax, %ecx
shll %cl, %edx
movl %eax, 0x80(%rbx)
xorl %r15d, %edx
movq %rdx, 0x98(%rbx)
callq 0x38d94
movsd 0x31c0(%rax), %xmm0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x18f20
movl %r15d, %edx
movl %eax, %ecx
shll %cl, %edx
movl %eax, 0x84(%rbx)
xorl %r15d, %edx
movq %rdx, 0xa0(%rbx)
callq 0x38d94
movsd 0x31c8(%rax), %xmm0
pushq $0x2
popq %r14
movq %rbx, %rdi
movl %r14d, %esi
callq 0x18f20
movl %r15d, %edx
movl %eax, %ecx
shll %cl, %edx
movl %eax, 0x88(%rbx)
xorl %r15d, %edx
movq %rdx, 0xa8(%rbx)
callq 0x38d94
movsd 0x31d0(%rax), %xmm0
movq %rbx, %rdi
movl %r14d, %esi
callq 0x18f20
movl %r15d, %edx
movl %eax, %ecx
shll %cl, %edx
movl %eax, 0x8c(%rbx)
notl %edx
movq %rdx, 0xb0(%rbx)
callq 0x38d94
movsd 0x31d8(%rax), %xmm0
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x18f20
movl %eax, %ecx
shll %cl, %r15d
movl %eax, 0x90(%rbx)
notl %r15d
movq %r15, 0xb8(%rbx)
movl 0x84(%rbx), %ecx
addl 0x80(%rbx), %ecx
addl 0x50(%rbx), %ecx
movl 0x40(%rbx), %edx
addl %ecx, %eax
addl 0x88(%rbx), %eax
movl %eax, 0xd0(%rbx)
movl %ecx, 0xd4(%rbx)
movl %ecx, 0xd8(%rbx)
movl %ecx, 0xdc(%rbx)
movl %ecx, 0xe0(%rbx)
subl %edx, 0x5e5fb(%rip)     # 0x77510
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq