#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 */
int /*<<< orphan*/ assert(int);
int fabs(float);
float AngleSubtract(float a1, float a2) {
  float a;
  a = a1 - a2;
  assert(fabs(a) < 3600);
  while (a > 180) {
    a -= 360;
  }
  while (a < -180) {
    a += 360;
  }
  return a;
}


x86 assembly (clang, -O0):
<AngleSubtract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0xe10,%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movss  -0xc(%rbp),%xmm0
movss  0xe96(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    118e <AngleSubtract+0x6e>
movss  -0xc(%rbp),%xmm0
movss  0xe88(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    115d <AngleSubtract+0x3d>
jmp    1193 <AngleSubtract+0x73>
movss  0xe69(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11bc <AngleSubtract+0x9c>
movss  0xe5b(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1193 <AngleSubtract+0x73>
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AngleSubtract>:
push   %rax
subss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
call   1030 <fabs@plt>
xor    %edi,%edi
cmp    $0xe10,%eax
setl   %dil
call   1040 <assert@plt>
movss  0x4(%rsp),%xmm0
ucomiss 0xeb3(%rip),%xmm0
jbe    1169 <AngleSubtract+0x49>
movss  0xead(%rip),%xmm2
movss  0xea1(%rip),%xmm1
nop
addss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
ja     1160 <AngleSubtract+0x40>
movss  0xe97(%rip),%xmm2
ucomiss %xmm0,%xmm2
jbe    1189 <AngleSubtract+0x69>
movss  0xe8e(%rip),%xmm1
xchg   %ax,%ax
addss  %xmm1,%xmm0
ucomiss %xmm0,%xmm2
ja     1180 <AngleSubtract+0x60>
pop    %rax
ret

LLVM IR (-O0):
define float @AngleSubtract(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* %5
%10 = call i32 @fabs(float %9)
%11 = icmp slt i32 %10, 3600
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
br label %14
14: ; preds = %17, %2
%15 = load float, float* %5
%16 = fcmp ogt float %15, 1.800000e+02
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load float, float* %5
%19 = fsub float %18, 3.600000e+02
store float %19, float* %5
br label %14
20: ; preds = %14
br label %21
21: ; preds = %24, %20
%22 = load float, float* %5
%23 = fcmp olt float %22, -1.800000e+02
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load float, float* %5
%26 = fadd float %25, 3.600000e+02
store float %26, float* %5
br label %21
27: ; preds = %21
%28 = load float, float* %5
ret float %28
}

LLVM IR (-O2):
define float @AngleSubtract(float %0, float %1) {
%3 = fsub float %0, %1
%4 = tail call i32 @fabs(float %3)
%5 = icmp slt i32 %4, 3600
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = fcmp ogt float %3, 1.800000e+02
br i1 %8, label %12, label %9
9: ; preds = %12, %2
%10 = phi float [ %3, %2 ], [ %14, %12 ]
%11 = fcmp olt float %10, -1.800000e+02
br i1 %11, label %16, label %20
12: ; preds = %2, %12
%13 = phi float [ %14, %12 ], [ %3, %2 ]
%14 = fadd float %13, -3.600000e+02
%15 = fcmp ogt float %14, 1.800000e+02
br i1 %15, label %12, label %9
16: ; preds = %9, %16
%17 = phi float [ %18, %16 ], [ %10, %9 ]
%18 = fadd float %17, 3.600000e+02
%19 = fcmp olt float %18, -1.800000e+02
br i1 %19, label %16, label %20
20: ; preds = %16, %9
%21 = phi float [ %10, %9 ], [ %18, %16 ]
ret float %21
}