#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 const pow(double const, double const);
double f_ellipsoid_raw(const double *x, const size_t number_of_variables) {
  static const double condition = 1.0e6;
  size_t i = 0;
  double result;
  result = x[i] * x[i];
  for (i = 1; i < number_of_variables; ++i) {
    const double exponent =
        1.0 * (double)(long)i / ((double)(long)number_of_variables - 1.0);
    result += pow(condition, exponent) * x[i] * x[i];
  }
  return result;
}


x86 assembly (clang, -O0):
<f_ellipsoid_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11d9 <f_ellipsoid_raw+0xc9>
cvtsi2sdq -0x18(%rbp),%xmm1
movsd  0xe9d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xe8b(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0xe69(%rip),%xmm0
call   1030 <pow@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114f <f_ellipsoid_raw+0x3f>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_ellipsoid_raw>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movsd  (%rdi),%xmm0
mulsd  %xmm0,%xmm0
cmp    $0x2,%rsi
jb     1225 <f_ellipsoid_raw+0x115>
mov    %rdi,%r14
cvtsi2sd %rsi,%xmm1
addsd  0xec1(%rip),%xmm1
lea    -0x1(%rsi),%r15
cmp    $0x2,%rsi
jne    115d <f_ellipsoid_raw+0x4d>
mov    $0x1,%ebx
test   $0x1,%r15b
jne    11f0 <f_ellipsoid_raw+0xe0>
jmp    1225 <f_ellipsoid_raw+0x115>
mov    %r15,%r12
and    $0xfffffffffffffffe,%r12
mov    $0x1,%ebx
movsd  %xmm1,0x8(%rsp)
nop
movsd  %xmm0,(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %rbx,%xmm1
divsd  0x8(%rsp),%xmm1
movsd  0xe7d(%rip),%xmm0
call   1030 <pow@plt>
movsd  (%r14,%rbx,8),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0x1(%rbx),%r13
xorps  %xmm1,%xmm1
cvtsi2sd %r13,%xmm1
divsd  0x8(%rsp),%xmm1
movsd  0xe46(%rip),%xmm0
call   1030 <pow@plt>
movsd  0x8(%r14,%rbx,8),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
add    $0x2,%rbx
cmp    %r12,%r13
jne    1170 <f_ellipsoid_raw+0x60>
movsd  0x8(%rsp),%xmm1
test   $0x1,%r15b
je     1225 <f_ellipsoid_raw+0x115>
movsd  %xmm0,(%rsp)
movapd %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rbx,%xmm1
divsd  %xmm0,%xmm1
movsd  0xdfb(%rip),%xmm0
call   1030 <pow@plt>
movsd  (%r14,%rbx,8),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@f_ellipsoid_raw.condition = internal constant double 1.000000e+06
define double @f_ellipsoid_raw(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
%7 = alloca double
store double* %0, double** %3
store i64 %1, i64* %4
store i64 0, i64* %5
%8 = load double*, double** %3
%9 = load i64, i64* %5
%10 = getelementptr inbounds double, double* %8, i64 %9
%11 = load double, double* %10
%12 = load double*, double** %3
%13 = load i64, i64* %5
%14 = getelementptr inbounds double, double* %12, i64 %13
%15 = load double, double* %14
%16 = fmul double %11, %15
store double %16, double* %6
store i64 1, i64* %5
br label %17
17: ; preds = %42, %2
%18 = load i64, i64* %5
%19 = load i64, i64* %4
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %45
21: ; preds = %17
%22 = load i64, i64* %5
%23 = sitofp i64 %22 to double
%24 = fmul double 1.000000e+00, %23
%25 = load i64, i64* %4
%26 = sitofp i64 %25 to double
%27 = fsub double %26, 1.000000e+00
%28 = fdiv double %24, %27
store double %28, double* %7
%29 = load double, double* %7
%30 = call double @pow(double 1.000000e+06, double %29)
%31 = load double*, double** %3
%32 = load i64, i64* %5
%33 = getelementptr inbounds double, double* %31, i64 %32
%34 = load double, double* %33
%35 = fmul double %30, %34
%36 = load double*, double** %3
%37 = load i64, i64* %5
%38 = getelementptr inbounds double, double* %36, i64 %37
%39 = load double, double* %38
%40 = load double, double* %6
%41 = call double @llvm.fmuladd.f64(double %35, double %39, double %40)
store double %41, double* %6
br label %42
42: ; preds = %21
%43 = load i64, i64* %5
%44 = add i64 %43, 1
store i64 %44, i64* %5
br label %17
45: ; preds = %17
%46 = load double, double* %6
ret double %46
}

LLVM IR (-O2):
define double @f_ellipsoid_raw(double* nocapture %0, i64 %1) {
%3 = load double, double* %0
%4 = fmul double %3, %3
%5 = icmp ugt i64 %1, 1
br i1 %5, label %6, label %49
6: ; preds = %2
%7 = sitofp i64 %1 to double
%8 = fadd double %7, -1.000000e+00
%9 = add i64 %1, -1
%10 = and i64 %9, 1
%11 = icmp eq i64 %1, 2
br i1 %11, label %36, label %12
12: ; preds = %6
%13 = and i64 %9, -2
br label %14
14: ; preds = %14, %12
%15 = phi i64 [ 1, %12 ], [ %33, %14 ]
%16 = phi double [ %4, %12 ], [ %32, %14 ]
%17 = phi i64 [ 0, %12 ], [ %34, %14 ]
%18 = sitofp i64 %15 to double
%19 = fdiv double %18, %8
%20 = tail call double @pow(double 1.000000e+06, double %19)
%21 = getelementptr inbounds double, double* %0, i64 %15
%22 = load double, double* %21
%23 = fmul double %20, %22
%24 = tail call double @llvm.fmuladd.f64(double %23, double %22, double %16)
%25 = add nuw i64 %15, 1
%26 = sitofp i64 %25 to double
%27 = fdiv double %26, %8
%28 = tail call double @pow(double 1.000000e+06, double %27)
%29 = getelementptr inbounds double, double* %0, i64 %25
%30 = load double, double* %29
%31 = fmul double %28, %30
%32 = tail call double @llvm.fmuladd.f64(double %31, double %30, double %24)
%33 = add nuw i64 %15, 2
%34 = add i64 %17, 2
%35 = icmp eq i64 %34, %13
br i1 %35, label %36, label %14
36: ; preds = %14, %6
%37 = phi double [ undef, %6 ], [ %32, %14 ]
%38 = phi i64 [ 1, %6 ], [ %33, %14 ]
%39 = phi double [ %4, %6 ], [ %32, %14 ]
%40 = icmp eq i64 %10, 0
br i1 %40, label %49, label %41
41: ; preds = %36
%42 = sitofp i64 %38 to double
%43 = fdiv double %42, %8
%44 = tail call double @pow(double 1.000000e+06, double %43)
%45 = getelementptr inbounds double, double* %0, i64 %38
%46 = load double, double* %45
%47 = fmul double %44, %46
%48 = tail call double @llvm.fmuladd.f64(double %47, double %46, double %39)
br label %49
49: ; preds = %41, %36, %2
%50 = phi double [ %4, %2 ], [ %37, %36 ], [ %48, %41 ]
ret double %50
}