#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 */

/* Variables and functions */
int /*<<< orphan*/ calculBarre(int, double);
int /*<<< orphan*/ printf(char *);
void calculHisto(int tableauLettres[]) {
  double sommeEtudiants;
  int i;
  for (i = 0; i < 12; i++) {
    sommeEtudiants += tableauLettres[i];
  }
  for (i = 11; i >= 0; i--) {
    switch (i) {
    case 11:
      printf("E     ");
      break;
    case 10:
      printf("D     ");
      break;
    case 9:
      printf("D+    ");
      break;
    case 8:
      printf("C-    ");
      break;
    case 7:
      printf("C     ");
      break;
    case 6:
      printf("C+    ");
      break;
    case 5:
      printf("B-    ");
      break;
    case 4:
      printf("B     ");
      break;
    case 3:
      printf("B+    ");
      break;
    case 2:
      printf("A-    ");
      break;
    case 1:
      printf("A     ");
      break;
    case 0:
      printf("A+    ");
      break;
    }
    calculBarre(tableauLettres[i], sommeEtudiants);
  }
}


x86 assembly (clang, -O0):
<calculHisto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    1162 <calculHisto+0x42>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <calculHisto+0x13>
movl   $0xb,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1282 <calculHisto+0x162>
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0xb,%rax
ja     125f <calculHisto+0x13f>
mov    -0x20(%rbp),%rax
lea    0xe71(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe2d(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <calculHisto+0x13f>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
movsd  -0x10(%rbp),%xmm0
call   1040 <calculBarre@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <calculHisto+0x49>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculHisto>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0xb,%ebx
lea    0xf28(%rip),%r15
jmp    1157 <calculHisto+0x37>
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,4),%edi
movsd  0xeb4(%rip),%xmm0
call   1040 <calculBarre@plt>
add    $0xffffffffffffffff,%rbx
jae    116a <calculHisto+0x4a>
cmp    $0xb,%ebx
ja     1140 <calculHisto+0x20>
movslq (%r15,%rbx,4),%rdi
add    %r15,%rdi
call   1030 <printf@plt>
jmp    1140 <calculHisto+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"E \00"
@.str.1 = [7 x i8] c"D \00"
@.str.2 = [7 x i8] c"D+ \00"
@.str.3 = [7 x i8] c"C- \00"
@.str.4 = [7 x i8] c"C \00"
@.str.5 = [7 x i8] c"C+ \00"
@.str.6 = [7 x i8] c"B- \00"
@.str.7 = [7 x i8] c"B \00"
@.str.8 = [7 x i8] c"B+ \00"
@.str.9 = [7 x i8] c"A- \00"
@.str.10 = [7 x i8] c"A \00"
@.str.11 = [7 x i8] c"A+ \00"
define void @calculHisto(i32* %0) {
%2 = alloca i32*
%3 = alloca double
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 12
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load i32*, i32** %2
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
%13 = load i32, i32* %12
%14 = sitofp i32 %13 to double
%15 = load double, double* %3
%16 = fadd double %15, %14
store double %16, double* %3
br label %17
17: ; preds = %8
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %5
20: ; preds = %5
store i32 11, i32* %4
br label %21
21: ; preds = %58, %20
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %61
24: ; preds = %21
%25 = load i32, i32* %4
switch i32 %25, label %50 [
i32 11, label %26
i32 10, label %28
i32 9, label %30
i32 8, label %32
i32 7, label %34
i32 6, label %36
i32 5, label %38
i32 4, label %40
i32 3, label %42
i32 2, label %44
i32 1, label %46
i32 0, label %48
]
26: ; preds = %24
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %50
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %50
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %50
32: ; preds = %24
%33 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %50
34: ; preds = %24
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %50
36: ; preds = %24
%37 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %50
38: ; preds = %24
%39 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %50
40: ; preds = %24
%41 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %50
42: ; preds = %24
%43 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %50
44: ; preds = %24
%45 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
br label %50
46: ; preds = %24
%47 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %50
48: ; preds = %24
%49 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %50
50: ; preds = %24, %48, %46, %44, %42, %40, %38, %36, %34, %32, %30, %28, %26
%51 = load i32*, i32** %2
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = load double, double* %3
%57 = call i32 @calculBarre(i32 %55, double %56)
br label %58
58: ; preds = %50
%59 = load i32, i32* %4
%60 = add nsw i32 %59, -1
store i32 %60, i32* %4
br label %21
61: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"E \00"
@.str.1 = [7 x i8] c"D \00"
@.str.2 = [7 x i8] c"D+ \00"
@.str.3 = [7 x i8] c"C- \00"
@.str.4 = [7 x i8] c"C \00"
@.str.5 = [7 x i8] c"C+ \00"
@.str.6 = [7 x i8] c"B- \00"
@.str.7 = [7 x i8] c"B \00"
@.str.8 = [7 x i8] c"B+ \00"
@.str.9 = [7 x i8] c"A- \00"
@.str.10 = [7 x i8] c"A \00"
@.str.11 = [7 x i8] c"A+ \00"
@reltable.calculHisto = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.3 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.calculHisto to i64)) to i32)]
define void @calculHisto(i32* nocapture %0) {
br label %2
2: ; preds = %1, %12
%3 = phi i64 [ 11, %1 ], [ %16, %12 ]
%4 = trunc i64 %3 to i32
%5 = icmp ult i32 %4, 12
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = shl i64 %3, 32
%8 = ashr exact i64 %7, 32
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.calculHisto to i8*), i64 %9)
%11 = tail call i32 @printf(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %2, %6
%13 = getelementptr inbounds i32, i32* %0, i64 %3
%14 = load i32, i32* %13
%15 = tail call i32 @calculBarre(i32 %14, double 0x7FF8000000000000)
%16 = add nsw i64 %3, -1
%17 = icmp eq i64 %3, 0
br i1 %17, label %18, label %2
18: ; preds = %12
ret void
}