// File: /workspace/github_cpp_makefile_star2_O3/amukherj[P]concurrencyts/future.cc
// Function: async_to_promise()
void async_to_promise() {
  std::experimental::future<int> f = std::experimental::async([](int a, int b, int x)->int {
    std::this_thread::sleep_for(std::chrono::seconds(4));
    return a + b + x;
  }, 10, 20, 30);
  std::cout << f.get() << '\n';

  auto f0 =
  std::experimental::async([](std::string a, const std::string b, std::string&& x)->std::string {
    std::this_thread::sleep_for(std::chrono::seconds(4));
    return a + " " + b + " " + x;
  }, "hello", "whats'", "up").then([](std::string s, std::string n) ->std::string {
    std::this_thread::sleep_for(std::chrono::seconds(2));
    return s + n;
  }, "?").then([](std::string s)->int {
    return s.size();
  });
  std::cout << f0.get() << '\n';
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl $0xa, 0x30(%rsp)
movl $0x14, 0x54(%rsp)
movl $0x1e, 0x3c(%rsp)
movl $0x80, %edi
callq 0x31a0
movq %rax, %rbx
movabsq $0x100000001, %r12      # imm = 0x100000001
movq %r12, 0x8(%rax)
leaq 0xa3a2(%rip), %rbp      # 0xdb78
movq %rbp, (%rax)
leaq 0x10(%rax), %r14
movq %r14, %rdi
callq 0x3200
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movq $0x0, 0x60(%rbx)
movw $0x0, 0x6c(%rbx)
movups %xmm0, 0x70(%rbx)
leaq 0x10(%rsp), %rsi
movq %rbx, 0x8(%rsi)
movq %r14, (%rsi)
leaq 0x58(%rsp), %rdi
callq 0x622c
movq $0x0, 0x8(%rsp)
movl $0x38, %edi
callq 0x31a0
leaq 0xa006(%rip), %rcx      # 0xd838
movq %rcx, (%rax)
movaps 0x10(%rsp), %xmm0
xorl %ecx, %ecx
movq %rcx, 0x18(%rsp)
movups %xmm0, 0x8(%rax)
movq %rcx, 0x10(%rsp)
leaq 0x2f(%rsp), %rcx
movq %rcx, 0x18(%rax)
leaq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rax)
leaq 0x54(%rsp), %r15
movq %r15, 0x28(%rax)
leaq 0x3c(%rsp), %rcx
movq %rcx, 0x30(%rax)
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0x3180
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x3892
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x8(%rsp), %rdi
callq 0x3270
cmpq $0x0, 0x8(%rsp)
jne 0x3d60
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x38b7
callq 0x66d0
movq 0x58(%rsp), %rdi
callq 0x674a
movl (%rax), %esi
movq 0xa706(%rip), %rdi      # 0xdfd0
callq 0x3260
leaq 0x10(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x31d0
movl $0xa0, %edi
callq 0x31a0
movq %rax, %rbx
movq %r12, 0x8(%rax)
leaq 0xa2f4(%rip), %r13      # 0xdbf0
movq %r13, (%rax)
movq %rax, %r14
addq $0x10, %r14
movq %r14, %rdi
callq 0x3200
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movq $0x0, 0x60(%rbx)
movw $0x0, 0x88(%rbx)
movups %xmm0, 0x90(%rbx)
leaq 0x10(%rsp), %rsi
movq %rbx, 0x8(%rsi)
movq %r14, (%rsi)
leaq 0x40(%rsp), %rdi
callq 0x6abe
movq $0x0, 0x30(%rsp)
movl $0x38, %edi
callq 0x31a0
leaq 0x9f17(%rip), %rcx      # 0xd878
movq %rcx, (%rax)
movaps 0x10(%rsp), %xmm0
xorl %ecx, %ecx
movq %rcx, 0x18(%rsp)
movups %xmm0, 0x8(%rax)
movq %rcx, 0x10(%rsp)
movq %r15, 0x18(%rax)
leaq 0x4680(%rip), %rcx      # 0x8004
movq %rcx, 0x20(%rax)
leaq 0x467b(%rip), %rcx      # 0x800a
movq %rcx, 0x28(%rax)
leaq 0x4677(%rip), %rcx      # 0x8011
movq %rcx, 0x30(%rax)
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
callq 0x3180
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x39c2
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x3270
cmpq $0x0, 0x30(%rsp)
jne 0x3d60
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x39ea
callq 0x66d0
movl $0xa0, %edi
callq 0x31a0
movq %rax, %rbx
movq %r12, 0x8(%rax)
movq %r13, (%rax)
movq %rax, %r14
addq $0x10, %r14
movq %r14, %rdi
callq 0x3200
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movq $0x0, 0x60(%rbx)
movw $0x0, 0x88(%rbx)
movups %xmm0, 0x90(%rbx)
movq 0xa591(%rip), %r13      # 0xdfc8
cmpb $0x0, (%r13)
je 0x3a48
movl 0x8(%rbx), %eax
incl %eax
movl %eax, 0x8(%rbx)
jmp 0x3a5a
lock
incl 0x8(%rbx)
cmpb $0x0, (%r13)
je 0x3c65
movl 0x8(%rbx), %eax
incl %eax
movl %eax, 0x8(%rbx)
movq %rbx, %rdi
callq 0x66d0
cmpb $0x0, (%r13)
je 0x3a73
incl 0x8(%rbx)
jmp 0x3a77
lock
incl 0x8(%rbx)
movq $0x0, 0x8(%rsp)
movl $0x38, %edi
callq 0x31a0
leaq 0x9e27(%rip), %rcx      # 0xd8b8
movq %rcx, (%rax)
movaps 0x40(%rsp), %xmm0
xorl %ecx, %ecx
movq %rcx, 0x48(%rsp)
movups %xmm0, 0x8(%rax)
movq %rcx, 0x40(%rsp)
movq %r14, 0x18(%rax)
movq %rbx, 0x20(%rax)
movq %r15, 0x28(%rax)
leaq 0x4558(%rip), %rcx      # 0x8014
movq %rcx, 0x30(%rax)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0x3180
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3ae4
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x8(%rsp), %rdi
callq 0x3270
cmpq $0x0, 0x8(%rsp)
jne 0x3d60
movq %rbx, %rdi
callq 0x66d0
movl $0x80, %edi
callq 0x31a0
movq %rax, %r15
movq %r12, 0x8(%rax)
movq %rbp, (%rax)
movq %rax, %r12
addq $0x10, %r12
movq %r12, %rdi
callq 0x3200
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r15)
movups %xmm0, 0x40(%r15)
movq $0x0, 0x60(%r15)
movw $0x0, 0x6c(%r15)
movups %xmm0, 0x70(%r15)
cmpb $0x0, (%r13)
je 0x3b59
movl 0x8(%r15), %eax
incl %eax
movl %eax, 0x8(%r15)
jmp 0x3b6d
lock
incl 0x8(%r15)
cmpb $0x0, (%r13)
je 0x3c6e
movl 0x8(%r15), %eax
incl %eax
movl %eax, 0x8(%r15)
movq %r15, %rdi
callq 0x66d0
cmpb $0x0, (%r13)
je 0x3b88
incl 0x8(%r15)
jmp 0x3b8d
lock
incl 0x8(%r15)
movq $0x0, 0x8(%rsp)
movl $0x30, %edi
callq 0x31a0
leaq 0x9d51(%rip), %rcx      # 0xd8f8
movq %rcx, (%rax)
movq %r14, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %r15, 0x20(%rax)
leaq 0x3c(%rsp), %rcx
movq %rcx, 0x28(%rax)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0x3180
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3be7
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x8(%rsp), %rdi
callq 0x3270
cmpq $0x0, 0x8(%rsp)
jne 0x3d60
movq %r15, %rdi
callq 0x66d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x3c14
callq 0x66d0
movq %r12, %rdi
callq 0x674a
movl (%rax), %esi
movq 0xa3ab(%rip), %rdi      # 0xdfd0
callq 0x3260
leaq 0x10(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x31d0
movq %r15, %rdi
callq 0x66d0
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3c56
callq 0x66d0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
lock
incl 0x8(%rbx)
jmp 0x3a5f
lock
incl 0x8(%r15)
jmp 0x3b73
cmpq $0x0, 0x8(%rsp)
jne 0x3d60
movq %rax, %r14
jmp 0x3c9c
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3c9c
movq (%rdi), %rax
callq *0x8(%rax)
xorl %ebx, %ebx
jmp 0x3cab
movq %rax, %r14
movq %r15, %rdi
callq 0x66d0
movq %r15, %rdi
callq 0x66d0
movq %r15, %rdi
callq 0x66d0
testq %rbx, %rbx
jne 0x3d00
jmp 0x3d08
movq %rax, %r14
jmp 0x3d00
cmpq $0x0, 0x8(%rsp)
jne 0x3d60
movq %rax, %r14
jmp 0x3cf8
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3cf8
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3cf8
movq %rax, %r14
movq %rbx, %rdi
callq 0x66d0
movq %rbx, %rdi
callq 0x66d0
movq %rbx, %rdi
callq 0x66d0
movq 0x48(%rsp), %rdi
jmp 0x3d4f
movq %rax, %r14
jmp 0x3d08
cmpq $0x0, 0x30(%rsp)
je 0x3d33
jmp 0x3d60
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3d36
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3d36
movq %rax, %r14
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x3d4a
callq 0x66d0
jmp 0x3d4a
movq %rax, %r14
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
jne 0x3d9e
jmp 0x3da8
jmp 0x3da5
cmpq $0x0, 0x8(%rsp)
je 0x3d7a
callq 0x3050
movq %rax, %r14
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x3d7d
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3d7d
movq %rax, %r14
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3d91
callq 0x66d0
jmp 0x3d91
movq %rax, %r14
movq 0x18(%rsp), %rdi
jmp 0x3dad
movq %rax, %r14
movq %r15, %rdi
callq 0x66d0
jmp 0x3da8
movq %rax, %r14
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3db7
callq 0x66d0
movq %r14, %rdi
callq 0x3280