; LLVM IR from tangjz/acm-icpc :: hdu/5412.ll (Z5solvei)

; 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.FastInput = type <{ ptr, ptr, ptr, i8, [7 x i8] }>
%struct.FastOutput = type { ptr, ptr, ptr }
%struct.Event = type { i32, i32, i32, i32 }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%class.anon = type { ptr, ptr }

@in = external dso_local global %struct.FastInput, align 8
@out = external dso_local global %struct.FastOutput, align 8
@_ZZ5solveiE1a = external hidden global [100001 x i32], align 16
@_ZZ5solveiE3que = external hidden global [200001 x i32], align 16
@_ZZ5solveiE3ord = external hidden global [300001 x i32], align 16
@_ZZ5solveiE3ans = external hidden global [300001 x i32], align 16
@_ZZ5solveiE3seq = external hidden global [300001 x %struct.Event], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvei(i32 noundef %0) #0 personality ptr @__gxx_personality_v0 {
  %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 %struct.Event, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct.Event, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca %"class.std::function", align 8
  %15 = alloca %class.anon, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  br label %19

19:                                               ; preds = %50, %1
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %53

24:                                               ; preds = %19
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solveiE1a, i64 0, i64 %26
  call void @_ZN9FastInput4readERi(ptr noundef nonnull align 8 dereferenceable(25) @in, ptr noundef nonnull align 4 dereferenceable(4) %27)
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %28 = getelementptr inbounds %struct.Event, ptr %8, i32 0, i32 0
  store i32 1, ptr %28, align 4, !tbaa !9
  %29 = getelementptr inbounds %struct.Event, ptr %8, i32 0, i32 1
  %30 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %30, ptr %29, align 4, !tbaa !11
  %31 = getelementptr inbounds %struct.Event, ptr %8, i32 0, i32 2
  %32 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %32, ptr %31, align 4, !tbaa !12
  %33 = getelementptr inbounds %struct.Event, ptr %8, i32 0, i32 3
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solveiE1a, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  store i32 %37, ptr %33, align 4, !tbaa !13
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %5, align 4, !tbaa !5
  %40 = sext i32 %38 to i64
  %41 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %40
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %41, ptr align 4 %8, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solveiE1a, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %4, align 4, !tbaa !5
  %48 = sext i32 %46 to i64
  %49 = getelementptr inbounds [200001 x i32], ptr @_ZZ5solveiE3que, i64 0, i64 %48
  store i32 %45, ptr %49, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %24
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %6, align 4, !tbaa !5
  br label %19, !llvm.loop !15

