#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 fabs(double);
double norm_angle_diff(double a, double b) {
  if ((a == -1024.0) || (b == -1024.0))
    return 1.0;
  while (a <= -3.14159265358979323846)
    a += 6.28318530718;
  while (a > 3.14159265358979323846)
    a -= 6.28318530718;
  while (b <= -3.14159265358979323846)
    b += 6.28318530718;
  while (b > 3.14159265358979323846)
    b -= 6.28318530718;
  a -= b;
  while (a <= -3.14159265358979323846)
    a += 6.28318530718;
  while (a > 3.14159265358979323846)
    a -= 6.28318530718;
  return fabs(a) / 3.14159265358979323846;
}


x86 assembly (clang, -O0):
<norm_angle_diff>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xee5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1130 <norm_angle_diff+0x30>
jp     1130 <norm_angle_diff+0x30>
jmp    114d <norm_angle_diff+0x4d>
movsd  -0x18(%rbp),%xmm0
movsd  0xec3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    115f <norm_angle_diff+0x5f>
jp     115f <norm_angle_diff+0x5f>
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <norm_angle_diff+0x1c0>
jmp    1164 <norm_angle_diff+0x64>
movsd  0xe9c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     118e <norm_angle_diff+0x8e>
movsd  0xe99(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1164 <norm_angle_diff+0x64>
jmp    1193 <norm_angle_diff+0x93>
movsd  -0x10(%rbp),%xmm0
movsd  0xe70(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c5 <norm_angle_diff+0xc5>
movsd  -0x10(%rbp),%xmm0
movsd  0xe61(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1193 <norm_angle_diff+0x93>
jmp    11ca <norm_angle_diff+0xca>
movsd  0xe36(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11f4 <norm_angle_diff+0xf4>
movsd  0xe33(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ca <norm_angle_diff+0xca>
jmp    11f9 <norm_angle_diff+0xf9>
movsd  -0x18(%rbp),%xmm0
movsd  0xe0a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    122b <norm_angle_diff+0x12b>
movsd  -0x18(%rbp),%xmm0
movsd  0xdfb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11f9 <norm_angle_diff+0xf9>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xdc2(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1268 <norm_angle_diff+0x168>
movsd  0xdbf(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    123e <norm_angle_diff+0x13e>
jmp    126d <norm_angle_diff+0x16d>
movsd  -0x10(%rbp),%xmm0
movsd  0xd96(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    129f <norm_angle_diff+0x19f>
movsd  -0x10(%rbp),%xmm0
movsd  0xd87(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    126d <norm_angle_diff+0x16d>
movsd  -0x10(%rbp),%xmm0
movaps 0xd85(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd59(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<norm_angle_diff>:
ucomisd 0xef8(%rip),%xmm0
movsd  0xef8(%rip),%xmm2
jne    1118 <norm_angle_diff+0x18>
jnp    122e <norm_angle_diff+0x12e>
ucomisd 0xee0(%rip),%xmm1
jne    1128 <norm_angle_diff+0x28>
jnp    122e <norm_angle_diff+0x12e>
movsd  0xee0(%rip),%xmm2
ucomisd %xmm0,%xmm2
jb     114a <norm_angle_diff+0x4a>
movsd  0xeda(%rip),%xmm3
xchg   %ax,%ax
addsd  %xmm3,%xmm0
ucomisd %xmm0,%xmm2
jae    1140 <norm_angle_diff+0x40>
ucomisd 0xece(%rip),%xmm0
jbe    117a <norm_angle_diff+0x7a>
movsd  0xecc(%rip),%xmm3
movsd  0xebc(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
addsd  %xmm3,%xmm0
ucomisd %xmm4,%xmm0
ja     1170 <norm_angle_diff+0x70>
ucomisd %xmm1,%xmm2
jb     119a <norm_angle_diff+0x9a>
movsd  0xe90(%rip),%xmm3
nopl   0x0(%rax,%rax,1)
addsd  %xmm3,%xmm1
ucomisd %xmm1,%xmm2
jae    1190 <norm_angle_diff+0x90>
ucomisd 0xe7e(%rip),%xmm1
jbe    11ca <norm_angle_diff+0xca>
movsd  0xe7c(%rip),%xmm3
movsd  0xe6c(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
addsd  %xmm3,%xmm1
ucomisd %xmm4,%xmm1
ja     11c0 <norm_angle_diff+0xc0>
subsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jb     11ea <norm_angle_diff+0xea>
movsd  0xe3c(%rip),%xmm1
nopl   0x0(%rax)
addsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jae    11e0 <norm_angle_diff+0xe0>
ucomisd 0xe2e(%rip),%xmm0
jbe    121a <norm_angle_diff+0x11a>
movsd  0xe2c(%rip),%xmm1
movsd  0xe1c(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
ja     1210 <norm_angle_diff+0x110>
andpd  0xe0e(%rip),%xmm0
divsd  0xdf6(%rip),%xmm0
movapd %xmm0,%xmm2
movapd %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @norm_angle_diff(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp oeq double %6, -1.024000e+03
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load double, double* %5
%10 = fcmp oeq double %9, -1.024000e+03
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store double 1.000000e+00, double* %3
br label %61
12: ; preds = %8
br label %13
13: ; preds = %16, %12
%14 = load double, double* %4
%15 = fcmp ole double %14, 0xC00921FB54442D18
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load double, double* %4
%18 = fadd double %17, 0x401921FB54442EEA
store double %18, double* %4
br label %13
19: ; preds = %13
br label %20
20: ; preds = %23, %19
%21 = load double, double* %4
%22 = fcmp ogt double %21, 0x400921FB54442D18
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load double, double* %4
%25 = fsub double %24, 0x401921FB54442EEA
store double %25, double* %4
br label %20
26: ; preds = %20
br label %27
27: ; preds = %30, %26
%28 = load double, double* %5
%29 = fcmp ole double %28, 0xC00921FB54442D18
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load double, double* %5
%32 = fadd double %31, 0x401921FB54442EEA
store double %32, double* %5
br label %27
33: ; preds = %27
br label %34
34: ; preds = %37, %33
%35 = load double, double* %5
%36 = fcmp ogt double %35, 0x400921FB54442D18
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load double, double* %5
%39 = fsub double %38, 0x401921FB54442EEA
store double %39, double* %5
br label %34
40: ; preds = %34
%41 = load double, double* %5
%42 = load double, double* %4
%43 = fsub double %42, %41
store double %43, double* %4
br label %44
44: ; preds = %47, %40
%45 = load double, double* %4
%46 = fcmp ole double %45, 0xC00921FB54442D18
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load double, double* %4
%49 = fadd double %48, 0x401921FB54442EEA
store double %49, double* %4
br label %44
50: ; preds = %44
br label %51
51: ; preds = %54, %50
%52 = load double, double* %4
%53 = fcmp ogt double %52, 0x400921FB54442D18
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load double, double* %4
%56 = fsub double %55, 0x401921FB54442EEA
store double %56, double* %4
br label %51
57: ; preds = %51
%58 = load double, double* %4
%59 = call double @llvm.fabs.f64(double %58)
%60 = fdiv double %59, 0x400921FB54442D18
store double %60, double* %3
br label %61
61: ; preds = %57, %11
%62 = load double, double* %3
ret double %62
}

LLVM IR (-O2):
define double @norm_angle_diff(double %0, double %1) {
%3 = fcmp oeq double %0, -1.024000e+03
%4 = fcmp oeq double %1, -1.024000e+03
%5 = or i1 %3, %4
br i1 %5, label %52, label %6
6: ; preds = %2
%7 = fcmp ugt double %0, 0xC00921FB54442D18
br i1 %7, label %8, label %11
8: ; preds = %11, %6
%9 = phi double [ %0, %6 ], [ %13, %11 ]
%10 = fcmp ogt double %9, 0x400921FB54442D18
br i1 %10, label %18, label %15
11: ; preds = %6, %11
%12 = phi double [ %13, %11 ], [ %0, %6 ]
%13 = fadd double %12, 0x401921FB54442EEA
%14 = fcmp ugt double %13, 0xC00921FB54442D18
br i1 %14, label %8, label %11
15: ; preds = %18, %8
%16 = phi double [ %9, %8 ], [ %20, %18 ]
%17 = fcmp ugt double %1, 0xC00921FB54442D18
br i1 %17, label %22, label %25
18: ; preds = %8, %18
%19 = phi double [ %20, %18 ], [ %9, %8 ]
%20 = fadd double %19, 0xC01921FB54442EEA
%21 = fcmp ogt double %20, 0x400921FB54442D18
br i1 %21, label %18, label %15
22: ; preds = %25, %15
%23 = phi double [ %1, %15 ], [ %27, %25 ]
%24 = fcmp ogt double %23, 0x400921FB54442D18
br i1 %24, label %29, label %33
25: ; preds = %15, %25
%26 = phi double [ %27, %25 ], [ %1, %15 ]
%27 = fadd double %26, 0x401921FB54442EEA
%28 = fcmp ugt double %27, 0xC00921FB54442D18
br i1 %28, label %22, label %25
29: ; preds = %22, %29
%30 = phi double [ %31, %29 ], [ %23, %22 ]
%31 = fadd double %30, 0xC01921FB54442EEA
%32 = fcmp ogt double %31, 0x400921FB54442D18
br i1 %32, label %29, label %33
33: ; preds = %29, %22
%34 = phi double [ %23, %22 ], [ %31, %29 ]
%35 = fsub double %16, %34
%36 = fcmp ugt double %35, 0xC00921FB54442D18
br i1 %36, label %37, label %40
37: ; preds = %40, %33
%38 = phi double [ %35, %33 ], [ %42, %40 ]
%39 = fcmp ogt double %38, 0x400921FB54442D18
br i1 %39, label %44, label %48
40: ; preds = %33, %40
%41 = phi double [ %42, %40 ], [ %35, %33 ]
%42 = fadd double %41, 0x401921FB54442EEA
%43 = fcmp ugt double %42, 0xC00921FB54442D18
br i1 %43, label %37, label %40
44: ; preds = %37, %44
%45 = phi double [ %46, %44 ], [ %38, %37 ]
%46 = fadd double %45, 0xC01921FB54442EEA
%47 = fcmp ogt double %46, 0x400921FB54442D18
br i1 %47, label %44, label %48
48: ; preds = %44, %37
%49 = phi double [ %38, %37 ], [ %46, %44 ]
%50 = tail call double @llvm.fabs.f64(double %49)
%51 = fdiv double %50, 0x400921FB54442D18
br label %52
52: ; preds = %2, %48
%53 = phi double [ %51, %48 ], [ 1.000000e+00, %2 ]
ret double %53
}