#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();
double sqrt(int);
double rndt2(void) {
  double u, t2;
  u = 2 * rndu() - 1;
  u *= u;
  t2 = sqrt(2 * u / (1 - u));
  if (rndu() < 0.5)
    t2 = -t2;
  return t2;
}


x86 assembly (clang, -O0):
<rndt2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <rndu@plt>
addsd  %xmm0,%xmm0
movsd  0xedd(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xeb5(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
subsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rndu@plt>
movaps %xmm0,%xmm1
movsd  0xe6f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bc <rndt2+0x9c>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rndt2>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1030 <rndu@plt>
addsd  %xmm0,%xmm0
addsd  0xec9(%rip),%xmm0
mulsd  %xmm0,%xmm0
movsd  0xec5(%rip),%xmm1
subsd  %xmm0,%xmm1
addsd  %xmm0,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rndu@plt>
movapd 0xeb4(%rip),%xmm1
cmpltsd 0xe9b(%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 @rndt2() {
%1 = alloca double
%2 = alloca double
%3 = call double (...) @rndu()
%4 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %3, double -1.000000e+00)
store double %4, double* %1
%5 = load double, double* %1
%6 = load double, double* %1
%7 = fmul double %6, %5
store double %7, double* %1
%8 = load double, double* %1
%9 = fmul double 2.000000e+00, %8
%10 = load double, double* %1
%11 = fsub double 1.000000e+00, %10
%12 = fdiv double %9, %11
%13 = fptosi double %12 to i32
%14 = call double @sqrt(i32 %13)
store double %14, double* %2
%15 = call double (...) @rndu()
%16 = fcmp olt double %15, 5.000000e-01
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = load double, double* %2
%19 = fneg double %18
store double %19, double* %2
br label %20
20: ; preds = %17, %0
%21 = load double, double* %2
ret double %21
}

LLVM IR (-O2):
define double @rndt2() {
%1 = tail call double (...) @rndu()
%2 = tail call double @llvm.fmuladd.f64(double %1, double 2.000000e+00, double -1.000000e+00)
%3 = fmul double %2, %2
%4 = fmul double %3, 2.000000e+00
%5 = fsub double 1.000000e+00, %3
%6 = fdiv double %4, %5
%7 = fptosi double %6 to i32
%8 = tail call double @sqrt(i32 %7)
%9 = tail call double (...) @rndu()
%10 = fcmp olt double %9, 5.000000e-01
%11 = fneg double %8
%12 = select i1 %10, double %11, double %8
ret double %12
}