; LLVM IR from tangjz/acm-icpc :: 51nod/1578.ll (Z5solvei)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::pair" = type { i32, i32 }

@chd = external dso_local global [1000001 x %"class.std::map"], align 16
@tot = external dso_local global i32, align 4
@pos = external dso_local global i32, align 4
@fa = external dso_local global [1000001 x i32], align 16
@fa1 = external dso_local global [1000001 x i32], align 16
@size = external dso_local global [3 x i32], align 4
@dmax = external dso_local global [3 x i64], align 16
@dmin = external dso_local global [3 x i64], align 16
@dcnt = external dso_local global [3 x i64], align 16
@dist = external dso_local global [1000001 x i64], align 16
@dist1 = external dso_local global [1000001 x i64], align 16
@e = external dso_local global [1000001 x %"class.std::vector"], align 16
@e1 = external dso_local global [1000001 x %"class.std::vector"], align 16

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4pfs1i(i32 noundef) #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs1i(i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvei(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::vector", align 8
  %8 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %9 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %10 = alloca %"class.std::map", align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  store i32 0, ptr @pos, align 4, !tbaa !5
  store i32 1, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %13 = call i32 @getchar()
  store i32 %13, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  br label %14

14:                                               ; preds = %79, %1
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 10
  br i1 %16, label %17, label %20

17:                                               ; preds = %14
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = icmp ne i32 %18, -1
  br label %20

20:                                               ; preds = %17, %14
  %21 = phi i1 [ false, %14 ], [ %19, %17 ]
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %20
  br label %24

24:                                               ; preds = %30, %23
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = call i32 @isdigit(i32 noundef %25) #8
  %27 = icmp ne i32 %26, 0
  %28 = xor i1 %27, true
  br i1 %28, label %29, label %32

29:                                               ; preds = %24
  br label %30

30:                                               ; preds = %29
  %31 = call i32 @getchar()
  store i32 %31, ptr %3, align 4, !tbaa !5
  br label %24, !llvm.loop !9

32:                                               ; preds = %24
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %46, %32
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = call i32 @isdigit(i32 noundef %34) #8
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %48

37:                                               ; preds = %33
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = shl i32 %38, 3
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = shl i32 %40, 1
  %42 = add nsw i32 %39, %41
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = sub nsw i32 %43, 48
  %45 = add nsw i32 %42, %44
  store i32 %45, ptr %4, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %37
  %47 = call i32 @getchar()
  store i32 %47, ptr %3, align 4, !tbaa !5
  br label %33, !llvm.loop !11

48:                                               ; preds = %33
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 8
  br i1 %50, label %51, label %56

51:                                               ; preds = %48
  %52 = load i32, ptr @pos, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [1000001 x i32], ptr @fa, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  store i32 %55, ptr @pos, align 4, !tbaa !5
  br label %79

56:                                               ; preds = %48
  %57 = load i32, ptr @pos, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %58
  %60 = call noundef i64 @_ZNKSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) %59, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %73, label %62

62:                                               ; preds = %56
  %63 = load i32, ptr @tot, align 4, !tbaa !5
  %64 = load i32, ptr @pos, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %65
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %66, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store i32 %63, ptr %67, align 4, !tbaa !5
  %68 = load i32, ptr @pos, align 4, !tbaa !5
  %69 = load i32, ptr @tot, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr @tot, align 4, !tbaa !5
  %71 = sext i32 %69 to i64
  %72 = getelementptr inbounds [1000001 x i32], ptr @fa, i64 0, i64 %71
  store i32 %68, ptr %72, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %62, %56
  %74 = load i32, ptr @pos, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %75
  %77 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %76, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %78 = load i32, ptr %77, align 4, !tbaa !5
  store i32 %78, ptr @pos, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %73, %51
  br label %14, !llvm.loop !12

80:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %115, %80
  %82 = load i32, ptr %5, align 4, !tbaa !5
  %83 = load i32, ptr @tot, align 4, !tbaa !5
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %86, label %85

85:                                               ; preds = %81
  store i32 10, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %118

86:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #7
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #7
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @e, i64 0, i64 %88
  call void @_ZNSt6vectorIiSaIiEE4swapERS1_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(24) %89) #7
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %91
  %93 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %92) #7
  %94 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %8, i32 0, i32 0
  store ptr %93, ptr %94, align 8
  br label %95

