; LLVM IR from Aryansh-S/USACO :: USACO/2019/Dec/Gold (online_milkvisits)

; 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::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"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 }
%struct.HLD = type <{ [100000 x %"class.std::vector"], %"class.std::vector", [100000 x i32], [100000 x i32], [100000 x i32], [100000 x i32], [100000 x i32], i32, [4 x i8], %struct.rngset, i8, [7 x i8] }>
%struct.rngset = type { %"class.__gnu_pbds::tree" }
%"class.__gnu_pbds::tree" = type { %"class.__gnu_pbds::basic_branch" }
%"class.__gnu_pbds::basic_branch" = type { %"class.__gnu_pbds::detail::rb_tree_set" }
%"class.__gnu_pbds::detail::rb_tree_set" = type { %"class.__gnu_pbds::detail::bin_search_tree_set" }
%"class.__gnu_pbds::detail::bin_search_tree_set" = type { %"class.__gnu_pbds::tree_order_statistics_node_update", [8 x i8], ptr, i64 }
%"class.__gnu_pbds::tree_order_statistics_node_update" = type { %"struct.__gnu_pbds::detail::branch_policy" }
%"struct.__gnu_pbds::detail::branch_policy" = type { 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" }

@CLK = external dso_local global %"class.std::chrono::time_point", align 8
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@cow = external dso_local global %"class.std::vector", align 8
@h = external dso_local global %struct.HLD, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: nounwind
declare i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::chrono::time_point", align 8
  %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
  store i32 0, ptr %1, align 4
  %11 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.6)
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %18

13:                                               ; preds = %0
  %14 = load ptr, ptr @stdin, align 8, !tbaa !5
  %15 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.6, ptr noundef %14)
  %16 = load ptr, ptr @stdout, align 8, !tbaa !5
  %17 = call ptr @freopen(ptr noundef @.str.7, ptr noundef @.str.8, ptr noundef %16)
  br label %18

18:                                               ; preds = %13, %0
  %19 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %20 = getelementptr i8, ptr %19, i64 -24
  %21 = load i64, ptr %20, align 8
  %22 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %21
  %23 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %22, ptr noundef null)
  %24 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #8
  %25 = call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #8
  %26 = getelementptr inbounds %"class.std::chrono::time_point", ptr %2, i32 0, i32 0
  %27 = getelementptr inbounds %"class.std::chrono::duration", ptr %26, i32 0, i32 0
  store i64 %25, ptr %27, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @CLK, ptr align 8 %2, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #8
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %28 = load i32, ptr @n, align 4, !tbaa !14
  %29 = sext i32 %28 to i64
  call void @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) @cow, i64 noundef %29)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  %30 = load i32, ptr @n, align 4, !tbaa !14
  %31 = icmp sgt i32 0, %30
  %32 = zext i1 %31 to i32
  %33 = sub nsw i32 0, %32
  store i32 %33, ptr %3, align 4, !tbaa !14
  br label %34

34:                                               ; preds = %56, %18
  %35 = load i32, ptr %3, align 4, !tbaa !14
  %36 = load i32, ptr @n, align 4, !tbaa !14
  %37 = load i32, ptr @n, align 4, !tbaa !14
  %38 = icmp sgt i32 0, %37
  %39 = zext i1 %38 to i32
  %40 = sub nsw i32 %36, %39
  %41 = icmp ne i32 %35, %40
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %34
  %44 = load i32, ptr %3, align 4, !tbaa !14
  %45 = sext i32 %44 to i64
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @cow, i64 noundef %45) #8
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %46)
  br label %47

47:                                               ; preds = %43
  %48 = load i32, ptr @n, align 4, !tbaa !14
  %49 = icmp sgt i32 0, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %47
  %51 = load i32, ptr %3, align 4, !tbaa !14
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr %3, align 4, !tbaa !14
  br label %56

