#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 ang_norm(int x1, int y1, int x2, int y2) {
  double dx, dy, ang;
  if (x1 == x2 && y1 == y2)
    return (0.0);
  dx = (double)(x2 - x1);
  dy = (double)(y2 - y1);
  ang = atan2(-1.0 * dx, dy);
  return (ang);
}


x86 assembly (clang, -O0):
<ang_norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1149 <ang_norm+0x39>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    1149 <ang_norm+0x39>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    118d <ang_norm+0x7d>
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe91(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ang_norm>:
sub    %edi,%edx
jne    111c <ang_norm+0xc>
cmp    %esi,%ecx
jne    111c <ang_norm+0xc>
xorps  %xmm0,%xmm0
ret
cvtsi2sd %edx,%xmm0
sub    %esi,%ecx
cvtsi2sd %ecx,%xmm1
xorpd  0xed2(%rip),%xmm0
jmp    1030 <atan2@plt>

LLVM IR (-O0):
define double @ang_norm(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %4
%17 = load i32, i32* %7
%18 = load i32, i32* %9
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %16
store double 0.000000e+00, double* %5
br label %35
21: ; preds = %16, %4
%22 = load i32, i32* %8
%23 = load i32, i32* %6
%24 = sub nsw i32 %22, %23
%25 = sitofp i32 %24 to double
store double %25, double* %10
%26 = load i32, i32* %9
%27 = load i32, i32* %7
%28 = sub nsw i32 %26, %27
%29 = sitofp i32 %28 to double
store double %29, double* %11
%30 = load double, double* %10
%31 = fmul double -1.000000e+00, %30
%32 = load double, double* %11
%33 = call double @atan2(double %31, double %32)
store double %33, double* %12
%34 = load double, double* %12
store double %34, double* %5
br label %35
35: ; preds = %21, %20
%36 = load double, double* %5
ret double %36
}

LLVM IR (-O2):
define double @ang_norm(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, %0
%6 = icmp eq i32 %3, %1
%7 = and i1 %5, %6
br i1 %7, label %15, label %8
8: ; preds = %4
%9 = sub nsw i32 %2, %0
%10 = sitofp i32 %9 to double
%11 = sub nsw i32 %3, %1
%12 = sitofp i32 %11 to double
%13 = fneg double %10
%14 = tail call double @atan2(double %13, double %12)
br label %15
15: ; preds = %4, %8
%16 = phi double [ %14, %8 ], [ 0.000000e+00, %4 ]
ret double %16
}