; LLVM IR from VastoLorde95/Competitive-Programming :: Hackerrank/Random/Direct Connections (A)

; 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::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i64, i64 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"struct.std::greater" = type { i8 }

@tree1 = external dso_local global [200001 x i64], align 16
@tree2 = external dso_local global [200001 x i64], align 16
@tree3 = external dso_local global [200001 x i64], align 16
@tree4 = external dso_local global [200001 x i64], align 16
@t = external dso_local global i64, align 8
@n = external dso_local global i64, align 8
@MOD = external dso_local global i64, align 8
@sorted_index = external dso_local global [200001 x i64], align 16
@ans = external dso_local global i64, align 8
@x = external dso_local global %"class.std::vector", align 8
@p = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6query1x(i64 noundef) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7update1xx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6query2x(i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7update2xx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6query3x(i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7update3xx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6query4x(i64 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7update4xx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %"struct.std::pair", align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca %"struct.std::pair", align 8
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %14 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %15 = alloca %"struct.std::greater", align 1
  %16 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %17 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  store i32 0, ptr %1, align 4
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %23

23:                                               ; preds = %246, %0
  %24 = load i64, ptr @t, align 8, !tbaa !5
  %25 = add nsw i64 %24, -1
  store i64 %25, ptr @t, align 8, !tbaa !5
  %26 = icmp ne i64 %24, 0
  br i1 %26, label %27, label %249

27:                                               ; preds = %23
  call void @llvm.memset.p0.i64(ptr align 16 @tree1, i8 0, i64 1600008, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @tree2, i8 0, i64 1600008, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @tree3, i8 0, i64 1600008, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @tree4, i8 0, i64 1600008, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @sorted_index, i8 0, i64 1600008, i1 false)
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) @x) #8
  store i64 0, ptr @ans, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #8
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #8
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %43, %27
  %30 = load i64, ptr %3, align 8, !tbaa !5
  %31 = load i64, ptr @n, align 8, !tbaa !5
  %32 = icmp slt i64 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #8
  br label %46

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #8
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #8
  %36 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %37 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 0
  %38 = extractvalue { i64, i64 } %36, 0
  store i64 %38, ptr %37, align 8
  %39 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 1
  %40 = extractvalue { i64, i64 } %36, 1
  store i64 %40, ptr %39, align 8
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @x, ptr noundef nonnull align 8 dereferenceable(16) %5)
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #8
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %42 = load i64, ptr %41, align 8, !tbaa !5
  store i64 %42, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #8
  br label %43

43:                                               ; preds = %34
  %44 = load i64, ptr %3, align 8, !tbaa !5
  %45 = add nsw i64 %44, 1
  store i64 %45, ptr %3, align 8, !tbaa !5
  br label %29, !llvm.loop !9

46:                                               ; preds = %33
  %47 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @x) #8
  %48 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  store ptr %47, ptr %48, align 8
  %49 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @x) #8
  %50 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %49, ptr %50, align 8
  %51 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %6, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8
  %53 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %52, ptr %54)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %67, %46
  %56 = load i64, ptr %8, align 8, !tbaa !5
  %57 = load i64, ptr @n, align 8, !tbaa !5
  %58 = icmp slt i64 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %70

60:                                               ; preds = %55
  %61 = load i64, ptr %8, align 8, !tbaa !5
  %62 = load i64, ptr %8, align 8, !tbaa !5
  %63 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %62) #8
  %64 = getelementptr inbounds %"struct.std::pair", ptr %63, i32 0, i32 1
  %65 = load i64, ptr %64, align 8, !tbaa !11
  %66 = getelementptr inbounds [200001 x i64], ptr @sorted_index, i64 0, i64 %65
  store i64 %61, ptr %66, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %60
  %68 = load i64, ptr %8, align 8, !tbaa !5
  %69 = add nsw i64 %68, 1
  store i64 %69, ptr %8, align 8, !tbaa !5
  br label %55, !llvm.loop !13

70:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  store i64 0, ptr %9, align 8, !tbaa !5
  br label %71

