double phi(re, im)
double re, im;
{
  if (re == 0)
    if (im > 0)
      return (3.1415926 / 2);
    else
      return (-3.1415926 / 2);
  if (re > 0)
    return (atan(im / re));
  else
    return (atan(im / re) + 3.1415926);
}


x86 assembly (clang, -O0):
<phi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1170 <phi+0x60>
jp     1170 <phi+0x60>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    115e <phi+0x4e>
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bb <phi+0xab>
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bb <phi+0xab>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    119b <phi+0x8b>
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <atan@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11bb <phi+0xab>
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <atan@plt>
movsd  0xe4e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<phi>:
push   %rax
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    1138 <phi+0x28>
jp     1138 <phi+0x28>
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %al
lea    0xedf(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
pop    %rax
ret
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
movsd  %xmm2,(%rsp)
call   1030 <atan@plt>
movsd  (%rsp),%xmm1
ucomisd 0xeb1(%rip),%xmm1
ja     1161 <phi+0x51>
addsd  0xe9f(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @phi(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load double, double* %5
%10 = fcmp ogt double %9, 0.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %8
store double 0x3FF921FB4D12D84A, double* %3
br label %27
12: ; preds = %8
store double 0xBFF921FB4D12D84A, double* %3
br label %27
13: ; preds = %2
%14 = load double, double* %4
%15 = fcmp ogt double %14, 0.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load double, double* %5
%18 = load double, double* %4
%19 = fdiv double %17, %18
%20 = call double @atan(double %19)
store double %20, double* %3
br label %27
21: ; preds = %13
%22 = load double, double* %5
%23 = load double, double* %4
%24 = fdiv double %22, %23
%25 = call double @atan(double %24)
%26 = fadd double %25, 0x400921FB4D12D84A
store double %26, double* %3
br label %27
27: ; preds = %21, %16, %12, %11
%28 = load double, double* %3
ret double %28
}

LLVM IR (-O2):
define double @phi(double %0, double %1) {
%3 = fcmp oeq double %0, 0.000000e+00
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = fcmp ogt double %1, 0.000000e+00
%6 = select i1 %5, double 0x3FF921FB4D12D84A, double 0xBFF921FB4D12D84A
br label %13
7: ; preds = %2
%8 = fcmp ogt double %0, 0.000000e+00
%9 = fdiv double %1, %0
%10 = tail call double @atan(double %9)
br i1 %8, label %13, label %11
11: ; preds = %7
%12 = fadd double %10, 0x400921FB4D12D84A
br label %13
13: ; preds = %7, %4, %11
%14 = phi double [ %12, %11 ], [ %6, %4 ], [ %10, %7 ]
ret double %14
}