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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN10SimTKIpopt11TNLPAdapter19internal_eval_jac_gEb(ptr noundef nonnull align 8 dereferenceable(400) %0, i1 noundef zeroext %1) #2 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  %7 = zext i1 %1 to i8
  store i8 %7, ptr %5, align 1, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 45
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 41
  %12 = load i32, ptr %11, align 8, !tbaa !28
  %13 = icmp eq i32 %10, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  br label %45

15:                                               ; preds = %2
  %16 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 41
  %17 = load i32, ptr %16, align 8, !tbaa !28
  %18 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 45
  store i32 %17, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %19 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 1
  %20 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_4TNLPEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %19)
  %21 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 12
  %22 = load i32, ptr %21, align 8, !tbaa !29
  %23 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 36
  %24 = load ptr, ptr %23, align 8, !tbaa !30
  %25 = load i8, ptr %5, align 1, !tbaa !9, !range !31, !noundef !32
  %26 = trunc i8 %25 to i1
  %27 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 13
  %28 = load i32, ptr %27, align 4, !tbaa !33
  %29 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 17
  %30 = load i32, ptr %29, align 4, !tbaa !34
  %31 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 39
  %32 = load ptr, ptr %31, align 8, !tbaa !35
  %33 = load ptr, ptr %20, align 8, !tbaa !36
  %34 = getelementptr inbounds ptr, ptr %33, i64 10
  %35 = load ptr, ptr %34, align 8
  %36 = call noundef zeroext i1 %35(ptr noundef nonnull align 8 dereferenceable(12) %20, i32 noundef %22, ptr noundef %24, i1 noundef zeroext %26, i32 noundef %28, i32 noundef %30, ptr noundef null, ptr noundef null, ptr noundef %32)
  %37 = zext i1 %36 to i8
  store i8 %37, ptr %6, align 1, !tbaa !9
  %38 = load i8, ptr %6, align 1, !tbaa !9, !range !31, !noundef !32
  %39 = trunc i8 %38 to i1
  br i1 %39, label %42, label %40

40:                                               ; preds = %15
  %41 = getelementptr inbounds %"class.SimTKIpopt::TNLPAdapter", ptr %8, i32 0, i32 45
  store i32 0, ptr %41, align 8, !tbaa !11
  br label %42

42:                                               ; preds = %40, %15
  %43 = load i8, ptr %6, align 1, !tbaa !9, !range !31, !noundef !32
  %44 = trunc i8 %43 to i1
  store i1 %44, ptr %3, align 1
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  br label %45

