#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);
double sqrt(int);
double translate(unsigned short, double);
double griewangk(unsigned short (*pop)[10]) {
  double res = 1;
  double sum = 0;
  double mul = 1;
  double member = 0;
  for (int i = 0; i < 10; i++) {
    member = translate((*pop)[i], 600.0);
    sum += (member * member);
    mul *= cos(member / sqrt(i + 1));
  }
  return res + (sum / 4000.0) - mul;
}


x86 assembly (clang, -O0):
<griewangk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea7(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xa,-0x2c(%rbp)
jge    11ef <griewangk+0xbf>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xe89(%rip),%xmm0
movzwl (%rax,%rcx,2),%edi
call   1050 <translate@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116d <griewangk+0x3d>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe07(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
subsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<griewangk>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movzwl (%rdi),%edi
movsd  0xebd(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,0x10(%rsp)
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x1,%edi
call   1040 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movzwl 0x2(%rbx),%edi
movsd  0xe6d(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x2,%edi
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movzwl 0x4(%rbx),%edi
movsd  0xe1c(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,0x18(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x3,%edi
call   1040 <sqrt@plt>
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movzwl 0x6(%rbx),%edi
movsd  0xdc9(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x4,%edi
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movzwl 0x8(%rbx),%edi
movsd  0xd77(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x5,%edi
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movzwl 0xa(%rbx),%edi
movsd  0xd25(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x6,%edi
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movzwl 0xc(%rbx),%edi
movsd  0xcd3(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x7,%edi
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movzwl 0xe(%rbx),%edi
movsd  0xc81(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x8,%edi
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movzwl 0x10(%rbx),%edi
movsd  0xc30(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,0x18(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x9,%edi
call   1040 <sqrt@plt>
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movzwl 0x12(%rbx),%edi
movsd  0xbdd(%rip),%xmm0
call   1050 <translate@plt>
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0xa,%edi
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
movsd  0x8(%rsp),%xmm1
divsd  0xb9d(%rip),%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  0xb97(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define double @griewangk([10 x i16]* nocapture %0) {
%2 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 0
%3 = load i16, i16* %2
%4 = tail call double @translate(i16 zeroext %3, double 6.000000e+02)
%5 = tail call double @llvm.fmuladd.f64(double %4, double %4, double 0.000000e+00)
%6 = tail call double @sqrt(i32 1)
%7 = fdiv double %4, %6
%8 = tail call double @cos(double %7)
%9 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 1
%10 = load i16, i16* %9
%11 = tail call double @translate(i16 zeroext %10, double 6.000000e+02)
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %5)
%13 = tail call double @sqrt(i32 2)
%14 = fdiv double %11, %13
%15 = tail call double @cos(double %14)
%16 = fmul double %8, %15
%17 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 2
%18 = load i16, i16* %17
%19 = tail call double @translate(i16 zeroext %18, double 6.000000e+02)
%20 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %12)
%21 = tail call double @sqrt(i32 3)
%22 = fdiv double %19, %21
%23 = tail call double @cos(double %22)
%24 = fmul double %16, %23
%25 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 3
%26 = load i16, i16* %25
%27 = tail call double @translate(i16 zeroext %26, double 6.000000e+02)
%28 = tail call double @llvm.fmuladd.f64(double %27, double %27, double %20)
%29 = tail call double @sqrt(i32 4)
%30 = fdiv double %27, %29
%31 = tail call double @cos(double %30)
%32 = fmul double %24, %31
%33 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 4
%34 = load i16, i16* %33
%35 = tail call double @translate(i16 zeroext %34, double 6.000000e+02)
%36 = tail call double @llvm.fmuladd.f64(double %35, double %35, double %28)
%37 = tail call double @sqrt(i32 5)
%38 = fdiv double %35, %37
%39 = tail call double @cos(double %38)
%40 = fmul double %32, %39
%41 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 5
%42 = load i16, i16* %41
%43 = tail call double @translate(i16 zeroext %42, double 6.000000e+02)
%44 = tail call double @llvm.fmuladd.f64(double %43, double %43, double %36)
%45 = tail call double @sqrt(i32 6)
%46 = fdiv double %43, %45
%47 = tail call double @cos(double %46)
%48 = fmul double %40, %47
%49 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 6
%50 = load i16, i16* %49
%51 = tail call double @translate(i16 zeroext %50, double 6.000000e+02)
%52 = tail call double @llvm.fmuladd.f64(double %51, double %51, double %44)
%53 = tail call double @sqrt(i32 7)
%54 = fdiv double %51, %53
%55 = tail call double @cos(double %54)
%56 = fmul double %48, %55
%57 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 7
%58 = load i16, i16* %57
%59 = tail call double @translate(i16 zeroext %58, double 6.000000e+02)
%60 = tail call double @llvm.fmuladd.f64(double %59, double %59, double %52)
%61 = tail call double @sqrt(i32 8)
%62 = fdiv double %59, %61
%63 = tail call double @cos(double %62)
%64 = fmul double %56, %63
%65 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 8
%66 = load i16, i16* %65
%67 = tail call double @translate(i16 zeroext %66, double 6.000000e+02)
%68 = tail call double @llvm.fmuladd.f64(double %67, double %67, double %60)
%69 = tail call double @sqrt(i32 9)
%70 = fdiv double %67, %69
%71 = tail call double @cos(double %70)
%72 = fmul double %64, %71
%73 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 9
%74 = load i16, i16* %73
%75 = tail call double @translate(i16 zeroext %74, double 6.000000e+02)
%76 = tail call double @llvm.fmuladd.f64(double %75, double %75, double %68)
%77 = tail call double @sqrt(i32 10)
%78 = fdiv double %75, %77
%79 = tail call double @cos(double %78)
%80 = fmul double %72, %79
%81 = fdiv double %76, 4.000000e+03
%82 = fadd double %81, 1.000000e+00
%83 = fsub double %82, %80
ret double %83
}