// File: /workspace/github_cpp_makefile_star2_O3/bonetblai[P]mdp-engine/ctp3/../engine/simple_astar.h
// Function: Algorithm::simple_astar_t<state_t>::solve(state_t const&, Problem::hash_t<state_t>&) const
virtual void solve(const T &s, Problem::hash_t<T> &hash) const {
        reset_stats(hash);
        Heuristic::wrapper_t<T> eval_function(heuristic_);
        hash.set_eval_function(&eval_function);

        priority_queue_t open;
        std::vector<std::pair<T, float> > outcomes;

        Hash::data_t *dptr = hash.data_ptr(s);
        dptr->set_g(0);
        dptr->set_parent(0);
        dptr->set_action(Problem::noop);
        dptr->mark();
        open.push(std::make_pair(s, dptr));

#ifdef DEBUG
        std::cout << "PUSH " << "state" ///s
                  << " w/ g=" << dptr->g()
                  << " and h=" << dptr->h()
                  << " => f=" << dptr->f()
                  << std::endl;
        std::cout << "queue.sz=" << open.size() << std::endl;
#endif

        while( !open.empty() ) {
            std::pair<T, Hash::data_t*> n = open.top();
            open.pop();

#ifdef DEBUG
            std::cout << "POP  " << "state: " << n.first
                      << " w/ g=" << n.second->g()
                      << " and h=" << n.second->h()
                      << " => f=" << n.second->f()
                      << std::endl;
            std::cout << "queue.sz=" << open.size() << std::endl;

            std::vector<const Hash::data_t*> path;
            path.reserve(n.second->g());
            for( const Hash::data_t *dptr = n.second; dptr != 0; dptr = dptr->parent() )
                path.push_back(dptr);

            std::cout << "path=<";
            for( size_t i = path.size() - 1; i > 0; --i )
                std::cout << path[i-1]->action() << ",";
            std::cout << ">" << std::endl;
#endif

            // check for termination
            if( problem_.terminal(n.first) ) {
#ifdef DEBUG
                std::cout << "GOAL FOUND!" << std::endl;
#endif

                std::vector<const Hash::data_t*> plan;
                plan.reserve(n.second->g());
                for( const Hash::data_t *dptr = n.second; dptr != 0; dptr = dptr->parent() )
                    plan.push_back(dptr);

                std::cout << "plan=<";
                for( size_t i = plan.size() - 1; i > 0; --i )
                    std::cout << plan[i-1]->action() << ",";
                std::cout << ">:" << plan.size() - 1 << std::endl;

                //return (int)n.second->g(); // NEED FIX
            }

            // expand state
            for( Problem::action_t a = 0; a < problem_.number_actions(n.first); ++a ) {
                if( problem_.applicable(n.first, a) ) {
                    problem_.next(n.first, a, outcomes);
                    assert(outcomes.size() == 1);
                    Hash::data_t *ptr = hash.data_ptr(outcomes[0].first);
                    float g = n.second->g() + problem_.cost(n.first, a);
                    if( !ptr->marked() || (g + ptr->h() < ptr->f()) ) {
                        ptr->set_g(g);
                        ptr->set_parent(n.second);
                        ptr->set_action(a);
                        ptr->mark();
                        open.push(std::make_pair(outcomes[0].first, ptr));
#ifdef DEBUG
                        std::cout << "PUSH " << "state: " <<outcomes[0].first
                                  << " w/ g=" << ptr->g()
                                  << " and h=" << ptr->h()
                                  << " => f=" << ptr->f()
                                  << std::endl;
                        std::cout << "queue.sz=" << open.size() << std::endl;
#endif
                    }
                }
            }
        }
        //return std::numeric_limits<size_t>::max(); // NEED FIX
        hash.set_eval_function(0);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %rax
movq %rdx, %rsi
callq *0x30(%rax)
movq 0x10(%r14), %rax
leaq 0x2683a(%rip), %rcx     # 0x3c1a0
leaq 0x158(%rsp), %rdx
movq %rcx, (%rdx)
movq %rax, 0x8(%rdx)
movq %rdx, 0x40(%rbx)
xorl %eax, %eax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq %rbx, 0x38(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xefb2
movq %rax, %r12
movl $0x0, 0x18(%rax)
xorl %eax, %eax
movq %rax, 0x20(%r12)
movl $0xffffffff, 0x10(%r12) # imm = 0xFFFFFFFF
movb $0x1, %cl
movb %cl, 0x5(%r12)
leaq 0xe0(%rsp), %rdi
movq %rax, 0x44(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x34(%rdi)
movups %xmm0, 0x24(%rdi)
movups %xmm0, 0x14(%rdi)
movups %xmm0, 0x4(%rdi)
movb %cl, 0x5c(%rdi)
movq %rax, 0x60(%rdi)
movq %r15, %rsi
callq 0xc30a
leaq 0xe0(%rsp), %rsi
movq %r12, 0x70(%rsi)
leaq 0x10(%rsp), %rdi
callq 0x160ae
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x15f6b
cmpb $0x0, 0x13c(%rsp)
jne 0x15a32
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x15a32
callq 0x5340
movq 0x10(%rsp), %r12
cmpq 0x18(%rsp), %r12
je 0x15d7e
leaq 0x64(%rsp), %rbx
leaq 0xe0(%rsp), %r15
leaq 0x60(%rsp), %r13
leaq 0xe4(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x40(%rax)
movb $0x1, 0x13c(%rsp)
movq %rcx, 0x140(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xc30a
movq 0x70(%r12), %rax
movq %rax, 0x150(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x15e88
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x20(%rax)
testb %al, %al
je 0x15c09
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x150(%rsp), %rax
movss 0x18(%rax), %xmm0
cvttss2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subss 0x1552b(%rip), %xmm0    # 0x2b018
cvttss2si %xmm0, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq %r13, %rdi
callq 0x15eda
movq 0x150(%rsp), %rax
movq %rax, (%rsp)
testq %rax, %rax
je 0x15b3d
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x15b28
movq %rax, (%rsi)
addq $0x8, 0x68(%rsp)
jmp 0x15b33
movq %r13, %rdi
movq %rsp, %rdx
callq 0x167c2
movq (%rsp), %rax
movq 0x20(%rax), %rax
jmp 0x15b08
movl $0x6, %edx
movq 0x2748f(%rip), %rdi     # 0x3cfd8
leaq 0x16303(%rip), %rsi     # 0x2be53
callq 0x52e0
movq 0x68(%rsp), %r12
subq 0x60(%rsp), %r12
sarq $0x3, %r12
cmpq $0x1, %r12
je 0x15b9b
movq 0x60(%rsp), %rax
movq -0x10(%rax,%r12,8), %rax
movl 0x10(%rax), %esi
movq 0x2745b(%rip), %rdi     # 0x3cfd8
callq 0x5400
decq %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0x162c6(%rip), %rsi     # 0x2be5a
callq 0x52e0
jmp 0x15b63
movl $0x2, %edx
movq 0x27431(%rip), %rdi     # 0x3cfd8
leaq 0x162ae(%rip), %rsi     # 0x2be5c
callq 0x52e0
movq 0x68(%rsp), %rsi
subq 0x60(%rsp), %rsi
sarq $0x3, %rsi
decq %rsi
movq 0x2740d(%rip), %rdi     # 0x3cfd8
callq 0x51d0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x5270
movsbl %al, %esi
movq %r12, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x51e0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x15c09
callq 0x5260
xorl %r12d, %r12d
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *0x10(%rax)
cmpl %eax, %r12d
jge 0x15d52
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r12d, %edx
callq *0x30(%rax)
testb %al, %al
je 0x15d4a
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r12d, %edx
leaq 0x40(%rsp), %rcx
callq *0x60(%rax)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rax
subq %rsi, %rax
cmpq $0x78, %rax
jne 0x15db1
movq 0x38(%rsp), %rdi
callq 0xefb2
movq %rax, %rbp
movq 0x150(%rsp), %rax
movss 0x18(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %r12d, %edx
callq *0x48(%rax)
addss 0xc(%rsp), %xmm0
cmpb $0x1, 0x5(%rbp)
jne 0x15cbc
movss (%rbp), %xmm1
movaps %xmm1, %xmm2
addss %xmm0, %xmm2
addss 0x18(%rbp), %xmm1
ucomiss %xmm1, %xmm2
jae 0x15d4a
movss %xmm0, 0x18(%rbp)
movq 0x150(%rsp), %rax
movq %rax, 0x20(%rbp)
movl %r12d, 0x10(%rbp)
movb $0x1, %cl
movb %cl, 0x5(%rbp)
movq 0x40(%rsp), %rsi
xorl %eax, %eax
movq %rax, 0x40(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movb %cl, 0xbc(%rsp)
movq %rax, 0xc0(%rsp)
movq %r13, %rdi
callq 0xc30a
movq %rbp, 0xd0(%rsp)
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x160ae
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x15f6b
cmpb $0x0, 0xbc(%rsp)
jne 0x15d4a
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x15d4a
callq 0x5340
incl %r12d
jmp 0x15c0c
cmpb $0x0, 0x13c(%rsp)
jne 0x15d6e
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x15d6e
callq 0x5340
movq 0x10(%rsp), %r12
cmpq 0x18(%rsp), %r12
jne 0x15a54
movq 0x38(%rsp), %rax
movq $0x0, 0x40(%rax)
leaq 0x40(%rsp), %rdi
callq 0xd12e
leaq 0x10(%rsp), %rdi
callq 0x168dc
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x160a7(%rip), %rdi     # 0x2be5f
leaq 0x160b5(%rip), %rsi     # 0x2be74
leaq 0x160c7(%rip), %rcx     # 0x2be8d
movl $0x97, %edx
callq 0x51c0
jmp 0x15dd6
jmp 0x15dd6
jmp 0x15e1c
movq %rax, %rbx
jmp 0x15e3b
jmp 0x15e1c
jmp 0x15e08
jmp 0x15e08
jmp 0x15e1c
jmp 0x15e1c
jmp 0x15e1c
movq %rax, %rbx
cmpb $0x0, 0xbc(%rsp)
jne 0x15e1f
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x15e1f
callq 0x5340
jmp 0x15e1f
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x15e1f
callq 0x5260
jmp 0x15e1f
movq %rax, %rbx
cmpb $0x0, 0x13c(%rsp)
jne 0x15e3b
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0x15e3b
callq 0x5340
leaq 0x40(%rsp), %rdi
callq 0xd12e
leaq 0x10(%rsp), %rdi
callq 0x168dc
movq %rbx, %rdi
callq 0x5410
nop