double ln_range_radians(double angle) {
  double temp;
  if (angle >= 0.0 && angle < (2.0 * 3.1415926535897932384626433832795))
    return angle;
  temp = (int)(angle / (3.1415926535897932384626433832795 * 2.0));
  if (angle < 0.0)
    temp--;
  temp *= (3.1415926535897932384626433832795 * 2.0);
  return angle - temp;
}


x86 assembly (clang, -O0):
<ln_range_radians>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     113d <ln_range_radians+0x3d>
movsd  0xedd(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    113d <ln_range_radians+0x3d>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119c <ln_range_radians+0x9c>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117b <ln_range_radians+0x7b>
movsd  0xe97(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe7d(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<ln_range_radians>:
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1119 <ln_range_radians+0x19>
movsd  0xeee(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1119 <ln_range_radians+0x19>
ret
movsd  0xedf(%rip),%xmm2
movapd %xmm0,%xmm3
divsd  %xmm2,%xmm3
cvttpd2dq %xmm3,%xmm3
cvtdq2pd %xmm3,%xmm3
movsd  0xecf(%rip),%xmm4
addsd  %xmm3,%xmm4
movapd %xmm0,%xmm5
cmpltsd %xmm1,%xmm5
movapd %xmm5,%xmm1
andnpd %xmm3,%xmm1
andpd  %xmm4,%xmm5
orpd   %xmm1,%xmm5
mulsd  %xmm2,%xmm5
subsd  %xmm5,%xmm0
ret

LLVM IR (-O0):
define double @ln_range_radians(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
%5 = load double, double* %3
%6 = fcmp oge double %5, 0.000000e+00
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load double, double* %3
%9 = fcmp olt double %8, 0x401921FB54442D18
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = load double, double* %3
store double %11, double* %2
br label %28
12: ; preds = %7, %1
%13 = load double, double* %3
%14 = fdiv double %13, 0x401921FB54442D18
%15 = fptosi double %14 to i32
%16 = sitofp i32 %15 to double
store double %16, double* %4
%17 = load double, double* %3
%18 = fcmp olt double %17, 0.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load double, double* %4
%21 = fadd double %20, -1.000000e+00
store double %21, double* %4
br label %22
22: ; preds = %19, %12
%23 = load double, double* %4
%24 = fmul double %23, 0x401921FB54442D18
store double %24, double* %4
%25 = load double, double* %3
%26 = load double, double* %4
%27 = fsub double %25, %26
store double %27, double* %2
br label %28
28: ; preds = %22, %10
%29 = load double, double* %2
ret double %29
}

LLVM IR (-O2):
define double @ln_range_radians(double %0) {
%2 = fcmp oge double %0, 0.000000e+00
%3 = fcmp olt double %0, 0x401921FB54442D18
%4 = and i1 %2, %3
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = fdiv double %0, 0x401921FB54442D18
%7 = fptosi double %6 to i32
%8 = sitofp i32 %7 to double
%9 = fcmp olt double %0, 0.000000e+00
%10 = fadd double %8, -1.000000e+00
%11 = select i1 %9, double %10, double %8
%12 = fmul double %11, 0x401921FB54442D18
%13 = fsub double %0, %12
br label %14
14: ; preds = %1, %5
%15 = phi double [ %13, %5 ], [ %0, %1 ]
ret double %15
}