// File: 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:
subq $0xc8, %rsp
movb %r9b, %al
movq %rdi, 0xc0(%rsp)
movl %esi, 0xbc(%rsp)
movl %edx, 0xb8(%rsp)
movq %rcx, 0xb0(%rsp)
movq %r8, 0xa8(%rsp)
andb $0x1, %al
movb %al, 0xa7(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpb $0x0, 0x70d53(%rip)     # 0x83380
jne 0x12674
leaq 0x70d4a(%rip), %rdi     # 0x83380
callq 0x6550
cmpl $0x0, %eax
je 0x12674
leaq 0x70d19(%rip), %rdi     # 0x83360
callq 0x12970
jmp 0x1264e
leaq 0x34b(%rip), %rdi       # 0x129a0
leaq 0x70d04(%rip), %rsi     # 0x83360
leaq 0x70c85(%rip), %rdx     # 0x832e8
callq 0x62e0
leaq 0x70d11(%rip), %rdi     # 0x83380
callq 0x6210
movq 0x8(%rsp), %rax
movl $0x7fffffff, 0x90(%rsp) # imm = 0x7FFFFFFF
movq 0x50(%rax), %rdi
movslq (%rax), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x61b0
movq 0x8(%rsp), %rdi
movl $0x0, 0x78(%rsp)
movl 0xbc(%rsp), %esi
callq 0x12a90
movl %eax, 0x74(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x74(%rsp), %rsi
callq 0x12a60
movq %rax, 0x7c(%rsp)
leaq 0xbc(%rsp), %rdi
leaq 0x7c(%rsp), %rsi
callq 0x12a10
movl %edx, 0x68(%rsp)
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x84(%rsp)
movl 0x68(%rsp), %eax
movl %eax, 0x8c(%rsp)
leaq 0x70c5f(%rip), %rdi     # 0x83360
leaq 0x84(%rsp), %rsi
callq 0x129b0
movq 0x8(%rsp), %rax
movq 0x50(%rax), %rax
movslq 0xbc(%rsp), %rcx
movl $0x1, (%rax,%rcx,4)
leaq 0x70c33(%rip), %rdi     # 0x83360
callq 0x12ab0
xorb $-0x1, %al
testb $0x1, %al
jne 0x1273d
jmp 0x1292f
leaq 0x70c1c(%rip), %rdi     # 0x83360
callq 0x12ad0
movq (%rax), %rcx
movq %rcx, 0x54(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x5c(%rsp)
leaq 0x70c01(%rip), %rdi     # 0x83360
callq 0x12ae0
movl 0x54(%rsp), %eax
cmpl 0xb8(%rsp), %eax
jne 0x127a6
movl 0x58(%rsp), %eax
movl %eax, 0x90(%rsp)
jmp 0x1292f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x70be4(%rip), %rdi     # 0x83380
callq 0x6200
jmp 0x12962
movq 0x8(%rsp), %rdi
movl $0x0, 0x50(%rsp)
addq $0x28, %rdi
movslq 0x54(%rsp), %rsi
callq 0xfd50
movq %rax, %rdi
callq 0xdcb0
movl %eax, 0x4c(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jge 0x1292a
movq 0x8(%rsp), %rdi
addq $0x28, %rdi
movslq 0x54(%rsp), %rsi
callq 0xfd50
movq %rax, %rdi
movslq 0x50(%rsp), %rsi
callq 0x12b30
movq 0x8(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x48(%rsp)
movl 0x48(%rsp), %esi
movq 0xb0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
movb 0xa7(%rsp), %al
andb $0x1, %al
movzbl %al, %r8d
callq 0x12b50
testb $0x1, %al
jne 0x12835
jmp 0x12918
movq 0x8(%rsp), %rdi
addq $0x10, %rdi
movslq 0x48(%rsp), %rsi
callq 0x12bf0
movq %rax, 0x40(%rsp)
movl 0x58(%rsp), %eax
movq 0x40(%rsp), %rcx
addl 0x8(%rcx), %eax
movl %eax, 0x3c(%rsp)
movl 0x54(%rsp), %eax
movq 0x40(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jne 0x12878
movq 0x40(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x12884
movq 0x40(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, 0x38(%rsp)
movq 0x50(%rax), %rax
movslq 0x38(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x12916
movq 0x8(%rsp), %rdi
movl 0x38(%rsp), %esi
callq 0x12a90
movl %eax, 0x20(%rsp)
leaq 0x3c(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xdbe0
movq %rax, 0x24(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x24(%rsp), %rsi
callq 0x12a10
movl %edx, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x2c(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x34(%rsp)
leaq 0x70a69(%rip), %rdi     # 0x83360
leaq 0x2c(%rsp), %rsi
callq 0x129b0
movq 0x8(%rsp), %rax
movq 0x50(%rax), %rax
movslq 0x38(%rsp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x12918
jmp 0x1291a
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x127cd
jmp 0x12726
jmp 0x12931
leaq 0x70a28(%rip), %rdi     # 0x83360
callq 0x12ab0
xorb $-0x1, %al
testb $0x1, %al
jne 0x12945
jmp 0x12953
leaq 0x70a14(%rip), %rdi     # 0x83360
callq 0x12ae0
jmp 0x12931
movl 0x90(%rsp), %eax
addq $0xc8, %rsp
retq
movq 0x98(%rsp), %rdi
callq 0x6520
nop