// File: iZhangHui[P]CppPrimer/CH08_TheIOLibrary/examples/fileIO.cc
// Function: main
int main(int argc, char* argv[])
{
	// for each file passed to the program
	for (auto p = argv + 1; p != argv + argc; ++p) {
	    ifstream input(*p);   // create input and open the file
	    if (input) {          // if the file is ok, ``process'' this file
	        process(input);
		} else
	        cerr << "couldn't open: " + string(*p);
	} // input goes out of scope and is destroyed on each iteration
	
	auto p = argv + 1, end = argv + argc;
	
	ifstream input;           
	while (p != end) {        // for each file passed to the program
		input.open(*p);       // open the file, automatically clears the stream 
	    if (input) {          // if the file is ok, read and ``process'' the input
	        	process(input);
		} else
			cerr << "couldn't open: " + string(*p);
	    input.close();        // close file when we're done with it
	    ++p;                  // increment pointer to get next file
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x500, %rsp            # imm = 0x500
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x8(%rbp), %rdx
shlq $0x3, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
je 0x1521
movq -0x18(%rbp), %rax
movq (%rax), %rsi
leaq -0x220(%rbp), %rdi
movl $0x8, %edx
callq 0x1150
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x10e0
movb %al, -0x4d2(%rbp)
jmp 0x13c9
movb -0x4d2(%rbp), %al
testb $0x1, %al
jne 0x13d5
jmp 0x13ff
leaq -0x220(%rbp), %rdi
callq 0x12a0
jmp 0x13e3
jmp 0x14f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x1510
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x4e8(%rbp)
leaq -0x271(%rbp), %rdi
movq %rdi, -0x4e0(%rbp)
callq 0x1140
movq -0x4e8(%rbp), %rsi
movq -0x4e0(%rbp), %rdx
leaq -0x270(%rbp), %rdi
callq 0x1100
jmp 0x143c
leaq 0xbc1(%rip), %rsi       # 0x2004
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rdx
callq 0x1730
jmp 0x1458
movq 0x2b91(%rip), %rdi      # 0x3ff0
leaq -0x250(%rbp), %rsi
callq 0x10a0
jmp 0x146d
leaq -0x250(%rbp), %rdi
callq 0x1070
leaq -0x270(%rbp), %rdi
callq 0x1070
leaq -0x271(%rbp), %rdi
callq 0x10c0
jmp 0x14f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x14e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x14d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x1070
leaq -0x270(%rbp), %rdi
callq 0x1070
leaq -0x271(%rbp), %rdi
callq 0x10c0
jmp 0x1510
leaq -0x220(%rbp), %rdi
callq 0x1050
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
jmp 0x1375
leaq -0x220(%rbp), %rdi
callq 0x1050
jmp 0x1719
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x280(%rbp)
movq -0x10(%rbp), %rax
movslq -0x8(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x288(%rbp)
leaq -0x490(%rbp), %rdi
callq 0x10d0
movq -0x280(%rbp), %rax
cmpq -0x288(%rbp), %rax
je 0x16f5
movq -0x280(%rbp), %rax
movq (%rax), %rsi
leaq -0x490(%rbp), %rdi
movl $0x8, %edx
callq 0x1080
jmp 0x1583
movq -0x490(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x490(%rbp,%rax), %rdi
callq 0x10e0
movb %al, -0x4e9(%rbp)
jmp 0x15a3
movb -0x4e9(%rbp), %al
testb $0x1, %al
jne 0x15af
jmp 0x15d9
leaq -0x490(%rbp), %rdi
callq 0x12a0
jmp 0x15bd
jmp 0x16d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x170d
movq -0x280(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x500(%rbp)
leaq -0x4d1(%rbp), %rdi
movq %rdi, -0x4f8(%rbp)
callq 0x1140
movq -0x500(%rbp), %rsi
movq -0x4f8(%rbp), %rdx
leaq -0x4d0(%rbp), %rdi
callq 0x1100
jmp 0x1619
leaq 0x9e4(%rip), %rsi       # 0x2004
leaq -0x4b0(%rbp), %rdi
leaq -0x4d0(%rbp), %rdx
callq 0x1730
jmp 0x1635
movq 0x29b4(%rip), %rdi      # 0x3ff0
leaq -0x4b0(%rbp), %rsi
callq 0x10a0
jmp 0x164a
leaq -0x4b0(%rbp), %rdi
callq 0x1070
leaq -0x4d0(%rbp), %rdi
callq 0x1070
leaq -0x4d1(%rbp), %rdi
callq 0x10c0
jmp 0x16d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x16c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x16b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x1070
leaq -0x4d0(%rbp), %rdi
callq 0x1070
leaq -0x4d1(%rbp), %rdi
callq 0x10c0
jmp 0x170d
leaq -0x490(%rbp), %rdi
callq 0x1030
jmp 0x16de
movq -0x280(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x280(%rbp)
jmp 0x1552
leaq -0x490(%rbp), %rdi
callq 0x1050
movl -0x4(%rbp), %eax
addq $0x500, %rsp            # imm = 0x500
popq %rbp
retq
leaq -0x490(%rbp), %rdi
callq 0x1050
movq -0x228(%rbp), %rdi
callq 0x1130
nopw %cs:(%rax,%rax)
nop