#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 *);
int /*<<< orphan*/ print_histogram(int *, int, int, int);
int tolower(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 frequencies[26] = {0};
  int c = 0;
  while ((c = getchar()) != EOF) {
    int character = tolower(c);
    if (character >= 'a' && character <= 'z')
      frequencies[character - 'a'] += 1;
  }
  print_histogram(frequencies, 26, vertical, vertical ? 40 : 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%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,-0x8c(%rbp)
sub    $0x3f,%eax
je     11cd <main+0x7d>
jmp    11ad <main+0x5d>
mov    -0x8c(%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    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x68,%edx
call   1030 <memset@plt>
movl   $0x0,-0x84(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x84(%rbp)
mov    0x2dde(%rip),%rcx
cmp    (%rcx),%eax
je     1258 <main+0x108>
mov    -0x84(%rbp),%edi
call   1050 <tolower@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x61,-0x88(%rbp)
jl     1253 <main+0x103>
cmpl   $0x7a,-0x88(%rbp)
jg     1253 <main+0x103>
mov    -0x88(%rbp),%eax
sub    $0x61,%eax
cltq
mov    -0x80(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80(%rbp,%rax,4)
jmp    11f6 <main+0xa6>
lea    -0x80(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%esi
mov    $0x64,%ecx
mov    $0x28,%eax
cmp    $0x0,%esi
cmovne %eax,%ecx
mov    $0x1a,%esi
call   1060 <print_histogram@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r14d,%r14d
mov    $0x64,%r15d
lea    0xe9f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   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
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,0x60(%rsp)
xor    %eax,%eax
call   1030 <getchar@plt>
mov    0x2e1a(%rip),%rbx
jmp    11d7 <main+0x97>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    (%rbx),%eax
je     11f2 <main+0xb2>
mov    %eax,%edi
call   1040 <tolower@plt>
add    $0xffffff9f,%eax
cmp    $0x19,%eax
ja     11d0 <main+0x90>
mov    %eax,%eax
addl   $0x1,(%rsp,%rax,4)
jmp    11d0 <main+0x90>
mov    %rsp,%rdi
mov    $0x1a,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1050 <print_histogram@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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 [26 x i32]
%9 = alloca i32
%10 = 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 %11
11: ; preds = %21, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %7
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = load i32, i32* %7
switch i32 %17, label %20 [
i32 118, label %18
i32 63, label %19
]
18: ; preds = %16
store i32 1, i32* %6
br label %21
19: ; preds = %16
br label %20
20: ; preds = %16, %19
br label %21
21: ; preds = %20, %18
br label %11
22: ; preds = %11
%23 = bitcast [26 x i32]* %8 to i8*
store i32 0, i32* %9
br label %24
24: ; preds = %43, %22
%25 = call i32 (...) @getchar()
store i32 %25, i32* %9
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %44
28: ; preds = %24
%29 = load i32, i32* %9
%30 = call i32 @tolower(i32 %29)
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = icmp sge i32 %31, 97
br i1 %32, label %33, label %43
33: ; preds = %28
%34 = load i32, i32* %10
%35 = icmp sle i32 %34, 122
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = load i32, i32* %10
%38 = sub nsw i32 %37, 97
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [26 x i32], [26 x i32]* %8, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = add nsw i32 %41, 1
store i32 %42, i32* %40
br label %43
43: ; preds = %36, %33, %28
br label %24
44: ; preds = %24
%45 = getelementptr inbounds [26 x i32], [26 x i32]* %8, i64 0, i64 0
%46 = load i32, i32* %6
%47 = load i32, i32* %6
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 40, i32 100
%51 = call i32 @print_histogram(i32* %45, i32 26, i32 %46, i32 %50)
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 [26 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 [26 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 %28, label %14
14: ; preds = %9, %24
%15 = phi i32 [ %25, %24 ], [ %11, %9 ]
%16 = tail call i32 @tolower(i32 %15)
%17 = add i32 %16, -97
%18 = icmp ult i32 %17, 26
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = zext i32 %17 to i64
%21 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %24
24: ; preds = %19, %14
%25 = tail call i32 (...) @getchar()
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %14
28: ; preds = %24, %9
%29 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 0
%30 = call i32 @print_histogram(i32* %29, i32 26, i32 %6, i32 %5)
ret i32 0
}