; LLVM IR from tangjz/acm-icpc :: 51nod (1115)

; 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<long long, int>, std::pair<long long, int>, std::_Identity<std::pair<long long, int>>, std::less<std::pair<long long, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<long long, int>, std::pair<long long, int>, std::_Identity<std::pair<long long, int>>, std::less<std::pair<long long, 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.0" = type <{ i64, i32, [4 x i8] }>
%"struct.std::pair" = 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
@tot = external dso_local global i32, align 4
@b = external dso_local global [100001 x i32], align 16
@L = external dso_local global [100001 x i32], align 16
@R = external dso_local global [100001 x i32], align 16
@a = external dso_local global [100001 x i64], align 16
@ans = external dso_local global i64, align 8
@sp = external dso_local global %"class.std::set", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 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 i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair.0", align 8
  %13 = alloca i64, align 8
  %14 = alloca { i64, i32 }, align 8
  %15 = alloca %"struct.std::pair", align 8
  %16 = alloca %"struct.std::pair.0", align 8
  %17 = alloca i64, align 8
  %18 = alloca { i64, i32 }, align 8
  %19 = alloca %"struct.std::pair", align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %23 = alloca %"struct.std::pair.0", align 8
  %24 = alloca i64, align 8
  %25 = alloca { i64, i32 }, align 8
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca %"struct.std::pair.0", align 8
  %29 = alloca i64, align 8
  %30 = alloca { i64, i32 }, align 8
  %31 = alloca i32, align 4
  %32 = alloca %"struct.std::pair.0", align 8
  %33 = alloca i64, align 8
  %34 = alloca { i64, i32 }, align 8
  %35 = alloca %"struct.std::pair.0", align 8
  %36 = alloca i64, align 8
  %37 = alloca { i64, i32 }, align 8
  %38 = alloca %"struct.std::pair", align 8
  store i32 0, ptr %1, align 4
  %39 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @tot, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  store i64 0, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %111, %0
  %41 = load i32, ptr %10, align 4, !tbaa !5
  %42 = load i32, ptr @tot, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %114

45:                                               ; preds = %40
  %46 = load i32, ptr %10, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr @b, i64 %47
  %49 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %48)
  %50 = load i32, ptr %10, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr @ans, align 8, !tbaa !9
  %56 = add nsw i64 %55, %54
  store i64 %56, ptr @ans, align 8, !tbaa !9
  %57 = load i64, ptr %7, align 8, !tbaa !9
  %58 = load i32, ptr %10, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = add nsw i64 %57, %62
  %64 = icmp sge i64 %63, 0
  br i1 %64, label %65, label %81

65:                                               ; preds = %45
  %66 = load i32, ptr %10, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = load i64, ptr %7, align 8, !tbaa !9
  %72 = add nsw i64 %71, %70
  store i64 %72, ptr %7, align 8, !tbaa !9
  %73 = load i64, ptr %6, align 8, !tbaa !9
  %74 = load i64, ptr %7, align 8, !tbaa !9
  %75 = icmp slt i64 %73, %74
  br i1 %75, label %76, label %80

76:                                               ; preds = %65
  %77 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %77, ptr %6, align 8, !tbaa !9
  %78 = load i32, ptr %2, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %3, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %76, %65
  br label %83

81:                                               ; preds = %45
  store i64 0, ptr %7, align 8, !tbaa !9
  %82 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %82, ptr %2, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %81, %80
  %84 = load i64, ptr %9, align 8, !tbaa !9
  %85 = load i32, ptr %10, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = sub nsw i64 %84, %89
  %91 = icmp sge i64 %90, 0
  br i1 %91, label %92, label %108

92:                                               ; preds = %83
  %93 = load i32, ptr %10, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = load i64, ptr %9, align 8, !tbaa !9
  %99 = sub nsw i64 %98, %97
  store i64 %99, ptr %9, align 8, !tbaa !9
  %100 = load i64, ptr %8, align 8, !tbaa !9
  %101 = load i64, ptr %9, align 8, !tbaa !9
  %102 = icmp slt i64 %100, %101
  br i1 %102, label %103, label %107

103:                                              ; preds = %92
  %104 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %104, ptr %8, align 8, !tbaa !9
  %105 = load i32, ptr %4, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %5, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %103, %92
  br label %110

108:                                              ; preds = %83
  store i64 0, ptr %9, align 8, !tbaa !9
  %109 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %109, ptr %4, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %108, %107
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %10, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %10, align 4, !tbaa !5
  br label %40, !llvm.loop !11

114:                                              ; preds = %44
  %115 = load i64, ptr %6, align 8, !tbaa !9
  %116 = load i64, ptr @ans, align 8, !tbaa !9
  %117 = load i64, ptr %8, align 8, !tbaa !9
  %118 = add nsw i64 %116, %117
  %119 = icmp sge i64 %115, %118
  br i1 %119, label %120, label %128

120:                                              ; preds = %114
  %121 = load i32, ptr %3, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds i32, ptr @b, i64 %122
  %124 = load i32, ptr @tot, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds i32, ptr @b, i64 %125
  %127 = call noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef @b, ptr noundef %123, ptr noundef %126)
  br label %136

128:                                              ; preds = %114
  %129 = load i32, ptr %5, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds i32, ptr @b, i64 %130
  %132 = load i32, ptr @tot, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds i32, ptr @b, i64 %133
  %135 = call noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef @b, ptr noundef %131, ptr noundef %134)
  br label %136

136:                                              ; preds = %128, %120
  store i64 0, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %203, %136
  %138 = load i32, ptr %11, align 4, !tbaa !5
  %139 = load i32, ptr @tot, align 4, !tbaa !5
  %140 = icmp slt i32 %138, %139
  br i1 %140, label %142, label %141

141:                                              ; preds = %137
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %206

142:                                              ; preds = %137
  %143 = load i32, ptr %11, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = icmp sgt i32 %146, 0
  br i1 %147, label %148, label %154

