// File: /workspace/github_cpp_makefile_star2_O2/bonetblai[P]mdp-engine/ctp3/./graph.h
// Function: CTP::graph_t::bfs(int, int, unsigned int const*, unsigned int const*, bool) const
int bfs(int start,
            int goal,
            const unsigned *k_bitmap,
            const unsigned *b_bitmap,
            bool optimistic = false) const {

        static std::priority_queue<std::pair<int, std::pair<int, int> >,
                                   std::vector<std::pair<int, std::pair<int, int> > >,
                                   bfs_open_list_cmp> queue;

        int cost_to_goal = INT_MAX;
        memset(in_queue_, 0, num_nodes_ * sizeof(int));
        queue.push(std::make_pair(start, std::make_pair(0, heuristic(start))));
        in_queue_[start] = 1;
        while( !queue.empty() ) {
            std::pair<int, std::pair<int, int> > p = queue.top();
            queue.pop();

            if( p.first == goal ) {
                cost_to_goal = p.second.first;
                break;
            }

            for( int i = 0, isz = at_[p.first].size(); i < isz; ++i ) {
                int idx = at_[p.first][i];
                if( good(idx, k_bitmap, b_bitmap, optimistic) ) {
                    const edge_t &edge = edge_list_[idx];
                    int cost = p.second.first + edge.cost_;
                    int next = p.first == edge.to_ ? edge.from_ : edge.to_;
                    if( in_queue_[next] == 0 ) {
                        queue.push(std::make_pair(next, std::make_pair(cost, heuristic(next))));
                        in_queue_[next] = 1;
                    }
                }
            }
        }

        while( !queue.empty() ) queue.pop();
        return cost_to_goal;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %r12d
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movl %edx, 0x1c(%rsp)
movl %esi, %ebp
movq %rdi, %r15
movb 0x2bea4(%rip), %al      # 0x352e8
testb %al, %al
je 0x95de
movq 0x50(%r15), %rdi
movslq (%r15), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x5170
movq 0x48(%r15), %rax
movslq %ebp, %rbx
movl (%rax,%rbx,4), %eax
movq %rax, %rcx
shlq $0x20, %rcx
leaq 0x10(%rsp), %rsi
movl %ebx, (%rsi)
movq %rcx, 0x4(%rsi)
movq (%rsi), %rcx
movq %rcx, (%rsi)
movl %eax, 0x8(%rsi)
leaq 0x2be3e(%rip), %rdi     # 0x352c8
callq 0x9636
movq 0x50(%r15), %rax
movl $0x1, (%rax,%rbx,4)
movzbl %r12b, %r12d
movq 0x2be23(%rip), %rax     # 0x352c8
cmpq 0x2be24(%rip), %rax     # 0x352d0
je 0x95a2
movslq (%rax), %rbx
movl 0x4(%rax), %eax
movl %eax, 0xc(%rsp)
leaq 0x2be05(%rip), %rdi     # 0x352c8
callq 0x964c
cmpl 0x1c(%rsp), %ebx
je 0x95aa
movq 0x28(%r15), %rax
movq %rbx, 0x20(%rsp)
imulq $0x18, %rbx, %rbx
movq 0x8(%rax,%rbx), %r14
subq (%rax,%rbx), %r14
shrq $0x2, %r14
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x949e
movq 0x28(%r15), %rax
movq (%rax,%rbx), %rax
movl (%rax,%r13,4), %ebp
movq %r15, %rdi
movl %ebp, %esi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
movl %r12d, %r8d
callq 0x9664
testb %al, %al
je 0x959a
movslq %ebp, %rax
shlq $0x4, %rax
movq 0x10(%r15), %rcx
movl 0x4(%rcx,%rax), %edx
cmpl %edx, 0x20(%rsp)
jne 0x953f
movl (%rcx,%rax), %edx
movq 0x50(%r15), %rsi
movslq %edx, %rbp
cmpl $0x0, (%rsi,%rbp,4)
jne 0x959a
addq %rax, %rcx
movl 0x8(%rcx), %eax
addl 0xc(%rsp), %eax
movq 0x48(%r15), %rcx
movl (%rcx,%rbp,4), %ecx
movq %rcx, %rdx
shlq $0x20, %rdx
orq %rdx, %rax
movl %ebp, 0x10(%rsp)
movq %rax, 0x14(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rsp)
movl %ecx, 0x18(%rsp)
leaq 0x2bd43(%rip), %rdi     # 0x352c8
leaq 0x10(%rsp), %rsi
callq 0x9636
movq 0x50(%r15), %rax
movl $0x1, (%rax,%rbp,4)
incq %r13
jmp 0x94fb
movl $0x7fffffff, 0xc(%rsp)  # imm = 0x7FFFFFFF
leaq 0x2bd17(%rip), %rbx     # 0x352c8
movq 0x2bd10(%rip), %rax     # 0x352c8
cmpq 0x2bd11(%rip), %rax     # 0x352d0
je 0x95cb
movq %rbx, %rdi
callq 0x964c
jmp 0x95b1
movl 0xc(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2bd03(%rip), %rdi     # 0x352e8
callq 0x5430
testl %eax, %eax
je 0x944c
xorps %xmm0, %xmm0
movups %xmm0, 0x2bccc(%rip)    # 0x352c8
andq $0x0, 0x2bcd4(%rip)     # 0x352d8
leaq 0x2bcbd(%rip), %rsi     # 0x352c8
leaq 0x1e(%rip), %rdi        # 0x9630
leaq 0x2bc37(%rip), %rdx     # 0x35250
callq 0x5240
leaq 0x2bcc3(%rip), %rdi     # 0x352e8
callq 0x51a0
jmp 0x944c
nop