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

; 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::SubsetInnerBag" = type { ptr }

@g_traceLevel = external global i32, align 4
@_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage = external hidden constant [48 x i8], align 16
@_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_0 = external hidden constant [109 x i8], align 16
@_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_1 = external hidden constant [75 x i8], align 16
@_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_2 = external hidden constant [47 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEm(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_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__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 8, 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_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__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 %79

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 8, %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_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__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 %78

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::SubsetInnerBag", ptr %57, i64 %58
  store ptr %59, ptr %11, align 8, !tbaa !11
  br label %60

60:                                               ; preds = %65, %55
  %61 = load ptr, ptr %10, align 8, !tbaa !11
  %62 = getelementptr inbounds %"struct.NAMESPACE_MAIN::SubsetInnerBag", ptr %61, i32 0, i32 0
  store ptr null, ptr %62, align 8, !tbaa !13
  %63 = load ptr, ptr %10, align 8, !tbaa !11
  %64 = getelementptr inbounds %"struct.NAMESPACE_MAIN::SubsetInnerBag", ptr %63, i32 1
  store ptr %64, ptr %10, align 8, !tbaa !11
  br label %65

65:                                               ; preds = %60
  %66 = load ptr, ptr %11, align 8, !tbaa !11
  %67 = load ptr, ptr %10, align 8, !tbaa !11
  %68 = icmp ne ptr %66, %67
  br i1 %68, label %60, label %69, !llvm.loop !15

69:                                               ; preds = %65
  br label %70

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

73:                                               ; preds = %70
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_2)
  br label %74

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

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %77, 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 %78

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

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

; 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, !12, i64 0}
!14 = !{!"_ZTSN14NAMESPACE_MAIN14SubsetInnerBagE", !12, 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"

@g_traceLevel = external local_unnamed_addr global i32, align 4
@_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage = external hidden constant [48 x i8], align 16
@_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_0 = external hidden constant [109 x i8], align 16
@_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_1 = external hidden constant [75 x i8], align 16
@_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_2 = external hidden constant [47 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local noalias noundef ptr @_ZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEm(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_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__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 8, i64 noundef %6) #5
  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 %22

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

12:                                               ; preds = %5
  %13 = shl i64 %6, 3
  %calloc = tail call ptr @calloc(i64 1, i64 %13)
  %14 = icmp eq ptr %calloc, null
  %15 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  br i1 %14, label %16, label %19, !prof !9

16:                                               ; preds = %12
  %17 = icmp sgt i32 %15, 1
  br i1 %17, label %18, label %22

18:                                               ; preds = %16
  tail call void @InteralLogWithoutArguments(i32 noundef 2, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_1)
  br label %22

19:                                               ; preds = %12
  %20 = icmp sgt i32 %15, 2
  br i1 %20, label %21, label %22

21:                                               ; preds = %19
  tail call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN14SubsetInnerBag23AllocateSubsetInnerBagsEmE13LOG__sMessage_2)
  br label %22

22:                                               ; preds = %18, %16, %21, %19, %8, %11
  %.1 = phi ptr [ null, %11 ], [ null, %8 ], [ null, %18 ], [ null, %16 ], [ %calloc, %21 ], [ %calloc, %19 ]
  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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #3

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #5 = { 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}


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