// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
cmpl $0x0, 0x3c(%rdi)
jne 0x1df2a
movq %rdi, %rbx
leaq 0x80(%rdi), %rax
movq %rax, 0xc0(%rdi)
leaq 0x98(%rdi), %rax
movq %rax, 0xc8(%rdi)
cmpb $0x0, 0x24(%rdi)
jne 0x1df2a
movl 0x18(%rsi), %edi
movl 0x40(%rsi), %r8d
movups 0x8(%rsi), %xmm0
movaps %xmm0, -0x30(%rbp)
movupd 0x30(%rsi), %xmm0
movapd %xmm0, -0x40(%rbp)
movl $0x6, %eax
movb $0x1, %cl
cmpl %edx, %edi
jg 0x1df26
movl 0x20(%rbx), %esi
movl 0xd8(%rbx), %r9d
addl %esi, %r9d
movl 0x6963d(%rip), %edi     # 0x87510
cmpl %edi, %r9d
jg 0x1df26
cmpl %edx, %r8d
jle 0x1dee4
movl $0x2, %eax
jmp 0x1df24
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x4d13e(%rip), %xmm0    # 0x6b040
jbe 0x1df15
addl 0xd0(%rbx), %esi
xorl %eax, %eax
cmpl %edi, %esi
setg %al
addl %eax, %eax
jmp 0x1df24
addl 0xd4(%rbx), %esi
xorl %eax, %eax
cmpl %edi, %esi
setg %al
incl %eax
xorl %ecx, %ecx
testb %cl, %cl
je 0x1df39
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, %eax
je 0x1e0a4
cmpl $0x1, %eax
je 0x1df9d
testl %eax, %eax
jne 0x1e16d
movsd -0x30(%rbp), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1db6c
movsd -0x28(%rbp), %xmm0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1db6c
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1e200
sqrtsd %xmm0, %xmm0
jmp 0x1e205
movsd -0x30(%rbp), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1db6c
movsd -0x28(%rbp), %xmm0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1db6c
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1dc6a
movb $0x1, 0x24(%rbx)
callq 0x35b4a
leaq 0x4e260(%rip), %rsi     # 0x6c23b
movq %rax, %rdi
callq 0x35d5e
movq %rax, %r14
movq 0x10(%rbx), %rax
movq 0x18(%rax), %rbx
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e012
addq $0x10, %rbx
movq %r14, %rdi
addq $0x210, %rdi            # imm = 0x210
movq %rbx, %rsi
callq 0xea74
leaq 0x4e22b(%rip), %rsi     # 0x6c244
movq %r14, %rdi
callq 0x1f2f0
movq %rax, %rbx
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e045
movq %rbx, %rdi
addq $0x210, %rdi            # imm = 0x210
leaq -0x30(%rbp), %rsi
callq 0x1f49d
leaq 0x50ba8(%rip), %rsi     # 0x6ebf4
movq %rbx, %rdi
callq 0x135bc
movq %rax, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e07e
leaq 0x210(%rbx), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1f49d
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e166
addq $0x210, %rbx            # imm = 0x210
movq %rbx, %rdi
callq 0x9240
jmp 0x1e166
movsd -0x30(%rbp), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1db6c
movsd -0x28(%rbp), %xmm0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1db6c
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1dc6a
callq 0x35b4a
leaq 0x4e15d(%rip), %rsi     # 0x6c23b
movq %rax, %rdi
callq 0x35d5e
movq %rax, %r14
movq 0x10(%rbx), %rax
movq 0x18(%rax), %r15
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e115
addq $0x10, %r15
movq %r14, %rdi
addq $0x210, %rdi            # imm = 0x210
movq %r15, %rsi
callq 0xea74
leaq 0x4e128(%rip), %rsi     # 0x6c244
movq %r14, %rdi
callq 0x1f2f0
movq %rax, %r14
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e145
leaq 0x210(%r14), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1f49d
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e162
addq $0x210, %r14            # imm = 0x210
movq %r14, %rdi
callq 0x9240
movb $0x1, 0x24(%rbx)
movb $0x1, %bl
jmp 0x1df2c
movq 0x68e7c(%rip), %rbx     # 0x86ff0
leaq 0x4e05b(%rip), %rsi     # 0x6c1d6
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x9560
leaq 0x51033(%rip), %rsi     # 0x6f1c2
movl $0x1, %edx
movq %rbx, %rdi
callq 0x9560
movq %rbx, %rdi
movl $0x17c, %esi            # imm = 0x17C
callq 0x9880
movq %rax, %rbx
leaq 0x4f2cc(%rip), %rsi     # 0x6d47f
movl $0x3, %edx
movq %rax, %rdi
callq 0x9560
leaq 0x4e08a(%rip), %rsi     # 0x6c251
movl $0x10, %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
jmp 0x1df2a
callq 0x93c0
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1db6c
movsd -0x40(%rbp), %xmm1
movapd 0x4cdf1(%rip), %xmm0    # 0x6b010
andpd %xmm1, %xmm0
movsd 0x4ce15(%rip), %xmm2    # 0x6b040
ucomisd %xmm0, %xmm2
jbe 0x1e248
movsd -0x38(%rbp), %xmm3
andpd 0x4cdd2(%rip), %xmm3    # 0x6b010
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm2
ja 0x1e262
movsd -0x38(%rbp), %xmm0
callq 0x90d0
mulsd 0x4cdee(%rip), %xmm0    # 0x6b048
divsd 0x4cdee(%rip), %xmm0    # 0x6b050
movq %rbx, %rdi
movl $0x4, %esi
callq 0x1db6c
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1dc6a
movb $0x1, 0x24(%rbx)
callq 0x35b4a
leaq 0x4dfb2(%rip), %rsi     # 0x6c23b
movq %rax, %rdi
callq 0x35d5e
movq %rax, %r14
movq 0x10(%rbx), %rax
movq 0x18(%rax), %rbx
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e2c0
addq $0x10, %rbx
movq %r14, %rdi
addq $0x210, %rdi            # imm = 0x210
movq %rbx, %rsi
callq 0xea74
leaq 0x4df7d(%rip), %rsi     # 0x6c244
movq %r14, %rdi
callq 0x1f2f0
movq %rax, %rbx
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e2f3
movq %rbx, %rdi
addq $0x210, %rdi            # imm = 0x210
leaq -0x30(%rbp), %rsi
callq 0x1f49d
leaq 0x508fa(%rip), %rsi     # 0x6ebf4
movq %rbx, %rdi
callq 0x135bc
movq %rax, %r14
callq 0x450ba
cmpb $0x1, 0x5c45(%rax)
jne 0x1e323
leaq 0x210(%r14), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1f49d
callq 0x450ba
movb $0x1, %bl
cmpb $0x1, 0x5c45(%rax)
jne 0x1df2c
addq $0x210, %r14            # imm = 0x210
movq %r14, %rdi
callq 0x9240
jmp 0x1df2c
nop