// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x234a
movq (%rbx), %r13
movq 0x8(%rbx), %r15
cmpq %r15, %r13
je 0x24d8
movq %r15, %rax
subq %r13, %rax
sarq $0x5, %rax
incq %rax
pushq $0x2
popq %rcx
cqto
idivq %rcx
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x3b94
movq 0x10(%r12), %rdx
testq %rdx, %rdx
je 0x24bd
movq -0x48(%rbp), %rcx
movq %r13, %rdi
movq %r15, %rsi
callq 0x2939
jmp 0x24c8
movq %r13, %rdi
movq %r15, %rsi
callq 0x28bf
leaq -0x50(%rbp), %rdi
callq 0x3c18
movq (%rbx), %r13
movq 0x8(%rbx), %r15
movq %r15, %rax
subq %r13, %rax
movq %rax, %rcx
sarq $0x7, %rcx
addq $0x40, %r13
testq %rcx, %rcx
jle 0x2513
cmpq %r14, -0x38(%r13)
jae 0x253d
cmpq %r14, -0x18(%r13)
jae 0x2543
cmpq %r14, 0x8(%r13)
jae 0x254d
cmpq %r14, 0x28(%r13)
jae 0x2549
decq %rcx
subq $-0x80, %r13
addq $-0x80, %rax
jmp 0x24e9
sarq $0x5, %rax
leaq -0x40(%r13), %rcx
cmpq $0x1, %rax
je 0x2681
cmpq $0x3, %rax
je 0x2663
movq %r15, %r12
cmpq $0x2, %rax
jne 0x2550
jmp 0x2677
addq $-0x40, %r13
jmp 0x254d
addq $-0x20, %r13
jmp 0x254d
addq $0x20, %r13
movq %r13, %r12
subq %r12, %r15
sarq $0x5, %r15
movq 0x5a72(%rip), %rdi      # 0x7fd0
movq %r15, %rsi
callq 0x2110
leaq 0x2aa8(%rip), %rsi      # 0x5015
movq %rax, %rdi
callq 0x2120
movq %rax, %r13
leaq 0x2a85(%rip), %rsi      # 0x5004
leaq -0x90(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
callq 0x2060
leaq 0x2a73(%rip), %rsi      # 0x5009
leaq -0x70(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x2060
leaq -0x50(%rbp), %rdi
leaq -0x90(%rbp), %rdx
leaq -0x70(%rbp), %rcx
movq %r15, %rsi
callq 0x3116
leaq -0x50(%rbp), %rsi
movq %r13, %rdi
callq 0x2100
leaq 0x2a3e(%rip), %rsi      # 0x500b
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
movq %r14, %rsi
callq 0x20c0
leaq 0x2a30(%rip), %rsi      # 0x5017
movq %rax, %rdi
callq 0x2120
movq %rax, %rdi
callq 0x20a0
leaq -0x50(%rbp), %rdi
callq 0x2090
leaq -0x70(%rbp), %rdi
callq 0x2090
leaq -0x90(%rbp), %rdi
callq 0x2090
movq 0x8(%rbx), %r15
movq 0x59b0(%rip), %rbx      # 0x7fd0
leaq 0x29ee(%rip), %r14      # 0x5015
cmpq %r15, %r12
je 0x2648
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2100
movq %rax, %rdi
movq %r14, %rsi
callq 0x2120
addq $0x20, %r12
jmp 0x2627
movq 0x5981(%rip), %rdi      # 0x7fd0
callq 0x20a0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %r12
cmpq %r14, -0x38(%r13)
jae 0x2550
addq $-0x20, %r13
movq %r13, %rcx
cmpq %r14, 0x8(%rcx)
jae 0x2689
addq $0x20, %rcx
cmpq %r14, 0x8(%rcx)
cmovbq %r15, %rcx
movq %rcx, %r12
jmp 0x2550
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3c18
jmp 0x26cf
movq %rax, %rbx
jmp 0x26ba
movq %rax, %rbx
jmp 0x26c3
movq %rax, %rbx
jmp 0x26cf
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x2090
leaq -0x70(%rbp), %rdi
callq 0x2090
leaq -0x90(%rbp), %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x21c0