// File: /workspace/github_cpp_makefile_star2_O3/halfflat[P]tinyopt/test/test_maybe.cc
// Function: maybe_conditional_apply_arg_Test::TestBody()
TEST(maybe, conditional_apply_arg) {
    int c = 0;
    auto f = [&c](int n) { c += n; };

    EXPECT_TRUE(f << maybe<int>(22));
    EXPECT_EQ(22, c);

    EXPECT_FALSE(f << maybe<int>());
    EXPECT_EQ(22, c);

    EXPECT_TRUE(f << maybe<double>(-7));
    EXPECT_EQ(15, c);

    c = 100;
    auto g = [&c](int n) { c += n; return n+1; };

    auto r1 = g << maybe<int>(10);
    ASSERT_TRUE(r1);
    EXPECT_EQ(11, r1.value());
    EXPECT_EQ(110, c);

    auto r2 = g << maybe<int>();
    EXPECT_FALSE(r2);
    EXPECT_EQ(110, c);
}

// Assembly:
pushq %rbx
subq $0x30, %rsp
movl $0x16, %eax
leaq 0x2c(%rsp), %r8
movl %eax, (%r8)
leaq 0x18(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x55856(%rip), %rsi     # 0x6cb64
leaq 0x55cba(%rip), %rdx     # 0x6cfcf
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x157b7
cmpb $0x0, (%rbx)
jne 0x17385
leaq 0x18(%rsp), %rdi
callq 0x4ca86
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x17340
movq (%rax), %r8
jmp 0x17347
leaq 0x57c8e(%rip), %r8      # 0x6efd5
leaq 0x55751(%rip), %rdx     # 0x6ca9f
movq %rsp, %rdi
movl $0x1, %esi
movl $0x76, %ecx
callq 0x4902a
movq %rsp, %rdi
leaq 0x18(%rsp), %rsi
callq 0x46a1c
movq %rsp, %rdi
callq 0x49096
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x17385
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x17399
leaq 0x10(%rsp), %rdi
callq 0x153ca
leaq 0x18(%rsp), %rcx
movl $0x16, (%rcx)
leaq 0x557b9(%rip), %rsi     # 0x6cb64
leaq 0x55c1d(%rip), %rdx     # 0x6cfcf
leaq 0x8(%rsp), %rbx
leaq 0x2c(%rsp), %r8
movq %rbx, %rdi
callq 0x157b7
cmpb $0x0, (%rbx)
jne 0x17427
leaq 0x18(%rsp), %rdi
callq 0x4ca86
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x173e2
movq (%rax), %r8
jmp 0x173e9
leaq 0x57bec(%rip), %r8      # 0x6efd5
leaq 0x556af(%rip), %rdx     # 0x6ca9f
movq %rsp, %rdi
movl $0x1, %esi
movl $0x79, %ecx
callq 0x4902a
movq %rsp, %rdi
leaq 0x18(%rsp), %rsi
callq 0x46a1c
movq %rsp, %rdi
callq 0x49096
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x17427
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x1743b
leaq 0x10(%rsp), %rdi
callq 0x153ca
leaq 0x2c(%rsp), %r8
addl $-0x7, (%r8)
leaq 0x18(%rsp), %rcx
movl $0xf, (%rcx)
leaq 0x55711(%rip), %rsi     # 0x6cb67
leaq 0x55b72(%rip), %rdx     # 0x6cfcf
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x157b7
cmpb $0x0, (%rbx)
jne 0x174cd
leaq 0x18(%rsp), %rdi
callq 0x4ca86
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x17488
movq (%rax), %r8
jmp 0x1748f
leaq 0x57b46(%rip), %r8      # 0x6efd5
leaq 0x55609(%rip), %rdx     # 0x6ca9f
movq %rsp, %rdi
movl $0x1, %esi
movl $0x7c, %ecx
callq 0x4902a
movq %rsp, %rdi
leaq 0x18(%rsp), %rsi
callq 0x46a1c
movq %rsp, %rdi
callq 0x49096
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x174cd
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x174e1
leaq 0x10(%rsp), %rdi
callq 0x153ca
movl $0x6e, 0x2c(%rsp)
movl $0xb, %eax
leaq 0x18(%rsp), %rdi
movl %eax, 0x4(%rdi)
movb $0x1, (%rdi)
movl %eax, (%rsp)
callq 0x17bb4
leaq 0x1c(%rsp), %r8
leaq 0x5565d(%rip), %rsi     # 0x6cb6a
leaq 0x55659(%rip), %rdx     # 0x6cb6d
leaq 0x8(%rsp), %rdi
movq %rsp, %rcx
callq 0x157b7
cmpb $0x0, 0x8(%rsp)
jne 0x17587
movq %rsp, %rdi
callq 0x4ca86
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x1753f
movq (%rax), %r8
jmp 0x17546
leaq 0x57a8f(%rip), %r8      # 0x6efd5
leaq 0x55552(%rip), %rdx     # 0x6ca9f
leaq 0x20(%rsp), %rdi
movl $0x1, %esi
movl $0x83, %ecx
callq 0x4902a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x46a1c
leaq 0x20(%rsp), %rdi
callq 0x49096
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x17587
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x1759b
leaq 0x10(%rsp), %rdi
callq 0x153ca
movq %rsp, %rcx
movl $0x6e, (%rcx)
leaq 0x555cd(%rip), %rsi     # 0x6cb78
leaq 0x55a1d(%rip), %rdx     # 0x6cfcf
leaq 0x8(%rsp), %rdi
leaq 0x2c(%rsp), %r8
callq 0x157b7
cmpb $0x0, 0x8(%rsp)
jne 0x17627
movq %rsp, %rdi
callq 0x4ca86
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x175df
movq (%rax), %r8
jmp 0x175e6
leaq 0x579ef(%rip), %r8      # 0x6efd5
leaq 0x554b2(%rip), %rdx     # 0x6ca9f
leaq 0x20(%rsp), %rdi
movl $0x1, %esi
movl $0x84, %ecx
callq 0x4902a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x46a1c
leaq 0x20(%rsp), %rdi
callq 0x49096
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x17627
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x1763b
leaq 0x10(%rsp), %rdi
callq 0x153ca
movq %rsp, %rcx
movl $0x6e, (%rcx)
leaq 0x5552d(%rip), %rsi     # 0x6cb78
leaq 0x5597d(%rip), %rdx     # 0x6cfcf
leaq 0x8(%rsp), %rdi
leaq 0x2c(%rsp), %r8
callq 0x157b7
cmpb $0x0, 0x8(%rsp)
jne 0x176c7
movq %rsp, %rdi
callq 0x4ca86
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x1767f
movq (%rax), %r8
jmp 0x17686
leaq 0x5794f(%rip), %r8      # 0x6efd5
leaq 0x55412(%rip), %rdx     # 0x6ca9f
leaq 0x20(%rsp), %rdi
movl $0x1, %esi
movl $0x88, %ecx
callq 0x4902a
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x46a1c
leaq 0x20(%rsp), %rdi
callq 0x49096
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x176c7
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x176db
leaq 0x10(%rsp), %rdi
callq 0x153ca
addq $0x30, %rsp
popq %rbx
retq
jmp 0x176ed
jmp 0x176fc
jmp 0x17735
jmp 0x176ed
jmp 0x176fc
jmp 0x17735
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x49096
jmp 0x176ff
movq %rax, %rbx
movq (%rsp), %rdi
jmp 0x17728
jmp 0x17735
jmp 0x17711
jmp 0x17720
jmp 0x17711
jmp 0x17735
jmp 0x17720
movq %rax, %rbx
movq %rsp, %rdi
callq 0x49096
jmp 0x17723
jmp 0x17735
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x17738
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x17738
movq %rax, %rbx
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x17755
leaq 0x10(%rsp), %rdi
callq 0x153ca
jmp 0x17755
jmp 0x17752
jmp 0x17752
movq %rax, %rbx
movq %rbx, %rdi
callq 0xda70
nop