#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 Angle2D(double x1, double y1, double x2, double y2) {
  double dtheta, theta1, theta2;
  theta1 = atan2(y1, x1);
  theta2 = atan2(y2, x2);
  dtheta = theta2 - theta1;
  while (dtheta > 3.141592653589793238462643)
    dtheta -= 6.283185307179586476925287;
  while (dtheta < -3.141592653589793238462643)
    dtheta += 6.283185307179586476925287;
  return (dtheta);
}


x86 assembly (clang, -O0):
<Angle2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1195 <Angle2D+0x85>
movsd  -0x28(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1163 <Angle2D+0x53>
jmp    119a <Angle2D+0x8a>
movsd  0xe66(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11c4 <Angle2D+0xb4>
movsd  0xe5b(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    119a <Angle2D+0x8a>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Angle2D>:
sub    $0x18,%rsp
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,0x10(%rsp)
movapd %xmm0,%xmm2
movaps %xmm1,%xmm0
movapd %xmm2,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <atan2@plt>
subsd  (%rsp),%xmm0
ucomisd 0xead(%rip),%xmm0
jbe    117a <Angle2D+0x6a>
movsd  0xeab(%rip),%xmm1
movsd  0xe9b(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nop
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
ja     1170 <Angle2D+0x60>
movsd  0xe8e(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    119a <Angle2D+0x8a>
movsd  0xe88(%rip),%xmm2
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
ja     1190 <Angle2D+0x80>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @Angle2D(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 = load double, double* %6
%13 = load double, double* %5
%14 = call double @atan2(double %12, double %13)
store double %14, double* %10
%15 = load double, double* %8
%16 = load double, double* %7
%17 = call double @atan2(double %15, double %16)
store double %17, double* %11
%18 = load double, double* %11
%19 = load double, double* %10
%20 = fsub double %18, %19
store double %20, double* %9
br label %21
21: ; preds = %24, %4
%22 = load double, double* %9
%23 = fcmp ogt double %22, 0x400921FB54442D18
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load double, double* %9
%26 = fsub double %25, 0x401921FB54442D18
store double %26, double* %9
br label %21
27: ; preds = %21
br label %28
28: ; preds = %31, %27
%29 = load double, double* %9
%30 = fcmp olt double %29, 0xC00921FB54442D18
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load double, double* %9
%33 = fadd double %32, 0x401921FB54442D18
store double %33, double* %9
br label %28
34: ; preds = %28
%35 = load double, double* %9
ret double %35
}

LLVM IR (-O2):
define double @Angle2D(double %0, double %1, double %2, double %3) {
%5 = tail call double @atan2(double %1, double %0)
%6 = tail call double @atan2(double %3, double %2)
%7 = fsub double %6, %5
%8 = fcmp ogt double %7, 0x400921FB54442D18
br i1 %8, label %12, label %9
9: ; preds = %12, %4
%10 = phi double [ %7, %4 ], [ %14, %12 ]
%11 = fcmp olt double %10, 0xC00921FB54442D18
br i1 %11, label %16, label %20
12: ; preds = %4, %12
%13 = phi double [ %14, %12 ], [ %7, %4 ]
%14 = fadd double %13, 0xC01921FB54442D18
%15 = fcmp ogt double %14, 0x400921FB54442D18
br i1 %15, label %12, label %9
16: ; preds = %9, %16
%17 = phi double [ %18, %16 ], [ %10, %9 ]
%18 = fadd double %17, 0x401921FB54442D18
%19 = fcmp olt double %18, 0xC00921FB54442D18
br i1 %19, label %16, label %20
20: ; preds = %16, %9
%21 = phi double [ %10, %9 ], [ %18, %16 ]
ret double %21
}