#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 dot_product(double *, double *);
double fabs(double);
double sign(double, double);
void calc_bnd_ang(double r1[3], double r2[3], double *angle) {
  double arg;
  arg = dot_product(r1, r2);
  arg = sign(((fabs(arg)) < (1.0e0)) ? (fabs(arg)) : (1.0e0), arg);
  *angle = acos(arg);
  return;
}


x86 assembly (clang, -O0):
<calc_bnd_ang>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <dot_product@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movaps 0xeae(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe92(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1192 <calc_bnd_ang+0x62>
movsd  -0x20(%rbp),%xmm0
movaps 0xe8c(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11a4 <calc_bnd_ang+0x74>
movsd  0xe66(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11a4 <calc_bnd_ang+0x74>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1050 <sign@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <acos@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_bnd_ang>:
push   %rbx
mov    %rdx,%rbx
call   1040 <dot_product@plt>
movapd %xmm0,%xmm1
movapd 0xebb(%rip),%xmm0
andpd  %xmm1,%xmm0
minsd  0xebf(%rip),%xmm0
call   1050 <sign@plt>
call   1030 <acos@plt>
movsd  %xmm0,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @calc_bnd_ang(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%8 = load double*, double** %4
%9 = load double*, double** %5
%10 = call double @dot_product(double* %8, double* %9)
store double %10, double* %7
%11 = load double, double* %7
%12 = call double @llvm.fabs.f64(double %11)
%13 = fcmp olt double %12, 1.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load double, double* %7
%16 = call double @llvm.fabs.f64(double %15)
br label %18
17: ; preds = %3
br label %18
18: ; preds = %17, %14
%19 = phi double [ %16, %14 ], [ 1.000000e+00, %17 ]
%20 = load double, double* %7
%21 = call double @sign(double %19, double %20)
store double %21, double* %7
%22 = load double, double* %7
%23 = call double @acos(double %22)
%24 = load double*, double** %6
store double %23, double* %24
ret void
}

LLVM IR (-O2):
define void @calc_bnd_ang(double* %0, double* %1, double* nocapture writeonly %2) {
%4 = tail call double @dot_product(double* %0, double* %1)
%5 = tail call double @llvm.fabs.f64(double %4)
%6 = fcmp olt double %5, 1.000000e+00
%7 = select i1 %6, double %5, double 1.000000e+00
%8 = tail call double @sign(double %7, double %4)
%9 = tail call double @acos(double %8)
store double %9, double* %2
ret void
}