#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    return 1;
  }
  FILE *file;
  char line[64];
  int lines = 10;
  file = fopen(argv[1], "r");
  while (lines--) {
    fgets(line, sizeof line, file);
    if (feof(file)) {
      break;
    }
    puts(line);
  }
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <main+0xa7>
movl   $0xa,-0x64(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x64(%rbp)
cmp    $0x0,%eax
je     11e7 <main+0x97>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x40,%esi
call   1050 <fgets@plt>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11d9 <main+0x89>
jmp    11e7 <main+0x97>
lea    -0x60(%rbp),%rdi
call   1030 <puts@plt>
jmp    119b <main+0x4b>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%eax
cmp    $0x2,%edi
jne    1332 <main+0x1e2>
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    0x8(%rsi),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x40,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1321 <main+0x1d1>
mov    %rsp,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [64 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %35
12: ; preds = %2
store i32 10, i32* %8
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
br label %17
17: ; preds = %29, %12
%18 = load i32, i32* %8
%19 = add nsw i32 %18, -1
store i32 %19, i32* %8
%20 = icmp ne i32 %18, 0
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%23 = load i32*, i32** %6
%24 = call i32 @fgets(i8* %22, i32 64, i32* %23)
%25 = load i32*, i32** %6
%26 = call i64 @feof(i32* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %21
br label %32
29: ; preds = %21
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%31 = call i32 @puts(i8* %30)
br label %17
32: ; preds = %28, %17
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
store i32 0, i32* %3
br label %35
35: ; preds = %32, %11
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %5, label %62
5: ; preds = %2
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%11 = call i64 @feof(i32* %9)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %60
13: ; preds = %5
%14 = call i32 @puts(i8* %6)
%15 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%16 = call i64 @feof(i32* %9)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %60
18: ; preds = %13
%19 = call i32 @puts(i8* %6)
%20 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%21 = call i64 @feof(i32* %9)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %60
23: ; preds = %18
%24 = call i32 @puts(i8* %6)
%25 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%26 = call i64 @feof(i32* %9)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %60
28: ; preds = %23
%29 = call i32 @puts(i8* %6)
%30 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%31 = call i64 @feof(i32* %9)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %60
33: ; preds = %28
%34 = call i32 @puts(i8* %6)
%35 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%36 = call i64 @feof(i32* %9)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %60
38: ; preds = %33
%39 = call i32 @puts(i8* %6)
%40 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%41 = call i64 @feof(i32* %9)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %60
43: ; preds = %38
%44 = call i32 @puts(i8* %6)
%45 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%46 = call i64 @feof(i32* %9)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %60
48: ; preds = %43
%49 = call i32 @puts(i8* %6)
%50 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%51 = call i64 @feof(i32* %9)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %60
53: ; preds = %48
%54 = call i32 @puts(i8* %6)
%55 = call i32 @fgets(i8* %6, i32 64, i32* %9)
%56 = call i64 @feof(i32* %9)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 @puts(i8* %6)
br label %60
60: ; preds = %58, %53, %48, %43, %38, %33, %28, %23, %18, %13, %5
%61 = call i32 @fclose(i32* %9)
br label %62
62: ; preds = %2, %60
%63 = phi i32 [ 0, %60 ], [ 1, %2 ]
ret i32 %63
}