; LLVM IR from Tunghohin/Competitive_Coding :: Luogu/p1272.ll (Z3dfsii)

; 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 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@p = external dso_local global i32, align 4
@sz = external dso_local global [1010 x i32], align 16
@dp = external dso_local global [1010 x [1010 x i32]], align 16
@ans = external dso_local global i32, align 4
@G = external dso_local global [1010 x %"class.std::vector"], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %12 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %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
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %19
  %21 = getelementptr inbounds [1010 x i32], ptr %20, i64 0, i64 0
  store i32 0, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1010 x %"class.std::vector"], ptr @G, i64 0, i64 %23
  store ptr %24, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %25) #4
  %27 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  store ptr %26, ptr %27, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %28) #4
  %30 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %29, ptr %30, align 8
  br label %31

31:                                               ; preds = %56, %2
  %32 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  br i1 %32, label %34, label %33

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

34:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  %36 = load i32, ptr %35, align 4, !tbaa !5
  store i32 %36, ptr %9, align 4, !tbaa !5
  %37 = load i32, ptr %9, align 4, !tbaa !5
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = icmp eq i32 %37, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %34
  store i32 3, ptr %8, align 4
  br label %53

41:                                               ; preds = %34
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = load i32, ptr %3, align 4, !tbaa !5
  call void @_Z3dfsii(i32 noundef %42, i32 noundef %43)
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = add nsw i32 %51, %47
  store i32 %52, ptr %50, align 4, !tbaa !5
  store i32 0, ptr %8, align 4
  br label %53

53:                                               ; preds = %41, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %54 = load i32, ptr %8, align 4
  switch i32 %54, label %201 [
    i32 0, label %55
    i32 3, label %56
  ]

55:                                               ; preds = %53
  br label %56

56:                                               ; preds = %55, %53
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #4
  br label %31

58:                                               ; preds = %33
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %61, align 4, !tbaa !5
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %65
  %67 = getelementptr inbounds [1010 x i32], ptr %66, i64 0, i64 0
  store i32 0, ptr %67, align 8, !tbaa !5
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %69
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1010 x i32], ptr %70, i64 0, i64 %75
  store i32 1, ptr %76, align 4, !tbaa !5
  %77 = load i32, ptr %3, align 4, !tbaa !5
  %78 = icmp eq i32 %77, 1
  br i1 %78, label %79, label %86

79:                                               ; preds = %58
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds ([1010 x [1010 x i32]], ptr @dp, i64 0, i64 1), i64 0, i64 %84
  store i32 0, ptr %85, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %79, %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %87 = load i32, ptr %3, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1010 x %"class.std::vector"], ptr @G, i64 0, i64 %88
  store ptr %89, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %90 = load ptr, ptr %10, align 8, !tbaa !9
  %91 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %90) #4
  %92 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %11, i32 0, i32 0
  store ptr %91, ptr %92, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %93 = load ptr, ptr %10, align 8, !tbaa !9
  %94 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %93) #4
  %95 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  store ptr %94, ptr %95, align 8
  br label %96

96:                                               ; preds = %165, %86
  %97 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12) #4
  br i1 %97, label %99, label %98

98:                                               ; preds = %96
  store i32 4, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %167

99:                                               ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %100 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  %101 = load i32, ptr %100, align 4, !tbaa !5
  store i32 %101, ptr %13, align 4, !tbaa !5
  %102 = load i32, ptr %13, align 4, !tbaa !5
  %103 = load i32, ptr %4, align 4, !tbaa !5
  %104 = icmp eq i32 %102, %103
  br i1 %104, label %105, label %106

105:                                              ; preds = %99
  store i32 5, ptr %8, align 4
  br label %162

106:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %107 = load i32, ptr %3, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = sub nsw i32 %110, 1
  store i32 %111, ptr %14, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %158, %106
  %113 = load i32, ptr %14, align 4, !tbaa !5
  %114 = icmp ne i32 %113, 0
  br i1 %114, label %116, label %115

115:                                              ; preds = %112
  store i32 6, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %161

116:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %117

117:                                              ; preds = %154, %116
  %118 = load i32, ptr %15, align 4, !tbaa !5
  %119 = load i32, ptr %14, align 4, !tbaa !5
  %120 = icmp sle i32 %118, %119
  br i1 %120, label %122, label %121

