#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 M_E;
double M_PI;
double cos(double);
int exp(double);
double sqrt(double);
double ackleys(double *xs) {
  double x = xs[0];
  double y = xs[1];
  return (-20 * exp(-0.2 * sqrt(0.5 * ((x * x) + (y * y)))) -
          exp(0.5 * (cos(2.0 * M_PI * x) + cos(2.0 * M_PI * y))) + 20.0 + M_E);
}


x86 assembly (clang, -O0):
<ackleys>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe8d(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
imul   $0xffffffec,%eax,%eax
mov    %eax,-0x1c(%rbp)
movsd  0xe67(%rip),%xmm0
mov    0x2e38(%rip),%rax
mulsd  (%rax),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe45(%rip),%xmm0
mov    0x2e16(%rip),%rax
mulsd  (%rax),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x28(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe17(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdf3(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    0x2dc0(%rip),%rax
cvtsi2sdl (%rax),%xmm1
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ackleys>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xea1(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     116f <ackleys+0x3f>
sqrtsd %xmm0,%xmm0
jmp    1174 <ackleys+0x44>
call   1050 <sqrt@plt>
mulsd  0xe8c(%rip),%xmm0
call   1030 <exp@plt>
shl    $0x2,%eax
lea    (%rax,%rax,4),%ebp
mov    0x2e5a(%rip),%rbx
movsd  (%rbx),%xmm1
addsd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm1
addsd  %xmm1,%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <cos@plt>
addsd  0x8(%rsp),%xmm0
mulsd  0xe30(%rip),%xmm0
call   1030 <exp@plt>
add    %ebp,%eax
neg    %eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  0xe28(%rip),%xmm1
mov    0x2de9(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sdl (%rax),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@M_E = global i32 0
define double @ackleys(double* %0) {
%2 = alloca double*
%3 = alloca double
%4 = alloca double
store double* %0, double** %2
%5 = load double*, double** %2
%6 = getelementptr inbounds double, double* %5, i64 0
%7 = load double, double* %6
store double %7, double* %3
%8 = load double*, double** %2
%9 = getelementptr inbounds double, double* %8, i64 1
%10 = load double, double* %9
store double %10, double* %4
%11 = load double, double* %3
%12 = load double, double* %3
%13 = load double, double* %4
%14 = load double, double* %4
%15 = fmul double %13, %14
%16 = call double @llvm.fmuladd.f64(double %11, double %12, double %15)
%17 = fmul double 5.000000e-01, %16
%18 = call double @sqrt(double %17)
%19 = fmul double -2.000000e-01, %18
%20 = call i32 @exp(double %19)
%21 = mul nsw i32 -20, %20
%22 = load double, double* @M_PI
%23 = fmul double 2.000000e+00, %22
%24 = load double, double* %3
%25 = fmul double %23, %24
%26 = call double @cos(double %25)
%27 = load double, double* @M_PI
%28 = fmul double 2.000000e+00, %27
%29 = load double, double* %4
%30 = fmul double %28, %29
%31 = call double @cos(double %30)
%32 = fadd double %26, %31
%33 = fmul double 5.000000e-01, %32
%34 = call i32 @exp(double %33)
%35 = sub nsw i32 %21, %34
%36 = sitofp i32 %35 to double
%37 = fadd double %36, 2.000000e+01
%38 = load i32, i32* @M_E
%39 = sitofp i32 %38 to double
%40 = fadd double %37, %39
ret double %40
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@M_E = global i32 0
define double @ackleys(double* nocapture %0) {
%2 = load double, double* %0
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = load double, double* %3
%5 = fmul double %4, %4
%6 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %5)
%7 = fmul double %6, 5.000000e-01
%8 = tail call double @sqrt(double %7)
%9 = fmul double %8, -2.000000e-01
%10 = tail call i32 @exp(double %9)
%11 = mul nsw i32 %10, -20
%12 = load double, double* @M_PI
%13 = fmul double %12, 2.000000e+00
%14 = fmul double %2, %13
%15 = tail call double @cos(double %14)
%16 = load double, double* @M_PI
%17 = fmul double %16, 2.000000e+00
%18 = fmul double %4, %17
%19 = tail call double @cos(double %18)
%20 = fadd double %15, %19
%21 = fmul double %20, 5.000000e-01
%22 = tail call i32 @exp(double %21)
%23 = sub nsw i32 %11, %22
%24 = sitofp i32 %23 to double
%25 = fadd double %24, 2.000000e+01
%26 = load i32, i32* @M_E
%27 = sitofp i32 %26 to double
%28 = fadd double %25, %27
ret double %28
}