148:                                              ; preds = %142
  %149 = load i32, ptr @n, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %150
  %152 = load i64, ptr %151, align 8, !tbaa !9
  %153 = icmp slt i64 %152, 0
  br i1 %153, label %166, label %154

154:                                              ; preds = %148, %142
  %155 = load i32, ptr %11, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = icmp slt i32 %158, 0
  br i1 %159, label %160, label %192

160:                                              ; preds = %154
  %161 = load i32, ptr @n, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %162
  %164 = load i64, ptr %163, align 8, !tbaa !9
  %165 = icmp sgt i64 %164, 0
  br i1 %165, label %166, label %192

166:                                              ; preds = %160, %148
  %167 = load i32, ptr @n, align 4, !tbaa !5
  %168 = sub nsw i32 %167, 1
  %169 = load i32, ptr @n, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %170
  store i32 %168, ptr %171, align 4, !tbaa !5
  %172 = load i32, ptr @n, align 4, !tbaa !5
  %173 = add nsw i32 %172, 1
  %174 = load i32, ptr @n, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %175
  store i32 %173, ptr %176, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %177 = load i32, ptr @n, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %178
  %180 = load i64, ptr %179, align 8, !tbaa !9
  %181 = call noundef i64 @_ZSt3absx(i64 noundef %180)
  store i64 %181, ptr %13, align 8, !tbaa !9
  %182 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 4 dereferenceable(4) @n)
  store { i64, i32 } %182, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %14, i64 12, i1 false)
  %183 = call { ptr, i8 } @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %12)
  %184 = getelementptr inbounds { ptr, i8 }, ptr %15, i32 0, i32 0
  %185 = extractvalue { ptr, i8 } %183, 0
  store ptr %185, ptr %184, align 8
  %186 = getelementptr inbounds { ptr, i8 }, ptr %15, i32 0, i32 1
  %187 = extractvalue { ptr, i8 } %183, 1
  store i8 %187, ptr %186, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #8
  %188 = load i32, ptr @n, align 4, !tbaa !5
  %189 = add nsw i32 %188, 1
  store i32 %189, ptr @n, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %190
  store i64 0, ptr %191, align 8, !tbaa !9
  br label %192

192:                                              ; preds = %166, %160, %154
  %193 = load i32, ptr %11, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %194
  %196 = load i32, ptr %195, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = load i32, ptr @n, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %199
  %201 = load i64, ptr %200, align 8, !tbaa !9
  %202 = add nsw i64 %201, %197
  store i64 %202, ptr %200, align 8, !tbaa !9
  br label %203

203:                                              ; preds = %192
  %204 = load i32, ptr %11, align 4, !tbaa !5
  %205 = add nsw i32 %204, 1
  store i32 %205, ptr %11, align 4, !tbaa !5
  br label %137, !llvm.loop !13

206:                                              ; preds = %141
  %207 = load i32, ptr @n, align 4, !tbaa !5
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %208
  %210 = load i64, ptr %209, align 8, !tbaa !9
  %211 = icmp ne i64 %210, 0
  br i1 %211, label %212, label %236

212:                                              ; preds = %206
  %213 = load i32, ptr @n, align 4, !tbaa !5
  %214 = sub nsw i32 %213, 1
  %215 = load i32, ptr @n, align 4, !tbaa !5
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %216
  store i32 %214, ptr %217, align 4, !tbaa !5
  %218 = load i32, ptr @n, align 4, !tbaa !5
  %219 = add nsw i32 %218, 1
  %220 = load i32, ptr @n, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %221
  store i32 %219, ptr %222, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %223 = load i32, ptr @n, align 4, !tbaa !5
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %224
  %226 = load i64, ptr %225, align 8, !tbaa !9
  %227 = call noundef i64 @_ZSt3absx(i64 noundef %226)
  store i64 %227, ptr %17, align 8, !tbaa !9
  %228 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 4 dereferenceable(4) @n)
  store { i64, i32 } %228, ptr %18, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %18, i64 12, i1 false)
  %229 = call { ptr, i8 } @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %16)
  %230 = getelementptr inbounds { ptr, i8 }, ptr %19, i32 0, i32 0
  %231 = extractvalue { ptr, i8 } %229, 0
  store ptr %231, ptr %230, align 8
  %232 = getelementptr inbounds { ptr, i8 }, ptr %19, i32 0, i32 1
  %233 = extractvalue { ptr, i8 } %229, 1
  store i8 %233, ptr %232, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #8
  %234 = load i32, ptr @n, align 4, !tbaa !5
  %235 = add nsw i32 %234, 1
  store i32 %235, ptr @n, align 4, !tbaa !5
  br label %236

236:                                              ; preds = %212, %206
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #8
  store i32 0, ptr %20, align 4, !tbaa !5
  br label %237

237:                                              ; preds = %258, %236
  %238 = load i32, ptr %20, align 4, !tbaa !5
  %239 = load i32, ptr @n, align 4, !tbaa !5
  %240 = icmp slt i32 %238, %239
  br i1 %240, label %242, label %241

241:                                              ; preds = %237
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #8
  br label %261

242:                                              ; preds = %237
  %243 = load i32, ptr %20, align 4, !tbaa !5
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %244
  %246 = load i64, ptr %245, align 8, !tbaa !9
  %247 = icmp sgt i64 %246, 0
  br i1 %247, label %248, label %257

248:                                              ; preds = %242
  %249 = load i32, ptr @m, align 4, !tbaa !5
  %250 = add nsw i32 %249, -1
  store i32 %250, ptr @m, align 4, !tbaa !5
  %251 = load i32, ptr %20, align 4, !tbaa !5
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %252
  %254 = load i64, ptr %253, align 8, !tbaa !9
  %255 = load i64, ptr @ans, align 8, !tbaa !9
  %256 = add nsw i64 %255, %254
  store i64 %256, ptr @ans, align 8, !tbaa !9
  br label %257

257:                                              ; preds = %248, %242
  br label %258

258:                                              ; preds = %257
  %259 = load i32, ptr %20, align 4, !tbaa !5
  %260 = add nsw i32 %259, 1
  store i32 %260, ptr %20, align 4, !tbaa !5
  br label %237, !llvm.loop !14

