; LLVM IR from tangjz/acm-icpc :: codeforces/1615D.ll (Z5solvev)

; 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, i32 }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%class.anon = type { ptr }
%class.anon.0 = type { ptr }

@_ZZ5solvevE3dsu = external hidden global [2000009 x i32], align 16
@_ZZ5solvevE3dis = external hidden global [2000009 x i32], align 16
@_ZZ5solvevE1e = external hidden global [2000009 x %struct.Edge], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  %4 = alloca %"class.std::function", align 8
  %5 = alloca %class.anon, align 8
  %6 = alloca %class.anon.0, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #6
  store i8 0, ptr %3, align 1, !tbaa !5
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %1, ptr noundef %2)
  %18 = load i32, ptr %1, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = mul i64 %19, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @_ZZ5solvevE3dsu, i64 1), i8 -1, i64 %20, i1 false)
  %21 = load i32, ptr %1, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = mul i64 %22, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @_ZZ5solvevE3dis, i64 1), i8 0, i64 %23, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %24 = getelementptr inbounds %class.anon, ptr %5, i32 0, i32 0
  store ptr %4, ptr %24, align 8, !tbaa !11
  call void @"_ZNSt8functionIFiiEEC2IZ5solvevE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %25 = getelementptr inbounds %class.anon.0, ptr %6, i32 0, i32 0
  store ptr %4, ptr %25, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %106, %0
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = load i32, ptr %1, align 4, !tbaa !9
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %109

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2000009 x %struct.Edge], ptr @_ZZ5solvevE1e, i64 0, i64 %33
  store ptr %34, ptr %9, align 8, !tbaa !11
  %35 = load ptr, ptr %9, align 8, !tbaa !11
  %36 = getelementptr inbounds %struct.Edge, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %9, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct.Edge, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %9, align 8, !tbaa !11
  %40 = getelementptr inbounds %struct.Edge, ptr %39, i32 0, i32 2
  %41 = invoke i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %36, ptr noundef %38, ptr noundef %40)
          to label %42 unwind label %48

42:                                               ; preds = %31
  %43 = load ptr, ptr %9, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct.Edge, ptr %43, i32 0, i32 2
  %45 = load i32, ptr %44, align 4, !tbaa !13
  %46 = icmp eq i32 %45, -1
  br i1 %46, label %47, label %52

47:                                               ; preds = %42
  store i32 4, ptr %8, align 4
  br label %103

48:                                               ; preds = %82, %31
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %10, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %231

52:                                               ; preds = %42
  %53 = load ptr, ptr %9, align 8, !tbaa !11
  %54 = getelementptr inbounds %struct.Edge, ptr %53, i32 0, i32 3
  store i32 0, ptr %54, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %55 = load ptr, ptr %9, align 8, !tbaa !11
  %56 = getelementptr inbounds %struct.Edge, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 4, !tbaa !13
  store i32 %57, ptr %12, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %76, %52
  %59 = load i32, ptr %12, align 4, !tbaa !9
  %60 = icmp sgt i32 %59, 0
  br i1 %60, label %62, label %61

61:                                               ; preds = %58
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %79

62:                                               ; preds = %58
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = and i32 %63, 1
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %75

66:                                               ; preds = %62
  %67 = load ptr, ptr %9, align 8, !tbaa !11
  %68 = getelementptr inbounds %struct.Edge, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 4, !tbaa !15
  %70 = icmp ne i32 %69, 0
  %71 = xor i1 %70, true
  %72 = zext i1 %71 to i32
  %73 = load ptr, ptr %9, align 8, !tbaa !11
  %74 = getelementptr inbounds %struct.Edge, ptr %73, i32 0, i32 3
  store i32 %72, ptr %74, align 4, !tbaa !15
  br label %75

75:                                               ; preds = %66, %62
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %12, align 4, !tbaa !9
  %78 = ashr i32 %77, 1
  store i32 %78, ptr %12, align 4, !tbaa !9
  br label %58, !llvm.loop !16

79:                                               ; preds = %61
  %80 = load i8, ptr %3, align 1, !tbaa !5, !range !18, !noundef !19
  %81 = trunc i8 %80 to i1
  br i1 %81, label %102, label %82

