#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 pow(double, double);
double powell(double sol[], int DIM) {
  int j;
  double aux;
  aux = 0.0;
  for (j = 1; j <= (int)DIM / 4; j++) {
    aux += pow(sol[4 * j - 4] + 10 * sol[4 * j - 3], 2.0) +
           5 * pow(sol[4 * j - 2] - sol[4 * j - 1], 2.0) +
           pow(sol[4 * j - 3] - 2 * sol[4 * j - 2], 4.0) +
           10 * pow(sol[4 * j - 4] - sol[4 * j - 1], 4.0);
  }
  return aux;
}


x86 assembly (clang, -O0):
<powell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jg     1280 <powell+0x170>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x4,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe92(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe7a(%rip),%xmm1
call   1030 <pow@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  0xe40(%rip),%xmm1
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   $0x5,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xdec(%rip),%xmm1
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x4,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  0xdab(%rip),%xmm1
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
imul   $0xa,%ecx,%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112e <powell+0x1e>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<powell>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
cmp    $0x4,%esi
jl     11ff <powell+0xef>
mov    %esi,%r14d
mov    %rdi,%r15
shr    $0x2,%r14d
shl    $0x5,%r14
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%r15,%rbx,1),%xmm0
mulsd  0xeab(%rip),%xmm0
addsd  (%r15,%rbx,1),%xmm0
movsd  0xea5(%rip),%xmm1
call   1030 <pow@plt>
mov    %eax,%ebp
movsd  0x10(%r15,%rbx,1),%xmm0
subsd  0x18(%r15,%rbx,1),%xmm0
movsd  0xe88(%rip),%xmm1
call   1030 <pow@plt>
lea    (%rax,%rax,4),%r12d
add    %ebp,%r12d
movsd  0x8(%r15,%rbx,1),%xmm0
movsd  0x10(%r15,%rbx,1),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe66(%rip),%xmm1
call   1030 <pow@plt>
mov    %eax,%ebp
add    %r12d,%ebp
movsd  (%r15,%rbx,1),%xmm0
subsd  0x18(%r15,%rbx,1),%xmm0
movsd  0xe47(%rip),%xmm1
call   1030 <pow@plt>
lea    (%rax,%rax,4),%eax
lea    0x0(%rbp,%rax,2),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x20,%rbx
cmp    %rbx,%r14
jne    1140 <powell+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @powell(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
store double 0.000000e+00, double* %6
store i32 1, i32* %5
br label %7
7: ; preds = %85, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = sdiv i32 %9, 4
%11 = icmp sle i32 %8, %10
br i1 %11, label %12, label %88
12: ; preds = %7
%13 = load double*, double** %3
%14 = load i32, i32* %5
%15 = mul nsw i32 4, %14
%16 = sub nsw i32 %15, 4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %13, i64 %17
%19 = load double, double* %18
%20 = load double*, double** %3
%21 = load i32, i32* %5
%22 = mul nsw i32 4, %21
%23 = sub nsw i32 %22, 3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %20, i64 %24
%26 = load double, double* %25
%27 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %26, double %19)
%28 = call i32 @pow(double %27, double 2.000000e+00)
%29 = load double*, double** %3
%30 = load i32, i32* %5
%31 = mul nsw i32 4, %30
%32 = sub nsw i32 %31, 2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %29, i64 %33
%35 = load double, double* %34
%36 = load double*, double** %3
%37 = load i32, i32* %5
%38 = mul nsw i32 4, %37
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %36, i64 %40
%42 = load double, double* %41
%43 = fsub double %35, %42
%44 = call i32 @pow(double %43, double 2.000000e+00)
%45 = mul nsw i32 5, %44
%46 = add nsw i32 %28, %45
%47 = load double*, double** %3
%48 = load i32, i32* %5
%49 = mul nsw i32 4, %48
%50 = sub nsw i32 %49, 3
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %47, i64 %51
%53 = load double, double* %52
%54 = load double*, double** %3
%55 = load i32, i32* %5
%56 = mul nsw i32 4, %55
%57 = sub nsw i32 %56, 2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %54, i64 %58
%60 = load double, double* %59
%61 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %60, double %53)
%62 = call i32 @pow(double %61, double 4.000000e+00)
%63 = add nsw i32 %46, %62
%64 = load double*, double** %3
%65 = load i32, i32* %5
%66 = mul nsw i32 4, %65
%67 = sub nsw i32 %66, 4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %64, i64 %68
%70 = load double, double* %69
%71 = load double*, double** %3
%72 = load i32, i32* %5
%73 = mul nsw i32 4, %72
%74 = sub nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %71, i64 %75
%77 = load double, double* %76
%78 = fsub double %70, %77
%79 = call i32 @pow(double %78, double 4.000000e+00)
%80 = mul nsw i32 10, %79
%81 = add nsw i32 %63, %80
%82 = sitofp i32 %81 to double
%83 = load double, double* %6
%84 = fadd double %83, %82
store double %84, double* %6
br label %85
85: ; preds = %12
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 1
store i32 %87, i32* %5
br label %7
88: ; preds = %7
%89 = load double, double* %6
ret double %89
}

LLVM IR (-O2):
define double @powell(double* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 4
br i1 %3, label %45, label %4
4: ; preds = %2
%5 = lshr i32 %1, 2
%6 = add nuw nsw i32 %5, 1
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %4, %8
%9 = phi i64 [ 1, %4 ], [ %43, %8 ]
%10 = phi double [ 0.000000e+00, %4 ], [ %42, %8 ]
%11 = shl nsw i64 %9, 2
%12 = add nsw i64 %11, -4
%13 = getelementptr inbounds double, double* %0, i64 %12
%14 = load double, double* %13
%15 = add nsw i64 %11, -3
%16 = getelementptr inbounds double, double* %0, i64 %15
%17 = load double, double* %16
%18 = tail call double @llvm.fmuladd.f64(double %17, double 1.000000e+01, double %14)
%19 = tail call i32 @pow(double %18, double 2.000000e+00)
%20 = add nsw i64 %11, -2
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = add nsw i64 %11, -1
%24 = getelementptr inbounds double, double* %0, i64 %23
%25 = load double, double* %24
%26 = fsub double %22, %25
%27 = tail call i32 @pow(double %26, double 2.000000e+00)
%28 = mul nsw i32 %27, 5
%29 = add nsw i32 %28, %19
%30 = load double, double* %16
%31 = load double, double* %21
%32 = tail call double @llvm.fmuladd.f64(double %31, double -2.000000e+00, double %30)
%33 = tail call i32 @pow(double %32, double 4.000000e+00)
%34 = add nsw i32 %29, %33
%35 = load double, double* %13
%36 = load double, double* %24
%37 = fsub double %35, %36
%38 = tail call i32 @pow(double %37, double 4.000000e+00)
%39 = mul nsw i32 %38, 10
%40 = add nsw i32 %34, %39
%41 = sitofp i32 %40 to double
%42 = fadd double %10, %41
%43 = add nuw nsw i64 %9, 1
%44 = icmp eq i64 %43, %7
br i1 %44, label %45, label %8
45: ; preds = %8, %2
%46 = phi double [ 0.000000e+00, %2 ], [ %42, %8 ]
ret double %46
}