// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x80, %rsp
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rbx
movaps %xmm0, (%rbx)
xorl %eax, %eax
movq %rax, 0x10(%rbx)
leaq -0x80(%rbp), %r12
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb $0x0, (%r12)
movq 0x6b4e(%rip), %r14      # 0x8fe0
leaq -0x90(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2160
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x24bf
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2790
jmp 0x2499
leaq -0x40(%rbp), %rdi
callq 0x23d3
leaq -0x58(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x27dc
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
cmpq %r14, %rbx
je 0x250f
movq %r14, %rax
subq %rbx, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2e23
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2f14
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2870
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
cmpq %r14, %rbx
je 0x2564
movq %r14, %rax
subq %rbx, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x18a(%rip), %rcx      # 0x23bd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x379b
leaq -0x19c(%rip), %rdx      # 0x23bd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x38f8
leaq -0x40(%rbp), %rdi
callq 0x23d3
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2870
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
cmpq %r14, %rbx
je 0x25b4
movq %r14, %rax
subq %rbx, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2e23
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2f14
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4048
leaq -0x40(%rbp), %rdi
movq 0x8(%rdi), %rdx
movq %rax, %rsi
callq 0x4122
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %rbx
cmpq %rbx, %r14
je 0x2642
movq %rbx, %rax
subq %r14, %rax
sarq $0x5, %rax
leaq 0x1(%rax), %rcx
shrq $0x3f, %rcx
leaq (%rax,%rcx), %rdx
incq %rdx
sarq %rdx
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0x41ee
movq -0x60(%rbp), %rdx
testq %rdx, %rdx
je 0x2627
movq -0x68(%rbp), %rcx
leaq -0x26e(%rip), %r8       # 0x23ac
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4316
jmp 0x2639
leaq -0x282(%rip), %rdx      # 0x23ac
movq %r14, %rdi
movq %rbx, %rsi
callq 0x427e
leaq -0x70(%rbp), %rdi
callq 0x43ec
leaq -0x40(%rbp), %rdi
callq 0x23d3
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2870
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
cmpq %r14, %rbx
je 0x26a0
movq %r14, %rax
subq %rbx, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x2d7(%rip), %rcx      # 0x23ac
movq %rbx, %rdi
movq %r14, %rsi
callq 0x379b
leaq -0x2e9(%rip), %rdx      # 0x23ac
movq %rbx, %rdi
movq %r14, %rsi
callq 0x38f8
leaq -0x40(%rbp), %rdi
callq 0x23d3
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
cmpq %r14, %rbx
je 0x26fb
movq %r14, %rax
subq %rbx, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x328(%rip), %r15      # 0x23ac
leaq -0x70(%rbp), %rcx
movq %r15, (%rcx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x527a
leaq -0xa0(%rbp), %rdx
movq %r15, (%rdx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5409
leaq -0x40(%rbp), %rdi
callq 0x23d3
leaq -0x58(%rbp), %rdi
callq 0x29fe
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x2725
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x40(%rbp), %rdi
callq 0x29fe
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x43ec
jmp 0x2759
jmp 0x2756
jmp 0x2764
jmp 0x2764
jmp 0x2756
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x29fe
jmp 0x2767
movq %rax, %rbx
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x277f
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x40(%rbp), %rdi
callq 0x29fe
movq %rbx, %rdi
callq 0x21a0