// File: iZhangHui[P]CppPrimer/CH10_GenericAlgorithms/examples/newcount-size.cc
// Function: main
int main()
{
    vector<string> words;

    // copy contents of each book into a single vector
    string next_word;
    while (cin >> next_word) {
        // insert next book's contents at end of words
        words.push_back(next_word);
    }

	biggies(words, 5); // biggies changes its first argument

	// alternative solution using bind and check_size function
	// NB: words was changed inside biggies, 
	//     at this point in the program words has only unique
	//     words and is in order by size
	size_t sz = 5;
	auto
	wc = find_if(words.begin(), words.end(), 
	             bind(check_size, std::placeholders::_1, sz));
	auto count = words.end() - wc;
    cout << count << " " << make_plural(count, "word", "s")
         << " of length " << sz << " or longer" << endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl $0x0, -0x4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x4e20
leaq -0x40(%rbp), %rdi
callq 0x21c0
movq 0xa555(%rip), %rdi      # 0xcfe0
leaq -0x40(%rbp), %rsi
callq 0x2190
movq %rax, -0x108(%rbp)
jmp 0x2a9d
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2180
movb %al, -0x109(%rbp)
jmp 0x2abb
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x2ac7
jmp 0x2ae9
leaq -0x20(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4e40
jmp 0x2ad6
jmp 0x2a84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2daa
leaq -0x20(%rbp), %rdi
movl $0x5, %esi
callq 0x2660
jmp 0x2af9
movq $0x5, -0x58(%rbp)
leaq -0x20(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x4c10
movq -0x118(%rbp), %rdi
movq %rax, -0x68(%rbp)
callq 0x4c40
movq %rax, -0x70(%rbp)
leaq -0xfc(%rip), %rsi       # 0x2a30
movq 0xa495(%rip), %rdx      # 0xcfc8
leaq -0x80(%rbp), %rdi
leaq -0x58(%rbp), %rcx
callq 0x4f10
jmp 0x2b42
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4eb0
movq %rax, -0x120(%rbp)
jmp 0x2b5c
movq -0x120(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x4c40
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4d80
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rsi
movq 0xa434(%rip), %rdi      # 0xcfd0
callq 0x2220
movq %rax, -0x128(%rbp)
jmp 0x2baa
movq -0x128(%rbp), %rdi
leaq 0x647d(%rip), %rsi      # 0x9035
callq 0x2120
movq %rax, -0x130(%rbp)
jmp 0x2bc6
movq -0x88(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x2210
movq -0x138(%rbp), %rdx
leaq 0x642f(%rip), %rsi      # 0x9024
leaq -0xd0(%rbp), %rdi
callq 0x21b0
jmp 0x2c03
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x2210
movq -0x148(%rbp), %rdx
leaq 0x6405(%rip), %rsi      # 0x9029
leaq -0xf8(%rbp), %rdi
callq 0x21b0
jmp 0x2c32
movq -0x140(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
leaq -0xf8(%rbp), %rcx
callq 0x4dc0
jmp 0x2c55
movq -0x130(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2110
movq %rax, -0x150(%rbp)
jmp 0x2c71
movq -0x150(%rbp), %rdi
leaq 0x63ac(%rip), %rsi      # 0x902b
callq 0x2120
movq %rax, -0x158(%rbp)
jmp 0x2c8d
movq -0x158(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x2040
movq %rax, -0x160(%rbp)
jmp 0x2ca6
movq -0x160(%rbp), %rdi
leaq 0x6383(%rip), %rsi      # 0x9037
callq 0x2120
movq %rax, -0x168(%rbp)
jmp 0x2cc2
movq -0x168(%rbp), %rdi
movq 0xa2e8(%rip), %rsi      # 0xcfb8
callq 0x2150
jmp 0x2cd7
leaq -0xb0(%rbp), %rdi
callq 0x20c0
leaq -0xf8(%rbp), %rdi
callq 0x20c0
leaq -0xf9(%rbp), %rdi
callq 0x2160
leaq -0xd0(%rbp), %rdi
callq 0x20c0
leaq -0xd1(%rbp), %rdi
callq 0x2160
movl $0x0, -0x4(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x20c0
leaq -0x20(%rbp), %rdi
callq 0x4f60
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2d9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2d86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2d7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x20c0
leaq -0xf8(%rbp), %rdi
callq 0x20c0
leaq -0xf9(%rbp), %rdi
callq 0x2160
leaq -0xd0(%rbp), %rdi
callq 0x20c0
leaq -0xd1(%rbp), %rdi
callq 0x2160
leaq -0x40(%rbp), %rdi
callq 0x20c0
leaq -0x20(%rbp), %rdi
callq 0x4f60
movq -0x48(%rbp), %rdi
callq 0x2200
nopw %cs:(%rax,%rax)