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

; 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 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@__PRETTY_FUNCTION__._ZNK10HeapMatrix18innerProductRowVecEjRKS_ = external hidden unnamed_addr constant [77 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

15:                                               ; preds = %3
  br label %18

16:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 91, ptr noundef @__PRETTY_FUNCTION__._ZNK10HeapMatrix18innerProductRowVecEjRKS_) #4
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.HeapMatrix, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  br label %26

24:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 92, ptr noundef @__PRETTY_FUNCTION__._ZNK10HeapMatrix18innerProductRowVecEjRKS_) #4
  unreachable

25:                                               ; No predecessors!
  br label %26

26:                                               ; preds = %25, %23
  %27 = load ptr, ptr %6, 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 = getelementptr inbounds %class.HeapMatrix, ptr %10, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !13
  %32 = icmp eq i32 %29, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %26
  br label %36

34:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 93, ptr noundef @__PRETTY_FUNCTION__._ZNK10HeapMatrix18innerProductRowVecEjRKS_) #4
  unreachable

35:                                               ; No predecessors!
  br label %36

36:                                               ; preds = %35, %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store float 0.000000e+00, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = getelementptr inbounds %class.HeapMatrix, ptr %10, i32 0, i32 3
  %39 = load i32, ptr %38, align 4, !tbaa !16
  %40 = mul i32 %37, %39
  store i32 %40, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %65, %36
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = getelementptr inbounds %class.HeapMatrix, ptr %10, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !13
  %45 = icmp ult i32 %42, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %68

47:                                               ; preds = %41
  %48 = getelementptr inbounds %class.HeapMatrix, ptr %10, i32 0, i32 6
  %49 = load ptr, ptr %48, align 16, !tbaa !17
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = add i32 %50, %51
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %49, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !14
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %class.HeapMatrix, ptr %56, i32 0, i32 6
  %58 = load ptr, ptr %57, align 16, !tbaa !17
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds float, ptr %58, i64 %60
  %62 = load float, ptr %61, align 4, !tbaa !14
  %63 = load float, ptr %7, align 4, !tbaa !14
  %64 = call float @llvm.fmuladd.f32(float %55, float %62, float %63)
  store float %64, ptr %7, align 4, !tbaa !14
  br label %65

65:                                               ; preds = %47
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = add i32 %66, 1
  store i32 %67, ptr %9, align 4, !tbaa !9
  br label %41, !llvm.loop !18

68:                                               ; preds = %46
  %69 = load float, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret float %69
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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, !10, i64 12}
!17 = !{!12, !6, i64 32}
!18 = distinct !{!18, !19}
!19 = !{!"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 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@__PRETTY_FUNCTION__._ZNK10HeapMatrix18innerProductRowVecEjRKS_ = external hidden unnamed_addr constant [77 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZNK10HeapMatrix18innerProductRowVecEjRKS_(ptr nocapture noundef nonnull readonly align 16 dereferenceable(40) %0, i32 noundef %1, ptr nocapture noundef nonnull readonly align 16 dereferenceable(40) %2) local_unnamed_addr #1 align 2 {
  %4 = load i32, ptr %0, align 16, !tbaa !5
  %5 = icmp ugt i32 %4, %1
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 91, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK10HeapMatrix18innerProductRowVecEjRKS_) #3
  unreachable

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %2, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 92, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK10HeapMatrix18innerProductRowVecEjRKS_) #3
  unreachable

12:                                               ; preds = %7
  %13 = load i32, ptr %2, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp eq i32 %13, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %12
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 93, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK10HeapMatrix18innerProductRowVecEjRKS_) #3
  unreachable

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = mul i32 %20, %1
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %18
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = load ptr, ptr %22, align 16, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %2, i64 32
  %25 = load ptr, ptr %24, align 16, !tbaa !13
  %wide.trip.count = zext i32 %13 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %26 = icmp ult i32 %13, 4
  br i1 %26, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %35

._crit_edge.loopexit.unr-lcssa:                   ; preds = %35, %.lr.ph
  %.lcssa.ph = phi float [ poison, %.lr.ph ], [ %67, %35 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.3, %35 ]
  %.01214.unr = phi float [ 0.000000e+00, %.lr.ph ], [ %67, %35 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01214.epil = phi float [ %34, %.epil.preheader ], [ %.01214.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %27 = trunc nuw i64 %indvars.iv.epil to i32
  %28 = add i32 %21, %27
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds float, ptr %23, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !14
  %32 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.epil
  %33 = load float, ptr %32, align 4, !tbaa !14
  %34 = tail call float @llvm.fmuladd.f32(float %31, float %33, float %.01214.epil)
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !16

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %18
  %.012.lcssa = phi float [ 0.000000e+00, %18 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %34, %.epil.preheader ]
  ret float %.012.lcssa

35:                                               ; preds = %35, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.3, %35 ]
  %.01214 = phi float [ 0.000000e+00, %.lr.ph.new ], [ %67, %35 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %35 ]
  %36 = trunc nuw i64 %indvars.iv to i32
  %37 = add i32 %21, %36
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %23, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !14
  %41 = getelementptr inbounds float, ptr %25, i64 %indvars.iv
  %42 = load float, ptr %41, align 4, !tbaa !14
  %43 = tail call float @llvm.fmuladd.f32(float %40, float %42, float %.01214)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %44 = trunc nuw i64 %indvars.iv.next to i32
  %45 = add i32 %21, %44
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %23, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !14
  %49 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next
  %50 = load float, ptr %49, align 4, !tbaa !14
  %51 = tail call float @llvm.fmuladd.f32(float %48, float %50, float %43)
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %52 = trunc nuw i64 %indvars.iv.next.1 to i32
  %53 = add i32 %21, %52
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds float, ptr %23, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !14
  %57 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next.1
  %58 = load float, ptr %57, align 4, !tbaa !14
  %59 = tail call float @llvm.fmuladd.f32(float %56, float %58, float %51)
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %60 = trunc nuw i64 %indvars.iv.next.2 to i32
  %61 = add i32 %21, %60
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds float, ptr %23, i64 %62
  %64 = load float, ptr %63, align 4, !tbaa !14
  %65 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next.2
  %66 = load float, ptr %65, align 4, !tbaa !14
  %67 = tail call float @llvm.fmuladd.f32(float %64, float %66, float %59)
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %35, !llvm.loop !18
}

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

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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, !7, i64 12}
!13 = !{!6, !10, i64 32}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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