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

; 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::TNLPAdapter" = type { %"class.SimTKIpopt::NLP.base", %"class.SimTKIpopt::SmartPtr.6", %"class.SimTKIpopt::SmartPtr.7", double, double, i32, i32, double, double, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %"class.SimTKIpopt::SmartPtr", %"class.SimTKIpopt::SmartPtr", %"class.SimTKIpopt::SmartPtr", %"class.SimTKIpopt::SmartPtr", %"class.SimTKIpopt::SmartPtr.5", %"class.SimTKIpopt::SmartPtr", %"class.SimTKIpopt::SmartPtr.5", %"class.SimTKIpopt::SmartPtr", %"class.SimTKIpopt::SmartPtr.5", %"class.SimTKIpopt::SmartPtr", %"class.SimTKIpopt::SmartPtr.5", %"class.SimTKIpopt::SmartPtr.5", %"class.SimTKIpopt::SmartPtr.5", %"class.SimTKIpopt::SmartPtr.8", ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, %"class.SimTKIpopt::SmartPtr.9", %"class.SimTKIpopt::SmartPtr.10", %"class.SimTKIpopt::SmartPtr.9", %"class.SimTKIpopt::SmartPtr.10", %"class.SimTKIpopt::SmartPtr.9", %"class.SimTKIpopt::SmartPtr.10", %"class.SimTKIpopt::SmartPtr.10", %"class.SimTKIpopt::SmartPtr.9", %"class.SimTKIpopt::SmartPtr.10", %"class.SimTKIpopt::SmartPtr.9", ptr, ptr, ptr }
%"class.SimTKIpopt::NLP.base" = type { %"class.SimTKIpopt::ReferencedObject.base" }
%"class.SimTKIpopt::ReferencedObject.base" = type <{ ptr, i32 }>
%"class.SimTKIpopt::SmartPtr.6" = type { ptr }
%"class.SimTKIpopt::SmartPtr.7" = type { ptr }
%"class.SimTKIpopt::SmartPtr" = type { ptr }
%"class.SimTKIpopt::SmartPtr.5" = type { ptr }
%"class.SimTKIpopt::SmartPtr.8" = type { ptr }
%"class.SimTKIpopt::SmartPtr.10" = type { ptr }
%"class.SimTKIpopt::SmartPtr.9" = type { ptr }

@_ZTIN10SimTKIpopt6VectorE = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTIN10SimTKIpopt11DenseVectorE = external constant ptr

; 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10SimTKIpopt11TNLPAdapter7ResortGERKNS_6VectorES3_Pd(ptr noundef nonnull align 8 dereferenceable(400) %0, ptr noundef nonnull align 8 dereferenceable(205) %1, ptr noundef nonnull align 8 dereferenceable(205) %2, ptr noundef %3) #4 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca double, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %26, label %24

24:                                               ; preds = %4
  %25 = call ptr @__dynamic_cast(ptr %22, ptr @_ZTIN10SimTKIpopt6VectorE, ptr @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #6
  br label %27

26:                                               ; preds = %4
  br label %27

27:                                               ; preds = %26, %24
  %28 = phi ptr [ %25, %24 ], [ null, %26 ]
  store ptr %28, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %29 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %21, i32 0, i32 53
  %30 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %29)
  %31 = call noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80) %30)
  store ptr %31, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %32)
  br i1 %33, label %34, label %58

34:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %35)
  store double %36, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %37

37:                                               ; preds = %54, %34
  %38 = load i32, ptr %12, align 4, !tbaa !11
  %39 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %21, i32 0, i32 53
  %40 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %39)
  %41 = call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %40)
  %42 = icmp slt i32 %38, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %57

44:                                               ; preds = %37
  %45 = load double, ptr %11, align 8, !tbaa !9
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds double, ptr %46, i64 %52
  store double %45, ptr %53, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %44
  %55 = load i32, ptr %12, align 4, !tbaa !11
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %12, align 4, !tbaa !11
  br label %37, !llvm.loop !13

57:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %86

58:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %59)
  store ptr %60, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !11
  br label %61

61:                                               ; preds = %82, %58
  %62 = load i32, ptr %14, align 4, !tbaa !11
  %63 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %21, i32 0, i32 53
  %64 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %63)
  %65 = call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %64)
  %66 = icmp slt i32 %62, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %85