95:                                               ; preds = %109, %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %96 = load i32, ptr %5, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %97
  %99 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %98) #7
  %100 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %9, i32 0, i32 0
  store ptr %99, ptr %100, align 8
  %101 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br i1 %101, label %103, label %102

102:                                              ; preds = %95
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %111

103:                                              ; preds = %95
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @e, i64 0, i64 %105
  %107 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #7
  %108 = getelementptr inbounds %"struct.std::pair", ptr %107, i32 0, i32 1
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %106, ptr noundef nonnull align 4 dereferenceable(4) %108)
  br label %109

109:                                              ; preds = %103
  %110 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %8) #7
  br label %95, !llvm.loop !13

111:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 48, ptr %10) #7
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 48, i1 false)
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %10) #7
  %112 = load i32, ptr %5, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %113
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE4swapERS6_(ptr noundef nonnull align 8 dereferenceable(48) %10, ptr noundef nonnull align 8 dereferenceable(48) %114) #7
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %10) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %10) #7
  br label %115

115:                                              ; preds = %111
  %116 = load i32, ptr %5, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %5, align 4, !tbaa !5
  br label %81, !llvm.loop !14

118:                                              ; preds = %85
  store i64 0, ptr @dist, align 16, !tbaa !15
  call void @_Z4pfs1i(i32 noundef 0)
  call void @_Z4dfs1i(i32 noundef 0)
  %119 = load i32, ptr @tot, align 4, !tbaa !5
  %120 = load i32, ptr %2, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [3 x i32], ptr @size, i64 0, i64 %121
  store i32 %119, ptr %122, align 4, !tbaa !5
  %123 = load i64, ptr @dist, align 16, !tbaa !15
  %124 = load i32, ptr %2, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [3 x i64], ptr @dcnt, i64 0, i64 %125
  store i64 %123, ptr %126, align 8, !tbaa !15
  %127 = load i32, ptr %2, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [3 x i64], ptr @dmin, i64 0, i64 %128
  store i64 %123, ptr %129, align 8, !tbaa !15
  %130 = load i32, ptr %2, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [3 x i64], ptr @dmax, i64 0, i64 %131
  store i64 %123, ptr %132, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %185, %118
  %134 = load i32, ptr %11, align 4, !tbaa !5
  %135 = load i32, ptr @tot, align 4, !tbaa !5
  %136 = icmp slt i32 %134, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %133
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %188

138:                                              ; preds = %133
  %139 = load i32, ptr %11, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [1000001 x i64], ptr @dist, i64 0, i64 %140
  %142 = load i64, ptr %141, align 8, !tbaa !15
  %143 = load i32, ptr %2, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [3 x i64], ptr @dcnt, i64 0, i64 %144
  %146 = load i64, ptr %145, align 8, !tbaa !15
  %147 = add nsw i64 %146, %142
  store i64 %147, ptr %145, align 8, !tbaa !15
  %148 = load i32, ptr %2, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [3 x i64], ptr @dmax, i64 0, i64 %149
  %151 = load i64, ptr %150, align 8, !tbaa !15
  %152 = load i32, ptr %11, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [1000001 x i64], ptr @dist, i64 0, i64 %153
  %155 = load i64, ptr %154, align 8, !tbaa !15
  %156 = icmp slt i64 %151, %155
  br i1 %156, label %157, label %165

157:                                              ; preds = %138
  %158 = load i32, ptr %11, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [1000001 x i64], ptr @dist, i64 0, i64 %159
  %161 = load i64, ptr %160, align 8, !tbaa !15
  %162 = load i32, ptr %2, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [3 x i64], ptr @dmax, i64 0, i64 %163
  store i64 %161, ptr %164, align 8, !tbaa !15
  br label %184

165:                                              ; preds = %138
  %166 = load i32, ptr %2, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [3 x i64], ptr @dmin, i64 0, i64 %167
  %169 = load i64, ptr %168, align 8, !tbaa !15
  %170 = load i32, ptr %11, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [1000001 x i64], ptr @dist, i64 0, i64 %171
  %173 = load i64, ptr %172, align 8, !tbaa !15
  %174 = icmp sgt i64 %169, %173
  br i1 %174, label %175, label %183

