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

; 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::DenseVector" = type { %"class.SimTKIpopt::Vector.base", ptr, ptr, i8, i8, double }
%"class.SimTKIpopt::Vector.base" = type <{ %"class.SimTKIpopt::TaggedObject", %"class.SimTKIpopt::SmartPtr", %"class.SimTKIpopt::CachedResults", i32, [4 x i8], double, i32, [4 x i8], double, i32, [4 x i8], double, i32, [4 x i8], double, i32, [4 x i8], double, i32, [4 x i8], double, i32, [4 x i8], double, i32, i8 }>
%"class.SimTKIpopt::TaggedObject" = type { %"class.SimTKIpopt::ReferencedObject.base", %"class.SimTKIpopt::Subject", i32, i32 }
%"class.SimTKIpopt::ReferencedObject.base" = type <{ ptr, i32 }>
%"class.SimTKIpopt::Subject" = type { ptr, %"class.std::vector.0" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<SimTKIpopt::Observer *, std::allocator<SimTKIpopt::Observer *>>::_Vector_impl" }
%"struct.std::_Vector_base<SimTKIpopt::Observer *, std::allocator<SimTKIpopt::Observer *>>::_Vector_impl" = type { %"struct.std::_Vector_base<SimTKIpopt::Observer *, std::allocator<SimTKIpopt::Observer *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<SimTKIpopt::Observer *, std::allocator<SimTKIpopt::Observer *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.SimTKIpopt::SmartPtr" = type { ptr }
%"class.SimTKIpopt::CachedResults" = type { ptr, i32, ptr }

@_ZTIN10SimTKIpopt6VectorE = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTIN10SimTKIpopt11DenseVectorE = 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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10SimTKIpopt12TaggedObject13ObjectChangedEv(ptr noundef nonnull align 8 dereferenceable(56)) #3 align 2

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

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

15:                                               ; preds = %3
  %16 = call ptr @__dynamic_cast(ptr %13, ptr @_ZTIN10SimTKIpopt6VectorE, ptr @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #5
  br label %18

17:                                               ; preds = %3
  br label %18

18:                                               ; preds = %17, %15
  %19 = phi ptr [ %16, %15 ], [ null, %17 ]
  store ptr %19, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %20 = call noundef ptr @_ZN10SimTKIpopt11DenseVector16values_allocatedEv(ptr noundef nonnull align 8 dereferenceable(240) %10)
  store ptr %20, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %10, i32 0, i32 4
  store i8 0, ptr %21, align 1, !tbaa !11
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %22, i32 0, i32 4
  %24 = load i8, ptr %23, align 1, !tbaa !11, !range !25, !noundef !26
  %25 = trunc i8 %24 to i1
  br i1 %25, label %26, label %33

26:                                               ; preds = %18
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %10, i32 0, i32 5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds double, ptr %29, i64 %31
  call void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef %27, ptr noundef %28, i32 noundef 1, ptr noundef %32, i32 noundef 1)
  br label %42

33:                                               ; preds = %18
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !27
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds double, ptr %38, i64 %40
  call void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef %34, ptr noundef %37, i32 noundef 1, ptr noundef %41, i32 noundef 1)
  br label %42

42:                                               ; preds = %33, %26
  %43 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %10, i32 0, i32 3
  store i8 1, ptr %43, align 8, !tbaa !28
  call void @_ZN10SimTKIpopt12TaggedObject13ObjectChangedEv(ptr noundef nonnull align 8 dereferenceable(56) %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !24, i64 225}
!12 = !{!"_ZTSN10SimTKIpopt11DenseVectorE", !13, i64 0, !6, i64 208, !6, i64 216, !24, i64 224, !24, i64 225, !23, i64 232}
!13 = !{!"_ZTSN10SimTKIpopt6VectorE", !14, i64 0, !21, i64 56, !22, i64 64, !10, i64 88, !23, i64 96, !10, i64 104, !23, i64 112, !10, i64 120, !23, i64 128, !10, i64 136, !23, i64 144, !10, i64 152, !23, i64 160, !10, i64 168, !23, i64 176, !10, i64 184, !23, i64 192, !10, i64 200, !24, i64 204}
!14 = !{!"_ZTSN10SimTKIpopt12TaggedObjectE", !15, i64 0, !16, i64 16, !10, i64 48, !10, i64 52}
!15 = !{!"_ZTSN10SimTKIpopt16ReferencedObjectE", !10, i64 8}
!16 = !{!"_ZTSN10SimTKIpopt7SubjectE", !17, i64 8}
!17 = !{!"_ZTSSt6vectorIPN10SimTKIpopt8ObserverESaIS2_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIPN10SimTKIpopt8ObserverESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIPN10SimTKIpopt8ObserverESaIS2_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIPN10SimTKIpopt8ObserverESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_11VectorSpaceEEE", !6, i64 0}
!22 = !{!"_ZTSN10SimTKIpopt13CachedResultsIdEE", !10, i64 8, !6, i64 16}
!23 = !{!"double", !7, i64 0}
!24 = !{!"bool", !7, i64 0}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!12, !6, i64 216}
!28 = !{!12, !24, i64 224}


