#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 main(void) {
  int ret = 0;
  int nblanks = 0, ntabs = 0, nnewlines = 0;
  int c = 0;
  printf("This program counts the number of blanks, tabs, newlines.\n");
  while ((c = getchar()) != EOF) {
    if (c == ' ')
      ++nblanks;
    if (c == '\t')
      ++ntabs;
    if (c == '\n')
      ++nnewlines;
  }
  printf("\nWe have %d blanks, %d tabs, %d nnewlines.\n", nblanks, ntabs,
         nnewlines);
  return ret;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     11b7 <main+0x97>
cmpl   $0x20,-0x18(%rbp)
jne    118c <main+0x6c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x9,-0x18(%rbp)
jne    119f <main+0x7f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xa,-0x18(%rbp)
jne    11b2 <main+0x92>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <main+0x40>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e94(%rip),%r15
mov    $0x0,%ebx
mov    $0x0,%ebp
cmp    (%r15),%eax
je     119b <main+0x6b>
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    $0x20,%eax
sete   %cl
add    %ecx,%r14d
xor    %ecx,%ecx
cmp    $0x9,%eax
sete   %cl
add    %ecx,%ebx
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r15),%eax
jne    1170 <main+0x40>
lea    0xe5e(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [44 x i8] c"\0AWe have %d blanks, %d tabs, %d nnewlines.\0A\00"
@str = [58 x i8] c"This program counts the number of blanks, tabs, newlines.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %22, label %5
5: ; preds = %0, %5
%6 = phi i32 [ %19, %5 ], [ %2, %0 ]
%7 = phi i32 [ %18, %5 ], [ 0, %0 ]
%8 = phi i32 [ %15, %5 ], [ 0, %0 ]
%9 = phi i32 [ %12, %5 ], [ 0, %0 ]
%10 = icmp eq i32 %6, 32
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %9, %11
%13 = icmp eq i32 %6, 9
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %8, %14
%16 = icmp eq i32 %6, 10
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %7, %17
%19 = tail call i32 (...) @getchar()
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %5
22: ; preds = %5, %0
%23 = phi i32 [ 0, %0 ], [ %12, %5 ]
%24 = phi i32 [ 0, %0 ], [ %15, %5 ]
%25 = phi i32 [ 0, %0 ], [ %18, %5 ]
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
ret i32 0
}