#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 Sign(double);
double atan(double);
double fabs(double);
double sqrt(double);
double ArcSin(double arg) {
  if (fabs(arg) >= 1.0)
    return (Sign(arg) * 1.57079632679489656);
  else
    return (atan(arg / sqrt(1.0 - arg * arg)));
}


x86 assembly (clang, -O0):
<ArcSin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xec7(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xeab(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     117f <ArcSin+0x4f>
movsd  -0x10(%rbp),%xmm0
call   1030 <Sign@plt>
movsd  0xe97(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d5 <ArcSin+0xa5>
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  0xe4a(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1040 <atan@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ArcSin>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
movapd 0xec0(%rip),%xmm0
andpd  %xmm2,%xmm0
ucomisd 0xec4(%rip),%xmm0
jae    1172 <ArcSin+0x42>
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xeb2(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1188 <ArcSin+0x58>
sqrtsd %xmm0,%xmm0
jmp    1197 <ArcSin+0x67>
movapd %xmm2,%xmm0
call   1030 <Sign@plt>
mulsd  0xe95(%rip),%xmm0
add    $0x18,%rsp
ret
movapd %xmm2,(%rsp)
call   1050 <sqrt@plt>
movapd (%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
jmp    1040 <atan@plt>

LLVM IR (-O0):
define double @ArcSin(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = call double @llvm.fabs.f64(double %4)
%6 = fcmp oge double %5, 1.000000e+00
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load double, double* %3
%9 = call double @Sign(double %8)
%10 = fmul double %9, 0x3FF921FB54442D18
store double %10, double* %2
br label %20
11: ; preds = %1
%12 = load double, double* %3
%13 = load double, double* %3
%14 = load double, double* %3
%15 = fneg double %13
%16 = call double @llvm.fmuladd.f64(double %15, double %14, double 1.000000e+00)
%17 = call double @sqrt(double %16)
%18 = fdiv double %12, %17
%19 = call double @atan(double %18)
store double %19, double* %2
br label %20
20: ; preds = %11, %7
%21 = load double, double* %2
ret double %21
}

LLVM IR (-O2):
define double @ArcSin(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
%3 = fcmp ult double %2, 1.000000e+00
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call double @Sign(double %0)
%6 = fmul double %5, 0x3FF921FB54442D18
br label %13
7: ; preds = %1
%8 = fneg double %0
%9 = tail call double @llvm.fmuladd.f64(double %8, double %0, double 1.000000e+00)
%10 = tail call double @sqrt(double %9)
%11 = fdiv double %0, %10
%12 = tail call double @atan(double %11)
br label %13
13: ; preds = %7, %4
%14 = phi double [ %6, %4 ], [ %12, %7 ]
ret double %14
}