void xytopolar(double x, double y, double rad, double *u, double *v) {
  double r1 = x * x + y * y;
  *v = sqrt(r1 / (rad * rad));
  double return_value_sqrt$1;
  double return_value_acos$2;
  double return_value_sqrt$3;
  double return_value_acos$4;
  if (y < 0.000000) {
    return_value_sqrt$1 = sqrt(r1);
    return_value_acos$2 = acos(x / return_value_sqrt$1);
    *u = 1.000000 - return_value_acos$2 / 6.283185e+0;
  } else {
    return_value_sqrt$3 = sqrt(r1);
    return_value_acos$4 = acos(x / return_value_sqrt$3);
    *u = return_value_acos$4 / 6.283185e+0;
  }
}


x86 assembly (clang, -O0):
<xytopolar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%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,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11db <xytopolar+0xbb>
movsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  0xe42(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe3e(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1217 <xytopolar+0xf7>
movsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xdf5(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xytopolar>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movapd %xmm0,%xmm3
movapd %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm2
movapd %xmm3,%xmm0
divsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1165 <xytopolar+0x45>
sqrtsd %xmm0,%xmm0
jmp    1178 <xytopolar+0x58>
movsd  %xmm3,(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  (%rsp),%xmm3
movsd  %xmm0,(%rbx)
ucomisd %xmm1,%xmm3
jb     118b <xytopolar+0x6b>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    1194 <xytopolar+0x74>
movapd %xmm3,%xmm0
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <acos@plt>
divsd  0xe51(%rip),%xmm0
movsd  0xe51(%rip),%xmm1
subsd  %xmm0,%xmm1
xorpd  %xmm2,%xmm2
movapd 0x10(%rsp),%xmm3
cmpltsd %xmm2,%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movlpd %xmm3,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @xytopolar(double %0, double %1, double %2, double* %3, double* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double* %3, double** %9
store double* %4, double** %10
%16 = load double, double* %6
%17 = load double, double* %6
%18 = load double, double* %7
%19 = load double, double* %7
%20 = fmul double %18, %19
%21 = call double @llvm.fmuladd.f64(double %16, double %17, double %20)
store double %21, double* %11
%22 = load double, double* %11
%23 = load double, double* %8
%24 = load double, double* %8
%25 = fmul double %23, %24
%26 = fdiv double %22, %25
%27 = call double @sqrt(double %26)
%28 = load double*, double** %10
store double %27, double* %28
%29 = load double, double* %7
%30 = fcmp olt double %29, 0.000000e+00
br i1 %30, label %31, label %42
31: ; preds = %5
%32 = load double, double* %11
%33 = call double @sqrt(double %32)
store double %33, double* %12
%34 = load double, double* %6
%35 = load double, double* %12
%36 = fdiv double %34, %35
%37 = call double @acos(double %36)
store double %37, double* %13
%38 = load double, double* %13
%39 = fdiv double %38, 0x401921FB3FA6DEFC
%40 = fsub double 1.000000e+00, %39
%41 = load double*, double** %9
store double %40, double* %41
br label %52
42: ; preds = %5
%43 = load double, double* %11
%44 = call double @sqrt(double %43)
store double %44, double* %14
%45 = load double, double* %6
%46 = load double, double* %14
%47 = fdiv double %45, %46
%48 = call double @acos(double %47)
store double %48, double* %15
%49 = load double, double* %15
%50 = fdiv double %49, 0x401921FB3FA6DEFC
%51 = load double*, double** %9
store double %50, double* %51
br label %52
52: ; preds = %42, %31
ret void
}

LLVM IR (-O2):
define void @xytopolar(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = fmul double %1, %1
%7 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %6)
%8 = fmul double %2, %2
%9 = fdiv double %7, %8
%10 = tail call double @sqrt(double %9)
store double %10, double* %4
%11 = fcmp olt double %1, 0.000000e+00
%12 = tail call double @sqrt(double %7)
%13 = fdiv double %0, %12
%14 = tail call double @acos(double %13)
%15 = fdiv double %14, 0x401921FB3FA6DEFC
%16 = fsub double 1.000000e+00, %15
%17 = select i1 %11, double %16, double %15
store double %17, double* %3
ret void
}