#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 sin(double);
double shubert(double sol[], int DIM) {
  double sum = 0.0;
  int i;
  for (i = 0; i < DIM; i++) {
    sum += -sin(2.0 * sol[i] + 1.0) - 2.0 * sin(3.0 * sol[i] + 2.0) -
           3.0 * sin(4.0 * sol[i] + 3.0) - 4.0 * sin(5.0 * sol[i] + 4.0) -
           5.0 * sin(6.0 * sol[i] + 5.0);
  }
  return sum / (DIM / 2.0);
}


x86 assembly (clang, -O0):
<shubert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1296 <shubert+0x186>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  %xmm0,%xmm0
movsd  0xeed(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xeab(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe67(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe5c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe60(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  -0x38(%rbp),%xmm1
movsd  0xe42(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe08(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe0c(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xdee(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xdbc(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdb8(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  -0x28(%rbp),%xmm1
movsd  0xd92(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112e <shubert+0x1e>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xd58(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shubert>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
test   %esi,%esi
jle    1239 <shubert+0x129>
mov    %rdi,%rbx
mov    %r14d,%r15d
xorpd  %xmm1,%xmm1
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x10(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
addsd  %xmm0,%xmm0
addsd  0xea9(%rip),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
movsd  0xe99(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0xe95(%rip),%xmm0
call   1030 <sin@plt>
mulsd  0xe90(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
movsd  0xe7f(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0xe5b(%rip),%xmm0
call   1030 <sin@plt>
mulsd  0xe6e(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
movsd  0xe5d(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0xe41(%rip),%xmm0
call   1030 <sin@plt>
mulsd  0xe4c(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
mulsd  0xe3b(%rip),%xmm0
addsd  0xe23(%rip),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0xe28(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm1
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1140 <shubert+0x30>
jmp    123d <shubert+0x12d>
xorpd  %xmm1,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  0xe03(%rip),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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