53:                                               ; preds = %23
  call void @_ZN9FastInput4readERi(ptr noundef nonnull align 8 dereferenceable(25) @in, ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %54

54:                                               ; preds = %118, %116, %53
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = add nsw i32 %55, -1
  store i32 %56, ptr %3, align 4, !tbaa !5
  %57 = icmp ne i32 %55, 0
  br i1 %57, label %58, label %119

58:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %5, align 4, !tbaa !5
  %61 = sext i32 %59 to i64
  %62 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %61
  store ptr %62, ptr %9, align 8, !tbaa !17
  %63 = load ptr, ptr %9, align 8, !tbaa !17
  call void @_ZN5Event4readEv(ptr noundef nonnull align 4 dereferenceable(16) %63)
  %64 = load ptr, ptr %9, align 8, !tbaa !17
  %65 = getelementptr inbounds %struct.Event, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = icmp eq i32 %66, 2
  br i1 %67, label %68, label %69

68:                                               ; preds = %58
  store i32 5, ptr %10, align 4
  br label %116, !llvm.loop !19

69:                                               ; preds = %58
  %70 = load ptr, ptr %9, align 8, !tbaa !17
  %71 = getelementptr inbounds %struct.Event, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !11
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solveiE1a, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = load ptr, ptr %9, align 8, !tbaa !17
  %77 = getelementptr inbounds %struct.Event, ptr %76, i32 0, i32 3
  %78 = load i32, ptr %77, align 4, !tbaa !13
  %79 = icmp eq i32 %75, %78
  br i1 %79, label %80, label %83

80:                                               ; preds = %69
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = add nsw i32 %81, -1
  store i32 %82, ptr %5, align 4, !tbaa !5
  store i32 5, ptr %10, align 4
  br label %116, !llvm.loop !19

83:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #5
  %84 = getelementptr inbounds %struct.Event, ptr %11, i32 0, i32 0
  store i32 -1, ptr %84, align 4, !tbaa !9
  %85 = getelementptr inbounds %struct.Event, ptr %11, i32 0, i32 1
  %86 = load ptr, ptr %9, align 8, !tbaa !17
  %87 = getelementptr inbounds %struct.Event, ptr %86, i32 0, i32 1
  %88 = load i32, ptr %87, align 4, !tbaa !11
  store i32 %88, ptr %85, align 4, !tbaa !11
  %89 = getelementptr inbounds %struct.Event, ptr %11, i32 0, i32 2
  %90 = load ptr, ptr %9, align 8, !tbaa !17
  %91 = getelementptr inbounds %struct.Event, ptr %90, i32 0, i32 1
  %92 = load i32, ptr %91, align 4, !tbaa !11
  store i32 %92, ptr %89, align 4, !tbaa !12
  %93 = getelementptr inbounds %struct.Event, ptr %11, i32 0, i32 3
  %94 = load ptr, ptr %9, align 8, !tbaa !17
  %95 = getelementptr inbounds %struct.Event, ptr %94, i32 0, i32 1
  %96 = load i32, ptr %95, align 4, !tbaa !11
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solveiE1a, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  store i32 %99, ptr %93, align 4, !tbaa !13
  %100 = load i32, ptr %5, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %5, align 4, !tbaa !5
  %102 = sext i32 %100 to i64
  %103 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %102
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %103, ptr align 4 %11, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #5
  %104 = load ptr, ptr %9, align 8, !tbaa !17
  %105 = getelementptr inbounds %struct.Event, ptr %104, i32 0, i32 3
  %106 = load i32, ptr %105, align 4, !tbaa !13
  %107 = load ptr, ptr %9, align 8, !tbaa !17
  %108 = getelementptr inbounds %struct.Event, ptr %107, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !11
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solveiE1a, i64 0, i64 %110
  store i32 %106, ptr %111, align 4, !tbaa !5
  %112 = load i32, ptr %4, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %4, align 4, !tbaa !5
  %114 = sext i32 %112 to i64
  %115 = getelementptr inbounds [200001 x i32], ptr @_ZZ5solveiE3que, i64 0, i64 %114
  store i32 %106, ptr %115, align 4, !tbaa !5
  store i32 0, ptr %10, align 4
  br label %116

116:                                              ; preds = %83, %80, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %117 = load i32, ptr %10, align 4
  switch i32 %117, label %210 [
    i32 0, label %118
    i32 5, label %54
  ]

118:                                              ; preds = %116
  br label %54, !llvm.loop !19

119:                                              ; preds = %54
  %120 = load i32, ptr %4, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr @_ZZ5solveiE3que, i64 %121
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @_ZZ5solveiE3que, ptr noundef %122)
  %123 = load i32, ptr %4, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds i32, ptr @_ZZ5solveiE3que, i64 %124
  %126 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @_ZZ5solveiE3que, ptr noundef %125)
  %127 = ptrtoint ptr %126 to i64
  %128 = sub i64 %127, ptrtoint (ptr @_ZZ5solveiE3que to i64)
  %129 = sdiv exact i64 %128, 4
  %130 = trunc i64 %129 to i32
  store i32 %130, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %158, %119
  %132 = load i32, ptr %12, align 4, !tbaa !5
  %133 = load i32, ptr %5, align 4, !tbaa !5
  %134 = icmp slt i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  store i32 7, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %161

136:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %137 = load i32, ptr %12, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %138
  store ptr %139, ptr %13, align 8, !tbaa !17
  %140 = load ptr, ptr %13, align 8, !tbaa !17
  %141 = getelementptr inbounds %struct.Event, ptr %140, i32 0, i32 0
  %142 = load i32, ptr %141, align 4, !tbaa !9
  %143 = icmp ne i32 %142, 2
  br i1 %143, label %144, label %157

144:                                              ; preds = %136
  %145 = load i32, ptr %4, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds i32, ptr @_ZZ5solveiE3que, i64 %146
  %148 = load ptr, ptr %13, align 8, !tbaa !17
  %149 = getelementptr inbounds %struct.Event, ptr %148, i32 0, i32 3
  %150 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @_ZZ5solveiE3que, ptr noundef %147, ptr noundef nonnull align 4 dereferenceable(4) %149)
  %151 = ptrtoint ptr %150 to i64
  %152 = sub i64 %151, ptrtoint (ptr @_ZZ5solveiE3que to i64)
  %153 = sdiv exact i64 %152, 4
  %154 = trunc i64 %153 to i32
  %155 = load ptr, ptr %13, align 8, !tbaa !17
  %156 = getelementptr inbounds %struct.Event, ptr %155, i32 0, i32 3
  store i32 %154, ptr %156, align 4, !tbaa !13
  br label %157

157:                                              ; preds = %144, %136
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %12, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %12, align 4, !tbaa !5
  br label %131, !llvm.loop !20

161:                                              ; preds = %135
  %162 = load i32, ptr %5, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds i32, ptr @_ZZ5solveiE3ord, i64 %163
  call void @_ZSt4iotaIPiiEvT_S1_T0_(ptr noundef @_ZZ5solveiE3ord, ptr noundef %164, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #5
  %165 = getelementptr inbounds %class.anon, ptr %15, i32 0, i32 0
  store ptr %2, ptr %165, align 8, !tbaa !17
  %166 = getelementptr inbounds %class.anon, ptr %15, i32 0, i32 1
  store ptr %14, ptr %166, align 8, !tbaa !17
  call void @"_ZNSt8functionIFviiiiEEC2IZ5solveiE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull align 8 dereferenceable(16) %15) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #5
  %167 = load i32, ptr %5, align 4, !tbaa !5
  %168 = sub nsw i32 %167, 1
  %169 = load i32, ptr %4, align 4, !tbaa !5
  %170 = sub nsw i32 %169, 1
  invoke void @_ZNKSt8functionIFviiiiEEclEiiii(ptr noundef nonnull align 8 dereferenceable(32) %14, i32 noundef 0, i32 noundef %168, i32 noundef 0, i32 noundef %170)
          to label %171 unwind label %177

171:                                              ; preds = %161
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %172

172:                                              ; preds = %200, %171
  %173 = load i32, ptr %18, align 4, !tbaa !5
  %174 = load i32, ptr %5, align 4, !tbaa !5
  %175 = icmp slt i32 %173, %174
  br i1 %175, label %181, label %176

176:                                              ; preds = %172
  store i32 10, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %203

177:                                              ; preds = %161
  %178 = landingpad { ptr, i32 }
          cleanup
  %179 = extractvalue { ptr, i32 } %178, 0
  store ptr %179, ptr %16, align 8
  %180 = extractvalue { ptr, i32 } %178, 1
  store i32 %180, ptr %17, align 4
  br label %204

181:                                              ; preds = %172
  %182 = load i32, ptr %18, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %183
  %185 = getelementptr inbounds %struct.Event, ptr %184, i32 0, i32 0
  %186 = load i32, ptr %185, align 16, !tbaa !9
  %187 = icmp eq i32 %186, 2
  br i1 %187, label %188, label %199

188:                                              ; preds = %181
  %189 = load i32, ptr %18, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [300001 x i32], ptr @_ZZ5solveiE3ans, i64 0, i64 %190
  %192 = load i32, ptr %191, align 4, !tbaa !5
  invoke void @_ZN10FastOutput5writeEi(ptr noundef nonnull align 8 dereferenceable(24) @out, i32 noundef %192)
          to label %193 unwind label %195

193:                                              ; preds = %188
  invoke void @_ZN10FastOutput9writeCharEc(ptr noundef nonnull align 8 dereferenceable(24) @out, i8 noundef signext 10)
          to label %194 unwind label %195

194:                                              ; preds = %193
  br label %199

195:                                              ; preds = %193, %188
  %196 = landingpad { ptr, i32 }
          cleanup
  %197 = extractvalue { ptr, i32 } %196, 0
  store ptr %197, ptr %16, align 8
  %198 = extractvalue { ptr, i32 } %196, 1
  store i32 %198, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %204

199:                                              ; preds = %194, %181
  br label %200

200:                                              ; preds = %199
  %201 = load i32, ptr %18, align 4, !tbaa !5
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %18, align 4, !tbaa !5
  br label %172, !llvm.loop !21

203:                                              ; preds = %176
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void

204:                                              ; preds = %195, %177
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %205

205:                                              ; preds = %204
  %206 = load ptr, ptr %16, align 8
  %207 = load i32, ptr %17, align 4
  %208 = insertvalue { ptr, i32 } poison, ptr %206, 0
  %209 = insertvalue { ptr, i32 } %208, i32 %207, 1
  resume { ptr, i32 } %209

210:                                              ; preds = %116
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9FastInput4readERi(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(4)) #0 align 2

; 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 @_ZN5Event4readEv(ptr noundef nonnull align 4 dereferenceable(16)) #0 align 2

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPiiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @"_ZNSt8functionIFviiiiEEC2IZ5solveiE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNKSt8functionIFviiiiEEclEiiii(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10FastOutput5writeEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10FastOutput9writeCharEc(ptr noundef nonnull align 8 dereferenceable(24), i8 noundef signext) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 2

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


; 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.FastInput = type <{ ptr, ptr, ptr, i8, [7 x i8] }>
%struct.FastOutput = type { ptr, ptr, ptr }
%struct.Event = type { i32, i32, i32, i32 }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%class.anon = type { ptr, ptr }

@in = external dso_local global %struct.FastInput, align 8
@out = external dso_local global %struct.FastOutput, align 8
@_ZZ5solveiE1a = external hidden global [100001 x i32], align 16
@_ZZ5solveiE3que = external hidden global [200001 x i32], align 16
@_ZZ5solveiE3ord = external hidden global [300001 x i32], align 16
@_ZZ5solveiE3ans = external hidden local_unnamed_addr global [300001 x i32], align 16
@_ZZ5solveiE3seq = external hidden global [300001 x %struct.Event], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvei(i32 noundef %0) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"class.std::function", align 8
  %5 = alloca %class.anon, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %.not57 = icmp slt i32 %0, 1
  br i1 %.not57, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %1
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.049.lcssa = phi i32 [ 0, %1 ], [ %0, %.lr.ph ]
  call void @_ZN9FastInput4readERi(ptr noundef nonnull align 8 dereferenceable(25) @in, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = add nsw i32 %6, -1
  store i32 %7, ptr %3, align 4, !tbaa !5
  %.not5462 = icmp eq i32 %6, 0
  br i1 %.not5462, label %._crit_edge67, label %.lr.ph66

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv78 = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next79, %.lr.ph ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %8 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solveiE1a, i64 0, i64 %indvars.iv78
  tail call void @_ZN9FastInput4readERi(ptr noundef nonnull align 8 dereferenceable(25) @in, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %indvars.iv
  store i32 1, ptr %10, align 16, !tbaa !5
  %.sroa.421.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 4
  %11 = trunc nuw nsw i64 %indvars.iv78 to i32
  store i32 %11, ptr %.sroa.421.0..sroa_idx, align 4, !tbaa !5
  %.sroa.522.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 8
  store i32 %11, ptr %.sroa.522.0..sroa_idx, align 8, !tbaa !5
  %.sroa.623.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 12
  store i32 %9, ptr %.sroa.623.0..sroa_idx, align 4, !tbaa !5
  %12 = getelementptr inbounds [200001 x i32], ptr @_ZZ5solveiE3que, i64 0, i64 %indvars.iv
  store i32 %9, ptr %12, align 4, !tbaa !5
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

.lr.ph66:                                         ; preds = %._crit_edge, %34
  %.164 = phi i32 [ %.2, %34 ], [ %.049.lcssa, %._crit_edge ]
  %.15063 = phi i32 [ %.251, %34 ], [ %.049.lcssa, %._crit_edge ]
  %13 = add nsw i32 %.15063, 1
  %14 = sext i32 %.15063 to i64
  %15 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %14
  call void @_ZN5Event4readEv(ptr noundef nonnull align 4 dereferenceable(16) %15)
  %16 = load i32, ptr %15, align 16, !tbaa !11
  %17 = icmp eq i32 %16, 2
  br i1 %17, label %34, label %18, !llvm.loop !13

18:                                               ; preds = %.lr.ph66
  %19 = getelementptr inbounds i8, ptr %15, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100001 x i32], ptr @_ZZ5solveiE1a, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %15, i64 12
  %25 = load i32, ptr %24, align 4, !tbaa !15
  %26 = icmp eq i32 %23, %25
  br i1 %26, label %34, label %27, !llvm.loop !13

27:                                               ; preds = %18
  %28 = add nsw i32 %.15063, 2
  %29 = sext i32 %13 to i64
  %30 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %29
  store i32 -1, ptr %30, align 16, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 4
  store i32 %20, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 8
  store i32 %20, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 12
  store i32 %23, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !5
  store i32 %25, ptr %22, align 4, !tbaa !5
  %31 = add nsw i32 %.164, 1
  %32 = sext i32 %.164 to i64
  %33 = getelementptr inbounds [200001 x i32], ptr @_ZZ5solveiE3que, i64 0, i64 %32
  store i32 %25, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %18, %.lr.ph66, %27
  %.251 = phi i32 [ %28, %27 ], [ %13, %.lr.ph66 ], [ %.15063, %18 ]
  %.2 = phi i32 [ %31, %27 ], [ %.164, %.lr.ph66 ], [ %.164, %18 ]
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = add nsw i32 %35, -1
  store i32 %36, ptr %3, align 4, !tbaa !5
  %.not54 = icmp eq i32 %35, 0
  br i1 %.not54, label %._crit_edge67, label %.lr.ph66

._crit_edge67:                                    ; preds = %34, %._crit_edge
  %.150.lcssa = phi i32 [ %.049.lcssa, %._crit_edge ], [ %.251, %34 ]
  %.1.lcssa = phi i32 [ %.049.lcssa, %._crit_edge ], [ %.2, %34 ]
  %37 = sext i32 %.1.lcssa to i64
  %38 = getelementptr inbounds i32, ptr @_ZZ5solveiE3que, i64 %37
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @_ZZ5solveiE3que, ptr noundef nonnull %38)
  %39 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @_ZZ5solveiE3que, ptr noundef nonnull %38)
  %40 = ptrtoint ptr %39 to i64
  %41 = sub i64 %40, ptrtoint (ptr @_ZZ5solveiE3que to i64)
  %42 = lshr exact i64 %41, 2
  %43 = trunc i64 %42 to i32
  %44 = icmp sgt i32 %.150.lcssa, 0
  br i1 %44, label %.lr.ph72, label %._crit_edge73

.lr.ph72:                                         ; preds = %._crit_edge67
  %sext = shl i64 %41, 30
  %45 = ashr i64 %sext, 32
  %46 = getelementptr inbounds i32, ptr @_ZZ5solveiE3que, i64 %45
  %wide.trip.count88 = zext nneg i32 %.150.lcssa to i64
  br label %52

._crit_edge73:                                    ; preds = %62, %._crit_edge67
  %47 = sext i32 %.150.lcssa to i64
  %48 = getelementptr inbounds i32, ptr @_ZZ5solveiE3ord, i64 %47
  call void @_ZSt4iotaIPiiEvT_S1_T0_(ptr noundef nonnull @_ZZ5solveiE3ord, ptr noundef nonnull %48, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  store ptr %2, ptr %5, align 8, !tbaa !16
  %49 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %4, ptr %49, align 8, !tbaa !16
  call void @"_ZNSt8functionIFviiiiEEC2IZ5solveiE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32) %4, ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  %50 = add nsw i32 %.150.lcssa, -1
  %51 = add nsw i32 %43, -1
  invoke void @_ZNKSt8functionIFviiiiEEclEiiii(ptr noundef nonnull align 8 dereferenceable(32) %4, i32 noundef 0, i32 noundef %50, i32 noundef 0, i32 noundef %51)
          to label %.preheader unwind label %63

.preheader:                                       ; preds = %._crit_edge73
  br i1 %44, label %.lr.ph75.preheader, label %._crit_edge76

.lr.ph75.preheader:                               ; preds = %.preheader
  %wide.trip.count93 = zext nneg i32 %.150.lcssa to i64
  br label %.lr.ph75

52:                                               ; preds = %.lr.ph72, %62
  %indvars.iv85 = phi i64 [ 0, %.lr.ph72 ], [ %indvars.iv.next86, %62 ]
  %53 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %indvars.iv85
  %54 = load i32, ptr %53, align 16, !tbaa !11
  %.not56 = icmp eq i32 %54, 2
  br i1 %.not56, label %62, label %55

55:                                               ; preds = %52
  %56 = getelementptr inbounds i8, ptr %53, i64 12
  %57 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @_ZZ5solveiE3que, ptr noundef nonnull %46, ptr noundef nonnull align 4 dereferenceable(4) %56)
  %58 = ptrtoint ptr %57 to i64
  %59 = sub i64 %58, ptrtoint (ptr @_ZZ5solveiE3que to i64)
  %60 = lshr exact i64 %59, 2
  %61 = trunc i64 %60 to i32
  store i32 %61, ptr %56, align 4, !tbaa !15
  br label %62

62:                                               ; preds = %55, %52
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %exitcond89.not = icmp eq i64 %indvars.iv.next86, %wide.trip.count88
  br i1 %exitcond89.not, label %._crit_edge73, label %52, !llvm.loop !18

._crit_edge76:                                    ; preds = %74, %.preheader
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret void

63:                                               ; preds = %._crit_edge73
  %64 = landingpad { ptr, i32 }
          cleanup
  br label %75

.lr.ph75:                                         ; preds = %.lr.ph75.preheader, %74
  %indvars.iv90 = phi i64 [ 0, %.lr.ph75.preheader ], [ %indvars.iv.next91, %74 ]
  %65 = getelementptr inbounds [300001 x %struct.Event], ptr @_ZZ5solveiE3seq, i64 0, i64 %indvars.iv90
  %66 = load i32, ptr %65, align 16, !tbaa !11
  %67 = icmp eq i32 %66, 2
  br i1 %67, label %68, label %74

68:                                               ; preds = %.lr.ph75
  %69 = getelementptr inbounds [300001 x i32], ptr @_ZZ5solveiE3ans, i64 0, i64 %indvars.iv90
  %70 = load i32, ptr %69, align 4, !tbaa !5
  invoke void @_ZN10FastOutput5writeEi(ptr noundef nonnull align 8 dereferenceable(24) @out, i32 noundef %70)
          to label %71 unwind label %72

71:                                               ; preds = %68
  invoke void @_ZN10FastOutput9writeCharEc(ptr noundef nonnull align 8 dereferenceable(24) @out, i8 noundef signext 10)
          to label %74 unwind label %72

72:                                               ; preds = %71, %68
  %73 = landingpad { ptr, i32 }
          cleanup
  br label %75

74:                                               ; preds = %.lr.ph75, %71
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %exitcond94.not = icmp eq i64 %indvars.iv.next91, %wide.trip.count93
  br i1 %exitcond94.not, label %._crit_edge76, label %.lr.ph75, !llvm.loop !19

75:                                               ; preds = %72, %63
  %.pn = phi { ptr, i32 } [ %73, %72 ], [ %64, %63 ]
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  resume { ptr, i32 } %.pn
}

; 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 uwtable
declare dso_local void @_ZN9FastInput4readERi(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Event4readEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #0 align 2

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPiiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @"_ZNSt8functionIFviiiiEEC2IZ5solveiE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNKSt8functionIFviiiiEEclEiiii(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10FastOutput5writeEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10FastOutput9writeCharEc(ptr noundef nonnull align 8 dereferenceable(24), i8 noundef signext) local_unnamed_addr #0 align 2

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

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

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

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


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