#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;
  int i;
  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
%6 = alloca i32
store double 0x4005BF0A87427F01, double* %4
store double 0x41DFFFFFFFC00000, double* %5
br label %7
7: ; preds = %26, %0
%8 = call double (...) @rand()
%9 = load double, double* %5
%10 = fdiv double %8, %9
%11 = call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double -1.000000e+00)
store double %11, double* %1
%12 = call double (...) @rand()
%13 = load double, double* %5
%14 = fdiv double %12, %13
store double %14, double* %2
%15 = load double, double* %4
%16 = load double, double* %1
%17 = fmul double -4.500000e+00, %16
%18 = load double, double* %1
%19 = fmul double %17, %18
%20 = call double @pow(double %15, double %19)
store double %20, double* %3
%21 = load double, double* %2
%22 = load double, double* %3
%23 = fcmp olt double %21, %22
br i1 %23, label %24, label %26
24: ; preds = %7
%25 = load double, double* %1
ret double %25
26: ; preds = %7
br label %7
}

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
}