#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;
float NAN;
float __domain_error();
float __signf(float);
float atanf(float);
scalar_t__ isnan(float);
float sqrtf(float);
float acosf(float x) {
  if ((x > 1.f) || (x < -1.f))
    return __domain_error();
  if (isnan(x))
    return NAN;
  return (float)M_PI / 2.f - __signf(x) * atanf(x / (1.f + sqrtf(1.f - x * x)));
}


x86 assembly (clang, -O0):
<acosf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  0xe96(%rip),%xmm1
ucomiss %xmm1,%xmm0
ja     1185 <acosf+0x35>
movss  0xe89(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    1196 <acosf+0x46>
mov    $0x0,%al
call   1040 <__domain_error@plt>
movss  %xmm0,-0x4(%rbp)
jmp    1265 <acosf+0x115>
movss  -0x8(%rbp),%xmm0
call   1060 <isnan@plt>
cmp    $0x0,%rax
je     11bf <acosf+0x6f>
mov    0x2e47(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1265 <acosf+0x115>
mov    0x2e1a(%rip),%rax
cvtsi2ssq (%rax),%xmm0
movss  0xe35(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
call   1070 <__signf@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm1,%xmm0
movss  0xde8(%rip),%xmm1
addss  %xmm1,%xmm0
call   1050 <sqrtf@plt>
movaps %xmm0,%xmm2
movss  -0x14(%rbp),%xmm0
movss  0xdcf(%rip),%xmm1
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
call   1030 <atanf@plt>
movss  -0x10(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acosf>:
sub    $0x18,%rsp
ucomiss 0xea5(%rip),%xmm0
ja     118a <acosf+0x3a>
movss  0xe9f(%rip),%xmm1
ucomiss %xmm0,%xmm1
ja     118a <acosf+0x3a>
movss  %xmm0,0xc(%rsp)
call   1060 <isnan@plt>
test   %rax,%rax
je     1195 <acosf+0x45>
mov    0x2e77(%rip),%rax
movss  (%rax),%xmm0
add    $0x18,%rsp
ret
xor    %eax,%eax
add    $0x18,%rsp
jmp    1040 <__domain_error@plt>
mov    0x2e44(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2ssq (%rax),%xmm0
mulss  0xe5c(%rip),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0xc(%rsp),%xmm0
call   1070 <__signf@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm1
movss  0xe2b(%rip),%xmm0
subss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11e7 <acosf+0x97>
sqrtss %xmm0,%xmm0
jmp    11ec <acosf+0x9c>
call   1050 <sqrtf@plt>
addss  0xe0c(%rip),%xmm0
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1030 <atanf@plt>
movss  0x10(%rsp),%xmm1
mulss  %xmm0,%xmm1
movss  0x14(%rsp),%xmm0
subss  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@NAN = global float 0.000000e+00
@M_PI = global i64 0
define float @acosf(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %3
%4 = load float, float* %3
%5 = fcmp ogt float %4, 1.000000e+00
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load float, float* %3
%8 = fcmp olt float %7, -1.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %6, %1
%10 = call float (...) @__domain_error()
store float %10, float* %2
br label %34
11: ; preds = %6
%12 = load float, float* %3
%13 = call i64 @isnan(float %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load float, float* @NAN
store float %16, float* %2
br label %34
17: ; preds = %11
%18 = load i64, i64* @M_PI
%19 = sitofp i64 %18 to float
%20 = fdiv float %19, 2.000000e+00
%21 = load float, float* %3
%22 = call float @__signf(float %21)
%23 = load float, float* %3
%24 = load float, float* %3
%25 = load float, float* %3
%26 = fneg float %24
%27 = call float @llvm.fmuladd.f32(float %26, float %25, float 1.000000e+00)
%28 = call float @sqrtf(float %27)
%29 = fadd float 1.000000e+00, %28
%30 = fdiv float %23, %29
%31 = call float @atanf(float %30)
%32 = fneg float %22
%33 = call float @llvm.fmuladd.f32(float %32, float %31, float %20)
store float %33, float* %2
br label %34
34: ; preds = %17, %15, %9
%35 = load float, float* %2
ret float %35
}

LLVM IR (-O2):
@NAN = global float 0.000000e+00
@M_PI = global i64 0
define float @acosf(float %0) {
%2 = fcmp ogt float %0, 1.000000e+00
%3 = fcmp olt float %0, -1.000000e+00
%4 = or i1 %2, %3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call float (...) @__domain_error()
br label %25
7: ; preds = %1
%8 = tail call i64 @isnan(float %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = load float, float* @NAN
br label %25
12: ; preds = %7
%13 = load i64, i64* @M_PI
%14 = sitofp i64 %13 to float
%15 = fmul float %14, 5.000000e-01
%16 = tail call float @__signf(float %0)
%17 = fneg float %0
%18 = tail call float @llvm.fmuladd.f32(float %17, float %0, float 1.000000e+00)
%19 = tail call float @sqrtf(float %18)
%20 = fadd float %19, 1.000000e+00
%21 = fdiv float %0, %20
%22 = tail call float @atanf(float %21)
%23 = fneg float %16
%24 = tail call float @llvm.fmuladd.f32(float %23, float %22, float %15)
br label %25
25: ; preds = %12, %10, %5
%26 = phi float [ %6, %5 ], [ %11, %10 ], [ %24, %12 ]
ret float %26
}