// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movaps 0xda9(%rip), %xmm0      # 0x20a0
leaq -0xd8(%rbp), %rbx
movaps %xmm0, -0x18(%rbx)
movabsq $0x530000006d, %r13     # imm = 0x530000006D
movq %r13, -0x8(%rbx)
leaq -0x2c(%rbp), %r14
movl $0x53, (%r14)
leaq -0xf0(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x17ac
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 -0xd0(%rbp), %rsi
movaps 0xce5(%rip), %xmm0      # 0x20a0
movaps %xmm0, (%rsi)
movq %r13, 0x10(%rsi)
leaq -0x68(%rbp), %r15
leaq -0x50(%rbp), %rcx
movl $0x6, %edx
movq %r15, %rdi
callq 0x16d8
movl $0x2a, (%r14)
movq (%r15), %rdi
movq 0x8(%r15), %rsi
movq %r14, %rdx
callq 0x18f8
movq %rax, %r15
movq 0x2be1(%rip), %rdi      # 0x3fd8
leaq 0xc06(%rip), %rsi       # 0x2004
movl $0xa, %edx
callq 0x1100
movl -0x2c(%rbp), %esi
movq 0x2bc6(%rip), %rdi      # 0x3fd8
callq 0x1130
movq %rax, %r14
xorl %eax, %eax
cmpq -0x60(%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 -0xc0(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0xbb8(%rip), %rsi       # 0x202b
leaq 0xbb5(%rip), %rdx       # 0x202f
leaq -0xd0(%rbp), %r14
movq %r14, %rdi
callq 0x19a6
leaq -0xb0(%rbp), %r15
leaq -0xa0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xb8e(%rip), %rsi       # 0x2030
leaq 0xb8b(%rip), %rdx       # 0x2034
movq %r15, %rdi
callq 0x19a6
leaq -0x90(%rbp), %r15
leaq -0x80(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xb6d(%rip), %rsi       # 0x2035
leaq 0xb6a(%rip), %rdx       # 0x2039
movq %r15, %rdi
callq 0x19a6
leaq -0x50(%rbp), %r14
leaq -0xd0(%rbp), %rsi
leaq -0x38(%rbp), %rcx
movl $0x3, %edx
movq %r14, %rdi
callq 0x171e
movq $-0x60, %r15
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x1510
movq (%r12), %rsi
incq %rsi
callq 0x10e0
addq $-0x20, %r12
addq $0x20, %r15
jne 0x14fa
leaq -0xd0(%rbp), %r12
movq %r13, (%r12)
leaq 0xb0e(%rip), %rsi       # 0x203a
leaq 0xb0e(%rip), %rdx       # 0x2041
movq %r12, %rdi
callq 0x19a6
movq -0x50(%rbp), %r15
movq %r12, -0x38(%rbp)
cmpq %r14, %r15
je 0x156c
leaq -0x38(%rbp), %r12
leaq -0x50(%rbp), %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x1b7a
testb %al, %al
jne 0x1569
movq (%r15), %r15
cmpq %r14, %r15
jne 0x1550
jmp 0x156c
movq %r15, %r14
movq 0x2a65(%rip), %rdi      # 0x3fd8
leaq 0xa8a(%rip), %rsi       # 0x2004
movl $0xa, %edx
callq 0x1100
movq -0xd0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
movq 0x2a3f(%rip), %rdi      # 0x3fd8
callq 0x1100
movq %rax, %r15
leaq -0x50(%rbp), %rax
xorl %ecx, %ecx
cmpq %rax, %r14
sete %cl
leaq 0xa5b(%rip), %rax       # 0x200f
cmoveq %rax, %rbx
leaq 0xb(,%rcx,4), %rdx
movq %r15, %rdi
movq %rbx, %rsi
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
movq -0xd0(%rbp), %rdi
cmpq %r13, %rdi
je 0x160d
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x10e0
leaq -0x50(%rbp), %rdi
callq 0x175c
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x162b
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10e0
xorl %eax, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x16ac
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x1170
jmp 0x16ba
jmp 0x165b
movq %rax, %rbx
addq $-0x10, %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1676
movq (%r15), %rsi
incq %rsi
callq 0x10e0
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x1662
jmp 0x16ba
jmp 0x16b7
jmp 0x168e
jmp 0x16b7
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
cmpq %r13, %rdi
je 0x16ac
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x10e0
leaq -0x50(%rbp), %rdi
callq 0x175c
jmp 0x16ba
movq %rax, %rbx
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x16cf
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq %rbx, %rdi
callq 0x1140
nop