// File: /workspace/github_cpp_makefile_star2_O3/masaers[P]blind/blind_test.cpp
// Function: main
int main(const int argc, const char** argv) {
  using namespace std;
  using namespace com::masaers::blind;
  using namespace std::placeholders;

  {
    const auto f = blind(foo(), 1);
    int i = 2;
    int j = f(cref(i));
    f(i);
    assert(i == 3);
    assert(j == 3);
  }
  {
    const auto f = blind(foo2(), _1, 1);
    int i = 2;
    int j = f(cref(i));
    f(i);
    assert(i == 3);
    assert(j == 3);
  }

  {
    const auto rsort = blind(BLIND_FUNC(sort), _1, _2, [](auto&& a, auto&& b) { return a > b; });
    vector<int> vec{ 1, 2, 3, 4 };
    rsort(begin(vec), end(vec));
    {
      auto it = begin(vec);
      assert(*it++ == 4);
      assert(*it++ == 3);
      assert(*it++ == 2);
      assert(*it++ == 1);
      assert(it == end(vec));
    }

    deque<string> dq{ "a", "b", "c", "d" };
    rsort(begin(dq), end(dq));
    {
      auto it = begin(dq);
      assert(*it++ == "d");
      assert(*it++ == "c");
      assert(*it++ == "b");
      assert(*it++ == "a");
      assert(it == end(dq));
    }
  }
  {
    ostringstream os;
    const auto p = blind(BLIND_FUNC(print), ref(os));
    p(1, 1.0, '1', "1") << 2;
    assert(os.str() == "11112");
  }
  {
    vector<int> vec{ 1, 2, 3, 4 };
    auto sort_vec = blind(BLIND_FUNC(sort), begin(vec), end(vec));
    sort_vec([](auto&& a, auto&& b) { return a > b; });
    {
      auto it = begin(vec);
      assert(*it++ == 4);
      assert(*it++ == 3);
      assert(*it++ == 2);
      assert(*it++ == 1);
      assert(it == end(vec));
    }
    sort_vec();
    {
      auto it = begin(vec);
      assert(*it++ == 1);
      assert(*it++ == 2);
      assert(*it++ == 3);
      assert(*it++ == 4);
      assert(it == end(vec));
    }
  }
  {
    auto f = blind(BLIND_FUNC(bar<int, int>), _1, 1);
    assert(f(2) == 3);
  }
  return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movaps 0x2c68(%rip), %xmm0     # 0x5010
leaq 0xc0(%rsp), %rsi
movaps %xmm0, (%rsi)
leaq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rcx
movl $0x4, %edx
callq 0x4258
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %rbx
cmpq %rbx, %r15
je 0x2446
movq %rbx, %r14
subq %r15, %r14
movq %r14, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2e71
cmpq $0x41, %r14
jl 0x243b
leaq 0x40(%r15), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x3083
cmpq %rbx, %r14
je 0x2446
movl -0x4(%r14), %ecx
movl (%r14), %eax
movq %r14, %rdx
cmpl %eax, %ecx
jge 0x2433
movq %r14, %rdx
movl %ecx, (%rdx)
movl -0x8(%rdx), %ecx
addq $-0x4, %rdx
cmpl %eax, %ecx
jl 0x2426
movl %eax, (%rdx)
addq $0x4, %r14
jmp 0x2410
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3083
movq 0x8(%rsp), %rax
cmpl $0x4, (%rax)
jne 0x2b38
cmpl $0x3, 0x4(%rax)
jne 0x2b57
cmpl $0x2, 0x8(%rax)
jne 0x2b76
cmpl $0x1, 0xc(%rax)
jne 0x2b95
addq $0x10, %rax
cmpq 0x10(%rsp), %rax
jne 0x2bb4
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2c01(%rip), %rsi      # 0x5095
leaq 0x2bfb(%rip), %rdx      # 0x5096
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
callq 0x49a4
leaq 0xe0(%rsp), %r15
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2bd1(%rip), %rsi      # 0x5097
leaq 0x2bcb(%rip), %rdx      # 0x5098
movq %r15, %rdi
callq 0x49a4
leaq 0x100(%rsp), %r15
leaq 0x110(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2ba9(%rip), %rsi      # 0x5099
leaq 0x2ba3(%rip), %rdx      # 0x509a
movq %r15, %rdi
callq 0x49a4
leaq 0x120(%rsp), %r15
leaq 0x130(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x2c36(%rip), %rsi      # 0x5150
leaq 0x2c30(%rip), %rdx      # 0x5151
movq %r15, %rdi
callq 0x49a4
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
leaq 0x140(%rsp), %r14
leaq 0xc0(%rsp), %rsi
movq %r14, %rdx
callq 0x4a3a
movq $-0x80, %r14
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0x2577
movq (%rbx), %rsi
incq %rsi
callq 0x2130
addq $-0x20, %rbx
addq $0x20, %r14
jne 0x2563
movq 0x30(%rsp), %rbx
movq 0x40(%rsp), %r13
movq 0x48(%rsp), %r15
movq 0x50(%rsp), %rdx
cmpq %rdx, %rbx
je 0x27f2
movq 0x38(%rsp), %rbp
movq 0x58(%rsp), %r8
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %r14
leaq 0x258(%rsp), %rdi
movq %rbx, (%rdi)
movq %rbp, 0x8(%rdi)
movq %r13, 0x10(%rdi)
movq %r15, 0x18(%rdi)
leaq 0x238(%rsp), %rsi
movq %rdx, (%rsi)
movq %r8, 0x8(%rsi)
movq %rax, 0x70(%rsp)
movq %rax, 0x10(%rsi)
movq %r14, 0x18(%rsi)
movq %r14, %rax
subq %r15, %rax
shrq $0x3, %rax
cmpq $0x1, %r14
adcq $-0x1, %rax
shlq $0x4, %rax
movq %rdx, %rcx
movq %r8, 0x78(%rsp)
subq %r8, %rcx
sarq $0x5, %rcx
movq %rdx, (%rsp)
movq %r13, %r12
subq %rbx, %r12
sarq $0x5, %r12
addq %rcx, %r12
addq %rax, %r12
bsrq %r12, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
callq 0x30f8
cmpq $0x11, %r12
jl 0x26ac
movq (%rsp), %r12
movq %rbx, 0x80(%rsp)
movq %rbp, 0x88(%rsp)
movq %r13, 0x90(%rsp)
movq %r15, 0x98(%rsp)
movq %rbp, 0xa8(%rsp)
movq %r13, 0xb0(%rsp)
movq %r15, 0xb8(%rsp)
movq %rbx, %r14
subq %rbp, %r14
sarq $0x5, %r14
leaq 0x10(%r14), %rdi
cmpq $-0x10, %r14
jl 0x26f2
jb 0x26fb
leaq 0x200(%rbx), %rax
leaq 0xa0(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x80(%rsp), %rdi
callq 0x3c82
jmp 0x2751
leaq 0xc0(%rsp), %rdi
movq %rbx, (%rdi)
movq %rbp, 0x8(%rdi)
movq %r13, 0x10(%rdi)
movq %r15, 0x18(%rdi)
leaq 0x80(%rsp), %rsi
movq (%rsp), %rax
movq %rax, (%rsi)
movq 0x78(%rsp), %rax
movq %rax, 0x8(%rsi)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsi)
movq %r14, 0x18(%rsi)
callq 0x3c82
jmp 0x27e3
movq %rdi, %rax
sarq $0x4, %rax
jmp 0x2702
movq %rdi, %rax
shrq $0x4, %rax
leaq (%r15,%rax,8), %rcx
leaq 0xa0(%rsp), %rsi
movq %rcx, 0x18(%rsi)
movq (%rcx), %rcx
movq %rcx, 0x8(%rsi)
leaq 0x200(%rcx), %rdx
movq %rdx, 0x10(%rsi)
shlq $0x4, %rax
movq %rdi, (%rsp)
movq %rdi, %rdx
subq %rax, %rdx
shlq $0x5, %rdx
addq %rcx, %rdx
movq %rdx, (%rsi)
leaq 0x80(%rsp), %rdi
callq 0x3c82
cmpq $-0x10, %r14
jl 0x275a
jb 0x2767
addq $0x200, %rbx            # imm = 0x200
jmp 0x278e
movq (%rsp), %rbx
movq %rbx, %rax
sarq $0x4, %rax
jmp 0x2772
movq (%rsp), %rbx
movq %rbx, %rax
shrq $0x4, %rax
leaq (%r15,%rax,8), %r15
movq (%r15), %rbp
leaq 0x200(%rbp), %r13
shlq $0x4, %rax
subq %rax, %rbx
shlq $0x5, %rbx
addq %rbp, %rbx
cmpq %r12, %rbx
je 0x27e3
leaq 0xc0(%rsp), %r14
movq %rbx, 0xc0(%rsp)
movq %rbp, 0xc8(%rsp)
movq %r13, 0xd0(%rsp)
movq %r15, 0xd8(%rsp)
movq %r14, %rdi
callq 0x3edb
addq $0x20, %rbx
cmpq %r13, %rbx
jne 0x27de
movq 0x8(%r15), %rbp
addq $0x8, %r15
leaq 0x200(%rbp), %r13
movq %rbp, %rbx
cmpq %r12, %rbx
jne 0x279b
movq 0x30(%rsp), %rbx
movq 0x40(%rsp), %r13
movq 0x48(%rsp), %r15
leaq 0x20(%rbx), %r14
cmpq %r13, %r14
jne 0x280a
movq 0x8(%r15), %r14
addq $0x8, %r15
leaq 0x200(%r14), %r13
leaq 0x293f(%rip), %rsi      # 0x5150
movq %rbx, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2bd3
leaq 0x20(%r14), %rbx
cmpq %r13, %rbx
jne 0x2839
movq 0x8(%r15), %rbx
addq $0x8, %r15
leaq 0x200(%rbx), %r13
leaq 0x2859(%rip), %rsi      # 0x5099
movq %r14, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2bf2
leaq 0x20(%rbx), %r14
cmpq %r13, %r14
jne 0x2868
movq 0x8(%r15), %r14
addq $0x8, %r15
leaq 0x200(%r14), %r13
leaq 0x2828(%rip), %rsi      # 0x5097
movq %rbx, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2c11
leaq 0x20(%r14), %rbx
cmpq %r13, %rbx
jne 0x288c
movq 0x8(%r15), %rbx
leaq 0x2802(%rip), %rsi      # 0x5095
movq %r14, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2c30
cmpq 0x50(%rsp), %rbx
jne 0x2c4f
leaq 0x20(%rsp), %rdi
callq 0x429e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x28cf
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
callq 0x2160
movb $0x31, 0x20(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x21d0
leaq 0xc0(%rsp), %rdi
movsd 0x271f(%rip), %xmm0     # 0x5020
callq 0x21a0
leaq 0x2777(%rip), %rdx      # 0x5084
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x459d
movq %rax, %rdi
movl $0x2, %esi
callq 0x21d0
leaq 0xc8(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x2190
leaq 0x2798(%rip), %rsi      # 0x50dd
leaq 0x20(%rsp), %rdi
callq 0x2050
testl %eax, %eax
jne 0x2c6e
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2972
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x565f(%rip), %rsi      # 0x7fd8
leaq 0xc0(%rsp), %rdi
callq 0x20b0
leaq 0x130(%rsp), %rdi
callq 0x2060
leaq 0x20(%rsp), %rsi
movaps 0x2671(%rip), %xmm0     # 0x5010
movaps %xmm0, (%rsi)
leaq 0xc0(%rsp), %rdi
leaq 0x80(%rsp), %rcx
movl $0x4, %edx
callq 0x4258
movq 0xc0(%rsp), %rbx
movq 0xc8(%rsp), %r14
cmpq %r14, %rbx
je 0x2a41
movq %r14, %r15
subq %rbx, %r15
movq %r15, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3fd0
cmpq $0x41, %r15
jl 0x2a36
leaq 0x40(%rbx), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x41e2
cmpq %r14, %r15
je 0x2a41
movl -0x4(%r15), %ecx
movl (%r15), %eax
movq %r15, %rdx
cmpl %eax, %ecx
jge 0x2a2e
movq %r15, %rdx
movl %ecx, (%rdx)
movl -0x8(%rdx), %ecx
addq $-0x4, %rdx
cmpl %eax, %ecx
jl 0x2a21
movl %eax, (%rdx)
addq $0x4, %r15
jmp 0x2a0b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x41e2
movq 0xc0(%rsp), %rax
cmpl $0x4, (%rax)
jne 0x2c8d
cmpl $0x3, 0x4(%rax)
jne 0x2cac
cmpl $0x2, 0x8(%rax)
jne 0x2ccb
cmpl $0x1, 0xc(%rax)
jne 0x2cea
addq $0x10, %rax
cmpq 0xc8(%rsp), %rax
jne 0x2d09
cmpq %r14, %rbx
je 0x2b19
movq %r14, %rax
subq %rbx, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x45db
movq %rbx, %rdi
movq %r14, %rsi
callq 0x46be
movq 0xc0(%rsp), %rdi
cmpl $0x1, (%rdi)
jne 0x2b19
cmpl $0x2, 0x4(%rdi)
jne 0x2d28
cmpl $0x3, 0x8(%rdi)
jne 0x2d47
cmpl $0x4, 0xc(%rdi)
jne 0x2d66
leaq 0x10(%rdi), %rax
cmpq 0xc8(%rsp), %rax
jne 0x2d85
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
xorl %eax, %eax
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x255b(%rip), %rdi      # 0x507b
leaq 0x2501(%rip), %rsi      # 0x5028
leaq 0x2509(%rip), %rcx      # 0x5037
movl $0x67, %edx
callq 0x20c0
leaq 0x251b(%rip), %rdi      # 0x505a
leaq 0x24e2(%rip), %rsi      # 0x5028
leaq 0x24ea(%rip), %rcx      # 0x5037
movl $0x40, %edx
callq 0x20c0
leaq 0x2507(%rip), %rdi      # 0x5065
leaq 0x24c3(%rip), %rsi      # 0x5028
leaq 0x24cb(%rip), %rcx      # 0x5037
movl $0x41, %edx
callq 0x20c0
leaq 0x24f3(%rip), %rdi      # 0x5070
leaq 0x24a4(%rip), %rsi      # 0x5028
leaq 0x24ac(%rip), %rcx      # 0x5037
movl $0x42, %edx
callq 0x20c0
leaq 0x24df(%rip), %rdi      # 0x507b
leaq 0x2485(%rip), %rsi      # 0x5028
leaq 0x248d(%rip), %rcx      # 0x5037
movl $0x43, %edx
callq 0x20c0
leaq 0x24cb(%rip), %rdi      # 0x5086
leaq 0x2466(%rip), %rsi      # 0x5028
leaq 0x246e(%rip), %rcx      # 0x5037
movl $0x44, %edx
callq 0x20c0
leaq 0x24c1(%rip), %rdi      # 0x509b
leaq 0x2447(%rip), %rsi      # 0x5028
leaq 0x244f(%rip), %rcx      # 0x5037
movl $0x4b, %edx
callq 0x20c0
leaq 0x24af(%rip), %rdi      # 0x50a8
leaq 0x2428(%rip), %rsi      # 0x5028
leaq 0x2430(%rip), %rcx      # 0x5037
movl $0x4c, %edx
callq 0x20c0
leaq 0x249d(%rip), %rdi      # 0x50b5
leaq 0x2409(%rip), %rsi      # 0x5028
leaq 0x2411(%rip), %rcx      # 0x5037
movl $0x4d, %edx
callq 0x20c0
leaq 0x248b(%rip), %rdi      # 0x50c2
leaq 0x23ea(%rip), %rsi      # 0x5028
leaq 0x23f2(%rip), %rcx      # 0x5037
movl $0x4e, %edx
callq 0x20c0
leaq 0x2479(%rip), %rdi      # 0x50cf
leaq 0x23cb(%rip), %rsi      # 0x5028
leaq 0x23d3(%rip), %rcx      # 0x5037
movl $0x4f, %edx
callq 0x20c0
leaq 0x246e(%rip), %rdi      # 0x50e3
leaq 0x23ac(%rip), %rsi      # 0x5028
leaq 0x23b4(%rip), %rcx      # 0x5037
movl $0x56, %edx
callq 0x20c0
leaq 0x23c6(%rip), %rdi      # 0x505a
leaq 0x238d(%rip), %rsi      # 0x5028
leaq 0x2395(%rip), %rcx      # 0x5037
movl $0x5e, %edx
callq 0x20c0
leaq 0x23b2(%rip), %rdi      # 0x5065
leaq 0x236e(%rip), %rsi      # 0x5028
leaq 0x2376(%rip), %rcx      # 0x5037
movl $0x5f, %edx
callq 0x20c0
leaq 0x239e(%rip), %rdi      # 0x5070
leaq 0x234f(%rip), %rsi      # 0x5028
leaq 0x2357(%rip), %rcx      # 0x5037
movl $0x60, %edx
callq 0x20c0
leaq 0x238a(%rip), %rdi      # 0x507b
leaq 0x2330(%rip), %rsi      # 0x5028
leaq 0x2338(%rip), %rcx      # 0x5037
movl $0x61, %edx
callq 0x20c0
leaq 0x2376(%rip), %rdi      # 0x5086
leaq 0x2311(%rip), %rsi      # 0x5028
leaq 0x2319(%rip), %rcx      # 0x5037
movl $0x62, %edx
callq 0x20c0
leaq 0x2341(%rip), %rdi      # 0x5070
leaq 0x22f2(%rip), %rsi      # 0x5028
leaq 0x22fa(%rip), %rcx      # 0x5037
movl $0x68, %edx
callq 0x20c0
leaq 0x2317(%rip), %rdi      # 0x5065
leaq 0x22d3(%rip), %rsi      # 0x5028
leaq 0x22db(%rip), %rcx      # 0x5037
movl $0x69, %edx
callq 0x20c0
leaq 0x22ed(%rip), %rdi      # 0x505a
leaq 0x22b4(%rip), %rsi      # 0x5028
leaq 0x22bc(%rip), %rcx      # 0x5037
movl $0x6a, %edx
callq 0x20c0
leaq 0x22fa(%rip), %rdi      # 0x5086
leaq 0x2295(%rip), %rsi      # 0x5028
leaq 0x229d(%rip), %rcx      # 0x5037
movl $0x6b, %edx
callq 0x20c0
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x429e
jmp 0x2e0d
jmp 0x2e1e
jmp 0x2e45
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4b12
leaq 0xc0(%rsp), %rsi
movq %r14, %rdi
callq 0x2210
jmp 0x2e0d
jmp 0x2ddd
jmp 0x2ddd
movq %rax, %rbx
addq $-0x10, %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x2df8
movq (%r15), %rsi
incq %rsi
callq 0x2130
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x2de4
jmp 0x2e0d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2e69
movq 0x18(%rsp), %rsi
jmp 0x2e3b
movq %rax, %rbx
jmp 0x2e69
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x2e69
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
jmp 0x2e69
movq %rax, %rbx
movq 0x5189(%rip), %rsi      # 0x7fd8
leaq 0xc0(%rsp), %rdi
callq 0x20b0
leaq 0x130(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x21e0