; LLVM IR from Slingshot-Physics/slingshot-community :: common/math/src/heap_matrix.ll (ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j)

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

%class.HeapMatrix = type { i32, i32, i32, i32, i32, [12 x i8], ptr, [8 x i8] }

@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__._ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j = external hidden unnamed_addr constant [139 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNK10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK10HeapMatrix5indexEjj(ptr noundef nonnull align 16 dereferenceable(40), i32 noundef, i32 noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j(ptr noundef nonnull align 16 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef nonnull align 16 dereferenceable(40) %5, i32 noundef %6) #1 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  store i32 %6, ptr %14, align 4, !tbaa !9
  %17 = load ptr, ptr %8, align 8
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = getelementptr inbounds %class.HeapMatrix, ptr %17, i32 0, i32 0
  %20 = load i32, ptr %19, align 16, !tbaa !11
  %21 = icmp ult i32 %18, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %7
  br label %25

23:                                               ; preds = %7
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 140, ptr noundef @__PRETTY_FUNCTION__._ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j) #5
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.HeapMatrix, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 16, !tbaa !11
  %30 = icmp ult i32 %26, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %25
  br label %34

32:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 141, ptr noundef @__PRETTY_FUNCTION__._ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j) #5
  unreachable

33:                                               ; No predecessors!
  br label %34

34:                                               ; preds = %33, %31
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.HeapMatrix, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !13
  %38 = getelementptr inbounds %class.HeapMatrix, ptr %17, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !13
  %40 = icmp eq i32 %37, %39
  br i1 %40, label %41, label %42

41:                                               ; preds = %34
  br label %44

42:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 142, ptr noundef @__PRETTY_FUNCTION__._ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j) #5
  unreachable

43:                                               ; No predecessors!
  br label %44

44:                                               ; preds = %43, %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store float 0.000000e+00, ptr %15, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %69, %44
  %46 = load i32, ptr %16, align 4, !tbaa !9
  %47 = load i32, ptr %14, align 4, !tbaa !9
  %48 = icmp ult i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %72

50:                                               ; preds = %45
  %51 = getelementptr inbounds %class.HeapMatrix, ptr %17, i32 0, i32 6
  %52 = load ptr, ptr %51, align 16, !tbaa !16
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = load i32, ptr %16, align 4, !tbaa !9
  %56 = add i32 %54, %55
  %57 = call noundef i32 @_ZNK10HeapMatrix5indexEjj(ptr noundef nonnull align 16 dereferenceable(40) %17, i32 noundef %53, i32 noundef %56)
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %52, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !14
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = load i32, ptr %16, align 4, !tbaa !9
  %65 = add i32 %63, %64
  %66 = call noundef float @_ZNK10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40) %61, i32 noundef %62, i32 noundef %65)
  %67 = load float, ptr %15, align 4, !tbaa !14
  %68 = call float @llvm.fmuladd.f32(float %60, float %66, float %67)
  store float %68, ptr %15, align 4, !tbaa !14
  br label %69

69:                                               ; preds = %50
  %70 = load i32, ptr %16, align 4, !tbaa !9
  %71 = add i32 %70, 1
  store i32 %71, ptr %16, align 4, !tbaa !9
  br label %45, !llvm.loop !17

72:                                               ; preds = %49
  %73 = load float, ptr %15, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  ret float %73
}

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 = { noreturn 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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS10HeapMatrix", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 32}
!13 = !{!12, !10, i64 4}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!12, !6, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__._ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j = external hidden unnamed_addr constant [139 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNK10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK10HeapMatrix5indexEjj(ptr noundef nonnull align 16 dereferenceable(40), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j(ptr noundef nonnull align 16 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef nonnull align 16 dereferenceable(40) %5, i32 noundef %6) local_unnamed_addr #0 align 2 {
  %8 = load i32, ptr %0, align 16, !tbaa !5
  %9 = icmp ugt i32 %8, %1
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 140, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j) #4
  unreachable

11:                                               ; preds = %7
  %12 = load i32, ptr %5, align 16, !tbaa !5
  %13 = icmp ugt i32 %12, %3
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 141, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j) #4
  unreachable

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %5, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %0, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = icmp eq i32 %17, %19
  br i1 %20, label %.preheader, label %22

.preheader:                                       ; preds = %15
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  br label %23

22:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 142, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK10HeapMatrix24innerProductSubRowMatRowEjjjjRKS_j) #4
  unreachable

._crit_edge:                                      ; preds = %23, %.preheader
  %.016.lcssa = phi float [ 0.000000e+00, %.preheader ], [ %32, %23 ]
  ret float %.016.lcssa

23:                                               ; preds = %.lr.ph, %23
  %.020 = phi i32 [ 0, %.lr.ph ], [ %33, %23 ]
  %.01619 = phi float [ 0.000000e+00, %.lr.ph ], [ %32, %23 ]
  %24 = load ptr, ptr %21, align 16, !tbaa !12
  %25 = add i32 %.020, %2
  %26 = tail call noundef i32 @_ZNK10HeapMatrix5indexEjj(ptr noundef nonnull align 16 dereferenceable(40) %0, i32 noundef %1, i32 noundef %25)
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %24, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !13
  %30 = add i32 %.020, %4
  %31 = tail call noundef float @_ZNK10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40) %5, i32 noundef %3, i32 noundef %30)
  %32 = tail call float @llvm.fmuladd.f32(float %29, float %31, float %.01619)
  %33 = add nuw i32 %.020, 1
  %exitcond.not = icmp eq i32 %33, %6
  br i1 %exitcond.not, label %._crit_edge, label %23, !llvm.loop !15
}

attributes #0 = { 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 #1 = { noreturn 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 #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 = { noreturn 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, !7, i64 0}
!6 = !{!"_ZTS10HeapMatrix", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !10, i64 32}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass