; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2017-18/Feb 2018/Plat/slingshot.ll (Z4initv)

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

%struct.SegTree = type { [262144 x i64] }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"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 }
%"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 }
%"struct.std::pair" = type { i32, i32 }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::array" = type { [3 x i32] }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"struct.std::pair.3" = type { %"struct.std::pair", i32 }

@S = external dso_local global [2 x [2 x %struct.SegTree]], align 16
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@co = external dso_local global i32, align 4
@m = external dso_local global %"class.std::map", align 8
@v = external dso_local global %"class.std::vector", align 8
@query = external dso_local global %"class.std::vector", align 8
@q = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.9 = 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 uwtable
define dso_local void @_Z4initv() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca %"struct.std::pair", align 4
  %7 = alloca %"struct.std::pair", align 4
  %8 = alloca %"struct.std::pair", align 4
  %9 = alloca ptr, align 8
  %10 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %11 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %12 = alloca ptr, align 8
  %13 = alloca %"struct.std::array", align 4
  %14 = alloca %"struct.std::array", align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"struct.std::array", align 4
  %19 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %20 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %21 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %22 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %23 = load ptr, ptr @stdin, align 8, !tbaa !5
  %24 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.7, ptr noundef %23)
  %25 = load ptr, ptr @stdout, align 8, !tbaa !5
  %26 = call ptr @freopen(ptr noundef @.str.8, ptr noundef @.str.9, ptr noundef %25)
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef nonnull align 4 dereferenceable(4) @M)
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %50, %0
  %30 = load i32, ptr %1, align 4, !tbaa !9
  %31 = load i32, ptr @N, align 4, !tbaa !9
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  br label %53

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %35, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %37 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %36, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %38 = call noundef i64 @_ZNKSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE5countERS4_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(8) %5)
  %39 = icmp ne i64 %38, 0
  %40 = xor i1 %39, true
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br i1 %40, label %41, label %44

41:                                               ; preds = %34
  %42 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(8) %6)
  store i32 %42, ptr %43, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  br label %49

44:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %45 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(8) %7)
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %45, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %47 = load i32, ptr %46, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(8) %8)
  store i32 %47, ptr %48, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %49

49:                                               ; preds = %44, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %1, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %1, align 4, !tbaa !9
  br label %29, !llvm.loop !11

53:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store ptr @m, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %54 = call ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  %55 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %10, i32 0, i32 0
  store ptr %54, ptr %55, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %56 = call ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  %57 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %11, i32 0, i32 0
  store ptr %56, ptr %57, align 8
  br label %58

58:                                               ; preds = %129, %53
  %59 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKS0_IiiEiEES6_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11) #6
  br i1 %59, label %61, label %60

60:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %131

61:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %62 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKS0_IiiEiEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #6
  store ptr %62, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #6
  %63 = getelementptr inbounds %"struct.std::array", ptr %13, i32 0, i32 0
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.std::pair.3", ptr %64, i32 0, i32 0
  %66 = getelementptr inbounds %"struct.std::pair", ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 4, !tbaa !13
  store i32 %67, ptr %63, align 4, !tbaa !9
  %68 = getelementptr inbounds i32, ptr %63, i64 1
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = getelementptr inbounds %"struct.std::pair.3", ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds %"struct.std::pair", ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !16
  store i32 %72, ptr %68, align 4, !tbaa !9
  %73 = getelementptr inbounds i32, ptr %63, i64 2
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.std::pair.3", ptr %74, i32 0, i32 1
  %76 = load i32, ptr %75, align 4, !tbaa !17
  store i32 %76, ptr %73, align 4, !tbaa !9
  call void @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @v, ptr noundef nonnull align 4 dereferenceable(12) %13)
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #6
  %77 = getelementptr inbounds %"struct.std::array", ptr %14, i32 0, i32 0
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = getelementptr inbounds %"struct.std::pair.3", ptr %78, i32 0, i32 0
  %80 = getelementptr inbounds %"struct.std::pair", ptr %79, i32 0, i32 1
  %81 = load i32, ptr %80, align 4, !tbaa !16
  store i32 %81, ptr %77, align 4, !tbaa !9
  %82 = getelementptr inbounds i32, ptr %77, i64 1
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = getelementptr inbounds %"struct.std::pair.3", ptr %83, i32 0, i32 0
  %85 = getelementptr inbounds %"struct.std::pair", ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !13
  store i32 %86, ptr %82, align 4, !tbaa !9
  %87 = getelementptr inbounds i32, ptr %77, i64 2
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = getelementptr inbounds %"struct.std::pair.3", ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !17
  store i32 %90, ptr %87, align 4, !tbaa !9
  call void @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @q, ptr noundef nonnull align 4 dereferenceable(12) %14)
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #6
  %91 = load i32, ptr @co, align 4, !tbaa !9
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %"struct.std::pair.3", ptr %92, i32 0, i32 0
  %94 = getelementptr inbounds %"struct.std::pair", ptr %93, i32 0, i32 1
  %95 = load i32, ptr %94, align 4, !tbaa !16
  %96 = sext i32 %95 to i64
  %97 = load ptr, ptr %12, align 8, !tbaa !5
  %98 = getelementptr inbounds %"struct.std::pair.3", ptr %97, i32 0, i32 0
  %99 = getelementptr inbounds %"struct.std::pair", ptr %98, i32 0, i32 0
  %100 = load i32, ptr %99, align 4, !tbaa !13
  %101 = sext i32 %100 to i64
  %102 = sub nsw i64 %96, %101
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = getelementptr inbounds %"struct.std::pair.3", ptr %103, i32 0, i32 1
  %105 = load i32, ptr %104, align 4, !tbaa !17
  %106 = sext i32 %105 to i64
  %107 = add nsw i64 %102, %106
  call void @_ZN7SegTree3updEix(ptr noundef nonnull align 8 dereferenceable(2097152) getelementptr inbounds ([2 x [2 x %struct.SegTree]], ptr @S, i64 0, i64 1), i32 noundef %91, i64 noundef %107)
  %108 = load i32, ptr @co, align 4, !tbaa !9
  %109 = load ptr, ptr %12, align 8, !tbaa !5
  %110 = getelementptr inbounds %"struct.std::pair.3", ptr %109, i32 0, i32 0
  %111 = getelementptr inbounds %"struct.std::pair", ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !16
  %113 = sext i32 %112 to i64
  %114 = load ptr, ptr %12, align 8, !tbaa !5
  %115 = getelementptr inbounds %"struct.std::pair.3", ptr %114, i32 0, i32 0
  %116 = getelementptr inbounds %"struct.std::pair", ptr %115, i32 0, i32 0
  %117 = load i32, ptr %116, align 4, !tbaa !13
  %118 = sext i32 %117 to i64
  %119 = add nsw i64 %113, %118
  %120 = load ptr, ptr %12, align 8, !tbaa !5
  %121 = getelementptr inbounds %"struct.std::pair.3", ptr %120, i32 0, i32 1
  %122 = load i32, ptr %121, align 4, !tbaa !17
  %123 = sext i32 %122 to i64
  %124 = add nsw i64 %119, %123
  call void @_ZN7SegTree3updEix(ptr noundef nonnull align 8 dereferenceable(2097152) getelementptr inbounds ([2 x %struct.SegTree], ptr getelementptr inbounds ([2 x [2 x %struct.SegTree]], ptr @S, i64 0, i64 1), i64 0, i64 1), i32 noundef %108, i64 noundef %124)
  %125 = load i32, ptr @co, align 4, !tbaa !9
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr @co, align 4, !tbaa !9
  %127 = load ptr, ptr %12, align 8, !tbaa !5
  %128 = getelementptr inbounds %"struct.std::pair.3", ptr %127, i32 0, i32 1
  store i32 %125, ptr %128, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %129

129:                                              ; preds = %61
  %130 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKS0_IiiEiEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #6
  br label %58

131:                                              ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %132

132:                                              ; preds = %146, %131
  %133 = load i32, ptr %15, align 4, !tbaa !9
  %134 = load i32, ptr @M, align 4, !tbaa !9
  %135 = icmp slt i32 %133, %134
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %149

137:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %138 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %139 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %138, ptr noundef nonnull align 4 dereferenceable(4) %17)
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #6
  %140 = getelementptr inbounds %"struct.std::array", ptr %18, i32 0, i32 0
  %141 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %141, ptr %140, align 4, !tbaa !9
  %142 = getelementptr inbounds i32, ptr %140, i64 1
  %143 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %143, ptr %142, align 4, !tbaa !9
  %144 = getelementptr inbounds i32, ptr %140, i64 2
  %145 = load i32, ptr %15, align 4, !tbaa !9
  store i32 %145, ptr %144, align 4, !tbaa !9
  call void @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @query, ptr noundef nonnull align 4 dereferenceable(12) %18)
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %146

146:                                              ; preds = %137
  %147 = load i32, ptr %15, align 4, !tbaa !9
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %15, align 4, !tbaa !9
  br label %132, !llvm.loop !18

