// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movl $0xa, 0x28(%rsp)
movl $0x14, 0x44(%rsp)
movl $0x1e, 0x40(%rsp)
xorl %r13d, %r13d
leaq 0x10(%rsp), %rbx
movq %r13, (%rbx)
movl $0x80, %edi
callq 0x31a0
movq %rax, %r14
movabsq $0x100000001, %r12      # imm = 0x100000001
movq %r12, 0x8(%rax)
leaq 0xb32a(%rip), %rbp      # 0xeb40
movq %rbp, (%rax)
leaq 0x10(%rax), %r15
movq %r15, %rdi
callq 0x3200
movq %r13, 0x60(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x40(%r14)
movw $0x0, 0x6c(%r14)
movups %xmm0, 0x70(%r14)
movq %r14, 0x8(%rbx)
movq %r15, (%rbx)
leaq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0x63b6
movq $0x0, 0x8(%rsp)
movl $0x38, %edi
callq 0x31a0
leaq 0xaf90(%rip), %rcx      # 0xe800
movq %rcx, (%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rdx
movq %rcx, 0x18(%rsp)
movq %rdx, 0x10(%rax)
movq %rcx, 0x10(%rsp)
leaq 0x27(%rsp), %rcx
movq %rcx, 0x18(%rax)
leaq 0x28(%rsp), %rcx
movq %rcx, 0x20(%rax)
leaq 0x44(%rsp), %r15
movq %r15, 0x28(%rax)
leaq 0x40(%rsp), %rcx
movq %rcx, 0x30(%rax)
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0x3180
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x38dd
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x8(%rsp), %rdi
callq 0x3270
cmpq $0x0, 0x8(%rsp)
jne 0x3de1
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x3902
callq 0x6854
movq 0x48(%rsp), %rdi
callq 0x68ce
movl (%rax), %esi
movq 0xb6bb(%rip), %rdi      # 0xefd0
callq 0x3260
leaq 0x10(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x31d0
movq $0x0, 0x10(%rsp)
movl $0xa0, %edi
callq 0x31a0
movq %rax, %rbx
movq %r12, 0x8(%rax)
leaq 0xb2a0(%rip), %r13      # 0xebf0
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 0x30(%rsp), %rdi
callq 0x6c54
movq $0x0, 0x28(%rsp)
movl $0x38, %edi
callq 0x31a0
leaq 0xae8b(%rip), %rcx      # 0xe840
movq %rcx, (%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rdx
movq %rcx, 0x18(%rsp)
movq %rdx, 0x10(%rax)
movq %rcx, 0x10(%rsp)
movq %r15, 0x18(%rax)
leaq 0x561f(%rip), %rcx      # 0x9004
movq %rcx, 0x20(%rax)
leaq 0x561a(%rip), %rcx      # 0x900a
movq %rcx, 0x28(%rax)
leaq 0x5616(%rip), %rcx      # 0x9011
movq %rcx, 0x30(%rax)
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x28(%rsp), %rdi
xorl %edx, %edx
callq 0x3180
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3a23
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x3270
cmpq $0x0, 0x28(%rsp)
jne 0x3de1
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x3a4b
callq 0x6854
movl $0xa0, %edi
callq 0x31a0
movq %rax, %r14
movq %r12, 0x8(%rax)
movq %r13, (%rax)
movq %rax, %rbx
addq $0x10, %rbx
movq %rbx, %rdi
callq 0x3200
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r14)
movups %xmm0, 0x40(%r14)
movq $0x0, 0x60(%r14)
movw $0x0, 0x88(%r14)
movups %xmm0, 0x90(%r14)
movq 0xb52c(%rip), %r13      # 0xefc8
cmpb $0x0, (%r13)
je 0x3aa9
incl 0x8(%r14)
jmp 0x3aae
lock
incl 0x8(%r14)
cmpb $0x0, (%r13)
je 0x3abb
incl 0x8(%r14)
jmp 0x3ac0
lock
incl 0x8(%r14)
movq %r14, %rdi
callq 0x6854
cmpb $0x0, (%r13)
je 0x3ad5
incl 0x8(%r14)
jmp 0x3ada
lock
incl 0x8(%r14)
movq $0x0, 0x8(%rsp)
movl $0x38, %edi
callq 0x31a0
leaq 0xad8c(%rip), %rcx      # 0xe880
movq %rcx, (%rax)
movq 0x30(%rsp), %rcx
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
movq %rcx, 0x10(%rax)
movq 0x38(%rsp), %rdx
movq %rcx, 0x38(%rsp)
movq %rdx, 0x10(%rax)
movq %rcx, 0x30(%rsp)
movq %rbx, 0x18(%rax)
movq %r14, 0x20(%rax)
movq %r15, 0x28(%rax)
leaq 0x54e8(%rip), %rcx      # 0x9014
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 0x3b54
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x8(%rsp), %rdi
callq 0x3270
cmpq $0x0, 0x8(%rsp)
jne 0x3de1
movq %r14, %rdi
callq 0x6854
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 0x3bc3
incl 0x8(%r15)
jmp 0x3bc8
lock
incl 0x8(%r15)
cmpb $0x0, (%r13)
je 0x3bd5
incl 0x8(%r15)
jmp 0x3bda
lock
incl 0x8(%r15)
movq %r15, %rdi
callq 0x6854
cmpb $0x0, (%r13)
je 0x3bef
incl 0x8(%r15)
jmp 0x3bf4
lock
incl 0x8(%r15)
movq $0x0, 0x8(%rsp)
movl $0x30, %edi
callq 0x31a0
leaq 0xacb2(%rip), %rcx      # 0xe8c0
movq %rcx, (%rax)
movq %rbx, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %r15, 0x20(%rax)
leaq 0x40(%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 0x3c4e
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x8(%rsp), %rdi
callq 0x3270
cmpq $0x0, 0x8(%rsp)
jne 0x3de1
movq %r15, %rdi
callq 0x6854
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3c7b
callq 0x6854
movq %r12, %rdi
callq 0x68ce
movl (%rax), %esi
movq 0xb344(%rip), %rdi      # 0xefd0
callq 0x3260
leaq 0x10(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x31d0
movq %r15, %rdi
callq 0x6854
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3cbd
callq 0x6854
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x8(%rsp)
jne 0x3de1
movq %rax, %rbx
xorl %r14d, %r14d
jmp 0x3d13
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3cf3
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x10(%rsp)
xorl %r14d, %r14d
xorl %edi, %edi
jmp 0x3d09
movq %rax, %rbx
movq %r15, %rdi
testq %rdi, %rdi
je 0x3d13
callq 0x6854
movq %r15, %rdi
callq 0x6854
movq %r15, %rdi
callq 0x6854
jmp 0x3d28
movq %rax, %rbx
testq %r14, %r14
jne 0x3d78
jmp 0x3d80
cmpq $0x0, 0x8(%rsp)
jne 0x3de1
movq %rax, %rbx
jmp 0x3d70
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3d53
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x10(%rsp)
xorl %edi, %edi
jmp 0x3d66
movq %rax, %rbx
movq %r14, %rdi
testq %rdi, %rdi
je 0x3d70
callq 0x6854
movq %r14, %rdi
callq 0x6854
movq %r14, %rdi
callq 0x6854
movq 0x38(%rsp), %rdi
jmp 0x3dd0
movq %rax, %rbx
jmp 0x3d80
cmpq $0x0, 0x28(%rsp)
je 0x3db4
jmp 0x3de1
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3da9
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x8(%rsp)
jmp 0x3db7
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x3dcb
callq 0x6854
jmp 0x3dcb
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
jne 0x3e28
jmp 0x3e32
jmp 0x3e2f
cmpq $0x0, 0x8(%rsp)
je 0x3e04
callq 0x3050
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x3df9
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0x30(%rsp)
jmp 0x3e07
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3e1b
callq 0x6854
jmp 0x3e1b
movq %rax, %rbx
movq 0x18(%rsp), %rdi
jmp 0x3e37
movq %rax, %rbx
movq %r15, %rdi
callq 0x6854
jmp 0x3e32
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3e41
callq 0x6854
movq %rbx, %rdi
callq 0x3280