261:                                              ; preds = %241
  br label %262

262:                                              ; preds = %435, %433, %261
  %263 = load i32, ptr @m, align 4, !tbaa !5
  %264 = icmp slt i32 %263, 0
  br i1 %264, label %265, label %436

265:                                              ; preds = %262
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #8
  %266 = call ptr @_ZNKSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #8
  %267 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %22, i32 0, i32 0
  store ptr %266, ptr %267, align 8
  %268 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIxiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %22) #8
  %269 = getelementptr inbounds %"struct.std::pair.0", ptr %268, i32 0, i32 1
  %270 = load i32, ptr %269, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #8
  store i32 %270, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %23) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #8
  %271 = load i32, ptr %21, align 4, !tbaa !5
  %272 = sext i32 %271 to i64
  %273 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %272
  %274 = load i64, ptr %273, align 8, !tbaa !9
  %275 = call noundef i64 @_ZSt3absx(i64 noundef %274)
  store i64 %275, ptr %24, align 8, !tbaa !9
  %276 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull align 4 dereferenceable(4) %21)
  store { i64, i32 } %276, ptr %25, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %23, ptr align 8 %25, i64 12, i1 false)
  %277 = call noundef i64 @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %23)
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %23) #8
  %278 = load i32, ptr %21, align 4, !tbaa !5
  %279 = sext i32 %278 to i64
  %280 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %279
  %281 = load i64, ptr %280, align 8, !tbaa !9
  %282 = icmp sle i64 %281, 0
  br i1 %282, label %283, label %317

283:                                              ; preds = %265
  %284 = load i32, ptr %21, align 4, !tbaa !5
  %285 = sext i32 %284 to i64
  %286 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %285
  %287 = load i32, ptr %286, align 4, !tbaa !5
  %288 = icmp slt i32 %287, 0
  br i1 %288, label %296, label %289

289:                                              ; preds = %283
  %290 = load i32, ptr %21, align 4, !tbaa !5
  %291 = sext i32 %290 to i64
  %292 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %291
  %293 = load i32, ptr %292, align 4, !tbaa !5
  %294 = load i32, ptr @n, align 4, !tbaa !5
  %295 = icmp sge i32 %293, %294
  br i1 %295, label %296, label %317

296:                                              ; preds = %289, %283
  %297 = load i32, ptr %21, align 4, !tbaa !5
  %298 = sext i32 %297 to i64
  %299 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %298
  %300 = load i32, ptr %299, align 4, !tbaa !5
  %301 = load i32, ptr %21, align 4, !tbaa !5
  %302 = sext i32 %301 to i64
  %303 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %302
  %304 = load i32, ptr %303, align 4, !tbaa !5
  %305 = sext i32 %304 to i64
  %306 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %305
  store i32 %300, ptr %306, align 4, !tbaa !5
  %307 = load i32, ptr %21, align 4, !tbaa !5
  %308 = sext i32 %307 to i64
  %309 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %308
  %310 = load i32, ptr %309, align 4, !tbaa !5
  %311 = load i32, ptr %21, align 4, !tbaa !5
  %312 = sext i32 %311 to i64
  %313 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %312
  %314 = load i32, ptr %313, align 4, !tbaa !5
  %315 = sext i32 %314 to i64
  %316 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %315
  store i32 %310, ptr %316, align 4, !tbaa !5
  store i32 11, ptr %26, align 4
  br label %433, !llvm.loop !17

317:                                              ; preds = %289, %265
  %318 = load i32, ptr %21, align 4, !tbaa !5
  %319 = sext i32 %318 to i64
  %320 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %319
  %321 = load i64, ptr %320, align 8, !tbaa !9
  %322 = call noundef i64 @_ZSt3absx(i64 noundef %321)
  %323 = load i64, ptr @ans, align 8, !tbaa !9
  %324 = sub nsw i64 %323, %322
  store i64 %324, ptr @ans, align 8, !tbaa !9
  %325 = load i32, ptr %21, align 4, !tbaa !5
  %326 = sext i32 %325 to i64
  %327 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %326
  %328 = load i32, ptr %327, align 4, !tbaa !5
  %329 = icmp sge i32 %328, 0
  br i1 %329, label %330, label %371

330:                                              ; preds = %317
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #8
  %331 = load i32, ptr %21, align 4, !tbaa !5
  %332 = sext i32 %331 to i64
  %333 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %332
  %334 = load i32, ptr %333, align 4, !tbaa !5
  store i32 %334, ptr %27, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %28) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #8
  %335 = load i32, ptr %27, align 4, !tbaa !5
  %336 = sext i32 %335 to i64
  %337 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %336
  %338 = load i64, ptr %337, align 8, !tbaa !9
  %339 = call noundef i64 @_ZSt3absx(i64 noundef %338)
  store i64 %339, ptr %29, align 8, !tbaa !9
  %340 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %29, ptr noundef nonnull align 4 dereferenceable(4) %27)
  store { i64, i32 } %340, ptr %30, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %28, ptr align 8 %30, i64 12, i1 false)
  %341 = call noundef i64 @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %28)
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %28) #8
  %342 = load i32, ptr %27, align 4, !tbaa !5
  %343 = sext i32 %342 to i64
  %344 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %343
  %345 = load i32, ptr %344, align 4, !tbaa !5
  %346 = load i32, ptr %27, align 4, !tbaa !5
  %347 = sext i32 %346 to i64
  %348 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %347
  %349 = load i32, ptr %348, align 4, !tbaa !5
  %350 = sext i32 %349 to i64
  %351 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %350
  store i32 %345, ptr %351, align 4, !tbaa !5
  %352 = load i32, ptr %27, align 4, !tbaa !5
  %353 = sext i32 %352 to i64
  %354 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %353
  %355 = load i32, ptr %354, align 4, !tbaa !5
  %356 = load i32, ptr %27, align 4, !tbaa !5
  %357 = sext i32 %356 to i64
  %358 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %357
  %359 = load i32, ptr %358, align 4, !tbaa !5
  %360 = sext i32 %359 to i64
  %361 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %360
  store i32 %355, ptr %361, align 4, !tbaa !5
  %362 = load i32, ptr %27, align 4, !tbaa !5
  %363 = sext i32 %362 to i64
  %364 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %363
  %365 = load i64, ptr %364, align 8, !tbaa !9
  %366 = load i32, ptr %21, align 4, !tbaa !5
  %367 = sext i32 %366 to i64
  %368 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %367
  %369 = load i64, ptr %368, align 8, !tbaa !9
  %370 = add nsw i64 %369, %365
  store i64 %370, ptr %368, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #8
  br label %371

371:                                              ; preds = %330, %317
  %372 = load i32, ptr %21, align 4, !tbaa !5
  %373 = sext i32 %372 to i64
  %374 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %373
  %375 = load i32, ptr %374, align 4, !tbaa !5
  %376 = load i32, ptr @n, align 4, !tbaa !5
  %377 = icmp slt i32 %375, %376
  br i1 %377, label %378, label %419

378:                                              ; preds = %371
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #8
  %379 = load i32, ptr %21, align 4, !tbaa !5
  %380 = sext i32 %379 to i64
  %381 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %380
  %382 = load i32, ptr %381, align 4, !tbaa !5
  store i32 %382, ptr %31, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %32) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #8
  %383 = load i32, ptr %31, align 4, !tbaa !5
  %384 = sext i32 %383 to i64
  %385 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %384
  %386 = load i64, ptr %385, align 8, !tbaa !9
  %387 = call noundef i64 @_ZSt3absx(i64 noundef %386)
  store i64 %387, ptr %33, align 8, !tbaa !9
  %388 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %33, ptr noundef nonnull align 4 dereferenceable(4) %31)
  store { i64, i32 } %388, ptr %34, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %32, ptr align 8 %34, i64 12, i1 false)
  %389 = call noundef i64 @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %32)
  call void @llvm.lifetime.end.p0(i64 8, ptr %33) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %32) #8
  %390 = load i32, ptr %31, align 4, !tbaa !5
  %391 = sext i32 %390 to i64
  %392 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %391
  %393 = load i32, ptr %392, align 4, !tbaa !5
  %394 = load i32, ptr %31, align 4, !tbaa !5
  %395 = sext i32 %394 to i64
  %396 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %395
  %397 = load i32, ptr %396, align 4, !tbaa !5
  %398 = sext i32 %397 to i64
  %399 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %398
  store i32 %393, ptr %399, align 4, !tbaa !5
  %400 = load i32, ptr %31, align 4, !tbaa !5
  %401 = sext i32 %400 to i64
  %402 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %401
  %403 = load i32, ptr %402, align 4, !tbaa !5
  %404 = load i32, ptr %31, align 4, !tbaa !5
  %405 = sext i32 %404 to i64
  %406 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %405
  %407 = load i32, ptr %406, align 4, !tbaa !5
  %408 = sext i32 %407 to i64
  %409 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %408
  store i32 %403, ptr %409, align 4, !tbaa !5
  %410 = load i32, ptr %31, align 4, !tbaa !5
  %411 = sext i32 %410 to i64
  %412 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %411
  %413 = load i64, ptr %412, align 8, !tbaa !9
  %414 = load i32, ptr %21, align 4, !tbaa !5
  %415 = sext i32 %414 to i64
  %416 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %415
  %417 = load i64, ptr %416, align 8, !tbaa !9
  %418 = add nsw i64 %417, %413
  store i64 %418, ptr %416, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #8
  br label %419

419:                                              ; preds = %378, %371
  %420 = load i32, ptr @m, align 4, !tbaa !5
  %421 = add nsw i32 %420, 1
  store i32 %421, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %35) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %36) #8
  %422 = load i32, ptr %21, align 4, !tbaa !5
  %423 = sext i32 %422 to i64
  %424 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %423
  %425 = load i64, ptr %424, align 8, !tbaa !9
  %426 = call noundef i64 @_ZSt3absx(i64 noundef %425)
  store i64 %426, ptr %36, align 8, !tbaa !9
  %427 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull align 4 dereferenceable(4) %21)
  store { i64, i32 } %427, ptr %37, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %35, ptr align 8 %37, i64 12, i1 false)
  %428 = call { ptr, i8 } @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %35)
  %429 = getelementptr inbounds { ptr, i8 }, ptr %38, i32 0, i32 0
  %430 = extractvalue { ptr, i8 } %428, 0
  store ptr %430, ptr %429, align 8
  %431 = getelementptr inbounds { ptr, i8 }, ptr %38, i32 0, i32 1
  %432 = extractvalue { ptr, i8 } %428, 1
  store i8 %432, ptr %431, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %36) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %35) #8
  store i32 0, ptr %26, align 4
  br label %433

433:                                              ; preds = %419, %296
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  %434 = load i32, ptr %26, align 4
  switch i32 %434, label %440 [
    i32 0, label %435
    i32 11, label %262
  ]

435:                                              ; preds = %433
  br label %262, !llvm.loop !17

436:                                              ; preds = %262
  %437 = load i64, ptr @ans, align 8, !tbaa !9
  %438 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %437)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %26, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  %439 = load i32, ptr %1, align 4
  ret i32 %439

440:                                              ; preds = %433
  unreachable
}

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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef, ptr noundef, ptr noundef) #3

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) #5

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(12)) #4 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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!16, !6, i64 8}
!16 = !{!"_ZTSSt4pairIxiE", !10, i64 0, !6, i64 8}
!17 = distinct !{!17, !12}


; 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<long long, int>, std::pair<long long, int>, std::_Identity<std::pair<long long, int>>, std::less<std::pair<long long, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<long long, int>, std::pair<long long, int>, std::_Identity<std::pair<long long, int>>, std::less<std::pair<long long, 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.0" = type <{ i64, i32, [4 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
@tot = external dso_local global i32, align 4
@b = external dso_local global [100001 x i32], align 16
@L = external dso_local local_unnamed_addr global [100001 x i32], align 16
@R = external dso_local local_unnamed_addr global [100001 x i32], align 16
@a = external dso_local local_unnamed_addr global [100001 x i64], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@sp = external dso_local global %"class.std::set", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %"struct.std::pair.0", align 8
  %2 = alloca i64, align 8
  %3 = alloca %"struct.std::pair.0", align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %7 = alloca %"struct.std::pair.0", align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::pair.0", align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"struct.std::pair.0", align 8
  %14 = alloca i64, align 8
  %15 = alloca %"struct.std::pair.0", align 8
  %16 = alloca i64, align 8
  %17 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @tot, ptr noundef nonnull @m)
  %18 = load i32, ptr @tot, align 4, !tbaa !5
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = load i64, ptr @ans, align 8, !tbaa !9
  br label %._crit_edge

._crit_edge.loopexit:                             ; preds = %48
  %20 = sext i32 %.162 to i64
  %21 = sext i32 %.166 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.._crit_edge_crit_edge, %._crit_edge.loopexit
  %22 = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %35, %._crit_edge.loopexit ]
  %.071.lcssa = phi i64 [ 0, %.._crit_edge_crit_edge ], [ %.172, %._crit_edge.loopexit ]
  %.067.lcssa = phi i64 [ 0, %.._crit_edge_crit_edge ], [ %.168, %._crit_edge.loopexit ]
  %.065.lcssa = phi i64 [ 0, %.._crit_edge_crit_edge ], [ %21, %._crit_edge.loopexit ]
  %.061.lcssa = phi i64 [ 0, %.._crit_edge_crit_edge ], [ %20, %._crit_edge.loopexit ]
  %.lcssa = phi i32 [ %18, %.._crit_edge_crit_edge ], [ %49, %._crit_edge.loopexit ]
  %23 = add nsw i64 %22, %.071.lcssa
  %.not = icmp slt i64 %.067.lcssa, %23
  %24 = sext i32 %.lcssa to i64
  %25 = getelementptr inbounds i32, ptr @b, i64 %24
  %.065.lcssa..061.lcssa = select i1 %.not, i64 %.065.lcssa, i64 %.061.lcssa
  %26 = getelementptr inbounds i32, ptr @b, i64 %.065.lcssa..061.lcssa
  %27 = tail call noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef nonnull @b, ptr noundef nonnull %26, ptr noundef nonnull %25)
  store i64 0, ptr @ans, align 8, !tbaa !9
  %28 = load i32, ptr @tot, align 4, !tbaa !5
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %.lr.ph101, label %.._crit_edge102_crit_edge

.lr.ph:                                           ; preds = %0, %48
  %indvars.iv = phi i64 [ %indvars.iv.next, %48 ], [ 0, %0 ]
  %.094 = phi i32 [ %.1, %48 ], [ 0, %0 ]
  %.06193 = phi i32 [ %.162, %48 ], [ 0, %0 ]
  %.06392 = phi i32 [ %.164, %48 ], [ 0, %0 ]
  %.06591 = phi i32 [ %.166, %48 ], [ 0, %0 ]
  %.06790 = phi i64 [ %.168, %48 ], [ 0, %0 ]
  %.06989 = phi i64 [ %.170, %48 ], [ 0, %0 ]
  %.07188 = phi i64 [ %.172, %48 ], [ 0, %0 ]
  %.07387 = phi i64 [ %.174, %48 ], [ 0, %0 ]
  %30 = getelementptr inbounds i32, ptr @b, i64 %indvars.iv
  %31 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %30)
  %32 = load i32, ptr %30, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = load i64, ptr @ans, align 8, !tbaa !9
  %35 = add nsw i64 %34, %33
  store i64 %35, ptr @ans, align 8, !tbaa !9
  %36 = add nsw i64 %.06989, %33
  %37 = icmp sgt i64 %36, -1
  %38 = trunc nuw nsw i64 %indvars.iv to i32
  br i1 %37, label %39, label %42

39:                                               ; preds = %.lr.ph
  %40 = icmp slt i64 %.06790, %36
  %41 = add nsw i32 %.094, 1
  %spec.select = tail call i64 @llvm.smax.i64(i64 %.06790, i64 %36)
  %spec.select83 = select i1 %40, i32 %41, i32 %.06193
  br label %42

42:                                               ; preds = %39, %.lr.ph
  %.170 = phi i64 [ %36, %39 ], [ 0, %.lr.ph ]
  %.168 = phi i64 [ %spec.select, %39 ], [ %.06790, %.lr.ph ]
  %.162 = phi i32 [ %spec.select83, %39 ], [ %.06193, %.lr.ph ]
  %.1 = phi i32 [ %.094, %39 ], [ %38, %.lr.ph ]
  %43 = sub nsw i64 %.07387, %33
  %44 = icmp sgt i64 %43, -1
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = icmp slt i64 %.07188, %43
  %47 = add nsw i32 %.06392, 1
  %spec.select84 = tail call i64 @llvm.smax.i64(i64 %.07188, i64 %43)
  %spec.select85 = select i1 %46, i32 %47, i32 %.06591
  br label %48

48:                                               ; preds = %45, %42
  %.174 = phi i64 [ %43, %45 ], [ 0, %42 ]
  %.172 = phi i64 [ %spec.select84, %45 ], [ %.07188, %42 ]
  %.166 = phi i32 [ %spec.select85, %45 ], [ %.06591, %42 ]
  %.164 = phi i32 [ %.06392, %45 ], [ %38, %42 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %49 = load i32, ptr @tot, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next, %50
  br i1 %51, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !11

.._crit_edge102_crit_edge:                        ; preds = %._crit_edge
  %.pre121 = load i32, ptr @n, align 4, !tbaa !5
  %.phi.trans.insert122 = sext i32 %.pre121 to i64
  %.phi.trans.insert123 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %.phi.trans.insert122
  %.pre124 = load i64, ptr %.phi.trans.insert123, align 8, !tbaa !9
  br label %._crit_edge102

.lr.ph101:                                        ; preds = %._crit_edge
  %.sroa.228.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  br label %54

._crit_edge102:                                   ; preds = %.thread, %.._crit_edge102_crit_edge
  %.pre-phi135 = phi i64 [ %.phi.trans.insert122, %.._crit_edge102_crit_edge ], [ %.pre-phi134, %.thread ]
  %52 = phi i64 [ %.pre124, %.._crit_edge102_crit_edge ], [ %92, %.thread ]
  %53 = phi i32 [ %.pre121, %.._crit_edge102_crit_edge ], [ %88, %.thread ]
  %.not81 = icmp eq i64 %52, 0
  br i1 %.not81, label %105, label %95

54:                                               ; preds = %.lr.ph101, %.thread
  %55 = phi i32 [ %28, %.lr.ph101 ], [ %86, %.thread ]
  %indvars.iv110 = phi i64 [ 0, %.lr.ph101 ], [ %indvars.iv.next111, %.thread ]
  %56 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %indvars.iv110
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = icmp sgt i32 %57, 0
  br i1 %58, label %59, label %65

59:                                               ; preds = %54
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = icmp slt i64 %63, 0
  br i1 %64, label %72, label %.thread

65:                                               ; preds = %54
  %66 = icmp slt i32 %57, 0
  %.pre117 = load i32, ptr @n, align 4, !tbaa !5
  %67 = sext i32 %.pre117 to i64
  %68 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !9
  br i1 %66, label %70, label %.thread

70:                                               ; preds = %65
  %71 = icmp sgt i64 %69, 0
  br i1 %71, label %72, label %.thread

72:                                               ; preds = %70, %59
  %73 = phi i64 [ %69, %70 ], [ %63, %59 ]
  %.pre-phi = phi i64 [ %67, %70 ], [ %61, %59 ]
  %74 = phi i32 [ %.pre117, %70 ], [ %60, %59 ]
  %75 = add nsw i32 %74, -1
  %76 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %.pre-phi
  store i32 %75, ptr %76, align 4, !tbaa !5
  %77 = add nsw i32 %74, 1
  %78 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %.pre-phi
  store i32 %77, ptr %78, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  %79 = call noundef i64 @_ZSt3absx(i64 noundef %73)
  store i64 %79, ptr %2, align 8, !tbaa !9
  %80 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %.fca.0.extract25 = extractvalue { i64, i32 } %80, 0
  %.fca.1.extract26 = extractvalue { i64, i32 } %80, 1
  store i64 %.fca.0.extract25, ptr %1, align 8
  store i32 %.fca.1.extract26, ptr %.sroa.228.0..sroa_idx, align 8
  %81 = call { ptr, i8 } @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #8
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr @n, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %84
  store i64 0, ptr %85, align 8, !tbaa !9
  %.pre116 = load i32, ptr %56, align 4, !tbaa !5
  %.pre120 = load i32, ptr @tot, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %65, %59, %72, %70
  %.pre-phi134 = phi i64 [ %61, %59 ], [ %84, %72 ], [ %67, %70 ], [ %67, %65 ]
  %86 = phi i32 [ %55, %59 ], [ %.pre120, %72 ], [ %55, %70 ], [ %55, %65 ]
  %87 = phi i64 [ %63, %59 ], [ 0, %72 ], [ %69, %70 ], [ %69, %65 ]
  %88 = phi i32 [ %60, %59 ], [ %83, %72 ], [ %.pre117, %70 ], [ %.pre117, %65 ]
  %89 = phi i32 [ %57, %59 ], [ %.pre116, %72 ], [ %57, %70 ], [ 0, %65 ]
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %.pre-phi134
  %92 = add nsw i64 %87, %90
  store i64 %92, ptr %91, align 8, !tbaa !9
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %93 = sext i32 %86 to i64
  %94 = icmp slt i64 %indvars.iv.next111, %93
  br i1 %94, label %54, label %._crit_edge102, !llvm.loop !13

95:                                               ; preds = %._crit_edge102
  %96 = add nsw i32 %53, -1
  %97 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %.pre-phi135
  store i32 %96, ptr %97, align 4, !tbaa !5
  %98 = add nsw i32 %53, 1
  %99 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %.pre-phi135
  store i32 %98, ptr %99, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #8
  %100 = call noundef i64 @_ZSt3absx(i64 noundef %52)
  store i64 %100, ptr %4, align 8, !tbaa !9
  %101 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %.fca.0.extract19 = extractvalue { i64, i32 } %101, 0
  %.fca.1.extract20 = extractvalue { i64, i32 } %101, 1
  store i64 %.fca.0.extract19, ptr %3, align 8
  %.sroa.222.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %.fca.1.extract20, ptr %.sroa.222.0..sroa_idx, align 8
  %102 = call { ptr, i8 } @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #8
  %103 = load i32, ptr @n, align 4, !tbaa !5
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr @n, align 4, !tbaa !5
  br label %105

105:                                              ; preds = %95, %._crit_edge102
  %106 = phi i32 [ %104, %95 ], [ %53, %._crit_edge102 ]
  %m.promoted = load i32, ptr @m, align 4, !tbaa !5
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !9
  %107 = icmp sgt i32 %106, 0
  br i1 %107, label %.lr.ph105.preheader, label %.preheader

.lr.ph105.preheader:                              ; preds = %105
  %wide.trip.count = zext nneg i32 %106 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %108 = icmp eq i32 %106, 1
  br i1 %108, label %.preheader.loopexit.unr-lcssa, label %.lr.ph105.preheader.new

.lr.ph105.preheader.new:                          ; preds = %.lr.ph105.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph105

.preheader.loopexit.unr-lcssa:                    ; preds = %134, %.lr.ph105.preheader
  %.lcssa149.ph = phi i64 [ poison, %.lr.ph105.preheader ], [ %135, %134 ]
  %.lcssa148.ph = phi i32 [ poison, %.lr.ph105.preheader ], [ %136, %134 ]
  %indvars.iv113.unr = phi i64 [ 0, %.lr.ph105.preheader ], [ %indvars.iv.next114.1, %134 ]
  %.unr = phi i32 [ %m.promoted, %.lr.ph105.preheader ], [ %136, %134 ]
  %.unr154 = phi i64 [ %ans.promoted, %.lr.ph105.preheader ], [ %135, %134 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph105.epil

.lr.ph105.epil:                                   ; preds = %.preheader.loopexit.unr-lcssa
  %109 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %indvars.iv113.unr
  %110 = load i64, ptr %109, align 8, !tbaa !9
  %111 = icmp sgt i64 %110, 0
  br i1 %111, label %112, label %.preheader

112:                                              ; preds = %.lr.ph105.epil
  %113 = add nsw i32 %.unr, -1
  store i32 %113, ptr @m, align 4, !tbaa !5
  %114 = add nsw i64 %.unr154, %110
  store i64 %114, ptr @ans, align 8, !tbaa !9
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit.unr-lcssa, %112, %.lr.ph105.epil, %105
  %115 = phi i64 [ %ans.promoted, %105 ], [ %.lcssa149.ph, %.preheader.loopexit.unr-lcssa ], [ %.unr154, %.lr.ph105.epil ], [ %114, %112 ]
  %116 = phi i32 [ %m.promoted, %105 ], [ %.lcssa148.ph, %.preheader.loopexit.unr-lcssa ], [ %.unr, %.lr.ph105.epil ], [ %113, %112 ]
  %117 = icmp slt i32 %116, 0
  br i1 %117, label %.lr.ph106, label %._crit_edge107

.lr.ph106:                                        ; preds = %.preheader
  %.sroa.213.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  %.sroa.29.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 8
  %.sroa.25.0..sroa_idx = getelementptr inbounds i8, ptr %13, i64 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %15, i64 8
  br label %137

.lr.ph105:                                        ; preds = %134, %.lr.ph105.preheader.new
  %indvars.iv113 = phi i64 [ 0, %.lr.ph105.preheader.new ], [ %indvars.iv.next114.1, %134 ]
  %118 = phi i32 [ %m.promoted, %.lr.ph105.preheader.new ], [ %136, %134 ]
  %119 = phi i64 [ %ans.promoted, %.lr.ph105.preheader.new ], [ %135, %134 ]
  %niter = phi i64 [ 0, %.lr.ph105.preheader.new ], [ %niter.next.1, %134 ]
  %120 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %indvars.iv113
  %121 = load i64, ptr %120, align 16, !tbaa !9
  %122 = icmp sgt i64 %121, 0
  br i1 %122, label %123, label %.lr.ph105.1

123:                                              ; preds = %.lr.ph105
  %124 = add nsw i32 %118, -1
  store i32 %124, ptr @m, align 4, !tbaa !5
  %125 = add nsw i64 %119, %121
  store i64 %125, ptr @ans, align 8, !tbaa !9
  br label %.lr.ph105.1

.lr.ph105.1:                                      ; preds = %.lr.ph105, %123
  %126 = phi i64 [ %119, %.lr.ph105 ], [ %125, %123 ]
  %127 = phi i32 [ %118, %.lr.ph105 ], [ %124, %123 ]
  %indvars.iv.next114 = or disjoint i64 %indvars.iv113, 1
  %128 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %indvars.iv.next114
  %129 = load i64, ptr %128, align 8, !tbaa !9
  %130 = icmp sgt i64 %129, 0
  br i1 %130, label %131, label %134

131:                                              ; preds = %.lr.ph105.1
  %132 = add nsw i32 %127, -1
  store i32 %132, ptr @m, align 4, !tbaa !5
  %133 = add nsw i64 %126, %129
  store i64 %133, ptr @ans, align 8, !tbaa !9
  br label %134

134:                                              ; preds = %131, %.lr.ph105.1
  %135 = phi i64 [ %126, %.lr.ph105.1 ], [ %133, %131 ]
  %136 = phi i32 [ %127, %.lr.ph105.1 ], [ %132, %131 ]
  %indvars.iv.next114.1 = add nuw nsw i64 %indvars.iv113, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.preheader.loopexit.unr-lcssa, label %.lr.ph105, !llvm.loop !14

137:                                              ; preds = %.lr.ph106, %232
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #8
  %138 = call ptr @_ZNKSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @sp) #8
  store ptr %138, ptr %6, align 8
  %139 = call noundef ptr @_ZNKSt23_Rb_tree_const_iteratorISt4pairIxiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #8
  %140 = getelementptr inbounds i8, ptr %139, i64 8
  %141 = load i32, ptr %140, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  store i32 %141, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %142
  %144 = load i64, ptr %143, align 8, !tbaa !9
  %145 = call noundef i64 @_ZSt3absx(i64 noundef %144)
  store i64 %145, ptr %8, align 8, !tbaa !9
  %146 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %.fca.0.extract10 = extractvalue { i64, i32 } %146, 0
  %.fca.1.extract11 = extractvalue { i64, i32 } %146, 1
  store i64 %.fca.0.extract10, ptr %7, align 8
  store i32 %.fca.1.extract11, ptr %.sroa.213.0..sroa_idx, align 8
  %147 = call noundef i64 @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  %148 = load i32, ptr %5, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %149
  %151 = load i64, ptr %150, align 8, !tbaa !9
  %152 = icmp slt i64 %151, 1
  br i1 %152, label %153, label %163

153:                                              ; preds = %137
  %154 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %149
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = icmp sgt i32 %155, -1
  %.phi.trans.insert131 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %149
  %.pre132 = load i32, ptr %.phi.trans.insert131, align 4, !tbaa !5
  %157 = load i32, ptr @n, align 4
  %.not82 = icmp slt i32 %.pre132, %157
  %or.cond = select i1 %156, i1 %.not82, i1 false
  br i1 %or.cond, label %163, label %._crit_edge130

._crit_edge130:                                   ; preds = %153
  %158 = sext i32 %.pre132 to i64
  %159 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %158
  store i32 %155, ptr %159, align 4, !tbaa !5
  %160 = load i32, ptr %154, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %161
  store i32 %.pre132, ptr %162, align 4, !tbaa !5
  br label %232, !llvm.loop !17

163:                                              ; preds = %153, %137
  %164 = call noundef i64 @_ZSt3absx(i64 noundef %151)
  %165 = load i64, ptr @ans, align 8, !tbaa !9
  %166 = sub nsw i64 %165, %164
  store i64 %166, ptr @ans, align 8, !tbaa !9
  %167 = load i32, ptr %5, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = icmp sgt i32 %170, -1
  br i1 %171, label %172, label %196

172:                                              ; preds = %163
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #8
  store i32 %170, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %10) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #8
  %173 = zext nneg i32 %170 to i64
  %174 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %173
  %175 = load i64, ptr %174, align 8, !tbaa !9
  %176 = call noundef i64 @_ZSt3absx(i64 noundef %175)
  store i64 %176, ptr %11, align 8, !tbaa !9
  %177 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %.fca.0.extract6 = extractvalue { i64, i32 } %177, 0
  %.fca.1.extract7 = extractvalue { i64, i32 } %177, 1
  store i64 %.fca.0.extract6, ptr %10, align 8
  store i32 %.fca.1.extract7, ptr %.sroa.29.0..sroa_idx, align 8
  %178 = call noundef i64 @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #8
  %179 = load i32, ptr %9, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %180
  %182 = load i32, ptr %181, align 4, !tbaa !5
  %183 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %180
  %184 = load i32, ptr %183, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %185
  store i32 %182, ptr %186, align 4, !tbaa !5
  %187 = sext i32 %182 to i64
  %188 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %187
  store i32 %184, ptr %188, align 4, !tbaa !5
  %189 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %180
  %190 = load i64, ptr %189, align 8, !tbaa !9
  %191 = load i32, ptr %5, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %192
  %194 = load i64, ptr %193, align 8, !tbaa !9
  %195 = add nsw i64 %194, %190
  store i64 %195, ptr %193, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #8
  br label %196

