#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 pow(float, double);
float rastrigin(float x1, float x2) {
  return 20 + (pow(x1, 2.0) - (10.0 * cos(2.0 * 3.14159265359 * x1))) +
         (pow(x2, 2.0) - (10.0 * cos(2.0 * 3.14159265359 * x2)));
}


x86 assembly (clang, -O0):
<rastrigin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movsd  0xed1(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xeae(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe95(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movsd  0xe77(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe54(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  -0x18(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rastrigin>:
sub    $0x18,%rsp
movss  %xmm1,0x4(%rsp)
movss  %xmm0,0x8(%rsp)
movsd  0xec8(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xeb3(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xeae(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
addsd  0xea8(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0x4(%rsp),%xmm0
movsd  0xe7c(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe67(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xe62(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @rastrigin(float %0, float %1) {
%3 = alloca float
%4 = alloca float
store float %0, float* %3
store float %1, float* %4
%5 = load float, float* %3
%6 = call double @pow(float %5, double 2.000000e+00)
%7 = load float, float* %3
%8 = fpext float %7 to double
%9 = fmul double 0x401921FB54442EEA, %8
%10 = call double @cos(double %9)
%11 = call double @llvm.fmuladd.f64(double -1.000000e+01, double %10, double %6)
%12 = fadd double 2.000000e+01, %11
%13 = load float, float* %4
%14 = call double @pow(float %13, double 2.000000e+00)
%15 = load float, float* %4
%16 = fpext float %15 to double
%17 = fmul double 0x401921FB54442EEA, %16
%18 = call double @cos(double %17)
%19 = call double @llvm.fmuladd.f64(double -1.000000e+01, double %18, double %14)
%20 = fadd double %12, %19
%21 = fptrunc double %20 to float
ret float %21
}

LLVM IR (-O2):
define float @rastrigin(float %0, float %1) {
%3 = tail call double @pow(float %0, double 2.000000e+00)
%4 = fpext float %0 to double
%5 = fmul double %4, 0x401921FB54442EEA
%6 = tail call double @cos(double %5)
%7 = tail call double @llvm.fmuladd.f64(double %6, double -1.000000e+01, double %3)
%8 = fadd double %7, 2.000000e+01
%9 = tail call double @pow(float %1, double 2.000000e+00)
%10 = fpext float %1 to double
%11 = fmul double %10, 0x401921FB54442EEA
%12 = tail call double @cos(double %11)
%13 = tail call double @llvm.fmuladd.f64(double %12, double -1.000000e+01, double %9)
%14 = fadd double %8, %13
%15 = fptrunc double %14 to float
ret float %15
}