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

; 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 = 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
@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.8 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._Z6solve2v = external hidden unnamed_addr constant [14 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
@.str.11 = external hidden unnamed_addr constant [27 x i8], align 1
@stderr = external global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [8 x i8], align 1
@_ZZ6solve2vE3ord = external hidden global [100001 x i32], align 16
@_ZZ6solve2vE4ways = external hidden global [50001 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: mustprogress uwtable
define dso_local void @_Z6solve2v() #2 {
  %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, 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #7
  store i32 101, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 50001, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp slt i32 %17, 101
  br i1 %18, label %19, label %26

19:                                               ; preds = %0
  %20 = load i32, ptr @m, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = add nsw i32 %21, %22
  %24 = sub nsw i32 %23, 1
  %25 = icmp eq i32 %20, %24
  br label %26

26:                                               ; preds = %19, %0
  %27 = phi i1 [ false, %0 ], [ %25, %19 ]
  br i1 %27, label %28, label %29

28:                                               ; preds = %26
  br label %31

29:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 160, ptr noundef @__PRETTY_FUNCTION__._Z6solve2v) #8
  unreachable

30:                                               ; No predecessors!
  br label %31

31:                                               ; preds = %30, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %98, %31
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = load i32, ptr @m, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %101

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

47:                                               ; preds = %37
  %48 = load ptr, ptr %6, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.Edge, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  %53 = icmp eq i32 %50, %52
  br i1 %53, label %54, label %66

54:                                               ; preds = %47
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.Edge, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !13
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  %60 = icmp eq i32 %57, %59
  br i1 %60, label %61, label %66

61:                                               ; preds = %54
  %62 = load ptr, ptr %6, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.Edge, ptr %62, i32 0, i32 2
  %64 = load i32, ptr %63, align 4, !tbaa !14
  %65 = icmp slt i32 %64, 50001
  br label %66

66:                                               ; preds = %61, %54, %47
  %67 = phi i1 [ false, %54 ], [ false, %47 ], [ %65, %61 ]
  br i1 %67, label %68, label %69

68:                                               ; preds = %66
  br label %71

69:                                               ; preds = %66
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 165, ptr noundef @__PRETTY_FUNCTION__._Z6solve2v) #8
  unreachable

70:                                               ; No predecessors!
  br label %71

71:                                               ; preds = %70, %68
  br label %97

72:                                               ; preds = %37
  %73 = load ptr, ptr %6, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.Edge, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %74, align 4, !tbaa !11
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  %78 = icmp eq i32 %75, %77
  br i1 %78, label %79, label %91

79:                                               ; preds = %72
  %80 = load ptr, ptr %6, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.Edge, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !13
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = add nsw i32 %83, 2
  %85 = icmp eq i32 %82, %84
  br i1 %85, label %86, label %91

86:                                               ; preds = %79
  %87 = load ptr, ptr %6, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.Edge, ptr %87, i32 0, i32 2
  %89 = load i32, ptr %88, align 4, !tbaa !14
  %90 = icmp eq i32 %89, 0
  br label %91

91:                                               ; preds = %86, %79, %72
  %92 = phi i1 [ false, %79 ], [ false, %72 ], [ %90, %86 ]
  br i1 %92, label %93, label %94

93:                                               ; preds = %91
  br label %96

94:                                               ; preds = %91
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 167, ptr noundef @__PRETTY_FUNCTION__._Z6solve2v) #8
  unreachable

95:                                               ; No predecessors!
  br label %96

96:                                               ; preds = %95, %93
  br label %97

97:                                               ; preds = %96, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %98

98:                                               ; preds = %97
  %99 = load i32, ptr %3, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %3, align 4, !tbaa !5
  br label %32, !llvm.loop !15

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

102:                                              ; preds = %130, %101
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = load i32, ptr @q, align 4, !tbaa !5
  %105 = icmp slt i32 %103, %104
  br i1 %105, label %107, label %106

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

107:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %109
  store ptr %110, ptr %9, align 8, !tbaa !9
  %111 = load ptr, ptr %9, align 8, !tbaa !9
  %112 = getelementptr inbounds %struct.Edge, ptr %111, i32 0, i32 0
  %113 = load i32, ptr %112, align 4, !tbaa !11
  %114 = icmp eq i32 %113, 1
  br i1 %114, label %115, label %120

115:                                              ; preds = %107
  %116 = load ptr, ptr %9, align 8, !tbaa !9
  %117 = getelementptr inbounds %struct.Edge, ptr %116, i32 0, i32 2
  %118 = load i32, ptr %117, align 4, !tbaa !14
  %119 = icmp slt i32 %118, 50001
  br label %120

120:                                              ; preds = %115, %107
  %121 = phi i1 [ false, %107 ], [ %119, %115 ]
  br i1 %121, label %122, label %123

122:                                              ; preds = %120
  br label %125

123:                                              ; preds = %120
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 173, ptr noundef @__PRETTY_FUNCTION__._Z6solve2v) #8
  unreachable

124:                                              ; No predecessors!
  br label %125

125:                                              ; preds = %124, %122
  %126 = load ptr, ptr %9, align 8, !tbaa !9
  %127 = getelementptr inbounds %struct.Edge, ptr %126, i32 0, i32 2
  %128 = 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) %127)
  %129 = load i32, ptr %128, align 4, !tbaa !5
  store i32 %129, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %130

130:                                              ; preds = %125
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %8, align 4, !tbaa !5
  br label %102, !llvm.loop !17

133:                                              ; preds = %106
  %134 = load ptr, ptr @stderr, align 8, !tbaa !9
  %135 = load i32, ptr %7, align 4, !tbaa !5
  %136 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %134, ptr noundef @.str.12, i32 noundef %135) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %137

137:                                              ; preds = %147, %133
  %138 = load i32, ptr %10, align 4, !tbaa !5
  %139 = load i32, ptr @q, align 4, !tbaa !5
  %140 = icmp slt i32 %138, %139
  br i1 %140, label %142, label %141

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

142:                                              ; preds = %137
  %143 = load i32, ptr %10, align 4, !tbaa !5
  %144 = load i32, ptr %10, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve2vE3ord, i64 0, i64 %145
  store i32 %143, ptr %146, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %142
  %148 = load i32, ptr %10, align 4, !tbaa !5
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %10, align 4, !tbaa !5
  br label %137, !llvm.loop !18

150:                                              ; preds = %141
  %151 = load i32, ptr @q, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds i32, ptr @_ZZ6solve2vE3ord, i64 %152
  call void @"_ZSt4sortIPiZ6solve2vE3$_0EvT_S2_T0_"(ptr noundef @_ZZ6solve2vE3ord, ptr noundef %153)
  store i32 1, ptr @_ZZ6solve2vE4ways, align 16, !tbaa !5
  %154 = load i32, ptr %7, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = mul i64 %155, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @_ZZ6solve2vE4ways, i64 1), i8 0, i64 %156, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %157

157:                                              ; preds = %235, %150
  %158 = load i32, ptr %12, align 4, !tbaa !5
  %159 = load i32, ptr @n, align 4, !tbaa !5
  %160 = icmp slt i32 %158, %159
  br i1 %160, label %161, label %165

161:                                              ; preds = %157
  %162 = load i32, ptr %13, align 4, !tbaa !5
  %163 = load i32, ptr @q, align 4, !tbaa !5
  %164 = icmp slt i32 %162, %163
  br label %165

165:                                              ; preds = %161, %157
  %166 = phi i1 [ false, %157 ], [ %164, %161 ]
  br i1 %166, label %168, label %167

167:                                              ; preds = %165
  store i32 11, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %238

