#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 */
int my_abs(double);
double my_sqrt(int);
double my_asin(double x) {
  x = my_abs(x);
  if (x >= 3.141592653589793 / 4) {
    return 0.5 * 3.141592653589793 - my_asin(my_sqrt(1 - x * x));
  }
  double result = x;
  double i = 0;
  double coef = 1;
  double pow_cache = x;
  double cache = 0;
  double pow_x = x * x;
  while (my_abs(cache - result) > 1e-15 * result) {
    cache = result;
    i++;
    coef = coef * i;
    i++;
    coef = coef / i;
    pow_cache = pow_cache * pow_x;
    result = result + coef * pow_cache / (i + 1);
  }
  return result;
}


x86 assembly (clang, -O0):
<my_asin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <my_abs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11bf <my_asin+0x8f>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe74(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <my_sqrt@plt>
call   1050 <my_asin@plt>
movaps %xmm0,%xmm1
movsd  0xe67(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12bc <my_asin+0x18c>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe2f(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <my_abs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xdf6(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    12b2 <my_asin+0x182>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdcd(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdac(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
movsd  0xd6d(%rip),%xmm2
addsd  -0x20(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ff <my_asin+0xcf>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_asin>:
sub    $0x28,%rsp
call   1030 <my_abs@plt>
cvtsi2sd %eax,%xmm1
test   %eax,%eax
jle    1170 <my_asin+0x40>
mulsd  %xmm1,%xmm1
movsd  0xebb(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <my_sqrt@plt>
call   1050 <my_asin@plt>
movsd  0xea9(%rip),%xmm1
subsd  %xmm0,%xmm1
jmp    1264 <my_asin+0x134>
xorpd  %xmm0,%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <my_abs@plt>
movsd  (%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe6a(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1260 <my_asin+0x130>
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe4e(%rip),%xmm4
movapd %xmm2,%xmm0
xorpd  %xmm5,%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mulsd  0x8(%rsp),%xmm2
movsd  %xmm2,(%rsp)
movsd  0xe25(%rip),%xmm3
addsd  %xmm3,%xmm5
mulsd  %xmm5,%xmm4
addsd  %xmm3,%xmm5
movsd  %xmm5,0x18(%rsp)
divsd  %xmm5,%xmm4
movsd  %xmm4,0x20(%rsp)
mulsd  %xmm2,%xmm4
movapd %xmm5,%xmm1
addsd  %xmm3,%xmm1
divsd  %xmm1,%xmm4
addsd  %xmm0,%xmm4
movsd  %xmm4,0x10(%rsp)
subsd  %xmm4,%xmm0
call   1030 <my_abs@plt>
movsd  0x18(%rsp),%xmm5
movsd  0x20(%rsp),%xmm4
movsd  (%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x10(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  0xdb4(%rip),%xmm1
ucomisd %xmm1,%xmm0
movapd %xmm3,%xmm1
movapd %xmm3,%xmm0
ja     11d0 <my_asin+0xa0>
jmp    1264 <my_asin+0x134>
movapd %xmm2,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @my_asin(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %3
%10 = load double, double* %3
%11 = call i32 @my_abs(double %10)
%12 = sitofp i32 %11 to double
store double %12, double* %3
%13 = load double, double* %3
%14 = fcmp oge double %13, 0x3FE921FB54442D18
br i1 %14, label %15, label %24
15: ; preds = %1
%16 = load double, double* %3
%17 = load double, double* %3
%18 = fneg double %16
%19 = call double @llvm.fmuladd.f64(double %18, double %17, double 1.000000e+00)
%20 = fptosi double %19 to i32
%21 = call double @my_sqrt(i32 %20)
%22 = call double @my_asin(double %21)
%23 = fsub double 0x3FF921FB54442D18, %22
store double %23, double* %2
br label %64
24: ; preds = %1
%25 = load double, double* %3
store double %25, double* %4
store double 0.000000e+00, double* %5
store double 1.000000e+00, double* %6
%26 = load double, double* %3
store double %26, double* %7
store double 0.000000e+00, double* %8
%27 = load double, double* %3
%28 = load double, double* %3
%29 = fmul double %27, %28
store double %29, double* %9
br label %30
30: ; preds = %39, %24
%31 = load double, double* %8
%32 = load double, double* %4
%33 = fsub double %31, %32
%34 = call i32 @my_abs(double %33)
%35 = sitofp i32 %34 to double
%36 = load double, double* %4
%37 = fmul double 1.000000e-15, %36
%38 = fcmp ogt double %35, %37
br i1 %38, label %39, label %62
39: ; preds = %30
%40 = load double, double* %4
store double %40, double* %8
%41 = load double, double* %5
%42 = fadd double %41, 1.000000e+00
store double %42, double* %5
%43 = load double, double* %6
%44 = load double, double* %5
%45 = fmul double %43, %44
store double %45, double* %6
%46 = load double, double* %5
%47 = fadd double %46, 1.000000e+00
store double %47, double* %5
%48 = load double, double* %6
%49 = load double, double* %5
%50 = fdiv double %48, %49
store double %50, double* %6
%51 = load double, double* %7
%52 = load double, double* %9
%53 = fmul double %51, %52
store double %53, double* %7
%54 = load double, double* %4
%55 = load double, double* %6
%56 = load double, double* %7
%57 = fmul double %55, %56
%58 = load double, double* %5
%59 = fadd double %58, 1.000000e+00
%60 = fdiv double %57, %59
%61 = fadd double %54, %60
store double %61, double* %4
br label %30
62: ; preds = %30
%63 = load double, double* %4
store double %63, double* %2
br label %64
64: ; preds = %62, %15
%65 = load double, double* %2
ret double %65
}

LLVM IR (-O2):
define double @my_asin(double %0) {
%2 = tail call i32 @my_abs(double %0)
%3 = sitofp i32 %2 to double
%4 = icmp sgt i32 %2, 0
br i1 %4, label %7, label %14
5: ; preds = %21, %14, %7
%6 = phi double [ %13, %7 ], [ %3, %14 ], [ %34, %21 ]
ret double %6
7: ; preds = %1
%8 = fneg double %3
%9 = tail call double @llvm.fmuladd.f64(double %8, double %3, double 1.000000e+00)
%10 = fptosi double %9 to i32
%11 = tail call double @my_sqrt(i32 %10)
%12 = tail call double @my_asin(double %11)
%13 = fsub double 0x3FF921FB54442D18, %12
br label %5
14: ; preds = %1
%15 = fmul double %3, %3
%16 = fsub double 0.000000e+00, %3
%17 = tail call i32 @my_abs(double %16)
%18 = sitofp i32 %17 to double
%19 = fmul double %3, 1.000000e-15
%20 = fcmp olt double %19, %18
br i1 %20, label %21, label %5
21: ; preds = %14, %21
%22 = phi double [ %30, %21 ], [ %3, %14 ]
%23 = phi double [ %29, %21 ], [ 1.000000e+00, %14 ]
%24 = phi double [ %28, %21 ], [ 0.000000e+00, %14 ]
%25 = phi double [ %34, %21 ], [ %3, %14 ]
%26 = fadd double %24, 1.000000e+00
%27 = fmul double %23, %26
%28 = fadd double %26, 1.000000e+00
%29 = fdiv double %27, %28
%30 = fmul double %15, %22
%31 = fmul double %29, %30
%32 = fadd double %28, 1.000000e+00
%33 = fdiv double %31, %32
%34 = fadd double %25, %33
%35 = fsub double %25, %34
%36 = tail call i32 @my_abs(double %35)
%37 = sitofp i32 %36 to double
%38 = fmul double %34, 1.000000e-15
%39 = fcmp olt double %38, %37
br i1 %39, label %21, label %5
}