// File: /workspace/github_cpp_makefile_star2_O1/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 0x3c68(%rip), %xmm0     # 0x6010
leaq 0xc0(%rsp), %rsi
movups %xmm0, (%rsi)
leaq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rcx
movl $0x4, %edx
callq 0x4358
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 0x2e9d
cmpq $0x41, %r14
jl 0x243b
leaq 0x40(%r15), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x30d9
cmpq %rbx, %r14
je 0x2446
movl -0x4(%r14), %ecx
movl (%r14), %eax
movq %r14, %rdx
cmpl %ecx, %eax
jle 0x2433
movq %r14, %rdx
movl %ecx, (%rdx)
movl -0x8(%rdx), %ecx
addq $-0x4, %rdx
cmpl %ecx, %eax
jg 0x2426
movl %eax, (%rdx)
addq $0x4, %r14
jmp 0x2410
movq %r15, %rdi
movq %rbx, %rsi
callq 0x30d9
movq 0x8(%rsp), %rax
cmpl $0x4, (%rax)
jne 0x2b27
cmpl $0x3, 0x4(%rax)
jne 0x2b46
cmpl $0x2, 0x8(%rax)
jne 0x2b65
cmpl $0x1, 0xc(%rax)
jne 0x2b84
addq $0x10, %rax
cmpq 0x10(%rsp), %rax
jne 0x2ba3
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3c01(%rip), %rsi      # 0x6095
leaq 0x3bfb(%rip), %rdx      # 0x6096
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
callq 0x4b58
leaq 0xe0(%rsp), %r14
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3bd1(%rip), %rsi      # 0x6097
leaq 0x3bcb(%rip), %rdx      # 0x6098
movq %r14, %rdi
callq 0x4b58
leaq 0x100(%rsp), %r14
leaq 0x110(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3ba9(%rip), %rsi      # 0x6099
leaq 0x3ba3(%rip), %rdx      # 0x609a
movq %r14, %rdi
callq 0x4b58
leaq 0x120(%rsp), %r14
leaq 0x130(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x3c36(%rip), %rsi      # 0x6150
leaq 0x3c30(%rip), %rdx      # 0x6151
movq %r14, %rdi
callq 0x4b58
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), %r12
leaq 0xc0(%rsp), %rsi
movq %r12, %rdx
callq 0x4be8
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), %rbp
movq 0x50(%rsp), %rdx
cmpq %rdx, %rbp
je 0x27f4
movq 0x38(%rsp), %r12
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %r15
movq 0x58(%rsp), %r8
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rbx
leaq 0x258(%rsp), %rdi
movq %rbp, (%rdi)
movq %r12, 0x8(%rdi)
movq %r14, 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 %rbx, 0x18(%rsi)
movq %rbx, %rax
subq %r15, %rax
shrq $0x3, %rax
cmpq $0x1, %rbx
adcq $-0x1, %rax
shlq $0x4, %rax
movq %rdx, %rcx
movq %r8, 0x78(%rsp)
subq %r8, %rcx
sarq $0x5, %rcx
movq %rdx, (%rsp)
movq %r14, %r13
subq %rbp, %r13
sarq $0x5, %r13
addq %rcx, %r13
addq %rax, %r13
bsrq %r13, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
callq 0x314e
cmpq $0x11, %r13
jl 0x2696
movq (%rsp), %r13
movq %rbp, 0xa0(%rsp)
movq %r12, 0xa8(%rsp)
movq %r14, 0xb0(%rsp)
movq %r15, 0xb8(%rsp)
movq %rbp, 0x80(%rsp)
movq %r12, 0x88(%rsp)
movq %r14, 0x90(%rsp)
movq %r15, 0x98(%rsp)
movq %rbp, %rbx
subq %r12, %rbx
sarq $0x5, %rbx
cmpq $-0x10, %rbx
jb 0x26dc
leaq 0x200(%rbp), %rax
jmp 0x2735
leaq 0xc0(%rsp), %rdi
movq %rbp, (%rdi)
movq %r12, 0x8(%rdi)
movq %r14, 0x10(%rdi)
movq %r15, 0x18(%rdi)
leaq 0xa0(%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 %rbx, 0x18(%rsi)
callq 0x3d36
jmp 0x27f4
leaq 0x10(%rbx), %rax
shrq $0x4, %rax
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
orq %rax, %rcx
cmpq $-0xf, %rbx
cmovgeq %rax, %rcx
leaq (%r15,%rcx,8), %rax
movq %rax, 0x98(%rsp)
movq (%rax), %rdx
movq %rdx, 0x88(%rsp)
leaq 0x200(%rdx), %rax
movq %rax, 0x90(%rsp)
shlq $0x4, %rcx
negq %rcx
leaq (%rbx,%rcx), %rax
addq $0x10, %rax
shlq $0x5, %rax
addq %rdx, %rax
leaq 0x80(%rsp), %rsi
movq %rax, (%rsi)
leaq 0xa0(%rsp), %rdi
callq 0x3d36
cmpq $-0x10, %rbx
jb 0x275c
addq $0x200, %rbp            # imm = 0x200
jmp 0x279e
leaq 0x10(%rbx), %rax
shrq $0x4, %rax
movabsq $-0x1000000000000000, %rcx # imm = 0xF000000000000000
orq %rax, %rcx
cmpq $-0xf, %rbx
cmovgeq %rax, %rcx
leaq (%r15,%rcx,8), %r15
movq (%r15), %r12
leaq 0x200(%r12), %r14
shlq $0x4, %rcx
negq %rcx
leaq (%rbx,%rcx), %rbp
addq $0x10, %rbp
shlq $0x5, %rbp
addq %r12, %rbp
cmpq %r13, %rbp
je 0x27f4
leaq 0xc0(%rsp), %rbx
movq %rbp, 0xc0(%rsp)
movq %r12, 0xc8(%rsp)
movq %r14, 0xd0(%rsp)
movq %r15, 0xd8(%rsp)
movq %rbx, %rdi
callq 0x3fb1
addq $0x20, %rbp
cmpq %r14, %rbp
jne 0x27ef
movq 0x8(%r15), %r12
addq $0x8, %r15
leaq 0x200(%r12), %r14
movq %r12, %rbp
cmpq %r13, %rbp
jne 0x27ab
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %r12
movq 0x48(%rsp), %r15
leaq 0x20(%rdi), %rbx
cmpq %r12, %rbx
jne 0x281b
movq 0x8(%r15), %rbx
addq $0x8, %r15
leaq 0x200(%rbx), %r12
leaq 0x392e(%rip), %rsi      # 0x6150
callq 0x2050
testl %eax, %eax
jne 0x2bc2
leaq 0x20(%rbx), %r14
cmpq %r12, %r14
jne 0x2847
movq 0x8(%r15), %r14
addq $0x8, %r15
leaq 0x200(%r14), %r12
leaq 0x384b(%rip), %rsi      # 0x6099
movq %rbx, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2be1
leaq 0x20(%r14), %rbx
cmpq %r12, %rbx
jne 0x2876
movq 0x8(%r15), %rbx
addq $0x8, %r15
leaq 0x200(%rbx), %r12
leaq 0x381a(%rip), %rsi      # 0x6097
movq %r14, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2c00
leaq 0x20(%rbx), %r14
cmpq %r12, %r14
jne 0x289a
movq 0x8(%r15), %r14
leaq 0x37f4(%rip), %rsi      # 0x6095
movq %rbx, %rdi
callq 0x2050
testl %eax, %eax
jne 0x2c1f
cmpq 0x50(%rsp), %r14
jne 0x2c3e
leaq 0x20(%rsp), %rdi
callq 0x439e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x28dd
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 0x3711(%rip), %xmm0     # 0x6020
callq 0x21a0
leaq 0x3769(%rip), %rdx      # 0x6084
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4721
movq %rax, %rdi
movl $0x2, %esi
callq 0x21d0
leaq 0xc8(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x2190
leaq 0x378a(%rip), %rsi      # 0x60dd
leaq 0x20(%rsp), %rdi
callq 0x2050
testl %eax, %eax
jne 0x2c5d
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2980
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x6651(%rip), %rsi      # 0x8fd8
leaq 0xc0(%rsp), %rdi
callq 0x20b0
leaq 0x130(%rsp), %rdi
callq 0x2060
leaq 0x20(%rsp), %rsi
movaps 0x3663(%rip), %xmm0     # 0x6010
movups %xmm0, (%rsi)
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rcx
movl $0x4, %edx
callq 0x4358
movq 0xc0(%rsp), %rbx
movq 0xc8(%rsp), %r14
cmpq %r14, %rbx
je 0x2a4f
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 0x40a6
cmpq $0x41, %r15
jl 0x2a44
leaq 0x40(%rbx), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x42e2
cmpq %r14, %r15
je 0x2a4f
movl -0x4(%r15), %ecx
movl (%r15), %eax
movq %r15, %rdx
cmpl %ecx, %eax
jle 0x2a3c
movq %r15, %rdx
movl %ecx, (%rdx)
movl -0x8(%rdx), %ecx
addq $-0x4, %rdx
cmpl %ecx, %eax
jg 0x2a2f
movl %eax, (%rdx)
addq $0x4, %r15
jmp 0x2a19
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42e2
movq 0xc0(%rsp), %rax
cmpl $0x4, (%rax)
jne 0x2c7c
cmpl $0x3, 0x4(%rax)
jne 0x2c9b
cmpl $0x2, 0x8(%rax)
jne 0x2cba
cmpl $0x1, 0xc(%rax)
jne 0x2cd9
addq $0x10, %rax
cmpq 0xc8(%rsp), %rax
jne 0x2cf8
cmpq %r14, %rbx
je 0x2ac2
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 0x475f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4842
movq 0xc0(%rsp), %rdi
cmpl $0x1, (%rdi)
jne 0x2d17
cmpl $0x2, 0x4(%rdi)
jne 0x2d36
cmpl $0x3, 0x8(%rdi)
jne 0x2d55
cmpl $0x4, 0xc(%rdi)
jne 0x2d74
leaq 0x10(%rdi), %rax
cmpq 0xc8(%rsp), %rax
jne 0x2d93
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 0x352c(%rip), %rdi      # 0x605a
leaq 0x34f3(%rip), %rsi      # 0x6028
leaq 0x34fb(%rip), %rcx      # 0x6037
movl $0x40, %edx
callq 0x20c0
leaq 0x3518(%rip), %rdi      # 0x6065
leaq 0x34d4(%rip), %rsi      # 0x6028
leaq 0x34dc(%rip), %rcx      # 0x6037
movl $0x41, %edx
callq 0x20c0
leaq 0x3504(%rip), %rdi      # 0x6070
leaq 0x34b5(%rip), %rsi      # 0x6028
leaq 0x34bd(%rip), %rcx      # 0x6037
movl $0x42, %edx
callq 0x20c0
leaq 0x34f0(%rip), %rdi      # 0x607b
leaq 0x3496(%rip), %rsi      # 0x6028
leaq 0x349e(%rip), %rcx      # 0x6037
movl $0x43, %edx
callq 0x20c0
leaq 0x34dc(%rip), %rdi      # 0x6086
leaq 0x3477(%rip), %rsi      # 0x6028
leaq 0x347f(%rip), %rcx      # 0x6037
movl $0x44, %edx
callq 0x20c0
leaq 0x34d2(%rip), %rdi      # 0x609b
leaq 0x3458(%rip), %rsi      # 0x6028
leaq 0x3460(%rip), %rcx      # 0x6037
movl $0x4b, %edx
callq 0x20c0
leaq 0x34c0(%rip), %rdi      # 0x60a8
leaq 0x3439(%rip), %rsi      # 0x6028
leaq 0x3441(%rip), %rcx      # 0x6037
movl $0x4c, %edx
callq 0x20c0
leaq 0x34ae(%rip), %rdi      # 0x60b5
leaq 0x341a(%rip), %rsi      # 0x6028
leaq 0x3422(%rip), %rcx      # 0x6037
movl $0x4d, %edx
callq 0x20c0
leaq 0x349c(%rip), %rdi      # 0x60c2
leaq 0x33fb(%rip), %rsi      # 0x6028
leaq 0x3403(%rip), %rcx      # 0x6037
movl $0x4e, %edx
callq 0x20c0
leaq 0x348a(%rip), %rdi      # 0x60cf
leaq 0x33dc(%rip), %rsi      # 0x6028
leaq 0x33e4(%rip), %rcx      # 0x6037
movl $0x4f, %edx
callq 0x20c0
leaq 0x347f(%rip), %rdi      # 0x60e3
leaq 0x33bd(%rip), %rsi      # 0x6028
leaq 0x33c5(%rip), %rcx      # 0x6037
movl $0x56, %edx
callq 0x20c0
leaq 0x33d7(%rip), %rdi      # 0x605a
leaq 0x339e(%rip), %rsi      # 0x6028
leaq 0x33a6(%rip), %rcx      # 0x6037
movl $0x5e, %edx
callq 0x20c0
leaq 0x33c3(%rip), %rdi      # 0x6065
leaq 0x337f(%rip), %rsi      # 0x6028
leaq 0x3387(%rip), %rcx      # 0x6037
movl $0x5f, %edx
callq 0x20c0
leaq 0x33af(%rip), %rdi      # 0x6070
leaq 0x3360(%rip), %rsi      # 0x6028
leaq 0x3368(%rip), %rcx      # 0x6037
movl $0x60, %edx
callq 0x20c0
leaq 0x339b(%rip), %rdi      # 0x607b
leaq 0x3341(%rip), %rsi      # 0x6028
leaq 0x3349(%rip), %rcx      # 0x6037
movl $0x61, %edx
callq 0x20c0
leaq 0x3387(%rip), %rdi      # 0x6086
leaq 0x3322(%rip), %rsi      # 0x6028
leaq 0x332a(%rip), %rcx      # 0x6037
movl $0x62, %edx
callq 0x20c0
leaq 0x335d(%rip), %rdi      # 0x607b
leaq 0x3303(%rip), %rsi      # 0x6028
leaq 0x330b(%rip), %rcx      # 0x6037
movl $0x67, %edx
callq 0x20c0
leaq 0x3333(%rip), %rdi      # 0x6070
leaq 0x32e4(%rip), %rsi      # 0x6028
leaq 0x32ec(%rip), %rcx      # 0x6037
movl $0x68, %edx
callq 0x20c0
leaq 0x3309(%rip), %rdi      # 0x6065
leaq 0x32c5(%rip), %rsi      # 0x6028
leaq 0x32cd(%rip), %rcx      # 0x6037
movl $0x69, %edx
callq 0x20c0
leaq 0x32df(%rip), %rdi      # 0x605a
leaq 0x32a6(%rip), %rsi      # 0x6028
leaq 0x32ae(%rip), %rcx      # 0x6037
movl $0x6a, %edx
callq 0x20c0
leaq 0x32ec(%rip), %rdi      # 0x6086
leaq 0x3287(%rip), %rsi      # 0x6028
leaq 0x328f(%rip), %rcx      # 0x6037
movl $0x6b, %edx
callq 0x20c0
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x439e
jmp 0x2e39
jmp 0x2e52
jmp 0x2e71
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4cda
leaq 0xc0(%rsp), %rsi
movq %r12, %rdi
callq 0x2210
movb $0x1, %al
jmp 0x2dff
jmp 0x2df0
jmp 0x2df0
movq %rax, %rbx
xorl %eax, %eax
jmp 0x2dff
movq %rax, %rbx
xorl %eax, %eax
movq %r15, %r14
cmpq %r14, %r15
sete %cl
orb %al, %cl
jne 0x2e39
addq $-0x10, %r14
leaq 0xc0(%rsp), %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x2e29
movq (%r14), %rsi
incq %rsi
callq 0x2130
leaq -0x20(%r14), %rax
addq $-0x10, %r14
cmpq %r15, %r14
movq %rax, %r14
jne 0x2e15
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x2e95
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2130
jmp 0x2e95
movq %rax, %rbx
jmp 0x2e95
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x2e95
movq 0xd0(%rsp), %rsi
jmp 0x2e48
movq %rax, %rbx
movq 0x615d(%rip), %rsi      # 0x8fd8
leaq 0xc0(%rsp), %rdi
callq 0x20b0
leaq 0x130(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x21e0