// File: /workspace/github_cpp_makefile_star2_O1/iZhangHui[P]CppPrimer/CH10_GenericAlgorithms/examples/use_find.cc
// Function: main
int main()
{
	int ia[] = {27, 210, 12, 47, 109, 83};
	int val = 83;
	int* result = find(begin(ia), end(ia), val);
	cout << "The value " << val
	     << (result == end(ia)
	           ? " is not present" : " is present") << endl;
	
	// search starting from ia[1] up to but not including ia[4]
	result = find(ia + 1, ia + 4, val);
	
	// initialize the vector with some values
	vector<int> vec = {27, 210, 12, 47, 109, 83};
	val = 42; // value we'll look for

	// result2 will denote the element we want if it's in vec, 
	// or vec.cend() if not
	auto result2 = find(vec.cbegin(), vec.cend(), val);

	// report the result
	cout << "The value " << val
	     << (result2 == vec.cend()
	           ? " is not present" : " is present") << endl;
	
	// now use find to look in a list of strings
	list<string> lst = {"val1", "val2", "val3"};

	string sval = "a value";  // value we'll look for
	// this call to find looks through string elements in a list
	auto result3 = find(lst.cbegin(), lst.cend(), sval);
	cout << "The value " << sval
	     << (result3 == lst.cend()
	           ? " is not present" : " is present") << endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movaps 0xda9(%rip), %xmm0      # 0x20a0
leaq -0xc8(%rbp), %rbx
movaps %xmm0, -0x18(%rbx)
movabsq $0x530000006d, %r13     # imm = 0x530000006D
movq %r13, -0x8(%rbx)
leaq -0x2c(%rbp), %r14
movl $0x53, (%r14)
leaq -0xe0(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x17d4
movq %rax, %r12
movq 0x2ca1(%rip), %r15      # 0x3fd8
leaq 0xcc6(%rip), %rsi       # 0x2004
movl $0xa, %edx
movq %r15, %rdi
callq 0x1100
movl (%r14), %esi
movq %r15, %rdi
callq 0x1130
movq %rax, %r15
xorl %eax, %eax
cmpq %rbx, %r12
sete %al
leaq 0xca7(%rip), %r12       # 0x200f
leaq 0xcb0(%rip), %rbx       # 0x201f
movq %rbx, %rsi
cmoveq %r12, %rsi
leaq 0xb(,%rax,4), %rdx
movq %r15, %rdi
callq 0x1100
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1070
leaq -0xb0(%rbp), %rsi
movaps 0xce5(%rip), %xmm0      # 0x20a0
movaps %xmm0, (%rsi)
movq %r13, 0x10(%rsi)
leaq -0x50(%rbp), %r15
leaq -0xc8(%rbp), %rcx
movl $0x6, %edx
movq %r15, %rdi
callq 0x1700
movl $0x2a, (%r14)
movq (%r15), %rdi
movq 0x8(%r15), %rsi
movq %r14, %rdx
callq 0x191c
movq %rax, %r15
movq 0x2bde(%rip), %rdi      # 0x3fd8
leaq 0xc03(%rip), %rsi       # 0x2004
movl $0xa, %edx
callq 0x1100
movl -0x2c(%rbp), %esi
movq 0x2bc3(%rip), %rdi      # 0x3fd8
callq 0x1130
movq %rax, %r14
xorl %eax, %eax
cmpq -0x48(%rbp), %r15
sete %al
movq %rbx, %rsi
cmoveq %r12, %rsi
leaq 0xb(,%rax,4), %rdx
movq %r14, %rdi
callq 0x1100
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1070
leaq -0xa0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xbb5(%rip), %rsi       # 0x202b
leaq 0xbb2(%rip), %rdx       # 0x202f
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
callq 0x19be
leaq -0x90(%rbp), %r15
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xb8e(%rip), %rsi       # 0x2030
leaq 0xb8b(%rip), %rdx       # 0x2034
movq %r15, %rdi
callq 0x19be
leaq -0x70(%rbp), %r15
leaq -0x60(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0xb71(%rip), %rsi       # 0x2035
leaq 0xb6e(%rip), %rdx       # 0x2039
movq %r15, %rdi
callq 0x19be
leaq -0xc8(%rbp), %r14
leaq -0xb0(%rbp), %rsi
leaq -0x38(%rbp), %rcx
movl $0x3, %edx
movq %r14, %rdi
callq 0x1746
movq $-0x60, %r15
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0x150e
movq (%r13), %rsi
incq %rsi
callq 0x10e0
addq $-0x20, %r13
addq $0x20, %r15
jne 0x14f9
leaq -0xb0(%rbp), %r12
leaq -0xa0(%rbp), %r13
movq %r13, (%r12)
leaq 0xb09(%rip), %rsi       # 0x203a
leaq 0xb09(%rip), %rdx       # 0x2041
movq %r12, %rdi
callq 0x19be
movq -0xc8(%rbp), %r15
movq %r12, -0x38(%rbp)
cmpq %r14, %r15
je 0x156b
leaq -0x38(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1b8a
testb %al, %al
jne 0x156b
movq (%r15), %r15
cmpq %r14, %r15
jne 0x1554
movq 0x2a66(%rip), %rdi      # 0x3fd8
leaq 0xa8b(%rip), %rsi       # 0x2004
movl $0xa, %edx
callq 0x1100
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
movq 0x2a40(%rip), %rdi      # 0x3fd8
callq 0x1100
movq %rax, %r12
xorl %eax, %eax
cmpq %r14, %r15
sete %al
leaq 0xa60(%rip), %rcx       # 0x200f
cmoveq %rcx, %rbx
leaq 0xb(,%rax,4), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1100
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1070
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x1609
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x10e0
leaq -0xc8(%rbp), %rdi
callq 0x1784
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x162a
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10e0
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x16d2
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x1170
movb $0x1, %al
jmp 0x166e
jmp 0x165f
movq %rax, %rbx
xorl %eax, %eax
jmp 0x166e
movq %rax, %rbx
xorl %eax, %eax
movq %r12, %r15
cmpq %r15, %r12
sete %cl
orb %al, %cl
jne 0x16e3
addq $-0x10, %r15
leaq -0xb0(%rbp), %r14
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1697
movq (%r15), %rsi
incq %rsi
callq 0x10e0
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x1683
jmp 0x16e3
jmp 0x16ad
jmp 0x16e0
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x16d2
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x10e0
leaq -0xc8(%rbp), %rdi
callq 0x1784
jmp 0x16e3
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x16f8
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq %rbx, %rdi
callq 0x1140