#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 M_PI;
float mod2pi(float v) {
  while (v < -M_PI)
    v += 2 * M_PI;
  while (v >= M_PI)
    v -= 2 * M_PI;
  return v;
}


x86 assembly (clang, -O0):
<mod2pi>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm1
mov    0x2ed3(%rip),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
jbe    1151 <mod2pi+0x51>
mov    0x2eb2(%rip),%rax
movss  (%rax),%xmm0
movss  -0x4(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1109 <mod2pi+0x9>
jmp    1156 <mod2pi+0x56>
movss  -0x4(%rbp),%xmm0
mov    0x2e86(%rip),%rax
ucomiss (%rax),%xmm0
jb     118d <mod2pi+0x8d>
mov    0x2e76(%rip),%rax
movss  (%rax),%xmm1
movss  -0x4(%rbp),%xmm0
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1156 <mod2pi+0x56>
movss  -0x4(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod2pi>:
mov    0x2ee1(%rip),%rax
movss  (%rax),%xmm1
movaps 0xeee(%rip),%xmm2
xorps  %xmm1,%xmm2
ucomiss %xmm0,%xmm2
jbe    1139 <mod2pi+0x39>
movaps %xmm1,%xmm3
addss  %xmm1,%xmm3
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addss  %xmm3,%xmm0
ucomiss %xmm0,%xmm2
ja     1130 <mod2pi+0x30>
ucomiss %xmm1,%xmm0
jb     1159 <mod2pi+0x59>
movaps %xmm1,%xmm2
addss  %xmm1,%xmm2
cs nopw 0x0(%rax,%rax,1)
nop
subss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jae    1150 <mod2pi+0x50>
ret

LLVM IR (-O0):
@M_PI = global float 0.000000e+00
define float @mod2pi(float %0) {
%2 = alloca float
store float %0, float* %2
br label %3
3: ; preds = %8, %1
%4 = load float, float* %2
%5 = load float, float* @M_PI
%6 = fneg float %5
%7 = fcmp olt float %4, %6
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = load float, float* @M_PI
%10 = load float, float* %2
%11 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %9, float %10)
store float %11, float* %2
br label %3
12: ; preds = %3
br label %13
13: ; preds = %17, %12
%14 = load float, float* %2
%15 = load float, float* @M_PI
%16 = fcmp oge float %14, %15
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load float, float* @M_PI
%19 = load float, float* %2
%20 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %18, float %19)
store float %20, float* %2
br label %13
21: ; preds = %13
%22 = load float, float* %2
ret float %22
}

LLVM IR (-O2):
@M_PI = global float 0.000000e+00
define float @mod2pi(float %0) {
%2 = load float, float* @M_PI
%3 = fneg float %2
%4 = fcmp ogt float %3, %0
br i1 %4, label %8, label %5
5: ; preds = %8, %1
%6 = phi float [ %0, %1 ], [ %10, %8 ]
%7 = fcmp ult float %6, %2
br i1 %7, label %16, label %12
8: ; preds = %1, %8
%9 = phi float [ %10, %8 ], [ %0, %1 ]
%10 = tail call float @llvm.fmuladd.f32(float %2, float 2.000000e+00, float %9)
%11 = fcmp olt float %10, %3
br i1 %11, label %8, label %5
12: ; preds = %5, %12
%13 = phi float [ %14, %12 ], [ %6, %5 ]
%14 = tail call float @llvm.fmuladd.f32(float %2, float -2.000000e+00, float %13)
%15 = fcmp ult float %14, %2
br i1 %15, label %16, label %12
16: ; preds = %12, %5
%17 = phi float [ %6, %5 ], [ %14, %12 ]
ret float %17
}