#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 */
int sqrt(int);
void KtoP(double *u, double *v, double x, double 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
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe9f(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe1a(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movsd  -0x28(%rbp),%xmm0
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KtoP>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movsd  0xec7(%rip),%xmm2
subsd  %xmm3,%xmm2
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
subsd  %xmm0,%xmm2
cvttsd2si %xmm2,%ebp
mov    %ebp,%edi
call   1030 <sqrt@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
mov    %ebp,%edi
call   1030 <sqrt@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @KtoP(double* nocapture writeonly %0, double* nocapture writeonly %1, double %2, double %3) {
%5 = fneg double %2
%6 = tail call double @llvm.fmuladd.f64(double %5, double %2, double 1.000000e+00)
%7 = fneg double %3
%8 = tail call double @llvm.fmuladd.f64(double %7, double %3, double %6)
%9 = fptosi double %8 to i32
%10 = tail call i32 @sqrt(i32 %9)
%11 = add nsw i32 %10, 1
%12 = sitofp i32 %11 to double
%13 = fdiv double %2, %12
store double %13, double* %0
%14 = tail call i32 @sqrt(i32 %9)
%15 = add nsw i32 %14, 1
%16 = sitofp i32 %15 to double
%17 = fdiv double %3, %16
store double %17, double* %1
ret void
}