; LLVM IR from tangjz/acm-icpc :: codechef/ACM15AMR/AMCOINS.ll (Z5solveiiii)

; 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.Query = type { i32, i32, i32, i32, i32 }
%struct.Event = type { i32, i32 }

@que = external dso_local global [500001 x i32], align 16
@tot = external dso_local global i32, align 4
@in = external dso_local global [500001 x i32], align 16
@out = external dso_local global [500001 x i32], align 16
@fa = external dso_local global [19 x [500001 x i32]], align 16
@ord = external dso_local global [100001 x i32], align 16
@tmp = external dso_local global [100001 x i32], align 16
@st = external dso_local global i32, align 4
@res = external dso_local global [100001 x i32], align 16
@query = external dso_local global [100001 x %struct.Query], align 16
@event = external dso_local global [200003 x %struct.Event], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@__PRETTY_FUNCTION__._Z5solveiiii = external hidden unnamed_addr constant [31 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solveiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %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 ptr, align 8
  %14 = alloca %struct.Event, align 4
  %15 = alloca %struct.Event, align 4
  %16 = alloca %struct.Event, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = icmp sgt i32 %25, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %4
  br label %353

29:                                               ; preds = %4
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = icmp eq i32 %30, %31
  br i1 %32, label %33, label %62

33:                                               ; preds = %29
  br label %34

34:                                               ; preds = %58, %33
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = icmp sle i32 %35, %36
  br i1 %37, label %38, label %61

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  store i32 %42, ptr %9, align 4, !tbaa !5
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.Query, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = icmp eq i32 %47, 2
  br i1 %48, label %49, label %57

49:                                               ; preds = %38
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [500001 x i32], ptr @que, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = load i32, ptr %9, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %55
  store i32 %53, ptr %56, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %49, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %5, align 4, !tbaa !5
  br label %34, !llvm.loop !11

61:                                               ; preds = %34
  br label %353

62:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = load i32, ptr %8, align 4, !tbaa !5
  %65 = add nsw i32 %63, %64
  %66 = ashr i32 %65, 1
  store i32 %66, ptr %10, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %67 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %67, ptr %11, align 4, !tbaa !5
  br label %68

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

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

73:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %74 = load i32, ptr %11, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  store i32 %77, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %78 = load i32, ptr %12, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %79
  store ptr %80, ptr %13, align 8, !tbaa !13
  %81 = load ptr, ptr %13, align 8, !tbaa !13
  %82 = getelementptr inbounds %struct.Query, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = icmp eq i32 %83, 1
  br i1 %84, label %85, label %101

85:                                               ; preds = %73
  %86 = load ptr, ptr %13, align 8, !tbaa !13
  %87 = getelementptr inbounds %struct.Query, ptr %86, i32 0, i32 3
  %88 = load i32, ptr %87, align 4, !tbaa !15
  %89 = load i32, ptr %10, align 4, !tbaa !5
  %90 = icmp sle i32 %88, %89
  br i1 %90, label %91, label %100

91:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %92 = getelementptr inbounds %struct.Event, ptr %14, i32 0, i32 0
  %93 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %93, ptr %92, align 4, !tbaa !16
  %94 = getelementptr inbounds %struct.Event, ptr %14, i32 0, i32 1
  %95 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %95, ptr %94, align 4, !tbaa !18
  %96 = load i32, ptr @tot, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr @tot, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [200003 x %struct.Event], ptr @event, i64 0, i64 %98
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %99, ptr align 4 %14, i64 8, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %100

100:                                              ; preds = %91, %85
  br label %123

101:                                              ; preds = %73
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %102 = getelementptr inbounds %struct.Event, ptr %15, i32 0, i32 0
  %103 = load ptr, ptr %13, align 8, !tbaa !13
  %104 = getelementptr inbounds %struct.Query, ptr %103, i32 0, i32 2
  %105 = load i32, ptr %104, align 4, !tbaa !20
  %106 = sub nsw i32 %105, 1
  store i32 %106, ptr %102, align 4, !tbaa !16
  %107 = getelementptr inbounds %struct.Event, ptr %15, i32 0, i32 1
  %108 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %108, ptr %107, align 4, !tbaa !18
  %109 = load i32, ptr @tot, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr @tot, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [200003 x %struct.Event], ptr @event, i64 0, i64 %111
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %112, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %113 = getelementptr inbounds %struct.Event, ptr %16, i32 0, i32 0
  %114 = load ptr, ptr %13, align 8, !tbaa !13
  %115 = getelementptr inbounds %struct.Query, ptr %114, i32 0, i32 3
  %116 = load i32, ptr %115, align 4, !tbaa !15
  store i32 %116, ptr %113, align 4, !tbaa !16
  %117 = getelementptr inbounds %struct.Event, ptr %16, i32 0, i32 1
  %118 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %118, ptr %117, align 4, !tbaa !18
  %119 = load i32, ptr @tot, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr @tot, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [200003 x %struct.Event], ptr @event, i64 0, i64 %121
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %122, ptr align 4 %16, i64 8, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %123

123:                                              ; preds = %101, %100
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %124

124:                                              ; preds = %123
  %125 = load i32, ptr %11, align 4, !tbaa !5
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %11, align 4, !tbaa !5
  br label %68, !llvm.loop !21

127:                                              ; preds = %72
  %128 = load i32, ptr @tot, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds %struct.Event, ptr @event, i64 %129
  %131 = getelementptr inbounds %struct.Event, ptr %130, i64 1
  call void @_ZSt4sortIP5EventEvT_S2_(ptr noundef getelementptr inbounds (%struct.Event, ptr @event, i64 1), ptr noundef %131)
  %132 = load i32, ptr @st, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr @st, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 1, ptr %17, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %250, %127
  %135 = load i32, ptr %17, align 4, !tbaa !5
  %136 = load i32, ptr @tot, align 4, !tbaa !5
  %137 = icmp sle i32 %135, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %253

139:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %140 = load i32, ptr %17, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [200003 x %struct.Event], ptr @event, i64 0, i64 %141
  store ptr %142, ptr %18, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %143 = load ptr, ptr %18, align 8, !tbaa !13
  %144 = getelementptr inbounds %struct.Event, ptr %143, i32 0, i32 1
  %145 = load i32, ptr %144, align 4, !tbaa !18
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %146
  store ptr %147, ptr %19, align 8, !tbaa !13
  %148 = load ptr, ptr %19, align 8, !tbaa !13
  %149 = getelementptr inbounds %struct.Query, ptr %148, i32 0, i32 0
  %150 = load i32, ptr %149, align 4, !tbaa !9
  %151 = icmp eq i32 %150, 1
  br i1 %151, label %152, label %189

152:                                              ; preds = %139
  %153 = load ptr, ptr %19, align 8, !tbaa !13
  %154 = getelementptr inbounds %struct.Query, ptr %153, i32 0, i32 1
  %155 = load i32, ptr %154, align 4, !tbaa !22
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  call void @_Z7bit_addii(i32 noundef %158, i32 noundef 1)
  %159 = load ptr, ptr %19, align 8, !tbaa !13
  %160 = getelementptr inbounds %struct.Query, ptr %159, i32 0, i32 2
  %161 = load i32, ptr %160, align 4, !tbaa !20
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  call void @_Z7bit_addii(i32 noundef %164, i32 noundef 1)
  %165 = load ptr, ptr %19, align 8, !tbaa !13
  %166 = getelementptr inbounds %struct.Query, ptr %165, i32 0, i32 4
  %167 = load i32, ptr %166, align 4, !tbaa !23
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  call void @_Z7bit_addii(i32 noundef %170, i32 noundef -1)
  %171 = load ptr, ptr %19, align 8, !tbaa !13
  %172 = getelementptr inbounds %struct.Query, ptr %171, i32 0, i32 4
  %173 = load i32, ptr %172, align 4, !tbaa !23
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [500001 x i32], ptr @fa, i64 0, i64 %174
  %176 = load i32, ptr %175, align 4, !tbaa !5
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %178, label %188

178:                                              ; preds = %152
  %179 = load ptr, ptr %19, align 8, !tbaa !13
  %180 = getelementptr inbounds %struct.Query, ptr %179, i32 0, i32 4
  %181 = load i32, ptr %180, align 4, !tbaa !23
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [500001 x i32], ptr @fa, i64 0, i64 %182
  %184 = load i32, ptr %183, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  call void @_Z7bit_addii(i32 noundef %187, i32 noundef -1)
  br label %188

188:                                              ; preds = %178, %152
  br label %249

189:                                              ; preds = %139
  %190 = load ptr, ptr %18, align 8, !tbaa !13
  %191 = getelementptr inbounds %struct.Event, ptr %190, i32 0, i32 0
  %192 = load i32, ptr %191, align 4, !tbaa !16
  %193 = load ptr, ptr %19, align 8, !tbaa !13
  %194 = getelementptr inbounds %struct.Query, ptr %193, i32 0, i32 2
  %195 = load i32, ptr %194, align 4, !tbaa !20
  %196 = icmp slt i32 %192, %195
  br i1 %196, label %197, label %219

197:                                              ; preds = %189
  %198 = load ptr, ptr %19, align 8, !tbaa !13
  %199 = getelementptr inbounds %struct.Query, ptr %198, i32 0, i32 1
  %200 = load i32, ptr %199, align 4, !tbaa !22
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [500001 x i32], ptr @out, i64 0, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !5
  %204 = call noundef i32 @_Z7bit_sumi(i32 noundef %203)
  %205 = load ptr, ptr %19, align 8, !tbaa !13
  %206 = getelementptr inbounds %struct.Query, ptr %205, i32 0, i32 1
  %207 = load i32, ptr %206, align 4, !tbaa !22
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %208
  %210 = load i32, ptr %209, align 4, !tbaa !5
  %211 = sub nsw i32 %210, 1
  %212 = call noundef i32 @_Z7bit_sumi(i32 noundef %211)
  %213 = sub nsw i32 %204, %212
  %214 = load ptr, ptr %18, align 8, !tbaa !13
  %215 = getelementptr inbounds %struct.Event, ptr %214, i32 0, i32 1
  %216 = load i32, ptr %215, align 4, !tbaa !18
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %217
  store i32 %213, ptr %218, align 4, !tbaa !5
  br label %248

219:                                              ; preds = %189
  %220 = load ptr, ptr %19, align 8, !tbaa !13
  %221 = getelementptr inbounds %struct.Query, ptr %220, i32 0, i32 1
  %222 = load i32, ptr %221, align 4, !tbaa !22
  %223 = sext i32 %222 to i64
  %224 = getelementptr inbounds [500001 x i32], ptr @out, i64 0, i64 %223
  %225 = load i32, ptr %224, align 4, !tbaa !5
  %226 = call noundef i32 @_Z7bit_sumi(i32 noundef %225)
  %227 = load ptr, ptr %19, align 8, !tbaa !13
  %228 = getelementptr inbounds %struct.Query, ptr %227, i32 0, i32 1
  %229 = load i32, ptr %228, align 4, !tbaa !22
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %230
  %232 = load i32, ptr %231, align 4, !tbaa !5
  %233 = sub nsw i32 %232, 1
  %234 = call noundef i32 @_Z7bit_sumi(i32 noundef %233)
  %235 = sub nsw i32 %226, %234
  %236 = load ptr, ptr %18, align 8, !tbaa !13
  %237 = getelementptr inbounds %struct.Event, ptr %236, i32 0, i32 1
  %238 = load i32, ptr %237, align 4, !tbaa !18
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  %242 = sub nsw i32 %235, %241
  %243 = load ptr, ptr %18, align 8, !tbaa !13
  %244 = getelementptr inbounds %struct.Event, ptr %243, i32 0, i32 1
  %245 = load i32, ptr %244, align 4, !tbaa !18
  %246 = sext i32 %245 to i64
  %247 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %246
  store i32 %242, ptr %247, align 4, !tbaa !5
  br label %248

248:                                              ; preds = %219, %197
  br label %249

249:                                              ; preds = %248, %188
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %250

250:                                              ; preds = %249
  %251 = load i32, ptr %17, align 4, !tbaa !5
  %252 = add nsw i32 %251, 1
  store i32 %252, ptr %17, align 4, !tbaa !5
  br label %134, !llvm.loop !24

253:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %254 = load i32, ptr %5, align 4, !tbaa !5
  %255 = sub nsw i32 %254, 1
  store i32 %255, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  store i32 0, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  %256 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %256, ptr %22, align 4, !tbaa !5
  br label %257

257:                                              ; preds = %332, %253
  %258 = load i32, ptr %22, align 4, !tbaa !5
  %259 = load i32, ptr %6, align 4, !tbaa !5
  %260 = icmp sle i32 %258, %259
  br i1 %260, label %262, label %261

261:                                              ; preds = %257
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  br label %335

262:                                              ; preds = %257
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  %263 = load i32, ptr %22, align 4, !tbaa !5
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %264
  %266 = load i32, ptr %265, align 4, !tbaa !5
  store i32 %266, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  %267 = load i32, ptr %23, align 4, !tbaa !5
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %268
  store ptr %269, ptr %24, align 8, !tbaa !13
  %270 = load ptr, ptr %24, align 8, !tbaa !13
  %271 = getelementptr inbounds %struct.Query, ptr %270, i32 0, i32 0
  %272 = load i32, ptr %271, align 4, !tbaa !9
  %273 = icmp eq i32 %272, 1
  br i1 %273, label %274, label %293

274:                                              ; preds = %262
  %275 = load ptr, ptr %24, align 8, !tbaa !13
  %276 = getelementptr inbounds %struct.Query, ptr %275, i32 0, i32 3
  %277 = load i32, ptr %276, align 4, !tbaa !15
  %278 = load i32, ptr %10, align 4, !tbaa !5
  %279 = icmp sle i32 %277, %278
  br i1 %279, label %280, label %286

280:                                              ; preds = %274
  %281 = load i32, ptr %23, align 4, !tbaa !5
  %282 = load i32, ptr %20, align 4, !tbaa !5
  %283 = add nsw i32 %282, 1
  store i32 %283, ptr %20, align 4, !tbaa !5
  %284 = sext i32 %283 to i64
  %285 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %284
  store i32 %281, ptr %285, align 4, !tbaa !5
  br label %292

286:                                              ; preds = %274
  %287 = load i32, ptr %23, align 4, !tbaa !5
  %288 = load i32, ptr %21, align 4, !tbaa !5
  %289 = add nsw i32 %288, 1
  store i32 %289, ptr %21, align 4, !tbaa !5
  %290 = sext i32 %289 to i64
  %291 = getelementptr inbounds [100001 x i32], ptr @tmp, i64 0, i64 %290
  store i32 %287, ptr %291, align 4, !tbaa !5
  br label %292

292:                                              ; preds = %286, %280
  br label %331

293:                                              ; preds = %262
  %294 = load i32, ptr %23, align 4, !tbaa !5
  %295 = sext i32 %294 to i64
  %296 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %295
  %297 = load i32, ptr %296, align 4, !tbaa !5
  %298 = load ptr, ptr %24, align 8, !tbaa !13
  %299 = getelementptr inbounds %struct.Query, ptr %298, i32 0, i32 4
  %300 = load i32, ptr %299, align 4, !tbaa !23
  %301 = icmp slt i32 %297, %300
  br i1 %301, label %302, label %324

302:                                              ; preds = %293
  %303 = load i32, ptr %23, align 4, !tbaa !5
  %304 = sext i32 %303 to i64
  %305 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %304
  %306 = load i32, ptr %305, align 4, !tbaa !5
  %307 = load ptr, ptr %24, align 8, !tbaa !13
  %308 = getelementptr inbounds %struct.Query, ptr %307, i32 0, i32 4
  %309 = load i32, ptr %308, align 4, !tbaa !23
  %310 = sub nsw i32 %309, %306
  store i32 %310, ptr %308, align 4, !tbaa !23
  %311 = load i32, ptr %23, align 4, !tbaa !5
  %312 = load i32, ptr %21, align 4, !tbaa !5
  %313 = add nsw i32 %312, 1
  store i32 %313, ptr %21, align 4, !tbaa !5
  %314 = sext i32 %313 to i64
  %315 = getelementptr inbounds [100001 x i32], ptr @tmp, i64 0, i64 %314
  store i32 %311, ptr %315, align 4, !tbaa !5
  %316 = load ptr, ptr %24, align 8, !tbaa !13
  %317 = getelementptr inbounds %struct.Query, ptr %316, i32 0, i32 4
  %318 = load i32, ptr %317, align 4, !tbaa !23
  %319 = icmp sge i32 %318, 1
  br i1 %319, label %320, label %321

320:                                              ; preds = %302
  br label %323

321:                                              ; preds = %302
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 118, ptr noundef @__PRETTY_FUNCTION__._Z5solveiiii) #7
  unreachable

322:                                              ; No predecessors!
  br label %323

323:                                              ; preds = %322, %320
  br label %330

324:                                              ; preds = %293
  %325 = load i32, ptr %23, align 4, !tbaa !5
  %326 = load i32, ptr %20, align 4, !tbaa !5
  %327 = add nsw i32 %326, 1
  store i32 %327, ptr %20, align 4, !tbaa !5
  %328 = sext i32 %327 to i64
  %329 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %328
  store i32 %325, ptr %329, align 4, !tbaa !5
  br label %330

330:                                              ; preds = %324, %323
  br label %331

331:                                              ; preds = %330, %292
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  br label %332

332:                                              ; preds = %331
  %333 = load i32, ptr %22, align 4, !tbaa !5
  %334 = add nsw i32 %333, 1
  store i32 %334, ptr %22, align 4, !tbaa !5
  br label %257, !llvm.loop !25

335:                                              ; preds = %261
  %336 = load i32, ptr %20, align 4, !tbaa !5
  %337 = sext i32 %336 to i64
  %338 = getelementptr inbounds i32, ptr @ord, i64 %337
  %339 = getelementptr inbounds i32, ptr %338, i64 1
  %340 = load i32, ptr %21, align 4, !tbaa !5
  %341 = sext i32 %340 to i64
  %342 = mul i64 %341, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %339, ptr align 4 getelementptr inbounds (i32, ptr @tmp, i64 1), i64 %342, i1 false)
  %343 = load i32, ptr %5, align 4, !tbaa !5
  %344 = load i32, ptr %20, align 4, !tbaa !5
  %345 = load i32, ptr %7, align 4, !tbaa !5
  %346 = load i32, ptr %10, align 4, !tbaa !5
  call void @_Z5solveiiii(i32 noundef %343, i32 noundef %344, i32 noundef %345, i32 noundef %346)
  %347 = load i32, ptr %20, align 4, !tbaa !5
  %348 = add nsw i32 %347, 1
  %349 = load i32, ptr %6, align 4, !tbaa !5
  %350 = load i32, ptr %10, align 4, !tbaa !5
  %351 = add nsw i32 %350, 1
  %352 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z5solveiiii(i32 noundef %348, i32 noundef %349, i32 noundef %351, i32 noundef %352)
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %353

353:                                              ; preds = %335, %61, %28
  ret void
}

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { noreturn 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 0}
!10 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!10, !6, i64 12}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTS5Event", !6, i64 0, !6, i64 4}
!18 = !{!17, !6, i64 4}
!19 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}
!20 = !{!10, !6, i64 8}
!21 = distinct !{!21, !12}
!22 = !{!10, !6, i64 4}
!23 = !{!10, !6, i64 16}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !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.Query = type { i32, i32, i32, i32, i32 }
%struct.Event = type { i32, i32 }

@que = external dso_local local_unnamed_addr global [500001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@in = external dso_local local_unnamed_addr global [500001 x i32], align 16
@out = external dso_local local_unnamed_addr global [500001 x i32], align 16
@fa = external dso_local local_unnamed_addr global [19 x [500001 x i32]], align 16
@ord = external dso_local local_unnamed_addr global [100001 x i32], align 16
@tmp = external dso_local local_unnamed_addr global [100001 x i32], align 16
@st = external dso_local local_unnamed_addr global i32, align 4
@res = external dso_local local_unnamed_addr global [100001 x i32], align 16
@query = external dso_local local_unnamed_addr global [100001 x %struct.Query], align 16
@event = external dso_local global [200003 x %struct.Event], align 16
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@__PRETTY_FUNCTION__._Z5solveiiii = external hidden unnamed_addr constant [31 x i8], align 1

; 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 void @_Z5solveiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = icmp sgt i32 %0, %1
  br i1 %5, label %.loopexit, label %.lr.ph133.preheader

.lr.ph133.preheader:                              ; preds = %4
  %6 = add i32 %1, 1
  br label %.lr.ph133

.lr.ph133:                                        ; preds = %.lr.ph133.preheader, %tailrecurse
  %.tr103131 = phi i32 [ %145, %tailrecurse ], [ %2, %.lr.ph133.preheader ]
  %.tr130 = phi i32 [ %144, %tailrecurse ], [ %0, %.lr.ph133.preheader ]
  %7 = icmp eq i32 %.tr103131, %3
  br i1 %7, label %.preheader, label %43

.preheader:                                       ; preds = %.lr.ph133
  %.not101134 = icmp sgt i32 %.tr130, %1
  br i1 %.not101134, label %.loopexit, label %.lr.ph136

.lr.ph136:                                        ; preds = %.preheader
  %8 = sext i32 %3 to i64
  %9 = getelementptr inbounds [500001 x i32], ptr @que, i64 0, i64 %8
  %10 = sext i32 %.tr130 to i64
  %11 = add i32 %.tr130, %1
  %12 = and i32 %11, 1
  %lcmp.mod.not.not = icmp eq i32 %12, 0
  br i1 %lcmp.mod.not.not, label %.prol.preheader, label %.prol.loopexit

.prol.preheader:                                  ; preds = %.lr.ph136
  %13 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %10
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %.prol.loopexit.unr-lcssa

19:                                               ; preds = %.prol.preheader
  %20 = load i32, ptr %9, align 4, !tbaa !5
  %21 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %15
  store i32 %20, ptr %21, align 4, !tbaa !5
  br label %.prol.loopexit.unr-lcssa

.prol.loopexit.unr-lcssa:                         ; preds = %19, %.prol.preheader
  %indvars.iv.next152.prol = add nsw i64 %10, 1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.lr.ph136
  %indvars.iv151.unr = phi i64 [ %10, %.lr.ph136 ], [ %indvars.iv.next152.prol, %.prol.loopexit.unr-lcssa ]
  %22 = icmp eq i32 %.tr130, %1
  br i1 %22, label %.loopexit, label %.lr.ph136.new

.lr.ph136.new:                                    ; preds = %.prol.loopexit, %42
  %indvars.iv151 = phi i64 [ %indvars.iv.next152.1, %42 ], [ %indvars.iv151.unr, %.prol.loopexit ]
  %23 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv151
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 2
  br i1 %28, label %29, label %32

29:                                               ; preds = %.lr.ph136.new
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %25
  store i32 %30, ptr %31, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %29, %.lr.ph136.new
  %indvars.iv.next152 = add nsw i64 %indvars.iv151, 1
  %33 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv.next152
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 2
  br i1 %38, label %39, label %42

39:                                               ; preds = %32
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %35
  store i32 %40, ptr %41, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %39, %32
  %indvars.iv.next152.1 = add nsw i64 %indvars.iv151, 2
  %lftr.wideiv154.1 = trunc i64 %indvars.iv.next152.1 to i32
  %exitcond155.not.1 = icmp eq i32 %6, %lftr.wideiv154.1
  br i1 %exitcond155.not.1, label %.loopexit, label %.lr.ph136.new, !llvm.loop !11

43:                                               ; preds = %.lr.ph133
  %44 = add nsw i32 %.tr103131, %3
  %45 = ashr i32 %44, 1
  store i32 0, ptr @tot, align 4, !tbaa !5
  %.not114 = icmp sgt i32 %.tr130, %1
  br i1 %.not114, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %43
  %46 = sext i32 %.tr130 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %74, %43
  %47 = phi i32 [ 0, %43 ], [ %75, %74 ]
  %48 = sext i32 %47 to i64
  %gep = getelementptr %struct.Event, ptr getelementptr inbounds (i8, ptr @event, i64 8), i64 %48
  tail call void @_ZSt4sortIP5EventEvT_S2_(ptr noundef nonnull getelementptr inbounds (i8, ptr @event, i64 8), ptr noundef nonnull %gep)
  %49 = load i32, ptr @st, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr @st, align 4, !tbaa !5
  %51 = load i32, ptr @tot, align 4, !tbaa !5
  %.not96116 = icmp slt i32 %51, 1
  br i1 %.not96116, label %._crit_edge120, label %.lr.ph119

.lr.ph:                                           ; preds = %.lr.ph.preheader, %74
  %indvars.iv = phi i64 [ %46, %.lr.ph.preheader ], [ %indvars.iv.next, %74 ]
  %52 = phi i32 [ 0, %.lr.ph.preheader ], [ %75, %74 ]
  %53 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = icmp eq i32 %57, 1
  br i1 %58, label %59, label %62

59:                                               ; preds = %.lr.ph
  %60 = getelementptr inbounds i8, ptr %56, i64 12
  %61 = load i32, ptr %60, align 4, !tbaa !13
  %.not100 = icmp sgt i32 %61, %45
  br i1 %.not100, label %74, label %.sink.split

62:                                               ; preds = %.lr.ph
  %63 = getelementptr inbounds i8, ptr %56, i64 8
  %64 = load i32, ptr %63, align 4, !tbaa !14
  %65 = add nsw i32 %64, -1
  %66 = add nsw i32 %52, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [200003 x %struct.Event], ptr @event, i64 0, i64 %67
  store i32 %65, ptr %68, align 8, !tbaa !5
  %.sroa.442.0..sroa_idx = getelementptr inbounds i8, ptr %68, i64 4
  store i32 %54, ptr %.sroa.442.0..sroa_idx, align 4, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %56, i64 12
  %70 = load i32, ptr %69, align 4, !tbaa !13
  br label %.sink.split

.sink.split:                                      ; preds = %59, %62
  %.sink163 = phi i32 [ 2, %62 ], [ 1, %59 ]
  %.sink159 = phi i32 [ %70, %62 ], [ %54, %59 ]
  %71 = add nsw i32 %52, %.sink163
  store i32 %71, ptr @tot, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [200003 x %struct.Event], ptr @event, i64 0, i64 %72
  store i32 %.sink159, ptr %73, align 8, !tbaa !5
  %.sroa.444.0..sroa_idx = getelementptr inbounds i8, ptr %73, i64 4
  store i32 %54, ptr %.sroa.444.0..sroa_idx, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %.sink.split, %59
  %75 = phi i32 [ %52, %59 ], [ %71, %.sink.split ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %6, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge120:                                   ; preds = %138, %._crit_edge
  %76 = add nsw i32 %.tr130, -1
  br i1 %.not114, label %tailrecurse, label %.lr.ph126.preheader

.lr.ph126.preheader:                              ; preds = %._crit_edge120
  %77 = sext i32 %.tr130 to i64
  br label %.lr.ph126

.lr.ph119:                                        ; preds = %._crit_edge, %138
  %indvars.iv143 = phi i64 [ %indvars.iv.next144, %138 ], [ 1, %._crit_edge ]
  %78 = getelementptr inbounds [200003 x %struct.Event], ptr @event, i64 0, i64 %indvars.iv143
  %79 = getelementptr inbounds i8, ptr %78, i64 4
  %80 = load i32, ptr %79, align 4, !tbaa !16
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = icmp eq i32 %83, 1
  br i1 %84, label %85, label %109

85:                                               ; preds = %.lr.ph119
  %86 = getelementptr inbounds i8, ptr %82, i64 4
  %87 = load i32, ptr %86, align 4, !tbaa !18
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  tail call void @_Z7bit_addii(i32 noundef %90, i32 noundef 1)
  %91 = getelementptr inbounds i8, ptr %82, i64 8
  %92 = load i32, ptr %91, align 4, !tbaa !14
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  tail call void @_Z7bit_addii(i32 noundef %95, i32 noundef 1)
  %96 = getelementptr inbounds i8, ptr %82, i64 16
  %97 = load i32, ptr %96, align 4, !tbaa !19
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  tail call void @_Z7bit_addii(i32 noundef %100, i32 noundef -1)
  %101 = load i32, ptr %96, align 4, !tbaa !19
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [500001 x i32], ptr @fa, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %.not99 = icmp eq i32 %104, 0
  br i1 %.not99, label %138, label %105

105:                                              ; preds = %85
  %106 = sext i32 %104 to i64
  %107 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  tail call void @_Z7bit_addii(i32 noundef %108, i32 noundef -1)
  br label %138

109:                                              ; preds = %.lr.ph119
  %110 = load i32, ptr %78, align 8, !tbaa !20
  %111 = getelementptr inbounds i8, ptr %82, i64 8
  %112 = load i32, ptr %111, align 4, !tbaa !14
  %113 = icmp slt i32 %110, %112
  %114 = getelementptr inbounds i8, ptr %82, i64 4
  %115 = load i32, ptr %114, align 4, !tbaa !18
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [500001 x i32], ptr @out, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = tail call noundef i32 @_Z7bit_sumi(i32 noundef %118)
  %120 = load i32, ptr %114, align 4, !tbaa !18
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [500001 x i32], ptr @in, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = add nsw i32 %123, -1
  %125 = tail call noundef i32 @_Z7bit_sumi(i32 noundef %124)
  br i1 %113, label %126, label %131

126:                                              ; preds = %109
  %127 = sub nsw i32 %119, %125
  %128 = load i32, ptr %79, align 4, !tbaa !16
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %129
  store i32 %127, ptr %130, align 4, !tbaa !5
  br label %138

131:                                              ; preds = %109
  %132 = load i32, ptr %79, align 4, !tbaa !16
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = add i32 %125, %135
  %137 = sub i32 %119, %136
  store i32 %137, ptr %134, align 4, !tbaa !5
  br label %138

138:                                              ; preds = %126, %131, %85, %105
  %indvars.iv.next144 = add nuw nsw i64 %indvars.iv143, 1
  %139 = load i32, ptr @tot, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %.not96.not = icmp slt i64 %indvars.iv143, %140
  br i1 %.not96.not, label %.lr.ph119, label %._crit_edge120, !llvm.loop !21

tailrecurse:                                      ; preds = %176, %._crit_edge120
  %.086.lcssa = phi i32 [ %76, %._crit_edge120 ], [ %.187, %176 ]
  %.085.lcssa = phi i32 [ 0, %._crit_edge120 ], [ %.1, %176 ]
  %141 = sext i32 %.086.lcssa to i64
  %gep129 = getelementptr i32, ptr getelementptr inbounds (i8, ptr @ord, i64 4), i64 %141
  %142 = sext i32 %.085.lcssa to i64
  %143 = shl nsw i64 %142, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %gep129, ptr nonnull align 4 getelementptr inbounds (i8, ptr @tmp, i64 4), i64 %143, i1 false)
  tail call void @_Z5solveiiii(i32 noundef %.tr130, i32 noundef %.086.lcssa, i32 noundef %.tr103131, i32 noundef %45)
  %144 = add nsw i32 %.086.lcssa, 1
  %145 = add nsw i32 %45, 1
  %.not = icmp slt i32 %.086.lcssa, %1
  br i1 %.not, label %.lr.ph133, label %.loopexit

.lr.ph126:                                        ; preds = %.lr.ph126.preheader, %176
  %indvars.iv146 = phi i64 [ %77, %.lr.ph126.preheader ], [ %indvars.iv.next147, %176 ]
  %.085123 = phi i32 [ 0, %.lr.ph126.preheader ], [ %.1, %176 ]
  %.086122 = phi i32 [ %76, %.lr.ph126.preheader ], [ %.187, %176 ]
  %146 = getelementptr inbounds [100001 x i32], ptr @ord, i64 0, i64 %indvars.iv146
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100001 x %struct.Query], ptr @query, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !9
  %151 = icmp eq i32 %150, 1
  br i1 %151, label %152, label %159

