#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*/ exit(int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int *vetor1, *vetor2;
  int n, i;
  printf("Digite o tamanho dos vetores: ");
  scanf("%d", &n);
  vetor1 = (int *)malloc(n * sizeof(int));
  if (vetor1 == NULL) {
    printf("Memoria nao alocada");
    exit(1);
  }
  for (i = 0; i < n; i++)
    vetor1[i] = 0;
  vetor2 = (int *)calloc(n, sizeof(int));
  if (vetor2 == NULL) {
    printf("Memoria nao alocada");
    exit(1);
  }
  for (i = 0; i < n; i++)
    printf("%d ", vetor1[i]);
  printf("\n");
  for (i = 0; i < n; i++)
    printf("%d ", vetor2[i]);
  printf("\n");
  free(vetor1);
  free(vetor2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c3 <main+0x63>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f3 <main+0x93>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ca <main+0x6a>
mov    -0x1c(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1227 <main+0xc7>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1261 <main+0x101>
mov    -0x10(%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    122e <main+0xce>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12a9 <main+0x149>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1276 <main+0x116>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe92(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1284 <main+0x114>
mov    %rax,%r12
mov    0x4(%rsp),%edi
test   %edi,%edi
jle    11d6 <main+0x66>
xor    %eax,%eax
nopl   0x0(%rax)
movl   $0x0,(%r12,%rax,4)
add    $0x1,%rax
movslq 0x4(%rsp),%rdi
cmp    %rdi,%rax
jl     11c0 <main+0x50>
mov    $0x4,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     1284 <main+0x114>
mov    %rax,%r14
cmpl   $0x0,0x4(%rsp)
jle    121c <main+0xac>
lea    0xe3c(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1200 <main+0x90>
mov    $0xa,%edi
call   1040 <putchar@plt>
cmpl   $0x0,0x4(%rsp)
jle    125c <main+0xec>
lea    0xe02(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1240 <main+0xd0>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xd97(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

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

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