#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 i, c, nw, state, tmp;
  int array[20];
  i = c = nw = 0;
  state = 0;
  for (i = 0; i <= 20; i++) {
    array[i] = 0;
  }
  printf("\nWords length histogram: \n");
  while ((c = getchar()) != EOF) {
    if (tmp == 20) {
      tmp = 0;
    }
    if (c == ' ' || c == '\t') {
      printf("\n");
    }
    if (c == '\n') {
      printf("\nWords length histogram: \n");
      for (i = 0; i <= 20; i++) {
        array[i] = 0;
      }
    }
    if (c == ' ' || c == '\n' || c == '\t') {
      tmp = 0;
    } else if (c != ' ' || c != '\n' || c != '\t') {
      ++tmp;
      array[tmp] = '#';
      printf("%c", array[tmp]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jg     1176 <main+0x56>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x70(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x32>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%eax
je     1295 <main+0x175>
cmpl   $0x14,-0x18(%rbp)
jne    11ae <main+0x8e>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0xc(%rbp)
je     11c2 <main+0xa2>
cmpl   $0x9,-0xc(%rbp)
jne    11d0 <main+0xb0>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xa,-0xc(%rbp)
jne    1218 <main+0xf8>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jg     1213 <main+0xf3>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x70(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ef <main+0xcf>
jmp    1218 <main+0xf8>
cmpl   $0x20,-0xc(%rbp)
je     1236 <main+0x116>
cmpl   $0xa,-0xc(%rbp)
je     1236 <main+0x116>
cmpl   $0x9,-0xc(%rbp)
jne    1242 <main+0x122>
movl   $0x0,-0x18(%rbp)
jmp    1290 <main+0x170>
cmpl   $0x20,-0xc(%rbp)
jne    1260 <main+0x140>
cmpl   $0xa,-0xc(%rbp)
jne    1260 <main+0x140>
cmpl   $0x9,-0xc(%rbp)
je     128b <main+0x16b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movl   $0x23,-0x70(%rbp,%rax,4)
movslq -0x18(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1290 <main+0x170>
jmp    1184 <main+0x64>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9a(%rip),%rbx
cmp    (%rbx),%eax
jne    1159 <main+0x29>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe9e(%rip),%r14
jmp    1185 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1152 <main+0x22>
cmp    $0x20,%ebp
je     1194 <main+0x64>
cmp    $0xa,%ebp
je     1170 <main+0x40>
cmp    $0x9,%ebp
jne    11ad <main+0x7d>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x9,%ebp
je     1178 <main+0x48>
cmp    $0x20,%ebp
je     1178 <main+0x48>
cmp    $0xa,%ebp
je     1170 <main+0x40>
mov    $0x23,%edi
call   1030 <putchar@plt>
jmp    1178 <main+0x48>

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

LLVM IR (-O2):
@EOF = global i32 0
@str.3 = [26 x i8] c"\0AWords length histogram: \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.3, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %17, label %5
5: ; preds = %0, %13
%6 = phi i32 [ %14, %13 ], [ %2, %0 ]
switch i32 %6, label %11 [
i32 32, label %7
i32 9, label %7
i32 10, label %9
]
7: ; preds = %5, %5
%8 = tail call i32 @putchar(i32 10)
switch i32 %6, label %11 [
i32 10, label %9
i32 32, label %13
i32 9, label %13
]
9: ; preds = %5, %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.3, i64 0, i64 0))
br label %13
11: ; preds = %5, %7
%12 = tail call i32 @putchar(i32 35)
br label %13
13: ; preds = %9, %7, %7, %11
%14 = tail call i32 (...) @getchar()
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %5
17: ; preds = %13, %0
ret i32 0
}