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

; 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"

%struct.Event = type { i32, i32, i32, i64 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@etot = external dso_local global i32, align 4
@ord = external dso_local global [800009 x i32], align 16
@ans = external dso_local global [100001 x i64], align 16
@eve = external dso_local global [800009 x %struct.Event], align 16
@a = external dso_local global [100001 x i32], align 16
@pL = external dso_local global [100001 x i32], align 16
@pR = external dso_local global [100001 x i32], align 16
@stk = external dso_local global [100001 x i32], align 16
@.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 nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8addEventiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solveii(i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %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 i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca %struct.Event, align 8
  %16 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %72, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp sle i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %75

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i32, ptr @a, i64 %25
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %26)
  br label %28

28:                                               ; preds = %48, %23
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %45

31:                                               ; preds = %28
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sub nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp sgt i32 %39, %43
  br label %45

45:                                               ; preds = %31, %28
  %46 = phi i1 [ false, %28 ], [ %44, %31 ]
  br i1 %46, label %47, label %51

47:                                               ; preds = %45
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !9

51:                                               ; preds = %45
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %61

54:                                               ; preds = %51
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  br label %62

61:                                               ; preds = %51
  br label %62

62:                                               ; preds = %61, %54
  %63 = phi i32 [ %60, %54 ], [ 1, %61 ]
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %65
  store i32 %63, ptr %66, align 4, !tbaa !5
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %3, align 4, !tbaa !5
  %70 = sext i32 %68 to i64
  %71 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %70
  store i32 %67, ptr %71, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %62
  %73 = load i32, ptr %2, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !11

75:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %76 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %76, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %169, %75
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = icmp sge i32 %78, 1
  br i1 %79, label %81, label %80

80:                                               ; preds = %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %172

81:                                               ; preds = %77
  br label %82

82:                                               ; preds = %102, %81
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %99

85:                                               ; preds = %82
  %86 = load i32, ptr %5, align 4, !tbaa !5
  %87 = sub nsw i32 %86, 1
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = load i32, ptr %4, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = icmp sge i32 %93, %97
  br label %99

99:                                               ; preds = %85, %82
  %100 = phi i1 [ false, %82 ], [ %98, %85 ]
  br i1 %100, label %101, label %105

101:                                              ; preds = %99
  br label %102

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

105:                                              ; preds = %99
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = icmp ne i32 %106, 0
  br i1 %107, label %108, label %115

108:                                              ; preds = %105
  %109 = load i32, ptr %5, align 4, !tbaa !5
  %110 = sub nsw i32 %109, 1
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = sub nsw i32 %113, 1
  br label %117

115:                                              ; preds = %105
  %116 = load i32, ptr @n, align 4, !tbaa !5
  br label %117

117:                                              ; preds = %115, %108
  %118 = phi i32 [ %114, %108 ], [ %116, %115 ]
  %119 = load i32, ptr %4, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %120
  store i32 %118, ptr %121, align 4, !tbaa !5
  %122 = load i32, ptr %4, align 4, !tbaa !5
  %123 = load i32, ptr %5, align 4, !tbaa !5
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %5, align 4, !tbaa !5
  %125 = sext i32 %123 to i64
  %126 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %125
  store i32 %122, ptr %126, align 4, !tbaa !5
  %127 = load i32, ptr %4, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = load i32, ptr %4, align 4, !tbaa !5
  %132 = load i32, ptr %4, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  call void @_Z8addEventiiii(i32 noundef 0, i32 noundef %130, i32 noundef %131, i32 noundef %135)
  %136 = load i32, ptr %4, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = load i32, ptr %4, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  %145 = load i32, ptr %4, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !5
  %149 = sub nsw i32 0, %148
  call void @_Z8addEventiiii(i32 noundef 0, i32 noundef %139, i32 noundef %144, i32 noundef %149)
  %150 = load i32, ptr %4, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  %152 = load i32, ptr %4, align 4, !tbaa !5
  %153 = load i32, ptr %4, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !5
  %157 = sub nsw i32 0, %156
  call void @_Z8addEventiiii(i32 noundef 0, i32 noundef %151, i32 noundef %152, i32 noundef %157)
  %158 = load i32, ptr %4, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  %160 = load i32, ptr %4, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = add nsw i32 %163, 1
  %165 = load i32, ptr %4, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !5
  call void @_Z8addEventiiii(i32 noundef 0, i32 noundef %159, i32 noundef %164, i32 noundef %168)
  br label %169

169:                                              ; preds = %117
  %170 = load i32, ptr %4, align 4, !tbaa !5
  %171 = add nsw i32 %170, -1
  store i32 %171, ptr %4, align 4, !tbaa !5
  br label %77, !llvm.loop !13

172:                                              ; preds = %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %173

173:                                              ; preds = %196, %172
  %174 = load i32, ptr %6, align 4, !tbaa !5
  %175 = load i32, ptr @m, align 4, !tbaa !5
  %176 = icmp sle i32 %174, %175
  br i1 %176, label %178, label %177

177:                                              ; preds = %173
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %199

178:                                              ; preds = %173
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %179 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %7, ptr noundef %8)
  %180 = load i32, ptr %6, align 4, !tbaa !5
  %181 = load i32, ptr %8, align 4, !tbaa !5
  %182 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z8addEventiiii(i32 noundef %180, i32 noundef %181, i32 noundef %182, i32 noundef 1)
  %183 = load i32, ptr %6, align 4, !tbaa !5
  %184 = load i32, ptr %7, align 4, !tbaa !5
  %185 = sub nsw i32 %184, 1
  %186 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z8addEventiiii(i32 noundef %183, i32 noundef %185, i32 noundef %186, i32 noundef -1)
  %187 = load i32, ptr %6, align 4, !tbaa !5
  %188 = load i32, ptr %8, align 4, !tbaa !5
  %189 = load i32, ptr %7, align 4, !tbaa !5
  %190 = sub nsw i32 %189, 1
  call void @_Z8addEventiiii(i32 noundef %187, i32 noundef %188, i32 noundef %190, i32 noundef -1)
  %191 = load i32, ptr %6, align 4, !tbaa !5
  %192 = load i32, ptr %7, align 4, !tbaa !5
  %193 = sub nsw i32 %192, 1
  %194 = load i32, ptr %7, align 4, !tbaa !5
  %195 = sub nsw i32 %194, 1
  call void @_Z8addEventiiii(i32 noundef %191, i32 noundef %193, i32 noundef %195, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %196

196:                                              ; preds = %178
  %197 = load i32, ptr %6, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %6, align 4, !tbaa !5
  br label %173, !llvm.loop !14

199:                                              ; preds = %177
  %200 = load i32, ptr @etot, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds i32, ptr @ord, i64 %201
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @ord, ptr noundef %202, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %203

203:                                              ; preds = %305, %199
  %204 = load i32, ptr %10, align 4, !tbaa !5
  %205 = load i32, ptr @etot, align 4, !tbaa !5
  %206 = icmp slt i32 %204, %205
  br i1 %206, label %208, label %207

207:                                              ; preds = %203
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %306

208:                                              ; preds = %203
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %209 = load i32, ptr %10, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %210
  %212 = load i32, ptr %211, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %213
  %215 = getelementptr inbounds %struct.Event, ptr %214, i32 0, i32 0
  %216 = load i32, ptr %215, align 8, !tbaa !15
  store i32 %216, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %217 = load i32, ptr %10, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %218
  %220 = load i32, ptr %219, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %221
  %223 = getelementptr inbounds %struct.Event, ptr %222, i32 0, i32 1
  %224 = load i32, ptr %223, align 4, !tbaa !18
  store i32 %224, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %225 = load i32, ptr %10, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %226
  %228 = load i32, ptr %227, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %229
  %231 = getelementptr inbounds %struct.Event, ptr %230, i32 0, i32 2
  %232 = load i32, ptr %231, align 8, !tbaa !19
  store i32 %232, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store i64 0, ptr %14, align 8, !tbaa !20
  br label %233

233:                                              ; preds = %283, %208
  %234 = load i32, ptr %10, align 4, !tbaa !5
  %235 = load i32, ptr @etot, align 4, !tbaa !5
  %236 = icmp slt i32 %234, %235
  br i1 %236, label %237, label %270

237:                                              ; preds = %233
  %238 = load i32, ptr %10, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %242
  %244 = getelementptr inbounds %struct.Event, ptr %243, i32 0, i32 0
  %245 = load i32, ptr %244, align 8, !tbaa !15
  %246 = load i32, ptr %11, align 4, !tbaa !5
  %247 = icmp eq i32 %245, %246
  br i1 %247, label %248, label %270

248:                                              ; preds = %237
  %249 = load i32, ptr %10, align 4, !tbaa !5
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %250
  %252 = load i32, ptr %251, align 4, !tbaa !5
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %253
  %255 = getelementptr inbounds %struct.Event, ptr %254, i32 0, i32 1
  %256 = load i32, ptr %255, align 4, !tbaa !18
  %257 = load i32, ptr %12, align 4, !tbaa !5
  %258 = icmp eq i32 %256, %257
  br i1 %258, label %259, label %270

259:                                              ; preds = %248
  %260 = load i32, ptr %10, align 4, !tbaa !5
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %261
  %263 = load i32, ptr %262, align 4, !tbaa !5
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %264
  %266 = getelementptr inbounds %struct.Event, ptr %265, i32 0, i32 2
  %267 = load i32, ptr %266, align 8, !tbaa !19
  %268 = load i32, ptr %13, align 4, !tbaa !5
  %269 = icmp eq i32 %267, %268
  br label %270

270:                                              ; preds = %259, %248, %237, %233
  %271 = phi i1 [ false, %248 ], [ false, %237 ], [ false, %233 ], [ %269, %259 ]
  br i1 %271, label %272, label %286

272:                                              ; preds = %270
  %273 = load i32, ptr %10, align 4, !tbaa !5
  %274 = sext i32 %273 to i64
  %275 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %274
  %276 = load i32, ptr %275, align 4, !tbaa !5
  %277 = sext i32 %276 to i64
  %278 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %277
  %279 = getelementptr inbounds %struct.Event, ptr %278, i32 0, i32 3
  %280 = load i64, ptr %279, align 8, !tbaa !21
  %281 = load i64, ptr %14, align 8, !tbaa !20
  %282 = add nsw i64 %281, %280
  store i64 %282, ptr %14, align 8, !tbaa !20
  br label %283

283:                                              ; preds = %272
  %284 = load i32, ptr %10, align 4, !tbaa !5
  %285 = add nsw i32 %284, 1
  store i32 %285, ptr %10, align 4, !tbaa !5
  br label %233, !llvm.loop !22

286:                                              ; preds = %270
  %287 = load i64, ptr %14, align 8, !tbaa !20
  %288 = icmp ne i64 %287, 0
  br i1 %288, label %289, label %305

289:                                              ; preds = %286
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #7
  %290 = getelementptr inbounds %struct.Event, ptr %15, i32 0, i32 0
  %291 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %291, ptr %290, align 8, !tbaa !15
  %292 = getelementptr inbounds %struct.Event, ptr %15, i32 0, i32 1
  %293 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %293, ptr %292, align 4, !tbaa !18
  %294 = getelementptr inbounds %struct.Event, ptr %15, i32 0, i32 2
  %295 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %295, ptr %294, align 8, !tbaa !19
  %296 = getelementptr inbounds %struct.Event, ptr %15, i32 0, i32 3
  %297 = load i64, ptr %14, align 8, !tbaa !20
  store i64 %297, ptr %296, align 8, !tbaa !21
  %298 = load i32, ptr %9, align 4, !tbaa !5
  %299 = add nsw i32 %298, 1
  store i32 %299, ptr %9, align 4, !tbaa !5
  %300 = sext i32 %298 to i64
  %301 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %300
  %302 = load i32, ptr %301, align 4, !tbaa !5
  %303 = sext i32 %302 to i64
  %304 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %303
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %304, ptr align 8 %15, i64 24, i1 false), !tbaa.struct !23
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #7
  br label %305

