#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);
int /*<<< orphan*/ putchar(char);
scalar_t__ space(int);
int main() {
  int c, state, length;
  int lengths[32] = {0};
  length = 0;
  state = 2;
  while ((c = getchar()) != EOF)
    if (space(c)) {
      if (state == 0)
        ++(lengths[length]);
      state = 2;
      length = 0;
    } else {
      state = 0;
      ++length;
    }
  for (int i = 0; i < 32; i++) {
    printf("%3d: ", i);
    for (int j = 0; j < lengths[i]; j++)
      putchar('|');
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    $0x0,%al
call   1070 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e54(%rip),%rcx
cmp    (%rcx),%eax
je     11f5 <main+0xa5>
mov    -0x8(%rbp),%edi
call   1030 <space@plt>
cmp    $0x0,%rax
je     11e0 <main+0x90>
cmpl   $0x0,-0xc(%rbp)
jne    11cd <main+0x7d>
movslq -0x10(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x90(%rbp,%rax,4)
movl   $0x2,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    11f0 <main+0xa0>
movl   $0x0,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1183 <main+0x33>
movl   $0x0,-0x94(%rbp)
cmpl   $0x20,-0x94(%rbp)
jge    127e <main+0x12e>
mov    -0x94(%rbp),%esi
lea    0xde7(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x98(%rbp)
mov    -0x98(%rbp),%eax
movslq -0x94(%rbp),%rcx
cmp    -0x90(%rbp,%rcx,4),%eax
jge    1260 <main+0x110>
mov    $0x7c,%edi
call   1040 <putchar@plt>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    1228 <main+0xd8>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11ff <main+0xaf>
mov    -0x4(%rbp),%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,0x70(%rsp)
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)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e61(%rip),%r14
cmp    (%r14),%eax
jne    11f3 <main+0xb3>
xor    %ebx,%ebx
lea    0xe6b(%rip),%r14
jmp    11b4 <main+0x74>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%rbx
cmp    $0x20,%rbx
je     11e1 <main+0xa1>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x7c,%edi
call   1040 <putchar@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x90>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x2,%ebx
xor    %ebp,%ebp
jmp    121f <main+0xdf>
nopl   0x0(%rax)
add    $0x1,%ebp
xor    %r15d,%r15d
mov    %ebp,%r12d
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %r12d,%ebp
mov    %r15d,%ebx
cmp    (%r14),%eax
je     118c <main+0x4c>
mov    %eax,%edi
call   1030 <space@plt>
test   %rax,%rax
je     1200 <main+0xc0>
xor    %r12d,%r12d
mov    $0x2,%r15d
test   %ebx,%ebx
jne    1209 <main+0xc9>
movslq %ebp,%rax
addl   $0x1,(%rsp,%rax,4)
jmp    1209 <main+0xc9>

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

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