#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 *, int, int, int);
int main() {
  int c, nl, nw, nc, state;
  state = 0;
  nl = nw = nc = 0;
  while ((c = getchar()) != EOF) {
    ++nc;
    if (c == ' ' || c == '\n' || c == '\t') {
      state = 0;
      if (c == '\n') {
        ++nl;
      }
    } else if (state == 0) {
      state = 1;
      ++nw;
    }
  }
  printf("Lines: %d, Words: %d, Characters %d.\n", nl, nw, nc);
  return 0;
}


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    %eax,-0x8(%rbp)
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     11ce <main+0xae>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x8(%rbp)
je     118b <main+0x6b>
cmpl   $0xa,-0x8(%rbp)
je     118b <main+0x6b>
cmpl   $0x9,-0x8(%rbp)
jne    11aa <main+0x8a>
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    11a5 <main+0x85>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c9 <main+0xa9>
cmpl   $0x0,-0x18(%rbp)
jne    11c4 <main+0xa4>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c9 <main+0xa9>
jmp    114b <main+0x2b>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eaf(%rip),%r15
mov    $0x0,%r12d
mov    $0x0,%ebp
cmp    (%r15),%eax
jne    1168 <main+0x48>
lea    0xeb0(%rip),%rdi
mov    %r14d,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r12d,%r12d
xor    %r14d,%r14d
jmp    1195 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14d
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%ebp
cmp    (%r15),%eax
je     1149 <main+0x29>
cmp    $0x9,%eax
je     1184 <main+0x64>
cmp    $0x20,%eax
je     1184 <main+0x64>
cmp    $0xa,%eax
je     1180 <main+0x60>
cmp    $0x1,%ebx
adc    $0x0,%r12d
mov    $0x1,%ebx
jmp    1186 <main+0x66>

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

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