#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 getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  int blanks_count, tabs_count, newlines_count, c;
  blanks_count = tabs_count = newlines_count = c = 0;
  printf("Enter some text: ");
  while ((c = getc(stdin)) != EOF) {
    if (c == 0x20)
      blanks_count++;
    else if (c == 0x9)
      tabs_count++;
    else if (c == 0xa)
      newlines_count++;
  }
  printf("\nREPORT SUMMARY\nblanks = %d\ntabs = %d\nnewlines = %d\n\n",
         blanks_count, tabs_count, newlines_count);
  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,-0x8(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e6f(%rip),%rcx
cmp    (%rcx),%eax
je     11cb <main+0xab>
cmpl   $0x20,-0x14(%rbp)
jne    1191 <main+0x71>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c6 <main+0xa6>
cmpl   $0x9,-0x14(%rbp)
jne    11a9 <main+0x89>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c1 <main+0xa1>
cmpl   $0xa,-0x14(%rbp)
jne    11bc <main+0x9c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c1 <main+0xa1>
jmp    11c6 <main+0xa6>
jmp    1159 <main+0x39>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
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
lea    0xed1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2ea8(%rip),%r15
mov    (%r15),%edi
call   1040 <getc@plt>
mov    0x2e91(%rip),%r12
mov    $0x0,%ebx
mov    $0x0,%ebp
cmp    (%r12),%eax
jne    117f <main+0x5f>
lea    0xeac(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    11a1 <main+0x81>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    (%r15),%edi
call   1040 <getc@plt>
cmp    (%r12),%eax
je     115f <main+0x3f>
cmp    $0x9,%eax
je     11c0 <main+0xa0>
cmp    $0xa,%eax
je     1190 <main+0x70>
cmp    $0x20,%eax
jne    1193 <main+0x73>
add    $0x1,%r14d
jmp    1193 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
jmp    1193 <main+0x73>

LLVM IR (-O0):
@.str = [18 x i8] c"Enter some text: \00"
@stdin = global i32 0
@EOF = global i32 0
@.str.1 = [54 x i8] c"\0AREPORT SUMMARY\0Ablanks = %d\0Atabs = %d\0Anewlines = %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = 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* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %32, %0
%8 = load i32, i32* @stdin
%9 = call i32 @getc(i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %33
12: ; preds = %7
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %32
18: ; preds = %12
%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 %31
24: ; preds = %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
br label %31
31: ; preds = %30, %21
br label %32
32: ; preds = %31, %15
br label %7
33: ; preds = %7
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter some text: \00"
@stdin = global i32 0
@EOF = global i32 0
@.str.1 = [54 x i8] c"\0AREPORT SUMMARY\0Ablanks = %d\0Atabs = %d\0Anewlines = %d\0A\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%2 = load i32, i32* @stdin
%3 = tail call i32 @getc(i32 %2)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %25, label %6
6: ; preds = %0, %17
%7 = phi i32 [ %22, %17 ], [ %3, %0 ]
%8 = phi i32 [ %20, %17 ], [ 0, %0 ]
%9 = phi i32 [ %19, %17 ], [ 0, %0 ]
%10 = phi i32 [ %18, %17 ], [ 0, %0 ]
switch i32 %7, label %17 [
i32 32, label %11
i32 9, label %13
i32 10, label %15
]
11: ; preds = %6
%12 = add nsw i32 %10, 1
br label %17
13: ; preds = %6
%14 = add nsw i32 %9, 1
br label %17
15: ; preds = %6
%16 = add nsw i32 %8, 1
br label %17
17: ; preds = %6, %13, %15, %11
%18 = phi i32 [ %12, %11 ], [ %10, %13 ], [ %10, %15 ], [ %10, %6 ]
%19 = phi i32 [ %9, %11 ], [ %14, %13 ], [ %9, %15 ], [ %9, %6 ]
%20 = phi i32 [ %8, %11 ], [ %8, %13 ], [ %16, %15 ], [ %8, %6 ]
%21 = load i32, i32* @stdin
%22 = tail call i32 @getc(i32 %21)
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %6
25: ; preds = %17, %0
%26 = phi i32 [ 0, %0 ], [ %18, %17 ]
%27 = phi i32 [ 0, %0 ], [ %19, %17 ]
%28 = phi i32 [ 0, %0 ], [ %20, %17 ]
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
ret i32 0
}