#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 rndu();
int sqrt(double);
double rndt4(void) {
  double u, v, w, c2, r2, t4, sqrt2 = 0.707106781;
  for (;;) {
    u = 2 * rndu() - 1;
    v = 2 * rndu() - 1;
    w = u * u + v * v;
    if (w < 1)
      break;
  }
  c2 = u * u / w;
  r2 = 4 / sqrt(w) - 4;
  t4 = sqrt(r2 * c2);
  if (rndu() < 0.5)
    t4 = -t4;
  return t4 * sqrt2;
}


x86 assembly (clang, -O0):
<rndt4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1030 <rndu@plt>
addsd  %xmm0,%xmm0
movsd  0xec8(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <rndu@plt>
addsd  %xmm0,%xmm0
movsd  0xeac(%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,-0x18(%rbp)
movsd  0xe72(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a6 <rndt4+0x86>
jmp    11ab <rndt4+0x8b>
jmp    1135 <rndt4+0x15>
movsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cltd
idiv   %ecx
sub    $0x4,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1030 <rndu@plt>
movaps %xmm0,%xmm1
movsd  0xe0f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1234 <rndt4+0x114>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rndt4>:
sub    $0x18,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <rndu@plt>
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xeb9(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
xor    %eax,%eax
call   1030 <rndu@plt>
addsd  %xmm0,%xmm0
addsd  0xe9d(%rip),%xmm0
mulsd  %xmm0,%xmm0
movsd  (%rsp),%xmm2
mulsd  %xmm2,%xmm2
movapd %xmm2,%xmm1
addsd  %xmm2,%xmm0
movsd  0xe88(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1130 <rndt4+0x10>
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    $0x4,%eax
xor    %edx,%edx
idiv   %ecx
add    $0xfffffffc,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rndu@plt>
movapd 0xe52(%rip),%xmm1
movapd (%rsp),%xmm2
xorpd  %xmm2,%xmm1
cmpltsd 0xe30(%rip),%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
mulsd  0xe24(%rip),%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @rndt4() {
br label %1
1: ; preds = %1, %0
%2 = tail call double (...) @rndu()
%3 = tail call double @llvm.fmuladd.f64(double %2, double 2.000000e+00, double -1.000000e+00)
%4 = tail call double (...) @rndu()
%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 olt double %7, 1.000000e+00
br i1 %8, label %9, label %1
9: ; preds = %1
%10 = fmul double %3, %3
%11 = fdiv double %10, %7
%12 = tail call i32 @sqrt(double %7)
%13 = sdiv i32 4, %12
%14 = add nsw i32 %13, -4
%15 = sitofp i32 %14 to double
%16 = fmul double %11, %15
%17 = tail call i32 @sqrt(double %16)
%18 = sitofp i32 %17 to double
%19 = tail call double (...) @rndu()
%20 = fcmp olt double %19, 5.000000e-01
%21 = fneg double %18
%22 = select i1 %20, double %21, double %18
%23 = fmul double %22, 0x3FE6A09E6665983E
ret double %23
}