#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 /*<<< orphan*/ assert(int);
double pow(double const, double);
double sin(double);
double f_schaffers_raw(const double *x, const size_t number_of_variables) {
  size_t i = 0;
  double result;
  assert(number_of_variables > 1);
  result = 0.0;
  for (i = 0; i < number_of_variables - 1; ++i) {
    const double tmp = x[i] * x[i] + x[i + 1] * x[i + 1];
    result += pow(tmp, 0.25) * (1.0 + pow(sin(50.0 * pow(tmp, 0.1)), 2.0));
  }
  result = pow(result / ((double)(long)number_of_variables - 1.0), 2.0);
  return result;
}


x86 assembly (clang, -O0):
<f_schaffers_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x1,-0x10(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    1243 <f_schaffers_raw+0x113>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsd  0x8(%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mulsd  0x8(%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe51(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe1a(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  0xdf9(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xdec(%rip),%xmm2
addsd  %xmm1,%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    116a <f_schaffers_raw+0x3a>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xdb2(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  0xd9a(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_schaffers_raw>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
cmp    $0x2,%rsi
setae  %dil
call   1030 <assert@plt>
xorpd  %xmm1,%xmm1
cmp    $0x1,%r14
je     11ed <f_schaffers_raw+0xbd>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x18(%rsp)
movsd  -0x8(%r15,%rbx,8),%xmm0
movsd  (%r15,%rbx,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe63(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0xe52(%rip),%xmm1
call   1050 <pow@plt>
mulsd  0xe4d(%rip),%xmm0
call   1040 <sin@plt>
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm0
addsd  0xe3e(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm1
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1170 <f_schaffers_raw+0x40>
xorps  %xmm0,%xmm0
cvtsi2sd %r14,%xmm0
addsd  0xe23(%rip),%xmm0
divsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @f_schaffers_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 i64, i64* %4
%9 = icmp ugt i64 %8, 1
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store double 0.000000e+00, double* %6
store i64 0, i64* %5
br label %12
12: ; preds = %48, %2
%13 = load i64, i64* %5
%14 = load i64, i64* %4
%15 = sub i64 %14, 1
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %51
17: ; preds = %12
%18 = load double*, double** %3
%19 = load i64, i64* %5
%20 = getelementptr inbounds double, double* %18, i64 %19
%21 = load double, double* %20
%22 = load double*, double** %3
%23 = load i64, i64* %5
%24 = getelementptr inbounds double, double* %22, i64 %23
%25 = load double, double* %24
%26 = load double*, double** %3
%27 = load i64, i64* %5
%28 = add i64 %27, 1
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = load double*, double** %3
%32 = load i64, i64* %5
%33 = add i64 %32, 1
%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 %21, double %25, double %36)
store double %37, double* %7
%38 = load double, double* %7
%39 = call double @pow(double %38, double 2.500000e-01)
%40 = load double, double* %7
%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 1.000000e+00, %44
%46 = load double, double* %6
%47 = call double @llvm.fmuladd.f64(double %39, double %45, double %46)
store double %47, double* %6
br label %48
48: ; preds = %17
%49 = load i64, i64* %5
%50 = add i64 %49, 1
store i64 %50, i64* %5
br label %12
51: ; preds = %12
%52 = load double, double* %6
%53 = load i64, i64* %4
%54 = sitofp i64 %53 to double
%55 = fsub double %54, 1.000000e+00
%56 = fdiv double %52, %55
%57 = call double @pow(double %56, double 2.000000e+00)
store double %57, double* %6
%58 = load double, double* %6
ret double %58
}

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