#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 getopt(int, char **, char *);
scalar_t__ isspace(int);
int /*<<< orphan*/ print_histogram(int *, int, int, int);
int main(int argc, char **argv) {
  bool vertical = false;
  int arg = 0;
  while ((arg = getopt(argc, argv, "v")) != -1) {
    switch (arg) {
    case 'v':
      vertical = true;
      break;
    case '?':
    default:
      break;
    }
  }
  int lengths[30 + 1] = {0};
  int max_length = 0;
  int length = 0;
  int c = 0;
  while ((c = getchar()) != EOF) {
    if (isspace(c)) {
      if (length > 0) {
        if (length > 30)
          length = 30;
        if (length > max_length)
          max_length = length;
        lengths[length] += 1;
        length = 0;
      }
    } else
      length++;
  }
  print_histogram(lengths, max_length + 1, vertical, vertical ? 40 : 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7b(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11dc <main+0x8c>
mov    -0x18(%rbp),%eax
mov    %eax,-0xb0(%rbp)
sub    $0x3f,%eax
je     11cd <main+0x7d>
jmp    11ad <main+0x5d>
mov    -0xb0(%rbp),%eax
sub    $0x76,%eax
jne    11d2 <main+0x82>
jmp    11c1 <main+0x71>
movl   $0x1,-0x14(%rbp)
jmp    11d7 <main+0x87>
jmp    11d2 <main+0x82>
jmp    11d7 <main+0x87>
jmp    1177 <main+0x27>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x7c,%edx
call   1030 <memset@plt>
movl   $0x0,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
movl   $0x0,-0xac(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0xac(%rbp)
mov    0x2dc7(%rip),%rcx
cmp    (%rcx),%eax
je     12bb <main+0x16b>
mov    -0xac(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     12a7 <main+0x157>
cmpl   $0x0,-0xa8(%rbp)
jle    12a2 <main+0x152>
cmpl   $0x1e,-0xa8(%rbp)
jle    1262 <main+0x112>
movl   $0x1e,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
cmp    -0xa4(%rbp),%eax
jle    1280 <main+0x130>
mov    -0xa8(%rbp),%eax
mov    %eax,-0xa4(%rbp)
movslq -0xa8(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xa0(%rbp,%rax,4)
movl   $0x0,-0xa8(%rbp)
jmp    12b6 <main+0x166>
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    120d <main+0xbd>
lea    -0xa0(%rbp),%rdi
mov    -0xa4(%rbp),%esi
add    $0x1,%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%r8d
mov    $0x64,%ecx
mov    $0x28,%eax
cmp    $0x0,%r8d
cmovne %eax,%ecx
call   1060 <print_histogram@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r14d,%r14d
mov    $0x64,%r15d
lea    0xe9a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1060 <getopt@plt>
cmp    $0x76,%eax
je     1189 <main+0x49>
cmp    $0xffffffff,%eax
jne    1170 <main+0x30>
jmp    1197 <main+0x57>
mov    $0x1,%r14d
mov    $0x28,%r15d
jmp    1170 <main+0x30>
xorps  %xmm0,%xmm0
movups %xmm0,0x6c(%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    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e17(%rip),%r13
cmp    0x0(%r13),%eax
jne    11fe <main+0xbe>
add    $0x1,%ebx
mov    %rsp,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1050 <print_histogram@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1e,%r12d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1220 <main+0xe0>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    0x0(%r13),%eax
je     11d7 <main+0x97>
mov    %eax,%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     1210 <main+0xd0>
test   %ebp,%ebp
jle    1213 <main+0xd3>
cmp    $0x1e,%ebp
cmovae %r12d,%ebp
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
addl   $0x1,(%rsp,%rbp,4)
xor    %ebp,%ebp
jmp    1213 <main+0xd3>

LLVM IR (-O0):
@.str = [2 x i8] c"v\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [31 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %12
12: ; preds = %22, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %7
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = load i32, i32* %7
switch i32 %18, label %21 [
i32 118, label %19
i32 63, label %20
]
19: ; preds = %17
store i32 1, i32* %6
br label %22
20: ; preds = %17
br label %21
21: ; preds = %17, %20
br label %22
22: ; preds = %21, %19
br label %12
23: ; preds = %12
%24 = bitcast [31 x i32]* %8 to i8*
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %25
25: ; preds = %56, %23
%26 = call i32 (...) @getchar()
store i32 %26, i32* %11
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %57
29: ; preds = %25
%30 = load i32, i32* %11
%31 = call i64 @isspace(i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %53
33: ; preds = %29
%34 = load i32, i32* %10
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %52
36: ; preds = %33
%37 = load i32, i32* %10
%38 = icmp sgt i32 %37, 30
br i1 %38, label %39, label %40
39: ; preds = %36
store i32 30, i32* %10
br label %40
40: ; preds = %39, %36
%41 = load i32, i32* %10
%42 = load i32, i32* %9
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = load i32, i32* %10
store i32 %45, i32* %9
br label %46
46: ; preds = %44, %40
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [31 x i32], [31 x i32]* %8, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
store i32 0, i32* %10
br label %52
52: ; preds = %46, %33
br label %56
53: ; preds = %29
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %56
56: ; preds = %53, %52
br label %25
57: ; preds = %25
%58 = getelementptr inbounds [31 x i32], [31 x i32]* %8, i64 0, i64 0
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
%61 = load i32, i32* %6
%62 = load i32, i32* %6
%63 = icmp ne i32 %62, 0
%64 = zext i1 %63 to i64
%65 = select i1 %63, i32 40, i32 100
%66 = call i32 @print_histogram(i32* %58, i32 %60, i32 %61, i32 %65)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"v\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [31 x i32]
br label %4
4: ; preds = %7, %2
%5 = phi i32 [ 100, %2 ], [ 40, %7 ]
%6 = phi i32 [ 0, %2 ], [ 1, %7 ]
br label %7
7: ; preds = %4, %7
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %7 [
i32 -1, label %9
i32 118, label %4
]
9: ; preds = %7
%10 = bitcast [31 x i32]* %3 to i8*
%11 = tail call i32 (...) @getchar()
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %39, label %14
14: ; preds = %9, %33
%15 = phi i32 [ %36, %33 ], [ %11, %9 ]
%16 = phi i32 [ %35, %33 ], [ 0, %9 ]
%17 = phi i32 [ %34, %33 ], [ 0, %9 ]
%18 = tail call i64 @isspace(i32 %15)
%19 = icmp eq i64 %18, 0
br i1 %19, label %31, label %20
20: ; preds = %14
%21 = icmp sgt i32 %16, 0
br i1 %21, label %22, label %33
22: ; preds = %20
%23 = icmp ult i32 %16, 30
%24 = select i1 %23, i32 %16, i32 30
%25 = icmp sgt i32 %24, %17
%26 = select i1 %25, i32 %24, i32 %17
%27 = zext i32 %24 to i64
%28 = getelementptr inbounds [31 x i32], [31 x i32]* %3, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %33
31: ; preds = %14
%32 = add nsw i32 %16, 1
br label %33
33: ; preds = %20, %22, %31
%34 = phi i32 [ %26, %22 ], [ %17, %20 ], [ %17, %31 ]
%35 = phi i32 [ 0, %22 ], [ %16, %20 ], [ %32, %31 ]
%36 = tail call i32 (...) @getchar()
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %14
39: ; preds = %33, %9
%40 = phi i32 [ 0, %9 ], [ %34, %33 ]
%41 = getelementptr inbounds [31 x i32], [31 x i32]* %3, i64 0, i64 0
%42 = add nsw i32 %40, 1
%43 = call i32 @print_histogram(i32* %41, i32 %42, i32 %6, i32 %5)
ret i32 0
}