double asin(x)
double x;
{
  double s, t, copysign(), atan2(), sqrt(), one = 1.0;
  if (x != x)
    return (x);
  s = copysign(x, one);
  if (s <= 0.5)
    return (atan2(x, sqrt(one - x * x)));
  else {
    t = one - s;
    s = t + t;
    return (atan2(x, sqrt(s - t * t)));
  }
}


x86 assembly (clang, -O0):
<asin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    1155 <asin+0x35>
jp     1155 <asin+0x35>
jmp    1164 <asin+0x44>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1261 <asin+0x141>
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movaps 0xe9b(%rip),%xmm2
pand   %xmm2,%xmm1
movaps 0xea0(%rip),%xmm2
pand   %xmm2,%xmm0
por    %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe73(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11f4 <asin+0xd4>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
call   1030 <atan2@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1261 <asin+0x141>
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
call   1030 <atan2@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asin>:
movapd %xmm0,%xmm2
ucomisd %xmm0,%xmm0
jp     11a9 <asin+0x89>
sub    $0x18,%rsp
movapd 0xeca(%rip),%xmm0
andpd  %xmm2,%xmm0
movsd  0xece(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1162 <asin+0x42>
movsd  0xec8(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm1
jmp    1172 <asin+0x52>
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xea6(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1189 <asin+0x69>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    119c <asin+0x7c>
movapd %xmm2,(%rsp)
call   1040 <sqrt@plt>
movapd (%rsp),%xmm2
movapd %xmm0,%xmm1
movapd %xmm2,%xmm0
add    $0x18,%rsp
jmp    1030 <atan2@plt>
movapd %xmm2,%xmm0
ret

LLVM IR (-O0):
define double @asin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store double 1.000000e+00, double* %6
%7 = load double, double* %3
%8 = load double, double* %3
%9 = fcmp une double %7, %8
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load double, double* %3
store double %11, double* %2
br label %42
12: ; preds = %1
%13 = load double, double* %3
%14 = load double, double* %6
%15 = call double @llvm.copysign.f64(double %13, double %14)
store double %15, double* %4
%16 = load double, double* %4
%17 = fcmp ole double %16, 5.000000e-01
br i1 %17, label %18, label %27
18: ; preds = %12
%19 = load double, double* %3
%20 = load double, double* %6
%21 = load double, double* %3
%22 = load double, double* %3
%23 = fneg double %21
%24 = call double @llvm.fmuladd.f64(double %23, double %22, double %20)
%25 = call double @sqrt(double %24)
%26 = call double @atan2(double %19, double %25)
store double %26, double* %2
br label %42
27: ; preds = %12
%28 = load double, double* %6
%29 = load double, double* %4
%30 = fsub double %28, %29
store double %30, double* %5
%31 = load double, double* %5
%32 = load double, double* %5
%33 = fadd double %31, %32
store double %33, double* %4
%34 = load double, double* %3
%35 = load double, double* %4
%36 = load double, double* %5
%37 = load double, double* %5
%38 = fneg double %36
%39 = call double @llvm.fmuladd.f64(double %38, double %37, double %35)
%40 = call double @sqrt(double %39)
%41 = call double @atan2(double %34, double %40)
store double %41, double* %2
br label %42
42: ; preds = %27, %18, %10
%43 = load double, double* %2
ret double %43
}

LLVM IR (-O2):
define double @asin(double %0) {
%2 = fcmp uno double %0, 0.000000e+00
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = tail call double @llvm.fabs.f64(double %0)
%5 = fcmp ugt double %4, 5.000000e-01
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = fneg double %0
%8 = tail call double @llvm.fmuladd.f64(double %7, double %0, double 1.000000e+00)
br label %14
9: ; preds = %3
%10 = fsub double 1.000000e+00, %4
%11 = fadd double %10, %10
%12 = fneg double %10
%13 = tail call double @llvm.fmuladd.f64(double %12, double %10, double %11)
br label %14
14: ; preds = %6, %9
%15 = phi double [ %13, %9 ], [ %8, %6 ]
%16 = tail call double @sqrt(double %15)
%17 = tail call double @atan2(double %0, double %16)
br label %18
18: ; preds = %14, %1
%19 = phi double [ %0, %1 ], [ %17, %14 ]
ret double %19
}