#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 inv_wrap_angle(float);
float inv_angle_diff(float ang1, float ang2) {
  float d;
  ang1 = inv_wrap_angle(ang1);
  ang2 = inv_wrap_angle(ang2);
  d = ang1 - ang2;
  if (d > 3.14159265358979)
    d -= 2 * (float)3.14159265358979;
  else if (d < -(float)3.14159265358979)
    d += 2 * (float)3.14159265358979;
  return d;
}


x86 assembly (clang, -O0):
<inv_angle_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <inv_wrap_angle@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <inv_wrap_angle@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1185 <inv_angle_diff+0x75>
movss  -0xc(%rbp),%xmm0
movss  0xe95(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11ae <inv_angle_diff+0x9e>
movss  0xe7b(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11a9 <inv_angle_diff+0x99>
movss  0xe6d(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11ae <inv_angle_diff+0x9e>
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_angle_diff>:
push   %rax
movss  %xmm1,0x4(%rsp)
call   1030 <inv_wrap_angle@plt>
movss  %xmm0,(%rsp)
movss  0x4(%rsp),%xmm0
call   1030 <inv_wrap_angle@plt>
movss  (%rsp),%xmm1
subss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
ucomisd 0xebc(%rip),%xmm0
jbe    1150 <inv_angle_diff+0x40>
addss  0xec2(%rip),%xmm1
jmp    1165 <inv_angle_diff+0x55>
movss  0xeb0(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    1165 <inv_angle_diff+0x55>
addss  0xea7(%rip),%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @inv_angle_diff(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 = call float @inv_wrap_angle(float %6)
store float %7, float* %3
%8 = load float, float* %4
%9 = call float @inv_wrap_angle(float %8)
store float %9, float* %4
%10 = load float, float* %3
%11 = load float, float* %4
%12 = fsub float %10, %11
store float %12, float* %5
%13 = load float, float* %5
%14 = fpext float %13 to double
%15 = fcmp ogt double %14, 0x400921FB54442D11
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load float, float* %5
%18 = fsub float %17, 0x401921FB60000000
store float %18, float* %5
br label %26
19: ; preds = %2
%20 = load float, float* %5
%21 = fcmp olt float %20, 0xC00921FB60000000
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load float, float* %5
%24 = fadd float %23, 0x401921FB60000000
store float %24, float* %5
br label %25
25: ; preds = %22, %19
br label %26
26: ; preds = %25, %16
%27 = load float, float* %5
ret float %27
}

LLVM IR (-O2):
define float @inv_angle_diff(float %0, float %1) {
%3 = tail call float @inv_wrap_angle(float %0)
%4 = tail call float @inv_wrap_angle(float %1)
%5 = fsub float %3, %4
%6 = fpext float %5 to double
%7 = fcmp ogt double %6, 0x400921FB54442D11
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = fadd float %5, 0xC01921FB60000000
br label %14
10: ; preds = %2
%11 = fcmp olt float %5, 0xC00921FB60000000
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = fadd float %5, 0x401921FB60000000
br label %14
14: ; preds = %10, %12, %8
%15 = phi float [ %9, %8 ], [ %13, %12 ], [ %5, %10 ]
ret float %15
}