#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 main() {
  int c, nc, nw, nl, state;
  state = 0;
  nl = nw = nc = 0;
  for (nc = 0; (c = getchar()) != EOF; nc++) {
    if (c == '\n')
      nl++;
    if (c == ' ' || c == '\t' || c == '\n')
      state = 0;
    else if (state == 0) {
      nw++;
      state = 1;
    }
  }
  printf("Total lines: %d\n", nl);
  printf("Total words: %d\n", nw);
  printf("Total chars: %d\n", nc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%eax
je     11da <main+0xba>
cmpl   $0xa,-0x8(%rbp)
jne    117e <main+0x5e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x8(%rbp)
je     119c <main+0x7c>
cmpl   $0x9,-0x8(%rbp)
je     119c <main+0x7c>
cmpl   $0xa,-0x8(%rbp)
jne    11a8 <main+0x88>
movl   $0x0,-0x18(%rbp)
jmp    11c7 <main+0xa7>
cmpl   $0x0,-0x18(%rbp)
jne    11c2 <main+0xa2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    11c7 <main+0xa7>
jmp    11cc <main+0xac>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <main+0x32>
mov    -0x14(%rbp),%esi
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe20(%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),%eax
jne    1187 <main+0x67>
lea    0xeae(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    %ebx,%esi
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    11c1 <main+0xa1>
nopl   (%rax)
cmp    $0x1,%r13d
adc    $0x0,%r14d
mov    $0x1,%r13d
mov    %dl,%cl
add    %ecx,%ebp
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r15),%eax
je     114b <main+0x2b>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %dl
cmp    $0x20,%eax
ja     11a0 <main+0x80>
mov    %eax,%eax
bt     %rax,%r12
jae    11a0 <main+0x80>
xor    %r13d,%r13d
jmp    11ae <main+0x8e>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [17 x i8] c"Total lines: %d\0A\00"
@.str.1 = [17 x i8] c"Total words: %d\0A\00"
@.str.2 = [17 x i8] c"Total chars: %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 [ %19, %17 ], [ 0, %0 ]
%7 = phi i32 [ %12, %17 ], [ 0, %0 ]
%8 = phi i32 [ %18, %17 ], [ 0, %0 ]
%9 = phi i32 [ %20, %17 ], [ 0, %0 ]
%10 = icmp eq i32 %5, 10
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %7, %11
switch i32 %5, label %13 [
i32 32, label %17
i32 10, label %17
i32 9, 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, %4
%18 = phi i32 [ %8, %4 ], [ %16, %13 ], [ %8, %4 ], [ %8, %4 ]
%19 = phi i32 [ 0, %4 ], [ 1, %13 ], [ 0, %4 ], [ 0, %4 ]
%20 = add nuw nsw i32 %9, 1
%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 ], [ %20, %17 ]
%26 = phi i32 [ 0, %0 ], [ %18, %17 ]
%27 = phi i32 [ 0, %0 ], [ %12, %17 ]
%28 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %25)
ret i32 0
}