#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 */
int M_PI;
int RAND_MAX;
int log(double);
scalar_t__ rand();
double sin(int);
double sqrt(int);
double randnormal(double mu, double sigma_2) {
  double x = (double)rand();
  return sqrt(sigma_2) * sqrt(-2 * log(x + 1) / (RAND_MAX + 1)) *
             sin(2 * M_PI * x / (RAND_MAX + 1)) +
         mu;
}


x86 assembly (clang, -O0):
<randnormal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x10(%rbp),%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe86(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%eax
mov    0x2e4f(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randnormal>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si 0x8(%rsp),%edi
call   1050 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe81(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
call   1040 <log@plt>
add    %eax,%eax
neg    %eax
mov    0x2e4b(%rip),%rbx
mov    (%rbx),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1050 <sqrt@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    (%rbx),%eax
add    $0x1,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global i32 0
@M_PI = global i32 0
define double @randnormal(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = call i64 (...) @rand()
%7 = sitofp i64 %6 to double
store double %7, double* %5
%8 = load double, double* %4
%9 = fptosi double %8 to i32
%10 = call double @sqrt(i32 %9)
%11 = load double, double* %5
%12 = fadd double %11, 1.000000e+00
%13 = call i32 @log(double %12)
%14 = mul nsw i32 -2, %13
%15 = load i32, i32* @RAND_MAX
%16 = add nsw i32 %15, 1
%17 = sdiv i32 %14, %16
%18 = call double @sqrt(i32 %17)
%19 = fmul double %10, %18
%20 = load i32, i32* @M_PI
%21 = mul nsw i32 2, %20
%22 = sitofp i32 %21 to double
%23 = load double, double* %5
%24 = fmul double %22, %23
%25 = load i32, i32* @RAND_MAX
%26 = add nsw i32 %25, 1
%27 = sitofp i32 %26 to double
%28 = fdiv double %24, %27
%29 = fptosi double %28 to i32
%30 = call double @sin(i32 %29)
%31 = load double, double* %3
%32 = call double @llvm.fmuladd.f64(double %19, double %30, double %31)
ret double %32
}

LLVM IR (-O2):
@RAND_MAX = global i32 0
@M_PI = global i32 0
define double @randnormal(double %0, double %1) {
%3 = tail call i64 (...) @rand()
%4 = sitofp i64 %3 to double
%5 = fptosi double %1 to i32
%6 = tail call double @sqrt(i32 %5)
%7 = fadd double %4, 1.000000e+00
%8 = tail call i32 @log(double %7)
%9 = mul nsw i32 %8, -2
%10 = load i32, i32* @RAND_MAX
%11 = add nsw i32 %10, 1
%12 = sdiv i32 %9, %11
%13 = tail call double @sqrt(i32 %12)
%14 = fmul double %6, %13
%15 = load i32, i32* @M_PI
%16 = shl nsw i32 %15, 1
%17 = sitofp i32 %16 to double
%18 = fmul double %4, %17
%19 = load i32, i32* @RAND_MAX
%20 = add nsw i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = fdiv double %18, %21
%23 = fptosi double %22 to i32
%24 = tail call double @sin(i32 %23)
%25 = tail call double @llvm.fmuladd.f64(double %14, double %24, double %0)
ret double %25
}