// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/Formation.cpp
// Function: FormationBase::GetFormationCenter(WorldState const&, bool, double)
const Vector &FormationBase::GetFormationCenter(const WorldState &world_state,
                                                bool is_teammate,
                                                double min_conf) {
  double conf = 0.0;
  double total_conf = 0.0;
  Vector center = Vector(0.0, 0.0);

  for (int i = 1; i <= TEAMSIZE; ++i) {
    if (is_teammate) {
      if (mIndex2Unum[i] == world_state.GetTeammateGoalieUnum()) {
        continue;
      }
      conf = world_state.GetTeammate(i).GetPosConf();
      if (conf > min_conf) {
        center += (world_state.GetTeammate(i).GetPos() +
                   mOffsetMatrix[mUnum2Index[i]][0]) *
                  conf;
        total_conf += conf;
      }
    } else {
      if (mIndex2Unum[i] == world_state.GetOpponentGoalieUnum()) {
        continue;
      }
      conf = world_state.GetOpponent(i).GetPosConf();
      if (conf > min_conf) {
        center += (world_state.GetOpponent(i).GetPos() +
                   mOffsetMatrix[mUnum2Index[i]][0]) *
                  conf;
        total_conf += conf;
      }
    }
  }

  mFormationCT = center / total_conf;
  return mFormationCT;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x11a10
movl $0x1, -0x54(%rbp)
cmpl $0xb, -0x54(%rbp)
jg 0x38adb
testb $0x1, -0x11(%rbp)
je 0x38966
movq -0xf0(%rbp), %rdi
addq $0x320, %rdi            # imm = 0x320
movslq -0x54(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
callq 0x3fad0
movl (%rax), %eax
movl %eax, -0xf4(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1eeb0
movl %eax, %ecx
movl -0xf4(%rbp), %eax
cmpl %ecx, %eax
jne 0x38857
jmp 0x38acd
movq -0x10(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x12520
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1d930
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
ucomisd -0x20(%rbp), %xmm0
jbe 0x38961
movq -0x10(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x12520
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq -0xf0(%rbp), %rdi
movq %rax, -0x100(%rbp)
movq %rdi, %rax
addq $0x380, %rax            # imm = 0x380
movq %rax, -0x108(%rbp)
addq $0x350, %rdi            # imm = 0x350
movslq -0x54(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x3fad0
movq -0x108(%rbp), %rdi
movslq (%rax), %rax
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rsi
callq 0x3fb30
movq %rax, %rdi
movq $0x0, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x3fb50
movq -0x100(%rbp), %rdi
movq %rax, %rsi
callq 0x11360
movsd %xmm0, -0x80(%rbp)
movsd %xmm1, -0x78(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x13320
movsd %xmm0, -0x70(%rbp)
movsd %xmm1, -0x68(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x32ae0
movsd -0x28(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x38acb
movq -0xf0(%rbp), %rdi
addq $0x320, %rdi            # imm = 0x320
movslq -0x54(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x3fad0
movl (%rax), %eax
movl %eax, -0x10c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x25310
movl %eax, %ecx
movl -0x10c(%rbp), %eax
cmpl %ecx, %eax
jne 0x389ad
jmp 0x38acd
movq -0x10(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x1d480
movq %rax, %rdi
addq $0x8, %rdi
callq 0x1d930
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
ucomisd -0x20(%rbp), %xmm0
jbe 0x38ac9
movq -0x10(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x1d480
movq %rax, %rdi
addq $0x8, %rdi
callq 0x11090
movq -0xf0(%rbp), %rdi
movq %rax, -0x118(%rbp)
movq %rdi, %rax
addq $0x380, %rax            # imm = 0x380
movq %rax, -0x120(%rbp)
addq $0x350, %rdi            # imm = 0x350
movslq -0x54(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x3fad0
movq -0x120(%rbp), %rdi
movslq (%rax), %rax
movq %rax, -0xc8(%rbp)
leaq -0xc8(%rbp), %rsi
callq 0x3fb30
movq %rax, %rdi
movq $0x0, -0xd8(%rbp)
leaq -0xd8(%rbp), %rsi
callq 0x3fb50
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0x11360
movsd %xmm0, -0xc0(%rbp)
movsd %xmm1, -0xb8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x13320
movsd %xmm0, -0xb0(%rbp)
movsd %xmm1, -0xa8(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x32ae0
movsd -0x28(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x38acb
jmp 0x38acd
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x38802
movsd -0x30(%rbp), %xmm0
leaq -0x40(%rbp), %rdi
callq 0x1eef0
movq -0xf0(%rbp), %rax
movsd %xmm0, -0xe8(%rbp)
movsd %xmm1, -0xe0(%rbp)
movq -0xe8(%rbp), %rcx
movq %rcx, 0xc80(%rax)
movq -0xe0(%rbp), %rcx
movq %rcx, 0xc88(%rax)
addq $0xc80, %rax            # imm = 0xC80
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax,%rax)