void oldpolcar(x, y, pr, pth) double x, y, *pr, *pth;
{
  double r, th, pi;
  pi = atan(1.0) * 2.0;
  r = sqrt((x * x) + (y * y));
  if (x < 0.0 && y < 0.0) {
    th = pi + atan(y / x);
  } else if (x < 0.0 && y >= 0.0) {
    th = pi + atan(y / x);
  } else if (x >= 0.0 && y >= 0.0) {
    if (x > 0.0) {
      th = atan(y / x);
    } else {
      th = pi / 2.0;
    }
  } else {
    if (x > 0.0) {
      th = atan(y / x) + (2.0 * pi);
    } else {
      th = 1.5 * pi;
    }
  }
  *pr = r;
  *pth = th;
}


x86 assembly (clang, -O0):
<oldpolcar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  0xec6(%rip),%xmm0
call   1030 <atan@plt>
movsd  0xeb1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11c9 <oldpolcar+0xa9>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11c9 <oldpolcar+0xa9>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
call   1030 <atan@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12de <oldpolcar+0x1be>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1218 <oldpolcar+0xf8>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1218 <oldpolcar+0xf8>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
call   1030 <atan@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12d9 <oldpolcar+0x1b9>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1282 <oldpolcar+0x162>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1282 <oldpolcar+0x162>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1267 <oldpolcar+0x147>
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
call   1030 <atan@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    127d <oldpolcar+0x15d>
movsd  -0x38(%rbp),%xmm0
movsd  0xd8c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12d4 <oldpolcar+0x1b4>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12bd <oldpolcar+0x19d>
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
call   1030 <atan@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12cf <oldpolcar+0x1af>
movsd  0xd4b(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12d4 <oldpolcar+0x1b4>
jmp    12d9 <oldpolcar+0x1b9>
jmp    12de <oldpolcar+0x1be>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oldpolcar>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  0xebf(%rip),%xmm0
call   1030 <atan@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jb     117f <oldpolcar+0x5f>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
ucomisd %xmm3,%xmm4
ja     119e <oldpolcar+0x7e>
jmp    11a8 <oldpolcar+0x88>
call   1040 <sqrt@plt>
xorpd  %xmm4,%xmm4
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
ucomisd %xmm3,%xmm4
jbe    11a8 <oldpolcar+0x88>
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
ja     11b8 <oldpolcar+0x98>
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
jbe    11ea <oldpolcar+0xca>
ucomisd %xmm0,%xmm2
jb     11ea <oldpolcar+0xca>
divsd  %xmm3,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <atan@plt>
movsd  0x8(%rsp),%xmm1
addsd  0xe47(%rip),%xmm0
movsd  %xmm1,(%rbx)
movsd  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
ucomisd %xmm0,%xmm3
jb     121b <oldpolcar+0xfb>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     121b <oldpolcar+0xfb>
ucomisd %xmm0,%xmm3
jbe    1248 <oldpolcar+0x128>
divsd  %xmm3,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <atan@plt>
movsd  0x8(%rsp),%xmm1
jmp    11d9 <oldpolcar+0xb9>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
jbe    1252 <oldpolcar+0x132>
divsd  %xmm3,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <atan@plt>
movsd  0x8(%rsp),%xmm1
addsd  0xdca(%rip),%xmm0
jmp    11d9 <oldpolcar+0xb9>
movsd  0xdc8(%rip),%xmm0
jmp    11d9 <oldpolcar+0xb9>
movsd  0xdae(%rip),%xmm0
jmp    11d9 <oldpolcar+0xb9>

LLVM IR (-O0):
define void @oldpolcar(double %0, double %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%12 = call double @atan(double 1.000000e+00)
%13 = fmul double %12, 2.000000e+00
store double %13, double* %11
%14 = load double, double* %5
%15 = load double, double* %5
%16 = load double, double* %6
%17 = load double, double* %6
%18 = fmul double %16, %17
%19 = call double @llvm.fmuladd.f64(double %14, double %15, double %18)
%20 = call double @sqrt(double %19)
store double %20, double* %9
%21 = load double, double* %5
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %33
23: ; preds = %4
%24 = load double, double* %6
%25 = fcmp olt double %24, 0.000000e+00
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load double, double* %11
%28 = load double, double* %6
%29 = load double, double* %5
%30 = fdiv double %28, %29
%31 = call double @atan(double %30)
%32 = fadd double %27, %31
store double %32, double* %10
br label %80
33: ; preds = %23, %4
%34 = load double, double* %5
%35 = fcmp olt double %34, 0.000000e+00
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = load double, double* %6
%38 = fcmp oge double %37, 0.000000e+00
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load double, double* %11
%41 = load double, double* %6
%42 = load double, double* %5
%43 = fdiv double %41, %42
%44 = call double @atan(double %43)
%45 = fadd double %40, %44
store double %45, double* %10
br label %79
46: ; preds = %36, %33
%47 = load double, double* %5
%48 = fcmp oge double %47, 0.000000e+00
br i1 %48, label %49, label %64
49: ; preds = %46
%50 = load double, double* %6
%51 = fcmp oge double %50, 0.000000e+00
br i1 %51, label %52, label %64
52: ; preds = %49
%53 = load double, double* %5
%54 = fcmp ogt double %53, 0.000000e+00
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = load double, double* %6
%57 = load double, double* %5
%58 = fdiv double %56, %57
%59 = call double @atan(double %58)
store double %59, double* %10
br label %63
60: ; preds = %52
%61 = load double, double* %11
%62 = fdiv double %61, 2.000000e+00
store double %62, double* %10
br label %63
63: ; preds = %60, %55
br label %78
64: ; preds = %49, %46
%65 = load double, double* %5
%66 = fcmp ogt double %65, 0.000000e+00
br i1 %66, label %67, label %74
67: ; preds = %64
%68 = load double, double* %6
%69 = load double, double* %5
%70 = fdiv double %68, %69
%71 = call double @atan(double %70)
%72 = load double, double* %11
%73 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %72, double %71)
store double %73, double* %10
br label %77
74: ; preds = %64
%75 = load double, double* %11
%76 = fmul double 1.500000e+00, %75
store double %76, double* %10
br label %77
77: ; preds = %74, %67
br label %78
78: ; preds = %77, %63
br label %79
79: ; preds = %78, %39
br label %80
80: ; preds = %79, %26
%81 = load double, double* %9
%82 = load double*, double** %7
store double %81, double* %82
%83 = load double, double* %10
%84 = load double*, double** %8
store double %83, double* %84
ret void
}

