#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 M_PI;
float acosf(float);
float vec3_dot(float *, float *);
int /*<<< orphan*/ vec3_normalize(float *);
float vec3_angle(float *a, float *b) {
  float tempA[3];
  float tempB[3];
  tempA[0] = a[0], tempA[1] = a[1], tempA[2] = a[2];
  tempB[0] = b[0], tempB[1] = b[1], tempB[2] = b[2];
  vec3_normalize(tempA);
  vec3_normalize(tempB);
  float cosine = vec3_dot(tempA, tempB);
  if (cosine > 1.0) {
    return 0;
  } else if (cosine < -1.0) {
    return M_PI;
  } else {
    return acosf(cosine);
  }
}


x86 assembly (clang, -O0):
<vec3_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
lea    -0x24(%rbp),%rdi
call   1050 <vec3_normalize@plt>
lea    -0x30(%rbp),%rdi
call   1050 <vec3_normalize@plt>
lea    -0x24(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <vec3_dot@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe39(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11de <vec3_angle+0xae>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    121d <vec3_angle+0xed>
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe19(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    120e <vec3_angle+0xde>
mov    0x2de8(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    121d <vec3_angle+0xed>
movss  -0x34(%rbp),%xmm0
call   1030 <acosf@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec3_angle>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movss  (%rdi),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x4(%rdi),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x8(%rdi),%xmm0
movss  %xmm0,0x14(%rsp)
movss  (%rsi),%xmm0
movss  %xmm0,(%rsp)
movss  0x4(%rsi),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsi),%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1050 <vec3_normalize@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <vec3_normalize@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <vec3_dot@plt>
xorps  %xmm1,%xmm1
ucomiss 0xe5d(%rip),%xmm0
ja     11c7 <vec3_angle+0x97>
movss  0xe57(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11bf <vec3_angle+0x8f>
mov    0x2e2f(%rip),%rax
movss  (%rax),%xmm1
jmp    11c7 <vec3_angle+0x97>
call   1030 <acosf@plt>
movaps %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global float 0.000000e+00
define float @vec3_angle(float* %0, float* %1) {
%3 = alloca float
%4 = alloca float*
%5 = alloca float*
%6 = alloca [3 x float]
%7 = alloca [3 x float]
%8 = alloca float
store float* %0, float** %4
store float* %1, float** %5
%9 = load float*, float** %4
%10 = getelementptr inbounds float, float* %9, i64 0
%11 = load float, float* %10
%12 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
store float %11, float* %12
%13 = load float*, float** %4
%14 = getelementptr inbounds float, float* %13, i64 1
%15 = load float, float* %14
%16 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
store float %15, float* %16
%17 = load float*, float** %4
%18 = getelementptr inbounds float, float* %17, i64 2
%19 = load float, float* %18
%20 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
store float %19, float* %20
%21 = load float*, float** %5
%22 = getelementptr inbounds float, float* %21, i64 0
%23 = load float, float* %22
%24 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
store float %23, float* %24
%25 = load float*, float** %5
%26 = getelementptr inbounds float, float* %25, i64 1
%27 = load float, float* %26
%28 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
store float %27, float* %28
%29 = load float*, float** %5
%30 = getelementptr inbounds float, float* %29, i64 2
%31 = load float, float* %30
%32 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
store float %31, float* %32
%33 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%34 = call i32 @vec3_normalize(float* %33)
%35 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%36 = call i32 @vec3_normalize(float* %35)
%37 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
%38 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%39 = call float @vec3_dot(float* %37, float* %38)
store float %39, float* %8
%40 = load float, float* %8
%41 = fpext float %40 to double
%42 = fcmp ogt double %41, 1.000000e+00
br i1 %42, label %43, label %44
43: ; preds = %2
store float 0.000000e+00, float* %3
br label %53
44: ; preds = %2
%45 = load float, float* %8
%46 = fpext float %45 to double
%47 = fcmp olt double %46, -1.000000e+00
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = load float, float* @M_PI
store float %49, float* %3
br label %53
50: ; preds = %44
%51 = load float, float* %8
%52 = call float @acosf(float %51)
store float %52, float* %3
br label %53
53: ; preds = %50, %48, %43
%54 = load float, float* %3
ret float %54
}

LLVM IR (-O2):
@M_PI = global float 0.000000e+00
define float @vec3_angle(float* nocapture %0, float* nocapture %1) {
%3 = alloca [3 x float]
%4 = alloca [3 x float]
%5 = bitcast [3 x float]* %3 to i8*
%6 = bitcast [3 x float]* %4 to i8*
%7 = load float, float* %0
%8 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 0
store float %7, float* %8
%9 = getelementptr inbounds float, float* %0, i64 1
%10 = load float, float* %9
%11 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 1
store float %10, float* %11
%12 = getelementptr inbounds float, float* %0, i64 2
%13 = load float, float* %12
%14 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 2
store float %13, float* %14
%15 = load float, float* %1
%16 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 0
store float %15, float* %16
%17 = getelementptr inbounds float, float* %1, i64 1
%18 = load float, float* %17
%19 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 1
store float %18, float* %19
%20 = getelementptr inbounds float, float* %1, i64 2
%21 = load float, float* %20
%22 = getelementptr inbounds [3 x float], [3 x float]* %4, i64 0, i64 2
store float %21, float* %22
%23 = call i32 @vec3_normalize(float* %8)
%24 = call i32 @vec3_normalize(float* %16)
%25 = call float @vec3_dot(float* %8, float* %16)
%26 = fcmp ogt float %25, 1.000000e+00
br i1 %26, label %33, label %27
27: ; preds = %2
%28 = fcmp olt float %25, -1.000000e+00
br i1 %28, label %29, label %31
29: ; preds = %27
%30 = load float, float* @M_PI
br label %33
31: ; preds = %27
%32 = call float @acosf(float %25)
br label %33
33: ; preds = %2, %31, %29
%34 = phi float [ %30, %29 ], [ %32, %31 ], [ 0.000000e+00, %2 ]
ret float %34
}