; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/135 Division 2/Problem E (E)

; 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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, std::pair<int, int>>, std::pair<int, std::pair<int, int>>, std::_Identity<std::pair<int, std::pair<int, int>>>, std::less<std::pair<int, std::pair<int, int>>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, std::pair<int, int>>, std::pair<int, std::pair<int, int>>, std::_Identity<std::pair<int, std::pair<int, int>>>, std::less<std::pair<int, 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, %"struct.std::pair.0" }
%"struct.std::pair.0" = type { i32, i32 }
%"struct.std::pair.2" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@l = external dso_local global [200100 x i32], align 16
@r = external dso_local global [200100 x i32], align 16
@pos = external dso_local global [1000100 x i32], align 16
@inf = external dso_local global i32, align 4
@s = external dso_local global %"class.std::set", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_Z3getii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZSt9make_pairIiSt4pairIiiEES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(8)) #0

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

; 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) #2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca %"struct.std::pair", align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair.0", align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca { i64, i32 }, align 8
  %8 = alloca %"struct.std::pair.2", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair.0", align 4
  %13 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %14 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %15 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca %"struct.std::pair", align 4
  %20 = alloca { i64, i32 }, align 8
  %21 = alloca %"struct.std::pair.2", align 8
  %22 = alloca %"struct.std::pair", align 4
  %23 = alloca { i64, i32 }, align 8
  %24 = alloca %"struct.std::pair.2", align 8
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca %"struct.std::pair", align 4
  %29 = alloca { i64, i32 }, align 8
  %30 = alloca %"struct.std::pair", align 4
  %31 = alloca { i64, i32 }, align 8
  %32 = alloca %"struct.std::pair", align 4
  %33 = alloca { i64, i32 }, align 8
  %34 = alloca %"struct.std::pair.2", align 8
  store i32 0, ptr %1, align 4
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr @r, align 16, !tbaa !5
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %40
  store i32 0, ptr %41, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %42 = load i32, ptr @inf, align 4, !tbaa !5
  %43 = sub nsw i32 0, %42
  store i32 %43, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !5
  %44 = call i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  store i64 %44, ptr %4, align 4
  %45 = call { i64, i32 } @_ZSt9make_pairIiSt4pairIiiEES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(8) %4)
  store { i64, i32 } %45, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 8 %7, i64 12, i1 false)
  %46 = call { ptr, i8 } @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE6insertEOS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %2)
  %47 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 0
  %48 = extractvalue { ptr, i8 } %46, 0
  store ptr %48, ptr %47, align 8
  %49 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 1
  %50 = extractvalue { ptr, i8 } %46, 1
  store i8 %50, ptr %49, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %158, %0
  %52 = load i32, ptr %11, align 4, !tbaa !5
  %53 = load i32, ptr @m, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %161

56:                                               ; preds = %51
  %57 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %9, ptr noundef %10)
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = icmp eq i32 %58, 1
  br i1 %59, label %60, label %120

60:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %61 = call ptr @_ZNKSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #6
  %62 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %13, i32 0, i32 0
  store ptr %61, ptr %62, align 8
  %63 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIiS0_IiiEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %13) #6
  %64 = getelementptr inbounds %"struct.std::pair", ptr %63, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %64, i64 8, i1 false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  %65 = call ptr @_ZNKSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #6
  %66 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %14, i32 0, i32 0
  store ptr %65, ptr %66, align 8
  %67 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %14, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8
  %69 = call ptr @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIS2_E(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr %68)
  %70 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %15, i32 0, i32 0
  store ptr %69, ptr %70, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %71 = getelementptr inbounds %"struct.std::pair.0", ptr %12, i32 0, i32 0
  %72 = load i32, ptr %71, align 4, !tbaa !9
  store i32 %72, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %73 = load i32, ptr %16, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  store i32 %76, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %77 = getelementptr inbounds %"struct.std::pair.0", ptr %12, i32 0, i32 1
  %78 = load i32, ptr %77, align 4, !tbaa !11
  store i32 %78, ptr %18, align 4, !tbaa !5
  %79 = load i32, ptr %18, align 4, !tbaa !5
  %80 = load i32, ptr %10, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1000100 x i32], ptr @pos, i64 0, i64 %81
  store i32 %79, ptr %82, align 4, !tbaa !5
  %83 = load i32, ptr %10, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1000100 x i32], ptr @pos, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %86)
  %88 = load i32, ptr %18, align 4, !tbaa !5
  %89 = load i32, ptr %16, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %90
  store i32 %88, ptr %91, align 4, !tbaa !5
  %92 = load i32, ptr %17, align 4, !tbaa !5
  %93 = load i32, ptr %18, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %94
  store i32 %92, ptr %95, align 4, !tbaa !5
  %96 = load i32, ptr %16, align 4, !tbaa !5
  %97 = load i32, ptr %18, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %98
  store i32 %96, ptr %99, align 4, !tbaa !5
  %100 = load i32, ptr %18, align 4, !tbaa !5
  %101 = load i32, ptr %17, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %102
  store i32 %100, ptr %103, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %19) #6
  %104 = load i32, ptr %16, align 4, !tbaa !5
  %105 = load i32, ptr %18, align 4, !tbaa !5
  %106 = call { i64, i32 } @_Z3getii(i32 noundef %104, i32 noundef %105)
  store { i64, i32 } %106, ptr %20, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 8 %20, i64 12, i1 false)
  %107 = call { ptr, i8 } @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE6insertEOS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %19)
  %108 = getelementptr inbounds { ptr, i8 }, ptr %21, i32 0, i32 0
  %109 = extractvalue { ptr, i8 } %107, 0
  store ptr %109, ptr %108, align 8
  %110 = getelementptr inbounds { ptr, i8 }, ptr %21, i32 0, i32 1
  %111 = extractvalue { ptr, i8 } %107, 1
  store i8 %111, ptr %110, align 8
  call void @llvm.lifetime.end.p0(i64 12, ptr %19) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr %22) #6
  %112 = load i32, ptr %18, align 4, !tbaa !5
  %113 = load i32, ptr %17, align 4, !tbaa !5
  %114 = call { i64, i32 } @_Z3getii(i32 noundef %112, i32 noundef %113)
  store { i64, i32 } %114, ptr %23, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 8 %23, i64 12, i1 false)
  %115 = call { ptr, i8 } @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE6insertEOS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %22)
  %116 = getelementptr inbounds { ptr, i8 }, ptr %24, i32 0, i32 0
  %117 = extractvalue { ptr, i8 } %115, 0
  store ptr %117, ptr %116, align 8
  %118 = getelementptr inbounds { ptr, i8 }, ptr %24, i32 0, i32 1
  %119 = extractvalue { ptr, i8 } %115, 1
  store i8 %119, ptr %118, align 8
  call void @llvm.lifetime.end.p0(i64 12, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %157

120:                                              ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #6
  %121 = load i32, ptr %10, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [1000100 x i32], ptr @pos, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  store i32 %124, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  %125 = load i32, ptr %25, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  store i32 %128, ptr %26, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #6
  %129 = load i32, ptr %25, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  store i32 %132, ptr %27, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %28) #6
  %133 = load i32, ptr %26, align 4, !tbaa !5
  %134 = load i32, ptr %25, align 4, !tbaa !5
  %135 = call { i64, i32 } @_Z3getii(i32 noundef %133, i32 noundef %134)
  store { i64, i32 } %135, ptr %29, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 8 %29, i64 12, i1 false)
  %136 = call noundef i64 @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5eraseERKS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %28)
  call void @llvm.lifetime.end.p0(i64 12, ptr %28) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr %30) #6
  %137 = load i32, ptr %25, align 4, !tbaa !5
  %138 = load i32, ptr %27, align 4, !tbaa !5
  %139 = call { i64, i32 } @_Z3getii(i32 noundef %137, i32 noundef %138)
  store { i64, i32 } %139, ptr %31, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %30, ptr align 8 %31, i64 12, i1 false)
  %140 = call noundef i64 @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5eraseERKS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %30)
  call void @llvm.lifetime.end.p0(i64 12, ptr %30) #6
  %141 = load i32, ptr %27, align 4, !tbaa !5
  %142 = load i32, ptr %26, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %143
  store i32 %141, ptr %144, align 4, !tbaa !5
  %145 = load i32, ptr %26, align 4, !tbaa !5
  %146 = load i32, ptr %27, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %147
  store i32 %145, ptr %148, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %32) #6
  %149 = load i32, ptr %26, align 4, !tbaa !5
  %150 = load i32, ptr %27, align 4, !tbaa !5
  %151 = call { i64, i32 } @_Z3getii(i32 noundef %149, i32 noundef %150)
  store { i64, i32 } %151, ptr %33, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 8 %33, i64 12, i1 false)
  %152 = call { ptr, i8 } @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE6insertEOS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %32)
  %153 = getelementptr inbounds { ptr, i8 }, ptr %34, i32 0, i32 0
  %154 = extractvalue { ptr, i8 } %152, 0
  store ptr %154, ptr %153, align 8
  %155 = getelementptr inbounds { ptr, i8 }, ptr %34, i32 0, i32 1
  %156 = extractvalue { ptr, i8 } %152, 1
  store i8 %156, ptr %155, align 8
  call void @llvm.lifetime.end.p0(i64 12, ptr %32) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  br label %157

157:                                              ; preds = %120, %60
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %11, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %11, align 4, !tbaa !5
  br label %51, !llvm.loop !12

161:                                              ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

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

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

declare i32 @printf(ptr noundef, ...) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5eraseERKS2_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(12)) #0 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { 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 = !{!10, !6, i64 4}
!12 = distinct !{!12, !13}
!13 = !{!"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"

%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, std::pair<int, int>>, std::pair<int, std::pair<int, int>>, std::_Identity<std::pair<int, std::pair<int, int>>>, std::less<std::pair<int, std::pair<int, int>>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, std::pair<int, int>>, std::pair<int, std::pair<int, int>>, std::_Identity<std::pair<int, std::pair<int, int>>>, std::less<std::pair<int, 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, %"struct.std::pair.0" }
%"struct.std::pair.0" = type { i32, i32 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@l = external dso_local local_unnamed_addr global [200100 x i32], align 16
@r = external dso_local local_unnamed_addr global [200100 x i32], align 16
@pos = external dso_local local_unnamed_addr global [1000100 x i32], align 16
@inf = external dso_local local_unnamed_addr global i32, align 4
@s = external dso_local global %"class.std::set", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_Z3getii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZSt9make_pairIiSt4pairIiiEES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca %"struct.std::pair", align 8
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::pair.0", align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %9 = alloca %"struct.std::pair", align 8
  %10 = alloca %"struct.std::pair", align 8
  %11 = alloca %"struct.std::pair", align 8
  %12 = alloca %"struct.std::pair", align 8
  %13 = alloca %"struct.std::pair", align 8
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr @r, align 16, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %17
  store i32 0, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %19 = load i32, ptr @inf, align 4, !tbaa !5
  %20 = sub nsw i32 0, %19
  store i32 %20, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  %21 = call i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store i64 %21, ptr %3, align 8
  %22 = call { i64, i32 } @_ZSt9make_pairIiSt4pairIiiEES0_INSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %.fca.0.extract54 = extractvalue { i64, i32 } %22, 0
  %.fca.1.extract55 = extractvalue { i64, i32 } %22, 1
  store i64 %.fca.0.extract54, ptr %1, align 8
  %.sroa.257.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %.fca.1.extract55, ptr %.sroa.257.0..sroa_idx, align 8
  %23 = call { ptr, i8 } @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE6insertEOS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  %24 = load i32, ptr @m, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.sroa.29.0..sroa_idx = getelementptr inbounds i8, ptr %11, i64 8
  %.sroa.25.0..sroa_idx = getelementptr inbounds i8, ptr %12, i64 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %13, i64 8
  %.sroa.232.0..sroa_idx = getelementptr inbounds i8, ptr %9, i64 8
  %.sroa.226.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 8
  br label %26

._crit_edge:                                      ; preds = %72, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  ret i32 0

26:                                               ; preds = %.lr.ph, %72
  %.058 = phi i32 [ 0, %.lr.ph ], [ %73, %72 ]
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = icmp eq i32 %28, 1
  br i1 %29, label %30, label %52

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  %31 = call ptr @_ZNKSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #5
  store ptr %31, ptr %8, align 8
  %32 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIiS0_IiiEEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #5
  %33 = getelementptr inbounds i8, ptr %32, i64 4
  %.sroa.049.0.copyload = load i32, ptr %33, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %32, i64 8
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  %34 = call ptr @_ZNKSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @s) #5
  %35 = call ptr @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIS2_E(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr %34)
  %36 = sext i32 %.sroa.049.0.copyload to i64
  %37 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1000100 x i32], ptr @pos, i64 0, i64 %40
  store i32 %.sroa.4.0.copyload, ptr %41, align 4, !tbaa !5
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.sroa.4.0.copyload)
  store i32 %.sroa.4.0.copyload, ptr %37, align 4, !tbaa !5
  %43 = sext i32 %.sroa.4.0.copyload to i64
  %44 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %43
  store i32 %38, ptr %44, align 4, !tbaa !5
  %45 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %43
  store i32 %.sroa.049.0.copyload, ptr %45, align 4, !tbaa !5
  %46 = sext i32 %38 to i64
  %47 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %46
  store i32 %.sroa.4.0.copyload, ptr %47, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #5
  %48 = call { i64, i32 } @_Z3getii(i32 noundef %.sroa.049.0.copyload, i32 noundef %.sroa.4.0.copyload)
  %.fca.0.extract29 = extractvalue { i64, i32 } %48, 0
  %.fca.1.extract30 = extractvalue { i64, i32 } %48, 1
  store i64 %.fca.0.extract29, ptr %9, align 8
  store i32 %.fca.1.extract30, ptr %.sroa.232.0..sroa_idx, align 8
  %49 = call { ptr, i8 } @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE6insertEOS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #5
  %50 = call { i64, i32 } @_Z3getii(i32 noundef %.sroa.4.0.copyload, i32 noundef %38)
  %.fca.0.extract23 = extractvalue { i64, i32 } %50, 0
  %.fca.1.extract24 = extractvalue { i64, i32 } %50, 1
  store i64 %.fca.0.extract23, ptr %10, align 8
  store i32 %.fca.1.extract24, ptr %.sroa.226.0..sroa_idx, align 8
  %51 = call { ptr, i8 } @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE6insertEOS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %10)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #5
  br label %72

