#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 getchar();
int /*<<< orphan*/ printf(char *, int);
main() {
  int code;
  int end = getchar();
  int tabCount = 0, spaceCount = 0, newLineCounter = 0;
  while ((code = getchar()) != end) {
    if (code == '\n') {
      ++newLineCounter;
    }
    if (code == ' ') {
      ++spaceCount;
    }
    if (code == '\t') {
      ++tabCount;
    }
  }
  printf("New lines: %d\n", newLineCounter);
  printf("Spaces: %d\n", spaceCount);
  printf("Tabs: %d\n", tabCount);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    -0xc(%rbp),%eax
je     119f <main+0x7f>
cmpl   $0xa,-0x8(%rbp)
jne    1174 <main+0x54>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x20,-0x8(%rbp)
jne    1187 <main+0x67>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x9,-0x8(%rbp)
jne    119a <main+0x7a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114e <main+0x2e>
mov    -0x18(%rbp),%esi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x0,%ebp
mov    $0x0,%ebx
cmp    %r14d,%eax
je     118b <main+0x6b>
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebx
xor    %ecx,%ecx
cmp    $0x20,%eax
sete   %cl
add    %ecx,%ebp
xor    %ecx,%ecx
cmp    $0x9,%eax
sete   %cl
add    %ecx,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    %r14d,%eax
jne    1160 <main+0x40>
lea    0xe6e(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xe6d(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"New lines: %d\0A\00"
@.str.1 = [12 x i8] c"Spaces: %d\0A\00"
@.str.2 = [10 x i8] c"Tabs: %d\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
%7 = call i32 (...) @getchar()
store i32 %7, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %30, %0
%9 = call i32 (...) @getchar()
store i32 %9, i32* %2
%10 = load i32, i32* %3
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %8
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 32
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %24
24: ; preds = %21, %18
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, 9
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 %8
31: ; preds = %8
%32 = load i32, i32* %6
%33 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %5
%35 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %4
%37 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %1
ret i32 %38
}

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