#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 */
int M_PI;
double NAN;
double __domain_error();
int __sign(double);
int atan(double);
scalar_t__ isnan(double);
int sqrt(int);
double acos(double x) {
  if ((x > 1.) || (x < -1.))
    return __domain_error();
  if (isnan(x))
    return NAN;
  return M_PI / 2. - __sign(x) * atan(x / (1. + sqrt(1. - x * x)));
}


x86 assembly (clang, -O0):
<acos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe96(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1187 <acos+0x37>
movsd  0xe8c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1198 <acos+0x48>
mov    $0x0,%al
call   1040 <__domain_error@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1266 <acos+0x116>
movsd  -0x10(%rbp),%xmm0
call   1060 <isnan@plt>
cmp    $0x0,%rax
je     11c1 <acos+0x71>
mov    0x2e45(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1266 <acos+0x116>
mov    0x2e18(%rip),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xe3c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <__sign@plt>
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xddf(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
movsd  0xdc1(%rip),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1050 <atan@plt>
movsd  -0x20(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acos>:
push   %rbx
sub    $0x10,%rsp
ucomisd 0xea3(%rip),%xmm0
ja     118c <acos+0x3c>
movsd  0xea1(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     118c <acos+0x3c>
movsd  %xmm0,(%rsp)
call   1060 <isnan@plt>
test   %rax,%rax
je     1198 <acos+0x48>
mov    0x2e75(%rip),%rax
movsd  (%rax),%xmm0
jmp    1213 <acos+0xc3>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1040 <__domain_error@plt>
mov    0x2e41(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sdl (%rax),%xmm0
mulsd  0xe62(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <__sign@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
mulsd  %xmm0,%xmm0
movsd  0xe2f(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1070 <sqrt@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  0xe13(%rip),%xmm1
movsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1050 <atan@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

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

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