; 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

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

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

10:                                               ; preds = %2
  %11 = call ptr @__dynamic_cast(ptr %8, ptr @_ZTIN10SimTKIpopt6VectorE, ptr @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #5
  br label %13

12:                                               ; preds = %2
  br label %13

13:                                               ; preds = %12, %10
  %14 = phi ptr [ %11, %10 ], [ null, %12 ]
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %7, i32 0, i32 4
  %16 = load i8, ptr %15, align 1, !tbaa !9, !range !24, !noundef !25
  %17 = trunc i8 %16 to i1
  br i1 %17, label %18, label %41

18:                                               ; preds = %13
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %19, i32 0, i32 4
  %21 = load i8, ptr %20, align 1, !tbaa !9, !range !24, !noundef !25
  %22 = trunc i8 %21 to i1
  br i1 %22, label %23, label %33

23:                                               ; preds = %18
  %24 = call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %7)
  %25 = sitofp i32 %24 to double
  %26 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %7, i32 0, i32 5
  %27 = load double, ptr %26, align 8, !tbaa !26
  %28 = fmul double %25, %27
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %29, i32 0, i32 5
  %31 = load double, ptr %30, align 8, !tbaa !26
  %32 = fmul double %28, %31
  store double %32, ptr %5, align 8, !tbaa !27
  br label %40

33:                                               ; preds = %18
  %34 = call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %7)
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !28
  %38 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %7, i32 0, i32 5
  %39 = call noundef double @_ZN10SimTKIpopt10IpBlasDdotEiPKdiS1_i(i32 noundef %34, ptr noundef %37, i32 noundef 1, ptr noundef %38, i32 noundef 0)
  store double %39, ptr %5, align 8, !tbaa !27
  br label %40

40:                                               ; preds = %33, %23
  br label %62

41:                                               ; preds = %13
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %42, i32 0, i32 4
  %44 = load i8, ptr %43, align 1, !tbaa !9, !range !24, !noundef !25
  %45 = trunc i8 %44 to i1
  br i1 %45, label %46, label %53

46:                                               ; preds = %41
  %47 = call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %7)
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %48, i32 0, i32 5
  %50 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %7, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !28
  %52 = call noundef double @_ZN10SimTKIpopt10IpBlasDdotEiPKdiS1_i(i32 noundef %47, ptr noundef %49, i32 noundef 0, ptr noundef %51, i32 noundef 1)
  store double %52, ptr %5, align 8, !tbaa !27
  br label %61

53:                                               ; preds = %41
  %54 = call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %7)
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !28
  %58 = getelementptr inbounds %"class.SimTKIpopt::DenseVector", ptr %7, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !28
  %60 = call noundef double @_ZN10SimTKIpopt10IpBlasDdotEiPKdiS1_i(i32 noundef %54, ptr noundef %57, i32 noundef 1, ptr noundef %59, i32 noundef 1)
  store double %60, ptr %5, align 8, !tbaa !27
  br label %61

61:                                               ; preds = %53, %46
  br label %62

62:                                               ; preds = %61, %40
  %63 = load double, ptr %5, align 8, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret double %63
}

declare noundef double @_ZN10SimTKIpopt10IpBlasDdotEiPKdiS1_i(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #4

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


; 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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK10SimTKIpopt11DenseVector7DotImplERKNS_6VectorE(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr noundef nonnull align 8 dereferenceable(205) %1) unnamed_addr #2 align 2 {
  %3 = tail call ptr @__dynamic_cast(ptr nonnull %1, ptr nonnull @_ZTIN10SimTKIpopt6VectorE, ptr nonnull @_ZTIN10SimTKIpopt11DenseVectorE, i64 0) #4
  %4 = getelementptr inbounds i8, ptr %0, i64 225
  %5 = load i8, ptr %4, align 1, !tbaa !5, !range !23, !noundef !24
  %6 = trunc nuw i8 %5 to i1
  %7 = getelementptr inbounds i8, ptr %3, i64 225
  %8 = load i8, ptr %7, align 1, !tbaa !5, !range !23, !noundef !24
  %9 = trunc nuw i8 %8 to i1
  %10 = tail call noundef i32 @_ZNK10SimTKIpopt6Vector3DimEv(ptr noundef nonnull align 8 dereferenceable(205) %0)
  br i1 %6, label %11, label %25

11:                                               ; preds = %2
  br i1 %9, label %12, label %20

12:                                               ; preds = %11
  %13 = sitofp i32 %10 to double
  %14 = getelementptr inbounds i8, ptr %0, i64 232
  %15 = load double, ptr %14, align 8, !tbaa !25
  %16 = fmul double %15, %13
  %17 = getelementptr inbounds i8, ptr %3, i64 232
  %18 = load double, ptr %17, align 8, !tbaa !25
  %19 = fmul double %16, %18
  br label %37

20:                                               ; preds = %11
  %21 = getelementptr inbounds i8, ptr %3, i64 216
  %22 = load ptr, ptr %21, align 8, !tbaa !26
  %23 = getelementptr inbounds i8, ptr %0, i64 232
  %24 = tail call noundef double @_ZN10SimTKIpopt10IpBlasDdotEiPKdiS1_i(i32 noundef %10, ptr noundef %22, i32 noundef 1, ptr noundef nonnull %23, i32 noundef 0)
  br label %37

25:                                               ; preds = %2
  br i1 %9, label %26, label %31

26:                                               ; preds = %25
  %27 = getelementptr inbounds i8, ptr %3, i64 232
  %28 = getelementptr inbounds i8, ptr %0, i64 216
  %29 = load ptr, ptr %28, align 8, !tbaa !26
  %30 = tail call noundef double @_ZN10SimTKIpopt10IpBlasDdotEiPKdiS1_i(i32 noundef %10, ptr noundef nonnull %27, i32 noundef 0, ptr noundef %29, i32 noundef 1)
  br label %37

31:                                               ; preds = %25
  %32 = getelementptr inbounds i8, ptr %3, i64 216
  %33 = load ptr, ptr %32, align 8, !tbaa !26
  %34 = getelementptr inbounds i8, ptr %0, i64 216
  %35 = load ptr, ptr %34, align 8, !tbaa !26
  %36 = tail call noundef double @_ZN10SimTKIpopt10IpBlasDdotEiPKdiS1_i(i32 noundef %10, ptr noundef %33, i32 noundef 1, ptr noundef %35, i32 noundef 1)
  br label %37

37:                                               ; preds = %26, %31, %12, %20
  %.0 = phi double [ %19, %12 ], [ %24, %20 ], [ %30, %26 ], [ %36, %31 ]
  ret double %.0
}

declare noundef double @_ZN10SimTKIpopt10IpBlasDdotEiPKdiS1_i(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

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 = { mustprogress nofree nounwind willreturn memory(read) }
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 = { "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 }

!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, !21, i64 232}
!26 = !{!6, !18, i64 216}


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