#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*/ print_histogram_horizontal(int *);
int /*<<< orphan*/ print_histogram_vertical(int *);
int main(void) {
  int c, words, flag;
  int size_of_words[10];
  words = flag = 0;
  while (flag < 10) {
    c = getchar();
    if (c == ' ' || c == '\n' || c == '\t' || (c >= '0' && c <= '9')) {
      if (words > 0) {
        size_of_words[flag] = words;
        flag++;
        words = 0;
      }
    } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
      words++;
    }
  }
  print_histogram_horizontal(size_of_words);
  print_histogram_vertical(size_of_words);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    11f8 <main+0xc8>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
je     1193 <main+0x63>
cmpl   $0xa,-0x8(%rbp)
je     1193 <main+0x63>
cmpl   $0x9,-0x8(%rbp)
je     1193 <main+0x63>
cmpl   $0x30,-0x8(%rbp)
jl     11bd <main+0x8d>
cmpl   $0x39,-0x8(%rbp)
jg     11bd <main+0x8d>
cmpl   $0x0,-0xc(%rbp)
jle    11b8 <main+0x88>
mov    -0xc(%rbp),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    11f3 <main+0xc3>
cmpl   $0x61,-0x8(%rbp)
jl     11d1 <main+0xa1>
cmpl   $0x7a,-0x8(%rbp)
jle    11e5 <main+0xb5>
cmpl   $0x41,-0x8(%rbp)
jl     11ee <main+0xbe>
cmpl   $0x5a,-0x8(%rbp)
jg     11ee <main+0xbe>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f3 <main+0xc3>
jmp    114d <main+0x1d>
lea    -0x40(%rbp),%rdi
call   1050 <print_histogram_horizontal@plt>
lea    -0x40(%rbp),%rdi
call   1030 <print_histogram_vertical@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movabs $0x100000600,%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1165 <main+0x35>
and    $0xffffffdf,%eax
add    $0xffffffbf,%eax
cmp    $0x1a,%eax
adc    $0x0,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xa,%ebx
jge    119a <main+0x6a>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x20,%eax
ja     1190 <main+0x60>
mov    %eax,%ecx
bt     %rcx,%r14
jae    1190 <main+0x60>
test   %ebp,%ebp
jle    1160 <main+0x30>
movslq %ebx,%rbx
mov    %ebp,(%rsp,%rbx,4)
add    $0x1,%ebx
xor    %ebp,%ebp
jmp    1160 <main+0x30>
nopw   0x0(%rax,%rax,1)
lea    -0x30(%rax),%ecx
cmp    $0x9,%ecx
ja     1148 <main+0x18>
jmp    1179 <main+0x49>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <print_histogram_horizontal@plt>
mov    %rbx,%rdi
call   1030 <print_histogram_vertical@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x i32]
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %3
br label %6
6: ; preds = %52, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %53
9: ; preds = %6
%10 = call i32 (...) @getchar()
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 32
br i1 %12, label %25, label %13
13: ; preds = %9
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 10
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 9
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = icmp sge i32 %20, 48
br i1 %21, label %22, label %36
22: ; preds = %19
%23 = load i32, i32* %2
%24 = icmp sle i32 %23, 57
br i1 %24, label %25, label %36
25: ; preds = %22, %16, %13, %9
%26 = load i32, i32* %3
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %31
store i32 %29, i32* %32
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
store i32 0, i32* %3
br label %35
35: ; preds = %28, %25
br label %52
36: ; preds = %22, %19
%37 = load i32, i32* %2
%38 = icmp sge i32 %37, 97
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %2
%41 = icmp sle i32 %40, 122
br i1 %41, label %48, label %42
42: ; preds = %39, %36
%43 = load i32, i32* %2
%44 = icmp sge i32 %43, 65
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i32, i32* %2
%47 = icmp sle i32 %46, 90
br i1 %47, label %48, label %51
48: ; preds = %45, %39
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %51
51: ; preds = %48, %45, %42
br label %52
52: ; preds = %51, %35
br label %6
53: ; preds = %6
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%55 = call i32 @print_histogram_horizontal(i32* %54)
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%57 = call i32 @print_histogram_vertical(i32* %56)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
br label %3
3: ; preds = %0, %22
%4 = phi i32 [ 0, %0 ], [ %24, %22 ]
%5 = phi i32 [ 0, %0 ], [ %23, %22 ]
%6 = tail call i32 (...) @getchar()
switch i32 %6, label %7 [
i32 32, label %10
i32 10, label %10
i32 9, label %10
]
7: ; preds = %3
%8 = add i32 %6, -48
%9 = icmp ult i32 %8, 10
br i1 %9, label %10, label %16
10: ; preds = %3, %3, %3, %7
%11 = icmp sgt i32 %5, 0
br i1 %11, label %12, label %22
12: ; preds = %10
%13 = sext i32 %4 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %13
store i32 %5, i32* %14
%15 = add nsw i32 %4, 1
br label %22
16: ; preds = %7
%17 = and i32 %6, -33
%18 = add i32 %17, -65
%19 = icmp ult i32 %18, 26
%20 = zext i1 %19 to i32
%21 = add nsw i32 %5, %20
br label %22
22: ; preds = %16, %10, %12
%23 = phi i32 [ 0, %12 ], [ %5, %10 ], [ %21, %16 ]
%24 = phi i32 [ %15, %12 ], [ %4, %10 ], [ %4, %16 ]
%25 = icmp slt i32 %24, 10
br i1 %25, label %3, label %26
26: ; preds = %22
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%28 = call i32 @print_histogram_horizontal(i32* %27)
%29 = call i32 @print_histogram_vertical(i32* %27)
ret i32 0
}