; LLVM IR from tangjz/acm-icpc :: codeforces/complete (1340A)

; 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 }
%"class.std::reverse_iterator" = type { %"struct.std::_Rb_tree_const_iterator" }

@n = external dso_local global i32, align 4
@p = external dso_local global [100003 x i32], align 16
@pL = external dso_local global [100003 x i32], align 16
@pR = external dso_local global [100003 x i32], align 16
@pos = external dso_local global [100003 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  %5 = alloca %"class.std::multiset", align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %"class.std::reverse_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 %"struct.std::_Rb_tree_const_iterator", align 8
  %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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %26

26:                                               ; preds = %187, %0
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = add nsw i32 %27, -1
  store i32 %28, ptr %2, align 4, !tbaa !5
  %29 = icmp ne i32 %27, 0
  br i1 %29, label %30, label %193

30:                                               ; preds = %26
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %59, %30
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = icmp sle i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %62

37:                                               ; preds = %32
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr @p, i64 %39
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %40)
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sub nsw i32 %42, 1
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100003 x i32], ptr @pL, i64 0, i64 %45
  store i32 %43, ptr %46, align 4, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100003 x i32], ptr @pR, i64 0, i64 %50
  store i32 %48, ptr %51, align 4, !tbaa !5
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100003 x i32], ptr @p, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100003 x i32], ptr @pos, i64 0, i64 %57
  store i32 %52, ptr %58, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %37
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %3, align 4, !tbaa !5
  br label %32, !llvm.loop !9

62:                                               ; preds = %36
  store i32 1, ptr @pR, align 16, !tbaa !5
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100003 x i32], ptr @pL, i64 0, i64 %66
  store i32 %63, ptr %67, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #6
  store i8 1, ptr %4, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 48, ptr %5) #6
  call void @_ZNSt8multisetIiSt4lessIiESaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %77, %62
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = icmp sle i32 %69, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %84

73:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !5
  %74 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %75 unwind label %80

75:                                               ; preds = %73
  %76 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %10, i32 0, i32 0
  store ptr %74, ptr %76, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %77

77:                                               ; preds = %75
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %6, align 4, !tbaa !5
  br label %68, !llvm.loop !13

80:                                               ; preds = %73
  %81 = landingpad { ptr, i32 }
          cleanup
  %82 = extractvalue { ptr, i32 } %81, 0
  store ptr %82, ptr %8, align 8
  %83 = extractvalue { ptr, i32 } %81, 1
  store i32 %83, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %192

84:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %175, %84
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = icmp sle i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  store i32 10, ptr %12, align 4
  br label %180

90:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %91 = load i32, ptr %11, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [100003 x i32], ptr @pos, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  store i32 %94, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %95 = load i32, ptr %13, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [100003 x i32], ptr @pL, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  store i32 %98, ptr %14, align 4, !tbaa !5
  %99 = load i32, ptr %13, align 4, !tbaa !5
  %100 = load i32, ptr %14, align 4, !tbaa !5
  %101 = sub nsw i32 %99, %100
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  call void @_ZNKSt8multisetIiSt4lessIiESaIiEE6rbeginEv(ptr dead_on_unwind writable sret(%"class.std::reverse_iterator") align 8 %15, ptr noundef nonnull align 8 dereferenceable(48) %5) #6
  %102 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt16reverse_iteratorISt23_Rb_tree_const_iteratorIiEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %15)
          to label %103 unwind label %110

103:                                              ; preds = %90
  %104 = load i32, ptr %102, align 4, !tbaa !5
  %105 = icmp ne i32 %101, %104
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br i1 %105, label %106, label %114

106:                                              ; preds = %103
  %107 = load ptr, ptr @stderr, align 8, !tbaa !14
  %108 = load i32, ptr %11, align 4, !tbaa !5
  %109 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef @.str.1, i32 noundef %108) #6
  store i8 0, ptr %4, align 1, !tbaa !11
  store i32 10, ptr %12, align 4
  br label %172

110:                                              ; preds = %90
  %111 = landingpad { ptr, i32 }
          cleanup
  %112 = extractvalue { ptr, i32 } %111, 0
  store ptr %112, ptr %8, align 8
  %113 = extractvalue { ptr, i32 } %111, 1
  store i32 %113, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %179

114:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %115 = load i32, ptr %13, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [100003 x i32], ptr @pR, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  store i32 %118, ptr %16, align 4, !tbaa !5
  %119 = load i32, ptr %16, align 4, !tbaa !5
  %120 = load i32, ptr %14, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100003 x i32], ptr @pR, i64 0, i64 %121
  store i32 %119, ptr %122, align 4, !tbaa !5
  %123 = load i32, ptr %14, align 4, !tbaa !5
  %124 = load i32, ptr %16, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [100003 x i32], ptr @pL, i64 0, i64 %125
  store i32 %123, ptr %126, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %127 = load i32, ptr %13, align 4, !tbaa !5
  %128 = load i32, ptr %14, align 4, !tbaa !5
  %129 = sub nsw i32 %127, %128
  store i32 %129, ptr %18, align 4, !tbaa !5
  %130 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE4findERKi(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 4 dereferenceable(4) %18)
          to label %131 unwind label %159

131:                                              ; preds = %114
  %132 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %17, i32 0, i32 0
  store ptr %130, ptr %132, align 8
  %133 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %17, i32 0, i32 0
  %134 = load ptr, ptr %133, align 8
  %135 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiE(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr %134)
          to label %136 unwind label %159

136:                                              ; preds = %131
  %137 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %19, i32 0, i32 0
  store ptr %135, ptr %137, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  %138 = load i32, ptr %16, align 4, !tbaa !5
  %139 = load i32, ptr @n, align 4, !tbaa !5
  %140 = icmp sle i32 %138, %139
  br i1 %140, label %141, label %171

141:                                              ; preds = %136
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %142 = load i32, ptr %16, align 4, !tbaa !5
  %143 = load i32, ptr %13, align 4, !tbaa !5
  %144 = sub nsw i32 %142, %143
  store i32 %144, ptr %21, align 4, !tbaa !5
  %145 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE4findERKi(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 4 dereferenceable(4) %21)
          to label %146 unwind label %163

146:                                              ; preds = %141
  %147 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %20, i32 0, i32 0
  store ptr %145, ptr %147, align 8
  %148 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %20, i32 0, i32 0
  %149 = load ptr, ptr %148, align 8
  %150 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiE(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr %149)
          to label %151 unwind label %163

151:                                              ; preds = %146
  %152 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %22, i32 0, i32 0
  store ptr %150, ptr %152, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  %153 = load i32, ptr %16, align 4, !tbaa !5
  %154 = load i32, ptr %14, align 4, !tbaa !5
  %155 = sub nsw i32 %153, %154
  store i32 %155, ptr %23, align 4, !tbaa !5
  %156 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 4 dereferenceable(4) %23)
          to label %157 unwind label %167

157:                                              ; preds = %151
  %158 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %24, i32 0, i32 0
  store ptr %156, ptr %158, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  br label %171

159:                                              ; preds = %131, %114
  %160 = landingpad { ptr, i32 }
          cleanup
  %161 = extractvalue { ptr, i32 } %160, 0
  store ptr %161, ptr %8, align 8
  %162 = extractvalue { ptr, i32 } %160, 1
  store i32 %162, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %178

163:                                              ; preds = %146, %141
  %164 = landingpad { ptr, i32 }
          cleanup
  %165 = extractvalue { ptr, i32 } %164, 0
  store ptr %165, ptr %8, align 8
  %166 = extractvalue { ptr, i32 } %164, 1
  store i32 %166, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  br label %178

167:                                              ; preds = %151
  %168 = landingpad { ptr, i32 }
          cleanup
  %169 = extractvalue { ptr, i32 } %168, 0
  store ptr %169, ptr %8, align 8
  %170 = extractvalue { ptr, i32 } %168, 1
  store i32 %170, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  br label %178

171:                                              ; preds = %157, %136
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  store i32 0, ptr %12, align 4
  br label %172

172:                                              ; preds = %171, %106
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  %173 = load i32, ptr %12, align 4
  switch i32 %173, label %180 [
    i32 0, label %174
  ]

174:                                              ; preds = %172
  br label %175

175:                                              ; preds = %174
  %176 = load i32, ptr %11, align 4, !tbaa !5
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr %11, align 4, !tbaa !5
  br label %85, !llvm.loop !16

178:                                              ; preds = %167, %163, %159
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %179

179:                                              ; preds = %178, %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %192

180:                                              ; preds = %172, %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %181

