// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, %r12
movq %rdx, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq (%rsi), %r8
movq %rsi, %rdi
movq %rdx, %rsi
movl %ecx, %edx
movq %rax, %rcx
callq *0x60(%r8)
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x3, %rax
movabsq $-0x1111111111111111, %r13 # imm = 0xEEEEEEEEEEEEEEEF
imulq %rax, %r13
movl %r13d, %r14d
leaq 0xf(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0xe(%rsp), %rcx
movq %r14, %rsi
callq 0x14638
movq %r15, 0x30(%rsp)
movq %r13, 0x38(%rsp)
testl %r13d, %r13d
je 0x1404c
addq $0x8, %r12
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
movl $0x70, %ebp
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x10(%rsp), %rax
leaq (%rax,%rbp), %rsi
addq $-0x70, %rsi
movq %r12, %rdi
callq 0xf446
testq %rax, %rax
je 0x13ff7
movq 0x78(%rax), %rsi
movl %r13d, %eax
shrl $0x3, %eax
andl $-0x8, %eax
movl $0x1, %edx
movl %r13d, %ecx
shlq %cl, %rdx
addq 0x40(%rsp), %rax
cmpb $0x1, 0x4(%rsi)
jne 0x14010
movq (%rax), %rcx
orq %rdx, %rcx
jmp 0x14019
movl %r13d, %eax
shrl $0x3, %eax
andl $-0x8, %eax
addq 0x40(%rsp), %rax
movl $0x1, %edx
movl %r13d, %ecx
shlq %cl, %rdx
movq %rdx, %rcx
notq %rcx
andq (%rax), %rcx
movq %rcx, (%rax)
testq %rdx, %rcx
je 0x1403a
movq 0x10(%rsp), %rax
movss 0x8(%rsp), %xmm0
addss (%rax,%rbp), %xmm0
movss %xmm0, 0x8(%rsp)
incq %r15
incq %r13
addq $0x78, %rbp
cmpq %r13, %r14
jne 0x13fb2
jmp 0x14058
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
xorl %r15d, %r15d
movq %r14, %r12
subq %r15, %r12
je 0x14118
callq 0x5250
cmpl $0x0, 0x38(%rsp)
je 0x140cb
movss 0x16f90(%rip), %xmm1    # 0x2b008
movaps %xmm1, %xmm2
subss 0x8(%rsp), %xmm2
cvtsd2ss %xmm0, %xmm0
movq 0x40(%rsp), %rax
movq 0x10(%rsp), %rsi
divss %xmm2, %xmm1
xorl %ecx, %ecx
movl %ecx, %edx
shrl $0x6, %edx
movq (%rax,%rdx,8), %rdx
btq %rcx, %rdx
jb 0x140bf
cmpq $0x1, %r12
je 0x140ea
movss 0x70(%rsi), %xmm2
mulss %xmm1, %xmm2
ucomiss %xmm2, %xmm0
jbe 0x140ea
decq %r12
subss %xmm2, %xmm0
incq %rcx
addq $0x78, %rsi
cmpq %rcx, %r14
jne 0x14095
leaq 0x17fb8(%rip), %rdi     # 0x2c08a
leaq 0x17591(%rip), %rsi     # 0x2b66a
leaq 0x17cd0(%rip), %rcx     # 0x2bdb0
movl $0xc5, %edx
callq 0x51c0
xorps %xmm0, %xmm0
movups %xmm0, 0x34(%rbx)
movups %xmm0, 0x24(%rbx)
movups %xmm0, 0x14(%rbx)
movups %xmm0, 0x4(%rbx)
xorl %eax, %eax
movq %rax, 0x44(%rbx)
movb $0x1, 0x5c(%rbx)
movq %rax, 0x60(%rbx)
movb $0x1, %r14b
movq %rbx, %rdi
callq 0xc30a
jmp 0x14147
xorps %xmm0, %xmm0
movups %xmm0, 0x34(%rbx)
movups %xmm0, 0x24(%rbx)
movups %xmm0, 0x14(%rbx)
movups %xmm0, 0x4(%rbx)
xorl %r14d, %r14d
movq %r14, 0x44(%rbx)
movb $0x1, 0x5c(%rbx)
movq %r14, 0x60(%rbx)
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0xc30a
movb %r14b, 0x70(%rbx)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1415a
callq 0x5260
leaq 0x10(%rsp), %rdi
callq 0xd12e
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14181
jmp 0x14181
jmp 0x1417c
movq %rax, %rbx
jmp 0x14193
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x14193
callq 0x5260
leaq 0x10(%rsp), %rdi
callq 0xd12e
movq %rbx, %rdi
callq 0x5410