#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 NAN;
double __domain_error();
int atan(double);
scalar_t__ isnan(double);
int sqrt(int);
double asin(double x) {
  if ((x > 1.) || (x < -1.))
    return __domain_error();
  if (isnan(x))
    return NAN;
  return 2. * atan(x / (1. + sqrt(1. - x * x)));
}


x86 assembly (clang, -O0):
<asin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1177 <asin+0x37>
movsd  0xe9c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1188 <asin+0x48>
mov    $0x0,%al
call   1030 <__domain_error@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1228 <asin+0xe8>
movsd  -0x10(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
je     11b1 <asin+0x71>
mov    0x2e55(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1228 <asin+0xe8>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe18(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movsd  -0x18(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
movsd  0xdfa(%rip),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1040 <atan@plt>
cvtsi2sd %eax,%xmm1
movsd  0xdf1(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asin>:
push   %rax
ucomisd 0xeb7(%rip),%xmm0
ja     1175 <asin+0x35>
movsd  0xeb5(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1175 <asin+0x35>
movsd  %xmm0,(%rsp)
call   1050 <isnan@plt>
test   %rax,%rax
je     117d <asin+0x3d>
mov    0x2e89(%rip),%rax
movsd  (%rax),%xmm0
pop    %rax
ret
xor    %eax,%eax
pop    %rcx
jmp    1030 <__domain_error@plt>
movsd  (%rsp),%xmm0
mulsd  %xmm0,%xmm0
movsd  0xe72(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1060 <sqrt@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  0xe56(%rip),%xmm1
movsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1040 <atan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
define double @asin(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ogt double %4, 1.000000e+00
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load double, double* %3
%8 = fcmp olt double %7, -1.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %6, %1
%10 = call double (...) @__domain_error()
store double %10, double* %2
br label %31
11: ; preds = %6
%12 = load double, double* %3
%13 = call i64 @isnan(double %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load double, double* @NAN
store double %16, double* %2
br label %31
17: ; preds = %11
%18 = load double, double* %3
%19 = load double, double* %3
%20 = load double, double* %3
%21 = fneg double %19
%22 = call double @llvm.fmuladd.f64(double %21, double %20, double 1.000000e+00)
%23 = fptosi double %22 to i32
%24 = call i32 @sqrt(i32 %23)
%25 = sitofp i32 %24 to double
%26 = fadd double 1.000000e+00, %25
%27 = fdiv double %18, %26
%28 = call i32 @atan(double %27)
%29 = sitofp i32 %28 to double
%30 = fmul double 2.000000e+00, %29
store double %30, double* %2
br label %31
31: ; preds = %17, %15, %9
%32 = load double, double* %2
ret double %32
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
define double @asin(double %0) {
%2 = fcmp ogt double %0, 1.000000e+00
%3 = fcmp olt double %0, -1.000000e+00
%4 = or i1 %2, %3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call double (...) @__domain_error()
br label %23
7: ; preds = %1
%8 = tail call i64 @isnan(double %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = load double, double* @NAN
br label %23
12: ; preds = %7
%13 = fneg double %0
%14 = tail call double @llvm.fmuladd.f64(double %13, double %0, double 1.000000e+00)
%15 = fptosi double %14 to i32
%16 = tail call i32 @sqrt(i32 %15)
%17 = sitofp i32 %16 to double
%18 = fadd double %17, 1.000000e+00
%19 = fdiv double %0, %18
%20 = tail call i32 @atan(double %19)
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 2.000000e+00
br label %23
23: ; preds = %12, %10, %5
%24 = phi double [ %6, %5 ], [ %11, %10 ], [ %22, %12 ]
ret double %24
}