// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH10_GenericAlgorithms/examples/elimDups.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);
    }
	print(words);

	vector<string> cpy = words; // save the original data

	// uses string < to compare elements
	// sort and print the vector
	sort(words.begin(), words.end());

	words = cpy;  // return to the original data
	// uses the LT function to compare elements
	// should have the same output as the previous sort
	sort(words.begin(), words.end(), LT);
    print(words);

	words = cpy;  // return to the original data

	// eliminate duplicates
	sort(words.begin(), words.end());
	auto it = unique(words.begin(), words.end());
	words.erase(it, words.end());

	// sort by length using a function
	stable_sort(words.begin(), words.end(), isShorter);  
    print(words);

	words = cpy; // return to the original data
	// sort the original input on word length, shortest to longest
	sort(words.begin(), words.end(), isShorter);  
    print(words);

	// use bind to invert isShorter to sort longest to shortest
	sort(words.begin(), words.end(), bind(isShorter, _2, _1));  
    print(words);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
xorps %xmm0, %xmm0
leaq -0x30(%rbp), %rbx
andq $0x0, 0x10(%rbx)
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movaps %xmm0, (%rbx)
movb $0x0, (%rax)
movq 0x6c41(%rip), %r14      # 0x8fe0
leaq -0x68(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2140
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x23c9
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2526
jmp 0x23a3
leaq -0x30(%rbp), %rdi
callq 0x2317
leaq -0x48(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2562
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x29f3
leaq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x25b6
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0xfb(%rip), %rdx       # 0x230d
callq 0x333f
leaq -0x30(%rbp), %rdi
callq 0x2317
leaq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x25b6
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x29f3
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3b58
leaq -0x30(%rbp), %rdi
movq 0x8(%rdi), %rdx
movq %rax, %rsi
callq 0x268a
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x160(%rip), %rdx      # 0x22fc
callq 0x3ce1
leaq -0x30(%rbp), %rdi
callq 0x2317
leaq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x25b6
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x18a(%rip), %rbx      # 0x22fc
movq %rbx, %rdx
callq 0x333f
leaq -0x30(%rbp), %rdi
callq 0x2317
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x78(%rbp), %rdx
movq %rbx, (%rdx)
callq 0x2694
leaq -0x30(%rbp), %rdi
callq 0x2317
leaq -0x48(%rbp), %rdi
callq 0x26b2
leaq -0x68(%rbp), %rdi
callq 0x2080
leaq -0x30(%rbp), %rdi
callq 0x26b2
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24e4
jmp 0x24f2
jmp 0x24f2
jmp 0x24e4
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x26b2
jmp 0x24f5
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x2080
leaq -0x30(%rbp), %rdi
callq 0x26b2
movq %rbx, %rdi
callq 0x21a0