double atan2d(y, x)
double x, y;
{
  if (y == 0.0) {
    if (x >= 0.0) {
      return 0.0;
    } else if (x < 0.0) {
      return 180.0;
    }
  } else if (x == 0.0) {
    if (y > 0.0) {
      return 90.0;
    } else if (y < 0.0) {
      return -90.0;
    }
  }
  return atan2(y, x) * 180.0 / 3.141592653589793238462643;
}


x86 assembly (clang, -O0):
<atan2d>:
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    1183 <atan2d+0x73>
jp     1183 <atan2d+0x73>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1159 <atan2d+0x49>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <atan2d+0x10a>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1179 <atan2d+0x69>
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <atan2d+0x10a>
jmp    117e <atan2d+0x6e>
jmp    11ee <atan2d+0xde>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11e9 <atan2d+0xd9>
jp     11e9 <atan2d+0xd9>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11bf <atan2d+0xaf>
movsd  0xe53(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <atan2d+0x10a>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11df <atan2d+0xcf>
movsd  0xe2b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <atan2d+0x10a>
jmp    11e4 <atan2d+0xd4>
jmp    11e9 <atan2d+0xd9>
jmp    11ee <atan2d+0xde>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  0xe13(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdff(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2d>:
push   %rax
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jne    1137 <atan2d+0x27>
jp     1137 <atan2d+0x27>
ucomisd %xmm2,%xmm1
jae    117c <atan2d+0x6c>
xorpd  %xmm2,%xmm2
ucomisd %xmm1,%xmm2
jbe    1163 <atan2d+0x53>
movsd  0xedb(%rip),%xmm2
jmp    117c <atan2d+0x6c>
ucomisd %xmm2,%xmm1
jne    1163 <atan2d+0x53>
jp     1163 <atan2d+0x53>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jbe    1153 <atan2d+0x43>
movsd  0xeaf(%rip),%xmm2
jmp    117c <atan2d+0x6c>
ucomisd %xmm0,%xmm2
jbe    1163 <atan2d+0x53>
movsd  0xea7(%rip),%xmm2
jmp    117c <atan2d+0x6c>
call   1030 <atan2@plt>
movapd %xmm0,%xmm2
mulsd  0xe9c(%rip),%xmm2
divsd  0xe9c(%rip),%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @atan2d(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 %18
8: ; preds = %2
%9 = load double, double* %5
%10 = fcmp oge double %9, 0.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %8
store double 0.000000e+00, double* %3
br label %38
12: ; preds = %8
%13 = load double, double* %5
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %12
store double 1.800000e+02, double* %3
br label %38
16: ; preds = %12
br label %17
17: ; preds = %16
br label %32
18: ; preds = %2
%19 = load double, double* %5
%20 = fcmp oeq double %19, 0.000000e+00
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = load double, double* %4
%23 = fcmp ogt double %22, 0.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %21
store double 9.000000e+01, double* %3
br label %38
25: ; preds = %21
%26 = load double, double* %4
%27 = fcmp olt double %26, 0.000000e+00
br i1 %27, label %28, label %29
28: ; preds = %25
store double -9.000000e+01, double* %3
br label %38
29: ; preds = %25
br label %30
30: ; preds = %29
br label %31
31: ; preds = %30, %18
br label %32
32: ; preds = %31, %17
%33 = load double, double* %4
%34 = load double, double* %5
%35 = call double @atan2(double %33, double %34)
%36 = fmul double %35, 1.800000e+02
%37 = fdiv double %36, 0x400921FB54442D18
store double %37, double* %3
br label %38
38: ; preds = %32, %28, %24, %15, %11
%39 = load double, double* %3
ret double %39
}

LLVM IR (-O2):
define double @atan2d(double %0, double %1) {
%3 = fcmp oeq double %0, 0.000000e+00
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = fcmp ult double %1, 0.000000e+00
br i1 %5, label %6, label %18
6: ; preds = %4
%7 = fcmp olt double %1, 0.000000e+00
br i1 %7, label %18, label %14
8: ; preds = %2
%9 = fcmp oeq double %1, 0.000000e+00
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = fcmp ogt double %0, 0.000000e+00
br i1 %11, label %18, label %12
12: ; preds = %10
%13 = fcmp olt double %0, 0.000000e+00
br i1 %13, label %18, label %14
14: ; preds = %8, %12, %6
%15 = tail call double @atan2(double %0, double %1)
%16 = fmul double %15, 1.800000e+02
%17 = fdiv double %16, 0x400921FB54442D18
br label %18
18: ; preds = %12, %10, %6, %4, %14
%19 = phi double [ %17, %14 ], [ 0.000000e+00, %4 ], [ 1.800000e+02, %6 ], [ 9.000000e+01, %10 ], [ -9.000000e+01, %12 ]
ret double %19
}