int main(void) {
  int *i = malloc(sizeof(int));
  retorna_algo(1, i);
  printf("%d\n", *i);
  i = realloc(i, sizeof(int) * 3);
  retorna_algo(3, i);
  printf("%d | %d | %d\n", i[0], i[1], i[2]);
  i = (int[]){1, 2, 3};
  printf("%d | %d | %d\n", i[0], i[1], i[2]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <retorna_algo@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0xc,%esi
call   1060 <realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x3,%edi
mov    $0x0,%al
call   1030 <retorna_algo@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x2,-0x10(%rbp)
movl   $0x3,-0xc(%rbp)
lea    -0x14(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <retorna_algo@plt>
mov    (%rbx),%esi
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xc,%esi
mov    %rbx,%rdi
call   1060 <realloc@plt>
mov    %rax,%rbx
mov    $0x3,%edi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <retorna_algo@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%ecx
lea    0xe65(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

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