#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 pow(double, double);
double sin(double);
double stretchedV(double sol[], int DIM) {
  double sum = 0.0;
  double aux;
  int i;
  for (i = 0; i < DIM - 1; i++) {
    aux = sol[i + 1] * sol[i + 1] + sol[i] * sol[i];
    sum += pow(aux, 0.25) * (pow(sin(50.0 * pow(aux, 0.1)), 2.0) + 1.0);
  }
  return sum;
}


x86 assembly (clang, -O0):
<stretchedV>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1218 <stretchedV+0xf8>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe79(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe5a(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe42(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  0xe29(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  0xe0c(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <stretchedV+0x1e>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stretchedV>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
cmp    $0x2,%esi
jl     11e0 <stretchedV+0xc0>
mov    %esi,%r14d
mov    %rdi,%r15
add    $0xffffffff,%r14d
xorps  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
lea    0x1(%rax),%rbx
movsd  (%r15,%rax,8),%xmm1
movsd  0x8(%r15,%rax,8),%xmm0
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe7f(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0xe6e(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xe69(%rip),%xmm0
call   1030 <sin@plt>
mulsd  %xmm0,%xmm0
addsd  0xe60(%rip),%xmm0
mulsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rax
cmp    %rbx,%r14
jne    1150 <stretchedV+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @stretchedV(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
store i32 0, i32* %7
br label %8
8: ; preds = %48, %2
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = sub nsw i32 %10, 1
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %51
13: ; preds = %8
%14 = load double*, double** %3
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %14, i64 %17
%19 = load double, double* %18
%20 = load double*, double** %3
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %20, i64 %23
%25 = load double, double* %24
%26 = load double*, double** %3
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = load double*, double** %3
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = fmul double %30, %35
%37 = call double @llvm.fmuladd.f64(double %19, double %25, double %36)
store double %37, double* %6
%38 = load double, double* %6
%39 = call double @pow(double %38, double 2.500000e-01)
%40 = load double, double* %6
%41 = call double @pow(double %40, double 1.000000e-01)
%42 = fmul double 5.000000e+01, %41
%43 = call double @sin(double %42)
%44 = call double @pow(double %43, double 2.000000e+00)
%45 = fadd double %44, 1.000000e+00
%46 = load double, double* %5
%47 = call double @llvm.fmuladd.f64(double %39, double %45, double %46)
store double %47, double* %5
br label %48
48: ; preds = %13
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %8
51: ; preds = %8
%52 = load double, double* %5
ret double %52
}

LLVM IR (-O2):
define double @stretchedV(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %25
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 0, %4 ], [ %10, %7 ]
%9 = phi double [ 0.000000e+00, %4 ], [ %23, %7 ]
%10 = add nuw nsw i64 %8, 1
%11 = getelementptr inbounds double, double* %0, i64 %10
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %0, i64 %8
%14 = load double, double* %13
%15 = fmul double %14, %14
%16 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %15)
%17 = tail call double @pow(double %16, double 2.500000e-01)
%18 = tail call double @pow(double %16, double 1.000000e-01)
%19 = fmul double %18, 5.000000e+01
%20 = tail call double @sin(double %19)
%21 = fmul double %20, %20
%22 = fadd double %21, 1.000000e+00
%23 = tail call double @llvm.fmuladd.f64(double %17, double %22, double %9)
%24 = icmp eq i64 %10, %6
br i1 %24, label %25, label %7
25: ; preds = %7, %2
%26 = phi double [ 0.000000e+00, %2 ], [ %23, %7 ]
ret double %26
}