#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 track_AngleMod(float);
float track_ApproachAngle(float targAngle, float inAngle, float speed) {
  float deltaAngle, out;
  targAngle = track_AngleMod(targAngle);
  out = track_AngleMod(targAngle);
  deltaAngle = targAngle - out;
  if (speed < 0)
    speed *= -1;
  if (deltaAngle < -180)
    deltaAngle += 360;
  else if (deltaAngle > 180)
    deltaAngle -= 360;
  if (deltaAngle > speed)
    out += speed;
  else if (deltaAngle < -speed)
    out -= speed;
  else
    out = targAngle;
  return out;
}


x86 assembly (clang, -O0):
<track_ApproachAngle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <track_AngleMod@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <track_AngleMod@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1173 <track_ApproachAngle+0x63>
movss  0xe97(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe89(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    119c <track_ApproachAngle+0x8c>
movss  0xe7f(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11cd <track_ApproachAngle+0xbd>
movss  -0x10(%rbp),%xmm0
movss  0xe5f(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11c8 <track_ApproachAngle+0xb8>
movss  -0x10(%rbp),%xmm0
movss  0xe4d(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11cd <track_ApproachAngle+0xbd>
movss  -0x10(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11f0 <track_ApproachAngle+0xe0>
movss  -0xc(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1237 <track_ApproachAngle+0x127>
movss  -0x10(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
jbe    1228 <track_ApproachAngle+0x118>
movss  -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1232 <track_ApproachAngle+0x122>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1237 <track_ApproachAngle+0x127>
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<track_ApproachAngle>:
sub    $0x28,%rsp
movaps %xmm2,0x10(%rsp)
call   1030 <track_AngleMod@plt>
movss  %xmm0,0xc(%rsp)
call   1030 <track_AngleMod@plt>
movss  0xc(%rsp),%xmm5
movaps %xmm5,%xmm2
subss  %xmm0,%xmm2
movaps 0xec3(%rip),%xmm3
movaps 0x10(%rsp),%xmm6
xorps  %xmm6,%xmm3
xorps  %xmm4,%xmm4
movaps %xmm6,%xmm1
cmpltss %xmm4,%xmm1
andps  %xmm1,%xmm3
andnps %xmm6,%xmm1
orps   %xmm3,%xmm1
movss  0xeaf(%rip),%xmm3
ucomiss %xmm2,%xmm3
jbe    1170 <track_ApproachAngle+0x60>
addss  0xeae(%rip),%xmm2
jmp    1181 <track_ApproachAngle+0x71>
ucomiss 0xe9d(%rip),%xmm2
jbe    1181 <track_ApproachAngle+0x71>
addss  0xe97(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    118f <track_ApproachAngle+0x7f>
addss  %xmm0,%xmm1
movaps %xmm1,%xmm5
jmp    11a5 <track_ApproachAngle+0x95>
movaps 0xe6a(%rip),%xmm3
xorps  %xmm1,%xmm3
ucomiss %xmm2,%xmm3
jbe    11a5 <track_ApproachAngle+0x95>
subss  %xmm1,%xmm0
movaps %xmm0,%xmm5
movaps %xmm5,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @track_ApproachAngle(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%9 = load float, float* %4
%10 = call float @track_AngleMod(float %9)
store float %10, float* %4
%11 = load float, float* %4
%12 = call float @track_AngleMod(float %11)
store float %12, float* %8
%13 = load float, float* %4
%14 = load float, float* %8
%15 = fsub float %13, %14
store float %15, float* %7
%16 = load float, float* %6
%17 = fcmp olt float %16, 0.000000e+00
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load float, float* %6
%20 = fmul float %19, -1.000000e+00
store float %20, float* %6
br label %21
21: ; preds = %18, %3
%22 = load float, float* %7
%23 = fcmp olt float %22, -1.800000e+02
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load float, float* %7
%26 = fadd float %25, 3.600000e+02
store float %26, float* %7
br label %34
27: ; preds = %21
%28 = load float, float* %7
%29 = fcmp ogt float %28, 1.800000e+02
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load float, float* %7
%32 = fsub float %31, 3.600000e+02
store float %32, float* %7
br label %33
33: ; preds = %30, %27
br label %34
34: ; preds = %33, %24
%35 = load float, float* %7
%36 = load float, float* %6
%37 = fcmp ogt float %35, %36
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load float, float* %6
%40 = load float, float* %8
%41 = fadd float %40, %39
store float %41, float* %8
br label %54
42: ; preds = %34
%43 = load float, float* %7
%44 = load float, float* %6
%45 = fneg float %44
%46 = fcmp olt float %43, %45
br i1 %46, label %47, label %51
47: ; preds = %42
%48 = load float, float* %6
%49 = load float, float* %8
%50 = fsub float %49, %48
store float %50, float* %8
br label %53
51: ; preds = %42
%52 = load float, float* %4
store float %52, float* %8
br label %53
53: ; preds = %51, %47
br label %54
54: ; preds = %53, %38
%55 = load float, float* %8
ret float %55
}

LLVM IR (-O2):
define float @track_ApproachAngle(float %0, float %1, float %2) {
%4 = tail call float @track_AngleMod(float %0)
%5 = tail call float @track_AngleMod(float %4)
%6 = fsub float %4, %5
%7 = fcmp olt float %2, 0.000000e+00
%8 = fneg float %2
%9 = select i1 %7, float %8, float %2
%10 = fcmp olt float %6, -1.800000e+02
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = fadd float %6, 3.600000e+02
br label %17
13: ; preds = %3
%14 = fcmp ogt float %6, 1.800000e+02
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = fadd float %6, -3.600000e+02
br label %17
17: ; preds = %13, %15, %11
%18 = phi float [ %12, %11 ], [ %16, %15 ], [ %6, %13 ]
%19 = fcmp ogt float %18, %9
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = fadd float %9, %5
br label %27
22: ; preds = %17
%23 = fneg float %9
%24 = fcmp olt float %18, %23
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = fsub float %5, %9
br label %27
27: ; preds = %22, %25, %20
%28 = phi float [ %21, %20 ], [ %26, %25 ], [ %4, %22 ]
ret float %28
}