// File: iZhangHui[P]CppPrimer/CH16_TemplatesAndGenericProgramming/exercises/ex16_06.cc
// Function: main
int main(int argc, char const *argv[])
{
	// std::array<std::string, 3> sa = {"hello", "c++", "primer"};
	std::string sa[] = {"hello", "c++", "primer"};
	std::cout << *(begin_custom(sa) + 1) << std::endl;
	std::cout << *(end_custom(sa) - 1) << std::endl;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x1, -0x8f(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq %rax, -0x78(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x10b0
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rdx
leaq 0xdb0(%rip), %rsi       # 0x2004
callq 0x1080
jmp 0x125b
leaq -0x50(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq %rax, -0x78(%rbp)
leaq -0x8d(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x10b0
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rdx
leaq 0xd78(%rip), %rsi       # 0x200a
callq 0x1080
jmp 0x1299
leaq -0x30(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq %rax, -0x78(%rbp)
leaq -0x8e(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x10b0
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
leaq 0xd3e(%rip), %rsi       # 0x200e
callq 0x1080
jmp 0x12d7
movb $0x0, -0x8f(%rbp)
leaq -0x8e(%rbp), %rdi
callq 0x1070
leaq -0x8d(%rbp), %rdi
callq 0x1070
leaq -0x79(%rbp), %rdi
callq 0x1070
leaq -0x70(%rbp), %rdi
callq 0x1510
movq %rax, -0xc8(%rbp)
jmp 0x1311
movq -0xc8(%rbp), %rsi
addq $0x20, %rsi
movq 0x2cb5(%rip), %rdi      # 0x3fd8
callq 0x1050
movq %rax, -0xd0(%rbp)
jmp 0x1331
movq -0xd0(%rbp), %rdi
movq 0x2c89(%rip), %rsi      # 0x3fc8
callq 0x1060
jmp 0x1346
leaq -0x70(%rbp), %rdi
callq 0x1520
movq %rax, -0xd8(%rbp)
jmp 0x1358
movq -0xd8(%rbp), %rsi
addq $-0x20, %rsi
movq 0x2c6e(%rip), %rdi      # 0x3fd8
callq 0x1050
movq %rax, -0xe0(%rbp)
jmp 0x1378
movq -0xe0(%rbp), %rdi
movq 0x2c42(%rip), %rsi      # 0x3fc8
callq 0x1060
jmp 0x138d
movl $0x0, -0x4(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0xf0(%rbp)
addq $0x60, %rax
movq %rax, -0xe8(%rbp)
jmp 0x1488
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x1401
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x13f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x8e(%rbp), %rdi
callq 0x1070
leaq -0x8d(%rbp), %rdi
callq 0x1070
leaq -0x79(%rbp), %rdi
callq 0x1070
testb $0x1, -0x8f(%rbp)
jne 0x1415
jmp 0x1459
movq -0x78(%rbp), %rax
leaq -0x70(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0xf8(%rbp)
je 0x1457
movq -0xf8(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x100(%rbp)
callq 0x1030
movq -0x100(%rbp), %rax
leaq -0x70(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0xf8(%rbp)
jne 0x1429
jmp 0x1459
jmp 0x14f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x110(%rbp)
addq $0x60, %rax
movq %rax, -0x108(%rbp)
jmp 0x14c5
movq -0xe8(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x118(%rbp)
callq 0x1030
movq -0xf0(%rbp), %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0xe8(%rbp)
jne 0x1488
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x108(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x120(%rbp)
callq 0x1030
movq -0x110(%rbp), %rcx
movq -0x120(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x108(%rbp)
jne 0x14c5
jmp 0x14f8
movq -0x88(%rbp), %rdi
callq 0x10a0
nopw %cs:(%rax,%rax)
nop