152:                                              ; preds = %.lr.ph126
  %153 = getelementptr inbounds i8, ptr %149, i64 12
  %154 = load i32, ptr %153, align 4, !tbaa !13
  %.not98 = icmp sgt i32 %154, %45
  br i1 %.not98, label %157, label %155

155:                                              ; preds = %152
  %156 = add nsw i32 %.086122, 1
  br label %.sink.split164

157:                                              ; preds = %152
  %158 = add nsw i32 %.085123, 1
  br label %.sink.split164

159:                                              ; preds = %.lr.ph126
  %160 = getelementptr inbounds [100001 x i32], ptr @res, i64 0, i64 %148
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = getelementptr inbounds i8, ptr %149, i64 16
  %163 = load i32, ptr %162, align 4, !tbaa !19
  %164 = icmp slt i32 %161, %163
  br i1 %164, label %165, label %172

165:                                              ; preds = %159
  %166 = sub nsw i32 %163, %161
  store i32 %166, ptr %162, align 4, !tbaa !19
  %167 = add nsw i32 %.085123, 1
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [100001 x i32], ptr @tmp, i64 0, i64 %168
  store i32 %147, ptr %169, align 4, !tbaa !5
  %170 = icmp sgt i32 %166, 0
  br i1 %170, label %176, label %171

171:                                              ; preds = %165
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 118, ptr noundef nonnull @__PRETTY_FUNCTION__._Z5solveiiii) #5
  unreachable

172:                                              ; preds = %159
  %173 = add nsw i32 %.086122, 1
  br label %.sink.split164

.sink.split164:                                   ; preds = %157, %155, %172
  %.sink = phi i32 [ %173, %172 ], [ %156, %155 ], [ %158, %157 ]
  %ord.sink = phi ptr [ @ord, %172 ], [ @ord, %155 ], [ @tmp, %157 ]
  %.187.ph = phi i32 [ %173, %172 ], [ %156, %155 ], [ %.086122, %157 ]
  %.1.ph = phi i32 [ %.085123, %172 ], [ %.085123, %155 ], [ %158, %157 ]
  %174 = sext i32 %.sink to i64
  %175 = getelementptr inbounds [100001 x i32], ptr %ord.sink, i64 0, i64 %174
  store i32 %147, ptr %175, align 4, !tbaa !5
  br label %176

176:                                              ; preds = %.sink.split164, %165
  %.187 = phi i32 [ %.086122, %165 ], [ %.187.ph, %.sink.split164 ]
  %.1 = phi i32 [ %167, %165 ], [ %.1.ph, %.sink.split164 ]
  %indvars.iv.next147 = add nsw i64 %indvars.iv146, 1
  %lftr.wideiv149 = trunc i64 %indvars.iv.next147 to i32
  %exitcond150.not = icmp eq i32 %6, %lftr.wideiv149
  br i1 %exitcond150.not, label %tailrecurse, label %.lr.ph126, !llvm.loop !22

.loopexit:                                        ; preds = %tailrecurse, %.prol.loopexit, %42, %4, %.preheader
  ret void
}

; Function Attrs: mustprogress 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5EventEvT_S2_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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 = { mustprogress nocallback nofree 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 = { noreturn 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 = { noreturn 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 0}
!10 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !6, i64 12}
!14 = !{!10, !6, i64 8}
!15 = distinct !{!15, !12}
!16 = !{!17, !6, i64 4}
!17 = !{!"_ZTS5Event", !6, i64 0, !6, i64 4}
!18 = !{!10, !6, i64 4}
!19 = !{!10, !6, i64 16}
!20 = !{!17, !6, i64 0}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}


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