; LLVM IR from lzyrapx/Competitive-Programming :: 百度之星/2020/第三场 (F)

; 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::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@inv = external dso_local global [200001 x i32], align 16
@ve = external dso_local global [200001 x %"class.std::vector"], align 16
@father = external dso_local global [200001 x i32], align 16
@ids = external dso_local global [200001 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6qpowerxxx(i64 noundef, i64 noundef, i64 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 @_Z3dfsii(i32 noundef, i32 noundef) #2

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

21:                                               ; preds = %33, %2
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = icmp slt i32 %22, 200001
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %21
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = call noundef i64 @_Z6qpowerxxx(i64 noundef %27, i64 noundef 1000000005, i64 noundef 1000000007)
  %29 = trunc i64 %28 to i32
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [200001 x i32], ptr @inv, i64 0, i64 %31
  store i32 %29, ptr %32, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %25
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %6, align 4, !tbaa !5
  br label %21, !llvm.loop !11

36:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %37 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %7)
  br label %38

38:                                               ; preds = %172, %170, %36
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %7, align 4, !tbaa !5
  %41 = icmp ne i32 %39, 0
  br i1 %41, label %42, label %173

42:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %8, ptr noundef %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %53, %42
  %45 = load i32, ptr %10, align 4, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %44
  %50 = load i32, ptr %10, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %51
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %52) #6
  br label %53

53:                                               ; preds = %49
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %10, align 4, !tbaa !5
  br label %44, !llvm.loop !13

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

57:                                               ; preds = %71, %56
  %58 = load i32, ptr %11, align 4, !tbaa !5
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %62, label %61

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

62:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %63 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %64 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %63, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %65 = load i32, ptr %12, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %66
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %67, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %68 = load i32, ptr %13, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %69
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %70, ptr noundef nonnull align 4 dereferenceable(4) %12)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %71

71:                                               ; preds = %62
  %72 = load i32, ptr %11, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %11, align 4, !tbaa !5
  br label %57, !llvm.loop !14

74:                                               ; preds = %61
  %75 = load i32, ptr %9, align 4, !tbaa !5
  %76 = icmp eq i32 %75, 1
  br i1 %76, label %77, label %80

77:                                               ; preds = %74
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 1)
  %79 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %78, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 5, ptr %14, align 4
  br label %170, !llvm.loop !15

80:                                               ; preds = %74
  call void @_Z3dfsii(i32 noundef 1, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %81 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %81, ptr %16, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %92, %80
  %83 = load i32, ptr %16, align 4, !tbaa !5
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %86, label %85

85:                                               ; preds = %82
  store i32 13, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %97

86:                                               ; preds = %82
  %87 = load i32, ptr %16, align 4, !tbaa !5
  %88 = load i32, ptr %15, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %15, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [200001 x i32], ptr @ids, i64 0, i64 %90
  store i32 %87, ptr %91, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %86
  %93 = load i32, ptr %16, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [200001 x i32], ptr @father, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  store i32 %96, ptr %16, align 4, !tbaa !5
  br label %82, !llvm.loop !16

97:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store i64 1, ptr %17, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 2, ptr %18, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %117, %97
  %99 = load i32, ptr %18, align 4, !tbaa !5
  %100 = load i32, ptr %15, align 4, !tbaa !5
  %101 = icmp sle i32 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 16, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %120

103:                                              ; preds = %98
  %104 = load i64, ptr %17, align 8, !tbaa !17
  %105 = load i32, ptr %18, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [200001 x i32], ptr @ids, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %109
  %111 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %110) #6
  %112 = getelementptr inbounds [200001 x i32], ptr @inv, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = mul nsw i64 %104, %114
  %116 = srem i64 %115, 1000000007
  store i64 %116, ptr %17, align 8, !tbaa !17
  br label %117

117:                                              ; preds = %103
  %118 = load i32, ptr %18, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %18, align 4, !tbaa !5
  br label %98, !llvm.loop !19

120:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %121 = load i64, ptr %17, align 8, !tbaa !17
  %122 = srem i64 %121, 1000000007
  store i64 %122, ptr %19, align 8, !tbaa !17
  %123 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) getelementptr inbounds ([200001 x %"class.std::vector"], ptr @ve, i64 0, i64 1)) #6
  %124 = icmp ne i64 %123, 1
  br i1 %124, label %125, label %129

125:                                              ; preds = %120
  %126 = load i64, ptr %17, align 8, !tbaa !17
  %127 = mul nsw i64 2, %126
  %128 = srem i64 %127, 1000000007
  store i64 %128, ptr %19, align 8, !tbaa !17
  br label %129

129:                                              ; preds = %125, %120
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 2, ptr %20, align 4, !tbaa !5
  br label %130

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

134:                                              ; preds = %130
  store i32 19, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %166

