// File: xukmin[P]rase/sensor-network.cc
// Function: SensorNetwork::FindNeighborCandidates(Position const&, double, std::vector<int, std::allocator<int>>*) const
void SensorNetwork::FindNeighborCandidates(const Position& position,
                                           double range,
                                           std::vector<int>* candidates) const {
  assert(candidates != NULL);
  candidates->clear();

  std::set<int> x_neighbors;
  {
    SensorMap::const_iterator lower = x_map_.lower_bound(position.x - range);
    SensorMap::const_iterator upper = x_map_.upper_bound(position.x + range);
    for (SensorMap::const_iterator it = lower; it != upper; ++it) {
      x_neighbors.insert(it->second);
    }
  }

  std::set<int> y_neighbors;
  {
    SensorMap::const_iterator lower = y_map_.lower_bound(position.y - range);
    SensorMap::const_iterator upper = y_map_.upper_bound(position.y + range);
    for (SensorMap::const_iterator it = lower; it != upper; ++it) {
      y_neighbors.insert(it->second);
    }
  }

  std::set_intersection(x_neighbors.begin(), x_neighbors.end(),
                        y_neighbors.begin(), y_neighbors.end(),
                        std::back_inserter(*candidates));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x6cf0
jmp 0x6d0f
leaq 0xd4f9(%rip), %rdi      # 0x141f0
leaq 0xd505(%rip), %rsi      # 0x14203
movl $0x3a, %edx
leaq 0xd50b(%rip), %rcx      # 0x14215
callq 0x3130
movq -0x20(%rbp), %rdi
callq 0x82a0
leaq -0x50(%rbp), %rdi
callq 0x82c0
movq -0x138(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
movsd -0x18(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
leaq -0x60(%rbp), %rsi
callq 0x82e0
movq %rax, -0x140(%rbp)
jmp 0x6d54
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rax
movq %rax, -0x58(%rbp)
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
movsd -0x18(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
leaq -0x80(%rbp), %rsi
callq 0x8310
movq %rax, -0x148(%rbp)
jmp 0x6d92
movq -0x148(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x8340
testb $0x1, %al
jne 0x6dbe
jmp 0x6e22
leaq -0x88(%rbp), %rdi
callq 0x83c0
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x50(%rbp), %rdi
callq 0x8370
movb %dl, -0x151(%rbp)
movq %rax, -0x150(%rbp)
jmp 0x6de9
movb -0x151(%rbp), %al
movq -0x150(%rbp), %rcx
movq %rcx, -0x98(%rbp)
movb %al, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x83e0
jmp 0x6da8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x702c
leaq -0xc8(%rbp), %rdi
callq 0x82c0
movq -0x138(%rbp), %rdi
addq $0x48, %rdi
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd -0x18(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0xd8(%rbp)
leaq -0xd8(%rbp), %rsi
callq 0x82e0
movq %rax, -0x160(%rbp)
jmp 0x6e68
movq -0x138(%rbp), %rdi
movq -0x160(%rbp), %rax
movq %rax, -0xd0(%rbp)
addq $0x48, %rdi
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd -0x18(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
leaq -0xe8(%rbp), %rsi
callq 0x8310
movq %rax, -0x168(%rbp)
jmp 0x6eb0
movq -0x168(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x8340
testb $0x1, %al
jne 0x6ee5
jmp 0x6f58
leaq -0xf0(%rbp), %rdi
callq 0x83c0
movq %rax, %rsi
addq $0x8, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x8370
movb %dl, -0x171(%rbp)
movq %rax, -0x170(%rbp)
jmp 0x6f13
movb -0x171(%rbp), %al
movq -0x170(%rbp), %rcx
movq %rcx, -0x100(%rbp)
movb %al, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x83e0
jmp 0x6ecc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x4ea0
jmp 0x702c
leaq -0x50(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x8480
movq -0x190(%rbp), %rdi
movq %rax, -0x108(%rbp)
callq 0x84b0
movq %rax, -0x110(%rbp)
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x8480
movq -0x188(%rbp), %rdi
movq %rax, -0x118(%rbp)
callq 0x84b0
movq %rax, -0x120(%rbp)
movq -0x20(%rbp), %rdi
callq 0x84e0
movq %rax, -0x180(%rbp)
jmp 0x6fc1
movq -0x180(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x108(%rbp), %rdi
movq -0x110(%rbp), %rsi
movq -0x118(%rbp), %rdx
movq -0x120(%rbp), %rcx
movq -0x128(%rbp), %r8
callq 0x8410
movq %rax, -0x198(%rbp)
jmp 0x7000
movq -0x198(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x4ea0
leaq -0x50(%rbp), %rdi
callq 0x4ea0
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x4ea0
movq -0x68(%rbp), %rdi
callq 0x3340
nop