#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 drand2();
double log(double);
double sqrt(double);
double randev1(double a) {
  double x, d, e, c, g, f, r1, r2;
  e = a - 1.0;
  c = 3.0 * a - 0.75;
  for (;;) {
    r1 = (drand2());
    g = r1 - (r1 * r1);
    if (g <= 0.0)
      continue;
    f = (r1 - 0.5) * sqrt(c / g);
    x = e + f;
    if (x <= 0.0)
      continue;
    r2 = (drand2());
    d = 64.0 * r2 * r2 * g * g * g;
    if ((d >= 1.0 - 2.0 * f * f / x) && (log(d) >= 2.0 * (e * log(x / e) - f)))
      continue;
    return (x);
  }
}


x86 assembly (clang, -O0):
<randev1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xec6(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe9c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1030 <drand2@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     11c7 <randev1+0x97>
jmp    1175 <randev1+0x45>
movsd  -0x40(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     121f <randev1+0xef>
jmp    1175 <randev1+0x45>
mov    $0x0,%al
call   1030 <drand2@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xdf5(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdc2(%rip),%xmm2
mulsd  -0x38(%rbp),%xmm2
mulsd  -0x38(%rbp),%xmm2
divsd  -0x10(%rbp),%xmm2
movsd  0xd9b(%rip),%xmm1
subsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     12f7 <randev1+0x1c7>
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  0xd3c(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     12f7 <randev1+0x1c7>
jmp    1175 <randev1+0x45>
movsd  -0x10(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randev1>:
sub    $0x28,%rsp
movsd  0xec4(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  0xeba(%rip),%xmm0
addsd  0xeba(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <drand2@plt>
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm0
movapd %xmm2,%xmm3
subsd  %xmm0,%xmm3
ucomisd %xmm3,%xmm1
jae    1160 <randev1+0x30>
addsd  0xe8f(%rip),%xmm2
movsd  0x20(%rsp),%xmm0
divsd  %xmm3,%xmm0
ucomisd %xmm1,%xmm0
movsd  %xmm3,0x8(%rsp)
jb     11b0 <randev1+0x80>
sqrtsd %xmm0,%xmm0
jmp    11c3 <randev1+0x93>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm2,(%rsp)
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm2
xorpd  %xmm1,%xmm1
mulsd  %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%rsp)
ucomisd %xmm0,%xmm1
jae    1160 <randev1+0x30>
xor    %eax,%eax
movsd  %xmm2,(%rsp)
call   1030 <drand2@plt>
movsd  (%rsp),%xmm3
movapd %xmm0,%xmm1
mulsd  0xe26(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm3,%xmm1
addsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm1
divsd  0x18(%rsp),%xmm1
movsd  0xdfe(%rip),%xmm2
subsd  %xmm1,%xmm2
ucomisd %xmm2,%xmm0
jb     126f <randev1+0x13f>
call   1040 <log@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
call   1040 <log@plt>
mulsd  0x10(%rsp),%xmm0
subsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jae    1160 <randev1+0x30>
movsd  0x18(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @randev1(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %2
%11 = load double, double* %2
%12 = fsub double %11, 1.000000e+00
store double %12, double* %5
%13 = load double, double* %2
%14 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %13, double -7.500000e-01)
store double %14, double* %6
br label %15
15: ; preds = %73, %38, %24, %1
%16 = call double (...) @drand2()
store double %16, double* %9
%17 = load double, double* %9
%18 = load double, double* %9
%19 = load double, double* %9
%20 = fneg double %18
%21 = call double @llvm.fmuladd.f64(double %20, double %19, double %17)
store double %21, double* %7
%22 = load double, double* %7
%23 = fcmp ole double %22, 0.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %15
br label %15
25: ; preds = %15
%26 = load double, double* %9
%27 = fsub double %26, 5.000000e-01
%28 = load double, double* %6
%29 = load double, double* %7
%30 = fdiv double %28, %29
%31 = call double @sqrt(double %30)
%32 = fmul double %27, %31
store double %32, double* %8
%33 = load double, double* %5
%34 = load double, double* %8
%35 = fadd double %33, %34
store double %35, double* %3
%36 = load double, double* %3
%37 = fcmp ole double %36, 0.000000e+00
br i1 %37, label %38, label %39
38: ; preds = %25
br label %15
39: ; preds = %25
%40 = call double (...) @drand2()
store double %40, double* %10
%41 = load double, double* %10
%42 = fmul double 6.400000e+01, %41
%43 = load double, double* %10
%44 = fmul double %42, %43
%45 = load double, double* %7
%46 = fmul double %44, %45
%47 = load double, double* %7
%48 = fmul double %46, %47
%49 = load double, double* %7
%50 = fmul double %48, %49
store double %50, double* %4
%51 = load double, double* %4
%52 = load double, double* %8
%53 = fmul double 2.000000e+00, %52
%54 = load double, double* %8
%55 = fmul double %53, %54
%56 = load double, double* %3
%57 = fdiv double %55, %56
%58 = fsub double 1.000000e+00, %57
%59 = fcmp oge double %51, %58
br i1 %59, label %60, label %74
60: ; preds = %39
%61 = load double, double* %4
%62 = call double @log(double %61)
%63 = load double, double* %5
%64 = load double, double* %3
%65 = load double, double* %5
%66 = fdiv double %64, %65
%67 = call double @log(double %66)
%68 = load double, double* %8
%69 = fneg double %68
%70 = call double @llvm.fmuladd.f64(double %63, double %67, double %69)
%71 = fmul double 2.000000e+00, %70
%72 = fcmp oge double %62, %71
br i1 %72, label %73, label %74
73: ; preds = %60
br label %15
74: ; preds = %60, %39
%75 = load double, double* %3
ret double %75
}

LLVM IR (-O2):
define double @randev1(double %0) {
%2 = fadd double %0, -1.000000e+00
%3 = tail call double @llvm.fmuladd.f64(double %0, double 3.000000e+00, double -7.500000e-01)
br label %4
4: ; preds = %9, %1
%5 = tail call double (...) @drand2()
%6 = fneg double %5
%7 = tail call double @llvm.fmuladd.f64(double %6, double %5, double %5)
%8 = fcmp ugt double %7, 0.000000e+00
br i1 %8, label %10, label %9
9: ; preds = %4, %10, %29
br label %4
10: ; preds = %4
%11 = fadd double %5, -5.000000e-01
%12 = fdiv double %3, %7
%13 = tail call double @sqrt(double %12)
%14 = fmul double %11, %13
%15 = fadd double %2, %14
%16 = fcmp ugt double %15, 0.000000e+00
br i1 %16, label %17, label %9
17: ; preds = %10
%18 = tail call double (...) @drand2()
%19 = fmul double %18, 6.400000e+01
%20 = fmul double %18, %19
%21 = fmul double %7, %20
%22 = fmul double %7, %21
%23 = fmul double %7, %22
%24 = fmul double %14, 2.000000e+00
%25 = fmul double %14, %24
%26 = fdiv double %25, %15
%27 = fsub double 1.000000e+00, %26
%28 = fcmp ult double %23, %27
br i1 %28, label %37, label %29
29: ; preds = %17
%30 = tail call double @log(double %23)
%31 = fdiv double %15, %2
%32 = tail call double @log(double %31)
%33 = fneg double %14
%34 = tail call double @llvm.fmuladd.f64(double %2, double %32, double %33)
%35 = fmul double %34, 2.000000e+00
%36 = fcmp ult double %30, %35
br i1 %36, label %37, label %9
37: ; preds = %29, %17
ret double %15
}