121:                                              ; preds = %117
  store i32 9, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %157

122:                                              ; preds = %117
  %123 = load i32, ptr %3, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %124
  %126 = load i32, ptr %14, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1010 x i32], ptr %125, i64 0, i64 %127
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %129 = load i32, ptr %3, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %130
  %132 = load i32, ptr %14, align 4, !tbaa !5
  %133 = load i32, ptr %15, align 4, !tbaa !5
  %134 = sub nsw i32 %132, %133
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [1010 x i32], ptr %131, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = load i32, ptr %13, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %139
  %141 = load i32, ptr %15, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [1010 x i32], ptr %140, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = add nsw i32 %137, %144
  store i32 %145, ptr %16, align 4, !tbaa !5
  %146 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %128, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = load i32, ptr %3, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %149
  %151 = load i32, ptr %14, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [1010 x i32], ptr %150, i64 0, i64 %152
  store i32 %147, ptr %153, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %154

154:                                              ; preds = %122
  %155 = load i32, ptr %15, align 4, !tbaa !5
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %15, align 4, !tbaa !5
  br label %117, !llvm.loop !11

157:                                              ; preds = %121
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %14, align 4, !tbaa !5
  %160 = add nsw i32 %159, -1
  store i32 %160, ptr %14, align 4, !tbaa !5
  br label %112, !llvm.loop !13

161:                                              ; preds = %115
  store i32 0, ptr %8, align 4
  br label %162

162:                                              ; preds = %161, %105
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  %163 = load i32, ptr %8, align 4
  switch i32 %163, label %201 [
    i32 0, label %164
    i32 5, label %165
  ]

164:                                              ; preds = %162
  br label %165

165:                                              ; preds = %164, %162
  %166 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  br label %96

167:                                              ; preds = %98
  %168 = load i32, ptr %3, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %169
  %171 = load i32, ptr %170, align 4, !tbaa !5
  %172 = load i32, ptr @p, align 4, !tbaa !5
  %173 = icmp sge i32 %171, %172
  br i1 %173, label %174, label %200

174:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %175 = load i32, ptr %3, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %176
  %178 = load i32, ptr %3, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = load i32, ptr @p, align 4, !tbaa !5
  %183 = sub nsw i32 %181, %182
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [1010 x i32], ptr %177, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !5
  %187 = load i32, ptr %3, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %188
  %190 = load i32, ptr %3, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %191
  %193 = load i32, ptr %192, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [1010 x i32], ptr %189, i64 0, i64 %194
  %196 = load i32, ptr %195, align 4, !tbaa !5
  %197 = add nsw i32 %186, %196
  store i32 %197, ptr %17, align 4, !tbaa !5
  %198 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %199 = load i32, ptr %198, align 4, !tbaa !5
  store i32 %199, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %200

200:                                              ; preds = %174, %167
  ret void

201:                                              ; preds = %162, %53
  unreachable
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

; 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 nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

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

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 = { 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 }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@p = external dso_local local_unnamed_addr global i32, align 4
@sz = external dso_local local_unnamed_addr global [1010 x i32], align 16
@dp = external dso_local global [1010 x [1010 x i32]], align 16
@ans = external dso_local global i32, align 4
@G = external dso_local global [1010 x %"class.std::vector"], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3dfsii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = sext i32 %0 to i64
  %10 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %9
  store i32 0, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds [1010 x %"class.std::vector"], ptr @G, i64 0, i64 %9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %12 = tail call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #3
  store ptr %12, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %13 = tail call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #3
  store ptr %13, ptr %4, align 8
  %14 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %15 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %9
  br label %22

._crit_edge:                                      ; preds = %32, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  %16 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %9
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %16, align 4, !tbaa !5
  store i32 0, ptr %10, align 8, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %9, i64 %19
  store i32 1, ptr %20, align 4, !tbaa !5
  %21 = icmp eq i32 %0, 1
  br i1 %21, label %35, label %37

22:                                               ; preds = %.lr.ph, %32
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #3
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = icmp eq i32 %24, %1
  br i1 %25, label %32, label %26

26:                                               ; preds = %22
  call void @_Z3dfsii(i32 noundef %24, i32 noundef %0)
  %27 = sext i32 %24 to i64
  %28 = getelementptr inbounds [1010 x i32], ptr @sz, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr %15, align 4, !tbaa !5
  %31 = add nsw i32 %30, %29
  store i32 %31, ptr %15, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %22, %26
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #3
  %34 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  br i1 %34, label %22, label %._crit_edge

35:                                               ; preds = %._crit_edge
  %36 = getelementptr inbounds [1010 x i32], ptr getelementptr inbounds (i8, ptr @dp, i64 4040), i64 0, i64 %19
  store i32 0, ptr %36, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %35, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %38 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #3
  store ptr %38, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %39 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #3
  store ptr %39, ptr %6, align 8
  %40 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  br i1 %40, label %.lr.ph54, label %._crit_edge55

._crit_edge55:                                    ; preds = %.loopexit45, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  %41 = load i32, ptr %16, align 4, !tbaa !5
  %42 = load i32, ptr @p, align 4, !tbaa !5
  %.not = icmp slt i32 %41, %42
  br i1 %.not, label %74, label %63

.lr.ph54:                                         ; preds = %37, %.loopexit45
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = icmp eq i32 %44, %1
  br i1 %45, label %.loopexit45, label %46

46:                                               ; preds = %.lr.ph54
  %47 = load i32, ptr %16, align 4, !tbaa !5
  %.not4350 = icmp eq i32 %47, 1
  br i1 %.not4350, label %.loopexit45, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %46
  %48 = sext i32 %44 to i64
  %49 = sext i32 %47 to i64
  %50 = add nsw i64 %49, -1
  br label %.preheader

.loopexit:                                        ; preds = %52, %.preheader
  %indvars.iv.next60 = add nsw i64 %indvars.iv59, -1
  %.not43 = icmp eq i64 %indvars.iv.next60, 0
  %indvars.iv.next58 = add nsw i32 %indvars.iv57, -1
  br i1 %.not43, label %.loopexit45, label %.preheader, !llvm.loop !9

.preheader:                                       ; preds = %.preheader.lr.ph, %.loopexit
  %indvars.iv59 = phi i64 [ %50, %.preheader.lr.ph ], [ %indvars.iv.next60, %.loopexit ]
  %indvars.iv57 = phi i32 [ %47, %.preheader.lr.ph ], [ %indvars.iv.next58, %.loopexit ]
  %.not44.not46 = icmp sgt i32 %indvars.iv57, 0
  br i1 %.not44.not46, label %.lr.ph48, label %.loopexit

.lr.ph48:                                         ; preds = %.preheader
  %51 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %9, i64 %indvars.iv59
  %wide.trip.count = zext nneg i32 %indvars.iv57 to i64
  br label %52

52:                                               ; preds = %.lr.ph48, %52
  %indvars.iv = phi i64 [ 0, %.lr.ph48 ], [ %indvars.iv.next, %52 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %53 = sub nsw i64 %indvars.iv59, %indvars.iv
  %54 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %9, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %48, i64 %indvars.iv
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = add nsw i32 %57, %55
  store i32 %58, ptr %7, align 4, !tbaa !5
  %59 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %51, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %60 = load i32, ptr %59, align 4, !tbaa !5
  store i32 %60, ptr %51, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  %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 %.loopexit, label %52, !llvm.loop !11

.loopexit45:                                      ; preds = %.loopexit, %46, %.lr.ph54
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  %62 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  br i1 %62, label %.lr.ph54, label %._crit_edge55

63:                                               ; preds = %._crit_edge55
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %64 = sub nsw i32 %41, %42
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %9, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sext i32 %41 to i64
  %69 = getelementptr inbounds [1010 x [1010 x i32]], ptr @dp, i64 0, i64 %9, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = add nsw i32 %70, %67
  store i32 %71, ptr %8, align 4, !tbaa !5
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %73 = load i32, ptr %72, align 4, !tbaa !5
  store i32 %73, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  br label %74

74:                                               ; preds = %63, %._crit_edge55
  ret void
}

; 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 nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

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

; 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 nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

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

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

!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}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass