#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();
scalar_t__ isspace(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main() {
  int tot_chars = 0;
  int tot_lines = 0;
  int tot_words = 0;
  int character;
  int prev_character;
  while ((character = getchar()) != EOF) {
    tot_chars++;
    if ((isspace(character)) && !isspace(prev_character)) {
      tot_words++;
    }
    if (character == '\n') {
      tot_lines++;
    }
    prev_character = character;
  }
  printf("%3d%4d%4d\n", tot_lines, tot_words, tot_chars);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%eax
je     11c1 <main+0x91>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11a3 <main+0x73>
mov    -0x18(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    11a3 <main+0x73>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    11b6 <main+0x86>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <main+0x24>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe2f(%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   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9c(%rip),%r13
mov    $0x0,%r14d
mov    $0x0,%ebp
cmp    0x0(%r13),%eax
jne    1182 <main+0x52>
lea    0xe9c(%rip),%rdi
mov    %r12d,%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
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    11af <main+0x7f>
nopl   0x0(%rax)
xor    %eax,%eax
cmp    $0xa,%r15d
sete   %al
add    %eax,%r12d
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%ebp
mov    %r15d,%ebx
cmp    0x0(%r13),%eax
je     115d <main+0x2d>
mov    %eax,%r15d
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     1190 <main+0x60>
mov    %ebx,%edi
call   1040 <isspace@plt>
cmp    $0x1,%rax
adc    $0x0,%r14d
jmp    1190 <main+0x60>

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

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