// File: /workspace/github_cpp_makefile_star2_O3/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, 0x24(%rsp)
movq %r8, 0x28(%rsp)
movq %rcx, %r15
movl %edx, 0x20(%rsp)
movl %esi, %ebp
movq %rdi, %r12
movb 0x32464(%rip), %al      # 0x3d2e8
testb %al, %al
je 0xb084
movq 0x50(%r12), %rdi
movslq (%r12), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x5180
movq 0x48(%r12), %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 0x323fb(%rip), %rdi     # 0x3d2c8
callq 0xb09c
movq 0x50(%r12), %rax
movl $0x1, (%rax,%rbx,4)
movq 0x323e3(%rip), %rcx     # 0x3d2c8
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq 0x323df(%rip), %rcx     # 0x3d2d0
je 0xb075
movq %r15, 0x30(%rsp)
movslq (%rcx), %rbx
movl 0x4(%rcx), %eax
movl %eax, 0xc(%rsp)
leaq 0x323bb(%rip), %rdi     # 0x3d2c8
callq 0xb10c
movq %rbx, %r8
cmpl 0x20(%rsp), %r8d
je 0xb042
movq 0x28(%r12), %rax
leaq (%r8,%r8,2), %rbp
movq 0x8(%rax,%rbp,8), %r10
subq (%rax,%rbp,8), %r10
shrq $0x2, %r10
testl %r10d, %r10d
movq 0x28(%rsp), %rdi
jle 0xb027
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movq 0x28(%r12), %rax
movq (%rax,%rbp,8), %rax
movslq (%rax,%r14,4), %rcx
movl %ecx, %edx
movl $0x1, %eax
shll %cl, %eax
sarl $0x5, %edx
movslq %edx, %rdx
movl (%r15,%rdx,4), %esi
btl %ecx, %esi
jae 0xaf7e
testl %eax, (%rdi,%rdx,4)
jne 0xb01b
jmp 0xaf89
cmpb $0x0, 0x24(%rsp)
je 0xb01b
shlq $0x4, %rcx
movq 0x10(%r12), %rax
movl 0x4(%rax,%rcx), %edx
cmpl %edx, %r8d
jne 0xaf9e
movl (%rax,%rcx), %edx
movq 0x50(%r12), %rsi
movslq %edx, %r13
cmpl $0x0, (%rsi,%r13,4)
jne 0xb01b
addq %rcx, %rax
movl 0x8(%rax), %eax
addl 0xc(%rsp), %eax
movq 0x48(%r12), %rcx
movl (%rcx,%r13,4), %ecx
movq %rcx, %rdx
shlq $0x20, %rdx
orq %rdx, %rax
movl %r13d, 0x10(%rsp)
movq %rax, 0x14(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rsp)
movl %ecx, 0x18(%rsp)
leaq 0x322df(%rip), %rdi     # 0x3d2c8
leaq 0x10(%rsp), %rsi
movq %r8, %r15
movq %r12, %rbx
movq %r10, %r12
callq 0xb09c
movq %r12, %r10
movq %rbx, %r12
movq %r15, %r8
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %rdi
movq 0x50(%rbx), %rax
movl $0x1, (%rax,%r13,4)
incq %r14
cmpq %r14, %r10
jne 0xaf4e
movq 0x3229a(%rip), %rcx     # 0x3d2c8
cmpq 0x3229b(%rip), %rcx     # 0x3d2d0
jne 0xaefc
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
jmp 0xb075
movq 0x3227f(%rip), %rax     # 0x3d2c8
cmpq 0x32280(%rip), %rax     # 0x3d2d0
je 0xb071
leaq 0x3226f(%rip), %rbx     # 0x3d2c8
movq %rbx, %rdi
callq 0xb10c
movq 0x32260(%rip), %rax     # 0x3d2c8
cmpq 0x32261(%rip), %rax     # 0x3d2d0
jne 0xb059
movl 0xc(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x54ed
jmp 0xae8c