; LLVM IR from reyadussalahin/problem-solving :: graph/lca/codeforces/F208E (Solution)

; 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"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@adj = external dso_local global [100010 x %"class.std::vector"], align 16
@p = external dso_local global [100010 x i32], align 16
@lev = external dso_local global [100010 x i32], align 16
@stp = external dso_local global [100010 x [19 x i32]], align 16
@stm = external dso_local global [100010 x i32], align 16
@etm = external dso_local global [100010 x i32], align 16
@b = external dso_local global [100010 x %"class.std::vector"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsiii(i32 noundef, i32 noundef, i32 noundef) #0

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z11getAncestorii(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %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 i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %46, %0
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = icmp sle i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %49

28:                                               ; preds = %23
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %30
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %31)
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %45

38:                                               ; preds = %28
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @adj, i64 0, i64 %43
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %44, ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %45

45:                                               ; preds = %38, %28
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !5
  br label %23, !llvm.loop !9

49:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %71, %49
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = icmp sle i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %74

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %67, %55
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = icmp slt i32 %57, 19
  br i1 %58, label %60, label %59

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

60:                                               ; preds = %56
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100010 x [19 x i32]], ptr @stp, i64 0, i64 %62
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [19 x i32], ptr %63, i64 0, i64 %65
  store i32 -1, ptr %66, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %60
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %6, align 4, !tbaa !5
  br label %56, !llvm.loop !11

70:                                               ; preds = %59
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %4, align 4, !tbaa !5
  br label %50, !llvm.loop !12

74:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %89, %74
  %76 = load i32, ptr %7, align 4, !tbaa !5
  %77 = load i32, ptr %2, align 4, !tbaa !5
  %78 = icmp sle i32 %76, %77
  br i1 %78, label %80, label %79

79:                                               ; preds = %75
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %92

80:                                               ; preds = %75
  %81 = load i32, ptr %7, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %86, label %88

86:                                               ; preds = %80
  %87 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z3dfsiii(i32 noundef %87, i32 noundef -1, i32 noundef 0)
  br label %88

88:                                               ; preds = %86, %80
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %7, align 4, !tbaa !5
  br label %75, !llvm.loop !13

92:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %93 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %206, %92
  %95 = load i32, ptr %9, align 4, !tbaa !5
  %96 = load i32, ptr %8, align 4, !tbaa !5
  %97 = icmp slt i32 %95, %96
  br i1 %97, label %99, label %98

98:                                               ; preds = %94
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %209

99:                                               ; preds = %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %100 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %10, ptr noundef %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %101 = load i32, ptr %10, align 4, !tbaa !5
  %102 = load i32, ptr %11, align 4, !tbaa !5
  %103 = call noundef i32 @_Z11getAncestorii(i32 noundef %101, i32 noundef %102)
  store i32 %103, ptr %12, align 4, !tbaa !5
  %104 = load i32, ptr %12, align 4, !tbaa !5
  %105 = icmp eq i32 %104, -1
  br i1 %105, label %106, label %108

106:                                              ; preds = %99
  %107 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  store i32 16, ptr %5, align 4
  br label %203

108:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %109 = load i32, ptr %10, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [100010 x i32], ptr @lev, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  store i32 %112, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %113 = load i32, ptr %13, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @b, i64 0, i64 %114
  %116 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %115) #6
  %117 = trunc i64 %116 to i32
  %118 = sub nsw i32 %117, 1
  store i32 %118, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 -1, ptr %16, align 4, !tbaa !5
  br label %119

119:                                              ; preds = %147, %108
  %120 = load i32, ptr %14, align 4, !tbaa !5
  %121 = load i32, ptr %15, align 4, !tbaa !5
  %122 = icmp sle i32 %120, %121
  br i1 %122, label %123, label %148

123:                                              ; preds = %119
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %124 = load i32, ptr %14, align 4, !tbaa !5
  %125 = load i32, ptr %15, align 4, !tbaa !5
  %126 = add nsw i32 %124, %125
  %127 = sdiv i32 %126, 2
  store i32 %127, ptr %17, align 4, !tbaa !5
  %128 = load i32, ptr %13, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @b, i64 0, i64 %129
  %131 = load i32, ptr %17, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %130, i64 noundef %132) #6
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = load i32, ptr %12, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100010 x i32], ptr @stm, i64 0, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !5
  %139 = icmp sgt i32 %134, %138
  br i1 %139, label %140, label %144

140:                                              ; preds = %123
  %141 = load i32, ptr %17, align 4, !tbaa !5
  store i32 %141, ptr %16, align 4, !tbaa !5
  %142 = load i32, ptr %17, align 4, !tbaa !5
  %143 = sub nsw i32 %142, 1
  store i32 %143, ptr %15, align 4, !tbaa !5
  br label %147

144:                                              ; preds = %123
  %145 = load i32, ptr %17, align 4, !tbaa !5
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %14, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %144, %140
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %119, !llvm.loop !14

148:                                              ; preds = %119
  %149 = load i32, ptr %16, align 4, !tbaa !5
  %150 = icmp eq i32 %149, -1
  br i1 %150, label %151, label %153

151:                                              ; preds = %148
  %152 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  store i32 16, ptr %5, align 4
  br label %202

153:                                              ; preds = %148
  store i32 0, ptr %14, align 4, !tbaa !5
  %154 = load i32, ptr %13, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @b, i64 0, i64 %155
  %157 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %156) #6
  %158 = trunc i64 %157 to i32
  %159 = sub nsw i32 %158, 1
  store i32 %159, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 -1, ptr %18, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %188, %153
  %161 = load i32, ptr %14, align 4, !tbaa !5
  %162 = load i32, ptr %15, align 4, !tbaa !5
  %163 = icmp sle i32 %161, %162
  br i1 %163, label %164, label %189

164:                                              ; preds = %160
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %165 = load i32, ptr %14, align 4, !tbaa !5
  %166 = load i32, ptr %15, align 4, !tbaa !5
  %167 = add nsw i32 %165, %166
  %168 = sdiv i32 %167, 2
  store i32 %168, ptr %19, align 4, !tbaa !5
  %169 = load i32, ptr %13, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @b, i64 0, i64 %170
  %172 = load i32, ptr %19, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %171, i64 noundef %173) #6
  %175 = load i32, ptr %174, align 4, !tbaa !5
  %176 = load i32, ptr %12, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [100010 x i32], ptr @etm, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = icmp slt i32 %175, %179
  br i1 %180, label %181, label %185

181:                                              ; preds = %164
  %182 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %182, ptr %18, align 4, !tbaa !5
  %183 = load i32, ptr %19, align 4, !tbaa !5
  %184 = add nsw i32 %183, 1
  store i32 %184, ptr %14, align 4, !tbaa !5
  br label %188

185:                                              ; preds = %164
  %186 = load i32, ptr %19, align 4, !tbaa !5
  %187 = sub nsw i32 %186, 1
  store i32 %187, ptr %15, align 4, !tbaa !5
  br label %188

188:                                              ; preds = %185, %181
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %160, !llvm.loop !15

189:                                              ; preds = %160
  %190 = load i32, ptr %18, align 4, !tbaa !5
  %191 = icmp eq i32 %190, -1
  br i1 %191, label %192, label %194

192:                                              ; preds = %189
  %193 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  store i32 16, ptr %5, align 4
  br label %201

194:                                              ; preds = %189
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 0, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %195 = load i32, ptr %18, align 4, !tbaa !5
  %196 = load i32, ptr %16, align 4, !tbaa !5
  %197 = sub nsw i32 %195, %196
  store i32 %197, ptr %21, align 4, !tbaa !5
  %198 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %20, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %199 = load i32, ptr %198, align 4, !tbaa !5
  %200 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %199)
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  store i32 0, ptr %5, align 4
  br label %201

201:                                              ; preds = %194, %192
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %202

202:                                              ; preds = %201, %151
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %203

203:                                              ; preds = %202, %106
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %204 = load i32, ptr %5, align 4
  switch i32 %204, label %212 [
    i32 0, label %205
    i32 16, label %206
  ]

205:                                              ; preds = %203
  br label %206

206:                                              ; preds = %205, %203
  %207 = load i32, ptr %9, align 4, !tbaa !5
  %208 = add nsw i32 %207, 1
  store i32 %208, ptr %9, align 4, !tbaa !5
  br label %94, !llvm.loop !16

209:                                              ; preds = %98
  %210 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %211 = load i32, ptr %1, align 4
  ret i32 %211

212:                                              ; preds = %203
  unreachable
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

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

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 = { 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 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "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 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@adj = external dso_local global [100010 x %"class.std::vector"], align 16
@p = external dso_local global [100010 x i32], align 16
@lev = external dso_local local_unnamed_addr global [100010 x i32], align 16
@stp = external dso_local local_unnamed_addr global [100010 x [19 x i32]], align 16
@stm = external dso_local local_unnamed_addr global [100010 x i32], align 16
@etm = external dso_local local_unnamed_addr global [100010 x i32], align 16
@b = external dso_local global [100010 x %"class.std::vector"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z11getAncestorii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %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 i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 1, ptr %2, align 4, !tbaa !5
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %.not61 = icmp slt i32 %9, 1
  br i1 %.not61, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %21, %0
  %10 = phi i32 [ %9, %0 ], [ %24, %21 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %.not5564 = icmp slt i32 %10, 0
  br i1 %.not5564, label %._crit_edge69, label %.preheader

.lr.ph:                                           ; preds = %0, %21
  %storemerge62 = phi i32 [ %23, %21 ], [ 1, %0 ]
  %11 = sext i32 %storemerge62 to i64
  %12 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %11
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %12)
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %.not59 = icmp eq i32 %17, 0
  br i1 %.not59, label %21, label %18

18:                                               ; preds = %.lr.ph
  %19 = sext i32 %17 to i64
  %20 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @adj, i64 0, i64 %19
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %.lr.ph, %18
  %22 = phi i32 [ %14, %.lr.ph ], [ %.pre, %18 ]
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %2, align 4, !tbaa !5
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %.not.not = icmp slt i32 %22, %24
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader:                                       ; preds = %._crit_edge
  %25 = add nuw i32 %10, 1
  %26 = zext i32 %25 to i64
  %27 = mul nuw nsw i64 %26, 76
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) @stp, i8 -1, i64 %27, i1 false), !tbaa !5
  %.not5666 = icmp eq i32 %10, 0
  br i1 %.not5666, label %._crit_edge69, label %.lr.ph68

._crit_edge69:                                    ; preds = %37, %._crit_edge, %.preheader
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3)
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %.lr.ph88, label %._crit_edge89

.lr.ph68:                                         ; preds = %.preheader, %37
  %31 = phi i32 [ %38, %37 ], [ %10, %.preheader ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %37 ], [ 1, %.preheader ]
  %32 = getelementptr inbounds [100010 x i32], ptr @p, i64 0, i64 %indvars.iv
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %37

35:                                               ; preds = %.lr.ph68
  %36 = trunc nuw nsw i64 %indvars.iv to i32
  call void @_Z3dfsiii(i32 noundef %36, i32 noundef -1, i32 noundef 0)
  %.pre94 = load i32, ptr %1, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %.lr.ph68, %35
  %38 = phi i32 [ %31, %.lr.ph68 ], [ %.pre94, %35 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %39 = sext i32 %38 to i64
  %.not56.not = icmp slt i64 %indvars.iv, %39
  br i1 %.not56.not, label %.lr.ph68, label %._crit_edge69, !llvm.loop !11

._crit_edge89:                                    ; preds = %95, %._crit_edge69
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0

.lr.ph88:                                         ; preds = %._crit_edge69, %95
  %.05086 = phi i32 [ %96, %95 ], [ 0, %._crit_edge69 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = call noundef i32 @_Z11getAncestorii(i32 noundef %42, i32 noundef %43)
  %45 = icmp eq i32 %44, -1
  br i1 %45, label %46, label %48

46:                                               ; preds = %.lr.ph88
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %95

48:                                               ; preds = %.lr.ph88
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100010 x i32], ptr @lev, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @b, i64 0, i64 %53
  %55 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %54) #7
  %56 = trunc i64 %55 to i32
  %.not5770 = icmp slt i32 %56, 1
  br i1 %.not5770, label %._crit_edge76.thread, label %.lr.ph75

.lr.ph75:                                         ; preds = %48
  %57 = add nsw i32 %56, -1
  %58 = sext i32 %44 to i64
  %59 = getelementptr inbounds [100010 x i32], ptr @stm, i64 0, i64 %58
  br label %60

60:                                               ; preds = %.lr.ph75, %60
  %.04173 = phi i32 [ -1, %.lr.ph75 ], [ %.142, %60 ]
  %.04372 = phi i32 [ %57, %.lr.ph75 ], [ %.144, %60 ]
  %.04571 = phi i32 [ 0, %.lr.ph75 ], [ %.146, %60 ]
  %61 = add nuw nsw i32 %.04372, %.04571
  %62 = lshr i32 %61, 1
  %63 = zext nneg i32 %62 to i64
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %54, i64 noundef %63) #7
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = load i32, ptr %59, align 4, !tbaa !5
  %67 = icmp sgt i32 %65, %66
  %68 = add nsw i32 %62, -1
  %69 = add nuw nsw i32 %62, 1
  %.146 = select i1 %67, i32 %.04571, i32 %69
  %.144 = select i1 %67, i32 %68, i32 %.04372
  %.142 = select i1 %67, i32 %62, i32 %.04173
  %.not57 = icmp sgt i32 %.146, %.144
  br i1 %.not57, label %._crit_edge76, label %60, !llvm.loop !12

._crit_edge76:                                    ; preds = %60
  %70 = icmp eq i32 %.142, -1
  br i1 %70, label %._crit_edge76.thread, label %72

._crit_edge76.thread:                             ; preds = %48, %._crit_edge76
  %71 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %95

72:                                               ; preds = %._crit_edge76
  %73 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %54) #7
  %74 = trunc i64 %73 to i32
  %.not5878 = icmp slt i32 %74, 1
  br i1 %.not5878, label %._crit_edge84.thread, label %.lr.ph83

.lr.ph83:                                         ; preds = %72
  %75 = add nsw i32 %74, -1
  %76 = sext i32 %44 to i64
  %77 = getelementptr inbounds [100010 x i32], ptr @etm, i64 0, i64 %76
  br label %78

78:                                               ; preds = %.lr.ph83, %78
  %.081 = phi i32 [ -1, %.lr.ph83 ], [ %.1, %78 ]
  %.280 = phi i32 [ %75, %.lr.ph83 ], [ %.3, %78 ]
  %.24779 = phi i32 [ 0, %.lr.ph83 ], [ %.348, %78 ]
  %79 = add nuw nsw i32 %.280, %.24779
  %80 = lshr i32 %79, 1
  %81 = zext nneg i32 %80 to i64
  %82 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %54, i64 noundef %81) #7
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %77, align 4, !tbaa !5
  %85 = icmp slt i32 %83, %84
  %86 = add nuw nsw i32 %80, 1
  %87 = add nsw i32 %80, -1
  %.348 = select i1 %85, i32 %86, i32 %.24779
  %.3 = select i1 %85, i32 %.280, i32 %87
  %.1 = select i1 %85, i32 %80, i32 %.081
  %.not58 = icmp sgt i32 %.348, %.3
  br i1 %.not58, label %._crit_edge84, label %78, !llvm.loop !13

._crit_edge84:                                    ; preds = %78
  %88 = icmp eq i32 %.1, -1
  br i1 %88, label %._crit_edge84.thread, label %90

._crit_edge84.thread:                             ; preds = %72, %._crit_edge84
  %89 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %95

90:                                               ; preds = %._crit_edge84
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %91 = sub nsw i32 %.1, %.142
  store i32 %91, ptr %7, align 4, !tbaa !5
  %92 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %93)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  br label %95

95:                                               ; preds = %._crit_edge76.thread, %90, %._crit_edge84.thread, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  %96 = add nuw nsw i32 %.05086, 1
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %.lr.ph88, label %._crit_edge89, !llvm.loop !14
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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

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

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

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

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

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


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