#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 vabs(double *);
double vdot(double *, double *);
double vangle(double v1[3], double v2[3]) {
  double c = vdot(v1, v2) / (vabs(v1) * vabs(v2));
  if (c > 1.0)
    c = 1.0;
  if (c < -1.0)
    c = -1.0;
  return acos(c);
}


x86 assembly (clang, -O0):
<vangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <vdot@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <vabs@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <vabs@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe70(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a7 <vangle+0x77>
movsd  0xe5e(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe59(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11c7 <vangle+0x97>
movsd  0xe46(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <acos@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vangle>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <vdot@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   1050 <vabs@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
call   1050 <vabs@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0xe8a(%rip),%xmm1
minsd  %xmm2,%xmm1
movsd  0xe86(%rip),%xmm0
maxsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <acos@plt>

LLVM IR (-O0):
define double @vangle(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%6 = load double*, double** %3
%7 = load double*, double** %4
%8 = call double @vdot(double* %6, double* %7)
%9 = load double*, double** %3
%10 = call double @vabs(double* %9)
%11 = load double*, double** %4
%12 = call double @vabs(double* %11)
%13 = fmul double %10, %12
%14 = fdiv double %8, %13
store double %14, double* %5
%15 = load double, double* %5
%16 = fcmp ogt double %15, 1.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %2
store double 1.000000e+00, double* %5
br label %18
18: ; preds = %17, %2
%19 = load double, double* %5
%20 = fcmp olt double %19, -1.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %18
store double -1.000000e+00, double* %5
br label %22
22: ; preds = %21, %18
%23 = load double, double* %5
%24 = call double @acos(double %23)
ret double %24
}

LLVM IR (-O2):
define double @vangle(double* %0, double* %1) {
%3 = tail call double @vdot(double* %0, double* %1)
%4 = tail call double @vabs(double* %0)
%5 = tail call double @vabs(double* %1)
%6 = fmul double %4, %5
%7 = fdiv double %3, %6
%8 = fcmp ogt double %7, 1.000000e+00
%9 = select i1 %8, double 1.000000e+00, double %7
%10 = fcmp olt double %9, -1.000000e+00
%11 = select i1 %10, double -1.000000e+00, double %9
%12 = tail call double @acos(double %11)
ret double %12
}