#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_2;
float floor(float);
float lash_normalizeQuadrantRadians(float radians) {
  float rotations = floor(radians / M_PI_2);
  if (rotations != 0)
    radians -= (float)M_PI_2 * rotations;
  else if (radians < 0)
    radians += M_PI_2 + (float)(M_PI_2 * rotations);
  return radians;
}


x86 assembly (clang, -O0):
<lash_normalizeQuadrantRadians>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
mov    0x2ebf(%rip),%rax
divss  (%rax),%xmm0
call   1030 <floor@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1153 <lash_normalizeQuadrantRadians+0x43>
jp     1153 <lash_normalizeQuadrantRadians+0x43>
jmp    1187 <lash_normalizeQuadrantRadians+0x77>
mov    0x2e8e(%rip),%rax
movss  (%rax),%xmm0
movss  -0x8(%rbp),%xmm2
movss  -0x4(%rbp),%xmm1
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c6 <lash_normalizeQuadrantRadians+0xb6>
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11c1 <lash_normalizeQuadrantRadians+0xb1>
mov    0x2e4d(%rip),%rax
movss  (%rax),%xmm1
mov    0x2e42(%rip),%rax
movss  (%rax),%xmm0
movss  -0x8(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c6 <lash_normalizeQuadrantRadians+0xb6>
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lash_normalizeQuadrantRadians>:
push   %rax
mov    0x2ed0(%rip),%rax
movss  (%rax),%xmm1
movss  %xmm0,0x4(%rsp)
movss  %xmm1,(%rsp)
divss  %xmm1,%xmm0
call   1030 <floorf@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    113a <lash_normalizeQuadrantRadians+0x2a>
jnp    114f <lash_normalizeQuadrantRadians+0x3f>
movss  (%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
subss  %xmm1,%xmm0
pop    %rax
ret
movss  (%rsp),%xmm2
movss  0x4(%rsp),%xmm3
ucomiss %xmm3,%xmm1
movaps %xmm3,%xmm1
jbe    116e <lash_normalizeQuadrantRadians+0x5e>
mulss  %xmm2,%xmm0
addss  %xmm2,%xmm0
addss  %xmm0,%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@M_PI_2 = global float 0.000000e+00
define float @lash_normalizeQuadrantRadians(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %2
%4 = load float, float* %2
%5 = load float, float* @M_PI_2
%6 = fdiv float %4, %5
%7 = call float @floor(float %6)
store float %7, float* %3
%8 = load float, float* %3
%9 = fcmp une float %8, 0.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load float, float* @M_PI_2
%12 = load float, float* %3
%13 = load float, float* %2
%14 = fneg float %11
%15 = call float @llvm.fmuladd.f32(float %14, float %12, float %13)
store float %15, float* %2
br label %27
16: ; preds = %1
%17 = load float, float* %2
%18 = fcmp olt float %17, 0.000000e+00
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load float, float* @M_PI_2
%21 = load float, float* @M_PI_2
%22 = load float, float* %3
%23 = call float @llvm.fmuladd.f32(float %21, float %22, float %20)
%24 = load float, float* %2
%25 = fadd float %24, %23
store float %25, float* %2
br label %26
26: ; preds = %19, %16
br label %27
27: ; preds = %26, %10
%28 = load float, float* %2
ret float %28
}

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