// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/CommunicateSystem.cpp
// Function: CommunicateSystem::SendTeammateStatus(WorldState const*, int, int)
bool CommunicateSystem::SendTeammateStatus(const WorldState *pWorldState,
                                           Unum num, int cd) {
  Assert(num > 0);

  if (mCommuType != FREE_FORM) {
    return false;
  }

  SetCommunicateType(FREE_FORM);

  if (mTeammateSended[num] == true) {
    return false;
  }
  if (pWorldState->GetTeammate(num).IsAlive() == false) {
    return false;
  }
  if (mpAgent->GetInfoState().GetPositionInfo().GetPlayerDistToPlayer(
          mpAgent->GetSelfUnum(), num) >
      ServerParam::instance().unumFarLength()) {
    return false;
  }

  int pos_cd = pWorldState->GetTeammate(num).GetPosDelay();
  if (pos_cd <= cd) {
    if (mFreeFormCodecBitCount[TEAMMATE_ONLY_POS] + mBitsUsed <=
        MAX_BITS_USED) {
      Vector pos = pWorldState->GetTeammate(num).GetPos();
      AddUnumToCommuBits(num);
      AddDataToCommuBits(pos.X(), POS_X);
      AddDataToCommuBits(pos.Y(), POS_Y);
      AddFreeFormFlagToCommuBits(TEAMMATE_ONLY_POS);
      Logger::instance().GetTextLogger("freeform")
          << mpAgent->GetWorldState().CurrentTime() << " send tm: " << num
          << " " << pos << endl;
      mTeammateSended[num] = true;
      return true;
    }
  }
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpl $0x0, 0x3c(%rax)
je 0x2d3bd
movb $0x0, -0x1(%rbp)
jmp 0x2d5ce
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x2e640
movq -0x40(%rbp), %rdi
addq $0x25, %rdi
leaq -0x1c(%rbp), %rsi
callq 0x2e7d0
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x2d3ee
movb $0x0, -0x1(%rbp)
jmp 0x2d5ce
movq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x12520
movq %rax, %rdi
callq 0x23f20
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x2d416
movb $0x0, -0x1(%rbp)
jmp 0x2d5ce
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2e810
movq %rax, %rdi
callq 0x49590
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, -0x50(%rbp)
movq 0x10(%rax), %rdi
callq 0x10e40
movq -0x50(%rbp), %rdi
movl %eax, %esi
movl -0x1c(%rbp), %edx
callq 0x7efb0
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x2e830
movsd -0x48(%rbp), %xmm0
ucomisd (%rax), %xmm0
jbe 0x2d477
movb $0x0, -0x1(%rbp)
jmp 0x2d5ce
movq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x12520
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1ddd0
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x2d5ca
movq -0x40(%rbp), %rcx
movl 0xdc(%rcx), %eax
addl 0x20(%rcx), %eax
cmpl 0xd117e(%rip), %eax     # 0xfe630
jg 0x2d5c8
movq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x12520
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq -0x40(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x1c(%rbp), %esi
callq 0x2cdf0
leaq -0x38(%rbp), %rdi
callq 0x176f0
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
xorl %esi, %esi
callq 0x2cbc0
leaq -0x38(%rbp), %rdi
callq 0x17700
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
movl $0x1, %esi
callq 0x2cbc0
movq -0x40(%rbp), %rdi
movl $0x3, %esi
callq 0x2ccd0
callq 0x5add0
movq %rax, %rdi
leaq 0x94c83(%rip), %rsi     # 0xc21bf
callq 0x5b110
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq 0x10(%rax), %rdi
callq 0x10550
movq %rax, %rdi
callq 0x12100
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x1a640
movq %rax, %rdi
leaq 0x94c73(%rip), %rsi     # 0xc21e6
callq 0x1a770
movq %rax, %rdi
leaq -0x1c(%rbp), %rsi
callq 0x2e850
movq %rax, %rdi
leaq 0x9774e(%rip), %rsi     # 0xc4cdc
callq 0x1a690
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x2e780
movq %rax, %rdi
movq 0xd0a07(%rip), %rsi     # 0xfdfb0
callq 0x1a7c0
movq -0x40(%rbp), %rdi
addq $0x25, %rdi
leaq -0x1c(%rbp), %rsi
callq 0x2e7d0
movb $0x1, (%rax)
movb $0x1, -0x1(%rbp)
jmp 0x2d5ce
jmp 0x2d5ca
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)