#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 /*<<< orphan*/ cross_product(float *, float *, float *);
scalar_t__ dot_product(float *, float *);
float unsigned_angle_between(float *, float *);
float angle_between(float *u, float *v, float *n) {
  float angle = unsigned_angle_between(u, v);
  float cross[3];
  cross_product(u, v, cross);
  if (dot_product(n, cross) > 0)
    angle *= -1;
  return angle;
}


x86 assembly (clang, -O0):
<angle_between>:
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   1050 <unsigned_angle_between@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <cross_product@plt>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <dot_product@plt>
cmp    $0x0,%rax
jle    1190 <angle_between+0x60>
movss  0xe7a(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<angle_between>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1050 <unsigned_angle_between@plt>
movaps %xmm0,(%rsp)
lea    0x1c(%rsp),%r12
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <cross_product@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <dot_product@plt>
test   %rax,%rax
jg     1176 <angle_between+0x46>
movaps (%rsp),%xmm0
jmp    1181 <angle_between+0x51>
movaps (%rsp),%xmm0
xorps  0xe7f(%rip),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @angle_between(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca float
%8 = alloca [3 x float]
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%9 = load float*, float** %4
%10 = load float*, float** %5
%11 = call float @unsigned_angle_between(float* %9, float* %10)
store float %11, float* %7
%12 = load float*, float** %4
%13 = load float*, float** %5
%14 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%15 = call i32 @cross_product(float* %12, float* %13, float* %14)
%16 = load float*, float** %6
%17 = getelementptr inbounds [3 x float], [3 x float]* %8, i64 0, i64 0
%18 = call i64 @dot_product(float* %16, float* %17)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %3
%21 = load float, float* %7
%22 = fmul float %21, -1.000000e+00
store float %22, float* %7
br label %23
23: ; preds = %20, %3
%24 = load float, float* %7
ret float %24
}

LLVM IR (-O2):
define float @angle_between(float* %0, float* %1, float* %2) {
%4 = alloca [3 x float]
%5 = tail call float @unsigned_angle_between(float* %0, float* %1)
%6 = bitcast [3 x float]* %4 to i8*
%7 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
%8 = call i32 @cross_product(float* %0, float* %1, float* %7)
%9 = call i64 @dot_product(float* %2, float* %7)
%10 = icmp sgt i64 %9, 0
%11 = fneg float %5
%12 = select i1 %10, float %11, float %5
ret float %12
}