; LLVM IR from tangjz/acm-icpc :: lydsy (1058)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@fir = external dso_local global [500001 x i32], align 16
@las = external dso_local global [500001 x i32], align 16
@gp = external dso_local global i32, align 4
@sp = external dso_local global %"class.std::multiset", align 8
@tp = external dso_local global %"class.std::multiset", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %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 i32, align 4
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %12 = alloca [13 x i8], align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %16 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %17 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %18 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %19 = alloca i32, align 4
  %20 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %21 = alloca i32, align 4
  %22 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %23 = alloca i32, align 4
  %24 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %25 = alloca i32, align 4
  %26 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %27 = alloca i32, align 4
  %28 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %29 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store i32 0, ptr %1, align 4
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %101, %0
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %104

36:                                               ; preds = %31
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr @fir, i64 %38
  %40 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %39)
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [500001 x i32], ptr @las, i64 0, i64 %46
  store i32 %44, ptr %47, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #8
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %49
  %51 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 4 dereferenceable(4) %50)
  %52 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %3, i32 0, i32 0
  store ptr %51, ptr %52, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %3, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #8
  %53 = call ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef 0) #8
  %54 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %5, i32 0, i32 0
  store ptr %53, ptr %54, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %55 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #8
  %56 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %6, i32 0, i32 0
  store ptr %55, ptr %56, align 8
  %57 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #8
  br i1 %57, label %58, label %68

58:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #8
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = sub nsw i32 %62, %64
  store i32 %65, ptr %7, align 4, !tbaa !5
  %66 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %67 = load i32, ptr %66, align 4, !tbaa !5
  store i32 %67, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %68

68:                                               ; preds = %58, %36
  %69 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEppEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  %70 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #8
  %71 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %8, i32 0, i32 0
  store ptr %70, ptr %71, align 8
  %72 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %69, ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br i1 %72, label %73, label %83

73:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #8
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = sub nsw i32 %75, %79
  store i32 %80, ptr %9, align 4, !tbaa !5
  %81 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %82 = load i32, ptr %81, align 4, !tbaa !5
  store i32 %82, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %83

83:                                               ; preds = %73, %68
  %84 = load i32, ptr %2, align 4, !tbaa !5
  %85 = icmp sgt i32 %84, 1
  br i1 %85, label %86, label %100

86:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = load i32, ptr %2, align 4, !tbaa !5
  %92 = sub nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = sub nsw i32 %90, %95
  %97 = call i32 @llvm.abs.i32(i32 %96, i1 true)
  store i32 %97, ptr %10, align 4, !tbaa !5
  %98 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %99 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %11, i32 0, i32 0
  store ptr %98, ptr %99, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %100

100:                                              ; preds = %86, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #8
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %2, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %2, align 4, !tbaa !5
  br label %31, !llvm.loop !12

104:                                              ; preds = %35
  br label %105

105:                                              ; preds = %205, %104
  %106 = load i32, ptr @m, align 4, !tbaa !5
  %107 = add nsw i32 %106, -1
  store i32 %107, ptr @m, align 4, !tbaa !5
  %108 = icmp ne i32 %106, 0
  br i1 %108, label %109, label %206

109:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 13, ptr %12) #8
  %110 = getelementptr inbounds [13 x i8], ptr %12, i64 0, i64 0
  %111 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %110)
  %112 = getelementptr inbounds [13 x i8], ptr %12, i64 0, i64 0
  %113 = load i8, ptr %112, align 1, !tbaa !14
  %114 = sext i8 %113 to i32
  %115 = icmp eq i32 %114, 73
  br i1 %115, label %116, label %190

116:                                              ; preds = %109
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %117 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %13, ptr noundef %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %118 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %119 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %15, i32 0, i32 0
  store ptr %118, ptr %119, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %15, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %120 = call ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEi(ptr noundef nonnull align 8 dereferenceable(8) %15, i32 noundef 0) #8
  %121 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %17, i32 0, i32 0
  store ptr %120, ptr %121, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %122 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #8
  %123 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %18, i32 0, i32 0
  store ptr %122, ptr %123, align 8
  %124 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 8 dereferenceable(8) %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  br i1 %124, label %125, label %132

125:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #8
  %126 = load i32, ptr %14, align 4, !tbaa !5
  %127 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #8
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = sub nsw i32 %126, %128
  store i32 %129, ptr %19, align 4, !tbaa !5
  %130 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %19)
  %131 = load i32, ptr %130, align 4, !tbaa !5
  store i32 %131, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #8
  br label %132

132:                                              ; preds = %125, %116
  %133 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEppEv(ptr noundef nonnull align 8 dereferenceable(8) %16) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %134 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #8
  %135 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %20, i32 0, i32 0
  store ptr %134, ptr %135, align 8
  %136 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %133, ptr noundef nonnull align 8 dereferenceable(8) %20) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  br i1 %136, label %137, label %144

137:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  %138 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %16) #8
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = load i32, ptr %14, align 4, !tbaa !5
  %141 = sub nsw i32 %139, %140
  store i32 %141, ptr %21, align 4, !tbaa !5
  %142 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %143 = load i32, ptr %142, align 4, !tbaa !5
  store i32 %143, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  br label %144

144:                                              ; preds = %137, %132
  %145 = load i32, ptr %13, align 4, !tbaa !5
  %146 = load i32, ptr @n, align 4, !tbaa !5
  %147 = icmp slt i32 %145, %146
  br i1 %147, label %148, label %185

148:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #8
  %149 = load i32, ptr %13, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [500001 x i32], ptr @las, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = load i32, ptr %13, align 4, !tbaa !5
  %154 = add nsw i32 %153, 1
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = sub nsw i32 %152, %157
  %159 = call i32 @llvm.abs.i32(i32 %158, i1 true)
  store i32 %159, ptr %23, align 4, !tbaa !5
  %160 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE4findERKi(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr noundef nonnull align 4 dereferenceable(4) %23)
  %161 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %22, i32 0, i32 0
  store ptr %160, ptr %161, align 8
  %162 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %22, i32 0, i32 0
  %163 = load ptr, ptr %162, align 8
  %164 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiE(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr %163)
  %165 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %24, i32 0, i32 0
  store ptr %164, ptr %165, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #8
  %166 = load i32, ptr %13, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [500001 x i32], ptr @las, i64 0, i64 %167
  %169 = load i32, ptr %168, align 4, !tbaa !5
  %170 = load i32, ptr %14, align 4, !tbaa !5
  %171 = sub nsw i32 %169, %170
  %172 = call i32 @llvm.abs.i32(i32 %171, i1 true)
  store i32 %172, ptr %25, align 4, !tbaa !5
  %173 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr noundef nonnull align 4 dereferenceable(4) %25)
  %174 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %26, i32 0, i32 0
  store ptr %173, ptr %174, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #8
  %175 = load i32, ptr %14, align 4, !tbaa !5
  %176 = load i32, ptr %13, align 4, !tbaa !5
  %177 = add nsw i32 %176, 1
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = sub nsw i32 %175, %180
  %182 = call i32 @llvm.abs.i32(i32 %181, i1 true)
  store i32 %182, ptr %27, align 4, !tbaa !5
  %183 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr noundef nonnull align 4 dereferenceable(4) %27)
  %184 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %28, i32 0, i32 0
  store ptr %183, ptr %184, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #8
  br label %185

185:                                              ; preds = %148, %144
  %186 = load i32, ptr %14, align 4, !tbaa !5
  %187 = load i32, ptr %13, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [500001 x i32], ptr @las, i64 0, i64 %188
  store i32 %186, ptr %189, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %205

190:                                              ; preds = %109
  %191 = getelementptr inbounds [13 x i8], ptr %12, i64 0, i64 4
  %192 = load i8, ptr %191, align 1, !tbaa !14
  %193 = sext i8 %192 to i32
  %194 = icmp eq i32 %193, 71
  br i1 %194, label %195, label %201

195:                                              ; preds = %190
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #8
  %196 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @tp) #8
  %197 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %29, i32 0, i32 0
  store ptr %196, ptr %197, align 8
  %198 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %29) #8
  %199 = load i32, ptr %198, align 4, !tbaa !5
  %200 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %199)
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #8
  br label %204

201:                                              ; preds = %190
  %202 = load i32, ptr @gp, align 4, !tbaa !5
  %203 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %202)
  br label %204

204:                                              ; preds = %201, %195
  br label %205

205:                                              ; preds = %204, %185
  call void @llvm.lifetime.end.p0(i64 13, ptr %12) #8
  br label %105, !llvm.loop !15

206:                                              ; preds = %105
  ret i32 0
}

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

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #6

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #7

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

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

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

attributes #0 = { 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 #1 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { inlinehint 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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 = !{i64 0, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !13}


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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@fir = external dso_local global [500001 x i32], align 16
@las = external dso_local local_unnamed_addr global [500001 x i32], align 16
@gp = external dso_local global i32, align 4
@sp = external dso_local global %"class.std::multiset", align 8
@tp = external dso_local global %"class.std::multiset", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %2 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %3 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %4 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [13 x i8], align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %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 %"struct.std::_Rb_tree_const_iterator", align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %23 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %.not17 = icmp slt i32 %24, 1
  br i1 %.not17, label %.preheader, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %25 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @fir, i64 4))
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @fir, i64 4), align 4, !tbaa !5
  store i32 %26, ptr getelementptr inbounds (i8, ptr @las, i64 4), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %27 = tail call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @fir, i64 4))
  store ptr %27, ptr %1, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %.cast16.peel = ptrtoint ptr %27 to i64
  store i64 %.cast16.peel, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %28 = call ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEi(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef 0) #7
  store ptr %28, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %29 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #7
  store ptr %29, ptr %4, align 8
  %30 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br i1 %30, label %31, label %38

31:                                               ; preds = %.lr.ph.preheader
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @fir, i64 4), align 4, !tbaa !5
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %1) #7
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sub nsw i32 %32, %34
  store i32 %35, ptr %5, align 4, !tbaa !5
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %37 = load i32, ptr %36, align 4, !tbaa !5
  store i32 %37, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  br label %38

38:                                               ; preds = %31, %.lr.ph.preheader
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  %40 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #7
  store ptr %40, ptr %6, align 8
  %41 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %39, ptr noundef nonnull align 8 dereferenceable(8) %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br i1 %41, label %42, label %._crit_edge23

42:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #7
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr getelementptr inbounds (i8, ptr @fir, i64 4), align 4, !tbaa !5
  %46 = sub nsw i32 %44, %45
  store i32 %46, ptr %7, align 4, !tbaa !5
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %48 = load i32, ptr %47, align 4, !tbaa !5
  store i32 %48, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  br label %._crit_edge23

._crit_edge23:                                    ; preds = %42, %38
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %.not.not.peel = icmp sgt i32 %.pre, 1
  br i1 %.not.not.peel, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %78, %._crit_edge23, %0
  %49 = load i32, ptr @m, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr @m, align 4, !tbaa !5
  %.not1519 = icmp eq i32 %49, 0
  br i1 %.not1519, label %._crit_edge, label %.lr.ph20

.lr.ph20:                                         ; preds = %.preheader
  %51 = getelementptr inbounds i8, ptr %9, i64 4
  br label %88

.lr.ph:                                           ; preds = %._crit_edge23, %78
  %indvars.iv = phi i64 [ %indvars.iv.next, %78 ], [ 2, %._crit_edge23 ]
  %52 = getelementptr inbounds i32, ptr @fir, i64 %indvars.iv
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %52)
  %54 = load i32, ptr %52, align 4, !tbaa !5
  %55 = getelementptr inbounds [500001 x i32], ptr @las, i64 0, i64 %indvars.iv
  store i32 %54, ptr %55, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %56 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 4 dereferenceable(4) %52)
  store ptr %56, ptr %1, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %.cast16 = ptrtoint ptr %56 to i64
  store i64 %.cast16, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %57 = call ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEi(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef 0) #7
  store ptr %57, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %58 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #7
  store ptr %58, ptr %4, align 8
  %59 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br i1 %59, label %60, label %67

60:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %61 = load i32, ptr %52, align 4, !tbaa !5
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %1) #7
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = sub nsw i32 %61, %63
  store i32 %64, ptr %5, align 4, !tbaa !5
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %66 = load i32, ptr %65, align 4, !tbaa !5
  store i32 %66, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  br label %67

67:                                               ; preds = %60, %.lr.ph
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  %69 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #7
  store ptr %69, ptr %6, align 8
  %70 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %68, ptr noundef nonnull align 8 dereferenceable(8) %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br i1 %70, label %71, label %78

71:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #7
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = load i32, ptr %52, align 4, !tbaa !5
  %75 = sub nsw i32 %73, %74
  store i32 %75, ptr %7, align 4, !tbaa !5
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %77 = load i32, ptr %76, align 4, !tbaa !5
  store i32 %77, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  br label %78

78:                                               ; preds = %71, %67
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #7
  %79 = load i32, ptr %52, align 4, !tbaa !5
  %80 = add nsw i64 %indvars.iv, -1
  %81 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sub nsw i32 %79, %82
  %84 = call i32 @llvm.abs.i32(i32 %83, i1 true)
  store i32 %84, ptr %8, align 4, !tbaa !5
  %85 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %.not.not = icmp slt i64 %indvars.iv, %87
  br i1 %.not.not, label %.lr.ph, label %.preheader, !llvm.loop !11

88:                                               ; preds = %.lr.ph20, %165
  call void @llvm.lifetime.start.p0(i64 13, ptr nonnull %9) #7
  %89 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %9)
  %90 = load i8, ptr %9, align 1, !tbaa !14
  %91 = icmp eq i8 %90, 73
  br i1 %91, label %92, label %154

92:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #7
  %93 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %10, ptr noundef nonnull %11)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #7
  %94 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 4 dereferenceable(4) %11)
  store ptr %94, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #7
  %.cast = ptrtoint ptr %94 to i64
  store i64 %.cast, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #7
  %95 = call ptr @_ZNSt23_Rb_tree_const_iteratorIiEmmEi(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef 0) #7
  store ptr %95, ptr %14, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %15) #7
  %96 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #7
  store ptr %96, ptr %15, align 8
  %97 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #7
  br i1 %97, label %98, label %105

98:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %16) #7
  %99 = load i32, ptr %11, align 4, !tbaa !5
  %100 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %12) #7
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = sub nsw i32 %99, %101
  store i32 %102, ptr %16, align 4, !tbaa !5
  %103 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %104 = load i32, ptr %103, align 4, !tbaa !5
  store i32 %104, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %16) #7
  br label %105

105:                                              ; preds = %98, %92
  %106 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIiEppEv(ptr noundef nonnull align 8 dereferenceable(8) %13) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %17) #7
  %107 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #7
  store ptr %107, ptr %17, align 8
  %108 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIiES2_(ptr noundef nonnull align 8 dereferenceable(8) %106, ptr noundef nonnull align 8 dereferenceable(8) %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %17) #7
  br i1 %108, label %109, label %116

109:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %18) #7
  %110 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %13) #7
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = load i32, ptr %11, align 4, !tbaa !5
  %113 = sub nsw i32 %111, %112
  store i32 %113, ptr %18, align 4, !tbaa !5
  %114 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @gp, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %115 = load i32, ptr %114, align 4, !tbaa !5
  store i32 %115, ptr @gp, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %18) #7
  br label %116

116:                                              ; preds = %109, %105
  %117 = load i32, ptr %10, align 4, !tbaa !5
  %118 = load i32, ptr @n, align 4, !tbaa !5
  %119 = icmp slt i32 %117, %118
  br i1 %119, label %120, label %149

120:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %19) #7
  %121 = sext i32 %117 to i64
  %122 = getelementptr inbounds [500001 x i32], ptr @las, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = add nsw i32 %117, 1
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = sub nsw i32 %123, %127
  %129 = call i32 @llvm.abs.i32(i32 %128, i1 true)
  store i32 %129, ptr %19, align 4, !tbaa !5
  %130 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE4findERKi(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr noundef nonnull align 4 dereferenceable(4) %19)
  %131 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiE(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr %130)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %19) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %20) #7
  %132 = load i32, ptr %10, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [500001 x i32], ptr @las, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = load i32, ptr %11, align 4, !tbaa !5
  %137 = sub nsw i32 %135, %136
  %138 = call i32 @llvm.abs.i32(i32 %137, i1 true)
  store i32 %138, ptr %20, align 4, !tbaa !5
  %139 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr noundef nonnull align 4 dereferenceable(4) %20)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %20) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %21) #7
  %140 = load i32, ptr %11, align 4, !tbaa !5
  %141 = load i32, ptr %10, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [500001 x i32], ptr @fir, i64 0, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = sub nsw i32 %140, %145
  %147 = call i32 @llvm.abs.i32(i32 %146, i1 true)
  store i32 %147, ptr %21, align 4, !tbaa !5
  %148 = call ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) @tp, ptr noundef nonnull align 4 dereferenceable(4) %21)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %21) #7
  %.pre25 = load i32, ptr %10, align 4, !tbaa !5
  br label %149

149:                                              ; preds = %120, %116
  %150 = phi i32 [ %.pre25, %120 ], [ %117, %116 ]
  %151 = load i32, ptr %11, align 4, !tbaa !5
  %152 = sext i32 %150 to i64
  %153 = getelementptr inbounds [500001 x i32], ptr @las, i64 0, i64 %152
  store i32 %151, ptr %153, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #7
  br label %165

154:                                              ; preds = %88
  %155 = load i8, ptr %51, align 1, !tbaa !14
  %156 = icmp eq i8 %155, 71
  br i1 %156, label %157, label %162

157:                                              ; preds = %154
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %22) #7
  %158 = call ptr @_ZNKSt8multisetIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @tp) #7
  store ptr %158, ptr %22, align 8
  %159 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %22) #7
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %160)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %22) #7
  br label %165

162:                                              ; preds = %154
  %163 = load i32, ptr @gp, align 4, !tbaa !5
  %164 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %163)
  br label %165

165:                                              ; preds = %157, %162, %149
  call void @llvm.lifetime.end.p0(i64 13, ptr nonnull %9) #7
  %166 = load i32, ptr @m, align 4, !tbaa !5
  %167 = add nsw i32 %166, -1
  store i32 %167, ptr @m, align 4, !tbaa !5
  %.not15 = icmp eq i32 %166, 0
  br i1 %.not15, label %._crit_edge, label %88, !llvm.loop !15

._crit_edge:                                      ; preds = %165, %.preheader
  ret i32 0
}

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

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #6

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

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

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

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { inlinehint 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.peeled.count", i32 1}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass