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

; 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 [96 x i8], align 1
@__func__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd = external hidden unnamed_addr constant [38 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd = external hidden unnamed_addr constant [90 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.122 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.123 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.124 = external hidden unnamed_addr constant [38 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

declare void @LogAssertFailure(i64 noundef, ptr noundef, ptr noundef, 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.start.p0(i64 immarg, ptr nocapture) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #5

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE3maxEv() #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE6lowestEv() #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd(i64 noundef %0, ptr noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  %10 = load i64, ptr %3, align 8, !tbaa !5
  %11 = icmp ule i64 1, %10
  br i1 %11, label %15, label %12

12:                                               ; preds = %2
  invoke void @LogAssertFailure(i64 noundef 798, ptr noundef @.str, ptr noundef @__func__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd, ptr noundef @.str.119)
          to label %13 unwind label %91

13:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.120, ptr noundef @.str, i32 noundef 798, ptr noundef @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd) #6
  unreachable

14:                                               ; No predecessors!
  br label %15

15:                                               ; preds = %14, %2
  %16 = phi i1 [ true, %2 ], [ false, %14 ]
  %17 = load ptr, ptr %4, align 8, !tbaa !9
  %18 = icmp ne ptr null, %17
  br i1 %18, label %22, label %19

19:                                               ; preds = %15
  invoke void @LogAssertFailure(i64 noundef 799, ptr noundef @.str, ptr noundef @__func__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd, ptr noundef @.str.121)
          to label %20 unwind label %91

20:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.122, ptr noundef @.str, i32 noundef 799, ptr noundef @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd) #6
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %15
  %23 = phi i1 [ true, %15 ], [ false, %21 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %24 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %24, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %25 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %25, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %26 = load ptr, ptr %4, align 8, !tbaa !9
  %27 = load i64, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds double, ptr %26, i64 %27
  store ptr %28, ptr %7, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %66, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = load double, ptr %30, align 8, !tbaa !11
  store double %31, ptr %8, align 8, !tbaa !11
  %32 = load double, ptr %8, align 8, !tbaa !11
  %33 = invoke noundef zeroext i1 @_ZSt5isnand(double noundef %32)
          to label %34 unwind label %91

34:                                               ; preds = %29
  br i1 %33, label %63, label %35

35:                                               ; preds = %34
  %36 = call noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #7
  %37 = load double, ptr %8, align 8, !tbaa !11
  %38 = fcmp oeq double %36, %37
  %39 = xor i1 %38, true
  %40 = xor i1 %39, true
  br i1 %40, label %41, label %43, !unpredictable !13

41:                                               ; preds = %35
  %42 = call noundef double @_ZNSt14numeric_limitsIdE3maxEv() #7
  br label %45

43:                                               ; preds = %35
  %44 = load double, ptr %8, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %43, %41
  %46 = phi double [ %42, %41 ], [ %44, %43 ]
  store double %46, ptr %8, align 8, !tbaa !11
  %47 = call noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #7
  %48 = fneg double %47
  %49 = load double, ptr %8, align 8, !tbaa !11
  %50 = fcmp oeq double %48, %49
  %51 = xor i1 %50, true
  %52 = xor i1 %51, true
  br i1 %52, label %53, label %55, !unpredictable !13

53:                                               ; preds = %45
  %54 = call noundef double @_ZNSt14numeric_limitsIdE6lowestEv() #7
  br label %57

55:                                               ; preds = %45
  %56 = load double, ptr %8, align 8, !tbaa !11
  br label %57

57:                                               ; preds = %55, %53
  %58 = phi double [ %54, %53 ], [ %56, %55 ]
  store double %58, ptr %8, align 8, !tbaa !11
  %59 = load double, ptr %8, align 8, !tbaa !11
  %60 = load ptr, ptr %6, align 8, !tbaa !9
  store double %59, ptr %60, align 8, !tbaa !11
  %61 = load ptr, ptr %6, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %61, i32 1
  store ptr %62, ptr %6, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %57, %34
  %64 = load ptr, ptr %5, align 8, !tbaa !9
  %65 = getelementptr inbounds double, ptr %64, i32 1
  store ptr %65, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %66

66:                                               ; preds = %63
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = load ptr, ptr %5, align 8, !tbaa !9
  %69 = icmp ne ptr %67, %68
  %70 = xor i1 %69, true
  %71 = xor i1 %70, true
  %72 = zext i1 %71 to i64
  %73 = call i64 @llvm.expect.i64(i64 %72, i64 1)
  %74 = icmp ne i64 %73, 0
  br i1 %74, label %29, label %75, !llvm.loop !14

75:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %76 = load ptr, ptr %6, align 8, !tbaa !9
  %77 = load ptr, ptr %4, align 8, !tbaa !9
  %78 = ptrtoint ptr %76 to i64
  %79 = ptrtoint ptr %77 to i64
  %80 = sub i64 %78, %79
  %81 = sdiv exact i64 %80, 8
  store i64 %81, ptr %9, align 8, !tbaa !5
  %82 = load i64, ptr %9, align 8, !tbaa !5
  %83 = load i64, ptr %3, align 8, !tbaa !5
  %84 = icmp ule i64 %82, %83
  br i1 %84, label %88, label %85

85:                                               ; preds = %75
  invoke void @LogAssertFailure(i64 noundef 852, ptr noundef @.str, ptr noundef @__func__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd, ptr noundef @.str.123)
          to label %86 unwind label %91

86:                                               ; preds = %85
  call void @__assert_fail(ptr noundef @.str.124, ptr noundef @.str, i32 noundef 852, ptr noundef @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd) #6
  unreachable

87:                                               ; No predecessors!
  br label %88

88:                                               ; preds = %87, %75
  %89 = phi i1 [ true, %75 ], [ false, %87 ]
  %90 = load i64, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  ret i64 %90

91:                                               ; preds = %85, %29, %19, %12
  %92 = landingpad { ptr, i32 }
          catch ptr null
  %93 = extractvalue { ptr, i32 } %92, 0
  call void @__clang_call_terminate(ptr %93) #6
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #0 align 2

attributes #0 = { 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 #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = !{!"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 = !{!"double", !7, i64 0}
!13 = !{}
!14 = distinct !{!14, !15}
!15 = !{!"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 [96 x i8], align 1
@__func__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd = external hidden unnamed_addr constant [38 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd = external hidden unnamed_addr constant [90 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.122 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.123 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.124 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSt5isnand(double 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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE3maxEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE6lowestEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i64 -1152921504606846976, 1152921504606846976) i64 @_ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd(i64 noundef %0, ptr noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %.not = icmp eq i64 %0, 0
  br i1 %.not, label %3, label %5

3:                                                ; preds = %2
  invoke void @LogAssertFailure(i64 noundef 798, ptr noundef nonnull @.str, ptr noundef nonnull @__func__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd, ptr noundef nonnull @.str.119)
          to label %4 unwind label %38

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.120, ptr noundef nonnull @.str, i32 noundef 798, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd) #4
  unreachable

5:                                                ; preds = %2
  %.not29 = icmp eq ptr %1, null
  br i1 %.not29, label %6, label %8

6:                                                ; preds = %5
  invoke void @LogAssertFailure(i64 noundef 799, ptr noundef nonnull @.str, ptr noundef nonnull @__func__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd, ptr noundef nonnull @.str.121)
          to label %7 unwind label %38

7:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.122, ptr noundef nonnull @.str, i32 noundef 799, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd) #4
  unreachable

8:                                                ; preds = %5
  %9 = getelementptr inbounds double, ptr %1, i64 %0
  br label %10

10:                                               ; preds = %28, %8
  %.022 = phi ptr [ %1, %8 ], [ %.1, %28 ]
  %.0 = phi ptr [ %1, %8 ], [ %29, %28 ]
  %11 = load double, ptr %.0, align 8, !tbaa !5
  %12 = tail call noundef zeroext i1 @_ZSt5isnand(double noundef %11)
  br i1 %12, label %28, label %13

13:                                               ; preds = %10
  %14 = tail call noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #5
  %15 = fcmp oeq double %14, %11
  br i1 %15, label %16, label %18, !unpredictable !9

16:                                               ; preds = %13
  %17 = tail call noundef double @_ZNSt14numeric_limitsIdE3maxEv() #5
  br label %18

18:                                               ; preds = %13, %16
  %19 = phi double [ %17, %16 ], [ %11, %13 ]
  %20 = tail call noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #5
  %21 = fneg double %20
  %22 = fcmp oeq double %19, %21
  br i1 %22, label %23, label %25, !unpredictable !9

23:                                               ; preds = %18
  %24 = tail call noundef double @_ZNSt14numeric_limitsIdE6lowestEv() #5
  br label %25

25:                                               ; preds = %18, %23
  %26 = phi double [ %24, %23 ], [ %19, %18 ]
  store double %26, ptr %.022, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.022, i64 8
  br label %28

28:                                               ; preds = %25, %10
  %.1 = phi ptr [ %.022, %10 ], [ %27, %25 ]
  %29 = getelementptr inbounds i8, ptr %.0, i64 8
  %.not30 = icmp eq ptr %9, %29
  br i1 %.not30, label %30, label %10, !prof !10, !llvm.loop !11

30:                                               ; preds = %28
  %31 = ptrtoint ptr %.1 to i64
  %32 = ptrtoint ptr %1 to i64
  %33 = sub i64 %31, %32
  %34 = ashr exact i64 %33, 3
  %.not31 = icmp ugt i64 %34, %0
  br i1 %.not31, label %35, label %37

35:                                               ; preds = %30
  invoke void @LogAssertFailure(i64 noundef 852, ptr noundef nonnull @.str, ptr noundef nonnull @__func__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd, ptr noundef nonnull @.str.123)
          to label %36 unwind label %38

36:                                               ; preds = %35
  tail call void @__assert_fail(ptr noundef nonnull @.str.124, ptr noundef nonnull @.str, i32 noundef 852, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN14NAMESPACE_MAIN37RemoveMissingValsAndReplaceInfinitiesEmPd) #4
  unreachable

37:                                               ; preds = %30
  ret i64 %34

38:                                               ; preds = %35, %6, %3
  %39 = landingpad { ptr, i32 }
          catch ptr null
  %40 = extractvalue { ptr, i32 } %39, 0
  tail call void @__clang_call_terminate(ptr %40) #4
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE8infinityEv() local_unnamed_addr #0 align 2

attributes #0 = { 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 #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 = { "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 = { noreturn nounwind }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{}
!10 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass