// File: iZhangHui[P]CppPrimer/CH10_GenericAlgorithms/examples/bind2.cc
// Function: main
int main()
{
	string s;
	vector<string> words;
	while (cin >> s)
		words.push_back(s);

	for_each(words.begin(), words.end(), 
	         bind(print, ref(cout), _1, ' '));
	cout << endl;

	ofstream os("data/outFile1");
	for_each(words.begin(), words.end(), 
	         bind(print, ref(os), _1, ' '));
	os << endl;

	ifstream is("data/outFile1");
	istream_iterator<string> in(is), eof;
	for_each(in, eof, bind(print, ref(cout), _1, '\n'));
	cout << endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x620, %rsp            # imm = 0x620
movl $0x0, -0x4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2160
leaq -0x40(%rbp), %rdi
callq 0x2730
movq 0x5c65(%rip), %rdi      # 0x7fe0
leaq -0x28(%rbp), %rsi
callq 0x2150
movq %rax, -0x600(%rbp)
jmp 0x238d
movq -0x600(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2140
movb %al, -0x601(%rbp)
jmp 0x23ab
movb -0x601(%rbp), %al
testb $0x1, %al
jne 0x23b7
jmp 0x23d9
leaq -0x40(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x2750
jmp 0x23c6
jmp 0x2374
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2714
leaq -0x40(%rbp), %rdi
movq %rdi, -0x610(%rbp)
callq 0x2840
movq -0x610(%rbp), %rdi
movq %rax, -0x58(%rbp)
callq 0x2870
movq %rax, -0x60(%rbp)
movq 0x5bcc(%rip), %rdi      # 0x7fd0
callq 0x28f0
movq %rax, -0x80(%rbp)
movb $0x20, -0x81(%rbp)
leaq -0x10b(%rip), %rsi      # 0x2310
movq 0x5ba6(%rip), %rcx      # 0x7fc8
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq -0x81(%rbp), %r8
callq 0x28a0
jmp 0x2438
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
leaq -0x78(%rbp), %rcx
callq 0x27c0
jmp 0x2452
movq 0x5b77(%rip), %rdi      # 0x7fd0
movq 0x5b58(%rip), %rsi      # 0x7fb8
callq 0x2110
jmp 0x2467
leaq 0x2b96(%rip), %rsi      # 0x5004
leaq -0x2a0(%rbp), %rdi
movl $0x10, %edx
callq 0x2120
jmp 0x2481
leaq -0x40(%rbp), %rdi
movq %rdi, -0x618(%rbp)
callq 0x2840
movq -0x618(%rbp), %rdi
movq %rax, -0x2a8(%rbp)
callq 0x2870
movq %rax, -0x2b0(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x29f0
movq %rax, -0x2d0(%rbp)
movb $0x20, -0x2d1(%rbp)
leaq -0x1bc(%rip), %rsi      # 0x2310
movq 0x5af5(%rip), %rcx      # 0x7fc8
leaq -0x2c8(%rbp), %rdi
leaq -0x2d0(%rbp), %rdx
leaq -0x2d1(%rbp), %r8
callq 0x29a0
jmp 0x24ef
movq -0x2a8(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
leaq -0x2f0(%rbp), %rdi
leaq -0x2c8(%rbp), %rcx
callq 0x2920
jmp 0x2512
movq 0x5a9f(%rip), %rsi      # 0x7fb8
leaq -0x2a0(%rbp), %rdi
callq 0x2110
jmp 0x2527
leaq 0x2ad6(%rip), %rsi      # 0x5004
leaq -0x4f8(%rbp), %rdi
movl $0x8, %edx
callq 0x21c0
jmp 0x2541
leaq -0x528(%rbp), %rdi
leaq -0x4f8(%rbp), %rsi
callq 0x2a20
jmp 0x2556
leaq -0x558(%rbp), %rdi
callq 0x2a80
jmp 0x2564
leaq -0x588(%rbp), %rdi
leaq -0x528(%rbp), %rsi
callq 0x2b40
jmp 0x2579
leaq -0x5b8(%rbp), %rdi
leaq -0x558(%rbp), %rsi
callq 0x2b40
jmp 0x258e
movq 0x5a3b(%rip), %rdi      # 0x7fd0
callq 0x28f0
movq %rax, -0x5d8(%rbp)
movb $0xa, -0x5d9(%rbp)
leaq -0x29f(%rip), %rsi      # 0x2310
movq 0x5a12(%rip), %rcx      # 0x7fc8
leaq -0x5d0(%rbp), %rdi
leaq -0x5d8(%rbp), %rdx
leaq -0x5d9(%rbp), %r8
callq 0x28a0
jmp 0x25d2
leaq -0x5f8(%rbp), %rdi
leaq -0x588(%rbp), %rsi
leaq -0x5b8(%rbp), %rdx
leaq -0x5d0(%rbp), %rcx
callq 0x2ac0
jmp 0x25f5
leaq -0x5b8(%rbp), %rdi
callq 0x2b90
leaq -0x588(%rbp), %rdi
callq 0x2b90
movq 0x59bc(%rip), %rdi      # 0x7fd0
movq 0x599d(%rip), %rsi      # 0x7fb8
callq 0x2110
jmp 0x2622
movl $0x0, -0x4(%rbp)
leaq -0x558(%rbp), %rdi
callq 0x2b90
leaq -0x528(%rbp), %rdi
callq 0x2b90
leaq -0x4f8(%rbp), %rdi
callq 0x2030
leaq -0x2a0(%rbp), %rdi
callq 0x2180
leaq -0x40(%rbp), %rdi
callq 0x2bb0
leaq -0x28(%rbp), %rdi
callq 0x20b0
movl -0x4(%rbp), %eax
addq $0x620, %rsp            # imm = 0x620
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2708
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x26d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x5b8(%rbp), %rdi
callq 0x2b90
leaq -0x588(%rbp), %rdi
callq 0x2b90
leaq -0x558(%rbp), %rdi
callq 0x2b90
leaq -0x528(%rbp), %rdi
callq 0x2b90
leaq -0x4f8(%rbp), %rdi
callq 0x2030
leaq -0x2a0(%rbp), %rdi
callq 0x2180
leaq -0x40(%rbp), %rdi
callq 0x2bb0
leaq -0x28(%rbp), %rdi
callq 0x20b0
movq -0x48(%rbp), %rdi
callq 0x21b0
nop