; LLVM IR from tangjz/acm-icpc :: lydsy (5478)

; 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
@a = external dso_local global [100001 x i32], align 16
@f = external dso_local global [100001 x i32], align 16
@g = external dso_local global [100001 x i32], align 16
@d = external dso_local global [100001 x %"class.std::vector"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

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

18:                                               ; preds = %63, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp sle i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %66

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i32, ptr @a, i64 %25
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %26)
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %32, %28
  store i32 %33, ptr %31, align 4, !tbaa !5
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @d, i64 0, i64 %35
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %36, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = add nsw i32 %37, %38
  store i32 %39, ptr %4, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %58, %23
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = icmp sle i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %62

45:                                               ; preds = %40
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sub nsw i32 %53, %49
  store i32 %54, ptr %52, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @d, i64 0, i64 %56
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %57, ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %58

58:                                               ; preds = %45
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = add nsw i32 %60, %59
  store i32 %61, ptr %4, align 4, !tbaa !5
  br label %40, !llvm.loop !9

62:                                               ; preds = %44
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !11

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

67:                                               ; preds = %182, %66
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = icmp sle i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %185

72:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %73 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %73, ptr %8, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %105, %72
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = load i32, ptr @n, align 4, !tbaa !5
  %77 = icmp sle i32 %75, %76
  br i1 %77, label %79, label %78

78:                                               ; preds = %74
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %109

79:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @d, i64 0, i64 %84
  store ptr %85, ptr %9, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %86 = load ptr, ptr %9, align 8, !tbaa !14
  %87 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %86) #6
  %88 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %10, i32 0, i32 0
  store ptr %87, ptr %88, align 8
  br label %89

89:                                               ; preds = %102, %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %90 = load ptr, ptr %9, align 8, !tbaa !14
  %91 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %90) #6
  %92 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %11, i32 0, i32 0
  store ptr %91, ptr %92, align 8
  %93 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br i1 %93, label %95, label %94

94:                                               ; preds = %89
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %104

95:                                               ; preds = %89
  %96 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #6
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [100001 x i32], ptr @g, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %99, align 4, !tbaa !5
  br label %102

102:                                              ; preds = %95
  %103 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #6
  br label %89, !llvm.loop !16

104:                                              ; preds = %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %105

105:                                              ; preds = %104
  %106 = load i32, ptr %6, align 4, !tbaa !5
  %107 = load i32, ptr %8, align 4, !tbaa !5
  %108 = add nsw i32 %107, %106
  store i32 %108, ptr %8, align 4, !tbaa !5
  br label %74, !llvm.loop !17

109:                                              ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %110 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %110, ptr %12, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %168, %109
  %112 = load i32, ptr %12, align 4, !tbaa !5
  %113 = load i32, ptr @n, align 4, !tbaa !5
  %114 = icmp sle i32 %112, %113
  br i1 %114, label %116, label %115

115:                                              ; preds = %111
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %172

116:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %117 = load i32, ptr %12, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @d, i64 0, i64 %121
  store ptr %122, ptr %13, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %123 = load ptr, ptr %13, align 8, !tbaa !14
  %124 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %123) #6
  %125 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %124, ptr %125, align 8
  br label %126

126:                                              ; preds = %165, %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %127 = load ptr, ptr %13, align 8, !tbaa !14
  %128 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %127) #6
  %129 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %15, i32 0, i32 0
  store ptr %128, ptr %129, align 8
  %130 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br i1 %130, label %132, label %131

131:                                              ; preds = %126
  store i32 20, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %167

132:                                              ; preds = %126
  %133 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #6
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [100001 x i32], ptr @g, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = icmp ne i32 %137, 0
  br i1 %138, label %139, label %164

139:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %140 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #6
  %141 = load i32, ptr %140, align 4, !tbaa !5
  store i32 %141, ptr %16, align 4, !tbaa !5
  %142 = load i32, ptr %16, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [100001 x i32], ptr @g, i64 0, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = load i32, ptr %16, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100001 x i32], ptr @g, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = mul nsw i64 %146, %151
  %153 = load i32, ptr %16, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = mul nsw i64 %152, %157
  %159 = load i64, ptr %7, align 8, !tbaa !12
  %160 = add nsw i64 %159, %158
  store i64 %160, ptr %7, align 8, !tbaa !12
  %161 = load i32, ptr %16, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [100001 x i32], ptr @g, i64 0, i64 %162
  store i32 0, ptr %163, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %164

164:                                              ; preds = %139, %132
  br label %165

165:                                              ; preds = %164
  %166 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #6
  br label %126, !llvm.loop !18

167:                                              ; preds = %131
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %168

