// File: iZhangHui[P]CppPrimer/CH10_GenericAlgorithms/examples/newcount-size.cc
// Function: biggies(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, unsigned long)
void 
biggies(vector<string> &words, vector<string>::size_type sz)
{
	elimDups(words); // put words in alphabetical order and remove duplicates
    // sort words by size, but maintain alphabetical order for words of the same size
    stable_sort(words.begin(), words.end(), 
	            [](const string &a, const string &b) 
	              { return a.size() < b.size();});

	// get an iterator to the first element whose size() is >= sz
    auto wc = find_if(words.begin(), words.end(), 
                [sz](const string &a) 
	                { return a.size() >= sz; });

	// compute the number of elements with size >= sz 
	auto count = words.end() - wc;
    cout << count << " " << make_plural(count, "word", "s")
         << " of length " << sz << " or longer" << endl;

	// print words of the given size or longer, each one followed by a space
	for_each(wc, words.end(), 
	         [](const string &s){cout << s << " ";});
	cout << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2400
movq -0x8(%rbp), %rdi
callq 0x4c10
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4c40
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x2940
movq -0x8(%rbp), %rdi
callq 0x4c10
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4c40
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x2980
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4c40
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4d80
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rsi
movq 0xa8cd(%rip), %rdi      # 0xcfd0
callq 0x2220
movq %rax, %rdi
leaq 0x6923(%rip), %rsi      # 0x9035
callq 0x2120
movq %rax, -0x108(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x2210
movq -0xf8(%rbp), %rdx
leaq 0x68da(%rip), %rsi      # 0x9024
leaq -0x98(%rbp), %rdi
callq 0x21b0
jmp 0x2758
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x2210
movq -0x110(%rbp), %rdx
leaq 0x68b0(%rip), %rsi      # 0x9029
leaq -0xd0(%rbp), %rdi
callq 0x21b0
jmp 0x2787
movq -0x100(%rbp), %rsi
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
callq 0x4dc0
jmp 0x27a7
movq -0x108(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2110
movq %rax, -0x118(%rbp)
jmp 0x27c0
movq -0x118(%rbp), %rdi
leaq 0x685d(%rip), %rsi      # 0x902b
callq 0x2120
movq %rax, -0x120(%rbp)
jmp 0x27dc
movq -0x120(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2040
movq %rax, -0x128(%rbp)
jmp 0x27f5
movq -0x128(%rbp), %rdi
leaq 0x6834(%rip), %rsi      # 0x9037
callq 0x2120
movq %rax, -0x130(%rbp)
jmp 0x2811
movq -0x130(%rbp), %rdi
movq 0xa799(%rip), %rsi      # 0xcfb8
callq 0x2150
jmp 0x2826
leaq -0x78(%rbp), %rdi
callq 0x20c0
leaq -0xd0(%rbp), %rdi
callq 0x20c0
leaq -0xd1(%rbp), %rdi
callq 0x2160
leaq -0x98(%rbp), %rdi
callq 0x20c0
leaq -0x99(%rbp), %rdi
callq 0x2160
movq -0x30(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4c40
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x29e0
movq 0xa73c(%rip), %rdi      # 0xcfd0
movq 0xa71d(%rip), %rsi      # 0xcfb8
callq 0x2150
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2924
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x290c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2900
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x20c0
leaq -0xd0(%rbp), %rdi
callq 0x20c0
leaq -0xd1(%rbp), %rdi
callq 0x2160
leaq -0x98(%rbp), %rdi
callq 0x20c0
leaq -0x99(%rbp), %rdi
callq 0x2160
movq -0xa8(%rbp), %rdi
callq 0x2200
nopl (%rax)