; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/311 Division 2/Problem D (D)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@color = external dso_local global [100100 x i32], align 16
@v = external dso_local global [100100 x i32], align 16
@g = external dso_local global [100100 x %"class.std::vector"], align 16
@comp = external dso_local global [100100 x %"class.std::vector"], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z3dfsiiii(i32 noundef, 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: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(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 ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #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 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %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 i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %14 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %30, %0
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %33

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3, ptr noundef %4)
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @g, i64 0, i64 %25
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @g, i64 0, i64 %28
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %29, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %30

30:                                               ; preds = %22
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !9

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

34:                                               ; preds = %54, %33
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = icmp sle i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 5, ptr %7, align 4
  br label %57

39:                                               ; preds = %34
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100100 x i32], ptr @v, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %53, label %45

45:                                               ; preds = %39
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %5, align 4, !tbaa !5
  %49 = call noundef zeroext i1 @_Z3dfsiiii(i32 noundef %46, i32 noundef -1, i32 noundef 1, i32 noundef %47)
  br i1 %49, label %52, label %50

50:                                               ; preds = %45
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %57

52:                                               ; preds = %45
  br label %53

53:                                               ; preds = %52, %39
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %6, align 4, !tbaa !5
  br label %34, !llvm.loop !11

57:                                               ; preds = %50, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %58 = load i32, ptr %7, align 4
  switch i32 %58, label %172 [
    i32 5, label %59
  ]

59:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %121, %59
  %61 = load i32, ptr %9, align 4, !tbaa !5
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %124

65:                                               ; preds = %60
  %66 = load i32, ptr %9, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @comp, i64 0, i64 %67
  %69 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %68) #6
  %70 = icmp ugt i64 %69, 2
  br i1 %70, label %71, label %120

71:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @comp, i64 0, i64 %73
  %75 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %74) #6
  %76 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  store ptr %75, ptr %76, align 8
  br label %77

77:                                               ; preds = %99, %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @comp, i64 0, i64 %79
  %81 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %80) #6
  %82 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %81, ptr %82, align 8
  %83 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br i1 %83, label %85, label %84

84:                                               ; preds = %77
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %102

85:                                               ; preds = %77
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %12) #6
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100100 x i32], ptr @color, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = icmp eq i32 %90, 1
  br i1 %91, label %92, label %95

92:                                               ; preds = %85
  %93 = load i32, ptr %10, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %10, align 4, !tbaa !5
  br label %98

95:                                               ; preds = %85
  %96 = load i32, ptr %11, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %11, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %95, %92
  br label %99

99:                                               ; preds = %98
  %100 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef 0) #6
  %101 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %100, ptr %101, align 8
  br label %77, !llvm.loop !14

102:                                              ; preds = %84
  %103 = load i32, ptr %10, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = load i32, ptr %10, align 4, !tbaa !5
  %106 = sub nsw i32 %105, 1
  %107 = sext i32 %106 to i64
  %108 = mul nsw i64 %104, %107
  %109 = sdiv i64 %108, 2
  %110 = load i32, ptr %11, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = load i32, ptr %11, align 4, !tbaa !5
  %113 = sub nsw i32 %112, 1
  %114 = sext i32 %113 to i64
  %115 = mul nsw i64 %111, %114
  %116 = sdiv i64 %115, 2
  %117 = add nsw i64 %109, %116
  %118 = load i64, ptr %8, align 8, !tbaa !12
  %119 = add nsw i64 %118, %117
  store i64 %119, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %120

120:                                              ; preds = %102, %65
  br label %121

121:                                              ; preds = %120
  %122 = load i32, ptr %9, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %9, align 4, !tbaa !5
  br label %60, !llvm.loop !15

124:                                              ; preds = %64
  %125 = load i64, ptr %8, align 8, !tbaa !12
  %126 = icmp sgt i64 %125, 0
  br i1 %126, label %127, label %130

127:                                              ; preds = %124
  %128 = load i64, ptr %8, align 8, !tbaa !12
  %129 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i64 noundef %128)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %171

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

131:                                              ; preds = %149, %130
  %132 = load i32, ptr %15, align 4, !tbaa !5
  %133 = load i32, ptr %5, align 4, !tbaa !5
  %134 = icmp slt i32 %132, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %131
  store i32 14, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %152

136:                                              ; preds = %131
  %137 = load i32, ptr %15, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @comp, i64 0, i64 %138
  %140 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %139) #6
  %141 = icmp ugt i64 %140, 1
  br i1 %141, label %142, label %148

