#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 */
char EOF;
char getchar();
scalar_t__ isspace(char);
int /*<<< orphan*/ painth(int *, int);
int /*<<< orphan*/ paintv(int *, int);
int /*<<< orphan*/ updatecounts(int *, int, int);
int main() {
  int len = 10;
  int counts[len];
  int i;
  for (i = 0; i < len; counts[i++] = 0)
    ;
  int isIn = 0;
  int wordlen = 0;
  char c;
  while ((c = getchar()) != EOF) {
    if (isIn) {
      if (isspace(c)) {
        updatecounts(counts, len, wordlen);
        isIn = 0;
        wordlen = 0;
      } else {
        wordlen++;
      }
    } else {
      if (!isspace(c)) {
        isIn = 1;
        wordlen = 1;
      }
    }
  }
  if (wordlen > 0)
    updatecounts(counts, len, wordlen);
  painth(counts, len);
  paintv(counts, len);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c3 <main+0x73>
jmp    11a5 <main+0x55>
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    1194 <main+0x44>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x25(%rbp)
movsbl %al,%eax
mov    0x2e03(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1268 <main+0x118>
cmpl   $0x0,-0x20(%rbp)
je     123d <main+0xed>
movsbl -0x25(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     122f <main+0xdf>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1050 <updatecounts@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
jmp    1238 <main+0xe8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1263 <main+0x113>
movsbl -0x25(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
jne    125e <main+0x10e>
movl   $0x1,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1263 <main+0x113>
jmp    11d1 <main+0x81>
cmpl   $0x0,-0x24(%rbp)
jle    1281 <main+0x131>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1050 <updatecounts@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <painth@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <paintv@plt>
mov    -0x10(%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   %r12
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e69(%rip),%r15
cmp    (%r15),%al
je     11fd <main+0xad>
mov    $0x1,%r12d
mov    %rsp,%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11b9 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
cmove  %r12d,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r15),%al
je     11ea <main+0x9a>
movsbl %al,%edi
call   1030 <isspace@plt>
test   %ebp,%ebp
je     11a0 <main+0x50>
test   %rax,%rax
je     11e0 <main+0x90>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %ebx,%edx
call   1050 <updatecounts@plt>
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11ad <main+0x5d>
nop
add    $0x1,%ebx
mov    $0x1,%ebp
jmp    11ad <main+0x5d>
test   %ebx,%ebx
jle    11fd <main+0xad>
mov    %rsp,%rdi
mov    $0xa,%esi
mov    %ebx,%edx
call   1050 <updatecounts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <painth@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <paintv@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i8 0
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call signext i8 (...) @getchar()
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %32, label %7
7: ; preds = %0, %22
%8 = phi i8 [ %25, %22 ], [ %4, %0 ]
%9 = phi i32 [ %24, %22 ], [ 0, %0 ]
%10 = phi i32 [ %23, %22 ], [ 0, %0 ]
%11 = icmp eq i32 %10, 0
%12 = call i64 @isspace(i8 signext %8)
%13 = icmp eq i64 %12, 0
br i1 %11, label %19, label %14
14: ; preds = %7
br i1 %13, label %17, label %15
15: ; preds = %14
%16 = call i32 @updatecounts(i32* %3, i32 10, i32 %9)
br label %22
17: ; preds = %14
%18 = add nsw i32 %9, 1
br label %22
19: ; preds = %7
%20 = zext i1 %13 to i32
%21 = select i1 %13, i32 1, i32 %9
br label %22
22: ; preds = %19, %15, %17
%23 = phi i32 [ 0, %15 ], [ 1, %17 ], [ %20, %19 ]
%24 = phi i32 [ 0, %15 ], [ %18, %17 ], [ %21, %19 ]
%25 = call signext i8 (...) @getchar()
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %25, %26
br i1 %27, label %28, label %7
28: ; preds = %22
%29 = icmp sgt i32 %24, 0
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = call i32 @updatecounts(i32* %3, i32 10, i32 %24)
br label %32
32: ; preds = %0, %30, %28
%33 = call i32 @painth(i32* %3, i32 10)
%34 = call i32 @paintv(i32* %3, i32 10)
ret i32 0
}