#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, int, int, int);
int main(void) {
  char ch;
  int nl, nw, nc, state;
  state = 0;
  nl = nw = nc = 0;
  while ((ch = getchar()) != EOF) {
    ++nc;
    if (ch == '\n') {
      ++nl;
    }
    if (ch == ' ' || ch == '\t' || ch == '\n') {
      state = 0;
    } else if (state == 0) {
      state = 1;
      ++nw;
    }
  }
  printf("Lines: %d\nWords: %d\nChars: %d\n", nl, nw, nc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e89(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e0 <main+0xc0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    1189 <main+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
je     11b0 <main+0x90>
movsbl -0x5(%rbp),%eax
cmp    $0x9,%eax
je     11b0 <main+0x90>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    11bc <main+0x9c>
movl   $0x0,-0x18(%rbp)
jmp    11db <main+0xbb>
cmpl   $0x0,-0x18(%rbp)
jne    11d6 <main+0xb6>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11db <main+0xbb>
jmp    114b <main+0x2b>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
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
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2ead(%rip),%r15
mov    $0x0,%r14d
mov    $0x0,%ebp
cmp    (%r15),%al
jne    116f <main+0x4f>
lea    0xeae(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000600,%r12
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    11b1 <main+0x91>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x1,%r13d
adc    $0x0,%r14d
mov    $0x1,%r13d
mov    %dl,%cl
add    %ecx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%ebp
cmp    (%r15),%al
je     114b <main+0x2b>
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %dl
cmp    $0x20,%al
ja     1190 <main+0x70>
movzbl %al,%eax
bt     %rax,%r12
jae    1190 <main+0x70>
xor    %r13d,%r13d
jmp    119e <main+0x7e>

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

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