#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 AngleMod(float);
float BotChangeViewAngle(float angle, float ideal_angle, float speed) {
  float move;
  angle = AngleMod(angle);
  ideal_angle = AngleMod(ideal_angle);
  if (angle == ideal_angle)
    return angle;
  move = ideal_angle - angle;
  if (ideal_angle > angle) {
    if (move > 180.0)
      move -= 360.0;
  } else {
    if (move < -180.0)
      move += 360.0;
  }
  if (move > 0) {
    if (move > speed)
      move = speed;
  } else {
    if (move < -speed)
      move = -speed;
  }
  return AngleMod(angle + move);
}


x86 assembly (clang, -O0):
<BotChangeViewAngle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <AngleMod@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <AngleMod@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1169 <BotChangeViewAngle+0x59>
jp     1169 <BotChangeViewAngle+0x59>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1282 <BotChangeViewAngle+0x172>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11c5 <BotChangeViewAngle+0xb5>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe78(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c0 <BotChangeViewAngle+0xb0>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe55(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1203 <BotChangeViewAngle+0xf3>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe2a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11fe <BotChangeViewAngle+0xee>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe17(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1203 <BotChangeViewAngle+0xf3>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1232 <BotChangeViewAngle+0x122>
movss  -0x14(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    122d <BotChangeViewAngle+0x11d>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    126e <BotChangeViewAngle+0x15e>
movss  -0x14(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
jbe    1269 <BotChangeViewAngle+0x159>
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    126e <BotChangeViewAngle+0x15e>
movss  -0x8(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
call   1030 <AngleMod@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BotChangeViewAngle>:
sub    $0x28,%rsp
movaps %xmm2,0x10(%rsp)
movss  %xmm1,0xc(%rsp)
call   1030 <AngleMod@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <AngleMod@plt>
movss  0x8(%rsp),%xmm2
ucomiss %xmm0,%xmm2
jne    114a <BotChangeViewAngle+0x3a>
jp     114a <BotChangeViewAngle+0x3a>
movaps %xmm2,%xmm0
add    $0x28,%rsp
ret
movaps 0x10(%rsp),%xmm3
ucomiss %xmm2,%xmm0
subss  %xmm2,%xmm0
jbe    116b <BotChangeViewAngle+0x5b>
ucomiss 0xea9(%rip),%xmm0
jbe    1180 <BotChangeViewAngle+0x70>
addss  0xea3(%rip),%xmm0
jmp    1180 <BotChangeViewAngle+0x70>
movss  0xe8d(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1180 <BotChangeViewAngle+0x70>
addss  0xe84(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    118f <BotChangeViewAngle+0x7f>
ucomiss %xmm3,%xmm0
ja     119b <BotChangeViewAngle+0x8b>
jmp    119e <BotChangeViewAngle+0x8e>
xorps  0xe7a(%rip),%xmm3
ucomiss %xmm0,%xmm3
jbe    119e <BotChangeViewAngle+0x8e>
movaps %xmm3,%xmm0
addss  %xmm0,%xmm2
movaps %xmm2,%xmm0
add    $0x28,%rsp
jmp    1030 <AngleMod@plt>

LLVM IR (-O0):
define float @BotChangeViewAngle(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* %5
store float %1, float* %6
store float %2, float* %7
%9 = load float, float* %5
%10 = call float @AngleMod(float %9)
store float %10, float* %5
%11 = load float, float* %6
%12 = call float @AngleMod(float %11)
store float %12, float* %6
%13 = load float, float* %5
%14 = load float, float* %6
%15 = fcmp oeq float %13, %14
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load float, float* %5
store float %17, float* %4
br label %69
18: ; preds = %3
%19 = load float, float* %6
%20 = load float, float* %5
%21 = fsub float %19, %20
store float %21, float* %8
%22 = load float, float* %6
%23 = load float, float* %5
%24 = fcmp ogt float %22, %23
br i1 %24, label %25, label %35
25: ; preds = %18
%26 = load float, float* %8
%27 = fpext float %26 to double
%28 = fcmp ogt double %27, 1.800000e+02
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load float, float* %8
%31 = fpext float %30 to double
%32 = fsub double %31, 3.600000e+02
%33 = fptrunc double %32 to float
store float %33, float* %8
br label %34
34: ; preds = %29, %25
br label %45
35: ; preds = %18
%36 = load float, float* %8
%37 = fpext float %36 to double
%38 = fcmp olt double %37, -1.800000e+02
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = load float, float* %8
%41 = fpext float %40 to double
%42 = fadd double %41, 3.600000e+02
%43 = fptrunc double %42 to float
store float %43, float* %8
br label %44
44: ; preds = %39, %35
br label %45
45: ; preds = %44, %34
%46 = load float, float* %8
%47 = fcmp ogt float %46, 0.000000e+00
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load float, float* %8
%50 = load float, float* %7
%51 = fcmp ogt float %49, %50
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = load float, float* %7
store float %53, float* %8
br label %54
54: ; preds = %52, %48
br label %64
55: ; preds = %45
%56 = load float, float* %8
%57 = load float, float* %7
%58 = fneg float %57
%59 = fcmp olt float %56, %58
br i1 %59, label %60, label %63
60: ; preds = %55
%61 = load float, float* %7
%62 = fneg float %61
store float %62, float* %8
br label %63
63: ; preds = %60, %55
br label %64
64: ; preds = %63, %54
%65 = load float, float* %5
%66 = load float, float* %8
%67 = fadd float %65, %66
%68 = call float @AngleMod(float %67)
store float %68, float* %4
br label %69
69: ; preds = %64, %16
%70 = load float, float* %4
ret float %70
}

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