; LLVM IR from tangjz/acm-icpc :: codeforces/complete/932F.ll (Z5queryRSt3setISt4pairIixESt4lessIS1_ESaIS1_EES1_)

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

%"struct.std::pair" = type { i32, i64 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.std::reverse_iterator" = type { %"struct.std::_Rb_tree_const_iterator" }

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt23_Rb_tree_const_iteratorISt4pairIixEEmmEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5queryRSt3setISt4pairIixESt4lessIS1_ESaIS1_EES1_(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 %1, i64 %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca %"struct.std::pair", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::reverse_iterator", align 8
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %13 = alloca %"struct.std::pair", align 8
  %14 = alloca i64, align 8
  %15 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %16 = alloca %"struct.std::pair", align 8
  %17 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %18 = alloca %"struct.std::pair", align 8
  %19 = alloca i64, align 8
  %20 = getelementptr inbounds { i32, i64 }, ptr %5, i32 0, i32 0
  store i32 %1, ptr %20, align 8
  %21 = getelementptr inbounds { i32, i64 }, ptr %5, i32 0, i32 1
  store i64 %2, ptr %21, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = call noundef i64 @_ZNKSt3setISt4pairIixESt4lessIS1_ESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %22) #4
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %3
  store i64 0, ptr %4, align 8
  br label %100

26:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call ptr @_ZNKSt3setISt4pairIixESt4lessIS1_ESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %27) #4
  %29 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %8, i32 0, i32 0
  store ptr %28, ptr %29, align 8
  %30 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  %31 = getelementptr inbounds %"struct.std::pair", ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  store i32 %32, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZNKSt3setISt4pairIixESt4lessIS1_ESaIS1_EE6rbeginEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator") align 8 %10, ptr noundef nonnull align 8 dereferenceable(48) %33) #4
  %34 = call noundef ptr @_ZNKSt16reverse_iteratorISt23_Rb_tree_const_iteratorISt4pairIixEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %10)
  %35 = getelementptr inbounds %"struct.std::pair", ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  store i32 %36, ptr %9, align 4, !tbaa !13
  br label %37

37:                                               ; preds = %81, %26
  %38 = load i32, ptr %7, align 4, !tbaa !13
  %39 = load i32, ptr %9, align 4, !tbaa !13
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %82

41:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %42 = load i32, ptr %7, align 4, !tbaa !13
  %43 = load i32, ptr %9, align 4, !tbaa !13
  %44 = add nsw i32 %42, %43
  %45 = add nsw i32 %44, 1
  %46 = ashr i32 %45, 1
  store i32 %46, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 -1000000000000001, ptr %14, align 8, !tbaa !14
  call void @_ZNSt4pairIixEC2IRixTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %48 = call ptr @_ZNSt3setISt4pairIixESt4lessIS1_ESaIS1_EE11lower_boundERKS1_(ptr noundef nonnull align 8 dereferenceable(48) %47, ptr noundef nonnull align 8 dereferenceable(16) %13)
  %49 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %12, i32 0, i32 0
  store ptr %48, ptr %49, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %50 = call ptr @_ZNSt23_Rb_tree_const_iteratorISt4pairIixEEmmEi(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef 0) #4
  %51 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %15, i32 0, i32 0
  store ptr %50, ptr %51, align 8
  %52 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #4
  %53 = getelementptr inbounds %"struct.std::pair", ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !9
  %55 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %12) #4
  %56 = getelementptr inbounds %"struct.std::pair", ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !9
  %58 = sub nsw i32 %54, %57
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = mul nsw i64 %59, %62
  %64 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #4
  %65 = getelementptr inbounds %"struct.std::pair", ptr %64, i32 0, i32 1
  %66 = load i64, ptr %65, align 8, !tbaa !15
  %67 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %12) #4
  %68 = getelementptr inbounds %"struct.std::pair", ptr %67, i32 0, i32 1
  %69 = load i64, ptr %68, align 8, !tbaa !15
  %70 = sub nsw i64 %66, %69
  %71 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %72 = load i64, ptr %71, align 8, !tbaa !15
  %73 = mul nsw i64 %70, %72
  %74 = add nsw i64 %63, %73
  %75 = icmp sle i64 %74, 0
  br i1 %75, label %76, label %78

