; LLVM IR from rahulyesantharao/b-epsilon-tree :: src/be_tree/be_tree.ll (ZN6BeNode10UpsertLeafEP8BeUpsertRi)

; 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::set" = type { %"class.std::_Rb_tree.3" }
%"class.std::_Rb_tree.3" = type { %"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned 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 }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%class.BeNode = type { %class.Serializable, ptr, i32, ptr, ptr, ptr, ptr, ptr }
%class.Serializable = type { ptr }
%struct.BeData = type { i32, [510 x i32], [510 x i32] }
%struct.BeUpsert = type { i32, i32, i32, i32 }

@.str.12 = external hidden unnamed_addr constant [89 x i8], align 1
@seen_keys = external dso_local global %"class.std::set", align 8
@.str.15 = external hidden unnamed_addr constant [9 x i8], align 1
@__PRETTY_FUNCTION__._ZN6BeNode10UpsertLeafEP8BeUpsertRi = external hidden unnamed_addr constant [50 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6BeNode10UpsertLeafEP8BeUpsertRi(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1, ptr noundef nonnull align 4 dereferenceable(4) %2) #2 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"struct.std::pair", align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8
  %15 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 4
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  br label %22

20:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.12, i32 noundef 117, ptr noundef @__PRETTY_FUNCTION__._ZN6BeNode10UpsertLeafEP8BeUpsertRi) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  br label %23

23:                                               ; preds = %228, %22
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %27, label %229

27:                                               ; preds = %23
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr %28, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 -1, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !13
  br label %31

31:                                               ; preds = %58, %27
  %32 = load i32, ptr %9, align 4, !tbaa !13
  %33 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = getelementptr inbounds %struct.BeData, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !15
  %37 = icmp ult i32 %32, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %31
  store i32 4, ptr %10, align 4
  br label %61

39:                                               ; preds = %31
  %40 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = getelementptr inbounds %struct.BeData, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %9, align 4, !tbaa !13
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [510 x i32], ptr %42, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !13
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load i32, ptr %48, align 4, !tbaa !13
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %struct.BeUpsert, ptr %47, i64 %50
  %52 = getelementptr inbounds %struct.BeUpsert, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 4, !tbaa !17
  %54 = icmp eq i32 %46, %53
  br i1 %54, label %55, label %57

55:                                               ; preds = %39
  %56 = load i32, ptr %9, align 4, !tbaa !13
  store i32 %56, ptr %8, align 4, !tbaa !13
  store i32 4, ptr %10, align 4
  br label %61

57:                                               ; preds = %39
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %9, align 4, !tbaa !13
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %9, align 4, !tbaa !13
  br label %31, !llvm.loop !20

61:                                               ; preds = %55, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load i32, ptr %64, align 4, !tbaa !13
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %struct.BeUpsert, ptr %63, i64 %66
  %68 = getelementptr inbounds %struct.BeUpsert, ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 4, !tbaa !17
  store i32 %69, ptr %11, align 4, !tbaa !13
  %70 = call { ptr, i8 } @_ZNSt3setIjSt4lessIjESaIjEE6insertEOj(ptr noundef nonnull align 8 dereferenceable(48) @seen_keys, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %71 = getelementptr inbounds { ptr, i8 }, ptr %12, i32 0, i32 0
  %72 = extractvalue { ptr, i8 } %70, 0
  store ptr %72, ptr %71, align 8
  %73 = getelementptr inbounds { ptr, i8 }, ptr %12, i32 0, i32 1
  %74 = extractvalue { ptr, i8 } %70, 1
  store i8 %74, ptr %73, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load i32, ptr %76, align 4, !tbaa !13
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds %struct.BeUpsert, ptr %75, i64 %78
  %80 = getelementptr inbounds %struct.BeUpsert, ptr %79, i32 0, i32 1
  %81 = load i32, ptr %80, align 4, !tbaa !22
  switch i32 %81, label %217 [
    i32 0, label %82
    i32 2, label %136
    i32 1, label %159
  ]

82:                                               ; preds = %62
  %83 = load i32, ptr %8, align 4, !tbaa !13
  %84 = icmp slt i32 %83, 0
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = load i32, ptr %86, align 4, !tbaa !13
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds %struct.BeUpsert, ptr %85, i64 %88
  %90 = getelementptr inbounds %struct.BeUpsert, ptr %89, i32 0, i32 0
  %91 = load i32, ptr %90, align 4, !tbaa !17
  call void (i1, ptr, ...) @_ZL8rtassertbPKcz(i1 noundef zeroext %84, ptr noundef @.str.16, i32 noundef %91)
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = load i32, ptr %93, align 4, !tbaa !13
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds %struct.BeUpsert, ptr %92, i64 %95
  %97 = getelementptr inbounds %struct.BeUpsert, ptr %96, i32 0, i32 0
  %98 = load i32, ptr %97, align 4, !tbaa !17
  %99 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %100 = load ptr, ptr %99, align 8, !tbaa !14
  %101 = getelementptr inbounds %struct.BeData, ptr %100, i32 0, i32 1
  %102 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %103 = load ptr, ptr %102, align 8, !tbaa !14
  %104 = getelementptr inbounds %struct.BeData, ptr %103, i32 0, i32 0
  %105 = load i32, ptr %104, align 4, !tbaa !15
  %106 = zext i32 %105 to i64
  %107 = getelementptr inbounds [510 x i32], ptr %101, i64 0, i64 %106
  store i32 %98, ptr %107, align 4, !tbaa !13
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = load i32, ptr %109, align 4, !tbaa !13
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds %struct.BeUpsert, ptr %108, i64 %111
  %113 = getelementptr inbounds %struct.BeUpsert, ptr %112, i32 0, i32 2
  %114 = load i32, ptr %113, align 4, !tbaa !23
  %115 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %116 = load ptr, ptr %115, align 8, !tbaa !14
  %117 = getelementptr inbounds %struct.BeData, ptr %116, i32 0, i32 2
  %118 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %119 = load ptr, ptr %118, align 8, !tbaa !14
  %120 = getelementptr inbounds %struct.BeData, ptr %119, i32 0, i32 0
  %121 = load i32, ptr %120, align 4, !tbaa !15
  %122 = zext i32 %121 to i64
  %123 = getelementptr inbounds [510 x i32], ptr %117, i64 0, i64 %122
  store i32 %114, ptr %123, align 4, !tbaa !13
  %124 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %125 = load ptr, ptr %124, align 8, !tbaa !14
  %126 = getelementptr inbounds %struct.BeData, ptr %125, i32 0, i32 0
  %127 = load i32, ptr %126, align 4, !tbaa !15
  %128 = add i32 %127, 1
  store i32 %128, ptr %126, align 4, !tbaa !15
  %129 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %130 = load ptr, ptr %129, align 8, !tbaa !14
  %131 = getelementptr inbounds %struct.BeData, ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 4, !tbaa !15
  %133 = icmp eq i32 %132, 510
  br i1 %133, label %134, label %135

134:                                              ; preds = %82
  store i1 true, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %226

135:                                              ; preds = %82
  br label %225

136:                                              ; preds = %62
  %137 = load i32, ptr %8, align 4, !tbaa !13
  %138 = icmp sge i32 %137, 0
  %139 = load ptr, ptr %6, align 8, !tbaa !5
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = load i32, ptr %140, align 4, !tbaa !13
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds %struct.BeUpsert, ptr %139, i64 %142
  %144 = getelementptr inbounds %struct.BeUpsert, ptr %143, i32 0, i32 0
  %145 = load i32, ptr %144, align 4, !tbaa !17
  call void (i1, ptr, ...) @_ZL8rtassertbPKcz(i1 noundef zeroext %138, ptr noundef @.str.17, i32 noundef %145)
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = load ptr, ptr %7, align 8, !tbaa !5
  %148 = load i32, ptr %147, align 4, !tbaa !13
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds %struct.BeUpsert, ptr %146, i64 %149
  %151 = getelementptr inbounds %struct.BeUpsert, ptr %150, i32 0, i32 2
  %152 = load i32, ptr %151, align 4, !tbaa !23
  %153 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %154 = load ptr, ptr %153, align 8, !tbaa !14
  %155 = getelementptr inbounds %struct.BeData, ptr %154, i32 0, i32 2
  %156 = load i32, ptr %8, align 4, !tbaa !13
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [510 x i32], ptr %155, i64 0, i64 %157
  store i32 %152, ptr %158, align 4, !tbaa !13
  br label %225

159:                                              ; preds = %62
  %160 = load i32, ptr %8, align 4, !tbaa !13
  %161 = icmp sge i32 %160, 0
  %162 = load ptr, ptr %6, align 8, !tbaa !5
  %163 = load ptr, ptr %7, align 8, !tbaa !5
  %164 = load i32, ptr %163, align 4, !tbaa !13
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds %struct.BeUpsert, ptr %162, i64 %165
  %167 = getelementptr inbounds %struct.BeUpsert, ptr %166, i32 0, i32 0
  %168 = load i32, ptr %167, align 4, !tbaa !17
  call void (i1, ptr, ...) @_ZL8rtassertbPKcz(i1 noundef zeroext %161, ptr noundef @.str.18, i32 noundef %168)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %169 = load i32, ptr %8, align 4, !tbaa !13
  %170 = add nsw i32 %169, 1
  store i32 %170, ptr %13, align 4, !tbaa !13
  br label %171

171:                                              ; preds = %208, %159
  %172 = load i32, ptr %13, align 4, !tbaa !13
  %173 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %174 = load ptr, ptr %173, align 8, !tbaa !14
  %175 = getelementptr inbounds %struct.BeData, ptr %174, i32 0, i32 0
  %176 = load i32, ptr %175, align 4, !tbaa !15
  %177 = icmp ult i32 %172, %176
  br i1 %177, label %179, label %178

178:                                              ; preds = %171
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %211

179:                                              ; preds = %171
  %180 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %181 = load ptr, ptr %180, align 8, !tbaa !14
  %182 = getelementptr inbounds %struct.BeData, ptr %181, i32 0, i32 1
  %183 = load i32, ptr %13, align 4, !tbaa !13
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [510 x i32], ptr %182, i64 0, i64 %184
  %186 = load i32, ptr %185, align 4, !tbaa !13
  %187 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %188 = load ptr, ptr %187, align 8, !tbaa !14
  %189 = getelementptr inbounds %struct.BeData, ptr %188, i32 0, i32 1
  %190 = load i32, ptr %13, align 4, !tbaa !13
  %191 = sub nsw i32 %190, 1
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [510 x i32], ptr %189, i64 0, i64 %192
  store i32 %186, ptr %193, align 4, !tbaa !13
  %194 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %195 = load ptr, ptr %194, align 8, !tbaa !14
  %196 = getelementptr inbounds %struct.BeData, ptr %195, i32 0, i32 2
  %197 = load i32, ptr %13, align 4, !tbaa !13
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [510 x i32], ptr %196, i64 0, i64 %198
  %200 = load i32, ptr %199, align 4, !tbaa !13
  %201 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %202 = load ptr, ptr %201, align 8, !tbaa !14
  %203 = getelementptr inbounds %struct.BeData, ptr %202, i32 0, i32 2
  %204 = load i32, ptr %13, align 4, !tbaa !13
  %205 = sub nsw i32 %204, 1
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [510 x i32], ptr %203, i64 0, i64 %206
  store i32 %200, ptr %207, align 4, !tbaa !13
  br label %208

208:                                              ; preds = %179
  %209 = load i32, ptr %13, align 4, !tbaa !13
  %210 = add nsw i32 %209, 1
  store i32 %210, ptr %13, align 4, !tbaa !13
  br label %171, !llvm.loop !24

211:                                              ; preds = %178
  %212 = getelementptr inbounds %class.BeNode, ptr %14, i32 0, i32 7
  %213 = load ptr, ptr %212, align 8, !tbaa !14
  %214 = getelementptr inbounds %struct.BeData, ptr %213, i32 0, i32 0
  %215 = load i32, ptr %214, align 4, !tbaa !15
  %216 = add i32 %215, -1
  store i32 %216, ptr %214, align 4, !tbaa !15
  br label %225

217:                                              ; preds = %62
  %218 = load ptr, ptr %6, align 8, !tbaa !5
  %219 = load ptr, ptr %7, align 8, !tbaa !5
  %220 = load i32, ptr %219, align 4, !tbaa !13
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds %struct.BeUpsert, ptr %218, i64 %221
  %223 = getelementptr inbounds %struct.BeUpsert, ptr %222, i32 0, i32 1
  %224 = load i32, ptr %223, align 4, !tbaa !22
  call void (i1, ptr, ...) @_ZL8rtassertbPKcz(i1 noundef zeroext false, ptr noundef @.str.19, i32 noundef %224)
  br label %225

225:                                              ; preds = %217, %211, %136, %135
  store i32 0, ptr %10, align 4
  br label %226

226:                                              ; preds = %225, %134
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %227 = load i32, ptr %10, align 4
  switch i32 %227, label %232 [
    i32 0, label %228
    i32 1, label %230
  ]

228:                                              ; preds = %226
  br label %23, !llvm.loop !25

229:                                              ; preds = %23
  store i1 false, ptr %4, align 1
  br label %230

230:                                              ; preds = %229, %226
  %231 = load i1, ptr %4, align 1
  ret i1 %231

232:                                              ; preds = %226
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8rtassertbPKcz(i1 noundef zeroext, ptr noundef, ...) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { 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 = { noreturn nounwind }
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, !6, i64 32}
!10 = !{!"_ZTS6BeNode", !11, i64 0, !6, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"_ZTS12Serializable"}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !6, i64 56}
!15 = !{!16, !12, i64 0}
!16 = !{!"_ZTS6BeData", !12, i64 0, !7, i64 4, !7, i64 2044}
!17 = !{!18, !12, i64 0}
!18 = !{!"_ZTS8BeUpsert", !12, i64 0, !19, i64 4, !12, i64 8, !12, i64 12}
!19 = !{!"_ZTS14UpsertFunction", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!18, !19, i64 4}
!23 = !{!18, !12, i64 8}
!24 = distinct !{!24, !21}
!25 = distinct !{!25, !21}


; 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::set" = type { %"class.std::_Rb_tree.3" }
%"class.std::_Rb_tree.3" = type { %"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned 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 }
%struct.BeUpsert = type { i32, i32, i32, i32 }

@.str.12 = external hidden unnamed_addr constant [89 x i8], align 1
@seen_keys = external dso_local global %"class.std::set", align 8
@.str.15 = external hidden unnamed_addr constant [9 x i8], align 1
@__PRETTY_FUNCTION__._ZN6BeNode10UpsertLeafEP8BeUpsertRi = external hidden unnamed_addr constant [50 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6BeNode10UpsertLeafEP8BeUpsertRi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(64) %0, ptr nocapture noundef readonly %1, ptr nocapture noundef nonnull align 4 dereferenceable(4) %2) local_unnamed_addr #2 align 2 {
  %4 = alloca i32, align 4
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load i32, ptr %6, align 4, !tbaa !12
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %11, label %.preheader

.preheader:                                       ; preds = %3
  %8 = load i32, ptr %2, align 4, !tbaa !12
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph61, label %.thread

.lr.ph61:                                         ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  br label %12

11:                                               ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.12, i32 noundef 117, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6BeNode10UpsertLeafEP8BeUpsertRi) #4
  unreachable

12:                                               ; preds = %.lr.ph61, %88
  %13 = phi i32 [ %8, %.lr.ph61 ], [ %89, %88 ]
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr %2, align 4, !tbaa !12
  %15 = load ptr, ptr %10, align 8, !tbaa !13
  %16 = load i32, ptr %15, align 4, !tbaa !14
  %.not65 = icmp eq i32 %16, 0
  br i1 %.not65, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %12
  %.phi.trans.insert = zext nneg i32 %14 to i64
  %.phi.trans.insert70 = getelementptr inbounds %struct.BeUpsert, ptr %1, i64 %.phi.trans.insert
  %.pre = load i32, ptr %.phi.trans.insert70, align 4, !tbaa !16
  br label %._crit_edge

.lr.ph:                                           ; preds = %12
  %17 = getelementptr inbounds i8, ptr %15, i64 4
  %18 = zext nneg i32 %14 to i64
  %19 = getelementptr inbounds %struct.BeUpsert, ptr %1, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !16
  %wide.trip.count = zext i32 %16 to i64
  br label %21

21:                                               ; preds = %.lr.ph, %25
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %25 ]
  %22 = getelementptr inbounds [510 x i32], ptr %17, i64 0, i64 %indvars.iv
  %23 = load i32, ptr %22, align 4, !tbaa !12
  %24 = icmp eq i32 %23, %20
  br i1 %24, label %._crit_edge.loopexit.split.loop.exit, label %25

25:                                               ; preds = %21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %21, !llvm.loop !19

._crit_edge.loopexit.split.loop.exit:             ; preds = %21
  %26 = trunc nuw nsw i64 %indvars.iv to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %25, %._crit_edge.loopexit.split.loop.exit, %.._crit_edge_crit_edge
  %27 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %20, %._crit_edge.loopexit.split.loop.exit ], [ %20, %25 ]
  %.040 = phi i32 [ -1, %.._crit_edge_crit_edge ], [ %26, %._crit_edge.loopexit.split.loop.exit ], [ -1, %25 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  store i32 %27, ptr %4, align 4, !tbaa !12
  %28 = call { ptr, i8 } @_ZNSt3setIjSt4lessIjESaIjEE6insertEOj(ptr noundef nonnull align 8 dereferenceable(48) @seen_keys, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  %29 = load i32, ptr %2, align 4, !tbaa !12
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds %struct.BeUpsert, ptr %1, i64 %30
  %32 = getelementptr inbounds i8, ptr %31, i64 4
  %33 = load i32, ptr %32, align 4, !tbaa !21
  switch i32 %33, label %87 [
    i32 0, label %34
    i32 2, label %54
    i32 1, label %65
  ]

34:                                               ; preds = %._crit_edge
  %35 = icmp slt i32 %.040, 0
  %36 = load i32, ptr %31, align 4, !tbaa !16
  call void (i1, ptr, ...) @_ZL8rtassertbPKcz(i1 noundef zeroext %35, ptr noundef nonnull @.str.16, i32 noundef %36)
  %37 = load i32, ptr %2, align 4, !tbaa !12
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %struct.BeUpsert, ptr %1, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !16
  %41 = load ptr, ptr %10, align 8, !tbaa !13
  %42 = getelementptr inbounds i8, ptr %41, i64 4
  %43 = load i32, ptr %41, align 4, !tbaa !14
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [510 x i32], ptr %42, i64 0, i64 %44
  store i32 %40, ptr %45, align 4, !tbaa !12
  %46 = load i32, ptr %2, align 4, !tbaa !12
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds %struct.BeUpsert, ptr %1, i64 %47, i32 2
  %49 = load i32, ptr %48, align 4, !tbaa !22
  %50 = getelementptr inbounds i8, ptr %41, i64 2044
  %51 = getelementptr inbounds [510 x i32], ptr %50, i64 0, i64 %44
  store i32 %49, ptr %51, align 4, !tbaa !12
  %52 = add i32 %43, 1
  store i32 %52, ptr %41, align 4, !tbaa !14
  %53 = icmp eq i32 %52, 510
  br i1 %53, label %.thread, label %88

54:                                               ; preds = %._crit_edge
  %55 = icmp sgt i32 %.040, -1
  %56 = load i32, ptr %31, align 4, !tbaa !16
  call void (i1, ptr, ...) @_ZL8rtassertbPKcz(i1 noundef zeroext %55, ptr noundef nonnull @.str.17, i32 noundef %56)
  %57 = load i32, ptr %2, align 4, !tbaa !12
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.BeUpsert, ptr %1, i64 %58, i32 2
  %60 = load i32, ptr %59, align 4, !tbaa !22
  %61 = load ptr, ptr %10, align 8, !tbaa !13
  %62 = getelementptr inbounds i8, ptr %61, i64 2044
  %63 = sext i32 %.040 to i64
  %64 = getelementptr inbounds [510 x i32], ptr %62, i64 0, i64 %63
  store i32 %60, ptr %64, align 4, !tbaa !12
  br label %88

65:                                               ; preds = %._crit_edge
  %66 = icmp sgt i32 %.040, -1
  %67 = load i32, ptr %31, align 4, !tbaa !16
  call void (i1, ptr, ...) @_ZL8rtassertbPKcz(i1 noundef zeroext %66, ptr noundef nonnull @.str.18, i32 noundef %67)
  %68 = load ptr, ptr %10, align 8, !tbaa !13
  %.053 = add nsw i32 %.040, 1
  %69 = load i32, ptr %68, align 4, !tbaa !14
  %70 = icmp ult i32 %.053, %69
  br i1 %70, label %.lr.ph57, label %._crit_edge58

.lr.ph57:                                         ; preds = %65
  %71 = getelementptr inbounds i8, ptr %68, i64 4
  %72 = getelementptr inbounds i8, ptr %68, i64 2044
  %73 = sext i32 %.053 to i64
  br label %75

._crit_edge58:                                    ; preds = %75, %65
  %.lcssa47 = phi i32 [ %69, %65 ], [ %83, %75 ]
  %74 = add i32 %.lcssa47, -1
  store i32 %74, ptr %68, align 4, !tbaa !14
  br label %88

75:                                               ; preds = %.lr.ph57, %75
  %indvars.iv67 = phi i64 [ %73, %.lr.ph57 ], [ %indvars.iv.next68, %75 ]
  %.0.in54 = phi i32 [ %.040, %.lr.ph57 ], [ %86, %75 ]
  %76 = getelementptr inbounds [510 x i32], ptr %71, i64 0, i64 %indvars.iv67
  %77 = load i32, ptr %76, align 4, !tbaa !12
  %78 = sext i32 %.0.in54 to i64
  %79 = getelementptr inbounds [510 x i32], ptr %71, i64 0, i64 %78
  store i32 %77, ptr %79, align 4, !tbaa !12
  %80 = getelementptr inbounds [510 x i32], ptr %72, i64 0, i64 %indvars.iv67
  %81 = load i32, ptr %80, align 4, !tbaa !12
  %82 = getelementptr inbounds [510 x i32], ptr %72, i64 0, i64 %78
  store i32 %81, ptr %82, align 4, !tbaa !12
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %83 = load i32, ptr %68, align 4, !tbaa !14
  %84 = trunc nsw i64 %indvars.iv.next68 to i32
  %85 = icmp ugt i32 %83, %84
  %86 = trunc nsw i64 %indvars.iv67 to i32
  br i1 %85, label %75, label %._crit_edge58, !llvm.loop !23

87:                                               ; preds = %._crit_edge
  call void (i1, ptr, ...) @_ZL8rtassertbPKcz(i1 noundef zeroext false, ptr noundef nonnull @.str.19, i32 noundef %33)
  br label %88

88:                                               ; preds = %54, %._crit_edge58, %87, %34
  %89 = load i32, ptr %2, align 4, !tbaa !12
  %90 = icmp sgt i32 %89, 0
  br i1 %90, label %12, label %.thread

.thread:                                          ; preds = %88, %34, %.preheader
  %.lcssa49 = phi i1 [ false, %.preheader ], [ true, %34 ], [ false, %88 ]
  ret i1 %.lcssa49
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8rtassertbPKcz(i1 noundef zeroext, ptr noundef, ...) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { 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 = { noreturn nounwind }
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, !8, i64 32}
!6 = !{!"_ZTS6BeNode", !7, i64 0, !8, i64 8, !11, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56}
!7 = !{!"_ZTS12Serializable"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!6, !8, i64 56}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTS6BeData", !11, i64 0, !9, i64 4, !9, i64 2044}
!16 = !{!17, !11, i64 0}
!17 = !{!"_ZTS8BeUpsert", !11, i64 0, !18, i64 4, !11, i64 8, !11, i64 12}
!18 = !{!"_ZTS14UpsertFunction", !9, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!17, !18, i64 4}
!22 = !{!17, !11, i64 8}
!23 = distinct !{!23, !20}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass