// File: /workspace/github_cpp_makefile_star2_O1/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 0x7a1c
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
imull $0x38e38e39, %eax, %eax # imm = 0x38E38E39
movslq %eax, %rsi
movq %r14, 0x90(%rsp)
movq %r14, %rdi
callq 0x76de
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
imull $0x38e38e39, %eax, %eax # imm = 0x38E38E39
movslq %eax, %rsi
leaq 0x40(%rsp), %r15
movb $0x0, (%r15)
leaq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rcx
movq %r15, %rdx
callq 0x5dd4
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 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x5f0a
movq 0x18(%rsp), %rax
orq $0x1, (%rax)
leaq 0x8(%rsp), %rsi
movl $0x0, (%rsi)
leaq 0x40(%rsp), %rdi
callq 0x6080
movq 0x50(%rsp), %rax
cmpq %rax, 0x70(%rsp)
je 0x6877
movl $0x1, 0x10(%rsp)
movl (%rax), %ecx
movl %ecx, 0x8(%rsp)
movq 0x60(%rsp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x6692
addq $0x4, %rax
jmp 0x66c4
movq 0x58(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x3180
movq 0x68(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x68(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x58(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0x60(%rsp)
movq %rax, 0x50(%rsp)
movslq 0x8(%rsp), %rcx
movq (%rbx), %rax
leaq (%rcx,%rcx,8), %rcx
leaq (%rax,%rcx,8), %r12
addq $0x18, %r12
movq 0x10(%r12), %rbp
cmpq %r12, %rbp
je 0x6865
movl 0x40(%rax,%rcx,8), %r15d
leal 0x1(%r15), %eax
movl %eax, 0x14(%rsp)
movslq 0x20(%rbp), %rcx
movl %ecx, 0xc(%rsp)
movq (%rbx), %rax
leaq (%rcx,%rcx,8), %rcx
movl 0x40(%rax,%rcx,8), %edx
cmpl $-0x1, %edx
je 0x6719
cmpl %r15d, %edx
jle 0x6851
cmpl $-0x1, %edx
je 0x6729
cmpl 0x14(%rsp), %edx
je 0x6737
jmp 0x6905
leaq (%rax,%rcx,8), %rax
addq $0x40, %rax
movl 0x14(%rsp), %ecx
movl %ecx, (%rax)
movslq 0xc(%rsp), %rax
movq 0x90(%rsp), %rcx
movq (%rcx), %r13
leaq (%rax,%rax,2), %r14
movq (%r13,%r14,8), %rdi
movq 0x8(%r13,%r14,8), %rsi
leaq 0x8(%rsp), %rdx
callq 0x7c1f
leaq (,%r14,8), %rdi
addq %r13, %rdi
movq 0x8(%rdi), %rsi
cmpq %rsi, %rax
jne 0x68e6
cmpq 0x10(%rdi), %rsi
je 0x678d
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x6797
leaq 0x8(%rsp), %rdx
callq 0x5c6a
movslq 0xc(%rsp), %rax
leaq 0x3f(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
sarq $0x6, %rcx
shlq $0x3, %rcx
addq 0x18(%rsp), %rcx
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
leaq 0x3f(%rdi), %r13
movq %rax, %rdx
andq %r13, %rdx
xorl %esi, %esi
cmpq %rdi, %rdx
setbe %sil
movq -0x8(%rcx,%rsi,8), %rcx
btq %rax, %rcx
jb 0x6851
movq 0x70(%rsp), %rcx
movq 0x80(%rsp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x67ff
movl %eax, (%rcx)
addq $0x4, %rcx
movq %rcx, 0x70(%rsp)
jmp 0x680e
leaq 0x40(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x62dc
movslq 0xc(%rsp), %rcx
leaq 0x3f(%rcx), %rax
testq %rcx, %rcx
cmovnsq %rcx, %rax
sarq $0x6, %rax
shlq $0x3, %rax
addq 0x18(%rsp), %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 0x10(%rsp)
movq %rbp, %rdi
callq 0x31b0
movq %rax, %rbp
cmpq %r12, %rax
jne 0x66f8
movq 0x50(%rsp), %rax
cmpq %rax, 0x70(%rsp)
jne 0x6678
jmp 0x687f
movl $0x1, 0x10(%rsp)
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
leaq 0x40(%rsp), %rdi
callq 0x570e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x68c0
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movl %eax, 0x30(%rsp)
movq %rax, 0x38(%rsp)
subq %r14, %rbx
shrq $0x3, %rbx
imull $0x38e38e39, %ebx, %eax # imm = 0x38E38E39
cmpl %eax, 0x10(%rsp)
sete %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2c03(%rip), %rdi      # 0x94f0
leaq 0x2b98(%rip), %rsi      # 0x948c
leaq 0x2ba5(%rip), %rcx      # 0x94a0
movl $0x41, %edx
callq 0x30e0
leaq 0x2b64(%rip), %rdi      # 0x9470
leaq 0x2b79(%rip), %rsi      # 0x948c
leaq 0x2b86(%rip), %rcx      # 0x94a0
movl $0x3c, %edx
callq 0x30e0
jmp 0x692d
movq %rax, %rbx
jmp 0x693a
jmp 0x692d
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x570e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x696a
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3180
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movl %eax, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movl %eax, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
callq 0x3280