// File: /workspace/github_cpp_makefile_star2_O3/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 0x2796
jmp 0x2499
leaq -0x40(%rbp), %rdi
callq 0x23d3
leaq -0x58(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x27e2
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 0x2e27
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2efb
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2876
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 0x375b
leaq -0x19c(%rip), %rdx      # 0x23bd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x389e
leaq -0x40(%rbp), %rdi
callq 0x23d3
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2876
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %rbx
cmpq %rbx, %r14
je 0x25bc
movq %rbx, %rax
subq %r14, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e27
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2efb
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3fcd
leaq -0x40(%rbp), %rdi
movq 0x8(%rdi), %rdx
movq %rax, %rsi
callq 0x40a8
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %rbx
cmpq %rbx, %r14
je 0x2648
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 0x417c
movq -0x60(%rbp), %rdx
testq %rdx, %rdx
je 0x262d
movq -0x68(%rbp), %rcx
leaq -0x274(%rip), %r8       # 0x23ac
movq %r14, %rdi
movq %rbx, %rsi
callq 0x42a4
jmp 0x263f
leaq -0x288(%rip), %rdx      # 0x23ac
movq %r14, %rdi
movq %rbx, %rsi
callq 0x420c
leaq -0x70(%rbp), %rdi
callq 0x437a
leaq -0x40(%rbp), %rdi
callq 0x23d3
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2876
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
cmpq %r14, %rbx
je 0x26a6
movq %r14, %rax
subq %rbx, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x2dd(%rip), %rcx      # 0x23ac
movq %rbx, %rdi
movq %r14, %rsi
callq 0x375b
leaq -0x2ef(%rip), %rdx      # 0x23ac
movq %rbx, %rdi
movq %r14, %rsi
callq 0x389e
leaq -0x40(%rbp), %rdi
callq 0x23d3
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r14
cmpq %r14, %rbx
je 0x2701
movq %r14, %rax
subq %rbx, %rax
sarq $0x5, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
leaq -0x32e(%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 0x53e4
leaq -0x40(%rbp), %rdi
callq 0x23d3
leaq -0x58(%rbp), %rdi
callq 0x2a24
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x272b
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x40(%rbp), %rdi
callq 0x2a24
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 0x437a
jmp 0x275f
jmp 0x275c
jmp 0x276a
jmp 0x276a
jmp 0x275c
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x2a24
jmp 0x276d
movq %rax, %rbx
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x2785
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x40(%rbp), %rdi
callq 0x2a24
movq %rbx, %rdi
callq 0x21a0