; LLVM IR from paroj/gltut :: glsdk/freeglut/progs/demos/spaceball (vmath)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.vec4_t = type { float, float, float, float }

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @quat_rotate(<2 x float> %0, <2 x float> %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5) #0 {
  %7 = alloca %struct.vec4_t, align 4
  %8 = alloca %struct.vec4_t, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca %struct.vec4_t, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 0
  store <2 x float> %0, ptr %16, align 4
  %17 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 1
  store <2 x float> %1, ptr %17, align 4
  store float %2, ptr %9, align 4, !tbaa !5
  store float %3, ptr %10, align 4, !tbaa !5
  store float %4, ptr %11, align 4, !tbaa !5
  store float %5, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %18 = load float, ptr %9, align 4, !tbaa !5
  %19 = fmul float %18, 5.000000e-01
  store float %19, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %20 = load float, ptr %14, align 4, !tbaa !5
  %21 = fpext float %20 to double
  %22 = call double @sin(double noundef %21) #4
  %23 = fptrunc double %22 to float
  store float %23, ptr %15, align 4, !tbaa !5
  %24 = load float, ptr %14, align 4, !tbaa !5
  %25 = fpext float %24 to double
  %26 = call double @cos(double noundef %25) #4
  %27 = fptrunc double %26 to float
  %28 = getelementptr inbounds %struct.vec4_t, ptr %13, i32 0, i32 3
  store float %27, ptr %28, align 4, !tbaa !9
  %29 = load float, ptr %10, align 4, !tbaa !5
  %30 = load float, ptr %15, align 4, !tbaa !5
  %31 = fmul float %29, %30
  %32 = getelementptr inbounds %struct.vec4_t, ptr %13, i32 0, i32 0
  store float %31, ptr %32, align 4, !tbaa !11
  %33 = load float, ptr %11, align 4, !tbaa !5
  %34 = load float, ptr %15, align 4, !tbaa !5
  %35 = fmul float %33, %34
  %36 = getelementptr inbounds %struct.vec4_t, ptr %13, i32 0, i32 1
  store float %35, ptr %36, align 4, !tbaa !12
  %37 = load float, ptr %12, align 4, !tbaa !5
  %38 = load float, ptr %15, align 4, !tbaa !5
  %39 = fmul float %37, %38
  %40 = getelementptr inbounds %struct.vec4_t, ptr %13, i32 0, i32 2
  store float %39, ptr %40, align 4, !tbaa !13
  %41 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 0
  %42 = load <2 x float>, ptr %41, align 4
  %43 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 1
  %44 = load <2 x float>, ptr %43, align 4
  %45 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 0
  %46 = load <2 x float>, ptr %45, align 4
  %47 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 1
  %48 = load <2 x float>, ptr %47, align 4
  %49 = call { <2 x float>, <2 x float> } @quat_mul(<2 x float> %42, <2 x float> %44, <2 x float> %46, <2 x float> %48)
  %50 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 0
  %51 = extractvalue { <2 x float>, <2 x float> } %49, 0
  store <2 x float> %51, ptr %50, align 4
  %52 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 1
  %53 = extractvalue { <2 x float>, <2 x float> } %49, 1
  store <2 x float> %53, ptr %52, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  %54 = load { <2 x float>, <2 x float> }, ptr %7, align 4
  ret { <2 x float>, <2 x float> } %54
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare double @sin(double noundef) #2

; Function Attrs: nounwind
declare double @cos(double noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden { <2 x float>, <2 x float> } @quat_mul(<2 x float>, <2 x float>, <2 x float>, <2 x float>) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 12}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 0}
!12 = !{!10, !6, i64 4}
!13 = !{!10, !6, i64 8}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @quat_rotate(<2 x float> %0, <2 x float> %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5) local_unnamed_addr #0 {
  %7 = fmul float %2, 5.000000e-01
  %8 = fpext float %7 to double
  %9 = tail call double @sin(double noundef %8) #3
  %10 = fptrunc double %9 to float
  %11 = tail call double @cos(double noundef %8) #3
  %12 = fptrunc double %11 to float
  %13 = insertelement <2 x float> poison, float %10, i64 0
  %14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> zeroinitializer
  %15 = insertelement <2 x float> poison, float %3, i64 0
  %16 = insertelement <2 x float> %15, float %4, i64 1
  %17 = fmul <2 x float> %14, %16
  %18 = fmul float %10, %5
  %19 = insertelement <2 x float> poison, float %18, i64 0
  %.sroa.5.8.vec.insert = insertelement <2 x float> %19, float %12, i64 1
  %20 = tail call { <2 x float>, <2 x float> } @quat_mul(<2 x float> %0, <2 x float> %1, <2 x float> %17, <2 x float> %.sroa.5.8.vec.insert)
  ret { <2 x float>, <2 x float> } %20
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden { <2 x float>, <2 x float> } @quat_mul(<2 x float>, <2 x float>, <2 x float>, <2 x float>) local_unnamed_addr #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass