#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*/ desplegarArreglo();
int maximo(int const **, int, int);
int minimo(int const **, int, int);
int /*<<< orphan*/ printf(char *, ...);
double promedio(int const *, int);
int main() {
  int estudiante;
  const int calificacionesEstudiantes[3][4] = {
      {80, 90, 60, 50}, {45, 70, 89, 96}, {90, 87, 76, 89}};
  printf("el arreglo : ");
  desplegarArreglo();
  printf("la calificacion mas baja es %d\n la calificacion mas alta es : %d\n",
         minimo(calificacionesEstudiantes, 3, 4),
         maximo(calificacionesEstudiantes, 3, 4));
  printf("promedio de cada estudiante: \n");
  for (estudiante = 0; estudiante < 3; estudiante++) {
    printf("el promedio del estdiante %d es: %.2f\n", estudiante,
           promedio(calificacionesEstudiantes[estudiante], 4));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <desplegarArreglo@plt>
lea    -0x40(%rbp),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1040 <minimo@plt>
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1060 <maximo@plt>
mov    -0x44(%rbp),%esi
mov    %eax,%edx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1232 <main+0xd2>
mov    -0x8(%rbp),%eax
mov    %eax,-0x48(%rbp)
movslq -0x8(%rbp),%rax
lea    -0x40(%rbp),%rdi
shl    $0x4,%rax
add    %rax,%rdi
mov    $0x4,%esi
call   1080 <promedio@plt>
mov    -0x48(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ea <main+0x8a>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe77(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <desplegarArreglo@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1050 <minimo@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1060 <maximo@plt>
lea    0xe62(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1080 <promedio@plt>
lea    0xe79(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r15,%rdi
mov    $0x4,%esi
call   1080 <promedio@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1080 <promedio@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.calificacionesEstudiantes = [3 x [4 x i32]] [[4 x i32] [i32 80, i32 90, i32 60, i32 50], [4 x i32] [i32 45, i32 70, i32 89, i32 96], [4 x i32] [i32 90, i32 87, i32 76, i32 89]]
@.str = [14 x i8] c"el arreglo : \00"
@.str.1 = [66 x i8] c"la calificacion mas baja es %d\0A la calificacion mas alta es : %d\0A\00"
@.str.2 = [31 x i8] c"promedio de cada estudiante: \0A\00"
@.str.3 = [39 x i8] c"el promedio del estdiante %d es: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [3 x [4 x i32]]
store i32 0, i32* %1
%4 = bitcast [3 x [4 x i32]]* %3 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @desplegarArreglo()
%7 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %3, i64 0, i64 0
%8 = bitcast [4 x i32]* %7 to i32**
%9 = call i32 @minimo(i32** %8, i32 3, i32 4)
%10 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %3, i64 0, i64 0
%11 = bitcast [4 x i32]* %10 to i32**
%12 = call i32 @maximo(i32** %11, i32 3, i32 4)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %15
15: ; preds = %26, %0
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %3, i64 0, i64 %21
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %22, i64 0, i64 0
%24 = call double @promedio(i32* %23, i32 4)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %19, double %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %15
29: ; preds = %15
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@__const.main.calificacionesEstudiantes = [3 x [4 x i32]] [[4 x i32] [i32 80, i32 90, i32 60, i32 50], [4 x i32] [i32 45, i32 70, i32 89, i32 96], [4 x i32] [i32 90, i32 87, i32 76, i32 89]]
@.str = [14 x i8] c"el arreglo : \00"
@.str.1 = [66 x i8] c"la calificacion mas baja es %d\0A la calificacion mas alta es : %d\0A\00"
@.str.3 = [39 x i8] c"el promedio del estdiante %d es: %.2f\0A\00"
@str = [30 x i8] c"promedio de cada estudiante: \00"
define i32 @main() {
%1 = alloca [3 x [4 x i32]]
%2 = bitcast [3 x [4 x i32]]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @desplegarArreglo()
%5 = bitcast [3 x [4 x i32]]* %1 to i32**
%6 = call i32 @minimo(i32** %5, i32 3, i32 4)
%7 = call i32 @maximo(i32** %5, i32 3, i32 4)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%10 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 0, i64 0
%11 = call double @promedio(i32* %10, i32 4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 0, double %11)
%13 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 1, i64 0
%14 = call double @promedio(i32* %13, i32 4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 1, double %14)
%16 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 2, i64 0
%17 = call double @promedio(i32* %16, i32 4)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 2, double %17)
ret i32 0
}