#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;
int /*<<< orphan*/ atan2kf(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fabsf(float);
float mulsignf(int /*<<< orphan*/, float);
int /*<<< orphan*/ sqrtf(float);
float xacosf(float d) {
  return mulsignf(atan2kf(sqrtf((1.0f + d) * (1.0f - d)), fabsf(d)), d) +
         (d < 0 ? (float)M_PI : 0.0f);
}


x86 assembly (clang, -O0):
<xacosf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xeab(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  0xe9e(%rip),%xmm1
subss  -0x4(%rbp),%xmm1
mulss  %xmm1,%xmm0
call   1050 <sqrtf@plt>
mov    %eax,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabsf@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%esi
call   1040 <atan2kf@plt>
mov    %eax,%edi
movss  -0x4(%rbp),%xmm0
call   1060 <mulsignf@plt>
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    11bb <xacosf+0x7b>
mov    0x2e3c(%rip),%rax
cvtsi2ssq (%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11c8 <xacosf+0x88>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11c8 <xacosf+0x88>
movss  -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xacosf>:
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,%xmm2
movaps %xmm0,(%rsp)
movss  0xeac(%rip),%xmm0
movaps %xmm2,%xmm1
addss  %xmm0,%xmm1
subss  %xmm2,%xmm0
mulss  %xmm1,%xmm0
call   1050 <sqrtf@plt>
mov    %eax,%ebx
movaps (%rsp),%xmm0
call   1030 <fabsf@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <atan2kf@plt>
mov    %eax,%edi
movaps (%rsp),%xmm0
call   1060 <mulsignf@plt>
mov    0x2e5a(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2ssq (%rax),%xmm1
xorps  %xmm2,%xmm2
movaps (%rsp),%xmm3
cmpltss %xmm2,%xmm3
andps  %xmm1,%xmm3
addss  %xmm3,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i64 0
define float @xacosf(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = fadd float 1.000000e+00, %3
%5 = load float, float* %2
%6 = fsub float 1.000000e+00, %5
%7 = fmul float %4, %6
%8 = call i32 @sqrtf(float %7)
%9 = load float, float* %2
%10 = call i32 @fabsf(float %9)
%11 = call i32 @atan2kf(i32 %8, i32 %10)
%12 = load float, float* %2
%13 = call float @mulsignf(i32 %11, float %12)
%14 = load float, float* %2
%15 = fcmp olt float %14, 0.000000e+00
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i64, i64* @M_PI
%18 = sitofp i64 %17 to float
br label %20
19: ; preds = %1
br label %20
20: ; preds = %19, %16
%21 = phi float [ %18, %16 ], [ 0.000000e+00, %19 ]
%22 = fadd float %13, %21
ret float %22
}

LLVM IR (-O2):
@M_PI = global i64 0
define float @xacosf(float %0) {
%2 = fadd float %0, 1.000000e+00
%3 = fsub float 1.000000e+00, %0
%4 = fmul float %2, %3
%5 = tail call i32 @sqrtf(float %4)
%6 = tail call i32 @fabsf(float %0)
%7 = tail call i32 @atan2kf(i32 %5, i32 %6)
%8 = tail call float @mulsignf(i32 %7, float %0)
%9 = fcmp olt float %0, 0.000000e+00
%10 = load i64, i64* @M_PI
%11 = sitofp i64 %10 to float
%12 = select i1 %9, float %11, float 0.000000e+00
%13 = fadd float %8, %12
ret float %13
}