#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 s[256];
  int j;
  int total = 0;
  FILE *arquivo;
  for (j = 0; j < 256; j++) {
    s[j] = 0;
  }
  arquivo = fopen("freq.c", "r");
  s['A']++;
  s['B']++;
  s['A']++;
  fclose(arquivo);
  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);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x418(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    118c <main+0x5c>
movslq -0x414(%rbp),%rax
movl   $0x0,-0x410(%rbp,%rax,4)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1156 <main+0x26>
lea    0xe6d(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x420(%rbp)
mov    -0x30c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30c(%rbp)
mov    -0x308(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x308(%rbp)
mov    -0x30c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30c(%rbp)
mov    -0x420(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    1227 <main+0xf7>
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    11e9 <main+0xb9>
lea    0xdd9(%rip),%rdi
lea    0xddb(%rip),%rsi
lea    0xddd(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    12ba <main+0x18a>
movslq -0x414(%rbp),%rax
cmpl   $0x0,-0x410(%rbp,%rax,4)
je     12a1 <main+0x171>
mov    -0x414(%rbp),%esi
mov    -0x414(%rbp),%edx
mov    -0x414(%rbp),%ecx
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%r8d
ff
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a6 <main+0x176>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    124d <main+0x11d>
mov    -0x418(%rbp),%edx
lea    0xd67(%rip),%rdi
lea    0xd69(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x428,%rsp
lea    0x20(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x400,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe9c(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
movabs $0x100000002,%rcx
mov    %rcx,0x124(%rsp)
mov    %rax,%rdi
call   1030 <fclose@plt>
pxor   %xmm0,%xmm0
pxor   %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
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    11a0 <main+0x60>
lea    0xe1d(%rip),%rdi
lea    0xe1f(%rip),%rsi
lea    0xe21(%rip),%rdx
xor    %eax,%eax
movdqa %xmm0,0x10(%rsp)
movdqa %xmm1,(%rsp)
call   1040 <printf@plt>
movdqa (%rsp),%xmm1
movdqa 0x10(%rsp),%xmm0
lea    0xe03(%rip),%r14
xor    %ebx,%ebx
jmp    122d <main+0xed>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     1254 <main+0x114>
mov    0x20(%rsp,%rbx,4),%r8d
test   %r8d,%r8d
je     1220 <main+0xe0>
mov    %r14,%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    1220 <main+0xe0>
paddd  %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edx
lea    0xdb9(%rip),%rdi
lea    0xdbb(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%eax
add    $0x428,%rsp
pop    %rbx
pop    %r14
ret

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

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