// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0xa8, %rsp
movl $0xa, 0x88(%rsp)
movl $0x14, 0x70(%rsp)
movl $0x1e, 0x60(%rsp)
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x5c43
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0x55d6
andq $0x0, 0x18(%rsp)
pushq $0x38
popq %rdi
callq 0x31a0
movaps 0x40(%rsp), %xmm0
andq $0x0, 0x48(%rsp)
leaq 0xb0fc(%rip), %rcx      # 0xe828
andq $0x0, 0x40(%rsp)
movq %rcx, (%rax)
movups %xmm0, 0x8(%rax)
leaq 0x38(%rsp), %rcx
movq %rcx, 0x18(%rax)
leaq 0x88(%rsp), %rcx
movq %rcx, 0x20(%rax)
leaq 0x70(%rsp), %rcx
movq %rcx, 0x28(%rax)
leaq 0x60(%rsp), %rcx
movq %rcx, 0x30(%rax)
leaq 0x28(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x18(%rsp), %rdi
xorl %edx, %edx
callq 0x3170
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3784
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x18(%rsp), %rdi
callq 0x3290
leaq 0x48(%rsp), %rbx
leaq 0x18(%rsp), %rdi
callq 0x55a8
movq %rbx, %rdi
callq 0x594e
movq 0x98(%rsp), %rdi
callq 0x5a32
movl (%rax), %esi
movq 0xb815(%rip), %rdi      # 0xefd0
callq 0x3280
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x31d0
leaq 0x40(%rsp), %rdi
callq 0x5f93
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x5f5c
andq $0x0, 0x18(%rsp)
pushq $0x38
popq %rdi
callq 0x31a0
movaps 0x40(%rsp), %xmm0
andq $0x0, 0x48(%rsp)
leaq 0xb064(%rip), %rcx      # 0xe868
andq $0x0, 0x40(%rsp)
movq %rcx, (%rax)
movups %xmm0, 0x8(%rax)
leaq 0x17(%rsp), %rcx
movq %rcx, 0x18(%rax)
leaq 0x47e3(%rip), %rcx      # 0x8004
movq %rcx, 0x20(%rax)
leaq 0x47de(%rip), %rcx      # 0x800a
movq %rcx, 0x28(%rax)
leaq 0x47da(%rip), %rcx      # 0x8011
movq %rcx, 0x30(%rax)
leaq 0x28(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x18(%rsp), %rdi
xorl %edx, %edx
callq 0x3170
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x385f
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x18(%rsp), %rdi
callq 0x3290
leaq 0x48(%rsp), %rbx
leaq 0x18(%rsp), %rdi
callq 0x55a8
movq %rbx, %rdi
callq 0x594e
leaq 0x28(%rsp), %rdi
callq 0x5f93
leaq 0x18(%rsp), %rbx
leaq 0x28(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6174
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x6174
leaq 0x20(%rsp), %rdi
callq 0x594e
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6174
leaq 0x16(%rsp), %rax
movq %rax, 0x10(%rbx)
leaq 0x473e(%rip), %rax      # 0x8014
movq %rax, 0x18(%rbx)
andq $0x0, 0x8(%rsp)
pushq $0x38
popq %rdi
callq 0x31a0
leaq 0x50(%rsp), %rcx
leaq 0xafb4(%rip), %rdx      # 0xe8a8
movq %rdx, (%rax)
movaps 0x60(%rsp), %xmm0
andq $0x0, 0x68(%rsp)
movups %xmm0, 0x8(%rax)
andq $0x0, 0x60(%rsp)
movaps -0x10(%rcx), %xmm0
andq $0x0, -0x8(%rcx)
movups %xmm0, 0x18(%rax)
andq $0x0, -0x10(%rcx)
movups (%rcx), %xmm0
movups %xmm0, 0x28(%rax)
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0x3170
leaq 0x48(%rsp), %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x394e
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x594e
leaq 0x8(%rsp), %rdi
callq 0x3290
leaq 0x8(%rsp), %rdi
callq 0x55a8
leaq 0x30(%rsp), %rdi
callq 0x594e
leaq 0x28(%rsp), %rdi
callq 0x5c43
leaq 0x18(%rsp), %rbx
leaq 0x28(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5de2
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
callq 0x5de2
leaq 0x20(%rsp), %rdi
callq 0x594e
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5de2
leaq 0x15(%rsp), %r14
movq %r14, 0x10(%rbx)
andq $0x0, 0x8(%rsp)
pushq $0x30
popq %rdi
callq 0x31a0
leaq 0xaf0d(%rip), %rcx      # 0xe8e8
movaps 0x70(%rsp), %xmm0
andq $0x0, 0x78(%rsp)
movq %rcx, (%rax)
andq $0x0, 0x70(%rsp)
movaps 0x40(%rsp), %xmm1
andq $0x0, 0x48(%rsp)
movups %xmm0, 0x8(%rax)
andq $0x0, 0x40(%rsp)
movups %xmm1, 0x18(%rax)
movq %r14, 0x28(%rax)
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0x3170
leaq 0x48(%rsp), %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3a35
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x594e
leaq 0x8(%rsp), %rdi
callq 0x3290
leaq 0x68(%rsp), %rbx
leaq 0x78(%rsp), %r14
leaq 0x8(%rsp), %rdi
callq 0x55a8
leaq 0x30(%rsp), %rdi
callq 0x594e
movq %r14, %rdi
callq 0x594e
movq %rbx, %rdi
callq 0x594e
movq 0x88(%rsp), %rdi
callq 0x5a32
movl (%rax), %esi
movq 0xb545(%rip), %rdi      # 0xefd0
callq 0x3280
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x31d0
leaq 0x90(%rsp), %rdi
callq 0x594e
leaq 0xa0(%rsp), %rdi
callq 0x594e
addq $0xa8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x55a8
jmp 0x3af1
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3ae7
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3ae7
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x594e
leaq 0x90(%rsp), %rdi
callq 0x594e
leaq 0x30(%rsp), %rdi
callq 0x594e
jmp 0x3b0d
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0x3b54
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x55a8
jmp 0x3b45
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3b3b
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3b3b
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x594e
leaq 0x78(%rsp), %rdi
callq 0x594e
leaq 0x30(%rsp), %rdi
callq 0x594e
leaq 0x68(%rsp), %rdi
jmp 0x3bf2
movq %rax, %rbx
jmp 0x3b59
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x55a8
jmp 0x3b8f
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3b8f
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3b8f
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x594e
jmp 0x3b9e
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x3bf2
jmp 0x3bf9
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x55a8
jmp 0x3bce
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x3bce
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3bce
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x594e
jmp 0x3be0
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x3c04
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x594e
jmp 0x3bfc
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x594e
movq %rbx, %rdi
callq 0x32a0