// File: bonetblai[P]mdp-engine/ctp3/./ctp3.h
// Function: problem_t::next(state_t const&, int, std::vector<std::pair<state_t, float>, std::allocator<std::pair<state_t, float>>>&) const
virtual void next(const state_t &s,
                      Problem::action_t a,
                      std::vector<std::pair<state_t, float> > &outcomes) const {

        if( use_cache_ ) {
            const std::vector<std::pair<state_t, float> > *ptr = next_cache_.lookup(s, a);
            if( ptr != 0 ) {
                outcomes = *ptr;
                return;
            }
        }

        //std::cout << "next" << s << " w/ a=" << a << " is:" << std::endl;

        ++expansions_;

        int to_node = -1;
        if( s.current_ == -1 ) {
            to_node = start_;
        } else {
            to_node = a;
            assert(to_node != s.current_);
        }

        // collect edges adjacent at to_node of unknown status
        int k = 0;
        std::vector<int> unknown_edges;
        unknown_edges.reserve(graph_.num_edges_);
        for( int i = 0, isz = graph_.at_[to_node].size(); i < isz; ++i ) {
            int e = graph_.at_[to_node][i];
            if( !s.known(e) ) {
                unknown_edges.push_back(e);
                ++k;
            }
        }
        max_branching_ = (1<<k) > max_branching_ ? (1<<k) : max_branching_;
        avg_branching_ = (expansions_ - 1) * avg_branching_ + (float)(1<<k);
        avg_branching_ /= (float)expansions_;

        // generate subsets of unknowns edges and update weathers
        outcomes.clear();
        outcomes.reserve(1 << k);
        for( int i = 0, isz = 1 << k; i < isz; ++i ) {
            state_t next(s);
            float p = 1;
            int subset = i;
            for( int j = 0; j < k; ++j ) {
                int e = unknown_edges[j];
                p *= (subset & 1) ? 1 - graph_.prob(e) : graph_.prob(e);
                next.info_.set_edge_status(e, subset & 1);
                subset = subset >> 1;
            }
            next.move_to(to_node);
            next.heuristic_ = -1;
            if( next.shared_ ) {
                next.distances_ = 0;
            } else {
                assert(next.distances_ != 0);
                delete[] next.distances_;
                next.distances_ = 0;
                next.shared_ = true;
            }
            assert(next.distances_ == 0);
            if( p > 0 ) {
                //next.preprocess();
                outcomes.push_back(std::make_pair(next, p));
                //std::cout << "    " << next << " w.p. " << p << std::endl;
            }
        }

        if( use_cache_ ) next_cache_.insert(s, a, outcomes);
    }

// Assembly:
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, 0x1a0(%rsp)
movq %rsi, 0x198(%rsp)
movl %edx, 0x194(%rsp)
movq %rcx, 0x188(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x40(%rsp)
testb $0x1, 0xa0(%rax)
je 0x1183b
movq 0x40(%rsp), %rdi
addq $0xa8, %rdi
movq 0x198(%rsp), %rsi
movl 0x194(%rsp), %edx
callq 0x16030
movq %rax, 0x180(%rsp)
cmpq $0x0, 0x180(%rsp)
je 0x11839
movq 0x180(%rsp), %rsi
movq 0x188(%rsp), %rdi
callq 0x160f0
jmp 0x11e7f
jmp 0x1183b
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movl $0xffffffff, 0x17c(%rsp) # imm = 0xFFFFFFFF
movq 0x198(%rsp), %rax
cmpl $-0x1, (%rax)
jne 0x11878
movq 0x40(%rsp), %rax
movl 0x90(%rax), %eax
movl %eax, 0x17c(%rsp)
jmp 0x118bc
movl 0x194(%rsp), %eax
movl %eax, 0x17c(%rsp)
movl 0x17c(%rsp), %eax
movq 0x198(%rsp), %rcx
cmpl (%rcx), %eax
je 0x1189b
jmp 0x118ba
leaq 0x4bbf2(%rip), %rdi     # 0x5d494
leaq 0x4bbc1(%rip), %rsi     # 0x5d46a
movl $0x25e, %edx            # imm = 0x25E
leaq 0x4bbf5(%rip), %rcx     # 0x5d4aa
callq 0x6220
jmp 0x118bc
movl $0x0, 0x178(%rsp)
leaq 0x160(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xe840
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %rdi
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rsi
callq 0x163b0
jmp 0x118f2
movq 0x40(%rsp), %rax
movl $0x0, 0x150(%rsp)
movq 0x18(%rax), %rdi
addq $0x28, %rdi
movslq 0x17c(%rsp), %rsi
callq 0xfd50
movq %rax, %rdi
callq 0xdcb0
movl %eax, 0x14c(%rsp)
movl 0x150(%rsp), %eax
cmpl 0x14c(%rsp), %eax
jge 0x119ec
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
addq $0x28, %rdi
movslq 0x17c(%rsp), %rsi
callq 0xfd50
movq %rax, %rdi
movslq 0x150(%rsp), %rsi
callq 0x12b30
movl (%rax), %eax
movl %eax, 0x148(%rsp)
movq 0x198(%rsp), %rdi
movl 0x148(%rsp), %esi
callq 0x164c0
movb %al, 0x37(%rsp)
jmp 0x11987
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x119d4
jmp 0x11991
leaq 0x160(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0xedb0
jmp 0x119a8
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
jmp 0x119d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x11e87
jmp 0x119d6
movl 0x150(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x150(%rsp)
jmp 0x11926
movl 0x178(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movq 0x40(%rsp), %rcx
cmpl 0x98(%rcx), %eax
jle 0x11a1b
movl 0x178(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, 0x30(%rsp)
jmp 0x11a2a
movq 0x40(%rsp), %rax
movl 0x98(%rax), %eax
movl %eax, 0x30(%rsp)
movq 0x40(%rsp), %rax
movl 0x30(%rsp), %ecx
movl %ecx, 0x98(%rax)
movq 0x10(%rax), %rax
decq %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, 0x28(%rsp)
testq %rax, %rax
movss %xmm0, 0x2c(%rsp)
js 0x11a79
movss 0x28(%rsp), %xmm0
movss %xmm0, 0x2c(%rsp)
movq 0x40(%rsp), %rax
movss 0x2c(%rsp), %xmm0
movss 0x9c(%rax), %xmm1
mulss %xmm1, %xmm0
movb 0x178(%rsp), %cl
movl $0x1, %edx
movl %edx, 0x1c(%rsp)
shll %cl, %edx
movl %edx, %ecx
cvtsi2ss %ecx, %xmm1
addss %xmm1, %xmm0
movss %xmm0, 0x9c(%rax)
movq 0x10(%rax), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, 0x20(%rsp)
testq %rax, %rax
movss %xmm0, 0x24(%rsp)
js 0x11af1
movss 0x20(%rsp), %xmm0
movss %xmm0, 0x24(%rsp)
movq 0x40(%rsp), %rax
movss 0x24(%rsp), %xmm1
movss 0x9c(%rax), %xmm0
divss %xmm1, %xmm0
movss %xmm0, 0x9c(%rax)
movq 0x188(%rsp), %rdi
callq 0x164f0
movl 0x1c(%rsp), %eax
movq 0x188(%rsp), %rdi
movb 0x178(%rsp), %cl
shll %cl, %eax
movslq %eax, %rsi
callq 0x16510
jmp 0x11b3c
movl $0x0, 0x144(%rsp)
movl 0x178(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, 0x140(%rsp)
movl 0x144(%rsp), %eax
cmpl 0x140(%rsp), %eax
jge 0x11e38
movq 0x198(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x16650
jmp 0x11b87
movss 0x4b475(%rip), %xmm0    # 0x5d004
movss %xmm0, 0xcc(%rsp)
movl 0x144(%rsp), %eax
movl %eax, 0xc8(%rsp)
movl $0x0, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
cmpl 0x178(%rsp), %eax
jge 0x11ccf
movslq 0xc4(%rsp), %rsi
leaq 0x160(%rsp), %rdi
callq 0xdcf0
movl (%rax), %eax
movl %eax, 0xc0(%rsp)
movl 0xc8(%rsp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x11c29
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0xc0(%rsp), %esi
callq 0x166c0
movss %xmm0, 0x18(%rsp)
jmp 0x11c0f
movss 0x18(%rsp), %xmm1
movss 0x4b3e7(%rip), %xmm0    # 0x5d004
subss %xmm1, %xmm0
movss %xmm0, 0x14(%rsp)
jmp 0x11c54
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0xc0(%rsp), %esi
callq 0x166c0
movss %xmm0, 0x10(%rsp)
jmp 0x11c46
movss 0x10(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
jmp 0x11c54
movss 0x14(%rsp), %xmm1
movss 0xcc(%rsp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, 0xcc(%rsp)
leaq 0xd4(%rsp), %rdi
movl 0xc0(%rsp), %esi
movl 0xc8(%rsp), %edx
andl $0x1, %edx
callq 0x166f0
jmp 0x11c90
movl 0xc8(%rsp), %eax
sarl %eax
movl %eax, 0xc8(%rsp)
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0x11bb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x11e29
movl 0x17c(%rsp), %esi
leaq 0xd0(%rsp), %rdi
callq 0x16780
jmp 0x11ce5
movl $0xffffffff, 0x138(%rsp) # imm = 0xFFFFFFFF
testb $0x1, 0x12c(%rsp)
je 0x11d08
movq $0x0, 0x130(%rsp)
jmp 0x11d65
cmpq $0x0, 0x130(%rsp)
je 0x11d15
jmp 0x11d34
leaq 0x4b7ff(%rip), %rdi     # 0x5d51b
leaq 0x4b747(%rip), %rsi     # 0x5d46a
movl $0x282, %edx            # imm = 0x282
leaq 0x4b77b(%rip), %rcx     # 0x5d4aa
callq 0x6220
movq 0x130(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x11d51
movq 0x8(%rsp), %rdi
callq 0x6420
movq $0x0, 0x130(%rsp)
movb $0x1, 0x12c(%rsp)
cmpq $0x0, 0x130(%rsp)
jne 0x11d72
jmp 0x11d91
leaq 0x4b7b7(%rip), %rdi     # 0x5d530
leaq 0x4b6ea(%rip), %rsi     # 0x5d46a
movl $0x287, %edx            # imm = 0x287
leaq 0x4b71e(%rip), %rcx     # 0x5d4aa
callq 0x6220
movss 0xcc(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x11e06
movq 0x188(%rsp), %rax
movq %rax, (%rsp)
leaq 0x48(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0xcc(%rsp), %rdx
callq 0x16800
jmp 0x11dca
movq (%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x167d0
jmp 0x11dda
leaq 0x48(%rsp), %rdi
callq 0x16840
jmp 0x11e06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x16840
jmp 0x11e29
leaq 0xd0(%rsp), %rdi
callq 0x115b0
movl 0x144(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x144(%rsp)
jmp 0x11b5c
leaq 0xd0(%rsp), %rdi
callq 0x115b0
jmp 0x11e87
movq 0x40(%rsp), %rax
testb $0x1, 0xa0(%rax)
je 0x11e72
movq 0x40(%rsp), %rdi
addq $0xa8, %rdi
movq 0x198(%rsp), %rsi
movl 0x194(%rsp), %edx
movq 0x188(%rsp), %rcx
callq 0x16850
jmp 0x11e70
jmp 0x11e72
leaq 0x160(%rsp), %rdi
callq 0xdfb0
addq $0x1a8, %rsp            # imm = 0x1A8
retq
leaq 0x160(%rsp), %rdi
callq 0xdfb0
movq 0x158(%rsp), %rdi
callq 0x6520
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)