#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
float ModAngle(float angle) {
  float revs = angle * (1.0f / (2.0f * 3.1415927f));
  angle -= (float)((int32_t)revs) * (2.0f * 3.1415927f);
  if (angle > 3.1415927f) {
    return angle - 2.0f * 3.1415927f;
  } else if (angle < -3.1415927f) {
    return angle + 2.0f * 3.1415927f;
  } else {
    return angle;
  }
}


x86 assembly (clang, -O0):
<ModAngle>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x8(%rbp)
movss  0xef7(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
cvttss2si -0xc(%rbp),%rax
cvtsi2ss %rax,%xmm0
movss  -0x8(%rbp),%xmm1
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xec4(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xea6(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    117e <ModAngle+0x7e>
movss  -0x8(%rbp),%xmm0
movss  0xe94(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11b1 <ModAngle+0xb1>
movss  0xe86(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11a7 <ModAngle+0xa7>
movss  0xe6c(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11b1 <ModAngle+0xb1>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ModAngle>:
movaps %xmm0,%xmm1
movss  0xef5(%rip),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xee0(%rip),%xmm0
addss  %xmm1,%xmm0
ucomiss 0xed9(%rip),%xmm0
jbe    113a <ModAngle+0x3a>
addss  0xecb(%rip),%xmm0
ret
movss  0xeca(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    114f <ModAngle+0x4f>
addss  0xec1(%rip),%xmm0
ret

LLVM IR (-O0):
define float @ModAngle(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
store float %0, float* %3
%5 = load float, float* %3
%6 = fmul float %5, 0x3FC45F3060000000
store float %6, float* %4
%7 = load float, float* %4
%8 = fptosi float %7 to i64
%9 = sitofp i64 %8 to float
%10 = load float, float* %3
%11 = fneg float %9
%12 = call float @llvm.fmuladd.f32(float %11, float 0x401921FB60000000, float %10)
store float %12, float* %3
%13 = load float, float* %3
%14 = fcmp ogt float %13, 0x400921FB60000000
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load float, float* %3
%17 = fsub float %16, 0x401921FB60000000
store float %17, float* %2
br label %26
18: ; preds = %1
%19 = load float, float* %3
%20 = fcmp olt float %19, 0xC00921FB60000000
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load float, float* %3
%23 = fadd float %22, 0x401921FB60000000
store float %23, float* %2
br label %26
24: ; preds = %18
%25 = load float, float* %3
store float %25, float* %2
br label %26
26: ; preds = %24, %21, %15
%27 = load float, float* %2
ret float %27
}

LLVM IR (-O2):
define float @ModAngle(float %0) {
%2 = fmul float %0, 0x3FC45F3060000000
%3 = fptosi float %2 to i64
%4 = sitofp i64 %3 to float
%5 = fneg float %4
%6 = tail call float @llvm.fmuladd.f32(float %5, float 0x401921FB60000000, float %0)
%7 = fcmp ogt float %6, 0x400921FB60000000
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = fadd float %6, 0xC01921FB60000000
br label %14
10: ; preds = %1
%11 = fcmp olt float %6, 0xC00921FB60000000
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = fadd float %6, 0x401921FB60000000
br label %14
14: ; preds = %10, %12, %8
%15 = phi float [ %9, %8 ], [ %13, %12 ], [ %6, %10 ]
ret float %15
}