// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/feature.cc
// Function: FEATURE::validateSegment(int)
int FEATURE::validateSegment(int segid){
int i;
int id,conn_to;
int nvisited=0;
int valid=1;
vector <int> nodelist;
vector <int> visited;

vector <int> heap;

/* count nodes and init heap */
for(i=0;i<(int)nodes.size();i++)
   {
   if(segments[i]==segid) 
      {
      nodelist.push_back(i);
//      visited.push_back(-1);
      };
   visited.push_back(-1);
   };

heap.push_back(nodelist[0]);
visited[nodelist[0]]=1;
nvisited++;

/* investigate connections by adding them to heap */
while(nvisited<(int)nodelist.size())
   {
   if(heap.size()==0)
     {
     valid=0;
     break;
     };

   id=heap.back();heap.pop_back();

   /* current node is id, investigate its connections, add to heap */

   for(i=0;i<(int)nodes.at(id).connections.size();i++)
      {
      conn_to=nodes.at(id).connections.at(i).to;

      if(segments[conn_to]==segid&&visited[conn_to]==-1) // if connected to other node within same segment and not visited, add to heap
        {
        heap.push_back(conn_to);
        nvisited++;
        visited[conn_to]=1;
        };
      };

   };


return valid;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebx
movq %rdi, %r14
leaq 0x30(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
leaq 0x50(%rsp), %r13
movaps %xmm0, (%r13)
andq $0x0, 0x10(%r13)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x60(%rdi), %r15
xorl %ecx, %ecx
pushq $0x48
popq %rbp
leaq 0xc(%rsp), %r12
movl %ecx, (%rsp)
movq 0x68(%r14), %rax
subq 0x60(%r14), %rax
cqto
idivq %rbp
cmpl %eax, %ecx
jge 0x5c5d4
movslq %ecx, %rax
movq 0x140(%r14), %rcx
cmpl %ebx, (%rcx,%rax,4)
jne 0x5c5bd
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x9434
orl $-0x1, 0xc(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x10324
movl (%rsp), %ecx
incl %ecx
jmp 0x5c58d
movq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x9434
movq 0x30(%rsp), %rax
movslq (%rax), %rcx
movq 0x50(%rsp), %rdx
movl $0x1, (%rdx,%rcx,4)
pushq $0x1
popq %rcx
pushq $0x28
popq %r12
movl %ecx, 0x4(%rsp)
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
cmpl %ecx, 0x4(%rsp)
jge 0x5c6d0
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x5c6d5
movslq -0x4(%rax), %rbp
addq $-0x4, %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
movl %r13d, (%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xabe2
movq 0x28(%rax), %rcx
subq 0x20(%rax), %rcx
movq %rcx, %rax
cqto
idivq %r12
cmpl %eax, %r13d
jge 0x5c6c6
movq %r15, %rdi
movq %rbp, %rsi
callq 0xabe2
addq $0x20, %rax
movslq (%rsp), %rsi
movq %rax, %rdi
callq 0x29efa
movslq 0x4(%rax), %rax
movl %eax, 0x8(%rsp)
movq 0x140(%r14), %rcx
cmpl %ebx, (%rcx,%rax,4)
jne 0x5c6ba
movq 0x50(%rsp), %rcx
cmpl $-0x1, (%rcx,%rax,4)
jne 0x5c6ba
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x9434
incl 0x4(%rsp)
movslq 0x8(%rsp), %rax
movq 0x50(%rsp), %rcx
movl $0x1, (%rcx,%rax,4)
movl (%rsp), %r13d
incl %r13d
jmp 0x5c638
movq 0x30(%rsp), %rax
jmp 0x5c602
pushq $0x1
popq %rbx
jmp 0x5c6d7
xorl %ebx, %ebx
leaq 0x10(%rsp), %rdi
callq 0xb290
leaq 0x50(%rsp), %rdi
callq 0xb290
leaq 0x30(%rsp), %rdi
callq 0xb290
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5c70c
jmp 0x5c70c
jmp 0x5c70c
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb290
leaq 0x50(%rsp), %rdi
callq 0xb290
leaq 0x30(%rsp), %rdi
callq 0xb290
movq %rbx, %rdi
callq 0x4780
nop