; LLVM IR from tangjz/acm-icpc :: hdu (6174)

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

@inv = external dso_local global [100003 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@p = external dso_local global [100001 x i32], align 16
@v = external dso_local global [100001 x i32], align 16
@f = external dso_local global [100001 x i32], align 16
@ans = external dso_local global i32, align 4
@e = external dso_local global [100001 x %"class.std::vector"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsii(i32 noundef, i32 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"class.std::vector", align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 1, ptr getelementptr inbounds ([100003 x i32], ptr @inv, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %31, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp sle i32 %11, 100001
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %10
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sdiv i32 1000000007, %15
  %17 = sext i32 %16 to i64
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = srem i32 1000000007, %18
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100003 x i32], ptr @inv, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = mul nsw i64 %17, %23
  %25 = srem i64 %24, 1000000007
  %26 = trunc i64 %25 to i32
  %27 = sub nsw i32 1000000007, %26
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100003 x i32], ptr @inv, i64 0, i64 %29
  store i32 %27, ptr %30, align 4, !tbaa !5
  br label %31

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

34:                                               ; preds = %13
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %36

36:                                               ; preds = %211, %34
  %37 = load i32, ptr @t, align 4, !tbaa !5
  %38 = add nsw i32 %37, -1
  store i32 %38, ptr @t, align 4, !tbaa !5
  %39 = icmp ne i32 %37, 0
  br i1 %39, label %40, label %214

40:                                               ; preds = %36
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %51, %40
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = icmp sle i32 %43, %44
  br i1 %45, label %47, label %46

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

47:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #6
  call void @llvm.memset.p0.i64(ptr align 8 %4, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #6
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @e, i64 0, i64 %49
  call void @_ZNSt6vectorIiSaIiEE4swapERS1_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %50) #6
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #6
  br label %51

51:                                               ; preds = %47
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %3, align 4, !tbaa !5
  br label %42, !llvm.loop !11

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

55:                                               ; preds = %71, %54
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %74

60:                                               ; preds = %55
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i32, ptr @p, i64 %62
  %64 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %63)
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @e, i64 0, i64 %69
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %70, ptr noundef nonnull align 4 dereferenceable(4) %5)
  br label %71

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

74:                                               ; preds = %59
  %75 = load i32, ptr @n, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr @ans, align 4, !tbaa !5
  %77 = load i32, ptr @n, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = mul i64 %78, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @v, i64 1), i8 0, i64 %79, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  br label %80

80:                                               ; preds = %208, %74
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = icmp sle i32 %81, %82
  br i1 %83, label %85, label %84

84:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %211

85:                                               ; preds = %80
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %190, label %91

91:                                               ; preds = %85
  %92 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %92, ptr %7, align 4, !tbaa !5
  br label %93

93:                                               ; preds = %101, %91
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = icmp ne i32 %97, 0
  %99 = xor i1 %98, true
  br i1 %99, label %100, label %110

100:                                              ; preds = %93
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %104
  store i32 %102, ptr %105, align 4, !tbaa !5
  %106 = load i32, ptr %7, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  store i32 %109, ptr %7, align 4, !tbaa !5
  br label %93, !llvm.loop !13

110:                                              ; preds = %93
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = icmp eq i32 %114, %115
  br i1 %116, label %117, label %189

117:                                              ; preds = %110
  %118 = load i32, ptr %7, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %119
  store i32 -1, ptr %120, align 4, !tbaa !5
  %121 = load i32, ptr %7, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  store i32 %124, ptr %8, align 4, !tbaa !5
  br label %125

125:                                              ; preds = %130, %117
  %126 = load i32, ptr %8, align 4, !tbaa !5
  %127 = load i32, ptr %7, align 4, !tbaa !5
  %128 = icmp ne i32 %126, %127
  br i1 %128, label %129, label %138

129:                                              ; preds = %125
  br label %130

130:                                              ; preds = %129
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %132
  store i32 -1, ptr %133, align 4, !tbaa !5
  %134 = load i32, ptr %8, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  store i32 %137, ptr %8, align 4, !tbaa !5
  br label %125, !llvm.loop !14

138:                                              ; preds = %125
  %139 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z3dfsii(i32 noundef %139, i32 noundef -1)
  %140 = load i32, ptr %7, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  store i32 %143, ptr %9, align 4, !tbaa !5
  %144 = load i32, ptr %7, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  store i32 %147, ptr %8, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %153, %138
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = load i32, ptr %7, align 4, !tbaa !5
  %151 = icmp ne i32 %149, %150
  br i1 %151, label %152, label %165

152:                                              ; preds = %148
  br label %153

153:                                              ; preds = %152
  %154 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z3dfsii(i32 noundef %154, i32 noundef -1)
  %155 = load i32, ptr %8, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = load i32, ptr %9, align 4, !tbaa !5
  %160 = add nsw i32 %159, %158
  store i32 %160, ptr %9, align 4, !tbaa !5
  %161 = load i32, ptr %8, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %162
  %164 = load i32, ptr %163, align 4, !tbaa !5
  store i32 %164, ptr %8, align 4, !tbaa !5
  br label %148, !llvm.loop !15

165:                                              ; preds = %148
  %166 = load i32, ptr %9, align 4, !tbaa !5
  %167 = load i32, ptr %7, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %168
  store i32 %166, ptr %169, align 4, !tbaa !5
  %170 = load i32, ptr %7, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %171
  %173 = load i32, ptr %172, align 4, !tbaa !5
  store i32 %173, ptr %8, align 4, !tbaa !5
  br label %174

174:                                              ; preds = %179, %165
  %175 = load i32, ptr %8, align 4, !tbaa !5
  %176 = load i32, ptr %7, align 4, !tbaa !5
  %177 = icmp ne i32 %175, %176
  br i1 %177, label %178, label %188

178:                                              ; preds = %174
  br label %179

179:                                              ; preds = %178
  %180 = load i32, ptr %9, align 4, !tbaa !5
  %181 = load i32, ptr %8, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %182
  store i32 %180, ptr %183, align 4, !tbaa !5
  %184 = load i32, ptr %8, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  store i32 %187, ptr %8, align 4, !tbaa !5
  br label %174, !llvm.loop !16

188:                                              ; preds = %174
  br label %189

189:                                              ; preds = %188, %110
  br label %190

190:                                              ; preds = %189, %85
  %191 = load i32, ptr %6, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %192
  %194 = load i32, ptr %193, align 4, !tbaa !5
  %195 = add nsw i32 %194, 1
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [100003 x i32], ptr @inv, i64 0, i64 %196
  %198 = load i32, ptr %197, align 4, !tbaa !5
  %199 = load i32, ptr @ans, align 4, !tbaa !5
  %200 = sub nsw i32 %199, %198
  store i32 %200, ptr @ans, align 4, !tbaa !5
  %201 = icmp slt i32 %200, 0
  br i1 %201, label %202, label %206

202:                                              ; preds = %190
  %203 = load i32, ptr @ans, align 4, !tbaa !5
  %204 = add nsw i32 %203, 1000000007
  store i32 %204, ptr @ans, align 4, !tbaa !5
  %205 = icmp ne i32 %204, 0
  br label %206

206:                                              ; preds = %202, %190
  %207 = phi i1 [ false, %190 ], [ %205, %202 ]
  br label %208

208:                                              ; preds = %206
  %209 = load i32, ptr %6, align 4, !tbaa !5
  %210 = add nsw i32 %209, 1
  store i32 %210, ptr %6, align 4, !tbaa !5
  br label %80, !llvm.loop !17

211:                                              ; preds = %84
  %212 = load i32, ptr @ans, align 4, !tbaa !5
  %213 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %212)
  br label %36, !llvm.loop !18

214:                                              ; preds = %36
  ret i32 0
}

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

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

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

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

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

