#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 */
float vectorAngleBetween_norm(float *, float *);
int /*<<< orphan*/ vectorCross(float *, float *, float *);
float vectorDot(float const *, float *);
int /*<<< orphan*/ vectorNormalize(float *, float const *);
float vectorOrientedAngleBetween(const float a[3], const float b[3],
                                 const float normal[3]) {
  float normA[3], normB[3];
  float angle;
  float cross[3];
  vectorNormalize(normA, a);
  vectorNormalize(normB, b);
  angle = vectorAngleBetween_norm(normA, normB);
  vectorCross(cross, normA, normB);
  if (vectorDot(normal, cross) < 0.0f) {
    angle = -angle;
  }
  return angle;
}


x86 assembly (clang, -O0):
<vectorOrientedAngleBetween>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x24(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <vectorNormalize@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <vectorNormalize@plt>
lea    -0x24(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <vectorAngleBetween_norm@plt>
movss  %xmm0,-0x34(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1060 <vectorCross@plt>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <vectorDot@plt>
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    11c4 <vectorOrientedAngleBetween+0x84>
movss  -0x34(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectorOrientedAngleBetween>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0x2c(%rsp),%r15
mov    %r15,%rdi
call   1030 <vectorNormalize@plt>
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <vectorNormalize@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <vectorAngleBetween_norm@plt>
movaps %xmm0,(%rsp)
lea    0x14(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <vectorCross@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <vectorDot@plt>
movaps 0xe5b(%rip),%xmm1
movaps (%rsp),%xmm3
xorps  %xmm3,%xmm1
xorps  %xmm2,%xmm2
cmpltss %xmm2,%xmm0
andps  %xmm0,%xmm1
andnps %xmm3,%xmm0
orps   %xmm1,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @vectorOrientedAngleBetween(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca [3 x float]
%8 = alloca [3 x float]
%9 = alloca float
%10 = alloca [3 x float]
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%11 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%12 = load float*, float** %4
%13 = call i32 @vectorNormalize(float* %11, float* %12)
%14 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%15 = load float*, float** %5
%16 = call i32 @vectorNormalize(float* %14, float* %15)
%17 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%18 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%19 = call float @vectorAngleBetween_norm(float* %17, float* %18)
store float %19, float* %9
%20 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%21 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%22 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%23 = call i32 @vectorCross(float* %20, float* %21, float* %22)
%24 = load float*, float** %6
%25 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%26 = call float @vectorDot(float* %24, float* %25)
%27 = fcmp olt float %26, 0.000000e+00
br i1 %27, label %28, label %31
28: ; preds = %3
%29 = load float, float* %9
%30 = fneg float %29
store float %30, float* %9
br label %31
31: ; preds = %28, %3
%32 = load float, float* %9
ret float %32
}

LLVM IR (-O2):
define float @vectorOrientedAngleBetween(float* %0, float* %1, float* %2) {
%4 = alloca [3 x float]
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = bitcast [3 x float]* %4 to i8*
%8 = bitcast [3 x float]* %5 to i8*
%9 = bitcast [3 x float]* %6 to i8*
%10 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%11 = call i32 @vectorNormalize(float* %10, float* %0)
%12 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%13 = call i32 @vectorNormalize(float* %12, float* %1)
%14 = call float @vectorAngleBetween_norm(float* %10, float* %12)
%15 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%16 = call i32 @vectorCross(float* %15, float* %10, float* %12)
%17 = call float @vectorDot(float* %2, float* %15)
%18 = fcmp olt float %17, 0.000000e+00
%19 = fneg float %14
%20 = select i1 %18, float %19, float %14
ret float %20
}