#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 exp(double);
int pow(double, int);
double gaussian(double *x, double *y, int n, double sigma) {
  int i;
  double d = 0.0;
  for (i = 0; i < n; i++)
    d += pow(x[i] - y[i], 2);
  return exp(-d / (2 * pow(sigma, 2)));
}


x86 assembly (clang, -O0):
<gaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1193 <gaussian+0x73>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2sd %eax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <gaussian+0x27>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  -0x38(%rbp),%xmm0
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussian>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
test   %edx,%edx
jle    114d <gaussian+0x2d>
mov    %rsi,%r14
mov    %rdi,%r12
movsd  %xmm0,0x18(%rsp)
mov    %edx,%r15d
cmp    $0x1,%edx
jne    1156 <gaussian+0x36>
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
jmp    11c9 <gaussian+0xa9>
xorpd  %xmm1,%xmm1
jmp    1206 <gaussian+0xe6>
mov    %r15d,%r13d
and    $0xfffffffe,%r13d
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm1,(%rsp)
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r12,%rbx,8),%xmm0
subsd  0x8(%r14,%rbx,8),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  (%rsp),%xmm1
add    $0x2,%rbx
cmp    %rbx,%r13
jne    1170 <gaussian+0x50>
test   $0x1,%r15b
movsd  0x18(%rsp),%xmm0
je     1206 <gaussian+0xe6>
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
mov    $0x2,%edi
movapd %xmm1,(%rsp)
call   1040 <pow@plt>
movapd (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
xorpd  0xdf2(%rip),%xmm1
movapd %xmm1,(%rsp)
mov    $0x2,%edi
call   1040 <pow@plt>
add    %eax,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd (%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <exp@plt>

LLVM IR (-O0):
define double @gaussian(double* %0, double* %1, i32 %2, double %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store double %3, double* %8
store double 0.000000e+00, double* %10
store i32 0, i32* %9
br label %11
11: ; preds = %31, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = load double*, double** %5
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = load double*, double** %6
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = fsub double %20, %25
%27 = call i32 @pow(double %26, i32 2)
%28 = sitofp i32 %27 to double
%29 = load double, double* %10
%30 = fadd double %29, %28
store double %30, double* %10
br label %31
31: ; preds = %15
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %11
34: ; preds = %11
%35 = load double, double* %10
%36 = fneg double %35
%37 = load double, double* %8
%38 = call i32 @pow(double %37, i32 2)
%39 = mul nsw i32 2, %38
%40 = sitofp i32 %39 to double
%41 = fdiv double %36, %40
%42 = call double @exp(double %41)
ret double %42
}

LLVM IR (-O2):
define double @gaussian(double* nocapture %0, double* nocapture %1, i32 %2, double %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %50
6: ; preds = %4
%7 = zext i32 %2 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %2, 1
br i1 %9, label %36, label %10
10: ; preds = %6
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %33, %12 ]
%14 = phi double [ 0.000000e+00, %10 ], [ %32, %12 ]
%15 = phi i64 [ 0, %10 ], [ %34, %12 ]
%16 = getelementptr inbounds double, double* %0, i64 %13
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 %13
%19 = load double, double* %18
%20 = fsub double %17, %19
%21 = tail call i32 @pow(double %20, i32 2)
%22 = sitofp i32 %21 to double
%23 = fadd double %14, %22
%24 = or i64 %13, 1
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %1, i64 %24
%28 = load double, double* %27
%29 = fsub double %26, %28
%30 = tail call i32 @pow(double %29, i32 2)
%31 = sitofp i32 %30 to double
%32 = fadd double %23, %31
%33 = add nuw nsw i64 %13, 2
%34 = add i64 %15, 2
%35 = icmp eq i64 %34, %11
br i1 %35, label %36, label %12
36: ; preds = %12, %6
%37 = phi double [ undef, %6 ], [ %32, %12 ]
%38 = phi i64 [ 0, %6 ], [ %33, %12 ]
%39 = phi double [ 0.000000e+00, %6 ], [ %32, %12 ]
%40 = icmp eq i64 %8, 0
br i1 %40, label %50, label %41
41: ; preds = %36
%42 = getelementptr inbounds double, double* %0, i64 %38
%43 = load double, double* %42
%44 = getelementptr inbounds double, double* %1, i64 %38
%45 = load double, double* %44
%46 = fsub double %43, %45
%47 = tail call i32 @pow(double %46, i32 2)
%48 = sitofp i32 %47 to double
%49 = fadd double %39, %48
br label %50
50: ; preds = %41, %36, %4
%51 = phi double [ 0.000000e+00, %4 ], [ %37, %36 ], [ %49, %41 ]
%52 = fneg double %51
%53 = tail call i32 @pow(double %3, i32 2)
%54 = shl nsw i32 %53, 1
%55 = sitofp i32 %54 to double
%56 = fdiv double %52, %55
%57 = tail call double @exp(double %56)
ret double %57
}