; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/288 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.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@in = external dso_local global [300300 x i32], align 16
@out = external dso_local global [300300 x i32], align 16
@g = external dso_local global [300300 x %"class.std::vector"], align 16
@s = external dso_local global [4 x i8], align 1
@v = external dso_local global %"class.std::vector", align 8
@_Z3resB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

15:                                               ; preds = %47, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %15
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef @s)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %22 = load i8, ptr @s, align 1, !tbaa !9
  %23 = sext i8 %22 to i32
  %24 = mul nsw i32 1000, %23
  %25 = load i8, ptr getelementptr inbounds ([4 x i8], ptr @s, i64 0, i64 1), align 1, !tbaa !9
  %26 = sext i8 %25 to i32
  %27 = add nsw i32 %24, %26
  store i32 %27, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %28 = load i8, ptr getelementptr inbounds ([4 x i8], ptr @s, i64 0, i64 1), align 1, !tbaa !9
  %29 = sext i8 %28 to i32
  %30 = mul nsw i32 1000, %29
  %31 = load i8, ptr getelementptr inbounds ([4 x i8], ptr @s, i64 0, i64 2), align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = add nsw i32 %30, %32
  store i32 %33, ptr %4, align 4, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [300300 x %"class.std::vector"], ptr @g, i64 0, i64 %35
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %36, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %39, align 4, !tbaa !5
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [300300 x i32], ptr @in, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %44, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %47

47:                                               ; preds = %20
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !10

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

51:                                               ; preds = %101, %50
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = icmp slt i32 %52, 300300
  br i1 %53, label %55, label %54

54:                                               ; preds = %51
  store i32 5, ptr %7, align 4
  br label %104

55:                                               ; preds = %51
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [300300 x i32], ptr @in, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = icmp eq i32 %60, %64
  br i1 %65, label %66, label %73

66:                                               ; preds = %55
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = icmp ne i32 %67, -1
  br i1 %68, label %69, label %71

69:                                               ; preds = %66
  %70 = call i32 @puts(ptr noundef @.str.5)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %104

71:                                               ; preds = %66
  %72 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %72, ptr %5, align 4, !tbaa !5
  br label %100

73:                                               ; preds = %55
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [300300 x i32], ptr @in, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = icmp eq i32 %77, %81
  br i1 %82, label %83, label %84

83:                                               ; preds = %73
  br label %99

84:                                               ; preds = %73
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [300300 x i32], ptr @in, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  %94 = icmp eq i32 %88, %93
  br i1 %94, label %95, label %96

95:                                               ; preds = %84
  br label %98

96:                                               ; preds = %84
  %97 = call i32 @puts(ptr noundef @.str.5)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %104

98:                                               ; preds = %95
  br label %99

99:                                               ; preds = %98, %83
  br label %100

100:                                              ; preds = %99, %71
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %6, align 4, !tbaa !5
  br label %51, !llvm.loop !12

104:                                              ; preds = %96, %69, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %105 = load i32, ptr %7, align 4
  switch i32 %105, label %170 [
    i32 5, label %106
  ]

106:                                              ; preds = %104
  %107 = load i32, ptr %5, align 4, !tbaa !5
  %108 = icmp eq i32 %107, -1
  br i1 %108, label %109, label %128

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

110:                                              ; preds = %123, %109
  %111 = load i32, ptr %8, align 4, !tbaa !5
  %112 = icmp sle i32 %111, 300300
  br i1 %112, label %114, label %113

113:                                              ; preds = %110
  store i32 8, ptr %7, align 4
  br label %126

114:                                              ; preds = %110
  %115 = load i32, ptr %8, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = icmp sgt i32 %118, 0
  br i1 %119, label %120, label %122

120:                                              ; preds = %114
  %121 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %121, ptr %5, align 4, !tbaa !5
  store i32 8, ptr %7, align 4
  br label %126

122:                                              ; preds = %114
  br label %123

123:                                              ; preds = %122
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %8, align 4, !tbaa !5
  br label %110, !llvm.loop !13

126:                                              ; preds = %120, %113
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %127

127:                                              ; preds = %126
  br label %128

128:                                              ; preds = %127, %106
  %129 = load i32, ptr %5, align 4, !tbaa !5
  call void @_Z3dfsi(i32 noundef %129)
  %130 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  %131 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %9, i32 0, i32 0
  store ptr %130, ptr %131, align 8
  %132 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  %133 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %10, i32 0, i32 0
  store ptr %132, ptr %133, align 8
  %134 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %9, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8
  %136 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %10, i32 0, i32 0
  %137 = load ptr, ptr %136, align 8
  call void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_(ptr %135, ptr %137)
  %138 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  %139 = load i32, ptr @n, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  %141 = sext i32 %140 to i64
  %142 = icmp ne i64 %138, %141
  br i1 %142, label %143, label %145

