#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int size;
  printf("Give di size of the array: ");
  scanf("%d", &size);
  int vec[size];
  printf("Initialize an array of %d elements:\n", size);
  for (int i = 0; i < size; i++) {
    printf("\tvector[%d]: ", i);
    scanf("%d", &vec[i]);
  }
  printf("Print each element:\n");
  for (int j = 0; j < size; j++)
    printf("\tvec[%d] = %d\n", j, vec[j]);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d2 <main+0xb2>
mov    -0x1c(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5d(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118c <main+0x6c>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121d <main+0xfd>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%esi
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e7 <main+0xc7>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%esi
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11d8 <main+0xa8>
lea    0xeab(%rip),%r14
lea    0xe7c(%rip),%r15
mov    %r13,%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     11b0 <main+0x80>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    121e <main+0xee>
lea    0xe61(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,4),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1200 <main+0xd0>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Give di size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"Initialize an array of %d elements:\0A\00"
@.str.3 = [14 x i8] c"\09vector[%d]: \00"
@.str.4 = [21 x i8] c"Print each element:\0A\00"
@.str.5 = [15 x i8] c"\09vec[%d] = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca i32, i64 %10
store i64 %10, i64* %4
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %13)
store i32 0, i32* %5
br label %15
15: ; preds = %26, %0
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %29
19: ; preds = %15
%20 = load i32, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %12, i64 %23
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %15
29: ; preds = %15
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %6
br label %31
31: ; preds = %42, %29
%32 = load i32, i32* %6
%33 = load i32, i32* %2
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %45
35: ; preds = %31
%36 = load i32, i32* %6
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %12, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %36, i32 %40)
br label %42
42: ; preds = %35
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %31
45: ; preds = %31
%46 = load i32, i32* @EXIT_SUCCESS
store i32 %46, i32* %1
%47 = load i8*, i8** %3
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [28 x i8] c"Give di size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"Initialize an array of %d elements:\0A\00"
@.str.3 = [14 x i8] c"\09vector[%d]: \00"
@.str.5 = [15 x i8] c"\09vec[%d] = %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [20 x i8] c"Print each element:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = load i32, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %17, %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %29, label %27
17: ; preds = %0, %17
%18 = phi i64 [ %23, %17 ], [ 0, %0 ]
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i32, i32* %8, i64 %18
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = add nuw nsw i64 %18, 1
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %17, label %13
27: ; preds = %29, %13
%28 = load i32, i32* @EXIT_SUCCESS
ret i32 %28
29: ; preds = %13, %29
%30 = phi i64 [ %35, %29 ], [ 0, %13 ]
%31 = getelementptr inbounds i32, i32* %8, i64 %30
%32 = load i32, i32* %31
%33 = trunc i64 %30 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 %32)
%35 = add nuw nsw i64 %30, 1
%36 = load i32, i32* %1
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %29, label %27
}