; LLVM IR from tangjz/acm-icpc :: uoj/200.ll (Z6solve3v)

; 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, i32 }
%class.anon.0 = type { i8 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@mod = external dso_local global i32, align 4
@ans = external dso_local global [100001 x i32], align 16
@e = external dso_local global [150001 x %struct.Edge], align 16
@que = external dso_local global [100001 x %struct.Edge], align 16
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 x i8], align 1
@stderr = external global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__._Z6solve3v = external hidden unnamed_addr constant [14 x i8], align 1
@_ZZ6solve3vE3ord = external hidden global [100001 x i32], align 16
@_ZZ6solve3vE4ways = external hidden global [1001 x i32], align 16
@_ZZ6solve3vE3inv = external hidden global [10001 x [1001 x i32]], align 16

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

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

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6solve3v() #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 ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %class.anon.0, align 1
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #8
  store i32 10001, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 1001, ptr %2, align 4, !tbaa !5
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = icmp slt i32 %22, 10001
  br i1 %23, label %24, label %31

24:                                               ; preds = %0
  %25 = load i32, ptr @m, align 4, !tbaa !5
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = add nsw i32 %26, %27
  %29 = sub nsw i32 %28, 1
  %30 = icmp eq i32 %25, %29
  br label %31

31:                                               ; preds = %24, %0
  %32 = phi i1 [ false, %0 ], [ %30, %24 ]
  br i1 %32, label %33, label %34

33:                                               ; preds = %31
  br label %36

34:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 198, ptr noundef @__PRETTY_FUNCTION__._Z6solve3v) #9
  unreachable

35:                                               ; No predecessors!
  br label %36

36:                                               ; preds = %35, %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %103, %36
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = load i32, ptr @m, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #8
  br label %106

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = sdiv i32 %43, 2
  store i32 %44, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = srem i32 %45, 2
  store i32 %46, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [150001 x %struct.Edge], ptr @e, i64 0, i64 %48
  store ptr %49, ptr %6, align 8, !tbaa !9
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %77

52:                                               ; preds = %42
  %53 = load ptr, ptr %6, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.Edge, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 4, !tbaa !11
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  %58 = icmp eq i32 %55, %57
  br i1 %58, label %59, label %71

59:                                               ; preds = %52
  %60 = load ptr, ptr %6, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.Edge, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 4, !tbaa !13
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  %65 = icmp eq i32 %62, %64
  br i1 %65, label %66, label %71

66:                                               ; preds = %59
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.Edge, ptr %67, i32 0, i32 2
  %69 = load i32, ptr %68, align 4, !tbaa !14
  %70 = icmp slt i32 %69, 1001
  br label %71

71:                                               ; preds = %66, %59, %52
  %72 = phi i1 [ false, %59 ], [ false, %52 ], [ %70, %66 ]
  br i1 %72, label %73, label %74

73:                                               ; preds = %71
  br label %76

74:                                               ; preds = %71
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 203, ptr noundef @__PRETTY_FUNCTION__._Z6solve3v) #9
  unreachable

75:                                               ; No predecessors!
  br label %76

76:                                               ; preds = %75, %73
  br label %102

77:                                               ; preds = %42
  %78 = load ptr, ptr %6, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.Edge, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 4, !tbaa !11
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  %83 = icmp eq i32 %80, %82
  br i1 %83, label %84, label %96

84:                                               ; preds = %77
  %85 = load ptr, ptr %6, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.Edge, ptr %85, i32 0, i32 1
  %87 = load i32, ptr %86, align 4, !tbaa !13
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = add nsw i32 %88, 2
  %90 = icmp eq i32 %87, %89
  br i1 %90, label %91, label %96

91:                                               ; preds = %84
  %92 = load ptr, ptr %6, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct.Edge, ptr %92, i32 0, i32 2
  %94 = load i32, ptr %93, align 4, !tbaa !14
  %95 = icmp eq i32 %94, 0
  br label %96

96:                                               ; preds = %91, %84, %77
  %97 = phi i1 [ false, %84 ], [ false, %77 ], [ %95, %91 ]
  br i1 %97, label %98, label %99

98:                                               ; preds = %96
  br label %101

99:                                               ; preds = %96
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 205, ptr noundef @__PRETTY_FUNCTION__._Z6solve3v) #9
  unreachable

100:                                              ; No predecessors!
  br label %101

101:                                              ; preds = %100, %98
  br label %102

102:                                              ; preds = %101, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %3, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %3, align 4, !tbaa !5
  br label %37, !llvm.loop !15

106:                                              ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %138, %106
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = load i32, ptr @q, align 4, !tbaa !5
  %110 = icmp slt i32 %108, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %141

112:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %113 = load i32, ptr %8, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %114
  store ptr %115, ptr %9, align 8, !tbaa !9
  %116 = load ptr, ptr %9, align 8, !tbaa !9
  %117 = getelementptr inbounds %struct.Edge, ptr %116, i32 0, i32 0
  %118 = load i32, ptr %117, align 4, !tbaa !11
  %119 = load ptr, ptr %9, align 8, !tbaa !9
  %120 = getelementptr inbounds %struct.Edge, ptr %119, i32 0, i32 1
  %121 = load i32, ptr %120, align 4, !tbaa !13
  %122 = icmp sle i32 %118, %121
  br i1 %122, label %123, label %128

123:                                              ; preds = %112
  %124 = load ptr, ptr %9, align 8, !tbaa !9
  %125 = getelementptr inbounds %struct.Edge, ptr %124, i32 0, i32 2
  %126 = load i32, ptr %125, align 4, !tbaa !14
  %127 = icmp slt i32 %126, 1001
  br label %128

128:                                              ; preds = %123, %112
  %129 = phi i1 [ false, %112 ], [ %127, %123 ]
  br i1 %129, label %130, label %131

130:                                              ; preds = %128
  br label %133

131:                                              ; preds = %128
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 211, ptr noundef @__PRETTY_FUNCTION__._Z6solve3v) #9
  unreachable

132:                                              ; No predecessors!
  br label %133

133:                                              ; preds = %132, %130
  %134 = load ptr, ptr %9, align 8, !tbaa !9
  %135 = getelementptr inbounds %struct.Edge, ptr %134, i32 0, i32 2
  %136 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %135)
  %137 = load i32, ptr %136, align 4, !tbaa !5
  store i32 %137, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  br label %138

138:                                              ; preds = %133
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %8, align 4, !tbaa !5
  br label %107, !llvm.loop !17

141:                                              ; preds = %111
  %142 = load ptr, ptr @stderr, align 8, !tbaa !9
  %143 = load i32, ptr %7, align 4, !tbaa !5
  %144 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %142, ptr noundef @.str.12, i32 noundef %143) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %145

145:                                              ; preds = %155, %141
  %146 = load i32, ptr %10, align 4, !tbaa !5
  %147 = load i32, ptr @q, align 4, !tbaa !5
  %148 = icmp slt i32 %146, %147
  br i1 %148, label %150, label %149

149:                                              ; preds = %145
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %158

150:                                              ; preds = %145
  %151 = load i32, ptr %10, align 4, !tbaa !5
  %152 = load i32, ptr %10, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve3vE3ord, i64 0, i64 %153
  store i32 %151, ptr %154, align 4, !tbaa !5
  br label %155

155:                                              ; preds = %150
  %156 = load i32, ptr %10, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %10, align 4, !tbaa !5
  br label %145, !llvm.loop !18

158:                                              ; preds = %149
  %159 = load i32, ptr @q, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds i32, ptr @_ZZ6solve3vE3ord, i64 %160
  call void @"_ZSt4sortIPiZ6solve3vE3$_0EvT_S2_T0_"(ptr noundef @_ZZ6solve3vE3ord, ptr noundef %161)
  store i32 1, ptr @_ZZ6solve3vE3inv, align 16, !tbaa !5
  store i32 1, ptr @_ZZ6solve3vE4ways, align 16, !tbaa !5
  %162 = load i32, ptr %7, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = mul i64 %163, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @_ZZ6solve3vE4ways, i64 1), i8 0, i64 %164, i1 false)
  %165 = load i32, ptr %7, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = mul i64 %166, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @_ZZ6solve3vE3inv, i64 1), i8 0, i64 %167, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %168

168:                                              ; preds = %318, %158
  %169 = load i32, ptr %12, align 4, !tbaa !5
  %170 = load i32, ptr @n, align 4, !tbaa !5
  %171 = icmp slt i32 %169, %170
  br i1 %171, label %172, label %176

