#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 *copia(int *, int);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int tam = 3;
  int *vet = malloc(tam * sizeof(int));
  vet[0] = 1;
  vet[1] = 2;
  vet[2] = 3;
  int *novo = copia(vet, tam);
  printf("0 -> %d\n", novo[0]);
  printf("1 -> %d\n", novo[1]);
  printf("2 -> %d\n", novo[2]);
  free(novo);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x3,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,0x8(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1040 <copia@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe61(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xc,%edi
call   1060 <malloc@plt>
movabs $0x200000001,%rcx
mov    %rcx,(%rax)
movl   $0x3,0x8(%rax)
mov    %rax,%rdi
mov    $0x3,%esi
call   1040 <copia@plt>
mov    %rax,%rbx
mov    (%rax),%esi
lea    0xe88(%rip),%rdi
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"0 -> %d\0A\00"
@.str.1 = [9 x i8] c"1 -> %d\0A\00"
@.str.2 = [9 x i8] c"2 -> %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
store i32 3, i32* %1
%4 = load i32, i32* %1
%5 = sext i32 %4 to i64
%6 = mul i64 %5, 4
%7 = trunc i64 %6 to i32
%8 = call i32* @malloc(i32 %7)
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32 1, i32* %10
%11 = load i32*, i32** %2
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 2, i32* %12
%13 = load i32*, i32** %2
%14 = getelementptr inbounds i32, i32* %13, i64 2
store i32 3, i32* %14
%15 = load i32*, i32** %2
%16 = load i32, i32* %1
%17 = call i32* @copia(i32* %15, i32 %16)
store i32* %17, i32** %3
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i64 1
%24 = load i32, i32* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %3
%27 = getelementptr inbounds i32, i32* %26, i64 2
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32*, i32** %3
%31 = call i32 @free(i32* %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"0 -> %d\0A\00"
@.str.1 = [9 x i8] c"1 -> %d\0A\00"
@.str.2 = [9 x i8] c"2 -> %d\0A\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 12)
store i32 1, i32* %1
%2 = getelementptr inbounds i32, i32* %1, i64 1
store i32 2, i32* %2
%3 = getelementptr inbounds i32, i32* %1, i64 2
store i32 3, i32* %3
%4 = tail call i32* @copia(i32* %1, i32 3)
%5 = load i32, i32* %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds i32, i32* %4, i64 1
%8 = load i32, i32* %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds i32, i32* %4, i64 2
%11 = load i32, i32* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = tail call i32 @free(i32* %4)
ret i32 0
}