143:                                              ; preds = %128
  %144 = call i32 @puts(ptr noundef @.str.5)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %170

145:                                              ; preds = %128
  %146 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @v, i64 noundef 0) #7
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = sdiv i32 %147, 1000
  %149 = trunc i32 %148 to i8
  %150 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) @_Z3resB5cxx11, i8 noundef signext %149)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %151 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  %152 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %11, i32 0, i32 0
  store ptr %151, ptr %152, align 8
  br label %153

153:                                              ; preds = %164, %145
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %154 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  %155 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  store ptr %154, ptr %155, align 8
  %156 = 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) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br i1 %156, label %158, label %157

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

158:                                              ; preds = %153
  %159 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #7
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = srem i32 %160, 1000
  %162 = trunc i32 %161 to i8
  %163 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) @_Z3resB5cxx11, i8 noundef signext %162)
  br label %164

164:                                              ; preds = %158
  %165 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %11, i32 noundef 0) #7
  %166 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %165, ptr %166, align 8
  br label %153, !llvm.loop !14

167:                                              ; preds = %157
  %168 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) @_Z3resB5cxx11) #7
  %169 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %168)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  br label %170

170:                                              ; preds = %167, %143, %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  %171 = load i32, ptr %1, align 4
  ret i32 %171
}

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

declare i32 @puts(ptr noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_(ptr, ptr) #4

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) #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)) #6

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

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #5 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 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 #3 = { "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = { 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 #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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}


; 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.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@in = external dso_local local_unnamed_addr global [300300 x i32], align 16
@out = external dso_local local_unnamed_addr global [300300 x i32], align 16
@g = external dso_local global [300300 x %"class.std::vector"], align 16
@s = external dso_local global [4 x i8], align 1
@v = external dso_local global %"class.std::vector", align 8
@_Z3resB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1

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

; 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 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %.preheader33.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.02436 = phi i32 [ %28, %.lr.ph ], [ 0, %0 ]
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @s)
  %8 = load i8, ptr @s, align 1, !tbaa !9
  %9 = sext i8 %8 to i64
  %10 = mul nsw i64 %9, 1000
  %11 = load i8, ptr getelementptr inbounds (i8, ptr @s, i64 1), align 1, !tbaa !9
  %12 = sext i8 %11 to i64
  %13 = add nsw i64 %10, %12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %14 = sext i8 %11 to i32
  %15 = mul nsw i32 %14, 1000
  %16 = load i8, ptr getelementptr inbounds (i8, ptr @s, i64 2), align 1, !tbaa !9
  %17 = sext i8 %16 to i32
  %18 = add nsw i32 %15, %17
  store i32 %18, ptr %1, align 4, !tbaa !5
  %19 = getelementptr inbounds [300300 x %"class.std::vector"], ptr @g, i64 0, i64 %13
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %19, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %20 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %13
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %20, align 4, !tbaa !5
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [300300 x i32], ptr @in, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %28 = add nuw nsw i32 %.02436, 1
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %.lr.ph, label %.preheader33.preheader, !llvm.loop !10

.preheader33.preheader:                           ; preds = %.lr.ph, %0
  br label %.preheader33

.preheader33:                                     ; preds = %59, %.preheader33.preheader
  %indvars.iv = phi i64 [ 0, %.preheader33.preheader ], [ %indvars.iv.next.1, %59 ]
  %.02538 = phi i32 [ -1, %.preheader33.preheader ], [ %.126.1, %59 ]
  %31 = getelementptr inbounds [300300 x i32], ptr @in, i64 0, i64 %indvars.iv
  %32 = load i32, ptr %31, align 8, !tbaa !5
  %33 = add nsw i32 %32, 1
  %34 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %indvars.iv
  %35 = load i32, ptr %34, align 8, !tbaa !5
  %36 = icmp eq i32 %33, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %.preheader33
  %.not = icmp eq i32 %.02538, -1
  %38 = trunc nuw nsw i64 %indvars.iv to i32
  br i1 %.not, label %.preheader33.1, label %39

39:                                               ; preds = %57, %37
  %40 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %103

41:                                               ; preds = %.preheader33
  %42 = icmp eq i32 %32, %35
  %43 = add nsw i32 %35, 1
  %44 = icmp eq i32 %32, %43
  %or.cond = select i1 %42, i1 true, i1 %44
  br i1 %or.cond, label %.preheader33.1, label %45

45:                                               ; preds = %53, %41
  %46 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %103

