#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[10];
  int i;
  int total = 0;
  FILE *arquivo;
  arquivo = fopen("freq.txt", "r");
  for (i = 0; i < 10; i++) {
    printf("s[i] = 0");
  }
  s['A']++;
  s['B']++;
  s['C']++;
  fclose(arquivo);
  for (i = 0; i < 10; i++) {
    total += s[i];
  }
  printf("%8s %13s\n", "ELEMENTO", "VALOR");
  for (i = 0; i < 10; i++) {
    if (s[i] != 0) {
      printf("%8d %4c %5x %13d\n", i, i, i, s[i]);
    }
  }
  printf("%8s%13d\n", "TOTAL", total);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x38(%rbp)
lea    0xeb3(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    118a <main+0x5a>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1164 <main+0x34>
mov    0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,0xd4(%rbp)
mov    0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,0xd8(%rbp)
mov    0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,0xdc(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11ed <main+0xbd>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c7 <main+0x97>
lea    0xe20(%rip),%rdi
lea    0xe23(%rip),%rsi
lea    0xe25(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    125c <main+0x12c>
movslq -0x34(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
je     1249 <main+0x119>
mov    -0x34(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x34(%rbp),%ecx
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%r8d
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124e <main+0x11e>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1210 <main+0xe0>
mov    -0x38(%rbp),%edx
lea    0xdd9(%rip),%rdi
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xeba(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0xe50(%rip),%rdi
lea    0xe53(%rip),%rsi
lea    0xe55(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4d(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
mov    $0x4,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x5,%edx
mov    $0x5,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x6,%edx
mov    $0x6,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x7,%edx
mov    $0x7,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x8,%edx
mov    $0x8,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x9,%edx
mov    $0x9,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd67(%rip),%rdi
lea    0xd69(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2cf3(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"freq.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"s[i] = 0\00"
@.str.3 = [10 x i8] c"%8s %13s\0A\00"
@.str.4 = [9 x i8] c"ELEMENTO\00"
@.str.5 = [6 x i8] c"VALOR\00"
@.str.6 = [18 x i8] c"%8d %4c %5x %13d\0A\00"
@.str.7 = [9 x i8] c"%8s%13d\0A\00"
@.str.8 = [6 x i8] c"TOTAL\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @fclose(i32* %1)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 0, i32 0, i32 undef)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 1, i32 1, i32 undef)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 2, i32 2, i32 2, i32 undef)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 3, i32 3, i32 3, i32 undef)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 4, i32 4, i32 4, i32 undef)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 5, i32 5, i32 5, i32 undef)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 6, i32 6, i32 6, i32 undef)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 7, i32 7, i32 7, i32 undef)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 8, i32 8, i32 8, i32 undef)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 9, i32 9, i32 9, i32 undef)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 undef)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}