// File: 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
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpl $0x0, 0x3c(%rax)
je 0x2cefd
movb $0x0, -0x1(%rbp)
jmp 0x2d373
movq -0x78(%rbp), %rdi
xorl %esi, %esi
callq 0x2e640
movq -0x78(%rbp), %rax
movb 0x24(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x2cf22
movb $0x0, -0x1(%rbp)
jmp 0x2d373
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x1ddd0
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x28a30
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x11090
movq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x10a80
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movl $0x6, -0x4c(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x2d014
movq -0x78(%rbp), %rcx
movl 0xd8(%rcx), %eax
addl 0x20(%rcx), %eax
cmpl 0xd1698(%rip), %eax     # 0xfe630
jg 0x2d012
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x2d009
leaq -0x48(%rbp), %rdi
callq 0x2e700
movsd 0x94055(%rip), %xmm1    # 0xc1008
ucomisd %xmm1, %xmm0
jbe 0x2cfe0
movq -0x78(%rbp), %rcx
movl 0xd0(%rcx), %eax
addl 0x20(%rcx), %eax
cmpl 0xd1664(%rip), %eax     # 0xfe630
jg 0x2cfd7
movl $0x0, -0x4c(%rbp)
jmp 0x2cfde
movl $0x2, -0x4c(%rbp)
jmp 0x2d007
movq -0x78(%rbp), %rcx
movl 0xd4(%rcx), %eax
addl 0x20(%rcx), %eax
cmpl 0xd163d(%rip), %eax     # 0xfe630
jg 0x2cffe
movl $0x1, -0x4c(%rbp)
jmp 0x2d005
movl $0x2, -0x4c(%rbp)
jmp 0x2d007
jmp 0x2d010
movl $0x2, -0x4c(%rbp)
jmp 0x2d012
jmp 0x2d014
cmpl $0x6, -0x4c(%rbp)
je 0x2d36f
movl -0x4c(%rbp), %eax
movl %eax, -0x7c(%rbp)
testl %eax, %eax
je 0x2d049
jmp 0x2d02a
movl -0x7c(%rbp), %eax
subl $0x1, %eax
je 0x2d14d
jmp 0x2d038
movl -0x7c(%rbp), %eax
subl $0x2, %eax
je 0x2d252
jmp 0x2d30d
leaq -0x38(%rbp), %rdi
callq 0x176f0
movq -0x78(%rbp), %rdi
movsd (%rax), %xmm0
xorl %esi, %esi
callq 0x2cbc0
leaq -0x38(%rbp), %rdi
callq 0x17700
movq -0x78(%rbp), %rdi
movsd (%rax), %xmm0
movl $0x1, %esi
callq 0x2cbc0
leaq -0x48(%rbp), %rdi
callq 0x104e0
movq -0x78(%rbp), %rdi
movl $0x2, %esi
callq 0x2cbc0
leaq -0x48(%rbp), %rdi
callq 0x10520
movq -0x78(%rbp), %rdi
movl $0x4, %esi
callq 0x2cbc0
movq -0x78(%rbp), %rdi
xorl %esi, %esi
callq 0x2ccd0
movq -0x78(%rbp), %rax
movb $0x1, 0x24(%rax)
callq 0x5add0
movq %rax, %rdi
leaq 0x950f3(%rip), %rsi     # 0xc21bf
callq 0x5b110
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x88(%rbp)
movq 0x10(%rax), %rdi
callq 0x10550
movq %rax, %rdi
callq 0x12100
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x1a640
movq %rax, %rdi
leaq 0x950bf(%rip), %rsi     # 0xc21c8
callq 0x2e730
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x2e780
movq %rax, %rdi
leaq 0x97bb8(%rip), %rsi     # 0xc4cdc
callq 0x1a690
movq %rax, %rdi
leaq -0x48(%rbp), %rsi
callq 0x2e780
movq %rax, %rdi
movq 0xd0e71(%rip), %rsi     # 0xfdfb0
callq 0x1a7c0
movb $0x1, -0x1(%rbp)
jmp 0x2d373
leaq -0x38(%rbp), %rdi
callq 0x176f0
movq -0x78(%rbp), %rdi
movsd (%rax), %xmm0
xorl %esi, %esi
callq 0x2cbc0
leaq -0x38(%rbp), %rdi
callq 0x17700
movq -0x78(%rbp), %rdi
movsd (%rax), %xmm0
movl $0x1, %esi
callq 0x2cbc0
movq -0x78(%rbp), %rdi
movl $0x1, %esi
callq 0x2ccd0
movq -0x78(%rbp), %rax
movb $0x1, 0x24(%rax)
callq 0x5add0
movq %rax, %rdi
leaq 0x9501a(%rip), %rsi     # 0xc21bf
callq 0x5b110
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x98(%rbp)
movq 0x10(%rax), %rdi
callq 0x10550
movq %rax, %rdi
callq 0x12100
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x1a640
movq %rax, %rdi
leaq 0x94fe6(%rip), %rsi     # 0xc21c8
callq 0x2e730
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x2e780
movq %rax, %rdi
leaq 0x97adf(%rip), %rsi     # 0xc4cdc
callq 0x1a690
movq %rax, -0x90(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x11a10
movq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2e780
movq %rax, %rdi
movq 0xd0d6c(%rip), %rsi     # 0xfdfb0
callq 0x1a7c0
movb $0x1, -0x1(%rbp)
jmp 0x2d373
leaq -0x38(%rbp), %rdi
callq 0x176f0
movq -0x78(%rbp), %rdi
movsd (%rax), %xmm0
xorl %esi, %esi
callq 0x2cbc0
leaq -0x38(%rbp), %rdi
callq 0x17700
movq -0x78(%rbp), %rdi
movsd (%rax), %xmm0
movl $0x1, %esi
callq 0x2cbc0
movq -0x78(%rbp), %rdi
movl $0x2, %esi
callq 0x2ccd0
callq 0x5add0
movq %rax, %rdi
leaq 0x94f1d(%rip), %rsi     # 0xc21bf
callq 0x5b110
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0xa0(%rbp)
movq 0x10(%rax), %rdi
callq 0x10550
movq %rax, %rdi
callq 0x12100
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x1a640
movq %rax, %rdi
leaq 0x94ee9(%rip), %rsi     # 0xc21c8
callq 0x2e730
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x2e780
movq %rax, %rdi
movq 0xd0cb6(%rip), %rsi     # 0xfdfb0
callq 0x1a7c0
movq -0x78(%rbp), %rax
movb $0x1, 0x24(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x2d373
jmp 0x2d30f
movq 0xd0cda(%rip), %rdi     # 0xfdff0
leaq 0x94e3d(%rip), %rsi     # 0xc215a
callq 0xa5a0
movq %rax, %rdi
leaq 0x97f25(%rip), %rsi     # 0xc5251
callq 0xa5a0
movq %rax, %rdi
movl $0x17c, %esi            # imm = 0x17C
callq 0xaa40
movq %rax, %rdi
leaq 0x96217(%rip), %rsi     # 0xc355f
callq 0xa5a0
movq %rax, %rdi
leaq 0x94e7e(%rip), %rsi     # 0xc21d5
callq 0xa5a0
movq %rax, %rdi
movq 0xd0c4a(%rip), %rsi     # 0xfdfb0
callq 0xa630
jmp 0x2d36d
jmp 0x2d36f
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)