#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 main() {
  int len[10];
  int c, state, wlen;
  for (int i = 0; i < 10; ++i)
    len[i] = 0;
  state = 0;
  wlen = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ' || c == '\t' || c == '\n') {
      state = 0;
      ++len[wlen];
    } else if (state == 0) {
      wlen = 0;
      state = 1;
    } else {
      ++wlen;
    }
  }
  for (int i = 0; i < 10; ++i) {
    printf("%2d|", i + 1);
    for (int x = len[i]; x > 0; --x) {
      printf("*");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0xa,-0x40(%rbp)
jge    115a <main+0x3a>
movslq -0x40(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1136 <main+0x16>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x34(%rbp)
mov    0x2e6f(%rip),%rcx
cmp    (%rcx),%eax
je     11ea <main+0xca>
cmpl   $0x20,-0x34(%rbp)
je     119f <main+0x7f>
cmpl   $0x9,-0x34(%rbp)
je     119f <main+0x7f>
cmpl   $0xa,-0x34(%rbp)
jne    11ba <main+0x9a>
movl   $0x0,-0x38(%rbp)
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11e5 <main+0xc5>
cmpl   $0x0,-0x38(%rbp)
jne    11d7 <main+0xb7>
movl   $0x0,-0x3c(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    11e0 <main+0xc0>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11e5 <main+0xc5>
jmp    1168 <main+0x48>
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    125c <main+0x13c>
mov    -0x44(%rbp),%esi
add    $0x1,%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jle    1240 <main+0x120>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
jmp    121a <main+0xfa>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11f1 <main+0xd1>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e8b(%rip),%r15
cmp    (%r15),%eax
jne    11c1 <main+0x91>
lea    0xe97(%rip),%r14
xor    %r15d,%r15d
jmp    1180 <main+0x50>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0xa,%r15
je     11b4 <main+0x84>
mov    %r15,%rbx
add    $0x1,%r15
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    1170 <main+0x40>
add    $0x1,%ebp
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     11a0 <main+0x70>
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000600,%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11fd <main+0xcd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
test   %ebx,%ebx
cmove  %ebx,%ebp
mov    $0x1,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r15),%eax
je     1162 <main+0x32>
cmp    $0x20,%eax
ja     11e0 <main+0xb0>
mov    %eax,%eax
bt     %rax,%r14
jae    11e0 <main+0xb0>
movslq %ebp,%rax
addl   $0x1,(%rsp,%rax,4)
xor    %ebx,%ebx
jmp    11ed <main+0xbd>

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

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