#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;
long double cosf(long double);
long double fmodf(long double, int /*<<< orphan*/);
long double sinf(long double);
float asinf(float x) {
  long double y;
  long double y_sin;
  long double y_cos;
  y = 0;
  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,-0x4(%rbp)
fldz
fstpt  -0x20(%rbp)
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    0x2e74(%rip),%rax
fldt   (%rax)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
ja     119c <asinf+0x6c>
jmp    117f <asinf+0x4f>
fldt   -0x20(%rbp)
mov    0x2e57(%rip),%rax
fldt   (%rax)
fchs
fucomip %st(1),%st
fstp   %st(0)
jbe    11b5 <asinf+0x85>
jmp    119c <asinf+0x6c>
fldt   -0x20(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <fmodf@plt>
fstpt  -0x20(%rbp)
fldt   -0x30(%rbp)
mov    0x2e11(%rip),%rax
fldt   (%rax)
faddp  %st,%st(1)
flds   -0x4(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     11fc <asinf+0xcc>
jmp    11d7 <asinf+0xa7>
fldt   -0x30(%rbp)
mov    0x2def(%rip),%rax
fldt   (%rax)
fsubrp %st,%st(1)
flds   -0x4(%rbp)
fucomip %st(1),%st
fstp   %st(0)
jb     11fc <asinf+0xcc>
jmp    11f7 <asinf+0xc7>
jmp    1216 <asinf+0xe6>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
flds   -0x4(%rbp)
fsubrp %st,%st(1)
fldt   -0x40(%rbp)
fdivrp %st,%st(1)
fsubrp %st,%st(1)
fstpt  -0x20(%rbp)
jmp    1142 <asinf+0x12>
fldt   -0x20(%rbp)
fstps  -0x44(%rbp)
movss  -0x44(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asinf>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movss  %xmm0,0x24(%rsp)
fldz
flds   0x24(%rsp)
fstpt  0x28(%rsp)
mov    0x2e90(%rip),%r15
mov    0x2e91(%rip),%r14
mov    0x2e72(%rip),%rbx
jmp    1168 <asinf+0x38>
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     11b0 <asinf+0x80>
fucomip %st(1),%st
fldz
ja     11b0 <asinf+0x80>
fstp   %st(0)
fxch   %st(1)
jmp    11c5 <asinf+0x95>
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     1160 <asinf+0x30>
fxch   %st(2)
fucomi %st(2),%st
fstp   %st(2)
fldz
jb     1160 <asinf+0x30>
fstp   %st(0)
fstp   %st(1)
fstp   %st(0)
fstp   %st(0)
fstps  0x20(%rsp)
movss  0x20(%rsp),%xmm0
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@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 x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
store float %0, float* %2
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %6
6: ; preds = %1, %38
%7 = load x86_fp80, x86_fp80* %3
%8 = call x86_fp80 @sinf(x86_fp80 %7)
store x86_fp80 %8, x86_fp80* %4
%9 = load x86_fp80, x86_fp80* %3
%10 = call x86_fp80 @cosf(x86_fp80 %9)
store x86_fp80 %10, x86_fp80* %5
%11 = load x86_fp80, x86_fp80* %3
%12 = load x86_fp80, x86_fp80* @M_PI_2
%13 = fcmp ogt x86_fp80 %11, %12
br i1 %13, label %19, label %14
14: ; preds = %6
%15 = load x86_fp80, x86_fp80* %3
%16 = load x86_fp80, x86_fp80* @M_PI_2
%17 = fneg x86_fp80 %16
%18 = fcmp olt x86_fp80 %15, %17
br i1 %18, label %19, label %23
19: ; preds = %14, %6
%20 = load x86_fp80, x86_fp80* %3
%21 = load i32, i32* @M_PI
%22 = call x86_fp80 @fmodf(x86_fp80 %20, i32 %21)
store x86_fp80 %22, x86_fp80* %3
br label %23
23: ; preds = %19, %14
%24 = load x86_fp80, x86_fp80* %4
%25 = load x86_fp80, x86_fp80* @FLT_EPSILON
%26 = fadd x86_fp80 %24, %25
%27 = load float, float* %2
%28 = fpext float %27 to x86_fp80
%29 = fcmp oge x86_fp80 %26, %28
br i1 %29, label %30, label %38
30: ; preds = %23
%31 = load x86_fp80, x86_fp80* %4
%32 = load x86_fp80, x86_fp80* @FLT_EPSILON
%33 = fsub x86_fp80 %31, %32
%34 = load float, float* %2
%35 = fpext float %34 to x86_fp80
%36 = fcmp ole x86_fp80 %33, %35
br i1 %36, label %37, label %38
37: ; preds = %30
br label %47
38: ; preds = %30, %23
%39 = load x86_fp80, x86_fp80* %3
%40 = load x86_fp80, x86_fp80* %4
%41 = load float, float* %2
%42 = fpext float %41 to x86_fp80
%43 = fsub x86_fp80 %40, %42
%44 = load x86_fp80, x86_fp80* %5
%45 = fdiv x86_fp80 %43, %44
%46 = fsub x86_fp80 %39, %45
store x86_fp80 %46, x86_fp80* %3
br label %6
47: ; preds = %37
%48 = load x86_fp80, x86_fp80* %3
%49 = fptrunc x86_fp80 %48 to float
ret float %49
}

LLVM IR (-O2):
@M_PI_2 = global x86_fp80 0xK00000000000000000000
@M_PI = global i32 0
@FLT_EPSILON = global x86_fp80 0xK00000000000000000000
define float @asinf(float %0) {
%2 = fpext float %0 to x86_fp80
br label %3
3: ; preds = %23, %1
%4 = phi x86_fp80 [ 0xK00000000000000000000, %1 ], [ %26, %23 ]
%5 = tail call x86_fp80 @sinf(x86_fp80 %4)
%6 = tail call x86_fp80 @cosf(x86_fp80 %4)
%7 = load x86_fp80, x86_fp80* @M_PI_2
%8 = fcmp ogt x86_fp80 %4, %7
%9 = fneg x86_fp80 %7
%10 = fcmp olt x86_fp80 %4, %9
%11 = or i1 %8, %10
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* @M_PI
%14 = tail call x86_fp80 @fmodf(x86_fp80 %4, i32 %13)
br label %15
15: ; preds = %3, %12
%16 = phi x86_fp80 [ %14, %12 ], [ %4, %3 ]
%17 = load x86_fp80, x86_fp80* @FLT_EPSILON
%18 = fadd x86_fp80 %5, %17
%19 = fcmp ult x86_fp80 %18, %2
%20 = fsub x86_fp80 %5, %17
%21 = fcmp ugt x86_fp80 %20, %2
%22 = or i1 %19, %21
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = fsub x86_fp80 %5, %2
%25 = fdiv x86_fp80 %24, %6
%26 = fsub x86_fp80 %16, %25
br label %3
27: ; preds = %15
%28 = fptrunc x86_fp80 %16 to float
ret float %28
}