#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 /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ mychomp(char *);
char *mystrdup(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
int main(int argc, char **argv) {
  int i;
  FILE *wrdlst;
  char *wf;
  char ts[1024];
  char *ap;
  unsigned char *wp;
  int cc[256];
  if (argv[1]) {
    wf = mystrdup(argv[1]);
  } else {
    fprintf(stderr, "correct syntax is:\n");
    fprintf(stderr, "countit word_list_file\n");
    exit(1);
  }
  wrdlst = fopen(wf, "r");
  if (!wrdlst) {
    fprintf(stderr, "Error - could not open word list file\n");
    exit(1);
  }
  for (i = 0; i < 256; i++)
    cc[i] = 0;
  if (!fgets(ts, 1024 - 1, wrdlst))
    return 2;
  while (fgets(ts, 1024 - 1, wrdlst)) {
    mychomp(ts);
    wp = (unsigned char *)ts;
    ap = strchr(ts, '/');
    if (ap)
      *ap = '\0';
    while (*wp) {
      cc[*wp] = cc[*wp] + 1;
      wp++;
    }
  }
  for (i = 0; i < 256; i++) {
    if (cc[i] > 0) {
      fprintf(stdout, "%d,%c\n", cc[i], i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11ae <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <mystrdup@plt>
mov    %rax,-0x28(%rbp)
jmp    11e6 <main+0x76>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1226 <main+0xb6>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1257 <main+0xe7>
movslq -0x14(%rbp),%rax
movl   $0x0,-0x840(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122d <main+0xbd>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3ff,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    1282 <main+0x112>
movl   $0x2,-0x4(%rbp)
jmp    13ab <main+0x23b>
jmp    1287 <main+0x117>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3ff,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1346 <main+0x1d6>
lea    -0x430(%rbp),%rdi
call   1090 <mychomp@plt>
lea    -0x430(%rbp),%rax
mov    %rax,-0x440(%rbp)
lea    -0x430(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
je     12f0 <main+0x180>
mov    -0x438(%rbp),%rax
movb   $0x0,(%rax)
jmp    12f5 <main+0x185>
mov    -0x440(%rbp),%rax
cmpb   $0x0,(%rax)
je     1341 <main+0x1d1>
mov    -0x440(%rbp),%rax
movzbl (%rax),%eax
mov    -0x840(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    -0x440(%rbp),%rax
movzbl (%rax),%eax
mov    %ecx,-0x840(%rbp,%rax,4)
mov    -0x440(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x440(%rbp)
jmp    12f5 <main+0x185>
jmp    1287 <main+0x117>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    13a4 <main+0x234>
movslq -0x14(%rbp),%rax
cmpl   $0x0,-0x840(%rbp,%rax,4)
jle    1391 <main+0x221>
mov    0x2c65(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rax
mov    -0x840(%rbp,%rax,4),%edx
mov    -0x14(%rbp),%ecx
lea    0xccb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1396 <main+0x226>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    134d <main+0x1dd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     12bf <main+0x13f>
call   1040 <mystrdup@plt>
lea    0xe87(%rip),%rsi
mov    %rax,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12e1 <main+0x161>
mov    %rax,%r14
lea    0x400(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rsp,%rdi
mov    $0x3ff,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12ad <main+0x12d>
mov    %rsp,%rdi
mov    $0x3ff,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1268 <main+0xe8>
lea    0x1(%rsp),%r15
mov    %rsp,%rbx
jmp    1225 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0x3ff,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1268 <main+0xe8>
mov    %rbx,%rdi
call   10a0 <mychomp@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1242 <main+0xc2>
movb   $0x0,(%rax)
mov    (%rsp),%al
test   %al,%al
je     1210 <main+0x90>
mov    %r15,%rcx
nopl   0x0(%rax)
movzbl %al,%eax
addl   $0x1,0x400(%rsp,%rax,4)
01
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    1250 <main+0xd0>
jmp    1210 <main+0x90>
mov    0x2d69(%rip),%r15
lea    0xddf(%rip),%r14
xor    %ebx,%ebx
jmp    128d <main+0x10d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
je     12a9 <main+0x129>
mov    0x400(%rsp,%rbx,4),%edx
test   %edx,%edx
jle    1280 <main+0x100>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1280 <main+0x100>
xor    %eax,%eax
jmp    12b2 <main+0x132>
mov    $0x2,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2d1a(%rip),%rbx
mov    (%rbx),%edi
lea    0xd31(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd35(%rip),%rsi
jmp    12f1 <main+0x171>
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
lea    0xd3d(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"correct syntax is:\0A\00"
@.str.1 = [24 x i8] c"countit word_list_file\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [39 x i8] c"Error - could not open word list file\0A\00"
@stdout = global i32 0
@.str.4 = [7 x i8] c"%d,%c\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 i8*
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [256 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i8* @mystrdup(i8* %20)
store i8* %21, i8** %8
br label %28
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %17
%29 = load i8*, i8** %8
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %30, i32** %7
%31 = load i32*, i32** %7
%32 = icmp ne i32* %31, null
br i1 %32, label %37, label %33
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %28
store i32 0, i32* %6
br label %38
38: ; preds = %45, %37
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 256
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [256 x i32], [256 x i32]* %12, i64 0, i64 %43
store i32 0, i32* %44
br label %45
45: ; preds = %41
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %38
48: ; preds = %38
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%50 = load i32*, i32** %7
%51 = call i64 @fgets(i8* %49, i32 1023, i32* %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %48
store i32 2, i32* %3
br label %112
54: ; preds = %48
br label %55
55: ; preds = %88, %54
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%57 = load i32*, i32** %7
%58 = call i64 @fgets(i8* %56, i32 1023, i32* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %89
60: ; preds = %55
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%62 = call i32 @mychomp(i8* %61)
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8* %63, i8** %11
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%65 = call i8* @strchr(i8* %64, i8 signext 47)
store i8* %65, i8** %10
%66 = load i8*, i8** %10
%67 = icmp ne i8* %66, null
br i1 %67, label %68, label %70
68: ; preds = %60
%69 = load i8*, i8** %10
store i8 0, i8* %69
br label %70
70: ; preds = %68, %60
br label %71
71: ; preds = %75, %70
%72 = load i8*, i8** %11
%73 = load i8, i8* %72
%74 = icmp ne i8 %73, 0
br i1 %74, label %75, label %88
75: ; preds = %71
%76 = load i8*, i8** %11
%77 = load i8, i8* %76
%78 = zext i8 %77 to i64
%79 = getelementptr inbounds [256 x i32], [256 x i32]* %12, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = add nsw i32 %80, 1
%82 = load i8*, i8** %11
%83 = load i8, i8* %82
%84 = zext i8 %83 to i64
%85 = getelementptr inbounds [256 x i32], [256 x i32]* %12, i64 0, i64 %84
store i32 %81, i32* %85
%86 = load i8*, i8** %11
%87 = getelementptr inbounds i8, i8* %86, i32 1
store i8* %87, i8** %11
br label %71
88: ; preds = %71
br label %55
89: ; preds = %55
store i32 0, i32* %6
br label %90
90: ; preds = %108, %89
%91 = load i32, i32* %6
%92 = icmp slt i32 %91, 256
br i1 %92, label %93, label %111
93: ; preds = %90
%94 = load i32, i32* %6
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [256 x i32], [256 x i32]* %12, i64 0, i64 %95
%97 = load i32, i32* %96
%98 = icmp sgt i32 %97, 0
br i1 %98, label %99, label %107
99: ; preds = %93
%100 = load i32, i32* @stdout
%101 = load i32, i32* %6
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [256 x i32], [256 x i32]* %12, i64 0, i64 %102
%104 = load i32, i32* %103
%105 = load i32, i32* %6
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %104, i32 %105)
br label %107
107: ; preds = %99, %93
br label %108
108: ; preds = %107
%109 = load i32, i32* %6
%110 = add nsw i32 %109, 1
store i32 %110, i32* %6
br label %90
111: ; preds = %90
store i32 0, i32* %3
br label %112
112: ; preds = %111, %53
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"correct syntax is:\0A\00"
@.str.1 = [24 x i8] c"countit word_list_file\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [39 x i8] c"Error - could not open word list file\0A\00"
@stdout = global i32 0
@.str.4 = [7 x i8] c"%d,%c\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [256 x i32]
%5 = bitcast [256 x i32]* %4 to i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %17, label %10
10: ; preds = %2
%11 = tail call i8* @mystrdup(i8* %8)
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %23, label %14
14: ; preds = %10
%15 = call i64 @fgets(i8* %6, i32 1023, i32* %12)
%16 = icmp eq i64 %15, 0
br i1 %16, label %64, label %27
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %10
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %14
%28 = call i64 @fgets(i8* %6, i32 1023, i32* %12)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %31, %27
br label %52
31: ; preds = %42, %39
%32 = call i64 @fgets(i8* %6, i32 1023, i32* %12)
%33 = icmp eq i64 %32, 0
br i1 %33, label %30, label %34
34: ; preds = %27, %31
%35 = call i32 @mychomp(i8* %6)
%36 = call i8* @strchr(i8* %6, i8 signext 47)
%37 = icmp eq i8* %36, null
br i1 %37, label %39, label %38
38: ; preds = %34
store i8 0, i8* %36
br label %39
39: ; preds = %38, %34
%40 = load i8, i8* %6
%41 = icmp eq i8 %40, 0
br i1 %41, label %31, label %42
42: ; preds = %39, %42
%43 = phi i8 [ %50, %42 ], [ %40, %39 ]
%44 = phi i8* [ %49, %42 ], [ %6, %39 ]
%45 = zext i8 %43 to i64
%46 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = add nsw i32 %47, 1
store i32 %48, i32* %46
%49 = getelementptr inbounds i8, i8* %44, i64 1
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 0
br i1 %51, label %31, label %42
52: ; preds = %30, %61
%53 = phi i64 [ %62, %61 ], [ 0, %30 ]
%54 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %52
%58 = load i32, i32* @stdout
%59 = trunc i64 %53 to i32
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %55, i32 %59)
br label %61
61: ; preds = %52, %57
%62 = add nuw nsw i64 %53, 1
%63 = icmp eq i64 %62, 256
br i1 %63, label %64, label %52
64: ; preds = %61, %14
%65 = phi i32 [ 2, %14 ], [ 0, %61 ]
ret i32 %65
}