71:                                               ; preds = %97, %70
  %72 = load i64, ptr %9, align 8, !tbaa !5
  %73 = load i64, ptr @n, align 8, !tbaa !5
  %74 = icmp slt i64 %72, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  br label %100

76:                                               ; preds = %71
  %77 = load i64, ptr %9, align 8, !tbaa !5
  %78 = add nsw i64 %77, 1
  %79 = load i64, ptr %9, align 8, !tbaa !5
  %80 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %79) #8
  %81 = getelementptr inbounds %"struct.std::pair", ptr %80, i32 0, i32 0
  %82 = load i64, ptr %81, align 8, !tbaa !14
  call void @_Z7update1xx(i64 noundef %78, i64 noundef %82)
  %83 = load i64, ptr @n, align 8, !tbaa !5
  %84 = load i64, ptr %9, align 8, !tbaa !5
  %85 = sub nsw i64 %83, %84
  %86 = load i64, ptr %2, align 8, !tbaa !5
  %87 = load i64, ptr %9, align 8, !tbaa !5
  %88 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %87) #8
  %89 = getelementptr inbounds %"struct.std::pair", ptr %88, i32 0, i32 0
  %90 = load i64, ptr %89, align 8, !tbaa !14
  %91 = sub nsw i64 %86, %90
  call void @_Z7update2xx(i64 noundef %85, i64 noundef %91)
  %92 = load i64, ptr %9, align 8, !tbaa !5
  %93 = add nsw i64 %92, 1
  call void @_Z7update3xx(i64 noundef %93, i64 noundef 1)
  %94 = load i64, ptr @n, align 8, !tbaa !5
  %95 = load i64, ptr %9, align 8, !tbaa !5
  %96 = sub nsw i64 %94, %95
  call void @_Z7update4xx(i64 noundef %96, i64 noundef 1)
  br label %97

97:                                               ; preds = %76
  %98 = load i64, ptr %9, align 8, !tbaa !5
  %99 = add nsw i64 %98, 1
  store i64 %99, ptr %9, align 8, !tbaa !5
  br label %71, !llvm.loop !15

100:                                              ; preds = %75
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  store i64 0, ptr %10, align 8, !tbaa !5
  br label %101

101:                                              ; preds = %113, %100
  %102 = load i64, ptr %10, align 8, !tbaa !5
  %103 = load i64, ptr @n, align 8, !tbaa !5
  %104 = icmp slt i64 %102, %103
  br i1 %104, label %106, label %105

105:                                              ; preds = %101
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  br label %116

106:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  %107 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %11)
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #8
  %108 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %109 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 0
  %110 = extractvalue { i64, i64 } %108, 0
  store i64 %110, ptr %109, align 8
  %111 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 1
  %112 = extractvalue { i64, i64 } %108, 1
  store i64 %112, ptr %111, align 8
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @p, ptr noundef nonnull align 8 dereferenceable(16) %12)
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  br label %113

113:                                              ; preds = %106
  %114 = load i64, ptr %10, align 8, !tbaa !5
  %115 = add nsw i64 %114, 1
  store i64 %115, ptr %10, align 8, !tbaa !5
  br label %101, !llvm.loop !16

116:                                              ; preds = %105
  %117 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  %118 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %117, ptr %118, align 8
  %119 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  %120 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %119, ptr %120, align 8
  %121 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8
  %123 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS3_SaIS3_EEEESt7greaterIS3_EEvT_SB_T0_(ptr %122, ptr %124)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %125 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  %126 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %16, i32 0, i32 0
  store ptr %125, ptr %126, align 8
  br label %127

127:                                              ; preds = %243, %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %128 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  %129 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %17, i32 0, i32 0
  store ptr %128, ptr %129, align 8
  %130 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIxxESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull align 8 dereferenceable(8) %17) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  br i1 %130, label %132, label %131

131:                                              ; preds = %127
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  br label %246

132:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %133 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %16) #8
  %134 = getelementptr inbounds %"struct.std::pair", ptr %133, i32 0, i32 0
  %135 = load i64, ptr %134, align 8, !tbaa !14
  store i64 %135, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #8
  %136 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %16) #8
  %137 = getelementptr inbounds %"struct.std::pair", ptr %136, i32 0, i32 1
  %138 = load i64, ptr %137, align 8, !tbaa !11
  %139 = getelementptr inbounds [200001 x i64], ptr @sorted_index, i64 0, i64 %138
  %140 = load i64, ptr %139, align 8, !tbaa !5
  store i64 %140, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %141 = load i64, ptr @n, align 8, !tbaa !5
  %142 = call noundef i64 @_Z6query1x(i64 noundef %141)
  %143 = load i64, ptr %19, align 8, !tbaa !5
  %144 = add nsw i64 %143, 1
  %145 = call noundef i64 @_Z6query1x(i64 noundef %144)
  %146 = sub nsw i64 %142, %145
  %147 = load i64, ptr @MOD, align 8, !tbaa !5
  %148 = add nsw i64 %146, %147
  %149 = load i64, ptr @MOD, align 8, !tbaa !5
  %150 = srem i64 %148, %149
  store i64 %150, ptr %20, align 8, !tbaa !5
  %151 = load i64, ptr %20, align 8, !tbaa !5
  %152 = load i64, ptr @MOD, align 8, !tbaa !5
  %153 = add nsw i64 %151, %152
  %154 = load i64, ptr @n, align 8, !tbaa !5
  %155 = call noundef i64 @_Z6query3x(i64 noundef %154)
  %156 = load i64, ptr %19, align 8, !tbaa !5
  %157 = add nsw i64 %156, 1
  %158 = call noundef i64 @_Z6query3x(i64 noundef %157)
  %159 = sub nsw i64 %155, %158
  %160 = load i64, ptr %19, align 8, !tbaa !5
  %161 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %160) #8
  %162 = getelementptr inbounds %"struct.std::pair", ptr %161, i32 0, i32 0
  %163 = load i64, ptr %162, align 8, !tbaa !14
  %164 = mul nsw i64 %159, %163
  %165 = load i64, ptr @MOD, align 8, !tbaa !5
  %166 = srem i64 %164, %165
  %167 = sub nsw i64 %153, %166
  %168 = load i64, ptr @MOD, align 8, !tbaa !5
  %169 = srem i64 %167, %168
  store i64 %169, ptr %20, align 8, !tbaa !5
  %170 = load i64, ptr @ans, align 8, !tbaa !5
  %171 = load i64, ptr %20, align 8, !tbaa !5
  %172 = load i64, ptr %18, align 8, !tbaa !5
  %173 = mul nsw i64 %171, %172
  %174 = load i64, ptr @MOD, align 8, !tbaa !5
  %175 = srem i64 %173, %174
  %176 = add nsw i64 %170, %175
  %177 = load i64, ptr @MOD, align 8, !tbaa !5
  %178 = srem i64 %176, %177
  store i64 %178, ptr @ans, align 8, !tbaa !5
  %179 = load i64, ptr %19, align 8, !tbaa !5
  %180 = add nsw i64 %179, 1
  %181 = load i64, ptr %19, align 8, !tbaa !5
  %182 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %181) #8
  %183 = getelementptr inbounds %"struct.std::pair", ptr %182, i32 0, i32 0
  %184 = load i64, ptr %183, align 8, !tbaa !14
  %185 = sub nsw i64 0, %184
  call void @_Z7update1xx(i64 noundef %180, i64 noundef %185)
  %186 = load i64, ptr %19, align 8, !tbaa !5
  %187 = add nsw i64 %186, 1
  call void @_Z7update3xx(i64 noundef %187, i64 noundef -1)
  %188 = load i64, ptr @n, align 8, !tbaa !5
  %189 = call noundef i64 @_Z6query2x(i64 noundef %188)
  %190 = load i64, ptr @n, align 8, !tbaa !5
  %191 = load i64, ptr %19, align 8, !tbaa !5
  %192 = sub nsw i64 %190, %191
  %193 = call noundef i64 @_Z6query2x(i64 noundef %192)
  %194 = sub nsw i64 %189, %193
  %195 = load i64, ptr @MOD, align 8, !tbaa !5
  %196 = add nsw i64 %194, %195
  %197 = load i64, ptr @MOD, align 8, !tbaa !5
  %198 = srem i64 %196, %197
  store i64 %198, ptr %20, align 8, !tbaa !5
  %199 = load i64, ptr %20, align 8, !tbaa !5
  %200 = load i64, ptr @MOD, align 8, !tbaa !5
  %201 = add nsw i64 %199, %200
  %202 = load i64, ptr @n, align 8, !tbaa !5
  %203 = call noundef i64 @_Z6query4x(i64 noundef %202)
  %204 = load i64, ptr @n, align 8, !tbaa !5
  %205 = load i64, ptr %19, align 8, !tbaa !5
  %206 = sub nsw i64 %204, %205
  %207 = call noundef i64 @_Z6query4x(i64 noundef %206)
  %208 = sub nsw i64 %203, %207
  %209 = load i64, ptr %2, align 8, !tbaa !5
  %210 = load i64, ptr %19, align 8, !tbaa !5
  %211 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %210) #8
  %212 = getelementptr inbounds %"struct.std::pair", ptr %211, i32 0, i32 0
  %213 = load i64, ptr %212, align 8, !tbaa !14
  %214 = sub nsw i64 %209, %213
  %215 = mul nsw i64 %208, %214
  %216 = load i64, ptr @MOD, align 8, !tbaa !5
  %217 = srem i64 %215, %216
  %218 = sub nsw i64 %201, %217
  %219 = load i64, ptr @MOD, align 8, !tbaa !5
  %220 = srem i64 %218, %219
  store i64 %220, ptr %20, align 8, !tbaa !5
  %221 = load i64, ptr @ans, align 8, !tbaa !5
  %222 = load i64, ptr %20, align 8, !tbaa !5
  %223 = load i64, ptr %18, align 8, !tbaa !5
  %224 = mul nsw i64 %222, %223
  %225 = load i64, ptr @MOD, align 8, !tbaa !5
  %226 = srem i64 %224, %225
  %227 = add nsw i64 %221, %226
  %228 = load i64, ptr @MOD, align 8, !tbaa !5
  %229 = srem i64 %227, %228
  store i64 %229, ptr @ans, align 8, !tbaa !5
  %230 = load i64, ptr @n, align 8, !tbaa !5
  %231 = load i64, ptr %19, align 8, !tbaa !5
  %232 = sub nsw i64 %230, %231
  %233 = load i64, ptr %2, align 8, !tbaa !5
  %234 = load i64, ptr %19, align 8, !tbaa !5
  %235 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %234) #8
  %236 = getelementptr inbounds %"struct.std::pair", ptr %235, i32 0, i32 0
  %237 = load i64, ptr %236, align 8, !tbaa !14
  %238 = sub nsw i64 %233, %237
  %239 = sub nsw i64 0, %238
  call void @_Z7update2xx(i64 noundef %232, i64 noundef %239)
  %240 = load i64, ptr @n, align 8, !tbaa !5
  %241 = load i64, ptr %19, align 8, !tbaa !5
  %242 = sub nsw i64 %240, %241
  call void @_Z7update4xx(i64 noundef %242, i64 noundef -1)
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  br label %243