LLVM IR (-O2):
define void @oldpolcar(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = tail call double @atan(double 1.000000e+00)
%6 = fmul double %1, %1
%7 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %6)
%8 = tail call double @sqrt(double %7)
%9 = fcmp olt double %0, 0.000000e+00
%10 = fcmp olt double %1, 0.000000e+00
%11 = and i1 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = fdiv double %1, %0
%14 = tail call double @atan(double %13)
%15 = fadd double %14, 0x3FF921FB54442D18
br label %36
16: ; preds = %4
%17 = fcmp oge double %1, 0.000000e+00
%18 = and i1 %9, %17
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = fdiv double %1, %0
%21 = tail call double @atan(double %20)
%22 = fadd double %21, 0x3FF921FB54442D18
br label %36
23: ; preds = %16
%24 = fcmp oge double %0, 0.000000e+00
%25 = and i1 %24, %17
%26 = fcmp ogt double %0, 0.000000e+00
br i1 %25, label %27, label %31
27: ; preds = %23
br i1 %26, label %28, label %36
28: ; preds = %27
%29 = fdiv double %1, %0
%30 = tail call double @atan(double %29)
br label %36
31: ; preds = %23
br i1 %26, label %32, label %36
32: ; preds = %31
%33 = fdiv double %1, %0
%34 = tail call double @atan(double %33)
%35 = fadd double %34, 0x400921FB54442D18
br label %36
36: ; preds = %31, %27, %19, %32, %28, %12
%37 = phi double [ %15, %12 ], [ %22, %19 ], [ %30, %28 ], [ %35, %32 ], [ 0x3FE921FB54442D18, %27 ], [ 0x4002D97C7F3321D2, %31 ]
store double %8, double* %2
store double %37, double* %3
ret void
}