// File: yohm[P]dynamical_graph_model/./dynamical_graph_model.cpp
// Function: Species::LocalCC() const
double Species::LocalCC() const {
  SpeciesSet neighbors = m_outgoingInteractions;
  for( auto pair : m_incomingInteractions ) {
    neighbors.insert( pair.first );
  }
  size_t k = neighbors.size();
  if( k <= 1 ) { return 0.0; }

  std::vector<uint32_t> neighbor_ids;
  for( auto n: neighbors ) {
    n->MakeOutLinkCache();
    neighbor_ids.push_back( n->m_immigrationTime );
  }

  std::vector<uint32_t> vIntersec;
  for( auto pSpecies : neighbors ) {
    std::set_intersection( neighbor_ids.begin(), neighbor_ids.end(),
        pSpecies->m_outLinkCache.begin(), pSpecies->m_outLinkCache.end(),
        std::back_inserter( vIntersec ) );
  }
  size_t num_triads = vIntersec.size();

  return ( static_cast<double>(num_triads) / (k*(k-1)) );
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x168(%rsp)
movq 0x168(%rsp), %rsi
movq %rsi, 0x30(%rsp)
addq $0x38, %rsi
leaq 0x138(%rsp), %rdi
callq 0x4a20
movq 0x30(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rdi
callq 0x4a50
movq %rax, 0x128(%rsp)
movq 0x130(%rsp), %rdi
callq 0x4a80
movq %rax, 0x120(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x4ab0
testb $0x1, %al
jne 0x29a3
jmp 0x2a1b
leaq 0x128(%rsp), %rdi
callq 0x4ad0
movups (%rax), %xmm0
movaps %xmm0, 0x110(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x4980
movb %dl, 0x27(%rsp)
movq %rax, 0x28(%rsp)
jmp 0x29db
movb 0x27(%rsp), %al
movq 0x28(%rsp), %rcx
movq %rcx, 0xf0(%rsp)
movb %al, 0xf8(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x4af0
jmp 0x2988
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x2d2b
leaq 0x138(%rsp), %rdi
callq 0x4b20
movq %rax, 0xe8(%rsp)
cmpq $0x1, 0xe8(%rsp)
ja 0x2a57
xorps %xmm0, %xmm0
movsd %xmm0, 0x170(%rsp)
movl $0x1, 0xe4(%rsp)
jmp 0x2d0d
leaq 0xc8(%rsp), %rdi
callq 0x4b30
leaq 0x138(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x4850
movq %rax, 0xb8(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x4880
movq %rax, 0xb0(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x48b0
testb $0x1, %al
jne 0x2ab9
jmp 0x2b21
leaq 0xb8(%rsp), %rdi
callq 0x48d0
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x2d50
jmp 0x2ae0
movq 0xa8(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x4b40
jmp 0x2af7
jmp 0x2af9
leaq 0xb8(%rsp), %rdi
callq 0x49e0
jmp 0x2a9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x2cfe
leaq 0x90(%rsp), %rdi
callq 0x4b30
leaq 0x138(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rdi
callq 0x4850
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rdi
callq 0x4880
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x48b0
testb $0x1, %al
jne 0x2b80
jmp 0x2c66
leaq 0x80(%rsp), %rdi
callq 0x48d0
movq (%rax), %rax
movq %rax, 0x70(%rsp)
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4c40
movq 0x10(%rsp), %rdi
movq %rax, 0x68(%rsp)
callq 0x4c70
movq %rax, 0x60(%rsp)
movq 0x70(%rsp), %rdi
addq $0x70, %rdi
callq 0x4c40
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rdi
addq $0x70, %rdi
callq 0x4c70
movq %rax, 0x50(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x4ca0
movq %rax, 0x18(%rsp)
jmp 0x2bf5
movq 0x18(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %r8
callq 0x4bb0
movq %rax, 0x8(%rsp)
jmp 0x2c24
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x49e0
jmp 0x2b65
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x108(%rsp)
movl %eax, 0x104(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x4cf0
jmp 0x2cfe
leaq 0x90(%rsp), %rdi
callq 0x4cd0
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %xmm0
movaps 0x838b(%rip), %xmm3     # 0xb010
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x838f(%rip), %xmm2     # 0xb020
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0xe8(%rsp), %rax
movq %rax, %rcx
decq %rcx
imulq %rcx, %rax
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x170(%rsp)
movl $0x1, 0xe4(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x4cf0
leaq 0xc8(%rsp), %rdi
callq 0x4cf0
jmp 0x2d0d
leaq 0xc8(%rsp), %rdi
callq 0x4cf0
jmp 0x2d2b
leaq 0x138(%rsp), %rdi
callq 0x4d50
movsd 0x170(%rsp), %xmm0
addq $0x178, %rsp            # imm = 0x178
retq
leaq 0x138(%rsp), %rdi
callq 0x4d50
movq 0x108(%rsp), %rdi
callq 0x22e0
nopw %cs:(%rax,%rax)