#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 forward_azimuth2D(double x1, double y1, double x2, double y2) {
  double angle = atan2(y2 - y1, x2 - x1);
  double azimuth = 3.14159265358979323846 / 2.0 - angle;
  if (azimuth < 0.0) {
    return azimuth + 2.0 * 3.14159265358979323846;
  } else {
    return azimuth;
  }
}


x86 assembly (clang, -O0):
<forward_azimuth2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xeae(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1181 <forward_azimuth2D+0x71>
movsd  0xe96(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    118b <forward_azimuth2D+0x7b>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<forward_azimuth2D>:
push   %rax
subsd  %xmm1,%xmm3
subsd  %xmm0,%xmm2
movapd %xmm3,%xmm0
movapd %xmm2,%xmm1
call   1030 <atan2@plt>
movsd  0xed2(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xece(%rip),%xmm2
addsd  %xmm1,%xmm2
xorpd  %xmm3,%xmm3
movapd %xmm1,%xmm0
cmpltsd %xmm3,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @forward_azimuth2D(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* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
%12 = load double, double* %9
%13 = load double, double* %7
%14 = fsub double %12, %13
%15 = load double, double* %8
%16 = load double, double* %6
%17 = fsub double %15, %16
%18 = call double @atan2(double %14, double %17)
store double %18, double* %10
%19 = load double, double* %10
%20 = fsub double 0x3FF921FB54442D18, %19
store double %20, double* %11
%21 = load double, double* %11
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %4
%24 = load double, double* %11
%25 = fadd double %24, 0x401921FB54442D18
store double %25, double* %5
br label %28
26: ; preds = %4
%27 = load double, double* %11
store double %27, double* %5
br label %28
28: ; preds = %26, %23
%29 = load double, double* %5
ret double %29
}

LLVM IR (-O2):
define double @forward_azimuth2D(double %0, double %1, double %2, double %3) {
%5 = fsub double %3, %1
%6 = fsub double %2, %0
%7 = tail call double @atan2(double %5, double %6)
%8 = fsub double 0x3FF921FB54442D18, %7
%9 = fcmp olt double %8, 0.000000e+00
%10 = fadd double %8, 0x401921FB54442D18
%11 = select i1 %9, double %10, double %8
ret double %11
}