#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 */
struct ht_node {
  int dummy;
};
struct ht {
  int dummy;
};

/* Variables and functions */
int EOF;
int /*<<< orphan*/ free_ht(struct ht_node **);
int get_ht(struct ht_node **, int);
int getchar();
int /*<<< orphan*/ memset(struct ht_node **, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ put_ht(struct ht_node **, int, int);
int /*<<< orphan*/ putchar(char);
int main() {
  struct ht_node *ht[7];
  memset(ht, 0, 7 * sizeof(struct ht *));
  int c;
  int l = 0;
  int max_len = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ' || c == '\t' || c == '\n') {
      if (l != 0) {
        put_ht(ht, l, get_ht(ht, l) + 1);
        if (l > max_len)
          max_len = l;
        l = 0;
      }
    } else {
      l++;
    }
  }
  printf("max_len=%d\n", max_len);
  for (int i = 1; i <= max_len; i++) {
    int count = get_ht(ht, i);
    printf("%3d #", i);
    for (int j = 0; j < count; j++)
      putchar('-');
    printf(">\n");
  }
  free_ht(ht);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1060 <memset@plt>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %eax,-0x44(%rbp)
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%eax
je     1235 <main+0xc5>
cmpl   $0x20,-0x44(%rbp)
je     11d4 <main+0x64>
cmpl   $0x9,-0x44(%rbp)
je     11d4 <main+0x64>
cmpl   $0xa,-0x44(%rbp)
jne    1227 <main+0xb7>
cmpl   $0x0,-0x48(%rbp)
je     1222 <main+0xb2>
lea    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x5c(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%esi
call   1090 <get_ht@plt>
mov    -0x68(%rbp),%rdi
mov    -0x5c(%rbp),%esi
mov    %eax,%edx
add    $0x1,%edx
call   1070 <put_ht@plt>
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jle    121b <main+0xab>
mov    -0x48(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
jmp    1230 <main+0xc0>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    119d <main+0x2d>
mov    -0x4c(%rbp),%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jg     12c0 <main+0x150>
lea    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%esi
call   1090 <get_ht@plt>
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%esi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    12a4 <main+0x134>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1280 <main+0x110>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    124d <main+0xdd>
lea    -0x40(%rbp),%rdi
call   1040 <free_ht@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1070 <memset@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    0x2e3d(%rip),%r12
cmp    (%r12),%eax
jne    11c6 <main+0x46>
lea    0xe48(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12a1 <main+0x121>
movabs $0x100000600,%r15
mov    %rsp,%r14
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    11f4 <main+0x74>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %ebx,%ebp
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %ebp,%ebx
cmp    (%r12),%eax
je     1227 <main+0xa7>
cmp    $0x20,%eax
ja     11e0 <main+0x60>
mov    %eax,%eax
bt     %rax,%r15
jae    11e0 <main+0x60>
xor    %ebp,%ebp
test   %ebx,%ebx
je     11e5 <main+0x65>
mov    %r14,%rdi
mov    %ebx,%esi
call   10a0 <get_ht@plt>
lea    0x1(%rax),%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1080 <put_ht@plt>
cmp    %r13d,%ebx
cmovg  %ebx,%r13d
jmp    11e5 <main+0x65>
lea    0xdd2(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r13d,%r13d
jle    12a1 <main+0x121>
mov    $0x1,%ebx
mov    %rsp,%r14
lea    0xdc0(%rip),%r15
lea    0xdbf(%rip),%r12
jmp    1272 <main+0xf2>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1040 <puts@plt>
lea    0x1(%rbx),%eax
cmp    %r13d,%ebx
mov    %eax,%ebx
je     12a1 <main+0x121>
mov    %r14,%rdi
mov    %ebx,%esi
call   10a0 <get_ht@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebp,%ebp
jle    1260 <main+0xe0>
xchg   %ax,%ax
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1290 <main+0x110>
jmp    1260 <main+0xe0>
mov    %rsp,%rdi
call   1050 <free_ht@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.ht_node = type { i32 }
@EOF = global i32 0
@.str = [12 x i8] c"max_len=%d\0A\00"
@.str.1 = [6 x i8] c"%3d #\00"
@str = [2 x i8] c">\00"
define i32 @main() {
%1 = alloca [7 x %struct.ht_node*]
%2 = bitcast [7 x %struct.ht_node*]* %1 to i8*
%3 = getelementptr inbounds [7 x %struct.ht_node*], [7 x %struct.ht_node*]* %1, i64 0, i64 0
%4 = call i32 @memset(%struct.ht_node** %3, i32 0, i32 56)
%5 = call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
br label %33
10: ; preds = %0, %24
%11 = phi i32 [ %27, %24 ], [ %5, %0 ]
%12 = phi i32 [ %26, %24 ], [ 0, %0 ]
%13 = phi i32 [ %25, %24 ], [ 0, %0 ]
switch i32 %11, label %22 [
i32 32, label %14
i32 10, label %14
i32 9, label %14
]
14: ; preds = %10, %10, %10
%15 = icmp eq i32 %12, 0
br i1 %15, label %24, label %16
16: ; preds = %14
%17 = call i32 @get_ht(%struct.ht_node** %3, i32 %12)
%18 = add nsw i32 %17, 1
%19 = call i32 @put_ht(%struct.ht_node** %3, i32 %12, i32 %18)
%20 = icmp sgt i32 %12, %13
%21 = select i1 %20, i32 %12, i32 %13
br label %24
22: ; preds = %10
%23 = add nsw i32 %12, 1
br label %24
24: ; preds = %14, %16, %22
%25 = phi i32 [ %21, %16 ], [ %13, %14 ], [ %13, %22 ]
%26 = phi i32 [ 0, %16 ], [ 0, %14 ], [ %23, %22 ]
%27 = call i32 (...) @getchar()
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %10
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %25)
%32 = icmp slt i32 %25, 1
br i1 %32, label %33, label %35
33: ; preds = %40, %8, %30
%34 = call i32 @free_ht(%struct.ht_node** %3)
ret i32 0
35: ; preds = %30, %40
%36 = phi i32 [ %42, %40 ], [ 1, %30 ]
%37 = call i32 @get_ht(%struct.ht_node** %3, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%39 = icmp sgt i32 %37, 0
br i1 %39, label %44, label %40
40: ; preds = %44, %35
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%42 = add nuw i32 %36, 1
%43 = icmp eq i32 %36, %25
br i1 %43, label %33, label %35
44: ; preds = %35, %44
%45 = phi i32 [ %47, %44 ], [ 0, %35 ]
%46 = call i32 @putchar(i8 signext 45)
%47 = add nuw nsw i32 %45, 1
%48 = icmp eq i32 %47, %37
br i1 %48, label %40, label %44
}