#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, int);
scalar_t__ read(int, char *, int);
int main(int argc, char **argv) {
  int characters = 0;
  int words = 0;
  int lines = 0;
  if (argc < 2) {
    exit(99);
  } else {
    for (int i = 1; i < argc; i++) {
      int f = open(argv[i], O_RDONLY);
      char c;
      while (read(f, &c, 1)) {
        if (c == '\n') {
          words++;
          lines++;
        }
        if (c == ' ') {
          words++;
        }
        characters++;
      }
      close(f);
    }
  }
  printf("%u characters, %u words, %u lines", characters, words, lines);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118f <main+0x3f>
mov    $0x63,%edi
call   1070 <exit@plt>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1233 <main+0xe3>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x25(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
cmp    $0x0,%rax
je     121d <main+0xcd>
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
jne    11f9 <main+0xa9>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jne    120f <main+0xbf>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bf <main+0x6f>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1196 <main+0x46>
jmp    1238 <main+0xe8>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xdb8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
cmp    $0x2,%edi
jl     1218 <main+0xc8>
mov    %edi,%eax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
mov    $0x1,%r14d
lea    0x7(%rsp),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11a3 <main+0x53>
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
call   1040 <close@plt>
add    $0x1,%r14
cmp    0x8(%rsp),%r14
je     11f4 <main+0xa4>
mov    0x10(%rsp),%rax
mov    (%rax,%r14,8),%rdi
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%r13d
mov    %eax,%edi
nop
mov    %r12,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
test   %rax,%rax
je     1190 <main+0x40>
movzbl 0x7(%rsp),%eax
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
add    %ecx,%ebp
add    %ecx,%ebx
xor    %ecx,%ecx
cmp    $0x20,%al
sete   %cl
add    %ecx,%ebp
add    $0x1,%r15d
mov    %r13d,%edi
jmp    11c0 <main+0x70>
lea    0xe05(%rip),%rdi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x63,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [34 x i8] c"%u characters, %u words, %u lines\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 i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @exit(i32 99)
unreachable
16: ; preds = %2
store i32 1, i32* %9
br label %17
17: ; preds = %55, %16
%18 = load i32, i32* %9
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %58
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %26, i32 %27)
store i32 %28, i32* %10
br label %29
29: ; preds = %49, %21
%30 = load i32, i32* %10
%31 = call i64 @read(i32 %30, i8* %11, i32 1)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %52
33: ; preds = %29
%34 = load i8, i8* %11
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %42
42: ; preds = %37, %33
%43 = load i8, i8* %11
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 32
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %49
49: ; preds = %46, %42
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %29
52: ; preds = %29
%53 = load i32, i32* %10
%54 = call i32 @close(i32 %53)
br label %55
55: ; preds = %52
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %17
58: ; preds = %17
br label %59
59: ; preds = %58
%60 = load i32, i32* %6
%61 = load i32, i32* %7
%62 = load i32, i32* %8
%63 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %60, i32 %61, i32 %62)
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [34 x i8] c"%u characters, %u words, %u lines\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = icmp slt i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %11
7: ; preds = %2
%8 = tail call i32 @exit(i32 99)
unreachable
9: ; preds = %37
%10 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %40, i32 %38, i32 %39)
ret i32 0
11: ; preds = %5, %37
%12 = phi i64 [ 1, %5 ], [ %42, %37 ]
%13 = phi i32 [ 0, %5 ], [ %40, %37 ]
%14 = phi i32 [ 0, %5 ], [ %39, %37 ]
%15 = phi i32 [ 0, %5 ], [ %38, %37 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %12
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDONLY
%19 = tail call i32 @open(i8* %17, i32 %18)
%20 = call i64 @read(i32 %19, i8* %3, i32 1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %37, label %22
22: ; preds = %11, %22
%23 = phi i32 [ %34, %22 ], [ %13, %11 ]
%24 = phi i32 [ %30, %22 ], [ %14, %11 ]
%25 = phi i32 [ %33, %22 ], [ %15, %11 ]
%26 = load i8, i8* %3
%27 = icmp eq i8 %26, 10
%28 = zext i1 %27 to i32
%29 = add nsw i32 %25, %28
%30 = add nsw i32 %24, %28
%31 = icmp eq i8 %26, 32
%32 = zext i1 %31 to i32
%33 = add nsw i32 %29, %32
%34 = add nsw i32 %23, 1
%35 = call i64 @read(i32 %19, i8* %3, i32 1)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %22
37: ; preds = %22, %11
%38 = phi i32 [ %15, %11 ], [ %33, %22 ]
%39 = phi i32 [ %14, %11 ], [ %30, %22 ]
%40 = phi i32 [ %13, %11 ], [ %34, %22 ]
%41 = tail call i32 @close(i32 %19)
%42 = add nuw nsw i64 %12, 1
%43 = icmp eq i64 %42, %6
br i1 %43, label %9, label %11
}