double tand(angle)
double angle;
{
  double resid;
  resid = fmod(angle, 360.0);
  if (resid == 0.0 || fabs(resid) == 180.0) {
    return 0.0;
  } else if (resid == 45.0 || resid == 225.0) {
    return 1.0;
  } else if (resid == -135.0 || resid == -315.0) {
    return -1.0;
  }
  return tan(angle * 3.141592653589793238462643 / 180.0);
}


x86 assembly (clang, -O0):
<tand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xec6(%rip),%xmm1
call   1030 <fmod@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1161 <tand+0x41>
jp     1161 <tand+0x41>
jmp    1189 <tand+0x69>
movsd  -0x18(%rbp),%xmm0
movaps 0xee3(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe8f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1196 <tand+0x76>
jp     1196 <tand+0x76>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1265 <tand+0x145>
movsd  -0x18(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11b8 <tand+0x98>
jp     11b8 <tand+0x98>
jmp    11d5 <tand+0xb5>
movsd  -0x18(%rbp),%xmm0
movsd  0xe53(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11e7 <tand+0xc7>
jp     11e7 <tand+0xc7>
movsd  0xe63(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1265 <tand+0x145>
movsd  -0x18(%rbp),%xmm0
movsd  0xe2c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1209 <tand+0xe9>
jp     1209 <tand+0xe9>
jmp    1226 <tand+0x106>
movsd  -0x18(%rbp),%xmm0
movsd  0xe12(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1238 <tand+0x118>
jp     1238 <tand+0x118>
movsd  0xe0a(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1265 <tand+0x145>
jmp    123d <tand+0x11d>
jmp    1242 <tand+0x122>
movsd  0xde6(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xdb1(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <tan@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tand>:
push   %rax
movsd  0xed7(%rip),%xmm1
movsd  %xmm0,(%rsp)
call   1030 <fmod@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1143 <tand+0x23>
jnp    11b6 <tand+0x96>
movapd 0xf05(%rip),%xmm2
andpd  %xmm1,%xmm2
ucomisd 0xeb1(%rip),%xmm2
jne    115b <tand+0x3b>
jnp    11b6 <tand+0x96>
ucomisd 0xead(%rip),%xmm1
movsd  0xead(%rip),%xmm0
jne    116f <tand+0x4f>
jnp    11b6 <tand+0x96>
ucomisd 0xea9(%rip),%xmm1
jne    117b <tand+0x5b>
jnp    11b6 <tand+0x96>
ucomisd 0xea5(%rip),%xmm1
movsd  0xea5(%rip),%xmm0
jne    118f <tand+0x6f>
jnp    11b6 <tand+0x96>
ucomisd 0xea1(%rip),%xmm1
jne    119b <tand+0x7b>
jnp    11b6 <tand+0x96>
movsd  (%rsp),%xmm0
mulsd  0xe98(%rip),%xmm0
divsd  0xe58(%rip),%xmm0
pop    %rax
jmp    1040 <tan@plt>
pop    %rax
ret

LLVM IR (-O0):
define double @tand(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
%5 = load double, double* %3
%6 = call double @fmod(double %5, double 3.600000e+02)
store double %6, double* %4
%7 = load double, double* %4
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = load double, double* %4
%11 = call double @llvm.fabs.f64(double %10)
%12 = fcmp oeq double %11, 1.800000e+02
br i1 %12, label %13, label %14
13: ; preds = %9, %1
store double 0.000000e+00, double* %2
br label %35
14: ; preds = %9
%15 = load double, double* %4
%16 = fcmp oeq double %15, 4.500000e+01
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load double, double* %4
%19 = fcmp oeq double %18, 2.250000e+02
br i1 %19, label %20, label %21
20: ; preds = %17, %14
store double 1.000000e+00, double* %2
br label %35
21: ; preds = %17
%22 = load double, double* %4
%23 = fcmp oeq double %22, -1.350000e+02
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load double, double* %4
%26 = fcmp oeq double %25, -3.150000e+02
br i1 %26, label %27, label %28
27: ; preds = %24, %21
store double -1.000000e+00, double* %2
br label %35
28: ; preds = %24
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = load double, double* %3
%32 = fmul double %31, 0x400921FB54442D18
%33 = fdiv double %32, 1.800000e+02
%34 = call double @tan(double %33)
store double %34, double* %2
br label %35
35: ; preds = %30, %27, %20, %13
%36 = load double, double* %2
ret double %36
}

LLVM IR (-O2):
define double @tand(double %0) {
%2 = tail call double @fmod(double %0, double 3.600000e+02)
%3 = fcmp oeq double %2, 0.000000e+00
%4 = tail call double @llvm.fabs.f64(double %2)
%5 = fcmp oeq double %4, 1.800000e+02
%6 = select i1 %3, i1 true, i1 %5
br i1 %6, label %19, label %7
7: ; preds = %1
%8 = fcmp oeq double %2, 4.500000e+01
%9 = fcmp oeq double %2, 2.250000e+02
%10 = or i1 %8, %9
br i1 %10, label %19, label %11
11: ; preds = %7
%12 = fcmp oeq double %2, -1.350000e+02
%13 = fcmp oeq double %2, -3.150000e+02
%14 = or i1 %12, %13
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = fmul double %0, 0x400921FB54442D18
%17 = fdiv double %16, 1.800000e+02
%18 = tail call double @tan(double %17)
br label %19
19: ; preds = %11, %7, %1, %15
%20 = phi double [ %18, %15 ], [ 0.000000e+00, %1 ], [ 1.000000e+00, %7 ], [ -1.000000e+00, %11 ]
ret double %20
}