#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;
  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;
}


x86 assembly (clang, -O0):
<rndt4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <rndu@plt>
addsd  %xmm0,%xmm0
movsd  0xecd(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <rndu@plt>
addsd  %xmm0,%xmm0
movsd  0xeb1(%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  0xe77(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1199 <rndt4+0x79>
jmp    119e <rndt4+0x7e>
jmp    1128 <rndt4+0x8>
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  0xe14(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1227 <rndt4+0x107>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x30,%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
cmpltsd 0xe39(%rip),%xmm0
movapd (%rsp),%xmm2
xorpd  %xmm2,%xmm1
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%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
br label %7
7: ; preds = %21, %0
%8 = call double (...) @rndu()
%9 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %8, double -1.000000e+00)
store double %9, double* %1
%10 = call double (...) @rndu()
%11 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %10, double -1.000000e+00)
store double %11, double* %2
%12 = load double, double* %1
%13 = load double, double* %1
%14 = load double, double* %2
%15 = load double, double* %2
%16 = fmul double %14, %15
%17 = call double @llvm.fmuladd.f64(double %12, double %13, double %16)
store double %17, double* %3
%18 = load double, double* %3
%19 = fcmp olt double %18, 1.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %7
br label %22
21: ; preds = %7
br label %7
22: ; preds = %20
%23 = load double, double* %1
%24 = load double, double* %1
%25 = fmul double %23, %24
%26 = load double, double* %3
%27 = fdiv double %25, %26
store double %27, double* %4
%28 = load double, double* %3
%29 = call i32 @sqrt(double %28)
%30 = sdiv i32 4, %29
%31 = sub nsw i32 %30, 4
%32 = sitofp i32 %31 to double
store double %32, double* %5
%33 = load double, double* %5
%34 = load double, double* %4
%35 = fmul double %33, %34
%36 = call i32 @sqrt(double %35)
%37 = sitofp i32 %36 to double
store double %37, double* %6
%38 = call double (...) @rndu()
%39 = fcmp olt double %38, 5.000000e-01
br i1 %39, label %40, label %43
40: ; preds = %22
%41 = load double, double* %6
%42 = fneg double %41
store double %42, double* %6
br label %43
43: ; preds = %40, %22
%44 = load double, double* %6
ret double %44
}

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
ret double %22
}