149:                                              ; preds = %136
  %150 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @q) #6
  %151 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %19, i32 0, i32 0
  store ptr %150, ptr %151, align 8
  %152 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @q) #6
  %153 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %20, i32 0, i32 0
  store ptr %152, ptr %153, align 8
  %154 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %19, i32 0, i32 0
  %155 = load ptr, ptr %154, align 8
  %156 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %20, i32 0, i32 0
  %157 = load ptr, ptr %156, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %155, ptr %157)
  %158 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @query) #6
  %159 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %21, i32 0, i32 0
  store ptr %158, ptr %159, align 8
  %160 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @query) #6
  %161 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %22, i32 0, i32 0
  store ptr %160, ptr %161, align 8
  %162 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %21, i32 0, i32 0
  %163 = load ptr, ptr %162, align 8
  %164 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %22, i32 0, i32 0
  %165 = load ptr, ptr %164, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %163, ptr %165)
  ret void
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE5countERS4_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7SegTree3updEix(ptr noundef nonnull align 8 dereferenceable(2097152), i32 noundef, i64 noundef) #0 align 2

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

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

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

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

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSSt4pairIKS_IiiEiE", !15, i64 0, !10, i64 8}
!15 = !{!"_ZTSSt4pairIiiE", !10, i64 0, !10, i64 4}
!16 = !{!14, !10, i64 4}
!17 = !{!14, !10, i64 8}
!18 = distinct !{!18, !12}


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

%struct.SegTree = type { [262144 x i64] }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int>>, std::less<std::pair<int, int>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"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 }
%"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 }
%"struct.std::pair" = type { i32, i32 }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::array" = type { [3 x i32] }

@S = external dso_local global [2 x [2 x %struct.SegTree]], align 16
@N = external dso_local global i32, align 4
@M = external dso_local global i32, align 4
@co = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local global %"class.std::map", align 8
@v = external dso_local global %"class.std::vector", align 8
@query = external dso_local global %"class.std::vector", align 8
@q = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.9 = 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 uwtable
define dso_local void @_Z4initv() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", align 4
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca %"struct.std::pair", align 4
  %7 = alloca %"struct.std::pair", align 4
  %8 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %9 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %10 = alloca %"struct.std::array", align 8
  %11 = alloca %"struct.std::array", align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"struct.std::array", align 4
  %15 = load ptr, ptr @stdin, align 8, !tbaa !5
  %16 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.7, ptr noundef %15)
  %17 = load ptr, ptr @stdout, align 8, !tbaa !5
  %18 = tail call ptr @freopen(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.9, ptr noundef %17)
  %19 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(4) @M)
  %21 = load i32, ptr @N, align 4, !tbaa !9
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %41, %0
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  %23 = call ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  store ptr %23, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #6
  %24 = call ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @m) #6
  store ptr %24, ptr %9, align 8
  %25 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKS0_IiiEiEES6_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #6
  br i1 %25, label %.lr.ph23, label %._crit_edge24

.lr.ph23:                                         ; preds = %._crit_edge
  %26 = getelementptr inbounds i8, ptr %10, i64 8
  %27 = getelementptr inbounds i8, ptr %11, i64 4
  %28 = getelementptr inbounds i8, ptr %11, i64 8
  br label %49

.lr.ph:                                           ; preds = %0, %41
  %.021 = phi i32 [ %42, %41 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %29, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %31 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %32 = call noundef i64 @_ZNKSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE5countERS4_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(8) %4)
  %.not = icmp eq i64 %32, 0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br i1 %.not, label %33, label %36

33:                                               ; preds = %.lr.ph
  %34 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(8) %5)
  store i32 %34, ptr %35, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %41

36:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(8) %6)
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %37, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %39 = load i32, ptr %38, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48) @m, ptr noundef nonnull align 4 dereferenceable(8) %7)
  store i32 %39, ptr %40, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  br label %41

41:                                               ; preds = %36, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %42 = add nuw nsw i32 %.021, 1
  %43 = load i32, ptr @N, align 4, !tbaa !9
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge24:                                    ; preds = %49, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  %45 = load i32, ptr @M, align 4, !tbaa !9
  %46 = icmp sgt i32 %45, 0
  br i1 %46, label %.lr.ph27, label %._crit_edge28

.lr.ph27:                                         ; preds = %._crit_edge24
  %47 = getelementptr inbounds i8, ptr %14, i64 4
  %48 = getelementptr inbounds i8, ptr %14, i64 8
  br label %84

