#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 count(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *in;
  if (argc == 1) {
    fprintf(stderr, "Missing input file.\n");
    return 0;
  }
  int i, cnt;
  for (i = 1; i < argc; i++) {
    in = fopen(argv[i], "r");
    if (in == NULL) {
      perror(argv[i]);
      continue;
    }
    cnt = count(in);
    printf("%s: %d line(s).\n", argv[i], cnt);
    fclose(in);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11a1 <main+0x41>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1236 <main+0xd6>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    122f <main+0xcf>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f1 <main+0x91>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <perror@plt>
jmp    1221 <main+0xc1>
mov    -0x18(%rbp),%rdi
call   1030 <count@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%edx
lea    0xe04(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a8 <main+0x48>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1187 <main+0x27>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11f8 <main+0x98>
jle    11f8 <main+0x98>
mov    %rsi,%r12
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xe7a(%rip),%r14
lea    0xe75(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbp,8),%rdi
mov    %r14,%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ed <main+0x8d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <count@plt>
mov    (%r12,%rbp,8),%rsi
mov    %r15,%rdi
mov    %eax,%edx
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11b0 <main+0x50>
jmp    11f8 <main+0x98>
mov    (%r12,%rbp,8),%rdi
call   1080 <perror@plt>
jmp    11e2 <main+0x82>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Missing input file.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"%s: %d line(s).\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%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 eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %51
14: ; preds = %2
store i32 1, i32* %7
br label %15
15: ; preds = %47, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %50
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %35
28: ; preds = %19
%29 = load i8**, i8*** %5
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 @perror(i8* %33)
br label %47
35: ; preds = %19
%36 = load i32*, i32** %6
%37 = call i32 @count(i32* %36)
store i32 %37, i32* %8
%38 = load i8**, i8*** %5
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = load i32, i32* %8
%44 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %42, i32 %43)
%45 = load i32*, i32** %6
%46 = call i32 @fclose(i32* %45)
br label %47
47: ; preds = %35, %28
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %15
50: ; preds = %15
store i32 0, i32* %3
br label %51
51: ; preds = %50, %11
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Missing input file.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"%s: %d line(s).\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %28
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %28
11: ; preds = %6, %25
%12 = phi i64 [ 1, %6 ], [ %26, %25 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8*, i8** %13
%19 = tail call i32 @perror(i8* %18)
br label %25
20: ; preds = %11
%21 = tail call i32 @count(i32* %15)
%22 = load i8*, i8** %13
%23 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 %21)
%24 = tail call i32 @fclose(i32* %15)
br label %25
25: ; preds = %20, %17
%26 = add nuw nsw i64 %12, 1
%27 = icmp eq i64 %26, %7
br i1 %27, label %28, label %11
28: ; preds = %25, %4, %8
ret i32 0
}