#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 acos(double);
double acos2(double num, double denom, double disambiguator) {
  double val;
  double cosine = num / denom;
  if (cosine > -1. && cosine < 1.) {
    val = acos(cosine);
    if (disambiguator < 0.) {
      val = -val;
    }
  } else {
    val = (cosine <= -1.) ? 3.14159265358979323846 : 0.;
  }
  return val;
}


x86 assembly (clang, -O0):
<acos2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xebd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a3 <acos2+0x93>
movsd  0xeb3(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11a3 <acos2+0x93>
movsd  -0x28(%rbp),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    119e <acos2+0x8e>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11d4 <acos2+0xc4>
movsd  -0x28(%rbp),%xmm0
movsd  0xe60(%rip),%xmm3
xorps  %xmm2,%xmm2
movsd  0xe45(%rip),%xmm1
cmplesd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<acos2>:
push   %rax
movapd %xmm0,%xmm3
divsd  %xmm1,%xmm3
ucomisd 0xedf(%rip),%xmm3
jbe    1154 <acos2+0x44>
movsd  0xedd(%rip),%xmm0
ucomisd %xmm3,%xmm0
jbe    1154 <acos2+0x44>
movapd %xmm3,%xmm0
movsd  %xmm2,(%rsp)
call   1030 <acos@plt>
xorpd  %xmm1,%xmm1
ucomisd (%rsp),%xmm1
jbe    1169 <acos2+0x59>
xorpd  0xece(%rip),%xmm0
pop    %rax
ret
cmplesd 0xea3(%rip),%xmm3
movsd  0xeab(%rip),%xmm0
andpd  %xmm3,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @acos2(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %4
%10 = load double, double* %5
%11 = fdiv double %9, %10
store double %11, double* %8
%12 = load double, double* %8
%13 = fcmp ogt double %12, -1.000000e+00
br i1 %13, label %14, label %26
14: ; preds = %3
%15 = load double, double* %8
%16 = fcmp olt double %15, 1.000000e+00
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load double, double* %8
%19 = call double @acos(double %18)
store double %19, double* %7
%20 = load double, double* %6
%21 = fcmp olt double %20, 0.000000e+00
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load double, double* %7
%24 = fneg double %23
store double %24, double* %7
br label %25
25: ; preds = %22, %17
br label %31
26: ; preds = %14, %3
%27 = load double, double* %8
%28 = fcmp ole double %27, -1.000000e+00
%29 = zext i1 %28 to i64
%30 = select i1 %28, double 0x400921FB54442D18, double 0.000000e+00
store double %30, double* %7
br label %31
31: ; preds = %26, %25
%32 = load double, double* %7
ret double %32
}

LLVM IR (-O2):
define double @acos2(double %0, double %1, double %2) {
%4 = fdiv double %0, %1
%5 = fcmp ogt double %4, -1.000000e+00
%6 = fcmp olt double %4, 1.000000e+00
%7 = and i1 %5, %6
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = tail call double @acos(double %4)
%10 = fcmp olt double %2, 0.000000e+00
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = fneg double %9
br label %16
13: ; preds = %3
%14 = fcmp ole double %4, -1.000000e+00
%15 = select i1 %14, double 0x400921FB54442D18, double 0.000000e+00
br label %16
16: ; preds = %8, %11, %13
%17 = phi double [ %12, %11 ], [ %9, %8 ], [ %15, %13 ]
ret double %17
}