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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     11c7 <main+0xa7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    1180 <main+0x60>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x20,-0x8(%rbp)
je     119e <main+0x7e>
cmpl   $0xa,-0x8(%rbp)
je     119e <main+0x7e>
cmpl   $0x9,-0x8(%rbp)
jne    11aa <main+0x8a>
movl   $0x0,-0x18(%rbp)
jmp    11c2 <main+0xa2>
cmpl   $0x0,-0x18(%rbp)
jne    11bd <main+0x9d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c2 <main+0xa2>
jmp    114b <main+0x2b>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe29(%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   %rbx
push   %rax
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb0(%rip),%r15
mov    $0x0,%ebx
mov    $0x0,%ebp
cmp    (%r15),%eax
je     1180 <main+0x60>
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
xchg   %ax,%ax
add    $0x1,%ebp
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebx
cmp    $0x20,%eax
setne  %cl
add    $0xfffffff5,%eax
cmp    $0xfffffffe,%eax
setb   %al
and    %cl,%al
movzbl %al,%eax
add    %eax,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r15),%eax
jne    1150 <main+0x30>
lea    0xe79(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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