#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 fabs(double);
double pow(double, double);
double gauss_sim(double d, double scale, double offset, double origin) {
  double d_norm;
  d_norm = fabs(d - origin);
  if (d_norm <= offset) {
    return 1.0;
  } else {
    return pow(2.0, -pow((d_norm - offset) / scale, 2.0));
  }
}


x86 assembly (clang, -O0):
<gauss_sim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movaps 0xec3(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     116c <gauss_sim+0x5c>
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b1 <gauss_sim+0xa1>
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
call   1030 <pow@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe69(%rip),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauss_sim>:
subsd  %xmm3,%xmm0
andpd  0xee4(%rip),%xmm0
ucomisd %xmm0,%xmm2
jae    1143 <gauss_sim+0x33>
subsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
movapd 0xede(%rip),%xmm1
xorpd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    1030 <exp2@plt>
movsd  0xed5(%rip),%xmm0
ret

LLVM IR (-O0):
define double @gauss_sim(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
%11 = load double, double* %6
%12 = load double, double* %9
%13 = fsub double %11, %12
%14 = call double @llvm.fabs.f64(double %13)
store double %14, double* %10
%15 = load double, double* %10
%16 = load double, double* %8
%17 = fcmp ole double %15, %16
br i1 %17, label %18, label %19
18: ; preds = %4
store double 1.000000e+00, double* %5
br label %28
19: ; preds = %4
%20 = load double, double* %10
%21 = load double, double* %8
%22 = fsub double %20, %21
%23 = load double, double* %7
%24 = fdiv double %22, %23
%25 = call double @pow(double %24, double 2.000000e+00)
%26 = fneg double %25
%27 = call double @pow(double 2.000000e+00, double %26)
store double %27, double* %5
br label %28
28: ; preds = %19, %18
%29 = load double, double* %5
ret double %29
}

LLVM IR (-O2):
define double @gauss_sim(double %0, double %1, double %2, double %3) {
%5 = fsub double %0, %3
%6 = tail call double @llvm.fabs.f64(double %5)
%7 = fcmp ugt double %6, %2
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = fsub double %6, %2
%10 = fdiv double %9, %1
%11 = fneg double %10
%12 = fmul double %10, %11
%13 = tail call double @exp2(double %12)
br label %14
14: ; preds = %4, %8
%15 = phi double [ %13, %8 ], [ 1.000000e+00, %4 ]
ret double %15
}