#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char *argv[], char *env[]) {
  FILE *f = fopen(argv[1], "r+");
  if (f != NULL) {
    char c = fgetc(f);
    int T[256];
    int cpt = 0;
    for (int i = 0; i < 256; i++)
      T[i] = 0;
    while (c != EOF) {
      T[c]++;
      cpt++;
      c = fgetc(f);
    }
    int tot = 0;
    int nbchar = 0;
    for (int i = 0; i < 256; i++) {
      if (T[i] != 0)
        nbchar++;
      printf("%e ", (float)T[i] / cpt);
      tot += T[i];
    }
    printf("\nNombre de caractères : %i\nFréquence totale : %f\nNombre de "
           "caractères différents : %i\n",
           cpt, (float)tot / cpt, nbchar);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe94(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1307 <main+0x1c7>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x21(%rbp)
movl   $0x0,-0x434(%rbp)
movl   $0x0,-0x438(%rbp)
cmpl   $0x100,-0x438(%rbp)
jge    11d6 <main+0x96>
movslq -0x438(%rbp),%rax
movl   $0x0,-0x430(%rbp,%rax,4)
mov    -0x438(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x438(%rbp)
jmp    11a0 <main+0x60>
jmp    11db <main+0x9b>
movsbl -0x21(%rbp),%eax
mov    0x2e02(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1227 <main+0xe7>
movsbq -0x21(%rbp),%rax
mov    -0x430(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x430(%rbp,%rax,4)
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x21(%rbp)
jmp    11db <main+0x9b>
movl   $0x0,-0x43c(%rbp)
movl   $0x0,-0x440(%rbp)
movl   $0x0,-0x444(%rbp)
cmpl   $0x100,-0x444(%rbp)
jge    12d5 <main+0x195>
movslq -0x444(%rbp),%rax
cmpl   $0x0,-0x430(%rbp,%rax,4)
je     1279 <main+0x139>
mov    -0x440(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x440(%rbp)
movslq -0x444(%rbp),%rax
cvtsi2ssl -0x430(%rbp,%rax,4),%xmm0
ff ff
cvtsi2ssl -0x434(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x444(%rbp),%rax
mov    -0x430(%rbp,%rax,4),%eax
add    -0x43c(%rbp),%eax
mov    %eax,-0x43c(%rbp)
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    1245 <main+0x105>
mov    -0x434(%rbp),%esi
cvtsi2ssl -0x43c(%rbp),%xmm0
ff
cvtsi2ssl -0x434(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x440(%rbp),%edx
lea    0xd07(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    0x8(%rsi),%rdi
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1253 <main+0x103>
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    0x2e49(%rip),%r14
mov    $0x0,%r12d
cmp    (%r14),%bl
je     11cc <main+0x7c>
xor    %r12d,%r12d
nopl   (%rax)
movsbq %bl,%rax
addl   $0x1,0x10(%rsp,%rax,4)
add    $0x1,%r12d
mov    %rbp,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebx
cmp    (%r14),%al
jne    11b0 <main+0x60>
mov    %rbp,0x8(%rsp)
cvtsi2ss %r12d,%xmm0
movss  %xmm0,0x4(%rsp)
lea    0xe20(%rip),%r15
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbp,4),%r14d
cmp    $0x1,%r14d
sbb    $0xffffffff,%r13d
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
divss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    %r14d,%ebx
add    $0x1,%rbp
cmp    $0x100,%rbp
jne    11f0 <main+0xa0>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
divss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc6(%rip),%rdi
mov    %r12d,%esi
mov    %r13d,%edx
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@EOF = global i8 0
@.str.1 = [4 x i8] c"%e \00"
@.str.2 = [91 x i8] c"\0ANombre de caract\C3\A8res : %i\0AFr\C3\A9quence totale : %f\0ANombre de caract\C3\A8res diff\C3\A9rents : %i\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8
%10 = alloca [256 x i32]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%16 = load i8**, i8*** %6
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %8
%20 = load i32*, i32** %8
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %95
22: ; preds = %3
%23 = load i32*, i32** %8
%24 = call signext i8 @fgetc(i32* %23)
store i8 %24, i8* %9
store i32 0, i32* %11
store i32 0, i32* %12
br label %25
25: ; preds = %32, %22
%26 = load i32, i32* %12
%27 = icmp slt i32 %26, 256
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i32, i32* %12
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 %30
store i32 0, i32* %31
br label %32
32: ; preds = %28
%33 = load i32, i32* %12
%34 = add nsw i32 %33, 1
store i32 %34, i32* %12
br label %25
35: ; preds = %25
br label %36
36: ; preds = %42, %35
%37 = load i8, i8* %9
%38 = sext i8 %37 to i32
%39 = load i8, i8* @EOF
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %38, %40
br i1 %41, label %42, label %52
42: ; preds = %36
%43 = load i8, i8* %9
%44 = sext i8 %43 to i64
%45 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
store i32 %47, i32* %45
%48 = load i32, i32* %11
%49 = add nsw i32 %48, 1
store i32 %49, i32* %11
%50 = load i32*, i32** %8
%51 = call signext i8 @fgetc(i32* %50)
store i8 %51, i8* %9
br label %36
52: ; preds = %36
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
br label %53
53: ; preds = %82, %52
%54 = load i32, i32* %15
%55 = icmp slt i32 %54, 256
br i1 %55, label %56, label %85
56: ; preds = %53
%57 = load i32, i32* %15
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %56
%63 = load i32, i32* %14
%64 = add nsw i32 %63, 1
store i32 %64, i32* %14
br label %65
65: ; preds = %62, %56
%66 = load i32, i32* %15
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = sitofp i32 %69 to float
%71 = load i32, i32* %11
%72 = sitofp i32 %71 to float
%73 = fdiv float %70, %72
%74 = fptosi float %73 to i32
%75 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %74)
%76 = load i32, i32* %15
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [256 x i32], [256 x i32]* %10, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = load i32, i32* %13
%81 = add nsw i32 %80, %79
store i32 %81, i32* %13
br label %82
82: ; preds = %65
%83 = load i32, i32* %15
%84 = add nsw i32 %83, 1
store i32 %84, i32* %15
br label %53
85: ; preds = %53
%86 = load i32, i32* %11
%87 = load i32, i32* %13
%88 = sitofp i32 %87 to float
%89 = load i32, i32* %11
%90 = sitofp i32 %89 to float
%91 = fdiv float %88, %90
%92 = fpext float %91 to double
%93 = load i32, i32* %14
%94 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.2, i64 0, i64 0), i32 %86, double %92, i32 %93)
br label %95
95: ; preds = %85, %3
%96 = load i32*, i32** %8
%97 = call i32 @fclose(i32* %96)
%98 = load i32, i32* %4
ret i32 %98
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@EOF = global i8 0
@.str.1 = [4 x i8] c"%e \00"
@.str.2 = [91 x i8] c"\0ANombre de caract\C3\A8res : %i\0AFr\C3\A9quence totale : %f\0ANombre de caract\C3\A8res diff\C3\A9rents : %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca [256 x i32]
%5 = bitcast [256 x i32]* %4 to i8*
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %49, label %10
10: ; preds = %3
%11 = tail call signext i8 @fgetc(i32* %8)
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %17, %10
%15 = phi i32 [ 0, %10 ], [ %24, %17 ]
%16 = sitofp i32 %15 to float
br label %33
17: ; preds = %10, %17
%18 = phi i32 [ %24, %17 ], [ 0, %10 ]
%19 = phi i8 [ %25, %17 ], [ %11, %10 ]
%20 = sext i8 %19 to i64
%21 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
%24 = add nuw nsw i32 %18, 1
%25 = tail call signext i8 @fgetc(i32* %8)
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %25, %26
br i1 %27, label %14, label %17
28: ; preds = %33
%29 = sitofp i32 %46 to float
%30 = fdiv float %29, %16
%31 = fpext float %30 to double
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.2, i64 0, i64 0), i32 %15, double %31, i32 %41)
br label %49
33: ; preds = %14, %33
%34 = phi i64 [ 0, %14 ], [ %47, %33 ]
%35 = phi i32 [ 0, %14 ], [ %41, %33 ]
%36 = phi i32 [ 0, %14 ], [ %46, %33 ]
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %34
%38 = load i32, i32* %37
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i32
%41 = add nuw nsw i32 %35, %40
%42 = sitofp i32 %38 to float
%43 = fdiv float %42, %16
%44 = fptosi float %43 to i32
%45 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = add nsw i32 %38, %36
%47 = add nuw nsw i64 %34, 1
%48 = icmp eq i64 %47, 256
br i1 %48, label %28, label %33
49: ; preds = %28, %3
%50 = tail call i32 @fclose(i32* %8)
ret i32 0
}