; LLVM IR from tangjz/acm-icpc :: codeforces/complete (536E)

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

@n = external dso_local global i32, align 4
@lnk = external dso_local global [100001 x i32], align 16
@dep = external dso_local global [100001 x i32], align 16
@fa = external dso_local global [100001 x i32], align 16
@idx = external dso_local global [100001 x i32], align 16
@top = external dso_local global [100001 x i32], align 16
@e = external dso_local global [200003 x %struct.Edge], align 16
@f = external dso_local global [100001 x i32], align 16
@m = external dso_local global i32, align 4
@etot = external dso_local global i32, align 4
@w = external dso_local global [100001 x i32], align 16
@p = external dso_local global [2 x [100001 x i32]], align 16
@eve = external dso_local global [200003 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z10tree_buildi(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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7seg_updiii(i32 noundef, i32 noundef, i32 noundef) #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: mustprogress uwtable
declare dso_local { i64, i32 } @_Z7seg_queiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #5 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %struct.Edge, align 4
  %7 = alloca %struct.Edge, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"struct.std::pair", align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::pair", align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca %struct.Segment, align 4
  %21 = alloca %struct.Segment, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca %struct.Segment, align 4
  %25 = alloca { i64, i32 }, align 8
  %26 = alloca %struct.Segment, align 4
  %27 = alloca { i64, i32 }, align 8
  %28 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #9
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %40, %0
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  br label %43

35:                                               ; preds = %30
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr @f, i64 %37
  %39 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %38)
  br label %40

40:                                               ; preds = %35
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %2, align 4, !tbaa !5
  br label %30, !llvm.loop !9

43:                                               ; preds = %34
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = mul i64 %45, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @lnk, i64 1), i8 -1, i64 %46, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #9
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %92, %43
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  %51 = icmp slt i32 %48, %50
  br i1 %51, label %53, label %52

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

53:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #9
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr @w, i64 %55
  %57 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %4, ptr noundef %5, ptr noundef %56)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #9
  %58 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 0
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  store i32 %62, ptr %58, align 4, !tbaa !11
  %63 = getelementptr inbounds %struct.Edge, ptr %6, i32 0, i32 1
  %64 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %64, ptr %63, align 4, !tbaa !13
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = shl i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [200003 x %struct.Edge], ptr @e, i64 0, i64 %67
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %68, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #9
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = shl i32 %69, 1
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %72
  store i32 %70, ptr %73, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #9
  %74 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 0
  %75 = load i32, ptr %5, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  store i32 %78, ptr %74, align 4, !tbaa !11
  %79 = getelementptr inbounds %struct.Edge, ptr %7, i32 0, i32 1
  %80 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %80, ptr %79, align 4, !tbaa !13
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = shl i32 %81, 1
  %83 = or i32 %82, 1
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [200003 x %struct.Edge], ptr @e, i64 0, i64 %84
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %85, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #9
  %86 = load i32, ptr %3, align 4, !tbaa !5
  %87 = shl i32 %86, 1
  %88 = or i32 %87, 1
  %89 = load i32, ptr %5, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %90
  store i32 %88, ptr %91, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #9
  br label %92

92:                                               ; preds = %53
  %93 = load i32, ptr %3, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %3, align 4, !tbaa !5
  br label %47, !llvm.loop !15

95:                                               ; preds = %52
  call void @_Z10tree_buildi(i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %133, %95
  %97 = load i32, ptr %8, align 4, !tbaa !5
  %98 = load i32, ptr @n, align 4, !tbaa !5
  %99 = sub nsw i32 %98, 1
  %100 = icmp slt i32 %97, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  br label %136

102:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = shl i32 %103, 1
  %105 = or i32 %104, 1
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [200003 x %struct.Edge], ptr @e, i64 0, i64 %106
  %108 = getelementptr inbounds %struct.Edge, ptr %107, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !13
  store i32 %109, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = shl i32 %110, 1
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [200003 x %struct.Edge], ptr @e, i64 0, i64 %112
  %114 = getelementptr inbounds %struct.Edge, ptr %113, i32 0, i32 1
  %115 = load i32, ptr %114, align 4, !tbaa !13
  store i32 %115, ptr %10, align 4, !tbaa !5
  %116 = load i32, ptr %9, align 4, !tbaa !5
  %117 = load i32, ptr %10, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = icmp eq i32 %116, %120
  br i1 %121, label %122, label %123

122:                                              ; preds = %102
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10) #9
  br label %123

123:                                              ; preds = %122, %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [100001 x i32], ptr @w, i64 0, i64 %125
  %127 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %126, ptr noundef nonnull align 4 dereferenceable(4) %9)
  store i64 %127, ptr %11, align 4
  %128 = load i32, ptr @etot, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr @etot, align 4, !tbaa !5
  %130 = sext i32 %128 to i64
  %131 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %130
  %132 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %131, ptr noundef nonnull align 4 dereferenceable(8) %11) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  br label %133

133:                                              ; preds = %123
  %134 = load i32, ptr %8, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %8, align 4, !tbaa !5
  br label %96, !llvm.loop !16

136:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %158, %136
  %138 = load i32, ptr %12, align 4, !tbaa !5
  %139 = load i32, ptr @m, align 4, !tbaa !5
  %140 = icmp sle i32 %138, %139
  br i1 %140, label %142, label %141

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

142:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  %143 = load i32, ptr %12, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds i32, ptr @p, i64 %144
  %146 = load i32, ptr %12, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds i32, ptr getelementptr inbounds ([2 x [100001 x i32]], ptr @p, i64 0, i64 1), i64 %147
  %149 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %145, ptr noundef %148, ptr noundef %13)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  %150 = load i32, ptr %12, align 4, !tbaa !5
  %151 = sub nsw i32 0, %150
  store i32 %151, ptr %15, align 4, !tbaa !5
  %152 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %15)
  store i64 %152, ptr %14, align 4
  %153 = load i32, ptr @etot, align 4, !tbaa !5
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr @etot, align 4, !tbaa !5
  %155 = sext i32 %153 to i64
  %156 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %155
  %157 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %156, ptr noundef nonnull align 4 dereferenceable(8) %14) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  br label %158

158:                                              ; preds = %142
  %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 %137, !llvm.loop !17

161:                                              ; preds = %141
  %162 = load i32, ptr @etot, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds %"struct.std::pair", ptr @eve, i64 %163
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef @eve, ptr noundef %164)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  %165 = load i32, ptr @etot, align 4, !tbaa !5
  %166 = sub nsw i32 %165, 1
  store i32 %166, ptr %16, align 4, !tbaa !5
  br label %167

167:                                              ; preds = %413, %161
  %168 = load i32, ptr %16, align 4, !tbaa !5
  %169 = icmp sge i32 %168, 0
  br i1 %169, label %171, label %170

170:                                              ; preds = %167
  store i32 14, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  br label %416

171:                                              ; preds = %167
  %172 = load i32, ptr %16, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %173
  %175 = getelementptr inbounds %"struct.std::pair", ptr %174, i32 0, i32 1
  %176 = load i32, ptr %175, align 4, !tbaa !18
  %177 = icmp sgt i32 %176, 0
  br i1 %177, label %178, label %188

178:                                              ; preds = %171
  %179 = load i32, ptr @n, align 4, !tbaa !5
  %180 = load i32, ptr %16, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %181
  %183 = getelementptr inbounds %"struct.std::pair", ptr %182, i32 0, i32 1
  %184 = load i32, ptr %183, align 4, !tbaa !18
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  call void @_Z7seg_updiii(i32 noundef 1, i32 noundef %179, i32 noundef %187)
  br label %412

188:                                              ; preds = %171
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #9
  %189 = load i32, ptr %16, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %190
  %192 = getelementptr inbounds %"struct.std::pair", ptr %191, i32 0, i32 1
  %193 = load i32, ptr %192, align 4, !tbaa !18
  %194 = sub nsw i32 0, %193
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %195
  %197 = load i32, ptr %196, align 4, !tbaa !5
  store i32 %197, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #9
  %198 = load i32, ptr %16, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %199
  %201 = getelementptr inbounds %"struct.std::pair", ptr %200, i32 0, i32 1
  %202 = load i32, ptr %201, align 4, !tbaa !18
  %203 = sub nsw i32 0, %202
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds ([2 x [100001 x i32]], ptr @p, i64 0, i64 1), i64 0, i64 %204
  %206 = load i32, ptr %205, align 4, !tbaa !5
  store i32 %206, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %20) #9
  call void @llvm.memset.p0.i64(ptr align 4 %20, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %21) #9
  call void @llvm.memset.p0.i64(ptr align 4 %21, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #9
  %207 = load i32, ptr %18, align 4, !tbaa !5
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [100001 x i32], ptr @top, i64 0, i64 %208
  %210 = load i32, ptr %209, align 4, !tbaa !5
  store i32 %210, ptr %22, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #9
  %211 = load i32, ptr %19, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [100001 x i32], ptr @top, i64 0, i64 %212
  %214 = load i32, ptr %213, align 4, !tbaa !5
  store i32 %214, ptr %23, align 4, !tbaa !5
  br label %215

215:                                              ; preds = %292, %188
  %216 = load i32, ptr %22, align 4, !tbaa !5
  %217 = load i32, ptr %23, align 4, !tbaa !5
  %218 = icmp ne i32 %216, %217
  br i1 %218, label %220, label %219

219:                                              ; preds = %215
  store i32 17, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #9
  br label %301

220:                                              ; preds = %215
  %221 = load i32, ptr %22, align 4, !tbaa !5
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds [100001 x i32], ptr @dep, i64 0, i64 %222
  %224 = load i32, ptr %223, align 4, !tbaa !5
  %225 = load i32, ptr %23, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [100001 x i32], ptr @dep, i64 0, i64 %226
  %228 = load i32, ptr %227, align 4, !tbaa !5
  %229 = icmp slt i32 %224, %228
  br i1 %229, label %230, label %231

230:                                              ; preds = %220
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %19) #9
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %22, ptr noundef nonnull align 4 dereferenceable(4) %23) #9
  call void @_ZSt4swapI7SegmentENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull align 4 dereferenceable(12) %21) #9
  br label %231