53:                                               ; preds = %47
  %54 = load i32, ptr %3, align 4, !tbaa !14
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %3, align 4, !tbaa !14
  br label %56

56:                                               ; preds = %53, %50
  %57 = phi ptr [ %3, %50 ], [ %3, %53 ]
  br label %34, !llvm.loop !16

58:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  %59 = load i32, ptr @n, align 4, !tbaa !14
  %60 = sub nsw i32 %59, 1
  %61 = icmp sgt i32 0, %60
  %62 = zext i1 %61 to i32
  %63 = sub nsw i32 0, %62
  store i32 %63, ptr %4, align 4, !tbaa !14
  br label %64

64:                                               ; preds = %92, %58
  %65 = load i32, ptr %4, align 4, !tbaa !14
  %66 = load i32, ptr @n, align 4, !tbaa !14
  %67 = sub nsw i32 %66, 1
  %68 = load i32, ptr @n, align 4, !tbaa !14
  %69 = sub nsw i32 %68, 1
  %70 = icmp sgt i32 0, %69
  %71 = zext i1 %70 to i32
  %72 = sub nsw i32 %67, %71
  %73 = icmp ne i32 %65, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %94

75:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %76 = load i32, ptr %5, align 4, !tbaa !14
  %77 = add nsw i32 %76, -1
  store i32 %77, ptr %5, align 4, !tbaa !14
  %78 = load i32, ptr %6, align 4, !tbaa !14
  %79 = add nsw i32 %78, -1
  store i32 %79, ptr %6, align 4, !tbaa !14
  %80 = load i32, ptr %5, align 4, !tbaa !14
  %81 = load i32, ptr %6, align 4, !tbaa !14
  call void @_ZN3HLDILi100000ELb0EE3addEii(ptr noundef nonnull align 8 dereferenceable(4400065) @h, i32 noundef %80, i32 noundef %81)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %82

82:                                               ; preds = %75
  %83 = load i32, ptr @n, align 4, !tbaa !14
  %84 = sub nsw i32 %83, 1
  %85 = icmp sgt i32 0, %84
  br i1 %85, label %86, label %89

86:                                               ; preds = %82
  %87 = load i32, ptr %4, align 4, !tbaa !14
  %88 = add nsw i32 %87, -1
  store i32 %88, ptr %4, align 4, !tbaa !14
  br label %92

89:                                               ; preds = %82
  %90 = load i32, ptr %4, align 4, !tbaa !14
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %4, align 4, !tbaa !14
  br label %92

92:                                               ; preds = %89, %86
  %93 = phi ptr [ %4, %86 ], [ %4, %89 ]
  br label %64, !llvm.loop !18

94:                                               ; preds = %74
  call void @_ZN3HLDILi100000ELb0EE4initEi(ptr noundef nonnull align 8 dereferenceable(4400065) @h, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %95 = load i32, ptr @n, align 4, !tbaa !14
  %96 = icmp sgt i32 0, %95
  %97 = zext i1 %96 to i32
  %98 = sub nsw i32 0, %97
  store i32 %98, ptr %7, align 4, !tbaa !14
  br label %99

99:                                               ; preds = %123, %94
  %100 = load i32, ptr %7, align 4, !tbaa !14
  %101 = load i32, ptr @n, align 4, !tbaa !14
  %102 = load i32, ptr @n, align 4, !tbaa !14
  %103 = icmp sgt i32 0, %102
  %104 = zext i1 %103 to i32
  %105 = sub nsw i32 %101, %104
  %106 = icmp ne i32 %100, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %125

108:                                              ; preds = %99
  %109 = load i32, ptr %7, align 4, !tbaa !14
  %110 = load i32, ptr %7, align 4, !tbaa !14
  %111 = sext i32 %110 to i64
  %112 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @cow, i64 noundef %111) #8
  %113 = load i32, ptr %112, align 4, !tbaa !14
  call void @_ZN3HLDILi100000ELb0EE3updEii(ptr noundef nonnull align 8 dereferenceable(4400065) @h, i32 noundef %109, i32 noundef %113)
  br label %114

114:                                              ; preds = %108
  %115 = load i32, ptr @n, align 4, !tbaa !14
  %116 = icmp sgt i32 0, %115
  br i1 %116, label %117, label %120

117:                                              ; preds = %114
  %118 = load i32, ptr %7, align 4, !tbaa !14
  %119 = add nsw i32 %118, -1
  store i32 %119, ptr %7, align 4, !tbaa !14
  br label %123

120:                                              ; preds = %114
  %121 = load i32, ptr %7, align 4, !tbaa !14
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %7, align 4, !tbaa !14
  br label %123

123:                                              ; preds = %120, %117
  %124 = phi ptr [ %7, %117 ], [ %7, %120 ]
  br label %99, !llvm.loop !19

125:                                              ; preds = %107
  br label %126

126:                                              ; preds = %130, %125
  %127 = load i32, ptr @m, align 4, !tbaa !14
  %128 = add nsw i32 %127, -1
  store i32 %128, ptr @m, align 4, !tbaa !14
  %129 = icmp ne i32 %127, 0
  br i1 %129, label %130, label %140

130:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  call void @_ZN7aryansh9io_macros2inIiJiiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %131 = load i32, ptr %8, align 4, !tbaa !14
  %132 = add nsw i32 %131, -1
  store i32 %132, ptr %8, align 4, !tbaa !14
  %133 = load i32, ptr %9, align 4, !tbaa !14
  %134 = add nsw i32 %133, -1
  store i32 %134, ptr %9, align 4, !tbaa !14
  %135 = load i32, ptr %8, align 4, !tbaa !14
  %136 = load i32, ptr %9, align 4, !tbaa !14
  %137 = load i32, ptr %10, align 4, !tbaa !14
  %138 = call noundef zeroext i1 @_ZN3HLDILi100000ELb0EE7qrypathEiii(ptr noundef nonnull align 8 dereferenceable(4400065) @h, i32 noundef %135, i32 noundef %136, i32 noundef %137)
  %139 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i1 noundef zeroext %138)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #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 %126, !llvm.loop !20

140:                                              ; preds = %126
  %141 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.9)
  %142 = load i32, ptr %1, align 4
  ret i32 %142
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #4 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #6

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #7 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) #6

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3HLDILi100000ELb0EE3addEii(ptr noundef nonnull align 8 dereferenceable(4400065), i32 noundef, i32 noundef) #7 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3HLDILi100000ELb0EE4initEi(ptr noundef nonnull align 8 dereferenceable(4400065), i32 noundef) #7 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3HLDILi100000ELb0EE3updEii(ptr noundef nonnull align 8 dereferenceable(4400065), i32 noundef, i32 noundef) #7 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIiJiiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #6

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8), i1 noundef zeroext) #7 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3HLDILi100000ELb0EE7qrypathEiii(ptr noundef nonnull align 8 dereferenceable(4400065), i32 noundef, i32 noundef, i32 noundef) #7 align 2

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

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


; 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::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"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 }
%struct.HLD = type <{ [100000 x %"class.std::vector"], %"class.std::vector", [100000 x i32], [100000 x i32], [100000 x i32], [100000 x i32], [100000 x i32], i32, [4 x i8], %struct.rngset, i8, [7 x i8] }>
%struct.rngset = type { %"class.__gnu_pbds::tree" }
%"class.__gnu_pbds::tree" = type { %"class.__gnu_pbds::basic_branch" }
%"class.__gnu_pbds::basic_branch" = type { %"class.__gnu_pbds::detail::rb_tree_set" }
%"class.__gnu_pbds::detail::rb_tree_set" = type { %"class.__gnu_pbds::detail::bin_search_tree_set" }
%"class.__gnu_pbds::detail::bin_search_tree_set" = type { %"class.__gnu_pbds::tree_order_statistics_node_update", [8 x i8], ptr, i64 }
%"class.__gnu_pbds::tree_order_statistics_node_update" = type { %"struct.__gnu_pbds::detail::branch_policy" }
%"struct.__gnu_pbds::detail::branch_policy" = type { 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" }

@CLK = external dso_local local_unnamed_addr global %"class.std::chrono::time_point", align 8
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@cow = external dso_local global %"class.std::vector", align 8
@h = external dso_local global %struct.HLD, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

; Function Attrs: nounwind
declare i64 @_ZNSt6chrono3_V212steady_clock3nowEv() local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.6)
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %12, label %7

7:                                                ; preds = %0
  %8 = load ptr, ptr @stdin, align 8, !tbaa !5
  %9 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.6, ptr noundef %8)
  %10 = load ptr, ptr @stdout, align 8, !tbaa !5
  %11 = tail call ptr @freopen(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.8, ptr noundef %10)
  br label %12

12:                                               ; preds = %7, %0
  %13 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %15
  %17 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  %18 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %19 = tail call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #8
  store i64 %19, ptr @CLK, align 8, !tbaa !11
  tail call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %20 = load i32, ptr @n, align 4, !tbaa !13
  %21 = sext i32 %20 to i64
  tail call void @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) @cow, i64 noundef %21)
  %22 = load i32, ptr @n, align 4, !tbaa !13
  %.not1827 = icmp eq i32 %22, 0
  br i1 %.not1827, label %.lr.ph33.preheader, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %12
  %.lobit.neg = ashr i32 %22, 31
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %.not2030 = icmp eq i32 %27, 1
  br i1 %.not2030, label %._crit_edge34, label %.lr.ph33.preheader

.lr.ph33.preheader:                               ; preds = %12, %._crit_edge
  %23 = phi i32 [ %27, %._crit_edge ], [ 0, %12 ]
  %24 = icmp slt i32 %23, 1
  %.neg = sext i1 %24 to i32
  br label %.lr.ph33

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.01528 = phi i32 [ %.116, %.lr.ph ], [ %.lobit.neg, %.lr.ph.preheader ]
  %25 = sext i32 %.01528 to i64
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @cow, i64 noundef %25) #8
  tail call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %26)
  %27 = load i32, ptr @n, align 4, !tbaa !13
  %.inv = icmp sgt i32 %27, -1
  %.116.v = select i1 %.inv, i32 1, i32 -1
  %.116 = add nsw i32 %.116.v, %.01528
  %.lobit.neg17 = ashr i32 %27, 31
  %28 = add i32 %.lobit.neg17, %27
  %.not18 = icmp eq i32 %.116, %28
  br i1 %.not18, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge34:                                    ; preds = %.lr.ph33, %._crit_edge
  call void @_ZN3HLDILi100000ELb0EE4initEi(ptr noundef nonnull align 8 dereferenceable(4400065) @h, i32 noundef 0)
  %29 = load i32, ptr @n, align 4, !tbaa !13
  %.not2336 = icmp eq i32 %29, 0
  br i1 %.not2336, label %.preheader, label %.lr.ph39.preheader

.lr.ph39.preheader:                               ; preds = %._crit_edge34
  %.lobit.neg21 = ashr i32 %29, 31
  br label %.lr.ph39

.lr.ph33:                                         ; preds = %.lr.ph33.preheader, %.lr.ph33
  %.01331 = phi i32 [ %.114, %.lr.ph33 ], [ %.neg, %.lr.ph33.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %30 = load i32, ptr %1, align 4, !tbaa !13
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr %1, align 4, !tbaa !13
  %32 = load i32, ptr %2, align 4, !tbaa !13
  %33 = add nsw i32 %32, -1
  store i32 %33, ptr %2, align 4, !tbaa !13
  call void @_ZN3HLDILi100000ELb0EE3addEii(ptr noundef nonnull align 8 dereferenceable(4400065) @h, i32 noundef %31, i32 noundef %33)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  %34 = load i32, ptr @n, align 4, !tbaa !13
  %35 = icmp slt i32 %34, 1
  %.114.v = select i1 %35, i32 -1, i32 1
  %.114 = add nsw i32 %.114.v, %.01331
  %36 = add nsw i32 %34, -1
  %.neg19 = sext i1 %35 to i32
  %37 = add i32 %36, %.neg19
  %.not20 = icmp eq i32 %.114, %37
  br i1 %.not20, label %._crit_edge34, label %.lr.ph33, !llvm.loop !17

.preheader:                                       ; preds = %.lr.ph39, %._crit_edge34
  %38 = load i32, ptr @m, align 4, !tbaa !13
  %39 = add nsw i32 %38, -1
  store i32 %39, ptr @m, align 4, !tbaa !13
  %.not2440 = icmp eq i32 %38, 0
  br i1 %.not2440, label %._crit_edge42, label %.lr.ph41

.lr.ph39:                                         ; preds = %.lr.ph39.preheader, %.lr.ph39
  %.037 = phi i32 [ %.1, %.lr.ph39 ], [ %.lobit.neg21, %.lr.ph39.preheader ]
  %40 = sext i32 %.037 to i64
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @cow, i64 noundef %40) #8
  %42 = load i32, ptr %41, align 4, !tbaa !13
  call void @_ZN3HLDILi100000ELb0EE3updEii(ptr noundef nonnull align 8 dereferenceable(4400065) @h, i32 noundef %.037, i32 noundef %42)
  %43 = load i32, ptr @n, align 4, !tbaa !13
  %.inv25 = icmp sgt i32 %43, -1
  %.1.v = select i1 %.inv25, i32 1, i32 -1
  %.1 = add nsw i32 %.1.v, %.037
  %.lobit.neg22 = ashr i32 %43, 31
  %44 = add i32 %.lobit.neg22, %43
  %.not23 = icmp eq i32 %.1, %44
  br i1 %.not23, label %.preheader, label %.lr.ph39, !llvm.loop !18

.lr.ph41:                                         ; preds = %.preheader, %.lr.ph41
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  call void @_ZN7aryansh9io_macros2inIiJiiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %45 = load i32, ptr %3, align 4, !tbaa !13
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr %3, align 4, !tbaa !13
  %47 = load i32, ptr %4, align 4, !tbaa !13
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr %4, align 4, !tbaa !13
  %49 = load i32, ptr %5, align 4, !tbaa !13
  %50 = call noundef zeroext i1 @_ZN3HLDILi100000ELb0EE7qrypathEiii(ptr noundef nonnull align 8 dereferenceable(4400065) @h, i32 noundef %46, i32 noundef %48, i32 noundef %49)
  %51 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i1 noundef zeroext %50)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  %52 = load i32, ptr @m, align 4, !tbaa !13
  %53 = add nsw i32 %52, -1
  store i32 %53, ptr @m, align 4, !tbaa !13
  %.not24 = icmp eq i32 %52, 0
  br i1 %.not24, label %._crit_edge42, label %.lr.ph41, !llvm.loop !19

._crit_edge42:                                    ; preds = %.lr.ph41, %.preheader
  %54 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.9)
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #7 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3HLDILi100000ELb0EE3addEii(ptr noundef nonnull align 8 dereferenceable(4400065), i32 noundef, i32 noundef) local_unnamed_addr #7 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3HLDILi100000ELb0EE4initEi(ptr noundef nonnull align 8 dereferenceable(4400065), i32 noundef) local_unnamed_addr #7 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3HLDILi100000ELb0EE3updEii(ptr noundef nonnull align 8 dereferenceable(4400065), i32 noundef, i32 noundef) local_unnamed_addr #7 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIiJiiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3HLDILi100000ELb0EE7qrypathEiii(ptr noundef nonnull align 8 dereferenceable(4400065), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #7 align 2

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

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


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