// File: Kobzol[P]sigmod-2016/src/evaluator.h
// Function: GraphEvaluator::query(unsigned int, unsigned int, unsigned long, unsigned long)
static int64_t query(sigint from, sigint to, size_t query_id, size_t thread_id)
    {
        if (!graph.has_vertex(from) || !graph.has_vertex(to)) return -1;
        if (from == to) return 0;

#ifdef USE_UNION_FIND
        if (graph.nodes[from].get_parent(graph) != graph.nodes[to].get_parent(graph))
        {
#ifdef COLLECT_STATS
            UNION_HITS++;
#endif
            return -1;
        }
#endif

        std::queue<DistanceInfo> q;
        q.push(DistanceInfo(from, 0));

        while (!q.empty())
        {
            DistanceInfo current = q.front();
            q.pop();

            for (Vertex* neighbor : graph.nodes[current.vertexId].edges_out)
            {
                if (neighbor->id == to)
                {
                    return current.distance + 1;
                }

#ifdef USE_THREADS
                if (neighbor->visited[thread_id] < query_id && neighbor->edges_out.size() > 0)
#else
                if (neighbor->visited < query_id && neighbor->edges_out.size() > 0)
#endif
                {
                    q.push(DistanceInfo(neighbor->id, current.distance + 1));
#ifdef COLLECT_STATS
                    BFS_QUEUE_MAX_SIZE = std::max(BFS_QUEUE_MAX_SIZE, q.size());
#endif
#ifdef USE_THREADS
                    neighbor->visited[thread_id] = query_id;
#else
                    neighbor->visited = query_id;
#endif
                }
            }
        }

        return -1;
    }

// Assembly:
subq $0xd8, %rsp
movl %edi, 0xcc(%rsp)
movl %esi, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rcx, 0xb8(%rsp)
movl 0xcc(%rsp), %esi
leaq 0x317f9d(%rip), %rdi    # 0x31e5f0
callq 0x2860
testb $0x1, %al
jne 0x665e
jmp 0x6675
movl 0xc8(%rsp), %esi
leaq 0x317f84(%rip), %rdi    # 0x31e5f0
callq 0x2860
testb $0x1, %al
jne 0x6686
movq $-0x1, 0xd0(%rsp)
jmp 0x68e6
movl 0xcc(%rsp), %eax
cmpl 0xc8(%rsp), %eax
jne 0x66a7
movq $0x0, 0xd0(%rsp)
jmp 0x68e6
leaq 0x317f42(%rip), %rdi    # 0x31e5f0
leaq 0xcc(%rsp), %rsi
callq 0x6be0
movq %rax, %rdi
leaq 0x317f2b(%rip), %rsi    # 0x31e5f0
callq 0x9ef0
movl %eax, 0x18(%rsp)
leaq 0x317f1b(%rip), %rdi    # 0x31e5f0
leaq 0xc8(%rsp), %rsi
callq 0x6be0
movq %rax, %rdi
leaq 0x317f04(%rip), %rsi    # 0x31e5f0
callq 0x9ef0
movl %eax, %ecx
movl 0x18(%rsp), %eax
cmpl %ecx, %eax
je 0x670c
movq $-0x1, 0xd0(%rsp)
jmp 0x68e6
leaq 0x68(%rsp), %rdi
callq 0x6c10
movl 0xcc(%rsp), %esi
leaq 0x60(%rsp), %rdi
xorl %edx, %edx
callq 0x6c70
jmp 0x672b
leaq 0x68(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x6c40
jmp 0x673c
jmp 0x673e
leaq 0x68(%rsp), %rdi
callq 0x6c90
movb %al, 0x17(%rsp)
jmp 0x674e
movb 0x17(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x675d
jmp 0x68c8
leaq 0x68(%rsp), %rdi
callq 0x6cb0
movq %rax, 0x8(%rsp)
jmp 0x676e
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x6cc0
jmp 0x6787
leaq 0x317e62(%rip), %rdi    # 0x31e5f0
leaq 0x48(%rsp), %rsi
callq 0x6be0
movq %rax, (%rsp)
jmp 0x679e
movq (%rsp), %rax
addq $0x8, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
callq 0x29a0
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rdi
callq 0x4200
movq %rax, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x4830
testb $0x1, %al
jne 0x67e1
jmp 0x68c3
leaq 0x38(%rsp), %rdi
callq 0x6cd0
movq (%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movl (%rax), %eax
cmpl 0xc8(%rsp), %eax
jne 0x683e
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, 0xd0(%rsp)
movl $0x1, 0x24(%rsp)
jmp 0x68dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x6d00
jmp 0x68f6
movq 0x28(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq 0x20(%rax,%rcx,8), %rax
cmpq 0xc0(%rsp), %rax
jae 0x68b2
movq 0x28(%rsp), %rdi
addq $0x8, %rdi
callq 0x28f0
cmpq $0x0, %rax
jbe 0x68b2
movq 0x28(%rsp), %rax
movl (%rax), %esi
movl 0x4c(%rsp), %edx
incl %edx
leaq 0x1c(%rsp), %rdi
callq 0x6c70
jmp 0x6887
leaq 0x68(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x6c40
jmp 0x6898
movq 0xc0(%rsp), %rdx
movq 0x28(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
jmp 0x68b4
leaq 0x38(%rsp), %rdi
callq 0x6ce0
jmp 0x67c9
jmp 0x673e
movq $-0x1, 0xd0(%rsp)
movl $0x1, 0x24(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x6d00
movq 0xd0(%rsp), %rax
addq $0xd8, %rsp
retq
movq 0x58(%rsp), %rdi
callq 0x2310