// File: /workspace/github_cpp_makefile_star2_O2/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, %rdi
callq 0x701a
movq 0x8(%rbx), %rax
subq (%rbx), %rax
pushq $0x48
popq %r15
cqto
idivq %r15
movslq %eax, %rsi
movq %r14, 0x18(%rsp)
movq %r14, %rdi
callq 0x7022
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %r15
movslq %eax, %rsi
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x4d8a
movq (%rbx), %rax
andl $0x0, 0x40(%rax)
leaq 0x48(%rsp), %rdi
callq 0x4d9e
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x4dba
orq %rdx, (%rax)
leaq 0xc(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x48(%rsp), %rdi
callq 0x5dbc
pushq $0x1
popq %rax
movl %eax, 0x10(%rsp)
movq 0x58(%rsp), %rax
cmpq %rax, 0x78(%rsp)
je 0x6531
movl (%rax), %eax
movl %eax, 0xc(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x6016
movslq 0xc(%rsp), %rax
movq (%rbx), %rcx
imulq $0x48, %rax, %rax
leaq (%rcx,%rax), %r14
addq $0x18, %r14
movl 0x28(%r14), %r13d
movq 0x10(%r14), %rbp
leal 0x1(%r13), %eax
movl %eax, 0x14(%rsp)
cmpq %r14, %rbp
je 0x6422
movslq 0x20(%rbp), %rax
movl %eax, 0x8(%rsp)
movq (%rbx), %rcx
imulq $0x48, %rax, %rdx
movl 0x40(%rcx,%rdx), %esi
cmpl $-0x1, %esi
je 0x648c
cmpl %r13d, %esi
jle 0x6521
cmpl $-0x1, %esi
je 0x649c
cmpl 0x14(%rsp), %esi
je 0x64af
jmp 0x6588
leaq (%rcx,%rdx), %rax
addq $0x40, %rax
movl 0x14(%rsp), %ecx
movl %ecx, (%rax)
movslq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rcx), %r15
imulq $0x18, %rax, %r12
movq (%r15,%r12), %rdi
movq 0x8(%r15,%r12), %rsi
leaq 0xc(%rsp), %rdx
callq 0x74cc
addq %r12, %r15
cmpq 0x8(%r15), %rax
jne 0x656f
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0x4d4e
movslq 0x8(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x4dba
testq %rdx, (%rax)
jne 0x6521
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x607c
movslq 0x8(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x4dba
orq %rdx, (%rax)
incl 0x10(%rsp)
movq %rbp, %rdi
callq 0x31a0
movq %rax, %rbp
jmp 0x6466
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
pushq $0x48
popq %rcx
idivq %rcx
cmpl %eax, 0x10(%rsp)
sete %bl
leaq 0x48(%rsp), %rdi
callq 0x5282
leaq 0x20(%rsp), %rdi
callq 0x4dd8
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f8a(%rip), %rdi      # 0x8500
leaq 0x1f1f(%rip), %rsi      # 0x849c
leaq 0x1f2c(%rip), %rcx      # 0x84b0
pushq $0x41
jmp 0x659f
leaq 0x1ef1(%rip), %rdi      # 0x8480
leaq 0x1f06(%rip), %rsi      # 0x849c
leaq 0x1f13(%rip), %rcx      # 0x84b0
pushq $0x3c
popq %rdx
callq 0x30f0
jmp 0x65b4
jmp 0x65b4
movq %rax, %rbx
jmp 0x65c1
jmp 0x65b4
jmp 0x65b4
jmp 0x65b4
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5282
leaq 0x20(%rsp), %rdi
callq 0x4dd8
movq %rbx, %rdi
callq 0x3290
nop