// File: iZhangHui[P]CppPrimer/CH09_SequentialContainers/examples/useConvs.cc
// Function: main
int main()
{
    int i = 42;
    // converts the int i to its character representation
    string s = to_string(i);

    double d = stod(s);   // converts the string s to floating-point
    cout << "i = " << i << " s = " << s << " d is: " << d << endl;

    // convert the first substring in s that starts with a digit,  d = 3.14
    string s2 = "pi = 3.14";
    d = stod(s2.substr(s2.find_first_of("+-.0123456789")));

    cout << "d = " << d << " s = " << s << " s2 is: " << s2 << endl;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl $0x0, -0x4(%rbp)
movl $0x2a, -0x8(%rbp)
movl -0x8(%rbp), %esi
leaq -0x28(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x15a0
movq -0x98(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x16c0
movsd %xmm0, -0x90(%rbp)
jmp 0x12f6
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x2cce(%rip), %rdi      # 0x3fd8
leaq 0xcf3(%rip), %rsi       # 0x2004
callq 0x10b0
movq %rax, -0xa0(%rbp)
jmp 0x131f
movq -0xa0(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x1120
movq %rax, -0xa8(%rbp)
jmp 0x1337
movq -0xa8(%rbp), %rdi
leaq 0xcc4(%rip), %rsi       # 0x2009
callq 0x10b0
movq %rax, -0xb0(%rbp)
jmp 0x1353
movq -0xb0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x10a0
movq %rax, -0xb8(%rbp)
jmp 0x136c
movq -0xb8(%rbp), %rdi
leaq 0xc95(%rip), %rsi       # 0x200f
callq 0x10b0
movq %rax, -0xc0(%rbp)
jmp 0x1388
movq -0xc0(%rbp), %rdi
movsd -0x30(%rbp), %xmm0
callq 0x1150
movq %rax, -0xc8(%rbp)
jmp 0x13a2
movq -0xc8(%rbp), %rdi
movq 0x2c10(%rip), %rsi      # 0x3fc0
callq 0x10d0
jmp 0x13b7
leaq -0x61(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x1140
movq -0xd0(%rbp), %rdx
leaq 0xc42(%rip), %rsi       # 0x2017
leaq -0x60(%rbp), %rdi
callq 0x10f0
jmp 0x13e0
leaq -0x61(%rbp), %rdi
callq 0x10e0
leaq 0xc31(%rip), %rsi       # 0x2021
xorl %eax, %eax
movl %eax, %edx
leaq -0x60(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x1050
movq -0xd8(%rbp), %rsi
movq %rax, %rdx
leaq -0x88(%rbp), %rdi
movq $-0x1, %rcx
callq 0x10c0
jmp 0x1423
xorl %eax, %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x16c0
movsd %xmm0, -0xe0(%rbp)
jmp 0x143d
movsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x1070
movq 0x2b7b(%rip), %rdi      # 0x3fd8
leaq 0xbcb(%rip), %rsi       # 0x202f
callq 0x10b0
movq %rax, -0xe8(%rbp)
jmp 0x1472
movq -0xe8(%rbp), %rdi
movsd -0x30(%rbp), %xmm0
callq 0x1150
movq %rax, -0xf0(%rbp)
jmp 0x148c
movq -0xf0(%rbp), %rdi
leaq 0xb6f(%rip), %rsi       # 0x2009
callq 0x10b0
movq %rax, -0xf8(%rbp)
jmp 0x14a8
movq -0xf8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x10a0
movq %rax, -0x100(%rbp)
jmp 0x14c1
movq -0x100(%rbp), %rdi
leaq 0xb65(%rip), %rsi       # 0x2034
callq 0x10b0
movq %rax, -0x108(%rbp)
jmp 0x14dd
movq -0x108(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x10a0
movq %rax, -0x110(%rbp)
jmp 0x14f6
movq -0x110(%rbp), %rdi
movq 0x2abc(%rip), %rsi      # 0x3fc0
callq 0x10d0
jmp 0x150b
movl $0x0, -0x4(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x1070
leaq -0x28(%rbp), %rdi
callq 0x1070
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1584
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x10e0
jmp 0x1584
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x157b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x1070
leaq -0x60(%rbp), %rdi
callq 0x1070
leaq -0x28(%rbp), %rdi
callq 0x1070
movq -0x38(%rbp), %rdi
callq 0x1130
nopw %cs:(%rax,%rax)