; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2012-13/Dec 2012/12 Dec G3.ll (Z3dfsi)

; 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::multiset" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_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::map" = type { %"class.std::_Rb_tree.0" }
%"class.std::_Rb_tree.0" = type { %"struct.std::_Rb_tree<int, std::pair<const int, long long>, std::_Select1st<std::pair<const int, long long>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, long long>, std::_Select1st<std::pair<const int, long long>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::pair" = type { i32, i64 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@L = external dso_local global i64, align 8
@ad = external dso_local global [200001 x i64], align 16
@loc = external dso_local global [200001 x i32], align 16
@ans = external dso_local global [200001 x i32], align 16
@val = external dso_local global [200001 x %"class.std::multiset"], align 16
@child = external dso_local global [200001 x %"class.std::map"], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsi(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca ptr, align 8
  %9 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %10 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair", align 8
  %13 = alloca ptr, align 8
  %14 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %15 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %19 = alloca i64, align 8
  %20 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %21 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %22 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %23 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %24 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %25 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %26, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [200001 x %"class.std::map"], ptr @child, i64 0, i64 %28
  store ptr %29, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %30 = load ptr, ptr %4, align 8, !tbaa !9
  %31 = call ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %30) #5
  %32 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %5, i32 0, i32 0
  store ptr %31, ptr %32, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %33 = load ptr, ptr %4, align 8, !tbaa !9
  %34 = call ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %33) #5
  %35 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %6, i32 0, i32 0
  store ptr %34, ptr %35, align 8
  br label %36

36:                                               ; preds = %78, %1
  %37 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKixEES5_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  br i1 %37, label %39, label %38

38:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %80

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  %40 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %40, i64 16, i1 false)
  %41 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !11
  call void @_Z3dfsi(i32 noundef %42)
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [200001 x %"class.std::map"], ptr @child, i64 0, i64 %44
  %46 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %45, ptr noundef nonnull align 4 dereferenceable(4) %46)
  %48 = load i64, ptr %47, align 8, !tbaa !14
  %49 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !14
  %57 = add nsw i64 %56, %48
  store i64 %57, ptr %55, align 8, !tbaa !14
  %58 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !11
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %63
  %65 = call noundef i64 @_ZNKSt8multisetIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %64) #5
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %70
  %72 = call noundef i64 @_ZNKSt8multisetIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %71) #5
  %73 = icmp ugt i64 %65, %72
  br i1 %73, label %74, label %77

74:                                               ; preds = %39
  %75 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  %76 = load i32, ptr %75, align 8, !tbaa !11
  store i32 %76, ptr %3, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %74, %39
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  br label %78

78:                                               ; preds = %77
  %79 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKixEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  br label %36

80:                                               ; preds = %38
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %86
  store i32 %84, ptr %87, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %88 = load i32, ptr %2, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [200001 x %"class.std::map"], ptr @child, i64 0, i64 %89
  store ptr %90, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %91 = load ptr, ptr %8, align 8, !tbaa !9
  %92 = call ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %91) #5
  %93 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %9, i32 0, i32 0
  store ptr %92, ptr %93, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %94 = load ptr, ptr %8, align 8, !tbaa !9
  %95 = call ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %94) #5
  %96 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %10, i32 0, i32 0
  store ptr %95, ptr %96, align 8
  br label %97

97:                                               ; preds = %156, %80
  %98 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKixEES5_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  br i1 %98, label %100, label %99

99:                                               ; preds = %97
  store i32 4, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %158

100:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  %101 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %101, i64 16, i1 false)
  %102 = getelementptr inbounds %"struct.std::pair", ptr %12, i32 0, i32 0
  %103 = load i32, ptr %102, align 8, !tbaa !11
  %104 = load i32, ptr %3, align 4, !tbaa !5
  %105 = icmp ne i32 %103, %104
  br i1 %105, label %106, label %155

106:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %107 = getelementptr inbounds %"struct.std::pair", ptr %12, i32 0, i32 0
  %108 = load i32, ptr %107, align 8, !tbaa !11
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %112
  store ptr %113, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %114 = load ptr, ptr %13, align 8, !tbaa !9
  %115 = call ptr @_ZNKSt8multisetIxSt4lessIxESaIxEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %114) #5
  %116 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %14, i32 0, i32 0
  store ptr %115, ptr %116, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %117 = load ptr, ptr %13, align 8, !tbaa !9
  %118 = call ptr @_ZNKSt8multisetIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %117) #5
  %119 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %15, i32 0, i32 0
  store ptr %118, ptr %119, align 8
  br label %120

120:                                              ; preds = %152, %106
  %121 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %15) #5
  br i1 %121, label %123, label %122

122:                                              ; preds = %120
  store i32 6, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %154

123:                                              ; preds = %120
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %124 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #5
  %125 = load i64, ptr %124, align 8, !tbaa !14
  store i64 %125, ptr %16, align 8, !tbaa !14
  %126 = load i32, ptr %2, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %130
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %132 = load i64, ptr %16, align 8, !tbaa !14
  %133 = getelementptr inbounds %"struct.std::pair", ptr %12, i32 0, i32 0
  %134 = load i32, ptr %133, align 8, !tbaa !11
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %138
  %140 = load i64, ptr %139, align 8, !tbaa !14
  %141 = add nsw i64 %132, %140
  %142 = load i32, ptr %2, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %146
  %148 = load i64, ptr %147, align 8, !tbaa !14
  %149 = sub nsw i64 %141, %148
  store i64 %149, ptr %17, align 8, !tbaa !14
  %150 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48) %131, ptr noundef nonnull align 8 dereferenceable(8) %17)
  %151 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %18, i32 0, i32 0
  store ptr %150, ptr %151, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %152

152:                                              ; preds = %123
  %153 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIxEppEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #5
  br label %120

154:                                              ; preds = %122
  br label %155

155:                                              ; preds = %154, %100
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  br label %156

156:                                              ; preds = %155
  %157 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKixEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  br label %97

158:                                              ; preds = %99
  %159 = load i32, ptr %2, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %163
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %165 = load i32, ptr %2, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %169
  %171 = load i64, ptr %170, align 8, !tbaa !14
  %172 = sub nsw i64 0, %171
  store i64 %172, ptr %19, align 8, !tbaa !14
  %173 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48) %164, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %174 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %20, i32 0, i32 0
  store ptr %173, ptr %174, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %175

175:                                              ; preds = %200, %158
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %176 = load i32, ptr %2, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %180
  %182 = call ptr @_ZNKSt8multisetIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %181) #5
  %183 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %22, i32 0, i32 0
  store ptr %182, ptr %183, align 8
  %184 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %22, i32 0, i32 0
  %185 = load ptr, ptr %184, align 8
  %186 = call ptr @_ZSt4prevISt23_Rb_tree_const_iteratorIxEET_S2_NSt15iterator_traitsIS2_E15difference_typeE(ptr %185, i64 noundef 1)
  %187 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %21, i32 0, i32 0
  store ptr %186, ptr %187, align 8
  %188 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %21) #5
  %189 = load i64, ptr %188, align 8, !tbaa !14
  %190 = load i32, ptr %2, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %191
  %193 = load i32, ptr %192, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %194
  %196 = load i64, ptr %195, align 8, !tbaa !14
  %197 = add nsw i64 %189, %196
  %198 = load i64, ptr @L, align 8, !tbaa !14
  %199 = icmp sgt i64 %197, %198
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  br i1 %199, label %200, label %223

200:                                              ; preds = %175
  %201 = load i32, ptr %2, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %202
  %204 = load i32, ptr %203, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %205
  %207 = load i32, ptr %2, align 4, !tbaa !5
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %208
  %210 = load i32, ptr %209, align 4, !tbaa !5
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %211
  %213 = call ptr @_ZNKSt8multisetIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %212) #5
  %214 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %24, i32 0, i32 0
  store ptr %213, ptr %214, align 8
  %215 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %24, i32 0, i32 0
  %216 = load ptr, ptr %215, align 8
  %217 = call ptr @_ZSt4prevISt23_Rb_tree_const_iteratorIxEET_S2_NSt15iterator_traitsIS2_E15difference_typeE(ptr %216, i64 noundef 1)
  %218 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %23, i32 0, i32 0
  store ptr %217, ptr %218, align 8
  %219 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %23, i32 0, i32 0
  %220 = load ptr, ptr %219, align 8
  %221 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIxE(ptr noundef nonnull align 8 dereferenceable(48) %206, ptr %220)
  %222 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %25, i32 0, i32 0
  store ptr %221, ptr %222, align 8
  br label %175, !llvm.loop !15

223:                                              ; preds = %175
  %224 = load i32, ptr %2, align 4, !tbaa !5
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %225
  %227 = load i32, ptr %226, align 4, !tbaa !5
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %228
  %230 = call noundef i64 @_ZNKSt8multisetIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %229) #5
  %231 = trunc i64 %230 to i32
  %232 = load i32, ptr %2, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds [200001 x i32], ptr @ans, i64 0, i64 %233
  store i32 %231, ptr %234, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

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

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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

; 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 noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKixEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4prevISt23_Rb_tree_const_iteratorIxEET_S2_NSt15iterator_traitsIS2_E15difference_typeE(ptr, i64 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNSt8multisetIxSt4lessIxESaIxEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIxE(ptr noundef nonnull align 8 dereferenceable(48), ptr) #0 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSSt4pairIKixE", !6, i64 0, !13, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

%"class.std::multiset" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_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::map" = type { %"class.std::_Rb_tree.0" }
%"class.std::_Rb_tree.0" = type { %"struct.std::_Rb_tree<int, std::pair<const int, long long>, std::_Select1st<std::pair<const int, long long>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, long long>, std::_Select1st<std::pair<const int, long long>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::pair" = type { i32, i64 }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@L = external dso_local local_unnamed_addr global i64, align 8
@ad = external dso_local local_unnamed_addr global [200001 x i64], align 16
@loc = external dso_local local_unnamed_addr global [200001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [200001 x i32], align 16
@val = external dso_local global [200001 x %"class.std::multiset"], align 16
@child = external dso_local global [200001 x %"class.std::map"], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %3 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %7 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %8 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %12 = sext i32 %0 to i64
  %13 = getelementptr inbounds [200001 x %"class.std::map"], ptr @child, i64 0, i64 %12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %14 = tail call ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %13) #5
  store ptr %14, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %15 = tail call ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %13) #5
  store ptr %15, ptr %3, align 8
  %16 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKixEES5_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  br i1 %16, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = sext i32 %spec.select to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %.pre-phi = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %12, %1 ]
  %.0.lcssa = phi i32 [ %spec.select, %._crit_edge.loopexit ], [ %0, %1 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  %17 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %.pre-phi
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %12
  store i32 %18, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %20 = call ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %13) #5
  store ptr %20, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %21 = call ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %13) #5
  store ptr %21, ptr %6, align 8
  %22 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKixEES5_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  br i1 %22, label %.lr.ph37, label %._crit_edge38

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.032 = phi i32 [ %spec.select, %.lr.ph ], [ %0, %1 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %23, i64 16, i1 false)
  %24 = load i32, ptr %4, align 8, !tbaa !9
  call void @_Z3dfsi(i32 noundef %24)
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %13, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %26 = load i64, ptr %25, align 8, !tbaa !12
  %27 = load i32, ptr %4, align 8, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !12
  %34 = add nsw i64 %33, %26
  store i64 %34, ptr %32, align 8, !tbaa !12
  %35 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %31
  %36 = call noundef i64 @_ZNKSt8multisetIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %35) #5
  %37 = sext i32 %.032 to i64
  %38 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %40
  %42 = call noundef i64 @_ZNKSt8multisetIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %41) #5
  %43 = icmp ugt i64 %36, %42
  %44 = load i32, ptr %4, align 8
  %spec.select = select i1 %43, i32 %44, i32 %.032
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKixEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  %46 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKixEES5_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  br i1 %46, label %.lr.ph, label %._crit_edge.loopexit

._crit_edge38:                                    ; preds = %80, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  %47 = load i32, ptr %19, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %48
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  %50 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %48
  %51 = load i64, ptr %50, align 8, !tbaa !12
  %52 = sub nsw i64 0, %51
  store i64 %52, ptr %10, align 8, !tbaa !12
  %53 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48) %49, ptr noundef nonnull align 8 dereferenceable(8) %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  br label %83

