#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(int);
double michalewitz(double sol[], int DIM) {
  int i;
  double aux;
  aux = 0;
  for (i = 0; i < DIM; i++) {
    aux = aux +
          sin(sol[i]) * pow(sin((i + 1) * sol[i] * sol[i] / (float)3.14159265),
                            2.0 * 10.0);
  }
  return (-1 * aux);
}


x86 assembly (clang, -O0):
<michalewitz>:
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,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d9 <michalewitz+0xb9>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%edi
call   1030 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  0xe79(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movsd  0xe5c(%rip),%xmm1
call   1040 <pow@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113e <michalewitz+0x1e>
movsd  0xe1f(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<michalewitz>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    11af <michalewitz+0x8f>
mov    %rdi,%r15
mov    %esi,%r14d
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
xchg   %ax,%ax
movaps %xmm0,(%rsp)
cvttsd2si (%r15,%rbx,8),%edi
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
lea    0x1(%rbx),%r12
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movsd  (%r15,%rbx,8),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
divsd  0xe89(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movsd  0xe80(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movapd (%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movaps (%rsp),%xmm0
mov    %r12,%rbx
cmp    %r12,%r14
jne    1140 <michalewitz+0x20>
jmp    11b2 <michalewitz+0x92>
xorps  %xmm0,%xmm0
xorps  0xe57(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @michalewitz(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %6
store i32 0, i32* %5
br label %7
7: ; preds = %40, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %43
11: ; preds = %7
%12 = load double, double* %6
%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 = fptosi double %17 to i32
%19 = call double @sin(i32 %18)
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
%22 = sitofp i32 %21 to double
%23 = load double*, double** %3
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fmul double %22, %27
%29 = load double*, double** %3
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = fmul double %28, %33
%35 = fdiv double %34, 0x400921FB60000000
%36 = fptosi double %35 to i32
%37 = call double @sin(i32 %36)
%38 = call double @pow(double %37, double 2.000000e+01)
%39 = call double @llvm.fmuladd.f64(double %19, double %38, double %12)
store double %39, double* %6
br label %40
40: ; preds = %11
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %7
43: ; preds = %7
%44 = load double, double* %6
%45 = fmul double -1.000000e+00, %44
ret double %45
}

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