; LLVM IR from erthink/libmdbx :: src (api-txn-data)

; 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.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon.0 }
%struct.anon.0 = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.cursor_couple = type { %struct.MDBX_cursor, ptr, %struct.inner_cursor }
%struct.MDBX_cursor = type { i32, %union.anon, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon = type { i16 }
%struct.inner_cursor = type { %struct.MDBX_cursor, %struct.tree }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%struct.iovec = type { ptr, i64 }
%struct.cursor_set_result = type { i32, i8 }
%struct.MDBX_txn = type { i32, i32, i64, i64, ptr, ptr, %struct.geo, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, %struct.MDBX_canary, ptr, %union.anon.4 }
%struct.geo = type { i16, i16, i32, i32, %union.anon.2, %union.anon.3 }
%union.anon.2 = type { i32 }
%union.anon.3 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.4 = type { %struct.anon.6 }
%struct.anon.6 = type { %struct.troika, ptr, %struct.anon.7, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.8 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.7 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.8 = type { %struct.anon.9 }
%struct.anon.9 = type { i64, ptr }
%struct.anon = type { i8, i8 }

@globals = external global %struct.libmdbx_globals, align 8
@.str.4 = external hidden unnamed_addr constant [67 x i8], align 1
@__func__.mdbx_replace_ex = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @log_if_error(i32 noundef, ptr noundef, i32 noundef) #1

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

declare i32 @cursor_init(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden ptr @page_node(ptr noundef, i64 noundef) #4

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden zeroext i8 @node_flags(ptr noalias noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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) #5

declare i64 @cursor_seek(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden zeroext i1 @inner_pointed(ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @check_txn_rw(ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden zeroext i1 @is_modifable(ptr noundef, ptr noundef) #4

declare i32 @cursor_del(ptr noundef, i32 noundef) #3

; Function Attrs: noreturn
declare void @mdbx_assert_fail(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #6

declare i32 @cursor_put_checklen(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_replace_ex(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef %6, ptr noundef %7) #7 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca %struct.cursor_couple, align 8
  %21 = alloca %struct.iovec, align 8
  %22 = alloca %struct.cursor_set_result, align 4
  %23 = alloca %struct.iovec, align 8
  %24 = alloca %struct.cursor_set_result, align 4
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  store ptr %0, ptr %10, align 8, !tbaa !5
  store i32 %1, ptr %11, align 4, !tbaa !9
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store i32 %5, ptr %15, align 4, !tbaa !9
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  %27 = load ptr, ptr %12, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %36

29:                                               ; preds = %8
  %30 = load ptr, ptr %14, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %36

32:                                               ; preds = %29
  %33 = load ptr, ptr %14, align 8, !tbaa !5
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = icmp eq ptr %33, %34
  br label %36

36:                                               ; preds = %32, %29, %8
  %37 = phi i1 [ true, %29 ], [ true, %8 ], [ %35, %32 ]
  %38 = xor i1 %37, true
  %39 = xor i1 %38, true
  %40 = zext i1 %39 to i32
  %41 = sext i32 %40 to i64
  %42 = call i64 @llvm.expect.i64(i64 %41, i64 0)
  %43 = icmp ne i64 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %36
  %45 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 338)
  store i32 %45, ptr %9, align 4
  br label %430

46:                                               ; preds = %36
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.iovec, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = icmp eq ptr %49, null
  br i1 %50, label %51, label %56

51:                                               ; preds = %46
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.iovec, ptr %52, i32 0, i32 1
  %54 = load i64, ptr %53, align 8, !tbaa !14
  %55 = icmp ne i64 %54, 0
  br label %56

56:                                               ; preds = %51, %46
  %57 = phi i1 [ false, %46 ], [ %55, %51 ]
  %58 = xor i1 %57, true
  %59 = xor i1 %58, true
  %60 = zext i1 %59 to i32
  %61 = sext i32 %60 to i64
  %62 = call i64 @llvm.expect.i64(i64 %61, i64 0)
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %56
  %65 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 341)
  store i32 %65, ptr %9, align 4
  br label %430

66:                                               ; preds = %56
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = icmp eq ptr %67, null
  br i1 %68, label %69, label %73

69:                                               ; preds = %66
  %70 = load i32, ptr %15, align 4, !tbaa !9
  %71 = and i32 %70, 65600
  %72 = icmp ne i32 %71, 64
  br label %73

73:                                               ; preds = %69, %66
  %74 = phi i1 [ false, %66 ], [ %72, %69 ]
  %75 = xor i1 %74, true
  %76 = xor i1 %75, true
  %77 = zext i1 %76 to i32
  %78 = sext i32 %77 to i64
  %79 = call i64 @llvm.expect.i64(i64 %78, i64 0)
  %80 = icmp ne i64 %79, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %73
  %82 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 344)
  store i32 %82, ptr %9, align 4
  br label %430

83:                                               ; preds = %73
  %84 = load i32, ptr %11, align 4, !tbaa !9
  %85 = icmp ule i32 %84, 0
  %86 = xor i1 %85, true
  %87 = xor i1 %86, true
  %88 = zext i1 %87 to i32
  %89 = sext i32 %88 to i64
  %90 = call i64 @llvm.expect.i64(i64 %89, i64 0)
  %91 = icmp ne i64 %90, 0
  br i1 %91, label %92, label %94

92:                                               ; preds = %83
  %93 = call i32 @log_if_error(i32 noundef -30780, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 347)
  store i32 %93, ptr %9, align 4
  br label %430

94:                                               ; preds = %83
  %95 = load i32, ptr %15, align 4, !tbaa !9
  %96 = and i32 %95, -458993
  %97 = icmp ne i32 %96, 0
  %98 = xor i1 %97, true
  %99 = xor i1 %98, true
  %100 = zext i1 %99 to i32
  %101 = sext i32 %100 to i64
  %102 = call i64 @llvm.expect.i64(i64 %101, i64 0)
  %103 = icmp ne i64 %102, 0
  br i1 %103, label %104, label %106

104:                                              ; preds = %94
  %105 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 351)
  store i32 %105, ptr %9, align 4
  br label %430

106:                                              ; preds = %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #8
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = call i32 @check_txn_rw(ptr noundef %107, i32 noundef 51)
  store i32 %108, ptr %18, align 4, !tbaa !9
  %109 = load i32, ptr %18, align 4, !tbaa !9
  %110 = icmp ne i32 %109, 0
  %111 = xor i1 %110, true
  %112 = xor i1 %111, true
  %113 = zext i1 %112 to i32
  %114 = sext i32 %113 to i64
  %115 = call i64 @llvm.expect.i64(i64 %114, i64 0)
  %116 = icmp ne i64 %115, 0
  br i1 %116, label %117, label %120

117:                                              ; preds = %106
  %118 = load i32, ptr %18, align 4, !tbaa !9
  %119 = call i32 @log_if_error(i32 noundef %118, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 355)
  store i32 %119, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %429

120:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 824, ptr %20) #8
  %121 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  %123 = load i32, ptr %11, align 4, !tbaa !9
  %124 = zext i32 %123 to i64
  %125 = call i32 @cursor_init(ptr noundef %121, ptr noundef %122, i64 noundef %124)
  store i32 %125, ptr %18, align 4, !tbaa !9
  %126 = load i32, ptr %18, align 4, !tbaa !9
  %127 = icmp ne i32 %126, 0
  %128 = xor i1 %127, true
  %129 = xor i1 %128, true
  %130 = zext i1 %129 to i32
  %131 = sext i32 %130 to i64
  %132 = call i64 @llvm.expect.i64(i64 %131, i64 0)
  %133 = icmp ne i64 %132, 0
  br i1 %133, label %134, label %137

134:                                              ; preds = %120
  %135 = load i32, ptr %18, align 4, !tbaa !9
  %136 = call i32 @log_if_error(i32 noundef %135, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 360)
  store i32 %136, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %428

137:                                              ; preds = %120
  %138 = load ptr, ptr %10, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.MDBX_txn, ptr %138, i32 0, i32 14
  %140 = load ptr, ptr %139, align 8, !tbaa !15
  %141 = load i32, ptr %11, align 4, !tbaa !9
  %142 = zext i32 %141 to i64
  %143 = getelementptr inbounds ptr, ptr %140, i64 %142
  %144 = load ptr, ptr %143, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %146 = getelementptr inbounds %struct.MDBX_cursor, ptr %145, i32 0, i32 11
  store ptr %144, ptr %146, align 8, !tbaa !20
  %147 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %148 = load ptr, ptr %10, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.MDBX_txn, ptr %148, i32 0, i32 14
  %150 = load ptr, ptr %149, align 8, !tbaa !15
  %151 = load i32, ptr %11, align 4, !tbaa !9
  %152 = zext i32 %151 to i64
  %153 = getelementptr inbounds ptr, ptr %150, i64 %152
  store ptr %147, ptr %153, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %21) #8
  %154 = load ptr, ptr %12, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 8 %154, i64 16, i1 false), !tbaa.struct !25
  %155 = load i32, ptr %15, align 4, !tbaa !9
  %156 = and i32 %155, 80
  %157 = icmp eq i32 %156, 80
  br i1 %157, label %158, label %190

158:                                              ; preds = %137
  %159 = load ptr, ptr %10, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.MDBX_txn, ptr %159, i32 0, i32 10
  %161 = load ptr, ptr %160, align 8, !tbaa !27
  %162 = load i32, ptr %11, align 4, !tbaa !9
  %163 = zext i32 %162 to i64
  %164 = getelementptr inbounds %struct.tree, ptr %161, i64 %163
  %165 = getelementptr inbounds %struct.tree, ptr %164, i32 0, i32 0
  %166 = load i16, ptr %165, align 4, !tbaa !28
  %167 = zext i16 %166 to i32
  %168 = and i32 %167, 4
  %169 = icmp ne i32 %168, 0
  %170 = xor i1 %169, true
  %171 = xor i1 %170, true
  %172 = xor i1 %171, true
  %173 = zext i1 %172 to i32
  %174 = sext i32 %173 to i64
  %175 = call i64 @llvm.expect.i64(i64 %174, i64 0)
  %176 = icmp ne i64 %175, 0
  br i1 %176, label %177, label %178

177:                                              ; preds = %158
  store i32 22, ptr %18, align 4, !tbaa !9
  br label %415

178:                                              ; preds = %158
  %179 = load i32, ptr %15, align 4, !tbaa !9
  %180 = sub i32 %179, 16
  store i32 %180, ptr %15, align 4, !tbaa !9
  %181 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %182 = load ptr, ptr %14, align 8, !tbaa !5
  %183 = call i64 @cursor_seek(ptr noundef %181, ptr noundef %21, ptr noundef %182, i32 noundef 2)
  store i64 %183, ptr %22, align 4
  %184 = getelementptr inbounds %struct.cursor_set_result, ptr %22, i32 0, i32 0
  %185 = load i32, ptr %184, align 4, !tbaa !29
  store i32 %185, ptr %18, align 4, !tbaa !9
  %186 = load i32, ptr %18, align 4, !tbaa !9
  %187 = icmp ne i32 %186, 0
  br i1 %187, label %188, label %189

188:                                              ; preds = %178
  br label %415

189:                                              ; preds = %178
  br label %394

190:                                              ; preds = %137
  %191 = load ptr, ptr %13, align 8, !tbaa !5
  %192 = icmp ne ptr %191, null
  br i1 %192, label %193, label %201

193:                                              ; preds = %190
  %194 = load ptr, ptr %14, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.iovec, ptr %194, i32 0, i32 0
  %196 = load ptr, ptr %195, align 8, !tbaa !11
  %197 = load ptr, ptr %13, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.iovec, ptr %197, i32 0, i32 0
  %199 = load ptr, ptr %198, align 8, !tbaa !11
  %200 = icmp eq ptr %196, %199
  br label %201

201:                                              ; preds = %193, %190
  %202 = phi i1 [ false, %190 ], [ %200, %193 ]
  %203 = xor i1 %202, true
  %204 = xor i1 %203, true
  %205 = zext i1 %204 to i32
  %206 = sext i32 %205 to i64
  %207 = call i64 @llvm.expect.i64(i64 %206, i64 0)
  %208 = icmp ne i64 %207, 0
  br i1 %208, label %209, label %211

209:                                              ; preds = %201
  %210 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 381)
  store i32 %210, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %427

