#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 *);
void leer(int *arr) {
  printf("Leyendo %d datos en el arreglo.\n\n", 5);
  for (int i = 0; i < 5; i++) {
    printf("Introduce el valor para la posición #%d: ", i + 1);
    scanf("%d", arr + i);
  }
  printf("Se leyeron %d datos correctamente.\n", 5);
}


x86 assembly (clang, -O0):
<leer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    1189 <leer+0x69>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xed7(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1144 <leer+0x24>
lea    0xec0(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leer>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xed1(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
lea    0xee2(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0xef9(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
lea    0x4(%rbx),%rsi
mov    %r15,%rdi
call   1040 <scanf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
lea    0x8(%rbx),%rsi
mov    %r15,%rdi
call   1040 <scanf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
lea    0xc(%rbx),%rsi
mov    %r15,%rdi
call   1040 <scanf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
add    $0x10,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xe83(%rip),%rdi
mov    $0x5,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"Leyendo %d datos en el arreglo.\0A\0A\00"
@.str.1 = [43 x i8] c"Introduce el valor para la posici\C3\B3n #%d: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [36 x i8] c"Se leyeron %d datos correctamente.\0A\00"
define void @leer(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 5)
store i32 0, i32* %3
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
%11 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32*, i32** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %15)
br label %17
17: ; preds = %8
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %5
20: ; preds = %5
%21 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 5)
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"Leyendo %d datos en el arreglo.\0A\0A\00"
@.str.1 = [43 x i8] c"Introduce el valor para la posici\C3\B3n #%d: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [36 x i8] c"Se leyeron %d datos correctamente.\0A\00"
define void @leer(i32* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 5)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 2)
%6 = getelementptr inbounds i32, i32* %0, i64 1
%7 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 3)
%9 = getelementptr inbounds i32, i32* %0, i64 2
%10 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 4)
%12 = getelementptr inbounds i32, i32* %0, i64 3
%13 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 5)
%15 = getelementptr inbounds i32, i32* %0, i64 4
%16 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %15)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 5)
ret void
}