#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);
int /*<<< orphan*/ scanf(char *, int *);
int promedio(int x) {
  int i, marks[10], prom, sum = 0;
  for (i = 0; i < x; ++i) {
    printf("Ingrese un numero%i: ", i + 1);
    scanf("%d", &marks[i]);
    sum += marks[i];
  }
  prom = sum / x;
  printf("Promedio = %d\n", prom);
  return 0;
}


x86 assembly (clang, -O0):
<promedio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118e <promedio+0x6e>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xea9(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <promedio+0x19>
mov    -0x38(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<promedio>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %edi,%edi
mov    %edi,0xc(%rsp)
jle    1188 <promedio+0x68>
mov    %edi,%r14d
xor    %ebx,%ebx
lea    0x10(%rsp),%rbp
lea    0xeb9(%rip),%r12
lea    0xec8(%rip),%r13
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
add    0x0(%rbp),%r15d
add    $0x4,%rbp
cmp    %rbx,%r14
jne    1160 <promedio+0x40>
jmp    118b <promedio+0x6b>
xor    %r15d,%r15d
mov    %r15d,%eax
cltd
idivl  0xc(%rsp)
lea    0xe7f(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Ingrese un numero%i: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Promedio = %d\0A\00"
define i32 @promedio(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %6
store i32 0, i32* %3
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %28
11: ; preds = %7
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* %6
%24 = add nsw i32 %23, %22
store i32 %24, i32* %6
br label %25
25: ; preds = %11
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %7
28: ; preds = %7
%29 = load i32, i32* %6
%30 = load i32, i32* %2
%31 = sdiv i32 %29, %30
store i32 %31, i32* %5
%32 = load i32, i32* %5
%33 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Ingrese un numero%i: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Promedio = %d\0A\00"
define i32 @promedio(i32 %0) {
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %2 to i8*
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %18
5: ; preds = %1
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %10, %7 ]
%9 = phi i32 [ 0, %5 ], [ %16, %7 ]
%10 = add nuw nsw i64 %8, 1
%11 = trunc i64 %10 to i32
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %8
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = load i32, i32* %13
%16 = add nsw i32 %15, %9
%17 = icmp eq i64 %10, %6
br i1 %17, label %18, label %7
18: ; preds = %7, %1
%19 = phi i32 [ 0, %1 ], [ %16, %7 ]
%20 = sdiv i32 %19, %0
%21 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %20)
ret i32 0
}