// File: iZhangHui[P]CppPrimer/CH13_CopyControl/examples/substr.cc
// Function: main
int main()
{
	string s1 = "a value", s2 = "another";
	auto x = position(s1, s2, "val");
	if (x == string::npos)
		cout << "not found" << endl;
	else if (x < s1.size())
		cout << "value is in first parameter" << endl;
	else
		cout << "value is in second parameter" << endl;

	auto n = (s1 + s2).find('a');
	cout << "n = " << n << endl;
	s1 + s2 = "wow!";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movl $0x0, -0x4(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x1100
movq -0xe8(%rbp), %rdx
leaq 0xd14(%rip), %rsi       # 0x2004
leaq -0x28(%rbp), %rdi
callq 0x10d0
jmp 0x12fb
leaq -0x29(%rbp), %rdi
callq 0x10a0
leaq -0x61(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x1100
movq -0xf0(%rbp), %rdx
leaq 0xcea(%rip), %rsi       # 0x200c
leaq -0x60(%rbp), %rdi
callq 0x10d0
jmp 0x132d
leaq -0x61(%rbp), %rdi
callq 0x10a0
leaq -0x91(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x1100
movq -0xf8(%rbp), %rdx
leaq 0xcbd(%rip), %rsi       # 0x2014
leaq -0x90(%rbp), %rdi
callq 0x10d0
jmp 0x1365
leaq -0x28(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x1270
movq %rax, -0x100(%rbp)
jmp 0x1382
leaq -0x90(%rbp), %rdi
callq 0x1050
leaq -0x91(%rbp), %rdi
callq 0x10a0
movq -0x100(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $-0x1, -0x70(%rbp)
jne 0x1462
movq 0x2c21(%rip), %rdi      # 0x3fd8
leaq 0xc5a(%rip), %rsi       # 0x2018
callq 0x1080
movq %rax, -0x108(%rbp)
jmp 0x13cc
movq -0x108(%rbp), %rdi
movq 0x2bee(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x13e1
jmp 0x14ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x10a0
jmp 0x160c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x10a0
jmp 0x1603
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1440
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x1050
leaq -0x91(%rbp), %rdi
callq 0x10a0
jmp 0x15fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x15fa
movq -0x70(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1060
movq %rax, %rcx
movq -0x110(%rbp), %rax
cmpq %rcx, %rax
jae 0x14b8
movq 0x2b4c(%rip), %rdi      # 0x3fd8
leaq 0xb8f(%rip), %rsi       # 0x2022
callq 0x1080
movq %rax, -0x118(%rbp)
jmp 0x14a1
movq -0x118(%rbp), %rdi
movq 0x2b19(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x14b6
jmp 0x14eb
movq 0x2b19(%rip), %rdi      # 0x3fd8
leaq 0xb78(%rip), %rsi       # 0x203e
callq 0x1080
movq %rax, -0x120(%rbp)
jmp 0x14d4
movq -0x120(%rbp), %rdi
movq 0x2ae6(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x14e9
jmp 0x14eb
jmp 0x14ed
leaq -0xc0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x1620
jmp 0x1503
xorl %eax, %eax
movl %eax, %edx
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x138(%rbp)
movl $0x61, %esi
callq 0x10b0
movq -0x138(%rbp), %rdi
movq %rax, -0x130(%rbp)
callq 0x1050
movq -0x130(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq 0x2a91(%rip), %rdi      # 0x3fd8
leaq 0xb0d(%rip), %rsi       # 0x205b
callq 0x1080
movq %rax, -0x128(%rbp)
jmp 0x155c
movq -0x128(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x1030
movq %rax, -0x140(%rbp)
jmp 0x1578
movq -0x140(%rbp), %rdi
movq 0x2a42(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x158d
leaq -0xe0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x1620
jmp 0x15a3
leaq 0xab6(%rip), %rsi       # 0x2060
leaq -0xe0(%rbp), %rdi
callq 0x10c0
jmp 0x15b8
leaq -0xe0(%rbp), %rdi
callq 0x1050
leaq -0x60(%rbp), %rdi
callq 0x1050
leaq -0x28(%rbp), %rdi
callq 0x1050
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x1050
leaq -0x60(%rbp), %rdi
callq 0x1050
leaq -0x28(%rbp), %rdi
callq 0x1050
movq -0x38(%rbp), %rdi
callq 0x10f0
nopw %cs:(%rax,%rax)
nop