135:                                              ; preds = %130
  %136 = load i64, ptr %19, align 8, !tbaa !17
  %137 = load i64, ptr %17, align 8, !tbaa !17
  %138 = mul nsw i64 1, %137
  %139 = load i32, ptr %20, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [200001 x i32], ptr @ids, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %143
  %145 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %144) #6
  %146 = sub i64 %145, 2
  %147 = mul i64 %138, %146
  %148 = urem i64 %147, 1000000007
  %149 = load i32, ptr %20, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [200001 x i32], ptr @ids, i64 0, i64 %150
  %152 = load i32, ptr %151, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %153
  %155 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %154) #6
  %156 = sub i64 %155, 1
  %157 = getelementptr inbounds [200001 x i32], ptr @inv, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = mul i64 %148, %159
  %161 = add i64 %136, %160
  %162 = urem i64 %161, 1000000007
  store i64 %162, ptr %19, align 8, !tbaa !17
  br label %163

163:                                              ; preds = %135
  %164 = load i32, ptr %20, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %20, align 4, !tbaa !5
  br label %130, !llvm.loop !20

166:                                              ; preds = %134
  %167 = load i64, ptr %19, align 8, !tbaa !17
  %168 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %167)
  %169 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %168, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  store i32 0, ptr %14, align 4
  br label %170

170:                                              ; preds = %166, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %171 = load i32, ptr %14, align 4
  switch i32 %171, label %175 [
    i32 0, label %172
    i32 5, label %38
  ]

172:                                              ; preds = %170
  br label %38, !llvm.loop !15

173:                                              ; preds = %38
  store i32 0, ptr %3, align 4
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  %174 = load i32, ptr %3, align 4
  ret i32 %174

175:                                              ; preds = %170
  unreachable
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE5clearEv(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)) #2 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #2 align 2

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = !{!18, !18, i64 0}
!18 = !{!"long long", !7, i64 0}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@inv = external dso_local local_unnamed_addr global [200001 x i32], align 16
@ve = external dso_local global [200001 x %"class.std::vector"], align 16
@father = external dso_local local_unnamed_addr global [200001 x i32], align 16
@ids = external dso_local local_unnamed_addr global [200001 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6qpowerxxx(i64 noundef, i64 noundef, i64 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 @_Z3dfsii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #3 {
  %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
  store i32 1, ptr @inv, align 16, !tbaa !5
  br label %12

8:                                                ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr %3, align 4, !tbaa !5
  %.not65 = icmp eq i32 %10, 0
  br i1 %.not65, label %._crit_edge68, label %.lr.ph67

12:                                               ; preds = %2, %12
  %indvars.iv = phi i64 [ 0, %2 ], [ %indvars.iv.next, %12 ]
  %13 = tail call noundef i64 @_Z6qpowerxxx(i64 noundef %indvars.iv, i64 noundef 1000000005, i64 noundef 1000000007)
  %14 = trunc i64 %13 to i32
  %15 = getelementptr inbounds [200001 x i32], ptr @inv, i64 0, i64 %indvars.iv
  store i32 %14, ptr %15, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 200001
  br i1 %exitcond.not, label %8, label %12, !llvm.loop !9

.lr.ph67:                                         ; preds = %8, %79
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #7
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %.not3743 = icmp slt i32 %17, 1
  br i1 %.not3743, label %._crit_edge, label %.lr.ph

.preheader41:                                     ; preds = %.lr.ph
  %18 = icmp sgt i32 %20, 1
  br i1 %18, label %.lr.ph46, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph67, %.lr.ph
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %.lr.ph ], [ 1, %.lr.ph67 ]
  %19 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %indvars.iv72
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #7
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %.not37.not = icmp slt i64 %indvars.iv72, %21
  br i1 %.not37.not, label %.lr.ph, label %.preheader41, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph46, %.lr.ph67, %.preheader41
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 1
  br i1 %23, label %35, label %37

.lr.ph46:                                         ; preds = %.preheader41, %.lr.ph46
  %.03445 = phi i32 [ %32, %.lr.ph46 ], [ 1, %.preheader41 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %27
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %30
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %31, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #7
  %32 = add nuw nsw i32 %.03445, 1
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %.lr.ph46, label %._crit_edge, !llvm.loop !12

35:                                               ; preds = %._crit_edge
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 1)
  br label %79, !llvm.loop !13

37:                                               ; preds = %._crit_edge
  call void @_Z3dfsii(i32 noundef 1, i32 noundef 0)
  %.03247 = load i32, ptr %5, align 4, !tbaa !5
  %.not3848 = icmp eq i32 %.03247, 0
  br i1 %.not3848, label %._crit_edge57, label %.lr.ph52

.preheader:                                       ; preds = %.lr.ph52
  %38 = trunc nuw nsw i64 %indvars.iv.next76 to i32
  %.not3953 = icmp eq i64 %indvars.iv75, 0
  br i1 %.not3953, label %._crit_edge57, label %.lr.ph56.preheader

.lr.ph56.preheader:                               ; preds = %.preheader
  %39 = add nuw i64 %indvars.iv75, 2
  %wide.trip.count = and i64 %39, 4294967295
  br label %.lr.ph56

.lr.ph52:                                         ; preds = %37, %.lr.ph52
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %.lr.ph52 ], [ 0, %37 ]
  %.03250 = phi i32 [ %.032, %.lr.ph52 ], [ %.03247, %37 ]
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %40 = getelementptr inbounds [200001 x i32], ptr @ids, i64 0, i64 %indvars.iv.next76
  store i32 %.03250, ptr %40, align 4, !tbaa !5
  %41 = sext i32 %.03250 to i64
  %42 = getelementptr inbounds [200001 x i32], ptr @father, i64 0, i64 %41
  %.032 = load i32, ptr %42, align 4, !tbaa !5
  %.not38 = icmp eq i32 %.032, 0
  br i1 %.not38, label %.preheader, label %.lr.ph52, !llvm.loop !14