49:                                               ; preds = %.lr.ph23, %49
  %50 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKS0_IiiEiEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #6
  %51 = getelementptr inbounds i8, ptr %50, i64 4
  %52 = load <2 x i32>, ptr %50, align 4, !tbaa !9
  store <2 x i32> %52, ptr %10, align 8, !tbaa !9
  %53 = getelementptr inbounds i8, ptr %50, i64 8
  %54 = load i32, ptr %53, align 4, !tbaa !13
  store i32 %54, ptr %26, align 8, !tbaa !9
  call void @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @v, ptr noundef nonnull align 4 dereferenceable(12) %10)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #6
  %55 = load i32, ptr %51, align 4, !tbaa !16
  store i32 %55, ptr %11, align 4, !tbaa !9
  %56 = load i32, ptr %50, align 4, !tbaa !17
  store i32 %56, ptr %27, align 4, !tbaa !9
  %57 = load i32, ptr %53, align 4, !tbaa !13
  store i32 %57, ptr %28, align 4, !tbaa !9
  call void @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @q, ptr noundef nonnull align 4 dereferenceable(12) %11)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #6
  %58 = load i32, ptr @co, align 4, !tbaa !9
  %59 = load i32, ptr %51, align 4, !tbaa !16
  %60 = sext i32 %59 to i64
  %61 = load i32, ptr %50, align 4, !tbaa !17
  %62 = sext i32 %61 to i64
  %63 = sub nsw i64 %60, %62
  %64 = load i32, ptr %53, align 4, !tbaa !13
  %65 = sext i32 %64 to i64
  %66 = add nsw i64 %63, %65
  call void @_ZN7SegTree3updEix(ptr noundef nonnull align 8 dereferenceable(2097152) getelementptr inbounds (i8, ptr @S, i64 4194304), i32 noundef %58, i64 noundef %66)
  %67 = load i32, ptr @co, align 4, !tbaa !9
  %68 = load i32, ptr %51, align 4, !tbaa !16
  %69 = sext i32 %68 to i64
  %70 = load i32, ptr %50, align 4, !tbaa !17
  %71 = sext i32 %70 to i64
  %72 = add nsw i64 %71, %69
  %73 = load i32, ptr %53, align 4, !tbaa !13
  %74 = sext i32 %73 to i64
  %75 = add nsw i64 %72, %74
  call void @_ZN7SegTree3updEix(ptr noundef nonnull align 8 dereferenceable(2097152) getelementptr inbounds (i8, ptr @S, i64 6291456), i32 noundef %67, i64 noundef %75)
  %76 = load i32, ptr @co, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr @co, align 4, !tbaa !9
  store i32 %76, ptr %53, align 4, !tbaa !13
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKS0_IiiEiEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  %79 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKS0_IiiEiEES6_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #6
  br i1 %79, label %49, label %._crit_edge24

._crit_edge28:                                    ; preds = %84, %._crit_edge24
  %80 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @q) #6
  %81 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @q) #6
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %80, ptr %81)
  %82 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @query) #6
  %83 = call ptr @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @query) #6
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt5arrayIiLm3EESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %82, ptr %83)
  ret void

84:                                               ; preds = %.lr.ph27, %84
  %.02025 = phi i32 [ 0, %.lr.ph27 ], [ %89, %84 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #6
  %85 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %86 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %85, ptr noundef nonnull align 4 dereferenceable(4) %13)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %14) #6
  %87 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %87, ptr %14, align 4, !tbaa !9
  %88 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %88, ptr %47, align 4, !tbaa !9
  store i32 %.02025, ptr %48, align 4, !tbaa !9
  call void @_ZNSt6vectorISt5arrayIiLm3EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @query, ptr noundef nonnull align 4 dereferenceable(12) %14)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #6
  %89 = add nuw nsw i32 %.02025, 1
  %90 = load i32, ptr @M, align 4, !tbaa !9
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %84, label %._crit_edge28, !llvm.loop !18
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNKSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEE5countERS4_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapISt4pairIiiEiSt4lessIS1_ESaIS0_IKS1_iEEEixEOS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

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

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

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

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

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

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

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

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

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

; 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

attributes #0 = { 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 #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSSt4pairIKS_IiiEiE", !15, i64 0, !10, i64 8}
!15 = !{!"_ZTSSt4pairIiiE", !10, i64 0, !10, i64 4}
!16 = !{!14, !10, i64 4}
!17 = !{!14, !10, i64 0}
!18 = distinct !{!18, !12}


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