#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 */
float sqrtf(float);
float tpdf(unsigned int urandom) {
  float frandom = (float)urandom / (float)0xFFFFFFFFu;
  return (frandom < 0.5f ? (sqrtf(2.0f * frandom) - 1.0f)
                         : (1.0f - sqrtf(2.0f * (1.0f - frandom))));
}


x86 assembly (clang, -O0):
<tpdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cvtsi2ss %rax,%xmm0
movss  0xed9(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xec4(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    116e <tpdf+0x5e>
movss  0xebe(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
call   1030 <sqrtf@plt>
movss  0xea8(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11a0 <tpdf+0x90>
movss  0xe92(%rip),%xmm1
subss  -0x8(%rbp),%xmm1
movss  0xe89(%rip),%xmm0
mulss  %xmm1,%xmm0
call   1030 <sqrtf@plt>
movaps %xmm0,%xmm1
movss  0xe71(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tpdf>:
push   %rax
mov    %edi,%eax
cvtsi2ss %rax,%xmm0
mulss  0xee0(%rip),%xmm0
movss  0xedc(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1147 <tpdf+0x37>
addss  %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     116b <tpdf+0x5b>
sqrtss %xmm0,%xmm2
addss  0xec7(%rip),%xmm2
jmp    1191 <tpdf+0x81>
movss  0xeb9(%rip),%xmm2
movaps %xmm2,%xmm1
subss  %xmm0,%xmm1
addss  %xmm1,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jb     117d <tpdf+0x6d>
xorps  %xmm0,%xmm0
sqrtss %xmm1,%xmm0
jmp    118d <tpdf+0x7d>
call   1030 <sqrtf@plt>
movaps %xmm0,%xmm2
addss  0xe91(%rip),%xmm2
jmp    1191 <tpdf+0x81>
movaps %xmm1,%xmm0
call   1030 <sqrtf@plt>
movss  0xe7b(%rip),%xmm2
subss  %xmm0,%xmm2
movaps %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @tpdf(i32 %0) {
%2 = alloca i32
%3 = alloca float
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = uitofp i32 %4 to float
%6 = fdiv float %5, 0x41F0000000000000
store float %6, float* %3
%7 = load float, float* %3
%8 = fcmp olt float %7, 5.000000e-01
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load float, float* %3
%11 = fmul float 2.000000e+00, %10
%12 = call float @sqrtf(float %11)
%13 = fsub float %12, 1.000000e+00
br label %20
14: ; preds = %1
%15 = load float, float* %3
%16 = fsub float 1.000000e+00, %15
%17 = fmul float 2.000000e+00, %16
%18 = call float @sqrtf(float %17)
%19 = fsub float 1.000000e+00, %18
br label %20
20: ; preds = %14, %9
%21 = phi float [ %13, %9 ], [ %19, %14 ]
ret float %21
}

LLVM IR (-O2):
define float @tpdf(i32 %0) {
%2 = uitofp i32 %0 to float
%3 = fmul float %2, 0x3DF0000000000000
%4 = fcmp olt float %3, 5.000000e-01
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = fmul float %3, 2.000000e+00
%7 = tail call float @sqrtf(float %6)
%8 = fadd float %7, -1.000000e+00
br label %14
9: ; preds = %1
%10 = fsub float 1.000000e+00, %3
%11 = fmul float %10, 2.000000e+00
%12 = tail call float @sqrtf(float %11)
%13 = fsub float 1.000000e+00, %12
br label %14
14: ; preds = %9, %5
%15 = phi float [ %8, %5 ], [ %13, %9 ]
ret float %15
}