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

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

@.str = external hidden unnamed_addr constant [89 x i8], align 1
@__func__.AlignedGrow = external hidden unnamed_addr constant [12 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.AlignedGrow = external hidden unnamed_addr constant [79 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [37 x i8], align 1

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

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

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) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @AlignedFree(ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local i32 @AlignedGrow(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) #5 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load i64, ptr %20, align 8, !tbaa !9
  store i64 %21, ptr %10, align 8, !tbaa !9
  %22 = load i64, ptr %10, align 8, !tbaa !9
  %23 = load i64, ptr %8, align 8, !tbaa !9
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %25, label %109

25:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = lshr i64 %26, 1
  %28 = add i64 %27, 16
  store i64 %28, ptr %11, align 8, !tbaa !9
  %29 = load i64, ptr %11, align 8, !tbaa !9
  %30 = sub i64 -72, %29
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %25
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %106

34:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %35 = load i64, ptr %11, align 8, !tbaa !9
  %36 = add i64 71, %35
  %37 = load i64, ptr %8, align 8, !tbaa !9
  %38 = add i64 %36, %37
  store i64 %38, ptr %13, align 8, !tbaa !9
  %39 = load i32, ptr %9, align 4, !tbaa !11
  %40 = icmp eq i32 0, %39
  br i1 %40, label %41, label %45

41:                                               ; preds = %34
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  call void @AlignedFree(ptr noundef %43)
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %44, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %41, %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %46 = load i64, ptr %13, align 8, !tbaa !9
  %47 = call noalias ptr @malloc(i64 noundef %46) #8
  store ptr %47, ptr %14, align 8, !tbaa !5
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = icmp eq ptr null, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %45
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %105

51:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = ptrtoint ptr %52 to i64
  store i64 %53, ptr %15, align 8, !tbaa !9
  %54 = load i64, ptr %15, align 8, !tbaa !9
  %55 = add i64 %54, 71
  %56 = and i64 %55, -64
  store i64 %56, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %57 = load i64, ptr %15, align 8, !tbaa !9
  %58 = inttoptr i64 %57 to ptr
  store ptr %58, ptr %16, align 8, !tbaa !5
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = load ptr, ptr %16, align 8, !tbaa !5
  %61 = icmp ult ptr %59, %60
  br i1 %61, label %64, label %62

62:                                               ; preds = %51
  call void @LogAssertFailure(i64 noundef 217, ptr noundef @.str, ptr noundef @__func__.AlignedGrow, ptr noundef @.str.23)
  call void @__assert_fail(ptr noundef @.str.24, ptr noundef @.str, i32 noundef 217, ptr noundef @__PRETTY_FUNCTION__.AlignedGrow) #9
  unreachable

63:                                               ; No predecessors!
  br label %64

64:                                               ; preds = %63, %51
  %65 = phi i1 [ true, %51 ], [ false, %63 ]
  %66 = load ptr, ptr %14, align 8, !tbaa !5
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  %68 = getelementptr inbounds ptr, ptr %67, i64 -1
  store ptr %66, ptr %68, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %69 = load ptr, ptr %16, align 8, !tbaa !5
  %70 = load ptr, ptr %14, align 8, !tbaa !5
  %71 = ptrtoint ptr %69 to i64
  %72 = ptrtoint ptr %70 to i64
  %73 = sub i64 %71, %72
  store i64 %73, ptr %17, align 8, !tbaa !9
  %74 = load i64, ptr %17, align 8, !tbaa !9
  %75 = load i64, ptr %13, align 8, !tbaa !9
  %76 = icmp ult i64 %74, %75
  br i1 %76, label %79, label %77

77:                                               ; preds = %64
  call void @LogAssertFailure(i64 noundef 220, ptr noundef @.str, ptr noundef @__func__.AlignedGrow, ptr noundef @.str.25)
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str, i32 noundef 220, ptr noundef @__PRETTY_FUNCTION__.AlignedGrow) #9
  unreachable

78:                                               ; No predecessors!
  br label %79

79:                                               ; preds = %78, %64
  %80 = phi i1 [ true, %64 ], [ false, %78 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %81 = load i64, ptr %13, align 8, !tbaa !9
  %82 = load i64, ptr %17, align 8, !tbaa !9
  %83 = sub i64 %81, %82
  store i64 %83, ptr %18, align 8, !tbaa !9
  %84 = load i64, ptr %8, align 8, !tbaa !9
  %85 = load i64, ptr %18, align 8, !tbaa !9
  %86 = icmp ule i64 %84, %85
  br i1 %86, label %89, label %87

87:                                               ; preds = %79
  call void @LogAssertFailure(i64 noundef 222, ptr noundef @.str, ptr noundef @__func__.AlignedGrow, ptr noundef @.str.27)
  call void @__assert_fail(ptr noundef @.str.28, ptr noundef @.str, i32 noundef 222, ptr noundef @__PRETTY_FUNCTION__.AlignedGrow) #9
  unreachable

88:                                               ; No predecessors!
  br label %89

89:                                               ; preds = %88, %79
  %90 = phi i1 [ true, %79 ], [ false, %88 ]
  %91 = load i64, ptr %18, align 8, !tbaa !9
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %91, ptr %92, align 8, !tbaa !9
  %93 = load i32, ptr %9, align 4, !tbaa !11
  %94 = icmp ne i32 0, %93
  br i1 %94, label %95, label %102

95:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = load ptr, ptr %96, align 8, !tbaa !5
  store ptr %97, ptr %19, align 8, !tbaa !5
  %98 = load ptr, ptr %16, align 8, !tbaa !5
  %99 = load ptr, ptr %19, align 8, !tbaa !5
  %100 = load i64, ptr %10, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %98, ptr align 1 %99, i64 %100, i1 false)
  %101 = load ptr, ptr %19, align 8, !tbaa !5
  call void @AlignedFree(ptr noundef %101)
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %102

102:                                              ; preds = %95, %89
  %103 = load ptr, ptr %16, align 8, !tbaa !5
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %103, ptr %104, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  store i32 0, ptr %12, align 4
  br label %105

105:                                              ; preds = %102, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %106

106:                                              ; preds = %105, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  %107 = load i32, ptr %12, align 4
  switch i32 %107, label %110 [
    i32 0, label %108
  ]

108:                                              ; preds = %106
  br label %109

109:                                              ; preds = %108, %4
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %110

110:                                              ; preds = %109, %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  %111 = load i32, ptr %5, align 4
  ret i32 %111
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

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 = { 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 = { 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 #4 = { 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 #5 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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"

@.str = external hidden unnamed_addr constant [89 x i8], align 1
@__func__.AlignedGrow = external hidden unnamed_addr constant [12 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.AlignedGrow = external hidden unnamed_addr constant [79 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [37 x i8], align 1

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 #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @AlignedFree(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local range(i32 -1, 1) i32 @AlignedGrow(ptr nocapture noundef %0, ptr nocapture noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #4 {
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = icmp ult i64 %5, %2
  br i1 %6, label %7, label %.critedge

7:                                                ; preds = %4
  %8 = lshr i64 %2, 1
  %9 = sub nuw i64 -88, %8
  %10 = icmp ult i64 %9, %2
  br i1 %10, label %.critedge, label %11

11:                                               ; preds = %7
  %12 = add nuw i64 %2, 87
  %13 = add i64 %12, %8
  %14 = icmp eq i32 %3, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %11
  %16 = load ptr, ptr %0, align 8, !tbaa !9
  tail call void @AlignedFree(ptr noundef %16)
  store ptr null, ptr %0, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %15, %11
  %18 = tail call noalias ptr @malloc(i64 noundef %13) #6
  %.not50 = icmp eq ptr %18, null
  br i1 %.not50, label %.critedge, label %19

19:                                               ; preds = %17
  %20 = ptrtoint ptr %18 to i64
  %21 = add i64 %20, 71
  %22 = and i64 %21, -64
  %23 = inttoptr i64 %22 to ptr
  %24 = icmp ult ptr %18, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %19
  tail call void @LogAssertFailure(i64 noundef 217, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.AlignedGrow, ptr noundef nonnull @.str.23)
  tail call void @__assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str, i32 noundef 217, ptr noundef nonnull @__PRETTY_FUNCTION__.AlignedGrow) #7
  unreachable

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %23, i64 -8
  store ptr %18, ptr %27, align 8, !tbaa !9
  %28 = sub i64 %22, %20
  %29 = icmp ult i64 %28, %13
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  tail call void @LogAssertFailure(i64 noundef 220, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.AlignedGrow, ptr noundef nonnull @.str.25)
  tail call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str, i32 noundef 220, ptr noundef nonnull @__PRETTY_FUNCTION__.AlignedGrow) #7
  unreachable

31:                                               ; preds = %26
  %32 = sub i64 %13, %28
  %.not = icmp ult i64 %32, %2
  br i1 %.not, label %33, label %34

33:                                               ; preds = %31
  tail call void @LogAssertFailure(i64 noundef 222, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.AlignedGrow, ptr noundef nonnull @.str.27)
  tail call void @__assert_fail(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str, i32 noundef 222, ptr noundef nonnull @__PRETTY_FUNCTION__.AlignedGrow) #7
  unreachable

34:                                               ; preds = %31
  store i64 %32, ptr %1, align 8, !tbaa !5
  br i1 %14, label %37, label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %0, align 8, !tbaa !9
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 64 %23, ptr align 1 %36, i64 %5, i1 false)
  tail call void @AlignedFree(ptr noundef %36)
  br label %37

37:                                               ; preds = %35, %34
  store ptr %23, ptr %0, align 8, !tbaa !9
  br label %.critedge

.critedge:                                        ; preds = %4, %37, %17, %7
  %.2 = phi i32 [ -1, %7 ], [ -1, %17 ], [ 0, %37 ], [ 0, %4 ]
  ret i32 %.2
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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


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