#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 */
float AngleDifference(float ang1, float ang2) {
  float diff;
  diff = ang1 - ang2;
  if (ang1 > ang2) {
    if (diff > 180.0)
      diff -= 360.0;
  } else {
    if (diff < -180.0)
      diff += 360.0;
  }
  return diff;
}


x86 assembly (clang, -O0):
<AngleDifference>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    116a <AngleDifference+0x6a>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xed3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1165 <AngleDifference+0x65>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb0(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11a8 <AngleDifference+0xa8>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe85(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a3 <AngleDifference+0xa3>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe72(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11a8 <AngleDifference+0xa8>
movss  -0xc(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<AngleDifference>:
ucomiss %xmm1,%xmm0
subss  %xmm1,%xmm0
jbe    111b <AngleDifference+0x1b>
ucomiss 0xef8(%rip),%xmm0
jbe    1130 <AngleDifference+0x30>
addss  0xef2(%rip),%xmm0
ret
movss  0xedd(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1130 <AngleDifference+0x30>
addss  0xed4(%rip),%xmm0
ret

LLVM IR (-O0):
define float @AngleDifference(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %3
store float %1, float* %4
%6 = load float, float* %3
%7 = load float, float* %4
%8 = fsub float %6, %7
store float %8, float* %5
%9 = load float, float* %3
%10 = load float, float* %4
%11 = fcmp ogt float %9, %10
br i1 %11, label %12, label %22
12: ; preds = %2
%13 = load float, float* %5
%14 = fpext float %13 to double
%15 = fcmp ogt double %14, 1.800000e+02
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load float, float* %5
%18 = fpext float %17 to double
%19 = fsub double %18, 3.600000e+02
%20 = fptrunc double %19 to float
store float %20, float* %5
br label %21
21: ; preds = %16, %12
br label %32
22: ; preds = %2
%23 = load float, float* %5
%24 = fpext float %23 to double
%25 = fcmp olt double %24, -1.800000e+02
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load float, float* %5
%28 = fpext float %27 to double
%29 = fadd double %28, 3.600000e+02
%30 = fptrunc double %29 to float
store float %30, float* %5
br label %31
31: ; preds = %26, %22
br label %32
32: ; preds = %31, %21
%33 = load float, float* %5
ret float %33
}

LLVM IR (-O2):
define float @AngleDifference(float %0, float %1) {
%3 = fsub float %0, %1
%4 = fcmp ogt float %0, %1
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = fcmp ogt float %3, 1.800000e+02
br i1 %6, label %7, label %13
7: ; preds = %5
%8 = fadd float %3, -3.600000e+02
br label %13
9: ; preds = %2
%10 = fcmp olt float %3, -1.800000e+02
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = fadd float %3, 3.600000e+02
br label %13
13: ; preds = %9, %11, %5, %7
%14 = phi float [ %8, %7 ], [ %3, %5 ], [ %12, %11 ], [ %3, %9 ]
ret float %14
}