; LLVM IR from simbody/simbody :: SimTKmath/Optimizers/src/IpOpt (IpTripletHelper)

; 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.SimTKIpopt::SmartPtr.5" = type { ptr }
%"class.SimTKIpopt::SmartPtr.6" = type { ptr }

@_ZTIN10SimTKIpopt11MatrixSpaceE = external constant ptr
@_ZTIN10SimTKIpopt22CompoundSymMatrixSpaceE = external dso_local constant { ptr, ptr, ptr }, align 8

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

declare i32 @__gxx_personality_v0(...)

; 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 dso_local void @_ZN10SimTKIpopt8SmartPtrIKNS_11MatrixSpaceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN10SimTKIpopt13TripletHelper16GetNumberEntriesERKNS_6MatrixE(ptr noundef nonnull align 8 dereferenceable(69)) #2 align 2

; Function Attrs: nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10SimTKIpopt8SmartPtrIKNS_6MatrixEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10SimTKIpopt13TripletHelper10FillRowColEiRKNS_6MatrixEPiS4_ii(i32 noundef, ptr noundef nonnull align 8 dereferenceable(69), ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10SimTKIpopt13TripletHelper11FillRowCol_EiRKNS_17CompoundSymMatrixEiiPiS4_(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(137) %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) #2 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca %"class.SimTKIpopt::SmartPtr.5", align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca %"class.SimTKIpopt::SmartPtr.6", align 8
  %24 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %25 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZNK10SimTKIpopt6Matrix10OwnerSpaceEv(ptr dead_on_unwind writable sret(%"class.SimTKIpopt::SmartPtr.5") align 8 %15, ptr noundef nonnull align 8 dereferenceable(69) %25)
  %26 = invoke noundef ptr @_ZN10SimTKIpopt9GetRawPtrIKNS_11MatrixSpaceEEEPT_RKNS_8SmartPtrIS3_EE(ptr noundef nonnull align 8 dereferenceable(8) %15)
          to label %27 unwind label %31

27:                                               ; preds = %6
  %28 = icmp eq ptr %26, null
  br i1 %28, label %35, label %29

29:                                               ; preds = %27
  %30 = call ptr @__dynamic_cast(ptr %26, ptr @_ZTIN10SimTKIpopt11MatrixSpaceE, ptr @_ZTIN10SimTKIpopt22CompoundSymMatrixSpaceE, i64 0) #6
  br label %36

31:                                               ; preds = %6
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %16, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %17, align 4
  call void @_ZN10SimTKIpopt8SmartPtrIKNS_11MatrixSpaceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %111

35:                                               ; preds = %27
  br label %36

36:                                               ; preds = %35, %29
  %37 = phi ptr [ %30, %29 ], [ null, %35 ]
  call void @_ZN10SimTKIpopt8SmartPtrIKNS_11MatrixSpaceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  store ptr %37, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %38 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %38, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %107, %36
  %40 = load i32, ptr %19, align 4, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  %42 = call noundef i32 @_ZNK10SimTKIpopt17CompoundSymMatrix10NComps_DimEv(ptr noundef nonnull align 8 dereferenceable(137) %41)
  %43 = icmp slt i32 %40, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %39
  store i32 2, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %110

45:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %46 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %46, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  store i32 0, ptr %22, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %97, %45
  %48 = load i32, ptr %22, align 4, !tbaa !5
  %49 = load i32, ptr %19, align 4, !tbaa !5
  %50 = icmp sle i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  store i32 5, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  br label %101

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %53 = load ptr, ptr %8, align 8, !tbaa !9
  %54 = load i32, ptr %19, align 4, !tbaa !5
  %55 = load i32, ptr %22, align 4, !tbaa !5
  call void @_ZNK10SimTKIpopt17CompoundSymMatrix7GetCompEii(ptr dead_on_unwind writable sret(%"class.SimTKIpopt::SmartPtr.6") align 8 %23, ptr noundef nonnull align 8 dereferenceable(137) %53, i32 noundef %54, i32 noundef %55)
  %56 = invoke noundef zeroext i1 @_ZN10SimTKIpopt7IsValidIKNS_6MatrixEEEbRKNS_8SmartPtrIT_EE(ptr noundef nonnull align 8 dereferenceable(8) %23)
          to label %57 unwind label %82

57:                                               ; preds = %52
  br i1 %56, label %58, label %90

58:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  %59 = invoke noundef nonnull align 8 dereferenceable(69) ptr @_ZNK10SimTKIpopt8SmartPtrIKNS_6MatrixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %23)
          to label %60 unwind label %86

60:                                               ; preds = %58
  %61 = invoke noundef i32 @_ZN10SimTKIpopt13TripletHelper16GetNumberEntriesERKNS_6MatrixE(ptr noundef nonnull align 8 dereferenceable(69) %59)
          to label %62 unwind label %86

62:                                               ; preds = %60
  store i32 %61, ptr %24, align 4, !tbaa !5
  %63 = load i32, ptr %24, align 4, !tbaa !5
  %64 = load i32, ptr %13, align 4, !tbaa !5
  %65 = add nsw i32 %64, %63
  store i32 %65, ptr %13, align 4, !tbaa !5
  %66 = load i32, ptr %24, align 4, !tbaa !5
  %67 = invoke noundef nonnull align 8 dereferenceable(69) ptr @_ZNK10SimTKIpopt8SmartPtrIKNS_6MatrixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %23)
          to label %68 unwind label %86

68:                                               ; preds = %62
  %69 = load ptr, ptr %11, align 8, !tbaa !9
  %70 = load ptr, ptr %12, align 8, !tbaa !9
  %71 = load i32, ptr %18, align 4, !tbaa !5
  %72 = load i32, ptr %21, align 4, !tbaa !5
  invoke void @_ZN10SimTKIpopt13TripletHelper10FillRowColEiRKNS_6MatrixEPiS4_ii(i32 noundef %66, ptr noundef nonnull align 8 dereferenceable(69) %67, ptr noundef %69, ptr noundef %70, i32 noundef %71, i32 noundef %72)
          to label %73 unwind label %86

73:                                               ; preds = %68
  %74 = load i32, ptr %24, align 4, !tbaa !5
  %75 = load ptr, ptr %11, align 8, !tbaa !9
  %76 = sext i32 %74 to i64
  %77 = getelementptr inbounds i32, ptr %75, i64 %76
  store ptr %77, ptr %11, align 8, !tbaa !9
  %78 = load i32, ptr %24, align 4, !tbaa !5
  %79 = load ptr, ptr %12, align 8, !tbaa !9
  %80 = sext i32 %78 to i64
  %81 = getelementptr inbounds i32, ptr %79, i64 %80
  store ptr %81, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  br label %90

82:                                               ; preds = %90, %52
  %83 = landingpad { ptr, i32 }
          cleanup
  %84 = extractvalue { ptr, i32 } %83, 0
  store ptr %84, ptr %16, align 8
  %85 = extractvalue { ptr, i32 } %83, 1
  store i32 %85, ptr %17, align 4
  br label %100

86:                                               ; preds = %68, %62, %60, %58
  %87 = landingpad { ptr, i32 }
          cleanup
  %88 = extractvalue { ptr, i32 } %87, 0
  store ptr %88, ptr %16, align 8
  %89 = extractvalue { ptr, i32 } %87, 1
  store i32 %89, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  br label %100

90:                                               ; preds = %73, %57
  %91 = load ptr, ptr %14, align 8, !tbaa !9
  %92 = load i32, ptr %22, align 4, !tbaa !5
  %93 = invoke noundef i32 @_ZNK10SimTKIpopt22CompoundSymMatrixSpace11GetBlockDimEi(ptr noundef nonnull align 8 dereferenceable(97) %91, i32 noundef %92)
          to label %94 unwind label %82

94:                                               ; preds = %90
  %95 = load i32, ptr %21, align 4, !tbaa !5
  %96 = add nsw i32 %95, %93
  store i32 %96, ptr %21, align 4, !tbaa !5
  call void @_ZN10SimTKIpopt8SmartPtrIKNS_6MatrixEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  br label %97

97:                                               ; preds = %94
  %98 = load i32, ptr %22, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %22, align 4, !tbaa !5
  br label %47, !llvm.loop !11

100:                                              ; preds = %86, %82
  call void @_ZN10SimTKIpopt8SmartPtrIKNS_6MatrixEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %111

101:                                              ; preds = %51
  %102 = load ptr, ptr %14, align 8, !tbaa !9
  %103 = load i32, ptr %19, align 4, !tbaa !5
  %104 = call noundef i32 @_ZNK10SimTKIpopt22CompoundSymMatrixSpace11GetBlockDimEi(ptr noundef nonnull align 8 dereferenceable(97) %102, i32 noundef %103)
  %105 = load i32, ptr %18, align 4, !tbaa !5
  %106 = add nsw i32 %105, %104
  store i32 %106, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  br label %107

107:                                              ; preds = %101
  %108 = load i32, ptr %19, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %19, align 4, !tbaa !5
  br label %39, !llvm.loop !13

110:                                              ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  ret void

111:                                              ; preds = %100, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %112

112:                                              ; preds = %111
  %113 = load ptr, ptr %16, align 8
  %114 = load i32, ptr %17, align 4
  %115 = insertvalue { ptr, i32 } poison, ptr %113, 0
  %116 = insertvalue { ptr, i32 } %115, i32 %114, 1
  resume { ptr, i32 } %116
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(69) ptr @_ZNK10SimTKIpopt8SmartPtrIKNS_6MatrixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN10SimTKIpopt7IsValidIKNS_6MatrixEEEbRKNS_8SmartPtrIT_EE(ptr noundef nonnull align 8 dereferenceable(8)) #2

declare noundef i32 @_ZNK10SimTKIpopt17CompoundSymMatrix10NComps_DimEv(ptr noundef nonnull align 8 dereferenceable(137)) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK10SimTKIpopt17CompoundSymMatrix7GetCompEii(ptr dead_on_unwind noalias writable sret(%"class.SimTKIpopt::SmartPtr.6") align 8, ptr noundef nonnull align 8 dereferenceable(137), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN10SimTKIpopt9GetRawPtrIKNS_11MatrixSpaceEEEPT_RKNS_8SmartPtrIS3_EE(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK10SimTKIpopt6Matrix10OwnerSpaceEv(ptr dead_on_unwind noalias writable sret(%"class.SimTKIpopt::SmartPtr.5") align 8, ptr noundef nonnull align 8 dereferenceable(69)) #5 align 2

declare noundef i32 @_ZNK10SimTKIpopt22CompoundSymMatrixSpace11GetBlockDimEi(ptr noundef nonnull align 8 dereferenceable(97), i32 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { nounwind willreturn memory(read) }
attributes #4 = { "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 #5 = { inlinehint 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.SimTKIpopt::SmartPtr.5" = type { ptr }
%"class.SimTKIpopt::SmartPtr.6" = type { ptr }

@_ZTIN10SimTKIpopt11MatrixSpaceE = external constant ptr
@_ZTIN10SimTKIpopt22CompoundSymMatrixSpaceE = external dso_local constant { ptr, ptr, ptr }, align 8

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

declare i32 @__gxx_personality_v0(...)

; 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 dso_local void @_ZN10SimTKIpopt8SmartPtrIKNS_11MatrixSpaceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN10SimTKIpopt13TripletHelper16GetNumberEntriesERKNS_6MatrixE(ptr noundef nonnull align 8 dereferenceable(69)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10SimTKIpopt8SmartPtrIKNS_6MatrixEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10SimTKIpopt13TripletHelper10FillRowColEiRKNS_6MatrixEPiS4_ii(i32 noundef, ptr noundef nonnull align 8 dereferenceable(69), ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10SimTKIpopt13TripletHelper11FillRowCol_EiRKNS_17CompoundSymMatrixEiiPiS4_(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(137) %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca %"class.SimTKIpopt::SmartPtr.5", align 8
  %8 = alloca %"class.SimTKIpopt::SmartPtr.6", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  call void @_ZNK10SimTKIpopt6Matrix10OwnerSpaceEv(ptr dead_on_unwind nonnull writable sret(%"class.SimTKIpopt::SmartPtr.5") align 8 %7, ptr noundef nonnull align 8 dereferenceable(69) %1)
  %9 = call noundef ptr @_ZN10SimTKIpopt9GetRawPtrIKNS_11MatrixSpaceEEEPT_RKNS_8SmartPtrIS3_EE(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %10 = icmp eq ptr %9, null
  br i1 %10, label %13, label %11

11:                                               ; preds = %6
  %12 = call ptr @__dynamic_cast(ptr nonnull %9, ptr nonnull @_ZTIN10SimTKIpopt11MatrixSpaceE, ptr nonnull @_ZTIN10SimTKIpopt22CompoundSymMatrixSpaceE, i64 0) #6
  br label %13

13:                                               ; preds = %6, %11
  %14 = phi ptr [ %12, %11 ], [ null, %6 ]
  call void @_ZN10SimTKIpopt8SmartPtrIKNS_11MatrixSpaceEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  %15 = call noundef i32 @_ZNK10SimTKIpopt17CompoundSymMatrix10NComps_DimEv(ptr noundef nonnull align 8 dereferenceable(137) %1)
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.preheader, label %._crit_edge

.preheader:                                       ; preds = %13, %17
  %indvars.iv = phi i32 [ %indvars.iv.next, %17 ], [ 1, %13 ]
  %.059 = phi ptr [ %.2, %17 ], [ %4, %13 ]
  %.03258 = phi i32 [ %20, %17 ], [ 0, %13 ]
  %.03357 = phi i32 [ %19, %17 ], [ %2, %13 ]
  %.03656 = phi ptr [ %.238, %17 ], [ %5, %13 ]
  br label %23

._crit_edge:                                      ; preds = %17, %13
  ret void

17:                                               ; preds = %41
  %18 = call noundef i32 @_ZNK10SimTKIpopt22CompoundSymMatrixSpace11GetBlockDimEi(ptr noundef nonnull align 8 dereferenceable(97) %14, i32 noundef %.03258)
  %19 = add nsw i32 %18, %.03357
  %20 = add nuw nsw i32 %.03258, 1
  %21 = call noundef i32 @_ZNK10SimTKIpopt17CompoundSymMatrix10NComps_DimEv(ptr noundef nonnull align 8 dereferenceable(137) %1)
  %22 = icmp slt i32 %20, %21
  %indvars.iv.next = add nuw i32 %indvars.iv, 1
  br i1 %22, label %.preheader, label %._crit_edge, !llvm.loop !5

23:                                               ; preds = %.preheader, %41
  %.154 = phi ptr [ %.059, %.preheader ], [ %.2, %41 ]
  %.03053 = phi i32 [ 0, %.preheader ], [ %43, %41 ]
  %.03152 = phi i32 [ %3, %.preheader ], [ %42, %41 ]
  %.13751 = phi ptr [ %.03656, %.preheader ], [ %.238, %41 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  call void @_ZNK10SimTKIpopt17CompoundSymMatrix7GetCompEii(ptr dead_on_unwind nonnull writable sret(%"class.SimTKIpopt::SmartPtr.6") align 8 %8, ptr noundef nonnull align 8 dereferenceable(137) %1, i32 noundef %.03258, i32 noundef %.03053)
  %24 = invoke noundef zeroext i1 @_ZN10SimTKIpopt7IsValidIKNS_6MatrixEEEbRKNS_8SmartPtrIT_EE(ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %25 unwind label %35

25:                                               ; preds = %23
  br i1 %24, label %26, label %39

26:                                               ; preds = %25
  %27 = call noundef nonnull align 8 dereferenceable(69) ptr @_ZNK10SimTKIpopt8SmartPtrIKNS_6MatrixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %8)
  %28 = invoke noundef i32 @_ZN10SimTKIpopt13TripletHelper16GetNumberEntriesERKNS_6MatrixE(ptr noundef nonnull align 8 dereferenceable(69) %27)
          to label %29 unwind label %37

29:                                               ; preds = %26
  %30 = call noundef nonnull align 8 dereferenceable(69) ptr @_ZNK10SimTKIpopt8SmartPtrIKNS_6MatrixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %8)
  invoke void @_ZN10SimTKIpopt13TripletHelper10FillRowColEiRKNS_6MatrixEPiS4_ii(i32 noundef %28, ptr noundef nonnull align 8 dereferenceable(69) %30, ptr noundef %.154, ptr noundef %.13751, i32 noundef %.03357, i32 noundef %.03152)
          to label %31 unwind label %37

31:                                               ; preds = %29
  %32 = sext i32 %28 to i64
  %33 = getelementptr inbounds i32, ptr %.154, i64 %32
  %34 = getelementptr inbounds i32, ptr %.13751, i64 %32
  br label %39

35:                                               ; preds = %39, %23
  %36 = landingpad { ptr, i32 }
          cleanup
  br label %44

37:                                               ; preds = %29, %26
  %38 = landingpad { ptr, i32 }
          cleanup
  br label %44

39:                                               ; preds = %31, %25
  %.238 = phi ptr [ %34, %31 ], [ %.13751, %25 ]
  %.2 = phi ptr [ %33, %31 ], [ %.154, %25 ]
  %40 = invoke noundef i32 @_ZNK10SimTKIpopt22CompoundSymMatrixSpace11GetBlockDimEi(ptr noundef nonnull align 8 dereferenceable(97) %14, i32 noundef %.03053)
          to label %41 unwind label %35

41:                                               ; preds = %39
  %42 = add nsw i32 %40, %.03152
  call void @_ZN10SimTKIpopt8SmartPtrIKNS_6MatrixEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  %43 = add nuw nsw i32 %.03053, 1
  %exitcond.not = icmp eq i32 %43, %indvars.iv
  br i1 %exitcond.not, label %17, label %23, !llvm.loop !7

44:                                               ; preds = %37, %35
  %.pn = phi { ptr, i32 } [ %36, %35 ], [ %38, %37 ]
  call void @_ZN10SimTKIpopt8SmartPtrIKNS_6MatrixEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(69) ptr @_ZNK10SimTKIpopt8SmartPtrIKNS_6MatrixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN10SimTKIpopt7IsValidIKNS_6MatrixEEEbRKNS_8SmartPtrIT_EE(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

declare noundef i32 @_ZNK10SimTKIpopt17CompoundSymMatrix10NComps_DimEv(ptr noundef nonnull align 8 dereferenceable(137)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK10SimTKIpopt17CompoundSymMatrix7GetCompEii(ptr dead_on_unwind noalias writable sret(%"class.SimTKIpopt::SmartPtr.6") align 8, ptr noundef nonnull align 8 dereferenceable(137), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN10SimTKIpopt9GetRawPtrIKNS_11MatrixSpaceEEEPT_RKNS_8SmartPtrIS3_EE(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK10SimTKIpopt6Matrix10OwnerSpaceEv(ptr dead_on_unwind noalias writable sret(%"class.SimTKIpopt::SmartPtr.5") align 8, ptr noundef nonnull align 8 dereferenceable(69)) local_unnamed_addr #5 align 2

declare noundef i32 @_ZNK10SimTKIpopt22CompoundSymMatrixSpace11GetBlockDimEi(ptr noundef nonnull align 8 dereferenceable(97), i32 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 nofree nounwind willreturn memory(read) }
attributes #4 = { "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 #5 = { inlinehint 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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