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

@g_traceLevel = external global i32, align 4
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage = external hidden constant [50 x i8], align 16
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_0 = external hidden constant [112 x i8], align 16
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_1 = external hidden constant [78 x i8], align 16
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_2 = external hidden constant [49 x i8], align 16

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

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

16:                                               ; preds = %13
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage)
  br label %17

17:                                               ; preds = %16, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %18

18:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = icmp eq i64 0, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  br label %24

22:                                               ; preds = %18
  %23 = load i64, ptr %3, align 8, !tbaa !5
  br label %24

24:                                               ; preds = %22, %21
  %25 = phi i64 [ 1, %21 ], [ %23, %22 ]
  store i64 %25, ptr %5, align 8, !tbaa !5
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = call noundef zeroext i1 @_ZN14NAMESPACE_MAINL15IsMultiplyErrorImEEbT_S1_(i64 noundef 24, i64 noundef %26) #6
  br i1 %27, label %28, label %36

28:                                               ; preds = %24
  br label %29

29:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 2, ptr %6, align 4, !tbaa !9
  %30 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %31 = icmp sle i32 2, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  call void @InteralLogWithoutArguments(i32 noundef 2, ptr noundef @_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_0)
  br label %33

33:                                               ; preds = %32, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %83

36:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = mul i64 24, %37
  %39 = call noalias ptr @malloc(i64 noundef %38) #7
  store ptr %39, ptr %8, align 8, !tbaa !11
  %40 = load ptr, ptr %8, align 8, !tbaa !11
  %41 = icmp eq ptr null, %40
  %42 = xor i1 %41, true
  %43 = xor i1 %42, true
  %44 = zext i1 %43 to i64
  %45 = call i64 @llvm.expect.i64(i64 %44, i64 0)
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %55

47:                                               ; preds = %36
  br label %48

48:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 2, ptr %9, align 4, !tbaa !9
  %49 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %50 = icmp sle i32 2, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %48
  call void @InteralLogWithoutArguments(i32 noundef 2, ptr noundef @_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_1)
  br label %52

52:                                               ; preds = %51, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %82

55:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %56 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %56, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %57 = load ptr, ptr %8, align 8, !tbaa !11
  %58 = load i64, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %57, i64 %58
  store ptr %59, ptr %11, align 8, !tbaa !11
  br label %60

60:                                               ; preds = %69, %55
  %61 = load ptr, ptr %10, align 8, !tbaa !11
  %62 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %61, i32 0, i32 0
  store i64 0, ptr %62, align 8, !tbaa !13
  %63 = load ptr, ptr %10, align 8, !tbaa !11
  %64 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %63, i32 0, i32 1
  store double 0.000000e+00, ptr %64, align 8, !tbaa !16
  %65 = load ptr, ptr %10, align 8, !tbaa !11
  %66 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %65, i32 0, i32 2
  store ptr null, ptr %66, align 8, !tbaa !17
  %67 = load ptr, ptr %10, align 8, !tbaa !11
  %68 = getelementptr inbounds %"struct.NAMESPACE_MAIN::DataSetInnerBag", ptr %67, i32 1
  store ptr %68, ptr %10, align 8, !tbaa !11
  br label %69

69:                                               ; preds = %60
  %70 = load ptr, ptr %11, align 8, !tbaa !11
  %71 = load ptr, ptr %10, align 8, !tbaa !11
  %72 = icmp ne ptr %70, %71
  br i1 %72, label %60, label %73, !llvm.loop !18

73:                                               ; preds = %69
  br label %74

74:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 3, ptr %12, align 4, !tbaa !9
  %75 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %76 = icmp sle i32 3, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %74
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_2)
  br label %78

78:                                               ; preds = %77, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %81, ptr %2, align 8
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %82

82:                                               ; preds = %80, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %83

83:                                               ; preds = %82, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  %84 = load ptr, ptr %2, align 8
  ret ptr %84
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN14NAMESPACE_MAINL15IsMultiplyErrorImEEbT_S1_(i64 noundef, i64 noundef) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { inlinehint 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 allocsize(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 #5 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTSN14NAMESPACE_MAIN15DataSetInnerBagE", !6, i64 0, !15, i64 8, !12, i64 16}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !15, i64 8}
!17 = !{!14, !12, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@g_traceLevel = external local_unnamed_addr global i32, align 4
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage = external hidden constant [50 x i8], align 16
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_0 = external hidden constant [112 x i8], align 16
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_1 = external hidden constant [78 x i8], align 16
@_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_2 = external hidden constant [49 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local noalias noundef ptr @_ZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEm(i64 noundef %0) local_unnamed_addr #0 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_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage)
  br label %5

5:                                                ; preds = %4, %1
  %6 = tail call i64 @llvm.umax.i64(i64 %0, i64 1)
  %7 = tail call noundef zeroext i1 @_ZN14NAMESPACE_MAINL15IsMultiplyErrorImEEbT_S1_(i64 noundef 24, i64 noundef %6) #6
  br i1 %7, label %8, label %12

8:                                                ; preds = %5
  %9 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 1
  br i1 %10, label %11, label %28

11:                                               ; preds = %8
  tail call void @InteralLogWithoutArguments(i32 noundef 2, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_0)
  br label %28

12:                                               ; preds = %5
  %13 = mul i64 %6, 24
  %14 = tail call noalias ptr @malloc(i64 noundef %13) #7
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %20, !prof !9

16:                                               ; preds = %12
  %17 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %18 = icmp sgt i32 %17, 1
  br i1 %18, label %19, label %28

19:                                               ; preds = %16
  tail call void @InteralLogWithoutArguments(i32 noundef 2, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_1)
  br label %28

20:                                               ; preds = %12
  %21 = add i64 %13, -24
  %22 = urem i64 %21, 24
  %23 = sub nuw i64 %21, %22
  %24 = add i64 %23, 24
  tail call void @llvm.memset.p0.i64(ptr nonnull align 8 %14, i8 0, i64 %24, i1 false), !tbaa !10
  %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 = %20
  tail call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN15DataSetInnerBag24AllocateDataSetInnerBagsEmE13LOG__sMessage_2)
  br label %28

28:                                               ; preds = %19, %16, %27, %20, %8, %11
  %.1 = phi ptr [ null, %11 ], [ null, %8 ], [ null, %19 ], [ null, %16 ], [ %14, %27 ], [ %14, %20 ]
  ret ptr %.1
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN14NAMESPACE_MAINL15IsMultiplyErrorImEEbT_S1_(i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { 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 = { "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 = { inlinehint 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LowerExpectIntrinsicPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass