; LLVM IR from eyangch/competitive-programming :: USACOcontests/gold/2019.02/dishes.ll (Z5worksPii)

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

%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, int, std::_Identity<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 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5worksPii(ptr noundef %0, i32 noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca %"struct.std::pair", align 8
  %21 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = call ptr @llvm.stacksave.p0()
  store ptr %24, ptr %6, align 8
  %25 = alloca i32, i64 %23, align 16
  store i64 %23, ptr %7, align 8
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %27, i64 %29
  %31 = call noundef ptr @_ZSt4copyIPiS0_ET0_T_S2_S1_(ptr noundef %26, ptr noundef %30, ptr noundef %25)
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %25, i64 %33
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef %25, ptr noundef %34)
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = zext i32 %35 to i64
  %37 = alloca i32, i64 %36, align 16
  store i64 %36, ptr %8, align 8
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = alloca i32, i64 %39, align 16
  store i64 %39, ptr %9, align 8
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr %37, i64 %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 2147483647, ptr %10, align 4, !tbaa !9
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef %37, ptr noundef %43, ptr noundef nonnull align 4 dereferenceable(4) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr %40, i64 %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef %40, ptr noundef %46, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = alloca %"class.std::set", i64 %48, align 16
  store i64 %48, ptr %12, align 8
  %50 = icmp eq i64 %48, 0
  br i1 %50, label %57, label %51

51:                                               ; preds = %2
  %52 = getelementptr inbounds %"class.std::set", ptr %49, i64 %48
  br label %53

53:                                               ; preds = %53, %51
  %54 = phi ptr [ %49, %51 ], [ %55, %53 ]
  call void @_ZNSt3setIiSt4lessIiESaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %54) #5
  %55 = getelementptr inbounds %"class.std::set", ptr %54, i64 1
  %56 = icmp eq ptr %55, %52
  br i1 %56, label %57, label %53

57:                                               ; preds = %53, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %197, %57
  %59 = load i32, ptr %15, align 4, !tbaa !9
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %58
  store i32 2, ptr %16, align 4
  br label %200

63:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %64 = load i32, ptr %14, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr %37, i64 %65
  %67 = load i32, ptr %5, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds i32, ptr %37, i64 %68
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load i32, ptr %15, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr %70, i64 %72
  %74 = invoke noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef %66, ptr noundef %69, ptr noundef nonnull align 4 dereferenceable(4) %73)
          to label %75 unwind label %97

75:                                               ; preds = %63
  %76 = ptrtoint ptr %74 to i64
  %77 = ptrtoint ptr %37 to i64
  %78 = sub i64 %76, %77
  %79 = sdiv exact i64 %78, 4
  %80 = trunc i64 %79 to i32
  store i32 %80, ptr %17, align 4, !tbaa !9
  %81 = load i32, ptr %17, align 4, !tbaa !9
  %82 = load i32, ptr %14, align 4, !tbaa !9
  %83 = icmp sgt i32 %81, %82
  br i1 %83, label %84, label %104

84:                                               ; preds = %75
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = load i32, ptr %15, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i32, ptr %85, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !9
  %90 = load i32, ptr %17, align 4, !tbaa !9
  %91 = sub nsw i32 %90, 1
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i32, ptr %40, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !9
  %95 = icmp slt i32 %89, %94
  br i1 %95, label %96, label %103

96:                                               ; preds = %84
  store i1 false, ptr %3, align 1
  store i32 1, ptr %16, align 4
  br label %194

97:                                               ; preds = %161, %104, %63
  %98 = landingpad { ptr, i32 }
          cleanup
  %99 = extractvalue { ptr, i32 } %98, 0
  store ptr %99, ptr %18, align 8
  %100 = extractvalue { ptr, i32 } %98, 1
  store i32 %100, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %101 = getelementptr inbounds %"class.std::set", ptr %49, i64 %48
  %102 = icmp eq ptr %49, %101
  br i1 %102, label %217, label %213

103:                                              ; preds = %84
  br label %104

104:                                              ; preds = %103, %75
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = load i32, ptr %15, align 4, !tbaa !9
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds i32, ptr %105, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !9
  %110 = load i32, ptr %17, align 4, !tbaa !9
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds i32, ptr %37, i64 %111
  store i32 %109, ptr %112, align 4, !tbaa !9
  %113 = load i32, ptr %17, align 4, !tbaa !9
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds %"class.std::set", ptr %49, i64 %114
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = load i32, ptr %15, align 4, !tbaa !9
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds i32, ptr %116, i64 %118
  %120 = invoke { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) %115, ptr noundef nonnull align 4 dereferenceable(4) %119)
          to label %121 unwind label %97

121:                                              ; preds = %104
  %122 = getelementptr inbounds { ptr, i8 }, ptr %20, i32 0, i32 0
  %123 = extractvalue { ptr, i8 } %120, 0
  store ptr %123, ptr %122, align 8
  %124 = getelementptr inbounds { ptr, i8 }, ptr %20, i32 0, i32 1
  %125 = extractvalue { ptr, i8 } %120, 1
  store i8 %125, ptr %124, align 8
  %126 = load i32, ptr %17, align 4, !tbaa !9
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds i32, ptr %40, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !9
  %130 = icmp eq i32 %129, 0
  br i1 %130, label %131, label %140

131:                                              ; preds = %121
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = load i32, ptr %15, align 4, !tbaa !9
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds i32, ptr %132, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !9
  %137 = load i32, ptr %17, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds i32, ptr %40, i64 %138
  store i32 %136, ptr %139, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %131, %121
  br label %141

141:                                              ; preds = %190, %140
  %142 = load i32, ptr %14, align 4, !tbaa !9
  %143 = load i32, ptr %5, align 4, !tbaa !9
  %144 = icmp slt i32 %142, %143
  br i1 %144, label %145, label %159

145:                                              ; preds = %141
  %146 = load i32, ptr %13, align 4, !tbaa !9
  %147 = load i32, ptr %5, align 4, !tbaa !9
  %148 = icmp slt i32 %146, %147
  br i1 %148, label %149, label %159

149:                                              ; preds = %145
  %150 = load i32, ptr %14, align 4, !tbaa !9
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds i32, ptr %37, i64 %151
  %153 = load i32, ptr %152, align 4, !tbaa !9
  %154 = load i32, ptr %13, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds i32, ptr %25, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !9
  %158 = icmp eq i32 %153, %157
  br label %159

159:                                              ; preds = %149, %145, %141
  %160 = phi i1 [ false, %145 ], [ false, %141 ], [ %158, %149 ]
  br i1 %160, label %161, label %193

161:                                              ; preds = %159
  %162 = load i32, ptr %14, align 4, !tbaa !9
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds %"class.std::set", ptr %49, i64 %163
  %165 = load i32, ptr %13, align 4, !tbaa !9
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds i32, ptr %25, i64 %166
  %168 = invoke noundef i64 @_ZNSt3setIiSt4lessIiESaIiEE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(48) %164, ptr noundef nonnull align 4 dereferenceable(4) %167)
          to label %169 unwind label %97

169:                                              ; preds = %161
  %170 = load i32, ptr %14, align 4, !tbaa !9
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds %"class.std::set", ptr %49, i64 %171
  %173 = call noundef i64 @_ZNKSt3setIiSt4lessIiESaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %172) #5
  %174 = trunc i64 %173 to i32
  %175 = icmp eq i32 %174, 0
  br i1 %175, label %176, label %179

176:                                              ; preds = %169
  %177 = load i32, ptr %14, align 4, !tbaa !9
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %14, align 4, !tbaa !9
  br label %190

179:                                              ; preds = %169
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %180 = load i32, ptr %14, align 4, !tbaa !9
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds %"class.std::set", ptr %49, i64 %181
  %183 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %182) #5
  %184 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %21, i32 0, i32 0
  store ptr %183, ptr %184, align 8
  %185 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %21) #5
  %186 = load i32, ptr %185, align 4, !tbaa !9
  %187 = load i32, ptr %14, align 4, !tbaa !9
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds i32, ptr %37, i64 %188
  store i32 %186, ptr %189, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  br label %190

190:                                              ; preds = %179, %176
  %191 = load i32, ptr %13, align 4, !tbaa !9
  %192 = add nsw i32 %191, 1
  store i32 %192, ptr %13, align 4, !tbaa !9
  br label %141, !llvm.loop !11

193:                                              ; preds = %159
  store i32 0, ptr %16, align 4
  br label %194

194:                                              ; preds = %193, %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  %195 = load i32, ptr %16, align 4
  switch i32 %195, label %200 [
    i32 0, label %196
  ]

196:                                              ; preds = %194
  br label %197

197:                                              ; preds = %196
  %198 = load i32, ptr %15, align 4, !tbaa !9
  %199 = add nsw i32 %198, 1
  store i32 %199, ptr %15, align 4, !tbaa !9
  br label %58, !llvm.loop !13

200:                                              ; preds = %194, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  %201 = load i32, ptr %16, align 4
  switch i32 %201, label %203 [
    i32 2, label %202
  ]

202:                                              ; preds = %200
  store i1 true, ptr %3, align 1
  store i32 1, ptr %16, align 4
  br label %203

203:                                              ; preds = %202, %200
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %204 = getelementptr inbounds %"class.std::set", ptr %49, i64 %48
  %205 = icmp eq ptr %49, %204
  br i1 %205, label %210, label %206

206:                                              ; preds = %206, %203
  %207 = phi ptr [ %204, %203 ], [ %208, %206 ]
  %208 = getelementptr inbounds %"class.std::set", ptr %207, i64 -1
  call void @_ZNSt3setIiSt4lessIiESaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %208) #5
  %209 = icmp eq ptr %208, %49
  br i1 %209, label %210, label %206

210:                                              ; preds = %206, %203
  %211 = load ptr, ptr %6, align 8
  call void @llvm.stackrestore.p0(ptr %211)
  %212 = load i1, ptr %3, align 1
  ret i1 %212

213:                                              ; preds = %213, %97
  %214 = phi ptr [ %101, %97 ], [ %215, %213 ]
  %215 = getelementptr inbounds %"class.std::set", ptr %214, i64 -1
  call void @_ZNSt3setIiSt4lessIiESaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %215) #5
  %216 = icmp eq ptr %215, %49
  br i1 %216, label %217, label %213

217:                                              ; preds = %213, %97
  br label %218

218:                                              ; preds = %217
  %219 = load ptr, ptr %18, align 8
  %220 = load i32, ptr %19, align 4
  %221 = insertvalue { ptr, i32 } poison, ptr %219, 0
  %222 = insertvalue { ptr, i32 } %221, i32 %220, 1
  resume { ptr, i32 } %222
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt4copyIPiS0_ET0_T_S2_S1_(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #2

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

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3setIiSt4lessIiESaIiEE5eraseERKi(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 @_ZNKSt3setIiSt4lessIiESaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) #4 align 2

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<int, int, std::_Identity<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 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5worksPii(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = zext i32 %1 to i64
  %7 = alloca i32, i64 %6, align 16
  %8 = sext i32 %1 to i64
  %9 = getelementptr inbounds i32, ptr %0, i64 %8
  %10 = call noundef ptr @_ZSt4copyIPiS0_ET0_T_S2_S1_(ptr noundef %0, ptr noundef %9, ptr noundef nonnull %7)
  %11 = getelementptr inbounds i32, ptr %7, i64 %8
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull %7, ptr noundef nonnull %11)
  %12 = alloca i32, i64 %6, align 16
  %13 = alloca i32, i64 %6, align 16
  %14 = getelementptr inbounds i32, ptr %12, i64 %8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  store i32 2147483647, ptr %3, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull %12, ptr noundef nonnull %14, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  %15 = getelementptr inbounds i32, ptr %13, i64 %8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull %13, ptr noundef nonnull %15, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  %16 = alloca %"class.std::set", i64 %6, align 16
  %17 = icmp eq i32 %1, 0
  br i1 %17, label %.loopexit, label %18

18:                                               ; preds = %2
  %19 = getelementptr inbounds %"class.std::set", ptr %16, i64 %6
  br label %20

20:                                               ; preds = %20, %18
  %21 = phi ptr [ %16, %18 ], [ %22, %20 ]
  call void @_ZNSt3setIiSt4lessIiESaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %21) #4
  %22 = getelementptr inbounds i8, ptr %21, i64 48
  %23 = icmp eq ptr %22, %19
  br i1 %23, label %.loopexit77, label %20

.loopexit77:                                      ; preds = %20
  %.not89 = icmp slt i32 %1, 1
  br i1 %.not89, label %.critedge68, label %.lr.ph95

.lr.ph95:                                         ; preds = %.loopexit77
  %24 = ptrtoint ptr %12 to i64
  br label %25

25:                                               ; preds = %.lr.ph95, %._crit_edge
  %indvars.iv100 = phi i64 [ 0, %.lr.ph95 ], [ %indvars.iv.next101, %._crit_edge ]
  %.not93 = phi i1 [ false, %.lr.ph95 ], [ %.not, %._crit_edge ]
  %.05192 = phi i32 [ 0, %.lr.ph95 ], [ %.152.lcssa, %._crit_edge ]
  %.05491 = phi i32 [ 0, %.lr.ph95 ], [ %.155.lcssa, %._crit_edge ]
  %26 = sext i32 %.05491 to i64
  %27 = getelementptr inbounds i32, ptr %12, i64 %26
  %28 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv100
  %29 = invoke noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull %27, ptr noundef nonnull %14, ptr noundef nonnull align 4 dereferenceable(4) %28)
          to label %30 unwind label %.loopexit.split-lp

30:                                               ; preds = %25
  %31 = ptrtoint ptr %29 to i64
  %32 = sub i64 %31, %24
  %33 = lshr exact i64 %32, 2
  %34 = trunc i64 %33 to i32
  %35 = icmp slt i32 %.05491, %34
  %.pre = load i32, ptr %28, align 4, !tbaa !5
  %36 = shl i64 %32, 30
  br i1 %35, label %37, label %._crit_edge102

37:                                               ; preds = %30
  %sext = add i64 %36, -4294967296
  %38 = ashr i64 %sext, 32
  %39 = getelementptr inbounds i32, ptr %13, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = icmp slt i32 %.pre, %40
  br i1 %41, label %.critedge68, label %._crit_edge102

.loopexit76:                                      ; preds = %63
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.preheader74

.loopexit.split-lp:                               ; preds = %25, %._crit_edge102
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %.preheader74

.preheader74:                                     ; preds = %.loopexit.split-lp, %.loopexit76
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit76 ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  %42 = getelementptr inbounds %"class.std::set", ptr %16, i64 %6
  br label %83

._crit_edge102:                                   ; preds = %30, %37
  %43 = ashr i64 %36, 32
  %44 = getelementptr inbounds i32, ptr %12, i64 %43
  store i32 %.pre, ptr %44, align 4, !tbaa !5
  %45 = getelementptr inbounds %"class.std::set", ptr %16, i64 %43
  %46 = invoke { ptr, i8 } @_ZNSt3setIiSt4lessIiESaIiEE6insertERKi(ptr noundef nonnull align 8 dereferenceable(48) %45, ptr noundef nonnull align 4 dereferenceable(4) %28)
          to label %47 unwind label %.loopexit.split-lp

47:                                               ; preds = %._crit_edge102
  %48 = getelementptr inbounds i32, ptr %13, i64 %43
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %47
  %52 = load i32, ptr %28, align 4, !tbaa !5
  store i32 %52, ptr %48, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %51, %47
  %54 = icmp slt i32 %.05491, %1
  %55 = icmp slt i32 %.05192, %1
  %or.cond82 = select i1 %54, i1 %55, i1 false
  br i1 %or.cond82, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %53
  %56 = sext i32 %.05192 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %76
  %indvars.iv = phi i64 [ %56, %.lr.ph.preheader ], [ %indvars.iv.next, %76 ]
  %.15583 = phi i32 [ %.05491, %.lr.ph.preheader ], [ %.256, %76 ]
  %57 = sext i32 %.15583 to i64
  %58 = getelementptr inbounds i32, ptr %12, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = icmp eq i32 %59, %61
  br i1 %62, label %63, label %._crit_edge.loopexit

63:                                               ; preds = %.lr.ph
  %64 = getelementptr inbounds %"class.std::set", ptr %16, i64 %57
  %65 = invoke noundef i64 @_ZNSt3setIiSt4lessIiESaIiEE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(48) %64, ptr noundef nonnull align 4 dereferenceable(4) %60)
          to label %66 unwind label %.loopexit76

66:                                               ; preds = %63
  %67 = call noundef i64 @_ZNKSt3setIiSt4lessIiESaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %64) #4
  %68 = and i64 %67, 4294967295
  %69 = icmp eq i64 %68, 0
  br i1 %69, label %70, label %72

70:                                               ; preds = %66
  %71 = add nsw i32 %.15583, 1
  br label %76

72:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %73 = call ptr @_ZNKSt3setIiSt4lessIiESaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) %64) #4
  store ptr %73, ptr %5, align 8
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt23_Rb_tree_const_iteratorIiEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  %75 = load i32, ptr %74, align 4, !tbaa !5
  store i32 %75, ptr %58, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %76

76:                                               ; preds = %72, %70
  %.256 = phi i32 [ %71, %70 ], [ %.15583, %72 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %77 = icmp slt i32 %.256, %1
  %78 = icmp slt i64 %indvars.iv.next, %8
  %or.cond = select i1 %77, i1 %78, i1 false
  br i1 %or.cond, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %76, %.lr.ph
  %.155.lcssa.ph = phi i32 [ %.15583, %.lr.ph ], [ %.256, %76 ]
  %.152.lcssa.ph.in = phi i64 [ %indvars.iv, %.lr.ph ], [ %indvars.iv.next, %76 ]
  %.152.lcssa.ph = trunc i64 %.152.lcssa.ph.in to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %53
  %.155.lcssa = phi i32 [ %.05491, %53 ], [ %.155.lcssa.ph, %._crit_edge.loopexit ]
  %.152.lcssa = phi i32 [ %.05192, %53 ], [ %.152.lcssa.ph, %._crit_edge.loopexit ]
  %indvars.iv.next101 = add nuw nsw i64 %indvars.iv100, 1
  %.not = icmp sge i64 %indvars.iv.next101, %8
  %exitcond = icmp eq i64 %indvars.iv.next101, %6
  br i1 %exitcond, label %.critedge68, label %25, !llvm.loop !11

.critedge68:                                      ; preds = %._crit_edge, %37, %.loopexit77
  %.not.lcssa = phi i1 [ true, %.loopexit77 ], [ %.not93, %37 ], [ %.not, %._crit_edge ]
  br i1 %17, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.critedge68
  %79 = getelementptr inbounds %"class.std::set", ptr %16, i64 %6
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %80 = phi ptr [ %81, %.preheader ], [ %79, %.preheader.preheader ]
  %81 = getelementptr inbounds i8, ptr %80, i64 -48
  call void @_ZNSt3setIiSt4lessIiESaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %81) #4
  %82 = icmp eq ptr %81, %16
  br i1 %82, label %.loopexit, label %.preheader

.loopexit:                                        ; preds = %.preheader, %2, %.critedge68
  %.not.lcssa106 = phi i1 [ %.not.lcssa, %.critedge68 ], [ true, %2 ], [ %.not.lcssa, %.preheader ]
  ret i1 %.not.lcssa106

83:                                               ; preds = %.preheader74, %83
  %84 = phi ptr [ %85, %83 ], [ %42, %.preheader74 ]
  %85 = getelementptr inbounds i8, ptr %84, i64 -48
  call void @_ZNSt3setIiSt4lessIiESaIiEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %85) #4
  %86 = icmp eq ptr %85, %16
  br i1 %86, label %.loopexit75, label %83

.loopexit75:                                      ; preds = %83
  resume { ptr, i32 } %lpad.phi
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt4copyIPiS0_ET0_T_S2_S1_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3setIiSt4lessIiESaIiEE5eraseERKi(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 @_ZNKSt3setIiSt4lessIiESaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3 align 2

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

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

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

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


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