#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 *, ...);
int /*<<< orphan*/ putchar(char);
int main() {
  int word_lengths[30], i, j;
  int c, nc, state;
  for (i = 0; i < 30; i++)
    word_lengths[i] = 0;
  nc = 0;
  state = 1;
  while ((c = getchar()) != EOF) {
    if (c == ' ' || c == '\n' || c == '\t') {
      if (state == 0) {
        word_lengths[nc - 1]++;
        nc = 0;
      }
      state = 1;
    } else {
      if (state == 1)
        state = 0;
      nc++;
    }
  }
  printf("\n--\n");
  for (i = 0; i < 30; i++) {
    printf("%i: ", i + 1);
    for (j = 0; j < word_lengths[i]; j++)
      putchar('#');
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x84(%rbp)
cmpl   $0x1e,-0x84(%rbp)
jge    117c <main+0x4c>
movslq -0x84(%rbp),%rax
movl   $0x0,-0x80(%rbp,%rax,4)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    114c <main+0x1c>
movl   $0x0,-0x90(%rbp)
movl   $0x1,-0x94(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8c(%rbp)
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%eax
je     123a <main+0x10a>
cmpl   $0x20,-0x8c(%rbp)
je     11d3 <main+0xa3>
cmpl   $0xa,-0x8c(%rbp)
je     11d3 <main+0xa3>
cmpl   $0x9,-0x8c(%rbp)
jne    120f <main+0xdf>
cmpl   $0x0,-0x94(%rbp)
jne    1200 <main+0xd0>
mov    -0x90(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x80(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80(%rbp,%rax,4)
movl   $0x0,-0x90(%rbp)
movl   $0x1,-0x94(%rbp)
jmp    1235 <main+0x105>
cmpl   $0x1,-0x94(%rbp)
jne    1226 <main+0xf6>
movl   $0x0,-0x94(%rbp)
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    1190 <main+0x60>
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x84(%rbp)
cmpl   $0x1e,-0x84(%rbp)
jge    12d7 <main+0x1a7>
mov    -0x84(%rbp),%esi
add    $0x1,%esi
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
movslq -0x84(%rbp),%rcx
cmp    -0x80(%rbp,%rcx,4),%eax
jge    12b5 <main+0x185>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1280 <main+0x150>
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1252 <main+0x122>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x70(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e5a(%rip),%r12
cmp    (%r12),%eax
jne    1203 <main+0xc3>
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe59(%rip),%r14
xor    %r15d,%r15d
jmp    11c0 <main+0x80>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x1e,%r15
je     11f1 <main+0xb1>
mov    %r15,%rbx
add    $0x1,%r15
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11b0 <main+0x70>
nopl   0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0xa0>
jmp    11b0 <main+0x70>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ecx
movabs $0x100000600,%r15
xor    %ebp,%ebp
jmp    123f <main+0xff>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x1,%ecx
cmove  %r14d,%ecx
add    $0x1,%ebp
mov    %ecx,%ebx
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %ebx,%ecx
cmp    (%r12),%eax
je     1194 <main+0x54>
cmp    $0x20,%eax
ja     1220 <main+0xe0>
mov    %eax,%eax
bt     %rax,%r15
jae    1220 <main+0xe0>
mov    $0x1,%ebx
test   %ecx,%ecx
jne    122c <main+0xec>
movslq %ebp,%rax
addl   $0x1,-0x4(%rsp,%rax,4)
xor    %ebp,%ebp
jmp    122c <main+0xec>

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

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