// File: /workspace/github_cpp_makefile_star2_O3/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
xorl %eax, %eax
leaq 0x30(%rsp), %r15
movq %rax, 0x10(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
leaq 0x50(%rsp), %r12
movq %rax, 0x10(%r12)
movaps %xmm0, (%r12)
movq %rax, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
leaq 0x4(%rsp), %r13
movl $0x0, (%r13)
leaq 0x4c(%rsp), %rbp
movslq %eax, %rcx
movq 0x140(%r14), %rdx
cmpl %ebx, (%rdx,%rcx,4)
jne 0x7b32b
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x7b320
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x7b32b
movq %r15, %rdi
movq %r13, %rdx
callq 0xf864
movl $0xffffffff, 0x4c(%rsp) # imm = 0xFFFFFFFF
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x7b350
movl $0xffffffff, (%rsi)     # imm = 0xFFFFFFFF
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x7b35b
movq %r12, %rdi
movq %rbp, %rdx
callq 0x14198
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
movq 0x68(%r14), %rcx
subq 0x60(%r14), %rcx
shrq $0x3, %rcx
imull $0x38e38e39, %ecx, %ecx # imm = 0x38E38E39
cmpl %ecx, %eax
jl 0x7b2f8
movq 0x30(%rsp), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x7b39f
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x7b3b0
leaq 0x10(%rsp), %rdi
callq 0xf864
movq 0x30(%rsp), %rdx
movl (%rdx), %eax
cltq
movq 0x50(%rsp), %rdi
movl $0x1, (%rdi,%rax,4)
movq 0x38(%rsp), %rax
subq %rdx, %rax
shrq $0x2, %rax
cmpl $0x2, %eax
jl 0x7b510
movl $0x1, 0x8(%rsp)
movabsq $-0x71c71c71c71c71c7, %r15 # imm = 0x8E38E38E38E38E39
movabsq $-0x3333333333333333, %r12 # imm = 0xCCCCCCCCCCCCCCCD
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rax, %rcx
je 0x7b51c
movslq -0x4(%rcx), %r13
addq $-0x4, %rcx
movq %rcx, 0x18(%rsp)
movl $0x0, 0x4(%rsp)
movq 0x60(%r14), %rax
movq 0x68(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r13, %rdx
jbe 0x7b575
xorl %esi, %esi
leaq (,%r13,8), %rbp
addq %r13, %rbp
movq 0x20(%rax,%rbp,8), %r8
movq 0x28(%rax,%rbp,8), %rdx
subq %r8, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpl %edx, %esi
jge 0x7b4f8
movslq %esi, %r9
cmpq %r9, %rdx
jbe 0x7b572
leaq (%r9,%r9,4), %rdx
movl 0x4(%r8,%rdx,8), %edx
movl %edx, 0xc(%rsp)
movslq %edx, %r8
movq 0x140(%r14), %r9
cmpl %ebx, (%r9,%r8,4)
jne 0x7b4d9
cmpl $-0x1, (%rdi,%r8,4)
jne 0x7b4d9
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x7b4a9
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x7b4c5
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xf864
movq 0x50(%rsp), %rdi
movq 0x60(%r14), %rax
movq 0x68(%r14), %rcx
incl 0x8(%rsp)
movslq 0xc(%rsp), %rdx
movl $0x1, (%rdi,%rdx,4)
movl 0x4(%rsp), %esi
incl %esi
movl %esi, 0x4(%rsp)
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r13, %rdx
ja 0x7b443
jmp 0x7b575
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
shrq $0x2, %rax
cmpl %eax, 0x8(%rsp)
jl 0x7b3ef
movl $0x1, %ebx
movq 0x10(%rsp), %rax
jmp 0x7b51e
xorl %ebx, %ebx
testq %rax, %rax
je 0x7b538
movq 0x20(%rsp), %rsi
subq %rax, %rsi
movq %rax, %rdi
callq 0x4470
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x7b54a
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7b561
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r9, %r13
leaq 0xd2179(%rip), %rdi     # 0x14d6f5
movq %r13, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x7b58c
jmp 0x7b58c
jmp 0x7b58c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7b5a6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x7b5bd
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7b5d4
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780