; LLVM IR from interpretml/interpret :: shared/libebm/Term.ll (ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_)

; 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 [78 x i8], align 1
@g_traceLevel = external global i32, align 4
@_ZZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_E13LOG__sMessage = external hidden constant [24 x i8], align 16
@__func__._ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_ = external hidden unnamed_addr constant [10 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_ = external hidden unnamed_addr constant [67 x i8], align 1
@_ZZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_E13LOG__sMessage_0 = external hidden constant [23 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 @LogAssertFailure(i64 noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_(i64 noundef %0, ptr noundef %1) #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store i64 %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  br label %8

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

11:                                               ; preds = %8
  invoke void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_E13LOG__sMessage)
          to label %12 unwind label %57

12:                                               ; preds = %11
  br label %13

13:                                               ; preds = %12, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  %16 = load ptr, ptr %4, align 8, !tbaa !9
  %17 = icmp ne ptr null, %16
  br i1 %17, label %18, label %48

18:                                               ; preds = %15
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = icmp ult i64 0, %19
  br i1 %20, label %24, label %21

21:                                               ; preds = %18
  invoke void @LogAssertFailure(i64 noundef 58, ptr noundef @.str, ptr noundef @__func__._ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_, ptr noundef @.str.5)
          to label %22 unwind label %57

22:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str, i32 noundef 58, ptr noundef @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_) #8
  unreachable

23:                                               ; No predecessors!
  br label %24

24:                                               ; preds = %23, %18
  %25 = phi i1 [ true, %18 ], [ false, %23 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  store i64 0, ptr %6, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %43, %24
  %27 = load i64, ptr %6, align 8, !tbaa !5
  %28 = load i64, ptr %3, align 8, !tbaa !5
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %46

31:                                               ; preds = %26
  %32 = load ptr, ptr %4, align 8, !tbaa !9
  %33 = load i64, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds ptr, ptr %32, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = icmp ne ptr null, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %31
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  %39 = load i64, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds ptr, ptr %38, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  call void @_ZN14NAMESPACE_MAIN4Term4FreeEPS0_(ptr noundef %41) #7
  br label %42

42:                                               ; preds = %37, %31
  br label %43

43:                                               ; preds = %42
  %44 = load i64, ptr %6, align 8, !tbaa !5
  %45 = add i64 %44, 1
  store i64 %45, ptr %6, align 8, !tbaa !5
  br label %26, !llvm.loop !13

46:                                               ; preds = %30
  %47 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %47) #7
  br label %48

48:                                               ; preds = %46, %15
  br label %49

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

52:                                               ; preds = %49
  invoke void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_E13LOG__sMessage_0)
          to label %53 unwind label %57

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  ret void

57:                                               ; preds = %52, %21, %11
  %58 = landingpad { ptr, i32 }
          catch ptr null
  %59 = extractvalue { ptr, i32 } %58, 0
  call void @__clang_call_terminate(ptr %59) #8
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN14NAMESPACE_MAIN4Term4FreeEPS0_(ptr noundef) #5 align 2

; Function Attrs: nounwind
declare void @free(ptr noundef) #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 = { noinline noreturn nounwind uwtable "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 = { 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 #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 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { 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 = distinct !{!13, !14}
!14 = !{!"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"

@.str = external hidden unnamed_addr constant [78 x i8], align 1
@g_traceLevel = external local_unnamed_addr global i32, align 4
@_ZZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_E13LOG__sMessage = external hidden constant [24 x i8], align 16
@__func__._ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_ = external hidden unnamed_addr constant [10 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_ = external hidden unnamed_addr constant [67 x i8], align 1
@_ZZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_E13LOG__sMessage_0 = external hidden constant [23 x i8], align 16

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #1

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

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

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

5:                                                ; preds = %2
  invoke void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_E13LOG__sMessage)
          to label %6 unwind label %21

6:                                                ; preds = %5, %2
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %16, label %7

7:                                                ; preds = %6
  %.not12 = icmp eq i64 %0, 0
  br i1 %.not12, label %8, label %.preheader

8:                                                ; preds = %7
  invoke void @LogAssertFailure(i64 noundef 58, ptr noundef nonnull @.str, ptr noundef nonnull @__func__._ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_, ptr noundef nonnull @.str.5)
          to label %9 unwind label %21

9:                                                ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str, i32 noundef 58, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_) #6
  unreachable

10:                                               ; preds = %14
  tail call void @free(ptr noundef nonnull %1) #7
  br label %16

.preheader:                                       ; preds = %7, %14
  %.014 = phi i64 [ %15, %14 ], [ 0, %7 ]
  %11 = getelementptr inbounds ptr, ptr %1, i64 %.014
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %.not13 = icmp eq ptr %12, null
  br i1 %.not13, label %14, label %13

13:                                               ; preds = %.preheader
  tail call void @_ZN14NAMESPACE_MAIN4Term4FreeEPS0_(ptr noundef nonnull %12) #7
  br label %14

14:                                               ; preds = %.preheader, %13
  %15 = add nuw i64 %.014, 1
  %exitcond.not = icmp eq i64 %15, %0
  br i1 %exitcond.not, label %10, label %.preheader, !llvm.loop !11

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

19:                                               ; preds = %16
  invoke void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZN14NAMESPACE_MAIN4Term9FreeTermsEmPPS0_E13LOG__sMessage_0)
          to label %20 unwind label %21

20:                                               ; preds = %19, %16
  ret void

21:                                               ; preds = %19, %8, %5
  %22 = landingpad { ptr, i32 }
          catch ptr null
  %23 = extractvalue { ptr, i32 } %22, 0
  tail call void @__clang_call_terminate(ptr %23) #6
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN14NAMESPACE_MAIN4Term4FreeEPS0_(ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #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 = { noinline noreturn nounwind uwtable "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 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 = { 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 #5 = { 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 #6 = { noreturn nounwind }
attributes #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass