#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 cos(double);
int /*<<< orphan*/ fabs(double);
double pow(int, int);
double sqrt(int /*<<< orphan*/);
double mpe(double sol[], int DIM) {
  int i;
  double aux1 = 0.0, aux2 = 0.0;
  for (i = 0; i < DIM; i++) {
    aux1 += 1 + cos(3 * sol[i]);
    aux2 +=
        (pow(-1, i) / (sqrt(fabs(10.60099896 - 4.141720682 * cos(sol[i])))));
  }
  return aux1 + aux2;
}


x86 assembly (clang, -O0):
<mpe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1211 <mpe+0xd1>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  0xe96(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe79(%rip),%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    $0xffffffff,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <cos@plt>
movsd  0xe2f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2b(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <mpe+0x26>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpe>:
test   %esi,%esi
jle    1213 <mpe+0xd3>
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
mov    %esi,%r15d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x18(%rsp)
movsd  (%r14,%rbx,8),%xmm0
mulsd  0xe7c(%rip),%xmm0
call   1040 <cos@plt>
addsd  0xe77(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0xffffffff,%edi
mov    %ebx,%esi
call   1050 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%r14,%rbx,8),%xmm0
call   1040 <cos@plt>
mulsd  0xe4a(%rip),%xmm0
addsd  0xe4a(%rip),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <mpe+0x30>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @mpe(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %5
br label %8
8: ; preds = %37, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %40
12: ; preds = %8
%13 = load double*, double** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = fmul double 3.000000e+00, %17
%19 = call double @cos(double %18)
%20 = fadd double 1.000000e+00, %19
%21 = load double, double* %6
%22 = fadd double %21, %20
store double %22, double* %6
%23 = load i32, i32* %5
%24 = call double @pow(i32 -1, i32 %23)
%25 = load double*, double** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = call double @cos(double %29)
%31 = call double @llvm.fmuladd.f64(double 0xC010911F39F96D61, double %30, double 0x402533B622BC4291)
%32 = call i32 @fabs(double %31)
%33 = call double @sqrt(i32 %32)
%34 = fdiv double %24, %33
%35 = load double, double* %7
%36 = fadd double %35, %34
store double %36, double* %7
br label %37
37: ; preds = %12
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %8
40: ; preds = %8
%41 = load double, double* %6
%42 = load double, double* %7
%43 = fadd double %41, %42
ret double %43
}

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