// File: /workspace/github_cpp_makefile_star2_O1/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, %ebp
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movl %edx, %r15d
movl %esi, %r13d
movq %rdi, %r12
movb 0x33298(%rip), %al      # 0x3f2e8
testb %al, %al
je 0xc279
movq 0x50(%r12), %rdi
movslq (%r12), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x6180
movq 0x48(%r12), %rax
movslq %r13d, %rbx
movl (%rax,%rbx,4), %eax
shlq $0x20, %rax
leaq 0x10(%rsp), %rsi
movl %ebx, (%rsi)
movq %rax, 0x4(%rsi)
movq (%rsi), %rax
movl 0x8(%rsi), %ecx
movq %rax, (%rsi)
movl %ecx, 0x8(%rsi)
leaq 0x3322f(%rip), %rdi     # 0x3f2c8
callq 0xc292
movq 0x50(%r12), %rax
movl $0x1, (%rax,%rbx,4)
movl %ebp, %r10d
xorb $0x1, %r10b
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movl %ebp, 0xc(%rsp)
movl %r15d, 0x20(%rsp)
movb %r10b, 0x7(%rsp)
movq 0x331fc(%rip), %rax     # 0x3f2c8
cmpq 0x331fd(%rip), %rax     # 0x3f2d0
je 0xc236
movslq (%rax), %rbx
movl 0x4(%rax), %ebp
leaq 0x331e2(%rip), %rdi     # 0x3f2c8
callq 0xc2fc
cmpl %r15d, %ebx
je 0xc228
movl %r14d, 0x8(%rsp)
movq 0x28(%r12), %rax
leaq (%rbx,%rbx,2), %r13
movq 0x8(%rax,%r13,8), %r14
subq (%rax,%r13,8), %r14
shrq $0x2, %r14
testl %r14d, %r14d
movq 0x30(%rsp), %r8
movq 0x28(%rsp), %r9
jle 0xc224
movl %ebp, 0x24(%rsp)
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorl %ebp, %ebp
movl 0xc(%rsp), %edi
movb 0x7(%rsp), %r10b
movq 0x28(%r12), %rax
movq (%rax,%r13,8), %rax
movslq (%rax,%rbp,4), %rcx
movl %ecx, %eax
sarl $0x5, %eax
movl $0x1, %edx
shll %cl, %edx
movslq %eax, %rsi
movl (%r9,%rsi,4), %eax
btl %ecx, %eax
setae %al
jae 0xc170
testl %edx, (%r8,%rsi,4)
sete %dl
movl %edx, %esi
orb %r10b, %sil
je 0xc179
jmp 0xc17b
testb %dil, %dil
je 0xc20d
movl %eax, %edx
testb %dl, %dl
je 0xc20d
shlq $0x4, %rcx
movq 0x10(%r12), %rax
movl 0x4(%rax,%rcx), %edx
cmpl %edx, %ebx
jne 0xc197
movl (%rax,%rcx), %edx
movq 0x50(%r12), %rsi
movslq %edx, %r15
cmpl $0x0, (%rsi,%r15,4)
jne 0xc20d
addq %rcx, %rax
movl 0x8(%rax), %eax
addl 0x24(%rsp), %eax
movq 0x48(%r12), %rcx
movl (%rcx,%r15,4), %ecx
shlq $0x20, %rcx
orq %rcx, %rax
movl %r15d, 0x10(%rsp)
movq %rax, 0x14(%rsp)
movq 0x10(%rsp), %rax
movl 0x18(%rsp), %ecx
movq %rax, 0x10(%rsp)
movl %ecx, 0x18(%rsp)
leaq 0x330e5(%rip), %rdi     # 0x3f2c8
leaq 0x10(%rsp), %rsi
callq 0xc292
movb 0x7(%rsp), %r10b
movq 0x28(%rsp), %r9
movq 0x30(%rsp), %r8
movl 0xc(%rsp), %edi
movq 0x50(%r12), %rax
movl $0x1, (%rax,%r15,4)
incq %rbp
cmpq %rbp, %r14
jne 0xc138
movl 0x8(%rsp), %ebp
movl 0x20(%rsp), %r15d
jmp 0xc228
movl 0x8(%rsp), %ebp
movl %ebp, %r14d
cmpl %r15d, %ebx
jne 0xc0c5
jmp 0xc239
movl %r14d, %ebp
movq 0x33088(%rip), %rax     # 0x3f2c8
cmpq 0x33089(%rip), %rax     # 0x3f2d0
je 0xc268
leaq 0x33078(%rip), %rbx     # 0x3f2c8
movq %rbx, %rdi
callq 0xc2fc
movq 0x33069(%rip), %rax     # 0x3f2c8
cmpq 0x3306a(%rip), %rax     # 0x3f2d0
jne 0xc250
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x64fb
jmp 0xc058
nop