#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 VecLen(float *);
float CosAng(float *v1, float *v2) {
  float ang, a, b;
  a = VecLen(v1);
  b = VecLen(v2);
  ang = ((v1[0] * v2[0]) + (v1[1] * v2[1]) + (v1[2] * v2[2])) / (a * b);
  return (ang);
}


x86 assembly (clang, -O0):
<CosAng>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <VecLen@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <VecLen@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
mulss  -0x1c(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CosAng>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <VecLen@plt>
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
call   1030 <VecLen@plt>
movss  (%rbx),%xmm2
movss  0x4(%rbx),%xmm3
mulss  0x4(%r14),%xmm3
mulss  (%r14),%xmm2
movss  0x8(%rbx),%xmm1
mulss  0x8(%r14),%xmm1
addss  %xmm3,%xmm2
addss  %xmm2,%xmm1
mulss  0x4(%rsp),%xmm0
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float @CosAng(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%8 = load float*, float** %3
%9 = call float @VecLen(float* %8)
store float %9, float* %6
%10 = load float*, float** %4
%11 = call float @VecLen(float* %10)
store float %11, float* %7
%12 = load float*, float** %3
%13 = getelementptr inbounds float, float* %12, i64 0
%14 = load float, float* %13
%15 = load float*, float** %4
%16 = getelementptr inbounds float, float* %15, i64 0
%17 = load float, float* %16
%18 = load float*, float** %3
%19 = getelementptr inbounds float, float* %18, i64 1
%20 = load float, float* %19
%21 = load float*, float** %4
%22 = getelementptr inbounds float, float* %21, i64 1
%23 = load float, float* %22
%24 = fmul float %20, %23
%25 = call float @llvm.fmuladd.f32(float %14, float %17, float %24)
%26 = load float*, float** %3
%27 = getelementptr inbounds float, float* %26, i64 2
%28 = load float, float* %27
%29 = load float*, float** %4
%30 = getelementptr inbounds float, float* %29, i64 2
%31 = load float, float* %30
%32 = call float @llvm.fmuladd.f32(float %28, float %31, float %25)
%33 = load float, float* %6
%34 = load float, float* %7
%35 = fmul float %33, %34
%36 = fdiv float %32, %35
store float %36, float* %5
%37 = load float, float* %5
ret float %37
}

LLVM IR (-O2):
define float @CosAng(float* %0, float* %1) {
%3 = tail call float @VecLen(float* %0)
%4 = tail call float @VecLen(float* %1)
%5 = load float, float* %0
%6 = load float, float* %1
%7 = getelementptr inbounds float, float* %0, i64 1
%8 = load float, float* %7
%9 = getelementptr inbounds float, float* %1, i64 1
%10 = load float, float* %9
%11 = fmul float %8, %10
%12 = tail call float @llvm.fmuladd.f32(float %5, float %6, float %11)
%13 = getelementptr inbounds float, float* %0, i64 2
%14 = load float, float* %13
%15 = getelementptr inbounds float, float* %1, i64 2
%16 = load float, float* %15
%17 = tail call float @llvm.fmuladd.f32(float %14, float %16, float %12)
%18 = fmul float %3, %4
%19 = fdiv float %17, %18
ret float %19
}