142:                                              ; preds = %136
  %143 = load i32, ptr @n, align 4, !tbaa !5
  %144 = sub nsw i32 %143, 2
  %145 = sext i32 %144 to i64
  %146 = load i64, ptr %8, align 8, !tbaa !12
  %147 = add nsw i64 %146, %145
  store i64 %147, ptr %8, align 8, !tbaa !12
  br label %148

148:                                              ; preds = %142, %136
  br label %149

149:                                              ; preds = %148
  %150 = load i32, ptr %15, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %15, align 4, !tbaa !5
  br label %131, !llvm.loop !16

152:                                              ; preds = %135
  %153 = load i64, ptr %8, align 8, !tbaa !12
  %154 = icmp sgt i64 %153, 0
  br i1 %154, label %155, label %158

155:                                              ; preds = %152
  %156 = load i64, ptr %8, align 8, !tbaa !12
  %157 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i64 noundef %156)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %171

158:                                              ; preds = %152
  %159 = load i32, ptr @n, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = load i32, ptr @n, align 4, !tbaa !5
  %162 = sub nsw i32 %161, 1
  %163 = sext i32 %162 to i64
  %164 = mul nsw i64 %160, %163
  %165 = load i32, ptr @n, align 4, !tbaa !5
  %166 = sub nsw i32 %165, 2
  %167 = sext i32 %166 to i64
  %168 = mul nsw i64 %164, %167
  %169 = sdiv i64 %168, 6
  %170 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i64 noundef %169)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %171

171:                                              ; preds = %158, %155, %127
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %172

172:                                              ; preds = %171, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  %173 = load i32, ptr %1, align 4
  ret i32 %173
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 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 = { 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 = { 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 #5 = { "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 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!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 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@color = external dso_local local_unnamed_addr global [100100 x i32], align 16
@v = external dso_local local_unnamed_addr global [100100 x i32], align 16
@g = external dso_local global [100100 x %"class.std::vector"], align 16
@comp = external dso_local global [100100 x %"class.std::vector"], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z3dfsiiii(i32 noundef, 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 nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #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)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 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 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %6 = load i32, ptr @m, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %.preheader49

.preheader49:                                     ; preds = %.lr.ph, %0
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %.not52 = icmp slt i32 %8, 1
  br i1 %.not52, label %._crit_edge69.thread, label %.lr.ph55

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.04551 = phi i32 [ %16, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @g, i64 0, i64 %11
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @g, i64 0, i64 %14
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %15, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %16 = add nuw nsw i32 %.04551, 1
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %.lr.ph, label %.preheader49, !llvm.loop !9

.preheader48:                                     ; preds = %28
  %19 = icmp sgt i32 %.143, 0
  br i1 %19, label %.lr.ph63.preheader, label %._crit_edge69.thread

.lr.ph63.preheader:                               ; preds = %.preheader48
  %wide.trip.count = zext nneg i32 %.143 to i64
  br label %.lr.ph63

.lr.ph55:                                         ; preds = %.preheader49, %28
  %20 = phi i32 [ %29, %28 ], [ %8, %.preheader49 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %28 ], [ 1, %.preheader49 ]
  %.04253 = phi i32 [ %.143, %28 ], [ 0, %.preheader49 ]
  %21 = getelementptr inbounds [100100 x i32], ptr @v, i64 0, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %.not46 = icmp eq i32 %22, 0
  br i1 %.not46, label %23, label %28

23:                                               ; preds = %.lr.ph55
  %24 = trunc nuw nsw i64 %indvars.iv to i32
  %25 = call noundef zeroext i1 @_Z3dfsiiii(i32 noundef %24, i32 noundef -1, i32 noundef 1, i32 noundef %.04253)
  br i1 %25, label %._crit_edge80, label %.thread

._crit_edge80:                                    ; preds = %23
  %26 = add nsw i32 %.04253, 1
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %28

.thread:                                          ; preds = %23
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %85

28:                                               ; preds = %._crit_edge80, %.lr.ph55
  %29 = phi i32 [ %20, %.lr.ph55 ], [ %.pre, %._crit_edge80 ]
  %.143 = phi i32 [ %.04253, %.lr.ph55 ], [ %26, %._crit_edge80 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = sext i32 %29 to i64
  %.not.not = icmp slt i64 %indvars.iv, %30
  br i1 %.not.not, label %.lr.ph55, label %.preheader48, !llvm.loop !11

._crit_edge64:                                    ; preds = %62
  %31 = icmp sgt i64 %.138, 0
  br i1 %31, label %63, label %.preheader

.preheader:                                       ; preds = %._crit_edge64
  br i1 %19, label %.lr.ph68.preheader, label %._crit_edge69.thread

.lr.ph68.preheader:                               ; preds = %.preheader
  %wide.trip.count78 = zext nneg i32 %.143 to i64
  br label %.lr.ph68

.lr.ph63:                                         ; preds = %.lr.ph63.preheader, %62
  %indvars.iv72 = phi i64 [ 0, %.lr.ph63.preheader ], [ %indvars.iv.next73, %62 ]
  %.03761 = phi i64 [ 0, %.lr.ph63.preheader ], [ %.138, %62 ]
  %32 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @comp, i64 0, i64 %indvars.iv72
  %33 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %32) #6
  %34 = icmp ugt i64 %33, 2
  br i1 %34, label %35, label %62

35:                                               ; preds = %.lr.ph63
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %36 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %32) #6
  store ptr %36, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %37 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %32) #6
  store ptr %37, ptr %4, align 8
  %38 = 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) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br i1 %38, label %.lr.ph58, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph58, %35
  %.034.lcssa = phi i32 [ 0, %35 ], [ %.135, %.lr.ph58 ]
  %.032.lcssa = phi i32 [ 0, %35 ], [ %.133, %.lr.ph58 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %39 = sext i32 %.034.lcssa to i64
  %40 = add nsw i32 %.034.lcssa, -1
  %41 = sext i32 %40 to i64
  %42 = mul nsw i64 %41, %39
  %43 = sdiv i64 %42, 2
  %44 = sext i32 %.032.lcssa to i64
  %45 = add nsw i32 %.032.lcssa, -1
  %46 = sext i32 %45 to i64
  %47 = mul nsw i64 %46, %44
  %48 = sdiv i64 %47, 2
  %49 = add i64 %43, %.03761
  %50 = add i64 %49, %48
  br label %62

.lr.ph58:                                         ; preds = %35, %.lr.ph58
  %.03257 = phi i32 [ %.133, %.lr.ph58 ], [ 0, %35 ]
  %.03456 = phi i32 [ %.135, %.lr.ph58 ], [ 0, %35 ]
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #6
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100100 x i32], ptr @color, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = icmp eq i32 %55, 1
  %57 = zext i1 %56 to i32
  %.135 = add nuw nsw i32 %.03456, %57
  %not. = xor i1 %56, true
  %58 = zext i1 %not. to i32
  %.133 = add nuw nsw i32 %.03257, %58
  %59 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %60 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %32) #6
  store ptr %60, ptr %4, align 8
  %61 = 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) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br i1 %61, label %.lr.ph58, label %._crit_edge, !llvm.loop !12

