// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/CommunicateSystem.cpp
// Function: CommunicateSystem::SendBallStatus(BallState const&, int)
bool CommunicateSystem::SendBallStatus(const BallState &ball_state, int cd) {
  if (mCommuType != FREE_FORM) {
    return false;
  }

  SetCommunicateType(FREE_FORM);

  if (mBallSended == true) {
    return false;
  }

  int pos_cd = ball_state.GetPosDelay();
  int vel_cd = ball_state.GetVelDelay();
  Vector pos = ball_state.GetPos();
  Vector vel = ball_state.GetVel();
  FreeFormType send_type = FREE_FORM_MAX;

  if (pos_cd <= cd) {
    if (mFreeFormCodecBitCount[BALL_ONLY_POS] + mBitsUsed <= MAX_BITS_USED) {
      if (vel_cd <= cd) {
        if (vel.Mod2() > FLOAT_EPS) { // BALL_WITH_SPEED
          if (mFreeFormCodecBitCount[BALL_WITH_SPEED] + mBitsUsed <=
              MAX_BITS_USED) {
            send_type = BALL_WITH_SPEED;
          } else { // BALL_ONLY_POS
            send_type = BALL_ONLY_POS;
          }
        } else { // BALL_WITH_ZERO_SPEED
          if (mFreeFormCodecBitCount[BALL_WITH_ZERO_SPEED] + mBitsUsed <=
              MAX_BITS_USED) {
            send_type = BALL_WITH_ZERO_SPEED;
          } else { // BALL_ONLY_POS
            send_type = BALL_ONLY_POS;
          }
        }
      } else { // BALL_ONLY_POS
        send_type = BALL_ONLY_POS;
      }
    }
  }
  if (send_type != FREE_FORM_MAX) {
    switch (send_type) {
    case BALL_WITH_SPEED:
      AddDataToCommuBits(pos.X(), POS_X);
      AddDataToCommuBits(pos.Y(), POS_Y);
      AddDataToCommuBits(vel.Mod(), BALL_SPEED);
      AddDataToCommuBits(vel.Dir(), DIR);
      AddFreeFormFlagToCommuBits(BALL_WITH_SPEED);
      mBallSended = true;
      Logger::instance().GetTextLogger("freeform")
          << mpAgent->GetWorldState().CurrentTime() << " send ball: " << pos
          << " " << vel << endl;
      return true;
    case BALL_WITH_ZERO_SPEED:
      AddDataToCommuBits(pos.X(), POS_X);
      AddDataToCommuBits(pos.Y(), POS_Y);
      AddFreeFormFlagToCommuBits(BALL_WITH_ZERO_SPEED);
      mBallSended = true;
      Logger::instance().GetTextLogger("freeform")
          << mpAgent->GetWorldState().CurrentTime() << " send ball: " << pos
          << " " << Vector(0, 0) << endl;
      return true;
    case BALL_ONLY_POS:
      AddDataToCommuBits(pos.X(), POS_X);
      AddDataToCommuBits(pos.Y(), POS_Y);
      AddFreeFormFlagToCommuBits(BALL_ONLY_POS);
      Logger::instance().GetTextLogger("freeform")
          << mpAgent->GetWorldState().CurrentTime() << " send ball: " << pos
          << endl;
      mBallSended = true;
      return true;
    default:
      PRINT_ERROR("send ball status");
      break;
    }
  }
  return false;
}