82:                                               ; preds = %79
  %83 = load ptr, ptr %9, align 8, !tbaa !11
  %84 = getelementptr inbounds %struct.Edge, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 4, !tbaa !20
  %86 = load ptr, ptr %9, align 8, !tbaa !11
  %87 = getelementptr inbounds %struct.Edge, ptr %86, i32 0, i32 1
  %88 = load i32, ptr %87, align 4, !tbaa !21
  %89 = load ptr, ptr %9, align 8, !tbaa !11
  %90 = getelementptr inbounds %struct.Edge, ptr %89, i32 0, i32 3
  %91 = load i32, ptr %90, align 4, !tbaa !15
  %92 = invoke noundef zeroext i1 @"_ZZ5solvevENK3$_1clEiii"(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef %85, i32 noundef %88, i32 noundef %91)
          to label %93 unwind label %48

93:                                               ; preds = %82
  %94 = xor i1 %92, true
  %95 = zext i1 %94 to i32
  %96 = load i8, ptr %3, align 1, !tbaa !5, !range !18, !noundef !19
  %97 = trunc i8 %96 to i1
  %98 = zext i1 %97 to i32
  %99 = or i32 %98, %95
  %100 = icmp ne i32 %99, 0
  %101 = zext i1 %100 to i8
  store i8 %101, ptr %3, align 1, !tbaa !5
  br label %102

102:                                              ; preds = %93, %79
  store i32 0, ptr %8, align 4
  br label %103

103:                                              ; preds = %102, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %104 = load i32, ptr %8, align 4
  switch i32 %104, label %237 [
    i32 0, label %105
    i32 4, label %106
  ]

105:                                              ; preds = %103
  br label %106

106:                                              ; preds = %105, %103
  %107 = load i32, ptr %7, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %7, align 4, !tbaa !9
  br label %26, !llvm.loop !22

109:                                              ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %110

110:                                              ; preds = %139, %109
  %111 = load i32, ptr %13, align 4, !tbaa !9
  %112 = load i32, ptr %2, align 4, !tbaa !9
  %113 = icmp slt i32 %111, %112
  br i1 %113, label %115, label %114

114:                                              ; preds = %110
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %142

115:                                              ; preds = %110
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store ptr @_ZZ5solvevE1e, ptr %14, align 8, !tbaa !11
  %116 = invoke i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @_ZZ5solvevE1e, ptr noundef getelementptr inbounds (%struct.Edge, ptr @_ZZ5solvevE1e, i32 0, i32 1), ptr noundef getelementptr inbounds (%struct.Edge, ptr @_ZZ5solvevE1e, i32 0, i32 3))
          to label %117 unwind label %134

117:                                              ; preds = %115
  %118 = load i8, ptr %3, align 1, !tbaa !5, !range !18, !noundef !19
  %119 = trunc i8 %118 to i1
  br i1 %119, label %138, label %120

120:                                              ; preds = %117
  %121 = load i32, ptr @_ZZ5solvevE1e, align 4, !tbaa !20
  %122 = load i32, ptr getelementptr inbounds (%struct.Edge, ptr @_ZZ5solvevE1e, i32 0, i32 1), align 4, !tbaa !21
  %123 = load i32, ptr getelementptr inbounds (%struct.Edge, ptr @_ZZ5solvevE1e, i32 0, i32 3), align 4, !tbaa !15
  %124 = invoke noundef zeroext i1 @"_ZZ5solvevENK3$_1clEiii"(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef %121, i32 noundef %122, i32 noundef %123)
          to label %125 unwind label %134

125:                                              ; preds = %120
  %126 = xor i1 %124, true
  %127 = zext i1 %126 to i32
  %128 = load i8, ptr %3, align 1, !tbaa !5, !range !18, !noundef !19
  %129 = trunc i8 %128 to i1
  %130 = zext i1 %129 to i32
  %131 = or i32 %130, %127
  %132 = icmp ne i32 %131, 0
  %133 = zext i1 %132 to i8
  store i8 %133, ptr %3, align 1, !tbaa !5
  br label %138

134:                                              ; preds = %120, %115
  %135 = landingpad { ptr, i32 }
          cleanup
  %136 = extractvalue { ptr, i32 } %135, 0
  store ptr %136, ptr %10, align 8
  %137 = extractvalue { ptr, i32 } %135, 1
  store i32 %137, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %231

138:                                              ; preds = %125, %117
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %139

139:                                              ; preds = %138
  %140 = load i32, ptr %13, align 4, !tbaa !9
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %13, align 4, !tbaa !9
  br label %110, !llvm.loop !23

142:                                              ; preds = %114
  %143 = load i8, ptr %3, align 1, !tbaa !5, !range !18, !noundef !19
  %144 = trunc i8 %143 to i1
  br i1 %144, label %145, label %152

145:                                              ; preds = %142
  %146 = invoke i32 @puts(ptr noundef @.str.3)
          to label %147 unwind label %148

147:                                              ; preds = %145
  store i32 1, ptr %8, align 4
  br label %228

148:                                              ; preds = %152, %145
  %149 = landingpad { ptr, i32 }
          cleanup
  %150 = extractvalue { ptr, i32 } %149, 0
  store ptr %150, ptr %10, align 8
  %151 = extractvalue { ptr, i32 } %149, 1
  store i32 %151, ptr %11, align 4
  br label %231

152:                                              ; preds = %142
  %153 = invoke i32 @puts(ptr noundef @.str.4)
          to label %154 unwind label %148

154:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 1, ptr %15, align 4, !tbaa !9
  br label %155

155:                                              ; preds = %224, %154
  %156 = load i32, ptr %15, align 4, !tbaa !9
  %157 = load i32, ptr %1, align 4, !tbaa !9
  %158 = icmp slt i32 %156, %157
  br i1 %158, label %160, label %159

159:                                              ; preds = %155
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %227

160:                                              ; preds = %155
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %161 = load i32, ptr %15, align 4, !tbaa !9
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [2000009 x %struct.Edge], ptr @_ZZ5solvevE1e, i64 0, i64 %162
  store ptr %163, ptr %16, align 8, !tbaa !11
  %164 = load ptr, ptr %16, align 8, !tbaa !11
  %165 = getelementptr inbounds %struct.Edge, ptr %164, i32 0, i32 2
  %166 = load i32, ptr %165, align 4, !tbaa !13
  %167 = icmp eq i32 %166, -1
  br i1 %167, label %168, label %212

168:                                              ; preds = %160
  %169 = load ptr, ptr %16, align 8, !tbaa !11
  %170 = getelementptr inbounds %struct.Edge, ptr %169, i32 0, i32 0
  %171 = load i32, ptr %170, align 4, !tbaa !20
  %172 = invoke noundef i32 @_ZNKSt8functionIFiiEEclEi(ptr noundef nonnull align 8 dereferenceable(32) %4, i32 noundef %171)
          to label %173 unwind label %196

173:                                              ; preds = %168
  %174 = load ptr, ptr %16, align 8, !tbaa !11
  %175 = getelementptr inbounds %struct.Edge, ptr %174, i32 0, i32 1
  %176 = load i32, ptr %175, align 4, !tbaa !21
  %177 = invoke noundef i32 @_ZNKSt8functionIFiiEEclEi(ptr noundef nonnull align 8 dereferenceable(32) %4, i32 noundef %176)
          to label %178 unwind label %196

178:                                              ; preds = %173
  %179 = icmp eq i32 %172, %177
  br i1 %179, label %180, label %200

180:                                              ; preds = %178
  %181 = load ptr, ptr %16, align 8, !tbaa !11
  %182 = getelementptr inbounds %struct.Edge, ptr %181, i32 0, i32 0
  %183 = load i32, ptr %182, align 4, !tbaa !20
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [2000009 x i32], ptr @_ZZ5solvevE3dis, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !9
  %187 = load ptr, ptr %16, align 8, !tbaa !11
  %188 = getelementptr inbounds %struct.Edge, ptr %187, i32 0, i32 1
  %189 = load i32, ptr %188, align 4, !tbaa !21
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [2000009 x i32], ptr @_ZZ5solvevE3dis, i64 0, i64 %190
  %192 = load i32, ptr %191, align 4, !tbaa !9
  %193 = xor i32 %186, %192
  %194 = load ptr, ptr %16, align 8, !tbaa !11
  %195 = getelementptr inbounds %struct.Edge, ptr %194, i32 0, i32 2
  store i32 %193, ptr %195, align 4, !tbaa !13
  br label %211

196:                                              ; preds = %212, %200, %173, %168
  %197 = landingpad { ptr, i32 }
          cleanup
  %198 = extractvalue { ptr, i32 } %197, 0
  store ptr %198, ptr %10, align 8
  %199 = extractvalue { ptr, i32 } %197, 1
  store i32 %199, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %231

200:                                              ; preds = %178
  %201 = load ptr, ptr %16, align 8, !tbaa !11
  %202 = getelementptr inbounds %struct.Edge, ptr %201, i32 0, i32 2
  store i32 0, ptr %202, align 4, !tbaa !13
  %203 = load ptr, ptr %16, align 8, !tbaa !11
  %204 = getelementptr inbounds %struct.Edge, ptr %203, i32 0, i32 0
  %205 = load i32, ptr %204, align 4, !tbaa !20
  %206 = load ptr, ptr %16, align 8, !tbaa !11
  %207 = getelementptr inbounds %struct.Edge, ptr %206, i32 0, i32 1
  %208 = load i32, ptr %207, align 4, !tbaa !21
  %209 = invoke noundef zeroext i1 @"_ZZ5solvevENK3$_1clEiii"(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 noundef %205, i32 noundef %208, i32 noundef 0)
          to label %210 unwind label %196

210:                                              ; preds = %200
  br label %211

211:                                              ; preds = %210, %180
  br label %212

212:                                              ; preds = %211, %160
  %213 = load ptr, ptr %16, align 8, !tbaa !11
  %214 = getelementptr inbounds %struct.Edge, ptr %213, i32 0, i32 0
  %215 = load i32, ptr %214, align 4, !tbaa !20
  %216 = load ptr, ptr %16, align 8, !tbaa !11
  %217 = getelementptr inbounds %struct.Edge, ptr %216, i32 0, i32 1
  %218 = load i32, ptr %217, align 4, !tbaa !21
  %219 = load ptr, ptr %16, align 8, !tbaa !11
  %220 = getelementptr inbounds %struct.Edge, ptr %219, i32 0, i32 2
  %221 = load i32, ptr %220, align 4, !tbaa !13
  %222 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %215, i32 noundef %218, i32 noundef %221)
          to label %223 unwind label %196

223:                                              ; preds = %212
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %224

224:                                              ; preds = %223
  %225 = load i32, ptr %15, align 4, !tbaa !9
  %226 = add nsw i32 %225, 1
  store i32 %226, ptr %15, align 4, !tbaa !9
  br label %155, !llvm.loop !24

227:                                              ; preds = %159
  store i32 0, ptr %8, align 4
  br label %228

228:                                              ; preds = %227, %147
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  %229 = load i32, ptr %8, align 4
  switch i32 %229, label %237 [
    i32 0, label %230
    i32 1, label %230
  ]

230:                                              ; preds = %228, %228
  ret void

231:                                              ; preds = %196, %148, %134, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  br label %232

232:                                              ; preds = %231
  %233 = load ptr, ptr %10, align 8
  %234 = load i32, ptr %11, align 4
  %235 = insertvalue { ptr, i32 } poison, ptr %233, 0
  %236 = insertvalue { ptr, i32 } %235, i32 %234, 1
  resume { ptr, i32 } %236

237:                                              ; preds = %228, %103
  unreachable
}

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

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

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef zeroext i1 @"_ZZ5solvevENK3$_1clEiii"(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i32 noundef, i32 noundef) #5 align 2

declare i32 @puts(ptr noundef) #2

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

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

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

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


; 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, i32 }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%class.anon = type { ptr }
%class.anon.0 = type { ptr }

@_ZZ5solvevE3dsu = external hidden local_unnamed_addr global [2000009 x i32], align 16
@_ZZ5solvevE3dis = external hidden local_unnamed_addr global [2000009 x i32], align 16
@_ZZ5solvevE1e = external hidden global [2000009 x %struct.Edge], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"class.std::function", align 8
  %4 = alloca %class.anon, align 8
  %5 = alloca %class.anon.0, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = shl nsw i64 %8, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @_ZZ5solvevE3dsu, i64 4), i8 -1, i64 %9, i1 false)
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @_ZZ5solvevE3dis, i64 4), i8 0, i64 %9, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  store ptr %3, ptr %4, align 8, !tbaa !9
  call void @"_ZNSt8functionIFiiEEC2IZ5solvevE3$_0vEEOT_"(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  store ptr %3, ptr %5, align 8, !tbaa !9
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 1
  br i1 %11, label %.lr.ph54, label %.preheader

.preheader:                                       ; preds = %41, %0
  %.0.lcssa = phi i8 [ 0, %0 ], [ %.2, %41 ]
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph57, label %._crit_edge58

.lr.ph54:                                         ; preds = %0, %41
  %indvars.iv = phi i64 [ %indvars.iv.next, %41 ], [ 1, %0 ]
  %.052 = phi i8 [ %.2, %41 ], [ 0, %0 ]
  %14 = getelementptr inbounds [2000009 x %struct.Edge], ptr @_ZZ5solvevE1e, i64 0, i64 %indvars.iv
  %15 = getelementptr inbounds i8, ptr %14, i64 4
  %16 = getelementptr inbounds i8, ptr %14, i64 8
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %14, ptr noundef nonnull %15, ptr noundef nonnull %16)
  %18 = load i32, ptr %16, align 8, !tbaa !11
  %19 = icmp eq i32 %18, -1
  br i1 %19, label %41, label %22

20:                                               ; preds = %34
  %21 = landingpad { ptr, i32 }
          cleanup
  br label %105

22:                                               ; preds = %.lr.ph54
  %23 = getelementptr inbounds i8, ptr %14, i64 12
  store i32 0, ptr %23, align 4, !tbaa !13
  %24 = icmp sgt i32 %18, 0
  br i1 %24, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %31, %22
  %25 = phi i32 [ 0, %22 ], [ %32, %31 ]
  %26 = trunc nuw i8 %.052 to i1
  br i1 %26, label %41, label %34

.lr.ph:                                           ; preds = %22, %31
  %27 = phi i32 [ %32, %31 ], [ 0, %22 ]
  %.04350 = phi i32 [ %33, %31 ], [ %18, %22 ]
  %28 = and i32 %.04350, 1
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %31, label %29

29:                                               ; preds = %.lr.ph
  %.not47 = icmp eq i32 %27, 0
  %30 = zext i1 %.not47 to i32
  store i32 %30, ptr %23, align 4, !tbaa !13
  br label %31

31:                                               ; preds = %.lr.ph, %29
  %32 = phi i32 [ %27, %.lr.ph ], [ %30, %29 ]
  %33 = lshr i32 %.04350, 1
  %.not63 = icmp ult i32 %.04350, 2
  br i1 %.not63, label %._crit_edge, label %.lr.ph, !llvm.loop !14

34:                                               ; preds = %._crit_edge
  %35 = load i32, ptr %14, align 16, !tbaa !16
  %36 = load i32, ptr %15, align 4, !tbaa !17
  %37 = invoke noundef zeroext i1 @"_ZZ5solvevENK3$_1clEiii"(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %35, i32 noundef %36, i32 noundef %25)
          to label %38 unwind label %20

38:                                               ; preds = %34
  %39 = xor i1 %37, true
  %40 = zext i1 %39 to i8
  br label %41

41:                                               ; preds = %._crit_edge, %38, %.lr.ph54
  %.2 = phi i8 [ %.052, %.lr.ph54 ], [ %.052, %._crit_edge ], [ %40, %38 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %42 = load i32, ptr %1, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = icmp slt i64 %indvars.iv.next, %43
  br i1 %44, label %.lr.ph54, label %.preheader, !llvm.loop !18

._crit_edge58:                                    ; preds = %58, %.preheader
  %.3.lcssa = phi i8 [ %.0.lcssa, %.preheader ], [ %.4, %58 ]
  %45 = trunc nuw i8 %.3.lcssa to i1
  br i1 %45, label %62, label %64

.lr.ph57:                                         ; preds = %.preheader, %58
  %.356 = phi i8 [ %.4, %58 ], [ %.0.lcssa, %.preheader ]
  %.04255 = phi i32 [ %59, %58 ], [ 0, %.preheader ]
  %46 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @_ZZ5solvevE1e, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZZ5solvevE1e, i64 4), ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZZ5solvevE1e, i64 12))
  %47 = trunc nuw i8 %.356 to i1
  br i1 %47, label %58, label %48

48:                                               ; preds = %.lr.ph57
  %49 = load i32, ptr @_ZZ5solvevE1e, align 16, !tbaa !16
  %50 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ5solvevE1e, i64 4), align 4, !tbaa !17
  %51 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ5solvevE1e, i64 12), align 4, !tbaa !13
  %52 = invoke noundef zeroext i1 @"_ZZ5solvevENK3$_1clEiii"(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %49, i32 noundef %50, i32 noundef %51)
          to label %53 unwind label %56

53:                                               ; preds = %48
  %54 = xor i1 %52, true
  %55 = zext i1 %54 to i8
  br label %58

56:                                               ; preds = %48
  %57 = landingpad { ptr, i32 }
          cleanup
  br label %105

58:                                               ; preds = %53, %.lr.ph57
  %.4 = phi i8 [ %.356, %.lr.ph57 ], [ %55, %53 ]
  %59 = add nuw nsw i32 %.04255, 1
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %.lr.ph57, label %._crit_edge58, !llvm.loop !19

62:                                               ; preds = %._crit_edge58
  %63 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.loopexit

64:                                               ; preds = %._crit_edge58
  %65 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.4)
  %66 = load i32, ptr %1, align 4, !tbaa !5
  %67 = icmp sgt i32 %66, 1
  br i1 %67, label %.lr.ph62, label %.loopexit

.lr.ph62:                                         ; preds = %64, %96
  %indvars.iv64 = phi i64 [ %indvars.iv.next65, %96 ], [ 1, %64 ]
  %68 = getelementptr inbounds [2000009 x %struct.Edge], ptr @_ZZ5solvevE1e, i64 0, i64 %indvars.iv64
  %69 = getelementptr inbounds i8, ptr %68, i64 8
  %70 = load i32, ptr %69, align 8, !tbaa !11
  %71 = icmp eq i32 %70, -1
  %.pre68 = load i32, ptr %68, align 16, !tbaa !16
  br i1 %71, label %72, label %96

72:                                               ; preds = %.lr.ph62
  %73 = invoke noundef i32 @_ZNKSt8functionIFiiEEclEi(ptr noundef nonnull align 8 dereferenceable(32) %3, i32 noundef %.pre68)
          to label %74 unwind label %90

74:                                               ; preds = %72
  %75 = getelementptr inbounds i8, ptr %68, i64 4
  %76 = load i32, ptr %75, align 4, !tbaa !17
  %77 = invoke noundef i32 @_ZNKSt8functionIFiiEEclEi(ptr noundef nonnull align 8 dereferenceable(32) %3, i32 noundef %76)
          to label %78 unwind label %90

78:                                               ; preds = %74
  %79 = icmp eq i32 %73, %77
  br i1 %79, label %80, label %92

80:                                               ; preds = %78
  %81 = load i32, ptr %68, align 16, !tbaa !16
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [2000009 x i32], ptr @_ZZ5solvevE3dis, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = load i32, ptr %75, align 4, !tbaa !17
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2000009 x i32], ptr @_ZZ5solvevE3dis, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = xor i32 %88, %84
  store i32 %89, ptr %69, align 8, !tbaa !11
  br label %96

90:                                               ; preds = %92, %74, %72
  %91 = landingpad { ptr, i32 }
          cleanup
  br label %105

92:                                               ; preds = %78
  store i32 0, ptr %69, align 8, !tbaa !11
  %93 = load i32, ptr %68, align 16, !tbaa !16
  %94 = load i32, ptr %75, align 4, !tbaa !17
  %95 = invoke noundef zeroext i1 @"_ZZ5solvevENK3$_1clEiii"(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %93, i32 noundef %94, i32 noundef 0)
          to label %._crit_edge67 unwind label %90

._crit_edge67:                                    ; preds = %92
  %.pre = load i32, ptr %68, align 16, !tbaa !16
  %.pre69 = load i32, ptr %69, align 8, !tbaa !11
  br label %96

96:                                               ; preds = %._crit_edge67, %80, %.lr.ph62
  %97 = phi i32 [ %.pre69, %._crit_edge67 ], [ %89, %80 ], [ %70, %.lr.ph62 ]
  %98 = phi i32 [ %.pre, %._crit_edge67 ], [ %81, %80 ], [ %.pre68, %.lr.ph62 ]
  %99 = getelementptr inbounds i8, ptr %68, i64 4
  %100 = load i32, ptr %99, align 4, !tbaa !17
  %101 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %98, i32 noundef %100, i32 noundef %97)
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %102 = load i32, ptr %1, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = icmp slt i64 %indvars.iv.next65, %103
  br i1 %104, label %.lr.ph62, label %.loopexit, !llvm.loop !20

.loopexit:                                        ; preds = %96, %64, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret void

105:                                              ; preds = %90, %56, %20
  %.pn = phi { ptr, i32 } [ %21, %20 ], [ %57, %56 ], [ %91, %90 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  resume { ptr, i32 } %.pn
}

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

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

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef zeroext i1 @"_ZZ5solvevENK3$_1clEiii"(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #5 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

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

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

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

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


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