#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 EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int s[256];
  int j;
  int total = 0;
  FILE *arquivo;
  arquivo = fopen(argv[1], "r");
  for (j = 0; j < 256; j++) {
    s[j] = 0;
  }
  s['A']++;
  s['B']++;
  for (j = 0; j < 256; j++) {
    total += s[j];
  }
  printf("%8s%13s\n", "Elemento", "Valor");
  for (j = 0; j < 256; j++) {
    if (s[j] != 0)
      printf("%8d%4c%5x%13d\n", j, j, j, s[j]);
  }
  printf("%8s%13d\n", "Total", total);
  fclose(arquivo);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x418(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb4(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x420(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    11ae <main+0x7e>
movslq -0x414(%rbp),%rax
movl   $0x0,-0x410(%rbp,%rax,4)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1178 <main+0x48>
mov    -0x30c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30c(%rbp)
mov    -0x308(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x308(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    1214 <main+0xe4>
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%eax
add    -0x418(%rbp),%eax
mov    %eax,-0x418(%rbp)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11d6 <main+0xa6>
lea    0xde5(%rip),%rdi
lea    0xde7(%rip),%rsi
lea    0xde9(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    12a7 <main+0x177>
movslq -0x414(%rbp),%rax
cmpl   $0x0,-0x410(%rbp,%rax,4)
je     128e <main+0x15e>
mov    -0x414(%rbp),%esi
mov    -0x414(%rbp),%edx
mov    -0x414(%rbp),%ecx
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%r8d
ff
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1293 <main+0x163>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    123a <main+0x10a>
mov    -0x418(%rbp),%edx
lea    0xd73(%rip),%rdi
lea    0xd75(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x420(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x420,%rsp
mov    0x8(%rsi),%rdi
lea    0xebf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0x20(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x400,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movabs $0x100000001,%rax
mov    %rax,0x124(%rsp)
pxor   %xmm0,%xmm0
pxor   %xmm1,%xmm1
nopl   0x0(%rax)
paddd  0x20(%rsp,%rbx,4),%xmm0
paddd  0x30(%rsp,%rbx,4),%xmm1
paddd  0x40(%rsp,%rbx,4),%xmm0
paddd  0x50(%rsp,%rbx,4),%xmm1
paddd  0x60(%rsp,%rbx,4),%xmm0
paddd  0x70(%rsp,%rbx,4),%xmm1
paddd  0x80(%rsp,%rbx,4),%xmm0
paddd  0x90(%rsp,%rbx,4),%xmm1
add    $0x20,%rbx
cmp    $0x100,%rbx
jne    1190 <main+0x50>
lea    0xe26(%rip),%rdi
lea    0xe28(%rip),%rsi
lea    0xe2a(%rip),%rdx
xor    %eax,%eax
movdqa %xmm0,0x10(%rsp)
movdqa %xmm1,(%rsp)
call   1040 <printf@plt>
movdqa (%rsp),%xmm1
movdqa 0x10(%rsp),%xmm0
lea    0xe0c(%rip),%r15
xor    %ebx,%ebx
jmp    121d <main+0xdd>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     1244 <main+0x104>
mov    0x20(%rsp,%rbx,4),%r8d
test   %r8d,%r8d
je     1210 <main+0xd0>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
movdqa (%rsp),%xmm1
movdqa 0x10(%rsp),%xmm0
jmp    1210 <main+0xd0>
paddd  %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edx
lea    0xdc2(%rip),%rdi
lea    0xdc4(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
add    $0x420,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%8s%13s\0A\00"
@.str.2 = [9 x i8] c"Elemento\00"
@.str.3 = [6 x i8] c"Valor\00"
@.str.4 = [15 x i8] c"%8d%4c%5x%13d\0A\00"
@.str.5 = [9 x i8] c"%8s%13d\0A\00"
@.str.6 = [6 x i8] c"Total\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %9
store i32 0, i32* %7
br label %14
14: ; preds = %21, %2
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 256
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %19
store i32 0, i32* %20
br label %21
21: ; preds = %17
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %14
24: ; preds = %14
%25 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 65
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
%28 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 66
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
store i32 0, i32* %7
br label %31
31: ; preds = %41, %24
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 256
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = load i32, i32* %8
%40 = add nsw i32 %39, %38
store i32 %40, i32* %8
br label %41
41: ; preds = %34
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %31
44: ; preds = %31
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %46
46: ; preds = %65, %44
%47 = load i32, i32* %7
%48 = icmp slt i32 %47, 256
br i1 %48, label %49, label %68
49: ; preds = %46
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %64
55: ; preds = %49
%56 = load i32, i32* %7
%57 = load i32, i32* %7
%58 = load i32, i32* %7
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %56, i32 %57, i32 %58, i32 %62)
br label %64
64: ; preds = %55, %49
br label %65
65: ; preds = %64
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %46
68: ; preds = %46
%69 = load i32, i32* %8
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %69)
%71 = load i32*, i32** %9
%72 = call i32 @fclose(i32* %71)
%73 = load i32, i32* @EXIT_SUCCESS
ret i32 %73
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"%8s%13s\0A\00"
@.str.2 = [9 x i8] c"Elemento\00"
@.str.3 = [6 x i8] c"Valor\00"
@.str.4 = [15 x i8] c"%8d%4c%5x%13d\0A\00"
@.str.5 = [9 x i8] c"%8s%13d\0A\00"
@.str.6 = [6 x i8] c"Total\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i32]
%4 = bitcast [256 x i32]* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 65
store i32 1, i32* %8
%9 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 66
store i32 1, i32* %9
br label %10
10: ; preds = %10, %2
%11 = phi i64 [ 0, %2 ], [ %49, %10 ]
%12 = phi <4 x i32> [ zeroinitializer, %2 ], [ %47, %10 ]
%13 = phi <4 x i32> [ zeroinitializer, %2 ], [ %48, %10 ]
%14 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %11
%15 = bitcast i32* %14 to <4 x i32>*
%16 = load <4 x i32>, <4 x i32>* %15
%17 = getelementptr inbounds i32, i32* %14, i64 4
%18 = bitcast i32* %17 to <4 x i32>*
%19 = load <4 x i32>, <4 x i32>* %18
%20 = add <4 x i32> %16, %12
%21 = add <4 x i32> %19, %13
%22 = or i64 %11, 8
%23 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %22
%24 = bitcast i32* %23 to <4 x i32>*
%25 = load <4 x i32>, <4 x i32>* %24
%26 = getelementptr inbounds i32, i32* %23, i64 4
%27 = bitcast i32* %26 to <4 x i32>*
%28 = load <4 x i32>, <4 x i32>* %27
%29 = add <4 x i32> %25, %20
%30 = add <4 x i32> %28, %21
%31 = or i64 %11, 16
%32 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %31
%33 = bitcast i32* %32 to <4 x i32>*
%34 = load <4 x i32>, <4 x i32>* %33
%35 = getelementptr inbounds i32, i32* %32, i64 4
%36 = bitcast i32* %35 to <4 x i32>*
%37 = load <4 x i32>, <4 x i32>* %36
%38 = add <4 x i32> %34, %29
%39 = add <4 x i32> %37, %30
%40 = or i64 %11, 24
%41 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %40
%42 = bitcast i32* %41 to <4 x i32>*
%43 = load <4 x i32>, <4 x i32>* %42
%44 = getelementptr inbounds i32, i32* %41, i64 4
%45 = bitcast i32* %44 to <4 x i32>*
%46 = load <4 x i32>, <4 x i32>* %45
%47 = add <4 x i32> %43, %38
%48 = add <4 x i32> %46, %39
%49 = add nuw nsw i64 %11, 32
%50 = icmp eq i64 %49, 256
br i1 %50, label %51, label %10
51: ; preds = %10
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %51, %61
%54 = phi i64 [ 0, %51 ], [ %62, %61 ]
%55 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %53
%59 = trunc i64 %54 to i32
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %59, i32 %59, i32 %59, i32 %56)
br label %61
61: ; preds = %53, %58
%62 = add nuw nsw i64 %54, 1
%63 = icmp eq i64 %62, 256
br i1 %63, label %64, label %53
64: ; preds = %61
%65 = add <4 x i32> %48, %47
%66 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %65)
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %66)
%68 = tail call i32 @fclose(i32* %7)
%69 = load i32, i32* @EXIT_SUCCESS
ret i32 %69
}