double angle360(angle)
double angle;
{
  int n;
  if (angle < 0.0) {
    n = (int)(angle / 360.0) - 1;
    return (angle - n * 360.0);
  } else if (angle > 360.0) {
    n = (int)(angle / 360.0);
    return (angle - n * 360.0);
  } else {
    return (angle);
  }
}


x86 assembly (clang, -O0):
<angle360>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    116d <angle360+0x6d>
movsd  -0x10(%rbp),%xmm0
movsd  0xedc(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xea5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e1 <angle360+0xe1>
movsd  -0x10(%rbp),%xmm0
movsd  0xe86(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d7 <angle360+0xd7>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6f(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe3b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e1 <angle360+0xe1>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<angle360>:
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    112a <angle360+0x2a>
movsd  0xeee(%rip),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
cvttsd2si %xmm2,%eax
add    $0xffffffff,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
jmp    114c <angle360+0x4c>
ucomisd 0xece(%rip),%xmm0
jbe    1154 <angle360+0x54>
movsd  0xec4(%rip),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
cvttpd2dq %xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @angle360(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = load double, double* %3
%9 = fdiv double %8, 3.600000e+02
%10 = fptosi double %9 to i32
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %4
%12 = load double, double* %3
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to double
%15 = fneg double %14
%16 = call double @llvm.fmuladd.f64(double %15, double 3.600000e+02, double %12)
store double %16, double* %2
br label %31
17: ; preds = %1
%18 = load double, double* %3
%19 = fcmp ogt double %18, 3.600000e+02
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load double, double* %3
%22 = fdiv double %21, 3.600000e+02
%23 = fptosi double %22 to i32
store i32 %23, i32* %4
%24 = load double, double* %3
%25 = load i32, i32* %4
%26 = sitofp i32 %25 to double
%27 = fneg double %26
%28 = call double @llvm.fmuladd.f64(double %27, double 3.600000e+02, double %24)
store double %28, double* %2
br label %31
29: ; preds = %17
%30 = load double, double* %3
store double %30, double* %2
br label %31
31: ; preds = %29, %20, %7
%32 = load double, double* %2
ret double %32
}

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