; LLVM IR from mateeeeeee/Adria-DX11 :: ThirdParty/tinygltf/examples/common/trackball.ll (Z9add_quatsPfS_S_)

; 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"

@_ZZ9add_quatsPfS_S_E5count = external hidden global i32, align 4

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL6vcrossPKfS0_Pf(ptr noundef, ptr noundef, ptr noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL5vcopyPKfPf(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL6vscalePff(ptr noundef, float noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9add_quatsPfS_S_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [4 x float], align 16
  %8 = alloca [4 x float], align 16
  %9 = alloca [4 x float], align 16
  %10 = alloca [4 x float], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  call void @_ZL5vcopyPKfPf(ptr noundef %11, ptr noundef %12)
  %13 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds float, ptr %14, i64 3
  %16 = load float, ptr %15, align 4, !tbaa !9
  call void @_ZL6vscalePff(ptr noundef %13, float noundef %16)
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds [4 x float], ptr %8, i64 0, i64 0
  call void @_ZL5vcopyPKfPf(ptr noundef %17, ptr noundef %18)
  %19 = getelementptr inbounds [4 x float], ptr %8, i64 0, i64 0
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds float, ptr %20, i64 3
  %22 = load float, ptr %21, align 4, !tbaa !9
  call void @_ZL6vscalePff(ptr noundef %19, float noundef %22)
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds [4 x float], ptr %9, i64 0, i64 0
  call void @_ZL6vcrossPKfS0_Pf(ptr noundef %23, ptr noundef %24, ptr noundef %25)
  %26 = getelementptr inbounds [4 x float], ptr %7, i64 0, i64 0
  %27 = getelementptr inbounds [4 x float], ptr %8, i64 0, i64 0
  %28 = getelementptr inbounds [4 x float], ptr %10, i64 0, i64 0
  call void @_ZL4vaddPKfS0_Pf(ptr noundef %26, ptr noundef %27, ptr noundef %28)
  %29 = getelementptr inbounds [4 x float], ptr %9, i64 0, i64 0
  %30 = getelementptr inbounds [4 x float], ptr %10, i64 0, i64 0
  %31 = getelementptr inbounds [4 x float], ptr %10, i64 0, i64 0
  call void @_ZL4vaddPKfS0_Pf(ptr noundef %29, ptr noundef %30, ptr noundef %31)
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds float, ptr %32, i64 3
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds float, ptr %35, i64 3
  %37 = load float, ptr %36, align 4, !tbaa !9
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = call noundef float @_ZL4vdotPKfS0_(ptr noundef %38, ptr noundef %39)
  %41 = fneg float %40
  %42 = call float @llvm.fmuladd.f32(float %34, float %37, float %41)
  %43 = getelementptr inbounds [4 x float], ptr %10, i64 0, i64 3
  store float %42, ptr %43, align 4, !tbaa !9
  %44 = getelementptr inbounds [4 x float], ptr %10, i64 0, i64 0
  %45 = load float, ptr %44, align 16, !tbaa !9
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds float, ptr %46, i64 0
  store float %45, ptr %47, align 4, !tbaa !9
  %48 = getelementptr inbounds [4 x float], ptr %10, i64 0, i64 1
  %49 = load float, ptr %48, align 4, !tbaa !9
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds float, ptr %50, i64 1
  store float %49, ptr %51, align 4, !tbaa !9
  %52 = getelementptr inbounds [4 x float], ptr %10, i64 0, i64 2
  %53 = load float, ptr %52, align 8, !tbaa !9
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds float, ptr %54, i64 2
  store float %53, ptr %55, align 4, !tbaa !9
  %56 = getelementptr inbounds [4 x float], ptr %10, i64 0, i64 3
  %57 = load float, ptr %56, align 4, !tbaa !9
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds float, ptr %58, i64 3
  store float %57, ptr %59, align 4, !tbaa !9
  %60 = load i32, ptr @_ZZ9add_quatsPfS_S_E5count, align 4, !tbaa !11
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr @_ZZ9add_quatsPfS_S_E5count, align 4, !tbaa !11
  %62 = icmp sgt i32 %61, 97
  br i1 %62, label %63, label %65

63:                                               ; preds = %3
  store i32 0, ptr @_ZZ9add_quatsPfS_S_E5count, align 4, !tbaa !11
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL14normalize_quatPf(ptr noundef %64)
  br label %65

65:                                               ; preds = %63, %3
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL4vaddPKfS0_Pf(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef float @_ZL4vdotPKfS0_(ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL14normalize_quatPf(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; 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"

@_ZZ9add_quatsPfS_S_E5count = external hidden local_unnamed_addr global i32, align 4

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL6vcrossPKfS0_Pf(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL5vcopyPKfPf(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL6vscalePff(ptr noundef, float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9add_quatsPfS_S_(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca [4 x float], align 16
  %5 = alloca [4 x float], align 16
  %6 = alloca [4 x float], align 16
  %7 = alloca [4 x float], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  call void @_ZL5vcopyPKfPf(ptr noundef %0, ptr noundef nonnull %4)
  %8 = getelementptr inbounds i8, ptr %1, i64 12
  %9 = load float, ptr %8, align 4, !tbaa !5
  call void @_ZL6vscalePff(ptr noundef nonnull %4, float noundef %9)
  call void @_ZL5vcopyPKfPf(ptr noundef %1, ptr noundef nonnull %5)
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load float, ptr %10, align 4, !tbaa !5
  call void @_ZL6vscalePff(ptr noundef nonnull %5, float noundef %11)
  call void @_ZL6vcrossPKfS0_Pf(ptr noundef %1, ptr noundef %0, ptr noundef nonnull %6)
  call void @_ZL4vaddPKfS0_Pf(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %7)
  call void @_ZL4vaddPKfS0_Pf(ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %7)
  %12 = load float, ptr %10, align 4, !tbaa !5
  %13 = load float, ptr %8, align 4, !tbaa !5
  %14 = call noundef float @_ZL4vdotPKfS0_(ptr noundef %0, ptr noundef %1)
  %15 = fneg float %14
  %16 = call float @llvm.fmuladd.f32(float %12, float %13, float %15)
  %17 = getelementptr inbounds i8, ptr %7, i64 12
  store float %16, ptr %17, align 4, !tbaa !5
  %18 = load <2 x float>, ptr %7, align 16, !tbaa !5
  store <2 x float> %18, ptr %2, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %7, i64 8
  %20 = load float, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %2, i64 8
  store float %20, ptr %21, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %2, i64 12
  store float %16, ptr %22, align 4, !tbaa !5
  %23 = load i32, ptr @_ZZ9add_quatsPfS_S_E5count, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr @_ZZ9add_quatsPfS_S_E5count, align 4, !tbaa !9
  %25 = icmp sgt i32 %23, 96
  br i1 %25, label %26, label %27

26:                                               ; preds = %3
  store i32 0, ptr @_ZZ9add_quatsPfS_S_E5count, align 4, !tbaa !9
  call void @_ZL14normalize_quatPf(ptr noundef nonnull %2)
  br label %27

27:                                               ; preds = %26, %3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL4vaddPKfS0_Pf(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef float @_ZL4vdotPKfS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL14normalize_quatPf(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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