// File: bonetblai[P]mdp-engine/ctp3/../engine/problem.h
// Function: Problem::problem_t<state_t>::nsample(state_t const&, int, Problem::hash_t<state_t> const&) const
std::pair<T, bool> nsample(const T &s, action_t a, const hash_t<T> &hash) const {
        std::vector<std::pair<T, float> > outcomes;
        next(s, a, outcomes);
        unsigned osize = outcomes.size();
        std::vector<bool> label(osize, false);

        size_t n = 0;
        float mass = 0;
        for( unsigned i = 0; i < osize; ++i ) {
            if( (label[i] = hash.solved(outcomes[i].first)) ) {
                mass += outcomes[i].second;
                ++n;
            }
        }

        mass = 1.0 - mass;
        n = osize - n;
        if( n == 0 ) return std::make_pair(s, false);

        float d = Random::real();
        for( unsigned i = 0; i < osize; ++i ) {
            if( !label[i] && ((n == 1) || (d <= outcomes[i].second / mass)) ) {
                return std::make_pair(outcomes[i].first, true);
            } else if( !label[i] ) {
                --n;
                d -= outcomes[i].second / mass;
            }
        }
        assert(0);
        return std::make_pair(s, false);
    }

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x60(%rsp)
movq %rdi, %rax
movq %rax, 0x68(%rsp)
movq %rdi, 0x150(%rsp)
movq %rsi, 0x148(%rsp)
movq %rdx, 0x140(%rsp)
movl %ecx, 0x13c(%rsp)
movq %r8, 0x130(%rsp)
movq 0x148(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x118(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x1a4a0
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rcx
movq 0x140(%rsp), %rsi
movl 0x13c(%rsp), %edx
movq (%rdi), %rax
movq 0x60(%rax), %rax
callq *%rax
jmp 0x2a9ee
leaq 0x118(%rsp), %rdi
callq 0x17030
movl %eax, 0x108(%rsp)
movl 0x108(%rsp), %eax
movq %rax, 0x50(%rsp)
movb $0x0, 0xdf(%rsp)
leaq 0xde(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x2b9b0
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rcx
leaq 0xe0(%rsp), %rdi
leaq 0xdf(%rsp), %rdx
callq 0x2b9c0
jmp 0x2aa49
leaq 0xde(%rsp), %rdi
callq 0x2ba40
movq $0x0, 0xd0(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0xcc(%rsp)
movl $0x0, 0xc8(%rsp)
movl 0xc8(%rsp), %eax
cmpl 0x108(%rsp), %eax
jae 0x2abe7
movq 0x130(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0xc8(%rsp), %eax
movl %eax, %esi
leaq 0x118(%rsp), %rdi
callq 0x1a4b0
movq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x26410
movb %al, 0x4f(%rsp)
jmp 0x2aac3
movl 0xc8(%rsp), %eax
movl %eax, %esi
leaq 0xe0(%rsp), %rdi
callq 0x2ba50
movq %rdx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
jmp 0x2aae5
movb 0x4f(%rsp), %al
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq %rdx, 0xb8(%rsp)
movq %rcx, 0xc0(%rsp)
movzbl %al, %esi
andl $0x1, %esi
leaq 0xb8(%rsp), %rdi
callq 0x2bab0
movq %rax, %rdi
callq 0x2bb00
testb $0x1, %al
jne 0x2ab27
jmp 0x2abcf
movl 0xc8(%rsp), %eax
movl %eax, %esi
leaq 0x118(%rsp), %rdi
callq 0x1a4b0
movss 0x70(%rax), %xmm0
addss 0xcc(%rsp), %xmm0
movss %xmm0, 0xcc(%rsp)
movq 0xd0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd0(%rsp)
jmp 0x2abcf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
jmp 0x2ae9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
leaq 0xde(%rsp), %rdi
callq 0x2ba40
jmp 0x2ae9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x2bb70
jmp 0x2ae9c
jmp 0x2abd1
movl 0xc8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc8(%rsp)
jmp 0x2aa79
movss 0xcc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x32454(%rip), %xmm0    # 0x5d050
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xcc(%rsp)
movl 0x108(%rsp), %eax
subq 0xd0(%rsp), %rax
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0xd0(%rsp)
jne 0x2ac63
movq 0x60(%rsp), %rdi
movq 0x140(%rsp), %rsi
movb $0x0, 0xb7(%rsp)
leaq 0xb7(%rsp), %rdx
callq 0x2bb30
jmp 0x2ac53
movl $0x1, 0xb0(%rsp)
jmp 0x2ae75
callq 0x19b50
movss %xmm0, 0x2c(%rsp)
jmp 0x2ac70
movss 0x2c(%rsp), %xmm0
movss %xmm0, 0xac(%rsp)
movl $0x0, 0xa8(%rsp)
movl 0xa8(%rsp), %eax
cmpl 0x108(%rsp), %eax
jae 0x2ae56
movl 0xa8(%rsp), %eax
movl %eax, %esi
leaq 0xe0(%rsp), %rdi
callq 0x2ba50
movq %rdx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x2acc0
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x98(%rsp)
movq %rax, 0xa0(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x2bb00
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x17(%rsp)
jne 0x2ad50
movb $0x1, %al
cmpq $0x1, 0xd0(%rsp)
movb %al, 0x16(%rsp)
je 0x2ad48
movss 0xac(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
movl 0xa8(%rsp), %eax
movl %eax, %esi
leaq 0x118(%rsp), %rdi
callq 0x1a4b0
movss 0x10(%rsp), %xmm1
movss 0x70(%rax), %xmm0
divss 0xcc(%rsp), %xmm0
ucomiss %xmm1, %xmm0
setae %al
movb %al, 0x16(%rsp)
movb 0x16(%rsp), %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x2ad5a
jmp 0x2ad9f
movl 0xa8(%rsp), %eax
movl %eax, %esi
leaq 0x118(%rsp), %rdi
callq 0x1a4b0
movq 0x60(%rsp), %rdi
movq %rax, %rsi
movb $0x1, 0x97(%rsp)
leaq 0x97(%rsp), %rdx
callq 0x1a4d0
jmp 0x2ad8f
movl $0x1, 0xb0(%rsp)
jmp 0x2ae75
movl 0xa8(%rsp), %eax
movl %eax, %esi
leaq 0xe0(%rsp), %rdi
callq 0x2ba50
movq %rdx, (%rsp)
movq %rax, 0x8(%rsp)
jmp 0x2adc0
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movq %rax, 0x88(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x2bb00
xorb $-0x1, %al
testb $0x1, %al
jne 0x2adee
jmp 0x2ae3c
movq 0xd0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0xd0(%rsp)
movl 0xa8(%rsp), %eax
movl %eax, %esi
leaq 0x118(%rsp), %rdi
callq 0x1a4b0
movss 0x70(%rax), %xmm1
divss 0xcc(%rsp), %xmm1
movss 0xac(%rsp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0xac(%rsp)
jmp 0x2ae3e
jmp 0x2ae40
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x2ac8a
leaq 0x33200(%rip), %rdi     # 0x5e05d
leaq 0x3279b(%rip), %rsi     # 0x5d5ff
movl $0xc5, %edx
leaq 0x32ed5(%rip), %rcx     # 0x5dd45
callq 0x6220
leaq 0xe0(%rsp), %rdi
callq 0x2bb70
leaq 0x118(%rsp), %rdi
callq 0x1a510
movq 0x68(%rsp), %rax
addq $0x158, %rsp            # imm = 0x158
retq
leaq 0x118(%rsp), %rdi
callq 0x1a510
movq 0x110(%rsp), %rdi
callq 0x6520
nopw %cs:(%rax,%rax)