// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movq %rdi, %rbx
xorl %eax, %eax
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq %rax, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movq %rax, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movl $0x0, 0x4(%rsp)
movq 0x68(%rdi), %rcx
subq 0x60(%rdi), %rcx
movl %esi, %ebp
shrq $0x3, %rcx
imull $0x38e38e39, %ecx, %ecx # imm = 0x38E38E39
testl %ecx, %ecx
jle 0x7c499
leaq 0x30(%rsp), %r14
leaq 0x4(%rsp), %r15
leaq 0x50(%rsp), %r12
leaq 0x74(%rsp), %r13
movslq %eax, %rcx
movq 0x140(%rbx), %rdx
cmpl %ebp, (%rdx,%rcx,4)
jne 0x7c445
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x7c43a
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x7c445
movq %r14, %rdi
movq %r15, %rdx
callq 0xf7b4
movl $0xffffffff, 0x74(%rsp) # imm = 0xFFFFFFFF
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x7c46a
movl $0xffffffff, (%rsi)     # imm = 0xFFFFFFFF
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x7c475
movq %r12, %rdi
movq %r13, %rdx
callq 0x1422c
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
movq 0x68(%rbx), %rcx
subq 0x60(%rbx), %rcx
shrq $0x3, %rcx
imull $0x38e38e39, %ecx, %ecx # imm = 0x38E38E39
cmpl %ecx, %eax
jl 0x7c412
movq 0x30(%rsp), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x7c4b9
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x7c4c3
leaq 0x10(%rsp), %rdi
callq 0xf7b4
movq 0x30(%rsp), %rax
movslq (%rax), %rax
movq 0x50(%rsp), %rcx
movl $0x1, (%rcx,%rax,4)
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
shrq $0x2, %rax
movl $0x1, %r14d
cmpl $0x2, %eax
jl 0x7c62d
movl $0x1, 0x8(%rsp)
movabsq $-0x71c71c71c71c71c7, %r14 # imm = 0x8E38E38E38E38E39
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x7c62a
movslq -0x4(%rax), %r12
addq $-0x4, %rax
movq %rax, 0x18(%rsp)
movl $0x0, 0x4(%rsp)
movq 0x60(%rbx), %rcx
movq 0x68(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %r12, %rdx
jbe 0x7c687
xorl %eax, %eax
leaq (%r12,%r12,8), %r13
movq 0x20(%rcx,%r13,8), %rsi
movq 0x28(%rcx,%r13,8), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpl %edx, %eax
jge 0x7c60a
cltq
cmpq %rax, %rdx
jbe 0x7c684
leaq (%rax,%rax,4), %rax
movl 0x4(%rsi,%rax,8), %eax
movl %eax, 0xc(%rsp)
movslq %eax, %rcx
movq 0x140(%rbx), %rdx
cmpl %ebp, (%rdx,%rcx,4)
jne 0x7c5e2
movq 0x50(%rsp), %rdx
cmpl $-0x1, (%rdx,%rcx,4)
jne 0x7c5e2
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x7c5be
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x7c5cd
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xf7b4
incl 0x8(%rsp)
movslq 0xc(%rsp), %rax
movq 0x50(%rsp), %rcx
movl $0x1, (%rcx,%rax,4)
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
movq 0x60(%rbx), %rcx
movq 0x68(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %r12, %rdx
ja 0x7c557
jmp 0x7c687
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
shrq $0x2, %rax
cmpl %eax, 0x8(%rsp)
jl 0x7c510
movl $0x1, %r14d
jmp 0x7c62d
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7c644
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x7c65b
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7c672
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movl %r14d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
leaq 0xd3017(%rip), %rdi     # 0x14f6a5
movq %r12, %rsi
xorl %eax, %eax
callq 0x4630
jmp 0x7c69e
jmp 0x7c69e
jmp 0x7c69e
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7c6b8
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x7c6cf
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7c6e6
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x4470
movq %rbx, %rdi
callq 0x4780