172:                                              ; preds = %168
  %173 = load i32, ptr %13, align 4, !tbaa !5
  %174 = load i32, ptr @q, align 4, !tbaa !5
  %175 = icmp slt i32 %173, %174
  br label %176

176:                                              ; preds = %172, %168
  %177 = phi i1 [ false, %168 ], [ %175, %172 ]
  br i1 %177, label %179, label %178

178:                                              ; preds = %176
  store i32 11, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %321

179:                                              ; preds = %176
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %180 = load i32, ptr %12, align 4, !tbaa !5
  %181 = shl i32 %180, 1
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [150001 x %struct.Edge], ptr @e, i64 0, i64 %182
  %184 = getelementptr inbounds %struct.Edge, ptr %183, i32 0, i32 2
  %185 = load i32, ptr %184, align 4, !tbaa !14
  store i32 %185, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %186 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %186, ptr %16, align 4, !tbaa !5
  br label %187

187:                                              ; preds = %202, %179
  %188 = load i32, ptr %16, align 4, !tbaa !5
  %189 = load i32, ptr %7, align 4, !tbaa !5
  %190 = icmp sle i32 %188, %189
  br i1 %190, label %192, label %191

191:                                              ; preds = %187
  store i32 14, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  br label %205

192:                                              ; preds = %187
  %193 = load i32, ptr %16, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [1001 x i32], ptr @_ZZ6solve3vE4ways, i64 0, i64 %194
  %196 = load i32, ptr %16, align 4, !tbaa !5
  %197 = load i32, ptr %15, align 4, !tbaa !5
  %198 = sub nsw i32 %196, %197
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [1001 x i32], ptr @_ZZ6solve3vE4ways, i64 0, i64 %199
  %201 = load i32, ptr %200, align 4, !tbaa !5
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %195, i32 noundef %201)
  br label %202

202:                                              ; preds = %192
  %203 = load i32, ptr %16, align 4, !tbaa !5
  %204 = add nsw i32 %203, 1
  store i32 %204, ptr %16, align 4, !tbaa !5
  br label %187, !llvm.loop !19

205:                                              ; preds = %191
  %206 = load i32, ptr %12, align 4, !tbaa !5
  %207 = add nsw i32 %206, 1
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %208
  %210 = getelementptr inbounds [1001 x i32], ptr %209, i64 0, i64 0
  %211 = load i32, ptr %12, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %212
  %214 = getelementptr inbounds [1001 x i32], ptr %213, i64 0, i64 0
  %215 = load i32, ptr %7, align 4, !tbaa !5
  %216 = add nsw i32 %215, 1
  %217 = sext i32 %216 to i64
  %218 = mul i64 %217, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %210, ptr align 4 %214, i64 %218, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %219 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %219, ptr %17, align 4, !tbaa !5
  br label %220

220:                                              ; preds = %244, %205
  %221 = load i32, ptr %17, align 4, !tbaa !5
  %222 = load i32, ptr %7, align 4, !tbaa !5
  %223 = icmp sle i32 %221, %222
  br i1 %223, label %225, label %224

224:                                              ; preds = %220
  store i32 17, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %247

225:                                              ; preds = %220
  %226 = load i32, ptr %12, align 4, !tbaa !5
  %227 = add nsw i32 %226, 1
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %228
  %230 = load i32, ptr %17, align 4, !tbaa !5
  %231 = sext i32 %230 to i64
  %232 = getelementptr inbounds [1001 x i32], ptr %229, i64 0, i64 %231
  %233 = load i32, ptr @mod, align 4, !tbaa !5
  %234 = load i32, ptr %12, align 4, !tbaa !5
  %235 = sext i32 %234 to i64
  %236 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %235
  %237 = load i32, ptr %17, align 4, !tbaa !5
  %238 = load i32, ptr %15, align 4, !tbaa !5
  %239 = sub nsw i32 %237, %238
  %240 = sext i32 %239 to i64
  %241 = getelementptr inbounds [1001 x i32], ptr %236, i64 0, i64 %240
  %242 = load i32, ptr %241, align 4, !tbaa !5
  %243 = sub nsw i32 %233, %242
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %232, i32 noundef %243)
  br label %244

244:                                              ; preds = %225
  %245 = load i32, ptr %17, align 4, !tbaa !5
  %246 = add nsw i32 %245, 1
  store i32 %246, ptr %17, align 4, !tbaa !5
  br label %220, !llvm.loop !20

247:                                              ; preds = %224
  br label %248

248:                                              ; preds = %314, %247
  %249 = load i32, ptr %13, align 4, !tbaa !5
  %250 = load i32, ptr @q, align 4, !tbaa !5
  %251 = icmp slt i32 %249, %250
  br i1 %251, label %252, label %264

252:                                              ; preds = %248
  %253 = load i32, ptr %13, align 4, !tbaa !5
  %254 = sext i32 %253 to i64
  %255 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve3vE3ord, i64 0, i64 %254
  %256 = load i32, ptr %255, align 4, !tbaa !5
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %257
  %259 = getelementptr inbounds %struct.Edge, ptr %258, i32 0, i32 1
  %260 = load i32, ptr %259, align 4, !tbaa !13
  %261 = load i32, ptr %12, align 4, !tbaa !5
  %262 = add nsw i32 %261, 1
  %263 = icmp eq i32 %260, %262
  br label %264

264:                                              ; preds = %252, %248
  %265 = phi i1 [ false, %248 ], [ %263, %252 ]
  br i1 %265, label %266, label %317

266:                                              ; preds = %264
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %267 = load i32, ptr %13, align 4, !tbaa !5
  %268 = sext i32 %267 to i64
  %269 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve3vE3ord, i64 0, i64 %268
  %270 = load i32, ptr %269, align 4, !tbaa !5
  %271 = sext i32 %270 to i64
  %272 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %271
  store i32 0, ptr %272, align 4, !tbaa !5
  store ptr %272, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #8
  %273 = load i32, ptr %13, align 4, !tbaa !5
  %274 = sext i32 %273 to i64
  %275 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve3vE3ord, i64 0, i64 %274
  %276 = load i32, ptr %275, align 4, !tbaa !5
  %277 = sext i32 %276 to i64
  %278 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %277
  %279 = getelementptr inbounds %struct.Edge, ptr %278, i32 0, i32 0
  %280 = load i32, ptr %279, align 4, !tbaa !11
  %281 = sub nsw i32 %280, 1
  %282 = sext i32 %281 to i64
  %283 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %282
  %284 = getelementptr inbounds [1001 x i32], ptr %283, i64 0, i64 0
  store ptr %284, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #8
  store i32 0, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #8
  %285 = load i32, ptr %13, align 4, !tbaa !5
  %286 = sext i32 %285 to i64
  %287 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve3vE3ord, i64 0, i64 %286
  %288 = load i32, ptr %287, align 4, !tbaa !5
  %289 = sext i32 %288 to i64
  %290 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %289
  %291 = getelementptr inbounds %struct.Edge, ptr %290, i32 0, i32 2
  %292 = load i32, ptr %291, align 4, !tbaa !14
  store i32 %292, ptr %21, align 4, !tbaa !5
  br label %293

293:                                              ; preds = %308, %266
  %294 = load i32, ptr %21, align 4, !tbaa !5
  %295 = icmp sge i32 %294, 0
  br i1 %295, label %297, label %296

296:                                              ; preds = %293
  store i32 23, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #8
  br label %313

297:                                              ; preds = %293
  %298 = load ptr, ptr %18, align 8, !tbaa !9
  %299 = load i32, ptr %20, align 4, !tbaa !5
  %300 = sext i32 %299 to i64
  %301 = getelementptr inbounds [1001 x i32], ptr @_ZZ6solve3vE4ways, i64 0, i64 %300
  %302 = load i32, ptr %301, align 4, !tbaa !5
  %303 = load ptr, ptr %19, align 8, !tbaa !9
  %304 = load i32, ptr %21, align 4, !tbaa !5
  %305 = sext i32 %304 to i64
  %306 = getelementptr inbounds i32, ptr %303, i64 %305
  %307 = load i32, ptr %306, align 4, !tbaa !5
  call void @_Z11mod_inc_mulRiii(ptr noundef nonnull align 4 dereferenceable(4) %298, i32 noundef %302, i32 noundef %307)
  br label %308

308:                                              ; preds = %297
  %309 = load i32, ptr %20, align 4, !tbaa !5
  %310 = add nsw i32 %309, 1
  store i32 %310, ptr %20, align 4, !tbaa !5
  %311 = load i32, ptr %21, align 4, !tbaa !5
  %312 = add nsw i32 %311, -1
  store i32 %312, ptr %21, align 4, !tbaa !5
  br label %293, !llvm.loop !21

313:                                              ; preds = %296
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  br label %314

314:                                              ; preds = %313
  %315 = load i32, ptr %13, align 4, !tbaa !5
  %316 = add nsw i32 %315, 1
  store i32 %316, ptr %13, align 4, !tbaa !5
  br label %248, !llvm.loop !22

317:                                              ; preds = %264
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %318

318:                                              ; preds = %317
  %319 = load i32, ptr %12, align 4, !tbaa !5
  %320 = add nsw i32 %319, 1
  store i32 %320, ptr %12, align 4, !tbaa !5
  br label %168, !llvm.loop !23

321:                                              ; preds = %178
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #8
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPiZ6solve3vE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) #6

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

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

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

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

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

@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@q = external dso_local local_unnamed_addr global i32, align 4
@mod = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local global [100001 x i32], align 16
@e = external dso_local local_unnamed_addr global [150001 x %struct.Edge], align 16
@que = external dso_local global [100001 x %struct.Edge], align 16
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__._Z6solve3v = external hidden unnamed_addr constant [14 x i8], align 1
@_ZZ6solve3vE3ord = external hidden global [100001 x i32], align 16
@_ZZ6solve3vE4ways = external hidden global [1001 x i32], align 16
@_ZZ6solve3vE3inv = external hidden global [10001 x [1001 x i32]], align 16

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6solve3v() local_unnamed_addr #5 {
  %1 = alloca i32, align 4
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp slt i32 %2, 10001
  br i1 %3, label %4, label %.critedge

4:                                                ; preds = %0
  %5 = load i32, ptr @m, align 4, !tbaa !5
  %6 = shl nsw i32 %2, 1
  %7 = add nsw i32 %6, -1
  %8 = icmp eq i32 %5, %7
  br i1 %8, label %.preheader82, label %.critedge

.preheader82:                                     ; preds = %4
  %9 = icmp sgt i32 %5, 0
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

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

.critedge:                                        ; preds = %0, %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 198, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6solve3v) #8
  unreachable

._crit_edge:                                      ; preds = %39, %.preheader82
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #9
  store i32 0, ptr %1, align 4, !tbaa !5
  %10 = load i32, ptr @q, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph87, label %._crit_edge88

.lr.ph:                                           ; preds = %.lr.ph.preheader, %39
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %39 ]
  %12 = trunc nuw nsw i64 %indvars.iv to i32
  %13 = lshr i32 %12, 1
  %14 = and i32 %12, 1
  %15 = getelementptr inbounds [150001 x %struct.Edge], ptr @e, i64 0, i64 %indvars.iv
  %16 = icmp eq i32 %14, 0
  %17 = load i32, ptr %15, align 4, !tbaa !9
  %18 = add nuw nsw i32 %13, 1
  %19 = icmp eq i32 %17, %18
  br i1 %16, label %20, label %29

20:                                               ; preds = %.lr.ph
  br i1 %19, label %21, label %.critedge2

21:                                               ; preds = %20
  %22 = getelementptr inbounds i8, ptr %15, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = icmp eq i32 %23, %18
  br i1 %24, label %25, label %.critedge2

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %15, i64 8
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = icmp slt i32 %27, 1001
  br i1 %28, label %39, label %.critedge2

.critedge2:                                       ; preds = %21, %20, %25
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 203, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6solve3v) #8
  unreachable

29:                                               ; preds = %.lr.ph
  br i1 %19, label %30, label %.critedge4

30:                                               ; preds = %29
  %31 = getelementptr inbounds i8, ptr %15, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = add nuw nsw i32 %13, 2
  %34 = icmp eq i32 %32, %33
  br i1 %34, label %35, label %.critedge4

35:                                               ; preds = %30
  %36 = getelementptr inbounds i8, ptr %15, i64 8
  %37 = load i32, ptr %36, align 4, !tbaa !12
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %.critedge4

.critedge4:                                       ; preds = %30, %29, %35
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 205, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6solve3v) #8
  unreachable

39:                                               ; preds = %35, %25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge88:                                    ; preds = %56, %._crit_edge
  %40 = phi i32 [ 0, %._crit_edge ], [ %58, %56 ]
  %41 = load ptr, ptr @stderr, align 8, !tbaa !15
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef nonnull @.str.12, i32 noundef %40) #10
  %43 = load i32, ptr @q, align 4, !tbaa !5
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %.lr.ph91.preheader, label %._crit_edge92

.lr.ph91.preheader:                               ; preds = %._crit_edge88
  %wide.trip.count126 = zext nneg i32 %43 to i64
  %min.iters.check = icmp ult i32 %43, 8
  br i1 %min.iters.check, label %.lr.ph91.preheader153, label %vector.ph

.lr.ph91.preheader153:                            ; preds = %middle.block, %.lr.ph91.preheader
  %indvars.iv123.ph = phi i64 [ 0, %.lr.ph91.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph91

vector.ph:                                        ; preds = %.lr.ph91.preheader
  %n.vec = and i64 %wide.trip.count126, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %45 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve3vE3ord, i64 0, i64 %index
  %46 = getelementptr inbounds i8, ptr %45, i64 16
  store <4 x i32> %vec.ind, ptr %45, align 16, !tbaa !5
  store <4 x i32> %step.add, ptr %46, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %47 = icmp eq i64 %index.next, %n.vec
  br i1 %47, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count126
  br i1 %cmp.n, label %._crit_edge92, label %.lr.ph91.preheader153

.lr.ph87:                                         ; preds = %._crit_edge, %56
  %indvars.iv120 = phi i64 [ %indvars.iv.next121, %56 ], [ 0, %._crit_edge ]
  %48 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %indvars.iv120
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = getelementptr inbounds i8, ptr %48, i64 4
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %.not81 = icmp sgt i32 %49, %51
  br i1 %.not81, label %.critedge6, label %52

52:                                               ; preds = %.lr.ph87
  %53 = getelementptr inbounds i8, ptr %48, i64 8
  %54 = load i32, ptr %53, align 4, !tbaa !12
  %55 = icmp slt i32 %54, 1001
  br i1 %55, label %56, label %.critedge6

.critedge6:                                       ; preds = %.lr.ph87, %52
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 211, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6solve3v) #8
  unreachable

56:                                               ; preds = %52
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %53)
  %58 = load i32, ptr %57, align 4, !tbaa !5
  store i32 %58, ptr %1, align 4, !tbaa !5
  %indvars.iv.next121 = add nuw nsw i64 %indvars.iv120, 1
  %59 = load i32, ptr @q, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = icmp slt i64 %indvars.iv.next121, %60
  br i1 %61, label %.lr.ph87, label %._crit_edge88, !llvm.loop !20

._crit_edge92:                                    ; preds = %.lr.ph91, %middle.block, %._crit_edge88
  %62 = sext i32 %43 to i64
  %63 = getelementptr inbounds i32, ptr @_ZZ6solve3vE3ord, i64 %62
  call void @"_ZSt4sortIPiZ6solve3vE3$_0EvT_S2_T0_"(ptr noundef nonnull @_ZZ6solve3vE3ord, ptr noundef nonnull %63)
  store i32 1, ptr @_ZZ6solve3vE3inv, align 16, !tbaa !5
  store i32 1, ptr @_ZZ6solve3vE4ways, align 16, !tbaa !5
  %64 = load i32, ptr %1, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = shl nsw i64 %65, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @_ZZ6solve3vE4ways, i64 4), i8 0, i64 %66, i1 false)
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @_ZZ6solve3vE3inv, i64 4), i8 0, i64 %66, i1 false)
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = icmp sgt i32 %67, 0
  %69 = load i32, ptr @q, align 4
  %70 = icmp sgt i32 %69, 0
  %71 = select i1 %68, i1 %70, i1 false
  br i1 %71, label %.lr.ph116, label %._crit_edge117

.lr.ph91:                                         ; preds = %.lr.ph91.preheader153, %.lr.ph91
  %indvars.iv123 = phi i64 [ %indvars.iv.next124, %.lr.ph91 ], [ %indvars.iv123.ph, %.lr.ph91.preheader153 ]
  %72 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve3vE3ord, i64 0, i64 %indvars.iv123
  %73 = trunc nuw nsw i64 %indvars.iv123 to i32
  store i32 %73, ptr %72, align 4, !tbaa !5
  %indvars.iv.next124 = add nuw nsw i64 %indvars.iv123, 1
  %exitcond127.not = icmp eq i64 %indvars.iv.next124, %wide.trip.count126
  br i1 %exitcond127.not, label %._crit_edge92, label %.lr.ph91, !llvm.loop !21