.preheader33.1:                                   ; preds = %37, %41
  %.126 = phi i32 [ %.02538, %41 ], [ %38, %37 ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %47 = getelementptr inbounds [300300 x i32], ptr @in, i64 0, i64 %indvars.iv.next
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  %50 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %indvars.iv.next
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = icmp eq i32 %49, %51
  br i1 %52, label %57, label %53

53:                                               ; preds = %.preheader33.1
  %54 = icmp eq i32 %48, %51
  %55 = add nsw i32 %51, 1
  %56 = icmp eq i32 %48, %55
  %or.cond.1 = select i1 %54, i1 true, i1 %56
  br i1 %or.cond.1, label %59, label %45

57:                                               ; preds = %.preheader33.1
  %.not.1 = icmp eq i32 %.126, -1
  %58 = trunc nuw nsw i64 %indvars.iv.next to i32
  br i1 %.not.1, label %59, label %39

59:                                               ; preds = %57, %53
  %.126.1 = phi i32 [ %.126, %53 ], [ %58, %57 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.1 = icmp eq i64 %indvars.iv.next.1, 300300
  br i1 %exitcond.1, label %.critedge, label %.preheader33, !llvm.loop !12

.critedge:                                        ; preds = %59
  %60 = icmp eq i32 %.126.1, -1
  br i1 %60, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %.critedge, %74
  %indvars.iv42 = phi i64 [ %indvars.iv.next43.3, %74 ], [ 0, %.critedge ]
  %61 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %indvars.iv42
  %62 = load i32, ptr %61, align 16, !tbaa !5
  %63 = icmp sgt i32 %62, 0
  br i1 %63, label %.loopexit.loopexit.split.loop.exit, label %64

64:                                               ; preds = %.preheader
  %exitcond45.not = icmp eq i64 %indvars.iv42, 300300
  br i1 %exitcond45.not, label %.loopexit, label %.preheader.1, !llvm.loop !13

.preheader.1:                                     ; preds = %64
  %indvars.iv.next43 = or disjoint i64 %indvars.iv42, 1
  %65 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %indvars.iv.next43
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = icmp sgt i32 %66, 0
  br i1 %67, label %.loopexit.loopexit.split.loop.exit, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %indvars.iv.next43.1 = or disjoint i64 %indvars.iv42, 2
  %68 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %indvars.iv.next43.1
  %69 = load i32, ptr %68, align 8, !tbaa !5
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %.loopexit.loopexit.split.loop.exit, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %indvars.iv.next43.2 = or disjoint i64 %indvars.iv42, 3
  %71 = getelementptr inbounds [300300 x i32], ptr @out, i64 0, i64 %indvars.iv.next43.2
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = icmp sgt i32 %72, 0
  br i1 %73, label %.loopexit.loopexit.split.loop.exit, label %74

74:                                               ; preds = %.preheader.3
  %indvars.iv.next43.3 = add nuw nsw i64 %indvars.iv42, 4
  br label %.preheader

.loopexit.loopexit.split.loop.exit:               ; preds = %.preheader.3, %.preheader.2, %.preheader.1, %.preheader
  %indvars.iv42.lcssa = phi i64 [ %indvars.iv42, %.preheader ], [ %indvars.iv.next43, %.preheader.1 ], [ %indvars.iv.next43.1, %.preheader.2 ], [ %indvars.iv.next43.2, %.preheader.3 ]
  %75 = trunc nuw nsw i64 %indvars.iv42.lcssa to i32
  br label %.loopexit

.loopexit:                                        ; preds = %64, %.loopexit.loopexit.split.loop.exit, %.critedge
  %.3 = phi i32 [ %.126.1, %.critedge ], [ %75, %.loopexit.loopexit.split.loop.exit ], [ -1, %64 ]
  call void @_Z3dfsi(i32 noundef %.3)
  %76 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  %77 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  call void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_(ptr %76, ptr %77)
  %78 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  %81 = sext i32 %80 to i64
  %.not31 = icmp eq i64 %78, %81
  br i1 %.not31, label %84, label %82

82:                                               ; preds = %.loopexit
  %83 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %103

84:                                               ; preds = %.loopexit
  %85 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @v, i64 noundef 0) #7
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = sdiv i32 %86, 1000
  %88 = trunc i32 %87 to i8
  %89 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) @_Z3resB5cxx11, i8 noundef signext %88)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %90 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  store ptr %90, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %91 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  store ptr %91, ptr %3, align 8
  %92 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br i1 %92, label %.lr.ph40, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph40, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %93 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) @_Z3resB5cxx11) #7
  %94 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %93)
  br label %103

.lr.ph40:                                         ; preds = %84, %.lr.ph40
  %95 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #7
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = srem i32 %96, 1000
  %98 = trunc i32 %97 to i8
  %99 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) @_Z3resB5cxx11, i8 noundef signext %98)
  %100 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef 0) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %101 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @v) #7
  store ptr %101, ptr %3, align 8
  %102 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br i1 %102, label %.lr.ph40, label %._crit_edge, !llvm.loop !14

103:                                              ; preds = %39, %45, %._crit_edge, %82
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEEvT_S7_(ptr, ptr) local_unnamed_addr #4

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) 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 #6

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

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #5 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 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 #3 = { 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 #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = { 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 #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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}


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