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

; 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.11 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZNK10HeapMatrixmlERKS_ = external hidden unnamed_addr constant [59 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 nonnull align 4 dereferenceable(4) ptr @_ZN10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40), i32 noundef, i32 noundef) #1 align 2

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10HeapMatrixmlERKS_(ptr dead_on_unwind noalias writable sret(%class.HeapMatrix) align 16 %0, ptr noundef nonnull align 16 dereferenceable(40) %1, ptr noundef nonnull align 16 dereferenceable(40) %2) #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i1, align 1
  %8 = alloca float, align 4
  %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
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8
  %16 = getelementptr inbounds %class.HeapMatrix, ptr %15, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.HeapMatrix, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 16, !tbaa !12
  %21 = icmp eq i32 %17, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %3
  br label %25

23:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 257, ptr noundef @__PRETTY_FUNCTION__._ZNK10HeapMatrixmlERKS_) #4
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  store i1 false, ptr %7, align 1
  %26 = getelementptr inbounds %class.HeapMatrix, ptr %15, i32 0, i32 0
  %27 = load i32, ptr %26, align 16, !tbaa !12
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.HeapMatrix, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !9
  call void @_ZN10HeapMatrixC1Ejj(ptr noundef nonnull align 16 dereferenceable(40) %0, i32 noundef %27, i32 noundef %30)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store float 0.000000e+00, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !15
  br label %31

31:                                               ; preds = %86, %25
  %32 = load i32, ptr %9, align 4, !tbaa !15
  %33 = getelementptr inbounds %class.HeapMatrix, ptr %15, i32 0, i32 0
  %34 = load i32, ptr %33, align 16, !tbaa !12
  %35 = icmp ult i32 %32, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %31
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %89

37:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !15
  br label %38

38:                                               ; preds = %77, %37
  %39 = load i32, ptr %11, align 4, !tbaa !15
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %class.HeapMatrix, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = icmp ult i32 %39, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %38
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %85

45:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !15
  br label %46

46:                                               ; preds = %64, %45
  %47 = load i32, ptr %12, align 4, !tbaa !15
  %48 = getelementptr inbounds %class.HeapMatrix, ptr %15, i32 0, i32 1
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = icmp ult i32 %47, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %46
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %71

52:                                               ; preds = %46
  %53 = load i32, ptr %9, align 4, !tbaa !15
  %54 = load i32, ptr %12, align 4, !tbaa !15
  %55 = invoke noundef float @_ZNK10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40) %15, i32 noundef %53, i32 noundef %54)
          to label %56 unwind label %67

56:                                               ; preds = %52
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i32, ptr %12, align 4, !tbaa !15
  %59 = load i32, ptr %11, align 4, !tbaa !15
  %60 = invoke noundef float @_ZNK10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40) %57, i32 noundef %58, i32 noundef %59)
          to label %61 unwind label %67

61:                                               ; preds = %56
  %62 = load float, ptr %8, align 4, !tbaa !13
  %63 = call float @llvm.fmuladd.f32(float %55, float %60, float %62)
  store float %63, ptr %8, align 4, !tbaa !13
  br label %64

64:                                               ; preds = %61
  %65 = load i32, ptr %12, align 4, !tbaa !15
  %66 = add i32 %65, 1
  store i32 %66, ptr %12, align 4, !tbaa !15
  br label %46, !llvm.loop !16

67:                                               ; preds = %56, %52
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %13, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %84

71:                                               ; preds = %51
  %72 = load float, ptr %8, align 4, !tbaa !13
  %73 = load i32, ptr %9, align 4, !tbaa !15
  %74 = load i32, ptr %11, align 4, !tbaa !15
  %75 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40) %0, i32 noundef %73, i32 noundef %74)
          to label %76 unwind label %80

76:                                               ; preds = %71
  store float %72, ptr %75, align 4, !tbaa !13
  store float 0.000000e+00, ptr %8, align 4, !tbaa !13
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %11, align 4, !tbaa !15
  %79 = add i32 %78, 1
  store i32 %79, ptr %11, align 4, !tbaa !15
  br label %38, !llvm.loop !18

80:                                               ; preds = %71
  %81 = landingpad { ptr, i32 }
          cleanup
  %82 = extractvalue { ptr, i32 } %81, 0
  store ptr %82, ptr %13, align 8
  %83 = extractvalue { ptr, i32 } %81, 1
  store i32 %83, ptr %14, align 4
  br label %84

84:                                               ; preds = %80, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @_ZN10HeapMatrixD1Ev(ptr noundef nonnull align 16 dereferenceable(40) %0) #5
  br label %93

85:                                               ; preds = %44
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %9, align 4, !tbaa !15
  %88 = add i32 %87, 1
  store i32 %88, ptr %9, align 4, !tbaa !15
  br label %31, !llvm.loop !19

89:                                               ; preds = %36
  store i1 true, ptr %7, align 1
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %90 = load i1, ptr %7, align 1
  br i1 %90, label %92, label %91

91:                                               ; preds = %89
  call void @_ZN10HeapMatrixD1Ev(ptr noundef nonnull align 16 dereferenceable(40) %0) #5
  br label %92

92:                                               ; preds = %91, %89
  ret void

93:                                               ; preds = %84
  %94 = load ptr, ptr %13, align 8
  %95 = load i32, ptr %14, align 4
  %96 = insertvalue { ptr, i32 } poison, ptr %94, 0
  %97 = insertvalue { ptr, i32 } %96, i32 %95, 1
  resume { ptr, i32 } %97
}

declare void @_ZN10HeapMatrixC1Ejj(ptr, i32, i32)

declare void @_ZN10HeapMatrixD1Ev(ptr)

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 = { 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, !11, i64 4}
!10 = !{!"_ZTS10HeapMatrix", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}


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

%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.11 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZNK10HeapMatrixmlERKS_ = external hidden unnamed_addr constant [59 x i8], align 1

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

; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10HeapMatrixmlERKS_(ptr dead_on_unwind noalias writable sret(%class.HeapMatrix) align 16 %0, ptr noundef nonnull align 16 dereferenceable(40) %1, ptr noundef nonnull align 16 dereferenceable(40) %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = load i32, ptr %2, align 16, !tbaa !11
  %7 = icmp eq i32 %5, %6
  br i1 %7, label %9, label %8

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

9:                                                ; preds = %3
  %10 = load i32, ptr %1, align 16, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %2, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !5
  tail call void @_ZN10HeapMatrixC1Ejj(ptr noundef nonnull align 16 dereferenceable(40) %0, i32 noundef %10, i32 noundef %12)
  %13 = load i32, ptr %1, align 16, !tbaa !11
  %.not = icmp eq i32 %13, 0
  %14 = load i32, ptr %11, align 4
  %.not35 = icmp eq i32 %14, 0
  %or.cond = select i1 %.not, i1 true, i1 %.not35
  br i1 %or.cond, label %._crit_edge34, label %.preheader27

.preheader27:                                     ; preds = %9, %._crit_edge32
  %15 = phi i32 [ %18, %._crit_edge32 ], [ %13, %9 ]
  %16 = phi i32 [ %19, %._crit_edge32 ], [ 1, %9 ]
  %.02433 = phi i32 [ %20, %._crit_edge32 ], [ 0, %9 ]
  %.not36 = icmp eq i32 %16, 0
  br i1 %.not36, label %._crit_edge32, label %.preheader

.preheader:                                       ; preds = %.preheader27, %33
  %.02331 = phi i32 [ %34, %33 ], [ 0, %.preheader27 ]
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %.not37 = icmp eq i32 %17, 0
  br i1 %.not37, label %._crit_edge, label %.lr.ph

._crit_edge32.loopexit:                           ; preds = %33
  %.pre = load i32, ptr %1, align 16, !tbaa !11
  br label %._crit_edge32

._crit_edge32:                                    ; preds = %._crit_edge32.loopexit, %.preheader27
  %18 = phi i32 [ %.pre, %._crit_edge32.loopexit ], [ %15, %.preheader27 ]
  %19 = phi i32 [ %35, %._crit_edge32.loopexit ], [ 0, %.preheader27 ]
  %20 = add nuw i32 %.02433, 1
  %21 = icmp ult i32 %20, %18
  br i1 %21, label %.preheader27, label %._crit_edge34, !llvm.loop !12

._crit_edge:                                      ; preds = %26, %.preheader
  %.2.lcssa = phi float [ 0.000000e+00, %.preheader ], [ %27, %26 ]
  %22 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40) %0, i32 noundef %.02433, i32 noundef %.02331)
          to label %33 unwind label %37

.lr.ph:                                           ; preds = %.preheader, %26
  %.02230 = phi i32 [ %28, %26 ], [ 0, %.preheader ]
  %.229 = phi float [ %27, %26 ], [ 0.000000e+00, %.preheader ]
  %23 = invoke noundef float @_ZNK10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40) %1, i32 noundef %.02433, i32 noundef %.02230)
          to label %24 unwind label %31

24:                                               ; preds = %.lr.ph
  %25 = invoke noundef float @_ZNK10HeapMatrixclEjj(ptr noundef nonnull align 16 dereferenceable(40) %2, i32 noundef %.02230, i32 noundef %.02331)
          to label %26 unwind label %31

26:                                               ; preds = %24
  %27 = tail call float @llvm.fmuladd.f32(float %23, float %25, float %.229)
  %28 = add nuw i32 %.02230, 1
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = icmp ult i32 %28, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !15

31:                                               ; preds = %24, %.lr.ph
  %32 = landingpad { ptr, i32 }
          cleanup
  br label %39

33:                                               ; preds = %._crit_edge
  store float %.2.lcssa, ptr %22, align 4, !tbaa !16
  %34 = add nuw i32 %.02331, 1
  %35 = load i32, ptr %11, align 4, !tbaa !5
  %36 = icmp ult i32 %34, %35
  br i1 %36, label %.preheader, label %._crit_edge32.loopexit, !llvm.loop !18

37:                                               ; preds = %._crit_edge
  %38 = landingpad { ptr, i32 }
          cleanup
  br label %39

39:                                               ; preds = %37, %31
  %.pn = phi { ptr, i32 } [ %32, %31 ], [ %38, %37 ]
  tail call void @_ZN10HeapMatrixD1Ev(ptr noundef nonnull align 16 dereferenceable(40) %0) #4
  resume { ptr, i32 } %.pn

._crit_edge34:                                    ; preds = %._crit_edge32, %9
  ret void
}

declare void @_ZN10HeapMatrixC1Ejj(ptr, i32, i32) local_unnamed_addr

declare void @_ZN10HeapMatrixD1Ev(ptr) local_unnamed_addr

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


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