#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 cos(double);
double drand48();
double log(double);
double sin(double);
double sqrt(double);
void normalDistRand(double stdDev, double *randomNumbers) {
  double radius = sqrt(-2.0 * log(drand48()));
  double angle = 2.0 * M_PI * drand48();
  randomNumbers[0] = stdDev * radius * sin(angle);
  randomNumbers[1] = stdDev * radius * cos(angle);
}


x86 assembly (clang, -O0):
<normalDistRand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <drand48@plt>
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe90(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe72(%rip),%xmm0
mov    0x2e53(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1070 <drand48@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalDistRand>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1070 <drand48@plt>
call   1050 <log@plt>
mulsd  0xe8e(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1182 <normalDistRand+0x32>
sqrtsd %xmm0,%xmm0
jmp    1187 <normalDistRand+0x37>
call   1060 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x2e54(%rip),%rax
movsd  (%rax),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1070 <drand48@plt>
movapd %xmm0,%xmm1
mulsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @normalDistRand(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 (...) @drand48()
%8 = call double @log(double %7)
%9 = fmul double -2.000000e+00, %8
%10 = call double @sqrt(double %9)
store double %10, double* %5
%11 = load double, double* @M_PI
%12 = fmul double 2.000000e+00, %11
%13 = call double (...) @drand48()
%14 = fmul double %12, %13
store double %14, double* %6
%15 = load double, double* %3
%16 = load double, double* %5
%17 = fmul double %15, %16
%18 = load double, double* %6
%19 = call double @sin(double %18)
%20 = fmul double %17, %19
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
store double %20, double* %22
%23 = load double, double* %3
%24 = load double, double* %5
%25 = fmul double %23, %24
%26 = load double, double* %6
%27 = call double @cos(double %26)
%28 = fmul double %25, %27
%29 = load double*, double** %4
%30 = getelementptr inbounds double, double* %29, i64 1
store double %28, double* %30
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @normalDistRand(double %0, double* nocapture writeonly %1) {
%3 = tail call double (...) @drand48()
%4 = tail call double @log(double %3)
%5 = fmul double %4, -2.000000e+00
%6 = tail call double @sqrt(double %5)
%7 = load double, double* @M_PI
%8 = fmul double %7, 2.000000e+00
%9 = tail call double (...) @drand48()
%10 = fmul double %8, %9
%11 = fmul double %6, %0
%12 = tail call double @sin(double %10)
%13 = fmul double %11, %12
store double %13, double* %1
%14 = tail call double @cos(double %10)
%15 = fmul double %11, %14
%16 = getelementptr inbounds double, double* %1, i64 1
store double %15, double* %16
ret void
}