#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 log(double);
double random_number();
double sqrt(double);
double gasdevC(void) {
  double fac, rsq, v1, v2;
  do {
    v1 = 2.0 * random_number() - 1.0;
    v2 = 2.0 * random_number() - 1.0;
    rsq = v1 * v1 + v2 * v2;
  } while (rsq >= 1.0 || rsq == 0.0);
  fac = sqrt(-2.0 * log(rsq) / rsq);
  return (double)(v2 * fac);
}


x86 assembly (clang, -O0):
<gasdevC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <random_number@plt>
addsd  %xmm0,%xmm0
movsd  0xeb5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <random_number@plt>
addsd  %xmm0,%xmm0
movsd  0xe99(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
movsd  0xe68(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jae    11c4 <gasdevC+0x94>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1138 <gasdevC+0x8>
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe2c(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gasdevC>:
sub    $0x18,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <random_number@plt>
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xea9(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   1030 <random_number@plt>
addsd  %xmm0,%xmm0
addsd  0xe8c(%rip),%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
ucomisd 0xe76(%rip),%xmm2
jae    1140 <gasdevC+0x10>
movapd %xmm2,%xmm1
ucomisd 0xe78(%rip),%xmm2
jne    11a4 <gasdevC+0x74>
jnp    1140 <gasdevC+0x10>
movsd  %xmm0,0x10(%rsp)
movapd %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1040 <log@plt>
mulsd  0xe4f(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11d7 <gasdevC+0xa7>
sqrtsd %xmm0,%xmm0
jmp    11dc <gasdevC+0xac>
call   1050 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @gasdevC() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
br label %5
5: ; preds = %22, %0
%6 = call double (...) @random_number()
%7 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %6, double -1.000000e+00)
store double %7, double* %3
%8 = call double (...) @random_number()
%9 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %8, double -1.000000e+00)
store double %9, double* %4
%10 = load double, double* %3
%11 = load double, double* %3
%12 = load double, double* %4
%13 = load double, double* %4
%14 = fmul double %12, %13
%15 = call double @llvm.fmuladd.f64(double %10, double %11, double %14)
store double %15, double* %2
br label %16
16: ; preds = %5
%17 = load double, double* %2
%18 = fcmp oge double %17, 1.000000e+00
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load double, double* %2
%21 = fcmp oeq double %20, 0.000000e+00
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ true, %16 ], [ %21, %19 ]
br i1 %23, label %5, label %24
24: ; preds = %22
%25 = load double, double* %2
%26 = call double @log(double %25)
%27 = fmul double -2.000000e+00, %26
%28 = load double, double* %2
%29 = fdiv double %27, %28
%30 = call double @sqrt(double %29)
store double %30, double* %1
%31 = load double, double* %4
%32 = load double, double* %1
%33 = fmul double %31, %32
ret double %33
}

LLVM IR (-O2):
define double @gasdevC() {
br label %1
1: ; preds = %1, %0
%2 = tail call double (...) @random_number()
%3 = tail call double @llvm.fmuladd.f64(double %2, double 2.000000e+00, double -1.000000e+00)
%4 = tail call double (...) @random_number()
%5 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double -1.000000e+00)
%6 = fmul double %5, %5
%7 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %6)
%8 = fcmp oge double %7, 1.000000e+00
%9 = fcmp oeq double %7, 0.000000e+00
%10 = or i1 %8, %9
br i1 %10, label %1, label %11
11: ; preds = %1
%12 = tail call double @log(double %7)
%13 = fmul double %12, -2.000000e+00
%14 = fdiv double %13, %7
%15 = tail call double @sqrt(double %14)
%16 = fmul double %5, %15
ret double %16
}