168:                                              ; preds = %165
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %169 = load i32, ptr %12, align 4, !tbaa !5
  %170 = shl i32 %169, 1
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [150001 x %struct.Edge], ptr @e, i64 0, i64 %171
  %173 = getelementptr inbounds %struct.Edge, ptr %172, i32 0, i32 2
  %174 = load i32, ptr %173, align 4, !tbaa !14
  store i32 %174, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  %175 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %175, ptr %16, align 4, !tbaa !5
  br label %176

176:                                              ; preds = %191, %168
  %177 = load i32, ptr %16, align 4, !tbaa !5
  %178 = load i32, ptr %7, align 4, !tbaa !5
  %179 = icmp sle i32 %177, %178
  br i1 %179, label %181, label %180

180:                                              ; preds = %176
  store i32 14, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %194

181:                                              ; preds = %176
  %182 = load i32, ptr %16, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [50001 x i32], ptr @_ZZ6solve2vE4ways, i64 0, i64 %183
  %185 = load i32, ptr %16, align 4, !tbaa !5
  %186 = load i32, ptr %15, align 4, !tbaa !5
  %187 = sub nsw i32 %185, %186
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [50001 x i32], ptr @_ZZ6solve2vE4ways, i64 0, i64 %188
  %190 = load i32, ptr %189, align 4, !tbaa !5
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) %184, i32 noundef %190)
  br label %191

191:                                              ; preds = %181
  %192 = load i32, ptr %16, align 4, !tbaa !5
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr %16, align 4, !tbaa !5
  br label %176, !llvm.loop !19

194:                                              ; preds = %180
  br label %195

195:                                              ; preds = %231, %194
  %196 = load i32, ptr %13, align 4, !tbaa !5
  %197 = load i32, ptr @q, align 4, !tbaa !5
  %198 = icmp slt i32 %196, %197
  br i1 %198, label %199, label %211

199:                                              ; preds = %195
  %200 = load i32, ptr %13, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve2vE3ord, i64 0, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !5
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %204
  %206 = getelementptr inbounds %struct.Edge, ptr %205, i32 0, i32 1
  %207 = load i32, ptr %206, align 4, !tbaa !13
  %208 = load i32, ptr %12, align 4, !tbaa !5
  %209 = add nsw i32 %208, 1
  %210 = icmp eq i32 %207, %209
  br label %211

211:                                              ; preds = %199, %195
  %212 = phi i1 [ false, %195 ], [ %210, %199 ]
  br i1 %212, label %213, label %234

213:                                              ; preds = %211
  %214 = load i32, ptr %13, align 4, !tbaa !5
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve2vE3ord, i64 0, i64 %215
  %217 = load i32, ptr %216, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %218
  %220 = getelementptr inbounds %struct.Edge, ptr %219, i32 0, i32 2
  %221 = load i32, ptr %220, align 4, !tbaa !14
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds [50001 x i32], ptr @_ZZ6solve2vE4ways, i64 0, i64 %222
  %224 = load i32, ptr %223, align 4, !tbaa !5
  %225 = load i32, ptr %13, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve2vE3ord, i64 0, i64 %226
  %228 = load i32, ptr %227, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %229
  store i32 %224, ptr %230, align 4, !tbaa !5
  br label %231

231:                                              ; preds = %213
  %232 = load i32, ptr %13, align 4, !tbaa !5
  %233 = add nsw i32 %232, 1
  store i32 %233, ptr %13, align 4, !tbaa !5
  br label %195, !llvm.loop !20

234:                                              ; preds = %211
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %235

235:                                              ; preds = %234
  %236 = load i32, ptr %12, align 4, !tbaa !5
  %237 = add nsw i32 %236, 1
  store i32 %237, ptr %12, align 4, !tbaa !5
  br label %157, !llvm.loop !21

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

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

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

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

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

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

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


; 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
@ans = external dso_local local_unnamed_addr 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.8 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._Z6solve2v = external hidden unnamed_addr constant [14 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
@.str.11 = external hidden unnamed_addr constant [27 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
@_ZZ6solve2vE3ord = external hidden global [100001 x i32], align 16
@_ZZ6solve2vE4ways = external hidden global [50001 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: mustprogress uwtable
define dso_local void @_Z6solve2v() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp slt i32 %2, 101
  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 %.preheader57, label %.critedge

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

.lr.ph.preheader:                                 ; preds = %.preheader57
  %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 160, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6solve2v) #7
  unreachable

._crit_edge:                                      ; preds = %39, %.preheader57
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  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.ph61, label %._crit_edge62

.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, 50001
  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 165, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6solve2v) #7
  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 167, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6solve2v) #7
  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_edge62:                                    ; preds = %55, %._crit_edge
  %40 = phi i32 [ 0, %._crit_edge ], [ %57, %55 ]
  %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) #9
  %43 = load i32, ptr @q, align 4, !tbaa !5
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %.lr.ph65.preheader, label %._crit_edge66

.lr.ph65.preheader:                               ; preds = %._crit_edge62
  %wide.trip.count88 = zext nneg i32 %43 to i64
  %min.iters.check = icmp ult i32 %43, 8
  br i1 %min.iters.check, label %.lr.ph65.preheader113, label %vector.ph

.lr.ph65.preheader113:                            ; preds = %middle.block, %.lr.ph65.preheader
  %indvars.iv85.ph = phi i64 [ 0, %.lr.ph65.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph65

vector.ph:                                        ; preds = %.lr.ph65.preheader
  %n.vec = and i64 %wide.trip.count88, 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 @_ZZ6solve2vE3ord, 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.count88
  br i1 %cmp.n, label %._crit_edge66, label %.lr.ph65.preheader113

.lr.ph61:                                         ; preds = %._crit_edge, %55
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %55 ], [ 0, %._crit_edge ]
  %48 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %indvars.iv82
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = icmp eq i32 %49, 1
  br i1 %50, label %51, label %.critedge6

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

.critedge6:                                       ; preds = %.lr.ph61, %51
  call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 173, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6solve2v) #7
  unreachable

55:                                               ; preds = %51
  %56 = 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) %52)
  %57 = load i32, ptr %56, align 4, !tbaa !5
  store i32 %57, ptr %1, align 4, !tbaa !5
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %58 = load i32, ptr @q, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = icmp slt i64 %indvars.iv.next83, %59
  br i1 %60, label %.lr.ph61, label %._crit_edge62, !llvm.loop !20

._crit_edge66:                                    ; preds = %.lr.ph65, %middle.block, %._crit_edge62
  %61 = sext i32 %43 to i64
  %62 = getelementptr inbounds i32, ptr @_ZZ6solve2vE3ord, i64 %61
  call void @"_ZSt4sortIPiZ6solve2vE3$_0EvT_S2_T0_"(ptr noundef nonnull @_ZZ6solve2vE3ord, ptr noundef nonnull %62)
  store i32 1, ptr @_ZZ6solve2vE4ways, align 16, !tbaa !5
  %63 = load i32, ptr %1, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = shl nsw i64 %64, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @_ZZ6solve2vE4ways, i64 4), i8 0, i64 %65, i1 false)
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = icmp sgt i32 %66, 0
  %68 = load i32, ptr @q, align 4
  %69 = icmp sgt i32 %68, 0
  %70 = select i1 %67, i1 %69, i1 false
  br i1 %70, label %.lr.ph79, label %._crit_edge80

.lr.ph65:                                         ; preds = %.lr.ph65.preheader113, %.lr.ph65
  %indvars.iv85 = phi i64 [ %indvars.iv.next86, %.lr.ph65 ], [ %indvars.iv85.ph, %.lr.ph65.preheader113 ]
  %71 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve2vE3ord, i64 0, i64 %indvars.iv85
  %72 = trunc nuw nsw i64 %indvars.iv85 to i32
  store i32 %72, ptr %71, align 4, !tbaa !5
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %exitcond89.not = icmp eq i64 %indvars.iv.next86, %wide.trip.count88
  br i1 %exitcond89.not, label %._crit_edge66, label %.lr.ph65, !llvm.loop !21

