; LLVM IR from interpretml/interpret :: shared/libebm/BoosterCore.ll (ZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_)

; 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.NAMESPACE_MAIN::BoosterCore" = type { %"struct.std::atomic", i64, i32, i64, ptr, i64, ptr, i64, ptr, ptr, double, i64, i64, i64, i64, %"struct.NAMESPACE_MAIN::DataSetBoosting", %"struct.NAMESPACE_MAIN::DataSetBoosting", %struct.ObjectiveWrapper, %struct.ObjectiveWrapper }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i64 }
%"struct.NAMESPACE_MAIN::DataSetBoosting" = type { i64, i64, ptr, ptr, ptr }
%struct.ObjectiveWrapper = type { ptr, ptr, ptr, ptr, i32, i32, i32, double, double, double, double, double, double, double, double, i32, i64, i64, i64, i32, ptr }

@g_traceLevel = external global i32, align 4
@_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage = external hidden constant [26 x i8], align 16
@_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage_0 = external hidden constant [44 x i8], align 16
@_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage_1 = external hidden constant [25 x i8], align 16

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

declare void @InteralLogWithoutArguments(i32 noundef, ptr noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_(ptr noundef %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 3, ptr %3, align 4, !tbaa !9
  %7 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %8 = icmp sle i32 3, %7
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage)
  br label %10

10:                                               ; preds = %9, %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %11

11:                                               ; preds = %10
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = icmp ne ptr null, %12
  br i1 %13, label %14, label %31

14:                                               ; preds = %11
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.NAMESPACE_MAIN::BoosterCore", ptr %15, i32 0, i32 0
  %17 = call noundef i64 @_ZNSt13__atomic_baseImE9fetch_subEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %16, i64 noundef 1, i32 noundef 3) #5
  %18 = icmp eq i64 1, %17
  br i1 %18, label %19, label %30

19:                                               ; preds = %14
  call void @_ZSt19atomic_thread_fenceSt12memory_order(i32 noundef 2) #5
  br label %20

20:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 3, ptr %4, align 4, !tbaa !9
  %21 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %22 = icmp sle i32 3, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage_0)
  br label %24

24:                                               ; preds = %23, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  call void @_ZN14NAMESPACE_MAIN11BoosterCoreD1Ev(ptr noundef nonnull align 8 dereferenceable(520) %26) #5
  call void @_ZdlPvm(ptr noundef %26, i64 noundef 520) #6
  br label %29

29:                                               ; preds = %28, %25
  br label %30

30:                                               ; preds = %29, %14
  br label %31

31:                                               ; preds = %30, %11
  br label %32

32:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 3, ptr %5, align 4, !tbaa !9
  %33 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %34 = icmp sle i32 3, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage_1)
  br label %36

36:                                               ; preds = %35, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %37

37:                                               ; preds = %36
  ret void
}

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZSt19atomic_thread_fenceSt12memory_order(i32 noundef) #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #4

declare void @_ZN14NAMESPACE_MAIN11BoosterCoreD1Ev(ptr)

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


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

@g_traceLevel = external local_unnamed_addr global i32, align 4
@_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage = external hidden constant [26 x i8], align 16
@_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage_0 = external hidden constant [44 x i8], align 16
@_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage_1 = external hidden constant [25 x i8], align 16

declare void @InteralLogWithoutArguments(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_(ptr noundef %0) local_unnamed_addr #1 align 2 {
  %2 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 2
  br i1 %3, label %4, label %5

4:                                                ; preds = %1
  tail call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage)
  br label %5

5:                                                ; preds = %4, %1
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %14, label %6

6:                                                ; preds = %5
  %7 = tail call noundef i64 @_ZNSt13__atomic_baseImE9fetch_subEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 noundef 1, i32 noundef 3) #4
  %8 = icmp eq i64 %7, 1
  br i1 %8, label %9, label %14

9:                                                ; preds = %6
  tail call void @_ZSt19atomic_thread_fenceSt12memory_order(i32 noundef 2) #4
  %10 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 2
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  tail call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage_0)
  br label %13

13:                                               ; preds = %9, %12
  tail call void @_ZN14NAMESPACE_MAIN11BoosterCoreD1Ev(ptr noundef nonnull align 8 dereferenceable(520) %0) #4
  tail call void @_ZdlPvm(ptr noundef nonnull %0, i64 noundef 520) #5
  br label %14

14:                                               ; preds = %5, %13, %6
  %15 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %16 = icmp sgt i32 %15, 2
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  tail call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN11BoosterCore4FreeEPS0_E13LOG__sMessage_1)
  br label %18

18:                                               ; preds = %17, %14
  ret void
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNSt13__atomic_baseImE9fetch_subEmSt12memory_order(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZSt19atomic_thread_fenceSt12memory_order(i32 noundef) local_unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

declare void @_ZN14NAMESPACE_MAIN11BoosterCoreD1Ev(ptr) local_unnamed_addr

attributes #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" }
attributes #2 = { alwaysinline 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 #3 = { nobuiltin nounwind "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 }
attributes #5 = { builtin 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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