// Assembly:
cmpl $0x0, 0x3c(%rdi)
je 0x19735
xorl %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x80(%rdi), %rax
movq %rax, 0xc0(%rdi)
leaq 0x98(%rdi), %rax
movq %rax, 0xc8(%rdi)
cmpb $0x0, 0x24(%rdi)
jne 0x19798
movl 0x18(%rsi), %eax
movl 0x40(%rsi), %edi
movups 0x8(%rsi), %xmm0
movaps %xmm0, -0x40(%rbp)
movupd 0x30(%rsi), %xmm0
movapd %xmm0, -0x30(%rbp)
cmpl %edx, %eax
jg 0x19798
movl 0x20(%rbx), %eax
movl 0xd8(%rbx), %esi
addl %eax, %esi
movl 0x5dd7c(%rip), %ecx     # 0x77510
cmpl %ecx, %esi
jle 0x197a5
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl %edx, %edi
jle 0x19836
leaq -0x40(%rbp), %r14
movsd (%r14), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x19512
movsd 0x8(%r14), %xmm0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x19512
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x195d0
callq 0x2ca2e
leaq 0x3ea13(%rip), %rsi     # 0x581fb
movq %rax, %rdi
callq 0x2cc3e
movq 0x10(%rbx), %rcx
movq 0x18(%rcx), %rsi
addq $0x10, %rsi
movq %rax, %rdi
callq 0x10e94
leaq 0x3e9f9(%rip), %rsi     # 0x58204
movq %rax, %rdi
callq 0x1a4ae
movq %rax, %rdi
movq %r14, %rsi
callq 0x1a4e0
movq 0x5d78b(%rip), %rsi     # 0x76fb0
movq %rax, %rdi
callq 0x10f5c
movb $0x1, 0x24(%rbx)
jmp 0x199db
movsd -0x30(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
ucomisd 0x3d7ec(%rip), %xmm1    # 0x57040
jbe 0x19922
addl 0xd0(%rbx), %eax
cmpl %ecx, %eax
jg 0x197ad
leaq -0x40(%rbp), %r14
movsd (%r14), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
movsd %xmm1, -0x48(%rbp)
callq 0x19512
movsd 0x8(%r14), %xmm0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x19512
sqrtsd -0x48(%rbp), %xmm0
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x19512
leaq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0xcd30
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x19512
movq %rbx, %rdi
xorl %esi, %esi
callq 0x195d0
movb $0x1, 0x24(%rbx)
callq 0x2ca2e
leaq 0x3e929(%rip), %rsi     # 0x581fb
movq %rax, %rdi
callq 0x2cc3e
movq 0x10(%rbx), %rcx
movq 0x18(%rcx), %rsi
addq $0x10, %rsi
movq %rax, %rdi
callq 0x10e94
leaq 0x3e90f(%rip), %rsi     # 0x58204
movq %rax, %rdi
callq 0x1a4ae
movq %rax, %rdi
movq %r14, %rsi
callq 0x1a4e0
leaq 0x41295(%rip), %rsi     # 0x5aba4
movq %rax, %rdi
callq 0x10ec6
movq %rax, %rdi
movq %r15, %rsi
jmp 0x199c7
addl 0xd4(%rbx), %eax
cmpl %ecx, %eax
jg 0x197ad
leaq -0x40(%rbp), %r14
movsd (%r14), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x19512
movsd 0x8(%r14), %xmm0
pushq $0x1
popq %r15
movq %rbx, %rdi
movl %r15d, %esi
callq 0x19512
movq %rbx, %rdi
movl %r15d, %esi
callq 0x195d0
movb $0x1, 0x24(%rbx)
callq 0x2ca2e
leaq 0x3e888(%rip), %rsi     # 0x581fb
movq %rax, %rdi
callq 0x2cc3e
movq 0x10(%rbx), %rcx
movq 0x18(%rcx), %rsi
addq $0x10, %rsi
movq %rax, %rdi
callq 0x10e94
leaq 0x3e86e(%rip), %rsi     # 0x58204
movq %rax, %rdi
callq 0x1a4ae
movq %rax, %rdi
movq %r14, %rsi
callq 0x1a4e0
leaq 0x411f4(%rip), %rsi     # 0x5aba4
movq %rax, %rdi
callq 0x10ec6
xorpd %xmm0, %xmm0
leaq -0x60(%rbp), %rsi
movapd %xmm0, (%rsi)
movq %rax, %rdi
callq 0x1a4e0
movq 0x5d5dd(%rip), %rsi     # 0x76fb0
movq %rax, %rdi
callq 0x10f5c
movb $0x1, %al
jmp 0x1979a