231:                                              ; preds = %230, %220
  call void @llvm.lifetime.start.p0(i64 12, ptr %24) #9
  %232 = load i32, ptr @n, align 4, !tbaa !5
  %233 = load i32, ptr %22, align 4, !tbaa !5
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %234
  %236 = load i32, ptr %235, align 4, !tbaa !5
  %237 = load i32, ptr %18, align 4, !tbaa !5
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %238
  %240 = load i32, ptr %239, align 4, !tbaa !5
  %241 = call { i64, i32 } @_Z7seg_queiiii(i32 noundef 1, i32 noundef %232, i32 noundef %236, i32 noundef %240)
  store { i64, i32 } %241, ptr %25, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 8 %25, i64 12, i1 false)
  %242 = getelementptr inbounds %struct.Segment, ptr %24, i32 0, i32 0
  %243 = load i32, ptr %242, align 4, !tbaa !20
  %244 = getelementptr inbounds %struct.Segment, ptr %24, i32 0, i32 2
  %245 = load i32, ptr %244, align 4, !tbaa !22
  %246 = sext i32 %245 to i64
  %247 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %246
  %248 = load i32, ptr %247, align 4, !tbaa !5
  %249 = sub nsw i32 %243, %248
  %250 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 0
  %251 = load i32, ptr %250, align 4, !tbaa !20
  %252 = add nsw i32 %249, %251
  %253 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  %254 = load i32, ptr %253, align 4, !tbaa !23
  %255 = sext i32 %254 to i64
  %256 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %255
  %257 = load i32, ptr %256, align 4, !tbaa !5
  %258 = sub nsw i32 %252, %257
  %259 = getelementptr inbounds %struct.Segment, ptr %24, i32 0, i32 2
  %260 = load i32, ptr %259, align 4, !tbaa !22
  %261 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  %262 = load i32, ptr %261, align 4, !tbaa !23
  %263 = add nsw i32 %260, %262
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %264
  %266 = load i32, ptr %265, align 4, !tbaa !5
  %267 = add nsw i32 %258, %266
  %268 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 0
  store i32 %267, ptr %268, align 4, !tbaa !20
  %269 = getelementptr inbounds %struct.Segment, ptr %24, i32 0, i32 1
  %270 = load i32, ptr %269, align 4, !tbaa !23
  %271 = getelementptr inbounds %struct.Segment, ptr %24, i32 0, i32 1
  %272 = load i32, ptr %271, align 4, !tbaa !23
  %273 = load i32, ptr %18, align 4, !tbaa !5
  %274 = sext i32 %273 to i64
  %275 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %274
  %276 = load i32, ptr %275, align 4, !tbaa !5
  %277 = load i32, ptr %22, align 4, !tbaa !5
  %278 = sext i32 %277 to i64
  %279 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %278
  %280 = load i32, ptr %279, align 4, !tbaa !5
  %281 = sub nsw i32 %276, %280
  %282 = add nsw i32 %281, 1
  %283 = icmp eq i32 %272, %282
  br i1 %283, label %284, label %287

284:                                              ; preds = %231
  %285 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  %286 = load i32, ptr %285, align 4, !tbaa !23
  br label %288

287:                                              ; preds = %231
  br label %288

288:                                              ; preds = %287, %284
  %289 = phi i32 [ %286, %284 ], [ 0, %287 ]
  %290 = add nsw i32 %270, %289
  %291 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  store i32 %290, ptr %291, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 12, ptr %24) #9
  br label %292

292:                                              ; preds = %288
  %293 = load i32, ptr %22, align 4, !tbaa !5
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %294
  %296 = load i32, ptr %295, align 4, !tbaa !5
  store i32 %296, ptr %18, align 4, !tbaa !5
  %297 = load i32, ptr %18, align 4, !tbaa !5
  %298 = sext i32 %297 to i64
  %299 = getelementptr inbounds [100001 x i32], ptr @top, i64 0, i64 %298
  %300 = load i32, ptr %299, align 4, !tbaa !5
  store i32 %300, ptr %22, align 4, !tbaa !5
  br label %215, !llvm.loop !24

301:                                              ; preds = %219
  %302 = load i32, ptr %18, align 4, !tbaa !5
  %303 = load i32, ptr %19, align 4, !tbaa !5
  %304 = icmp ne i32 %302, %303
  br i1 %304, label %305, label %377

305:                                              ; preds = %301
  %306 = load i32, ptr %18, align 4, !tbaa !5
  %307 = sext i32 %306 to i64
  %308 = getelementptr inbounds [100001 x i32], ptr @dep, i64 0, i64 %307
  %309 = load i32, ptr %308, align 4, !tbaa !5
  %310 = load i32, ptr %19, align 4, !tbaa !5
  %311 = sext i32 %310 to i64
  %312 = getelementptr inbounds [100001 x i32], ptr @dep, i64 0, i64 %311
  %313 = load i32, ptr %312, align 4, !tbaa !5
  %314 = icmp slt i32 %309, %313
  br i1 %314, label %315, label %316

315:                                              ; preds = %305
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %19) #9
  call void @_ZSt4swapI7SegmentENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull align 4 dereferenceable(12) %21) #9
  br label %316

316:                                              ; preds = %315, %305
  call void @llvm.lifetime.start.p0(i64 12, ptr %26) #9
  %317 = load i32, ptr @n, align 4, !tbaa !5
  %318 = load i32, ptr %19, align 4, !tbaa !5
  %319 = sext i32 %318 to i64
  %320 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %319
  %321 = load i32, ptr %320, align 4, !tbaa !5
  %322 = add nsw i32 %321, 1
  %323 = load i32, ptr %18, align 4, !tbaa !5
  %324 = sext i32 %323 to i64
  %325 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %324
  %326 = load i32, ptr %325, align 4, !tbaa !5
  %327 = call { i64, i32 } @_Z7seg_queiiii(i32 noundef 1, i32 noundef %317, i32 noundef %322, i32 noundef %326)
  store { i64, i32 } %327, ptr %27, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 8 %27, i64 12, i1 false)
  %328 = getelementptr inbounds %struct.Segment, ptr %26, i32 0, i32 0
  %329 = load i32, ptr %328, align 4, !tbaa !20
  %330 = getelementptr inbounds %struct.Segment, ptr %26, i32 0, i32 2
  %331 = load i32, ptr %330, align 4, !tbaa !22
  %332 = sext i32 %331 to i64
  %333 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %332
  %334 = load i32, ptr %333, align 4, !tbaa !5
  %335 = sub nsw i32 %329, %334
  %336 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 0
  %337 = load i32, ptr %336, align 4, !tbaa !20
  %338 = add nsw i32 %335, %337
  %339 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  %340 = load i32, ptr %339, align 4, !tbaa !23
  %341 = sext i32 %340 to i64
  %342 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %341
  %343 = load i32, ptr %342, align 4, !tbaa !5
  %344 = sub nsw i32 %338, %343
  %345 = getelementptr inbounds %struct.Segment, ptr %26, i32 0, i32 2
  %346 = load i32, ptr %345, align 4, !tbaa !22
  %347 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  %348 = load i32, ptr %347, align 4, !tbaa !23
  %349 = add nsw i32 %346, %348
  %350 = sext i32 %349 to i64
  %351 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %350
  %352 = load i32, ptr %351, align 4, !tbaa !5
  %353 = add nsw i32 %344, %352
  %354 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 0
  store i32 %353, ptr %354, align 4, !tbaa !20
  %355 = getelementptr inbounds %struct.Segment, ptr %26, i32 0, i32 1
  %356 = load i32, ptr %355, align 4, !tbaa !23
  %357 = getelementptr inbounds %struct.Segment, ptr %26, i32 0, i32 1
  %358 = load i32, ptr %357, align 4, !tbaa !23
  %359 = load i32, ptr %18, align 4, !tbaa !5
  %360 = sext i32 %359 to i64
  %361 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %360
  %362 = load i32, ptr %361, align 4, !tbaa !5
  %363 = load i32, ptr %19, align 4, !tbaa !5
  %364 = sext i32 %363 to i64
  %365 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %364
  %366 = load i32, ptr %365, align 4, !tbaa !5
  %367 = sub nsw i32 %362, %366
  %368 = icmp eq i32 %358, %367
  br i1 %368, label %369, label %372

369:                                              ; preds = %316
  %370 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  %371 = load i32, ptr %370, align 4, !tbaa !23
  br label %373

372:                                              ; preds = %316
  br label %373

373:                                              ; preds = %372, %369
  %374 = phi i32 [ %371, %369 ], [ 0, %372 ]
  %375 = add nsw i32 %356, %374
  %376 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  store i32 %375, ptr %376, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 12, ptr %26) #9
  br label %377

377:                                              ; preds = %373, %301
  %378 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 0
  %379 = load i32, ptr %378, align 4, !tbaa !20
  %380 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  %381 = load i32, ptr %380, align 4, !tbaa !23
  %382 = sext i32 %381 to i64
  %383 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %382
  %384 = load i32, ptr %383, align 4, !tbaa !5
  %385 = sub nsw i32 %379, %384
  %386 = getelementptr inbounds %struct.Segment, ptr %21, i32 0, i32 0
  %387 = load i32, ptr %386, align 4, !tbaa !20
  %388 = add nsw i32 %385, %387
  %389 = getelementptr inbounds %struct.Segment, ptr %21, i32 0, i32 1
  %390 = load i32, ptr %389, align 4, !tbaa !23
  %391 = sext i32 %390 to i64
  %392 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %391
  %393 = load i32, ptr %392, align 4, !tbaa !5
  %394 = sub nsw i32 %388, %393
  %395 = getelementptr inbounds %struct.Segment, ptr %20, i32 0, i32 1
  %396 = load i32, ptr %395, align 4, !tbaa !23
  %397 = getelementptr inbounds %struct.Segment, ptr %21, i32 0, i32 1
  %398 = load i32, ptr %397, align 4, !tbaa !23
  %399 = add nsw i32 %396, %398
  %400 = sext i32 %399 to i64
  %401 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %400
  %402 = load i32, ptr %401, align 4, !tbaa !5
  %403 = add nsw i32 %394, %402
  %404 = load i32, ptr %16, align 4, !tbaa !5
  %405 = sext i32 %404 to i64
  %406 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %405
  %407 = getelementptr inbounds %"struct.std::pair", ptr %406, i32 0, i32 1
  %408 = load i32, ptr %407, align 4, !tbaa !18
  %409 = sub nsw i32 0, %408
  %410 = sext i32 %409 to i64
  %411 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %410
  store i32 %403, ptr %411, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %21) #9
  call void @llvm.lifetime.end.p0(i64 12, ptr %20) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  br label %412

412:                                              ; preds = %377, %178
  br label %413

413:                                              ; preds = %412
  %414 = load i32, ptr %16, align 4, !tbaa !5
  %415 = add nsw i32 %414, -1
  store i32 %415, ptr %16, align 4, !tbaa !5
  br label %167, !llvm.loop !25

416:                                              ; preds = %170
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #9
  store i32 1, ptr %28, align 4, !tbaa !5
  br label %417

417:                                              ; preds = %428, %416
  %418 = load i32, ptr %28, align 4, !tbaa !5
  %419 = load i32, ptr @m, align 4, !tbaa !5
  %420 = icmp sle i32 %418, %419
  br i1 %420, label %422, label %421

421:                                              ; preds = %417
  store i32 20, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #9
  br label %431

422:                                              ; preds = %417
  %423 = load i32, ptr %28, align 4, !tbaa !5
  %424 = sext i32 %423 to i64
  %425 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %424
  %426 = load i32, ptr %425, align 4, !tbaa !5
  %427 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %426)
  br label %428

428:                                              ; preds = %422
  %429 = load i32, ptr %28, align 4, !tbaa !5
  %430 = add nsw i32 %429, 1
  store i32 %430, ptr %28, align 4, !tbaa !5
  br label %417, !llvm.loop !26

431:                                              ; preds = %421
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #7

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapI7SegmentENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #7

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

@n = external dso_local global i32, align 4
@lnk = external dso_local local_unnamed_addr global [100001 x i32], align 16
@dep = external dso_local local_unnamed_addr global [100001 x i32], align 16
@fa = external dso_local local_unnamed_addr global [100001 x i32], align 16
@idx = external dso_local local_unnamed_addr global [100001 x i32], align 16
@top = external dso_local local_unnamed_addr global [100001 x i32], align 16
@e = external dso_local local_unnamed_addr global [200003 x %struct.Edge], align 16
@f = external dso_local global [100001 x i32], align 16
@m = external dso_local global i32, align 4
@etot = external dso_local local_unnamed_addr global i32, align 4
@w = external dso_local global [100001 x i32], align 16
@p = external dso_local global [2 x [100001 x i32]], align 16
@eve = external dso_local global [200003 x %"struct.std::pair"], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_Z7seg_queiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

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

._crit_edge.thread:                               ; preds = %0
  %.pre122 = sext i32 %16 to i64
  %18 = shl nsw i64 %.pre122, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @lnk, i64 4), i8 -1, i64 %18, i1 false)
  br label %._crit_edge76

._crit_edge:                                      ; preds = %.lr.ph
  %19 = icmp sgt i32 %23, 1
  %20 = shl nsw i64 %24, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @lnk, i64 4), i8 -1, i64 %20, i1 false)
  br i1 %19, label %.lr.ph75, label %._crit_edge76

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %21 = getelementptr inbounds i32, ptr @f, i64 %indvars.iv
  %22 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %21)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge76:                                    ; preds = %.lr.ph75, %._crit_edge.thread, %._crit_edge
  call void @_Z10tree_buildi(i32 noundef 1)
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = icmp sgt i32 %26, 1
  br i1 %27, label %.lr.ph79, label %.preheader71

.lr.ph75:                                         ; preds = %._crit_edge, %.lr.ph75
  %indvars.iv98 = phi i64 [ %indvars.iv.next99, %.lr.ph75 ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  %28 = getelementptr inbounds i32, ptr @w, i64 %indvars.iv98
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %28)
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = shl nuw i64 %indvars.iv98, 1
  %36 = trunc nuw i64 %35 to i32
  %sext = shl i64 %indvars.iv98, 33
  %37 = ashr exact i64 %sext, 32
  %38 = getelementptr inbounds [200003 x %struct.Edge], ptr @e, i64 0, i64 %37
  store i32 %33, ptr %38, align 16, !tbaa !5
  %.sroa.437.0..sroa_idx = getelementptr inbounds i8, ptr %38, i64 4
  store i32 %34, ptr %.sroa.437.0..sroa_idx, align 4, !tbaa !5
  store i32 %36, ptr %32, align 4, !tbaa !5
  %39 = sext i32 %34 to i64
  %40 = getelementptr inbounds [100001 x i32], ptr @lnk, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = trunc i64 %35 to i32
  %43 = or disjoint i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [200003 x %struct.Edge], ptr @e, i64 0, i64 %44
  store i32 %41, ptr %45, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %45, i64 4
  store i32 %30, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  store i32 %43, ptr %40, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %47 = add nsw i32 %46, -1
  %48 = sext i32 %47 to i64
  %49 = icmp slt i64 %indvars.iv.next99, %48
  br i1 %49, label %.lr.ph75, label %._crit_edge76, !llvm.loop !11

.preheader71:                                     ; preds = %64, %._crit_edge76
  %50 = load i32, ptr @m, align 4, !tbaa !5
  %.not80 = icmp slt i32 %50, 1
  br i1 %.not80, label %._crit_edge83, label %.lr.ph82

.lr.ph79:                                         ; preds = %._crit_edge76, %64
  %indvars.iv101 = phi i64 [ %indvars.iv.next102, %64 ], [ 0, %._crit_edge76 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  %51 = shl i64 %indvars.iv101, 33
  %sext124 = ashr exact i64 %51, 32
  %52 = or disjoint i64 %sext124, 1
  %53 = getelementptr inbounds [200003 x %struct.Edge], ptr @e, i64 0, i64 %52, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !12
  store i32 %54, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  %indvars.iv101.tr = trunc i64 %indvars.iv101 to i32
  %55 = shl i32 %indvars.iv101.tr, 1
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [200003 x %struct.Edge], ptr @e, i64 0, i64 %56, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !12
  store i32 %58, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = icmp eq i32 %54, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %.lr.ph79
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) #8
  br label %64

64:                                               ; preds = %63, %.lr.ph79
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  %65 = getelementptr inbounds [100001 x i32], ptr @w, i64 0, i64 %indvars.iv101
  %66 = call i64 @_ZSt9make_pairIRiS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %65, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store i64 %66, ptr %5, align 8
  %67 = load i32, ptr @etot, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr @etot, align 4, !tbaa !5
  %69 = sext i32 %67 to i64
  %70 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %69
  %71 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %70, ptr noundef nonnull align 4 dereferenceable(8) %5) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %72 = load i32, ptr @n, align 4, !tbaa !5
  %73 = add nsw i32 %72, -1
  %74 = sext i32 %73 to i64
  %75 = icmp slt i64 %indvars.iv.next102, %74
  br i1 %75, label %.lr.ph79, label %.preheader71, !llvm.loop !14

._crit_edge83:                                    ; preds = %.lr.ph82, %.preheader71
  %76 = load i32, ptr @etot, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %"struct.std::pair", ptr @eve, i64 %77
  call void @_ZSt4sortIPSt4pairIiiEEvT_S3_(ptr noundef nonnull @eve, ptr noundef nonnull %78)
  %79 = load i32, ptr @etot, align 4, !tbaa !5
  %80 = icmp sgt i32 %79, 0
  br i1 %80, label %.lr.ph91, label %.preheader

.lr.ph91:                                         ; preds = %._crit_edge83
  %81 = getelementptr inbounds i8, ptr %11, i64 4
  %82 = getelementptr inbounds i8, ptr %12, i64 4
  %83 = zext nneg i32 %79 to i64
  br label %98

.lr.ph82:                                         ; preds = %.preheader71, %.lr.ph82
  %indvars.iv104 = phi i64 [ %indvars.iv.next105, %.lr.ph82 ], [ 1, %.preheader71 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  %84 = getelementptr inbounds i32, ptr @p, i64 %indvars.iv104
  %85 = getelementptr inbounds i32, ptr getelementptr inbounds (i8, ptr @p, i64 400004), i64 %indvars.iv104
  %86 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %84, ptr noundef nonnull %85, ptr noundef nonnull %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #8
  %87 = trunc i64 %indvars.iv104 to i32
  %88 = sub i32 0, %87
  store i32 %88, ptr %8, align 4, !tbaa !5
  %89 = call i64 @_ZSt9make_pairIRiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %8)
  store i64 %89, ptr %7, align 8
  %90 = load i32, ptr @etot, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr @etot, align 4, !tbaa !5
  %92 = sext i32 %90 to i64
  %93 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %92
  %94 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %93, ptr noundef nonnull align 4 dereferenceable(8) %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #8
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, 1
  %95 = load i32, ptr @m, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %.not.not = icmp slt i64 %indvars.iv104, %96
  br i1 %.not.not, label %.lr.ph82, label %._crit_edge83, !llvm.loop !15

.preheader:                                       ; preds = %247, %._crit_edge83
  %97 = load i32, ptr @m, align 4, !tbaa !5
  %.not5992 = icmp slt i32 %97, 1
  br i1 %.not5992, label %._crit_edge95, label %.lr.ph94

98:                                               ; preds = %.lr.ph91, %247
  %indvars.iv107 = phi i64 [ %83, %.lr.ph91 ], [ %indvars.iv.next108, %247 ]
  %indvars.iv.next108 = add nsw i64 %indvars.iv107, -1
  %99 = getelementptr inbounds [200003 x %"struct.std::pair"], ptr @eve, i64 0, i64 %indvars.iv.next108, i32 1
  %100 = load i32, ptr %99, align 4, !tbaa !16
  %101 = icmp sgt i32 %100, 0
  br i1 %101, label %102, label %107

102:                                              ; preds = %98
  %103 = load i32, ptr @n, align 4, !tbaa !5
  %104 = zext nneg i32 %100 to i64
  %105 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  call void @_Z7seg_updiii(i32 noundef 1, i32 noundef %103, i32 noundef %106)
  br label %247

107:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #8
  %108 = sub nsw i32 0, %100
  %109 = zext nneg i32 %108 to i64
  %110 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  store i32 %111, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #8
  %112 = getelementptr inbounds [100001 x i32], ptr getelementptr inbounds (i8, ptr @p, i64 400004), i64 0, i64 %109
  %113 = load i32, ptr %112, align 4, !tbaa !5
  store i32 %113, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %11, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %12) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %12, i8 0, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #8
  %114 = sext i32 %111 to i64
  %115 = getelementptr inbounds [100001 x i32], ptr @top, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  store i32 %116, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #8
  %117 = sext i32 %113 to i64
  %118 = getelementptr inbounds [100001 x i32], ptr @top, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  store i32 %119, ptr %14, align 4, !tbaa !5
  %.not6084 = icmp eq i32 %116, %119
  br i1 %.not6084, label %._crit_edge87, label %.lr.ph86

._crit_edge87.loopexit:                           ; preds = %135
  %.pre114 = load i32, ptr %10, align 4, !tbaa !5
  br label %._crit_edge87

._crit_edge87:                                    ; preds = %._crit_edge87.loopexit, %107
  %120 = phi i32 [ %172, %._crit_edge87.loopexit ], [ 0, %107 ]
  %121 = phi i32 [ %159, %._crit_edge87.loopexit ], [ 0, %107 ]
  %122 = phi i32 [ %.pre114, %._crit_edge87.loopexit ], [ %113, %107 ]
  %123 = phi i32 [ %174, %._crit_edge87.loopexit ], [ %111, %107 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #8
  %.not61 = icmp eq i32 %123, %122
  br i1 %.not61, label %224, label %179

.lr.ph86:                                         ; preds = %107, %135
  %124 = phi i32 [ %174, %135 ], [ %111, %107 ]
  %125 = phi i32 [ %178, %135 ], [ %119, %107 ]
  %126 = phi i32 [ %177, %135 ], [ %116, %107 ]
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [100001 x i32], ptr @dep, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = sext i32 %125 to i64
  %131 = getelementptr inbounds [100001 x i32], ptr @dep, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = icmp slt i32 %129, %132
  br i1 %133, label %134, label %135

134:                                              ; preds = %.lr.ph86
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10) #8
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %14) #8
  call void @_ZSt4swapI7SegmentENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 4 dereferenceable(12) %12) #8
  %.pre = load i32, ptr %13, align 4, !tbaa !5
  %.pre113 = load i32, ptr %9, align 4, !tbaa !5
  %.pre117 = sext i32 %.pre to i64
  br label %135

135:                                              ; preds = %134, %.lr.ph86
  %.pre-phi = phi i64 [ %.pre117, %134 ], [ %127, %.lr.ph86 ]
  %136 = phi i32 [ %.pre113, %134 ], [ %124, %.lr.ph86 ]
  %137 = load i32, ptr @n, align 4, !tbaa !5
  %138 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %.pre-phi
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = sext i32 %136 to i64
  %141 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = call { i64, i32 } @_Z7seg_queiiii(i32 noundef 1, i32 noundef %137, i32 noundef %139, i32 noundef %142)
  %.fca.0.extract8 = extractvalue { i64, i32 } %143, 0
  %.fca.1.extract9 = extractvalue { i64, i32 } %143, 1
  %.sroa.012.0.extract.trunc = trunc i64 %.fca.0.extract8 to i32
  %144 = sext i32 %.fca.1.extract9 to i64
  %145 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = load i32, ptr %11, align 4, !tbaa !18
  %148 = load i32, ptr %81, align 4
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = add nsw i32 %148, %.fca.1.extract9
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = add i32 %147, %.sroa.012.0.extract.trunc
  %157 = add i32 %146, %151
  %158 = sub i32 %156, %157
  %159 = add nsw i32 %158, %155
  store i32 %159, ptr %11, align 4, !tbaa !18
  %.sroa.012.4.extract.shift = lshr i64 %.fca.0.extract8, 32
  %.sroa.012.4.extract.trunc = trunc nuw i64 %.sroa.012.4.extract.shift to i32
  %160 = load i32, ptr %9, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = load i32, ptr %13, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %165
  %167 = load i32, ptr %166, align 4, !tbaa !5
  %168 = add i32 %163, 1
  %169 = sub i32 %168, %167
  %170 = icmp eq i32 %169, %.sroa.012.4.extract.trunc
  %171 = select i1 %170, i32 %148, i32 0
  %172 = add nsw i32 %171, %.sroa.012.4.extract.trunc
  store i32 %172, ptr %81, align 4, !tbaa !20
  %173 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %165
  %174 = load i32, ptr %173, align 4, !tbaa !5
  store i32 %174, ptr %9, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [100001 x i32], ptr @top, i64 0, i64 %175
  %177 = load i32, ptr %176, align 4, !tbaa !5
  store i32 %177, ptr %13, align 4, !tbaa !5
  %178 = load i32, ptr %14, align 4, !tbaa !5
  %.not60 = icmp eq i32 %177, %178
  br i1 %.not60, label %._crit_edge87.loopexit, label %.lr.ph86, !llvm.loop !21

179:                                              ; preds = %._crit_edge87
  %180 = sext i32 %123 to i64
  %181 = getelementptr inbounds [100001 x i32], ptr @dep, i64 0, i64 %180
  %182 = load i32, ptr %181, align 4, !tbaa !5
  %183 = sext i32 %122 to i64
  %184 = getelementptr inbounds [100001 x i32], ptr @dep, i64 0, i64 %183
  %185 = load i32, ptr %184, align 4, !tbaa !5
  %186 = icmp slt i32 %182, %185
  br i1 %186, label %187, label %188

187:                                              ; preds = %179
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10) #8
  call void @_ZSt4swapI7SegmentENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 4 dereferenceable(12) %12) #8
  %.pre115 = load i32, ptr %10, align 4, !tbaa !5
  %.pre116 = load i32, ptr %9, align 4, !tbaa !5
  %.pre118 = sext i32 %.pre115 to i64
  %.pre120 = sext i32 %.pre116 to i64
  br label %188

188:                                              ; preds = %187, %179
  %.pre-phi121 = phi i64 [ %.pre120, %187 ], [ %180, %179 ]
  %.pre-phi119 = phi i64 [ %.pre118, %187 ], [ %183, %179 ]
  %189 = load i32, ptr @n, align 4, !tbaa !5
  %190 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %.pre-phi119
  %191 = load i32, ptr %190, align 4, !tbaa !5
  %192 = add nsw i32 %191, 1
  %193 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %.pre-phi121
  %194 = load i32, ptr %193, align 4, !tbaa !5
  %195 = call { i64, i32 } @_Z7seg_queiiii(i32 noundef 1, i32 noundef %189, i32 noundef %192, i32 noundef %194)
  %.fca.0.extract = extractvalue { i64, i32 } %195, 0
  %.fca.1.extract = extractvalue { i64, i32 } %195, 1
  %.sroa.03.0.extract.trunc = trunc i64 %.fca.0.extract to i32
  %196 = sext i32 %.fca.1.extract to i64
  %197 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %196
  %198 = load i32, ptr %197, align 4, !tbaa !5
  %199 = load i32, ptr %11, align 4, !tbaa !18
  %200 = load i32, ptr %81, align 4
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !5
  %204 = add nsw i32 %200, %.fca.1.extract
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %205
  %207 = load i32, ptr %206, align 4, !tbaa !5
  %208 = add i32 %199, %.sroa.03.0.extract.trunc
  %209 = add i32 %198, %203
  %210 = sub i32 %208, %209
  %211 = add nsw i32 %210, %207
  %.sroa.03.4.extract.shift = lshr i64 %.fca.0.extract, 32
  %.sroa.03.4.extract.trunc = trunc nuw i64 %.sroa.03.4.extract.shift to i32
  %212 = load i32, ptr %9, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %213
  %215 = load i32, ptr %214, align 4, !tbaa !5
  %216 = load i32, ptr %10, align 4, !tbaa !5
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [100001 x i32], ptr @idx, i64 0, i64 %217
  %219 = load i32, ptr %218, align 4, !tbaa !5
  %220 = sub nsw i32 %215, %219
  %221 = icmp eq i32 %220, %.sroa.03.4.extract.trunc
  %222 = select i1 %221, i32 %200, i32 0
  %223 = add nsw i32 %222, %.sroa.03.4.extract.trunc
  br label %224

224:                                              ; preds = %188, %._crit_edge87
  %225 = phi i32 [ %223, %188 ], [ %120, %._crit_edge87 ]
  %226 = phi i32 [ %211, %188 ], [ %121, %._crit_edge87 ]
  %227 = sext i32 %225 to i64
  %228 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %227
  %229 = load i32, ptr %228, align 4, !tbaa !5
  %230 = load i32, ptr %12, align 4, !tbaa !18
  %231 = load i32, ptr %82, align 4, !tbaa !20
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %232
  %234 = load i32, ptr %233, align 4, !tbaa !5
  %235 = add nsw i32 %231, %225
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %236
  %238 = load i32, ptr %237, align 4, !tbaa !5
  %239 = add i32 %226, %230
  %240 = add i32 %229, %234
  %241 = sub i32 %239, %240
  %242 = add nsw i32 %241, %238
  %243 = load i32, ptr %99, align 4, !tbaa !16
  %244 = sub nsw i32 0, %243
  %245 = sext i32 %244 to i64
  %246 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %245
  store i32 %242, ptr %246, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %12) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #8
  br label %247

247:                                              ; preds = %102, %224
  %248 = icmp sgt i64 %indvars.iv107, 1
  br i1 %248, label %98, label %.preheader, !llvm.loop !22

._crit_edge95:                                    ; preds = %.lr.ph94, %.preheader
  ret i32 0

.lr.ph94:                                         ; preds = %.preheader, %.lr.ph94
  %indvars.iv110 = phi i64 [ %indvars.iv.next111, %.lr.ph94 ], [ 1, %.preheader ]
  %249 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %indvars.iv110
  %250 = load i32, ptr %249, align 4, !tbaa !5
  %251 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %250)
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %252 = load i32, ptr @m, align 4, !tbaa !5
  %253 = sext i32 %252 to i64
  %.not59.not = icmp slt i64 %indvars.iv110, %253
  br i1 %.not59.not, label %.lr.ph94, label %._crit_edge95, !llvm.loop !23
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapI7SegmentENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { 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 #8 = { nounwind }

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

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


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