68:                                               ; preds = %61
  %69 = load ptr, ptr %13, align 8, !tbaa !5
  %70 = load i32, ptr %14, align 4, !tbaa !11
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds double, ptr %69, i64 %71
  %73 = load double, ptr %72, align 8, !tbaa !9
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = load i32, ptr %14, align 4, !tbaa !11
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr %75, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !11
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds double, ptr %74, i64 %80
  store double %73, ptr %81, align 8, !tbaa !9
  br label %82

82:                                               ; preds = %68
  %83 = load i32, ptr %14, align 4, !tbaa !11
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %14, align 4, !tbaa !11
  br label %61, !llvm.loop !15

85:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %86

86:                                               ; preds = %85, %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = icmp eq ptr %87, null
  br i1 %88, label %91, label %89

89:                                               ; preds = %86
  %90 = call ptr @__dynamic_cast(ptr %87, ptr @_ZTIN10SimTKIpopt6VectorE, ptr @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #6
  br label %92

91:                                               ; preds = %86
  br label %92

92:                                               ; preds = %91, %89
  %93 = phi ptr [ %90, %89 ], [ null, %91 ]
  store ptr %93, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %94 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %21, i32 0, i32 55
  %95 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %94)
  %96 = call noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80) %95)
  store ptr %96, ptr %16, align 8, !tbaa !5
  %97 = load ptr, ptr %15, align 8, !tbaa !5
  %98 = call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %97)
  br i1 %98, label %99, label %122

99:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %100 = load ptr, ptr %15, align 8, !tbaa !5
  %101 = call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %100)
  store double %101, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 0, ptr %18, align 4, !tbaa !11
  br label %102

102:                                              ; preds = %118, %99
  %103 = load i32, ptr %18, align 4, !tbaa !11
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %104)
  %106 = icmp slt i32 %103, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %102
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %121

108:                                              ; preds = %102
  %109 = load double, ptr %17, align 8, !tbaa !9
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = load ptr, ptr %16, align 8, !tbaa !5
  %112 = load i32, ptr %18, align 4, !tbaa !11
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds i32, ptr %111, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !11
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds double, ptr %110, i64 %116
  store double %109, ptr %117, align 8, !tbaa !9
  br label %118

118:                                              ; preds = %108
  %119 = load i32, ptr %18, align 4, !tbaa !11
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %18, align 4, !tbaa !11
  br label %102, !llvm.loop !16

121:                                              ; preds = %107
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %149

122:                                              ; preds = %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %123 = load ptr, ptr %15, align 8, !tbaa !5
  %124 = call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %123)
  store ptr %124, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 0, ptr %20, align 4, !tbaa !11
  br label %125

125:                                              ; preds = %145, %122
  %126 = load i32, ptr %20, align 4, !tbaa !11
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %127)
  %129 = icmp slt i32 %126, %128
  br i1 %129, label %131, label %130

130:                                              ; preds = %125
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %148

131:                                              ; preds = %125
  %132 = load ptr, ptr %19, align 8, !tbaa !5
  %133 = load i32, ptr %20, align 4, !tbaa !11
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds double, ptr %132, i64 %134
  %136 = load double, ptr %135, align 8, !tbaa !9
  %137 = load ptr, ptr %8, align 8, !tbaa !5
  %138 = load ptr, ptr %16, align 8, !tbaa !5
  %139 = load i32, ptr %20, align 4, !tbaa !11
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds i32, ptr %138, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !11
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds double, ptr %137, i64 %143
  store double %136, ptr %144, align 8, !tbaa !9
  br label %145

145:                                              ; preds = %131
  %146 = load i32, ptr %20, align 4, !tbaa !11
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %20, align 4, !tbaa !11
  br label %125, !llvm.loop !17

148:                                              ; preds = %130
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %149

149:                                              ; preds = %148, %121
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240)) #5 align 2

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

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

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 = { nounwind willreturn memory(read) }
attributes #3 = { 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 #4 = { 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 #5 = { inlinehint 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 #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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}


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