305:                                              ; preds = %289, %286
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %203, !llvm.loop !24

306:                                              ; preds = %207
  %307 = load i32, ptr %9, align 4, !tbaa !5
  %308 = icmp ne i32 %307, 0
  br i1 %308, label %309, label %312

309:                                              ; preds = %306
  %310 = load i32, ptr %9, align 4, !tbaa !5
  %311 = sub nsw i32 %310, 1
  call void @_Z5solveii(i32 noundef 0, i32 noundef %311)
  br label %312

312:                                              ; preds = %309, %306
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 1, ptr %16, align 4, !tbaa !5
  br label %313

313:                                              ; preds = %324, %312
  %314 = load i32, ptr %16, align 4, !tbaa !5
  %315 = load i32, ptr @m, align 4, !tbaa !5
  %316 = icmp sle i32 %314, %315
  br i1 %316, label %318, label %317

317:                                              ; preds = %313
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %327

318:                                              ; preds = %313
  %319 = load i32, ptr %16, align 4, !tbaa !5
  %320 = sext i32 %319 to i64
  %321 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %320
  %322 = load i64, ptr %321, align 8, !tbaa !20
  %323 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %322)
  br label %324

324:                                              ; preds = %318
  %325 = load i32, ptr %16, align 4, !tbaa !5
  %326 = add nsw i32 %325, 1
  store i32 %326, ptr %16, align 4, !tbaa !5
  br label %313, !llvm.loop !25

327:                                              ; preds = %317
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) #6

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

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

%struct.Event = type { i32, i32, i32, i64 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@etot = external dso_local local_unnamed_addr global i32, align 4
@ord = external dso_local global [800009 x i32], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i64], align 16
@eve = external dso_local local_unnamed_addr global [800009 x %struct.Event], align 16
@a = external dso_local global [100001 x i32], align 16
@pL = external dso_local local_unnamed_addr global [100001 x i32], align 16
@pR = external dso_local local_unnamed_addr global [100001 x i32], align 16
@stk = external dso_local local_unnamed_addr global [100001 x i32], align 16
@.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 nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8addEventiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solveii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not100 = icmp slt i32 %4, 1
  br i1 %.not100, label %.preheader, label %.lr.ph

.preheader93:                                     ; preds = %.critedge90
  %5 = icmp sgt i32 %28, 0
  br i1 %5, label %.preheader92.preheader, label %.preheader

.preheader92.preheader:                           ; preds = %.preheader93
  %6 = zext nneg i32 %28 to i64
  br label %.preheader92

.lr.ph:                                           ; preds = %0, %.critedge90
  %indvars.iv128 = phi i64 [ %indvars.iv.next129, %.critedge90 ], [ 1, %0 ]
  %.072101 = phi i32 [ %24, %.critedge90 ], [ 0, %0 ]
  %7 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv128
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %7)
  %9 = sext i32 %.072101 to i64
  br label %10

10:                                               ; preds = %12, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %12 ], [ %9, %.lr.ph ]
  %11 = icmp eq i64 %indvars.iv, 0
  br i1 %11, label %.critedge90, label %12

12:                                               ; preds = %10
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %13 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %indvars.iv.next
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = icmp sgt i32 %17, %18
  br i1 %19, label %10, label %.critedge, !llvm.loop !9

.critedge:                                        ; preds = %12
  %20 = trunc nsw i64 %indvars.iv to i32
  %21 = add nsw i32 %14, 1
  br label %.critedge90

.critedge90:                                      ; preds = %10, %.critedge
  %.1124 = phi i32 [ %20, %.critedge ], [ 0, %10 ]
  %22 = phi i32 [ %21, %.critedge ], [ 1, %10 ]
  %23 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %indvars.iv128
  store i32 %22, ptr %23, align 4, !tbaa !5
  %24 = add nsw i32 %.1124, 1
  %25 = sext i32 %.1124 to i64
  %26 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %25
  %27 = trunc nuw nsw i64 %indvars.iv128 to i32
  store i32 %27, ptr %26, align 4, !tbaa !5
  %indvars.iv.next129 = add nuw nsw i64 %indvars.iv128, 1
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %.not.not = icmp slt i64 %indvars.iv128, %29
  br i1 %.not.not, label %.lr.ph, label %.preheader93, !llvm.loop !11

.preheader92:                                     ; preds = %.preheader92.preheader, %45
  %indvars.iv134 = phi i64 [ %6, %.preheader92.preheader ], [ %indvars.iv.next135, %45 ]
  %.074103 = phi i32 [ 0, %.preheader92.preheader ], [ %49, %45 ]
  %indvars136 = trunc i64 %indvars.iv134 to i32
  %30 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv134
  %31 = sext i32 %.074103 to i64
  br label %33

.preheader:                                       ; preds = %45, %0, %.preheader93
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %.not83105 = icmp slt i32 %32, 1
  br i1 %.not83105, label %._crit_edge, label %.lr.ph107

33:                                               ; preds = %.preheader92, %35
  %indvars.iv131 = phi i64 [ %31, %.preheader92 ], [ %indvars.iv.next132, %35 ]
  %34 = icmp eq i64 %indvars.iv131, 0
  br i1 %34, label %.critedge91, label %35

35:                                               ; preds = %33
  %indvars.iv.next132 = add nsw i64 %indvars.iv131, -1
  %36 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %indvars.iv.next132
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = load i32, ptr %30, align 4, !tbaa !5
  %.not88 = icmp slt i32 %40, %41
  br i1 %.not88, label %.critedge2, label %33, !llvm.loop !12

.critedge2:                                       ; preds = %35
  %42 = trunc nsw i64 %indvars.iv131 to i32
  %43 = add nsw i32 %37, -1
  br label %45

.critedge91:                                      ; preds = %33
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %.pre = load i32, ptr %30, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %.critedge91, %.critedge2
  %46 = phi i32 [ %41, %.critedge2 ], [ %.pre, %.critedge91 ]
  %.175122 = phi i32 [ %42, %.critedge2 ], [ 0, %.critedge91 ]
  %47 = phi i32 [ %43, %.critedge2 ], [ %44, %.critedge91 ]
  %48 = getelementptr inbounds [100001 x i32], ptr @pR, i64 0, i64 %indvars.iv134
  store i32 %47, ptr %48, align 4, !tbaa !5
  %49 = add nsw i32 %.175122, 1
  %50 = sext i32 %.175122 to i64
  %51 = getelementptr inbounds [100001 x i32], ptr @stk, i64 0, i64 %50
  store i32 %indvars136, ptr %51, align 4, !tbaa !5
  %52 = getelementptr inbounds [100001 x i32], ptr @pL, i64 0, i64 %indvars.iv134
  %53 = load i32, ptr %52, align 4, !tbaa !5
  tail call void @_Z8addEventiiii(i32 noundef 0, i32 noundef %53, i32 noundef %indvars136, i32 noundef %46)
  %54 = load i32, ptr %52, align 4, !tbaa !5
  %55 = load i32, ptr %48, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  %57 = load i32, ptr %30, align 4, !tbaa !5
  %58 = sub nsw i32 0, %57
  tail call void @_Z8addEventiiii(i32 noundef 0, i32 noundef %54, i32 noundef %56, i32 noundef %58)
  %59 = add nuw nsw i32 %indvars136, 1
  %60 = load i32, ptr %30, align 4, !tbaa !5
  %61 = sub nsw i32 0, %60
  tail call void @_Z8addEventiiii(i32 noundef 0, i32 noundef %59, i32 noundef %indvars136, i32 noundef %61)
  %62 = load i32, ptr %48, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  %64 = load i32, ptr %30, align 4, !tbaa !5
  %65 = trunc i64 %indvars.iv134 to i32
  %66 = add i32 %65, 1
  tail call void @_Z8addEventiiii(i32 noundef 0, i32 noundef %66, i32 noundef %63, i32 noundef %64)
  %indvars.iv.next135 = add nsw i64 %indvars.iv134, -1
  %67 = icmp sgt i64 %indvars.iv134, 1
  br i1 %67, label %.preheader92, label %.preheader, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph107, %.preheader
  %68 = load i32, ptr @etot, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr @ord, i64 %69
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @ord, ptr noundef nonnull %70, ptr noundef nonnull @_Z3cmpRKiS0_)
  %71 = load i32, ptr @etot, align 4, !tbaa !5
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %.lr.ph113.preheader, label %._crit_edge114.thread

.lr.ph113.preheader:                              ; preds = %._crit_edge
  %73 = zext nneg i32 %71 to i64
  br label %.lr.ph113

.lr.ph107:                                        ; preds = %.preheader, %.lr.ph107
  %.076106 = phi i32 [ %84, %.lr.ph107 ], [ 1, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %74 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %75 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z8addEventiiii(i32 noundef %.076106, i32 noundef %75, i32 noundef %75, i32 noundef 1)
  %76 = load i32, ptr %1, align 4, !tbaa !5
  %77 = add nsw i32 %76, -1
  %78 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z8addEventiiii(i32 noundef %.076106, i32 noundef %77, i32 noundef %78, i32 noundef -1)
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = load i32, ptr %1, align 4, !tbaa !5
  %81 = add nsw i32 %80, -1
  call void @_Z8addEventiiii(i32 noundef %.076106, i32 noundef %79, i32 noundef %81, i32 noundef -1)
  %82 = load i32, ptr %1, align 4, !tbaa !5
  %83 = add nsw i32 %82, -1
  call void @_Z8addEventiiii(i32 noundef %.076106, i32 noundef %83, i32 noundef %83, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %84 = add nuw nsw i32 %.076106, 1
  %85 = load i32, ptr @m, align 4, !tbaa !5
  %.not83.not = icmp slt i32 %.076106, %85
  br i1 %.not83.not, label %.lr.ph107, label %._crit_edge, !llvm.loop !14

._crit_edge114:                                   ; preds = %127
  %.not84 = icmp eq i32 %.179, 0
  br i1 %.not84, label %._crit_edge114.thread, label %129

.lr.ph113:                                        ; preds = %.lr.ph113.preheader, %127
  %.078111 = phi i32 [ %.179, %127 ], [ 0, %.lr.ph113.preheader ]
  %.080110 = phi i32 [ %.181.lcssa, %127 ], [ 0, %.lr.ph113.preheader ]
  %86 = sext i32 %.080110 to i64
  %87 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %89
  %91 = load i32, ptr %90, align 8, !tbaa !15
  %92 = getelementptr inbounds i8, ptr %90, i64 4
  %93 = load i32, ptr %92, align 4, !tbaa !18
  %94 = getelementptr inbounds i8, ptr %90, i64 8
  %95 = load i32, ptr %94, align 8, !tbaa !19
  %96 = add nsw i32 %.080110, 1
  %smax = call i32 @llvm.smax.i32(i32 %71, i32 %96)
  br label %97

97:                                               ; preds = %.lr.ph113, %112
  %indvars.iv137 = phi i64 [ %86, %.lr.ph113 ], [ %indvars.iv.next138, %112 ]
  %.077109 = phi i64 [ 0, %.lr.ph113 ], [ %115, %112 ]
  %98 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %indvars.iv137
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %100
  %102 = load i32, ptr %101, align 8, !tbaa !15
  %103 = icmp eq i32 %102, %91
  br i1 %103, label %104, label %.critedge4.split.loop.exit151

104:                                              ; preds = %97
  %105 = getelementptr inbounds i8, ptr %101, i64 4
  %106 = load i32, ptr %105, align 4, !tbaa !18
  %107 = icmp eq i32 %106, %93
  br i1 %107, label %108, label %.critedge4.split.loop.exit

108:                                              ; preds = %104
  %109 = getelementptr inbounds i8, ptr %101, i64 8
  %110 = load i32, ptr %109, align 8, !tbaa !19
  %111 = icmp eq i32 %110, %95
  br i1 %111, label %112, label %.critedge4.split.loop.exit157

112:                                              ; preds = %108
  %113 = getelementptr inbounds i8, ptr %101, i64 16
  %114 = load i64, ptr %113, align 8, !tbaa !20
  %115 = add nsw i64 %114, %.077109
  %indvars.iv.next138 = add nsw i64 %indvars.iv137, 1
  %116 = icmp slt i64 %indvars.iv.next138, %73
  br i1 %116, label %97, label %.critedge4, !llvm.loop !21

.critedge4.split.loop.exit:                       ; preds = %104
  %117 = trunc nsw i64 %indvars.iv137 to i32
  br label %.critedge4

.critedge4.split.loop.exit151:                    ; preds = %97
  %118 = trunc nsw i64 %indvars.iv137 to i32
  br label %.critedge4

.critedge4.split.loop.exit157:                    ; preds = %108
  %119 = trunc nsw i64 %indvars.iv137 to i32
  br label %.critedge4

.critedge4:                                       ; preds = %112, %.critedge4.split.loop.exit157, %.critedge4.split.loop.exit151, %.critedge4.split.loop.exit
  %.181.lcssa = phi i32 [ %117, %.critedge4.split.loop.exit ], [ %118, %.critedge4.split.loop.exit151 ], [ %119, %.critedge4.split.loop.exit157 ], [ %smax, %112 ]
  %.077.lcssa = phi i64 [ %.077109, %.critedge4.split.loop.exit ], [ %.077109, %.critedge4.split.loop.exit151 ], [ %.077109, %.critedge4.split.loop.exit157 ], [ %115, %112 ]
  %.not86 = icmp eq i64 %.077.lcssa, 0
  br i1 %.not86, label %127, label %120

120:                                              ; preds = %.critedge4
  %121 = add nsw i32 %.078111, 1
  %122 = sext i32 %.078111 to i64
  %123 = getelementptr inbounds [800009 x i32], ptr @ord, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [800009 x %struct.Event], ptr @eve, i64 0, i64 %125
  store i32 %91, ptr %126, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %126, i64 4
  store i32 %93, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %126, i64 8
  store i32 %95, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !5
  %.sroa.67.0..sroa_idx = getelementptr inbounds i8, ptr %126, i64 16
  store i64 %.077.lcssa, ptr %.sroa.67.0..sroa_idx, align 8, !tbaa !22
  br label %127

127:                                              ; preds = %120, %.critedge4
  %.179 = phi i32 [ %121, %120 ], [ %.078111, %.critedge4 ]
  %128 = icmp slt i32 %.181.lcssa, %71
  br i1 %128, label %.lr.ph113, label %._crit_edge114, !llvm.loop !23

129:                                              ; preds = %._crit_edge114
  %130 = add nsw i32 %.179, -1
  call void @_Z5solveii(i32 noundef 0, i32 noundef %130)
  br label %._crit_edge114.thread

._crit_edge114.thread:                            ; preds = %._crit_edge, %129, %._crit_edge114
  %131 = load i32, ptr @m, align 4, !tbaa !5
  %.not85116 = icmp slt i32 %131, 1
  br i1 %.not85116, label %._crit_edge120, label %.lr.ph119

._crit_edge120:                                   ; preds = %.lr.ph119, %._crit_edge114.thread
  ret i32 0

.lr.ph119:                                        ; preds = %._crit_edge114.thread, %.lr.ph119
  %indvars.iv140 = phi i64 [ %indvars.iv.next141, %.lr.ph119 ], [ 1, %._crit_edge114.thread ]
  %132 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %indvars.iv140
  %133 = load i64, ptr %132, align 8, !tbaa !22
  %134 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %133)
  %indvars.iv.next141 = add nuw nsw i64 %indvars.iv140, 1
  %135 = load i32, ptr @m, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %.not85.not = icmp slt i64 %indvars.iv140, %136
  br i1 %.not85.not, label %.lr.ph119, label %._crit_edge120, !llvm.loop !24
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS5Event", !6, i64 0, !6, i64 4, !6, i64 8, !17, i64 16}
!17 = !{!"long long", !7, i64 0}
!18 = !{!16, !6, i64 4}
!19 = !{!16, !6, i64 8}
!20 = !{!16, !17, i64 16}
!21 = distinct !{!21, !10}
!22 = !{!17, !17, i64 0}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}


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