#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, nl, nw, nc, wl, state;
  int len = 10 + 1;
  int wordlen[len];
  nl = nw = nc = wl = 0;
  for (i = 0; i < len; ++i)
    wordlen[i] = 0;
  state = 0;
  while ((c = getchar()) != EOF) {
    ++nc;
    if (c == '\n')
      ++nl;
    if (c == ' ' || c == '\n' || c == '\t') {
      if (state == 1) {
        if (wl >= 10)
          ++wordlen[10];
        else
          ++wordlen[wl];
        wl = 0;
      }
      state = 0;
    } else {
      if (state == 0) {
        state = 1;
        ++nw;
      }
      ++wl;
    }
  }
  printf("%s   %s   %s\n", "Len", "Num", "Histogram");
  for (i = 1; i < len; ++i) {
    printf("%3d   %3d   ", i, wordlen[i]);
    for (int j = 0; j < wordlen[i]; ++j)
      printf("%c", 'x');
    printf("\n");
  }
  printf("\nTotal number of lines: %d  words: %d  characters: %d\n", nl, nw,
         nc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xb,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11a9 <main+0x89>
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x60>
movl   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e27(%rip),%rcx
cmp    (%rcx),%eax
je     1275 <main+0x155>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    11e5 <main+0xc5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x20,-0xc(%rbp)
je     1203 <main+0xe3>
cmpl   $0xa,-0xc(%rbp)
je     1203 <main+0xe3>
cmpl   $0x9,-0xc(%rbp)
jne    124d <main+0x12d>
cmpl   $0x1,-0x20(%rbp)
jne    1241 <main+0x121>
cmpl   $0xa,-0x1c(%rbp)
jl     1229 <main+0x109>
mov    -0x48(%rbp),%rax
mov    0x28(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x28(%rax)
jmp    123a <main+0x11a>
mov    -0x48(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
jmp    1270 <main+0x150>
cmpl   $0x0,-0x20(%rbp)
jne    1267 <main+0x147>
movl   $0x1,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b0 <main+0x90>
lea    0xd84(%rip),%rdi
lea    0xd8b(%rip),%rsi
lea    0xd88(%rip),%rdx
lea    0xd85(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    131f <main+0x1ff>
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x48(%rbp),%rcx
mov    -0x3c(%rbp),%eax
movslq -0x8(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1303 <main+0x1e3>
lea    0xd44(%rip),%rdi
mov    $0x78,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12ce <main+0x1ae>
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    129f <main+0x17f>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x2c(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e87(%rip),%rbx
movl   $0x0,0xc(%rsp)
mov    $0x0,%r13d
cmp    (%rbx),%eax
jne    121a <main+0xea>
lea    0xe82(%rip),%rdi
lea    0xe89(%rip),%rsi
lea    0xe86(%rip),%rdx
lea    0xe83(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
lea    0xe7a(%rip),%r12
jmp    11c4 <main+0x94>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0xb,%rbx
je     11f1 <main+0xc1>
mov    0x10(%rsp,%rbx,4),%ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11b0 <main+0x80>
nopw   0x0(%rax,%rax,1)
mov    $0x78,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0xb0>
jmp    11b0 <main+0x80>
lea    0xe35(%rip),%rdi
mov    %r13d,%esi
mov    0xc(%rsp),%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000600,%r12
xor    %r13d,%r13d
movl   $0x0,0xc(%rsp)
xor    %esi,%esi
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    126c <main+0x13c>
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%esi
adcl   $0x0,0xc(%rsp)
add    $0x1,%ebp
mov    $0x1,%r14d
mov    %dl,%cl
add    %ecx,%r13d
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%r15d
mov    %r14d,%esi
cmp    (%rbx),%eax
je     1177 <main+0x47>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %dl
cmp    $0x20,%eax
ja     1240 <main+0x110>
mov    %eax,%eax
bt     %rax,%r12
jae    1240 <main+0x110>
xor    %r14d,%r14d
cmp    $0x1,%esi
jne    1251 <main+0x121>
cmp    $0xa,%ebp
jge    1298 <main+0x168>
movslq %ebp,%rax
addl   $0x1,0x10(%rsp,%rax,4)
jmp    129d <main+0x16d>
addl   $0x1,0x38(%rsp)
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    1251 <main+0x121>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [14 x i8] c"%s %s %s\0A\00"
@.str.1 = [4 x i8] c"Len\00"
@.str.2 = [4 x i8] c"Num\00"
@.str.3 = [10 x i8] c"Histogram\00"
@.str.4 = [13 x i8] c"%3d %3d \00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [55 x i8] c"\0ATotal number of lines: %d words: %d characters: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %1
store i32 11, i32* %9
%13 = load i32, i32* %9
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %10
%16 = alloca i32, i64 %14
store i64 %14, i64* %11
store i32 0, i32* %7
store i32 0, i32* %6
store i32 0, i32* %5
store i32 0, i32* %4
store i32 0, i32* %2
br label %17
17: ; preds = %25, %0
%18 = load i32, i32* %2
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %16, i64 %23
store i32 0, i32* %24
br label %25
25: ; preds = %21
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %17
28: ; preds = %17
store i32 0, i32* %8
br label %29
29: ; preds = %77, %28
%30 = call i32 (...) @getchar()
store i32 %30, i32* %3
%31 = load i32, i32* @EOF
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %78
33: ; preds = %29
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %41
41: ; preds = %38, %33
%42 = load i32, i32* %3
%43 = icmp eq i32 %42, 32
br i1 %43, label %50, label %44
44: ; preds = %41
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, 10
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = load i32, i32* %3
%49 = icmp eq i32 %48, 9
br i1 %49, label %50, label %68
50: ; preds = %47, %44, %41
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %67
53: ; preds = %50
%54 = load i32, i32* %7
%55 = icmp sge i32 %54, 10
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = getelementptr inbounds i32, i32* %16, i64 10
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %57
br label %66
60: ; preds = %53
%61 = load i32, i32* %7
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %16, i64 %62
%64 = load i32, i32* %63
%65 = add nsw i32 %64, 1
store i32 %65, i32* %63
br label %66
66: ; preds = %60, %56
store i32 0, i32* %7
br label %67
67: ; preds = %66, %50
store i32 0, i32* %8
br label %77
68: ; preds = %47
%69 = load i32, i32* %8
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %68
store i32 1, i32* %8
%72 = load i32, i32* %5
%73 = add nsw i32 %72, 1
store i32 %73, i32* %5
br label %74
74: ; preds = %71, %68
%75 = load i32, i32* %7
%76 = add nsw i32 %75, 1
store i32 %76, i32* %7
br label %77
77: ; preds = %74, %67
br label %29
78: ; preds = %29
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %80
80: ; preds = %105, %78
%81 = load i32, i32* %2
%82 = load i32, i32* %9
%83 = icmp slt i32 %81, %82
br i1 %83, label %84, label %108
84: ; preds = %80
%85 = load i32, i32* %2
%86 = load i32, i32* %2
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %16, i64 %87
%89 = load i32, i32* %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %85, i32 %89)
store i32 0, i32* %12
br label %91
91: ; preds = %100, %84
%92 = load i32, i32* %12
%93 = load i32, i32* %2
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %16, i64 %94
%96 = load i32, i32* %95
%97 = icmp slt i32 %92, %96
br i1 %97, label %98, label %103
98: ; preds = %91
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 120)
br label %100
100: ; preds = %98
%101 = load i32, i32* %12
%102 = add nsw i32 %101, 1
store i32 %102, i32* %12
br label %91
103: ; preds = %91
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %105
105: ; preds = %103
%106 = load i32, i32* %2
%107 = add nsw i32 %106, 1
store i32 %107, i32* %2
br label %80
108: ; preds = %80
%109 = load i32, i32* %4
%110 = load i32, i32* %5
%111 = load i32, i32* %6
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0), i32 %109, i32 %110, i32 %111)
%113 = load i8*, i8** %10
%114 = load i32, i32* %1
ret i32 %114
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [14 x i8] c"%s %s %s\0A\00"
@.str.1 = [4 x i8] c"Len\00"
@.str.2 = [4 x i8] c"Num\00"
@.str.3 = [10 x i8] c"Histogram\00"
@.str.4 = [13 x i8] c"%3d %3d \00"
@.str.7 = [55 x i8] c"\0ATotal number of lines: %d words: %d characters: %d\0A\00"
define i32 @main() {
%1 = alloca [11 x i32]
%2 = bitcast [11 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 %43, label %6
6: ; preds = %0
%7 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 10
br label %8
8: ; preds = %6, %36
%9 = phi i32 [ %3, %6 ], [ %40, %36 ]
%10 = phi i32 [ 0, %6 ], [ %18, %36 ]
%11 = phi i32 [ 0, %6 ], [ %39, %36 ]
%12 = phi i32 [ 0, %6 ], [ %38, %36 ]
%13 = phi i32 [ 0, %6 ], [ %37, %36 ]
%14 = phi i32 [ 0, %6 ], [ %15, %36 ]
%15 = add nuw nsw i32 %14, 1
%16 = icmp eq i32 %9, 10
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %10, %17
switch i32 %9, label %31 [
i32 32, label %19
i32 10, label %19
i32 9, label %19
]
19: ; preds = %8, %8, %8
%20 = icmp eq i32 %12, 1
br i1 %20, label %21, label %36
21: ; preds = %19
%22 = icmp sgt i32 %13, 9
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %36
26: ; preds = %21
%27 = sext i32 %13 to i64
%28 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %36
31: ; preds = %8
%32 = icmp eq i32 %12, 0
%33 = zext i1 %32 to i32
%34 = add nsw i32 %11, %33
%35 = add nsw i32 %13, 1
br label %36
36: ; preds = %19, %26, %23, %31
%37 = phi i32 [ %35, %31 ], [ %13, %19 ], [ 0, %26 ], [ 0, %23 ]
%38 = phi i32 [ 1, %31 ], [ 0, %19 ], [ 0, %26 ], [ 0, %23 ]
%39 = phi i32 [ %34, %31 ], [ %11, %19 ], [ %11, %26 ], [ %11, %23 ]
%40 = tail call i32 (...) @getchar()
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %8
43: ; preds = %36, %0
%44 = phi i32 [ 0, %0 ], [ %15, %36 ]
%45 = phi i32 [ 0, %0 ], [ %39, %36 ]
%46 = phi i32 [ 0, %0 ], [ %18, %36 ]
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %48
48: ; preds = %43, %55
%49 = phi i64 [ 1, %43 ], [ %57, %55 ]
%50 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = trunc i64 %49 to i32
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %51)
%54 = icmp sgt i32 %51, 0
br i1 %54, label %59, label %55
55: ; preds = %59, %48
%56 = tail call i32 @putchar(i32 10)
%57 = add nuw nsw i64 %49, 1
%58 = icmp eq i64 %57, 11
br i1 %58, label %64, label %48
59: ; preds = %48, %59
%60 = phi i32 [ %62, %59 ], [ 0, %48 ]
%61 = tail call i32 @putchar(i32 120)
%62 = add nuw nsw i32 %60, 1
%63 = icmp eq i32 %62, %51
br i1 %63, label %55, label %59
64: ; preds = %55
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0), i32 %46, i32 %45, i32 %44)
ret i32 0
}