// File: /workspace/github_cpp_makefile_star2_O1/Luthaf[P]zeopp/networkanalysis.cc
// Function: TRAVERSAL_NETWORK::TRAVERSAL_NETWORK(int, int, int, DIJKSTRA_NETWORK*)
TRAVERSAL_NETWORK::TRAVERSAL_NETWORK(int dx, int dy, int dz, DIJKSTRA_NETWORK * dnetwork){
  direction = DELTA_POS(dx,dy,dz);
  sourceNodeIDs = vector<int> ();
  regConnections = vector< vector<CONN> > ();
  connectToSource = vector< vector<CONN> > ();
  connectToSink = vector< vector<CONN> > ();
  dnet = dnetwork;
    
  map<int,bool> sourceIDs;
  
  // Iterate over all nodes
  for(unsigned int i = 0; i < dnet->nodes.size(); i++){
    DIJKSTRA_NODE currentNode = dnet->nodes.at(i);
    vector<CONN> regConns = vector <CONN> ();
    vector<CONN> srcConns = vector <CONN> ();
    vector<CONN> drainConns = vector<CONN> ();
    
    // Iterate over all connections
    for(unsigned int j = 0; j < currentNode.connections.size(); j++){
      CONN currentConn = currentNode.connections.at(j);
      DELTA_POS component = currentConn.deltaPos*direction;
      
      int directionComp;
      int otherComp;
      
      if(!component.isZero()){
	if(direction.x != 0){
	  directionComp = direction.x;
	  otherComp = component.x;
	}
	else if (direction.y != 0){
	  directionComp = direction.y;
	  otherComp = component.y;
	}
	else if (direction.z != 0){
	  directionComp = direction.z;
	  otherComp = component.z;
	}
	else{
	  cerr << "Invalid argument reached when building TRAVERSAL_NETWORK. Please contact the source code provider with your input" 
	       << "\n" << "Exiting..." << "\n";
	  exit(1);
	}
	
	if(directionComp == otherComp){
	  //Connection is a drain connection and receiver is a drain node
	  drainConns.push_back(currentConn);
	}
	else if (directionComp == -1*otherComp){
	  //Connection is source connection and receiver is a source node
	  srcConns.push_back(currentConn);
	  sourceIDs.insert(pair<int,bool> (currentConn.to,true));
	}
	else{
	  // There's a problem with the logic
	  cerr << "Invalid argument reached when building TRAVERSAL_NETWORK. Please contact the source code provider with your input" 
	       << "\n" << "Exiting..." << "\n";
	  exit(1);
	}
      }
      else{
	// Connection is a drain connection
	regConns.push_back(currentConn);
      }
    }      
    
    // Store connections according to type
      regConnections.push_back(regConns);
      connectToSource.push_back(srcConns);
      connectToSink.push_back(drainConns);
  }
  
  //Copy from map to id list to prevent duplicate id's
  map<int,bool>::iterator iter = sourceIDs.begin();
  while(iter != sourceIDs.end()){
    sourceNodeIDs.push_back(iter->first);
    iter++;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %r8, %r14
movl %ecx, %ebp
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x18(%rdi), %rax
movq %rax, 0xc0(%rsp)
leaq 0x30(%rdi), %rax
movq %rax, 0xb8(%rsp)
leaq 0x48(%rdi), %rax
movq %rax, 0xb0(%rsp)
leaq 0x60(%rdi), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x509d8
leaq 0xe0(%rsp), %rdi
movl %r12d, %esi
movl %r15d, %edx
movl %ebp, %ecx
callq 0x509d8
leaq 0xe0(%rsp), %r15
movl 0x8(%r15), %eax
movl %eax, 0x8(%r13)
movq (%r15), %rax
movq %rax, (%r13)
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
movq $0x0, 0x10(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x12d52
movq (%r15), %rdi
testq %rdi, %rdi
je 0x31ae7
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
xorl %ebp, %ebp
leaq 0x130(%rsp), %r15
movq %rbp, 0x10(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
leaq 0xe0(%rsp), %r12
movq %rbp, 0x10(%r12)
movaps %xmm0, (%r12)
movq 0x18(%rbx), %rax
movups 0x20(%rbx), %xmm0
movq (%r15), %rcx
movq %rcx, 0x18(%rbx)
movq 0x8(%r15), %rcx
movq %rcx, 0x20(%rbx)
movq 0x10(%r15), %rcx
movq %rcx, 0x28(%rbx)
movq (%r12), %rcx
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rsi
movq %rax, (%r12)
movups %xmm0, 0x8(%r12)
movq %rcx, (%r15)
movq %rdx, 0x8(%r15)
movq %rsi, 0x10(%r15)
movq %r12, %rdi
callq 0xf0ca
movq %r15, %rdi
callq 0xf0ca
movq %rbp, 0x10(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
movq %rbp, 0x10(%r12)
movaps %xmm0, (%r12)
movq 0x30(%rbx), %rax
movups 0x38(%rbx), %xmm0
movq (%r15), %rcx
movq %rcx, 0x30(%rbx)
movq 0x8(%r15), %rcx
movq %rcx, 0x38(%rbx)
movq 0x10(%r15), %rcx
movq %rcx, 0x40(%rbx)
movq (%r12), %rcx
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rsi
movq %rax, (%r12)
movups %xmm0, 0x8(%r12)
movq %rcx, (%r15)
movq %rdx, 0x8(%r15)
movq %rsi, 0x10(%r15)
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
callq 0xf0ca
leaq 0x130(%rsp), %r12
movq %r12, %rdi
callq 0xf0ca
movq %rbp, 0x10(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movq %rbp, 0x10(%r15)
movaps %xmm0, (%r15)
movq 0x48(%rbx), %rax
movups 0x50(%rbx), %xmm0
movq (%r12), %rcx
movq %rcx, 0x48(%rbx)
movq 0x8(%r12), %rcx
movq %rcx, 0x50(%rbx)
movq 0x10(%r12), %rcx
movq %rcx, 0x58(%rbx)
movq (%r15), %rcx
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rsi
movq %rax, (%r15)
movups %xmm0, 0x8(%r15)
movq %rcx, (%r12)
movq %rdx, 0x8(%r12)
movq %rsi, 0x10(%r12)
leaq 0xe0(%rsp), %rdi
callq 0xf0ca
leaq 0x130(%rsp), %rdi
callq 0xf0ca
movq %r14, 0x70(%rbx)
leaq 0x138(%rsp), %rax
movl $0x0, (%rax)
movq %rbp, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rbp, 0x20(%rax)
movq 0x70(%rbx), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x31fff
leaq 0x98(%rsp), %rbp
movabsq $-0x71c71c71c71c71c7, %rdi # imm = 0x8E38E38E38E38E39
leaq 0x60(%rsp), %r15
leaq 0x40(%rsp), %r14
xorl %esi, %esi
xorl %r12d, %r12d
movq %rbx, 0x8(%rsp)
movq %r13, 0xd0(%rsp)
movq %r12, 0xd8(%rsp)
movq %r14, %r13
leaq 0x100(%rsp), %r14
movq (%rax), %rbx
movq 0x8(%rax), %rdx
subq %rbx, %rdx
sarq $0x3, %rdx
imulq %rdi, %rdx
cmpq %rsi, %rdx
jbe 0x32129
movq %r15, %r12
movq %rbp, %r15
leaq (%rsi,%rsi,8), %rbp
leaq (%rbx,%rbp,8), %rsi
addq $0x20, %rsi
movups -0x20(%rsi), %xmm0
movups -0x10(%rsi), %xmm1
movaps %xmm1, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movq %r14, %rdi
callq 0x38318
leaq (%rbx,%rbp,8), %rax
movb 0x40(%rax), %cl
movb %cl, 0x20(%r14)
movq 0x38(%rax), %rax
movq %rax, 0x18(%r14)
xorl %eax, %eax
movq %rax, 0x70(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq %rax, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq 0x100(%rsp), %rax
cmpq %rax, 0x108(%rsp)
movq %r15, %rbp
movq %r12, %r15
movq %r13, %r14
movq 0xd0(%rsp), %r13
je 0x31f32
movl $0x1, %ebx
xorl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq %rdx, 0xa0(%rsp)
movups (%rax,%rcx,8), %xmm0
movups 0x10(%rax,%rcx,8), %xmm1
movaps %xmm1, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x50a14
movq %rax, 0x10(%rsp)
movl %edx, 0x18(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x50a86
testb %al, %al
je 0x31df7
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x31e05
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsi)
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x28, %rsi
movq %rsi, 0x68(%rsp)
jmp 0x31f00
movl (%r13), %eax
testl %eax, %eax
je 0x31e0d
movl 0x10(%rsp), %ecx
jmp 0x31e2e
movq %r15, %rdi
jmp 0x31eb6
movq 0x8(%rsp), %rcx
movl 0x64(%rcx), %eax
testl %eax, %eax
je 0x31e1f
movl 0x14(%rsp), %ecx
jmp 0x31e2e
movl 0x68(%rcx), %eax
testl %eax, %eax
je 0x320c4
movl 0x18(%rsp), %ecx
cmpl %ecx, %eax
jne 0x31e6f
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x31eb1
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsi)
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x28, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x31f00
addl %ecx, %eax
jne 0x32067
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x31ec5
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsi)
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x28, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x31ed5
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x396ae
jmp 0x31f00
movq %r14, %rdi
leaq 0x80(%rsp), %rdx
callq 0x396ae
movl 0x84(%rsp), %eax
movl %eax, 0xc8(%rsp)
movb $0x1, 0xcc(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x397da
movl %ebx, %ecx
movq 0x100(%rsp), %rax
movq 0x108(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rsi, %rdx
incl %ebx
cmpq %rcx, %rdx
ja 0x31d6e
movq 0xc0(%rsp), %rdi
movq %r15, %rsi
callq 0x382ec
movq 0xb8(%rsp), %rdi
movq %r14, %rsi
callq 0x382ec
movq 0xb0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x382ec
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
movq 0x8(%rsp), %rbx
je 0x31f80
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x31f97
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x31fae
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
movq 0xd8(%rsp), %r12
je 0x31fd3
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
incl %r12d
movq 0x70(%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
movabsq $-0x71c71c71c71c71c7, %rdi # imm = 0x8E38E38E38E38E39
imulq %rdi, %rcx
movq %r12, %rsi
cmpq %r12, %rcx
ja 0x31caa
movq 0x148(%rsp), %r14
leaq 0x138(%rsp), %r15
cmpq %r15, %r14
je 0x32048
leaq 0x20(%r14), %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x32030
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x32038
movq %rbx, %rdi
callq 0xf7b4
movq %r14, %rdi
callq 0x42d0
movq %rax, %r14
cmpq %r15, %rax
jne 0x32014
leaq 0x130(%rsp), %rdi
callq 0x38e76
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x164f82(%rip), %rdi    # 0x196ff0
leaq 0x121296(%rip), %rsi    # 0x15330b
movl $0x71, %edx
callq 0x44e0
movq 0x164f6a(%rip), %rdi    # 0x196ff0
leaq 0x1234a1(%rip), %rsi    # 0x15552e
movl $0x1, %edx
callq 0x44e0
movq 0x164f52(%rip), %rdi    # 0x196ff0
leaq 0x12450d(%rip), %rsi    # 0x1565b2
movl $0xa, %edx
callq 0x44e0
movq 0x164f3a(%rip), %rdi    # 0x196ff0
leaq 0x123471(%rip), %rsi    # 0x15552e
callq 0x4440
jmp 0x3211f
movq 0x164f25(%rip), %rdi    # 0x196ff0
leaq 0x121239(%rip), %rsi    # 0x15330b
movl $0x71, %edx
callq 0x44e0
movq 0x164f0d(%rip), %rdi    # 0x196ff0
leaq 0x123444(%rip), %rsi    # 0x15552e
movl $0x1, %edx
callq 0x44e0
movq 0x164ef5(%rip), %rdi    # 0x196ff0
leaq 0x1244b0(%rip), %rsi    # 0x1565b2
movl $0xa, %edx
callq 0x44e0
movq 0x164edd(%rip), %rdi    # 0x196ff0
leaq 0x123414(%rip), %rsi    # 0x15552e
callq 0x4440
movl $0x1, %edi
callq 0x710c
leaq 0x11d575(%rip), %rdi    # 0x14f6a5
xorl %eax, %eax
callq 0x4630
jmp 0x32139
movq %rax, %r14
jmp 0x321d1
movq %rax, %r14
jmp 0x321c4
jmp 0x32148
movq %rax, %r14
movq 0x8(%rsp), %rbx
jmp 0x321c4
jmp 0x3215a
jmp 0x3215a
jmp 0x3215a
jmp 0x3215a
movq %rax, %r14
movq 0x8(%rsp), %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x32179
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x32190
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x321a7
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x321c4
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
leaq 0x130(%rsp), %rdi
callq 0x38e76
movq 0xb0(%rsp), %rdi
callq 0xf0ca
movq 0xb8(%rsp), %rdi
callq 0xf0ca
movq 0xc0(%rsp), %rdi
callq 0xf0ca
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x3220c
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x4470
movq %r14, %rdi
callq 0x4780