; LLVM IR from interpretml/interpret :: shared/libebm (DataSetInnerBag)

; 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.NAMESPACE_MAIN::DataSetInnerBag" = type { i64, double, ptr }
%"struct.NAMESPACE_MAIN::TermInnerBag" = type { ptr, ptr }

@g_traceLevel = external global i32, align 4
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_mE13LOG__sMessage = external hidden constant [46 x i8], align 16
@.str = external hidden unnamed_addr constant [89 x i8], align 1
@__func__._ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m = external hidden unnamed_addr constant [118 x i8], align 1
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_mE13LOG__sMessage_0 = external hidden constant [45 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: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m(i64 noundef %0, ptr noundef %1, i64 noundef %2) #3 align 2 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store i64 %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 3, ptr %7, align 4, !tbaa !11
  %16 = load i32, ptr @g_traceLevel, align 4, !tbaa !11
  %17 = icmp sle i32 3, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_mE13LOG__sMessage)
  br label %19

19:                                               ; preds = %18, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr %5, align 8, !tbaa !9
  %22 = icmp ne ptr null, %21
  %23 = xor i1 %22, true
  %24 = xor i1 %23, true
  %25 = zext i1 %24 to i64
  %26 = call i64 @llvm.expect.i64(i64 %25, i64 1)
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %28, label %76

28:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %29 = load i64, ptr %4, align 8, !tbaa !5
  %30 = icmp eq i64 0, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  br label %34

32:                                               ; preds = %28
  %33 = load i64, ptr %4, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %32, %31
  %35 = phi i64 [ 1, %31 ], [ %33, %32 ]
  store i64 %35, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %36, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = load i64, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %37, i64 %38
  store ptr %39, ptr %10, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %70, %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %41 = load ptr, ptr %9, align 8, !tbaa !9
  %42 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  store ptr %43, ptr %11, align 8, !tbaa !9
  %44 = load ptr, ptr %11, align 8, !tbaa !9
  %45 = icmp ne ptr null, %44
  br i1 %45, label %46, label %67

46:                                               ; preds = %40
  %47 = load i64, ptr %6, align 8, !tbaa !5
  %48 = icmp ule i64 1, %47
  br i1 %48, label %51, label %49

49:                                               ; preds = %46
  call void @LogAssertFailure(i64 noundef 71, ptr noundef @.str, ptr noundef @__func__._ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m, ptr noundef @.str.1)
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str, i32 noundef 71, ptr noundef @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m) #7
  unreachable

50:                                               ; No predecessors!
  br label %51

51:                                               ; preds = %50, %46
  %52 = phi i1 [ true, %46 ], [ false, %50 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %53 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %53, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %54 = load ptr, ptr %12, align 8, !tbaa !9
  %55 = load i64, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.NAMESPACE_MAIN::TermInnerBag", ptr %54, i64 %55
  store ptr %56, ptr %13, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %61, %51
  %58 = load ptr, ptr %12, align 8, !tbaa !9
  call void @_ZN14NAMESPACE_MAIN12TermInnerBag16FreeTermInnerBagEPS0_(ptr noundef %58)
  %59 = load ptr, ptr %12, align 8, !tbaa !9
  %60 = getelementptr inbounds %"struct.NAMESPACE_MAIN::TermInnerBag", ptr %59, i32 1
  store ptr %60, ptr %12, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %57
  %62 = load ptr, ptr %13, align 8, !tbaa !9
  %63 = load ptr, ptr %12, align 8, !tbaa !9
  %64 = icmp ne ptr %62, %63
  br i1 %64, label %57, label %65, !llvm.loop !16

65:                                               ; preds = %61
  %66 = load ptr, ptr %11, align 8, !tbaa !9
  call void @free(ptr noundef %66) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %67

67:                                               ; preds = %65, %40
  %68 = load ptr, ptr %9, align 8, !tbaa !9
  %69 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %68, i32 1
  store ptr %69, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %70

70:                                               ; preds = %67
  %71 = load ptr, ptr %10, align 8, !tbaa !9
  %72 = load ptr, ptr %9, align 8, !tbaa !9
  %73 = icmp ne ptr %71, %72
  br i1 %73, label %40, label %74, !llvm.loop !18

74:                                               ; preds = %70
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  call void @free(ptr noundef %75) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %76

76:                                               ; preds = %74, %20
  br label %77

77:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 3, ptr %14, align 4, !tbaa !11
  %78 = load i32, ptr @g_traceLevel, align 4, !tbaa !11
  %79 = icmp sle i32 3, %78
  br i1 %79, label %80, label %81

80:                                               ; preds = %77
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_mE13LOG__sMessage_0)
  br label %81