211:                                              ; preds = %201
  call void @llvm.lifetime.start.p0(i64 16, ptr %23) #8
  %212 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %213 = call i64 @cursor_seek(ptr noundef %212, ptr noundef %21, ptr noundef %23, i32 noundef 16)
  store i64 %213, ptr %24, align 4
  %214 = getelementptr inbounds %struct.cursor_set_result, ptr %24, i32 0, i32 0
  %215 = load i32, ptr %214, align 4, !tbaa !29
  store i32 %215, ptr %18, align 4, !tbaa !9
  %216 = load i32, ptr %18, align 4, !tbaa !9
  %217 = icmp ne i32 %216, 0
  %218 = xor i1 %217, true
  %219 = xor i1 %218, true
  %220 = zext i1 %219 to i32
  %221 = sext i32 %220 to i64
  %222 = call i64 @llvm.expect.i64(i64 %221, i64 0)
  %223 = icmp ne i64 %222, 0
  br i1 %223, label %224, label %237

224:                                              ; preds = %211
  %225 = load ptr, ptr %14, align 8, !tbaa !5
  %226 = getelementptr inbounds %struct.iovec, ptr %225, i32 0, i32 0
  store ptr null, ptr %226, align 8, !tbaa !11
  %227 = load ptr, ptr %14, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.iovec, ptr %227, i32 0, i32 1
  store i64 0, ptr %228, align 8, !tbaa !14
  %229 = load i32, ptr %18, align 4, !tbaa !9
  %230 = icmp ne i32 %229, -30798
  br i1 %230, label %235, label %231