196:                                              ; preds = %172, %163
  %.pre-phi125 = phi i64 [ %192, %172 ], [ %168, %163 ]
  %197 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %.pre-phi125
  %198 = load i32, ptr %197, align 4, !tbaa !5
  %199 = load i32, ptr @n, align 4, !tbaa !5
  %200 = icmp slt i32 %198, %199
  br i1 %200, label %201, label %._crit_edge127

._crit_edge127:                                   ; preds = %196
  %.phi.trans.insert128 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %.pre-phi125
  %.pre129 = load i64, ptr %.phi.trans.insert128, align 8, !tbaa !9
  br label %225

201:                                              ; preds = %196
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #8
  store i32 %198, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %13) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #8
  %202 = sext i32 %198 to i64
  %203 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %202
  %204 = load i64, ptr %203, align 8, !tbaa !9
  %205 = call noundef i64 @_ZSt3absx(i64 noundef %204)
  store i64 %205, ptr %14, align 8, !tbaa !9
  %206 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %.fca.0.extract2 = extractvalue { i64, i32 } %206, 0
  %.fca.1.extract3 = extractvalue { i64, i32 } %206, 1
  store i64 %.fca.0.extract2, ptr %13, align 8
  store i32 %.fca.1.extract3, ptr %.sroa.25.0..sroa_idx, align 8
  %207 = call noundef i64 @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE5eraseERKS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %13)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %13) #8
  %208 = load i32, ptr %12, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %209
  %211 = load i32, ptr %210, align 4, !tbaa !5
  %212 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %209
  %213 = load i32, ptr %212, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [100001 x i32], ptr @L, i64 0, i64 %214
  store i32 %211, ptr %215, align 4, !tbaa !5
  %216 = sext i32 %211 to i64
  %217 = getelementptr inbounds [100001 x i32], ptr @R, i64 0, i64 %216
  store i32 %213, ptr %217, align 4, !tbaa !5
  %218 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %209
  %219 = load i64, ptr %218, align 8, !tbaa !9
  %220 = load i32, ptr %5, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %221
  %223 = load i64, ptr %222, align 8, !tbaa !9
  %224 = add nsw i64 %223, %219
  store i64 %224, ptr %222, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #8
  br label %225

