#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 */
double asin_core(float);
float simple_fabs(float const);
float simple_sqrt(double);
float simple_acos(const float x) {
  float xa, t;
  xa = simple_fabs(x);
  if (xa > 0.5625) {
    t = 2.0 * asin_core(simple_sqrt(0.5 * (1.0 - xa)));
  } else {
    t = 1.5707963267948966 - asin_core(xa);
  }
  return (x < 0.0) ? (3.1415926535897932 - t) : t;
}


x86 assembly (clang, -O0):
<simple_acos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <simple_fabs@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11af <simple_acos+0x7f>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea8(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe94(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <simple_sqrt@plt>
call   1040 <asin_core@plt>
movaps %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11d1 <simple_acos+0xa1>
movss  -0x8(%rbp),%xmm0
call   1040 <asin_core@plt>
movaps %xmm0,%xmm1
movsd  0xe44(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1206 <simple_acos+0xd6>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe30(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1214 <simple_acos+0xe4>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_acos>:
sub    $0x18,%rsp
movaps %xmm0,(%rsp)
call   1030 <simple_fabs@plt>
ucomiss 0xebc(%rip),%xmm0
jbe    116e <simple_acos+0x3e>
cvtss2sd %xmm0,%xmm1
movsd  0xebe(%rip),%xmm0
subsd  %xmm1,%xmm0
mulsd  0xeba(%rip),%xmm0
call   1050 <simple_sqrt@plt>
call   1040 <asin_core@plt>
addsd  %xmm0,%xmm0
jmp    1182 <simple_acos+0x52>
call   1040 <asin_core@plt>
movaps %xmm0,%xmm1
movsd  0xe8a(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
movsd  0xe8b(%rip),%xmm2
subsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
xorps  %xmm2,%xmm2
movaps (%rsp),%xmm0
cmpltss %xmm2,%xmm0
andps  %xmm0,%xmm1
andnps %xmm3,%xmm0
orps   %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @simple_acos(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
store float %0, float* %2
%5 = load float, float* %2
%6 = call float @simple_fabs(float %5)
store float %6, float* %3
%7 = load float, float* %3
%8 = fpext float %7 to double
%9 = fcmp ogt double %8, 5.625000e-01
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = load float, float* %3
%12 = fpext float %11 to double
%13 = fsub double 1.000000e+00, %12
%14 = fmul double 5.000000e-01, %13
%15 = call float @simple_sqrt(double %14)
%16 = call double @asin_core(float %15)
%17 = fmul double 2.000000e+00, %16
%18 = fptrunc double %17 to float
store float %18, float* %4
br label %24
19: ; preds = %1
%20 = load float, float* %3
%21 = call double @asin_core(float %20)
%22 = fsub double 0x3FF921FB54442D18, %21
%23 = fptrunc double %22 to float
store float %23, float* %4
br label %24
24: ; preds = %19, %10
%25 = load float, float* %2
%26 = fpext float %25 to double
%27 = fcmp olt double %26, 0.000000e+00
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load float, float* %4
%30 = fpext float %29 to double
%31 = fsub double 0x400921FB54442D18, %30
br label %35
32: ; preds = %24
%33 = load float, float* %4
%34 = fpext float %33 to double
br label %35
35: ; preds = %32, %28
%36 = phi double [ %31, %28 ], [ %34, %32 ]
%37 = fptrunc double %36 to float
ret float %37
}

LLVM IR (-O2):
define float @simple_acos(float %0) {
%2 = tail call float @simple_fabs(float %0)
%3 = fcmp ogt float %2, 5.625000e-01
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = fpext float %2 to double
%6 = fsub double 1.000000e+00, %5
%7 = fmul double %6, 5.000000e-01
%8 = tail call float @simple_sqrt(double %7)
%9 = tail call double @asin_core(float %8)
%10 = fmul double %9, 2.000000e+00
br label %14
11: ; preds = %1
%12 = tail call double @asin_core(float %2)
%13 = fsub double 0x3FF921FB54442D18, %12
br label %14
14: ; preds = %11, %4
%15 = phi double [ %10, %4 ], [ %13, %11 ]
%16 = fptrunc double %15 to float
%17 = fcmp olt float %0, 0.000000e+00
%18 = fpext float %16 to double
%19 = fsub double 0x400921FB54442D18, %18
%20 = fptrunc double %19 to float
%21 = select i1 %17, float %20, float %16
ret float %21
}