.lr.ph37:                                         ; preds = %._crit_edge, %80
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKixEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  %.sroa.07.0.copyload = load i32, ptr %54, align 8
  %.not = icmp eq i32 %.sroa.07.0.copyload, %.0.lcssa
  br i1 %.not, label %80, label %55

55:                                               ; preds = %.lr.ph37
  %56 = sext i32 %.sroa.07.0.copyload to i64
  %57 = getelementptr inbounds [200001 x i32], ptr @loc, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %59
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %61 = call ptr @_ZNKSt8multisetIxSt4lessIxESaIxEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %60) #5
  store ptr %61, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  %62 = call ptr @_ZNKSt8multisetIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %60) #5
  store ptr %62, ptr %8, align 8
  %63 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #5
  br i1 %63, label %.lr.ph34, label %._crit_edge35

._crit_edge35:                                    ; preds = %.lr.ph34, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %80

.lr.ph34:                                         ; preds = %55, %.lr.ph34
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  %65 = load i64, ptr %64, align 8, !tbaa !12
  %66 = load i32, ptr %19, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %67
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  %69 = load i32, ptr %57, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !12
  %73 = add nsw i64 %72, %65
  %74 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %67
  %75 = load i64, ptr %74, align 8, !tbaa !12
  %76 = sub i64 %73, %75
  store i64 %76, ptr %9, align 8, !tbaa !12
  %77 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE6insertEOx(ptr noundef nonnull align 8 dereferenceable(48) %68, ptr noundef nonnull align 8 dereferenceable(8) %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt23_Rb_tree_const_iteratorIxEppEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  %79 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8) #5
  br i1 %79, label %.lr.ph34, label %._crit_edge35

80:                                               ; preds = %._crit_edge35, %.lr.ph37
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKixEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  %82 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKixEES5_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  br i1 %82, label %.lr.ph37, label %._crit_edge38

83:                                               ; preds = %99, %._crit_edge38
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  %84 = load i32, ptr %19, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %85
  %87 = call ptr @_ZNKSt8multisetIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %86) #5
  %88 = call ptr @_ZSt4prevISt23_Rb_tree_const_iteratorIxEET_S2_NSt15iterator_traitsIS2_E15difference_typeE(ptr %87, i64 noundef 1)
  store ptr %88, ptr %11, align 8
  %89 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %90 = load i64, ptr %89, align 8, !tbaa !12
  %91 = load i32, ptr %19, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [200001 x i64], ptr @ad, i64 0, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !12
  %95 = add nsw i64 %94, %90
  %96 = load i64, ptr @L, align 8, !tbaa !12
  %97 = icmp sgt i64 %95, %96
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  %98 = getelementptr inbounds [200001 x %"class.std::multiset"], ptr @val, i64 0, i64 %92
  br i1 %97, label %99, label %103

99:                                               ; preds = %83
  %100 = call ptr @_ZNKSt8multisetIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %98) #5
  %101 = call ptr @_ZSt4prevISt23_Rb_tree_const_iteratorIxEET_S2_NSt15iterator_traitsIS2_E15difference_typeE(ptr %100, i64 noundef 1)
  %102 = call ptr @_ZNSt8multisetIxSt4lessIxESaIxEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIxE(ptr noundef nonnull align 8 dereferenceable(48) %98, ptr %101)
  br label %83, !llvm.loop !13

103:                                              ; preds = %83
  %104 = call noundef i64 @_ZNKSt8multisetIxSt4lessIxESaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %98) #5
  %105 = trunc i64 %104 to i32
  %106 = getelementptr inbounds [200001 x i32], ptr @ans, i64 0, i64 %12
  store i32 %105, ptr %106, align 4, !tbaa !5
  ret void
}

; 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 nounwind uwtable
declare dso_local ptr @_ZNSt3mapIixSt4lessIiESaISt4pairIKixEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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

; 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 noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKixEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

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

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4prevISt23_Rb_tree_const_iteratorIxEET_S2_NSt15iterator_traitsIS2_E15difference_typeE(ptr, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNSt8multisetIxSt4lessIxESaIxEE5eraseB5cxx11ESt23_Rb_tree_const_iteratorIxE(ptr noundef nonnull align 8 dereferenceable(48), ptr) local_unnamed_addr #0 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSSt4pairIKixE", !6, i64 0, !11, i64 8}
!11 = !{!"long long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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