#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__ s_brrand();
float rgaussian(float sigma, float mu) {
  int j;
  int N = 12;
  int halfN = 6;
  int scale = 1;
  float output;
  float randnum;
  const float minval = mu - sigma;
  const float maxval = mu + sigma;
  randnum = 0.0;
  for (j = 0; j < N; j++) {
    randnum += s_brrand();
  }
  output = -1.0;
  while ((output < minval) && (output > maxval)) {
    output = sigma * scale * (randnum - halfN) + mu;
  }
  return (output);
}


x86 assembly (clang, -O0):
<rgaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movl   $0xc,-0x10(%rbp)
movl   $0x6,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1194 <rgaussian+0x84>
mov    $0x0,%al
call   1030 <s_brrand@plt>
cvtsi2ss %rax,%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <rgaussian+0x54>
movss  0xe64(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  -0x24(%rbp),%xmm0
xor    %eax,%eax
ucomiss %xmm1,%xmm0
mov    %al,-0x29(%rbp)
jbe    11c8 <rgaussian+0xb8>
movss  -0x1c(%rbp),%xmm0
ucomiss -0x28(%rbp),%xmm0
seta   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11d8 <rgaussian+0xc8>
jmp    120b <rgaussian+0xfb>
movss  -0x4(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  -0x20(%rbp),%xmm2
cvtsi2ssl -0x14(%rbp),%xmm1
subss  %xmm1,%xmm2
movss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11a1 <rgaussian+0x91>
movss  -0x1c(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgaussian>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0x4(%rsp)
subss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,0x30(%rsp)
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,0x28(%rsp)
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,0x20(%rsp)
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,0x18(%rsp)
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1030 <s_brrand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <s_brrand@plt>
movss  0xc(%rsp),%xmm5
movss  0xe3f(%rip),%xmm0
ucomiss %xmm0,%xmm5
jbe    12a2 <rgaussian+0x192>
movss  0x4(%rsp),%xmm6
movaps %xmm6,%xmm1
movss  0x8(%rsp),%xmm4
addss  %xmm4,%xmm1
movss  0xe1b(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    12a2 <rgaussian+0x192>
xorps  %xmm0,%xmm0
cvtsi2ssq 0x30(%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtsi2ssq 0x28(%rsp),%xmm2
cvtsi2ssq 0x20(%rsp),%xmm3
addss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2ssq 0x18(%rsp),%xmm0
addss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtsi2ssq 0x10(%rsp),%xmm2
addss  %xmm3,%xmm0
xorps  %xmm3,%xmm3
cvtsi2ss %rbp,%xmm3
addss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2ss %r14,%xmm0
addss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtsi2ss %r15,%xmm2
addss  %xmm3,%xmm0
xorps  %xmm3,%xmm3
cvtsi2ss %r12,%xmm3
addss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2ss %r13,%xmm0
addss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtsi2ss %rbx,%xmm2
addss  %xmm3,%xmm0
xorps  %xmm3,%xmm3
cvtsi2ss %rax,%xmm3
addss  %xmm0,%xmm2
addss  %xmm2,%xmm3
addss  0xd7b(%rip),%xmm3
mulss  %xmm3,%xmm6
movaps %xmm6,%xmm0
addss  %xmm4,%xmm0
ucomiss %xmm0,%xmm5
jbe    12a2 <rgaussian+0x192>
ucomiss %xmm1,%xmm0
jbe    12a2 <rgaussian+0x192>
xchg   %ax,%ax
jmp    12a0 <rgaussian+0x190>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define float @rgaussian(float %0, float %1) {
%3 = fsub float %1, %0
%4 = tail call i64 (...) @s_brrand()
%5 = tail call i64 (...) @s_brrand()
%6 = tail call i64 (...) @s_brrand()
%7 = tail call i64 (...) @s_brrand()
%8 = tail call i64 (...) @s_brrand()
%9 = tail call i64 (...) @s_brrand()
%10 = tail call i64 (...) @s_brrand()
%11 = tail call i64 (...) @s_brrand()
%12 = tail call i64 (...) @s_brrand()
%13 = tail call i64 (...) @s_brrand()
%14 = tail call i64 (...) @s_brrand()
%15 = tail call i64 (...) @s_brrand()
%16 = fadd float %0, %1
%17 = fcmp ogt float %3, -1.000000e+00
%18 = fcmp olt float %16, -1.000000e+00
%19 = and i1 %17, %18
br i1 %19, label %20, label %50
20: ; preds = %2
%21 = sitofp i64 %4 to float
%22 = sitofp i64 %5 to float
%23 = fadd float %21, %22
%24 = sitofp i64 %6 to float
%25 = fadd float %23, %24
%26 = sitofp i64 %7 to float
%27 = fadd float %25, %26
%28 = sitofp i64 %8 to float
%29 = fadd float %27, %28
%30 = sitofp i64 %9 to float
%31 = fadd float %29, %30
%32 = sitofp i64 %10 to float
%33 = fadd float %31, %32
%34 = sitofp i64 %11 to float
%35 = fadd float %33, %34
%36 = sitofp i64 %12 to float
%37 = fadd float %35, %36
%38 = sitofp i64 %13 to float
%39 = fadd float %37, %38
%40 = sitofp i64 %14 to float
%41 = fadd float %39, %40
%42 = sitofp i64 %15 to float
%43 = fadd float %41, %42
%44 = fadd float %43, -6.000000e+00
%45 = tail call float @llvm.fmuladd.f32(float %0, float %44, float %1)
%46 = fcmp olt float %45, %3
%47 = fcmp ogt float %45, %16
%48 = and i1 %46, %47
br i1 %48, label %49, label %50
49: ; preds = %20, %49
br label %49
50: ; preds = %20, %2
%51 = phi float [ -1.000000e+00, %2 ], [ %45, %20 ]
ret float %51
}