; LLVM IR from Aryansh-S/USACO :: algo_ds/more-tree/CSES (pathqry)

; 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 }
%struct.HLD = type { [200005 x %"class.std::vector"], %"class.std::vector", [200005 x i32], [200005 x i32], [200005 x i32], [200005 x i32], [200005 x i32], i32, %struct.SEG, 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.SEG = type { i64, i32, %"class.std::vector.0" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_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 }

@CLK = external dso_local global %"class.std::chrono::time_point", align 8
@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@h = external dso_local global %struct.HLD, align 8
@v = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [4 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 [5 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

; 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
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %13 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.6)
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %20

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

20:                                               ; preds = %15, %0
  %21 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %22 = getelementptr i8, ptr %21, i64 -24
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %23
  %25 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %24, ptr noundef null)
  %26 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #8
  %27 = call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #8
  %28 = getelementptr inbounds %"class.std::chrono::time_point", ptr %2, i32 0, i32 0
  %29 = getelementptr inbounds %"class.std::chrono::duration", ptr %28, i32 0, i32 0
  store i64 %27, ptr %29, 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) @q)
  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 = %53, %20
  %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 %55

43:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @v, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %44

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

47:                                               ; preds = %44
  %48 = load i32, ptr %3, align 4, !tbaa !14
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %3, align 4, !tbaa !14
  br label %53

50:                                               ; preds = %44
  %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 %53

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

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

61:                                               ; preds = %89, %55
  %62 = load i32, ptr %5, align 4, !tbaa !14
  %63 = load i32, ptr @n, align 4, !tbaa !14
  %64 = sub nsw i32 %63, 1
  %65 = load i32, ptr @n, align 4, !tbaa !14
  %66 = sub nsw i32 %65, 1
  %67 = icmp sgt i32 0, %66
  %68 = zext i1 %67 to i32
  %69 = sub nsw i32 %64, %68
  %70 = icmp ne i32 %62, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #8
  br label %91

72:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %73 = load i32, ptr %6, align 4, !tbaa !14
  %74 = add nsw i32 %73, -1
  store i32 %74, ptr %6, align 4, !tbaa !14
  %75 = load i32, ptr %7, align 4, !tbaa !14
  %76 = add nsw i32 %75, -1
  store i32 %76, ptr %7, align 4, !tbaa !14
  %77 = load i32, ptr %6, align 4, !tbaa !14
  %78 = load i32, ptr %7, align 4, !tbaa !14
  call void @_ZN3HLDILi200005ELb0EE3addEii(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef %77, i32 noundef %78)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  br label %79

79:                                               ; preds = %72
  %80 = load i32, ptr @n, align 4, !tbaa !14
  %81 = sub nsw i32 %80, 1
  %82 = icmp sgt i32 0, %81
  br i1 %82, label %83, label %86

83:                                               ; preds = %79
  %84 = load i32, ptr %5, align 4, !tbaa !14
  %85 = add nsw i32 %84, -1
  store i32 %85, ptr %5, align 4, !tbaa !14
  br label %89

86:                                               ; preds = %79
  %87 = load i32, ptr %5, align 4, !tbaa !14
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %5, align 4, !tbaa !14
  br label %89

89:                                               ; preds = %86, %83
  %90 = phi ptr [ %5, %83 ], [ %5, %86 ]
  br label %61, !llvm.loop !18

91:                                               ; preds = %71
  call void @_ZN3HLDILi200005ELb0EE4initEi(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  %92 = load i32, ptr @n, align 4, !tbaa !14
  %93 = icmp sgt i32 0, %92
  %94 = zext i1 %93 to i32
  %95 = sub nsw i32 0, %94
  store i32 %95, ptr %8, align 4, !tbaa !14
  br label %96

96:                                               ; preds = %120, %91
  %97 = load i32, ptr %8, align 4, !tbaa !14
  %98 = load i32, ptr @n, align 4, !tbaa !14
  %99 = load i32, ptr @n, align 4, !tbaa !14
  %100 = icmp sgt i32 0, %99
  %101 = zext i1 %100 to i32
  %102 = sub nsw i32 %98, %101
  %103 = icmp ne i32 %97, %102
  br i1 %103, label %105, label %104

104:                                              ; preds = %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %122

105:                                              ; preds = %96
  %106 = load i32, ptr %8, align 4, !tbaa !14
  %107 = load i32, ptr %8, align 4, !tbaa !14
  %108 = sext i32 %107 to i64
  %109 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @v, i64 noundef %108) #8
  %110 = load i32, ptr %109, align 4, !tbaa !14
  call void @_ZN3HLDILi200005ELb0EE3updEii(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef %106, i32 noundef %110)
  br label %111

111:                                              ; preds = %105
  %112 = load i32, ptr @n, align 4, !tbaa !14
  %113 = icmp sgt i32 0, %112
  br i1 %113, label %114, label %117

114:                                              ; preds = %111
  %115 = load i32, ptr %8, align 4, !tbaa !14
  %116 = add nsw i32 %115, -1
  store i32 %116, ptr %8, align 4, !tbaa !14
  br label %120

117:                                              ; preds = %111
  %118 = load i32, ptr %8, align 4, !tbaa !14
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %8, align 4, !tbaa !14
  br label %120

120:                                              ; preds = %117, %114
  %121 = phi ptr [ %8, %114 ], [ %8, %117 ]
  br label %96, !llvm.loop !19

122:                                              ; preds = %104
  br label %123

123:                                              ; preds = %140, %122
  %124 = load i32, ptr @q, align 4, !tbaa !14
  %125 = add nsw i32 %124, -1
  store i32 %125, ptr @q, align 4, !tbaa !14
  %126 = icmp ne i32 %124, 0
  br i1 %126, label %127, label %141

127:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %9)
  %128 = load i32, ptr %9, align 4, !tbaa !14
  %129 = icmp eq i32 %128, 1
  br i1 %129, label %130, label %135

130:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %131 = load i32, ptr %10, align 4, !tbaa !14
  %132 = add nsw i32 %131, -1
  store i32 %132, ptr %10, align 4, !tbaa !14
  %133 = load i32, ptr %10, align 4, !tbaa !14
  %134 = load i32, ptr %11, align 4, !tbaa !14
  call void @_ZN3HLDILi200005ELb0EE3updEii(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef %133, i32 noundef %134)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %140

135:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %12)
  %136 = load i32, ptr %12, align 4, !tbaa !14
  %137 = add nsw i32 %136, -1
  store i32 %137, ptr %12, align 4, !tbaa !14
  %138 = load i32, ptr %12, align 4, !tbaa !14
  %139 = call noundef i64 @_ZN3HLDILi200005ELb0EE7qrypathEii(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef 0, i32 noundef %138)
  call void @_ZN7aryansh9io_macros3outIxvEEvT_(i64 noundef %139)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %140

140:                                              ; preds = %135, %130
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %123, !llvm.loop !20

141:                                              ; preds = %123
  %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: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) #6

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

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

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

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

; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros3outIxvEEvT_(i64 noundef) #6

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3HLDILi200005ELb0EE7qrypathEii(ptr noundef nonnull align 8 dereferenceable(8800296), i32 noundef, i32 noundef) #7 align 2

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 }
%struct.HLD = type { [200005 x %"class.std::vector"], %"class.std::vector", [200005 x i32], [200005 x i32], [200005 x i32], [200005 x i32], [200005 x i32], i32, %struct.SEG, 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.SEG = type { i64, i32, %"class.std::vector.0" }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_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 }

@CLK = external dso_local local_unnamed_addr global %"class.std::chrono::time_point", align 8
@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@h = external dso_local global %struct.HLD, align 8
@v = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [4 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 [5 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

; 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 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.6)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %14, label %9

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

14:                                               ; preds = %9, %0
  %15 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %16 = getelementptr i8, ptr %15, i64 -24
  %17 = load i64, ptr %16, align 8
  %18 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %17
  %19 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %18, ptr noundef null)
  %20 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %21 = tail call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #8
  store i64 %21, 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) @q)
  %22 = load i32, ptr @n, align 4, !tbaa !13
  %.not1726 = icmp eq i32 %22, 0
  br i1 %.not1726, label %.lr.ph32.preheader, label %.lr.ph.preheader

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

._crit_edge:                                      ; preds = %.lr.ph
  %.not1929 = icmp eq i32 %25, 1
  br i1 %.not1929, label %._crit_edge33, label %.lr.ph32.preheader

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.01427 = phi i32 [ %.115, %.lr.ph ], [ %.lobit.neg, %.lr.ph.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) @v, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  %25 = load i32, ptr @n, align 4, !tbaa !13
  %.inv = icmp sgt i32 %25, -1
  %.115.v = select i1 %.inv, i32 1, i32 -1
  %.115 = add nsw i32 %.115.v, %.01427
  %.lobit.neg16 = ashr i32 %25, 31
  %26 = add i32 %.lobit.neg16, %25
  %.not17 = icmp eq i32 %.115, %26
  br i1 %.not17, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge33:                                    ; preds = %.lr.ph32, %._crit_edge
  call void @_ZN3HLDILi200005ELb0EE4initEi(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef 0)
  %27 = load i32, ptr @n, align 4, !tbaa !13
  %.not2235 = icmp eq i32 %27, 0
  br i1 %.not2235, label %.preheader, label %.lr.ph38.preheader

