// File: pollo[P]graph-partitioning/graph.cpp
// Function: Graph::get_communication_volume(Partition const&) const
double Graph::get_communication_volume(const Partition& partition) const
{
  int communication_volume = 0;

  for (int node = 0; node < counted_nodes_number; node++)
  {
    int node_partition = partition.get_node_partition(node);
    vector<bool> seen_partition(partition.get_partitions_number(), false);
    for (vector<int>::const_iterator neighbor = neighbors[node].begin();
         neighbor != neighbors[node].end();
         ++neighbor)
    {
      int neighbor_partition = partition.get_node_partition(*neighbor);
      if (node_partition != neighbor_partition &&
          !seen_partition[neighbor_partition])
      {
        communication_volume ++;
        seen_partition[neighbor_partition] = true;
      }
    }
  }

  double fraction_communication_volume = ((double) communication_volume) /
    (counted_nodes_number * (partition.get_partitions_number()-1));

  return fraction_communication_volume;;
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x60(%rsp)
movl $0x0, 0xf4(%rsp)
movl $0x0, 0xf0(%rsp)
movq 0x60(%rsp), %rcx
movl 0xf0(%rsp), %eax
cmpl 0x8(%rcx), %eax
jge 0x3b91
movq 0xf8(%rsp), %rdi
movl 0xf0(%rsp), %esi
callq 0x81a0
movl %eax, 0xec(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x8200
cltq
movq %rax, 0x50(%rsp)
movb $0x0, 0xbf(%rsp)
leaq 0xbe(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x4210
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rcx
leaq 0xc0(%rsp), %rdi
leaq 0xbf(%rsp), %rdx
callq 0x4220
jmp 0x3999
leaq 0xbe(%rsp), %rdi
callq 0x42a0
movq 0x60(%rsp), %rdi
addq $0x10, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x4040
movq %rax, %rdi
callq 0x3f50
movq %rax, 0xa0(%rsp)
movq 0x60(%rsp), %rdi
addq $0x10, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x4040
movq %rax, %rdi
callq 0x3fc0
movq %rax, 0x98(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x3f80
testb $0x1, %al
jne 0x3a10
jmp 0x3b6e
movq 0xf8(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x3ff0
movq 0x40(%rsp), %rdi
movl (%rax), %esi
callq 0x81a0
movl %eax, 0x4c(%rsp)
jmp 0x3a3c
movl 0x4c(%rsp), %eax
movl %eax, 0x94(%rsp)
movl 0xec(%rsp), %ecx
xorl %eax, %eax
cmpl 0x94(%rsp), %ecx
movb %al, 0x3f(%rsp)
je 0x3aab
movslq 0x94(%rsp), %rsi
leaq 0xc0(%rsp), %rdi
callq 0x43f0
movq %rdx, 0x28(%rsp)
movq %rax, 0x30(%rsp)
jmp 0x3a7e
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movq %rax, 0x88(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x4450
xorb $-0x1, %al
movb %al, 0x3f(%rsp)
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x3ab8
jmp 0x3b5a
movl 0xf4(%rsp), %eax
incl %eax
movl %eax, 0xf4(%rsp)
movslq 0x94(%rsp), %rsi
leaq 0xc0(%rsp), %rdi
callq 0x43f0
movq %rdx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x3ae9
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x70(%rsp)
movq %rax, 0x78(%rsp)
leaq 0x70(%rsp), %rdi
movl $0x1, %esi
callq 0x4480
jmp 0x3b5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0xbe(%rsp), %rdi
callq 0x42a0
jmp 0x3be7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x4590
jmp 0x3be7
jmp 0x3b5c
leaq 0xa0(%rsp), %rdi
callq 0x4540
jmp 0x39cc
leaq 0xc0(%rsp), %rdi
callq 0x4590
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x391a
movq 0x60(%rsp), %rax
cvtsi2sdl 0xf4(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x14(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x8200
movsd 0x8(%rsp), %xmm0
movl %eax, %ecx
movl 0x14(%rsp), %eax
subl $0x1, %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x68(%rsp), %xmm0
addq $0x108, %rsp            # imm = 0x108
retq
movq 0xb0(%rsp), %rdi
callq 0x2270
nopw %cs:(%rax,%rax)