#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int c, nl, nw, nc, state;
  FILE *fp;
  char *infile = "../../src/bib";
  if (argc > 1)
    infile = argv[1];
  fp = fopen(infile, "r");
  if (fp == NULL) {
    fprintf(stderr, "can't open %s\n", infile);
    exit(1);
  }
  state = 0;
  nl = nw = nc = 0;
  while ((c = getc(fp)) != EOF) {
    ++nc;
    if (c == '\n')
      ++nl;
    if (c == ' ' || c == '\n' || c == '\t')
      state = 0;
    else if (state == 0) {
      state = 1;
      ++nw;
    }
  }
  printf("%d %d %d\n", nl, nw, nc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1187 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11c9 <main+0x79>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%eax
je     126a <main+0x11a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    121c <main+0xcc>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x14(%rbp)
je     123a <main+0xea>
cmpl   $0xa,-0x14(%rbp)
je     123a <main+0xea>
cmpl   $0x9,-0x14(%rbp)
jne    1246 <main+0xf6>
movl   $0x0,-0x24(%rbp)
jmp    1265 <main+0x115>
cmpl   $0x0,-0x24(%rbp)
jne    1260 <main+0x110>
movl   $0x1,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1265 <main+0x115>
jmp    11e5 <main+0x95>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xda5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1166 <main+0x16>
mov    0x8(%rsi),%rbx
jmp    116d <main+0x1d>
lea    0xe93(%rip),%rbx
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     1227 <main+0xd7>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <getc@plt>
mov    0x2e51(%rip),%r12
xor    %r14d,%r14d
mov    $0x0,%ebx
mov    $0x0,%ebp
cmp    (%r12),%eax
jne    11ce <main+0x7e>
lea    0xe6e(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    1203 <main+0xb3>
nopw   0x0(%rax,%rax,1)
cmp    $0x1,%r13d
adc    $0x0,%r14d
mov    $0x1,%r13d
mov    %dl,%cl
add    %ecx,%ebp
mov    %r15,%rdi
call   1070 <getc@plt>
add    $0x1,%ebx
cmp    (%r12),%eax
je     11aa <main+0x5a>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %dl
cmp    $0x20,%eax
ja     11e0 <main+0x90>
mov    %eax,%eax
movabs $0x100000600,%rsi
bt     %rax,%rsi
jae    11e0 <main+0x90>
xor    %r13d,%r13d
jmp    11ee <main+0x9e>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdd9(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"../../src/bib\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"can't open %s\0A\00"
@EOF = global i32 0
@.str.3 = [10 x i8] c"%d %d %d\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
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %12
br label %19
19: ; preds = %15, %2
%20 = load i8*, i8** %12
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %11
%22 = load i32*, i32** %11
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %12
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %19
store i32 0, i32* %10
store i32 0, i32* %9
store i32 0, i32* %8
store i32 0, i32* %7
br label %30
30: ; preds = %60, %29
%31 = load i32*, i32** %11
%32 = call i32 @getc(i32* %31)
store i32 %32, i32* %6
%33 = load i32, i32* @EOF
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %61
35: ; preds = %30
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
%38 = load i32, i32* %6
%39 = icmp eq i32 %38, 10
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %43
43: ; preds = %40, %35
%44 = load i32, i32* %6
%45 = icmp eq i32 %44, 32
br i1 %45, label %52, label %46
46: ; preds = %43
%47 = load i32, i32* %6
%48 = icmp eq i32 %47, 10
br i1 %48, label %52, label %49
49: ; preds = %46
%50 = load i32, i32* %6
%51 = icmp eq i32 %50, 9
br i1 %51, label %52, label %53
52: ; preds = %49, %46, %43
store i32 0, i32* %10
br label %60
53: ; preds = %49
%54 = load i32, i32* %10
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
store i32 1, i32* %10
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
br label %59
59: ; preds = %56, %53
br label %60
60: ; preds = %59, %52
br label %30
61: ; preds = %30
%62 = load i32, i32* %7
%63 = load i32, i32* %8
%64 = load i32, i32* %9
%65 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %62, i32 %63, i32 %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"../../src/bib\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"can't open %s\0A\00"
@EOF = global i32 0
@.str.3 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %4, %2
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = tail call i32 @getc(i32* %9)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %39, label %19
15: ; preds = %7
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %11, %33
%20 = phi i32 [ %36, %33 ], [ %12, %11 ]
%21 = phi i32 [ %28, %33 ], [ 0, %11 ]
%22 = phi i32 [ %35, %33 ], [ 0, %11 ]
%23 = phi i32 [ %25, %33 ], [ 0, %11 ]
%24 = phi i32 [ %34, %33 ], [ 0, %11 ]
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %20, 10
%27 = zext i1 %26 to i32
%28 = add nuw nsw i32 %21, %27
switch i32 %20, label %29 [
i32 32, label %33
i32 10, label %33
i32 9, label %33
]
29: ; preds = %19
%30 = icmp eq i32 %22, 0
%31 = zext i1 %30 to i32
%32 = add nsw i32 %24, %31
br label %33
33: ; preds = %29, %19, %19, %19
%34 = phi i32 [ %24, %19 ], [ %32, %29 ], [ %24, %19 ], [ %24, %19 ]
%35 = phi i32 [ 0, %19 ], [ 1, %29 ], [ 0, %19 ], [ 0, %19 ]
%36 = tail call i32 @getc(i32* %9)
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %19
39: ; preds = %33, %11
%40 = phi i32 [ 0, %11 ], [ %34, %33 ]
%41 = phi i32 [ 0, %11 ], [ %25, %33 ]
%42 = phi i32 [ 0, %11 ], [ %28, %33 ]
%43 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %42, i32 %40, i32 %41)
ret i32 0
}