#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 c, newline_count, space_count, tabs_count;
  newline_count = space_count = tabs_count = 0;
  printf("enter some characters with EOF on the end\n");
  while ((c = getchar()) != EOF) {
    if (c == '\n')
      newline_count++;
    if (c == '\t')
      tabs_count++;
    if (c == ' ')
      space_count++;
  }
  printf("newlines = %d\ntabs = %d\nspaces = %d\n", newline_count, tabs_count,
         space_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)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%eax
je     11a9 <main+0x89>
cmpl   $0xa,-0x8(%rbp)
jne    117e <main+0x5e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x9,-0x8(%rbp)
jne    1191 <main+0x71>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x20,-0x8(%rbp)
jne    11a4 <main+0x84>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <main+0x32>
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe72(%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   %rbx
push   %rax
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e94(%rip),%r15
mov    $0x0,%ebp
mov    $0x0,%ebx
cmp    (%r15),%eax
je     119b <main+0x6b>
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%r14d
xor    %ecx,%ecx
cmp    $0x9,%eax
sete   %cl
add    %ecx,%ebx
xor    %ecx,%ecx
cmp    $0x20,%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 = [43 x i8] c"enter some characters with EOF on the end\0A\00"
@EOF = global i32 0
@.str.1 = [37 x i8] c"newlines = %d\0Atabs = %d\0Aspaces = %d\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
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %29, %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 %30
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 10
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %17
17: ; preds = %14, %11
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 9
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %23
23: ; preds = %20, %17
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 32
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %29
29: ; preds = %26, %23
br label %7
30: ; preds = %7
%31 = load i32, i32* %3
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [37 x i8] c"newlines = %d\0Atabs = %d\0Aspaces = %d\0A\00"
@str = [42 x i8] c"enter some characters with EOF on the end\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 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 [ %15, %5 ], [ 0, %0 ]
%8 = phi i32 [ %18, %5 ], [ 0, %0 ]
%9 = phi i32 [ %12, %5 ], [ 0, %0 ]
%10 = icmp eq i32 %6, 10
%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 %7, %14
%16 = icmp eq i32 %6, 32
%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 %5
22: ; preds = %5, %0
%23 = phi i32 [ 0, %0 ], [ %12, %5 ]
%24 = phi i32 [ 0, %0 ], [ %18, %5 ]
%25 = phi i32 [ 0, %0 ], [ %15, %5 ]
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %25, i32 %24)
ret i32 0
}