#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 */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char, int);
int main(int argc, char *argv[]) {
  int charCount[26];
  char curChar = 0;
  while (curChar < 26) {
    charCount[curChar] = 0;
    curChar++;
  }
  char sourceFromFile = 0;
  if (argc == 2) {
    sourceFromFile = 1;
  }
  FILE *in;
  if (sourceFromFile) {
    in = fopen(argv[1], "r");
    while ((curChar = fgetc(in)) != EOF) {
      if (curChar >= 65 && curChar <= 90) {
        charCount[curChar - 65]++;
      }
      if (curChar >= 97 && curChar <= 122) {
        charCount[curChar - 97]++;
      }
    }
  }
  curChar = 0;
  while (curChar < 26) {
    printf("%c - %5d\n", curChar + 65, charCount[curChar]);
    curChar++;
  }
}


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)
movb   $0x0,-0x81(%rbp)
movsbl -0x81(%rbp),%eax
cmp    $0x1a,%eax
jge    1183 <main+0x53>
movsbq -0x81(%rbp),%rax
ff
movl   $0x0,-0x80(%rbp,%rax,4)
mov    -0x81(%rbp),%al
add    $0x1,%al
mov    %al,-0x81(%rbp)
jmp    1150 <main+0x20>
movb   $0x0,-0x82(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    119b <main+0x6b>
movb   $0x1,-0x82(%rbp)
cmpb   $0x0,-0x82(%rbp)
je     1262 <main+0x132>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe49(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x81(%rbp)
movsbl %al,%eax
mov    0x2e09(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     125d <main+0x12d>
movsbl -0x81(%rbp),%eax
cmp    $0x41,%eax
jl     1221 <main+0xf1>
movsbl -0x81(%rbp),%eax
cmp    $0x5a,%eax
jg     1221 <main+0xf1>
movsbl -0x81(%rbp),%eax
sub    $0x41,%eax
cltq
mov    -0x80(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80(%rbp,%rax,4)
movsbl -0x81(%rbp),%eax
cmp    $0x61,%eax
jl     1258 <main+0x128>
movsbl -0x81(%rbp),%eax
cmp    $0x7a,%eax
jg     1258 <main+0x128>
movsbl -0x81(%rbp),%eax
sub    $0x61,%eax
cltq
mov    -0x80(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80(%rbp,%rax,4)
jmp    11c3 <main+0x93>
jmp    1262 <main+0x132>
movb   $0x0,-0x81(%rbp)
movsbl -0x81(%rbp),%eax
cmp    $0x1a,%eax
jge    12b1 <main+0x181>
movsbl -0x81(%rbp),%eax
add    $0x41,%eax
movsbq -0x81(%rbp),%rcx
ff
mov    -0x80(%rbp,%rcx,4),%edx
lea    0xd6c(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x81(%rbp),%al
add    $0x1,%al
mov    %al,-0x81(%rbp)
jmp    1269 <main+0x139>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
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)
cmp    $0x2,%edi
jne    118e <main+0x5e>
mov    0x8(%rsi),%rdi
lea    0xe8e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    0x2e5f(%rip),%r14
cmp    (%r14),%al
jne    11c7 <main+0x97>
xor    %ebx,%ebx
lea    0xe6b(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%edx
lea    0x41(%rbx),%eax
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x1a,%rbx
jne    11a0 <main+0x70>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0xffffff9f,%ecx
lea    0x20(%rcx),%rbx
jmp    11f7 <main+0xc7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbq %al,%rax
add    %eax,%ecx
addl   $0x1,(%rsp,%rcx,4)
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    (%r14),%al
je     118e <main+0x5e>
lea    -0x41(%rax),%edx
mov    %rbx,%rcx
cmp    $0x1a,%dl
jb     11e0 <main+0xb0>
lea    -0x61(%rax),%edx
mov    $0xffffff9f,%ecx
cmp    $0x19,%dl
jbe    11e0 <main+0xb0>
jmp    11ea <main+0xba>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.1 = [10 x i8] c"%c - %5d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [26 x i32]
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %7
br label %10
10: ; preds = %14, %2
%11 = load i8, i8* %7
%12 = sext i8 %11 to i32
%13 = icmp slt i32 %12, 26
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i8, i8* %7
%16 = sext i8 %15 to i64
%17 = getelementptr inbounds [26 x i32], [26 x i32]* %6, i64 0, i64 %16
store i32 0, i32* %17
%18 = load i8, i8* %7
%19 = add i8 %18, 1
store i8 %19, i8* %7
br label %10
20: ; preds = %10
store i8 0, i8* %8
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %24
23: ; preds = %20
store i8 1, i8* %8
br label %24
24: ; preds = %23, %20
%25 = load i8, i8* %8
%26 = icmp ne i8 %25, 0
br i1 %26, label %27, label %73
27: ; preds = %24
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %31, i32** %9
br label %32
32: ; preds = %71, %27
%33 = load i32*, i32** %9
%34 = call signext i8 @fgetc(i32* %33)
store i8 %34, i8* %7
%35 = sext i8 %34 to i32
%36 = load i8, i8* @EOF
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %35, %37
br i1 %38, label %39, label %72
39: ; preds = %32
%40 = load i8, i8* %7
%41 = sext i8 %40 to i32
%42 = icmp sge i32 %41, 65
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = load i8, i8* %7
%45 = sext i8 %44 to i32
%46 = icmp sle i32 %45, 90
br i1 %46, label %47, label %55
47: ; preds = %43
%48 = load i8, i8* %7
%49 = sext i8 %48 to i32
%50 = sub nsw i32 %49, 65
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [26 x i32], [26 x i32]* %6, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = add nsw i32 %53, 1
store i32 %54, i32* %52
br label %55
55: ; preds = %47, %43, %39
%56 = load i8, i8* %7
%57 = sext i8 %56 to i32
%58 = icmp sge i32 %57, 97
br i1 %58, label %59, label %71
59: ; preds = %55
%60 = load i8, i8* %7
%61 = sext i8 %60 to i32
%62 = icmp sle i32 %61, 122
br i1 %62, label %63, label %71
63: ; preds = %59
%64 = load i8, i8* %7
%65 = sext i8 %64 to i32
%66 = sub nsw i32 %65, 97
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [26 x i32], [26 x i32]* %6, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = add nsw i32 %69, 1
store i32 %70, i32* %68
br label %71
71: ; preds = %63, %59, %55
br label %32
72: ; preds = %32
br label %73
73: ; preds = %72, %24
store i8 0, i8* %7
br label %74
74: ; preds = %78, %73
%75 = load i8, i8* %7
%76 = sext i8 %75 to i32
%77 = icmp slt i32 %76, 26
br i1 %77, label %78, label %90
78: ; preds = %74
%79 = load i8, i8* %7
%80 = sext i8 %79 to i32
%81 = add nsw i32 %80, 65
%82 = trunc i32 %81 to i8
%83 = load i8, i8* %7
%84 = sext i8 %83 to i64
%85 = getelementptr inbounds [26 x i32], [26 x i32]* %6, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext %82, i32 %86)
%88 = load i8, i8* %7
%89 = add i8 %88, 1
store i8 %89, i8* %7
br label %74
90: ; preds = %74
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.1 = [10 x i8] c"%c - %5d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [26 x i32]
%4 = bitcast [26 x i32]* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %32
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call signext i8 @fgetc(i32* %9)
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %32, label %13
13: ; preds = %6, %28
%14 = phi i8 [ %29, %28 ], [ %10, %6 ]
%15 = sext i8 %14 to i64
%16 = add i8 %14, -65
%17 = icmp ult i8 %16, 26
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = add i8 %14, -97
%20 = icmp ult i8 %19, 26
br i1 %20, label %21, label %28
21: ; preds = %18, %13
%22 = phi i64 [ 4294967231, %13 ], [ 4294967199, %18 ]
%23 = add nsw i64 %22, %15
%24 = and i64 %23, 4294967295
%25 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
br label %28
28: ; preds = %21, %18
%29 = tail call signext i8 @fgetc(i32* %9)
%30 = load i8, i8* @EOF
%31 = icmp eq i8 %29, %30
br i1 %31, label %32, label %13
32: ; preds = %28, %6, %2
br label %33
33: ; preds = %32, %33
%34 = phi i64 [ %40, %33 ], [ 0, %32 ]
%35 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = trunc i64 %34 to i8
%38 = add i8 %37, 65
%39 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext %38, i32 %36)
%40 = add nuw nsw i64 %34, 1
%41 = icmp eq i64 %40, 26
br i1 %41, label %42, label %33
42: ; preds = %33
ret i32 0
}