#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  int n, i;
  char nombre[20], mejorNombre[20];
  int nota1, nota2, nota3;
  float prom, mejorProm;
  printf("Introduzca el numero de alumnos: ");
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    printf("Nombre del Alumno %d: ", i + 1);
    scanf("%s", nombre);
    printf("Las 3 notas de %s separadas por espacios: \n");
    scanf("%d %d %d", &nota1, &nota2, &nota3);
    prom = (nota1 + nota2 + nota3) / 3;
    if (prom > mejorProm) {
      mejorProm = prom;
      strcpy(mejorNombre, nombre);
    }
  }
  printf("\n\n=> El mejor promedio es de %s con promedio %.2f", mejorNombre,
         mejorProm);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf1a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1213 <main+0xe3>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x44(%rbp),%eax
add    -0x48(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
ucomiss -0x54(%rbp),%xmm0
jbe    1200 <main+0xd0>
movss  -0x50(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1205 <main+0xd5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x36>
lea    -0x40(%rbp),%rsi
movss  -0x54(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf1b(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    122e <main+0xfe>
lea    0x40(%rsp),%rbx
lea    0xef2(%rip),%r13
lea    0x1c(%rsp),%rbp
lea    0x18(%rsp),%r14
lea    0x14(%rsp),%r15
xor    %r12d,%r12d
jmp    119b <main+0x6b>
nopw   0x0(%rax,%rax,1)
cmp    0x10(%rsp),%r12d
jge    122e <main+0xfe>
add    $0x1,%r12d
lea    0xe7c(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x18(%rsp),%eax
add    0x1c(%rsp),%eax
add    0x14(%rsp),%eax
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
ucomiss 0xc(%rsp),%xmm0
jbe    1190 <main+0x60>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
movss  %xmm0,0xc(%rsp)
call   1030 <strcpy@plt>
jmp    1190 <main+0x60>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe32(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Introduzca el numero de alumnos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"Nombre del Alumno %d: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [44 x i8] c"Las 3 notas de %s separadas por espacios: \0A\00"
@.str.5 = [9 x i8] c"%d %d %d\00"
@.str.6 = [50 x i8] c"\0A\0A=> El mejor promedio es de %s con promedio %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = alloca [20 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %13
13: ; preds = %41, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %44
17: ; preds = %13
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* %6, i32* %7, i32* %8)
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = add nsw i32 %25, %26
%28 = load i32, i32* %8
%29 = add nsw i32 %27, %28
%30 = sdiv i32 %29, 3
%31 = sitofp i32 %30 to float
store float %31, float* %9
%32 = load float, float* %9
%33 = load float, float* %10
%34 = fcmp ogt float %32, %33
br i1 %34, label %35, label %40
35: ; preds = %17
%36 = load float, float* %9
store float %36, float* %10
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%39 = call i32 @strcpy(i8* %37, i8* %38)
br label %40
40: ; preds = %35, %17
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %13
44: ; preds = %13
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%46 = load float, float* %10
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %45, double %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Introduzca el numero de alumnos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"Nombre del Alumno %d: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [44 x i8] c"Las 3 notas de %s separadas por espacios: \0A\00"
@.str.5 = [9 x i8] c"%d %d %d\00"
@.str.6 = [50 x i8] c"\0A\0A=> El mejor promedio es de %s con promedio %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %1 to i8*
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %0, %35
%18 = phi float [ %36, %35 ], [ undef, %0 ]
%19 = phi i32 [ %20, %35 ], [ 0, %0 ]
%20 = add nuw nsw i32 %19, 1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = add nsw i32 %26, %25
%28 = load i32, i32* %6
%29 = add nsw i32 %27, %28
%30 = sdiv i32 %29, 3
%31 = sitofp i32 %30 to float
%32 = fcmp olt float %18, %31
br i1 %32, label %33, label %35
33: ; preds = %17
%34 = call i32 @strcpy(i8* %9, i8* %8)
br label %35
35: ; preds = %17, %33
%36 = phi float [ %31, %33 ], [ %18, %17 ]
%37 = load i32, i32* %1
%38 = icmp slt i32 %20, %37
br i1 %38, label %17, label %39
39: ; preds = %35, %0
%40 = phi float [ undef, %0 ], [ %36, %35 ]
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %9, double %41)
ret i32 0
}