#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 */
scalar_t__ EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned char);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, unsigned char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ sort(int *);
int main() {
  unsigned char bytes;
  FILE *pFile, *newFile;
  pFile = fopen("musicIn.mp3", "rb");
  newFile = fopen("musicOut.mp3", "w");
  int freq[255], i;
  for (i = 0; i < 256; i++)
    freq[i] = 0;
  int soma = 0;
  while (fscanf(pFile, "%c", &bytes) != EOF) {
    fprintf(newFile, "%c", bytes);
    freq[bytes]++;
    soma++;
  }
  sort(freq);
  for (i = 0; i < 256; i++)
    if (freq[i] != 0)
      printf("%c ~~ %d\n", i, freq[i]);
  printf("Total de Bytes: %d\n", soma);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8f(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x424(%rbp)
cmpl   $0x100,-0x424(%rbp)
jge    11d0 <main+0x80>
movslq -0x424(%rbp),%rax
movl   $0x0,-0x420(%rbp,%rax,4)
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    119a <main+0x4a>
movl   $0x0,-0x428(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe39(%rip),%rsi
lea    -0x5(%rbp),%rdx
call   1050 <fscanf@plt>
mov    0x2df3(%rip),%rcx
cmp    (%rcx),%rax
je     123b <main+0xeb>
mov    -0x18(%rbp),%rdi
lea    0xe15(%rip),%rsi
movzbl -0x5(%rbp),%edx
call   1060 <fprintf@plt>
movzbl -0x5(%rbp),%eax
mov    -0x420(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x420(%rbp,%rax,4)
mov    -0x428(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x428(%rbp)
jmp    11da <main+0x8a>
lea    -0x420(%rbp),%rdi
call   1040 <sort@plt>
movl   $0x0,-0x424(%rbp)
cmpl   $0x100,-0x424(%rbp)
jge    12b1 <main+0x161>
movslq -0x424(%rbp),%rax
cmpl   $0x0,-0x420(%rbp,%rax,4)
je     1298 <main+0x148>
mov    -0x424(%rbp),%esi
movslq -0x424(%rbp),%rax
mov    -0x420(%rbp,%rax,4),%edx
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129d <main+0x14d>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    1251 <main+0x101>
mov    -0x428(%rbp),%esi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
lea    0xe88(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe81(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0x10(%rsp),%rdi
xor    %ebp,%ebp
mov    $0x400,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe67(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %r14,%rdi
call   1060 <fscanf@plt>
mov    0x2e1d(%rip),%rbx
cmp    (%rbx),%rax
je     120d <main+0xad>
xor    %ebp,%ebp
lea    0xe45(%rip),%r12
lea    0xf(%rsp),%r13
xchg   %ax,%ax
movsbl 0xf(%rsp),%edi
mov    %r15,%rsi
call   1070 <fputc@plt>
movzbl 0xf(%rsp),%eax
addl   $0x1,0x10(%rsp,%rax,4)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <fscanf@plt>
cmp    (%rbx),%rax
jne    11e0 <main+0x80>
lea    0x10(%rsp),%rdi
call   1040 <sort@plt>
lea    0xe03(%rip),%r14
xor    %ebx,%ebx
jmp    123d <main+0xdd>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x100,%rbx
je     1253 <main+0xf3>
mov    0x10(%rsp,%rbx,4),%edx
test   %edx,%edx
je     1230 <main+0xd0>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1230 <main+0xd0>
lea    0xdd1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"musicIn.mp3\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [13 x i8] c"musicOut.mp3\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%c\00"
@EOF = global i64 0
@.str.5 = [10 x i8] c"%c ~~ %d\0A\00"
@.str.6 = [20 x i8] c"Total de Bytes: %d\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [255 x i32]
%3 = bitcast [255 x i32]* %2 to i8*
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%6 = call i64 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %23, label %9
9: ; preds = %0, %9
%10 = phi i32 [ %19, %9 ], [ 0, %0 ]
%11 = load i8, i8* %1
%12 = sext i8 %11 to i32
%13 = call i32 @fputc(i32 %12, i32* %5)
%14 = load i8, i8* %1
%15 = zext i8 %14 to i64
%16 = getelementptr inbounds [255 x i32], [255 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
%19 = add nuw nsw i32 %10, 1
%20 = call i64 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%21 = load i64, i64* @EOF
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %9
23: ; preds = %9, %0
%24 = phi i32 [ 0, %0 ], [ %19, %9 ]
%25 = getelementptr inbounds [255 x i32], [255 x i32]* %2, i64 0, i64 0
%26 = call i32 @sort(i32* %25)
br label %27
27: ; preds = %23, %35
%28 = phi i64 [ 0, %23 ], [ %36, %35 ]
%29 = getelementptr inbounds [255 x i32], [255 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %27
%33 = trunc i64 %28 to i32
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 %30)
br label %35
35: ; preds = %27, %32
%36 = add nuw nsw i64 %28, 1
%37 = icmp eq i64 %36, 256
br i1 %37, label %38, label %27
38: ; preds = %35
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %24)
ret i32 0
}