#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 CalcInProduct(float *, float *);
double acos(double);
float CalcVecAngle(float vec1[3], float vec2[3]) {
  float asw;
  double asw_double;
  asw = CalcInProduct(vec1, vec2);
  asw_double = asw;
  {
    if ((asw_double) > 1.0) {
      (asw_double) = 1.0;
    } else if ((asw_double) < -1.0) {
      (asw_double) = -1.0;
    }
  };
  double rad_double = acos(asw_double);
  return (float)(rad_double);
}


x86 assembly (clang, -O0):
<CalcVecAngle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <CalcInProduct@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1179 <CalcVecAngle+0x59>
movsd  0xe91(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    119e <CalcVecAngle+0x7e>
movsd  0xe87(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1199 <CalcVecAngle+0x79>
movsd  0xe74(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    119e <CalcVecAngle+0x7e>
movsd  -0x20(%rbp),%xmm0
call   1040 <acos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcVecAngle>:
push   %rax
call   1030 <CalcInProduct@plt>
ucomiss 0xee3(%rip),%xmm0
jbe    1139 <CalcVecAngle+0x19>
movsd  0xec9(%rip),%xmm0
jmp    1154 <CalcVecAngle+0x34>
movss  0xed3(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1150 <CalcVecAngle+0x30>
movsd  0xeba(%rip),%xmm0
jmp    1154 <CalcVecAngle+0x34>
cvtss2sd %xmm0,%xmm0
call   1040 <acos@plt>
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @CalcVecAngle(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca double
%7 = alloca double
store float* %0, float** %3
store float* %1, float** %4
%8 = load float*, float** %3
%9 = load float*, float** %4
%10 = call float @CalcInProduct(float* %8, float* %9)
store float %10, float* %5
%11 = load float, float* %5
%12 = fpext float %11 to double
store double %12, double* %6
%13 = load double, double* %6
%14 = fcmp ogt double %13, 1.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %2
store double 1.000000e+00, double* %6
br label %21
16: ; preds = %2
%17 = load double, double* %6
%18 = fcmp olt double %17, -1.000000e+00
br i1 %18, label %19, label %20
19: ; preds = %16
store double -1.000000e+00, double* %6
br label %20
20: ; preds = %19, %16
br label %21
21: ; preds = %20, %15
%22 = load double, double* %6
%23 = call double @acos(double %22)
store double %23, double* %7
%24 = load double, double* %7
%25 = fptrunc double %24 to float
ret float %25
}

LLVM IR (-O2):
define float @CalcVecAngle(float* %0, float* %1) {
%3 = tail call float @CalcInProduct(float* %0, float* %1)
%4 = fcmp ogt float %3, 1.000000e+00
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = fpext float %3 to double
%7 = fcmp olt float %3, -1.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %5
br label %9
9: ; preds = %2, %5, %8
%10 = phi double [ -1.000000e+00, %8 ], [ %6, %5 ], [ 1.000000e+00, %2 ]
%11 = tail call double @acos(double %10)
%12 = fptrunc double %11 to float
ret float %12
}