// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rdi, 0x30(%rsp)
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, %rbp # imm = 0xEEEEEEEEEEEEEEEF
imulq %rax, %rbp
movl %ebp, %r14d
leaq 0xf(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x38(%rsp), %rdi
leaq 0xe(%rsp), %rcx
movq %r14, %rsi
callq 0x15a1c
movq %rbx, 0x60(%rsp)
testl %ebp, %ebp
je 0x153c3
addq $0x8, %r12
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
movl $0x70, %ebx
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x10(%rsp), %rax
leaq (%rax,%rbx), %rsi
addq $-0x70, %rsi
movq %r12, %rdi
callq 0x1069e
testq %rax, %rax
je 0x1535e
movq 0x78(%rax), %rax
movb 0x4(%rax), %dil
jmp 0x15360
xorl %edi, %edi
movq 0x38(%rsp), %rax
movq %r13, %rdx
shrq $0x6, %rdx
movl $0x1, %esi
movl %r13d, %ecx
shlq %cl, %rsi
testb %dil, %dil
je 0x15385
movq (%rax,%rdx,8), %rcx
orq %rsi, %rcx
jmp 0x1538f
movq %rsi, %rcx
notq %rcx
andq (%rax,%rdx,8), %rcx
movq %rcx, (%rax,%rdx,8)
testq %rsi, %rcx
je 0x153b1
movq 0x10(%rsp), %rax
movss 0x8(%rsp), %xmm0
addss (%rax,%rbx), %xmm0
movss %xmm0, 0x8(%rsp)
incq %r15
incq %r13
addq $0x78, %rbx
cmpq %r13, %r14
jne 0x1533a
jmp 0x153cf
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
xorl %r15d, %r15d
subq %r15, %r14
je 0x154bb
callq 0x6250
testl %ebp, %ebp
je 0x15458
movss 0x17c1f(%rip), %xmm1    # 0x2d008
movaps %xmm1, %xmm2
subss 0x8(%rsp), %xmm2
cvtsd2ss %xmm0, %xmm0
movq 0x38(%rsp), %rax
movq 0x10(%rsp), %rdx
movl %ebp, %esi
divss %xmm2, %xmm1
movl $0x70, %edi
xorl %ecx, %ecx
movl $0x1, %r8d
shlq %cl, %r8
movq %rcx, %r9
shrq $0x6, %r9
andq (%rax,%r9,8), %r8
jne 0x1544c
cmpq $0x1, %r14
je 0x15477
movss (%rdx,%rdi), %xmm2
mulss %xmm1, %xmm2
ucomiss %xmm2, %xmm0
jbe 0x15477
testq %r8, %r8
jne 0x1544c
decq %r14
movss (%rdx,%rdi), %xmm2
mulss %xmm1, %xmm2
subss %xmm2, %xmm0
incq %rcx
addq $0x78, %rdi
cmpq %rcx, %rsi
jne 0x1540d
leaq 0x18c6e(%rip), %rdi     # 0x2e0cd
leaq 0x18209(%rip), %rsi     # 0x2d66f
leaq 0x18948(%rip), %rcx     # 0x2ddb5
movl $0xc5, %edx
callq 0x61c0
movq 0x10(%rsp), %rax
leaq (%rax,%rdi), %rsi
addq $-0x70, %rsi
xorps %xmm0, %xmm0
movq 0x30(%rsp), %r14
movups %xmm0, 0x34(%r14)
movups %xmm0, 0x24(%r14)
movups %xmm0, 0x14(%r14)
movups %xmm0, 0x4(%r14)
xorl %eax, %eax
movq %rax, 0x44(%r14)
movb $0x1, 0x5c(%r14)
movq %rax, 0x60(%r14)
movb $0x1, %bl
movq %r14, %rdi
callq 0xd546
jmp 0x154f3
xorps %xmm0, %xmm0
movq 0x30(%rsp), %r14
movups %xmm0, 0x34(%r14)
movups %xmm0, 0x24(%r14)
movups %xmm0, 0x14(%r14)
movups %xmm0, 0x4(%r14)
xorl %ebx, %ebx
movq %rbx, 0x44(%r14)
movb $0x1, 0x5c(%r14)
movq %rbx, 0x60(%r14)
movq %r14, %rdi
movq 0x60(%rsp), %rsi
callq 0xd546
movb %bl, 0x70(%r14)
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1551f
callq 0x6260
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movl %eax, 0x50(%rsp)
movq %rax, 0x58(%rsp)
leaq 0x10(%rsp), %rdi
callq 0xe35c
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15546
jmp 0x15546
jmp 0x15541
movq %rax, %rbx
jmp 0x15571
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x15571
callq 0x6260
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movl %eax, 0x50(%rsp)
movq %rax, 0x58(%rsp)
leaq 0x10(%rsp), %rdi
callq 0xe35c
movq %rbx, %rdi
callq 0x6410