// File: iZhangHui[P]CppPrimer/CH09_SequentialContainers/examples/substr.cc
// Function: main
int main()
{
    try {
        string s("hello world");
        cout << s.substr(0, 5) << endl;  // prints hello
        cout << s.substr(6) << endl;     // prints world
        cout << s.substr(6, 11) << endl; // prints world
        cout << s.substr(12) << endl;    // throws out_of_range
    } catch (out_of_range& e) {
        cout << e.what() << endl;
        // cout << "caught out_of_range" << endl;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movl $0x0, -0x4(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x1100
movq -0xd0(%rbp), %rdx
leaq 0xd84(%rip), %rsi       # 0x2004
leaq -0x28(%rbp), %rdi
callq 0x10c0
jmp 0x128b
leaq -0x29(%rbp), %rdi
callq 0x10b0
xorl %eax, %eax
movl %eax, %edx
leaq -0x60(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x5, %ecx
callq 0x1090
jmp 0x12ac
movq 0x2d25(%rip), %rdi      # 0x3fd8
leaq -0x60(%rbp), %rsi
callq 0x1070
movq %rax, -0xd8(%rbp)
jmp 0x12c5
movq -0xd8(%rbp), %rdi
movq 0x2cf5(%rip), %rsi      # 0x3fc8
callq 0x10a0
jmp 0x12da
leaq -0x60(%rbp), %rdi
callq 0x1050
leaq -0x80(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x6, %edx
movq $-0x1, %rcx
callq 0x1090
jmp 0x12fe
movq 0x2cd3(%rip), %rdi      # 0x3fd8
leaq -0x80(%rbp), %rsi
callq 0x1070
movq %rax, -0xe0(%rbp)
jmp 0x1317
movq -0xe0(%rbp), %rdi
movq 0x2ca3(%rip), %rsi      # 0x3fc8
callq 0x10a0
jmp 0x132c
leaq -0x80(%rbp), %rdi
callq 0x1050
leaq -0xa0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x6, %edx
movl $0xb, %ecx
callq 0x1090
jmp 0x1351
movq 0x2c80(%rip), %rdi      # 0x3fd8
leaq -0xa0(%rbp), %rsi
callq 0x1070
movq %rax, -0xe8(%rbp)
jmp 0x136d
movq -0xe8(%rbp), %rdi
movq 0x2c4d(%rip), %rsi      # 0x3fc8
callq 0x10a0
jmp 0x1382
leaq -0xa0(%rbp), %rdi
callq 0x1050
leaq -0xc0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0xc, %edx
movq $-0x1, %rcx
callq 0x1090
jmp 0x13ac
movq 0x2c25(%rip), %rdi      # 0x3fd8
leaq -0xc0(%rbp), %rsi
callq 0x1070
movq %rax, -0xf0(%rbp)
jmp 0x13c8
movq -0xf0(%rbp), %rdi
movq 0x2bf2(%rip), %rsi      # 0x3fc8
callq 0x10a0
jmp 0x13dd
leaq -0xc0(%rbp), %rdi
callq 0x1050
leaq -0x28(%rbp), %rdi
callq 0x1050
jmp 0x14e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x10b0
jmp 0x1485
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x147c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x1050
jmp 0x147c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x1050
jmp 0x147c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x1050
jmp 0x147c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x1050
leaq -0x28(%rbp), %rdi
callq 0x1050
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1503
movq -0x38(%rbp), %rdi
callq 0x1040
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x2b1d(%rip), %rdi      # 0x3fd8
callq 0x1080
movq %rax, -0xf8(%rbp)
jmp 0x14c9
movq -0xf8(%rbp), %rdi
movq 0x2af1(%rip), %rsi      # 0x3fc8
callq 0x10a0
jmp 0x14de
callq 0x10e0
xorl %eax, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x10e0
jmp 0x1501
jmp 0x1503
movq -0x38(%rbp), %rdi
callq 0x10f0
movq %rax, %rdi
callq 0x1520
nopw %cs:(%rax,%rax)
nop