void KtoP(u, v, x, y) float *u, *v, x, y;
{
  *u = x / (1 + sqrt(1 - x * x - y * y));
  *v = y / (1 + sqrt(1 - x * x - y * y));
}


x86 assembly (clang, -O0):
<KtoP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm1,-0x30(%rbp)
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
cvtsd2ss %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm0
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm1,-0x14(%rbp)
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm0,%xmm1
movss  0xe98(%rip),%xmm0
addss  %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  0xe54(%rip),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm0,%xmm1
movss  0xe17(%rip),%xmm0
addss  %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  0xdd3(%rip),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KtoP>:
push   %r14
push   %rbx
sub    $0x28,%rsp
cvtsd2ss %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm2
mov    %rsi,%r14
mov    %rdi,%rbx
cvtss2sd %xmm0,%xmm3
mulss  %xmm0,%xmm0
movss  0xecb(%rip),%xmm1
subss  %xmm0,%xmm1
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
subss  %xmm0,%xmm1
cvtss2sd %xmm1,%xmm4
xorps  %xmm1,%xmm1
sqrtsd %xmm4,%xmm1
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm4
movapd %xmm1,%xmm0
jae    119a <KtoP+0x8a>
movapd %xmm4,%xmm0
movsd  %xmm1,0x8(%rsp)
movss  %xmm2,0x14(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm4,0x18(%rsp)
call   1030 <sqrt@plt>
xorpd  %xmm5,%xmm5
movsd  0x18(%rsp),%xmm4
movsd  0x20(%rsp),%xmm3
movss  0x14(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
addsd  0xe66(%rip),%xmm0
divsd  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtsd2ss %xmm3,%xmm0
movss  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
ucomisd %xmm5,%xmm4
jae    11d7 <KtoP+0xc7>
movsd  %xmm0,0x8(%rsp)
movapd %xmm4,%xmm0
call   1030 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  0xe29(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @KtoP(float* %0, float* %1, double %2, double %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = fptrunc double %2 to float
%10 = fptrunc double %3 to float
store float* %0, float** %5
store float* %1, float** %6
store float %9, float* %7
store float %10, float* %8
%11 = load float, float* %7
%12 = fpext float %11 to double
%13 = load float, float* %7
%14 = load float, float* %7
%15 = fneg float %13
%16 = call float @llvm.fmuladd.f32(float %15, float %14, float 1.000000e+00)
%17 = load float, float* %8
%18 = load float, float* %8
%19 = fneg float %17
%20 = call float @llvm.fmuladd.f32(float %19, float %18, float %16)
%21 = fpext float %20 to double
%22 = call double @sqrt(double %21)
%23 = fadd double 1.000000e+00, %22
%24 = fdiv double %12, %23
%25 = fptrunc double %24 to float
%26 = load float*, float** %5
store float %25, float* %26
%27 = load float, float* %8
%28 = fpext float %27 to double
%29 = load float, float* %7
%30 = load float, float* %7
%31 = fneg float %29
%32 = call float @llvm.fmuladd.f32(float %31, float %30, float 1.000000e+00)
%33 = load float, float* %8
%34 = load float, float* %8
%35 = fneg float %33
%36 = call float @llvm.fmuladd.f32(float %35, float %34, float %32)
%37 = fpext float %36 to double
%38 = call double @sqrt(double %37)
%39 = fadd double 1.000000e+00, %38
%40 = fdiv double %28, %39
%41 = fptrunc double %40 to float
%42 = load float*, float** %6
store float %41, float* %42
ret void
}

LLVM IR (-O2):
define void @KtoP(float* nocapture writeonly %0, float* nocapture writeonly %1, double %2, double %3) {
%5 = fptrunc double %2 to float
%6 = fptrunc double %3 to float
%7 = fpext float %5 to double
%8 = fneg float %5
%9 = tail call float @llvm.fmuladd.f32(float %8, float %5, float 1.000000e+00)
%10 = fneg float %6
%11 = tail call float @llvm.fmuladd.f32(float %10, float %6, float %9)
%12 = fpext float %11 to double
%13 = tail call double @sqrt(double %12)
%14 = fadd double %13, 1.000000e+00
%15 = fdiv double %7, %14
%16 = fptrunc double %15 to float
store float %16, float* %0
%17 = fpext float %6 to double
%18 = tail call double @sqrt(double %12)
%19 = fadd double %18, 1.000000e+00
%20 = fdiv double %17, %19
%21 = fptrunc double %20 to float
store float %21, float* %1
ret void
}