float k2_angle_difference_radiansf(float a, float b) {
  float d = a - b;
  while (d >= (float)6.28318530717959)
    d -= (float)6.28318530717959;
  d += 9.42477796076938;
  while (d >= (float)6.28318530717959)
    d -= (float)6.28318530717959;
  d -= 3.14159265358979323846;
  return d;
}


x86 assembly (clang, -O0):
<k2_angle_difference_radiansf>:
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  -0xc(%rbp),%xmm0
movss  0xed6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     114e <k2_angle_difference_radiansf+0x4e>
movss  -0xc(%rbp),%xmm0
movss  0xec0(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    111d <k2_angle_difference_radiansf+0x1d>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea9(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe87(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     119d <k2_angle_difference_radiansf+0x9d>
movss  -0xc(%rbp),%xmm0
movss  0xe71(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    116c <k2_angle_difference_radiansf+0x6c>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe62(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<k2_angle_difference_radiansf>:
subss  %xmm1,%xmm0
ucomiss 0xef5(%rip),%xmm0
jb     1129 <k2_angle_difference_radiansf+0x29>
movss  0xeef(%rip),%xmm1
movss  0xee3(%rip),%xmm2
nopl   (%rax)
addss  %xmm1,%xmm0
ucomiss %xmm2,%xmm0
jae    1120 <k2_angle_difference_radiansf+0x20>
cvtss2sd %xmm0,%xmm0
addsd  0xed3(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
ucomiss 0xec0(%rip),%xmm0
jb     1169 <k2_angle_difference_radiansf+0x69>
movss  0xeba(%rip),%xmm1
movss  0xeae(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addss  %xmm1,%xmm0
ucomiss %xmm2,%xmm0
jae    1160 <k2_angle_difference_radiansf+0x60>
cvtss2sd %xmm0,%xmm0
addsd  0xe9b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @k2_angle_difference_radiansf(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
br label %9
9: ; preds = %12, %2
%10 = load float, float* %5
%11 = fcmp oge float %10, 0x401921FB60000000
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load float, float* %5
%14 = fsub float %13, 0x401921FB60000000
store float %14, float* %5
br label %9
15: ; preds = %9
%16 = load float, float* %5
%17 = fpext float %16 to double
%18 = fadd double %17, 0x4022D97C7F3321D2
%19 = fptrunc double %18 to float
store float %19, float* %5
br label %20
20: ; preds = %23, %15
%21 = load float, float* %5
%22 = fcmp oge float %21, 0x401921FB60000000
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load float, float* %5
%25 = fsub float %24, 0x401921FB60000000
store float %25, float* %5
br label %20
26: ; preds = %20
%27 = load float, float* %5
%28 = fpext float %27 to double
%29 = fsub double %28, 0x400921FB54442D18
%30 = fptrunc double %29 to float
store float %30, float* %5
%31 = load float, float* %5
ret float %31
}

LLVM IR (-O2):
define float @k2_angle_difference_radiansf(float %0, float %1) {
%3 = fsub float %0, %1
%4 = fcmp ult float %3, 0x401921FB60000000
br i1 %4, label %9, label %5
5: ; preds = %2, %5
%6 = phi float [ %7, %5 ], [ %3, %2 ]
%7 = fadd float %6, 0xC01921FB60000000
%8 = fcmp ult float %7, 0x401921FB60000000
br i1 %8, label %9, label %5
9: ; preds = %5, %2
%10 = phi float [ %3, %2 ], [ %7, %5 ]
%11 = fpext float %10 to double
%12 = fadd double %11, 0x4022D97C7F3321D2
%13 = fptrunc double %12 to float
%14 = fcmp ult float %13, 0x401921FB60000000
br i1 %14, label %19, label %15
15: ; preds = %9, %15
%16 = phi float [ %17, %15 ], [ %13, %9 ]
%17 = fadd float %16, 0xC01921FB60000000
%18 = fcmp ult float %17, 0x401921FB60000000
br i1 %18, label %19, label %15
19: ; preds = %15, %9
%20 = phi float [ %13, %9 ], [ %17, %15 ]
%21 = fpext float %20 to double
%22 = fadd double %21, 0xC00921FB54442D18
%23 = fptrunc double %22 to float
ret float %23
}