#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double atan2(double, int /*<<< orphan*/);
double copysign(double, double);
int /*<<< orphan*/ sqrt(double);
double asin(double x) {
  double s, t, 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    125f <asin+0x13f>
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     11f3 <asin+0xd3>
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>
movsd  -0x30(%rbp),%xmm0
mov    %eax,%edi
call   1030 <atan2@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    125f <asin+0x13f>
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>
movsd  -0x38(%rbp),%xmm0
mov    %eax,%edi
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     118f <asin+0x6f>
sub    $0x18,%rsp
movapd 0xeca(%rip),%xmm0
andpd  %xmm2,%xmm0
movsd  0xece(%rip),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm2,(%rsp)
jae    1167 <asin+0x47>
movsd  0xec3(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm1
jmp    1177 <asin+0x57>
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xea1(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps (%rsp),%xmm0
mov    %eax,%edi
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 i32 @sqrt(double %24)
%26 = call double @atan2(double %19, i32 %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 i32 @sqrt(double %39)
%41 = call double @atan2(double %34, i32 %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 i32 @sqrt(double %15)
%17 = tail call double @atan2(double %0, i32 %16)
br label %18
18: ; preds = %14, %1
%19 = phi double [ %0, %1 ], [ %17, %14 ]
ret double %19
}