#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 *, unsigned long, unsigned long, unsigned long);
main() {
  unsigned long int characters = 0, words = 0, lines = 0;
  int in_word = 0;
  char ch;
  while ((ch = getchar()) != EOF) {
    characters++;
    switch (ch) {
    case '\n':
      lines++;
    case '\t':
    case ' ':
      if (in_word) {
        words++;
        in_word = 0;
      }
      break;
    default:
      in_word = 1;
    }
  }
  printf("%7d %7d %7d\n", lines, words, characters);
}


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   $0x0,-0x24(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x25(%rbp)
movsbl %al,%eax
mov    0x2e86(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ea <main+0xca>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movsbl -0x25(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x9,%eax
je     11bc <main+0x9c>
jmp    118e <main+0x6e>
mov    -0x2c(%rbp),%eax
sub    $0xa,%eax
je     11b0 <main+0x90>
jmp    119f <main+0x7f>
mov    -0x2c(%rbp),%eax
sub    $0x20,%eax
je     11bc <main+0x9c>
jmp    11de <main+0xbe>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11d9 <main+0xb9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
jmp    11e5 <main+0xc5>
movl   $0x1,-0x24(%rbp)
jmp    114e <main+0x2e>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe03(%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   %r12
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb2(%rip),%r12
cmp    (%r12),%al
jne    1164 <main+0x44>
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %ebx,%ebx
lea    0xeb5(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %ecx,%ecx
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    118c <main+0x6c>
cmp    $0x1,%ecx
sbb    $0xffffffffffffffff,%r14
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x1,%rbx
mov    %ebp,%ecx
cmp    (%r12),%al
je     1144 <main+0x24>
movsbl %al,%eax
cmp    $0x9,%eax
je     1170 <main+0x50>
cmp    $0x20,%eax
je     1170 <main+0x50>
mov    $0x1,%ebp
cmp    $0xa,%eax
jne    1179 <main+0x59>
add    $0x1,%r15
jmp    1170 <main+0x50>

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

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