#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 */
scalar_t__ brrand();
float gaussian() {
  int j;
  int N = 12;
  int halfN = 6;
  int scale = 1;
  float output;
  float sigma = .166666;
  float mu = .5;
  float randnum;
  randnum = 0.0;
  for (j = 0; j < N; j++) {
    randnum += brrand();
  }
  output = -1.0;
  while ((output < 0.0) && (output > 1.0)) {
    output = sigma * scale * (randnum - halfN) + mu;
  }
  return (output);
}


x86 assembly (clang, -O0):
<gaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0xc,-0x8(%rbp)
movl   $0x6,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movss  0xecf(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xebe(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1186 <gaussian+0x76>
mov    $0x0,%al
call   1030 <brrand@plt>
cvtsi2ss %rax,%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1156 <gaussian+0x46>
movss  0xe7a(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xor    %eax,%eax
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jbe    11c9 <gaussian+0xb9>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe51(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11d9 <gaussian+0xc9>
jmp    120c <gaussian+0xfc>
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  -0x20(%rbp),%xmm2
cvtsi2ssl -0xc(%rbp),%xmm1
subss  %xmm1,%xmm2
movss  -0x1c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1193 <gaussian+0x83>
movss  -0x14(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussian>:
push   %rax
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
xor    %eax,%eax
call   1030 <brrand@plt>
movss  0xe93(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @gaussian() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store i32 12, i32* %2
store i32 6, i32* %3
store i32 1, i32* %4
store float 0x3FC5554FC0000000, float* %6
store float 5.000000e-01, float* %7
store float 0.000000e+00, float* %8
store i32 0, i32* %1
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = call i64 (...) @brrand()
%15 = sitofp i64 %14 to float
%16 = load float, float* %8
%17 = fadd float %16, %15
store float %17, float* %8
br label %18
18: ; preds = %13
%19 = load i32, i32* %1
%20 = add nsw i32 %19, 1
store i32 %20, i32* %1
br label %9
21: ; preds = %9
store float -1.000000e+00, float* %5
br label %22
22: ; preds = %32, %21
%23 = load float, float* %5
%24 = fpext float %23 to double
%25 = fcmp olt double %24, 0.000000e+00
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load float, float* %5
%28 = fpext float %27 to double
%29 = fcmp ogt double %28, 1.000000e+00
br label %30
30: ; preds = %26, %22
%31 = phi i1 [ false, %22 ], [ %29, %26 ]
br i1 %31, label %32, label %43
32: ; preds = %30
%33 = load float, float* %6
%34 = load i32, i32* %4
%35 = sitofp i32 %34 to float
%36 = fmul float %33, %35
%37 = load float, float* %8
%38 = load i32, i32* %3
%39 = sitofp i32 %38 to float
%40 = fsub float %37, %39
%41 = load float, float* %7
%42 = call float @llvm.fmuladd.f32(float %36, float %40, float %41)
store float %42, float* %5
br label %22
43: ; preds = %30
%44 = load float, float* %5
ret float %44
}

LLVM IR (-O2):
define float @gaussian() {
%1 = tail call i64 (...) @brrand()
%2 = tail call i64 (...) @brrand()
%3 = tail call i64 (...) @brrand()
%4 = tail call i64 (...) @brrand()
%5 = tail call i64 (...) @brrand()
%6 = tail call i64 (...) @brrand()
%7 = tail call i64 (...) @brrand()
%8 = tail call i64 (...) @brrand()
%9 = tail call i64 (...) @brrand()
%10 = tail call i64 (...) @brrand()
%11 = tail call i64 (...) @brrand()
%12 = tail call i64 (...) @brrand()
ret float -1.000000e+00
}