#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 atan(double);
double sqrt(int);
double asin(double x) {
  if (x < -1.0 || x > 1.0)
    return -1024;
  if (x == -1.0)
    return -1.5707963;
  if (x == 1.0)
    return 1.5707963;
  if (x > 0.816) {
    return atan(x / sqrt((1 + x) * (1 - x)));
  } else {
    return atan(x / sqrt(1 - x * x));
  }
}


x86 assembly (clang, -O0):
<asin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xecb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1157 <asin+0x37>
movsd  -0x10(%rbp),%xmm0
movsd  0xebb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1169 <asin+0x49>
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1284 <asin+0x164>
movsd  -0x10(%rbp),%xmm0
movsd  0xe8a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1198 <asin+0x78>
jp     1198 <asin+0x78>
movsd  0xe92(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1284 <asin+0x164>
movsd  -0x10(%rbp),%xmm0
movsd  0xe63(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11c7 <asin+0xa7>
jp     11c7 <asin+0xa7>
movsd  0xe5b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1284 <asin+0x164>
movsd  -0x10(%rbp),%xmm0
movsd  0xe3c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    122a <asin+0x10a>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe18(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xe0b(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <atan@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1284 <asin+0x164>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%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  0xda7(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <atan@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asin>:
push   %rax
movapd %xmm0,%xmm2
movsd  0xed3(%rip),%xmm0
ucomisd %xmm2,%xmm0
movsd  0xecf(%rip),%xmm0
ja     1159 <asin+0x39>
ucomisd 0xecd(%rip),%xmm2
ja     1159 <asin+0x39>
ucomisd 0xeb3(%rip),%xmm2
jne    115b <asin+0x3b>
jp     115b <asin+0x3b>
movsd  0xebf(%rip),%xmm0
pop    %rax
ret
ucomisd 0xead(%rip),%xmm2
jne    1171 <asin+0x51>
jp     1171 <asin+0x51>
movsd  0xeb1(%rip),%xmm0
pop    %rax
ret
ucomisd 0xeaf(%rip),%xmm2
movsd  %xmm2,(%rsp)
jbe    119a <asin+0x7a>
movsd  0xe88(%rip),%xmm0
movapd %xmm2,%xmm1
addsd  %xmm0,%xmm1
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
jmp    11aa <asin+0x8a>
mulsd  %xmm2,%xmm2
movsd  0xe6a(%rip),%xmm0
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
jmp    1030 <atan@plt>

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

LLVM IR (-O2):
define double @asin(double %0) {
%2 = fcmp olt double %0, -1.000000e+00
%3 = fcmp ogt double %0, 1.000000e+00
%4 = or i1 %2, %3
br i1 %4, label %24, label %5
5: ; preds = %1
%6 = fcmp oeq double %0, -1.000000e+00
br i1 %6, label %24, label %7
7: ; preds = %5
%8 = fcmp oeq double %0, 1.000000e+00
br i1 %8, label %24, label %9
9: ; preds = %7
%10 = fcmp ogt double %0, 8.160000e-01
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = fadd double %0, 1.000000e+00
%13 = fsub double 1.000000e+00, %0
%14 = fmul double %12, %13
br label %18
15: ; preds = %9
%16 = fneg double %0
%17 = tail call double @llvm.fmuladd.f64(double %16, double %0, double 1.000000e+00)
br label %18
18: ; preds = %11, %15
%19 = phi double [ %17, %15 ], [ %14, %11 ]
%20 = fptosi double %19 to i32
%21 = tail call double @sqrt(i32 %20)
%22 = fdiv double %0, %21
%23 = tail call double @atan(double %22)
br label %24
24: ; preds = %18, %7, %5, %1
%25 = phi double [ -1.024000e+03, %1 ], [ 0xBFF921FB4D12D84A, %5 ], [ 0x3FF921FB4D12D84A, %7 ], [ %23, %18 ]
ret double %25
}