; 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 dso_local constant { ptr, ptr, ptr }, align 8

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10SimTKIpopt12TaggedObject13ObjectChangedEv(ptr noundef nonnull align 8 dereferenceable(56)) 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 uwtable
define dso_local void @_ZN10SimTKIpopt11DenseVector9CopyToPosEiRKNS_6VectorE(ptr noundef nonnull align 8 dereferenceable(240) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(205) %2) local_unnamed_addr #2 align 2 {
  %4 = tail call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %2)
  %5 = tail call ptr @__dynamic_cast(ptr nonnull %2, ptr nonnull @_ZTIN10SimTKIpopt6VectorE, ptr nonnull @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #4
  %6 = tail call noundef ptr @_ZN10SimTKIpopt11DenseVector16values_allocatedEv(ptr noundef nonnull align 8 dereferenceable(240) %0)
  %7 = getelementptr inbounds i8, ptr %0, i64 225
  store i8 0, ptr %7, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %5, i64 225
  %9 = load i8, ptr %8, align 1, !tbaa !5, !range !23, !noundef !24
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %11, label %15

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %0, i64 232
  %13 = sext i32 %1 to i64
  %14 = getelementptr inbounds double, ptr %6, i64 %13
  tail call void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef %4, ptr noundef nonnull %12, i32 noundef 1, ptr noundef %14, i32 noundef 1)
  br label %20

15:                                               ; preds = %3
  %16 = getelementptr inbounds i8, ptr %5, i64 216
  %17 = load ptr, ptr %16, align 8, !tbaa !25
  %18 = sext i32 %1 to i64
  %19 = getelementptr inbounds double, ptr %6, i64 %18
  tail call void @_ZN10SimTKIpopt11IpBlasDcopyEiPKdiPdi(i32 noundef %4, ptr noundef %17, i32 noundef 1, ptr noundef %19, i32 noundef 1)
  br label %20

20:                                               ; preds = %15, %11
  %21 = getelementptr inbounds i8, ptr %0, i64 224
  store i8 1, ptr %21, align 8, !tbaa !26
  tail call void @_ZN10SimTKIpopt12TaggedObject13ObjectChangedEv(ptr noundef nonnull align 8 dereferenceable(56) %0)
  ret void
}

attributes #0 = { 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 #1 = { "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 = { 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, !22, i64 225}
!6 = !{!"_ZTSN10SimTKIpopt11DenseVectorE", !7, i64 0, !18, i64 208, !18, i64 216, !22, i64 224, !22, i64 225, !21, i64 232}
!7 = !{!"_ZTSN10SimTKIpopt6VectorE", !8, i64 0, !19, i64 56, !20, i64 64, !10, i64 88, !21, i64 96, !10, i64 104, !21, i64 112, !10, i64 120, !21, i64 128, !10, i64 136, !21, i64 144, !10, i64 152, !21, i64 160, !10, i64 168, !21, i64 176, !10, i64 184, !21, i64 192, !10, i64 200, !22, i64 204}
!8 = !{!"_ZTSN10SimTKIpopt12TaggedObjectE", !9, i64 0, !13, i64 16, !10, i64 48, !10, i64 52}
!9 = !{!"_ZTSN10SimTKIpopt16ReferencedObjectE", !10, i64 8}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"_ZTSN10SimTKIpopt7SubjectE", !14, i64 8}
!14 = !{!"_ZTSSt6vectorIPN10SimTKIpopt8ObserverESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIPN10SimTKIpopt8ObserverESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPN10SimTKIpopt8ObserverESaIS2_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIPN10SimTKIpopt8ObserverESaIS2_EE17_Vector_impl_dataE", !18, i64 0, !18, i64 8, !18, i64 16}
!18 = !{!"any pointer", !11, i64 0}
!19 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_11VectorSpaceEEE", !18, i64 0}
!20 = !{!"_ZTSN10SimTKIpopt13CachedResultsIdEE", !10, i64 8, !18, i64 16}
!21 = !{!"double", !11, i64 0}
!22 = !{!"bool", !11, i64 0}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!6, !18, i64 216}
!26 = !{!6, !22, i64 224}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass