#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 pow(int, int);
int *integerPower(int y) {
  int *ret = malloc(4 * sizeof(int));
  ret[0] = pow(y, 2);
  ret[1] = pow(y, 3);
  ret[2] = pow(y, 4);
  ret[3] = ret[0] + ret[1] + ret[2];
  return ret;
}


x86 assembly (clang, -O0):
<integerPower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x10,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
add    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
add    0x8(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integerPower>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
mov    $0x10,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    %r15d,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %eax,%r14d
mov    %eax,(%rbx)
mov    %r15d,%edi
mov    $0x3,%esi
call   1040 <pow@plt>
mov    %eax,%ebp
mov    %eax,0x4(%rbx)
mov    %r15d,%edi
mov    $0x4,%esi
call   1040 <pow@plt>
mov    %eax,0x8(%rbx)
add    %r14d,%ebp
add    %eax,%ebp
mov    %ebp,0xc(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @integerPower(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i32* @malloc(i32 16)
store i32* %4, i32** %3
%5 = load i32, i32* %2
%6 = call i32 @pow(i32 %5, i32 2)
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i64 0
store i32 %6, i32* %8
%9 = load i32, i32* %2
%10 = call i32 @pow(i32 %9, i32 3)
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 %10, i32* %12
%13 = load i32, i32* %2
%14 = call i32 @pow(i32 %13, i32 4)
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 2
store i32 %14, i32* %16
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 0
%19 = load i32, i32* %18
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = add nsw i32 %19, %22
%24 = load i32*, i32** %3
%25 = getelementptr inbounds i32, i32* %24, i64 2
%26 = load i32, i32* %25
%27 = add nsw i32 %23, %26
%28 = load i32*, i32** %3
%29 = getelementptr inbounds i32, i32* %28, i64 3
store i32 %27, i32* %29
%30 = load i32*, i32** %3
ret i32* %30
}

LLVM IR (-O2):
define noalias i32* @integerPower(i32 %0) {
%2 = tail call i32* @malloc(i32 16)
%3 = tail call i32 @pow(i32 %0, i32 2)
store i32 %3, i32* %2
%4 = tail call i32 @pow(i32 %0, i32 3)
%5 = getelementptr inbounds i32, i32* %2, i64 1
store i32 %4, i32* %5
%6 = tail call i32 @pow(i32 %0, i32 4)
%7 = getelementptr inbounds i32, i32* %2, i64 2
store i32 %6, i32* %7
%8 = add nsw i32 %4, %3
%9 = add nsw i32 %8, %6
%10 = getelementptr inbounds i32, i32* %2, i64 3
store i32 %9, i32* %10
ret i32* %2
}