81:                                               ; preds = %80, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %82

82:                                               ; preds = %81
  ret void
}

declare void @LogAssertFailure(i64 noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

declare void @_ZN14NAMESPACE_MAIN12TermInnerBag16FreeTermInnerBagEPS0_(ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = { noreturn 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 "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 #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ZTSN14NAMESPACE_MAIN15DataSetInnerBagE", !6, i64 0, !15, i64 8, !10, i64 16}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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.NAMESPACE_MAIN::DataSetInnerBag" = type { i64, double, ptr }
%"struct.NAMESPACE_MAIN::TermInnerBag" = type { ptr, ptr }

@g_traceLevel = external local_unnamed_addr global i32, align 4
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_mE13LOG__sMessage = external hidden constant [46 x i8], align 16
@.str = external hidden unnamed_addr constant [89 x i8], align 1
@__func__._ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m = external hidden unnamed_addr constant [118 x i8], align 1
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_mE13LOG__sMessage_0 = external hidden constant [45 x i8], align 16

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

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

6:                                                ; preds = %3
  tail call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_mE13LOG__sMessage)
  br label %7

7:                                                ; preds = %6, %3
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %24, label %8, !prof !9

8:                                                ; preds = %7
  %9 = tail call i64 @llvm.umax.i64(i64 %0, i64 1)
  %10 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %1, i64 %9
  %.not26 = icmp eq i64 %2, 0
  br i1 %.not26, label %.split.us, label %.split

.split.us:                                        ; preds = %8, %13
  %.0.us = phi ptr [ %14, %13 ], [ %1, %8 ]
  %11 = getelementptr inbounds i8, ptr %.0.us, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !10
  %.not25.us = icmp eq ptr %12, null
  br i1 %.not25.us, label %13, label %.split30.us

13:                                               ; preds = %.split.us
  %14 = getelementptr inbounds i8, ptr %.0.us, i64 24
  %.not28.us = icmp eq ptr %10, %14
  br i1 %.not28.us, label %.split32.us, label %.split.us, !llvm.loop !15

.split:                                           ; preds = %8, %22
  %.0 = phi ptr [ %23, %22 ], [ %1, %8 ]
  %15 = getelementptr inbounds i8, ptr %.0, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !10
  %.not25 = icmp eq ptr %16, null
  br i1 %.not25, label %22, label %17

17:                                               ; preds = %.split
  %18 = getelementptr inbounds %"struct.NAMESPACE_MAIN::TermInnerBag", ptr %16, i64 %2
  br label %19

.split30.us:                                      ; preds = %.split.us
  tail call void @LogAssertFailure(i64 noundef 71, ptr noundef nonnull @.str, ptr noundef nonnull @__func__._ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m, ptr noundef nonnull @.str.1)
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str, i32 noundef 71, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_m) #5
  unreachable

19:                                               ; preds = %19, %17
  %.020 = phi ptr [ %16, %17 ], [ %20, %19 ]
  tail call void @_ZN14NAMESPACE_MAIN12TermInnerBag16FreeTermInnerBagEPS0_(ptr noundef nonnull %.020)
  %20 = getelementptr inbounds i8, ptr %.020, i64 16
  %.not27 = icmp eq ptr %18, %20
  br i1 %.not27, label %21, label %19, !llvm.loop !17

21:                                               ; preds = %19
  tail call void @free(ptr noundef %16) #6
  br label %22

22:                                               ; preds = %21, %.split
  %23 = getelementptr inbounds i8, ptr %.0, i64 24
  %.not28 = icmp eq ptr %10, %23
  br i1 %.not28, label %.split32.us, label %.split, !llvm.loop !15

.split32.us:                                      ; preds = %22, %13
  tail call void @free(ptr noundef %1) #6
  br label %24

24:                                               ; preds = %7, %.split32.us
  %25 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 2
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  tail call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN15DataSetInnerBag20FreeDataSetInnerBagsEmPS0_mE13LOG__sMessage_0)
  br label %28

28:                                               ; preds = %27, %24
  ret void
}

declare void @LogAssertFailure(i64 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN14NAMESPACE_MAIN12TermInnerBag16FreeTermInnerBagEPS0_(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #4

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 = { noreturn 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 #3 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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"}
!9 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!10 = !{!11, !14, i64 16}
!11 = !{!"_ZTSN14NAMESPACE_MAIN15DataSetInnerBagE", !12, i64 0, !13, i64 8, !14, i64 16}
!12 = !{!"long", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass