; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/SHORT/COOK65/Problem E (brute)

; 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
@t = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@chno = external dso_local global i32, align 4
@idx = external dso_local global i32, align 4
@neg_inf = external dso_local global i32, align 4
@g = external dso_local global [100010 x %"class.std::vector"], align 16
@_ZL2ch = external hidden global [100010 x i32], align 16
@_ZL1P = external hidden global i32, align 4
@_ZL3lca = external hidden global [100010 x [20 x i32]], align 16
@_ZL3vis = external hidden global [100010 x i32], align 16
@_ZL1C = external hidden global [100010 x i32], align 16
@_ZL5chain = external hidden global [100010 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@_ZL1A = external hidden global i32, align 4
@_ZL1B = external hidden global i32, align 4
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [111 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3cmpii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildiii(i32 noundef, 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 uwtable
declare dso_local void @_Z3dfsi(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3hldi(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updateiii(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5queryii(i32 noundef, i32 noundef) #1

; 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 i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %12 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %19

19:                                               ; preds = %181, %0
  %20 = load i32, ptr @t, align 4, !tbaa !5
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr @t, align 4, !tbaa !5
  %22 = icmp ne i32 %20, 0
  br i1 %22, label %23, label %182

23:                                               ; preds = %19
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @n, ptr noundef @q, ptr noundef @_ZL1A, ptr noundef @_ZL1B)
  %25 = load i32, ptr @_ZL1A, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %37

27:                                               ; preds = %23
  %28 = load i32, ptr @_ZL1B, align 4, !tbaa !5
  %29 = icmp sge i32 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  %31 = load i32, ptr @neg_inf, align 4, !tbaa !5
  br label %35

32:                                               ; preds = %27
  %33 = load i32, ptr @neg_inf, align 4, !tbaa !5
  %34 = mul nsw i32 -1, %33
  br label %35

35:                                               ; preds = %32, %30
  %36 = phi i32 [ %31, %30 ], [ %34, %32 ]
  store i32 %36, ptr @_ZL1P, align 4, !tbaa !5
  br label %57

37:                                               ; preds = %23
  %38 = load i32, ptr @_ZL1B, align 4, !tbaa !5
  %39 = icmp slt i32 %38, 0
  br i1 %39, label %40, label %48

40:                                               ; preds = %37
  %41 = load i32, ptr @_ZL1B, align 4, !tbaa !5
  %42 = sitofp i32 %41 to double
  %43 = fmul double -1.000000e+00, %42
  %44 = load i32, ptr @_ZL1A, align 4, !tbaa !5
  %45 = sitofp i32 %44 to double
  %46 = fdiv double %43, %45
  %47 = call double @llvm.ceil.f64(double %46)
  br label %54

48:                                               ; preds = %37
  %49 = load i32, ptr @_ZL1B, align 4, !tbaa !5
  %50 = sub nsw i32 0, %49
  %51 = load i32, ptr @_ZL1A, align 4, !tbaa !5
  %52 = sdiv i32 %50, %51
  %53 = sitofp i32 %52 to double
  br label %54

54:                                               ; preds = %48, %40
  %55 = phi double [ %47, %40 ], [ %53, %48 ]
  %56 = fptosi double %55 to i32
  store i32 %56, ptr @_ZL1P, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %54, %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #8
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %88, %57
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = icmp sle i32 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 4, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #8
  br label %91

63:                                               ; preds = %58
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %65
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %66) #8
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100010 x i32], ptr @_ZL3vis, i64 0, i64 %68
  store i32 0, ptr %69, align 4, !tbaa !5
  %70 = load i32, ptr %2, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [100010 x i32], ptr @_ZL2ch, i64 0, i64 %71
  store i32 0, ptr %72, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %84, %63
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = icmp sle i32 %74, 19
  br i1 %75, label %77, label %76

76:                                               ; preds = %73
  store i32 7, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %87

77:                                               ; preds = %73
  %78 = load i32, ptr %2, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100010 x [20 x i32]], ptr @_ZL3lca, i64 0, i64 %79
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [20 x i32], ptr %80, i64 0, i64 %82
  store i32 -1, ptr %83, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %77
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %4, align 4, !tbaa !5
  br label %73, !llvm.loop !9

87:                                               ; preds = %76
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %2, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %2, align 4, !tbaa !5
  br label %58, !llvm.loop !11

91:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @_ZNSt6vectorIiSaIiEE9push_backEOi(ptr noundef nonnull align 8 dereferenceable(24) getelementptr inbounds ([100010 x %"class.std::vector"], ptr @g, i64 0, i64 1), ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  store i32 1, ptr @_ZL3vis, align 16, !tbaa !5
  store i32 1000000000, ptr @_ZL2ch, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %102, %91
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = load i32, ptr @n, align 4, !tbaa !5
  %95 = icmp sle i32 %93, %94
  br i1 %95, label %97, label %96

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

97:                                               ; preds = %92
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [100010 x i32], ptr @_ZL1C, i64 0, i64 %99
  %101 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %100)
  br label %102

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

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

106:                                              ; preds = %120, %105
  %107 = load i32, ptr %7, align 4, !tbaa !5
  %108 = load i32, ptr @n, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 1
  %110 = icmp sle i32 %107, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %106
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %123

112:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %113 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %8, ptr noundef %9)
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %115
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %116, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %117 = load i32, ptr %9, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %118
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %119, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %120

120:                                              ; preds = %112
  %121 = load i32, ptr %7, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %7, align 4, !tbaa !5
  br label %106, !llvm.loop !13

123:                                              ; preds = %111
  call void @_Z3dfsi(i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %144, %123
  %125 = load i32, ptr %10, align 4, !tbaa !5
  %126 = load i32, ptr @n, align 4, !tbaa !5
  %127 = icmp sle i32 %125, %126
  br i1 %127, label %129, label %128

128:                                              ; preds = %124
  store i32 16, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %147

129:                                              ; preds = %124
  %130 = load i32, ptr %10, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %131
  %133 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %132) #8
  %134 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %11, i32 0, i32 0
  store ptr %133, ptr %134, align 8
  %135 = load i32, ptr %10, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %136
  %138 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %137) #8
  %139 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  store ptr %138, ptr %139, align 8
  %140 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %11, i32 0, i32 0
  %141 = load ptr, ptr %140, align 8
  %142 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %12, i32 0, i32 0
  %143 = load ptr, ptr %142, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEPFiiiEEvT_S9_T0_(ptr %141, ptr %143, ptr noundef @_Z3cmpii)
  br label %144

