double range_degrees(double angle) {
  double temp;
  double range;
  if (angle >= 0.0 && angle < 360.0)
    return (angle);
  temp = (int)(angle / 360);
  if (angle < 0.0)
    temp--;
  temp *= 360;
  range = angle - temp;
  return (range);
}


x86 assembly (clang, -O0):
<range_degrees>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     113d <range_degrees+0x3d>
movsd  0xedd(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    113d <range_degrees+0x3d>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a6 <range_degrees+0xa6>
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 <range_degrees+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,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<range_degrees>:
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1119 <range_degrees+0x19>
movsd  0xeee(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1119 <range_degrees+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 @range_degrees(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
%6 = load double, double* %3
%7 = fcmp oge double %6, 0.000000e+00
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load double, double* %3
%10 = fcmp olt double %9, 3.600000e+02
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = load double, double* %3
store double %12, double* %2
br label %30
13: ; preds = %8, %1
%14 = load double, double* %3
%15 = fdiv double %14, 3.600000e+02
%16 = fptosi double %15 to i32
%17 = sitofp i32 %16 to double
store double %17, double* %4
%18 = load double, double* %3
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load double, double* %4
%22 = fadd double %21, -1.000000e+00
store double %22, double* %4
br label %23
23: ; preds = %20, %13
%24 = load double, double* %4
%25 = fmul double %24, 3.600000e+02
store double %25, double* %4
%26 = load double, double* %3
%27 = load double, double* %4
%28 = fsub double %26, %27
store double %28, double* %5
%29 = load double, double* %5
store double %29, double* %2
br label %30
30: ; preds = %23, %11
%31 = load double, double* %2
ret double %31
}

LLVM IR (-O2):
define double @range_degrees(double %0) {
%2 = fcmp oge double %0, 0.000000e+00
%3 = fcmp olt double %0, 3.600000e+02
%4 = and i1 %2, %3
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = fdiv double %0, 3.600000e+02
%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, 3.600000e+02
%13 = fsub double %0, %12
br label %14
14: ; preds = %1, %5
%15 = phi double [ %13, %5 ], [ %0, %1 ]
ret double %15
}