double sind(angle)
double angle;
{
  int i;
  if (fmod(angle, 90.0) == 0.0) {
    i = abs((int)floor(angle / 90.0 - 0.5)) % 4;
    switch (i) {
    case 0:
      return 1.0;
    case 1:
      return 0.0;
    case 2:
      return -1.0;
    case 3:
      return 0.0;
    }
  }
  return sin(angle * 3.141592653589793238462643 / 180.0);
}


x86 assembly (clang, -O0):
<sind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
call   1040 <fmod@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1219 <sind+0xd9>
jp     1219 <sind+0xd9>
movsd  -0x10(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe7d(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <floor@plt>
cvttsd2si %xmm0,%edi
call   1030 <abs@plt>
mov    %eax,%edx
add    $0x3,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     1214 <sind+0xd4>
mov    -0x20(%rbp),%rax
lea    0xe63(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xe3a(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123c <sind+0xfc>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123c <sind+0xfc>
movsd  0xe13(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123c <sind+0xfc>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    123c <sind+0xfc>
jmp    1219 <sind+0xd9>
movsd  0xe07(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xdf2(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sind>:
push   %rax
movsd  0xec7(%rip),%xmm1
movsd  %xmm0,(%rsp)
call   1030 <fmod@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1185 <sind+0x55>
jp     1185 <sind+0x55>
movsd  (%rsp),%xmm0
divsd  0xea4(%rip),%xmm0
addsd  0xeb4(%rip),%xmm0
call   1050 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
and    $0x3,%ecx
lea    0xea2(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
pop    %rax
ret
movsd  (%rsp),%xmm0
mulsd  0xe76(%rip),%xmm0
divsd  0xe76(%rip),%xmm0
pop    %rax
jmp    1040 <sin@plt>

LLVM IR (-O0):
define double @sind(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = call double @fmod(double %5, double 9.000000e+01)
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %8, label %22
8: ; preds = %1
%9 = load double, double* %3
%10 = fdiv double %9, 9.000000e+01
%11 = fsub double %10, 5.000000e-01
%12 = call double @llvm.floor.f64(double %11)
%13 = fptosi double %12 to i32
%14 = call i32 @abs(i32 %13)
%15 = srem i32 %14, 4
store i32 %15, i32* %4
%16 = load i32, i32* %4
switch i32 %16, label %21 [
i32 0, label %17
i32 1, label %18
i32 2, label %19
i32 3, label %20
]
17: ; preds = %8
store double 1.000000e+00, double* %2
br label %27
18: ; preds = %8
store double 0.000000e+00, double* %2
br label %27
19: ; preds = %8
store double -1.000000e+00, double* %2
br label %27
20: ; preds = %8
store double 0.000000e+00, double* %2
br label %27
21: ; preds = %8
br label %22
22: ; preds = %21, %1
%23 = load double, double* %3
%24 = fmul double %23, 0x400921FB54442D18
%25 = fdiv double %24, 1.800000e+02
%26 = call double @sin(double %25)
store double %26, double* %2
br label %27
27: ; preds = %22, %20, %19, %18, %17
%28 = load double, double* %2
ret double %28
}

LLVM IR (-O2):
@switch.table.sind = [4 x double] [double 1.000000e+00, double 0.000000e+00, double -1.000000e+00, double 0.000000e+00]
define double @sind(double %0) {
%2 = tail call double @fmod(double %0, double 9.000000e+01)
%3 = fcmp oeq double %2, 0.000000e+00
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = fdiv double %0, 9.000000e+01
%6 = fadd double %5, -5.000000e-01
%7 = tail call double @llvm.floor.f64(double %6)
%8 = fptosi double %7 to i32
%9 = tail call i32 @llvm.abs.i32(i32 %8, i1 true)
%10 = and i32 %9, 3
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [4 x double], [4 x double]* @switch.table.sind, i64 0, i64 %11
%13 = load double, double* %12
br label %18
14: ; preds = %1
%15 = fmul double %0, 0x400921FB54442D18
%16 = fdiv double %15, 1.800000e+02
%17 = tail call double @sin(double %16)
br label %18
18: ; preds = %4, %14
%19 = phi double [ %17, %14 ], [ %13, %4 ]
ret double %19
}