#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ InitialiseArrayToZero(int *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fopen_s(int /*<<< orphan*/ **, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ isalpha(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *input;
  int wordLength, maxLength, character, i, state = 1;
  int lengthCount[25 + 1];
  InitialiseArrayToZero(lengthCount, 25);
  fopen_s(&input, argv[1], "r");
  maxLength = wordLength = 0;
  while ((character = fgetc(input)) != EOF) {
    if (isalpha(character) || character == '-') {
      if (wordLength <= 25) {
        wordLength++;
      } else {
        state = 0;
        break;
      }
    } else {
      lengthCount[wordLength]++;
      if (wordLength > maxLength)
        maxLength = wordLength;
      wordLength = 0;
    }
  }
  fclose(input);
  switch (state) {
  case 1:
    for (i = 1; i <= maxLength; i++)
      printf("Length %d :\t%d Occurrences\n", i, lengthCount[i]);
    return 0;
  case 0:
    fprintf(stderr, "Word > 25 characters encountered.\n");
    return 1;
  default:
    fprintf(stderr, "State error.\n");
    return 2;
  }
}


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   $0x1,-0x2c(%rbp)
lea    -0xa0(%rbp),%rdi
mov    $0x19,%esi
call   1040 <InitialiseArrayToZero@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x18(%rbp),%rdi
lea    0xe4c(%rip),%rdx
call   1030 <fopen_s@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e0e(%rip),%rcx
cmp    (%rcx),%eax
je     125a <main+0xea>
mov    -0x24(%rbp),%edi
call   1090 <isalpha@plt>
cmp    $0x0,%rax
jne    11fe <main+0x8e>
cmpl   $0x2d,-0x24(%rbp)
jne    1227 <main+0xb7>
cmpl   $0x19,-0x1c(%rbp)
jg     1216 <main+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1222 <main+0xb2>
movl   $0x0,-0x2c(%rbp)
jmp    125a <main+0xea>
jmp    1255 <main+0xe5>
movslq -0x1c(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    124e <main+0xde>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
jmp    11c7 <main+0x57>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0xa4(%rbp)
test   %eax,%eax
je     12d4 <main+0x164>
jmp    1279 <main+0x109>
mov    -0xa4(%rbp),%eax
sub    $0x1,%eax
jne    12f5 <main+0x185>
jmp    128d <main+0x11d>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     12c8 <main+0x158>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%edx
lea    0xd4d(%rip),%rdi
call   1060 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1294 <main+0x124>
movl   $0x0,-0x4(%rbp)
jmp    1311 <main+0x1a1>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xd3a(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1311 <main+0x1a1>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
lea    0xd3c(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%rbx
lea    0x10(%rsp),%rdi
mov    $0x19,%esi
call   1040 <InitialiseArrayToZero@plt>
mov    0x8(%rbx),%rsi
lea    0xe64(%rip),%rdx
lea    0x8(%rsp),%rdi
call   1030 <fopen_s@plt>
mov    0x8(%rsp),%rdi
call   1070 <fgetc@plt>
mov    0x2e31(%rip),%r14
cmp    (%r14),%eax
jne    11ce <main+0x5e>
mov    0x8(%rsp),%rdi
call   1050 <fclose@plt>
xor    %r14d,%r14d
jmp    127e <main+0x10e>
mov    %eax,%ebx
xor    %r12d,%r12d
xor    %ebp,%ebp
jmp    1202 <main+0x92>
nopw   0x0(%rax,%rax,1)
movslq %ebp,%rax
addl   $0x1,0x10(%rsp,%rax,4)
cmp    %r12d,%eax
cmovg  %ebp,%r12d
xor    %ebp,%ebp
mov    0x8(%rsp),%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebx
cmp    (%r14),%eax
je     121d <main+0xad>
mov    %ebx,%edi
call   1090 <isalpha@plt>
cmp    $0x2d,%ebx
je     1213 <main+0xa3>
test   %rax,%rax
je     11e0 <main+0x70>
cmp    $0x19,%ebp
jg     1259 <main+0xe9>
add    $0x1,%ebp
jmp    11f1 <main+0x81>
mov    0x8(%rsp),%rdi
call   1050 <fclose@plt>
xor    %r14d,%r14d
test   %r12d,%r12d
jle    127e <main+0x10e>
add    $0x1,%r12d
mov    $0x1,%ebx
lea    0xdc3(%rip),%r15
nop
mov    0x10(%rsp,%rbx,4),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1240 <main+0xd0>
jmp    127e <main+0x10e>
mov    0x8(%rsp),%rdi
call   1050 <fclose@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.1 = [28 x i8] c"Length %d :\09%d Occurrences\0A\00"
@stderr = global i32 0
@.str.2 = [35 x i8] c"Word > 25 characters encountered.\0A\00"
@.str.3 = [14 x i8] c"State error.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [26 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %11
%13 = getelementptr inbounds [26 x i32], [26 x i32]* %12, i64 0, i64 0
%14 = call i32 @InitialiseArrayToZero(i32* %13, i32 25)
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @fopen_s(i32** %6, i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
store i32 0, i32* %8
br label %19
19: ; preds = %51, %2
%20 = load i32*, i32** %6
%21 = call i32 @fgetc(i32* %20)
store i32 %21, i32* %9
%22 = load i32, i32* @EOF
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %52
24: ; preds = %19
%25 = load i32, i32* %9
%26 = call i64 @isalpha(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %24
%29 = load i32, i32* %9
%30 = icmp eq i32 %29, 45
br i1 %30, label %31, label %39
31: ; preds = %28, %24
%32 = load i32, i32* %7
%33 = icmp sle i32 %32, 25
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %38
37: ; preds = %31
store i32 0, i32* %11
br label %52
38: ; preds = %34
br label %51
39: ; preds = %28
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [26 x i32], [26 x i32]* %12, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = add nsw i32 %43, 1
store i32 %44, i32* %42
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = icmp sgt i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %39
%49 = load i32, i32* %7
store i32 %49, i32* %8
br label %50
50: ; preds = %48, %39
store i32 0, i32* %7
br label %51
51: ; preds = %50, %38
br label %19
52: ; preds = %37, %19
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
%55 = load i32, i32* %11
switch i32 %55, label %75 [
i32 1, label %56
i32 0, label %72
]
56: ; preds = %52
store i32 1, i32* %10
br label %57
57: ; preds = %68, %56
%58 = load i32, i32* %10
%59 = load i32, i32* %8
%60 = icmp sle i32 %58, %59
br i1 %60, label %61, label %71
61: ; preds = %57
%62 = load i32, i32* %10
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [26 x i32], [26 x i32]* %12, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %62, i32 %66)
br label %68
68: ; preds = %61
%69 = load i32, i32* %10
%70 = add nsw i32 %69, 1
store i32 %70, i32* %10
br label %57
71: ; preds = %57
store i32 0, i32* %3
br label %78
72: ; preds = %52
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %78
75: ; preds = %52
%76 = load i32, i32* @stderr
%77 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
br label %78
78: ; preds = %75, %72, %71
%79 = load i32, i32* %3
ret i32 %79
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.1 = [28 x i8] c"Length %d :\09%d Occurrences\0A\00"
@stderr = global i32 0
@.str.2 = [35 x i8] c"Word > 25 characters encountered.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = alloca [26 x i32]
%5 = bitcast i32** %3 to i8*
%6 = bitcast [26 x i32]* %4 to i8*
%7 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 0
%8 = call i32 @InitialiseArrayToZero(i32* %7, i32 25)
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @fopen_s(i32** %3, i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = call i32 @fgetc(i32* %12)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i32*, i32** %3
%18 = call i32 @fclose(i32* %17)
br label %65
19: ; preds = %2, %38
%20 = phi i32 [ %42, %38 ], [ %13, %2 ]
%21 = phi i32 [ %40, %38 ], [ 0, %2 ]
%22 = phi i32 [ %39, %38 ], [ 0, %2 ]
%23 = call i64 @isalpha(i32 %20)
%24 = icmp ne i64 %23, 0
%25 = icmp eq i32 %20, 45
%26 = or i1 %25, %24
br i1 %26, label %27, label %31
27: ; preds = %19
%28 = icmp slt i32 %22, 26
br i1 %28, label %29, label %60
29: ; preds = %27
%30 = add nsw i32 %22, 1
br label %38
31: ; preds = %19
%32 = sext i32 %22 to i64
%33 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %33
%36 = icmp sgt i32 %22, %21
%37 = select i1 %36, i32 %22, i32 %21
br label %38
38: ; preds = %31, %29
%39 = phi i32 [ %30, %29 ], [ 0, %31 ]
%40 = phi i32 [ %21, %29 ], [ %37, %31 ]
%41 = load i32*, i32** %3
%42 = call i32 @fgetc(i32* %41)
%43 = load i32, i32* @EOF
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %19
45: ; preds = %38
%46 = load i32*, i32** %3
%47 = call i32 @fclose(i32* %46)
%48 = icmp slt i32 %40, 1
br i1 %48, label %65, label %49
49: ; preds = %45
%50 = add nuw i32 %40, 1
%51 = zext i32 %50 to i64
br label %52
52: ; preds = %49, %52
%53 = phi i64 [ 1, %49 ], [ %58, %52 ]
%54 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = trunc i64 %53 to i32
%57 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %56, i32 %55)
%58 = add nuw nsw i64 %53, 1
%59 = icmp eq i64 %58, %51
br i1 %59, label %65, label %52
60: ; preds = %27
%61 = load i32*, i32** %3
%62 = call i32 @fclose(i32* %61)
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %65
65: ; preds = %52, %16, %45, %60
%66 = phi i32 [ 1, %60 ], [ 0, %45 ], [ 0, %16 ], [ 0, %52 ]
ret i32 %66
}