double acosd(v)
double v;
{
  if (v >= 1.0) {
    if (v - 1.0 < 1e-10)
      return 0.0;
  } else if (v == 0.0) {
    return 90.0;
  } else if (v <= -1.0) {
    if (v + 1.0 > -1e-10)
      return 180.0;
  }
  return acos(v) * 180.0 / 3.141592653589793238462643;
}


x86 assembly (clang, -O0):
<acosd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1169 <acosd+0x59>
movsd  -0x10(%rbp),%xmm1
movsd  0xebf(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xedb(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1164 <acosd+0x54>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120d <acosd+0xfd>
jmp    11e6 <acosd+0xd6>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1193 <acosd+0x83>
jp     1193 <acosd+0x83>
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120d <acosd+0xfd>
movsd  0xe6d(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11dc <acosd+0xcc>
movsd  0xe52(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xe55(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d7 <acosd+0xc7>
movsd  0xe4b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120d <acosd+0xfd>
jmp    11dc <acosd+0xcc>
jmp    11e1 <acosd+0xd1>
jmp    11e6 <acosd+0xd6>
movsd  -0x10(%rbp),%xmm0
call   1030 <acos@plt>
movsd  0xe20(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acosd>:
push   %rax
ucomisd 0xee7(%rip),%xmm0
jae    1131 <acosd+0x21>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116a <acosd+0x5a>
jp     116a <acosd+0x5a>
movsd  0xee9(%rip),%xmm1
jmp    1196 <acosd+0x86>
movsd  0xecf(%rip),%xmm2
addsd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
movsd  0xec7(%rip),%xmm3
ucomisd %xmm2,%xmm3
ja     1196 <acosd+0x86>
call   1030 <acos@plt>
movapd %xmm0,%xmm1
mulsd  0xec0(%rip),%xmm1
divsd  0xec8(%rip),%xmm1
jmp    1196 <acosd+0x86>
movsd  0xe96(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     114f <acosd+0x3f>
movsd  0xe80(%rip),%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xe9c(%rip),%xmm1
jbe    114f <acosd+0x3f>
movsd  0xe8a(%rip),%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @acosd(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp oge double %4, 1.000000e+00
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load double, double* %3
%8 = fsub double %7, 1.000000e+00
%9 = fcmp olt double %8, 1.000000e-10
br i1 %9, label %10, label %11
10: ; preds = %6
store double 0.000000e+00, double* %2
br label %32
11: ; preds = %6
br label %27
12: ; preds = %1
%13 = load double, double* %3
%14 = fcmp oeq double %13, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %12
store double 9.000000e+01, double* %2
br label %32
16: ; preds = %12
%17 = load double, double* %3
%18 = fcmp ole double %17, -1.000000e+00
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load double, double* %3
%21 = fadd double %20, 1.000000e+00
%22 = fcmp ogt double %21, -1.000000e-10
br i1 %22, label %23, label %24
23: ; preds = %19
store double 1.800000e+02, double* %2
br label %32
24: ; preds = %19
br label %25
25: ; preds = %24, %16
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26, %11
%28 = load double, double* %3
%29 = call double @acos(double %28)
%30 = fmul double %29, 1.800000e+02
%31 = fdiv double %30, 0x400921FB54442D18
store double %31, double* %2
br label %32
32: ; preds = %27, %23, %15, %10
%33 = load double, double* %2
ret double %33
}

LLVM IR (-O2):
define double @acosd(double %0) {
%2 = fcmp ult double %0, 1.000000e+00
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = fadd double %0, -1.000000e+00
%5 = fcmp olt double %4, 1.000000e-10
br i1 %5, label %17, label %13
6: ; preds = %1
%7 = fcmp oeq double %0, 0.000000e+00
br i1 %7, label %17, label %8
8: ; preds = %6
%9 = fcmp ole double %0, -1.000000e+00
%10 = fadd double %0, 1.000000e+00
%11 = fcmp ogt double %10, -1.000000e-10
%12 = and i1 %9, %11
br i1 %12, label %17, label %13
13: ; preds = %8, %3
%14 = tail call double @acos(double %0)
%15 = fmul double %14, 1.800000e+02
%16 = fdiv double %15, 0x400921FB54442D18
br label %17
17: ; preds = %8, %6, %3, %13
%18 = phi double [ %16, %13 ], [ 0.000000e+00, %3 ], [ 9.000000e+01, %6 ], [ 1.800000e+02, %8 ]
ret double %18
}