76:                                               ; preds = %41
  %77 = load i32, ptr %11, align 4, !tbaa !13
  store i32 %77, ptr %7, align 4, !tbaa !13
  br label %81

78:                                               ; preds = %41
  %79 = load i32, ptr %11, align 4, !tbaa !13
  %80 = sub nsw i32 %79, 1
  store i32 %80, ptr %9, align 4, !tbaa !13
  br label %81

81:                                               ; preds = %78, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %37, !llvm.loop !16

82:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  store i64 -1000000000000001, ptr %19, align 8, !tbaa !14
  call void @_ZNSt4pairIixEC2IRixTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %84 = call ptr @_ZNSt3setISt4pairIixESt4lessIS1_ESaIS1_EE11lower_boundERKS1_(ptr noundef nonnull align 8 dereferenceable(48) %83, ptr noundef nonnull align 8 dereferenceable(16) %18)
  %85 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %17, i32 0, i32 0
  store ptr %84, ptr %85, align 8
  %86 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %17) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %86, i64 16, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  %87 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %88 = load i32, ptr %87, align 8, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds %"struct.std::pair", ptr %16, i32 0, i32 0
  %91 = load i32, ptr %90, align 8, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = mul nsw i64 %89, %92
  %94 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %95 = load i64, ptr %94, align 8, !tbaa !15
  %96 = getelementptr inbounds %"struct.std::pair", ptr %16, i32 0, i32 1
  %97 = load i64, ptr %96, align 8, !tbaa !15
  %98 = mul nsw i64 %95, %97
  %99 = add nsw i64 %93, %98
  store i64 %99, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %100

100:                                              ; preds = %82, %25
  %101 = load i64, ptr %4, align 8
  ret i64 %101
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNKSt3setISt4pairIixESt4lessIS1_ESaIS1_EE6rbeginEv(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_iteratorISt23_Rb_tree_const_iteratorISt4pairIixEEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIixEC2IRixTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 0}
!10 = !{!"_ZTSSt4pairIixE", !11, i64 0, !12, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{!10, !12, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.std::reverse_iterator" = type { %"struct.std::_Rb_tree_const_iterator" }
%"struct.std::pair" = type { i32, i64 }

; 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 uwtable
declare dso_local ptr @_ZNSt3setISt4pairIixESt4lessIS1_ESaIS1_EE11lower_boundERKS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt23_Rb_tree_const_iteratorISt4pairIixEEmmEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2 align 2

; 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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5queryRSt3setISt4pairIixESt4lessIS1_ESaIS1_EES1_(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 %1, i64 %2) local_unnamed_addr #1 {
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = alloca %"class.std::reverse_iterator", align 8
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %9 = alloca %"struct.std::pair", align 8
  %10 = alloca i64, align 8
  %11 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %12 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %13 = alloca %"struct.std::pair", align 8
  %14 = alloca i64, align 8
  %15 = tail call noundef i64 @_ZNKSt3setISt4pairIixESt4lessIS1_ESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %0) #3
  %.not = icmp eq i64 %15, 0
  br i1 %.not, label %60, label %16

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %17 = tail call ptr @_ZNKSt3setISt4pairIixESt4lessIS1_ESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %0) #3
  store ptr %17, ptr %5, align 8
  %18 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  %19 = load i32, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  store i32 %19, ptr %4, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @_ZNKSt3setISt4pairIixESt4lessIS1_ESaIS1_EE6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(48) %0) #3
  %20 = call noundef ptr @_ZNKSt16reverse_iteratorISt23_Rb_tree_const_iteratorISt4pairIixEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %21 = load i32, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  %22 = icmp slt i32 %19, %21
  %23 = sext i32 %1 to i64
  br i1 %22, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %16, %51
  %24 = phi i32 [ %52, %51 ], [ %19, %16 ]
  %.01112 = phi i32 [ %.1, %51 ], [ %21, %16 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %25 = add i32 %.01112, 1
  %26 = add i32 %25, %24
  %27 = ashr i32 %26, 1
  store i32 %27, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #3
  store i64 -1000000000000001, ptr %10, align 8, !tbaa !12
  call void @_ZNSt4pairIixEC2IRixTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %28 = call ptr @_ZNSt3setISt4pairIixESt4lessIS1_ESaIS1_EE11lower_boundERKS1_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(16) %9)
  store ptr %28, ptr %8, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #3
  %29 = call ptr @_ZNSt23_Rb_tree_const_iteratorISt4pairIixEEmmEi(ptr noundef nonnull align 8 dereferenceable(8) %8, i32 noundef 0) #3
  store ptr %29, ptr %11, align 8
  %30 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #3
  %31 = load i32, ptr %30, align 8, !tbaa !5
  %32 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #3
  %33 = load i32, ptr %32, align 8, !tbaa !5
  %34 = sub nsw i32 %31, %33
  %35 = sext i32 %34 to i64
  %36 = mul nsw i64 %35, %23
  %37 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #3
  %38 = getelementptr inbounds i8, ptr %37, i64 8
  %39 = load i64, ptr %38, align 8, !tbaa !13
  %40 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #3
  %41 = getelementptr inbounds i8, ptr %40, i64 8
  %42 = load i64, ptr %41, align 8, !tbaa !13
  %43 = sub nsw i64 %39, %42
  %44 = mul nsw i64 %43, %2
  %45 = add nsw i64 %44, %36
  %46 = icmp slt i64 %45, 1
  %47 = load i32, ptr %7, align 4, !tbaa !11
  br i1 %46, label %48, label %49

48:                                               ; preds = %.lr.ph
  store i32 %47, ptr %4, align 4, !tbaa !11
  br label %51

49:                                               ; preds = %.lr.ph
  %50 = add nsw i32 %47, -1
  br label %51

51:                                               ; preds = %49, %48
  %52 = phi i32 [ %47, %48 ], [ %24, %49 ]
  %.1 = phi i32 [ %.01112, %48 ], [ %50, %49 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  %53 = icmp slt i32 %52, %.1
  br i1 %53, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %51, %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #3
  store i64 -1000000000000001, ptr %14, align 8, !tbaa !12
  call void @_ZNSt4pairIixEC2IRixTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %54 = call ptr @_ZNSt3setISt4pairIixESt4lessIS1_ESaIS1_EE11lower_boundERKS1_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(16) %13)
  store ptr %54, ptr %12, align 8
  %55 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %12) #3
  %.sroa.0.0.copyload = load i32, ptr %55, align 8
  %.sroa.41.0..sroa_idx = getelementptr inbounds i8, ptr %55, i64 8
  %.sroa.41.0.copyload = load i64, ptr %.sroa.41.0..sroa_idx, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #3
  %56 = sext i32 %.sroa.0.0.copyload to i64
  %57 = mul nsw i64 %23, %56
  %58 = mul nsw i64 %.sroa.41.0.copyload, %2
  %59 = add nsw i64 %57, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br label %60

60:                                               ; preds = %3, %._crit_edge
  %.0 = phi i64 [ %59, %._crit_edge ], [ 0, %3 ]
  ret i64 %.0
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNKSt3setISt4pairIixESt4lessIS1_ESaIS1_EE6rbeginEv(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_iteratorISt23_Rb_tree_const_iteratorISt4pairIixEEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIixEC2IRixTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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 = { 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 = !{!"_ZTSSt4pairIixE", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = !{!6, !10, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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