// File: /workspace/github_cpp_makefile_star2_O3/xukmin[P]rase/routing-builders.cc
// Function: GenerateParentCandidates(SensorNetwork*, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>*)
bool GenerateParentCandidates(SensorNetwork* network,
                              std::vector<std::vector<int> >* parents) {
  parents->clear();
  parents->resize(network->num_sensors());

  std::vector<bool> visited(network->num_sensors());
  int num_visited = 0;
  network->SetLevel(0, 0);
  std::queue<int> queue;
  visited[0] = true;
  num_visited++;
  queue.push(0);  // Start from the base station.
  while (!queue.empty()) {
    int current = queue.front();
    queue.pop();
    int level = network->GetLevel(current);
    const std::set<int>& neighbors = network->GetNeighbors(current);
    for (std::set<int>::const_iterator it = neighbors.begin();
         it != neighbors.end();
         ++it) {
      int neighbor = *it;
      int neighbor_level = network->GetLevel(neighbor);
      if (neighbor_level == -1 || neighbor_level > level) {
        if (neighbor_level == -1) {
          network->SetLevel(neighbor, level + 1);
        } else {
          assert(neighbor_level == level + 1);
        }
        std::vector<int>& neighbor_parents = (*parents)[neighbor];
        assert(std::find(neighbor_parents.begin(),
                         neighbor_parents.end(),
                         current) == neighbor_parents.end());
        neighbor_parents.push_back(current);
        if (!visited[neighbor]) {
          queue.push(neighbor);
          visited[neighbor] = true;
          num_visited++;
        }
      }
    }
  }

  return num_visited == network->num_sensors();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rsi
movq %r14, %rdi
callq 0x7ab2
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
imull $0x38e38e39, %eax, %eax # imm = 0x38E38E39
movslq %eax, %rsi
movq %r14, 0x68(%rsp)
movq %r14, %rdi
callq 0x7764
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
imull $0x38e38e39, %eax, %eax # imm = 0x38E38E39
movslq %eax, %rsi
leaq 0x10(%rsp), %r15
movb $0x0, (%r15)
leaq 0x70(%rsp), %rdi
movq %rsp, %rcx
movq %r15, %rdx
callq 0x5ece
movq (%rbx), %rax
movl $0x0, 0x40(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%r15)
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x6004
movq 0x70(%rsp), %rax
orq $0x1, (%rax)
movq %rsp, %rsi
movl $0x0, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x617a
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
je 0x6959
movl $0x1, 0x8(%rsp)
movl (%rax), %ecx
movl %ecx, (%rsp)
movq 0x30(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rax
je 0x677e
addq $0x4, %rax
jmp 0x67b3
movq 0x28(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x3170
movq 0x38(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x38(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x30(%rsp)
movl (%rsp), %ecx
movq %rax, 0x20(%rsp)
movslq %ecx, %rdx
movq (%rbx), %rcx
leaq (%rdx,%rdx,8), %rdx
leaq (%rcx,%rdx,8), %r12
addq $0x18, %r12
movq 0x10(%r12), %rbp
cmpq %r12, %rbp
je 0x694c
movl 0x40(%rcx,%rdx,8), %r15d
leal 0x1(%r15), %eax
movl %eax, 0xc(%rsp)
movslq 0x20(%rbp), %rax
movl %eax, 0x4(%rsp)
movq (%rbx), %rcx
leaq (%rax,%rax,8), %rdx
movl 0x40(%rcx,%rdx,8), %esi
cmpl $-0x1, %esi
je 0x6806
cmpl %r15d, %esi
jle 0x6933
cmpl $-0x1, %esi
je 0x6816
cmpl 0xc(%rsp), %esi
je 0x6829
jmp 0x69d1
leaq (%rcx,%rdx,8), %rax
addq $0x40, %rax
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movslq 0x4(%rsp), %rax
movq 0x68(%rsp), %rcx
movq (%rcx), %r13
leaq (%rax,%rax,2), %r14
movq (%r13,%r14,8), %rdi
movq 0x8(%r13,%r14,8), %rsi
movq %rsp, %rdx
callq 0x7cad
leaq (,%r14,8), %rdi
addq %r13, %rdi
movq 0x8(%rdi), %rsi
cmpq %rsi, %rax
jne 0x69b2
cmpq 0x10(%rdi), %rax
je 0x6874
movl (%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x687c
movq %rsp, %rdx
callq 0x5d64
movslq 0x4(%rsp), %rcx
leal 0x3f(%rcx), %edx
testq %rcx, %rcx
movq 0x70(%rsp), %rax
cmovnsl %ecx, %edx
sarl $0x6, %edx
movslq %edx, %rdx
leaq (%rax,%rdx,8), %rdx
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
leaq 0x3f(%r8), %r13
movq %rcx, %rsi
andq %r13, %rsi
xorl %edi, %edi
cmpq %r8, %rsi
setbe %dil
movq -0x8(%rdx,%rdi,8), %rdx
btq %rcx, %rdx
jb 0x6933
movq 0x40(%rsp), %rdx
movq 0x50(%rsp), %rsi
addq $-0x4, %rsi
cmpq %rsi, %rdx
je 0x68e1
movl %ecx, (%rdx)
addq $0x4, %rdx
movq %rdx, 0x40(%rsp)
jmp 0x68f5
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x63d6
movq 0x70(%rsp), %rax
movslq 0x4(%rsp), %rcx
leal 0x3f(%rcx), %edx
testq %rcx, %rcx
cmovnsl %ecx, %edx
sarl $0x6, %edx
movslq %edx, %rdx
leaq (%rax,%rdx,8), %rax
andq %rcx, %r13
xorl %edx, %edx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
cmpq %rsi, %r13
setbe %dl
movl $0x1, %esi
shlq %cl, %rsi
orq %rsi, -0x8(%rax,%rdx,8)
incl 0x8(%rsp)
movq %rbp, %rdi
callq 0x31a0
movq %rax, %rbp
cmpq %r12, %rax
jne 0x67e5
movq 0x20(%rsp), %rax
cmpq %rax, 0x40(%rsp)
jne 0x6765
jmp 0x6961
movl $0x1, 0x8(%rsp)
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
leaq 0x10(%rsp), %rdi
callq 0x5808
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x698c
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3170
subq %r14, %rbx
shrq $0x3, %rbx
imull $0x38e38e39, %ebx, %eax # imm = 0x38E38E39
cmpl %eax, 0x8(%rsp)
sete %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b87(%rip), %rdi      # 0x9540
leaq 0x2b1c(%rip), %rsi      # 0x94dc
leaq 0x2b29(%rip), %rcx      # 0x94f0
movl $0x41, %edx
callq 0x30e0
leaq 0x2ae8(%rip), %rdi      # 0x94c0
leaq 0x2afd(%rip), %rsi      # 0x94dc
leaq 0x2b0a(%rip), %rcx      # 0x94f0
movl $0x3c, %edx
callq 0x30e0
jmp 0x69f9
movq %rax, %rbx
jmp 0x6a06
jmp 0x69f9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5808
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x6a20
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3170
movq %rbx, %rdi
callq 0x3270