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

; 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 global i32, align 4
@_ZZ11CleanFloatsE13LOG__sMessage = external hidden constant [59 x i8], align 16
@_ZZ11CleanFloatsE13LOG__sMessage_0 = external hidden constant [61 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSt5isnand(double noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @CleanFloats(i64 noundef %0, ptr noundef %1) #2 {
  %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
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = call noundef zeroext i1 @_ZN14NAMESPACE_MAINL14IsConvertErrorImlEENSt9enable_ifIXaaaantsr3std9is_signedIT_EE5valuesr3std9is_signedIT0_EE5valueleclsr3std14numeric_limitsIS3_EE3maxEclsr3std14numeric_limitsIS2_EE3maxEEbE4typeES3_(i64 noundef %11) #5
  br i1 %12, label %13, label %20

13:                                               ; preds = %2
  br label %14

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

17:                                               ; preds = %14
  call void @InteralLogWithoutArguments(i32 noundef 1, ptr noundef @_ZZ11CleanFloatsE13LOG__sMessage)
  br label %18

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

19:                                               ; preds = %18
  br label %61

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %21 = load i64, ptr %3, align 8, !tbaa !5
  store i64 %21, ptr %6, align 8, !tbaa !5
  %22 = load i64, ptr %6, align 8, !tbaa !5
  %23 = call noundef zeroext i1 @_ZN14NAMESPACE_MAINL15IsMultiplyErrorImEEbT_S1_(i64 noundef 8, i64 noundef %22) #5
  br i1 %23, label %24, label %32

24:                                               ; preds = %20
  br label %25

25:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !11
  %26 = load i32, ptr @g_traceLevel, align 4, !tbaa !11
  %27 = icmp sle i32 1, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  call void @InteralLogWithoutArguments(i32 noundef 1, ptr noundef @_ZZ11CleanFloatsE13LOG__sMessage_0)
  br label %29

29:                                               ; preds = %28, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  store i32 1, ptr %8, align 4
  br label %59

32:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %33 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %33, ptr %9, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %57, %32
  %35 = load i64, ptr %6, align 8, !tbaa !5
  %36 = icmp ne i64 0, %35
  br i1 %36, label %37, label %58

37:                                               ; preds = %34
  %38 = load i64, ptr %6, align 8, !tbaa !5
  %39 = add i64 %38, -1
  store i64 %39, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %40 = load ptr, ptr %9, align 8, !tbaa !9
  %41 = load i64, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds double, ptr %40, i64 %41
  %43 = load volatile double, ptr %42, align 8, !tbaa !13
  store volatile double %43, ptr %10, align 8, !tbaa !13
  %44 = load volatile double, ptr %10, align 8, !tbaa !13
  %45 = call noundef zeroext i1 @_ZSt5isnand(double noundef %44)
  br i1 %45, label %57, label %46

46:                                               ; preds = %37
  %47 = load volatile double, ptr %10, align 8, !tbaa !13
  %48 = fcmp olt double 0x8010000000000000, %47
  br i1 %48, label %49, label %56

49:                                               ; preds = %46
  %50 = load volatile double, ptr %10, align 8, !tbaa !13
  %51 = fcmp olt double %50, 0x10000000000000
  br i1 %51, label %52, label %56

52:                                               ; preds = %49
  %53 = load ptr, ptr %9, align 8, !tbaa !9
  %54 = load i64, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds double, ptr %53, i64 %54
  store volatile double 0.000000e+00, ptr %55, align 8, !tbaa !13
  br label %56

56:                                               ; preds = %52, %49, %46
  br label %57

57:                                               ; preds = %56, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %34, !llvm.loop !15

58:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  store i32 0, ptr %8, align 4
  br label %59

59:                                               ; preds = %58, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %60 = load i32, ptr %8, align 4
  switch i32 %60, label %62 [
    i32 0, label %61
    i32 1, label %61
  ]

61:                                               ; preds = %59, %59, %19
  ret void

62:                                               ; preds = %59
  unreachable
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { "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 = { 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 = !{!14, !14, i64 0}
!14 = !{!"double", !7, 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
@_ZZ11CleanFloatsE13LOG__sMessage = external hidden constant [59 x i8], align 16
@_ZZ11CleanFloatsE13LOG__sMessage_0 = external hidden constant [61 x i8], align 16

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSt5isnand(double noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @CleanFloats(i64 noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca double, align 8
  %4 = tail call noundef zeroext i1 @_ZN14NAMESPACE_MAINL14IsConvertErrorImlEENSt9enable_ifIXaaaantsr3std9is_signedIT_EE5valuesr3std9is_signedIT0_EE5valueleclsr3std14numeric_limitsIS3_EE3maxEclsr3std14numeric_limitsIS2_EE3maxEEbE4typeES3_(i64 noundef %0) #5
  br i1 %4, label %5, label %8

5:                                                ; preds = %2
  %6 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.loopexit.sink.split, label %.loopexit

8:                                                ; preds = %2
  %9 = tail call noundef zeroext i1 @_ZN14NAMESPACE_MAINL15IsMultiplyErrorImEEbT_S1_(i64 noundef 8, i64 noundef %0) #5
  br i1 %9, label %10, label %.preheader

.preheader:                                       ; preds = %8
  %.not12 = icmp eq i64 %0, 0
  br i1 %.not12, label %.loopexit, label %.lr.ph

10:                                               ; preds = %8
  %11 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.loopexit.sink.split, label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %22
  %.013 = phi i64 [ %13, %22 ], [ %0, %.preheader ]
  %13 = add i64 %.013, -1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3)
  %14 = getelementptr inbounds double, ptr %1, i64 %13
  %15 = load volatile double, ptr %14, align 8, !tbaa !9
  store volatile double %15, ptr %3, align 8, !tbaa !9
  %.0..0..0..0. = load volatile double, ptr %3, align 8, !tbaa !9
  %16 = tail call noundef zeroext i1 @_ZSt5isnand(double noundef %.0..0..0..0.)
  br i1 %16, label %22, label %17

17:                                               ; preds = %.lr.ph
  %.0..0..0..0.1 = load volatile double, ptr %3, align 8, !tbaa !9
  %18 = fcmp ogt double %.0..0..0..0.1, 0x8010000000000000
  br i1 %18, label %19, label %22

19:                                               ; preds = %17
  %.0..0..0..0.2 = load volatile double, ptr %3, align 8, !tbaa !9
  %20 = fcmp olt double %.0..0..0..0.2, 0x10000000000000
  br i1 %20, label %21, label %22

21:                                               ; preds = %19
  store volatile double 0.000000e+00, ptr %14, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %17, %19, %21, %.lr.ph
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3)
  %.not = icmp eq i64 %13, 0
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !11

.loopexit.sink.split:                             ; preds = %10, %5
  %_ZZ11CleanFloatsE13LOG__sMessage_0.sink = phi ptr [ @_ZZ11CleanFloatsE13LOG__sMessage, %5 ], [ @_ZZ11CleanFloatsE13LOG__sMessage_0, %10 ]
  tail call void @InteralLogWithoutArguments(i32 noundef 1, ptr noundef nonnull %_ZZ11CleanFloatsE13LOG__sMessage_0.sink)
  br label %.loopexit

.loopexit:                                        ; preds = %22, %.loopexit.sink.split, %.preheader, %10, %5
  ret void
}

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { "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 = { 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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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