#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 *);
int vectordereales() {
  int vector[50];
  int num = 0;
  int i = 0;
  int j = 0;
  int sum = 0;
  printf("Ingrese un valor");
  scanf("%d", &num);
  while (num != -1 && i < 50) {
    vector[i] = num;
    sum = sum + vector[i];
    i = i + 1;
    scanf("%d", &num);
  }
  for (j = 0; j < i; j++) {
    printf("%d\n", vector[j]);
  }
  return i;
}


x86 assembly (clang, -O0):
<vectordereales>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
movl   $0x0,-0xdc(%rbp)
movl   $0x0,-0xe0(%rbp)
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0xd4(%rbp),%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0xffffffff,-0xd4(%rbp)
mov    %al,-0xe1(%rbp)
je     1199 <vectordereales+0x79>
cmpl   $0x32,-0xd8(%rbp)
setl   %al
mov    %al,-0xe1(%rbp)
mov    -0xe1(%rbp),%al
test   $0x1,%al
jne    11ac <vectordereales+0x8c>
jmp    1201 <vectordereales+0xe1>
mov    -0xd4(%rbp),%ecx
movslq -0xd8(%rbp),%rax
mov    %ecx,-0xd0(%rbp,%rax,4)
mov    -0xe0(%rbp),%eax
movslq -0xd8(%rbp),%rcx
add    -0xd0(%rbp,%rcx,4),%eax
mov    %eax,-0xe0(%rbp)
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
lea    0xe21(%rip),%rdi
lea    -0xd4(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1174 <vectordereales+0x54>
movl   $0x0,-0xdc(%rbp)
mov    -0xdc(%rbp),%eax
cmp    -0xd8(%rbp),%eax
jge    124d <vectordereales+0x12d>
movslq -0xdc(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    120b <vectordereales+0xeb>
mov    -0xd8(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectordereales>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
movl   $0x0,0xc(%rsp)
lea    0xec3(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     11c7 <vectordereales+0xa7>
xor    %ebx,%ebx
lea    0xea7(%rip),%r14
lea    0xc(%rsp),%r15
nop
mov    %eax,0x10(%rsp,%rbx,4)
lea    0x1(%rbx),%r12
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     1195 <vectordereales+0x75>
cmp    $0x31,%rbx
mov    %r12,%rbx
jb     1170 <vectordereales+0x50>
lea    -0x1(%r12),%r15
mov    $0xffffffffffffffff,%rbx
lea    0xe6c(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    0x14(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11b0 <vectordereales+0x90>
mov    %r12d,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Ingrese un valor\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @vectordereales() {
%1 = alloca [50 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %16, %0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 50
br label %14
14: ; preds = %11, %8
%15 = phi i1 [ false, %8 ], [ %13, %11 ]
br i1 %15, label %16, label %30
16: ; preds = %14
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %19
store i32 %17, i32* %20
%21 = load i32, i32* %5
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = add nsw i32 %21, %25
store i32 %26, i32* %5
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
30: ; preds = %14
store i32 0, i32* %4
br label %31
31: ; preds = %41, %30
%32 = load i32, i32* %4
%33 = load i32, i32* %3
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %44
35: ; preds = %31
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %35
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %31
44: ; preds = %31
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [17 x i8] c"Ingrese un valor\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @vectordereales() {
%1 = alloca [50 x i32]
%2 = alloca i32
%3 = bitcast [50 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, -1
br i1 %8, label %29, label %12
9: ; preds = %12
%10 = trunc i64 %16 to i32
%11 = and i64 %16, 4294967295
br label %22
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = phi i32 [ %18, %12 ], [ %7, %0 ]
%15 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %13
store i32 %14, i32* %15
%16 = add nuw nsw i64 %13, 1
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, -1
%20 = icmp ult i64 %13, 49
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %12, label %9
22: ; preds = %9, %22
%23 = phi i64 [ 0, %9 ], [ %27, %22 ]
%24 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i64 %23, 1
%28 = icmp eq i64 %27, %11
br i1 %28, label %29, label %22
29: ; preds = %22, %0
%30 = phi i32 [ 0, %0 ], [ %10, %22 ]
ret i32 %30
}