#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 */
float calcular_nota();
int /*<<< orphan*/ generar_respuestas_correctas();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i, j;
  float nota;
  int aprobados = 0, suspensos = 0;
  float nota_media = 0, nota_max = 0, nota_min = 10;
  generar_respuestas_correctas();
  for (i = 0; i < 50000; i++) {
    nota = calcular_nota();
    nota_media = nota_media + nota;
    if (nota_max < nota)
      nota_max = nota;
    if (nota_min > nota)
      nota_min = nota;
    if (nota >= 5)
      aprobados++;
    else
      suspensos++;
  }
  printf("\nSe ha hecho el examen %d veces, y los resultados son:\n", 50000);
  printf("\nLa nota máxima es: %0.3f", nota_max);
  printf("\nLa nota mínima es: %0.3f", nota_min);
  printf("\nLa nota media es: %0.3f", nota_media / 50000);
  printf("\nHa suspendido %d veces, lo que supone el %0.2f%%.", suspensos,
         (float)suspensos * 100 / 50000);
  printf("\nHa aprobado %d veces, lo que supone el %0.2f%%.", aprobados,
         (float)aprobados * 100 / 50000);
  printf("\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe9b(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    $0x0,%al
call   1050 <generar_respuestas_correctas@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xc350,-0x8(%rbp)
jge    1216 <main+0xe6>
mov    $0x0,%al
call   1040 <calcular_nota@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x20(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11bd <main+0x8d>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x24(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11d6 <main+0xa6>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe29(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11fa <main+0xca>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1203 <main+0xd3>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1208 <main+0xd8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1178 <main+0x48>
lea    0xdf3(%rip),%rdi
mov    $0xc350,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe13(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
movss  0xda0(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
cvtsi2ssl -0x18(%rbp),%xmm0
movss  0xd7e(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xd6e(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
cvtsi2ssl -0x14(%rbp),%xmm0
movss  0xd4c(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xd3c(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1060 <generar_respuestas_correctas@plt>
xorps  %xmm2,%xmm2
movss  0xea6(%rip),%xmm1
mov    $0xc350,%ebx
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %ebp,%ebp
xor    %r14d,%r14d
nopl   (%rax)
movss  %xmm2,0x4(%rsp)
movss  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   1050 <calcular_nota@plt>
movaps %xmm0,%xmm1
movss  0xe76(%rip),%xmm0
ucomiss %xmm0,%xmm1
sbb    $0xffffffff,%r14d
ucomiss %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movaps %xmm1,%xmm2
maxss  0x4(%rsp),%xmm2
minss  0x8(%rsp),%xmm1
adc    $0x0,%ebp
add    $0xffffffff,%ebx
jne    1170 <main+0x30>
lea    0xe4a(%rip),%rdi
mov    $0xc350,%esi
xor    %eax,%eax
movss  %xmm1,0x8(%rsp)
movss  %xmm2,0x4(%rsp)
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
divss  0xdec(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe57(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mulss  0xdcf(%rip),%xmm0
divss  0xdc3(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe47(%rip),%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
mulss  0xda3(%rip),%xmm0
divss  0xd97(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4e(%rip),%rdi
mov    %r14d,%esi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"\0ASe ha hecho el examen %d veces, y los resultados son:\0A\00"
@.str.1 = [27 x i8] c"\0ALa nota m\C3\A1xima es: %0.3f\00"
@.str.2 = [27 x i8] c"\0ALa nota m\C3\ADnima es: %0.3f\00"
@.str.3 = [25 x i8] c"\0ALa nota media es: %0.3f\00"
@.str.4 = [51 x i8] c"\0AHa suspendido %d veces, lo que supone el %0.2f%%.\00"
@.str.5 = [49 x i8] c"\0AHa aprobado %d veces, lo que supone el %0.2f%%.\00"
@.str.6 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %8
store float 1.000000e+01, float* %9
%10 = call i32 (...) @generar_respuestas_correctas()
store i32 0, i32* %2
br label %11
11: ; preds = %40, %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 50000
br i1 %13, label %14, label %43
14: ; preds = %11
%15 = call float (...) @calcular_nota()
store float %15, float* %4
%16 = load float, float* %7
%17 = load float, float* %4
%18 = fadd float %16, %17
store float %18, float* %7
%19 = load float, float* %8
%20 = load float, float* %4
%21 = fcmp olt float %19, %20
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = load float, float* %4
store float %23, float* %8
br label %24
24: ; preds = %22, %14
%25 = load float, float* %9
%26 = load float, float* %4
%27 = fcmp ogt float %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load float, float* %4
store float %29, float* %9
br label %30
30: ; preds = %28, %24
%31 = load float, float* %4
%32 = fcmp oge float %31, 5.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %39
36: ; preds = %30
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %39
39: ; preds = %36, %33
br label %40
40: ; preds = %39
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %11
43: ; preds = %11
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 50000)
%45 = load float, float* %8
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %46)
%48 = load float, float* %9
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %49)
%51 = load float, float* %7
%52 = fdiv float %51, 5.000000e+04
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %53)
%55 = load i32, i32* %6
%56 = load i32, i32* %6
%57 = sitofp i32 %56 to float
%58 = fmul float %57, 1.000000e+02
%59 = fdiv float %58, 5.000000e+04
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %55, double %60)
%62 = load i32, i32* %5
%63 = load i32, i32* %5
%64 = sitofp i32 %63 to float
%65 = fmul float %64, 1.000000e+02
%66 = fdiv float %65, 5.000000e+04
%67 = fpext float %66 to double
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i32 %62, double %67)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%70 = load i32, i32* %1
ret i32 %70
}

LLVM IR (-O2):
@.str = [56 x i8] c"\0ASe ha hecho el examen %d veces, y los resultados son:\0A\00"
@.str.1 = [27 x i8] c"\0ALa nota m\C3\A1xima es: %0.3f\00"
@.str.2 = [27 x i8] c"\0ALa nota m\C3\ADnima es: %0.3f\00"
@.str.3 = [25 x i8] c"\0ALa nota media es: %0.3f\00"
@.str.4 = [51 x i8] c"\0AHa suspendido %d veces, lo que supone el %0.2f%%.\00"
@.str.5 = [49 x i8] c"\0AHa aprobado %d veces, lo que supone el %0.2f%%.\00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @generar_respuestas_correctas()
br label %2
2: ; preds = %0, %2
%3 = phi float [ 1.000000e+01, %0 ], [ %14, %2 ]
%4 = phi float [ 0.000000e+00, %0 ], [ %12, %2 ]
%5 = phi float [ 0.000000e+00, %0 ], [ %10, %2 ]
%6 = phi i32 [ 0, %0 ], [ %20, %2 ]
%7 = phi i32 [ 0, %0 ], [ %18, %2 ]
%8 = phi i32 [ 0, %0 ], [ %21, %2 ]
%9 = tail call float (...) @calcular_nota()
%10 = fadd float %5, %9
%11 = fcmp olt float %4, %9
%12 = select i1 %11, float %9, float %4
%13 = fcmp ogt float %3, %9
%14 = select i1 %13, float %9, float %3
%15 = fcmp ult float %9, 5.000000e+00
%16 = xor i1 %15, true
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %7, %17
%19 = zext i1 %15 to i32
%20 = add nuw nsw i32 %6, %19
%21 = add nuw nsw i32 %8, 1
%22 = icmp eq i32 %21, 50000
br i1 %22, label %23, label %2
23: ; preds = %2
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 50000)
%25 = fpext float %12 to double
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = fpext float %14 to double
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = fdiv float %10, 5.000000e+04
%30 = fpext float %29 to double
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %30)
%32 = sitofp i32 %20 to float
%33 = fmul float %32, 1.000000e+02
%34 = fdiv float %33, 5.000000e+04
%35 = fpext float %34 to double
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %20, double %35)
%37 = sitofp i32 %18 to float
%38 = fmul float %37, 1.000000e+02
%39 = fdiv float %38, 5.000000e+04
%40 = fpext float %39 to double
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i32 %18, double %40)
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}