175:                                              ; preds = %165
  %176 = load i32, ptr %11, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [1000001 x i64], ptr @dist, i64 0, i64 %177
  %179 = load i64, ptr %178, align 8, !tbaa !15
  %180 = load i32, ptr %2, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [3 x i64], ptr @dmin, i64 0, i64 %181
  store i64 %179, ptr %182, align 8, !tbaa !15
  br label %183

183:                                              ; preds = %175, %165
  br label %184

184:                                              ; preds = %183, %157
  br label %185

185:                                              ; preds = %184
  %186 = load i32, ptr %11, align 4, !tbaa !5
  %187 = add nsw i32 %186, 1
  store i32 %187, ptr %11, align 4, !tbaa !5
  br label %133, !llvm.loop !17

188:                                              ; preds = %137
  %189 = load i32, ptr %2, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [3 x i64], ptr @dcnt, i64 0, i64 %190
  %192 = load i64, ptr %191, align 8, !tbaa !15
  %193 = ashr i64 %192, 1
  store i64 %193, ptr %191, align 8, !tbaa !15
  %194 = load i32, ptr %2, align 4, !tbaa !5
  %195 = icmp eq i32 %194, 1
  br i1 %195, label %196, label %219

196:                                              ; preds = %188
  %197 = load i32, ptr @tot, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = mul i64 %198, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @fa1, ptr align 16 @fa, i64 %199, i1 false)
  %200 = load i32, ptr @tot, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = mul i64 %201, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @dist1, ptr align 16 @dist, i64 %202, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %203

203:                                              ; preds = %215, %196
  %204 = load i32, ptr %12, align 4, !tbaa !5
  %205 = load i32, ptr @tot, align 4, !tbaa !5
  %206 = icmp slt i32 %204, %205
  br i1 %206, label %208, label %207

207:                                              ; preds = %203
  store i32 19, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %218

208:                                              ; preds = %203
  %209 = load i32, ptr %12, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @e1, i64 0, i64 %210
  %212 = load i32, ptr %12, align 4, !tbaa !5
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @e, i64 0, i64 %213
  call void @_ZNSt6vectorIiSaIiEE4swapERS1_(ptr noundef nonnull align 8 dereferenceable(24) %211, ptr noundef nonnull align 8 dereferenceable(24) %214) #7
  br label %215

215:                                              ; preds = %208
  %216 = load i32, ptr %12, align 4, !tbaa !5
  %217 = add nsw i32 %216, 1
  store i32 %217, ptr %12, align 4, !tbaa !5
  br label %203, !llvm.loop !18

218:                                              ; preds = %207
  br label %219

219:                                              ; preds = %218, %188
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @getchar() #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @isdigit(i32 noundef) #4

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

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

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

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

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

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

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

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

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

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

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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind willreturn memory(read) "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int>>, std::less<int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::_Rb_tree_iterator" = type { ptr }

@chd = external dso_local global [1000001 x %"class.std::map"], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@pos = external dso_local local_unnamed_addr global i32, align 4
@fa = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@fa1 = external dso_local local_unnamed_addr global [1000001 x i32], align 16
@size = external dso_local local_unnamed_addr global [3 x i32], align 4
@dmax = external dso_local local_unnamed_addr global [3 x i64], align 16
@dmin = external dso_local local_unnamed_addr global [3 x i64], align 16
@dcnt = external dso_local local_unnamed_addr global [3 x i64], align 16
@dist = external dso_local local_unnamed_addr global [1000001 x i64], align 16
@dist1 = external dso_local local_unnamed_addr global [1000001 x i64], align 16
@e = external dso_local global [1000001 x %"class.std::vector"], align 16
@e1 = external dso_local global [1000001 x %"class.std::vector"], align 16

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4pfs1i(i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4dfs1i(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvei(i32 noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = alloca %"class.std::vector", align 8
  %4 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %5 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %6 = alloca %"class.std::map", align 8
  store i32 0, ptr @pos, align 4, !tbaa !5
  store i32 1, ptr @tot, align 4, !tbaa !5
  %7 = tail call i32 @getchar()
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  br label %8

8:                                                ; preds = %41, %1
  %.036 = phi i32 [ %7, %1 ], [ %18, %41 ]
  switch i32 %.036, label %.preheader [
    i32 -1, label %10
    i32 10, label %10
  ]

.preheader:                                       ; preds = %8
  %9 = add i32 %.036, -58
  %isdigit40 = icmp ult i32 %9, -10
  br i1 %isdigit40, label %.lr.ph, label %._crit_edge

10:                                               ; preds = %8, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %11 = load i32, ptr @tot, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph53, label %._crit_edge54

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %13 = call i32 @getchar()
  %14 = add i32 %13, -58
  %isdigit = icmp ult i32 %14, -10
  br i1 %isdigit, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.1.lcssa = phi i32 [ %.036, %.preheader ], [ %13, %.lr.ph ]
  store i32 0, ptr %2, align 4, !tbaa !5
  %isdigittmp41 = add nsw i32 %.1.lcssa, -48
  br label %.lr.ph45

.lr.ph45:                                         ; preds = %._crit_edge, %.lr.ph45
  %isdigittmp43 = phi i32 [ %isdigittmp, %.lr.ph45 ], [ %isdigittmp41, %._crit_edge ]
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = mul i32 %15, 10
  %17 = add nsw i32 %16, %isdigittmp43
  store i32 %17, ptr %2, align 4, !tbaa !5
  %18 = call i32 @getchar()
  %isdigittmp = add i32 %18, -48
  %isdigit39 = icmp ult i32 %isdigittmp, 10
  br i1 %isdigit39, label %.lr.ph45, label %._crit_edge46, !llvm.loop !11

._crit_edge46:                                    ; preds = %.lr.ph45
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  %19 = icmp eq i32 %.pre, 8
  %20 = load i32, ptr @pos, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  br i1 %19, label %22, label %._crit_edge46.thread

22:                                               ; preds = %._crit_edge46
  %23 = getelementptr inbounds [1000001 x i32], ptr @fa, i64 0, i64 %21
  br label %41

._crit_edge46.thread:                             ; preds = %._crit_edge46
  %24 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %21
  %25 = call noundef i64 @_ZNKSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5countERS3_(ptr noundef nonnull align 8 dereferenceable(48) %24, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %.not = icmp eq i64 %25, 0
  %.pre72 = load i32, ptr @pos, align 4, !tbaa !5
  br i1 %.not, label %26, label %36

26:                                               ; preds = %._crit_edge46.thread
  %27 = load i32, ptr @tot, align 4, !tbaa !5
  %28 = sext i32 %.pre72 to i64
  %29 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %28
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %29, ptr noundef nonnull align 4 dereferenceable(4) %2)
  store i32 %27, ptr %30, align 4, !tbaa !5
  %31 = load i32, ptr @pos, align 4, !tbaa !5
  %32 = load i32, ptr @tot, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr @tot, align 4, !tbaa !5
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds [1000001 x i32], ptr @fa, i64 0, i64 %34
  store i32 %31, ptr %35, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %26, %._crit_edge46.thread
  %37 = phi i32 [ %31, %26 ], [ %.pre72, %._crit_edge46.thread ]
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %38
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) %39, ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %41

41:                                               ; preds = %36, %22
  %storemerge.in = phi ptr [ %40, %36 ], [ %23, %22 ]
  %storemerge = load i32, ptr %storemerge.in, align 4, !tbaa !5
  store i32 %storemerge, ptr @pos, align 4, !tbaa !5
  br label %8, !llvm.loop !12

._crit_edge54:                                    ; preds = %._crit_edge50, %10
  store i64 0, ptr @dist, align 16, !tbaa !13
  call void @_Z4pfs1i(i32 noundef 0)
  call void @_Z4dfs1i(i32 noundef 0)
  %42 = load i32, ptr @tot, align 4, !tbaa !5
  %43 = sext i32 %0 to i64
  %44 = getelementptr inbounds [3 x i32], ptr @size, i64 0, i64 %43
  store i32 %42, ptr %44, align 4, !tbaa !5
  %45 = load i64, ptr @dist, align 16, !tbaa !13
  %46 = getelementptr inbounds [3 x i64], ptr @dcnt, i64 0, i64 %43
  %47 = getelementptr inbounds [3 x i64], ptr @dmin, i64 0, i64 %43
  store i64 %45, ptr %47, align 8, !tbaa !13
  %48 = getelementptr inbounds [3 x i64], ptr @dmax, i64 0, i64 %43
  store i64 %45, ptr %48, align 8, !tbaa !13
  %49 = icmp sgt i32 %42, 1
  br i1 %49, label %.lr.ph57, label %._crit_edge58

.lr.ph57:                                         ; preds = %._crit_edge54
  %wide.trip.count = zext nneg i32 %42 to i64
  %50 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %50, 1
  %51 = icmp eq i32 %42, 2
  br i1 %51, label %._crit_edge58.loopexit.unr-lcssa, label %.lr.ph57.new

.lr.ph57.new:                                     ; preds = %.lr.ph57
  %unroll_iter = and i64 %50, -2
  br label %74

.lr.ph53:                                         ; preds = %10, %._crit_edge50
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge50 ], [ 0, %10 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #6
  %52 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @e, i64 0, i64 %indvars.iv
  call void @_ZNSt6vectorIiSaIiEE4swapERS1_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %52) #6
  call void @_ZNSt6vectorIiSaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %53 = getelementptr inbounds [1000001 x %"class.std::map"], ptr @chd, i64 0, i64 %indvars.iv
  %54 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %53) #6
  store ptr %54, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %55 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %53) #6
  store ptr %55, ptr %5, align 8
  %56 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br i1 %56, label %.lr.ph49, label %._crit_edge50

._crit_edge50:                                    ; preds = %.lr.ph49, %.lr.ph53
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %6) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %6, i8 0, i64 48, i1 false)
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #6
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE4swapERS6_(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(48) %53) #6
  call void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %6) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %57 = load i32, ptr @tot, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = icmp slt i64 %indvars.iv.next, %58
  br i1 %59, label %.lr.ph53, label %._crit_edge54, !llvm.loop !15

.lr.ph49:                                         ; preds = %.lr.ph53, %.lr.ph49
  %60 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  %61 = getelementptr inbounds i8, ptr %60, i64 4
  call void @_ZNSt6vectorIiSaIiEE9push_backERKi(ptr noundef nonnull align 8 dereferenceable(24) %52, ptr noundef nonnull align 4 dereferenceable(4) %61)
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %63 = call ptr @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %53) #6
  store ptr %63, ptr %5, align 8
  %64 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKiiEES5_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br i1 %64, label %.lr.ph49, label %._crit_edge50, !llvm.loop !16

._crit_edge58.loopexit.unr-lcssa:                 ; preds = %93, %.lr.ph57
  %.lcssa.ph = phi i64 [ poison, %.lr.ph57 ], [ %89, %93 ]
  %.unr = phi i64 [ %45, %.lr.ph57 ], [ %94, %93 ]
  %indvars.iv66.unr = phi i64 [ 1, %.lr.ph57 ], [ %indvars.iv.next67.1, %93 ]
  %.unr83 = phi i64 [ %45, %.lr.ph57 ], [ %95, %93 ]
  %.unr84 = phi i64 [ %45, %.lr.ph57 ], [ %89, %93 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge58, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge58.loopexit.unr-lcssa
  %65 = getelementptr inbounds [1000001 x i64], ptr @dist, i64 0, i64 %indvars.iv66.unr
  %66 = load i64, ptr %65, align 8, !tbaa !13
  %67 = add nsw i64 %.unr84, %66
  %68 = icmp slt i64 %.unr83, %66
  br i1 %68, label %.sink.split.epil, label %69

69:                                               ; preds = %.epil.preheader
  %70 = icmp sgt i64 %.unr, %66
  br i1 %70, label %.sink.split.epil, label %._crit_edge58

.sink.split.epil:                                 ; preds = %69, %.epil.preheader
  %.sink.epil = phi ptr [ %48, %.epil.preheader ], [ %47, %69 ]
  store i64 %66, ptr %.sink.epil, align 8, !tbaa !13
  br label %._crit_edge58

._crit_edge58:                                    ; preds = %._crit_edge58.loopexit.unr-lcssa, %.sink.split.epil, %69, %._crit_edge54
  %71 = phi i64 [ %45, %._crit_edge54 ], [ %.lcssa.ph, %._crit_edge58.loopexit.unr-lcssa ], [ %67, %.sink.split.epil ], [ %67, %69 ]
  %72 = ashr i64 %71, 1
  store i64 %72, ptr %46, align 8, !tbaa !13
  %73 = icmp eq i32 %0, 1
  br i1 %73, label %96, label %.loopexit

74:                                               ; preds = %93, %.lr.ph57.new
  %75 = phi i64 [ %45, %.lr.ph57.new ], [ %94, %93 ]
  %indvars.iv66 = phi i64 [ 1, %.lr.ph57.new ], [ %indvars.iv.next67.1, %93 ]
  %76 = phi i64 [ %45, %.lr.ph57.new ], [ %95, %93 ]
  %77 = phi i64 [ %45, %.lr.ph57.new ], [ %89, %93 ]
  %niter = phi i64 [ 0, %.lr.ph57.new ], [ %niter.next.1, %93 ]
  %78 = getelementptr inbounds [1000001 x i64], ptr @dist, i64 0, i64 %indvars.iv66
  %79 = load i64, ptr %78, align 8, !tbaa !13
  %80 = add nsw i64 %77, %79
  %81 = icmp slt i64 %76, %79
  br i1 %81, label %.sink.split, label %82

82:                                               ; preds = %74
  %83 = icmp sgt i64 %75, %79
  br i1 %83, label %.sink.split, label %84

.sink.split:                                      ; preds = %82, %74
  %.sink = phi ptr [ %48, %74 ], [ %47, %82 ]
  %.ph = phi i64 [ %75, %74 ], [ %79, %82 ]
  %.ph78 = phi i64 [ %79, %74 ], [ %76, %82 ]
  store i64 %79, ptr %.sink, align 8, !tbaa !13
  br label %84

84:                                               ; preds = %.sink.split, %82
  %85 = phi i64 [ %75, %82 ], [ %.ph, %.sink.split ]
  %86 = phi i64 [ %76, %82 ], [ %.ph78, %.sink.split ]
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %87 = getelementptr inbounds [1000001 x i64], ptr @dist, i64 0, i64 %indvars.iv.next67
  %88 = load i64, ptr %87, align 8, !tbaa !13
  %89 = add nsw i64 %80, %88
  %90 = icmp slt i64 %86, %88
  br i1 %90, label %.sink.split.1, label %91

91:                                               ; preds = %84
  %92 = icmp sgt i64 %85, %88
  br i1 %92, label %.sink.split.1, label %93

.sink.split.1:                                    ; preds = %91, %84
  %.sink.1 = phi ptr [ %48, %84 ], [ %47, %91 ]
  %.ph.1 = phi i64 [ %85, %84 ], [ %88, %91 ]
  %.ph78.1 = phi i64 [ %88, %84 ], [ %86, %91 ]
  store i64 %88, ptr %.sink.1, align 8, !tbaa !13
  br label %93

93:                                               ; preds = %.sink.split.1, %91
  %94 = phi i64 [ %85, %91 ], [ %.ph.1, %.sink.split.1 ]
  %95 = phi i64 [ %86, %91 ], [ %.ph78.1, %.sink.split.1 ]
  %indvars.iv.next67.1 = add nuw nsw i64 %indvars.iv66, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge58.loopexit.unr-lcssa, label %74, !llvm.loop !17

96:                                               ; preds = %._crit_edge58
  %97 = sext i32 %42 to i64
  %98 = shl nsw i64 %97, 2
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @fa1, ptr nonnull align 16 @fa, i64 %98, i1 false)
  %99 = shl nsw i64 %97, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @dist1, ptr nonnull align 16 @dist, i64 %99, i1 false)
  %100 = icmp sgt i32 %42, 0
  br i1 %100, label %.lr.ph62, label %.loopexit

.lr.ph62:                                         ; preds = %96, %.lr.ph62
  %indvars.iv69 = phi i64 [ %indvars.iv.next70, %.lr.ph62 ], [ 0, %96 ]
  %101 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @e1, i64 0, i64 %indvars.iv69
  %102 = getelementptr inbounds [1000001 x %"class.std::vector"], ptr @e, i64 0, i64 %indvars.iv69
  call void @_ZNSt6vectorIiSaIiEE4swapERS1_(ptr noundef nonnull align 8 dereferenceable(24) %101, ptr noundef nonnull align 8 dereferenceable(24) %102) #6
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %103 = load i32, ptr @tot, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = icmp slt i64 %indvars.iv.next70, %104
  br i1 %105, label %.lr.ph62, label %.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %.lr.ph62, %96, %._crit_edge58
  ret void
}

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @getchar() local_unnamed_addr #3

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

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKiiEEptEv(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 @_ZNSt17_Rb_tree_iteratorISt4pairIKiiEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapIiiSt4lessIiESaISt4pairIKiiEEE4swapERS6_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #0 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) #5

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, 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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass