#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 angle(double const *, double const *);
int /*<<< orphan*/ cross(double *, double const *, double const *);
int dot(double const *, double *);
double oriented_angle(const double *u, const double *v, const double *n) {
  double geometric_angle = angle(u, v);
  double c[3];
  cross(c, u, v);
  return dot(n, c) < 0. ? -geometric_angle : geometric_angle;
}


x86 assembly (clang, -O0):
<oriented_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <angle@plt>
movsd  %xmm0,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <cross@plt>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <dot@plt>
cvtsi2sd %eax,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11ab <oriented_angle+0x7b>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11b5 <oriented_angle+0x85>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oriented_angle>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <angle@plt>
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <cross@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <dot@plt>
test   %eax,%eax
js     1175 <oriented_angle+0x45>
movaps (%rsp),%xmm0
jmp    1180 <oriented_angle+0x50>
movaps (%rsp),%xmm0
xorps  0xe80(%rip),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @oriented_angle(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca [3 x 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 = call double @angle(double* %9, double* %10)
store double %11, double* %7
%12 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%13 = load double*, double** %4
%14 = load double*, double** %5
%15 = call i32 @cross(double* %12, double* %13, double* %14)
%16 = load double*, double** %6
%17 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%18 = call i32 @dot(double* %16, double* %17)
%19 = sitofp i32 %18 to double
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = load double, double* %7
%23 = fneg double %22
br label %26
24: ; preds = %3
%25 = load double, double* %7
br label %26
26: ; preds = %24, %21
%27 = phi double [ %23, %21 ], [ %25, %24 ]
ret double %27
}

LLVM IR (-O2):
define double @oriented_angle(double* %0, double* %1, double* %2) {
%4 = alloca [3 x double]
%5 = tail call double @angle(double* %0, double* %1)
%6 = bitcast [3 x double]* %4 to i8*
%7 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%8 = call i32 @cross(double* %7, double* %0, double* %1)
%9 = call i32 @dot(double* %2, double* %7)
%10 = icmp slt i32 %9, 0
%11 = fneg double %5
%12 = select i1 %10, double %11, double %5
ret double %12
}