; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2011-12/Feb/12 Feb G1.ll (Z2adi)

; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int>>, std::less<std::pair<int, int>>>::_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.std::pair" = type { i32, i32 }
%"struct.std::pair.3" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@M = external dso_local global i64, align 8
@cow = external dso_local global %"class.std::vector", align 8
@pri = external dso_local global %"class.std::set", align 8
@p2 = external dso_local global %"struct.std::pair", align 4
@c1 = external dso_local global i64, align 8
@c2 = external dso_local global i64, align 8
@num = external dso_local global i32, align 4

; 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 void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 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 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4nextISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr, i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE4findERKS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2adi(i32 noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 4
  %4 = alloca %"struct.std::pair.3", align 8
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %7 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %9 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %10 = alloca %"struct.std::pair", align 4
  %11 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %12 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %13 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @cow, i64 noundef %15) #5
  %17 = getelementptr inbounds %"struct.std::pair", ptr %16, i32 0, i32 0
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %18 = call noundef zeroext i1 @_ZStleIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) @p2)
  br i1 %18, label %19, label %27

19:                                               ; preds = %1
  %20 = getelementptr inbounds %"struct.std::pair", ptr %3, i32 0, i32 0
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = load i64, ptr @c2, align 8, !tbaa !11
  %24 = add nsw i64 %23, %22
  store i64 %24, ptr @c2, align 8, !tbaa !11
  %25 = load i32, ptr @num, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr @num, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %19, %1
  %28 = call { ptr, i8 } @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE6insertERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @pri, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %29 = getelementptr inbounds { ptr, i8 }, ptr %4, i32 0, i32 0
  %30 = extractvalue { ptr, i8 } %28, 0
  store ptr %30, ptr %29, align 8
  %31 = getelementptr inbounds { ptr, i8 }, ptr %4, i32 0, i32 1
  %32 = extractvalue { ptr, i8 } %28, 1
  store i8 %32, ptr %31, align 8
  br label %33

33:                                               ; preds = %39, %27
  %34 = load i64, ptr @c1, align 8, !tbaa !11
  %35 = load i64, ptr @c2, align 8, !tbaa !11
  %36 = add nsw i64 %34, %35
  %37 = load i64, ptr @M, align 8, !tbaa !11
  %38 = icmp sgt i64 %36, %37
  br i1 %38, label %39, label %54

39:                                               ; preds = %33
  %40 = load i32, ptr @p2, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = load i64, ptr @c2, align 8, !tbaa !11
  %43 = sub nsw i64 %42, %41
  store i64 %43, ptr @c2, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %44 = call ptr @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE4findERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @pri, ptr noundef nonnull align 4 dereferenceable(8) @p2)
  %45 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %6, i32 0, i32 0
  store ptr %44, ptr %45, align 8
  %46 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %6, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8
  %48 = call ptr @_ZSt4prevISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr %47, i64 noundef 1)
  %49 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %5, i32 0, i32 0
  store ptr %48, ptr %49, align 8
  %50 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIiiEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  %51 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) @p2, ptr noundef nonnull align 4 dereferenceable(8) %50)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %52 = load i32, ptr @num, align 4, !tbaa !5
  %53 = add nsw i32 %52, -1
  store i32 %53, ptr @num, align 4, !tbaa !5
  br label %33, !llvm.loop !13

54:                                               ; preds = %33
  br label %55

55:                                               ; preds = %102, %54
  %56 = load i64, ptr @c1, align 8, !tbaa !11
  %57 = load i64, ptr @c2, align 8, !tbaa !11
  %58 = add nsw i64 %56, %57
  %59 = load i64, ptr @M, align 8, !tbaa !11
  %60 = icmp slt i64 %58, %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  br i1 %60, label %61, label %71

61:                                               ; preds = %55
  %62 = call ptr @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE4findERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @pri, ptr noundef nonnull align 4 dereferenceable(8) @p2)
  %63 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %8, i32 0, i32 0
  store ptr %62, ptr %63, align 8
  %64 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %8, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8
  %66 = call ptr @_ZSt4nextISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr %65, i64 noundef 1)
  %67 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %7, i32 0, i32 0
  store ptr %66, ptr %67, align 8
  %68 = call ptr @_ZNKSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @pri) #5
  %69 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %9, i32 0, i32 0
  store ptr %68, ptr %69, align 8
  %70 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorISt4pairIiiEES4_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  br label %71

71:                                               ; preds = %61, %55
  %72 = phi i1 [ false, %55 ], [ %70, %61 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br i1 %72, label %73, label %103

73:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %74 = call ptr @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE4findERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @pri, ptr noundef nonnull align 4 dereferenceable(8) @p2)
  %75 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %12, i32 0, i32 0
  store ptr %74, ptr %75, align 8
  %76 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %12, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8
  %78 = call ptr @_ZSt4nextISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr %77, i64 noundef 1)
  %79 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %11, i32 0, i32 0
  store ptr %78, ptr %79, align 8
  %80 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIiiEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %80, i64 8, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %81 = load i64, ptr @c1, align 8, !tbaa !11
  %82 = load i64, ptr @c2, align 8, !tbaa !11
  %83 = add nsw i64 %81, %82
  %84 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = add nsw i64 %83, %86
  %88 = load i64, ptr @M, align 8, !tbaa !11
  %89 = icmp sgt i64 %87, %88
  br i1 %89, label %90, label %91

90:                                               ; preds = %73
  store i32 5, ptr %13, align 4
  br label %100

91:                                               ; preds = %73
  %92 = load i32, ptr @num, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr @num, align 4, !tbaa !5
  %94 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %95 = load i32, ptr %94, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = load i64, ptr @c2, align 8, !tbaa !11
  %98 = add nsw i64 %97, %96
  store i64 %98, ptr @c2, align 8, !tbaa !11
  %99 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) @p2, ptr noundef nonnull align 4 dereferenceable(8) %10)
  store i32 0, ptr %13, align 4
  br label %100

100:                                              ; preds = %91, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %101 = load i32, ptr %13, align 4
  switch i32 %101, label %104 [
    i32 0, label %102
    i32 5, label %103
  ]

102:                                              ; preds = %100
  br label %55, !llvm.loop !15

103:                                              ; preds = %100, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void

104:                                              ; preds = %100
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE6insertERKS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4prevISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr, i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorISt4pairIiiEES4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1

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

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 = { 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 #3 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int>>, std::less<std::pair<int, int>>>::_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.std::pair" = type { i32, i32 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@M = external dso_local local_unnamed_addr global i64, align 8
@cow = external dso_local global %"class.std::vector", align 8
@pri = external dso_local global %"class.std::set", align 8
@p2 = external dso_local global %"struct.std::pair", align 4
@c1 = external dso_local local_unnamed_addr global i64, align 8
@c2 = external dso_local local_unnamed_addr global i64, align 8
@num = external dso_local local_unnamed_addr global i32, align 4

; 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 void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 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 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4nextISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE4findERKS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z2adi(i32 noundef %0) local_unnamed_addr #3 {
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair", align 4
  %4 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %9 = sext i32 %0 to i64
  %10 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt4pairIiiESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @cow, i64 noundef %9) #4
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %11 = call noundef zeroext i1 @_ZStleIiiEbRKSt4pairIT_T0_ES5_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) @p2)
  br i1 %11, label %12, label %19

12:                                               ; preds = %1
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = load i64, ptr @c2, align 8, !tbaa !11
  %16 = add nsw i64 %15, %14
  store i64 %16, ptr @c2, align 8, !tbaa !11
  %17 = load i32, ptr @num, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr @num, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %12, %1
  %20 = call { ptr, i8 } @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE6insertERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @pri, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %21 = load i64, ptr @c1, align 8, !tbaa !11
  %22 = load i64, ptr @c2, align 8, !tbaa !11
  %23 = add nsw i64 %22, %21
  %24 = load i64, ptr @M, align 8, !tbaa !11
  %25 = icmp sgt i64 %23, %24
  br i1 %25, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %19
  %.pre-phi = phi i64 [ %23, %19 ], [ %40, %.lr.ph ]
  %26 = phi i64 [ %24, %19 ], [ %41, %.lr.ph ]
  %27 = icmp slt i64 %.pre-phi, %26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  br i1 %27, label %.lr.ph6, label %.critedge

.lr.ph:                                           ; preds = %19, %.lr.ph
  %28 = phi i64 [ %39, %.lr.ph ], [ %22, %19 ]
  %29 = load i32, ptr @p2, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = sub nsw i64 %28, %30
  store i64 %31, ptr @c2, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %32 = call ptr @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE4findERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @pri, ptr noundef nonnull align 4 dereferenceable(8) @p2)
  %33 = call ptr @_ZSt4prevISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr %32, i64 noundef 1)
  store ptr %33, ptr %4, align 8
  %34 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIiiEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  %35 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) @p2, ptr noundef nonnull align 4 dereferenceable(8) %34)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %36 = load i32, ptr @num, align 4, !tbaa !5
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr @num, align 4, !tbaa !5
  %38 = load i64, ptr @c1, align 8, !tbaa !11
  %39 = load i64, ptr @c2, align 8, !tbaa !11
  %40 = add nsw i64 %39, %38
  %41 = load i64, ptr @M, align 8, !tbaa !11
  %42 = icmp sgt i64 %40, %41
  br i1 %42, label %.lr.ph, label %.preheader, !llvm.loop !13

.lr.ph6:                                          ; preds = %.preheader, %59
  %43 = call ptr @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE4findERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @pri, ptr noundef nonnull align 4 dereferenceable(8) @p2)
  %44 = call ptr @_ZSt4nextISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr %43, i64 noundef 1)
  store ptr %44, ptr %5, align 8
  %45 = call ptr @_ZNKSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @pri) #4
  store ptr %45, ptr %6, align 8
  %46 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorISt4pairIiiEES4_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br i1 %46, label %47, label %.loopexit

47:                                               ; preds = %.lr.ph6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  %48 = call ptr @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE4findERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @pri, ptr noundef nonnull align 4 dereferenceable(8) @p2)
  %49 = call ptr @_ZSt4nextISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr %48, i64 noundef 1)
  store ptr %49, ptr %8, align 8
  %50 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIiiEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  %51 = load i64, ptr %50, align 4
  store i64 %51, ptr %7, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  %52 = load i64, ptr @c1, align 8, !tbaa !11
  %53 = load i64, ptr @c2, align 8, !tbaa !11
  %sext = shl i64 %51, 32
  %54 = ashr exact i64 %sext, 32
  %55 = add i64 %53, %54
  %56 = add i64 %55, %52
  %57 = load i64, ptr @M, align 8, !tbaa !11
  %58 = icmp sgt i64 %56, %57
  br i1 %58, label %.thread, label %59

.thread:                                          ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  br label %.loopexit

59:                                               ; preds = %47
  %60 = load i32, ptr @num, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr @num, align 4, !tbaa !5
  store i64 %55, ptr @c2, align 8, !tbaa !11
  %62 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSERKS0_(ptr noundef nonnull align 4 dereferenceable(8) @p2, ptr noundef nonnull align 4 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  %63 = load i64, ptr @c1, align 8, !tbaa !11
  %64 = load i64, ptr @c2, align 8, !tbaa !11
  %65 = add nsw i64 %64, %63
  %66 = load i64, ptr @M, align 8, !tbaa !11
  %67 = icmp slt i64 %65, %66
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  br i1 %67, label %.lr.ph6, label %.critedge

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

.loopexit:                                        ; preds = %.lr.ph6, %.thread, %.critedge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setISt4pairIiiESt4lessIS1_ESaIS1_EE6insertERKS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4prevISt23_Rb_tree_const_iteratorISt4pairIiiEEET_S4_NSt15iterator_traitsIS4_E15difference_typeE(ptr, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorISt4pairIiiEES4_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

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

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 = { 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 #3 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass