; LLVM IR from tangjz/acm-icpc :: codeforces/gym/101471L.ll (Z5checkv)

; 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.std::pair" = type { i32, i32 }
%struct.Event = type { i32, i32, i32, i32 }

@n = external dso_local global i32, align 4
@ord = external dso_local global [100001 x i32], align 16
@qtot = external dso_local global i32, align 4
@etot = external dso_local global i32, align 4
@que = external dso_local global [200003 x i32], align 16
@cnt = external dso_local global [200003 x i32], align 16
@bit = external dso_local global [200003 x i32], align 16
@a = external dso_local global [100001 x %"struct.std::pair"], align 16
@b = external dso_local global [100001 x %"struct.std::pair"], align 16
@e = external dso_local global [200003 x %struct.Event], align 16

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7bit_sumi(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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5checkv() #2 {
  %1 = alloca i1, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %struct.Event, align 4
  %7 = alloca %struct.Event, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr @etot, align 4, !tbaa !5
  store i32 0, ptr @qtot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %34, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp sle i32 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %37

15:                                               ; preds = %10
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %17
  %19 = getelementptr inbounds %"struct.std::pair", ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = load i32, ptr @qtot, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr @qtot, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [200003 x i32], ptr @que, i64 0, i64 %23
  store i32 %20, ptr %24, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %26
  %28 = getelementptr inbounds %"struct.std::pair", ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = load i32, ptr @qtot, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @qtot, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [200003 x i32], ptr @que, i64 0, i64 %32
  store i32 %29, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %15
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !11

37:                                               ; preds = %14
  %38 = load i32, ptr @qtot, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr @que, i64 %39
  %41 = getelementptr inbounds i32, ptr %40, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %41)
  %42 = load i32, ptr @qtot, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr @que, i64 %43
  %45 = getelementptr inbounds i32, ptr %44, i64 1
  %46 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %45)
  %47 = ptrtoint ptr %46 to i64
  %48 = sub i64 %47, ptrtoint (ptr @que to i64)
  %49 = sdiv exact i64 %48, 4
  %50 = sub nsw i64 %49, 1
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr @qtot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %120, %37
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = load i32, ptr @n, align 4, !tbaa !5
  %55 = icmp sle i32 %53, %54
  br i1 %55, label %57, label %56

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

57:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %58 = load i32, ptr @qtot, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr @que, i64 %59
  %61 = getelementptr inbounds i32, ptr %60, i64 1
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %63
  %65 = getelementptr inbounds %"struct.std::pair", ptr %64, i32 0, i32 1
  %66 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %61, ptr noundef nonnull align 4 dereferenceable(4) %65)
  %67 = ptrtoint ptr %66 to i64
  %68 = sub i64 %67, ptrtoint (ptr @que to i64)
  %69 = sdiv exact i64 %68, 4
  %70 = trunc i64 %69 to i32
  store i32 %70, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %71 = load i32, ptr @qtot, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr @que, i64 %72
  %74 = getelementptr inbounds i32, ptr %73, i64 1
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %79
  %81 = getelementptr inbounds %"struct.std::pair", ptr %80, i32 0, i32 1
  %82 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %74, ptr noundef nonnull align 4 dereferenceable(4) %81)
  %83 = ptrtoint ptr %82 to i64
  %84 = sub i64 %83, ptrtoint (ptr @que to i64)
  %85 = sdiv exact i64 %84, 4
  %86 = trunc i64 %85 to i32
  store i32 %86, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #6
  %87 = getelementptr inbounds %struct.Event, ptr %6, i32 0, i32 0
  store i32 1, ptr %87, align 4, !tbaa !13
  %88 = getelementptr inbounds %struct.Event, ptr %6, i32 0, i32 1
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %90
  %92 = getelementptr inbounds %"struct.std::pair", ptr %91, i32 0, i32 0
  %93 = load i32, ptr %92, align 8, !tbaa !15
  store i32 %93, ptr %88, align 4, !tbaa !16
  %94 = getelementptr inbounds %struct.Event, ptr %6, i32 0, i32 2
  %95 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %95, ptr %94, align 4, !tbaa !17
  %96 = getelementptr inbounds %struct.Event, ptr %6, i32 0, i32 3
  %97 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %97, ptr %96, align 4, !tbaa !18
  %98 = load i32, ptr @etot, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr @etot, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %100
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %101, ptr align 4 %6, i64 16, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  %102 = getelementptr inbounds %struct.Event, ptr %7, i32 0, i32 0
  store i32 -1, ptr %102, align 4, !tbaa !13
  %103 = getelementptr inbounds %struct.Event, ptr %7, i32 0, i32 1
  %104 = load i32, ptr %3, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %108
  %110 = getelementptr inbounds %"struct.std::pair", ptr %109, i32 0, i32 0
  %111 = load i32, ptr %110, align 8, !tbaa !15
  store i32 %111, ptr %103, align 4, !tbaa !16
  %112 = getelementptr inbounds %struct.Event, ptr %7, i32 0, i32 2
  %113 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %113, ptr %112, align 4, !tbaa !17
  %114 = getelementptr inbounds %struct.Event, ptr %7, i32 0, i32 3
  %115 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %115, ptr %114, align 4, !tbaa !18
  %116 = load i32, ptr @etot, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr @etot, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %118
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %119, ptr align 4 %7, i64 16, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %120

120:                                              ; preds = %57
  %121 = load i32, ptr %3, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %3, align 4, !tbaa !5
  br label %52, !llvm.loop !20

123:                                              ; preds = %56
  %124 = load i32, ptr @etot, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds %struct.Event, ptr @e, i64 %125
  %127 = getelementptr inbounds %struct.Event, ptr %126, i64 1
  call void @_ZSt4sortIP5EventEvT_S2_(ptr noundef getelementptr inbounds (%struct.Event, ptr @e, i64 1), ptr noundef %127)
  %128 = load i32, ptr @etot, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = mul i64 %129, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @bit, i64 1), i8 0, i64 %130, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %239, %123
  %132 = load i32, ptr %8, align 4, !tbaa !5
  %133 = load i32, ptr @etot, align 4, !tbaa !5
  %134 = icmp sle i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  store i32 8, ptr %9, align 4
  br label %242

136:                                              ; preds = %131
  %137 = load i32, ptr %8, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %138
  %140 = getelementptr inbounds %struct.Event, ptr %139, i32 0, i32 0
  %141 = load i32, ptr %140, align 16, !tbaa !13
  %142 = icmp eq i32 %141, -1
  br i1 %142, label %143, label %172

143:                                              ; preds = %136
  %144 = load i32, ptr %8, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %145
  %147 = getelementptr inbounds %struct.Event, ptr %146, i32 0, i32 2
  %148 = load i32, ptr %147, align 8, !tbaa !17
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = add nsw i32 %151, -1
  store i32 %152, ptr %150, align 4, !tbaa !5
  %153 = load i32, ptr %8, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %154
  %156 = getelementptr inbounds %struct.Event, ptr %155, i32 0, i32 2
  %157 = load i32, ptr %156, align 8, !tbaa !17
  call void @_Z7bit_addii(i32 noundef %157, i32 noundef -1)
  %158 = load i32, ptr %8, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %159
  %161 = getelementptr inbounds %struct.Event, ptr %160, i32 0, i32 3
  %162 = load i32, ptr %161, align 4, !tbaa !18
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %163
  %165 = load i32, ptr %164, align 4, !tbaa !5
  %166 = add nsw i32 %165, -1
  store i32 %166, ptr %164, align 4, !tbaa !5
  %167 = load i32, ptr %8, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %168
  %170 = getelementptr inbounds %struct.Event, ptr %169, i32 0, i32 3
  %171 = load i32, ptr %170, align 4, !tbaa !18
  call void @_Z7bit_addii(i32 noundef %171, i32 noundef 1)
  br label %238

172:                                              ; preds = %136
  %173 = load i32, ptr %8, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %174
  %176 = getelementptr inbounds %struct.Event, ptr %175, i32 0, i32 2
  %177 = load i32, ptr %176, align 8, !tbaa !17
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %178
  %180 = load i32, ptr %179, align 4, !tbaa !5
  %181 = icmp ne i32 %180, 0
  br i1 %181, label %236, label %182

182:                                              ; preds = %172
  %183 = load i32, ptr %8, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %184
  %186 = getelementptr inbounds %struct.Event, ptr %185, i32 0, i32 3
  %187 = load i32, ptr %186, align 4, !tbaa !18
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %188
  %190 = load i32, ptr %189, align 4, !tbaa !5
  %191 = icmp ne i32 %190, 0
  br i1 %191, label %236, label %192

192:                                              ; preds = %182
  %193 = load i32, ptr %8, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %194
  %196 = getelementptr inbounds %struct.Event, ptr %195, i32 0, i32 2
  %197 = load i32, ptr %196, align 8, !tbaa !17
  %198 = sub nsw i32 %197, 1
  %199 = call noundef i32 @_Z7bit_sumi(i32 noundef %198)
  %200 = load i32, ptr %8, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %201
  %203 = getelementptr inbounds %struct.Event, ptr %202, i32 0, i32 3
  %204 = load i32, ptr %203, align 4, !tbaa !18
  %205 = call noundef i32 @_Z7bit_sumi(i32 noundef %204)
  %206 = icmp eq i32 %199, %205
  br i1 %206, label %207, label %236

207:                                              ; preds = %192
  %208 = load i32, ptr %8, align 4, !tbaa !5
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %209
  %211 = getelementptr inbounds %struct.Event, ptr %210, i32 0, i32 2
  %212 = load i32, ptr %211, align 8, !tbaa !17
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %213
  %215 = load i32, ptr %214, align 4, !tbaa !5
  %216 = add nsw i32 %215, 1
  store i32 %216, ptr %214, align 4, !tbaa !5
  %217 = load i32, ptr %8, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %218
  %220 = getelementptr inbounds %struct.Event, ptr %219, i32 0, i32 2
  %221 = load i32, ptr %220, align 8, !tbaa !17
  call void @_Z7bit_addii(i32 noundef %221, i32 noundef 1)
  %222 = load i32, ptr %8, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %223
  %225 = getelementptr inbounds %struct.Event, ptr %224, i32 0, i32 3
  %226 = load i32, ptr %225, align 4, !tbaa !18
  %227 = sext i32 %226 to i64
  %228 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %227
  %229 = load i32, ptr %228, align 4, !tbaa !5
  %230 = add nsw i32 %229, 1
  store i32 %230, ptr %228, align 4, !tbaa !5
  %231 = load i32, ptr %8, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %232
  %234 = getelementptr inbounds %struct.Event, ptr %233, i32 0, i32 3
  %235 = load i32, ptr %234, align 4, !tbaa !18
  call void @_Z7bit_addii(i32 noundef %235, i32 noundef -1)
  br label %237

236:                                              ; preds = %192, %182, %172
  store i1 false, ptr %1, align 1
  store i32 1, ptr %9, align 4
  br label %242

237:                                              ; preds = %207
  br label %238

238:                                              ; preds = %237, %143
  br label %239

239:                                              ; preds = %238
  %240 = load i32, ptr %8, align 4, !tbaa !5
  %241 = add nsw i32 %240, 1
  store i32 %241, ptr %8, align 4, !tbaa !5
  br label %131, !llvm.loop !21

242:                                              ; preds = %236, %135
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %243 = load i32, ptr %9, align 4
  switch i32 %243, label %247 [
    i32 8, label %244
    i32 1, label %245
  ]

244:                                              ; preds = %242
  store i1 true, ptr %1, align 1
  br label %245

245:                                              ; preds = %244, %242
  %246 = load i1, ptr %1, align 1
  ret i1 %246

247:                                              ; preds = %242
  unreachable
}

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

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }

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

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

%"struct.std::pair" = type { i32, i32 }
%struct.Event = type { i32, i32, i32, i32 }

@n = external dso_local local_unnamed_addr global i32, align 4
@ord = external dso_local local_unnamed_addr global [100001 x i32], align 16
@qtot = external dso_local local_unnamed_addr global i32, align 4
@etot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [200003 x i32], align 16
@cnt = external dso_local local_unnamed_addr global [200003 x i32], align 16
@bit = external dso_local local_unnamed_addr global [200003 x i32], align 16
@a = external dso_local global [100001 x %"struct.std::pair"], align 16
@b = external dso_local global [100001 x %"struct.std::pair"], align 16
@e = external dso_local global [200003 x %struct.Event], align 16

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5checkv() local_unnamed_addr #1 {
  store i32 0, ptr @etot, align 4, !tbaa !5
  store i32 0, ptr @qtot, align 4, !tbaa !5
  %1 = load i32, ptr @n, align 4, !tbaa !5
  %.not42 = icmp slt i32 %1, 1
  br i1 %.not42, label %16, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %2 = add nuw i32 %1, 1
  %wide.trip.count = zext i32 %2 to i64
  %min.iters.check = icmp ult i32 %1, 5
  br i1 %min.iters.check, label %.lr.ph.preheader92, label %vector.ph

.lr.ph.preheader92:                               ; preds = %vector.body, %.lr.ph.preheader
  %indvars.iv62.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %ind.end, %vector.body ]
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph.preheader ], [ %ind.end82, %vector.body ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %3 = zext nneg i32 %1 to i64
  %n.mod.vf = and i64 %3, 3
  %4 = icmp eq i64 %n.mod.vf, 0
  %5 = select i1 %4, i64 4, i64 %n.mod.vf
  %n.vec = sub nsw i64 %3, %5
  %ind.end = shl nsw i64 %n.vec, 1
  %ind.end82 = add nsw i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 1
  %offset.idx84 = or disjoint i64 %index, 1
  %6 = or disjoint i64 %index, 3
  %7 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %offset.idx84, i32 1
  %8 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %6, i32 1
  %wide.vec = load <4 x i32>, ptr %7, align 4, !tbaa !9
  %wide.vec85 = load <4 x i32>, ptr %8, align 4, !tbaa !9
  %9 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %offset.idx84, i32 1
  %10 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %6, i32 1
  %wide.vec87 = load <4 x i32>, ptr %9, align 4, !tbaa !9
  %wide.vec88 = load <4 x i32>, ptr %10, align 4, !tbaa !9
  %11 = or disjoint i64 %offset.idx, 2
  %12 = or disjoint i64 %offset.idx, 6
  %gep93 = getelementptr [200003 x i32], ptr getelementptr (i8, ptr @que, i64 -4), i64 0, i64 %11
  %gep94 = getelementptr [200003 x i32], ptr getelementptr (i8, ptr @que, i64 -4), i64 0, i64 %12
  %interleaved.vec = shufflevector <4 x i32> %wide.vec, <4 x i32> %wide.vec87, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
  store <4 x i32> %interleaved.vec, ptr %gep93, align 4, !tbaa !5
  %interleaved.vec91 = shufflevector <4 x i32> %wide.vec85, <4 x i32> %wide.vec88, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
  store <4 x i32> %interleaved.vec91, ptr %gep94, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %13 = icmp eq i64 %index.next, %n.vec
  br i1 %13, label %.lr.ph.preheader92, label %vector.body, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph
  %14 = trunc nuw nsw i64 %indvars.iv.next63 to i32
  store i32 %14, ptr @qtot, align 4, !tbaa !5
  %sext = shl i64 %indvars.iv.next63, 32
  %15 = ashr exact i64 %sext, 32
  br label %16

16:                                               ; preds = %._crit_edge, %0
  %17 = phi i64 [ %15, %._crit_edge ], [ 0, %0 ]
  %18 = getelementptr inbounds i32, ptr @que, i64 %17
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %19)
  %20 = load i32, ptr @qtot, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr @que, i64 %21
  %23 = getelementptr inbounds i8, ptr %22, i64 4
  %24 = tail call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %23)
  %25 = ptrtoint ptr %24 to i64
  %26 = sub i64 %25, ptrtoint (ptr @que to i64)
  %27 = lshr exact i64 %26, 2
  %28 = trunc i64 %27 to i32
  %29 = add i32 %28, -1
  store i32 %29, ptr @qtot, align 4, !tbaa !5
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %.not3845 = icmp slt i32 %30, 1
  br i1 %.not3845, label %.._crit_edge49_crit_edge, label %.lr.ph48

