// File: /workspace/github_cpp_makefile_star2_O1/iZhangHui[P]CppPrimer/CH10_GenericAlgorithms/examples/newcount-size.cc
// Function: elimDups(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>>>>&)
void elimDups(vector<string> &words)
{
    // sort words alphabetically so we can find the duplicates
    sort(words.begin(), words.end());
	for_each(words.begin(), words.end(), 
	         [](const string &s) { cout << s << " "; });
	cout << endl;


    // unique reorders the input so that each word appears once in the
    // front part of the range 
	// returns an iterator one past the unique range
    auto end_unique = unique(words.begin(), words.end());
	for_each(words.begin(), words.end(), 
	         [](const string &s) { cout << s << " "; });
	cout << endl;

    // erase uses a vector operation to remove the nonunique elements
    words.erase(end_unique, words.end());
	for_each(words.begin(), 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
pushq %rax
movq %rdi, %rbx
movq (%rdi), %r14
movq 0x8(%rdi), %r15
cmpq %r15, %r14
je 0x23d4
movq %r15, %rax
subq %r14, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x38a7
movq %r14, %rdi
movq %r15, %rsi
callq 0x3998
movq (%rbx), %r12
movq 0x8(%rbx), %r13
cmpq %r13, %r12
je 0x2418
movq 0x4be9(%rip), %r14      # 0x6fd0
leaq 0x2c27(%rip), %r15      # 0x5015
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r14, %rdi
callq 0x2160
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
addq $0x20, %r12
cmpq %r13, %r12
jne 0x23ee
movq 0x4bb1(%rip), %r14      # 0x6fd0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0x411b
movq %rax, -0x30(%rbp)
movq (%rbx), %r15
movq 0x8(%rbx), %r14
cmpq %r14, %r15
je 0x2498
movq 0x4b67(%rip), %r12      # 0x6fd0
leaq 0x2ba5(%rip), %r13      # 0x5015
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %r12, %rdi
callq 0x2160
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2160
addq $0x20, %r15
cmpq %r14, %r15
jne 0x2470
movq 0x4b31(%rip), %r13      # 0x6fd0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq 0x8(%rbx), %rdx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x41f6
movq (%rbx), %r12
movq 0x8(%rbx), %r14
cmpq %r14, %r12
je 0x251b
movq 0x4ae6(%rip), %rbx      # 0x6fd0
leaq 0x2b24(%rip), %r15      # 0x5015
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0x2160
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
addq $0x20, %r12
cmpq %r14, %r12
jne 0x24f1
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20b0