#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 *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int citire_v(int n, int **vector) {
  (*vector) = malloc(n * sizeof(**vector));
  for (int i = 0; i < n; i++) {
    printf("v[%d]=", i + 1);
    scanf("%d", &(*vector)[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<citire_v>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a9 <citire_v+0x79>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe71(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <citire_v+0x2f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<citire_v>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%ebp
lea    0x0(,%rbp,4),%edi
call   1040 <malloc@plt>
mov    %rax,(%r12)
test   %ebp,%ebp
jle    1195 <citire_v+0x65>
mov    %ebp,%r13d
shl    $0x2,%r13
mov    $0x1,%ebp
xor    %ebx,%ebx
lea    0xe97(%rip),%r14
lea    0xe97(%rip),%r15
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    (%r12),%rsi
add    %rbx,%rsi
mov    %r15,%rdi
call   1050 <scanf@plt>
add    $0x4,%rbx
add    $0x1,%ebp
cmp    %rbx,%r13
jne    1170 <citire_v+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"v[%d]=\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @citire_v(i32 %0, i32** %1) {
%3 = alloca i32
%4 = alloca i32**
%5 = alloca i32
store i32 %0, i32* %3
store i32** %1, i32*** %4
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = mul i64 %7, 4
%9 = trunc i64 %8 to i32
%10 = call i32* @malloc(i32 %9)
%11 = load i32**, i32*** %4
store i32* %10, i32** %11
store i32 0, i32* %5
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32**, i32*** %4
%21 = load i32*, i32** %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, 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 = %16
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %12
29: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"v[%d]=\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @citire_v(i32 %0, i32** nocapture %1) {
%3 = shl i32 %0, 2
%4 = tail call i32* @malloc(i32 %3)
store i32* %4, i32** %1
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %9
8: ; preds = %9, %2
ret i32 0
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %11, %9 ]
%11 = add nuw nsw i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %1
%15 = getelementptr inbounds i32, i32* %14, i64 %10
%16 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = icmp eq i64 %11, %7
br i1 %17, label %8, label %9
}