#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 ceil(double);
int floor(double);
double r2r(double r) {
  if (r < 0.0) {
    r += ceil(r / (-2 * (3.14159265358979323846))) *
         (2 * (3.14159265358979323846));
  }
  if (r >= (2 * (3.14159265358979323846))) {
    r -= floor(r / (2 * (3.14159265358979323846))) *
         (2 * (3.14159265358979323846));
  }
  return (r);
}


x86 assembly (clang, -O0):
<r2r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    116f <r2r+0x4f>
movsd  -0x8(%rbp),%xmm0
movsd  0xec0(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
cvtsi2sd %eax,%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xe9e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11d1 <r2r+0xb1>
movsd  -0x8(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
cvtsi2sd %eax,%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe3c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<r2r>:
push   %rax
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    115d <r2r+0x3d>
movapd %xmm1,%xmm0
divsd  0xec5(%rip),%xmm0
movsd  %xmm1,(%rsp)
call   1030 <ceil@plt>
movsd  (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xeaf(%rip),%xmm0
addsd  %xmm0,%xmm1
ucomisd 0xea3(%rip),%xmm1
jae    116d <r2r+0x4d>
movapd %xmm1,%xmm0
pop    %rax
ret
movapd %xmm1,%xmm0
divsd  0xe8f(%rip),%xmm0
movsd  %xmm1,(%rsp)
call   1040 <floor@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe76(%rip),%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @r2r(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fcmp olt double %3, 0.000000e+00
br i1 %4, label %5, label %12
5: ; preds = %1
%6 = load double, double* %2
%7 = fdiv double %6, 0xC01921FB54442D18
%8 = call i32 @ceil(double %7)
%9 = sitofp i32 %8 to double
%10 = load double, double* %2
%11 = call double @llvm.fmuladd.f64(double %9, double 0x401921FB54442D18, double %10)
store double %11, double* %2
br label %12
12: ; preds = %5, %1
%13 = load double, double* %2
%14 = fcmp oge double %13, 0x401921FB54442D18
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load double, double* %2
%17 = fdiv double %16, 0x401921FB54442D18
%18 = call i32 @floor(double %17)
%19 = sitofp i32 %18 to double
%20 = load double, double* %2
%21 = fneg double %19
%22 = call double @llvm.fmuladd.f64(double %21, double 0x401921FB54442D18, double %20)
store double %22, double* %2
br label %23
23: ; preds = %15, %12
%24 = load double, double* %2
ret double %24
}

LLVM IR (-O2):
define double @r2r(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = fdiv double %0, 0xC01921FB54442D18
%5 = tail call i32 @ceil(double %4)
%6 = sitofp i32 %5 to double
%7 = tail call double @llvm.fmuladd.f64(double %6, double 0x401921FB54442D18, double %0)
br label %8
8: ; preds = %3, %1
%9 = phi double [ %7, %3 ], [ %0, %1 ]
%10 = fcmp ult double %9, 0x401921FB54442D18
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = fdiv double %9, 0x401921FB54442D18
%13 = tail call i32 @floor(double %12)
%14 = sitofp i32 %13 to double
%15 = fneg double %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double 0x401921FB54442D18, double %9)
br label %17
17: ; preds = %11, %8
%18 = phi double [ %16, %11 ], [ %9, %8 ]
ret double %18
}