#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 */
double *malloc(int);
double *pow_square(const double *power, int size) {
  int i;
  double *power2;
  power2 = malloc(sizeof(double) * size);
  for (i = 0; i < size; i++) {
    power2[i] = power[i] * power[i];
  }
  return power2;
}


x86 assembly (clang, -O0):
<pow_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117a <pow_square+0x6a>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1139 <pow_square+0x29>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pow_square>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0x0(,%r14,8),%edi
call   1030 <malloc@plt>
test   %r14d,%r14d
jle    1207 <pow_square+0xf7>
mov    %r14d,%ecx
cmp    $0x4,%r14d
jae    1140 <pow_square+0x30>
xor    %edx,%edx
jmp    11f0 <pow_square+0xe0>
mov    %ecx,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rsi
mov    %rsi,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rsi,%rsi
je     120f <pow_square+0xff>
mov    %r8,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movupd (%rbx,%rsi,8),%xmm0
movupd 0x10(%rbx,%rsi,8),%xmm1
mulpd  %xmm0,%xmm0
mulpd  %xmm1,%xmm1
movupd %xmm0,(%rax,%rsi,8)
movupd %xmm1,0x10(%rax,%rsi,8)
movupd 0x20(%rbx,%rsi,8),%xmm0
movupd 0x30(%rbx,%rsi,8),%xmm1
mulpd  %xmm0,%xmm0
mulpd  %xmm1,%xmm1
movupd %xmm0,0x20(%rax,%rsi,8)
movupd %xmm1,0x30(%rax,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1170 <pow_square+0x60>
test   $0x1,%r8b
je     11dc <pow_square+0xcc>
movupd (%rbx,%rsi,8),%xmm0
movupd 0x10(%rbx,%rsi,8),%xmm1
mulpd  %xmm0,%xmm0
mulpd  %xmm1,%xmm1
movupd %xmm0,(%rax,%rsi,8)
movupd %xmm1,0x10(%rax,%rsi,8)
cmp    %rcx,%rdx
je     1207 <pow_square+0xf7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rdx,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    11f0 <pow_square+0xe0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %esi,%esi
test   $0x1,%r8b
jne    11be <pow_square+0xae>
jmp    11dc <pow_square+0xcc>

LLVM IR (-O0):
define double* @pow_square(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
store double* %0, double** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = mul i64 8, %8
%10 = trunc i64 %9 to i32
%11 = call double* @malloc(i32 %10)
store double* %11, double** %6
store i32 0, i32* %5
br label %12
12: ; preds = %32, %2
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %35
16: ; preds = %12
%17 = load double*, double** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = load double*, double** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = fmul double %21, %26
%28 = load double*, double** %6
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double %27, double* %31
br label %32
32: ; preds = %16
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %12
35: ; preds = %12
%36 = load double*, double** %6
ret double* %36
}

LLVM IR (-O2):
define noalias double* @pow_square(double* nocapture %0, i32 %1) {
%3 = shl i32 %1, 3
%4 = tail call double* @malloc(i32 %3)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %77
6: ; preds = %2
%7 = zext i32 %1 to i64
%8 = icmp ult i32 %1, 4
br i1 %8, label %67, label %9
9: ; preds = %6
%10 = and i64 %7, 4294967292
%11 = add nsw i64 %10, -4
%12 = lshr exact i64 %11, 2
%13 = add nuw nsw i64 %12, 1
%14 = and i64 %13, 1
%15 = icmp eq i64 %11, 0
br i1 %15, label %49, label %16
16: ; preds = %9
%17 = and i64 %13, 9223372036854775806
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %46, %18 ]
%20 = phi i64 [ 0, %16 ], [ %47, %18 ]
%21 = getelementptr inbounds double, double* %0, i64 %19
%22 = bitcast double* %21 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = getelementptr inbounds double, double* %21, i64 2
%25 = bitcast double* %24 to <2 x double>*
%26 = load <2 x double>, <2 x double>* %25
%27 = fmul <2 x double> %23, %23
%28 = fmul <2 x double> %26, %26
%29 = getelementptr inbounds double, double* %4, i64 %19
%30 = bitcast double* %29 to <2 x double>*
store <2 x double> %27, <2 x double>* %30
%31 = getelementptr inbounds double, double* %29, i64 2
%32 = bitcast double* %31 to <2 x double>*
store <2 x double> %28, <2 x double>* %32
%33 = or i64 %19, 4
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = bitcast double* %34 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
%37 = getelementptr inbounds double, double* %34, i64 2
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = fmul <2 x double> %36, %36
%41 = fmul <2 x double> %39, %39
%42 = getelementptr inbounds double, double* %4, i64 %33
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> %40, <2 x double>* %43
%44 = getelementptr inbounds double, double* %42, i64 2
%45 = bitcast double* %44 to <2 x double>*
store <2 x double> %41, <2 x double>* %45
%46 = add nuw i64 %19, 8
%47 = add i64 %20, 2
%48 = icmp eq i64 %47, %17
br i1 %48, label %49, label %18
49: ; preds = %18, %9
%50 = phi i64 [ 0, %9 ], [ %46, %18 ]
%51 = icmp eq i64 %14, 0
br i1 %51, label %65, label %52
52: ; preds = %49
%53 = getelementptr inbounds double, double* %0, i64 %50
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %53, i64 2
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = fmul <2 x double> %55, %55
%60 = fmul <2 x double> %58, %58
%61 = getelementptr inbounds double, double* %4, i64 %50
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> %59, <2 x double>* %62
%63 = getelementptr inbounds double, double* %61, i64 2
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> %60, <2 x double>* %64
br label %65
65: ; preds = %49, %52
%66 = icmp eq i64 %10, %7
br i1 %66, label %77, label %67
67: ; preds = %6, %65
%68 = phi i64 [ 0, %6 ], [ %10, %65 ]
br label %69
69: ; preds = %67, %69
%70 = phi i64 [ %75, %69 ], [ %68, %67 ]
%71 = getelementptr inbounds double, double* %0, i64 %70
%72 = load double, double* %71
%73 = fmul double %72, %72
%74 = getelementptr inbounds double, double* %4, i64 %70
store double %73, double* %74
%75 = add nuw nsw i64 %70, 1
%76 = icmp eq i64 %75, %7
br i1 %76, label %77, label %69
77: ; preds = %69, %65, %2
ret double* %4
}