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

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

@g_traceLevel = external dso_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@_ZL22g_pLogCallbackFunction = external hidden global ptr, align 8
@_ZZ13SetTraceLevelE12sStartLogOff = external hidden constant [42 x i8], align 16
@_ZZ13SetTraceLevelE14sStartLogError = external hidden constant [44 x i8], align 16
@_ZZ13SetTraceLevelE16sStartLogWarning = external hidden constant [46 x i8], align 16
@_ZZ13SetTraceLevelE13sStartLogInfo = external hidden constant [43 x i8], align 16
@_ZZ13SetTraceLevelE16sStartLogVerbose = external hidden constant [46 x i8], align 16
@_ZZ13SetTraceLevelE16sStartLogIllegal = external hidden constant [46 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [53 x i8], align 1
@__PRETTY_FUNCTION__.SetTraceLevel = external hidden unnamed_addr constant [29 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @SetTraceLevel(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %4 = load i32, ptr %2, align 4, !tbaa !5
  switch i32 %4, label %14 [
    i32 0, label %5
    i32 1, label %10
    i32 2, label %11
    i32 3, label %12
    i32 4, label %13
  ]

5:                                                ; preds = %1
  %6 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %7 = icmp eq i32 0, %6
  %8 = zext i1 %7 to i64
  %9 = select i1 %7, ptr null, ptr @_ZZ13SetTraceLevelE12sStartLogOff
  store ptr %9, ptr %3, align 8, !tbaa !9
  br label %19

10:                                               ; preds = %1
  store ptr @_ZZ13SetTraceLevelE14sStartLogError, ptr %3, align 8, !tbaa !9
  br label %19

11:                                               ; preds = %1
  store ptr @_ZZ13SetTraceLevelE16sStartLogWarning, ptr %3, align 8, !tbaa !9
  br label %19

12:                                               ; preds = %1
  store ptr @_ZZ13SetTraceLevelE13sStartLogInfo, ptr %3, align 8, !tbaa !9
  br label %19

13:                                               ; preds = %1
  store ptr @_ZZ13SetTraceLevelE16sStartLogVerbose, ptr %3, align 8, !tbaa !9
  br label %19

14:                                               ; preds = %1
  %15 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %16 = icmp eq i32 0, %15
  %17 = zext i1 %16 to i64
  %18 = select i1 %16, ptr null, ptr @_ZZ13SetTraceLevelE16sStartLogIllegal
  store ptr %18, ptr %3, align 8, !tbaa !9
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %14, %13, %12, %11, %10, %5
  %20 = load ptr, ptr @_ZL22g_pLogCallbackFunction, align 8, !tbaa !9
  %21 = icmp eq ptr null, %20
  br i1 %21, label %22, label %34

22:                                               ; preds = %19
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = icmp eq i32 0, %23
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %27 = icmp eq i32 0, %26
  br label %28

28:                                               ; preds = %25, %22
  %29 = phi i1 [ false, %22 ], [ %27, %25 ]
  br i1 %29, label %30, label %31

30:                                               ; preds = %28
  br label %33

31:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 96, ptr noundef @__PRETTY_FUNCTION__.SetTraceLevel) #4
  unreachable

32:                                               ; No predecessors!
  br label %33

33:                                               ; preds = %32, %30
  store i32 0, ptr %2, align 4, !tbaa !5
  store ptr null, ptr %3, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %33, %19
  %35 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %34
  %39 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %39, ptr @g_traceLevel, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %38, %34
  %41 = load ptr, ptr %3, align 8, !tbaa !9
  %42 = icmp ne ptr null, %41
  br i1 %42, label %43, label %45

43:                                               ; preds = %40
  %44 = load ptr, ptr %3, align 8, !tbaa !9
  call void @InteralLogWithoutArguments(i32 noundef 1, ptr noundef %44)
  br label %45

45:                                               ; preds = %43, %40
  %46 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %46, ptr @g_traceLevel, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local 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) #2

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }
attributes #4 = { 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 = !{!"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}


; 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 dso_local local_unnamed_addr global i32, align 4
@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@_ZL22g_pLogCallbackFunction = external hidden local_unnamed_addr global ptr, align 8
@_ZZ13SetTraceLevelE12sStartLogOff = external hidden constant [42 x i8], align 16
@_ZZ13SetTraceLevelE14sStartLogError = external hidden constant [44 x i8], align 16
@_ZZ13SetTraceLevelE16sStartLogWarning = external hidden constant [46 x i8], align 16
@_ZZ13SetTraceLevelE13sStartLogInfo = external hidden constant [43 x i8], align 16
@_ZZ13SetTraceLevelE16sStartLogVerbose = external hidden constant [46 x i8], align 16
@_ZZ13SetTraceLevelE16sStartLogIllegal = external hidden constant [46 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [53 x i8], align 1
@__PRETTY_FUNCTION__.SetTraceLevel = external hidden unnamed_addr constant [29 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @SetTraceLevel(i32 noundef %0) local_unnamed_addr #1 {
  switch i32 %0, label %9 [
    i32 0, label %2
    i32 1, label %13
    i32 2, label %6
    i32 3, label %7
    i32 4, label %8
  ]

2:                                                ; preds = %1
  %3 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %4 = icmp eq i32 %3, 0
  %5 = select i1 %4, ptr null, ptr @_ZZ13SetTraceLevelE12sStartLogOff
  br label %13

6:                                                ; preds = %1
  br label %13

7:                                                ; preds = %1
  br label %13

8:                                                ; preds = %1
  br label %13

9:                                                ; preds = %1
  %10 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %11 = icmp eq i32 %10, 0
  %12 = select i1 %11, ptr null, ptr @_ZZ13SetTraceLevelE16sStartLogIllegal
  br label %13

13:                                               ; preds = %1, %9, %8, %7, %6, %2
  %14 = phi i1 [ true, %9 ], [ false, %8 ], [ false, %7 ], [ false, %6 ], [ true, %2 ], [ false, %1 ]
  %.06 = phi i32 [ 0, %9 ], [ %0, %8 ], [ %0, %7 ], [ %0, %6 ], [ 0, %2 ], [ %0, %1 ]
  %.0 = phi ptr [ %12, %9 ], [ @_ZZ13SetTraceLevelE16sStartLogVerbose, %8 ], [ @_ZZ13SetTraceLevelE13sStartLogInfo, %7 ], [ @_ZZ13SetTraceLevelE16sStartLogWarning, %6 ], [ %5, %2 ], [ @_ZZ13SetTraceLevelE14sStartLogError, %1 ]
  %15 = load ptr, ptr @_ZL22g_pLogCallbackFunction, align 8, !tbaa !9
  %16 = icmp eq ptr %15, null
  %.pre = load i32, ptr @g_traceLevel, align 4
  br i1 %16, label %17, label %21

17:                                               ; preds = %13
  %18 = icmp eq i32 %.pre, 0
  %19 = select i1 %14, i1 %18, i1 false
  br i1 %19, label %.thread14, label %20

20:                                               ; preds = %17
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 96, ptr noundef nonnull @__PRETTY_FUNCTION__.SetTraceLevel) #2
  unreachable

21:                                               ; preds = %13
  %22 = icmp slt i32 %.pre, %.06
  br i1 %22, label %23, label %24

23:                                               ; preds = %21
  store i32 %.06, ptr @g_traceLevel, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %23, %21
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %.thread14, label %25

25:                                               ; preds = %24
  tail call void @InteralLogWithoutArguments(i32 noundef 1, ptr noundef nonnull %.0)
  br label %.thread14

.thread14:                                        ; preds = %17, %25, %24
  %.171218 = phi i32 [ %.06, %25 ], [ %.06, %24 ], [ 0, %17 ]
  store i32 %.171218, ptr @g_traceLevel, align 4, !tbaa !5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @InteralLogWithoutArguments(i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 }

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


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