#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 log(double);
scalar_t__ randomMT();
double sqrt(int);
double normrand2(void) {
  double x1, x2, n1, n2, rad;
  rad = 2;
  while (rad >= 1) {
    x1 = (double)(((unsigned long)randomMT()) / 4294967296.) * 2 - 1;
    x2 = (double)(((unsigned long)randomMT()) / 4294967296.) * 2 - 1;
    rad = x1 * x1 + x2 * x2;
  }
  n1 = x1 * sqrt(-2 * log(rad) / rad);
  n2 = x2 * sqrt(-2 * log(rad) / rad);
  return (n1);
}


x86 assembly (clang, -O0):
<normrand2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  0xec0(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1228 <normrand2+0xf8>
xor    %eax,%eax
mov    %al,-0x51(%rbp)
call   1030 <randomMT@plt>
mov    %rax,%rcx
mov    -0x51(%rbp),%al
movq   %rcx,%xmm0
movaps 0xea8(%rip),%xmm1
movaps %xmm1,-0x50(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xea8(%rip),%xmm1
movaps %xmm1,-0x40(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe75(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
movsd  0xe5d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
call   1030 <randomMT@plt>
movaps -0x50(%rbp),%xmm2
movaps -0x40(%rbp),%xmm1
movq   %rax,%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe2f(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
movsd  0xe17(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1145 <normrand2+0x15>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%eax
cvtsi2sd %eax,%xmm0
divsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%eax
cvtsi2sd %eax,%xmm0
divsd  -0x28(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normrand2>:
sub    $0x28,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <randomMT@plt>
movq   %rax,%xmm0
movdqa 0xeac(%rip),%xmm1
punpckldq %xmm1,%xmm0
movapd 0xeb0(%rip),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xea8(%rip),%xmm0
mulsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  0xea0(%rip),%xmm0
addsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
xor    %eax,%eax
call   1030 <randomMT@plt>
movq   %rax,%xmm0
punpckldq 0xe5b(%rip),%xmm0
subpd  0xe63(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe5f(%rip),%xmm1
addsd  %xmm1,%xmm1
addsd  0xe5b(%rip),%xmm1
mulsd  %xmm1,%xmm1
movapd (%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd 0xe4a(%rip),%xmm0
jae    1140 <normrand2+0x10>
movapd %xmm0,0x10(%rsp)
call   1040 <log@plt>
add    %eax,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movaps 0x10(%rsp),%xmm0
call   1040 <log@plt>
add    %eax,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @normrand2() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double 2.000000e+00, double* %5
br label %6
6: ; preds = %9, %0
%7 = load double, double* %5
%8 = fcmp oge double %7, 1.000000e+00
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = call i64 (...) @randomMT()
%11 = uitofp i64 %10 to double
%12 = fdiv double %11, 0x41F0000000000000
%13 = call double @llvm.fmuladd.f64(double %12, double 2.000000e+00, double -1.000000e+00)
store double %13, double* %1
%14 = call i64 (...) @randomMT()
%15 = uitofp i64 %14 to double
%16 = fdiv double %15, 0x41F0000000000000
%17 = call double @llvm.fmuladd.f64(double %16, double 2.000000e+00, double -1.000000e+00)
store double %17, double* %2
%18 = load double, double* %1
%19 = load double, double* %1
%20 = load double, double* %2
%21 = load double, double* %2
%22 = fmul double %20, %21
%23 = call double @llvm.fmuladd.f64(double %18, double %19, double %22)
store double %23, double* %5
br label %6
24: ; preds = %6
%25 = load double, double* %1
%26 = load double, double* %5
%27 = call i32 @log(double %26)
%28 = mul nsw i32 -2, %27
%29 = sitofp i32 %28 to double
%30 = load double, double* %5
%31 = fdiv double %29, %30
%32 = fptosi double %31 to i32
%33 = call double @sqrt(i32 %32)
%34 = fmul double %25, %33
store double %34, double* %3
%35 = load double, double* %2
%36 = load double, double* %5
%37 = call i32 @log(double %36)
%38 = mul nsw i32 -2, %37
%39 = sitofp i32 %38 to double
%40 = load double, double* %5
%41 = fdiv double %39, %40
%42 = fptosi double %41 to i32
%43 = call double @sqrt(i32 %42)
%44 = fmul double %35, %43
store double %44, double* %4
%45 = load double, double* %3
ret double %45
}

LLVM IR (-O2):
define double @normrand2() {
br label %1
1: ; preds = %0, %1
%2 = tail call i64 (...) @randomMT()
%3 = uitofp i64 %2 to double
%4 = fmul double %3, 0x3DF0000000000000
%5 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double -1.000000e+00)
%6 = tail call i64 (...) @randomMT()
%7 = uitofp i64 %6 to double
%8 = fmul double %7, 0x3DF0000000000000
%9 = tail call double @llvm.fmuladd.f64(double %8, double 2.000000e+00, double -1.000000e+00)
%10 = fmul double %9, %9
%11 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %10)
%12 = fcmp ult double %11, 1.000000e+00
br i1 %12, label %13, label %1
13: ; preds = %1
%14 = tail call i32 @log(double %11)
%15 = mul nsw i32 %14, -2
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, %11
%18 = fptosi double %17 to i32
%19 = tail call double @sqrt(i32 %18)
%20 = fmul double %5, %19
%21 = tail call i32 @log(double %11)
%22 = mul nsw i32 %21, -2
%23 = sitofp i32 %22 to double
%24 = fdiv double %23, %11
%25 = fptosi double %24 to i32
%26 = tail call double @sqrt(i32 %25)
ret double %20
}