#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 /*<<< orphan*/ exit(int);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
main() {
  int c, w, i, j;
  int histo[20];
  w = 0;
  for (i = 0; i < 20; ++i)
    histo[i] = 0;
  while ((c = getchar()) != EOF)
    if (c == ' ' || c == '\t' || c == '\n' || c == '.') {
      if (w > 0) {
        if (w >= 20) {
          printf("word too long.\n");
          exit(1);
        }
        ++histo[w - 1];
        w = 0;
      }
    } else {
      ++w;
    }
  for (i = 0; i < 20; ++i) {
    if (i < 9)
      printf(" %d ", i + 1);
    else
      printf("%d ", i + 1);
    for (j = 1; j <= histo[i]; ++j)
      printf("#");
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    1171 <main+0x41>
movslq -0x10(%rbp),%rax
movl   $0x0,-0x70(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114d <main+0x1d>
jmp    1176 <main+0x46>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e61(%rip),%rcx
cmp    (%rcx),%eax
je     1210 <main+0xe0>
cmpl   $0x20,-0x8(%rbp)
je     11b7 <main+0x87>
cmpl   $0x9,-0x8(%rbp)
je     11b7 <main+0x87>
cmpl   $0xa,-0x8(%rbp)
je     11b7 <main+0x87>
cmpl   $0x2e,-0x8(%rbp)
jne    1202 <main+0xd2>
cmpl   $0x0,-0xc(%rbp)
jle    11fd <main+0xcd>
cmpl   $0x14,-0xc(%rbp)
jl     11e3 <main+0xb3>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x70(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x70(%rbp,%rax,4)
movl   $0x0,-0xc(%rbp)
jmp    120b <main+0xdb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <main+0x46>
movl   $0x0,-0x10(%rbp)
cmpl   $0x14,-0x10(%rbp)
jge    12a8 <main+0x178>
cmpl   $0x9,-0x10(%rbp)
jge    1244 <main+0x114>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1258 <main+0x128>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
movslq -0x10(%rbp),%rcx
cmp    -0x70(%rbp,%rcx,4),%eax
jg     128c <main+0x15c>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    125f <main+0x12f>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1217 <main+0xe7>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e65(%rip),%r15
cmp    (%r15),%eax
jne    11ee <main+0x9e>
lea    0xe71(%rip),%r14
lea    0xe6b(%rip),%r15
xor    %ebx,%ebx
jmp    11b4 <main+0x64>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x14,%rbx
je     11e1 <main+0x91>
lea    0x1(%rbx),%esi
cmp    $0x9,%rbx
mov    %r15,%rdi
cmovb  %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11a0 <main+0x50>
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x80>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x400100000600,%r14
xor    %ebx,%ebx
jmp    1213 <main+0xc3>
nopl   0x0(%rax)
add    $0x1,%ebx
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%r15),%eax
je     1188 <main+0x38>
cmp    $0x2e,%eax
ja     1200 <main+0xb0>
mov    %eax,%eax
bt     %rax,%r14
jae    1200 <main+0xb0>
test   %ebx,%ebx
jle    1203 <main+0xb3>
cmp    $0x14,%ebx
jae    1234 <main+0xe4>
add    $0xffffffff,%ebx
addl   $0x1,(%rsp,%rbx,4)
xor    %ebx,%ebx
jmp    1203 <main+0xb3>
lea    0xdca(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [16 x i8] c"word too long.\0A\00"
@.str.1 = [5 x i8] c" %d \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [20 x i32]
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 20
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 %12
store i32 0, i32* %13
br label %14
14: ; preds = %10
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %7
17: ; preds = %7
br label %18
18: ; preds = %54, %17
%19 = call i32 (...) @getchar()
store i32 %19, i32* %2
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %55
22: ; preds = %18
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 32
br i1 %24, label %34, label %25
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 9
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i32, i32* %2
%30 = icmp eq i32 %29, 10
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 46
br i1 %33, label %34, label %51
34: ; preds = %31, %28, %25, %22
%35 = load i32, i32* %3
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %50
37: ; preds = %34
%38 = load i32, i32* %3
%39 = icmp sge i32 %38, 20
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %37
%44 = load i32, i32* %3
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = add nsw i32 %48, 1
store i32 %49, i32* %47
store i32 0, i32* %3
br label %50
50: ; preds = %43, %34
br label %54
51: ; preds = %31
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %54
54: ; preds = %51, %50
br label %18
55: ; preds = %18
store i32 0, i32* %4
br label %56
56: ; preds = %85, %55
%57 = load i32, i32* %4
%58 = icmp slt i32 %57, 20
br i1 %58, label %59, label %88
59: ; preds = %56
%60 = load i32, i32* %4
%61 = icmp slt i32 %60, 9
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %64)
br label %70
66: ; preds = %59
%67 = load i32, i32* %4
%68 = add nsw i32 %67, 1
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %66, %62
store i32 1, i32* %5
br label %71
71: ; preds = %80, %70
%72 = load i32, i32* %5
%73 = load i32, i32* %4
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 %74
%76 = load i32, i32* %75
%77 = icmp sle i32 %72, %76
br i1 %77, label %78, label %83
78: ; preds = %71
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %80
80: ; preds = %78
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
store i32 %82, i32* %5
br label %71
83: ; preds = %71
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %85
85: ; preds = %83
%86 = load i32, i32* %4
%87 = add nsw i32 %86, 1
store i32 %87, i32* %4
br label %56
88: ; preds = %56
%89 = load i32, i32* %1
ret i32 %89
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [5 x i8] c" %d \00"
@.str.2 = [4 x i8] c"%d \00"
@str = [15 x i8] c"word too long.\00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %29, label %6
6: ; preds = %0, %24
%7 = phi i32 [ %26, %24 ], [ %3, %0 ]
%8 = phi i32 [ %25, %24 ], [ 0, %0 ]
switch i32 %7, label %22 [
i32 46, label %9
i32 32, label %9
i32 10, label %9
i32 9, label %9
]
9: ; preds = %6, %6, %6, %6
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %24
11: ; preds = %9
%12 = icmp ugt i32 %8, 19
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %11
%17 = add nsw i32 %8, -1
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
br label %24
22: ; preds = %6
%23 = add nsw i32 %8, 1
br label %24
24: ; preds = %9, %16, %22
%25 = phi i32 [ 0, %16 ], [ %8, %9 ], [ %23, %22 ]
%26 = tail call i32 (...) @getchar()
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %6
29: ; preds = %24, %0
br label %30
30: ; preds = %29, %45
%31 = phi i64 [ %47, %45 ], [ 0, %29 ]
%32 = icmp ult i64 %31, 9
%33 = trunc i64 %31 to i32
%34 = add i32 %33, 1
%35 = select i1 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %35, i32 %34)
%37 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %31
%38 = load i32, i32* %37
%39 = icmp slt i32 %38, 1
br i1 %39, label %45, label %40
40: ; preds = %30, %40
%41 = phi i32 [ %43, %40 ], [ 1, %30 ]
%42 = tail call i32 @putchar(i32 35)
%43 = add nuw i32 %41, 1
%44 = icmp eq i32 %41, %38
br i1 %44, label %45, label %40
45: ; preds = %40, %30
%46 = tail call i32 @putchar(i32 10)
%47 = add nuw nsw i64 %31, 1
%48 = icmp eq i64 %47, 20
br i1 %48, label %49, label %30
49: ; preds = %45
ret i32 0
}