// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x50(%rbp), %rbx
movl $0x2, %esi
movq %rbx, %rdi
movl $0x2d, %edx
callq 0x10f0
movq (%rbx), %rax
movw $0x3234, (%rax)         # imm = 0x3234
movq (%rbx), %r14
callq 0x1040
movq %rax, %rbx
movl (%rax), %r13d
movl $0x0, (%rax)
leaq -0x70(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x1080
movsd %xmm0, -0x30(%rbp)
cmpq %r14, (%r15)
je 0x1561
movl (%rbx), %eax
testl %eax, %eax
je 0x132b
cmpl $0x22, %eax
jne 0x132e
leaq 0xd17(%rip), %rdi       # 0x203d
callq 0x1100
movl %r13d, (%rbx)
movq 0x2ca3(%rip), %rdi      # 0x3fd8
leaq 0xcc8(%rip), %rsi       # 0x2004
movl $0x4, %edx
callq 0x10e0
movq 0x2c8b(%rip), %rdi      # 0x3fd8
movl $0x2a, %esi
callq 0x1140
movq %rax, %r14
leaq 0xca8(%rip), %rsi       # 0x2009
movl $0x5, %edx
movq %rax, %rdi
callq 0x10e0
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r14, %rdi
callq 0x10e0
movq %rax, %r14
leaq 0xc87(%rip), %rsi       # 0x200f
movl $0x7, %edx
movq %rax, %rdi
callq 0x10e0
movq %r14, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x1130
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1060
leaq -0x60(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0xc3c(%rip), %rsi       # 0x2017
leaq 0xc3e(%rip), %rdx       # 0x2020
leaq -0x70(%rbp), %rdi
callq 0x15ee
leaq 0xc2f(%rip), %rsi       # 0x2021
leaq -0x70(%rbp), %r14
movl $0xd, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x1110
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
movq %rax, %rdx
movq $-0x1, %rcx
callq 0x10d0
movq -0x90(%rbp), %r14
movl (%rbx), %r12d
movl $0x0, (%rbx)
leaq -0x98(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x1080
movsd %xmm0, -0x30(%rbp)
cmpq %r14, (%r15)
je 0x156d
movl (%rbx), %eax
testl %eax, %eax
je 0x1465
cmpl $0x22, %eax
jne 0x1468
leaq 0xbdd(%rip), %rdi       # 0x203d
callq 0x1100
movl %r12d, (%rbx)
leaq -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1481
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x10c0
movq 0x2b50(%rip), %rdi      # 0x3fd8
leaq 0xba0(%rip), %rsi       # 0x202f
movl $0x4, %edx
callq 0x10e0
movq 0x2b38(%rip), %rdi      # 0x3fd8
movsd -0x30(%rbp), %xmm0
callq 0x1130
movq %rax, %rbx
leaq 0xb55(%rip), %rsi       # 0x2009
movl $0x5, %edx
movq %rax, %rdi
callq 0x10e0
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %rbx, %rdi
callq 0x10e0
movq %rax, %rbx
leaq 0xb59(%rip), %rsi       # 0x2034
movl $0x8, %edx
movq %rax, %rdi
callq 0x10e0
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %rbx, %rdi
callq 0x10e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1060
movq -0x70(%rbp), %rdi
cmpq %r13, %rdi
je 0x1537
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x10c0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x1550
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10c0
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xad5(%rip), %rdi       # 0x203d
callq 0x1050
leaq 0xac9(%rip), %rdi       # 0x203d
callq 0x1050
jmp 0x15b0
jmp 0x15ca
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x1588
movl %r12d, (%rbx)
leaq -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15b3
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x10c0
jmp 0x15b3
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x15cd
movl %r13d, (%rbx)
jmp 0x15cd
movq %rax, %r14
movq -0x70(%rbp), %rdi
cmpq %r13, %rdi
je 0x15cd
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x10c0
jmp 0x15cd
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x15e6
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10c0
movq %r14, %rdi
callq 0x1150