#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf_s(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int i;
  int N;
  int *vector;
  printf("Dame un valor para N: ");
  scanf_s("%i", &N);
  vector = (int *)malloc(N * sizeof(int));
  if (vector == NULL) {
    printf("No se ha podido reservar la memoria.\n");
  } else {
    for (i = 0; i < N; i++) {
      *(vector + i) = i;
    }
    for (i = 0; i < N; i++) {
      printf("%i ", *(vector + i));
    }
    printf("\n");
    printf("Dame otro valor para N: ");
    scanf_s("%i", &N);
    vector = (int *)malloc(N * sizeof(int));
    if (vector == NULL) {
      printf("No se ha podido reservar la memoria.\n");
    } else {
      for (i = 0; i < N; i++) {
        *(vector + i) = i;
      }
      for (i = 0; i < N; i++) {
        printf("%i ", *(vector + i));
      }
      printf("\n");
    }
  }
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf_s@plt>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119e <main+0x5e>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e0 <main+0x1a0>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <main+0x8d>
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a5 <main+0x65>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1207 <main+0xc7>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d4 <main+0x94>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xded(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf_s@plt>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1264 <main+0x124>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12db <main+0x19b>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1293 <main+0x153>
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    126b <main+0x12b>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12cd <main+0x18d>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    129a <main+0x15a>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e0 <main+0x1a0>
lea    0xd76(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe99(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf_s@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1288 <main+0x128>
cmpl   $0x0,0xc(%rsp)
jle    11ec <main+0x8c>
mov    %rax,%r15
xor    %eax,%eax
nopl   0x0(%rax)
mov    %eax,(%r15,%rax,4)
add    $0x1,%rax
movslq 0xc(%rsp),%rcx
cmp    %rcx,%rax
jl     11b0 <main+0x50>
test   %ecx,%ecx
jle    11ec <main+0x8c>
lea    0xe4d(%rip),%r14
xor    %ebx,%ebx
nop
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11d0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe0c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf_s@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1288 <main+0x128>
cmpl   $0x0,0xc(%rsp)
jle    127c <main+0x11c>
mov    %rax,%r15
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,(%r15,%rax,4)
add    $0x1,%rax
movslq 0xc(%rsp),%rcx
cmp    %rcx,%rax
jl     1240 <main+0xe0>
test   %ecx,%ecx
jle    127c <main+0x11c>
lea    0xdbd(%rip),%r14
xor    %ebx,%ebx
nop
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1260 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1294 <main+0x134>
lea    0xdae(%rip),%rdi
call   1040 <puts@plt>
lea    0xd9c(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Dame un valor para N: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [38 x i8] c"No se ha podido reservar la memoria.\0A\00"
@.str.3 = [4 x i8] c"%i \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [25 x i8] c"Dame otro valor para N: \00"
@.str.6 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 4
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %92
17: ; preds = %0
store i32 0, i32* %2
br label %18
18: ; preds = %28, %17
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %2
%24 = load i32*, i32** %4
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
store i32 %23, i32* %27
br label %28
28: ; preds = %22
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %18
31: ; preds = %18
store i32 0, i32* %2
br label %32
32: ; preds = %43, %31
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = load i32*, i32** %4
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %36
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %32
46: ; preds = %32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%49 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = mul i64 %51, 4
%53 = trunc i64 %52 to i32
%54 = call i64 @malloc(i32 %53)
%55 = inttoptr i64 %54 to i32*
store i32* %55, i32** %4
%56 = load i32*, i32** %4
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %60
58: ; preds = %46
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %91
60: ; preds = %46
store i32 0, i32* %2
br label %61
61: ; preds = %71, %60
%62 = load i32, i32* %2
%63 = load i32, i32* %3
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %74
65: ; preds = %61
%66 = load i32, i32* %2
%67 = load i32*, i32** %4
%68 = load i32, i32* %2
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
store i32 %66, i32* %70
br label %71
71: ; preds = %65
%72 = load i32, i32* %2
%73 = add nsw i32 %72, 1
store i32 %73, i32* %2
br label %61
74: ; preds = %61
store i32 0, i32* %2
br label %75
75: ; preds = %86, %74
%76 = load i32, i32* %2
%77 = load i32, i32* %3
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %89
79: ; preds = %75
%80 = load i32*, i32** %4
%81 = load i32, i32* %2
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %80, i64 %82
%84 = load i32, i32* %83
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %79
%87 = load i32, i32* %2
%88 = add nsw i32 %87, 1
store i32 %88, i32* %2
br label %75
89: ; preds = %75
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %91
91: ; preds = %89, %58
br label %92
92: ; preds = %91, %15
%93 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Dame un valor para N: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.3 = [4 x i8] c"%i \00"
@.str.5 = [25 x i8] c"Dame otro valor para N: \00"
@.str.6 = [6 x i8] c"pause\00"
@str.7 = [37 x i8] c"No se ha podido reservar la memoria.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = shl i32 %5, 2
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = icmp eq i64 %7, 0
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %17, label %34
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %69
15: ; preds = %17
%16 = icmp sgt i32 %22, 0
br i1 %16, label %25, label %34
17: ; preds = %10, %17
%18 = phi i64 [ %21, %17 ], [ 0, %10 ]
%19 = getelementptr inbounds i32, i32* %8, i64 %18
%20 = trunc i64 %18 to i32
store i32 %20, i32* %19
%21 = add nuw nsw i64 %18, 1
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %17, label %15
25: ; preds = %15, %25
%26 = phi i64 [ %30, %25 ], [ 0, %15 ]
%27 = getelementptr inbounds i32, i32* %8, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = add nuw nsw i64 %26, 1
%31 = load i32, i32* %1
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %25, label %34
34: ; preds = %25, %10, %15
%35 = call i32 @putchar(i32 10)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%38 = load i32, i32* %1
%39 = shl i32 %38, 2
%40 = call i64 @malloc(i32 %39)
%41 = inttoptr i64 %40 to i32*
%42 = icmp eq i64 %40, 0
br i1 %42, label %46, label %43
43: ; preds = %34
%44 = load i32, i32* %1
%45 = icmp sgt i32 %44, 0
br i1 %45, label %50, label %67
46: ; preds = %34
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %69
48: ; preds = %50
%49 = icmp sgt i32 %55, 0
br i1 %49, label %58, label %67
50: ; preds = %43, %50
%51 = phi i64 [ %54, %50 ], [ 0, %43 ]
%52 = getelementptr inbounds i32, i32* %41, i64 %51
%53 = trunc i64 %51 to i32
store i32 %53, i32* %52
%54 = add nuw nsw i64 %51, 1
%55 = load i32, i32* %1
%56 = sext i32 %55 to i64
%57 = icmp slt i64 %54, %56
br i1 %57, label %50, label %48
58: ; preds = %48, %58
%59 = phi i64 [ %63, %58 ], [ 0, %48 ]
%60 = getelementptr inbounds i32, i32* %41, i64 %59
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%63 = add nuw nsw i64 %59, 1
%64 = load i32, i32* %1
%65 = sext i32 %64 to i64
%66 = icmp slt i64 %63, %65
br i1 %66, label %58, label %67
67: ; preds = %58, %43, %48
%68 = call i32 @putchar(i32 10)
br label %69
69: ; preds = %46, %67, %13
%70 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}