; LLVM IR from Aryansh-S/USACO :: algo_ds/DP/atcoder (q-flowers)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3>>>::_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 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@fl = external dso_local global %"class.std::vector", align 8
@dp = external dso_local global %struct.SEG, align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = 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: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %12 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.4)
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %19

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

19:                                               ; preds = %14, %0
  %20 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %21 = getelementptr i8, ptr %20, i64 -24
  %22 = load i64, ptr %21, align 8
  %23 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %22
  %24 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %23, ptr noundef null)
  %25 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @_Z2reIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) @n)
  %26 = load i32, ptr @n, align 4, !tbaa !11
  %27 = sext i32 %26 to i64
  call void @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) @fl, i64 noundef %27)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %38, %19
  %29 = load i32, ptr %2, align 4, !tbaa !11
  %30 = load i32, ptr @n, align 4, !tbaa !11
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %41

33:                                               ; preds = %28
  %34 = load i32, ptr %2, align 4, !tbaa !11
  %35 = sext i32 %34 to i64
  %36 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @fl, i64 noundef %35) #7
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %36, i64 noundef 0) #7
  call void @_Z2reIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) %37)
  br label %38

38:                                               ; preds = %33
  %39 = load i32, ptr %2, align 4, !tbaa !11
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %2, align 4, !tbaa !11
  br label %28, !llvm.loop !13

41:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %42

42:                                               ; preds = %52, %41
  %43 = load i32, ptr %3, align 4, !tbaa !11
  %44 = load i32, ptr @n, align 4, !tbaa !11
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %47, label %46

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

47:                                               ; preds = %42
  %48 = load i32, ptr %3, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @fl, i64 noundef %49) #7
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %50, i64 noundef 1) #7
  call void @_Z2reIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) %51)
  br label %52

52:                                               ; preds = %47
  %53 = load i32, ptr %3, align 4, !tbaa !11
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %3, align 4, !tbaa !11
  br label %42, !llvm.loop !15

55:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %56

56:                                               ; preds = %67, %55
  %57 = load i32, ptr %4, align 4, !tbaa !11
  %58 = load i32, ptr @n, align 4, !tbaa !11
  %59 = icmp slt i32 %57, %58
  br i1 %59, label %61, label %60

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

61:                                               ; preds = %56
  %62 = load i32, ptr %4, align 4, !tbaa !11
  %63 = load i32, ptr %4, align 4, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @fl, i64 noundef %64) #7
  %66 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %65, i64 noundef 2) #7
  store i32 %62, ptr %66, align 4, !tbaa !11
  br label %67

67:                                               ; preds = %61
  %68 = load i32, ptr %4, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %4, align 4, !tbaa !11
  br label %56, !llvm.loop !16

70:                                               ; preds = %60
  %71 = call ptr @_ZSt5beginISt6vectorISt5arrayIiLm3EESaIS2_EEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @fl)
  %72 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %5, i32 0, i32 0
  store ptr %71, ptr %72, align 8
  %73 = call ptr @_ZSt3endISt6vectorISt5arrayIiLm3EESaIS2_EEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @fl)
  %74 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  store ptr %73, ptr %74, align 8
  %75 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %5, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8
  %77 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %76, ptr %78)
  %79 = load i32, ptr @n, align 4, !tbaa !11
  call void @_ZN3SEG4initEi(ptr noundef nonnull align 8 dereferenceable(40) @dp, i32 noundef %79)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store ptr @fl, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %80 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @fl) #7
  %81 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  store ptr %80, ptr %81, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %82 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @fl) #7
  %83 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %9, i32 0, i32 0
  store ptr %82, ptr %83, align 8
  br label %84

84:                                               ; preds = %102, %70
  %85 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  br i1 %85, label %87, label %86

86:                                               ; preds = %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %104

87:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %88 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #7
  store ptr %88, ptr %10, align 8, !tbaa !5
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %89, i64 noundef 2) #7
  %91 = load i32, ptr %90, align 4, !tbaa !11
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  %93 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %92, i64 noundef 2) #7
  %94 = load i32, ptr %93, align 4, !tbaa !11
  %95 = sub nsw i32 %94, 1
  %96 = call noundef i64 @_ZN3SEG3qryEii(ptr noundef nonnull align 8 dereferenceable(40) @dp, i32 noundef 0, i32 noundef %95)
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %97, i64 noundef 1) #7
  %99 = load i32, ptr %98, align 4, !tbaa !11
  %100 = sext i32 %99 to i64
  %101 = add nsw i64 %96, %100
  call void @_ZN3SEG3updEix(ptr noundef nonnull align 8 dereferenceable(40) @dp, i32 noundef %91, i64 noundef %101)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %102

102:                                              ; preds = %87
  %103 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #7
  br label %84

104:                                              ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %105 = load i32, ptr @n, align 4, !tbaa !11
  %106 = sub nsw i32 %105, 1
  %107 = call noundef i64 @_ZN3SEG3qryEii(ptr noundef nonnull align 8 dereferenceable(40) @dp, i32 noundef 0, i32 noundef %106)
  store i64 %107, ptr %11, align 8, !tbaa !17
  call void @_Z2prIxJEEvOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8) %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  %108 = load i32, ptr %1, align 4
  ret i32 %108
}

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2reIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3SEG4initEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) #3 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3SEG3updEix(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3SEG3qryEii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z2prIxJEEvOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8)) #3

attributes #0 = { 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 #1 = { "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 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 #3 = { 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 #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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 #7 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = !{!18, !18, i64 0}
!18 = !{!"long long", !7, i64 0}


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3>>>::_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 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@n = external dso_local global i32, align 4
@fl = external dso_local global %"class.std::vector", align 8
@dp = external dso_local global %struct.SEG, align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %2 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %3 = alloca i64, align 8
  %4 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.4)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %10, label %5

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

10:                                               ; preds = %5, %0
  %11 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %12 = getelementptr i8, ptr %11, i64 -24
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %13
  %15 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %14, ptr noundef null)
  %16 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  tail call void @_Z2reIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) @n)
  %17 = load i32, ptr @n, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  tail call void @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) @fl, i64 noundef %18)
  %19 = load i32, ptr @n, align 4, !tbaa !11
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.preheader16:                                     ; preds = %.lr.ph
  %21 = icmp sgt i32 %24, 0
  br i1 %21, label %.lr.ph19, label %._crit_edge

.lr.ph:                                           ; preds = %10, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %10 ]
  %22 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @fl, i64 noundef %indvars.iv) #8
  %23 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %22, i64 noundef 0) #8
  tail call void @_Z2reIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) %23)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = load i32, ptr @n, align 4, !tbaa !11
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next, %25
  br i1 %26, label %.lr.ph, label %.preheader16, !llvm.loop !13

.preheader:                                       ; preds = %.lr.ph19
  %27 = icmp sgt i32 %30, 0
  br i1 %27, label %.lr.ph21, label %._crit_edge

.lr.ph19:                                         ; preds = %.preheader16, %.lr.ph19
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %.lr.ph19 ], [ 0, %.preheader16 ]
  %28 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @fl, i64 noundef %indvars.iv26) #8
  %29 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %28, i64 noundef 1) #8
  tail call void @_Z2reIRiJEEvOT_DpOT0_(ptr noundef nonnull align 4 dereferenceable(4) %29)
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %30 = load i32, ptr @n, align 4, !tbaa !11
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %indvars.iv.next27, %31
  br i1 %32, label %.lr.ph19, label %.preheader, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph21, %10, %.preheader16, %.preheader
  %33 = tail call ptr @_ZSt5beginISt6vectorISt5arrayIiLm3EESaIS2_EEEDTcldtfp_5beginEERT_(ptr noundef nonnull align 8 dereferenceable(24) @fl)
  %34 = tail call ptr @_ZSt3endISt6vectorISt5arrayIiLm3EESaIS2_EEEDTcldtfp_3endEERT_(ptr noundef nonnull align 8 dereferenceable(24) @fl)
  tail call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %33, ptr %34)
  %35 = load i32, ptr @n, align 4, !tbaa !11
  tail call void @_ZN3SEG4initEi(ptr noundef nonnull align 8 dereferenceable(40) @dp, i32 noundef %35)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #8
  %36 = tail call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @fl) #8
  store ptr %36, ptr %1, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  %37 = tail call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @fl) #8
  store ptr %37, ptr %2, align 8
  %38 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2) #8
  br i1 %38, label %.lr.ph23, label %._crit_edge24

.lr.ph21:                                         ; preds = %.preheader, %.lr.ph21
  %indvars.iv29 = phi i64 [ %indvars.iv.next30, %.lr.ph21 ], [ 0, %.preheader ]
  %39 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @fl, i64 noundef %indvars.iv29) #8
  %40 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %39, i64 noundef 2) #8
  %41 = trunc nuw nsw i64 %indvars.iv29 to i32
  store i32 %41, ptr %40, align 4, !tbaa !11
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %42 = load i32, ptr @n, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = icmp slt i64 %indvars.iv.next30, %43
  br i1 %44, label %.lr.ph21, label %._crit_edge, !llvm.loop !16

._crit_edge24:                                    ; preds = %.lr.ph23, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %45 = load i32, ptr @n, align 4, !tbaa !11
  %46 = add nsw i32 %45, -1
  %47 = call noundef i64 @_ZN3SEG3qryEii(ptr noundef nonnull align 8 dereferenceable(40) @dp, i32 noundef 0, i32 noundef %46)
  store i64 %47, ptr %3, align 8, !tbaa !17
  call void @_Z2prIxJEEvOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  ret i32 0

.lr.ph23:                                         ; preds = %._crit_edge, %.lr.ph23
  %48 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %1) #8
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %48, i64 noundef 2) #8
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %48, i64 noundef 2) #8
  %52 = load i32, ptr %51, align 4, !tbaa !11
  %53 = add nsw i32 %52, -1
  %54 = call noundef i64 @_ZN3SEG3qryEii(ptr noundef nonnull align 8 dereferenceable(40) @dp, i32 noundef 0, i32 noundef %53)
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12) %48, i64 noundef 1) #8
  %56 = load i32, ptr %55, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = add nsw i64 %54, %57
  call void @_ZN3SEG3updEix(ptr noundef nonnull align 8 dereferenceable(40) @dp, i32 noundef %50, i64 noundef %58)
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %1) #8
  %60 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2) #8
  br i1 %60, label %.lr.ph23, label %._crit_edge24
}

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

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIiLm3EEixEm(ptr noundef nonnull align 4 dereferenceable(12), i64 noundef) local_unnamed_addr #3 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3SEG4initEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) local_unnamed_addr #4 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #7

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS2_SaIS2_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3SEG3updEix(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3SEG3qryEii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef) local_unnamed_addr #4 align 2

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

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

attributes #0 = { 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 #1 = { 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 #2 = { "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 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 = { mustprogress nocallback nofree nosync 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 = { 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 #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 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = !{!18, !18, i64 0}
!18 = !{!"long long", !7, i64 0}


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