#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 *, ...);
void symbol_counter() {
  int c;
  int p;
  int t = 0;
  int nl = 0;
  int bl = 0;
  int s = 0;
  while ((c = getchar()) != EOF) {
    switch (c) {
    case '\n':
      if (p == '\n')
        ++bl;
      ++nl;
    case '\t':
      ++t;
    case 32:
      ++s;
    }
    p = c;
  }
  printf("%8s %s\n", "Number", "Symbol");
  printf("%8d %s\n", nl, "New lines");
  printf("%8d %s\n", t, "Tabs");
  printf("%8d %s\n", bl, "Blanks");
  printf("%8d %s\n", s, "Spaces");
}


x86 assembly (clang, -O0):
<symbol_counter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
je     11cc <symbol_counter+0xac>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x9,%eax
je     11af <symbol_counter+0x8f>
jmp    1171 <symbol_counter+0x51>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     1193 <symbol_counter+0x73>
jmp    1182 <symbol_counter+0x62>
mov    -0x1c(%rbp),%eax
sub    $0x20,%eax
je     11b8 <symbol_counter+0x98>
jmp    11c1 <symbol_counter+0xa1>
cmpl   $0xa,-0x8(%rbp)
jne    11a6 <symbol_counter+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <symbol_counter+0x24>
lea    0xe2d(%rip),%rdi
lea    0xe2e(%rip),%rsi
lea    0xe2e(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe24(%rip),%rdi
lea    0xe25(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe0c(%rip),%rdi
lea    0xe17(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdf4(%rip),%rdi
lea    0xe04(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xddc(%rip),%rdi
lea    0xdf3(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symbol_counter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r13d,%r13d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eac(%rip),%r12
mov    $0x0,%r15d
mov    $0x0,%r14d
mov    $0x0,%ebx
cmp    (%r12),%eax
jne    11d7 <symbol_counter+0xb7>
lea    0xea2(%rip),%rdi
lea    0xea3(%rip),%rsi
lea    0xea3(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9c(%rip),%r12
lea    0xe9d(%rip),%rdx
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe93(%rip),%rdx
mov    %r12,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe84(%rip),%rdx
mov    %r12,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe77(%rip),%rdx
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
xor    %ebx,%ebx
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %r13d,%r13d
jmp    120a <symbol_counter+0xea>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13d
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%ecx
cmp    (%r12),%eax
je     1157 <symbol_counter+0x37>
mov    %eax,%ebp
cmp    $0x9,%eax
je     11f0 <symbol_counter+0xd0>
cmp    $0x20,%ebp
je     11f4 <symbol_counter+0xd4>
cmp    $0xa,%ebp
jne    11f7 <symbol_counter+0xd7>
xor    %eax,%eax
cmp    $0xa,%ecx
sete   %al
add    %eax,%r14d
add    $0x1,%r15d
jmp    11f0 <symbol_counter+0xd0>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [8 x i8] c"%8s %s\0A\00"
@.str.1 = [7 x i8] c"Number\00"
@.str.2 = [7 x i8] c"Symbol\00"
@.str.3 = [8 x i8] c"%8d %s\0A\00"
@.str.4 = [10 x i8] c"New lines\00"
@.str.5 = [5 x i8] c"Tabs\00"
@.str.6 = [7 x i8] c"Blanks\00"
@.str.7 = [7 x i8] c"Spaces\00"
define void @symbol_counter() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %33, label %4
4: ; preds = %0, %25
%5 = phi i32 [ %30, %25 ], [ %1, %0 ]
%6 = phi i32 [ %29, %25 ], [ 0, %0 ]
%7 = phi i32 [ %28, %25 ], [ 0, %0 ]
%8 = phi i32 [ %27, %25 ], [ 0, %0 ]
%9 = phi i32 [ %26, %25 ], [ 0, %0 ]
%10 = phi i32 [ %5, %25 ], [ undef, %0 ]
switch i32 %5, label %25 [
i32 10, label %11
i32 9, label %16
i32 32, label %20
]
11: ; preds = %4
%12 = icmp eq i32 %10, 10
%13 = zext i1 %12 to i32
%14 = add nsw i32 %7, %13
%15 = add nsw i32 %8, 1
br label %16
16: ; preds = %4, %11
%17 = phi i32 [ %8, %4 ], [ %15, %11 ]
%18 = phi i32 [ %7, %4 ], [ %14, %11 ]
%19 = add nsw i32 %9, 1
br label %20
20: ; preds = %4, %16
%21 = phi i32 [ %9, %4 ], [ %19, %16 ]
%22 = phi i32 [ %8, %4 ], [ %17, %16 ]
%23 = phi i32 [ %7, %4 ], [ %18, %16 ]
%24 = add nsw i32 %6, 1
br label %25
25: ; preds = %20, %4
%26 = phi i32 [ %9, %4 ], [ %21, %20 ]
%27 = phi i32 [ %8, %4 ], [ %22, %20 ]
%28 = phi i32 [ %7, %4 ], [ %23, %20 ]
%29 = phi i32 [ %6, %4 ], [ %24, %20 ]
%30 = tail call i32 (...) @getchar()
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %4
33: ; preds = %25, %0
%34 = phi i32 [ 0, %0 ], [ %26, %25 ]
%35 = phi i32 [ 0, %0 ], [ %27, %25 ]
%36 = phi i32 [ 0, %0 ], [ %28, %25 ]
%37 = phi i32 [ 0, %0 ], [ %29, %25 ]
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %35, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
ret void
}