#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 HUGE_VAL;
double atan(double);
double trig_delta_to_angle_d(double dx, double dy) {
  double angle;
  if (dx == 0)
    angle = (dy < 0) ? -HUGE_VAL : HUGE_VAL;
  else
    angle = dy / dx;
  angle = atan(angle);
  if (dx < 0)
    angle = angle + 3.141592653589793;
  else if (angle < 0)
    angle = 2. * 3.141592653589793 + angle;
  return angle;
}


x86 assembly (clang, -O0):
<trig_delta_to_angle_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1193 <trig_delta_to_angle_d+0x83>
jp     1193 <trig_delta_to_angle_d+0x83>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1174 <trig_delta_to_angle_d+0x64>
mov    0x2e99(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1184 <trig_delta_to_angle_d+0x74>
mov    0x2e6d(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11a2 <trig_delta_to_angle_d+0x92>
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <atan@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11d6 <trig_delta_to_angle_d+0xc6>
movsd  0xe41(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11fb <trig_delta_to_angle_d+0xeb>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11f6 <trig_delta_to_angle_d+0xe6>
movsd  0xe14(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11fb <trig_delta_to_angle_d+0xeb>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trig_delta_to_angle_d>:
push   %rax
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
movsd  %xmm0,(%rsp)
jne    114c <trig_delta_to_angle_d+0x3c>
jp     114c <trig_delta_to_angle_d+0x3c>
mov    0x2ebf(%rip),%rax
movsd  (%rax),%xmm2
movapd 0xecb(%rip),%xmm3
xorpd  %xmm2,%xmm3
cmpltsd %xmm4,%xmm1
andpd  %xmm1,%xmm3
andnpd %xmm2,%xmm1
orpd   %xmm3,%xmm1
jmp    1150 <trig_delta_to_angle_d+0x40>
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <atan@plt>
xorpd  %xmm1,%xmm1
ucomisd (%rsp),%xmm1
jbe    116e <trig_delta_to_angle_d+0x5e>
addsd  0xeac(%rip),%xmm0
pop    %rax
ret
ucomisd %xmm0,%xmm1
jbe    117c <trig_delta_to_angle_d+0x6c>
addsd  0xe94(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@HUGE_VAL = global double 0.000000e+00
define double @trig_delta_to_angle_d(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* %3
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = load double, double* %4
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load double, double* @HUGE_VAL
%13 = fneg double %12
br label %16
14: ; preds = %8
%15 = load double, double* @HUGE_VAL
br label %16
16: ; preds = %14, %11
%17 = phi double [ %13, %11 ], [ %15, %14 ]
store double %17, double* %5
br label %22
18: ; preds = %2
%19 = load double, double* %4
%20 = load double, double* %3
%21 = fdiv double %19, %20
store double %21, double* %5
br label %22
22: ; preds = %18, %16
%23 = load double, double* %5
%24 = call double @atan(double %23)
store double %24, double* %5
%25 = load double, double* %3
%26 = fcmp olt double %25, 0.000000e+00
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load double, double* %5
%29 = fadd double %28, 0x400921FB54442D18
store double %29, double* %5
br label %37
30: ; preds = %22
%31 = load double, double* %5
%32 = fcmp olt double %31, 0.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load double, double* %5
%35 = fadd double 0x401921FB54442D18, %34
store double %35, double* %5
br label %36
36: ; preds = %33, %30
br label %37
37: ; preds = %36, %27
%38 = load double, double* %5
ret double %38
}

LLVM IR (-O2):
@HUGE_VAL = global double 0.000000e+00
define double @trig_delta_to_angle_d(double %0, double %1) {
%3 = fcmp oeq double %0, 0.000000e+00
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = fcmp olt double %1, 0.000000e+00
%6 = load double, double* @HUGE_VAL
%7 = fneg double %6
%8 = select i1 %5, double %7, double %6
br label %11
9: ; preds = %2
%10 = fdiv double %1, %0
br label %11
11: ; preds = %9, %4
%12 = phi double [ %8, %4 ], [ %10, %9 ]
%13 = tail call double @atan(double %12)
%14 = fcmp olt double %0, 0.000000e+00
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = fadd double %13, 0x400921FB54442D18
br label %21
17: ; preds = %11
%18 = fcmp olt double %13, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = fadd double %13, 0x401921FB54442D18
br label %21
21: ; preds = %17, %19, %15
%22 = phi double [ %16, %15 ], [ %20, %19 ], [ %13, %17 ]
ret double %22
}