._crit_edge80:                                    ; preds = %.critedge8, %101, %._crit_edge66
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret void

.lr.ph79:                                         ; preds = %._crit_edge66, %.critedge8
  %73 = phi i32 [ %80, %.critedge8 ], [ %68, %._crit_edge66 ]
  %74 = phi i32 [ %81, %.critedge8 ], [ %63, %._crit_edge66 ]
  %indvars.iv97 = phi i64 [ %83, %.critedge8 ], [ 0, %._crit_edge66 ]
  %.05077 = phi i32 [ %.1.lcssa, %.critedge8 ], [ 0, %._crit_edge66 ]
  %indvars.iv97.tr = trunc i64 %indvars.iv97 to i32
  %75 = shl i32 %indvars.iv97.tr, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [150001 x %struct.Edge], ptr @e, i64 0, i64 %76, i32 2
  %78 = load i32, ptr %77, align 8, !tbaa !12
  %.not67 = icmp sgt i32 %78, %74
  br i1 %.not67, label %.preheader, label %.lr.ph70.preheader

.lr.ph70.preheader:                               ; preds = %.lr.ph79
  %79 = sext i32 %78 to i64
  br label %.lr.ph70

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

.preheader:                                       ; preds = %.preheader.loopexit, %.lr.ph79
  %80 = phi i32 [ %.pre, %.preheader.loopexit ], [ %73, %.lr.ph79 ]
  %81 = phi i32 [ %90, %.preheader.loopexit ], [ %74, %.lr.ph79 ]
  %82 = icmp slt i32 %.05077, %80
  %83 = add nuw nsw i64 %indvars.iv97, 1
  br i1 %82, label %.lr.ph72, label %.critedge8

.lr.ph72:                                         ; preds = %.preheader
  %84 = sext i32 %.05077 to i64
  %85 = sext i32 %80 to i64
  br label %92

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

92:                                               ; preds = %.lr.ph72, %101
  %indvars.iv93 = phi i64 [ %84, %.lr.ph72 ], [ %indvars.iv.next94, %101 ]
  %93 = getelementptr inbounds [100001 x i32], ptr @_ZZ6solve2vE3ord, i64 0, i64 %indvars.iv93
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100001 x %struct.Edge], ptr @que, i64 0, i64 %95
  %97 = getelementptr inbounds i8, ptr %96, i64 4
  %98 = load i32, ptr %97, align 4, !tbaa !11
  %99 = zext i32 %98 to i64
  %100 = icmp eq i64 %83, %99
  br i1 %100, label %101, label %.critedge8.loopexit

101:                                              ; preds = %92
  %102 = getelementptr inbounds i8, ptr %96, i64 8
  %103 = load i32, ptr %102, align 4, !tbaa !12
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [50001 x i32], ptr @_ZZ6solve2vE4ways, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %95
  store i32 %106, ptr %107, align 4, !tbaa !5
  %indvars.iv.next94 = add nsw i64 %indvars.iv93, 1
  %exitcond96.not = icmp eq i64 %indvars.iv.next94, %85
  br i1 %exitcond96.not, label %._crit_edge80, label %92, !llvm.loop !23

.critedge8.loopexit:                              ; preds = %92
  %108 = trunc nsw i64 %indvars.iv93 to i32
  br label %.critedge8

.critedge8:                                       ; preds = %.preheader, %.critedge8.loopexit
  %.1.lcssa = phi i32 [ %108, %.critedge8.loopexit ], [ %.05077, %.preheader ]
  %109 = load i32, ptr @n, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = icmp slt i64 %83, %110
  %112 = icmp slt i32 %.1.lcssa, %80
  %113 = select i1 %111, i1 %112, i1 false
  br i1 %113, label %.lr.ph79, label %._crit_edge80, !llvm.loop !24
}

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

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

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

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

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

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


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