#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 fmodf(float, float);
float mod(float a) {
  if (a + M_PI < 0.0f) {
    return -(fmodf(-(a + M_PI), M_PI * 2.0) - M_PI);
  } else {
    return fmodf(a + M_PI, M_PI * 2.0) - M_PI;
  }
}


x86 assembly (clang, -O0):
<mod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm1
mov    0x2ebf(%rip),%rax
addss  (%rax),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    119c <mod+0x8c>
movss  -0x8(%rbp),%xmm0
mov    0x2ea3(%rip),%rax
addss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    0x2e8b(%rip),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe93(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
call   1030 <fmodf@plt>
mov    0x2e67(%rip),%rax
subss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e0 <mod+0xd0>
movss  -0x8(%rbp),%xmm0
mov    0x2e40(%rip),%rax
addss  (%rax),%xmm0
mov    0x2e35(%rip),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe3d(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
call   1030 <fmodf@plt>
mov    0x2e11(%rip),%rax
subss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod>:
push   %rbx
mov    0x2ed0(%rip),%rbx
movss  (%rbx),%xmm1
addss  %xmm1,%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm0,%xmm2
jbe    1145 <mod+0x35>
xorps  0xed1(%rip),%xmm0
addss  %xmm1,%xmm1
call   1030 <fmodf@plt>
subss  (%rbx),%xmm0
xorps  0xebd(%rip),%xmm0
pop    %rbx
ret
addss  %xmm1,%xmm1
call   1030 <fmodf@plt>
subss  (%rbx),%xmm0
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global float 0.000000e+00
define float @mod(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %3
%4 = load float, float* %3
%5 = load float, float* @M_PI
%6 = fadd float %4, %5
%7 = fcmp olt float %6, 0.000000e+00
br i1 %7, label %8, label %21
8: ; preds = %1
%9 = load float, float* %3
%10 = load float, float* @M_PI
%11 = fadd float %9, %10
%12 = fneg float %11
%13 = load float, float* @M_PI
%14 = fpext float %13 to double
%15 = fmul double %14, 2.000000e+00
%16 = fptrunc double %15 to float
%17 = call float @fmodf(float %12, float %16)
%18 = load float, float* @M_PI
%19 = fsub float %17, %18
%20 = fneg float %19
store float %20, float* %2
br label %32
21: ; preds = %1
%22 = load float, float* %3
%23 = load float, float* @M_PI
%24 = fadd float %22, %23
%25 = load float, float* @M_PI
%26 = fpext float %25 to double
%27 = fmul double %26, 2.000000e+00
%28 = fptrunc double %27 to float
%29 = call float @fmodf(float %24, float %28)
%30 = load float, float* @M_PI
%31 = fsub float %29, %30
store float %31, float* %2
br label %32
32: ; preds = %21, %8
%33 = load float, float* %2
ret float %33
}

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