45:                                               ; preds = %42, %14
  %46 = load i1, ptr %3, align 1
  ret i1 %46
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!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 = !{!"bool", !7, i64 0}
!11 = !{!12, !15, i64 288}
!12 = !{!"_ZTSN10SimTKIpopt11TNLPAdapterE", !13, i64 0, !16, i64 16, !17, i64 24, !18, i64 32, !18, i64 40, !19, i64 48, !20, i64 52, !18, i64 56, !18, i64 64, !10, i64 72, !10, i64 73, !21, i64 76, !15, i64 80, !15, i64 84, !15, i64 88, !15, i64 92, !15, i64 96, !15, i64 100, !15, i64 104, !15, i64 108, !15, i64 112, !22, i64 116, !23, i64 120, !23, i64 128, !23, i64 136, !23, i64 144, !24, i64 152, !23, i64 160, !24, i64 168, !23, i64 176, !24, i64 184, !23, i64 192, !24, i64 200, !24, i64 208, !24, i64 216, !25, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !15, i64 272, !15, i64 276, !15, i64 280, !15, i64 284, !15, i64 288, !26, i64 296, !27, i64 304, !26, i64 312, !27, i64 320, !26, i64 328, !27, i64 336, !27, i64 344, !26, i64 352, !27, i64 360, !26, i64 368, !6, i64 376, !6, i64 384, !6, i64 392}
!13 = !{!"_ZTSN10SimTKIpopt3NLPE", !14, i64 0}
!14 = !{!"_ZTSN10SimTKIpopt16ReferencedObjectE", !15, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_4TNLPEEE", !6, i64 0}
!17 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_10JournalistEEE", !6, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{!"_ZTSN10SimTKIpopt11TNLPAdapter26FixedVariableTreatmentEnumE", !7, i64 0}
!20 = !{!"_ZTSN10SimTKIpopt11TNLPAdapter18DerivativeTestEnumE", !7, i64 0}
!21 = !{!"_ZTSN10SimTKIpopt24HessianApproximationTypeE", !7, i64 0}
!22 = !{!"_ZTSN10SimTKIpopt4TNLP14IndexStyleEnumE", !7, i64 0}
!23 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_11VectorSpaceEEE", !6, i64 0}
!24 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_11MatrixSpaceEEE", !6, i64 0}
!25 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_14SymMatrixSpaceEEE", !6, i64 0}
!26 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_15ExpansionMatrixEEE", !6, i64 0}
!27 = !{!"_ZTSN10SimTKIpopt8SmartPtrINS_20ExpansionMatrixSpaceEEE", !6, i64 0}
!28 = !{!12, !15, i64 272}
!29 = !{!12, !15, i64 80}
!30 = !{!12, !6, i64 232}
!31 = !{i8 0, i8 2}
!32 = !{}
!33 = !{!12, !15, i64 84}
!34 = !{!12, !15, i64 100}
!35 = !{!12, !6, i64 256}
!36 = !{!37, !37, i64 0}
!37 = !{!"vtable pointer", !8, i64 0}


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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN10SimTKIpopt11TNLPAdapter19internal_eval_jac_gEb(ptr noundef nonnull align 8 dereferenceable(400) %0, i1 noundef zeroext %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 288
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 272
  %6 = load i32, ptr %5, align 8, !tbaa !26
  %7 = icmp eq i32 %4, %6
  br i1 %7, label %26, label %8

8:                                                ; preds = %2
  store i32 %6, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = tail call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_4TNLPEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = load i32, ptr %11, align 8, !tbaa !27
  %13 = getelementptr inbounds i8, ptr %0, i64 232
  %14 = load ptr, ptr %13, align 8, !tbaa !28
  %15 = getelementptr inbounds i8, ptr %0, i64 84
  %16 = load i32, ptr %15, align 4, !tbaa !29
  %17 = getelementptr inbounds i8, ptr %0, i64 100
  %18 = load i32, ptr %17, align 4, !tbaa !30
  %19 = getelementptr inbounds i8, ptr %0, i64 256
  %20 = load ptr, ptr %19, align 8, !tbaa !31
  %21 = load ptr, ptr %10, align 8, !tbaa !32
  %22 = getelementptr inbounds i8, ptr %21, i64 80
  %23 = load ptr, ptr %22, align 8
  %24 = tail call noundef zeroext i1 %23(ptr noundef nonnull align 8 dereferenceable(12) %10, i32 noundef %12, ptr noundef %14, i1 noundef zeroext %1, i32 noundef %16, i32 noundef %18, ptr noundef null, ptr noundef null, ptr noundef %20)
  br i1 %24, label %26, label %25

25:                                               ; preds = %8
  store i32 0, ptr %3, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %8, %25, %2
  %.0 = phi i1 [ true, %2 ], [ false, %25 ], [ true, %8 ]
  ret i1 %.0
}

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

!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 288}
!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 = !{!6, !9, i64 272}
!27 = !{!6, !9, i64 80}
!28 = !{!6, !13, i64 232}
!29 = !{!6, !9, i64 84}
!30 = !{!6, !9, i64 100}
!31 = !{!6, !13, i64 256}
!32 = !{!33, !33, i64 0}
!33 = !{!"vtable pointer", !11, i64 0}


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