243:                                              ; preds = %132
  %244 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS2_SaIS2_EEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %16, i32 noundef 0) #8
  %245 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %21, i32 0, i32 0
  store ptr %244, ptr %245, align 8
  br label %127, !llvm.loop !17

246:                                              ; preds = %131
  %247 = load i64, ptr @ans, align 8, !tbaa !5
  %248 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %247)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #8
  br label %23, !llvm.loop !18

249:                                              ; preds = %23
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIxxESt6vectorIS2_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 ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

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

declare i32 @printf(ptr noundef, ...) #3

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


; 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::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i64, i64 }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@tree1 = external dso_local local_unnamed_addr global [200001 x i64], align 16
@tree2 = external dso_local local_unnamed_addr global [200001 x i64], align 16
@tree3 = external dso_local local_unnamed_addr global [200001 x i64], align 16
@tree4 = external dso_local local_unnamed_addr global [200001 x i64], align 16
@t = external dso_local global i64, align 8
@n = external dso_local global i64, align 8
@MOD = external dso_local local_unnamed_addr global i64, align 8
@sorted_index = external dso_local local_unnamed_addr global [200001 x i64], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@x = external dso_local global %"class.std::vector", align 8
@p = external dso_local global %"class.std::vector", align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6query1x(i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7update1xx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6query2x(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7update2xx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6query3x(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7update3xx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z6query4x(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7update4xx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %11 = load i64, ptr @t, align 8, !tbaa !5
  %12 = add nsw i64 %11, -1
  store i64 %12, ptr @t, align 8, !tbaa !5
  %.not52 = icmp eq i64 %11, 0
  br i1 %.not52, label %._crit_edge55, label %.lr.ph54

.lr.ph54:                                         ; preds = %0
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  %14 = getelementptr inbounds i8, ptr %7, i64 8
  br label %15

15:                                               ; preds = %.lr.ph54, %._crit_edge51
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600008) @tree1, i8 0, i64 1600008, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600008) @tree2, i8 0, i64 1600008, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600008) @tree3, i8 0, i64 1600008, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600008) @tree4, i8 0, i64 1600008, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1600008) @sorted_index, i8 0, i64 1600008, i1 false)
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) @x) #8
  store i64 0, ptr @ans, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #8
  store i64 0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  store i64 0, ptr %2, align 8, !tbaa !5
  %17 = load i64, ptr @n, align 8, !tbaa !5
  %18 = icmp sgt i64 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  %19 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @x) #8
  %20 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @x) #8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS3_SaIS3_EEEEEvT_S9_(ptr %19, ptr %20)
  %21 = load i64, ptr @n, align 8, !tbaa !5
  %22 = icmp sgt i64 %21, 0
  br i1 %22, label %.lr.ph42, label %._crit_edge45.thread

