// File: nilnilnil[P]autocomplete/./include/suggest.hpp
// Function: naive_suggest(PhraseMap&, SegmentTree&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
vp_t
naive_suggest(PhraseMap& pm, RMQ& st, std::string prefix, uint_t n = 16) {
    pvpi_t phrases = pm.query(prefix);
    std::vector<uint_t> indexes;
    vp_t ret;

    while (phrases.first != phrases.second) {
        indexes.push_back(phrases.first - pm.repr.begin());
        ++phrases.first;
    }

    while (ret.size() < n && !indexes.empty()) {
        uint_t mi = 0;
        for (size_t i = 1; i < indexes.size(); ++i) {
            if (pm.repr[indexes[i]].weight > pm.repr[indexes[mi]].weight) {
                mi = i;
            }
        }
        ret.push_back(pm.repr[indexes[mi]]);
        indexes.erase(indexes.begin() + mi);
    }
    return ret;
}

// Assembly:
subq $0xf8, %rsp
movq %rcx, 0x48(%rsp)
movq %rsi, %rax
movq 0x48(%rsp), %rsi
movq %rdi, 0x58(%rsp)
movq %rdi, %rcx
movq %rcx, 0x50(%rsp)
movq %rdi, 0xf0(%rsp)
movq %rax, 0xe8(%rsp)
movq %rdx, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movl %r8d, 0xd4(%rsp)
movq 0xe8(%rsp), %rdi
callq 0xdc40
movq %rax, 0xc0(%rsp)
movq %rdx, 0xc8(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xd3d0
movq 0x58(%rsp), %rdi
movb $0x0, 0xa7(%rsp)
callq 0xdf20
leaq 0xc0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
addq $0x8, %rsi
callq 0xda80
testb $0x1, %al
jne 0x7c87
jmp 0x7d0e
movq 0xe8(%rsp), %rdi
callq 0xda50
movq %rax, 0x98(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xdca0
movl %eax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xd3e0
jmp 0x7ccf
leaq 0xc0(%rsp), %rdi
callq 0xdb40
jmp 0x7c65
movq 0x58(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
callq 0xe170
leaq 0xa8(%rsp), %rdi
callq 0xd550
jmp 0x7f08
jmp 0x7d10
movq 0x58(%rsp), %rdi
callq 0xe000
movq %rax, %rcx
movl 0xd4(%rsp), %eax
movl %eax, %edx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x47(%rsp)
jae 0x7d44
leaq 0xa8(%rsp), %rdi
callq 0xe1d0
xorb $-0x1, %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x7d51
jmp 0x7ed2
movl $0x0, 0x88(%rsp)
movq $0x1, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xd4e0
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x7e2f
movq 0xe8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x80(%rsp), %rsi
leaq 0xa8(%rsp), %rdi
callq 0xe220
movq 0x20(%rsp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0xe110
movl (%rax), %eax
movl %eax, 0x34(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0x88(%rsp), %eax
movl %eax, %esi
leaq 0xa8(%rsp), %rdi
callq 0xe220
movq 0x28(%rsp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0xe110
movq %rax, %rcx
movl 0x34(%rsp), %eax
cmpl (%rcx), %eax
jbe 0x7e14
movq 0x80(%rsp), %rax
movl %eax, 0x88(%rsp)
jmp 0x7e16
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0x7d68
movq 0xe8(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x88(%rsp), %eax
movl %eax, %esi
leaq 0xa8(%rsp), %rdi
callq 0xe220
movq 0x18(%rsp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0xe110
movq 0x58(%rsp), %rdi
movq %rax, %rsi
callq 0xe0a0
jmp 0x7e6f
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xe2b0
movq %rax, 0x68(%rsp)
movl 0x88(%rsp), %eax
movl %eax, %esi
leaq 0x68(%rsp), %rdi
callq 0xe2e0
movq %rax, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xe320
movq 0x8(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xe240
movq %rax, 0x10(%rsp)
jmp 0x7ec3
movq 0x10(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0x7d10
movb $0x1, 0xa7(%rsp)
testb $0x1, 0xa7(%rsp)
jne 0x7eee
movq 0x58(%rsp), %rdi
callq 0xe170
leaq 0xa8(%rsp), %rdi
callq 0xd550
movq 0x50(%rsp), %rax
addq $0xf8, %rsp
retq
movq 0x90(%rsp), %rdi
callq 0x5a40
nopw %cs:(%rax,%rax)