._crit_edge117:                                   ; preds = %.critedge8, %._crit_edge92
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #9
  ret void

.lr.ph116:                                        ; preds = %._crit_edge92, %.critedge8
  %indvars.iv146 = phi i64 [ %indvars.iv.next147, %.critedge8 ], [ 0, %._crit_edge92 ]
  %.074114 = phi i32 [ %.1.lcssa, %.critedge8 ], [ 0, %._crit_edge92 ]
  %indvars.iv146.tr = trunc i64 %indvars.iv146 to i32
  %74 = shl i32 %indvars.iv146.tr, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [150001 x %struct.Edge], ptr @e, i64 0, i64 %75, i32 2
  %77 = load i32, ptr %76, align 8, !tbaa !12
  %78 = load i32, ptr %1, align 4, !tbaa !5
  %.not93 = icmp sgt i32 %77, %78
  br i1 %.not93, label %._crit_edge97, label %.lr.ph96.preheader

.lr.ph96.preheader:                               ; preds = %.lr.ph116
  %79 = sext i32 %77 to i64
  br label %.lr.ph96

._crit_edge97:                                    ; preds = %.lr.ph96, %.lr.ph116
  %80 = phi i32 [ %78, %.lr.ph116 ], [ %91, %.lr.ph96 ]
  %indvars.iv.next147 = add nuw nsw i64 %indvars.iv146, 1
  %81 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %indvars.iv.next147
  %82 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %indvars.iv146
  %83 = add nsw i32 %80, 1
  %84 = sext i32 %83 to i64
  %85 = shl nsw i64 %84, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %81, ptr nonnull align 4 %82, i64 %85, i1 false)
  %.not8099 = icmp sgt i32 %77, %80
  br i1 %.not8099, label %.preheader, label %.lr.ph102.preheader

.lr.ph102.preheader:                              ; preds = %._crit_edge97
  %86 = sext i32 %77 to i64
  br label %.lr.ph102

.lr.ph96:                                         ; preds = %.lr.ph96.preheader, %.lr.ph96
  %indvars.iv128 = phi i64 [ %79, %.lr.ph96.preheader ], [ %indvars.iv.next129, %.lr.ph96 ]
  %87 = getelementptr inbounds [1001 x i32], ptr @_ZZ6solve3vE4ways, i64 0, i64 %indvars.iv128
  %88 = sub nsw i64 %indvars.iv128, %79
  %89 = getelementptr inbounds [1001 x i32], ptr @_ZZ6solve3vE4ways, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %87, i32 noundef %90)
  %indvars.iv.next129 = add nsw i64 %indvars.iv128, 1
  %91 = load i32, ptr %1, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %.not.not = icmp slt i64 %indvars.iv128, %92
  br i1 %.not.not, label %.lr.ph96, label %._crit_edge97, !llvm.loop !22

.preheader:                                       ; preds = %.lr.ph102, %._crit_edge97
  %93 = load i32, ptr @q, align 4
  %94 = icmp slt i32 %.074114, %93
  br i1 %94, label %.lr.ph109.preheader, label %.critedge8

.lr.ph109.preheader:                              ; preds = %.preheader
  %95 = sext i32 %.074114 to i64
  br label %.lr.ph109

.lr.ph102:                                        ; preds = %.lr.ph102.preheader, %.lr.ph102
  %indvars.iv131 = phi i64 [ %86, %.lr.ph102.preheader ], [ %indvars.iv.next132, %.lr.ph102 ]
  %96 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %indvars.iv.next147, i64 %indvars.iv131
  %97 = load i32, ptr @mod, align 4, !tbaa !5
  %98 = sub nsw i64 %indvars.iv131, %86
  %99 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %indvars.iv146, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = sub nsw i32 %97, %100
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %96, i32 noundef %101)
  %indvars.iv.next132 = add nsw i64 %indvars.iv131, 1
  %102 = load i32, ptr %1, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %.not80.not = icmp slt i64 %indvars.iv131, %103
  br i1 %.not80.not, label %.lr.ph102, label %.preheader, !llvm.loop !23

.lr.ph109:                                        ; preds = %.lr.ph109.preheader, %._crit_edge107
  %104 = phi i32 [ %93, %.lr.ph109.preheader ], [ %124, %._crit_edge107 ]
  %indvars.iv143 = phi i64 [ %95, %.lr.ph109.preheader ], [ %indvars.iv.next144, %._crit_edge107 ]
  %105 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve3vE3ord, i64 0, i64 %indvars.iv143
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %107, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !11
  %110 = zext i32 %109 to i64
  %111 = icmp eq i64 %indvars.iv.next147, %110
  br i1 %111, label %112, label %.critedge8.loopexit

112:                                              ; preds = %.lr.ph109
  %113 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %107
  store i32 0, ptr %113, align 4, !tbaa !5
  %114 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %107
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = add nsw i32 %115, -1
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [10001 x [1001 x i32]], ptr @_ZZ6solve3vE3inv, i64 0, i64 %117
  %119 = getelementptr inbounds i8, ptr %114, i64 8
  %120 = load i32, ptr %119, align 4, !tbaa !12
  %121 = icmp sgt i32 %120, -1
  br i1 %121, label %.lr.ph106.preheader, label %._crit_edge107

.lr.ph106.preheader:                              ; preds = %112
  %122 = zext nneg i32 %120 to i64
  %123 = add nuw i32 %120, 1
  %wide.trip.count141 = zext i32 %123 to i64
  br label %.lr.ph106

._crit_edge107.loopexit:                          ; preds = %.lr.ph106
  %.pre = load i32, ptr @q, align 4
  br label %._crit_edge107

._crit_edge107:                                   ; preds = %._crit_edge107.loopexit, %112
  %124 = phi i32 [ %.pre, %._crit_edge107.loopexit ], [ %104, %112 ]
  %indvars.iv.next144 = add nsw i64 %indvars.iv143, 1
  %125 = sext i32 %124 to i64
  %126 = icmp slt i64 %indvars.iv.next144, %125
  br i1 %126, label %.lr.ph109, label %.critedge8.loopexit, !llvm.loop !24

.lr.ph106:                                        ; preds = %.lr.ph106.preheader, %.lr.ph106
  %indvars.iv136 = phi i64 [ 0, %.lr.ph106.preheader ], [ %indvars.iv.next137, %.lr.ph106 ]
  %indvars.iv134 = phi i64 [ %122, %.lr.ph106.preheader ], [ %indvars.iv.next135, %.lr.ph106 ]
  %127 = getelementptr inbounds [1001 x i32], ptr @_ZZ6solve3vE4ways, i64 0, i64 %indvars.iv136
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = getelementptr inbounds i32, ptr %118, i64 %indvars.iv134
  %130 = load i32, ptr %129, align 4, !tbaa !5
  call void @_Z11mod_inc_mulRiii(ptr noundef nonnull align 4 dereferenceable(4) %113, i32 noundef %128, i32 noundef %130)
  %indvars.iv.next137 = add nuw nsw i64 %indvars.iv136, 1
  %indvars.iv.next135 = add nsw i64 %indvars.iv134, -1
  %exitcond142.not = icmp eq i64 %indvars.iv.next137, %wide.trip.count141
  br i1 %exitcond142.not, label %._crit_edge107.loopexit, label %.lr.ph106, !llvm.loop !25

.critedge8.loopexit:                              ; preds = %._crit_edge107, %.lr.ph109
  %131 = phi i32 [ %104, %.lr.ph109 ], [ %124, %._crit_edge107 ]
  %.1.lcssa.ph.in = phi i64 [ %indvars.iv143, %.lr.ph109 ], [ %indvars.iv.next144, %._crit_edge107 ]
  %.1.lcssa.ph = trunc i64 %.1.lcssa.ph.in to i32
  br label %.critedge8

.critedge8:                                       ; preds = %.critedge8.loopexit, %.preheader
  %132 = phi i32 [ %93, %.preheader ], [ %131, %.critedge8.loopexit ]
  %.1.lcssa = phi i32 [ %.074114, %.preheader ], [ %.1.lcssa.ph, %.critedge8.loopexit ]
  %133 = load i32, ptr @n, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = icmp slt i64 %indvars.iv.next147, %134
  %136 = icmp slt i32 %.1.lcssa, %132
  %137 = select i1 %135, i1 %136, i1 false
  br i1 %137, label %.lr.ph116, label %._crit_edge117, !llvm.loop !26
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPiZ6solve3vE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) local_unnamed_addr #6

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

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

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


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