#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 M_PI;
double RAND_MAX;
double cos(double);
double log(double);
double rand();
double sqrt(double);
double rand_gauss(double a, double b) {
  double s, t;
  s = (1.0 + rand()) / (RAND_MAX + 2.0);
  t = rand() * 2.0 * M_PI / (RAND_MAX + 1.0);
  return a + b * sqrt(-2.0 * log(s)) * cos(t);
}


x86 assembly (clang, -O0):
<rand_gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movaps %xmm0,%xmm1
movsd  0xea4(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  0xea0(%rip),%xmm1
mov    0x2e69(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movsd  0xe7d(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e4a(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe5e(%rip),%xmm1
mov    0x2e2f(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe19(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_gauss>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
addsd  0xea1(%rip),%xmm0
mov    0x2e7a(%rip),%rbx
movsd  (%rbx),%xmm1
addsd  0xe96(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
addsd  %xmm0,%xmm0
mov    0x2e5a(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xe66(%rip),%xmm1
addsd  (%rbx),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <log@plt>
mulsd  0xe55(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11cb <rand_gauss+0x8b>
sqrtsd %xmm0,%xmm0
jmp    11d0 <rand_gauss+0x90>
call   1050 <sqrt@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <cos@plt>
mulsd  (%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @rand_gauss(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store double %1, double* %4
%7 = call double (...) @rand()
%8 = fadd double 1.000000e+00, %7
%9 = load double, double* @RAND_MAX
%10 = fadd double %9, 2.000000e+00
%11 = fdiv double %8, %10
store double %11, double* %5
%12 = call double (...) @rand()
%13 = fmul double %12, 2.000000e+00
%14 = load double, double* @M_PI
%15 = fmul double %13, %14
%16 = load double, double* @RAND_MAX
%17 = fadd double %16, 1.000000e+00
%18 = fdiv double %15, %17
store double %18, double* %6
%19 = load double, double* %3
%20 = load double, double* %4
%21 = load double, double* %5
%22 = call double @log(double %21)
%23 = fmul double -2.000000e+00, %22
%24 = call double @sqrt(double %23)
%25 = fmul double %20, %24
%26 = load double, double* %6
%27 = call double @cos(double %26)
%28 = call double @llvm.fmuladd.f64(double %25, double %27, double %19)
ret double %28
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @rand_gauss(double %0, double %1) {
%3 = tail call double (...) @rand()
%4 = fadd double %3, 1.000000e+00
%5 = load double, double* @RAND_MAX
%6 = fadd double %5, 2.000000e+00
%7 = fdiv double %4, %6
%8 = tail call double (...) @rand()
%9 = fmul double %8, 2.000000e+00
%10 = load double, double* @M_PI
%11 = fmul double %9, %10
%12 = load double, double* @RAND_MAX
%13 = fadd double %12, 1.000000e+00
%14 = fdiv double %11, %13
%15 = tail call double @log(double %7)
%16 = fmul double %15, -2.000000e+00
%17 = tail call double @sqrt(double %16)
%18 = fmul double %17, %1
%19 = tail call double @cos(double %14)
%20 = tail call double @llvm.fmuladd.f64(double %18, double %19, double %0)
ret double %20
}