; 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: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix20CompressedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

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

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

declare void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #5

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

19:                                               ; preds = %3
  %20 = call ptr @__dynamic_cast(ptr %17, ptr @_ZTIN10SimTKIpopt6VectorE, ptr @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #7
  br label %22

21:                                               ; preds = %3
  br label %22

22:                                               ; preds = %21, %19
  %23 = phi ptr [ %20, %19 ], [ null, %21 ]
  store ptr %23, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %16, i32 0, i32 46
  %25 = call noundef zeroext i1 @_ZN10SimTKIpopt7IsValidINS_15ExpansionMatrixEEEbRKNS_8SmartPtrIT_EE(ptr noundef nonnull align 8 dereferenceable(8) %24)
  br i1 %25, label %26, label %115

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %27 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %16, i32 0, i32 46
  %28 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %27)
  %29 = call noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix20CompressedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80) %28)
  store ptr %29, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %30)
  br i1 %31, label %32, label %71

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

35:                                               ; preds = %67, %32
  %36 = load i32, ptr %10, align 4, !tbaa !11
  %37 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %16, i32 0, i32 12
  %38 = load i32, ptr %37, align 8, !tbaa !13
  %39 = icmp slt i32 %36, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %70

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load i32, ptr %10, align 4, !tbaa !11
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %42, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !11
  store i32 %46, ptr %11, align 4, !tbaa !11
  %47 = load i32, ptr %11, align 4, !tbaa !11
  %48 = icmp ne i32 %47, -1
  br i1 %48, label %49, label %55

49:                                               ; preds = %41
  %50 = load double, ptr %9, align 8, !tbaa !9
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i32, ptr %10, align 4, !tbaa !11
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %51, i64 %53
  store double %50, ptr %54, align 8, !tbaa !9
  br label %66

55:                                               ; preds = %41
  %56 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %16, i32 0, i32 36
  %57 = load ptr, ptr %56, align 8, !tbaa !29
  %58 = load i32, ptr %10, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load i32, ptr %10, align 4, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %62, i64 %64
  store double %61, ptr %65, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %55, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %10, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %10, align 4, !tbaa !11
  br label %35, !llvm.loop !30

70:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %114

71:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %72)
  store ptr %73, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %74

74:                                               ; preds = %110, %71
  %75 = load i32, ptr %13, align 4, !tbaa !11
  %76 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %16, i32 0, i32 12
  %77 = load i32, ptr %76, align 8, !tbaa !13
  %78 = icmp slt i32 %75, %77
  br i1 %78, label %80, label %79

79:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %113

80:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = load i32, ptr %13, align 4, !tbaa !11
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i32, ptr %81, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !11
  store i32 %85, ptr %14, align 4, !tbaa !11
  %86 = load i32, ptr %14, align 4, !tbaa !11
  %87 = icmp ne i32 %86, -1
  br i1 %87, label %88, label %98

88:                                               ; preds = %80
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load i32, ptr %14, align 4, !tbaa !11
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds double, ptr %89, i64 %91
  %93 = load double, ptr %92, align 8, !tbaa !9
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = load i32, ptr %13, align 4, !tbaa !11
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds double, ptr %94, i64 %96
  store double %93, ptr %97, align 8, !tbaa !9
  br label %109

98:                                               ; preds = %80
  %99 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %16, i32 0, i32 36
  %100 = load ptr, ptr %99, align 8, !tbaa !29
  %101 = load i32, ptr %13, align 4, !tbaa !11
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds double, ptr %100, i64 %102
  %104 = load double, ptr %103, align 8, !tbaa !9
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = load i32, ptr %13, align 4, !tbaa !11
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds double, ptr %105, i64 %107
  store double %104, ptr %108, align 8, !tbaa !9
  br label %109

109:                                              ; preds = %98, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %110

110:                                              ; preds = %109
  %111 = load i32, ptr %13, align 4, !tbaa !11
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %13, align 4, !tbaa !11
  br label %74, !llvm.loop !32

113:                                              ; preds = %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %114

114:                                              ; preds = %113, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %131

115:                                              ; preds = %22
  %116 = load ptr, ptr %7, align 8, !tbaa !5
  %117 = call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %116)
  br i1 %117, label %118, label %124

118:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %119)
  store double %120, ptr %15, align 8, !tbaa !9
  %121 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %16, i32 0, i32 12
  %122 = load i32, ptr %121, align 8, !tbaa !13
  %123 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef %122, ptr noundef %15, i32 noundef 0, ptr noundef %123, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %130

124:                                              ; preds = %115
  %125 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %16, i32 0, i32 12
  %126 = load i32, ptr %125, align 8, !tbaa !13
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %127)
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef %126, ptr noundef %128, i32 noundef 1, ptr noundef %129, i32 noundef 1)
  br label %130

130:                                              ; preds = %124, %118
  br label %131

131:                                              ; preds = %130, %114
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240)) #6 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 = { 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 = { nounwind willreturn memory(read) }
attributes #5 = { "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 = { 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 #7 = { 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 = !{!14, !12, i64 80}
!14 = !{!"_ZTSN10SimTKIpopt11TNLPAdapterE", !15, i64 0, !17, i64 16, !18, i64 24, !10, i64 32, !10, i64 40, !19, i64 48, !20, i64 52, !10, i64 56, !10, i64 64, !21, i64 72, !21, i64 73, !22, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !23, i64 116, !24, i64 120, !24, i64 128, !24, i64 136, !24, i64 144, !25, i64 152, !24, i64 160, !25, i64 168, !24, i64 176, !25, i64 184, !24, i64 192, !25, i64 200, !25, i64 208, !25, i64 216, !26, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !12, i64 272, !12, i64 276, !12, i64 280, !12, i64 284, !12, i64 288, !27, i64 296, !28, i64 304, !27, i64 312, !28, i64 320, !27, i64 328, !28, i64 336, !28, i64 344, !27, i64 352, !28, i64 360, !27, i64 368, !6, i64 376, !6, i64 384, !6, i64 392}
!15 = !{!"_ZTSN10SimTKIpopt3NLPE", !16, i64 0}
!16 = !{!"_ZTSN10SimTKIpopt16ReferencedObjectE", !12, i64 8}
!17 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_4TNLPEEE", !6, i64 0}
!18 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_10JournalistEEE", !6, i64 0}
!19 = !{!"_ZTSN10SimTKIpopt11TNLPAdapter26FixedVariableTreatmentEnumE", !7, i64 0}
!20 = !{!"_ZTSN10SimTKIpopt11TNLPAdapter18DerivativeTestEnumE", !7, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{!"_ZTSN10SimTKIpopt24HessianApproximationTypeE", !7, i64 0}
!23 = !{!"_ZTSN10SimTKIpopt4TNLP14IndexStyleEnumE", !7, i64 0}
!24 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_11VectorSpaceEEE", !6, i64 0}
!25 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_11MatrixSpaceEEE", !6, i64 0}
!26 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_14SymMatrixSpaceEEE", !6, i64 0}
!27 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEE", !6, i64 0}
!28 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_20ExpansionMatrixSpaceEEE", !6, i64 0}
!29 = !{!14, !6, i64 232}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = distinct !{!32, !31}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

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

declare void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10SimTKIpopt11TNLPAdapter7ResortXERKNS_6VectorEPd(ptr noundef nonnull align 8 dereferenceable(400) %0, ptr noundef nonnull align 8 dereferenceable(205) %1, ptr noundef %2) local_unnamed_addr #3 align 2 {
  %4 = alloca double, align 8
  %5 = tail call ptr @__dynamic_cast(ptr nonnull %1, ptr nonnull @_ZTIN10SimTKIpopt6VectorE, ptr nonnull @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #7
  %6 = getelementptr inbounds i8, ptr %0, i64 296
  %7 = tail call noundef zeroext i1 @_ZN10SimTKIpopt7IsValidINS_15ExpansionMatrixEEEbRKNS_8SmartPtrIT_EE(ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %7, label %8, label %55

8:                                                ; preds = %3
  %9 = tail call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %10 = tail call noundef ptr @_ZNK10SimTKIpopt15ExpansionMatrix20CompressedPosIndicesEv(ptr noundef nonnull align 8 dereferenceable(80) %9)
  %11 = tail call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  %12 = getelementptr inbounds i8, ptr %0, i64 80
  br i1 %11, label %13, label %35

13:                                               ; preds = %8
  %14 = tail call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  %15 = load i32, ptr %12, align 8, !tbaa !5
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph38, label %.loopexit

.lr.ph38:                                         ; preds = %13
  %17 = getelementptr inbounds i8, ptr %0, i64 232
  %18 = load ptr, ptr %17, align 8
  %wide.trip.count44 = zext nneg i32 %15 to i64
  %xtraiter51 = and i64 %wide.trip.count44, 1
  %19 = icmp eq i32 %15, 1
  br i1 %19, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph38.new

.lr.ph38.new:                                     ; preds = %.lr.ph38
  %unroll_iter53 = and i64 %wide.trip.count44, 2147483646
  br label %20

20:                                               ; preds = %33, %.lr.ph38.new
  %indvars.iv41 = phi i64 [ 0, %.lr.ph38.new ], [ %indvars.iv.next42.1, %33 ]
  %niter54 = phi i64 [ 0, %.lr.ph38.new ], [ %niter54.next.1, %33 ]
  %21 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv41
  %22 = load i32, ptr %21, align 4, !tbaa !26
  %.not34 = icmp eq i32 %22, -1
  br i1 %.not34, label %23, label %26

23:                                               ; preds = %20
  %24 = getelementptr inbounds double, ptr %18, i64 %indvars.iv41
  %25 = load double, ptr %24, align 8, !tbaa !27
  br label %26

26:                                               ; preds = %20, %23
  %.sink = phi double [ %25, %23 ], [ %14, %20 ]
  %27 = getelementptr inbounds double, ptr %2, i64 %indvars.iv41
  store double %.sink, ptr %27, align 8
  %indvars.iv.next42 = or disjoint i64 %indvars.iv41, 1
  %28 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv.next42
  %29 = load i32, ptr %28, align 4, !tbaa !26
  %.not34.1 = icmp eq i32 %29, -1
  br i1 %.not34.1, label %30, label %33

30:                                               ; preds = %26
  %31 = getelementptr inbounds double, ptr %18, i64 %indvars.iv.next42
  %32 = load double, ptr %31, align 8, !tbaa !27
  br label %33

33:                                               ; preds = %30, %26
  %.sink.1 = phi double [ %32, %30 ], [ %14, %26 ]
  %34 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next42
  store double %.sink.1, ptr %34, align 8
  %indvars.iv.next42.1 = add nuw nsw i64 %indvars.iv41, 2
  %niter54.next.1 = add i64 %niter54, 2
  %niter54.ncmp.1 = icmp eq i64 %niter54.next.1, %unroll_iter53
  br i1 %niter54.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %20, !llvm.loop !28

35:                                               ; preds = %8
  %36 = tail call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  %37 = load i32, ptr %12, align 8, !tbaa !5
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %35
  %39 = getelementptr inbounds i8, ptr %0, i64 232
  %40 = load ptr, ptr %39, align 8
  %wide.trip.count = zext nneg i32 %37 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %41 = icmp eq i32 %37, 1
  br i1 %41, label %.loopexit.loopexit49.unr-lcssa, label %.lr.ph.new

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

42:                                               ; preds = %42, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %42 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %42 ]
  %43 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv
  %44 = load i32, ptr %43, align 4, !tbaa !26
  %.not = icmp eq i32 %44, -1
  %45 = getelementptr inbounds double, ptr %40, i64 %indvars.iv
  %46 = sext i32 %44 to i64
  %47 = getelementptr inbounds double, ptr %36, i64 %46
  %.sink46.in = select i1 %.not, ptr %45, ptr %47
  %.sink46 = load double, ptr %.sink46.in, align 8, !tbaa !27
  %48 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double %.sink46, ptr %48, align 8
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %49 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv.next
  %50 = load i32, ptr %49, align 4, !tbaa !26
  %.not.1 = icmp eq i32 %50, -1
  %51 = getelementptr inbounds double, ptr %40, i64 %indvars.iv.next
  %52 = sext i32 %50 to i64
  %53 = getelementptr inbounds double, ptr %36, i64 %52
  %.sink46.in.1 = select i1 %.not.1, ptr %51, ptr %53
  %.sink46.1 = load double, ptr %.sink46.in.1, align 8, !tbaa !27
  %54 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next
  store double %.sink46.1, ptr %54, align 8
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.loopexit.loopexit49.unr-lcssa, label %42, !llvm.loop !30

55:                                               ; preds = %3
  %56 = tail call noundef zeroext i1 @_ZNK10SimTKIpopt11DenseVector13IsHomogeneousEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  br i1 %56, label %57, label %61

57:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %58 = tail call noundef double @_ZNK10SimTKIpopt11DenseVector6ScalarEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  store double %58, ptr %4, align 8, !tbaa !27
  %59 = getelementptr inbounds i8, ptr %0, i64 80
  %60 = load i32, ptr %59, align 8, !tbaa !5
  call void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef %60, ptr noundef nonnull %4, i32 noundef 0, ptr noundef %2, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %.loopexit

61:                                               ; preds = %55
  %62 = getelementptr inbounds i8, ptr %0, i64 80
  %63 = load i32, ptr %62, align 8, !tbaa !5
  %64 = tail call noundef ptr @_ZNK10SimTKIpopt11DenseVector6ValuesEv(ptr noundef nonnull align 8 dereferenceable(240) %5)
  tail call void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef %63, ptr noundef %64, i32 noundef 1, ptr noundef %2, i32 noundef 1)
  br label %.loopexit

.loopexit.loopexit.unr-lcssa:                     ; preds = %33, %.lr.ph38
  %indvars.iv41.unr = phi i64 [ 0, %.lr.ph38 ], [ %indvars.iv.next42.1, %33 ]
  %lcmp.mod52.not = icmp eq i64 %xtraiter51, 0
  br i1 %lcmp.mod52.not, label %.loopexit, label %.epil.preheader50

.epil.preheader50:                                ; preds = %.loopexit.loopexit.unr-lcssa
  %65 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv41.unr
  %66 = load i32, ptr %65, align 4, !tbaa !26
  %.not34.epil = icmp eq i32 %66, -1
  br i1 %.not34.epil, label %67, label %.loopexit.loopexit.epilog-lcssa

67:                                               ; preds = %.epil.preheader50
  %68 = getelementptr inbounds double, ptr %18, i64 %indvars.iv41.unr
  %69 = load double, ptr %68, align 8, !tbaa !27
  br label %.loopexit.loopexit.epilog-lcssa

.loopexit.loopexit.epilog-lcssa:                  ; preds = %67, %.epil.preheader50
  %.sink.epil = phi double [ %69, %67 ], [ %14, %.epil.preheader50 ]
  %70 = getelementptr inbounds double, ptr %2, i64 %indvars.iv41.unr
  store double %.sink.epil, ptr %70, align 8
  br label %.loopexit

.loopexit.loopexit49.unr-lcssa:                   ; preds = %42, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %42 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.loopexit.loopexit49.epilog-lcssa

.loopexit.loopexit49.epilog-lcssa:                ; preds = %.loopexit.loopexit49.unr-lcssa
  %71 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv.unr
  %72 = load i32, ptr %71, align 4, !tbaa !26
  %.not.epil = icmp eq i32 %72, -1
  %73 = getelementptr inbounds double, ptr %40, i64 %indvars.iv.unr
  %74 = sext i32 %72 to i64
  %75 = getelementptr inbounds double, ptr %36, i64 %74
  %.sink46.in.epil = select i1 %.not.epil, ptr %73, ptr %75
  %.sink46.epil = load double, ptr %.sink46.in.epil, align 8, !tbaa !27
  %76 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.unr
  store double %.sink46.epil, ptr %76, align 8
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit49.epilog-lcssa, %.loopexit.loopexit49.unr-lcssa, %.loopexit.loopexit.epilog-lcssa, %.loopexit.loopexit.unr-lcssa, %35, %13, %57, %61
  ret void
}

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

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

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

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 = { 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 = { mustprogress nofree nounwind willreturn memory(read) }
attributes #5 = { "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 = { 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 #7 = { 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, !9, i64 80}
!6 = !{!"_ZTSN10SimTKIpopt11TNLPAdapterE", !7, i64 0, !12, i64 16, !14, i64 24, !15, i64 32, !15, i64 40, !16, i64 48, !17, i64 52, !15, i64 56, !15, i64 64, !18, i64 72, !18, i64 73, !19, i64 76, !9, i64 80, !9, i64 84, !9, i64 88, !9, i64 92, !9, i64 96, !9, i64 100, !9, i64 104, !9, i64 108, !9, i64 112, !20, i64 116, !21, i64 120, !21, i64 128, !21, i64 136, !21, i64 144, !22, i64 152, !21, i64 160, !22, i64 168, !21, i64 176, !22, i64 184, !21, i64 192, !22, i64 200, !22, i64 208, !22, i64 216, !23, i64 224, !13, i64 232, !13, i64 240, !13, i64 248, !13, i64 256, !13, i64 264, !9, i64 272, !9, i64 276, !9, i64 280, !9, i64 284, !9, i64 288, !24, i64 296, !25, i64 304, !24, i64 312, !25, i64 320, !24, i64 328, !25, i64 336, !25, i64 344, !24, i64 352, !25, i64 360, !24, i64 368, !13, i64 376, !13, i64 384, !13, i64 392}
!7 = !{!"_ZTSN10SimTKIpopt3NLPE", !8, i64 0}
!8 = !{!"_ZTSN10SimTKIpopt16ReferencedObjectE", !9, i64 8}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_4TNLPEEE", !13, i64 0}
!13 = !{!"any pointer", !10, i64 0}
!14 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_10JournalistEEE", !13, i64 0}
!15 = !{!"double", !10, i64 0}
!16 = !{!"_ZTSN10SimTKIpopt11TNLPAdapter26FixedVariableTreatmentEnumE", !10, i64 0}
!17 = !{!"_ZTSN10SimTKIpopt11TNLPAdapter18DerivativeTestEnumE", !10, i64 0}
!18 = !{!"bool", !10, i64 0}
!19 = !{!"_ZTSN10SimTKIpopt24HessianApproximationTypeE", !10, i64 0}
!20 = !{!"_ZTSN10SimTKIpopt4TNLP14IndexStyleEnumE", !10, i64 0}
!21 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_11VectorSpaceEEE", !13, i64 0}
!22 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_11MatrixSpaceEEE", !13, i64 0}
!23 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_14SymMatrixSpaceEEE", !13, i64 0}
!24 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEE", !13, i64 0}
!25 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_20ExpansionMatrixSpaceEEE", !13, i64 0}
!26 = !{!9, !9, i64 0}
!27 = !{!15, !15, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}


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