@inv = external dso_local local_unnamed_addr global [100003 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@p = external dso_local global [100001 x i32], align 16
@v = external dso_local local_unnamed_addr global [100001 x i32], align 16
@f = external dso_local local_unnamed_addr global [100001 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@e = external dso_local global [100001 x %"class.std::vector"], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsii(i32 noundef, i32 noundef) 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca %"class.std::vector", align 8
  %2 = alloca i32, align 4
  store i32 1, ptr getelementptr inbounds (i8, ptr @inv, i64 4), align 4, !tbaa !5
  br label %7

3:                                                ; preds = %7
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %5 = load i32, ptr @t, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @t, align 4, !tbaa !5
  %.not100 = icmp eq i32 %5, 0
  br i1 %.not100, label %._crit_edge103, label %.lr.ph102

7:                                                ; preds = %0, %7
  %indvars.iv = phi i64 [ 2, %0 ], [ %indvars.iv.next, %7 ]
  %8 = trunc nuw nsw i64 %indvars.iv to i32
  %9 = udiv i32 1000000007, %8
  %10 = zext nneg i32 %9 to i64
  %11 = urem i32 1000000007, %8
  %12 = zext nneg i32 %11 to i64
  %13 = getelementptr inbounds [100003 x i32], ptr @inv, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = mul nsw i64 %15, %10
  %17 = srem i64 %16, 1000000007
  %18 = trunc nsw i64 %17 to i32
  %19 = sub nsw i32 1000000007, %18
  %20 = getelementptr inbounds [100003 x i32], ptr @inv, i64 0, i64 %indvars.iv
  store i32 %19, ptr %20, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100002
  br i1 %exitcond.not, label %3, label %7, !llvm.loop !9

.lr.ph102:                                        ; preds = %3, %._crit_edge99
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %.not4962 = icmp slt i32 %22, 1
  br i1 %.not4962, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %.lr.ph102
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  br label %._crit_edge68

._crit_edge:                                      ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  %.not5064 = icmp slt i32 %24, 1
  br i1 %.not5064, label %._crit_edge68, label %.lr.ph67

.lr.ph:                                           ; preds = %.lr.ph102, %.lr.ph
  %indvars.iv111 = phi i64 [ %indvars.iv.next112, %.lr.ph ], [ 1, %.lr.ph102 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %1, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #6
  %23 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @e, i64 0, i64 %indvars.iv111
  call void @_ZNSt6vectorIiSaIiEE4swapERS1_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %23) #6
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %1) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #6
  %indvars.iv.next112 = add nuw nsw i64 %indvars.iv111, 1
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %.not49.not = icmp slt i64 %indvars.iv111, %25
  br i1 %.not49.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge68:                                    ; preds = %.lr.ph67, %._crit_edge.thread, %._crit_edge
  %26 = phi i32 [ %24, %._crit_edge ], [ %22, %._crit_edge.thread ], [ %41, %.lr.ph67 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr @ans, align 4, !tbaa !5
  %28 = sext i32 %26 to i64
  %29 = shl nsw i64 %28, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @v, i64 4), i8 0, i64 %29, i1 false)
  %.not5195 = icmp slt i32 %26, 1
  br i1 %.not5195, label %._crit_edge99, label %.lr.ph98

.lr.ph67:                                         ; preds = %._crit_edge, %.lr.ph67
  %storemerge65 = phi i32 [ %40, %.lr.ph67 ], [ 1, %._crit_edge ]
  %30 = sext i32 %storemerge65 to i64
  %31 = getelementptr inbounds i32, ptr @p, i64 %30
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %31)
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100001 x %"class.std::vector"], ptr @e, i64 0, i64 %37
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %38, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %2, align 4, !tbaa !5
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %.not50.not = icmp slt i32 %39, %41
  br i1 %.not50.not, label %.lr.ph67, label %._crit_edge68, !llvm.loop !12

._crit_edge99:                                    ; preds = %.loopexit, %._crit_edge68
  %42 = phi i32 [ %27, %._crit_edge68 ], [ %spec.select, %.loopexit ]
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %42)
  %44 = load i32, ptr @t, align 4, !tbaa !5
  %45 = add nsw i32 %44, -1
  store i32 %45, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %44, 0
  br i1 %.not, label %._crit_edge103, label %.lr.ph102, !llvm.loop !13

.lr.ph98:                                         ; preds = %._crit_edge68, %.loopexit
  %indvars.iv114 = phi i64 [ %indvars.iv.next115, %.loopexit ], [ 1, %._crit_edge68 ]
  %46 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %indvars.iv114
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %.not52 = icmp eq i32 %47, 0
  br i1 %.not52, label %.lr.ph70.preheader, label %.loopexit

.lr.ph70.preheader:                               ; preds = %.lr.ph98
  %48 = trunc nuw nsw i64 %indvars.iv114 to i32
  br label %.lr.ph70

.lr.ph70:                                         ; preds = %.lr.ph70.preheader, %.lr.ph70
  %49 = phi ptr [ %54, %.lr.ph70 ], [ %46, %.lr.ph70.preheader ]
  %50 = phi i64 [ %53, %.lr.ph70 ], [ %indvars.iv114, %.lr.ph70.preheader ]
  store i32 %48, ptr %49, align 4, !tbaa !5
  %51 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %.not53 = icmp eq i32 %55, 0
  br i1 %.not53, label %.lr.ph70, label %._crit_edge71, !llvm.loop !14

._crit_edge71:                                    ; preds = %.lr.ph70
  %56 = zext i32 %55 to i64
  %57 = icmp eq i64 %indvars.iv114, %56
  br i1 %57, label %58, label %.loopexit

58:                                               ; preds = %._crit_edge71
  store i32 -1, ptr %54, align 4, !tbaa !5
  %59 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %53
  %.04276 = load i32, ptr %59, align 4, !tbaa !5
  %.not5477 = icmp eq i32 %.04276, %52
  br i1 %.not5477, label %._crit_edge81, label %.lr.ph80

.lr.ph80:                                         ; preds = %58, %.lr.ph80
  %.04278 = phi i32 [ %.042, %.lr.ph80 ], [ %.04276, %58 ]
  %60 = sext i32 %.04278 to i64
  %61 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %60
  store i32 -1, ptr %61, align 4, !tbaa !5
  %62 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %60
  %.042 = load i32, ptr %62, align 4, !tbaa !5
  %.not54 = icmp eq i32 %.042, %52
  br i1 %.not54, label %._crit_edge81, label %.lr.ph80, !llvm.loop !15

._crit_edge81:                                    ; preds = %.lr.ph80, %58
  call void @_Z3dfsii(i32 noundef %52, i32 noundef -1)
  %63 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %53
  %.182 = load i32, ptr %59, align 4, !tbaa !5
  %.not5583 = icmp eq i32 %.182, %52
  br i1 %.not5583, label %.loopexit, label %.lr.ph87.preheader

.lr.ph87.preheader:                               ; preds = %._crit_edge81
  %64 = load i32, ptr %63, align 4, !tbaa !5
  br label %.lr.ph87

.lr.ph87:                                         ; preds = %.lr.ph87.preheader, %.lr.ph87
  %.185 = phi i32 [ %.1, %.lr.ph87 ], [ %.182, %.lr.ph87.preheader ]
  %.084 = phi i32 [ %68, %.lr.ph87 ], [ %64, %.lr.ph87.preheader ]
  call void @_Z3dfsii(i32 noundef %.185, i32 noundef -1)
  %65 = sext i32 %.185 to i64
  %66 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = add nsw i32 %67, %.084
  %69 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %65
  %.1 = load i32, ptr %69, align 4, !tbaa !5
  %.not55 = icmp eq i32 %.1, %52
  br i1 %.not55, label %._crit_edge88, label %.lr.ph87, !llvm.loop !16

._crit_edge88:                                    ; preds = %.lr.ph87
  %.290.pre = load i32, ptr %59, align 4, !tbaa !5
  store i32 %68, ptr %63, align 4, !tbaa !5
  %.not5691 = icmp eq i32 %.290.pre, %52
  br i1 %.not5691, label %.loopexit, label %.lr.ph94

.lr.ph94:                                         ; preds = %._crit_edge88, %.lr.ph94
  %.292 = phi i32 [ %.2, %.lr.ph94 ], [ %.290.pre, %._crit_edge88 ]
  %70 = sext i32 %.292 to i64
  %71 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %70
  store i32 %68, ptr %71, align 4, !tbaa !5
  %72 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %70
  %.2 = load i32, ptr %72, align 4, !tbaa !5
  %.not56 = icmp eq i32 %.2, %52
  br i1 %.not56, label %.loopexit, label %.lr.ph94, !llvm.loop !17

.loopexit:                                        ; preds = %.lr.ph94, %._crit_edge81, %._crit_edge88, %._crit_edge71, %.lr.ph98
  %73 = getelementptr inbounds [100001 x i32], ptr @f, i64 0, i64 %indvars.iv114
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100003 x i32], ptr @inv, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = load i32, ptr @ans, align 4, !tbaa !5
  %80 = sub nsw i32 %79, %78
  %81 = icmp slt i32 %80, 0
  %82 = add nsw i32 %80, 1000000007
  %spec.select = select i1 %81, i32 %82, i32 %80
  store i32 %spec.select, ptr @ans, align 4, !tbaa !5
  %indvars.iv.next115 = add nuw nsw i64 %indvars.iv114, 1
  %83 = load i32, ptr @n, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %.not51.not = icmp slt i64 %indvars.iv114, %84
  br i1 %.not51.not, label %.lr.ph98, label %._crit_edge99, !llvm.loop !18

._crit_edge103:                                   ; preds = %._crit_edge99, %3
  ret i32 0
}

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

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

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

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

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


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