// File: 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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x109f0
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x8(%rbp), %rdi
callq 0x87a0
movq -0x140(%rbp), %rdi
movslq %eax, %rsi
callq 0x10a10
movq -0x8(%rbp), %rdi
callq 0x87a0
cltq
movq %rax, -0x138(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x87c0
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x87e0
jmp 0xf10a
leaq -0x39(%rbp), %rdi
callq 0x8820
movl $0x0, -0x50(%rbp)
movq -0x8(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x10aa0
jmp 0xf129
leaq -0xa0(%rbp), %rdi
callq 0x8840
jmp 0xf137
xorl %eax, %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
callq 0x8960
movq %rdx, -0x150(%rbp)
movq %rax, -0x148(%rbp)
jmp 0xf154
movq -0x150(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x8a40
movl -0x50(%rbp), %eax
incl %eax
movl %eax, -0x50(%rbp)
movl $0x0, -0xb4(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xb4(%rbp), %rsi
callq 0x8870
jmp 0xf1a8
jmp 0xf1aa
leaq -0xa0(%rbp), %rdi
callq 0x88a0
movb %al, -0x151(%rbp)
jmp 0xf1be
movb -0x151(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xf1cf
jmp 0xf525
leaq -0xa0(%rbp), %rdi
callq 0x88c0
movq %rax, -0x160(%rbp)
jmp 0xf1e4
movq -0x160(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xb8(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x88e0
jmp 0xf201
movq -0x8(%rbp), %rdi
movl -0xb8(%rbp), %esi
callq 0x10ad0
movl %eax, -0x164(%rbp)
jmp 0xf218
movl -0x164(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0x8(%rbp), %rdi
movl -0xb8(%rbp), %esi
callq 0x8900
movq %rax, -0x170(%rbp)
jmp 0xf23c
movq -0x170(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x8480
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x84b0
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x8930
testb $0x1, %al
jne 0xf28c
jmp 0xf520
leaq -0xd0(%rbp), %rdi
callq 0x89c0
movl (%rax), %eax
movl %eax, -0xdc(%rbp)
movq -0x8(%rbp), %rdi
movl -0xdc(%rbp), %esi
callq 0x10ad0
movl %eax, -0x174(%rbp)
jmp 0xf2b7
movl -0x174(%rbp), %eax
movl %eax, -0xe0(%rbp)
cmpl $-0x1, -0xe0(%rbp)
je 0xf2de
movl -0xe0(%rbp), %eax
cmpl -0xbc(%rbp), %eax
jle 0xf50d
cmpl $-0x1, -0xe0(%rbp)
jne 0xf34a
movq -0x8(%rbp), %rdi
movl -0xdc(%rbp), %esi
movl -0xbc(%rbp), %edx
incl %edx
callq 0x10aa0
jmp 0xf300
jmp 0xf380
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x8820
jmp 0xf585
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xf57c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x8ac0
jmp 0xf57c
movl -0xe0(%rbp), %eax
movl -0xbc(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xf35f
jmp 0xf37e
leaq 0x5102(%rip), %rdi      # 0x14468
leaq 0x5117(%rip), %rsi      # 0x14484
movl $0x3c, %edx
leaq 0x511f(%rip), %rcx      # 0x14498
callq 0x3130
jmp 0xf380
movq -0x10(%rbp), %rdi
movslq -0xdc(%rbp), %rsi
callq 0x10b00
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
callq 0xc9c0
movq %rax, -0xf8(%rbp)
movq -0xe8(%rbp), %rdi
callq 0xc850
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rdi
movq -0x100(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x10b60
movq %rax, -0x180(%rbp)
jmp 0xf3e0
movq -0x180(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xe8(%rbp), %rdi
callq 0xc850
movq %rax, -0x108(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x10b20
testb $0x1, %al
jne 0xf41a
jmp 0xf41c
jmp 0xf43b
leaq 0x50c5(%rip), %rdi      # 0x144e8
leaq 0x505a(%rip), %rsi      # 0x14484
movl $0x41, %edx
leaq 0x5062(%rip), %rcx      # 0x14498
callq 0x3130
movq -0xe8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x85a0
jmp 0xf450
movslq -0xdc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x8960
movq %rdx, -0x190(%rbp)
movq %rax, -0x188(%rbp)
jmp 0xf470
movq -0x190(%rbp), %rax
movq -0x188(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movq %rax, -0x110(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x89e0
xorb $-0x1, %al
testb $0x1, %al
jne 0xf4a0
jmp 0xf50b
leaq -0xa0(%rbp), %rdi
leaq -0xdc(%rbp), %rsi
callq 0x8a10
jmp 0xf4b5
movslq -0xdc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x8960
movq %rdx, -0x1a0(%rbp)
movq %rax, -0x198(%rbp)
jmp 0xf4d5
movq -0x1a0(%rbp), %rax
movq -0x198(%rbp), %rcx
movq %rcx, -0x128(%rbp)
movq %rax, -0x120(%rbp)
leaq -0x128(%rbp), %rdi
movl $0x1, %esi
callq 0x8a40
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xf50d
jmp 0xf50f
leaq -0xd0(%rbp), %rdi
callq 0x8a90
jmp 0xf25d
jmp 0xf1aa
movl -0x50(%rbp), %eax
movl %eax, -0x1a8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x87a0
movl %eax, -0x1a4(%rbp)
jmp 0xf53f
movl -0x1a8(%rbp), %eax
movl -0x1a4(%rbp), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x1a9(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x8ac0
leaq -0x38(%rbp), %rdi
callq 0x8ae0
movb -0x1a9(%rbp), %al
andb $0x1, %al
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x8ae0
movq -0x48(%rbp), %rdi
callq 0x3340
nop