#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 /*<<< orphan*/ putchar(char);
int main(void) {
  int c;
  int state = 1;
  int char_count = 0;
  int height = 0;
  int word_len[10 + 2] = {0};
  printf("Enter a string: ");
  while ((c = getchar()) != EOF) {
    if (c != ' ' && c != '\n' && c != '\t') {
      ++char_count;
      state = 0;
    } else {
      if (state == 0) {
        if (char_count <= 10)
          ++word_len[char_count];
        else
          ++word_len[10 + 1];
      }
      char_count = 0;
      state = 1;
    }
  }
  printf("\n%5cHorizontal-oriented histogram\n", ' ');
  printf("%5c=============================\n", ' ');
  for (int i = 1; i < 10 + 2; ++i) {
    if (i == 10 + 1)
      printf("%2s|", "+");
    else
      printf("%2d|", i);
    for (int j = 0; j < word_len[i]; ++j)
      putchar('#');
    putchar('\n');
  }
  printf("\n%5cVertical-oriented histogram\n", ' ');
  printf("%5c=============================\n", ' ');
  for (int i = 0; i <= 10 + 1; ++i)
    if (word_len[i] > height)
      height = word_len[i];
  printf(" W\n");
  for (int row = height; row > 0; --row) {
    printf("%2d|", row);
    for (int col = 1; col <= 10 + 1; ++col) {
      if (row - word_len[col] > 0)
        printf("%2c ", ' ');
      else
        printf("%2c ", '#');
    }
    putchar('\n');
  }
  printf("  +-");
  for (int col = 0; col < 10 * 3 + 1; ++col)
    putchar('-');
  printf("\n L");
  for (int col = 1; col <= 10; ++col)
    printf("%3d", col);
  printf(" 10+ \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%eax
je     1217 <main+0xd7>
cmpl   $0x20,-0x8(%rbp)
je     11ce <main+0x8e>
cmpl   $0xa,-0x8(%rbp)
je     11ce <main+0x8e>
cmpl   $0x9,-0x8(%rbp)
je     11ce <main+0x8e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    1212 <main+0xd2>
cmpl   $0x0,-0xc(%rbp)
jne    1204 <main+0xc4>
cmpl   $0xa,-0x10(%rbp)
jg     11f6 <main+0xb6>
movslq -0x10(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x50(%rbp,%rax,4)
jmp    11ff <main+0xbf>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1204 <main+0xc4>
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
jmp    1182 <main+0x42>
lea    0xdf3(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe03(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x54(%rbp)
cmpl   $0xc,-0x54(%rbp)
jge    12cb <main+0x18b>
cmpl   $0xb,-0x54(%rbp)
jne    1272 <main+0x132>
lea    0xdf7(%rip),%rdi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1283 <main+0x143>
mov    -0x54(%rbp),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
movslq -0x54(%rbp),%rcx
cmp    -0x50(%rbp,%rcx,4),%eax
jge    12b3 <main+0x173>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    128a <main+0x14a>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1244 <main+0x104>
lea    0xd90(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd4f(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0xb,-0x5c(%rbp)
jg     1331 <main+0x1f1>
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
cmp    -0x14(%rbp),%eax
jle    131e <main+0x1de>
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x14(%rbp)
jmp    1323 <main+0x1e3>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12f8 <main+0x1b8>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
jle    13db <main+0x29b>
mov    -0x60(%rbp),%esi
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x64(%rbp)
cmpl   $0xb,-0x64(%rbp)
jg     13c3 <main+0x283>
mov    -0x60(%rbp),%eax
movslq -0x64(%rbp),%rcx
sub    -0x50(%rbp,%rcx,4),%eax
cmp    $0x0,%eax
jle    139d <main+0x25d>
lea    0xcfb(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13b0 <main+0x270>
lea    0xce3(%rip),%rdi
mov    $0x23,%esi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13b5 <main+0x275>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1367 <main+0x227>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x60(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x60(%rbp)
jmp    1345 <main+0x205>
lea    0xcaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x68(%rbp)
cmpl   $0x1f,-0x68(%rbp)
jge    1412 <main+0x2d2>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    13f0 <main+0x2b0>
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x6c(%rbp)
cmpl   $0xa,-0x6c(%rbp)
jg     1450 <main+0x310>
mov    -0x6c(%rbp),%esi
lea    0xc5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1427 <main+0x2e7>
lea    0xc42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%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    $0x58,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e6c(%rip),%r15
cmp    (%r15),%eax
jne    1652 <main+0x512>
lea    0xe85(%rip),%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
lea    0xe9f(%rip),%r14
lea    0xe9d(%rip),%r15
lea    0xe98(%rip),%r12
jmp    11e4 <main+0xa4>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0xc,%rbx
je     1231 <main+0xf1>
cmp    $0xb,%rbx
jne    1200 <main+0xc0>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    120c <main+0xcc>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11d0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1220 <main+0xe0>
jmp    11d0 <main+0x90>
lea    0xe2a(%rip),%rdi
xor    %ebx,%ebx
mov    $0x20,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde7(%rip),%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%eax
test   %eax,%eax
cmovns %eax,%ebx
mov    0x24(%rsp),%eax
cmp    %ebx,%eax
mov    %eax,0x1c(%rsp)
cmovg  %eax,%ebx
mov    0x28(%rsp),%eax
cmp    %ebx,%eax
mov    %eax,0x18(%rsp)
cmovg  %eax,%ebx
mov    0x2c(%rsp),%eax
cmp    %ebx,%eax
mov    %eax,0x14(%rsp)
cmovg  %eax,%ebx
mov    0x30(%rsp),%eax
cmp    %ebx,%eax
mov    %eax,0x10(%rsp)
cmovg  %eax,%ebx
mov    0x34(%rsp),%eax
cmp    %ebx,%eax
mov    %eax,0xc(%rsp)
cmovg  %eax,%ebx
mov    0x38(%rsp),%eax
cmp    %ebx,%eax
mov    %eax,0x8(%rsp)
cmovg  %eax,%ebx
mov    0x3c(%rsp),%eax
cmp    %ebx,%eax
mov    %eax,0x4(%rsp)
cmovg  %eax,%ebx
mov    0x40(%rsp),%r14d
cmp    %ebx,%r14d
cmovg  %r14d,%ebx
mov    0x44(%rsp),%r12d
cmp    %ebx,%r12d
cmovg  %r12d,%ebx
mov    0x48(%rsp),%r13d
cmp    %ebx,%r13d
cmovg  %r13d,%ebx
mov    0x4c(%rsp),%ebp
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
lea    0xda4(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
je     1446 <main+0x306>
lea    0xd7e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xd46(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    0x1c(%rsp),%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    0x18(%rsp),%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    0x14(%rsp),%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    0x10(%rsp),%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    0xc(%rsp),%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    0x8(%rsp),%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    0x4(%rsp),%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    %r14d,%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    %r12d,%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    %r13d,%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
cmp    %ebp,%ebx
setle  %al
lea    (%rax,%rax,2),%esi
or     $0x20,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
jg     1310 <main+0x1d0>
lea    0xc3b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    $0x2d,%edi
call   1030 <putchar@plt>
lea    0xafc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xaf2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xa5c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edx
movabs $0x100000600,%r14
xor    %ecx,%ecx
jmp    168b <main+0x54b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ecx
xor    %ebp,%ebp
mov    %ecx,%ebx
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %ebx,%ecx
mov    %ebp,%edx
cmp    (%r15),%eax
je     1185 <main+0x45>
cmp    $0x20,%eax
ja     1670 <main+0x530>
mov    %eax,%eax
bt     %rax,%r14
jae    1670 <main+0x530>
xor    %ebx,%ebx
mov    $0x1,%ebp
test   %edx,%edx
jne    1677 <main+0x537>
cmp    $0xa,%ecx
jg     16b2 <main+0x572>
movslq %ecx,%rax
addl   $0x1,0x20(%rsp,%rax,4)
jmp    1677 <main+0x537>
addl   $0x1,0x4c(%rsp)
jmp    1677 <main+0x537>

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a string: \00"
@EOF = global i32 0
@.str.1 = [35 x i8] c"\0A%5cHorizontal-oriented histogram\0A\00"
@.str.2 = [34 x i8] c"%5c=============================\0A\00"
@.str.3 = [5 x i8] c"%2s|\00"
@.str.4 = [2 x i8] c"+\00"
@.str.5 = [5 x i8] c"%2d|\00"
@.str.6 = [33 x i8] c"\0A%5cVertical-oriented histogram\0A\00"
@.str.7 = [4 x i8] c" W\0A\00"
@.str.8 = [5 x i8] c"%2c \00"
@.str.9 = [5 x i8] c" +-\00"
@.str.10 = [4 x i8] c"\0A L\00"
@.str.11 = [4 x i8] c"%3d\00"
@.str.12 = [7 x i8] c" 10+ \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [12 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%14 = bitcast [12 x i32]* %6 to i8*
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %50, %0
%17 = call i32 (...) @getchar()
store i32 %17, i32* %2
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %51
20: ; preds = %16
%21 = load i32, i32* %2
%22 = icmp ne i32 %21, 32
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32, i32* %2
%28 = icmp ne i32 %27, 9
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
store i32 0, i32* %3
br label %50
32: ; preds = %26, %23, %20
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %49
35: ; preds = %32
%36 = load i32, i32* %4
%37 = icmp sle i32 %36, 10
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
store i32 %43, i32* %41
br label %48
44: ; preds = %35
%45 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 11
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
store i32 %47, i32* %45
br label %48
48: ; preds = %44, %38
br label %49
49: ; preds = %48, %32
store i32 0, i32* %4
store i32 1, i32* %3
br label %50
50: ; preds = %49, %29
br label %16
51: ; preds = %16
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 32)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 32)
store i32 1, i32* %7
br label %54
54: ; preds = %80, %51
%55 = load i32, i32* %7
%56 = icmp slt i32 %55, 12
br i1 %56, label %57, label %83
57: ; preds = %54
%58 = load i32, i32* %7
%59 = icmp eq i32 %58, 11
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %65
62: ; preds = %57
%63 = load i32, i32* %7
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %62, %60
store i32 0, i32* %8
br label %66
66: ; preds = %75, %65
%67 = load i32, i32* %8
%68 = load i32, i32* %7
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = icmp slt i32 %67, %71
br i1 %72, label %73, label %78
73: ; preds = %66
%74 = call i32 @putchar(i8 signext 35)
br label %75
75: ; preds = %73
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %66
78: ; preds = %66
%79 = call i32 @putchar(i8 signext 10)
br label %80
80: ; preds = %78
%81 = load i32, i32* %7
%82 = add nsw i32 %81, 1
store i32 %82, i32* %7
br label %54
83: ; preds = %54
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 32)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 32)
store i32 0, i32* %9
br label %86
86: ; preds = %102, %83
%87 = load i32, i32* %9
%88 = icmp sle i32 %87, 11
br i1 %88, label %89, label %105
89: ; preds = %86
%90 = load i32, i32* %9
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 %91
%93 = load i32, i32* %92
%94 = load i32, i32* %5
%95 = icmp sgt i32 %93, %94
br i1 %95, label %96, label %101
96: ; preds = %89
%97 = load i32, i32* %9
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 %98
%100 = load i32, i32* %99
store i32 %100, i32* %5
br label %101
101: ; preds = %96, %89
br label %102
102: ; preds = %101
%103 = load i32, i32* %9
%104 = add nsw i32 %103, 1
store i32 %104, i32* %9
br label %86
105: ; preds = %86
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%107 = load i32, i32* %5
store i32 %107, i32* %10
br label %108
108: ; preds = %135, %105
%109 = load i32, i32* %10
%110 = icmp sgt i32 %109, 0
br i1 %110, label %111, label %138
111: ; preds = %108
%112 = load i32, i32* %10
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %112)
store i32 1, i32* %11
br label %114
114: ; preds = %130, %111
%115 = load i32, i32* %11
%116 = icmp sle i32 %115, 11
br i1 %116, label %117, label %133
117: ; preds = %114
%118 = load i32, i32* %10
%119 = load i32, i32* %11
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 %120
%122 = load i32, i32* %121
%123 = sub nsw i32 %118, %122
%124 = icmp sgt i32 %123, 0
br i1 %124, label %125, label %127
125: ; preds = %117
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 32)
br label %129
127: ; preds = %117
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 35)
br label %129
129: ; preds = %127, %125
br label %130
130: ; preds = %129
%131 = load i32, i32* %11
%132 = add nsw i32 %131, 1
store i32 %132, i32* %11
br label %114
133: ; preds = %114
%134 = call i32 @putchar(i8 signext 10)
br label %135
135: ; preds = %133
%136 = load i32, i32* %10
%137 = add nsw i32 %136, -1
store i32 %137, i32* %10
br label %108
138: ; preds = %108
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %12
br label %140
140: ; preds = %145, %138
%141 = load i32, i32* %12
%142 = icmp slt i32 %141, 31
br i1 %142, label %143, label %148
143: ; preds = %140
%144 = call i32 @putchar(i8 signext 45)
br label %145
145: ; preds = %143
%146 = load i32, i32* %12
%147 = add nsw i32 %146, 1
store i32 %147, i32* %12
br label %140
148: ; preds = %140
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %13
br label %150
150: ; preds = %156, %148
%151 = load i32, i32* %13
%152 = icmp sle i32 %151, 10
br i1 %152, label %153, label %159
153: ; preds = %150
%154 = load i32, i32* %13
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %154)
br label %156
156: ; preds = %153
%157 = load i32, i32* %13
%158 = add nsw i32 %157, 1
store i32 %158, i32* %13
br label %150
159: ; preds = %150
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a string: \00"
@EOF = global i32 0
@.str.1 = [35 x i8] c"\0A%5cHorizontal-oriented histogram\0A\00"
@.str.2 = [34 x i8] c"%5c=============================\0A\00"
@.str.3 = [5 x i8] c"%2s|\00"
@.str.4 = [2 x i8] c"+\00"
@.str.5 = [5 x i8] c"%2d|\00"
@.str.6 = [33 x i8] c"\0A%5cVertical-oriented histogram\0A\00"
@.str.8 = [5 x i8] c"%2c \00"
@.str.9 = [5 x i8] c" +-\00"
@.str.10 = [4 x i8] c"\0A L\00"
@.str.11 = [4 x i8] c"%3d\00"
@str = [3 x i8] c" W\00"
@str.13 = [6 x i8] c" 10+ \00"
define i32 @main() {
%1 = alloca [12 x i32]
%2 = bitcast [12 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @getchar()
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %33, label %7
7: ; preds = %0
%8 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 11
br label %9
9: ; preds = %7, %27
%10 = phi i32 [ %4, %7 ], [ %30, %27 ]
%11 = phi i32 [ 0, %7 ], [ %29, %27 ]
%12 = phi i32 [ 1, %7 ], [ %28, %27 ]
switch i32 %10, label %13 [
i32 32, label %15
i32 10, label %15
i32 9, label %15
]
13: ; preds = %9
%14 = add nsw i32 %11, 1
br label %27
15: ; preds = %9, %9, %9
%16 = icmp eq i32 %12, 0
br i1 %16, label %17, label %27
17: ; preds = %15
%18 = icmp slt i32 %11, 11
br i1 %18, label %19, label %24
19: ; preds = %17
%20 = sext i32 %11 to i64
%21 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
br label %27
24: ; preds = %17
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %27
27: ; preds = %15, %24, %19, %13
%28 = phi i32 [ 0, %13 ], [ 1, %19 ], [ 1, %24 ], [ 1, %15 ]
%29 = phi i32 [ %14, %13 ], [ 0, %19 ], [ 0, %24 ], [ 0, %15 ]
%30 = tail call i32 (...) @getchar()
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %9
33: ; preds = %27, %0
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 32)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 32)
br label %89
36: ; preds = %101
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 32)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 32)
%39 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%40 = load i32, i32* %39
%41 = icmp sgt i32 %40, 0
%42 = select i1 %41, i32 %40, i32 0
%43 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 1
%44 = load i32, i32* %43
%45 = icmp sgt i32 %44, %42
%46 = select i1 %45, i32 %44, i32 %42
%47 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 2
%48 = load i32, i32* %47
%49 = icmp sgt i32 %48, %46
%50 = select i1 %49, i32 %48, i32 %46
%51 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 3
%52 = load i32, i32* %51
%53 = icmp sgt i32 %52, %50
%54 = select i1 %53, i32 %52, i32 %50
%55 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 4
%56 = load i32, i32* %55
%57 = icmp sgt i32 %56, %54
%58 = select i1 %57, i32 %56, i32 %54
%59 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 5
%60 = load i32, i32* %59
%61 = icmp sgt i32 %60, %58
%62 = select i1 %61, i32 %60, i32 %58
%63 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 6
%64 = load i32, i32* %63
%65 = icmp sgt i32 %64, %62
%66 = select i1 %65, i32 %64, i32 %62
%67 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 7
%68 = load i32, i32* %67
%69 = icmp sgt i32 %68, %66
%70 = select i1 %69, i32 %68, i32 %66
%71 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 8
%72 = load i32, i32* %71
%73 = icmp sgt i32 %72, %70
%74 = select i1 %73, i32 %72, i32 %70
%75 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 9
%76 = load i32, i32* %75
%77 = icmp sgt i32 %76, %74
%78 = select i1 %77, i32 %76, i32 %74
%79 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 10
%80 = load i32, i32* %79
%81 = icmp sgt i32 %80, %78
%82 = select i1 %81, i32 %80, i32 %78
%83 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 11
%84 = load i32, i32* %83
%85 = icmp sgt i32 %84, %82
%86 = select i1 %85, i32 %84, i32 %82
%87 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%88 = icmp eq i32 %86, 0
br i1 %88, label %110, label %155
89: ; preds = %33, %101
%90 = phi i64 [ 1, %33 ], [ %103, %101 ]
%91 = icmp eq i64 %90, 11
br i1 %91, label %92, label %94
92: ; preds = %89
%93 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %97
94: ; preds = %89
%95 = trunc i64 %90 to i32
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %95)
br label %97
97: ; preds = %94, %92
%98 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %90
%99 = load i32, i32* %98
%100 = icmp sgt i32 %99, 0
br i1 %100, label %105, label %101
101: ; preds = %105, %97
%102 = tail call i32 @putchar(i8 signext 10)
%103 = add nuw nsw i64 %90, 1
%104 = icmp eq i64 %103, 12
br i1 %104, label %36, label %89
105: ; preds = %97, %105
%106 = phi i32 [ %108, %105 ], [ 0, %97 ]
%107 = tail call i32 @putchar(i8 signext 35)
%108 = add nuw nsw i32 %106, 1
%109 = icmp eq i32 %108, %99
br i1 %109, label %101, label %105
110: ; preds = %155, %36
%111 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%112 = tail call i32 @putchar(i8 signext 45)
%113 = tail call i32 @putchar(i8 signext 45)
%114 = tail call i32 @putchar(i8 signext 45)
%115 = tail call i32 @putchar(i8 signext 45)
%116 = tail call i32 @putchar(i8 signext 45)
%117 = tail call i32 @putchar(i8 signext 45)
%118 = tail call i32 @putchar(i8 signext 45)
%119 = tail call i32 @putchar(i8 signext 45)
%120 = tail call i32 @putchar(i8 signext 45)
%121 = tail call i32 @putchar(i8 signext 45)
%122 = tail call i32 @putchar(i8 signext 45)
%123 = tail call i32 @putchar(i8 signext 45)
%124 = tail call i32 @putchar(i8 signext 45)
%125 = tail call i32 @putchar(i8 signext 45)
%126 = tail call i32 @putchar(i8 signext 45)
%127 = tail call i32 @putchar(i8 signext 45)
%128 = tail call i32 @putchar(i8 signext 45)
%129 = tail call i32 @putchar(i8 signext 45)
%130 = tail call i32 @putchar(i8 signext 45)
%131 = tail call i32 @putchar(i8 signext 45)
%132 = tail call i32 @putchar(i8 signext 45)
%133 = tail call i32 @putchar(i8 signext 45)
%134 = tail call i32 @putchar(i8 signext 45)
%135 = tail call i32 @putchar(i8 signext 45)
%136 = tail call i32 @putchar(i8 signext 45)
%137 = tail call i32 @putchar(i8 signext 45)
%138 = tail call i32 @putchar(i8 signext 45)
%139 = tail call i32 @putchar(i8 signext 45)
%140 = tail call i32 @putchar(i8 signext 45)
%141 = tail call i32 @putchar(i8 signext 45)
%142 = tail call i32 @putchar(i8 signext 45)
%143 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%144 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 1)
%145 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 2)
%146 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 3)
%147 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 4)
%148 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 5)
%149 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 6)
%150 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 7)
%151 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 8)
%152 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 9)
%153 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 10)
%154 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.13, i64 0, i64 0))
ret i32 0
155: ; preds = %36, %155
%156 = phi i32 [ %192, %155 ], [ %86, %36 ]
%157 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %156)
%158 = icmp sgt i32 %156, %44
%159 = select i1 %158, i32 32, i32 35
%160 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %159)
%161 = icmp sgt i32 %156, %48
%162 = select i1 %161, i32 32, i32 35
%163 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %162)
%164 = icmp sgt i32 %156, %52
%165 = select i1 %164, i32 32, i32 35
%166 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %165)
%167 = icmp sgt i32 %156, %56
%168 = select i1 %167, i32 32, i32 35
%169 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %168)
%170 = icmp sgt i32 %156, %60
%171 = select i1 %170, i32 32, i32 35
%172 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %171)
%173 = icmp sgt i32 %156, %64
%174 = select i1 %173, i32 32, i32 35
%175 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %174)
%176 = icmp sgt i32 %156, %68
%177 = select i1 %176, i32 32, i32 35
%178 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %177)
%179 = icmp sgt i32 %156, %72
%180 = select i1 %179, i32 32, i32 35
%181 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %180)
%182 = icmp sgt i32 %156, %76
%183 = select i1 %182, i32 32, i32 35
%184 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %183)
%185 = icmp sgt i32 %156, %80
%186 = select i1 %185, i32 32, i32 35
%187 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %186)
%188 = icmp sgt i32 %156, %84
%189 = select i1 %188, i32 32, i32 35
%190 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %189)
%191 = tail call i32 @putchar(i8 signext 10)
%192 = add nsw i32 %156, -1
%193 = icmp sgt i32 %156, 1
br i1 %193, label %155, label %110
}