._crit_edge57:                                    ; preds = %.lr.ph56, %37, %.preheader
  %.033.lcssa89 = phi i32 [ %38, %.preheader ], [ 0, %37 ], [ %38, %.lr.ph56 ]
  %.031.lcssa = phi i64 [ 1, %.preheader ], [ 1, %37 ], [ %53, %.lr.ph56 ]
  %43 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) getelementptr inbounds (i8, ptr @ve, i64 24)) #7
  %.not40 = icmp eq i64 %43, 1
  br i1 %.not40, label %57, label %54

.lr.ph56:                                         ; preds = %.lr.ph56.preheader, %.lr.ph56
  %indvars.iv78 = phi i64 [ 2, %.lr.ph56.preheader ], [ %indvars.iv.next79, %.lr.ph56 ]
  %.03154 = phi i64 [ 1, %.lr.ph56.preheader ], [ %53, %.lr.ph56 ]
  %44 = getelementptr inbounds [200001 x i32], ptr @ids, i64 0, i64 %indvars.iv78
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %46
  %48 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %47) #7
  %49 = getelementptr inbounds [200001 x i32], ptr @inv, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = mul nsw i64 %.03154, %51
  %53 = srem i64 %52, 1000000007
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %exitcond81.not = icmp eq i64 %indvars.iv.next79, %wide.trip.count
  br i1 %exitcond81.not, label %._crit_edge57, label %.lr.ph56, !llvm.loop !15

54:                                               ; preds = %._crit_edge57
  %55 = shl nsw i64 %.031.lcssa, 1
  %56 = srem i64 %55, 1000000007
  br label %57

57:                                               ; preds = %54, %._crit_edge57
  %.029 = phi i64 [ %56, %54 ], [ %.031.lcssa, %._crit_edge57 ]
  %58 = icmp ugt i32 %.033.lcssa89, 2
  br i1 %58, label %.lr.ph62.preheader, label %._crit_edge63

.lr.ph62.preheader:                               ; preds = %57
  %wide.trip.count85 = zext i32 %.033.lcssa89 to i64
  br label %.lr.ph62

._crit_edge63:                                    ; preds = %.lr.ph62, %57
  %.1.lcssa = phi i64 [ %.029, %57 ], [ %78, %.lr.ph62 ]
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.1.lcssa)
  br label %79

.lr.ph62:                                         ; preds = %.lr.ph62.preheader, %.lr.ph62
  %indvars.iv82 = phi i64 [ 2, %.lr.ph62.preheader ], [ %indvars.iv.next83, %.lr.ph62 ]
  %.159 = phi i64 [ %.029, %.lr.ph62.preheader ], [ %78, %.lr.ph62 ]
  %60 = getelementptr inbounds [200001 x i32], ptr @ids, i64 0, i64 %indvars.iv82
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %62
  %64 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %63) #7
  %65 = add i64 %64, -2
  %66 = mul i64 %65, %.031.lcssa
  %67 = urem i64 %66, 1000000007
  %68 = load i32, ptr %60, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [200001 x %"class.std::vector"], ptr @ve, i64 0, i64 %69
  %71 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %70) #7
  %72 = add i64 %71, -1
  %73 = getelementptr inbounds [200001 x i32], ptr @inv, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = mul nsw i64 %67, %75
  %77 = add nsw i64 %76, %.159
  %78 = urem i64 %77, 1000000007
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %exitcond86.not = icmp eq i64 %indvars.iv.next83, %wide.trip.count85
  br i1 %exitcond86.not, label %._crit_edge63, label %.lr.ph62, !llvm.loop !16

79:                                               ; preds = %._crit_edge63, %35
  %.sink = phi ptr [ %59, %._crit_edge63 ], [ %36, %35 ]
  %80 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %.sink, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = add nsw i32 %81, -1
  store i32 %82, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %81, 0
  br i1 %.not, label %._crit_edge68, label %.lr.ph67

._crit_edge68:                                    ; preds = %79, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE5clearEv(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 #2 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #6

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #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 = 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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass