#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 pow(double, double);
double rand();
double gaus() {
  double rnd_x, rnd_y, gauss;
  double e = 2.7182818, rmax = 2147483647;
  for (;;) {
    rnd_x = (rand() / rmax * 2 - 1);
    rnd_y = (rand() / rmax);
    gauss = pow(e, -0.5 * 9 * rnd_x * rnd_x);
    if (rnd_y < gauss)
      return rnd_x;
  }
}


x86 assembly (clang, -O0):
<gaus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  0xed8(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
divsd  -0x28(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xebe(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe8f(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b4 <gaus+0x94>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret
jmp    1142 <gaus+0x22>

x86 assembly (clang, -O2):
<gaus>:
sub    $0x18,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <rand@plt>
movapd %xmm0,%xmm1
movsd  0xebd(%rip),%xmm0
divsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
addsd  0xeb5(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
divsd  0xe98(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
mulsd  0xe90(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
call   1030 <pow@plt>
ucomisd 0x10(%rsp),%xmm0
jbe    1130 <gaus+0x10>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @gaus() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double 0x4005BF0A87427F01, double* %4
store double 0x41DFFFFFFFC00000, double* %5
br label %6
6: ; preds = %25, %0
%7 = call double (...) @rand()
%8 = load double, double* %5
%9 = fdiv double %7, %8
%10 = call double @llvm.fmuladd.f64(double %9, double 2.000000e+00, double -1.000000e+00)
store double %10, double* %1
%11 = call double (...) @rand()
%12 = load double, double* %5
%13 = fdiv double %11, %12
store double %13, double* %2
%14 = load double, double* %4
%15 = load double, double* %1
%16 = fmul double -4.500000e+00, %15
%17 = load double, double* %1
%18 = fmul double %16, %17
%19 = call double @pow(double %14, double %18)
store double %19, double* %3
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fcmp olt double %20, %21
br i1 %22, label %23, label %25
23: ; preds = %6
%24 = load double, double* %1
ret double %24
25: ; preds = %6
br label %6
}

LLVM IR (-O2):
define double @gaus() {
br label %1
1: ; preds = %1, %0
%2 = tail call double (...) @rand()
%3 = fdiv double %2, 0x41DFFFFFFFC00000
%4 = tail call double @llvm.fmuladd.f64(double %3, double 2.000000e+00, double -1.000000e+00)
%5 = tail call double (...) @rand()
%6 = fdiv double %5, 0x41DFFFFFFFC00000
%7 = fmul double %4, -4.500000e+00
%8 = fmul double %4, %7
%9 = tail call double @pow(double 0x4005BF0A87427F01, double %8)
%10 = fcmp olt double %6, %9
br i1 %10, label %11, label %1
11: ; preds = %1
ret double %4
}