#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 genrand();
double log(double);
double const sqrt(double);
double rng_gauss(const double sigma) {
  double x, y, r2;
  x = 2.0 * genrand() - 1.0;
  do {
    y = 2.0 * genrand() - 1.0;
    r2 = x * x + y * y;
  } while (r2 > 1.0);
  if (r2 == 0.0)
    return 0;
  return sigma * y * sqrt(-2.0 * log(r2) / r2);
}


x86 assembly (clang, -O0):
<rng_gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <genrand@plt>
addsd  %xmm0,%xmm0
movsd  0xeb0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <genrand@plt>
addsd  %xmm0,%xmm0
movsd  0xe94(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe65(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1159 <rng_gauss+0x29>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d2 <rng_gauss+0xa2>
jp     11d2 <rng_gauss+0xa2>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1215 <rng_gauss+0xe5>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe1a(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rng_gauss>:
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <genrand@plt>
addsd  %xmm0,%xmm0
addsd  0xeb3(%rip),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <genrand@plt>
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  0xe89(%rip),%xmm1
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
addsd  0x10(%rsp),%xmm2
ucomisd 0xe7b(%rip),%xmm2
ja     1160 <rng_gauss+0x30>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    11a0 <rng_gauss+0x70>
jp     11a0 <rng_gauss+0x70>
add    $0x18,%rsp
ret
mulsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1040 <log@plt>
mulsd  0xe4d(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11d9 <rng_gauss+0xa9>
sqrtsd %xmm0,%xmm0
jmp    11de <rng_gauss+0xae>
call   1050 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @rng_gauss(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
%7 = call double (...) @genrand()
%8 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %7, double -1.000000e+00)
store double %8, double* %4
br label %9
9: ; preds = %18, %1
%10 = call double (...) @genrand()
%11 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %10, double -1.000000e+00)
store double %11, double* %5
%12 = load double, double* %4
%13 = load double, double* %4
%14 = load double, double* %5
%15 = load double, double* %5
%16 = fmul double %14, %15
%17 = call double @llvm.fmuladd.f64(double %12, double %13, double %16)
store double %17, double* %6
br label %18
18: ; preds = %9
%19 = load double, double* %6
%20 = fcmp ogt double %19, 1.000000e+00
br i1 %20, label %9, label %21
21: ; preds = %18
%22 = load double, double* %6
%23 = fcmp oeq double %22, 0.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %21
store double 0.000000e+00, double* %2
br label %36
25: ; preds = %21
%26 = load double, double* %3
%27 = load double, double* %5
%28 = fmul double %26, %27
%29 = load double, double* %6
%30 = call double @log(double %29)
%31 = fmul double -2.000000e+00, %30
%32 = load double, double* %6
%33 = fdiv double %31, %32
%34 = call double @sqrt(double %33)
%35 = fmul double %28, %34
store double %35, double* %2
br label %36
36: ; preds = %25, %24
%37 = load double, double* %2
ret double %37
}

LLVM IR (-O2):
define double @rng_gauss(double %0) {
%2 = tail call double (...) @genrand()
%3 = tail call double @llvm.fmuladd.f64(double %2, double 2.000000e+00, double -1.000000e+00)
br label %4
4: ; preds = %4, %1
%5 = tail call double (...) @genrand()
%6 = tail call double @llvm.fmuladd.f64(double %5, double 2.000000e+00, double -1.000000e+00)
%7 = fmul double %6, %6
%8 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %7)
%9 = fcmp ogt double %8, 1.000000e+00
br i1 %9, label %4, label %10
10: ; preds = %4
%11 = fcmp oeq double %8, 0.000000e+00
br i1 %11, label %19, label %12
12: ; preds = %10
%13 = fmul double %6, %0
%14 = tail call double @log(double %8)
%15 = fmul double %14, -2.000000e+00
%16 = fdiv double %15, %8
%17 = tail call double @sqrt(double %16)
%18 = fmul double %13, %17
br label %19
19: ; preds = %10, %12
%20 = phi double [ %18, %12 ], [ 0.000000e+00, %10 ]
ret double %20
}