#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 */
long double FLT_EPSILON;
int /*<<< orphan*/ M_PI;
long double M_PI_2;
float NAN;
long double cosf(long double);
long double fmodf(long double, int /*<<< orphan*/);
scalar_t__ isnan(float);
long double sinf(long double);
float asinf(float x) {
  long double y;
  long double y_sin;
  long double y_cos;
  y = 0;
  if (isnan(x) || x < -1.0 || x > 1.0) {
    return NAN;
  }
  while (1) {
    y_sin = sinf(y);
    y_cos = cosf(y);
    if (y > M_PI_2 || y < -M_PI_2) {
      y = fmodf(y, M_PI);
    }
    if (y_sin + FLT_EPSILON >= x && y_sin - FLT_EPSILON <= x) {
      break;
    }
    y = y - (y_sin - x) / y_cos;
  }
  return y;
}


x86 assembly (clang, -O0):
<asinf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movss  %xmm0,-0x8(%rbp)
fldz
fstpt  -0x20(%rbp)
movss  -0x8(%rbp),%xmm0
call   1060 <isnan@plt>
cmp    $0x0,%rax
jne    119c <asinf+0x5c>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     119c <asinf+0x5c>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe76(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b1 <asinf+0x71>
mov    0x2e55(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    129a <asinf+0x15a>
jmp    11b6 <asinf+0x76>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <sinf@plt>
fstpt  -0x30(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <cosf@plt>
fstpt  -0x40(%rbp)
fldt   -0x20(%rbp)
mov    0x2df8(%rip),%rax
fldt   (%rax)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
ja     1210 <asinf+0xd0>
jmp    11f3 <asinf+0xb3>
fldt   -0x20(%rbp)
mov    0x2ddb(%rip),%rax
fldt   (%rax)
fchs
fucomip %st(1),%st
fstp   %st(0)
jbe    1229 <asinf+0xe9>
jmp    1210 <asinf+0xd0>
fldt   -0x20(%rbp)
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <fmodf@plt>
fstpt  -0x20(%rbp)
fldt   -0x30(%rbp)
mov    0x2d95(%rip),%rax
fldt   (%rax)
faddp  %st,%st(1)
flds   -0x8(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     1270 <asinf+0x130>
jmp    124b <asinf+0x10b>
fldt   -0x30(%rbp)
mov    0x2d73(%rip),%rax
fldt   (%rax)
fsubrp %st,%st(1)
flds   -0x8(%rbp)
fucomip %st(1),%st
fstp   %st(0)
jb     1270 <asinf+0x130>
jmp    126b <asinf+0x12b>
jmp    128a <asinf+0x14a>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
flds   -0x8(%rbp)
fsubrp %st,%st(1)
fldt   -0x40(%rbp)
fdivrp %st,%st(1)
fsubrp %st,%st(1)
fstpt  -0x20(%rbp)
jmp    11b6 <asinf+0x76>
fldt   -0x20(%rbp)
fstps  -0x44(%rbp)
movss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asinf>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movss  %xmm0,0x14(%rsp)
call   1060 <isnan@plt>
movss  0x14(%rsp),%xmm1
ucomiss 0xe9f(%rip),%xmm1
ja     124f <asinf+0x10f>
movss  0xe95(%rip),%xmm0
ucomiss %xmm1,%xmm0
ja     124f <asinf+0x10f>
test   %rax,%rax
jne    124f <asinf+0x10f>
movss  %xmm1,0x24(%rsp)
fldz
flds   0x24(%rsp)
fstpt  0x28(%rsp)
mov    0x2e40(%rip),%r15
mov    0x2e41(%rip),%r14
mov    0x2e22(%rip),%rbx
jmp    11b8 <asinf+0x78>
nopl   0x0(%rax,%rax,1)
fstp   %st(0)
fsubp  %st,%st(1)
fdivp  %st,%st(1)
fsubrp %st,%st(1)
fld    %st(0)
fstpt  0x14(%rsp)
fstpt  (%rsp)
call   1030 <sinf@plt>
fstpt  0x34(%rsp)
fldt   0x14(%rsp)
fstpt  (%rsp)
call   1040 <cosf@plt>
fldt   0x14(%rsp)
fldt   (%r15)
fxch   %st(1)
fucomi %st(1),%st
fxch   %st(1)
fchs
ja     1200 <asinf+0xc0>
fucomip %st(1),%st
fldz
ja     1200 <asinf+0xc0>
fstp   %st(0)
fxch   %st(1)
jmp    1215 <asinf+0xd5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
fstp   %st(0)
mov    (%r14),%edi
fstpt  (%rsp)
fstpt  0x14(%rsp)
call   1050 <fmodf@plt>
fldt   0x14(%rsp)
fldt   (%rbx)
fldt   0x34(%rsp)
fld    %st(0)
fadd   %st(2),%st
fldt   0x28(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fxch   %st(2)
fsubr  %st(1),%st
jb     11b0 <asinf+0x70>
fxch   %st(2)
fucomi %st(2),%st
fstp   %st(2)
fldz
jb     11b0 <asinf+0x70>
fstp   %st(0)
fstp   %st(1)
fstp   %st(0)
fstp   %st(0)
fstps  0x20(%rsp)
movss  0x20(%rsp),%xmm0
jmp    125a <asinf+0x11a>
mov    0x2da2(%rip),%rax
movss  (%rax),%xmm0
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@NAN = global float 0.000000e+00
@M_PI_2 = global x86_fp80 0xK00000000000000000000
@M_PI = global i32 0
@FLT_EPSILON = global x86_fp80 0xK00000000000000000000
define float @asinf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca x86_fp80
store float %0, float* %3
store x86_fp80 0xK00000000000000000000, x86_fp80* %4
%7 = load float, float* %3
%8 = call i64 @isnan(float %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %1
%11 = load float, float* %3
%12 = fpext float %11 to double
%13 = fcmp olt double %12, -1.000000e+00
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fcmp ogt double %16, 1.000000e+00
br i1 %17, label %18, label %20
18: ; preds = %14, %10, %1
%19 = load float, float* @NAN
store float %19, float* %2
br label %65
20: ; preds = %14
br label %21
21: ; preds = %20, %53
%22 = load x86_fp80, x86_fp80* %4
%23 = call x86_fp80 @sinf(x86_fp80 %22)
store x86_fp80 %23, x86_fp80* %5
%24 = load x86_fp80, x86_fp80* %4
%25 = call x86_fp80 @cosf(x86_fp80 %24)
store x86_fp80 %25, x86_fp80* %6
%26 = load x86_fp80, x86_fp80* %4
%27 = load x86_fp80, x86_fp80* @M_PI_2
%28 = fcmp ogt x86_fp80 %26, %27
br i1 %28, label %34, label %29
29: ; preds = %21
%30 = load x86_fp80, x86_fp80* %4
%31 = load x86_fp80, x86_fp80* @M_PI_2
%32 = fneg x86_fp80 %31
%33 = fcmp olt x86_fp80 %30, %32
br i1 %33, label %34, label %38
34: ; preds = %29, %21
%35 = load x86_fp80, x86_fp80* %4
%36 = load i32, i32* @M_PI
%37 = call x86_fp80 @fmodf(x86_fp80 %35, i32 %36)
store x86_fp80 %37, x86_fp80* %4
br label %38
38: ; preds = %34, %29
%39 = load x86_fp80, x86_fp80* %5
%40 = load x86_fp80, x86_fp80* @FLT_EPSILON
%41 = fadd x86_fp80 %39, %40
%42 = load float, float* %3
%43 = fpext float %42 to x86_fp80
%44 = fcmp oge x86_fp80 %41, %43
br i1 %44, label %45, label %53
45: ; preds = %38
%46 = load x86_fp80, x86_fp80* %5
%47 = load x86_fp80, x86_fp80* @FLT_EPSILON
%48 = fsub x86_fp80 %46, %47
%49 = load float, float* %3
%50 = fpext float %49 to x86_fp80
%51 = fcmp ole x86_fp80 %48, %50
br i1 %51, label %52, label %53
52: ; preds = %45
br label %62
53: ; preds = %45, %38
%54 = load x86_fp80, x86_fp80* %4
%55 = load x86_fp80, x86_fp80* %5
%56 = load float, float* %3
%57 = fpext float %56 to x86_fp80
%58 = fsub x86_fp80 %55, %57
%59 = load x86_fp80, x86_fp80* %6
%60 = fdiv x86_fp80 %58, %59
%61 = fsub x86_fp80 %54, %60
store x86_fp80 %61, x86_fp80* %4
br label %21
62: ; preds = %52
%63 = load x86_fp80, x86_fp80* %4
%64 = fptrunc x86_fp80 %63 to float
store float %64, float* %2
br label %65
65: ; preds = %62, %18
%66 = load float, float* %2
ret float %66
}

LLVM IR (-O2):
@NAN = global float 0.000000e+00
@M_PI_2 = global x86_fp80 0xK00000000000000000000
@M_PI = global i32 0
@FLT_EPSILON = global x86_fp80 0xK00000000000000000000
define float @asinf(float %0) {
%2 = tail call i64 @isnan(float %0)
%3 = icmp ne i64 %2, 0
%4 = fcmp olt float %0, -1.000000e+00
%5 = or i1 %4, %3
%6 = fcmp ogt float %0, 1.000000e+00
%7 = or i1 %6, %5
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = fpext float %0 to x86_fp80
br label %12
10: ; preds = %1
%11 = load float, float* @NAN
br label %38
12: ; preds = %8, %32
%13 = phi x86_fp80 [ %35, %32 ], [ 0xK00000000000000000000, %8 ]
%14 = tail call x86_fp80 @sinf(x86_fp80 %13)
%15 = tail call x86_fp80 @cosf(x86_fp80 %13)
%16 = load x86_fp80, x86_fp80* @M_PI_2
%17 = fcmp ogt x86_fp80 %13, %16
%18 = fneg x86_fp80 %16
%19 = fcmp olt x86_fp80 %13, %18
%20 = or i1 %17, %19
br i1 %20, label %21, label %24
21: ; preds = %12
%22 = load i32, i32* @M_PI
%23 = tail call x86_fp80 @fmodf(x86_fp80 %13, i32 %22)
br label %24
24: ; preds = %12, %21
%25 = phi x86_fp80 [ %23, %21 ], [ %13, %12 ]
%26 = load x86_fp80, x86_fp80* @FLT_EPSILON
%27 = fadd x86_fp80 %14, %26
%28 = fcmp ult x86_fp80 %27, %9
%29 = fsub x86_fp80 %14, %26
%30 = fcmp ugt x86_fp80 %29, %9
%31 = or i1 %28, %30
br i1 %31, label %32, label %36
32: ; preds = %24
%33 = fsub x86_fp80 %14, %9
%34 = fdiv x86_fp80 %33, %15
%35 = fsub x86_fp80 %25, %34
br label %12
36: ; preds = %24
%37 = fptrunc x86_fp80 %25 to float
br label %38
38: ; preds = %36, %10
%39 = phi float [ %11, %10 ], [ %37, %36 ]
ret float %39
}