231:                                              ; preds = %224
  %232 = load i32, ptr %15, align 4, !tbaa !9
  %233 = and i32 %232, 64
  %234 = icmp ne i32 %233, 0
  br i1 %234, label %235, label %236

235:                                              ; preds = %231, %224
  store i32 2, ptr %19, align 4
  br label %391

236:                                              ; preds = %231
  br label %390

237:                                              ; preds = %211
  %238 = load i32, ptr %15, align 4, !tbaa !9
  %239 = and i32 %238, 16
  %240 = icmp ne i32 %239, 0
  br i1 %240, label %241, label %243

241:                                              ; preds = %237
  store i32 -30799, ptr %18, align 4, !tbaa !9
  %242 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %242, ptr align 8 %23, i64 16, i1 false), !tbaa.struct !25
  store i32 2, ptr %19, align 4
  br label %391

243:                                              ; preds = %237
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #8
  %244 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %245 = getelementptr inbounds %struct.MDBX_cursor, ptr %244, i32 0, i32 9
  %246 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %247 = getelementptr inbounds %struct.MDBX_cursor, ptr %246, i32 0, i32 1
  %248 = getelementptr inbounds %struct.anon, ptr %247, i32 0, i32 1
  %249 = load i8, ptr %248, align 1, !tbaa !32
  %250 = sext i8 %249 to i64
  %251 = getelementptr inbounds [32 x ptr], ptr %245, i64 0, i64 %250
  %252 = load ptr, ptr %251, align 8, !tbaa !5
  store ptr %252, ptr %25, align 8, !tbaa !5
  %253 = load ptr, ptr %10, align 8, !tbaa !5
  %254 = getelementptr inbounds %struct.MDBX_txn, ptr %253, i32 0, i32 10
  %255 = load ptr, ptr %254, align 8, !tbaa !27
  %256 = load i32, ptr %11, align 4, !tbaa !9
  %257 = zext i32 %256 to i64
  %258 = getelementptr inbounds %struct.tree, ptr %255, i64 %257
  %259 = getelementptr inbounds %struct.tree, ptr %258, i32 0, i32 0
  %260 = load i16, ptr %259, align 4, !tbaa !28
  %261 = zext i16 %260 to i32
  %262 = and i32 %261, 4
  %263 = icmp ne i32 %262, 0
  br i1 %263, label %264, label %343

264:                                              ; preds = %243
  %265 = load i32, ptr %15, align 4, !tbaa !9
  %266 = and i32 %265, 64
  %267 = icmp ne i32 %266, 0
  br i1 %267, label %268, label %342

268:                                              ; preds = %264
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #8
  %269 = load ptr, ptr %25, align 8, !tbaa !5
  %270 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %271 = getelementptr inbounds %struct.MDBX_cursor, ptr %270, i32 0, i32 10
  %272 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %273 = getelementptr inbounds %struct.MDBX_cursor, ptr %272, i32 0, i32 1
  %274 = getelementptr inbounds %struct.anon, ptr %273, i32 0, i32 1
  %275 = load i8, ptr %274, align 1, !tbaa !32
  %276 = sext i8 %275 to i64
  %277 = getelementptr inbounds [32 x i16], ptr %271, i64 0, i64 %276
  %278 = load i16, ptr %277, align 2, !tbaa !33
  %279 = zext i16 %278 to i64
  %280 = call ptr @page_node(ptr noundef %269, i64 noundef %279) #9
  store ptr %280, ptr %26, align 8, !tbaa !5
  %281 = load ptr, ptr %26, align 8, !tbaa !5
  %282 = call zeroext i8 @node_flags(ptr noundef %281) #9
  %283 = zext i8 %282 to i32
  %284 = and i32 %283, 4
  %285 = icmp ne i32 %284, 0
  br i1 %285, label %286, label %338

286:                                              ; preds = %268
  br label %287

287:                                              ; preds = %286
  %288 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !34
  %289 = zext i8 %288 to i32
  %290 = and i32 %289, 1
  %291 = icmp ne i32 %290, 0
  %292 = xor i1 %291, true
  %293 = xor i1 %292, true
  %294 = zext i1 %293 to i32
  %295 = sext i32 %294 to i64
  %296 = call i64 @llvm.expect.i64(i64 %295, i64 1)
  %297 = icmp ne i64 %296, 0
  br i1 %297, label %298, label %326

298:                                              ; preds = %287
  br label %299

299:                                              ; preds = %298
  %300 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %301 = call zeroext i1 @inner_pointed(ptr noundef %300) #9
  br i1 %301, label %302, label %310

302:                                              ; preds = %299
  %303 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %304 = getelementptr inbounds %struct.MDBX_cursor, ptr %303, i32 0, i32 8
  %305 = load ptr, ptr %304, align 8, !tbaa !36
  %306 = getelementptr inbounds %struct.inner_cursor, ptr %305, i32 0, i32 1
  %307 = getelementptr inbounds %struct.tree, ptr %306, i32 0, i32 8
  %308 = load i64, ptr %307, align 8, !tbaa !37
  %309 = icmp ugt i64 %308, 1
  br label %310

310:                                              ; preds = %302, %299
  %311 = phi i1 [ false, %299 ], [ %309, %302 ]
  %312 = xor i1 %311, true
  %313 = xor i1 %312, true
  %314 = xor i1 %313, true
  %315 = zext i1 %314 to i32
  %316 = sext i32 %315 to i64
  %317 = call i64 @llvm.expect.i64(i64 %316, i64 0)
  %318 = icmp ne i64 %317, 0
  br i1 %318, label %319, label %323

319:                                              ; preds = %310
  %320 = load ptr, ptr %10, align 8, !tbaa !5
  %321 = getelementptr inbounds %struct.MDBX_txn, ptr %320, i32 0, i32 9
  %322 = load ptr, ptr %321, align 8, !tbaa !38
  call void @mdbx_assert_fail(ptr noundef %322, ptr noundef @.str.4, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 400) #10
  unreachable

323:                                              ; preds = %310
  br label %324

324:                                              ; preds = %323
  br label %325

325:                                              ; preds = %324
  br label %326

326:                                              ; preds = %325, %287
  br label %327

327:                                              ; preds = %326
  br label %328

328:                                              ; preds = %327
  %329 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %330 = getelementptr inbounds %struct.MDBX_cursor, ptr %329, i32 0, i32 8
  %331 = load ptr, ptr %330, align 8, !tbaa !36
  %332 = getelementptr inbounds %struct.inner_cursor, ptr %331, i32 0, i32 1
  %333 = getelementptr inbounds %struct.tree, ptr %332, i32 0, i32 8
  %334 = load i64, ptr %333, align 8, !tbaa !37
  %335 = icmp ugt i64 %334, 1
  br i1 %335, label %336, label %337

336:                                              ; preds = %328
  store i32 -30421, ptr %18, align 4, !tbaa !9
  store i32 2, ptr %19, align 4
  br label %339

337:                                              ; preds = %328
  br label %338

338:                                              ; preds = %337, %268
  store i32 0, ptr %19, align 4
  br label %339

339:                                              ; preds = %338, %336
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #8
  %340 = load i32, ptr %19, align 4
  switch i32 %340, label %386 [
    i32 0, label %341
  ]

341:                                              ; preds = %339
  br label %342

342:                                              ; preds = %341, %264
  br label %343

343:                                              ; preds = %342, %243
  %344 = load ptr, ptr %10, align 8, !tbaa !5
  %345 = load ptr, ptr %25, align 8, !tbaa !5
  %346 = call zeroext i1 @is_modifable(ptr noundef %344, ptr noundef %345) #9
  br i1 %346, label %347, label %381

347:                                              ; preds = %343
  %348 = load ptr, ptr %13, align 8, !tbaa !5
  %349 = icmp ne ptr %348, null
  br i1 %349, label %350, label %356

350:                                              ; preds = %347
  %351 = load ptr, ptr %13, align 8, !tbaa !5
  %352 = call zeroext i1 @eq_fast(ptr noundef %23, ptr noundef %351) #9
  br i1 %352, label %353, label %356

353:                                              ; preds = %350
  %354 = load ptr, ptr %14, align 8, !tbaa !5
  %355 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %354, ptr align 8 %355, i64 16, i1 false), !tbaa.struct !25
  store i32 2, ptr %19, align 4
  br label %386

356:                                              ; preds = %350, %347
  %357 = load ptr, ptr %16, align 8, !tbaa !5
  %358 = icmp ne ptr %357, null
  br i1 %358, label %359, label %368

359:                                              ; preds = %356
  %360 = load ptr, ptr %16, align 8, !tbaa !5
  %361 = load ptr, ptr %17, align 8, !tbaa !5
  %362 = load ptr, ptr %14, align 8, !tbaa !5
  %363 = getelementptr inbounds %struct.iovec, ptr %23, i32 0, i32 0
  %364 = load ptr, ptr %363, align 8, !tbaa !11
  %365 = getelementptr inbounds %struct.iovec, ptr %23, i32 0, i32 1
  %366 = load i64, ptr %365, align 8, !tbaa !14
  %367 = call i32 %360(ptr noundef %361, ptr noundef %362, ptr noundef %364, i64 noundef %366)
  br label %369

368:                                              ; preds = %356
  br label %369

369:                                              ; preds = %368, %359
  %370 = phi i32 [ %367, %359 ], [ 0, %368 ]
  store i32 %370, ptr %18, align 4, !tbaa !9
  %371 = load i32, ptr %18, align 4, !tbaa !9
  %372 = icmp ne i32 %371, 0
  %373 = xor i1 %372, true
  %374 = xor i1 %373, true
  %375 = zext i1 %374 to i32
  %376 = sext i32 %375 to i64
  %377 = call i64 @llvm.expect.i64(i64 %376, i64 0)
  %378 = icmp ne i64 %377, 0
  br i1 %378, label %379, label %380

379:                                              ; preds = %369
  store i32 2, ptr %19, align 4
  br label %386

380:                                              ; preds = %369
  br label %383

381:                                              ; preds = %343
  %382 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %382, ptr align 8 %23, i64 16, i1 false), !tbaa.struct !25
  br label %383

383:                                              ; preds = %381, %380
  %384 = load i32, ptr %15, align 4, !tbaa !9
  %385 = or i32 %384, 64
  store i32 %385, ptr %15, align 4, !tbaa !9
  store i32 0, ptr %19, align 4
  br label %386

386:                                              ; preds = %383, %379, %353, %339
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #8
  %387 = load i32, ptr %19, align 4
  switch i32 %387, label %391 [
    i32 0, label %388
  ]

388:                                              ; preds = %386
  br label %389

389:                                              ; preds = %388
  br label %390

390:                                              ; preds = %389, %236
  store i32 0, ptr %19, align 4
  br label %391

391:                                              ; preds = %390, %386, %241, %235
  call void @llvm.lifetime.end.p0(i64 16, ptr %23) #8
  %392 = load i32, ptr %19, align 4
  switch i32 %392, label %427 [
    i32 0, label %393
    i32 2, label %415
  ]

393:                                              ; preds = %391
  br label %394

394:                                              ; preds = %393, %189
  %395 = load ptr, ptr %13, align 8, !tbaa !5
  %396 = icmp ne ptr %395, null
  %397 = xor i1 %396, true
  %398 = xor i1 %397, true
  %399 = zext i1 %398 to i32
  %400 = sext i32 %399 to i64
  %401 = call i64 @llvm.expect.i64(i64 %400, i64 1)
  %402 = icmp ne i64 %401, 0
  br i1 %402, label %403, label %409

403:                                              ; preds = %394
  %404 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %405 = load ptr, ptr %12, align 8, !tbaa !5
  %406 = load ptr, ptr %13, align 8, !tbaa !5
  %407 = load i32, ptr %15, align 4, !tbaa !9
  %408 = call i32 @cursor_put_checklen(ptr noundef %404, ptr noundef %405, ptr noundef %406, i32 noundef %407)
  store i32 %408, ptr %18, align 4, !tbaa !9
  br label %414

409:                                              ; preds = %394
  %410 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %411 = load i32, ptr %15, align 4, !tbaa !9
  %412 = and i32 %411, 128
  %413 = call i32 @cursor_del(ptr noundef %410, i32 noundef %412)
  store i32 %413, ptr %18, align 4, !tbaa !9
  br label %414

414:                                              ; preds = %409, %403
  br label %415

415:                                              ; preds = %414, %391, %188, %177
  %416 = getelementptr inbounds %struct.cursor_couple, ptr %20, i32 0, i32 0
  %417 = getelementptr inbounds %struct.MDBX_cursor, ptr %416, i32 0, i32 11
  %418 = load ptr, ptr %417, align 8, !tbaa !20
  %419 = load ptr, ptr %10, align 8, !tbaa !5
  %420 = getelementptr inbounds %struct.MDBX_txn, ptr %419, i32 0, i32 14
  %421 = load ptr, ptr %420, align 8, !tbaa !15
  %422 = load i32, ptr %11, align 4, !tbaa !9
  %423 = zext i32 %422 to i64
  %424 = getelementptr inbounds ptr, ptr %421, i64 %423
  store ptr %418, ptr %424, align 8, !tbaa !5
  %425 = load i32, ptr %18, align 4, !tbaa !9
  %426 = call i32 @log_if_error(i32 noundef %425, ptr noundef @__func__.mdbx_replace_ex, i32 noundef 437)
  store i32 %426, ptr %9, align 4
  store i32 1, ptr %19, align 4
  br label %427

427:                                              ; preds = %415, %391, %209
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #8
  br label %428

428:                                              ; preds = %427, %134
  call void @llvm.lifetime.end.p0(i64 824, ptr %20) #8
  br label %429

429:                                              ; preds = %428, %117
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #8
  br label %430

