#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, char);
scalar_t__ islower(int);
scalar_t__ isupper(int);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    return EXIT_FAILURE;
  }
  char charcount[26] = {0};
  FILE *infptr;
  infptr = fopen(argv[1], "r");
  if (infptr == NULL) {
    return EXIT_FAILURE;
  }
  int onechar;
  do {
    onechar = fgetc(infptr);
    if (isupper(onechar)) {
      charcount[onechar - 'A']++;
    }
    if (islower(onechar)) {
      charcount[onechar - 'a']++;
    }
  } while (onechar != EOF);
  fclose(infptr);
  FILE *outfptr;
  outfptr = fopen(argv[2], "w");
  if (outfptr == NULL) {
    return EXIT_FAILURE;
  }
  int ind;
  for (ind = 0; ind < 26; ind++) {
    fprintf(outfptr, "%c: %d\n", ind + 'A', charcount[ind]);
  }
  fclose(outfptr);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a1 <main+0x31>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12e7 <main+0x177>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1a,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11e5 <main+0x75>
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12e7 <main+0x177>
jmp    11ea <main+0x7a>
mov    -0x38(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
call   1080 <isupper@plt>
cmp    $0x0,%rax
je     121b <main+0xab>
mov    -0x3c(%rbp),%eax
sub    $0x41,%eax
cltq
mov    -0x30(%rbp,%rax,1),%cl
add    $0x1,%cl
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x3c(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1240 <main+0xd0>
mov    -0x3c(%rbp),%eax
sub    $0x61,%eax
cltq
mov    -0x30(%rbp,%rax,1),%cl
add    $0x1,%cl
mov    %cl,-0x30(%rbp,%rax,1)
jmp    1245 <main+0xd5>
mov    -0x3c(%rbp),%eax
mov    0x2d99(%rip),%rcx
cmp    (%rcx),%eax
jne    11ea <main+0x7a>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd93(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1294 <main+0x124>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12e7 <main+0x177>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x1a,-0x4c(%rbp)
jge    12d2 <main+0x162>
mov    -0x48(%rbp),%rdi
mov    -0x4c(%rbp),%edx
add    $0x41,%edx
movslq -0x4c(%rbp),%rax
lea    0xd4a(%rip),%rsi
movsbl -0x30(%rbp,%rax,1),%ecx
call   1070 <fprintf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    129b <main+0x12b>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2cee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jg     117f <main+0x1f>
mov    0x2e5e(%rip),%rax
jmp    1257 <main+0xf7>
mov    %rsi,%r14
xorps  %xmm0,%xmm0
movups %xmm0,0xa(%rsp)
movaps %xmm0,(%rsp)
mov    0x8(%rsi),%rdi
lea    0xe67(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    0x2e30(%rip),%rax
test   %rbx,%rbx
je     1257 <main+0xf7>
mov    0x2e30(%rip),%r12
mov    %rsp,%r13
jmp    11c6 <main+0x66>
nopl   (%rax)
cmp    (%r12),%ebp
je     11f9 <main+0x99>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <isupper@plt>
movslq %ebp,%r15
test   %rax,%rax
je     11e5 <main+0x85>
addb   $0x1,-0x41(%r15,%r13,1)
mov    %ebp,%edi
call   1030 <islower@plt>
test   %rax,%rax
je     11c0 <main+0x60>
addb   $0x1,-0x61(%r15,%r13,1)
jmp    11c0 <main+0x60>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x10(%r14),%rdi
lea    0xdf6(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
mov    0x2dba(%rip),%rax
je     1257 <main+0xf7>
mov    $0xffffffffffffffe6,%rbp
lea    0xdd6(%rip),%r14
xchg   %ax,%ax
movsbl 0x1a(%rsp,%rbp,1),%ecx
lea    0x5b(%rbp),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <fprintf@plt>
inc    %rbp
jne    1230 <main+0xd0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [8 x i8] c"%c: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [26 x i8]
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = load i32, i32* @EXIT_FAILURE
br label %55
7: ; preds = %2
%8 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %52, label %13
13: ; preds = %7, %32
%14 = tail call i32 @fgetc(i32* %11)
%15 = tail call i64 @isupper(i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %13
%18 = add nsw i32 %14, -65
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = add i8 %21, 1
store i8 %22, i8* %20
br label %23
23: ; preds = %17, %13
%24 = tail call i64 @islower(i32 %14)
%25 = icmp eq i64 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %23
%27 = add nsw i32 %14, -97
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = add i8 %30, 1
store i8 %31, i8* %29
br label %32
32: ; preds = %23, %26
%33 = load i32, i32* @EOF
%34 = icmp eq i32 %14, %33
br i1 %34, label %35, label %13
35: ; preds = %32
%36 = tail call i32 @fclose(i32* %11)
%37 = getelementptr inbounds i8*, i8** %1, i64 2
%38 = load i8*, i8** %37
%39 = tail call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %52, label %41
41: ; preds = %35, %41
%42 = phi i64 [ %48, %41 ], [ 0, %35 ]
%43 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = trunc i64 %42 to i32
%46 = add i32 %45, 65
%47 = tail call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %46, i8 signext %44)
%48 = add nuw nsw i64 %42, 1
%49 = icmp eq i64 %48, 26
br i1 %49, label %50, label %41
50: ; preds = %41
%51 = tail call i32 @fclose(i32* %39)
br label %52
52: ; preds = %50, %35, %7
%53 = phi i32* [ @EXIT_FAILURE, %7 ], [ @EXIT_SUCCESS, %50 ], [ @EXIT_FAILURE, %35 ]
%54 = load i32, i32* %53
br label %55
55: ; preds = %52, %5
%56 = phi i32 [ %6, %5 ], [ %54, %52 ]
ret i32 %56
}