#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 my_asin(double);
double my_sqrt(int);
double square(double);
double asinOpt(double x) {
  double result;
  double squareX = square(x);
  if (x >= -1.0 && x <= -0.5) {
    result = -3.14159265358979323846 / 2 + my_asin(my_sqrt(1 - squareX));
  } else if (x >= 0.5 && x <= 1.0)
    result = 3.14159265358979323846 / 2 - my_asin(my_sqrt(1 - squareX));
  else {
    result = my_asin(x);
  }
  return result;
}


x86 assembly (clang, -O0):
<asinOpt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <square@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11aa <asinOpt+0x7a>
movsd  0xe9d(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     11aa <asinOpt+0x7a>
movsd  0xe9a(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <my_sqrt@plt>
call   1050 <my_asin@plt>
movaps %xmm0,%xmm1
movsd  0xe8c(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    121c <asinOpt+0xec>
movsd  -0x8(%rbp),%xmm0
movsd  0xe59(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1208 <asinOpt+0xd8>
movsd  0xe4f(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     1208 <asinOpt+0xd8>
movsd  0xe3c(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <my_sqrt@plt>
call   1050 <my_asin@plt>
movaps %xmm0,%xmm1
movsd  0xe26(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1217 <asinOpt+0xe7>
movsd  -0x8(%rbp),%xmm0
call   1050 <my_asin@plt>
movsd  %xmm0,-0x10(%rbp)
jmp    121c <asinOpt+0xec>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asinOpt>:
push   %rax
movsd  %xmm0,(%rsp)
call   1030 <square@plt>
movsd  (%rsp),%xmm2
ucomisd 0xeb8(%rip),%xmm2
jb     117c <asinOpt+0x4c>
movsd  0xeb6(%rip),%xmm1
ucomisd %xmm2,%xmm1
jb     117c <asinOpt+0x4c>
movsd  0xeb8(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <my_sqrt@plt>
call   1050 <my_asin@plt>
addsd  0xeae(%rip),%xmm0
pop    %rax
ret
ucomisd 0xe8c(%rip),%xmm2
jb     11b8 <asinOpt+0x88>
movsd  0xe8a(%rip),%xmm1
ucomisd %xmm2,%xmm1
jb     11b8 <asinOpt+0x88>
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <my_sqrt@plt>
call   1050 <my_asin@plt>
movapd %xmm0,%xmm1
movsd  0xe6e(%rip),%xmm0
subsd  %xmm1,%xmm0
pop    %rax
ret
movapd %xmm2,%xmm0
pop    %rax
jmp    1050 <my_asin@plt>

LLVM IR (-O0):
define double @asinOpt(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %2
%5 = load double, double* %2
%6 = call double @square(double %5)
store double %6, double* %4
%7 = load double, double* %2
%8 = fcmp oge double %7, -1.000000e+00
br i1 %8, label %9, label %19
9: ; preds = %1
%10 = load double, double* %2
%11 = fcmp ole double %10, -5.000000e-01
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load double, double* %4
%14 = fsub double 1.000000e+00, %13
%15 = fptosi double %14 to i32
%16 = call double @my_sqrt(i32 %15)
%17 = call double @my_asin(double %16)
%18 = fadd double 0xBFF921FB54442D18, %17
store double %18, double* %3
br label %36
19: ; preds = %9, %1
%20 = load double, double* %2
%21 = fcmp oge double %20, 5.000000e-01
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load double, double* %2
%24 = fcmp ole double %23, 1.000000e+00
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load double, double* %4
%27 = fsub double 1.000000e+00, %26
%28 = fptosi double %27 to i32
%29 = call double @my_sqrt(i32 %28)
%30 = call double @my_asin(double %29)
%31 = fsub double 0x3FF921FB54442D18, %30
store double %31, double* %3
br label %35
32: ; preds = %22, %19
%33 = load double, double* %2
%34 = call double @my_asin(double %33)
store double %34, double* %3
br label %35
35: ; preds = %32, %25
br label %36
36: ; preds = %35, %12
%37 = load double, double* %3
ret double %37
}

LLVM IR (-O2):
define double @asinOpt(double %0) {
%2 = tail call double @square(double %0)
%3 = fcmp oge double %0, -1.000000e+00
%4 = fcmp ole double %0, -5.000000e-01
%5 = and i1 %3, %4
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = fsub double 1.000000e+00, %2
%8 = fptosi double %7 to i32
%9 = tail call double @my_sqrt(i32 %8)
%10 = tail call double @my_asin(double %9)
%11 = fadd double %10, 0xBFF921FB54442D18
br label %24
12: ; preds = %1
%13 = fcmp oge double %0, 5.000000e-01
%14 = fcmp ole double %0, 1.000000e+00
%15 = and i1 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = fsub double 1.000000e+00, %2
%18 = fptosi double %17 to i32
%19 = tail call double @my_sqrt(i32 %18)
%20 = tail call double @my_asin(double %19)
%21 = fsub double 0x3FF921FB54442D18, %20
br label %24
22: ; preds = %12
%23 = tail call double @my_asin(double %0)
br label %24
24: ; preds = %16, %22, %6
%25 = phi double [ %11, %6 ], [ %21, %16 ], [ %23, %22 ]
ret double %25
}