#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 */
scalar_t__ M_PI;
long double NAN;
long double __domain_error();
long double __signl(long double);
long double atanl(long double);
scalar_t__ isnan(long double);
long sqrtl(long);
long double acosl(long double x) {
  if ((x > 1.l) || (x < -1.l))
    return __domain_error();
  if (isnan(x))
    return NAN;
  return (long double)M_PI / 2.l -
         __signl(x) * atanl(x / (1.l + sqrtl(1.l - x * x)));
}


x86 assembly (clang, -O0):
<acosl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
ja     118d <acosl+0x3d>
jmp    1177 <acosl+0x27>
fldt   -0x20(%rbp)
fld1
fchs
fucomip %st(1),%st
fstp   %st(0)
jbe    119c <acosl+0x4c>
jmp    118d <acosl+0x3d>
xor    %eax,%eax
call   1040 <__domain_error@plt>
fstpt  -0x10(%rbp)
jmp    124f <acosl+0xff>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <isnan@plt>
cmp    $0x0,%rax
je     11c4 <acosl+0x74>
mov    0x2e3e(%rip),%rax
fldt   (%rax)
fstpt  -0x10(%rbp)
jmp    124f <acosl+0xff>
mov    0x2e15(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
fildll -0x38(%rbp)
flds   0xe25(%rip)
fdivrp %st,%st(1)
fstpt  -0x48(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1070 <__signl@plt>
fstpt  -0x54(%rbp)
fldt   -0x20(%rbp)
fld    %st(0)
fstpt  -0x60(%rbp)
fmul   %st,%st(0)
fld1
fld    %st(0)
fstpt  -0x6c(%rbp)
fsubp  %st,%st(1)
fnstcw -0x3a(%rbp)
movzwl -0x3a(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x3c(%rbp)
fldcw  -0x3c(%rbp)
fistpll -0x30(%rbp)
fldcw  -0x3a(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <sqrtl@plt>
fldt   -0x6c(%rbp)
fldt   -0x60(%rbp)
mov    %rax,-0x28(%rbp)
fildll -0x28(%rbp)
faddp  %st,%st(2)
fdivp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <atanl@plt>
fldt   -0x54(%rbp)
fldt   -0x48(%rbp)
fxch   %st(1)
fmulp  %st,%st(2)
fsubp  %st,%st(1)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acosl>:
sub    $0x68,%rsp
fldt   0x70(%rsp)
fld1
fxch   %st(1)
fucomi %st(1),%st
ja     118f <acosl+0x3f>
fxch   %st(1)
fchs
fucomip %st(1),%st
fldz
fxch   %st(1)
ja     118f <acosl+0x3f>
fstp   %st(1)
fld    %st(0)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
call   1060 <isnan@plt>
test   %rax,%rax
je     119e <acosl+0x4e>
mov    0x2e70(%rip),%rax
fldt   (%rax)
add    $0x68,%rsp
ret
fstp   %st(1)
fstp   %st(0)
xor    %eax,%eax
add    $0x68,%rsp
jmp    1040 <__domain_error@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x28(%rsp)
fildll 0x28(%rsp)
fmuls  0xe49(%rip)
fstpt  0x5c(%rsp)
fldt   0x1c(%rsp)
fstpt  (%rsp)
call   1070 <__signl@plt>
fldt   0x1c(%rsp)
fmul   %st,%st(0)
fld1
fld    %st(0)
fstpt  0x50(%rsp)
fsubp  %st,%st(1)
fnstcw 0x18(%rsp)
movzwl 0x18(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x1a(%rsp)
fldcw  0x1a(%rsp)
fistpll 0x30(%rsp)
fldcw  0x18(%rsp)
fstpt  0x44(%rsp)
mov    0x30(%rsp),%rdi
call   1050 <sqrtl@plt>
mov    %rax,0x38(%rsp)
fildll 0x38(%rsp)
fldt   0x50(%rsp)
faddp  %st,%st(1)
fldt   0x1c(%rsp)
fdivp  %st,%st(1)
fstpt  (%rsp)
call   1030 <atanl@plt>
fldt   0x44(%rsp)
fmulp  %st,%st(1)
fldt   0x5c(%rsp)
fsubp  %st,%st(1)
add    $0x68,%rsp
ret

LLVM IR (-O0):
@NAN = global x86_fp80 0xK00000000000000000000
@M_PI = global i64 0
define x86_fp80 @acosl(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %3
%4 = load x86_fp80, x86_fp80* %3
%5 = fcmp ogt x86_fp80 %4, 0xK3FFF8000000000000000
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load x86_fp80, x86_fp80* %3
%8 = fcmp olt x86_fp80 %7, 0xKBFFF8000000000000000
br i1 %8, label %9, label %11
9: ; preds = %6, %1
%10 = call x86_fp80 (...) @__domain_error()
store x86_fp80 %10, x86_fp80* %2
br label %36
11: ; preds = %6
%12 = load x86_fp80, x86_fp80* %3
%13 = call i64 @isnan(x86_fp80 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load x86_fp80, x86_fp80* @NAN
store x86_fp80 %16, x86_fp80* %2
br label %36
17: ; preds = %11
%18 = load i64, i64* @M_PI
%19 = sitofp i64 %18 to x86_fp80
%20 = fdiv x86_fp80 %19, 0xK40008000000000000000
%21 = load x86_fp80, x86_fp80* %3
%22 = call x86_fp80 @__signl(x86_fp80 %21)
%23 = load x86_fp80, x86_fp80* %3
%24 = load x86_fp80, x86_fp80* %3
%25 = load x86_fp80, x86_fp80* %3
%26 = fneg x86_fp80 %24
%27 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %26, x86_fp80 %25, x86_fp80 0xK3FFF8000000000000000)
%28 = fptosi x86_fp80 %27 to i64
%29 = call i64 @sqrtl(i64 %28)
%30 = sitofp i64 %29 to x86_fp80
%31 = fadd x86_fp80 0xK3FFF8000000000000000, %30
%32 = fdiv x86_fp80 %23, %31
%33 = call x86_fp80 @atanl(x86_fp80 %32)
%34 = fneg x86_fp80 %22
%35 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %34, x86_fp80 %33, x86_fp80 %20)
store x86_fp80 %35, x86_fp80* %2
br label %36
36: ; preds = %17, %15, %9
%37 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %37
}

LLVM IR (-O2):
@NAN = global x86_fp80 0xK00000000000000000000
@M_PI = global i64 0
define x86_fp80 @acosl(x86_fp80 %0) {
%2 = fcmp ogt x86_fp80 %0, 0xK3FFF8000000000000000
%3 = fcmp olt x86_fp80 %0, 0xKBFFF8000000000000000
%4 = or i1 %2, %3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call x86_fp80 (...) @__domain_error()
br label %27
7: ; preds = %1
%8 = tail call i64 @isnan(x86_fp80 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = load x86_fp80, x86_fp80* @NAN
br label %27
12: ; preds = %7
%13 = load i64, i64* @M_PI
%14 = sitofp i64 %13 to x86_fp80
%15 = fmul x86_fp80 %14, 0xK3FFE8000000000000000
%16 = tail call x86_fp80 @__signl(x86_fp80 %0)
%17 = fneg x86_fp80 %0
%18 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %17, x86_fp80 %0, x86_fp80 0xK3FFF8000000000000000)
%19 = fptosi x86_fp80 %18 to i64
%20 = tail call i64 @sqrtl(i64 %19)
%21 = sitofp i64 %20 to x86_fp80
%22 = fadd x86_fp80 %21, 0xK3FFF8000000000000000
%23 = fdiv x86_fp80 %0, %22
%24 = tail call x86_fp80 @atanl(x86_fp80 %23)
%25 = fneg x86_fp80 %16
%26 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %25, x86_fp80 %24, x86_fp80 %15)
br label %27
27: ; preds = %12, %10, %5
%28 = phi x86_fp80 [ %6, %5 ], [ %11, %10 ], [ %26, %12 ]
ret x86_fp80 %28
}