#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 /*<<< orphan*/ M_E;
double pow(int /*<<< orphan*/, int);
double gauss_distribution(int i, double sigma) {
  if (i == 0)
    return 1.0;
  else if (i < 0)
    return gauss_distribution(-i, sigma);
  else
    return pow(M_E, -(i * i) / (2 * sigma * sigma));
}


x86 assembly (clang, -O0):
<gauss_distribution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    114c <gauss_distribution+0x2c>
movsd  0xec6(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ab <gauss_distribution+0x8b>
cmpl   $0x0,-0xc(%rbp)
jge    116f <gauss_distribution+0x4f>
xor    %edi,%edi
sub    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1030 <gauss_distribution@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11ab <gauss_distribution+0x8b>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
xor    %eax,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe71(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1040 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauss_distribution>:
test   %edi,%edi
je     1153 <gauss_distribution+0x43>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %edi,%eax
neg    %edi
test   %eax,%eax
js     1120 <gauss_distribution+0x10>
mov    0x2eb1(%rip),%rcx
mov    (%rcx),%edi
imul   %eax,%eax
neg    %eax
cvtsi2sd %eax,%xmm1
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%esi
jmp    1030 <pow@plt>
movsd  0xea5(%rip),%xmm0
ret

LLVM IR (-O0):
@M_E = global i32 0
define double @gauss_distribution(i32 %0, double %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
store double 1.000000e+00, double* %3
br label %31
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %4
%14 = sub nsw i32 0, %13
%15 = load double, double* %5
%16 = call double @gauss_distribution(i32 %14, double %15)
store double %16, double* %3
br label %31
17: ; preds = %9
%18 = load i32, i32* @M_E
%19 = load i32, i32* %4
%20 = load i32, i32* %4
%21 = mul nsw i32 %19, %20
%22 = sub nsw i32 0, %21
%23 = sitofp i32 %22 to double
%24 = load double, double* %5
%25 = fmul double 2.000000e+00, %24
%26 = load double, double* %5
%27 = fmul double %25, %26
%28 = fdiv double %23, %27
%29 = fptosi double %28 to i32
%30 = call double @pow(i32 %18, i32 %29)
store double %30, double* %3
br label %31
31: ; preds = %17, %12, %8
%32 = load double, double* %3
ret double %32
}

LLVM IR (-O2):
@M_E = global i32 0
define double @gauss_distribution(i32 %0, double %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %18, label %4
4: ; preds = %2, %4
%5 = phi i32 [ %7, %4 ], [ %0, %2 ]
%6 = icmp slt i32 %5, 0
%7 = sub nsw i32 0, %5
br i1 %6, label %4, label %8
8: ; preds = %4
%9 = load i32, i32* @M_E
%10 = mul i32 %5, %5
%11 = sub i32 0, %10
%12 = sitofp i32 %11 to double
%13 = fmul double %1, 2.000000e+00
%14 = fmul double %13, %1
%15 = fdiv double %12, %14
%16 = fptosi double %15 to i32
%17 = tail call double @pow(i32 %9, i32 %16)
br label %18
18: ; preds = %2, %8
%19 = phi double [ %17, %8 ], [ 1.000000e+00, %2 ]
ret double %19
}