#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 fmod(float, int);
float ang_diff(float a, float b) {
  float delta_theta = fmod(a, 360) - fmod(b, 360);
  if (delta_theta < -180)
    delta_theta += 360;
  if (delta_theta > 180)
    delta_theta -= 360;
  return delta_theta;
}


x86 assembly (clang, -O0):
<ang_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
mov    $0x168,%edi
call   1030 <fmod@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
mov    $0x168,%edi
call   1030 <fmod@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xea2(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    117a <ang_diff+0x6a>
movss  0xe94(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe81(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11a6 <ang_diff+0x96>
movss  -0xc(%rbp),%xmm0
movss  0xe67(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ang_diff>:
sub    $0x28,%rsp
movss  %xmm1,0xc(%rsp)
mov    $0x168,%edi
call   1030 <fmod@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
mov    $0x168,%edi
call   1030 <fmod@plt>
movaps 0x10(%rsp),%xmm2
subss  %xmm0,%xmm2
movss  0xeb6(%rip),%xmm0
addss  %xmm2,%xmm0
movaps %xmm2,%xmm1
cmpltss 0xeaa(%rip),%xmm1
andps  %xmm1,%xmm0
andnps %xmm2,%xmm1
orps   %xmm0,%xmm1
movss  0xe9d(%rip),%xmm2
addss  %xmm1,%xmm2
movss  0xe95(%rip),%xmm0
cmpltss %xmm1,%xmm0
andps  %xmm0,%xmm2
andnps %xmm1,%xmm0
orps   %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @ang_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 @fmod(float %6, i32 360)
%8 = load float, float* %4
%9 = call float @fmod(float %8, i32 360)
%10 = fsub float %7, %9
store float %10, float* %5
%11 = load float, float* %5
%12 = fcmp olt float %11, -1.800000e+02
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load float, float* %5
%15 = fadd float %14, 3.600000e+02
store float %15, float* %5
br label %16
16: ; preds = %13, %2
%17 = load float, float* %5
%18 = fcmp ogt float %17, 1.800000e+02
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load float, float* %5
%21 = fsub float %20, 3.600000e+02
store float %21, float* %5
br label %22
22: ; preds = %19, %16
%23 = load float, float* %5
ret float %23
}

LLVM IR (-O2):
define float @ang_diff(float %0, float %1) {
%3 = tail call float @fmod(float %0, i32 360)
%4 = tail call float @fmod(float %1, i32 360)
%5 = fsub float %3, %4
%6 = fcmp olt float %5, -1.800000e+02
%7 = fadd float %5, 3.600000e+02
%8 = select i1 %6, float %7, float %5
%9 = fcmp ogt float %8, 1.800000e+02
%10 = fadd float %8, -3.600000e+02
%11 = select i1 %9, float %10, float %8
ret float %11
}