// File: xukmin[P]rase/sensor-network.cc
// Function: SensorNetwork::IsConnectedWithRoutings() const
bool SensorNetwork::IsConnectedWithRoutings() const {
  assert(num_sensors() > 0);

  std::vector<bool> visited(num_sensors());
  int num_connected = 0;

  visited[0] = true;
  num_connected++;

  for (int i = 1; i < num_sensors(); i++) {
    int parent = GetParent(i);
    while (parent > 0 && !visited[parent]) {
      visited[parent] = true;
      parent = GetParent(parent);
    }
    if (parent < 0) {
      return false;
    }
    num_connected++;
  }

  return num_connected == num_sensors();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x87a0
cmpl $0x0, %eax
jle 0x7aa6
jmp 0x7ac5
leaq 0xc88a(%rip), %rdi      # 0x14337
leaq 0xc74f(%rip), %rsi      # 0x14203
movl $0xc5, %edx
leaq 0xc8bd(%rip), %rcx      # 0x1437d
callq 0x3130
movq -0x98(%rbp), %rdi
callq 0x87a0
cltq
movq %rax, -0xa8(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x87c0
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x87e0
jmp 0x7b03
leaq -0x39(%rbp), %rdi
callq 0x8820
movl $0x0, -0x50(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
callq 0x8960
movq %rdx, -0xb8(%rbp)
movq %rax, -0xb0(%rbp)
jmp 0x7b30
movq -0xb8(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq %rcx, -0x60(%rbp)
movq %rax, -0x58(%rbp)
leaq -0x60(%rbp), %rdi
movl $0x1, %esi
callq 0x8a40
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl $0x1, -0x64(%rbp)
movq -0x98(%rbp), %rdi
movl -0x64(%rbp), %eax
movl %eax, -0xc0(%rbp)
callq 0x87a0
movl %eax, -0xbc(%rbp)
jmp 0x7b81
movl -0xc0(%rbp), %eax
movl -0xbc(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7ce3
movq -0x98(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x8b00
movl %eax, -0xc4(%rbp)
jmp 0x7bac
movl -0xc4(%rbp), %eax
movl %eax, -0x68(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x68(%rbp)
movb %al, -0xc5(%rbp)
jle 0x7c07
movslq -0x68(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x8960
movq %rdx, -0xd8(%rbp)
movq %rax, -0xd0(%rbp)
jmp 0x7be0
movq -0xd8(%rbp), %rax
movq -0xd0(%rbp), %rcx
movq %rcx, -0x78(%rbp)
movq %rax, -0x70(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x89e0
xorb $-0x1, %al
movb %al, -0xc5(%rbp)
movb -0xc5(%rbp), %al
testb $0x1, %al
jne 0x7c16
jmp 0x7cb6
movslq -0x68(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x8960
movq %rdx, -0xe8(%rbp)
movq %rax, -0xe0(%rbp)
jmp 0x7c33
movq -0xe8(%rbp), %rax
movq -0xe0(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq %rax, -0x80(%rbp)
leaq -0x88(%rbp), %rdi
movl $0x1, %esi
callq 0x8a40
movq -0x98(%rbp), %rdi
movl -0x68(%rbp), %esi
callq 0x8b00
movl %eax, -0xec(%rbp)
jmp 0x7c74
movl -0xec(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0x7bb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x8820
jmp 0x7d37
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x8ae0
jmp 0x7d37
cmpl $0x0, -0x68(%rbp)
jge 0x7ccc
movb $0x0, -0x1(%rbp)
movl $0x1, -0x8c(%rbp)
jmp 0x7d20
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x7b64
movq -0x98(%rbp), %rdi
movl -0x50(%rbp), %eax
movl %eax, -0xf4(%rbp)
callq 0x87a0
movl %eax, -0xf0(%rbp)
jmp 0x7d00
movl -0xf4(%rbp), %eax
movl -0xf0(%rbp), %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0x8c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x8ae0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x3340