#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);
main() {
  int c, nw, lw, state;
  int nword[1000 + 1];
  state = 0;
  nw = lw = 0;
  for (int i = 0; i <= 1000 + 1; i++) {
    nword[i] = 0;
  }
  while ((c = getchar()) != EOF) {
    if (c == ' ' || c == '\n' || c == '\t') {
      state = 0;
      nword[lw]++;
      lw = 0;
    } else {
      state = 1;
      ++lw;
    }
  }
  printf("output:\n");
  for (int i = 1; i <= 1000; i++) {
    if (nword[i] > 0) {
      printf("length %3d: ", i);
      for (int j = 1; j <= nword[i]; j++) {
        putchar('*');
      }
      putchar('\n');
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xfc4(%rbp)
cmpl   $0x3e9,-0xfc4(%rbp)
jg     1197 <main+0x67>
movslq -0xfc4(%rbp),%rax
movl   $0x0,-0xfc0(%rbp,%rax,4)
mov    -0xfc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc4(%rbp)
jmp    1161 <main+0x31>
jmp    119c <main+0x6c>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e3b(%rip),%rcx
cmp    (%rcx),%eax
je     1210 <main+0xe0>
cmpl   $0x20,-0x8(%rbp)
je     11d3 <main+0xa3>
cmpl   $0xa,-0x8(%rbp)
je     11d3 <main+0xa3>
cmpl   $0x9,-0x8(%rbp)
jne    11fb <main+0xcb>
movl   $0x0,-0x14(%rbp)
movslq -0x10(%rbp),%rax
mov    -0xfc0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xfc0(%rbp,%rax,4)
movl   $0x0,-0x10(%rbp)
jmp    120b <main+0xdb>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119c <main+0x6c>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0xfc8(%rbp)
cmpl   $0x3e8,-0xfc8(%rbp)
jg     12c6 <main+0x196>
movslq -0xfc8(%rbp),%rax
cmpl   $0x0,-0xfc0(%rbp,%rax,4)
jle    12ad <main+0x17d>
mov    -0xfc8(%rbp),%esi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0xfcc(%rbp)
mov    -0xfcc(%rbp),%eax
movslq -0xfc8(%rbp),%rcx
cmp    -0xfc0(%rbp,%rcx,4),%eax
jg     12a3 <main+0x173>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    -0xfcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfcc(%rbp)
jmp    126b <main+0x13b>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    12b2 <main+0x182>
mov    -0xfc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc8(%rbp)
jmp    1228 <main+0xf8>
xor    %eax,%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xfb0,%rsp
mov    %rsp,%rdi
mov    $0xfa8,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e70(%rip),%rbx
cmp    (%rbx),%eax
jne    11e9 <main+0x99>
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
lea    0xe6c(%rip),%r14
jmp    11ad <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x3e9,%rbx
je     11db <main+0x8b>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11a0 <main+0x50>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11c0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0xfb0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
movabs $0x100000600,%r14
xor    %ebp,%ebp
jmp    1212 <main+0xc2>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%eax
je     117c <main+0x2c>
cmp    $0x20,%eax
ja     1200 <main+0xb0>
mov    %eax,%eax
bt     %rax,%r14
jae    1200 <main+0xb0>
movslq %ebp,%rax
addl   $0x1,(%rsp,%rax,4)
xor    %ebp,%ebp
jmp    1203 <main+0xb3>

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

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