.lr.ph:                                           ; preds = %15, %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #8
  %24 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %25 = extractvalue { i64, i64 } %24, 0
  store i64 %25, ptr %4, align 8
  %26 = extractvalue { i64, i64 } %24, 1
  store i64 %26, ptr %13, align 8
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @x, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #8
  %27 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %28 = load i64, ptr %27, align 8, !tbaa !5
  store i64 %28, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  %29 = load i64, ptr %2, align 8, !tbaa !5
  %30 = add nsw i64 %29, 1
  store i64 %30, ptr %2, align 8, !tbaa !5
  %31 = load i64, ptr @n, align 8, !tbaa !5
  %32 = icmp slt i64 %30, %31
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader:                                       ; preds = %.lr.ph42
  %33 = icmp sgt i64 %39, 0
  br i1 %33, label %.lr.ph44, label %._crit_edge45.thread

.lr.ph42:                                         ; preds = %._crit_edge, %.lr.ph42
  %.040 = phi i64 [ %38, %.lr.ph42 ], [ 0, %._crit_edge ]
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %.040) #8
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = load i64, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds [200001 x i64], ptr @sorted_index, i64 0, i64 %36
  store i64 %.040, ptr %37, align 8, !tbaa !5
  %38 = add nuw nsw i64 %.040, 1
  %39 = load i64, ptr @n, align 8, !tbaa !5
  %40 = icmp slt i64 %38, %39
  br i1 %40, label %.lr.ph42, label %.preheader, !llvm.loop !13

._crit_edge45.thread:                             ; preds = %.preheader, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  br label %._crit_edge48

._crit_edge45:                                    ; preds = %.lr.ph44
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  store i64 0, ptr %5, align 8, !tbaa !5
  %41 = icmp sgt i64 %53, 0
  br i1 %41, label %.lr.ph47, label %._crit_edge48

.lr.ph44:                                         ; preds = %.preheader, %.lr.ph44
  %.03443 = phi i64 [ %42, %.lr.ph44 ], [ 0, %.preheader ]
  %42 = add nuw nsw i64 %.03443, 1
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %.03443) #8
  %44 = load i64, ptr %43, align 8, !tbaa !14
  call void @_Z7update1xx(i64 noundef %42, i64 noundef %44)
  %45 = load i64, ptr @n, align 8, !tbaa !5
  %46 = sub nsw i64 %45, %.03443
  %47 = load i64, ptr %1, align 8, !tbaa !5
  %48 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %.03443) #8
  %49 = load i64, ptr %48, align 8, !tbaa !14
  %50 = sub nsw i64 %47, %49
  call void @_Z7update2xx(i64 noundef %46, i64 noundef %50)
  call void @_Z7update3xx(i64 noundef %42, i64 noundef 1)
  %51 = load i64, ptr @n, align 8, !tbaa !5
  %52 = sub nsw i64 %51, %.03443
  call void @_Z7update4xx(i64 noundef %52, i64 noundef 1)
  %53 = load i64, ptr @n, align 8, !tbaa !5
  %54 = icmp slt i64 %42, %53
  br i1 %54, label %.lr.ph44, label %._crit_edge45, !llvm.loop !15

._crit_edge48:                                    ; preds = %.lr.ph47, %._crit_edge45.thread, %._crit_edge45
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  %55 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  %56 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  call void @_ZSt4sortIN9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS3_SaIS3_EEEESt7greaterIS3_EEvT_SB_T0_(ptr %55, ptr %56)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #8
  %57 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  store ptr %57, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #8
  %58 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  store ptr %58, ptr %9, align 8
  %59 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIxxESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #8
  br i1 %59, label %.lr.ph50, label %._crit_edge51

.lr.ph47:                                         ; preds = %._crit_edge45, %.lr.ph47
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #8
  %60 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %6)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #8
  %61 = call { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %62 = extractvalue { i64, i64 } %61, 0
  store i64 %62, ptr %7, align 8
  %63 = extractvalue { i64, i64 } %61, 1
  store i64 %63, ptr %14, align 8
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) @p, ptr noundef nonnull align 8 dereferenceable(16) %7)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  %64 = load i64, ptr %5, align 8, !tbaa !5
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr %5, align 8, !tbaa !5
  %66 = load i64, ptr @n, align 8, !tbaa !5
  %67 = icmp slt i64 %65, %66
  br i1 %67, label %.lr.ph47, label %._crit_edge48, !llvm.loop !16

._crit_edge51:                                    ; preds = %.lr.ph50, %._crit_edge48
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #8
  %68 = load i64, ptr @ans, align 8, !tbaa !5
  %69 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %68)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  %70 = load i64, ptr @t, align 8, !tbaa !5
  %71 = add nsw i64 %70, -1
  store i64 %71, ptr @t, align 8, !tbaa !5
  %.not = icmp eq i64 %70, 0
  br i1 %.not, label %._crit_edge55, label %15, !llvm.loop !17

.lr.ph50:                                         ; preds = %._crit_edge48, %.lr.ph50
  %72 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  %73 = load i64, ptr %72, align 8, !tbaa !14
  %74 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS2_SaIS2_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #8
  %75 = getelementptr inbounds i8, ptr %74, i64 8
  %76 = load i64, ptr %75, align 8, !tbaa !11
  %77 = getelementptr inbounds [200001 x i64], ptr @sorted_index, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !5
  %79 = load i64, ptr @n, align 8, !tbaa !5
  %80 = call noundef i64 @_Z6query1x(i64 noundef %79)
  %81 = add nsw i64 %78, 1
  %82 = call noundef i64 @_Z6query1x(i64 noundef %81)
  %83 = sub i64 %80, %82
  %84 = load i64, ptr @MOD, align 8, !tbaa !5
  %85 = add nsw i64 %83, %84
  %86 = srem i64 %85, %84
  %87 = add nsw i64 %86, %84
  %88 = load i64, ptr @n, align 8, !tbaa !5
  %89 = call noundef i64 @_Z6query3x(i64 noundef %88)
  %90 = call noundef i64 @_Z6query3x(i64 noundef %81)
  %91 = sub nsw i64 %89, %90
  %92 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %78) #8
  %93 = load i64, ptr %92, align 8, !tbaa !14
  %94 = mul nsw i64 %93, %91
  %95 = load i64, ptr @MOD, align 8, !tbaa !5
  %96 = srem i64 %94, %95
  %97 = sub i64 %87, %96
  %98 = srem i64 %97, %95
  %99 = load i64, ptr @ans, align 8, !tbaa !5
  %100 = mul nsw i64 %98, %73
  %101 = srem i64 %100, %95
  %102 = add nsw i64 %101, %99
  %103 = srem i64 %102, %95
  store i64 %103, ptr @ans, align 8, !tbaa !5
  %104 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %78) #8
  %105 = load i64, ptr %104, align 8, !tbaa !14
  %106 = sub nsw i64 0, %105
  call void @_Z7update1xx(i64 noundef %81, i64 noundef %106)
  call void @_Z7update3xx(i64 noundef %81, i64 noundef -1)
  %107 = load i64, ptr @n, align 8, !tbaa !5
  %108 = call noundef i64 @_Z6query2x(i64 noundef %107)
  %109 = load i64, ptr @n, align 8, !tbaa !5
  %110 = sub nsw i64 %109, %78
  %111 = call noundef i64 @_Z6query2x(i64 noundef %110)
  %112 = sub i64 %108, %111
  %113 = load i64, ptr @MOD, align 8, !tbaa !5
  %114 = add nsw i64 %112, %113
  %115 = srem i64 %114, %113
  %116 = add nsw i64 %115, %113
  %117 = load i64, ptr @n, align 8, !tbaa !5
  %118 = call noundef i64 @_Z6query4x(i64 noundef %117)
  %119 = load i64, ptr @n, align 8, !tbaa !5
  %120 = sub nsw i64 %119, %78
  %121 = call noundef i64 @_Z6query4x(i64 noundef %120)
  %122 = sub nsw i64 %118, %121
  %123 = load i64, ptr %1, align 8, !tbaa !5
  %124 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %78) #8
  %125 = load i64, ptr %124, align 8, !tbaa !14
  %126 = sub nsw i64 %123, %125
  %127 = mul nsw i64 %126, %122
  %128 = load i64, ptr @MOD, align 8, !tbaa !5
  %129 = srem i64 %127, %128
  %130 = sub i64 %116, %129
  %131 = srem i64 %130, %128
  %132 = load i64, ptr @ans, align 8, !tbaa !5
  %133 = mul nsw i64 %131, %73
  %134 = srem i64 %133, %128
  %135 = add nsw i64 %134, %132
  %136 = srem i64 %135, %128
  store i64 %136, ptr @ans, align 8, !tbaa !5
  %137 = load i64, ptr @n, align 8, !tbaa !5
  %138 = sub nsw i64 %137, %78
  %139 = load i64, ptr %1, align 8, !tbaa !5
  %140 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @x, i64 noundef %78) #8
  %141 = load i64, ptr %140, align 8, !tbaa !14
  %.neg = sub nsw i64 %141, %139
  call void @_Z7update2xx(i64 noundef %138, i64 noundef %.neg)
  %142 = load i64, ptr @n, align 8, !tbaa !5
  %143 = sub nsw i64 %142, %78
  call void @_Z7update4xx(i64 noundef %143, i64 noundef -1)
  %144 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS2_SaIS2_EEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %8, i32 noundef 0) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #8
  %145 = call ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) @p) #8
  store ptr %145, ptr %9, align 8
  %146 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPSt4pairIxxESt6vectorIS2_SaIS2_EEEEbRKNS_17__normal_iteratorIT_T0_EESC_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #8
  br i1 %146, label %.lr.ph50, label %._crit_edge51, !llvm.loop !18

._crit_edge55:                                    ; preds = %._crit_edge51, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZSt9make_pairIRxS0_ESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS2_INS3_IT0_E4typeEE6__typeEEOS4_OS9_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZN9__gnu_cxx17__normal_iteratorIPSt4pairIxxESt6vectorIS2_SaIS2_EEEppEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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


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