#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(int);
float exp(int);
double sqrt(double);
float ackley(float x, float y) {
  float p1, p2, f;
  float pi = 3.14159265359;
  p1 = 20 * exp(-0.2 * sqrt(0.5 * (x * x + y * y)));
  p2 = exp(0.5 * (cos(2 * pi * x) + cos(2 * pi * y)));
  f = -p1 - p2 + exp(1) + 20;
  return f;
}


x86 assembly (clang, -O0):
<ackley>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  0xebe(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe99(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe8d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movss  0xe5d(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe50(%rip),%xmm0
mulss  -0x18(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movss  0xe30(%rip),%xmm0
mulss  -0x18(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <cos@plt>
movsd  -0x28(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe18(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    $0x1,%edi
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  0xdbc(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ackley>:
sub    $0x18,%rsp
movss  %xmm1,0x14(%rsp)
movaps %xmm1,%xmm2
mulss  %xmm1,%xmm2
movss  %xmm0,0x8(%rsp)
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
addss  %xmm2,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe9f(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1170 <ackley+0x40>
sqrtsd %xmm0,%xmm0
jmp    1175 <ackley+0x45>
call   1050 <sqrt@plt>
mulsd  0xe8b(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
mulss  0xe76(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movss  0x14(%rsp),%xmm0
mulss  0xe59(%rip),%xmm0
cvttss2si %xmm0,%edi
call   1040 <cos@plt>
addsd  0x8(%rsp),%xmm0
mulsd  0xe32(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
movss  0x4(%rsp),%xmm1
mulss  0xe2f(%rip),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    $0x1,%edi
call   1030 <exp@plt>
addss  0x4(%rsp),%xmm0
addss  0xe11(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @ackley(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %3
store float %1, float* %4
store float 0x400921FB60000000, float* %8
%9 = load float, float* %3
%10 = load float, float* %3
%11 = load float, float* %4
%12 = load float, float* %4
%13 = fmul float %11, %12
%14 = call float @llvm.fmuladd.f32(float %9, float %10, float %13)
%15 = fpext float %14 to double
%16 = fmul double 5.000000e-01, %15
%17 = call double @sqrt(double %16)
%18 = fmul double -2.000000e-01, %17
%19 = fptosi double %18 to i32
%20 = call float @exp(i32 %19)
%21 = fmul float 2.000000e+01, %20
store float %21, float* %5
%22 = load float, float* %8
%23 = fmul float 2.000000e+00, %22
%24 = load float, float* %3
%25 = fmul float %23, %24
%26 = fptosi float %25 to i32
%27 = call double @cos(i32 %26)
%28 = load float, float* %8
%29 = fmul float 2.000000e+00, %28
%30 = load float, float* %4
%31 = fmul float %29, %30
%32 = fptosi float %31 to i32
%33 = call double @cos(i32 %32)
%34 = fadd double %27, %33
%35 = fmul double 5.000000e-01, %34
%36 = fptosi double %35 to i32
%37 = call float @exp(i32 %36)
store float %37, float* %6
%38 = load float, float* %5
%39 = fneg float %38
%40 = load float, float* %6
%41 = fsub float %39, %40
%42 = call float @exp(i32 1)
%43 = fadd float %41, %42
%44 = fadd float %43, 2.000000e+01
store float %44, float* %7
%45 = load float, float* %7
ret float %45
}

LLVM IR (-O2):
define float @ackley(float %0, float %1) {
%3 = fmul float %1, %1
%4 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %3)
%5 = fpext float %4 to double
%6 = fmul double %5, 5.000000e-01
%7 = tail call double @sqrt(double %6)
%8 = fmul double %7, -2.000000e-01
%9 = fptosi double %8 to i32
%10 = tail call float @exp(i32 %9)
%11 = fmul float %0, 0x401921FB60000000
%12 = fptosi float %11 to i32
%13 = tail call double @cos(i32 %12)
%14 = fmul float %1, 0x401921FB60000000
%15 = fptosi float %14 to i32
%16 = tail call double @cos(i32 %15)
%17 = fadd double %13, %16
%18 = fmul double %17, 5.000000e-01
%19 = fptosi double %18 to i32
%20 = tail call float @exp(i32 %19)
%21 = fmul float %10, -2.000000e+01
%22 = fsub float %21, %20
%23 = tail call float @exp(i32 1)
%24 = fadd float %22, %23
%25 = fadd float %24, 2.000000e+01
ret float %25
}