.lr.ph38.preheader:                               ; preds = %._crit_edge33
  %.lobit.neg20 = ashr i32 %27, 31
  br label %.lr.ph38

.lr.ph32:                                         ; preds = %.lr.ph32.preheader, %.lr.ph32
  %.01230 = phi i32 [ %.113, %.lr.ph32 ], [ %.neg, %.lr.ph32.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %28 = load i32, ptr %2, align 4, !tbaa !13
  %29 = add nsw i32 %28, -1
  store i32 %29, ptr %2, align 4, !tbaa !13
  %30 = load i32, ptr %3, align 4, !tbaa !13
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr %3, align 4, !tbaa !13
  call void @_ZN3HLDILi200005ELb0EE3addEii(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef %29, i32 noundef %31)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  %32 = load i32, ptr @n, align 4, !tbaa !13
  %33 = icmp slt i32 %32, 1
  %.113.v = select i1 %33, i32 -1, i32 1
  %.113 = add nsw i32 %.113.v, %.01230
  %34 = add nsw i32 %32, -1
  %.neg18 = sext i1 %33 to i32
  %35 = add i32 %34, %.neg18
  %.not19 = icmp eq i32 %.113, %35
  br i1 %.not19, label %._crit_edge33, label %.lr.ph32, !llvm.loop !17

.preheader:                                       ; preds = %.lr.ph38, %._crit_edge33
  %36 = load i32, ptr @q, align 4, !tbaa !13
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr @q, align 4, !tbaa !13
  %.not2339 = icmp eq i32 %36, 0
  br i1 %.not2339, label %._crit_edge41, label %.lr.ph40

.lr.ph38:                                         ; preds = %.lr.ph38.preheader, %.lr.ph38
  %.036 = phi i32 [ %.1, %.lr.ph38 ], [ %.lobit.neg20, %.lr.ph38.preheader ]
  %38 = sext i32 %.036 to i64
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @v, i64 noundef %38) #8
  %40 = load i32, ptr %39, align 4, !tbaa !13
  call void @_ZN3HLDILi200005ELb0EE3updEii(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef %.036, i32 noundef %40)
  %41 = load i32, ptr @n, align 4, !tbaa !13
  %.inv24 = icmp sgt i32 %41, -1
  %.1.v = select i1 %.inv24, i32 1, i32 -1
  %.1 = add nsw i32 %.1.v, %.036
  %.lobit.neg21 = ashr i32 %41, 31
  %42 = add i32 %.lobit.neg21, %41
  %.not22 = icmp eq i32 %.1, %42
  br i1 %.not22, label %.preheader, label %.lr.ph38, !llvm.loop !18

.lr.ph40:                                         ; preds = %.preheader, %53
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %4)
  %43 = load i32, ptr %4, align 4, !tbaa !13
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %45, label %49

45:                                               ; preds = %.lr.ph40
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #8
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %46 = load i32, ptr %5, align 4, !tbaa !13
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr %5, align 4, !tbaa !13
  %48 = load i32, ptr %6, align 4, !tbaa !13
  call void @_ZN3HLDILi200005ELb0EE3updEii(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef %47, i32 noundef %48)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  br label %53

49:                                               ; preds = %.lr.ph40
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #8
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %7)
  %50 = load i32, ptr %7, align 4, !tbaa !13
  %51 = add nsw i32 %50, -1
  store i32 %51, ptr %7, align 4, !tbaa !13
  %52 = call noundef i64 @_ZN3HLDILi200005ELb0EE7qrypathEii(ptr noundef nonnull align 8 dereferenceable(8800296) @h, i32 noundef 0, i32 noundef %51)
  call void @_ZN7aryansh9io_macros3outIxvEEvT_(i64 noundef %52)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #8
  br label %53

53:                                               ; preds = %49, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  %54 = load i32, ptr @q, align 4, !tbaa !13
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr @q, align 4, !tbaa !13
  %.not23 = icmp eq i32 %54, 0
  br i1 %.not23, label %._crit_edge41, label %.lr.ph40, !llvm.loop !19

._crit_edge41:                                    ; preds = %53, %.preheader
  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: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

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

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

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

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

; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros3outIxvEEvT_(i64 noundef) local_unnamed_addr #6

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3HLDILi200005ELb0EE7qrypathEii(ptr noundef nonnull align 8 dereferenceable(8800296), i32 noundef, i32 noundef) local_unnamed_addr #7 align 2

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