#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 */
char EOF;
char getchar();
int /*<<< orphan*/ print_histogram_row(char *, int);
int main() {
  int frequencies[4];
  for (int i = 0; i < 4; ++i) {
    frequencies[i] = 0;
  }
  char current_char = EOF;
  while ((current_char = getchar()) != EOF) {
    if (current_char == '\n') {
      ++frequencies[0];
    } else if (current_char == '\t') {
      ++frequencies[1];
    } else if (current_char == ' ') {
      ++frequencies[2];
    }
    ++frequencies[3];
  }
  print_histogram_row("Lines", frequencies[0]);
  print_histogram_row("Tabs", frequencies[1]);
  print_histogram_row("Spaces", frequencies[2]);
  print_histogram_row("Characters", frequencies[3]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    115a <main+0x3a>
movslq -0x24(%rbp),%rax
movl   $0x0,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1136 <main+0x16>
mov    0x2e87(%rip),%rax
mov    (%rax),%al
mov    %al,-0x25(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x25(%rbp)
movsbl %al,%eax
mov    0x2e6e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e9 <main+0xc9>
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
jne    11a0 <main+0x80>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11db <main+0xbb>
movsbl -0x25(%rbp),%eax
cmp    $0x9,%eax
jne    11bb <main+0x9b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d6 <main+0xb6>
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jne    11d1 <main+0xb1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <main+0xb6>
jmp    11db <main+0xbb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <main+0x46>
mov    -0x20(%rbp),%esi
lea    0xe0d(%rip),%rdi
call   1030 <print_histogram_row@plt>
mov    -0x1c(%rbp),%esi
lea    0xe04(%rip),%rdi
call   1030 <print_histogram_row@plt>
mov    -0x18(%rbp),%esi
lea    0xdfa(%rip),%rdi
call   1030 <print_histogram_row@plt>
mov    -0x14(%rbp),%esi
lea    0xdf2(%rip),%rdi
call   1030 <print_histogram_row@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eaf(%rip),%r12
mov    $0x0,%ebp
mov    $0x0,%r15d
mov    $0x0,%ebx
cmp    (%r12),%al
jne    1194 <main+0x74>
lea    0xeaa(%rip),%rdi
mov    %r14d,%esi
call   1030 <print_histogram_row@plt>
lea    0xea1(%rip),%rdi
mov    %ebp,%esi
call   1030 <print_histogram_row@plt>
lea    0xe98(%rip),%rdi
mov    %r15d,%esi
call   1030 <print_histogram_row@plt>
lea    0xe90(%rip),%rdi
mov    %ebx,%esi
call   1030 <print_histogram_row@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    11b4 <main+0x94>
add    $0x1,%r15d
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r12),%al
je     114f <main+0x2f>
cmp    $0x9,%al
je     11d0 <main+0xb0>
cmp    $0x20,%al
je     11a0 <main+0x80>
cmp    $0xa,%al
jne    11a4 <main+0x84>
add    $0x1,%r14d
jmp    11a4 <main+0x84>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
jmp    11a4 <main+0x84>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [6 x i8] c"Lines\00"
@.str.1 = [5 x i8] c"Tabs\00"
@.str.2 = [7 x i8] c"Spaces\00"
@.str.3 = [11 x i8] c"Characters\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 4
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %10
store i32 0, i32* %11
br label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
%16 = load i8, i8* @EOF
store i8 %16, i8* %4
br label %17
17: ; preds = %49, %15
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %4
%19 = sext i8 %18 to i32
%20 = load i8, i8* @EOF
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %53
23: ; preds = %17
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 10
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %49
31: ; preds = %23
%32 = load i8, i8* %4
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 9
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%37 = load i32, i32* %36
%38 = add nsw i32 %37, 1
store i32 %38, i32* %36
br label %48
39: ; preds = %31
%40 = load i8, i8* %4
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 32
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %44
br label %47
47: ; preds = %43, %39
br label %48
48: ; preds = %47, %35
br label %49
49: ; preds = %48, %27
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%51 = load i32, i32* %50
%52 = add nsw i32 %51, 1
store i32 %52, i32* %50
br label %17
53: ; preds = %17
%54 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%55 = load i32, i32* %54
%56 = call i32 @print_histogram_row(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%58 = load i32, i32* %57
%59 = call i32 @print_histogram_row(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%61 = load i32, i32* %60
%62 = call i32 @print_histogram_row(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %61)
%63 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%64 = load i32, i32* %63
%65 = call i32 @print_histogram_row(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %64)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [6 x i8] c"Lines\00"
@.str.1 = [5 x i8] c"Tabs\00"
@.str.2 = [7 x i8] c"Spaces\00"
@.str.3 = [11 x i8] c"Characters\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %24, label %4
4: ; preds = %0, %16
%5 = phi i32 [ %20, %16 ], [ 0, %0 ]
%6 = phi i32 [ %17, %16 ], [ 0, %0 ]
%7 = phi i32 [ %18, %16 ], [ 0, %0 ]
%8 = phi i32 [ %19, %16 ], [ 0, %0 ]
%9 = phi i8 [ %21, %16 ], [ %1, %0 ]
switch i8 %9, label %16 [
i8 10, label %10
i8 9, label %12
i8 32, label %14
]
10: ; preds = %4
%11 = add nsw i32 %6, 1
br label %16
12: ; preds = %4
%13 = add nsw i32 %7, 1
br label %16
14: ; preds = %4
%15 = add nsw i32 %8, 1
br label %16
16: ; preds = %4, %12, %14, %10
%17 = phi i32 [ %6, %4 ], [ %6, %12 ], [ %6, %14 ], [ %11, %10 ]
%18 = phi i32 [ %7, %4 ], [ %13, %12 ], [ %7, %14 ], [ %7, %10 ]
%19 = phi i32 [ %8, %4 ], [ %8, %12 ], [ %15, %14 ], [ %8, %10 ]
%20 = add nuw nsw i32 %5, 1
%21 = tail call signext i8 (...) @getchar()
%22 = load i8, i8* @EOF
%23 = icmp eq i8 %21, %22
br i1 %23, label %24, label %4
24: ; preds = %16, %0
%25 = phi i32 [ 0, %0 ], [ %17, %16 ]
%26 = phi i32 [ 0, %0 ], [ %18, %16 ]
%27 = phi i32 [ 0, %0 ], [ %19, %16 ]
%28 = phi i32 [ 0, %0 ], [ %20, %16 ]
%29 = tail call i32 @print_histogram_row(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %25)
%30 = tail call i32 @print_histogram_row(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%31 = tail call i32 @print_histogram_row(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%32 = tail call i32 @print_histogram_row(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %28)
ret i32 0
}