// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb0, %rsp
movq %rdi, %rbx
leaq 0x38(%rdi), %rsi
leaq 0x60(%rsp), %rdi
callq 0x3e60
movq 0x20(%rbx), %r14
addq $0x10, %rbx
cmpq %rbx, %r14
je 0x281a
leaq 0x60(%rsp), %r15
movq %rsp, %r12
movupd 0x20(%r14), %xmm0
movapd %xmm0, (%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x4784
movq %r14, %rdi
callq 0x2250
movq %rax, %r14
cmpq %rbx, %rax
jne 0x27f4
movq 0x88(%rsp), %r12
xorpd %xmm2, %xmm2
cmpq $0x2, %r12
jb 0x29b7
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x68(%rsp), %r13
movq 0x10(%r13), %rbx
cmpq %r13, %rbx
je 0x289f
movq %rsp, %r14
movq 0x20(%rbx), %r15
movq %r15, %rdi
callq 0x2a1a
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x287b
movl (%r15), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x2886
movq %r14, %rdi
movq %r15, %rdx
callq 0x4832
movq %rbx, %rdi
callq 0x2250
movq %rax, %rbx
cmpq %r13, %rax
jne 0x2853
movq 0x78(%rsp), %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
cmpq %r13, %rbx
je 0x28f1
leaq 0x40(%rsp), %r14
movq 0x20(%rbx), %rax
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x70(%rax), %rdx
movq 0x78(%rax), %rcx
movq %r14, %r8
callq 0x4965
movq %rbx, %rdi
callq 0x2250
movq %rax, %rbx
cmpq %r13, %rax
jne 0x28b8
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rax
jmp 0x28f5
xorl %edi, %edi
xorl %eax, %eax
subq %rdi, %rax
sarq $0x2, %rax
movq %rax, %xmm3
movq 0x2737(%rip), %xmm0     # 0x5040
punpckldq %xmm0, %xmm3    # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
movapd 0x273b(%rip), %xmm1     # 0x5050
subpd %xmm1, %xmm3
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
leaq -0x1(%r12), %rax
imulq %r12, %rax
movq %rax, %xmm4
punpckldq %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1]
subpd %xmm1, %xmm4
movapd %xmm4, %xmm0
unpckhpd %xmm4, %xmm0            # xmm0 = xmm0[1],xmm4[1]
testq %rdi, %rdi
je 0x2985
movapd %xmm2, 0x20(%rsp)
movapd %xmm3, 0xa0(%rsp)
movapd %xmm0, 0x30(%rsp)
movapd %xmm4, 0x90(%rsp)
callq 0x21e0
movapd 0x90(%rsp), %xmm4
movapd 0x30(%rsp), %xmm0
movapd 0xa0(%rsp), %xmm3
movapd 0x20(%rsp), %xmm2
addsd %xmm3, %xmm2
addsd %xmm4, %xmm0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x29b3
movapd %xmm2, 0x20(%rsp)
movapd %xmm0, 0x30(%rsp)
callq 0x21e0
movapd 0x30(%rsp), %xmm0
movapd 0x20(%rsp), %xmm2
divsd %xmm0, %xmm2
movapd %xmm2, 0x20(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x403a
movaps 0x20(%rsp), %xmm0
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x29f4
callq 0x21e0
jmp 0x29f4
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2a07
callq 0x21e0
jmp 0x2a07
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x403a
movq %rbx, %rdi
callq 0x2330
nop