168:                                              ; preds = %167
  %169 = load i32, ptr %6, align 4, !tbaa !5
  %170 = load i32, ptr %12, align 4, !tbaa !5
  %171 = add nsw i32 %170, %169
  store i32 %171, ptr %12, align 4, !tbaa !5
  br label %111, !llvm.loop !19

172:                                              ; preds = %115
  %173 = load i64, ptr %7, align 8, !tbaa !12
  %174 = load i32, ptr %6, align 4, !tbaa !5
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %175
  %177 = load i32, ptr %176, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = mul nsw i64 %173, %178
  %180 = load i64, ptr %5, align 8, !tbaa !12
  %181 = add nsw i64 %180, %179
  store i64 %181, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %182

182:                                              ; preds = %172
  %183 = load i32, ptr %6, align 4, !tbaa !5
  %184 = add nsw i32 %183, 1
  store i32 %184, ptr %6, align 4, !tbaa !5
  br label %67, !llvm.loop !20

185:                                              ; preds = %71
  %186 = load i64, ptr %5, align 8, !tbaa !12
  %187 = srem i64 %186, 1000000007
  %188 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %187)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  %189 = load i32, ptr %1, align 4
  ret i32 %189
}

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

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

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

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

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

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

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !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
@a = external dso_local global [100001 x i32], align 16
@f = external dso_local local_unnamed_addr global [100001 x i32], align 16
@g = external dso_local local_unnamed_addr global [100001 x i32], align 16
@d = external dso_local global [100001 x %"class.std::vector"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 1, ptr %1, align 4, !tbaa !5
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not43 = icmp slt i32 %7, 1
  br i1 %.not43, label %._crit_edge47.thread, label %.lr.ph46

._crit_edge47.thread:                             ; preds = %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  br label %._crit_edge67

._crit_edge47:                                    ; preds = %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %.not3564 = icmp slt i32 %20, 1
  br i1 %.not3564, label %._crit_edge67, label %.preheader40

.lr.ph46:                                         ; preds = %0, %._crit_edge
  %storemerge44 = phi i32 [ %22, %._crit_edge ], [ 1, %0 ]
  %8 = sext i32 %storemerge44 to i64
  %9 = getelementptr inbounds i32, ptr @a, i64 %8
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %9)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = add nsw i32 %14, %11
  store i32 %15, ptr %13, align 4, !tbaa !5
  %16 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @d, i64 0, i64 %12
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %16, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = shl nsw i32 %17, 1
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %.not3941 = icmp sgt i32 %18, %19
  br i1 %.not3941, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph46
  %20 = phi i32 [ %19, %.lr.ph46 ], [ %34, %.lr.ph ]
  %21 = phi i32 [ %17, %.lr.ph46 ], [ %32, %.lr.ph ]
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %1, align 4, !tbaa !5
  %.not.not = icmp slt i32 %21, %20
  br i1 %.not.not, label %.lr.ph46, label %._crit_edge47, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph46, %.lr.ph
  %23 = phi i32 [ %32, %.lr.ph ], [ %17, %.lr.ph46 ]
  %.02942 = phi i32 [ %33, %.lr.ph ], [ %18, %.lr.ph46 ]
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = sext i32 %.02942 to i64
  %28 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sub nsw i32 %29, %26
  store i32 %30, ptr %28, align 4, !tbaa !5
  %31 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @d, i64 0, i64 %27
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %31, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = add nsw i32 %32, %.02942
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %.not39 = icmp sgt i32 %33, %34
  br i1 %.not39, label %._crit_edge, label %.lr.ph, !llvm.loop !11

.preheader40:                                     ; preds = %._crit_edge47, %._crit_edge62
  %35 = phi i32 [ %58, %._crit_edge62 ], [ %20, %._crit_edge47 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge62 ], [ 1, %._crit_edge47 ]
  %.03365 = phi i64 [ %63, %._crit_edge62 ], [ 0, %._crit_edge47 ]
  %36 = sext i32 %35 to i64
  %.not3651 = icmp sgt i64 %indvars.iv, %36
  br i1 %.not3651, label %.preheader, label %.lr.ph53

._crit_edge67.loopexit:                           ; preds = %._crit_edge62
  %37 = srem i64 %63, 1000000007
  br label %._crit_edge67

._crit_edge67:                                    ; preds = %._crit_edge47.thread, %._crit_edge67.loopexit, %._crit_edge47
  %.033.lcssa = phi i64 [ 0, %._crit_edge47 ], [ %37, %._crit_edge67.loopexit ], [ 0, %._crit_edge47.thread ]
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.033.lcssa)
  ret i32 0

.preheader.loopexit:                              ; preds = %._crit_edge50
  %.pre = sext i32 %47 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.preheader40
  %.pre-phi = phi i64 [ %.pre, %.preheader.loopexit ], [ %36, %.preheader40 ]
  %39 = phi i32 [ %47, %.preheader.loopexit ], [ %35, %.preheader40 ]
  %.not3758 = icmp sgt i64 %indvars.iv, %.pre-phi
  br i1 %.not3758, label %._crit_edge62, label %.lr.ph61

.lr.ph53:                                         ; preds = %.preheader40, %._crit_edge50
  %indvars.iv69 = phi i64 [ %indvars.iv.next70, %._crit_edge50 ], [ %indvars.iv, %.preheader40 ]
  %40 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv69
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @d, i64 0, i64 %42
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %44 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %43) #6
  store ptr %44, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %45 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %43) #6
  store ptr %45, ptr %3, align 8
  %46 = 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) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  br i1 %46, label %.lr.ph49, label %._crit_edge50

._crit_edge50:                                    ; preds = %.lr.ph49, %.lr.ph53
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, %indvars.iv
  %47 = load i32, ptr @n, align 4, !tbaa !5
  %48 = trunc nuw i64 %indvars.iv.next70 to i32
  %.not36 = icmp slt i32 %47, %48
  br i1 %.not36, label %.preheader.loopexit, label %.lr.ph53, !llvm.loop !12

.lr.ph49:                                         ; preds = %.lr.ph53, %.lr.ph49
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #6
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100001 x i32], ptr @g, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %52, align 4, !tbaa !5
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %56 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %43) #6
  store ptr %56, ptr %3, align 8
  %57 = 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) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  br i1 %57, label %.lr.ph49, label %._crit_edge50, !llvm.loop !13

._crit_edge62.loopexit:                           ; preds = %._crit_edge57
  %.pre76 = sext i32 %71 to i64
  br label %._crit_edge62

._crit_edge62:                                    ; preds = %._crit_edge62.loopexit, %.preheader
  %.pre-phi77 = phi i64 [ %.pre76, %._crit_edge62.loopexit ], [ %.pre-phi, %.preheader ]
  %58 = phi i32 [ %71, %._crit_edge62.loopexit ], [ %39, %.preheader ]
  %.031.lcssa = phi i64 [ %.1.lcssa, %._crit_edge62.loopexit ], [ 0, %.preheader ]
  %59 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %indvars.iv
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = mul nsw i64 %.031.lcssa, %61
  %63 = add nsw i64 %62, %.03365
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not35.not = icmp slt i64 %indvars.iv, %.pre-phi77
  br i1 %.not35.not, label %.preheader40, label %._crit_edge67.loopexit, !llvm.loop !14

.lr.ph61:                                         ; preds = %.preheader, %._crit_edge57
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %._crit_edge57 ], [ %indvars.iv, %.preheader ]
  %.03159 = phi i64 [ %.1.lcssa, %._crit_edge57 ], [ 0, %.preheader ]
  %64 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv72
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @d, i64 0, i64 %66
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %68 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %67) #6
  store ptr %68, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %69 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %67) #6
  store ptr %69, ptr %5, align 8
  %70 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br i1 %70, label %.lr.ph56, label %._crit_edge57

._crit_edge57:                                    ; preds = %91, %.lr.ph61
  %.1.lcssa = phi i64 [ %.03159, %.lr.ph61 ], [ %.2, %91 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, %indvars.iv
  %71 = load i32, ptr @n, align 4, !tbaa !5
  %72 = trunc nuw i64 %indvars.iv.next73 to i32
  %.not37 = icmp slt i32 %71, %72
  br i1 %.not37, label %._crit_edge62.loopexit, label %.lr.ph61, !llvm.loop !15

.lr.ph56:                                         ; preds = %.lr.ph61, %91
  %.154 = phi i64 [ %.2, %91 ], [ %.03159, %.lr.ph61 ]
  %73 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [100001 x i32], ptr @g, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %.not38 = icmp eq i32 %77, 0
  br i1 %.not38, label %91, label %78

78:                                               ; preds = %.lr.ph56
  %79 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100001 x i32], ptr @g, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = mul nsw i64 %84, %84
  %86 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %81
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = mul nsw i64 %85, %88
  %90 = add nsw i64 %89, %.154
  store i32 0, ptr %82, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %.lr.ph56, %78
  %.2 = phi i64 [ %90, %78 ], [ %.154, %.lr.ph56 ]
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %93 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %67) #6
  store ptr %93, ptr %5, align 8
  %94 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br i1 %94, label %.lr.ph56, label %._crit_edge57, !llvm.loop !16
}

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

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

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

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

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

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

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

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

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

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

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


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