; LLVM IR from Aryansh-S/USACO :: algo_ds/more-segtree/CSES (hotel_queries)

; 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.SEG = type { i32, i32, %"class.std::vector" }
%"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" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@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
@v = external dso_local global %"class.std::vector", align 8
@second = external dso_local global %struct.SEG, 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
@_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 uwtable
declare dso_local noundef i32 @_Z3ansii(i32 noundef, i32 noundef) #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) #3 align 2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::chrono::time_point", align 8
  %3 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %4 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %5 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.6)
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %16

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

16:                                               ; preds = %11, %0
  %17 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %18 = getelementptr i8, ptr %17, i64 -24
  %19 = load i64, ptr %18, align 8
  %20 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %19
  %21 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %20, ptr noundef null)
  %22 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #9
  %23 = call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #9
  %24 = getelementptr inbounds %"class.std::chrono::time_point", ptr %2, i32 0, i32 0
  %25 = getelementptr inbounds %"class.std::chrono::duration", ptr %24, i32 0, i32 0
  store i64 %23, ptr %25, 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) #9
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %26 = load i32, ptr @n, align 4, !tbaa !14
  %27 = sext i32 %26 to i64
  call void @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) @v, i64 noundef %27)
  %28 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @v)
  %29 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %3, i32 0, i32 0
  store ptr %28, ptr %29, align 8
  %30 = call ptr @_ZSt3endISt6vectorIiSaIiEEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @v)
  %31 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  store ptr %30, ptr %31, align 8
  %32 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %3, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8
  %34 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %4, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8
  call void @_ZN7aryansh9io_macros2inIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEvEEvT_S9_(ptr %33, ptr %35)
  %36 = call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @v)
  %37 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %5, i32 0, i32 0
  store ptr %36, ptr %37, align 8
  %38 = call ptr @_ZSt3endISt6vectorIiSaIiEEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @v)
  %39 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  store ptr %38, ptr %39, align 8
  %40 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %5, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8
  %42 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8
  call void @_ZN3SEGIiE4initIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEvEEvT_S9_(ptr noundef nonnull align 8 dereferenceable(32) @second, ptr %41, ptr %43)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #9
  %44 = load i32, ptr @m, align 4, !tbaa !14
  %45 = icmp sgt i32 0, %44
  %46 = zext i1 %45 to i32
  %47 = sub nsw i32 0, %46
  store i32 %47, ptr %7, align 4, !tbaa !14
  br label %48

48:                                               ; preds = %86, %16
  %49 = load i32, ptr %7, align 4, !tbaa !14
  %50 = load i32, ptr @m, align 4, !tbaa !14
  %51 = load i32, ptr @m, align 4, !tbaa !14
  %52 = icmp sgt i32 0, %51
  %53 = zext i1 %52 to i32
  %54 = sub nsw i32 %50, %53
  %55 = icmp ne i32 %49, %54
  br i1 %55, label %57, label %56

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

57:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %8)
  %58 = load i32, ptr %8, align 4, !tbaa !14
  %59 = call noundef i32 @_Z3ansii(i32 noundef 1, i32 noundef %58)
  %60 = add nsw i32 %59, 1
  call void @_ZN7aryansh9io_macros4out_IivEEvT_(i32 noundef %60)
  %61 = load i32, ptr %8, align 4, !tbaa !14
  %62 = call noundef i32 @_Z3ansii(i32 noundef 1, i32 noundef %61)
  %63 = icmp ne i32 %62, -1
  br i1 %63, label %64, label %76

64:                                               ; preds = %57
  %65 = load i32, ptr %8, align 4, !tbaa !14
  %66 = call noundef i32 @_Z3ansii(i32 noundef 1, i32 noundef %65)
  %67 = load i32, ptr %8, align 4, !tbaa !14
  %68 = call noundef i32 @_Z3ansii(i32 noundef 1, i32 noundef %67)
  %69 = load i32, ptr getelementptr inbounds (%struct.SEG, ptr @second, i32 0, i32 1), align 4, !tbaa !16
  %70 = add nsw i32 %68, %69
  %71 = sext i32 %70 to i64
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) getelementptr inbounds (%struct.SEG, ptr @second, i32 0, i32 2), i64 noundef %71) #9
  %73 = load i32, ptr %72, align 4, !tbaa !14
  %74 = load i32, ptr %8, align 4, !tbaa !14
  %75 = sub nsw i32 %73, %74
  call void @_ZN3SEGIiE3updEii(ptr noundef nonnull align 8 dereferenceable(32) @second, i32 noundef %66, i32 noundef %75)
  br label %76

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

77:                                               ; preds = %76
  %78 = load i32, ptr @m, align 4, !tbaa !14
  %79 = icmp sgt i32 0, %78
  br i1 %79, label %80, label %83

80:                                               ; preds = %77
  %81 = load i32, ptr %7, align 4, !tbaa !14
  %82 = add nsw i32 %81, -1
  store i32 %82, ptr %7, align 4, !tbaa !14
  br label %86

83:                                               ; preds = %77
  %84 = load i32, ptr %7, align 4, !tbaa !14
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %7, align 4, !tbaa !14
  br label %86

86:                                               ; preds = %83, %80
  %87 = phi ptr [ %7, %80 ], [ %7, %83 ]
  br label %48, !llvm.loop !22

88:                                               ; preds = %56
  %89 = 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)
  %90 = load i32, ptr %1, align 4
  ret i32 %90
}

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

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

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

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

; 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) #6

; 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)) #7

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEvEEvT_S9_(ptr, ptr) #7

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3SEGIiE4initIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEvEEvT_S9_(ptr noundef nonnull align 8 dereferenceable(32), ptr, ptr) #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros4out_IivEEvT_(i32 noundef) #7

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3SEGIiE3updEii(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef) #2 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) #7

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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 #4 = { 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 #5 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 #8 = { inlinehint 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 #9 = { 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 = !{!17, !15, i64 4}
!17 = !{!"_ZTS3SEGIiE", !15, i64 0, !15, i64 4, !18, i64 8}
!18 = !{!"_ZTSSt6vectorIiSaIiEE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; 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.SEG = type { i32, i32, %"class.std::vector" }
%"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
@v = external dso_local global %"class.std::vector", align 8
@second = external dso_local global %struct.SEG, 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
@_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 uwtable
declare dso_local noundef i32 @_Z3ansii(i32 noundef, i32 noundef) local_unnamed_addr #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 #3 align 2

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

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

8:                                                ; preds = %3, %0
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %15 = tail call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #9
  store i64 %15, 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)
  %16 = load i32, ptr @n, align 4, !tbaa !13
  %17 = sext i32 %16 to i64
  tail call void @_ZNSt6vectorIiSaIiEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) @v, i64 noundef %17)
  %18 = tail call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @v)
  %19 = tail call ptr @_ZSt3endISt6vectorIiSaIiEEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @v)
  tail call void @_ZN7aryansh9io_macros2inIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEvEEvT_S9_(ptr %18, ptr %19)
  %20 = tail call ptr @_ZSt5beginISt6vectorIiSaIiEEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @v)
  %21 = tail call ptr @_ZSt3endISt6vectorIiSaIiEEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @v)
  tail call void @_ZN3SEGIiE4initIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEvEEvT_S9_(ptr noundef nonnull align 8 dereferenceable(32) @second, ptr %20, ptr %21)
  %22 = load i32, ptr @m, align 4, !tbaa !13
  %.not912 = icmp eq i32 %22, 0
  br i1 %.not912, label %._crit_edge, label %.lr.ph.preheader

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

._crit_edge:                                      ; preds = %41, %8
  %23 = 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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %41
  %.013 = phi i32 [ %.1, %41 ], [ %.lobit.neg, %.lr.ph.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #9
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %1)
  %24 = load i32, ptr %1, align 4, !tbaa !13
  %25 = call noundef i32 @_Z3ansii(i32 noundef 1, i32 noundef %24)
  %26 = add nsw i32 %25, 1
  call void @_ZN7aryansh9io_macros4out_IivEEvT_(i32 noundef %26)
  %27 = load i32, ptr %1, align 4, !tbaa !13
  %28 = call noundef i32 @_Z3ansii(i32 noundef 1, i32 noundef %27)
  %.not10 = icmp eq i32 %28, -1
  br i1 %.not10, label %41, label %29

29:                                               ; preds = %.lr.ph
  %30 = load i32, ptr %1, align 4, !tbaa !13
  %31 = call noundef i32 @_Z3ansii(i32 noundef 1, i32 noundef %30)
  %32 = load i32, ptr %1, align 4, !tbaa !13
  %33 = call noundef i32 @_Z3ansii(i32 noundef 1, i32 noundef %32)
  %34 = load i32, ptr getelementptr inbounds (i8, ptr @second, i64 4), align 4, !tbaa !15
  %35 = add nsw i32 %34, %33
  %36 = sext i32 %35 to i64
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) getelementptr inbounds (i8, ptr @second, i64 8), i64 noundef %36) #9
  %38 = load i32, ptr %37, align 4, !tbaa !13
  %39 = load i32, ptr %1, align 4, !tbaa !13
  %40 = sub nsw i32 %38, %39
  call void @_ZN3SEGIiE3updEii(ptr noundef nonnull align 8 dereferenceable(32) @second, i32 noundef %31, i32 noundef %40)
  br label %41

41:                                               ; preds = %29, %.lr.ph
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #9
  %42 = load i32, ptr @m, align 4, !tbaa !13
  %.inv = icmp sgt i32 %42, -1
  %.1.v = select i1 %.inv, i32 1, i32 -1
  %.1 = add nsw i32 %.1.v, %.013
  %.lobit.neg8 = ashr i32 %42, 31
  %43 = add i32 %.lobit.neg8, %42
  %.not9 = icmp eq i32 %.1, %43
  br i1 %.not9, label %._crit_edge, label %.lr.ph, !llvm.loop !21
}

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEEvEEvT_S9_(ptr, ptr) local_unnamed_addr #7

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros4out_IivEEvT_(i32 noundef) local_unnamed_addr #7

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3SEGIiE3updEii(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef) local_unnamed_addr #2 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 #7

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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 #4 = { 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 #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { "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 = { 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 #8 = { inlinehint 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 #9 = { 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 = !{!16, !14, i64 4}
!16 = !{!"_ZTS3SEGIiE", !14, i64 0, !14, i64 4, !17, i64 8}
!17 = !{!"_ZTSSt6vectorIiSaIiEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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