#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 *, double, ...);
double promedio(double *, int);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  int i;
  double notas[4];
  for (i = 0; i < 4; i++) {
    printf("Ingrese nota %d/%d: ", i + 1, 4);
    scanf("%lf", &notas[i]);
  }
  printf("promedio=%f\n", promedio(notas, 4));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1196 <main+0x66>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
lea    0xe9f(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe92(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   1050 <promedio@plt>
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xee0(%rip),%r15
movsd  0xeb8(%rip),%xmm0
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
movsd  0xe94(%rip),%xmm0
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movsd  0xe78(%rip),%xmm0
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movsd  0xe5c(%rip),%xmm0
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1050 <promedio@plt>
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Ingrese nota %d/%d: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [13 x i8] c"promedio=%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x double]
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 4
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i32, i32* %2
%9 = add nsw i32 %8, 1
%10 = sitofp i32 %9 to double
%11 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %10, i32 4)
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %14)
br label %16
16: ; preds = %7
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %4
19: ; preds = %4
%20 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 0
%21 = call double @promedio(double* %20, i32 4)
%22 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Ingrese nota %d/%d: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [13 x i8] c"promedio=%f\0A\00"
define i32 @main() {
%1 = alloca [4 x double]
%2 = bitcast [4 x double]* %1 to i8*
%3 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double 1.000000e+00, i32 4)
%4 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%6 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double 2.000000e+00, i32 4)
%7 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 1
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %7)
%9 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double 3.000000e+00, i32 4)
%10 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 2
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %10)
%12 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double 4.000000e+00, i32 4)
%13 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 3
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %13)
%15 = call double @promedio(double* %4, i32 4)
%16 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %15)
ret i32 0
}