#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__ calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ imprimir(int *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ realloc(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int *p;
  int n;
  int i;
  printf("Digite um tamanho: ");
  scanf("%d", &n);
  int vetor[n];
  p = (int *)calloc(n, sizeof(int));
  for (i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  for (i = 0; i < n; i++) {
    printf("%d\n", p[i]);
  }
  imprimir(p, n);
  imprimir(vetor, n);
  p = (int *)realloc(p, (n + 5) * sizeof(int));
  for (i = 0; i < (n + 5); i++) {
    scanf("%d", &p[i]);
  }
  free(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe89(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1208 <main+0xa8>
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe1f(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d3 <main+0x73>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1242 <main+0xe2>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    120f <main+0xaf>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <imprimir@plt>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <imprimir@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x5,%eax
cltq
shl    $0x2,%rax
mov    %eax,%esi
call   1070 <realloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x5,%ecx
cmp    %ecx,%eax
jge    12b6 <main+0x156>
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xd71(%rip),%rdi
call   1080 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    127c <main+0x11c>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%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    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1080 <scanf@plt>
mov    %rsp,%r13
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x2c(%rbp),%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%r15
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    122b <main+0xcb>
mov    %r13,-0x38(%rbp)
xor    %r13d,%r13d
lea    0xe45(%rip),%r12
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rsi
add    $0x4,%rbx
cmp    %rsi,%r13
jl     11e0 <main+0x80>
test   %esi,%esi
mov    -0x38(%rbp),%r13
jle    122b <main+0xcb>
lea    0xe0c(%rip),%r12
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r15,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rsi
cmp    %rsi,%rbx
jl     1210 <main+0xb0>
mov    %r15,%rdi
call   1050 <imprimir@plt>
mov    -0x2c(%rbp),%esi
mov    %r14,%rdi
call   1050 <imprimir@plt>
mov    -0x2c(%rbp),%eax
lea    0x14(,%rax,4),%esi
mov    %r15,%rdi
call   1070 <realloc@plt>
mov    %rax,%r14
cmpl   $0xfffffffc,-0x2c(%rbp)
jl     1290 <main+0x130>
mov    $0xffffffffffffffff,%r12
lea    0xdad(%rip),%r15
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
movslq -0x2c(%rbp),%rax
add    $0x4,%rax
add    $0x1,%r12
add    $0x4,%rbx
cmp    %rax,%r12
jl     1270 <main+0x110>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Digite um tamanho: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%13 = load i32, i32* %7
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i32, i64 %14
store i64 %14, i64* %10
%17 = load i32, i32* %7
%18 = call i64 @calloc(i32 %17, i32 4)
%19 = inttoptr i64 %18 to i32*
store i32* %19, i32** %6
store i32 0, i32* %8
br label %20
20: ; preds = %30, %2
%21 = load i32, i32* %8
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = load i32*, i32** %6
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %20
33: ; preds = %20
store i32 0, i32* %8
br label %34
34: ; preds = %45, %33
%35 = load i32, i32* %8
%36 = load i32, i32* %7
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %48
38: ; preds = %34
%39 = load i32*, i32** %6
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %38
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %34
48: ; preds = %34
%49 = load i32*, i32** %6
%50 = load i32, i32* %7
%51 = call i32 @imprimir(i32* %49, i32 %50)
%52 = load i32, i32* %7
%53 = call i32 @imprimir(i32* %16, i32 %52)
%54 = load i32*, i32** %6
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 5
%57 = sext i32 %56 to i64
%58 = mul i64 %57, 4
%59 = trunc i64 %58 to i32
%60 = call i64 @realloc(i32* %54, i32 %59)
%61 = inttoptr i64 %60 to i32*
store i32* %61, i32** %6
store i32 0, i32* %8
br label %62
62: ; preds = %73, %48
%63 = load i32, i32* %8
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 5
%66 = icmp slt i32 %63, %65
br i1 %66, label %67, label %76
67: ; preds = %62
%68 = load i32*, i32** %6
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %68, i64 %70
%72 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %71)
br label %73
73: ; preds = %67
%74 = load i32, i32* %8
%75 = add nsw i32 %74, 1
store i32 %75, i32* %8
br label %62
76: ; preds = %62
%77 = load i32*, i32** %6
%78 = call i32 @free(i32* %77)
store i32 0, i32* %3
%79 = load i8*, i8** %9
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str = [20 x i8] c"Digite um tamanho: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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* %3)
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = load i32, i32* %3
%12 = call i64 @calloc(i32 %11, i32 4)
%13 = inttoptr i64 %12 to i32*
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 0
br i1 %15, label %18, label %35
16: ; preds = %18
%17 = icmp sgt i32 %23, 0
br i1 %17, label %26, label %35
18: ; preds = %2, %18
%19 = phi i64 [ %22, %18 ], [ 0, %2 ]
%20 = getelementptr inbounds i32, i32* %13, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %18, label %16
26: ; preds = %16, %26
%27 = phi i64 [ %31, %26 ], [ 0, %16 ]
%28 = getelementptr inbounds i32, i32* %13, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = add nuw nsw i64 %27, 1
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %26, label %35
35: ; preds = %26, %2, %16
%36 = phi i32 [ %23, %16 ], [ %14, %2 ], [ %32, %26 ]
%37 = call i32 @imprimir(i32* %13, i32 %36)
%38 = load i32, i32* %3
%39 = call i32 @imprimir(i32* %10, i32 %38)
%40 = load i32, i32* %3
%41 = shl i32 %40, 2
%42 = add i32 %41, 20
%43 = call i64 @realloc(i32* %13, i32 %42)
%44 = inttoptr i64 %43 to i32*
%45 = load i32, i32* %3
%46 = icmp sgt i32 %45, -5
br i1 %46, label %47, label %56
47: ; preds = %35, %47
%48 = phi i64 [ %51, %47 ], [ 0, %35 ]
%49 = getelementptr inbounds i32, i32* %44, i64 %48
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %49)
%51 = add nuw nsw i64 %48, 1
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 4
%54 = sext i32 %53 to i64
%55 = icmp slt i64 %48, %54
br i1 %55, label %47, label %56
56: ; preds = %47, %35
%57 = call i32 @free(i32* %44)
ret i32 0
}