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

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

%struct.__va_list_tag = type { i32, i32, ptr, ptr }
%"class.SimTKIpopt::Journalist" = type { %"class.SimTKIpopt::ReferencedObject.base", %"class.std::vector" }
%"class.SimTKIpopt::ReferencedObject.base" = type <{ ptr, i32 }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<SimTKIpopt::SmartPtr<SimTKIpopt::Journal>, std::allocator<SimTKIpopt::SmartPtr<SimTKIpopt::Journal>>>::_Vector_impl" }
%"struct.std::_Vector_base<SimTKIpopt::SmartPtr<SimTKIpopt::Journal>, std::allocator<SimTKIpopt::SmartPtr<SimTKIpopt::Journal>>>::_Vector_impl" = type { %"struct.std::_Vector_base<SimTKIpopt::SmartPtr<SimTKIpopt::Journal>, std::allocator<SimTKIpopt::SmartPtr<SimTKIpopt::Journal>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<SimTKIpopt::SmartPtr<SimTKIpopt::Journal>, std::allocator<SimTKIpopt::SmartPtr<SimTKIpopt::Journal>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK10SimTKIpopt10Journalist7VPrintfENS_13EJournalLevelENS_16EJournalCategoryEPKcP13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca [1 x %struct.__va_list_tag], align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !11
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !13
  br label %14

14:                                               ; preds = %42, %5
  %15 = load i32, ptr %11, align 4, !tbaa !13
  %16 = getelementptr inbounds %"class.SimTKIpopt::Journalist", ptr %13, i32 0, i32 1
  %17 = call noundef i64 @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #4
  %18 = trunc i64 %17 to i32
  %19 = icmp slt i32 %15, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %45

21:                                               ; preds = %14
  %22 = getelementptr inbounds %"class.SimTKIpopt::Journalist", ptr %13, i32 0, i32 1
  %23 = load i32, ptr %11, align 4, !tbaa !13
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef %24) #4
  %26 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_7JournalEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %25)
  %27 = load i32, ptr %8, align 4, !tbaa !11
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = call noundef zeroext i1 @_ZNK10SimTKIpopt7Journal10IsAcceptedENS_16EJournalCategoryENS_13EJournalLevelE(ptr noundef nonnull align 8 dereferenceable(108) %26, i32 noundef %27, i32 noundef %28)
  br i1 %29, label %30, label %41

30:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #4
  %31 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.va_copy.p0(ptr %31, ptr %32)
  %33 = getelementptr inbounds %"class.SimTKIpopt::Journalist", ptr %13, i32 0, i32 1
  %34 = load i32, ptr %11, align 4, !tbaa !13
  %35 = sext i32 %34 to i64
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %33, i64 noundef %35) #4
  %37 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_7JournalEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %36)
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  call void @_ZN10SimTKIpopt7Journal6PrintfEPKcP13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(108) %37, ptr noundef %38, ptr noundef %39)
  %40 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  call void @llvm.va_end.p0(ptr %40)
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #4
  br label %41

41:                                               ; preds = %30, %21
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %11, align 4, !tbaa !13
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %11, align 4, !tbaa !13
  br label %14, !llvm.loop !15

45:                                               ; preds = %20
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #2

; 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 i64 @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK10SimTKIpopt7Journal10IsAcceptedENS_16EJournalCategoryENS_13EJournalLevelE(ptr noundef nonnull align 8 dereferenceable(108), i32 noundef, i32 noundef) #3 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_copy.p0(ptr, ptr) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10SimTKIpopt7Journal6PrintfEPKcP13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(108), ptr noundef, ptr noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { 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 #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, !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 = !{!"_ZTSN10SimTKIpopt13EJournalLevelE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN10SimTKIpopt16EJournalCategoryE", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

%struct.__va_list_tag = type { i32, i32, ptr, 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 uwtable
define dso_local void @_ZNK10SimTKIpopt10Journalist7VPrintfENS_13EJournalLevelENS_16EJournalCategoryEPKcP13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 align 2 {
  %6 = alloca [1 x %struct.__va_list_tag], align 16
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = tail call noundef i64 @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %9 = trunc i64 %8 to i32
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %17, %5
  ret void

.lr.ph:                                           ; preds = %5, %17
  %indvars.iv = phi i64 [ %indvars.iv.next, %17 ], [ 0, %5 ]
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %indvars.iv) #4
  %12 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_7JournalEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11)
  %13 = call noundef zeroext i1 @_ZNK10SimTKIpopt7Journal10IsAcceptedENS_16EJournalCategoryENS_13EJournalLevelE(ptr noundef nonnull align 8 dereferenceable(108) %12, i32 noundef %2, i32 noundef %1)
  br i1 %13, label %14, label %17

14:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.va_copy.p0(ptr nonnull %6, ptr %4)
  %15 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %indvars.iv) #4
  %16 = call noundef ptr @_ZNK10SimTKIpopt8SmartPtrINS_7JournalEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %15)
  call void @_ZN10SimTKIpopt7Journal6PrintfEPKcP13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(108) %16, ptr noundef %3, ptr noundef nonnull %6)
  call void @llvm.va_end.p0(ptr nonnull %6)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  br label %17

17:                                               ; preds = %.lr.ph, %14
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = call noundef i64 @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %sext = shl i64 %18, 32
  %19 = ashr exact i64 %sext, 32
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !5
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #2

; 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 i64 @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIN10SimTKIpopt8SmartPtrINS0_7JournalEEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK10SimTKIpopt7Journal10IsAcceptedENS_16EJournalCategoryENS_13EJournalLevelE(ptr noundef nonnull align 8 dereferenceable(108), i32 noundef, i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_copy.p0(ptr, ptr) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10SimTKIpopt7Journal6PrintfEPKcP13__va_list_tag(ptr noundef nonnull align 8 dereferenceable(108), ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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