181:                                              ; preds = %180
  %182 = load i8, ptr %4, align 1, !tbaa !11, !range !17, !noundef !18
  %183 = trunc i8 %182 to i1
  %184 = zext i1 %183 to i64
  %185 = select i1 %183, ptr @.str.2, ptr @.str.3
  %186 = invoke i32 @puts(ptr noundef %185)
          to label %187 unwind label %188

187:                                              ; preds = %181
  call void @_ZNSt8multisetIiSt4lessIiESaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #6
  br label %26, !llvm.loop !19

188:                                              ; preds = %181
  %189 = landingpad { ptr, i32 }
          cleanup
  %190 = extractvalue { ptr, i32 } %189, 0
  store ptr %190, ptr %8, align 8
  %191 = extractvalue { ptr, i32 } %189, 1
  store i32 %191, ptr %9, align 4
  br label %192

192:                                              ; preds = %188, %179, %80
  call void @_ZNSt8multisetIiSt4lessIiESaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %195

193:                                              ; preds = %26
  store i32 0, ptr %1, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %194 = load i32, ptr %1, align 4
  ret i32 %194

195:                                              ; preds = %192
  %196 = load ptr, ptr %8, align 8
  %197 = load i32, ptr %9, align 4
  %198 = insertvalue { ptr, i32 } poison, ptr %196, 0
  %199 = insertvalue { ptr, i32 } %198, i32 %197, 1
  resume { ptr, i32 } %199
}

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #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 nounwind uwtable
declare dso_local void @_ZNSt8multisetIiSt4lessIiESaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3 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)) #4 align 2

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #5

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

declare i32 @puts(ptr noundef) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 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 #4 = { 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 #5 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !10}


; 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 }
%"class.std::reverse_iterator" = type { %"struct.std::_Rb_tree_const_iterator" }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@p = external dso_local global [100003 x i32], align 16
@pL = external dso_local local_unnamed_addr global [100003 x i32], align 16
@pR = external dso_local local_unnamed_addr global [100003 x i32], align 16
@pos = external dso_local local_unnamed_addr global [100003 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::multiset", align 8
  %3 = alloca i32, align 4
  %4 = alloca %"class.std::reverse_iterator", align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr %1, align 4, !tbaa !5
  %.not72 = icmp eq i32 %9, 0
  br i1 %.not72, label %._crit_edge75, label %.lr.ph74

.lr.ph74:                                         ; preds = %0, %.loopexit
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %.not4963 = icmp slt i32 %12, 1
  br i1 %.not4963, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph74
  %.lcssa = phi i32 [ %12, %.lr.ph74 ], [ %28, %.lr.ph ]
  store i32 1, ptr @pR, align 16, !tbaa !5
  %13 = add nsw i32 %.lcssa, 1
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [100003 x i32], ptr @pL, i64 0, i64 %14
  store i32 %.lcssa, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #5
  call void @_ZNSt8multisetIiSt4lessIiESaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %.not5065 = icmp slt i32 %16, 1
  br i1 %.not5065, label %.loopexit, label %.lr.ph68

.lr.ph:                                           ; preds = %.lr.ph74, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph74 ]
  %17 = getelementptr inbounds i32, ptr @p, i64 %indvars.iv
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %17)
  %19 = getelementptr inbounds [100003 x i32], ptr @pL, i64 0, i64 %indvars.iv
  %20 = trunc i64 %indvars.iv to i32
  %21 = add i32 %20, -1
  store i32 %21, ptr %19, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = getelementptr inbounds [100003 x i32], ptr @pR, i64 0, i64 %indvars.iv
  %23 = trunc nuw i64 %indvars.iv.next to i32
  store i32 %23, ptr %22, align 4, !tbaa !5
  %24 = load i32, ptr %17, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100003 x i32], ptr @pos, i64 0, i64 %25
  %27 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %27, ptr %26, align 4, !tbaa !5
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %.not49.not = icmp slt i64 %indvars.iv, %29
  br i1 %.not49.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader:                                       ; preds = %31
  %.not5169 = icmp slt i32 %33, 1
  br i1 %.not5169, label %.loopexit, label %.lr.ph71

.lr.ph68:                                         ; preds = %._crit_edge, %31
  %.04066 = phi i32 [ %32, %31 ], [ 1, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  %30 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %31 unwind label %34

31:                                               ; preds = %.lr.ph68
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %32 = add nuw nsw i32 %.04066, 1
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %.not50.not = icmp slt i32 %.04066, %33
  br i1 %.not50.not, label %.lr.ph68, label %.preheader, !llvm.loop !11

34:                                               ; preds = %.lr.ph68
  %35 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  br label %82

.lr.ph71:                                         ; preds = %.preheader, %75
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %75 ], [ 1, %.preheader ]
  %36 = getelementptr inbounds [100003 x i32], ptr @pos, i64 0, i64 %indvars.iv82
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100003 x i32], ptr @pL, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sub nsw i32 %37, %40
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @_ZNKSt8multisetIiSt4lessIiESaIiEE6rbeginEv(ptr dead_on_unwind nonnull writable sret(%"class.std::reverse_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(48) %2) #5
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt16reverse_iteratorISt23_Rb_tree_const_iteratorIiEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %.not52 = icmp eq i32 %41, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br i1 %.not52, label %44, label %71

44:                                               ; preds = %.lr.ph71
  %45 = getelementptr inbounds [100003 x i32], ptr @pR, i64 0, i64 %38
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = sext i32 %40 to i64
  %48 = getelementptr inbounds [100003 x i32], ptr @pR, i64 0, i64 %47
  store i32 %46, ptr %48, align 4, !tbaa !5
  %49 = sext i32 %46 to i64
  %50 = getelementptr inbounds [100003 x i32], ptr @pL, i64 0, i64 %49
  store i32 %40, ptr %50, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  store i32 %41, ptr %5, align 4, !tbaa !5
  %51 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE4findERKi(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(4) %5)
          to label %52 unwind label %65

52:                                               ; preds = %44
  %53 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiE(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr %51)
          to label %54 unwind label %65

54:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %.not53 = icmp sgt i32 %46, %55
  br i1 %.not53, label %75, label %56

56:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %57 = sub nsw i32 %46, %37
  store i32 %57, ptr %6, align 4, !tbaa !5
  %58 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE4findERKi(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(4) %6)
          to label %59 unwind label %67

59:                                               ; preds = %56
  %60 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIiE(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr %58)
          to label %61 unwind label %67

61:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  %62 = sub nsw i32 %46, %40
  store i32 %62, ptr %7, align 4, !tbaa !5
  %63 = invoke ptr @_ZNSt8multisetIiSt4lessIiESaIiEE6insertEOi(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(4) %7)
          to label %64 unwind label %69

64:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %75

65:                                               ; preds = %52, %44
  %66 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  br label %82

67:                                               ; preds = %59, %56
  %68 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  br label %82

69:                                               ; preds = %61
  %70 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  br label %82

71:                                               ; preds = %.lr.ph71
  %72 = trunc nuw nsw i64 %indvars.iv82 to i32
  %73 = load ptr, ptr @stderr, align 8, !tbaa !12
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef nonnull @.str.1, i32 noundef %72) #6
  br label %.loopexit

75:                                               ; preds = %54, %64
  %76 = phi i32 [ %55, %54 ], [ %.pre, %64 ]
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %77 = sext i32 %76 to i64
  %.not51.not = icmp slt i64 %indvars.iv82, %77
  br i1 %.not51.not, label %.lr.ph71, label %.loopexit, !llvm.loop !14

.loopexit:                                        ; preds = %75, %._crit_edge, %.preheader, %71
  %78 = phi ptr [ @.str.3, %71 ], [ @.str.2, %.preheader ], [ @.str.2, %._crit_edge ], [ @.str.2, %75 ]
  %79 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %78)
  call void @_ZNSt8multisetIiSt4lessIiESaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #5
  %80 = load i32, ptr %1, align 4, !tbaa !5
  %81 = add nsw i32 %80, -1
  store i32 %81, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %80, 0
  br i1 %.not, label %._crit_edge75, label %.lr.ph74, !llvm.loop !15

82:                                               ; preds = %65, %67, %69, %34
  %.pn55 = phi { ptr, i32 } [ %35, %34 ], [ %70, %69 ], [ %68, %67 ], [ %66, %65 ]
  call void @_ZNSt8multisetIiSt4lessIiESaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  resume { ptr, i32 } %.pn55

._crit_edge75:                                    ; preds = %.loopexit, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; 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 nounwind uwtable
declare dso_local void @_ZNSt8multisetIiSt4lessIiESaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3 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 #4 align 2

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { cold 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"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass