#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 *, ...);
main() {
  int i, c, state, current_len;
  int words_hist[50];
  for (i = 0; i < 50; ++i)
    words_hist[i] = 0;
  state = 0, current_len = 0;
  while ((c = getchar()) != EOF) {
    if (c != ' ' && c != '\n' && c != '\t') {
      if (state == 0) {
        current_len = 1;
        state = 1;
      } else {
        current_len++;
      }
    } else if (state == 1) {
      state = 0;
      if (current_len < 50) {
        ++words_hist[current_len];
      } else {
        printf(" a word longer than max length appears! ");
      }
    }
  }
  printf("  Horizonal bars\n");
  printf("\tLength \t Count\n");
  for (i = 0; i < 50; ++i) {
    if (words_hist[i])
      printf("\t %5d \t %5d \n", i, words_hist[i]);
  }
  printf("\n  Vertical bars\n");
  printf("\tLength ");
  for (i = 0; i < 50; ++i) {
    if (words_hist[i])
      printf("\t %3d ", i);
  }
  printf("\n\tCount ");
  for (i = 0; i < 50; ++i) {
    if (words_hist[i])
      printf("\t %3d ", words_hist[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jge    1160 <main+0x40>
movslq -0x8(%rbp),%rax
movl   $0x0,-0xe0(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <main+0x19>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%eax
je     1222 <main+0x102>
cmpl   $0x20,-0xc(%rbp)
je     11d0 <main+0xb0>
cmpl   $0xa,-0xc(%rbp)
je     11d0 <main+0xb0>
cmpl   $0x9,-0xc(%rbp)
je     11d0 <main+0xb0>
cmpl   $0x0,-0x10(%rbp)
jne    11c2 <main+0xa2>
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x10(%rbp)
jmp    11cb <main+0xab>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121d <main+0xfd>
cmpl   $0x1,-0x10(%rbp)
jne    1218 <main+0xf8>
movl   $0x0,-0x10(%rbp)
cmpl   $0x32,-0x14(%rbp)
jge    1205 <main+0xe5>
movslq -0x14(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xe0(%rbp,%rax,4)
jmp    1213 <main+0xf3>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1218 <main+0xf8>
jmp    121d <main+0xfd>
jmp    116e <main+0x4e>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jge    1290 <main+0x170>
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0xe0(%rbp,%rax,4)
je     127d <main+0x15d>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%edx
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1282 <main+0x162>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1245 <main+0x125>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jge    12f3 <main+0x1d3>
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0xe0(%rbp,%rax,4)
je     12e0 <main+0x1c0>
mov    -0x8(%rbp),%esi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e5 <main+0x1c5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12b3 <main+0x193>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x32,-0x8(%rbp)
jge    1350 <main+0x230>
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0xe0(%rbp,%rax,4)
je     133d <main+0x21d>
movslq -0x8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%esi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1342 <main+0x222>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1308 <main+0x1e8>
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
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)
movq   $0x0,0xc0(%rsp)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e35(%rip),%r12
cmp    (%r12),%eax
jne    12a9 <main+0x169>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
lea    0xe91(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4d(%rip),%r14
xor    %ebx,%ebx
jmp    11ea <main+0xaa>
add    $0x1,%rbx
cmp    $0x32,%rbx
je     11ff <main+0xbf>
mov    (%rsp,%rbx,4),%edx
test   %edx,%edx
je     11e0 <main+0xa0>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e0 <main+0xa0>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe20(%rip),%r14
xor    %ebx,%ebx
jmp    123a <main+0xfa>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    $0x32,%rbx
je     124e <main+0x10e>
cmpl   $0x0,(%rsp,%rbx,4)
je     1230 <main+0xf0>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1230 <main+0xf0>
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xddd(%rip),%rbx
xor    %ebp,%ebp
jmp    127a <main+0x13a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    $0x32,%rbp
je     128d <main+0x14d>
mov    (%rsp,%rbp,4),%esi
test   %esi,%esi
je     1270 <main+0x130>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1270 <main+0x130>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000600,%r15
lea    0xd46(%rip),%r14
xor    %ebp,%ebp
xor    %ecx,%ecx
jmp    12e0 <main+0x1a0>
add    $0x1,%ebp
test   %ecx,%ecx
mov    $0x1,%ebx
cmove  %ebx,%ebp
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %ebx,%ecx
cmp    (%r12),%eax
je     11bd <main+0x7d>
cmp    $0x20,%eax
ja     12c0 <main+0x180>
mov    %eax,%eax
bt     %rax,%r15
jae    12c0 <main+0x180>
xor    %ebx,%ebx
cmp    $0x1,%ecx
jne    12cd <main+0x18d>
cmp    $0x31,%ebp
jg     1302 <main+0x1c2>
movslq %ebp,%rax
addl   $0x1,(%rsp,%rax,4)
jmp    12cd <main+0x18d>
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12cd <main+0x18d>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [41 x i8] c" a word longer than max length appears! \00"
@.str.1 = [18 x i8] c" Horizonal bars\0A\00"
@.str.2 = [17 x i8] c"\09Length \09 Count\0A\00"
@.str.3 = [14 x i8] c"\09 %5d \09 %5d \0A\00"
@.str.4 = [18 x i8] c"\0A Vertical bars\0A\00"
@.str.5 = [9 x i8] c"\09Length \00"
@.str.6 = [7 x i8] c"\09 %3d \00"
@.str.7 = [9 x i8] c"\0A\09Count \00"
@.str.8 = [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 [50 x i32]
store i32 0, i32* %1
store i32 0, i32* %2
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 50
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %12
store i32 0, i32* %13
br label %14
14: ; preds = %10
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %7
17: ; preds = %7
store i32 0, i32* %4
store i32 0, i32* %5
br label %18
18: ; preds = %55, %17
%19 = call i32 (...) @getchar()
store i32 %19, i32* %3
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %56
22: ; preds = %18
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 32
br i1 %24, label %25, label %39
25: ; preds = %22
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 10
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = load i32, i32* %3
%30 = icmp ne i32 %29, 9
br i1 %30, label %31, label %39
31: ; preds = %28
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 1, i32* %5
store i32 1, i32* %4
br label %38
35: ; preds = %31
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %38
38: ; preds = %35, %34
br label %55
39: ; preds = %28, %25, %22
%40 = load i32, i32* %4
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %54
42: ; preds = %39
store i32 0, i32* %4
%43 = load i32, i32* %5
%44 = icmp slt i32 %43, 50
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = add nsw i32 %49, 1
store i32 %50, i32* %48
br label %53
51: ; preds = %42
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %53
53: ; preds = %51, %45
br label %54
54: ; preds = %53, %39
br label %55
55: ; preds = %54, %38
br label %18
56: ; preds = %18
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %59
59: ; preds = %76, %56
%60 = load i32, i32* %2
%61 = icmp slt i32 %60, 50
br i1 %61, label %62, label %79
62: ; preds = %59
%63 = load i32, i32* %2
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %75
68: ; preds = %62
%69 = load i32, i32* %2
%70 = load i32, i32* %2
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %69, i32 %73)
br label %75
75: ; preds = %68, %62
br label %76
76: ; preds = %75
%77 = load i32, i32* %2
%78 = add nsw i32 %77, 1
store i32 %78, i32* %2
br label %59
79: ; preds = %59
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %82
82: ; preds = %95, %79
%83 = load i32, i32* %2
%84 = icmp slt i32 %83, 50
br i1 %84, label %85, label %98
85: ; preds = %82
%86 = load i32, i32* %2
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %87
%89 = load i32, i32* %88
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %85
%92 = load i32, i32* %2
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %92)
br label %94
94: ; preds = %91, %85
br label %95
95: ; preds = %94
%96 = load i32, i32* %2
%97 = add nsw i32 %96, 1
store i32 %97, i32* %2
br label %82
98: ; preds = %82
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %2
br label %100
100: ; preds = %116, %98
%101 = load i32, i32* %2
%102 = icmp slt i32 %101, 50
br i1 %102, label %103, label %119
103: ; preds = %100
%104 = load i32, i32* %2
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %105
%107 = load i32, i32* %106
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %115
109: ; preds = %103
%110 = load i32, i32* %2
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %111
%113 = load i32, i32* %112
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %113)
br label %115
115: ; preds = %109, %103
br label %116
116: ; preds = %115
%117 = load i32, i32* %2
%118 = add nsw i32 %117, 1
store i32 %118, i32* %2
br label %100
119: ; preds = %100
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%121 = load i32, i32* %1
ret i32 %121
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [41 x i8] c" a word longer than max length appears! \00"
@.str.3 = [14 x i8] c"\09 %5d \09 %5d \0A\00"
@.str.5 = [9 x i8] c"\09Length \00"
@.str.6 = [7 x i8] c"\09 %3d \00"
@.str.7 = [9 x i8] c"\0A\09Count \00"
@str = [17 x i8] c" Horizonal bars\00"
@str.9 = [16 x i8] c"\09Length \09 Count\00"
@str.10 = [17 x i8] c"\0A Vertical bars\00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = bitcast [50 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 %31, label %6
6: ; preds = %0, %25
%7 = phi i32 [ %28, %25 ], [ %3, %0 ]
%8 = phi i32 [ %27, %25 ], [ 0, %0 ]
%9 = phi i32 [ %26, %25 ], [ 0, %0 ]
switch i32 %7, label %10 [
i32 32, label %14
i32 10, label %14
i32 9, label %14
]
10: ; preds = %6
%11 = icmp eq i32 %9, 0
%12 = add nsw i32 %8, 1
%13 = select i1 %11, i32 1, i32 %12
br label %25
14: ; preds = %6, %6, %6
%15 = icmp eq i32 %9, 1
br i1 %15, label %16, label %25
16: ; preds = %14
%17 = icmp slt i32 %8, 50
br i1 %17, label %18, label %23
18: ; preds = %16
%19 = sext i32 %8 to i64
%20 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %20
br label %25
23: ; preds = %16
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %10, %14, %23, %18
%26 = phi i32 [ 0, %18 ], [ 0, %23 ], [ 0, %14 ], [ 1, %10 ]
%27 = phi i32 [ %8, %18 ], [ %8, %23 ], [ %8, %14 ], [ %13, %10 ]
%28 = tail call i32 (...) @getchar()
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %6
31: ; preds = %25, %0
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.9, i64 0, i64 0))
br label %34
34: ; preds = %31, %42
%35 = phi i64 [ 0, %31 ], [ %43, %42 ]
%36 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %34
%40 = trunc i64 %35 to i32
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %37)
br label %42
42: ; preds = %34, %39
%43 = add nuw nsw i64 %35, 1
%44 = icmp eq i64 %43, 50
br i1 %44, label %45, label %34
45: ; preds = %42
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %45, %56
%49 = phi i64 [ 0, %45 ], [ %57, %56 ]
%50 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %48
%54 = trunc i64 %49 to i32
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %48, %53
%57 = add nuw nsw i64 %49, 1
%58 = icmp eq i64 %57, 50
br i1 %58, label %59, label %48
59: ; preds = %56
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %61
61: ; preds = %59, %68
%62 = phi i64 [ 0, %59 ], [ %69, %68 ]
%63 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = icmp eq i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %61
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %64)
br label %68
68: ; preds = %61, %66
%69 = add nuw nsw i64 %62, 1
%70 = icmp eq i64 %69, 50
br i1 %70, label %71, label %61
71: ; preds = %68
%72 = tail call i32 @putchar(i32 10)
ret i32 0
}