#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 */
double atan2(double, double);
double atan2deg(double b, double a) {
  double h;
  if (a == 0 && b == 0)
    h = 0;
  else
    h = atan2(a, b);
  h *= (180. / 3.14159265358979323846);
  while (h > 360.)
    h -= 360.;
  while (h < 0)
    h += 360.;
  return h;
}


x86 assembly (clang, -O0):
<atan2deg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115f <atan2deg+0x4f>
jp     115f <atan2deg+0x4f>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115f <atan2deg+0x4f>
jp     115f <atan2deg+0x4f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1173 <atan2deg+0x63>
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe85(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe76(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b7 <atan2deg+0xa7>
movsd  -0x18(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1185 <atan2deg+0x75>
jmp    11bc <atan2deg+0xac>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11e1 <atan2deg+0xd1>
movsd  0xe36(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11bc <atan2deg+0xac>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2deg>:
push   %rax
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    112d <atan2deg+0x1d>
jp     112d <atan2deg+0x1d>
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm1
jne    112d <atan2deg+0x1d>
jnp    118a <atan2deg+0x7a>
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
call   1030 <atan2@plt>
mulsd  0xebe(%rip),%xmm0
ucomisd 0xebe(%rip),%xmm0
jbe    116a <atan2deg+0x5a>
movsd  0xebc(%rip),%xmm1
movsd  0xeac(%rip),%xmm2
nopl   0x0(%rax)
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
ja     1160 <atan2deg+0x50>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    118a <atan2deg+0x7a>
movsd  0xe8c(%rip),%xmm2
nopl   0x0(%rax)
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
ja     1180 <atan2deg+0x70>
pop    %rax
ret

LLVM IR (-O0):
define double @atan2deg(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = load double, double* %4
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load double, double* %3
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %8
store double 0.000000e+00, double* %5
br label %16
12: ; preds = %8, %2
%13 = load double, double* %4
%14 = load double, double* %3
%15 = call double @atan2(double %13, double %14)
store double %15, double* %5
br label %16
16: ; preds = %12, %11
%17 = load double, double* %5
%18 = fmul double %17, 0x404CA5DC1A63C1F8
store double %18, double* %5
br label %19
19: ; preds = %22, %16
%20 = load double, double* %5
%21 = fcmp ogt double %20, 3.600000e+02
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load double, double* %5
%24 = fsub double %23, 3.600000e+02
store double %24, double* %5
br label %19
25: ; preds = %19
br label %26
26: ; preds = %29, %25
%27 = load double, double* %5
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load double, double* %5
%31 = fadd double %30, 3.600000e+02
store double %31, double* %5
br label %26
32: ; preds = %26
%33 = load double, double* %5
ret double %33
}

LLVM IR (-O2):
define double @atan2deg(double %0, double %1) {
%3 = fcmp oeq double %1, 0.000000e+00
%4 = fcmp oeq double %0, 0.000000e+00
%5 = and i1 %4, %3
br i1 %5, label %21, label %6
6: ; preds = %2
%7 = tail call double @atan2(double %1, double %0)
%8 = fmul double %7, 0x404CA5DC1A63C1F8
%9 = fcmp ogt double %8, 3.600000e+02
br i1 %9, label %13, label %10
10: ; preds = %13, %6
%11 = phi double [ %8, %6 ], [ %15, %13 ]
%12 = fcmp olt double %11, 0.000000e+00
br i1 %12, label %17, label %21
13: ; preds = %6, %13
%14 = phi double [ %15, %13 ], [ %8, %6 ]
%15 = fadd double %14, -3.600000e+02
%16 = fcmp ogt double %15, 3.600000e+02
br i1 %16, label %13, label %10
17: ; preds = %10, %17
%18 = phi double [ %19, %17 ], [ %11, %10 ]
%19 = fadd double %18, 3.600000e+02
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %17, label %21
21: ; preds = %17, %2, %10
%22 = phi double [ %11, %10 ], [ 0.000000e+00, %2 ], [ %19, %17 ]
ret double %22
}