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

/* Variables and functions */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ hshistogram(int /*<<< orphan*/ *, int *, int, char **);
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vshistogram(int /*<<< orphan*/ *, int *, int, char **);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Missing input files\n");
    return 1;
  }
  int i, size;
  int a[3];
  FILE *in, *out;
  char ch;
  char *name[] = {
      "digit",
      "alpha",
      "other",
  };
  size = 3;
  for (i = 1; i < argc; i++) {
    in = fopen(argv[i], "r");
    out = fopen("output.dat", "w");
    if (in == NULL || out == NULL) {
      perror(argv[i]);
      return 1;
    }
    memset(a, 0, sizeof(a));
    while ((ch = fgetc(in)) != EOF) {
      if (isdigit(ch)) {
        a[0]++;
      } else if (isalpha(ch)) {
        a[1]++;
      } else {
        a[2]++;
      }
    }
    hshistogram(out, a, size, name);
    vshistogram(out, a, size, name);
    fclose(in);
    fclose(out);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11e1 <main+0x41>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1357 <main+0x1b7>
mov    0x2c08(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c05(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2c02(%rip),%rax
mov    %rax,-0x50(%rbp)
movl   $0x3,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1350 <main+0x1b0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdf6(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
lea    0xde8(%rip),%rdi
lea    0xdec(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1265 <main+0xc5>
cmpq   $0x0,-0x38(%rbp)
jne    1282 <main+0xe2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1357 <main+0x1b7>
lea    -0x24(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    -0x30(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x39(%rbp)
movsbl %al,%eax
mov    0x2d38(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1308 <main+0x168>
movsbl -0x39(%rbp),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     12d4 <main+0x134>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1303 <main+0x163>
movsbl -0x39(%rbp),%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%rax
je     12f5 <main+0x155>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12fe <main+0x15e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1303 <main+0x163>
jmp    1292 <main+0xf2>
mov    -0x38(%rbp),%rdi
lea    -0x24(%rbp),%rsi
mov    -0x18(%rbp),%edx
lea    -0x60(%rbp),%rcx
call   1030 <hshistogram@plt>
mov    -0x38(%rbp),%rdi
lea    -0x24(%rbp),%rsi
mov    -0x18(%rbp),%edx
lea    -0x60(%rbp),%rcx
call   1090 <vshistogram@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1210 <main+0x70>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,0x10(%rsp)
cmp    $0x1,%edi
jg     11d7 <main+0x37>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    12f4 <main+0x154>
mov    0x2c22(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0x2c06(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %edi,%eax
mov    %rax,0x18(%rsp)
mov    $0x1,%r13d
mov    0x2ddd(%rip),%rbp
jmp    125f <main+0xbf>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
lea    0x4(%rsp),%r12
mov    %r12,%rsi
mov    $0x3,%edx
lea    0x20(%rsp),%rbx
mov    %rbx,%rcx
call   1030 <hshistogram@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x3,%edx
mov    %rbx,%rcx
call   1090 <vshistogram@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x1,%r13
cmp    0x18(%rsp),%r13
je     12f2 <main+0x152>
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rdi
lea    0xdb6(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
lea    0xda9(%rip),%rdi
lea    0xdad(%rip),%rsi
call   10b0 <fopen@plt>
test   %r14,%r14
je     1303 <main+0x163>
mov    %rax,%r15
test   %rax,%rax
je     1303 <main+0x163>
lea    0x4(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
jmp    12b5 <main+0x115>
nopw   0x0(%rax,%rax,1)
addl   $0x1,0x4(%rsp)
mov    %r14,%rdi
call   1070 <fgetc@plt>
cmp    0x0(%rbp),%al
je     1210 <main+0x70>
movsbl %al,%r12d
mov    %r12d,%edi
call   1040 <isdigit@plt>
test   %rax,%rax
jne    12b0 <main+0x110>
mov    %r12d,%edi
call   10a0 <isalpha@plt>
test   %rax,%rax
je     12eb <main+0x14b>
addl   $0x1,0x8(%rsp)
jmp    12b5 <main+0x115>
addl   $0x1,0xc(%rsp)
jmp    12b5 <main+0x115>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13d,%eax
mov    0x10(%rsp),%rcx
mov    (%rcx,%rax,8),%rdi
call   10c0 <perror@plt>
mov    $0x1,%eax
jmp    12f4 <main+0x154>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Missing input files\0A\00"
@.str.1 = [6 x i8] c"digit\00"
@.str.2 = [6 x i8] c"alpha\00"
@.str.3 = [6 x i8] c"other\00"
@__const.main.name = [3 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [11 x i8] c"output.dat\00"
@.str.6 = [2 x i8] c"w\00"
@EOF = global i8 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i32]
%4 = alloca [3 x i8*]
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %65
9: ; preds = %2
%10 = bitcast [3 x i32]* %3 to i8*
%11 = bitcast [3 x i8*]* %4 to i8*
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%15 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
%16 = zext i32 %0 to i64
br label %17
17: ; preds = %9, %56
%18 = phi i64 [ 1, %9 ], [ %61, %56 ]
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i32* %21, null
%24 = icmp eq i32* %22, null
%25 = or i1 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %17
%27 = and i64 %18, 4294967295
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @perror(i8* %29)
br label %63
31: ; preds = %17
%32 = call i32 @memset(i32* %12, i32 0, i32 12)
%33 = call signext i8 @fgetc(i32* %21)
%34 = load i8, i8* @EOF
%35 = icmp eq i8 %33, %34
br i1 %35, label %56, label %36
36: ; preds = %31, %52
%37 = phi i8 [ %53, %52 ], [ %33, %31 ]
%38 = call i64 @isdigit(i8 signext %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %36
%41 = load i32, i32* %12
%42 = add nsw i32 %41, 1
store i32 %42, i32* %12
br label %52
43: ; preds = %36
%44 = call i64 @isalpha(i8 signext %37)
%45 = icmp eq i64 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = load i32, i32* %13
%48 = add nsw i32 %47, 1
store i32 %48, i32* %13
br label %52
49: ; preds = %43
%50 = load i32, i32* %14
%51 = add nsw i32 %50, 1
store i32 %51, i32* %14
br label %52
52: ; preds = %46, %49, %40
%53 = call signext i8 @fgetc(i32* %21)
%54 = load i8, i8* @EOF
%55 = icmp eq i8 %53, %54
br i1 %55, label %56, label %36
56: ; preds = %52, %31
%57 = call i32 @hshistogram(i32* %22, i32* %12, i32 3, i8** %15)
%58 = call i32 @vshistogram(i32* %22, i32* %12, i32 3, i8** %15)
%59 = call i32 @fclose(i32* %21)
%60 = call i32 @fclose(i32* %22)
%61 = add nuw nsw i64 %18, 1
%62 = icmp eq i64 %61, %16
br i1 %62, label %63, label %17
63: ; preds = %56, %26
%64 = phi i32 [ 1, %26 ], [ 0, %56 ]
br label %65
65: ; preds = %63, %6
%66 = phi i32 [ 1, %6 ], [ %64, %63 ]
ret i32 %66
}