52:                                               ; preds = %26
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1000100 x i32], ptr @pos, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %57
  %61 = load i32, ptr %60, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #5
  %62 = call { i64, i32 } @_Z3getii(i32 noundef %59, i32 noundef %56)
  %.fca.0.extract6 = extractvalue { i64, i32 } %62, 0
  %.fca.1.extract7 = extractvalue { i64, i32 } %62, 1
  store i64 %.fca.0.extract6, ptr %11, align 8
  store i32 %.fca.1.extract7, ptr %.sroa.29.0..sroa_idx, align 8
  %63 = call noundef i64 @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5eraseERKS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %11)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %12) #5
  %64 = call { i64, i32 } @_Z3getii(i32 noundef %56, i32 noundef %61)
  %.fca.0.extract2 = extractvalue { i64, i32 } %64, 0
  %.fca.1.extract3 = extractvalue { i64, i32 } %64, 1
  store i64 %.fca.0.extract2, ptr %12, align 8
  store i32 %.fca.1.extract3, ptr %.sroa.25.0..sroa_idx, align 8
  %65 = call noundef i64 @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5eraseERKS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %12)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %12) #5
  %66 = sext i32 %59 to i64
  %67 = getelementptr inbounds [200100 x i32], ptr @r, i64 0, i64 %66
  store i32 %61, ptr %67, align 4, !tbaa !5
  %68 = sext i32 %61 to i64
  %69 = getelementptr inbounds [200100 x i32], ptr @l, i64 0, i64 %68
  store i32 %59, ptr %69, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %13) #5
  %70 = call { i64, i32 } @_Z3getii(i32 noundef %59, i32 noundef %61)
  %.fca.0.extract = extractvalue { i64, i32 } %70, 0
  %.fca.1.extract = extractvalue { i64, i32 } %70, 1
  store i64 %.fca.0.extract, ptr %13, align 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %71 = call { ptr, i8 } @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE6insertEOS2_(ptr noundef nonnull align 8 dereferenceable(48) @s, ptr noundef nonnull align 4 dereferenceable(12) %13)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %13) #5
  br label %72

72:                                               ; preds = %30, %52
  %73 = add nuw nsw i32 %.058, 1
  %74 = load i32, ptr @m, align 4, !tbaa !5
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %26, label %._crit_edge, !llvm.loop !9
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3setISt4pairIiS0_IiiEESt4lessIS2_ESaIS2_EE5eraseERKS2_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 align 2

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


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