225:                                              ; preds = %._crit_edge127, %201
  %226 = phi i64 [ %224, %201 ], [ %.pre129, %._crit_edge127 ]
  %227 = load i32, ptr @m, align 4, !tbaa !5
  %228 = add nsw i32 %227, 1
  store i32 %228, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %15) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %16) #8
  %229 = call noundef i64 @_ZSt3absx(i64 noundef %226)
  store i64 %229, ptr %16, align 8, !tbaa !9
  %230 = call { i64, i32 } @_ZSt9make_pairIxRiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %.fca.0.extract = extractvalue { i64, i32 } %230, 0
  %.fca.1.extract = extractvalue { i64, i32 } %230, 1
  store i64 %.fca.0.extract, ptr %15, align 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %231 = call { ptr, i8 } @_ZNSt3setISt4pairIxiESt4lessIS1_ESaIS1_EE6insertEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @sp, ptr noundef nonnull align 8 dereferenceable(12) %15)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %15) #8
  br label %232

232:                                              ; preds = %225, %._crit_edge130
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  %233 = load i32, ptr @m, align 4, !tbaa !5
  %234 = icmp slt i32 %233, 0
  br i1 %234, label %137, label %._crit_edge107.loopexit

._crit_edge107.loopexit:                          ; preds = %232
  %.pre133 = load i64, ptr @ans, align 8, !tbaa !9
  br label %._crit_edge107

._crit_edge107:                                   ; preds = %._crit_edge107.loopexit, %.preheader
  %235 = phi i64 [ %.pre133, %._crit_edge107.loopexit ], [ %115, %.preheader ]
  %236 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %235)
  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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZSt3absx(i64 noundef) local_unnamed_addr #5

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #7

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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { 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 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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!16, !6, i64 8}
!16 = !{!"_ZTSSt4pairIxiE", !10, i64 0, !6, i64 8}
!17 = distinct !{!17, !12}


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