; LLVM IR from cruppstahl/upscaledb :: src/3page_manager/freelist.ll (ZN9upscaledb8Freelist8truncateEm)

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

%"class.std::reverse_iterator" = type { %"struct.std::_Rb_tree_iterator" }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.upscaledb::Freelist" = type { ptr, %"class.std::map", i64, i64 }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned long, std::pair<const unsigned long, unsigned long>, std::_Select1st<std::pair<const unsigned long, unsigned long>>, std::less<unsigned long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned long, std::pair<const unsigned long, unsigned long>, std::_Select1st<std::pair<const unsigned long, unsigned long>>, std::less<unsigned long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.upscaledb::EnvConfig" = type <{ i32, i32, i32, i32, i64, i64, i64, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i8, [16 x i8], [3 x i8], i64, i32, [4 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"struct.std::pair.3" = type { i64, i64 }

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN9upscaledb8Freelist8truncateEm(ptr noundef nonnull align 8 dereferenceable(72) %0, i64 noundef %1) #1 align 2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.std::reverse_iterator", align 8
  %10 = alloca %"class.std::reverse_iterator", align 8
  %11 = alloca %"class.std::reverse_iterator", align 8
  %12 = alloca %"class.std::reverse_iterator", align 8
  %13 = alloca %"class.std::reverse_iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %14 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %15 = getelementptr inbounds %"struct.upscaledb::Freelist", ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = getelementptr inbounds %"struct.upscaledb::EnvConfig", ptr %16, i32 0, i32 3
  %18 = load i32, ptr %17, align 4, !tbaa !21
  store i32 %18, ptr %6, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %19 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %19, ptr %7, align 8, !tbaa !9
  %20 = getelementptr inbounds %"struct.upscaledb::Freelist", ptr %14, i32 0, i32 1
  %21 = call noundef zeroext i1 @_ZNKSt3mapImmSt4lessImESaISt4pairIKmmEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) %20) #4
  br i1 %21, label %22, label %24

22:                                               ; preds = %2
  %23 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %23, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %72

24:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %25 = getelementptr inbounds %"struct.upscaledb::Freelist", ptr %14, i32 0, i32 1
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE6rbeginEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator") align 8 %9, ptr noundef nonnull align 8 dereferenceable(48) %25) #4
  br label %26

26:                                               ; preds = %49, %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %27 = getelementptr inbounds %"struct.upscaledb::Freelist", ptr %14, i32 0, i32 1
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE4rendEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator") align 8 %10, ptr noundef nonnull align 8 dereferenceable(48) %27) #4
  %28 = call noundef zeroext i1 @_ZStneISt17_Rb_tree_iteratorISt4pairIKmmEEEbRKSt16reverse_iteratorIT_ES9_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 2, ptr %8, align 4
  br label %50

30:                                               ; preds = %26
  %31 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %32 = getelementptr inbounds %"struct.std::pair.3", ptr %31, i32 0, i32 0
  %33 = load i64, ptr %32, align 8, !tbaa !28
  %34 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %35 = getelementptr inbounds %"struct.std::pair.3", ptr %34, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !30
  %37 = load i32, ptr %6, align 4, !tbaa !27
  %38 = zext i32 %37 to i64
  %39 = mul i64 %36, %38
  %40 = add i64 %33, %39
  %41 = load i64, ptr %7, align 8, !tbaa !9
  %42 = icmp eq i64 %40, %41
  br i1 %42, label %43, label %47

43:                                               ; preds = %30
  %44 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %45 = getelementptr inbounds %"struct.std::pair.3", ptr %44, i32 0, i32 0
  %46 = load i64, ptr %45, align 8, !tbaa !28
  store i64 %46, ptr %7, align 8, !tbaa !9
  br label %48

47:                                               ; preds = %30
  store i32 2, ptr %8, align 4
  br label %50

48:                                               ; preds = %43
  br label %49

49:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @_ZNSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEppEi(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator") align 8 %11, ptr noundef nonnull align 8 dereferenceable(8) %9, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %26, !llvm.loop !31

50:                                               ; preds = %47, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %64, %51
  %53 = getelementptr inbounds %"struct.upscaledb::Freelist", ptr %14, i32 0, i32 1
  %54 = call noundef zeroext i1 @_ZNKSt3mapImmSt4lessImESaISt4pairIKmmEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) %53) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  br i1 %54, label %62, label %55

55:                                               ; preds = %52
  %56 = getelementptr inbounds %"struct.upscaledb::Freelist", ptr %14, i32 0, i32 1
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE6rbeginEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator") align 8 %12, ptr noundef nonnull align 8 dereferenceable(48) %56) #4
  %57 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %12)
  %58 = getelementptr inbounds %"struct.std::pair.3", ptr %57, i32 0, i32 0
  %59 = load i64, ptr %58, align 8, !tbaa !28
  %60 = load i64, ptr %7, align 8, !tbaa !9
  %61 = icmp uge i64 %59, %60
  br label %62

62:                                               ; preds = %55, %52
  %63 = phi i1 [ false, %52 ], [ %61, %55 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br i1 %63, label %64, label %70

64:                                               ; preds = %62
  %65 = getelementptr inbounds %"struct.upscaledb::Freelist", ptr %14, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %66 = getelementptr inbounds %"struct.upscaledb::Freelist", ptr %14, i32 0, i32 1
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE6rbeginEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator") align 8 %13, ptr noundef nonnull align 8 dereferenceable(48) %66) #4
  %67 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
  %68 = getelementptr inbounds %"struct.std::pair.3", ptr %67, i32 0, i32 0
  %69 = call noundef i64 @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) %65, ptr noundef nonnull align 8 dereferenceable(8) %68)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %52, !llvm.loop !33

70:                                               ; preds = %62
  %71 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %71, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %72

72:                                               ; preds = %70, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %73 = load i64, ptr %3, align 8
  ret i64 %73
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt3mapImmSt4lessImESaISt4pairIKmmEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE6rbeginEv(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZStneISt17_Rb_tree_iteratorISt4pairIKmmEEEbRKSt16reverse_iteratorIT_ES9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE4rendEv(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEppEi(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { inlinehint 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 #4 = { 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, !6, i64 0}
!12 = !{!"_ZTSN9upscaledb8FreelistE", !6, i64 0, !13, i64 8, !10, i64 56, !10, i64 64}
!13 = !{!"_ZTSSt3mapImmSt4lessImESaISt4pairIKmmEEE", !14, i64 0}
!14 = !{!"_ZTSSt8_Rb_treeImSt4pairIKmmESt10_Select1stIS2_ESt4lessImESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSNSt8_Rb_treeImSt4pairIKmmESt10_Select1stIS2_ESt4lessImESaIS2_EE13_Rb_tree_implIS6_Lb1EEE", !16, i64 0, !18, i64 8}
!16 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessImEE", !17, i64 0}
!17 = !{!"_ZTSSt4lessImE"}
!18 = !{!"_ZTSSt15_Rb_tree_header", !19, i64 0, !10, i64 32}
!19 = !{!"_ZTSSt18_Rb_tree_node_base", !20, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!21 = !{!22, !23, i64 12}
!22 = !{!"_ZTSN9upscaledb9EnvConfigE", !23, i64 0, !23, i64 4, !23, i64 8, !23, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !24, i64 40, !24, i64 72, !23, i64 104, !26, i64 108, !7, i64 109, !10, i64 128, !23, i64 136}
!23 = !{!"int", !7, i64 0}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !25, i64 0, !10, i64 8, !7, i64 16}
!25 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!26 = !{!"bool", !7, i64 0}
!27 = !{!23, !23, i64 0}
!28 = !{!29, !10, i64 0}
!29 = !{!"_ZTSSt4pairIKmmE", !10, i64 0, !10, i64 8}
!30 = !{!29, !10, i64 8}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}
!33 = distinct !{!33, !32}


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

%"class.std::reverse_iterator" = type { %"struct.std::_Rb_tree_iterator" }
%"struct.std::_Rb_tree_iterator" = type { ptr }

; 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 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 noundef i64 @_ZN9upscaledb8Freelist8truncateEm(ptr noundef nonnull align 8 dereferenceable(72) %0, i64 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.std::reverse_iterator", align 8
  %4 = alloca %"class.std::reverse_iterator", align 8
  %5 = alloca %"class.std::reverse_iterator", align 8
  %6 = alloca %"class.std::reverse_iterator", align 8
  %7 = alloca %"class.std::reverse_iterator", align 8
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 12
  %10 = load i32, ptr %9, align 4, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = tail call noundef zeroext i1 @_ZNKSt3mapImmSt4lessImESaISt4pairIKmmEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) %11) #4
  br i1 %12, label %.loopexit, label %13

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(48) %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE4rendEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(48) %11) #4
  %14 = call noundef zeroext i1 @_ZStneISt17_Rb_tree_iteratorISt4pairIKmmEEEbRKSt16reverse_iteratorIT_ES9_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %13
  %15 = zext i32 %10 to i64
  br label %16

16:                                               ; preds = %.lr.ph, %25
  %.08 = phi i64 [ %1, %.lr.ph ], [ %27, %25 ]
  %17 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %18 = load i64, ptr %17, align 8, !tbaa !25
  %19 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !27
  %22 = mul i64 %21, %15
  %23 = add i64 %22, %18
  %24 = icmp eq i64 %23, %.08
  br i1 %24, label %25, label %._crit_edge

25:                                               ; preds = %16
  %26 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %27 = load i64, ptr %26, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @_ZNSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEppEi(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %5, ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE4rendEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(48) %11) #4
  %28 = call noundef zeroext i1 @_ZStneISt17_Rb_tree_iteratorISt4pairIKmmEEEbRKSt16reverse_iteratorIT_ES9_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br i1 %28, label %16, label %._crit_edge, !llvm.loop !28

._crit_edge:                                      ; preds = %25, %16, %13
  %.0.lcssa = phi i64 [ %1, %13 ], [ %.08, %16 ], [ %27, %25 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %29 = call noundef zeroext i1 @_ZNKSt3mapImmSt4lessImESaISt4pairIKmmEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  br i1 %29, label %.critedge, label %.lr.ph12

.lr.ph12:                                         ; preds = %._crit_edge, %32
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(48) %11) #4
  %30 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %31 = load i64, ptr %30, align 8, !tbaa !25
  %.not = icmp ult i64 %31, %.0.lcssa
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br i1 %.not, label %.loopexit, label %32

32:                                               ; preds = %.lr.ph12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  call void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %7, ptr noundef nonnull align 8 dereferenceable(48) %11) #4
  %33 = call noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %34 = call noundef i64 @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48) %11, ptr noundef nonnull align 8 dereferenceable(8) %33)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  %35 = call noundef zeroext i1 @_ZNKSt3mapImmSt4lessImESaISt4pairIKmmEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48) %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  br i1 %35, label %.critedge, label %.lr.ph12, !llvm.loop !30

.critedge:                                        ; preds = %32, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph12, %.critedge, %2
  %.07 = phi i64 [ %1, %2 ], [ %.0.lcssa, %.critedge ], [ %.0.lcssa, %.lr.ph12 ]
  ret i64 %.07
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt3mapImmSt4lessImESaISt4pairIKmmEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE6rbeginEv(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZStneISt17_Rb_tree_iteratorISt4pairIKmmEEEbRKSt16reverse_iteratorIT_ES9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE4rendEv(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNKSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt16reverse_iteratorISt17_Rb_tree_iteratorISt4pairIKmmEEEppEi(ptr dead_on_unwind noalias writable sret(%"class.std::reverse_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3mapImmSt4lessImESaISt4pairIKmmEEE5eraseERS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { inlinehint 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 #4 = { 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, !7, i64 0}
!6 = !{!"_ZTSN9upscaledb8FreelistE", !7, i64 0, !10, i64 8, !18, i64 56, !18, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt3mapImmSt4lessImESaISt4pairIKmmEEE", !11, i64 0}
!11 = !{!"_ZTSSt8_Rb_treeImSt4pairIKmmESt10_Select1stIS2_ESt4lessImESaIS2_EE", !12, i64 0}
!12 = !{!"_ZTSNSt8_Rb_treeImSt4pairIKmmESt10_Select1stIS2_ESt4lessImESaIS2_EE13_Rb_tree_implIS6_Lb1EEE", !13, i64 0, !15, i64 8}
!13 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessImEE", !14, i64 0}
!14 = !{!"_ZTSSt4lessImE"}
!15 = !{!"_ZTSSt15_Rb_tree_header", !16, i64 0, !18, i64 32}
!16 = !{!"_ZTSSt18_Rb_tree_node_base", !17, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!17 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!18 = !{!"long", !8, i64 0}
!19 = !{!20, !21, i64 12}
!20 = !{!"_ZTSN9upscaledb9EnvConfigE", !21, i64 0, !21, i64 4, !21, i64 8, !21, i64 12, !18, i64 16, !18, i64 24, !18, i64 32, !22, i64 40, !22, i64 72, !21, i64 104, !24, i64 108, !8, i64 109, !18, i64 128, !21, i64 136}
!21 = !{!"int", !8, i64 0}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !23, i64 0, !18, i64 8, !8, i64 16}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !7, i64 0}
!24 = !{!"bool", !8, i64 0}
!25 = !{!26, !18, i64 0}
!26 = !{!"_ZTSSt4pairIKmmE", !18, i64 0, !18, i64 8}
!27 = !{!26, !18, i64 8}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}


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