#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 main(int argc, char const *argv[]) {
  int countspace = 0;
  int counttable = 0;
  int countenter = 0;
  int c;
  while ((c = getchar()) != EOF) {
    if (c == '\t')
      counttable++;
    if (c == ' ')
      countspace++;
    if (c == '\n')
      countenter++;
  }
  printf("countspace is %d\n", countspace);
  printf("counttable is %d\n", counttable);
  printf("countenter is %d\n", countenter);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     11a2 <main+0x82>
cmpl   $0x9,-0x20(%rbp)
jne    1177 <main+0x57>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x20(%rbp)
jne    118a <main+0x6a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x20(%rbp)
jne    119d <main+0x7d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <main+0x2b>
mov    -0x14(%rbp),%esi
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe5a(%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,%ebp
mov    $0x0,%ebx
cmp    (%r15),%eax
je     117b <main+0x5b>
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r14d,%r14d
xchg   %ax,%ax
xor    %ecx,%ecx
cmp    $0x9,%eax
sete   %cl
add    %ecx,%r14d
xor    %ecx,%ecx
cmp    $0x20,%eax
sete   %cl
add    %ecx,%ebx
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r15),%eax
jne    1150 <main+0x30>
lea    0xe7e(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
mov    %ebp,%esi
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 = [18 x i8] c"countspace is %d\0A\00"
@.str.1 = [18 x i8] c"counttable is %d\0A\00"
@.str.2 = [18 x i8] c"countenter is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %10
10: ; preds = %32, %2
%11 = call i32 (...) @getchar()
store i32 %11, i32* %9
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i32, i32* %9
%16 = icmp eq i32 %15, 9
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, 32
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %9
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %32
32: ; preds = %29, %26
br label %10
33: ; preds = %10
%34 = load i32, i32* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %7
%37 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %8
%39 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %38)
ret i32 0
}

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