#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_PI;
double cos(int);
double exp(double);
double sin(int);
int fun(double x, double y, double *z, const void *params) {
  double alpha = *(const double *)params;
  double envelope;
  envelope = exp(-alpha * (x * x + y * y));
  *z = envelope * exp(cos(5 * M_PI * x) * sin(2 * M_PI * y));
  return 0;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm2
mulsd  -0x10(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2e3a(%rip),%rax
imul   $0x5,(%rax),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
movsd  (%rsi),%xmm3
xorpd  0xeaf(%rip),%xmm3
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm3,%xmm0
call   1040 <exp@plt>
mov    0x2e77(%rip),%rbx
mov    (%rbx),%eax
lea    (%rax,%rax,4),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm0,0x8(%rsp)
mulsd  (%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1050 <cos@plt>
mov    (%rbx),%eax
add    %eax,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm0,(%rsp)
mulsd  0x10(%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
call   1040 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global i32 0
define i32 @fun(double %0, double %1, double* %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca i8*
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %8
%12 = bitcast i8* %11 to double*
%13 = load double, double* %12
store double %13, double* %9
%14 = load double, double* %9
%15 = fneg double %14
%16 = load double, double* %5
%17 = load double, double* %5
%18 = load double, double* %6
%19 = load double, double* %6
%20 = fmul double %18, %19
%21 = call double @llvm.fmuladd.f64(double %16, double %17, double %20)
%22 = fmul double %15, %21
%23 = call double @exp(double %22)
store double %23, double* %10
%24 = load double, double* %10
%25 = load i32, i32* @M_PI
%26 = mul nsw i32 5, %25
%27 = sitofp i32 %26 to double
%28 = load double, double* %5
%29 = fmul double %27, %28
%30 = fptosi double %29 to i32
%31 = call double @cos(i32 %30)
%32 = load i32, i32* @M_PI
%33 = mul nsw i32 2, %32
%34 = sitofp i32 %33 to double
%35 = load double, double* %6
%36 = fmul double %34, %35
%37 = fptosi double %36 to i32
%38 = call double @sin(i32 %37)
%39 = fmul double %31, %38
%40 = call double @exp(double %39)
%41 = fmul double %24, %40
%42 = load double*, double** %7
store double %41, double* %42
ret i32 0
}

LLVM IR (-O2):
@M_PI = global i32 0
define i32 @fun(double %0, double %1, double* nocapture writeonly %2, i8* nocapture %3) {
%5 = bitcast i8* %3 to double*
%6 = load double, double* %5
%7 = fneg double %6
%8 = fmul double %1, %1
%9 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %8)
%10 = fmul double %9, %7
%11 = tail call double @exp(double %10)
%12 = load i32, i32* @M_PI
%13 = mul nsw i32 %12, 5
%14 = sitofp i32 %13 to double
%15 = fmul double %14, %0
%16 = fptosi double %15 to i32
%17 = tail call double @cos(i32 %16)
%18 = load i32, i32* @M_PI
%19 = shl nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fmul double %20, %1
%22 = fptosi double %21 to i32
%23 = tail call double @sin(i32 %22)
%24 = fmul double %17, %23
%25 = tail call double @exp(double %24)
%26 = fmul double %11, %25
store double %26, double* %2
ret i32 0
}