430:                                              ; preds = %429, %104, %92, %81, %64, %44
  %431 = load i32, ptr %9, align 4
  ret i32 %431
}

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden zeroext i1 @eq_fast(ptr noundef, ptr noundef) #4

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"iovec", !6, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!16, !6, i64 120}
!16 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !17, i64 40, !13, i64 64, !13, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !19, i64 128, !6, i64 160, !7, i64 168}
!17 = !{!"geo", !18, i64 0, !18, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!18 = !{!"short", !7, i64 0}
!19 = !{!"MDBX_canary", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!20 = !{!21, !6, i64 368}
!21 = !{!"cursor_couple", !22, i64 0, !6, i64 384, !23, i64 392}
!22 = !{!"MDBX_cursor", !10, i64 0, !7, i64 4, !7, i64 6, !7, i64 7, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !7, i64 304, !6, i64 368, !6, i64 376}
!23 = !{!"inner_cursor", !22, i64 0, !24, i64 384}
!24 = !{!"tree", !18, i64 0, !18, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 32, !13, i64 40}
!25 = !{i64 0, i64 8, !5, i64 8, i64 8, !26}
!26 = !{!13, !13, i64 0}
!27 = !{!16, !6, i64 88}
!28 = !{!24, !18, i64 0}
!29 = !{!30, !10, i64 0}
!30 = !{!"cursor_set_result", !10, i64 0, !31, i64 4}
!31 = !{!"_Bool", !7, i64 0}
!32 = !{!7, !7, i64 0}
!33 = !{!18, !18, i64 0}
!34 = !{!35, !7, i64 25}
!35 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !31, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !13, i64 80, !6, i64 88}
!36 = !{!21, !6, i64 40}
!37 = !{!23, !13, i64 416}
!38 = !{!16, !6, i64 80}


; 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.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon.0 }
%struct.anon.0 = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.cursor_couple = type { %struct.MDBX_cursor, ptr, %struct.inner_cursor }
%struct.MDBX_cursor = type { i32, %union.anon, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon = type { i16 }
%struct.inner_cursor = type { %struct.MDBX_cursor, %struct.tree }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%struct.iovec = type { ptr, i64 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.4 = external hidden unnamed_addr constant [67 x i8], align 1
@__func__.mdbx_replace_ex = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @log_if_error(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

declare i32 @cursor_init(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden ptr @page_node(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden zeroext i8 @node_flags(ptr noalias noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress 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) #4

declare i64 @cursor_seek(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden zeroext i1 @inner_pointed(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @check_txn_rw(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden zeroext i1 @is_modifable(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @cursor_del(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: noreturn
declare void @mdbx_assert_fail(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

declare i32 @cursor_put_checklen(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_replace_ex(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, ptr noundef readonly %6, ptr noundef %7) local_unnamed_addr #6 {
  %9 = alloca %struct.cursor_couple, align 8
  %10 = alloca %struct.iovec, align 8
  %11 = alloca %struct.iovec, align 8
  %12 = icmp eq ptr %2, null
  %13 = icmp eq ptr %4, null
  %or.cond.not = or i1 %12, %13
  %14 = icmp eq ptr %4, %3
  %spec.select = or i1 %14, %or.cond.not
  br i1 %spec.select, label %15, label %17, !prof !5

15:                                               ; preds = %8
  %16 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 338)
  br label %139

17:                                               ; preds = %8
  %18 = load ptr, ptr %4, align 8, !tbaa !6
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %.critedge

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %4, i64 8
  %22 = load i64, ptr %21, align 8, !tbaa !12
  %.not132 = icmp eq i64 %22, 0
  br i1 %.not132, label %.critedge, label %23, !prof !13

23:                                               ; preds = %20
  %24 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 341)
  br label %139

.critedge:                                        ; preds = %17, %20
  %25 = icmp eq ptr %3, null
  %26 = and i32 %5, 65600
  %27 = icmp ne i32 %26, 64
  %28 = and i1 %25, %27
  br i1 %28, label %29, label %31, !prof !5

29:                                               ; preds = %.critedge
  %30 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 344)
  br label %139

31:                                               ; preds = %.critedge
  %32 = icmp eq i32 %1, 0
  br i1 %32, label %33, label %35, !prof !5

33:                                               ; preds = %31
  %34 = tail call i32 @log_if_error(i32 noundef -30780, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 347)
  br label %139

35:                                               ; preds = %31
  %36 = and i32 %5, -458993
  %.not = icmp eq i32 %36, 0
  br i1 %.not, label %39, label %37, !prof !13

37:                                               ; preds = %35
  %38 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 351)
  br label %139

39:                                               ; preds = %35
  %40 = tail call i32 @check_txn_rw(ptr noundef %0, i32 noundef 51)
  %.not93 = icmp eq i32 %40, 0
  br i1 %.not93, label %43, label %41, !prof !13

41:                                               ; preds = %39
  %42 = tail call i32 @log_if_error(i32 noundef %40, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 355)
  br label %139

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 824, ptr nonnull %9) #8
  %44 = zext i32 %1 to i64
  %45 = call i32 @cursor_init(ptr noundef nonnull %9, ptr noundef %0, i64 noundef %44) #8
  %.not94 = icmp eq i32 %45, 0
  br i1 %.not94, label %48, label %46, !prof !13

46:                                               ; preds = %43
  %47 = call i32 @log_if_error(i32 noundef %45, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 360)
  br label %138

48:                                               ; preds = %43
  %49 = getelementptr inbounds i8, ptr %0, i64 120
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds ptr, ptr %50, i64 %44
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  %53 = getelementptr inbounds i8, ptr %9, i64 368
  store ptr %52, ptr %53, align 8, !tbaa !21
  store ptr %9, ptr %51, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %10) #8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) %2, i64 16, i1 false), !tbaa.struct !26
  %54 = and i32 %5, 80
  %55 = icmp eq i32 %54, 80
  br i1 %55, label %56, label %65

56:                                               ; preds = %48
  %57 = getelementptr inbounds i8, ptr %0, i64 88
  %58 = load ptr, ptr %57, align 8, !tbaa !28
  %59 = getelementptr inbounds %struct.tree, ptr %58, i64 %44
  %60 = load i16, ptr %59, align 4, !tbaa !29
  %61 = and i16 %60, 4
  %.not106 = icmp eq i16 %61, 0
  br i1 %.not106, label %132, label %62, !prof !5

62:                                               ; preds = %56
  %63 = add nsw i32 %5, -16
  %64 = call i64 @cursor_seek(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %4, i32 noundef 2) #8
  %.sroa.05.0.extract.trunc = trunc i64 %64 to i32
  %.not107 = icmp eq i32 %.sroa.05.0.extract.trunc, 0
  br i1 %.not107, label %126, label %132

65:                                               ; preds = %48
  br i1 %25, label %.critedge110, label %66

66:                                               ; preds = %65
  %67 = load ptr, ptr %4, align 8, !tbaa !6
  %68 = load ptr, ptr %3, align 8, !tbaa !6
  %69 = icmp eq ptr %67, %68
  br i1 %69, label %70, label %.critedge110, !prof !5

70:                                               ; preds = %66
  %71 = call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 381)
  br label %137

.critedge110:                                     ; preds = %65, %66
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %11) #8
  %72 = call i64 @cursor_seek(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %11, i32 noundef 16) #8
  %.sroa.0.0.extract.trunc = trunc i64 %72 to i32
  %.not96 = icmp eq i32 %.sroa.0.0.extract.trunc, 0
  br i1 %.not96, label %75, label %73, !prof !13

73:                                               ; preds = %.critedge110
  %.not104 = icmp eq i32 %.sroa.0.0.extract.trunc, -30798
  %74 = and i32 %5, 64
  %.not105 = icmp eq i32 %74, 0
  %or.cond111 = and i1 %.not105, %.not104
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  br i1 %or.cond111, label %125, label %.thread126

75:                                               ; preds = %.critedge110
  %76 = and i32 %5, 16
  %.not97 = icmp eq i32 %76, 0
  br i1 %.not97, label %77, label %.thread126.sink.split

77:                                               ; preds = %75
  %78 = getelementptr inbounds i8, ptr %9, i64 48
  %79 = getelementptr inbounds i8, ptr %9, i64 5
  %80 = load i8, ptr %79, align 1, !tbaa !30
  %81 = sext i8 %80 to i64
  %82 = getelementptr inbounds [32 x ptr], ptr %78, i64 0, i64 %81
  %83 = load ptr, ptr %82, align 8, !tbaa !20
  %84 = getelementptr inbounds i8, ptr %0, i64 88
  %85 = load ptr, ptr %84, align 8, !tbaa !28
  %86 = getelementptr inbounds %struct.tree, ptr %85, i64 %44
  %87 = load i16, ptr %86, align 4, !tbaa !29
  %88 = and i16 %87, 4
  %.not98 = icmp eq i16 %88, 0
  %89 = and i32 %5, 64
  %.not99 = icmp eq i32 %89, 0
  %or.cond112 = or i1 %.not99, %.not98
  br i1 %or.cond112, label %.thread, label %90

90:                                               ; preds = %77
  %91 = getelementptr inbounds i8, ptr %9, i64 304
  %92 = getelementptr inbounds [32 x i16], ptr %91, i64 0, i64 %81
  %93 = load i16, ptr %92, align 2, !tbaa !31
  %94 = zext i16 %93 to i64
  %95 = call ptr @page_node(ptr noundef %83, i64 noundef %94) #9
  %96 = call zeroext i8 @node_flags(ptr noundef %95) #9
  %97 = and i8 %96, 4
  %.not100 = icmp eq i8 %97, 0
  br i1 %.not100, label %.thread, label %98

98:                                               ; preds = %90
  %99 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !32
  %100 = and i8 %99, 1
  %.not101 = icmp eq i8 %100, 0
  br i1 %.not101, label %111, label %101, !prof !5

101:                                              ; preds = %98
  %102 = call zeroext i1 @inner_pointed(ptr noundef nonnull %9) #9
  br i1 %102, label %103, label %.critedge114, !prof !13

103:                                              ; preds = %101
  %104 = getelementptr inbounds i8, ptr %9, i64 40
  %105 = load ptr, ptr %104, align 8, !tbaa !35
  %106 = getelementptr inbounds i8, ptr %105, i64 416
  %107 = load i64, ptr %106, align 8, !tbaa !36
  %108 = icmp ult i64 %107, 2
  br i1 %108, label %.critedge114, label %.thread126, !prof !5

.critedge114:                                     ; preds = %101, %103
  %109 = getelementptr inbounds i8, ptr %0, i64 80
  %110 = load ptr, ptr %109, align 8, !tbaa !37
  call void @mdbx_assert_fail(ptr noundef %110, ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 400) #10
  unreachable

111:                                              ; preds = %98
  %.phi.trans.insert = getelementptr inbounds i8, ptr %9, i64 40
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !35
  %.phi.trans.insert133 = getelementptr inbounds i8, ptr %.pre, i64 416
  %.pre134 = load i64, ptr %.phi.trans.insert133, align 8, !tbaa !36
  %112 = icmp ugt i64 %.pre134, 1
  br i1 %112, label %.thread126, label %.thread

.thread:                                          ; preds = %111, %90, %77
  %113 = call zeroext i1 @is_modifable(ptr noundef nonnull %0, ptr noundef %83) #9
  br i1 %113, label %114, label %123

114:                                              ; preds = %.thread
  br i1 %25, label %117, label %115

115:                                              ; preds = %114
  %116 = call zeroext i1 @eq_fast(ptr noundef nonnull %11, ptr noundef nonnull %3) #9
  br i1 %116, label %.thread126.sink.split, label %117

117:                                              ; preds = %115, %114
  %.not102 = icmp eq ptr %6, null
  br i1 %.not102, label %.thread118, label %118

118:                                              ; preds = %117
  %119 = load ptr, ptr %11, align 8, !tbaa !6
  %120 = getelementptr inbounds i8, ptr %11, i64 8
  %121 = load i64, ptr %120, align 8, !tbaa !12
  %122 = call i32 %6(ptr noundef %7, ptr noundef nonnull %4, ptr noundef %119, i64 noundef %121) #8
  %.not103 = icmp eq i32 %122, 0
  br i1 %.not103, label %.thread118, label %.thread126, !prof !38

123:                                              ; preds = %.thread
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %11, i64 16, i1 false), !tbaa.struct !26
  br label %.thread118

.thread118:                                       ; preds = %117, %123, %118
  %124 = or i32 %5, 64
  br label %125

.thread126.sink.split:                            ; preds = %115, %75
  %.sink = phi ptr [ %11, %75 ], [ %3, %115 ]
  %.5.ph.ph = phi i32 [ -30799, %75 ], [ 0, %115 ]
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %.sink, i64 16, i1 false)
  br label %.thread126

.thread126:                                       ; preds = %.thread126.sink.split, %103, %73, %118, %111
  %.5.ph = phi i32 [ %.sroa.0.0.extract.trunc, %73 ], [ -30421, %111 ], [ %122, %118 ], [ -30421, %103 ], [ %.5.ph.ph, %.thread126.sink.split ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %11) #8
  br label %132

125:                                              ; preds = %73, %.thread118
  %.274 = phi i32 [ %124, %.thread118 ], [ %5, %73 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %11) #8
  br label %126

126:                                              ; preds = %125, %62
  %.375 = phi i32 [ %63, %62 ], [ %.274, %125 ]
  br i1 %25, label %129, label %127, !prof !5

127:                                              ; preds = %126
  %128 = call i32 @cursor_put_checklen(ptr noundef nonnull %9, ptr noundef nonnull %2, ptr noundef nonnull %3, i32 noundef %.375) #8
  br label %132

129:                                              ; preds = %126
  %130 = and i32 %.375, 128
  %131 = call i32 @cursor_del(ptr noundef nonnull %9, i32 noundef %130) #8
  br label %132

132:                                              ; preds = %.thread126, %56, %127, %129, %62
  %.6 = phi i32 [ %.sroa.05.0.extract.trunc, %62 ], [ %128, %127 ], [ %131, %129 ], [ 22, %56 ], [ %.5.ph, %.thread126 ]
  %133 = load ptr, ptr %53, align 8, !tbaa !21
  %134 = load ptr, ptr %49, align 8, !tbaa !14
  %135 = getelementptr inbounds ptr, ptr %134, i64 %44
  store ptr %133, ptr %135, align 8, !tbaa !20
  %136 = call i32 @log_if_error(i32 noundef %.6, ptr noundef nonnull @__func__.mdbx_replace_ex, i32 noundef 437)
  br label %137

137:                                              ; preds = %132, %70
  %.0 = phi i32 [ %136, %132 ], [ %71, %70 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #8
  br label %138

138:                                              ; preds = %137, %46
  %.1 = phi i32 [ %47, %46 ], [ %.0, %137 ]
  call void @llvm.lifetime.end.p0(i64 824, ptr nonnull %9) #8
  br label %139

139:                                              ; preds = %41, %138, %37, %33, %29, %23, %15
  %.3 = phi i32 [ %16, %15 ], [ %24, %23 ], [ %30, %29 ], [ %34, %33 ], [ %38, %37 ], [ %42, %41 ], [ %.1, %138 ]
  ret i32 %.3
}

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden zeroext i1 @eq_fast(ptr noundef, ptr noundef) local_unnamed_addr #3

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

attributes #0 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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: readwrite) }
attributes #5 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { noreturn 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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !8, i64 0}
!7 = !{!"iovec", !8, i64 0, !11, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!7, !11, i64 8}
!13 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!14 = !{!15, !8, i64 120}
!15 = !{!"MDBX_txn", !16, i64 0, !16, i64 4, !11, i64 8, !11, i64 16, !8, i64 24, !8, i64 32, !17, i64 40, !11, i64 64, !11, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104, !8, i64 112, !8, i64 120, !19, i64 128, !8, i64 160, !9, i64 168}
!16 = !{!"int", !9, i64 0}
!17 = !{!"geo", !18, i64 0, !18, i64 2, !16, i64 4, !16, i64 8, !9, i64 12, !9, i64 16}
!18 = !{!"short", !9, i64 0}
!19 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!20 = !{!8, !8, i64 0}
!21 = !{!22, !8, i64 368}
!22 = !{!"cursor_couple", !23, i64 0, !8, i64 384, !24, i64 392}
!23 = !{!"MDBX_cursor", !16, i64 0, !9, i64 4, !9, i64 6, !9, i64 7, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !9, i64 48, !9, i64 304, !8, i64 368, !8, i64 376}
!24 = !{!"inner_cursor", !23, i64 0, !25, i64 384}
!25 = !{!"tree", !18, i64 0, !18, i64 2, !16, i64 4, !16, i64 8, !16, i64 12, !16, i64 16, !16, i64 20, !11, i64 24, !11, i64 32, !11, i64 40}
!26 = !{i64 0, i64 8, !20, i64 8, i64 8, !27}
!27 = !{!11, !11, i64 0}
!28 = !{!15, !8, i64 88}
!29 = !{!25, !18, i64 0}
!30 = !{!9, !9, i64 0}
!31 = !{!18, !18, i64 0}
!32 = !{!33, !9, i64 25}
!33 = !{!"libmdbx_globals", !9, i64 0, !16, i64 16, !16, i64 20, !9, i64 24, !9, i64 25, !9, i64 26, !34, i64 27, !16, i64 28, !9, i64 32, !9, i64 40, !11, i64 80, !8, i64 88}
!34 = !{!"_Bool", !9, i64 0}
!35 = !{!22, !8, i64 40}
!36 = !{!24, !11, i64 416}
!37 = !{!15, !8, i64 80}
!38 = !{!"branch_weights", !"expected", i32 2145766520, i32 1717128}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LowerExpectIntrinsicPass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass