#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(void) {
  int blanks, tabs, newlines;
  int c;
  int done = 0;
  int lastchar = 0;
  blanks = 0;
  tabs = 0;
  newlines = 0;
  while (done == 0) {
    c = getchar();
    if (c == ' ')
      ++blanks;
    if (c == '\t')
      ++tabs;
    if (c == '\n')
      ++newlines;
    if (c == EOF) {
      if (lastchar != '\n') {
        ++newlines;
      }
      done = 1;
    }
    lastchar = c;
  }
  printf("Blanks: %d\nTabs: %d\nLines: %d\n", blanks, tabs, newlines);
  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,-0x1c(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11d6 <main+0xb6>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jne    1179 <main+0x59>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x9,-0x14(%rbp)
jne    118c <main+0x6c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    119f <main+0x7f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%eax
jne    11cb <main+0xab>
cmpl   $0xa,-0x1c(%rbp)
je     11c4 <main+0xa4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <main+0x32>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe1a(%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
mov    0x2eb9(%rip),%r15
xor    %r12d,%r12d
xor    %r14d,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %ecx,%ecx
cmp    $0x20,%eax
sete   %cl
add    %ecx,%r14d
xor    %ecx,%ecx
cmp    $0x9,%eax
sete   %cl
add    %ecx,%ebp
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ebx,%ecx
mov    (%r15),%edx
cmp    %edx,%eax
sete   %sil
cmp    $0xa,%r12d
setne  %bl
and    %sil,%bl
movzbl %bl,%ebx
add    %ecx,%ebx
mov    %eax,%r12d
cmp    %edx,%eax
jne    1140 <main+0x20>
lea    0xe74(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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