144:                                              ; preds = %129
  %145 = load i32, ptr %10, align 4, !tbaa !5
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %10, align 4, !tbaa !5
  br label %124, !llvm.loop !14

147:                                              ; preds = %128
  store i32 1, ptr @chno, align 4, !tbaa !5
  store i32 0, ptr @idx, align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds ([100010 x i32], ptr @_ZL5chain, i64 0, i64 1), align 4, !tbaa !5
  call void @_Z3hldi(i32 noundef 1)
  %148 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z5buildiii(i32 noundef 1, i32 noundef %148, i32 noundef 1)
  br label %149

149:                                              ; preds = %180, %147
  %150 = load i32, ptr @q, align 4, !tbaa !5
  %151 = add nsw i32 %150, -1
  store i32 %151, ptr @q, align 4, !tbaa !5
  %152 = icmp ne i32 %150, 0
  br i1 %152, label %153, label %181

153:                                              ; preds = %149
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %154 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef %13, ptr noundef %14, ptr noundef %15)
  %155 = load i32, ptr %13, align 4, !tbaa !5
  %156 = icmp eq i32 %155, 1
  br i1 %156, label %157, label %162

157:                                              ; preds = %153
  %158 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %16)
  %159 = load i32, ptr %14, align 4, !tbaa !5
  %160 = load i32, ptr %15, align 4, !tbaa !5
  %161 = load i32, ptr %16, align 4, !tbaa !5
  call void @_Z6updateiii(i32 noundef %159, i32 noundef %160, i32 noundef %161)
  br label %180

162:                                              ; preds = %153
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #8
  %163 = load i32, ptr %14, align 4, !tbaa !5
  %164 = load i32, ptr %15, align 4, !tbaa !5
  %165 = call noundef i32 @_Z5queryii(i32 noundef %163, i32 noundef %164)
  store i32 %165, ptr %17, align 4, !tbaa !5
  %166 = load i32, ptr %17, align 4, !tbaa !5
  %167 = icmp sge i32 %166, 0
  br i1 %167, label %168, label %172

168:                                              ; preds = %162
  %169 = load i32, ptr %17, align 4, !tbaa !5
  %170 = load i32, ptr @n, align 4, !tbaa !5
  %171 = icmp sle i32 %169, %170
  br label %172

172:                                              ; preds = %168, %162
  %173 = phi i1 [ false, %162 ], [ %171, %168 ]
  br i1 %173, label %174, label %175

174:                                              ; preds = %172
  br label %177

175:                                              ; preds = %172
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef 308, ptr noundef @__PRETTY_FUNCTION__.main) #9
  unreachable

176:                                              ; No predecessors!
  br label %177

177:                                              ; preds = %176, %174
  %178 = load i32, ptr %17, align 4, !tbaa !5
  %179 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %178)
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #8
  br label %180

180:                                              ; preds = %177, %157
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %149, !llvm.loop !15

181:                                              ; preds = %149
  br label %19, !llvm.loop !16

182:                                              ; preds = %19
  ret i32 0
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #5

; 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_backEOi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) #1 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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEPFiiiEEvT_S9_T0_(ptr, ptr, ptr noundef) #6

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #7

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 nosync nounwind speculatable willreturn memory(none) }
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 = { noreturn 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 #8 = { nounwind }
attributes #9 = { noreturn 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}


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

@n = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@chno = external dso_local local_unnamed_addr global i32, align 4
@idx = external dso_local local_unnamed_addr global i32, align 4
@neg_inf = external dso_local local_unnamed_addr global i32, align 4
@g = external dso_local global [100010 x %"class.std::vector"], align 16
@_ZL2ch = external hidden local_unnamed_addr global [100010 x i32], align 16
@_ZL1P = external hidden local_unnamed_addr global i32, align 4
@_ZL3lca = external hidden local_unnamed_addr global [100010 x [20 x i32]], align 16
@_ZL3vis = external hidden local_unnamed_addr global [100010 x i32], align 16
@_ZL1C = external hidden global [100010 x i32], align 16
@_ZL5chain = external hidden local_unnamed_addr global [100010 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@_ZL1A = external hidden global i32, align 4
@_ZL1B = external hidden global i32, align 4
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [111 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3cmpii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildiii(i32 noundef, 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 uwtable
declare dso_local void @_Z3dfsi(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updateiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5queryii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %9 = load i32, ptr @t, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @t, align 4, !tbaa !5
  %.not53 = icmp eq i32 %9, 0
  br i1 %.not53, label %._crit_edge56, label %.lr.ph55

.loopexit:                                        ; preds = %87, %._crit_edge49
  %11 = load i32, ptr @t, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %._crit_edge56, label %.lr.ph55, !llvm.loop !9

.lr.ph55:                                         ; preds = %0, %.loopexit
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @n, ptr noundef nonnull @q, ptr noundef nonnull @_ZL1A, ptr noundef nonnull @_ZL1B)
  %14 = load i32, ptr @_ZL1A, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 0
  %16 = load i32, ptr @_ZL1B, align 4, !tbaa !5
  br i1 %15, label %17, label %22

17:                                               ; preds = %.lr.ph55
  %18 = load i32, ptr @neg_inf, align 4
  %19 = sub nsw i32 0, %18
  %20 = icmp slt i32 %16, 0
  %21 = select i1 %20, i32 %19, i32 %18
  br label %37

22:                                               ; preds = %.lr.ph55
  %23 = icmp slt i32 %16, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %22
  %25 = sitofp i32 %16 to double
  %26 = fneg double %25
  %27 = sitofp i32 %14 to double
  %28 = fdiv double %26, %27
  %29 = call double @llvm.ceil.f64(double %28)
  br label %34

30:                                               ; preds = %22
  %31 = sdiv i32 %16, %14
  %32 = sub nsw i32 0, %31
  %33 = sitofp i32 %32 to double
  br label %34

34:                                               ; preds = %30, %24
  %35 = phi double [ %29, %24 ], [ %33, %30 ]
  %36 = fptosi double %35 to i32
  br label %37

37:                                               ; preds = %34, %17
  %storemerge = phi i32 [ %36, %34 ], [ %21, %17 ]
  store i32 %storemerge, ptr @_ZL1P, align 4, !tbaa !5
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %.not2935 = icmp slt i32 %38, 0
  br i1 %.not2935, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %37
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #9
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @_ZNSt6vectorIiSaIiEE9push_backEOi(ptr noundef nonnull align 8 dereferenceable(24) getelementptr inbounds (i8, ptr @g, i64 24), ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #9
  store i32 1, ptr @_ZL3vis, align 16, !tbaa !5
  store i32 1000000000, ptr @_ZL2ch, align 16, !tbaa !5
  %39 = load i32, ptr @n, align 4, !tbaa !5
  %.not3037 = icmp slt i32 %39, 1
  br i1 %.not3037, label %._crit_edge44, label %.lr.ph40

.lr.ph:                                           ; preds = %37, %.lr.ph
  %indvar = phi i64 [ %indvar.next, %.lr.ph ], [ 0, %37 ]
  %40 = mul nuw nsw i64 %indvar, 80
  %scevgep = getelementptr i8, ptr @_ZL3lca, i64 %40
  %41 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %indvar
  call void @_ZNSt6vectorIiSaIiEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %41) #9
  %42 = getelementptr inbounds [100010 x i32], ptr @_ZL3vis, i64 0, i64 %indvar
  store i32 0, ptr %42, align 4, !tbaa !5
  %43 = getelementptr inbounds [100010 x i32], ptr @_ZL2ch, i64 0, i64 %indvar
  store i32 0, ptr %43, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(80) %scevgep, i8 -1, i64 80, i1 false), !tbaa !5
  %indvar.next = add nuw nsw i64 %indvar, 1
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %.not29.not = icmp slt i64 %indvar, %45
  br i1 %.not29.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph40
  %.not31.not41 = icmp sgt i32 %48, 1
  br i1 %.not31.not41, label %.lr.ph43, label %._crit_edge44

.lr.ph40:                                         ; preds = %._crit_edge, %.lr.ph40
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph40 ], [ 1, %._crit_edge ]
  %46 = getelementptr inbounds [100010 x i32], ptr @_ZL1C, i64 0, i64 %indvars.iv
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %46)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %.not30.not = icmp slt i64 %indvars.iv, %49
  br i1 %.not30.not, label %.lr.ph40, label %.preheader, !llvm.loop !12

._crit_edge44:                                    ; preds = %.lr.ph43, %._crit_edge, %.preheader
  call void @_Z3dfsi(i32 noundef 1)
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %.not3245 = icmp slt i32 %50, 1
  br i1 %.not3245, label %._crit_edge49, label %.lr.ph48

.lr.ph43:                                         ; preds = %.preheader, %.lr.ph43
  %.02442 = phi i32 [ %58, %.lr.ph43 ], [ 1, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #9
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %53
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %54, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %56
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %57, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #9
  %58 = add nuw nsw i32 %.02442, 1
  %59 = load i32, ptr @n, align 4, !tbaa !5
  %.not31.not = icmp slt i32 %58, %59
  br i1 %.not31.not, label %.lr.ph43, label %._crit_edge44, !llvm.loop !13

._crit_edge49:                                    ; preds = %.lr.ph48, %._crit_edge44
  store i32 1, ptr @chno, align 4, !tbaa !5
  store i32 0, ptr @idx, align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @_ZL5chain, i64 4), align 4, !tbaa !5
  call void @_Z3hldi(i32 noundef 1)
  %60 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z5buildiii(i32 noundef 1, i32 noundef %60, i32 noundef 1)
  %61 = load i32, ptr @q, align 4, !tbaa !5
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr @q, align 4, !tbaa !5
  %.not3350 = icmp eq i32 %61, 0
  br i1 %.not3350, label %.loopexit, label %.lr.ph52

.lr.ph48:                                         ; preds = %._crit_edge44, %.lr.ph48
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %.lr.ph48 ], [ 1, %._crit_edge44 ]
  %63 = getelementptr inbounds [100010 x %"class.std::vector"], ptr @g, i64 0, i64 %indvars.iv60
  %64 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %63) #9
  %65 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %63) #9
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEPFiiiEEvT_S9_T0_(ptr %64, ptr %65, ptr noundef nonnull @_Z3cmpii)
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %.not32.not = icmp slt i64 %indvars.iv60, %67
  br i1 %.not32.not, label %.lr.ph48, label %._crit_edge49, !llvm.loop !14

.lr.ph52:                                         ; preds = %._crit_edge49, %87
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #9
  %68 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = icmp eq i32 %69, 1
  br i1 %70, label %71, label %76

71:                                               ; preds = %.lr.ph52
  %72 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %7)
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z6updateiii(i32 noundef %73, i32 noundef %74, i32 noundef %75)
  br label %87

76:                                               ; preds = %.lr.ph52
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = call noundef i32 @_Z5queryii(i32 noundef %77, i32 noundef %78)
  %80 = icmp sgt i32 %79, -1
  %81 = load i32, ptr @n, align 4
  %82 = icmp sle i32 %79, %81
  %83 = select i1 %80, i1 %82, i1 false
  br i1 %83, label %85, label %84

84:                                               ; preds = %76
  call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, i32 noundef 308, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #10
  unreachable

85:                                               ; preds = %76
  %86 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %79)
  br label %87

87:                                               ; preds = %85, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #9
  %88 = load i32, ptr @q, align 4, !tbaa !5
  %89 = add nsw i32 %88, -1
  store i32 %89, ptr @q, align 4, !tbaa !5
  %.not33 = icmp eq i32 %88, 0
  br i1 %.not33, label %.loopexit, label %.lr.ph52, !llvm.loop !15

._crit_edge56:                                    ; preds = %.loopexit, %0
  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 nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #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_backEOi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEPFiiiEEvT_S9_T0_(ptr, ptr, ptr noundef) local_unnamed_addr #6

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #7

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

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

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 nosync nounwind speculatable willreturn memory(none) }
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 = { noreturn 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 #8 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #9 = { nounwind }
attributes #10 = { noreturn 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}


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