.._crit_edge49_crit_edge:                         ; preds = %16
  %.pre = load i32, ptr @etot, align 4, !tbaa !5
  %.pre72 = sext i32 %.pre to i64
  br label %._crit_edge49

.lr.ph:                                           ; preds = %.lr.ph.preheader92, %.lr.ph
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %.lr.ph ], [ %indvars.iv62.ph, %.lr.ph.preheader92 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader92 ]
  %31 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = or disjoint i64 %indvars.iv62, 1
  %34 = getelementptr inbounds [200003 x i32], ptr @que, i64 0, i64 %33
  store i32 %32, ptr %34, align 4, !tbaa !5
  %35 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %indvars.iv, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 2
  %37 = getelementptr inbounds [200003 x i32], ptr @que, i64 0, i64 %indvars.iv.next63
  store i32 %36, ptr %37, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge49:                                    ; preds = %.lr.ph48, %.._crit_edge49_crit_edge
  %.pre-phi = phi i64 [ %.pre72, %.._crit_edge49_crit_edge ], [ %73, %.lr.ph48 ]
  %38 = getelementptr inbounds %struct.Event, ptr @e, i64 %.pre-phi
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  tail call void @_ZSt4sortIP5EventEvT_S2_(ptr noundef nonnull getelementptr inbounds (i8, ptr @e, i64 16), ptr noundef nonnull %39)
  %40 = load i32, ptr @etot, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = shl nsw i64 %41, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @bit, i64 4), i8 0, i64 %42, i1 false)
  %.not3950 = icmp slt i32 %40, 1
  br i1 %.not3950, label %._crit_edge55, label %.lr.ph54

.lr.ph48:                                         ; preds = %16, %.lr.ph48
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %.lr.ph48 ], [ 1, %16 ]
  %43 = load i32, ptr @qtot, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @que, i64 4), i64 %44
  %45 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @a, i64 0, i64 %indvars.iv67
  %46 = getelementptr inbounds i8, ptr %45, i64 4
  %47 = tail call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %gep, ptr noundef nonnull align 4 dereferenceable(4) %46)
  %48 = ptrtoint ptr %47 to i64
  %49 = sub i64 %48, ptrtoint (ptr @que to i64)
  %50 = lshr exact i64 %49, 2
  %51 = trunc i64 %50 to i32
  %52 = load i32, ptr @qtot, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %gep44 = getelementptr i32, ptr getelementptr inbounds (i8, ptr @que, i64 4), i64 %53
  %54 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv67
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %56, i32 1
  %58 = tail call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %gep44, ptr noundef nonnull align 4 dereferenceable(4) %57)
  %59 = ptrtoint ptr %58 to i64
  %60 = sub i64 %59, ptrtoint (ptr @que to i64)
  %61 = lshr exact i64 %60, 2
  %62 = trunc i64 %61 to i32
  %63 = load i32, ptr %45, align 8, !tbaa !16
  %64 = load i32, ptr @etot, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %66
  store i32 1, ptr %67, align 16, !tbaa !5
  %.sroa.417.0..sroa_idx = getelementptr inbounds i8, ptr %67, i64 4
  store i32 %63, ptr %.sroa.417.0..sroa_idx, align 4, !tbaa !5
  %.sroa.518.0..sroa_idx = getelementptr inbounds i8, ptr %67, i64 8
  store i32 %51, ptr %.sroa.518.0..sroa_idx, align 8, !tbaa !5
  %.sroa.619.0..sroa_idx = getelementptr inbounds i8, ptr %67, i64 12
  store i32 %62, ptr %.sroa.619.0..sroa_idx, align 4, !tbaa !5
  %68 = load i32, ptr %54, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @b, i64 0, i64 %69
  %71 = load i32, ptr %70, align 8, !tbaa !16
  %72 = add nsw i32 %64, 2
  store i32 %72, ptr @etot, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %73
  store i32 -1, ptr %74, align 16, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %74, i64 4
  store i32 %71, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %74, i64 8
  store i32 %51, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %74, i64 12
  store i32 %62, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !5
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %75 = load i32, ptr @n, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %.not38.not = icmp slt i64 %indvars.iv67, %76
  br i1 %.not38.not, label %.lr.ph48, label %._crit_edge49, !llvm.loop !17

.lr.ph54:                                         ; preds = %._crit_edge49, %107
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %107 ], [ 1, %._crit_edge49 ]
  %77 = getelementptr inbounds [200003 x %struct.Event], ptr @e, i64 0, i64 %indvars.iv70
  %78 = load i32, ptr %77, align 16, !tbaa !18
  %79 = icmp eq i32 %78, -1
  %80 = getelementptr inbounds i8, ptr %77, i64 8
  %81 = load i32, ptr %80, align 8, !tbaa !20
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  br i1 %79, label %85, label %88

85:                                               ; preds = %.lr.ph54
  %86 = add nsw i32 %84, -1
  store i32 %86, ptr %83, align 4, !tbaa !5
  tail call void @_Z7bit_addii(i32 noundef %81, i32 noundef -1)
  %87 = getelementptr inbounds i8, ptr %77, i64 12
  br label %107

88:                                               ; preds = %.lr.ph54
  %.not40 = icmp eq i32 %84, 0
  br i1 %.not40, label %89, label %._crit_edge55

89:                                               ; preds = %88
  %90 = getelementptr inbounds i8, ptr %77, i64 12
  %91 = load i32, ptr %90, align 4, !tbaa !21
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %.not41 = icmp eq i32 %94, 0
  br i1 %.not41, label %95, label %._crit_edge55

95:                                               ; preds = %89
  %96 = add nsw i32 %81, -1
  %97 = tail call noundef i32 @_Z7bit_sumi(i32 noundef %96)
  %98 = load i32, ptr %90, align 4, !tbaa !21
  %99 = tail call noundef i32 @_Z7bit_sumi(i32 noundef %98)
  %100 = icmp eq i32 %97, %99
  br i1 %100, label %101, label %._crit_edge55

101:                                              ; preds = %95
  %102 = load i32, ptr %80, align 8, !tbaa !20
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %104, align 4, !tbaa !5
  tail call void @_Z7bit_addii(i32 noundef %102, i32 noundef 1)
  br label %107

107:                                              ; preds = %85, %101
  %.sink81 = phi ptr [ %87, %85 ], [ %90, %101 ]
  %.sink77 = phi i32 [ -1, %85 ], [ 1, %101 ]
  %.sink73 = phi i32 [ 1, %85 ], [ -1, %101 ]
  %108 = load i32, ptr %.sink81, align 4, !tbaa !21
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [200003 x i32], ptr @cnt, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = add nsw i32 %111, %.sink77
  store i32 %112, ptr %110, align 4, !tbaa !5
  tail call void @_Z7bit_addii(i32 noundef %108, i32 noundef %.sink73)
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %113 = load i32, ptr @etot, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %.not39.not = icmp slt i64 %indvars.iv70, %114
  br i1 %.not39.not, label %.lr.ph54, label %._crit_edge55, !llvm.loop !22

._crit_edge55:                                    ; preds = %107, %95, %89, %88, %._crit_edge49
  %.not39.lcssa = phi i1 [ true, %._crit_edge49 ], [ false, %88 ], [ false, %89 ], [ false, %95 ], [ true, %107 ]
  ret i1 %.not39.lcssa
}

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 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 #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

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

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


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