@_ZTIN10SimTKIpopt6VectorE = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTIN10SimTKIpopt11DenseVectorE = external constant ptr

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10SimTKIpopt11TNLPAdapter7ResortGERKNS_6VectorES3_Pd(ptr noundef nonnull align 8 dereferenceable(400) %0, ptr noundef nonnull align 8 dereferenceable(205) %1, ptr noundef nonnull align 8 dereferenceable(205) %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #3 align 2 {
  %5 = tail call ptr @__dynamic_cast(ptr nonnull %1, ptr nonnull @_ZTIN10SimTKIpopt6VectorE, ptr nonnull @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #5
  %6 = getelementptr inbounds i8, ptr %0, i64 352
  %7 = tail call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %8 = tail call noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80) %7)
  %9 = tail call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  br i1 %9, label %10, label %23

10:                                               ; preds = %4
  %11 = tail call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  %12 = tail call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %13 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %12)
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph44, label %.loopexit40

.lr.ph44:                                         ; preds = %10, %.lr.ph44
  %indvars.iv52 = phi i64 [ %indvars.iv.next53, %.lr.ph44 ], [ 0, %10 ]
  %15 = getelementptr inbounds i32, ptr %8, i64 %indvars.iv52
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds double, ptr %3, i64 %17
  store double %11, ptr %18, align 8, !tbaa !9
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %19 = tail call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %20 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %19)
  %21 = sext i32 %20 to i64
  %22 = icmp slt i64 %indvars.iv.next53, %21
  br i1 %22, label %.lr.ph44, label %.loopexit40, !llvm.loop !11

23:                                               ; preds = %4
  %24 = tail call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  %25 = tail call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %26 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %25)
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.lr.ph, label %.loopexit40

.lr.ph:                                           ; preds = %23, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %23 ]
  %28 = getelementptr inbounds double, ptr %24, i64 %indvars.iv
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds i32, ptr %8, i64 %indvars.iv
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds double, ptr %3, i64 %32
  store double %29, ptr %33, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = tail call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %35 = tail call noundef i32 @_ZNK10SimTKIpopt6Matrix5NColsEv(ptr noundef nonnull align 8 dereferenceable(69) %34)
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv.next, %36
  br i1 %37, label %.lr.ph, label %.loopexit40, !llvm.loop !13

.loopexit40:                                      ; preds = %.lr.ph, %.lr.ph44, %23, %10
  %38 = tail call ptr @__dynamic_cast(ptr nonnull %2, ptr nonnull @_ZTIN10SimTKIpopt6VectorE, ptr nonnull @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #5
  %39 = getelementptr inbounds i8, ptr %0, i64 368
  %40 = tail call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %39)
  %41 = tail call noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix18ExpandedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80) %40)
  %42 = tail call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %38)
  br i1 %42, label %43, label %54

43:                                               ; preds = %.loopexit40
  %44 = tail call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %38)
  %45 = tail call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %2)
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %.lr.ph48, label %.loopexit

.lr.ph48:                                         ; preds = %43, %.lr.ph48
  %indvars.iv58 = phi i64 [ %indvars.iv.next59, %.lr.ph48 ], [ 0, %43 ]
  %47 = getelementptr inbounds i32, ptr %41, i64 %indvars.iv58
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds double, ptr %3, i64 %49
  store double %44, ptr %50, align 8, !tbaa !9
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %51 = tail call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %2)
  %52 = sext i32 %51 to i64
  %53 = icmp slt i64 %indvars.iv.next59, %52
  br i1 %53, label %.lr.ph48, label %.loopexit, !llvm.loop !14

54:                                               ; preds = %.loopexit40
  %55 = tail call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %38)
  %56 = tail call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %2)
  %57 = icmp sgt i32 %56, 0
  br i1 %57, label %.lr.ph46, label %.loopexit

.lr.ph46:                                         ; preds = %54, %.lr.ph46
  %indvars.iv55 = phi i64 [ %indvars.iv.next56, %.lr.ph46 ], [ 0, %54 ]
  %58 = getelementptr inbounds double, ptr %55, i64 %indvars.iv55
  %59 = load double, ptr %58, align 8, !tbaa !9
  %60 = getelementptr inbounds i32, ptr %41, i64 %indvars.iv55
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds double, ptr %3, i64 %62
  store double %59, ptr %63, align 8, !tbaa !9
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %64 = tail call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %2)
  %65 = sext i32 %64 to i64
  %66 = icmp slt i64 %indvars.iv.next56, %65
  br i1 %66, label %.lr.ph46, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph46, %.lr.ph48, %54, %43
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240)) local_unnamed_addr #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240)) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(read) }
attributes #2 = { 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 #3 = { 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 #4 = { inlinehint 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass