#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, long);
int main() {
  long characters, words, lines;
  int character, state;
  characters = 0;
  words = 0;
  lines = 0;
  state = 1;
  while ((character = getchar()) != EOF) {
    ++characters;
    if (character == '\n') {
      ++lines;
    }
    if (state == 1) {
      if (character != ' ' && character != '\t' && character != '\n') {
        state = 0;
        ++words;
      }
    } else if (state == 0) {
      if (character == ' ' || character == '\t' || character == '\n') {
        state = 1;
      }
    }
  }
  printf("Characters = %ld\n", characters);
  printf("Words = %ld\n", words);
  printf("Lines = %ld\n", lines);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x28(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%eax
je     1207 <main+0xe7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0xa,-0x24(%rbp)
jne    1189 <main+0x69>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    11c9 <main+0xa9>
cmpl   $0x20,-0x24(%rbp)
je     11c4 <main+0xa4>
cmpl   $0x9,-0x24(%rbp)
je     11c4 <main+0xa4>
cmpl   $0xa,-0x24(%rbp)
je     11c4 <main+0xa4>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1202 <main+0xe2>
cmpl   $0x0,-0x28(%rbp)
jne    11fd <main+0xdd>
cmpl   $0x20,-0x24(%rbp)
je     11f1 <main+0xd1>
cmpl   $0x9,-0x24(%rbp)
je     11f1 <main+0xd1>
cmpl   $0xa,-0x24(%rbp)
jne    11f8 <main+0xd8>
movl   $0x1,-0x28(%rbp)
jmp    11fd <main+0xdd>
jmp    1202 <main+0xe2>
jmp    114e <main+0x2e>
mov    -0x10(%rbp),%rsi
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdf0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eac(%rip),%r12
cmp    (%r12),%eax
jne    1185 <main+0x65>
xor    %r15d,%r15d
xor    %ebx,%ebx
lea    0xeb2(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
movabs $0x100000600,%r13
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    11c6 <main+0xa6>
add    $0x1,%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %dl,%cl
add    %rcx,%r15
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbx
cmp    (%r12),%eax
je     1147 <main+0x27>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %dl
cmp    $0x1,%ebp
jne    11f0 <main+0xd0>
cmp    $0x20,%eax
ja     119e <main+0x7e>
mov    $0x1,%ebp
mov    %eax,%eax
bt     %rax,%r13
jb     11b0 <main+0x90>
jmp    119e <main+0x7e>
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cmp    $0x20,%eax
ja     11b0 <main+0x90>
mov    %eax,%eax
bt     %rax,%r13
jae    11b0 <main+0x90>
mov    $0x1,%ebp
jmp    11b0 <main+0x90>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [18 x i8] c"Characters = %ld\0A\00"
@.str.1 = [13 x i8] c"Words = %ld\0A\00"
@.str.2 = [13 x i8] c"Lines = %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i32 1, i32* %6
br label %7
7: ; preds = %50, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %5
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %51
11: ; preds = %7
%12 = load i64, i64* %2
%13 = add nsw i64 %12, 1
store i64 %13, i64* %2
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i64, i64* %4
%18 = add nsw i64 %17, 1
store i64 %18, i64* %4
br label %19
19: ; preds = %16, %11
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i32, i32* %5
%24 = icmp ne i32 %23, 32
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 9
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 10
br i1 %30, label %31, label %34
31: ; preds = %28
store i32 0, i32* %6
%32 = load i64, i64* %3
%33 = add nsw i64 %32, 1
store i64 %33, i64* %3
br label %34
34: ; preds = %31, %28, %25, %22
br label %50
35: ; preds = %19
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %49
38: ; preds = %35
%39 = load i32, i32* %5
%40 = icmp eq i32 %39, 32
br i1 %40, label %47, label %41
41: ; preds = %38
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 9
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 10
br i1 %46, label %47, label %48
47: ; preds = %44, %41, %38
store i32 1, i32* %6
br label %48
48: ; preds = %47, %44
br label %49
49: ; preds = %48, %35
br label %50
50: ; preds = %49, %34
br label %7
51: ; preds = %7
%52 = load i64, i64* %2
%53 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %52)
%54 = load i64, i64* %3
%55 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %54)
%56 = load i64, i64* %4
%57 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %56)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [18 x i8] c"Characters = %ld\0A\00"
@.str.1 = [13 x i8] c"Words = %ld\0A\00"
@.str.2 = [13 x i8] c"Lines = %ld\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %26, label %4
4: ; preds = %0, %20
%5 = phi i32 [ %23, %20 ], [ %1, %0 ]
%6 = phi i32 [ %22, %20 ], [ 1, %0 ]
%7 = phi i64 [ %10, %20 ], [ 0, %0 ]
%8 = phi i64 [ %13, %20 ], [ 0, %0 ]
%9 = phi i64 [ %21, %20 ], [ 0, %0 ]
%10 = add nuw nsw i64 %7, 1
%11 = icmp eq i32 %5, 10
%12 = zext i1 %11 to i64
%13 = add nuw nsw i64 %8, %12
%14 = icmp eq i32 %6, 1
br i1 %14, label %15, label %18
15: ; preds = %4
switch i32 %5, label %16 [
i32 32, label %20
i32 10, label %20
i32 9, label %20
]
16: ; preds = %15
%17 = add nsw i64 %9, 1
br label %20
18: ; preds = %4
switch i32 %5, label %20 [
i32 32, label %19
i32 10, label %19
i32 9, label %19
]
19: ; preds = %18, %18, %18
br label %20
20: ; preds = %18, %15, %15, %15, %19, %16
%21 = phi i64 [ %17, %16 ], [ %9, %15 ], [ %9, %19 ], [ %9, %18 ], [ %9, %15 ], [ %9, %15 ]
%22 = phi i32 [ 0, %16 ], [ 1, %15 ], [ 1, %19 ], [ 0, %18 ], [ 1, %15 ], [ 1, %15 ]
%23 = tail call i32 (...) @getchar()
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %4
26: ; preds = %20, %0
%27 = phi i64 [ 0, %0 ], [ %21, %20 ]
%28 = phi i64 [ 0, %0 ], [ %13, %20 ]
%29 = phi i64 [ 0, %0 ], [ %10, %20 ]
%30 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %29)
%31 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %27)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %28)
ret i32 0
}