#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 M_PI;
char floor(float);
float lash_normalizeRadians(float radians) {
  char rotations = floor(radians / (2 * M_PI));
  if (rotations != 0)
    radians -= (M_PI * 2) * rotations;
  else if (radians < 0)
    radians += (M_PI * 2);
  return radians;
}


x86 assembly (clang, -O0):
<lash_normalizeRadians>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
mov    0x2ebf(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
call   1030 <floor@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
je     1175 <lash_normalizeRadians+0x65>
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
movsbl -0x5(%rbp),%ecx
imul   %ecx,%eax
cvtsi2ss %eax,%xmm1
movss  -0x4(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11a1 <lash_normalizeRadians+0x91>
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    119c <lash_normalizeRadians+0x8c>
mov    0x2e5f(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11a1 <lash_normalizeRadians+0x91>
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lash_normalizeRadians>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ecc(%rip),%rbx
mov    (%rbx),%eax
add    %eax,%eax
cvtsi2ss %eax,%xmm1
movss  %xmm0,0xc(%rsp)
divss  %xmm1,%xmm0
call   1030 <floor@plt>
test   %al,%al
je     1155 <lash_normalizeRadians+0x45>
movsbl %al,%eax
imul   (%rbx),%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xc(%rsp),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,%xmm0
jmp    1175 <lash_normalizeRadians+0x65>
xorps  %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm1,%xmm0
movaps %xmm1,%xmm0
jbe    1175 <lash_normalizeRadians+0x65>
mov    (%rbx),%eax
add    %eax,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i32 0
define float @lash_normalizeRadians(float %0) {
%2 = alloca float
%3 = alloca i8
store float %0, float* %2
%4 = load float, float* %2
%5 = load i32, i32* @M_PI
%6 = mul nsw i32 2, %5
%7 = sitofp i32 %6 to float
%8 = fdiv float %4, %7
%9 = call signext i8 @floor(float %8)
store i8 %9, i8* %3
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %1
%14 = load i32, i32* @M_PI
%15 = mul nsw i32 %14, 2
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = mul nsw i32 %15, %17
%19 = sitofp i32 %18 to float
%20 = load float, float* %2
%21 = fsub float %20, %19
store float %21, float* %2
br label %32
22: ; preds = %1
%23 = load float, float* %2
%24 = fcmp olt float %23, 0.000000e+00
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* @M_PI
%27 = mul nsw i32 %26, 2
%28 = sitofp i32 %27 to float
%29 = load float, float* %2
%30 = fadd float %29, %28
store float %30, float* %2
br label %31
31: ; preds = %25, %22
br label %32
32: ; preds = %31, %13
%33 = load float, float* %2
ret float %33
}

LLVM IR (-O2):
@M_PI = global i32 0
define float @lash_normalizeRadians(float %0) {
%2 = load i32, i32* @M_PI
%3 = shl nsw i32 %2, 1
%4 = sitofp i32 %3 to float
%5 = fdiv float %0, %4
%6 = tail call signext i8 @floor(float %5)
%7 = icmp eq i8 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %1
%9 = sext i8 %6 to i32
%10 = load i32, i32* @M_PI
%11 = shl nsw i32 %9, 1
%12 = mul i32 %11, %10
%13 = sitofp i32 %12 to float
%14 = fsub float %0, %13
br label %22
15: ; preds = %1
%16 = fcmp olt float %0, 0.000000e+00
br i1 %16, label %17, label %22
17: ; preds = %15
%18 = load i32, i32* @M_PI
%19 = shl nsw i32 %18, 1
%20 = sitofp i32 %19 to float
%21 = fadd float %20, %0
br label %22
22: ; preds = %15, %17, %8
%23 = phi float [ %14, %8 ], [ %21, %17 ], [ %0, %15 ]
ret float %23
}