62:                                               ; preds = %.lr.ph63, %._crit_edge
  %.138 = phi i64 [ %50, %._crit_edge ], [ %.03761, %.lr.ph63 ]
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next73, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge64, label %.lr.ph63, !llvm.loop !13

63:                                               ; preds = %._crit_edge64
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i64 noundef %.138)
  br label %85

._crit_edge69:                                    ; preds = %.lr.ph68
  %65 = icmp sgt i64 %.3, 0
  br i1 %65, label %73, label %._crit_edge69.thread

.lr.ph68:                                         ; preds = %.lr.ph68.preheader, %.lr.ph68
  %indvars.iv75 = phi i64 [ 0, %.lr.ph68.preheader ], [ %indvars.iv.next76, %.lr.ph68 ]
  %.23966 = phi i64 [ %.138, %.lr.ph68.preheader ], [ %.3, %.lr.ph68 ]
  %66 = getelementptr inbounds [100100 x %"class.std::vector"], ptr @comp, i64 0, i64 %indvars.iv75
  %67 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %66) #6
  %68 = icmp ugt i64 %67, 1
  %69 = load i32, ptr @n, align 4
  %70 = add nsw i32 %69, -2
  %71 = sext i32 %70 to i64
  %72 = select i1 %68, i64 %71, i64 0
  %.3 = add nsw i64 %72, %.23966
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %exitcond79.not = icmp eq i64 %indvars.iv.next76, %wide.trip.count78
  br i1 %exitcond79.not, label %._crit_edge69, label %.lr.ph68, !llvm.loop !14

73:                                               ; preds = %._crit_edge69
  %74 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i64 noundef %.3)
  br label %85

._crit_edge69.thread:                             ; preds = %.preheader48, %.preheader49, %.preheader, %._crit_edge69
  %75 = load i32, ptr @n, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = add nsw i32 %75, -1
  %78 = sext i32 %77 to i64
  %79 = mul nsw i64 %78, %76
  %80 = add nsw i32 %75, -2
  %81 = sext i32 %80 to i64
  %82 = mul nsw i64 %79, %81
  %83 = sdiv i64 %82, 6
  %84 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i64 noundef %83)
  br label %85

85:                                               ; preds = %.thread, %63, %73, %._crit_edge69.thread
  ret i32 0
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 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 = { 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 = { 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 #5 = { 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 #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}


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