#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 RAND_MAX;
double cos(int);
int log(double);
double rand();
double sqrt(int);
double gauss(double u, double std) {
  double x = (rand() + 1.0) / (RAND_MAX + 1.0);
  double y = (rand() + 1.0) / (RAND_MAX + 1.0);
  x = sqrt(-2 * log(y)) * cos(2 * 3.14159265358979323846 * x);
  return (x + u) * std;
}


x86 assembly (clang, -O0):
<gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movsd  0xea7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe9b(%rip),%xmm1
mov    0x2e74(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
movsd  0xe78(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe6c(%rip),%xmm1
mov    0x2e45(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe2e(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauss>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movsd  0xea0(%rip),%xmm2
addsd  %xmm2,%xmm0
mov    0x2e7d(%rip),%rbx
movsd  (%rbx),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movsd  0xe74(%rip),%xmm1
addsd  %xmm1,%xmm0
addsd  (%rbx),%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
lea    (%rax,%rax,1),%edi
neg    %edi
call   1050 <sqrt@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe4e(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mulsd  (%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define double @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 %7, 1.000000e+00
%9 = load double, double* @RAND_MAX
%10 = fadd double %9, 1.000000e+00
%11 = fdiv double %8, %10
store double %11, double* %5
%12 = call double (...) @rand()
%13 = fadd double %12, 1.000000e+00
%14 = load double, double* @RAND_MAX
%15 = fadd double %14, 1.000000e+00
%16 = fdiv double %13, %15
store double %16, double* %6
%17 = load double, double* %6
%18 = call i32 @log(double %17)
%19 = mul nsw i32 -2, %18
%20 = call double @sqrt(i32 %19)
%21 = load double, double* %5
%22 = fmul double 0x401921FB54442D18, %21
%23 = fptosi double %22 to i32
%24 = call double @cos(i32 %23)
%25 = fmul double %20, %24
store double %25, double* %5
%26 = load double, double* %5
%27 = load double, double* %3
%28 = fadd double %26, %27
%29 = load double, double* %4
%30 = fmul double %28, %29
ret double %30
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define double @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, 1.000000e+00
%7 = fdiv double %4, %6
%8 = tail call double (...) @rand()
%9 = fadd double %8, 1.000000e+00
%10 = load double, double* @RAND_MAX
%11 = fadd double %10, 1.000000e+00
%12 = fdiv double %9, %11
%13 = tail call i32 @log(double %12)
%14 = mul nsw i32 %13, -2
%15 = tail call double @sqrt(i32 %14)
%16 = fmul double %7, 0x401921FB54442D18
%17 = fptosi double %16 to i32
%18 = tail call double @cos(i32 %17)
%19 = fmul double %15, %18
%20 = fadd double %19, %0
%21 = fmul double %20, %1
ret double %21
}