; LLVM IR from erthink/libmdbx :: src (node)

; 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.node_search_result = type { ptr, i8 }
%struct.iovec = type { ptr, i64 }
%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.anon = type { i8, i8 }
%struct.page = type <{ i64, i16, i16, %union.anon.2, i32, [0 x i16] }>
%union.anon.2 = type { i32 }
%struct.clc2 = type { %struct.clc, %struct.clc }
%struct.clc = type { ptr, i64, i64 }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%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.6 }
%struct.geo = type { i16, i16, i32, i32, %union.anon.4, %union.anon.5 }
%union.anon.4 = type { i32 }
%union.anon.5 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.6 = type { %struct.anon.8 }
%struct.anon.8 = type { %struct.troika, ptr, %struct.anon.9, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.10 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.9 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.10 = type { %struct.anon.11 }
%struct.anon.11 = type { i64, ptr }
%struct.MDBX_env = type { %union.mdbx_atomic_uint32_t, i32, i32, %struct.osal_mmap, i32, i32, %struct.osal_mmap, ptr, i16, i16, i16, i16, i16, i16, %union.mdbx_atomic_uint32_t, i8, i8, i16, i32, i32, i32, i32, %struct.anon.13, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.14, %struct.anon.18, i8, ptr, ptr, ptr, %struct.anon.19, %union.pthread_mutex_t, i32, i32, ptr, %struct.osal_ioring, %union.pthread_mutex_t, [71 x %union.mdbx_atomic_uint64_t] }
%struct.osal_mmap = type { %union.anon.12, i32, i64, i64, i64 }
%union.anon.12 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.13 = type { ptr, ptr, ptr, ptr }
%struct.anon.14 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.15, %union.anon.16 }
%struct.anon.15 = type { i16, i16, i16, i16 }
%union.anon.16 = type { i32 }
%struct.anon.18 = type { i64, i64, i64, i64, i64 }
%struct.anon.19 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, ptr }
%union.mdbx_atomic_uint64_t = type { i64 }

@globals = external global %struct.libmdbx_globals, align 8
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [7 x i8], align 1
@__func__.node_search = external hidden unnamed_addr constant [12 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [140 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [44 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(none)
declare i64 @llvm.expect.i64(i64, i64) #1

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

declare void @debug_log(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #3

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

declare ptr @mdbx_dump_val(ptr noundef, ptr noundef, i64 noundef) #3

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

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

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

; 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 ptr @node_key(ptr noalias noundef) #4

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

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

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

; Function Attrs: hot nounwind uwtable
define dso_local { ptr, i8 } @node_search(ptr noundef %0, ptr noundef %1) #5 {
  %3 = alloca %struct.node_search_result, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca [510 x i8], align 16
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca %struct.iovec, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.MDBX_cursor, ptr %18, i32 0, i32 9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.MDBX_cursor, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %struct.anon, ptr %21, i32 0, i32 1
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = sext i8 %23 to i64
  %25 = getelementptr inbounds [32 x ptr], ptr %19, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  store ptr %26, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call i64 @page_numkeys(ptr noundef %27) #7
  store i64 %28, ptr %7, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 510, ptr %8) #6
  br label %29

29:                                               ; preds = %2
  %30 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !12
  %31 = zext i8 %30 to i32
  %32 = icmp sle i32 5, %31
  %33 = xor i1 %32, true
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = call i64 @llvm.expect.i64(i64 %36, i64 0)
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %52

39:                                               ; preds = %29
  %40 = load i64, ptr %7, align 8, !tbaa !10
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call zeroext i1 @is_leaf(ptr noundef %41) #7
  %43 = zext i1 %42 to i64
  %44 = select i1 %42, ptr @.str.24, ptr @.str.25
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call zeroext i1 @is_subpage(ptr noundef %45) #7
  %47 = zext i1 %46 to i64
  %48 = select i1 %46, ptr @.str.2, ptr @.str.3
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.page, ptr %49, i32 0, i32 4
  %51 = load i32, ptr %50, align 1, !tbaa !16
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.node_search, i32 noundef 294, ptr noundef @.str.44, i64 noundef %40, ptr noundef %44, ptr noundef %48, i32 noundef %51)
  br label %52

52:                                               ; preds = %39, %29
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  %55 = getelementptr inbounds %struct.node_search_result, ptr %3, i32 0, i32 1
  store i8 0, ptr %55, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.page, ptr %56, i32 0, i32 2
  %58 = load i16, ptr %57, align 1, !tbaa !19
  %59 = zext i16 %58 to i32
  %60 = and i32 %59, 1
  %61 = sext i32 %60 to i64
  store i64 %61, ptr %9, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %62 = load i64, ptr %7, align 8, !tbaa !10
  %63 = sub nsw i64 %62, 1
  store i64 %63, ptr %10, align 8, !tbaa !10
  %64 = load i64, ptr %10, align 8, !tbaa !10
  %65 = load i64, ptr %9, align 8, !tbaa !10
  %66 = icmp slt i64 %64, %65
  %67 = xor i1 %66, true
  %68 = xor i1 %67, true
  %69 = zext i1 %68 to i32
  %70 = sext i32 %69 to i64
  %71 = call i64 @llvm.expect.i64(i64 %70, i64 0)
  %72 = icmp ne i64 %71, 0
  br i1 %72, label %73, label %83

73:                                               ; preds = %54
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.MDBX_cursor, ptr %74, i32 0, i32 10
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.MDBX_cursor, ptr %76, i32 0, i32 1
  %78 = getelementptr inbounds %struct.anon, ptr %77, i32 0, i32 1
  %79 = load i8, ptr %78, align 1, !tbaa !9
  %80 = sext i8 %79 to i64
  %81 = getelementptr inbounds [32 x i16], ptr %75, i64 0, i64 %80
  store i16 0, ptr %81, align 2, !tbaa !19
  %82 = getelementptr inbounds %struct.node_search_result, ptr %3, i32 0, i32 0
  store ptr null, ptr %82, align 8, !tbaa !21
  store i32 1, ptr %11, align 4
  br label %439

83:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.MDBX_cursor, ptr %84, i32 0, i32 7
  %86 = load ptr, ptr %85, align 8, !tbaa !22
  %87 = getelementptr inbounds %struct.clc2, ptr %86, i32 0, i32 0
  %88 = getelementptr inbounds %struct.clc, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !24
  store ptr %89, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #6
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = call zeroext i1 @is_dupfix_leaf(ptr noundef %90) #7
  %92 = xor i1 %91, true
  %93 = xor i1 %92, true
  %94 = zext i1 %93 to i32
  %95 = sext i32 %94 to i64
  %96 = call i64 @llvm.expect.i64(i64 %95, i64 0)
  %97 = icmp ne i64 %96, 0
  br i1 %97, label %98, label %275

98:                                               ; preds = %83
  br label %99

99:                                               ; preds = %98
  %100 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !27
  %101 = zext i8 %100 to i32
  %102 = and i32 %101, 1
  %103 = icmp ne i32 %102, 0
  %104 = xor i1 %103, true
  %105 = xor i1 %104, true
  %106 = zext i1 %105 to i32
  %107 = sext i32 %106 to i64
  %108 = call i64 @llvm.expect.i64(i64 %107, i64 1)
  %109 = icmp ne i64 %108, 0
  br i1 %109, label %110, label %138

110:                                              ; preds = %99
  br label %111

111:                                              ; preds = %110
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.page, ptr %112, i32 0, i32 1
  %114 = load i16, ptr %113, align 1, !tbaa !19
  %115 = zext i16 %114 to i32
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.MDBX_cursor, ptr %116, i32 0, i32 6
  %118 = load ptr, ptr %117, align 8, !tbaa !28
  %119 = getelementptr inbounds %struct.tree, ptr %118, i32 0, i32 2
  %120 = load i32, ptr %119, align 4, !tbaa !29
  %121 = icmp eq i32 %115, %120
  %122 = xor i1 %121, true
  %123 = xor i1 %122, true
  %124 = xor i1 %123, true
  %125 = zext i1 %124 to i32
  %126 = sext i32 %125 to i64
  %127 = call i64 @llvm.expect.i64(i64 %126, i64 0)
  %128 = icmp ne i64 %127, 0
  br i1 %128, label %129, label %135

129:                                              ; preds = %111
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.MDBX_cursor, ptr %130, i32 0, i32 5
  %132 = load ptr, ptr %131, align 8, !tbaa !31
  %133 = getelementptr inbounds %struct.MDBX_txn, ptr %132, i32 0, i32 9
  %134 = load ptr, ptr %133, align 8, !tbaa !32
  call void @mdbx_assert_fail(ptr noundef %134, ptr noundef @.str.45, ptr noundef @__func__.node_search, i32 noundef 311) #8
  unreachable

135:                                              ; preds = %111
  br label %136

136:                                              ; preds = %135
  br label %137

137:                                              ; preds = %136
  br label %138

138:                                              ; preds = %137, %99
  br label %139

139:                                              ; preds = %138
  br label %140

140:                                              ; preds = %139
  %141 = load ptr, ptr %6, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.page, ptr %141, i32 0, i32 1
  %143 = load i16, ptr %142, align 1, !tbaa !19
  %144 = zext i16 %143 to i64
  %145 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 1
  store i64 %144, ptr %145, align 8, !tbaa !36
  br label %146

146:                                              ; preds = %248, %140
  %147 = load i64, ptr %9, align 8, !tbaa !10
  %148 = load i64, ptr %10, align 8, !tbaa !10
  %149 = add nsw i64 %147, %148
  %150 = ashr i64 %149, 1
  store i64 %150, ptr %12, align 8, !tbaa !10
  %151 = load ptr, ptr %6, align 8, !tbaa !5
  %152 = load i64, ptr %12, align 8, !tbaa !10
  %153 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 1
  %154 = load i64, ptr %153, align 8, !tbaa !36
  %155 = call ptr @page_dupfix_ptr(ptr noundef %151, i64 noundef %152, i64 noundef %154) #7
  %156 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 0
  store ptr %155, ptr %156, align 8, !tbaa !38
  br label %157

157:                                              ; preds = %146
  %158 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !27
  %159 = zext i8 %158 to i32
  %160 = and i32 %159, 1
  %161 = icmp ne i32 %160, 0
  %162 = xor i1 %161, true
  %163 = xor i1 %162, true
  %164 = zext i1 %163 to i32
  %165 = sext i32 %164 to i64
  %166 = call i64 @llvm.expect.i64(i64 %165, i64 1)
  %167 = icmp ne i64 %166, 0
  br i1 %167, label %168, label %206

168:                                              ; preds = %157
  br label %169

169:                                              ; preds = %168
  %170 = load ptr, ptr %6, align 8, !tbaa !5
  %171 = ptrtoint ptr %170 to i64
  %172 = load ptr, ptr %4, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.MDBX_cursor, ptr %172, i32 0, i32 5
  %174 = load ptr, ptr %173, align 8, !tbaa !31
  %175 = getelementptr inbounds %struct.MDBX_txn, ptr %174, i32 0, i32 9
  %176 = load ptr, ptr %175, align 8, !tbaa !32
  %177 = getelementptr inbounds %struct.MDBX_env, ptr %176, i32 0, i32 2
  %178 = load i32, ptr %177, align 8, !tbaa !39
  %179 = zext i32 %178 to i64
  %180 = add nsw i64 %171, %179
  %181 = inttoptr i64 %180 to ptr
  %182 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 0
  %183 = load ptr, ptr %182, align 8, !tbaa !38
  %184 = ptrtoint ptr %183 to i64
  %185 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 1
  %186 = load i64, ptr %185, align 8, !tbaa !36
  %187 = add nsw i64 %184, %186
  %188 = inttoptr i64 %187 to ptr
  %189 = icmp uge ptr %181, %188
  %190 = xor i1 %189, true
  %191 = xor i1 %190, true
  %192 = xor i1 %191, true
  %193 = zext i1 %192 to i32
  %194 = sext i32 %193 to i64
  %195 = call i64 @llvm.expect.i64(i64 %194, i64 0)
  %196 = icmp ne i64 %195, 0
  br i1 %196, label %197, label %203

197:                                              ; preds = %169
  %198 = load ptr, ptr %4, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.MDBX_cursor, ptr %198, i32 0, i32 5
  %200 = load ptr, ptr %199, align 8, !tbaa !31
  %201 = getelementptr inbounds %struct.MDBX_txn, ptr %200, i32 0, i32 9
  %202 = load ptr, ptr %201, align 8, !tbaa !32
  call void @mdbx_assert_fail(ptr noundef %202, ptr noundef @.str.46, ptr noundef @__func__.node_search, i32 noundef 316) #8
  unreachable

203:                                              ; preds = %169
  br label %204

204:                                              ; preds = %203
  br label %205

205:                                              ; preds = %204
  br label %206

206:                                              ; preds = %205, %157
  br label %207

207:                                              ; preds = %206
  br label %208

208:                                              ; preds = %207
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %209 = load ptr, ptr %13, align 8, !tbaa !5
  %210 = load ptr, ptr %5, align 8, !tbaa !5
  %211 = call i32 %209(ptr noundef %210, ptr noundef %14)
  store i32 %211, ptr %15, align 4, !tbaa !16
  br label %212

212:                                              ; preds = %208
  %213 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !12
  %214 = zext i8 %213 to i32
  %215 = icmp sle i32 5, %214
  %216 = xor i1 %215, true
  %217 = xor i1 %216, true
  %218 = zext i1 %217 to i32
  %219 = sext i32 %218 to i64
  %220 = call i64 @llvm.expect.i64(i64 %219, i64 0)
  %221 = icmp ne i64 %220, 0
  br i1 %221, label %222, label %227

222:                                              ; preds = %212
  %223 = load i64, ptr %12, align 8, !tbaa !10
  %224 = getelementptr inbounds [510 x i8], ptr %8, i64 0, i64 0
  %225 = call ptr @mdbx_dump_val(ptr noundef %14, ptr noundef %224, i64 noundef 255)
  %226 = load i32, ptr %15, align 4, !tbaa !16
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.node_search, i32 noundef 318, ptr noundef @.str.47, i64 noundef %223, ptr noundef %225, i32 noundef %226)
  br label %227

227:                                              ; preds = %222, %212
  br label %228

228:                                              ; preds = %227
  br label %229

229:                                              ; preds = %228
  %230 = load i32, ptr %15, align 4, !tbaa !16
  %231 = icmp sgt i32 %230, 0
  br i1 %231, label %232, label %235

232:                                              ; preds = %229
  %233 = load i64, ptr %12, align 8, !tbaa !10
  %234 = add nsw i64 %233, 1
  store i64 %234, ptr %12, align 8, !tbaa !10
  store i64 %234, ptr %9, align 8, !tbaa !10
  br label %244

235:                                              ; preds = %229
  %236 = load i32, ptr %15, align 4, !tbaa !16
  %237 = icmp slt i32 %236, 0
  br i1 %237, label %238, label %241

238:                                              ; preds = %235
  %239 = load i64, ptr %12, align 8, !tbaa !10
  %240 = sub nsw i64 %239, 1
  store i64 %240, ptr %10, align 8, !tbaa !10
  br label %243

241:                                              ; preds = %235
  %242 = getelementptr inbounds %struct.node_search_result, ptr %3, i32 0, i32 1
  store i8 1, ptr %242, align 8, !tbaa !17
  store i32 8, ptr %11, align 4
  br label %245

243:                                              ; preds = %238
  br label %244

244:                                              ; preds = %243, %232
  store i32 0, ptr %11, align 4
  br label %245

245:                                              ; preds = %244, %241
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  %246 = load i32, ptr %11, align 4
  switch i32 %246, label %441 [
    i32 0, label %247
    i32 8, label %258
  ]

247:                                              ; preds = %245
  br label %248

248:                                              ; preds = %247
  %249 = load i64, ptr %9, align 8, !tbaa !10
  %250 = load i64, ptr %10, align 8, !tbaa !10
  %251 = icmp sle i64 %249, %250
  %252 = xor i1 %251, true
  %253 = xor i1 %252, true
  %254 = zext i1 %253 to i32
  %255 = sext i32 %254 to i64
  %256 = call i64 @llvm.expect.i64(i64 %255, i64 1)
  %257 = icmp ne i64 %256, 0
  br i1 %257, label %146, label %258, !llvm.loop !48

258:                                              ; preds = %248, %245
  %259 = load i64, ptr %12, align 8, !tbaa !10
  %260 = trunc i64 %259 to i16
  %261 = load ptr, ptr %4, align 8, !tbaa !5
  %262 = getelementptr inbounds %struct.MDBX_cursor, ptr %261, i32 0, i32 10
  %263 = load ptr, ptr %4, align 8, !tbaa !5
  %264 = getelementptr inbounds %struct.MDBX_cursor, ptr %263, i32 0, i32 1
  %265 = getelementptr inbounds %struct.anon, ptr %264, i32 0, i32 1
  %266 = load i8, ptr %265, align 1, !tbaa !9
  %267 = sext i8 %266 to i64
  %268 = getelementptr inbounds [32 x i16], ptr %262, i64 0, i64 %267
  store i16 %260, ptr %268, align 2, !tbaa !19
  %269 = load i64, ptr %12, align 8, !tbaa !10
  %270 = load i64, ptr %7, align 8, !tbaa !10
  %271 = icmp slt i64 %269, %270
  %272 = zext i1 %271 to i64
  %273 = select i1 %271, ptr inttoptr (i64 -1 to ptr), ptr null
  %274 = getelementptr inbounds %struct.node_search_result, ptr %3, i32 0, i32 0
  store ptr %273, ptr %274, align 8, !tbaa !21
  store i32 1, ptr %11, align 4
  br label %438

275:                                              ; preds = %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  br label %276

276:                                              ; preds = %406, %275
  %277 = load i64, ptr %9, align 8, !tbaa !10
  %278 = load i64, ptr %10, align 8, !tbaa !10
  %279 = add nsw i64 %277, %278
  %280 = ashr i64 %279, 1
  store i64 %280, ptr %12, align 8, !tbaa !10
  %281 = load ptr, ptr %6, align 8, !tbaa !5
  %282 = load i64, ptr %12, align 8, !tbaa !10
  %283 = call ptr @page_node(ptr noundef %281, i64 noundef %282) #7
  store ptr %283, ptr %16, align 8, !tbaa !5
  %284 = load ptr, ptr %16, align 8, !tbaa !5
  %285 = call i64 @node_ks(ptr noundef %284) #7
  %286 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 1
  store i64 %285, ptr %286, align 8, !tbaa !36
  %287 = load ptr, ptr %16, align 8, !tbaa !5
  %288 = call ptr @node_key(ptr noundef %287) #7
  %289 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 0
  store ptr %288, ptr %289, align 8, !tbaa !38
  br label %290

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

301:                                              ; preds = %290
  br label %302

302:                                              ; preds = %301
  %303 = load ptr, ptr %6, align 8, !tbaa !5
  %304 = ptrtoint ptr %303 to i64
  %305 = load ptr, ptr %4, align 8, !tbaa !5
  %306 = getelementptr inbounds %struct.MDBX_cursor, ptr %305, i32 0, i32 5
  %307 = load ptr, ptr %306, align 8, !tbaa !31
  %308 = getelementptr inbounds %struct.MDBX_txn, ptr %307, i32 0, i32 9
  %309 = load ptr, ptr %308, align 8, !tbaa !32
  %310 = getelementptr inbounds %struct.MDBX_env, ptr %309, i32 0, i32 2
  %311 = load i32, ptr %310, align 8, !tbaa !39
  %312 = zext i32 %311 to i64
  %313 = add nsw i64 %304, %312
  %314 = inttoptr i64 %313 to ptr
  %315 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 0
  %316 = load ptr, ptr %315, align 8, !tbaa !38
  %317 = ptrtoint ptr %316 to i64
  %318 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 1
  %319 = load i64, ptr %318, align 8, !tbaa !36
  %320 = add nsw i64 %317, %319
  %321 = inttoptr i64 %320 to ptr
  %322 = icmp uge ptr %314, %321
  %323 = xor i1 %322, true
  %324 = xor i1 %323, true
  %325 = xor i1 %324, true
  %326 = zext i1 %325 to i32
  %327 = sext i32 %326 to i64
  %328 = call i64 @llvm.expect.i64(i64 %327, i64 0)
  %329 = icmp ne i64 %328, 0
  br i1 %329, label %330, label %336

330:                                              ; preds = %302
  %331 = load ptr, ptr %4, align 8, !tbaa !5
  %332 = getelementptr inbounds %struct.MDBX_cursor, ptr %331, i32 0, i32 5
  %333 = load ptr, ptr %332, align 8, !tbaa !31
  %334 = getelementptr inbounds %struct.MDBX_txn, ptr %333, i32 0, i32 9
  %335 = load ptr, ptr %334, align 8, !tbaa !32
  call void @mdbx_assert_fail(ptr noundef %335, ptr noundef @.str.46, ptr noundef @__func__.node_search, i32 noundef 347) #8
  unreachable

336:                                              ; preds = %302
  br label %337

337:                                              ; preds = %336
  br label %338

338:                                              ; preds = %337
  br label %339

339:                                              ; preds = %338, %290
  br label %340

340:                                              ; preds = %339
  br label %341

341:                                              ; preds = %340
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %342 = load ptr, ptr %13, align 8, !tbaa !5
  %343 = load ptr, ptr %5, align 8, !tbaa !5
  %344 = call i32 %342(ptr noundef %343, ptr noundef %14)
  store i32 %344, ptr %17, align 4, !tbaa !16
  %345 = load ptr, ptr %6, align 8, !tbaa !5
  %346 = call zeroext i1 @is_leaf(ptr noundef %345) #7
  br i1 %346, label %347, label %366

347:                                              ; preds = %341
  br label %348

348:                                              ; preds = %347
  %349 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !12
  %350 = zext i8 %349 to i32
  %351 = icmp sle i32 5, %350
  %352 = xor i1 %351, true
  %353 = xor i1 %352, true
  %354 = zext i1 %353 to i32
  %355 = sext i32 %354 to i64
  %356 = call i64 @llvm.expect.i64(i64 %355, i64 0)
  %357 = icmp ne i64 %356, 0
  br i1 %357, label %358, label %363

358:                                              ; preds = %348
  %359 = load i64, ptr %12, align 8, !tbaa !10
  %360 = getelementptr inbounds [510 x i8], ptr %8, i64 0, i64 0
  %361 = call ptr @mdbx_dump_val(ptr noundef %14, ptr noundef %360, i64 noundef 255)
  %362 = load i32, ptr %17, align 4, !tbaa !16
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.node_search, i32 noundef 350, ptr noundef @.str.47, i64 noundef %359, ptr noundef %361, i32 noundef %362)
  br label %363

363:                                              ; preds = %358, %348
  br label %364

364:                                              ; preds = %363
  br label %365

365:                                              ; preds = %364
  br label %387

366:                                              ; preds = %341
  br label %367

367:                                              ; preds = %366
  %368 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !12
  %369 = zext i8 %368 to i32
  %370 = icmp sle i32 5, %369
  %371 = xor i1 %370, true
  %372 = xor i1 %371, true
  %373 = zext i1 %372 to i32
  %374 = sext i32 %373 to i64
  %375 = call i64 @llvm.expect.i64(i64 %374, i64 0)
  %376 = icmp ne i64 %375, 0
  br i1 %376, label %377, label %384

377:                                              ; preds = %367
  %378 = load i64, ptr %12, align 8, !tbaa !10
  %379 = getelementptr inbounds [510 x i8], ptr %8, i64 0, i64 0
  %380 = call ptr @mdbx_dump_val(ptr noundef %14, ptr noundef %379, i64 noundef 255)
  %381 = load ptr, ptr %16, align 8, !tbaa !5
  %382 = call i32 @node_pgno(ptr noundef %381) #7
  %383 = load i32, ptr %17, align 4, !tbaa !16
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.node_search, i32 noundef 352, ptr noundef @.str.48, i64 noundef %378, ptr noundef %380, i32 noundef %382, i32 noundef %383)
  br label %384

384:                                              ; preds = %377, %367
  br label %385

385:                                              ; preds = %384
  br label %386

386:                                              ; preds = %385
  br label %387

387:                                              ; preds = %386, %365
  %388 = load i32, ptr %17, align 4, !tbaa !16
  %389 = icmp sgt i32 %388, 0
  br i1 %389, label %390, label %393

390:                                              ; preds = %387
  %391 = load i64, ptr %12, align 8, !tbaa !10
  %392 = add nsw i64 %391, 1
  store i64 %392, ptr %12, align 8, !tbaa !10
  store i64 %392, ptr %9, align 8, !tbaa !10
  br label %402

393:                                              ; preds = %387
  %394 = load i32, ptr %17, align 4, !tbaa !16
  %395 = icmp slt i32 %394, 0
  br i1 %395, label %396, label %399

396:                                              ; preds = %393
  %397 = load i64, ptr %12, align 8, !tbaa !10
  %398 = sub nsw i64 %397, 1
  store i64 %398, ptr %10, align 8, !tbaa !10
  br label %401

399:                                              ; preds = %393
  %400 = getelementptr inbounds %struct.node_search_result, ptr %3, i32 0, i32 1
  store i8 1, ptr %400, align 8, !tbaa !17
  store i32 16, ptr %11, align 4
  br label %403

401:                                              ; preds = %396
  br label %402

402:                                              ; preds = %401, %390
  store i32 0, ptr %11, align 4
  br label %403

403:                                              ; preds = %402, %399
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  %404 = load i32, ptr %11, align 4
  switch i32 %404, label %441 [
    i32 0, label %405
    i32 16, label %416
  ]

405:                                              ; preds = %403
  br label %406

406:                                              ; preds = %405
  %407 = load i64, ptr %9, align 8, !tbaa !10
  %408 = load i64, ptr %10, align 8, !tbaa !10
  %409 = icmp sle i64 %407, %408
  %410 = xor i1 %409, true
  %411 = xor i1 %410, true
  %412 = zext i1 %411 to i32
  %413 = sext i32 %412 to i64
  %414 = call i64 @llvm.expect.i64(i64 %413, i64 1)
  %415 = icmp ne i64 %414, 0
  br i1 %415, label %276, label %416, !llvm.loop !50

416:                                              ; preds = %406, %403
  %417 = load i64, ptr %12, align 8, !tbaa !10
  %418 = trunc i64 %417 to i16
  %419 = load ptr, ptr %4, align 8, !tbaa !5
  %420 = getelementptr inbounds %struct.MDBX_cursor, ptr %419, i32 0, i32 10
  %421 = load ptr, ptr %4, align 8, !tbaa !5
  %422 = getelementptr inbounds %struct.MDBX_cursor, ptr %421, i32 0, i32 1
  %423 = getelementptr inbounds %struct.anon, ptr %422, i32 0, i32 1
  %424 = load i8, ptr %423, align 1, !tbaa !9
  %425 = sext i8 %424 to i64
  %426 = getelementptr inbounds [32 x i16], ptr %420, i64 0, i64 %425
  store i16 %418, ptr %426, align 2, !tbaa !19
  %427 = load i64, ptr %12, align 8, !tbaa !10
  %428 = load i64, ptr %7, align 8, !tbaa !10
  %429 = icmp slt i64 %427, %428
  br i1 %429, label %430, label %434

430:                                              ; preds = %416
  %431 = load ptr, ptr %6, align 8, !tbaa !5
  %432 = load i64, ptr %12, align 8, !tbaa !10
  %433 = call ptr @page_node(ptr noundef %431, i64 noundef %432) #7
  br label %435

434:                                              ; preds = %416
  br label %435

435:                                              ; preds = %434, %430
  %436 = phi ptr [ %433, %430 ], [ null, %434 ]
  %437 = getelementptr inbounds %struct.node_search_result, ptr %3, i32 0, i32 0
  store ptr %436, ptr %437, align 8, !tbaa !21
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %438

438:                                              ; preds = %435, %258
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %439

439:                                              ; preds = %438, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 510, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %440 = load { ptr, i8 }, ptr %3, align 8
  ret { ptr, i8 } %440

441:                                              ; preds = %403, %245
  unreachable
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #2 = { 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 #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 = { hot 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !7, i64 26}
!13 = !{!"libmdbx_globals", !7, i64 0, !14, i64 16, !14, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !15, i64 27, !14, i64 28, !7, i64 32, !7, i64 40, !11, i64 80, !6, i64 88}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!18, !15, i64 8}
!18 = !{!"node_search_result", !6, i64 0, !15, i64 8}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!18, !6, i64 0}
!22 = !{!23, !6, i64 32}
!23 = !{!"MDBX_cursor", !14, 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}
!24 = !{!25, !6, i64 0}
!25 = !{!"clc2", !26, i64 0, !26, i64 24}
!26 = !{!"clc", !6, i64 0, !11, i64 8, !11, i64 16}
!27 = !{!13, !7, i64 25}
!28 = !{!23, !6, i64 24}
!29 = !{!30, !14, i64 4}
!30 = !{!"tree", !20, i64 0, !20, i64 2, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !11, i64 24, !11, i64 32, !11, i64 40}
!31 = !{!23, !6, i64 16}
!32 = !{!33, !6, i64 80}
!33 = !{!"MDBX_txn", !14, i64 0, !14, i64 4, !11, i64 8, !11, i64 16, !6, i64 24, !6, i64 32, !34, i64 40, !11, i64 64, !11, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !35, i64 128, !6, i64 160, !7, i64 168}
!34 = !{!"geo", !20, i64 0, !20, i64 2, !14, i64 4, !14, i64 8, !7, i64 12, !7, i64 16}
!35 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!36 = !{!37, !11, i64 8}
!37 = !{!"iovec", !6, i64 0, !11, i64 8}
!38 = !{!37, !6, i64 0}
!39 = !{!40, !14, i64 8}
!40 = !{!"MDBX_env", !7, i64 0, !14, i64 4, !14, i64 8, !41, i64 16, !14, i64 56, !14, i64 60, !41, i64 64, !6, i64 104, !20, i64 112, !20, i64 114, !20, i64 116, !20, i64 118, !20, i64 120, !20, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !20, i64 130, !14, i64 132, !14, i64 136, !14, i64 140, !14, i64 144, !42, i64 152, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !14, i64 224, !14, i64 228, !14, i64 232, !6, i64 240, !6, i64 248, !11, i64 256, !43, i64 264, !45, i64 320, !15, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !46, i64 392, !7, i64 400, !14, i64 440, !14, i64 444, !6, i64 448, !47, i64 456, !7, i64 496, !7, i64 536}
!41 = !{!"osal_mmap", !7, i64 0, !14, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!42 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!43 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !11, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !14, i64 28, !14, i64 32, !15, i64 36, !15, i64 37, !15, i64 38, !44, i64 40, !7, i64 48}
!44 = !{!"", !20, i64 0, !20, i64 2, !20, i64 4, !20, i64 6}
!45 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!46 = !{!"", !11, i64 0}
!47 = !{!"osal_ioring", !14, i64 0, !14, i64 4, !14, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!48 = distinct !{!48, !49}
!49 = !{!"llvm.loop.mustprogress"}
!50 = distinct !{!50, !49}


; 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.iovec = type { ptr, i64 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [7 x i8], align 1
@__func__.node_search = external hidden unnamed_addr constant [12 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [140 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [44 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: noreturn
declare void @mdbx_assert_fail(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @debug_log(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #2

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

declare ptr @mdbx_dump_val(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden ptr @page_dupfix_ptr(ptr noundef, i64 noundef, i64 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) #0

; 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 ptr @node_key(ptr noalias noundef) local_unnamed_addr #3

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

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

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

; Function Attrs: hot nounwind uwtable
define dso_local { ptr, i8 } @node_search(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #4 {
  %3 = alloca [510 x i8], align 16
  %4 = alloca %struct.iovec, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = getelementptr inbounds i8, ptr %0, i64 5
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = sext i8 %7 to i64
  %9 = getelementptr inbounds [32 x ptr], ptr %5, i64 0, i64 %8
  %10 = load ptr, ptr %9, align 8, !tbaa !8
  %11 = tail call i64 @page_numkeys(ptr noundef %10) #5
  call void @llvm.lifetime.start.p0(i64 510, ptr nonnull %3) #6
  %12 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !10
  %13 = icmp ugt i8 %12, 4
  br i1 %13, label %14, label %21, !prof !15

14:                                               ; preds = %2
  %15 = tail call zeroext i1 @is_leaf(ptr noundef %10) #5
  %16 = select i1 %15, ptr @.str.24, ptr @.str.25
  %17 = tail call zeroext i1 @is_subpage(ptr noundef %10) #5
  %18 = select i1 %17, ptr @.str.2, ptr @.str.3
  %19 = getelementptr inbounds i8, ptr %10, i64 16
  %20 = load i32, ptr %19, align 1, !tbaa !16
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.node_search, i32 noundef 294, ptr noundef nonnull @.str.44, i64 noundef %11, ptr noundef nonnull %16, ptr noundef nonnull %18, i32 noundef %20) #6
  br label %21

21:                                               ; preds = %14, %2
  %22 = getelementptr inbounds i8, ptr %10, i64 10
  %23 = load i16, ptr %22, align 1, !tbaa !17
  %24 = and i16 %23, 1
  %25 = zext nneg i16 %24 to i64
  %26 = add nsw i64 %11, -1
  %.not = icmp sgt i64 %11, %25
  br i1 %.not, label %32, label %27, !prof !19

27:                                               ; preds = %21
  %28 = getelementptr inbounds i8, ptr %0, i64 304
  %29 = load i8, ptr %6, align 1, !tbaa !5
  %30 = sext i8 %29 to i64
  %31 = getelementptr inbounds [32 x i16], ptr %28, i64 0, i64 %30
  store i16 0, ptr %31, align 2, !tbaa !17
  br label %151

32:                                               ; preds = %21
  %33 = getelementptr inbounds i8, ptr %0, i64 32
  %34 = load ptr, ptr %33, align 8, !tbaa !20
  %35 = load ptr, ptr %34, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  %36 = tail call zeroext i1 @is_dupfix_leaf(ptr noundef nonnull %10) #5
  br i1 %36, label %40, label %.preheader, !prof !15

.preheader:                                       ; preds = %32
  %37 = getelementptr inbounds i8, ptr %4, i64 8
  %38 = ptrtoint ptr %10 to i64
  %39 = getelementptr inbounds i8, ptr %0, i64 16
  br label %100

40:                                               ; preds = %32
  %41 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !25
  %42 = and i8 %41, 1
  %.not91 = icmp eq i8 %42, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %10, i64 8
  %.pre = load i16, ptr %.phi.trans.insert, align 1, !tbaa !17
  br i1 %.not91, label %._crit_edge, label %43, !prof !15

43:                                               ; preds = %40
  %44 = zext i16 %.pre to i32
  %45 = getelementptr inbounds i8, ptr %0, i64 24
  %46 = load ptr, ptr %45, align 8, !tbaa !26
  %47 = getelementptr inbounds i8, ptr %46, i64 4
  %48 = load i32, ptr %47, align 4, !tbaa !27
  %.not92 = icmp eq i32 %48, %44
  br i1 %.not92, label %._crit_edge, label %49, !prof !19

49:                                               ; preds = %43
  %50 = getelementptr inbounds i8, ptr %0, i64 16
  %51 = load ptr, ptr %50, align 8, !tbaa !29
  %52 = getelementptr inbounds i8, ptr %51, i64 80
  %53 = load ptr, ptr %52, align 8, !tbaa !30
  tail call void @mdbx_assert_fail(ptr noundef %53, ptr noundef nonnull @.str.45, ptr noundef nonnull @__func__.node_search, i32 noundef 311) #7
  unreachable

._crit_edge:                                      ; preds = %40, %43
  %54 = zext i16 %.pre to i64
  %55 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %54, ptr %55, align 8, !tbaa !34
  %56 = ptrtoint ptr %10 to i64
  %57 = getelementptr inbounds i8, ptr %0, i64 16
  br label %58

58:                                               ; preds = %92, %._crit_edge
  %.072 = phi i64 [ %26, %._crit_edge ], [ %.274, %92 ]
  %.0 = phi i64 [ %25, %._crit_edge ], [ %.2, %92 ]
  %59 = add nuw nsw i64 %.0, %.072
  %60 = lshr i64 %59, 1
  %61 = load i64, ptr %55, align 8, !tbaa !34
  %62 = call ptr @page_dupfix_ptr(ptr noundef %10, i64 noundef %60, i64 noundef %61) #5
  store ptr %62, ptr %4, align 8, !tbaa !36
  %63 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !25
  %64 = and i8 %63, 1
  %.not93 = icmp eq i8 %64, 0
  br i1 %.not93, label %78, label %65, !prof !15

65:                                               ; preds = %58
  %66 = load ptr, ptr %57, align 8, !tbaa !29
  %67 = getelementptr inbounds i8, ptr %66, i64 80
  %68 = load ptr, ptr %67, align 8, !tbaa !30
  %69 = getelementptr inbounds i8, ptr %68, i64 8
  %70 = load i32, ptr %69, align 8, !tbaa !37
  %71 = zext i32 %70 to i64
  %72 = add nsw i64 %71, %56
  %73 = inttoptr i64 %72 to ptr
  %74 = ptrtoint ptr %62 to i64
  %75 = add nsw i64 %61, %74
  %76 = inttoptr i64 %75 to ptr
  %.not94 = icmp ult ptr %73, %76
  br i1 %.not94, label %77, label %78, !prof !15

77:                                               ; preds = %65
  call void @mdbx_assert_fail(ptr noundef nonnull %68, ptr noundef nonnull @.str.46, ptr noundef nonnull @__func__.node_search, i32 noundef 316) #7
  unreachable

78:                                               ; preds = %65, %58
  %79 = call i32 %35(ptr noundef %1, ptr noundef nonnull %4) #6
  %80 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !10
  %81 = icmp ugt i8 %80, 4
  br i1 %81, label %82, label %84, !prof !15

82:                                               ; preds = %78
  %83 = call ptr @mdbx_dump_val(ptr noundef nonnull %4, ptr noundef nonnull %3, i64 noundef 255) #6
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.node_search, i32 noundef 318, ptr noundef nonnull @.str.47, i64 noundef %60, ptr noundef %83, i32 noundef %79) #6
  br label %84

84:                                               ; preds = %82, %78
  %85 = icmp sgt i32 %79, 0
  br i1 %85, label %86, label %88

86:                                               ; preds = %84
  %87 = add nuw nsw i64 %60, 1
  br label %92

88:                                               ; preds = %84
  %89 = icmp slt i32 %79, 0
  br i1 %89, label %90, label %.thread

90:                                               ; preds = %88
  %91 = add nsw i64 %60, -1
  br label %92

92:                                               ; preds = %86, %90
  %.179 = phi i64 [ %87, %86 ], [ %60, %90 ]
  %.274 = phi i64 [ %.072, %86 ], [ %91, %90 ]
  %.2 = phi i64 [ %87, %86 ], [ %.0, %90 ]
  %.not95 = icmp sgt i64 %.2, %.274
  br i1 %.not95, label %.thread, label %58, !prof !46, !llvm.loop !47

.thread:                                          ; preds = %88, %92
  %.sroa.4.1108 = phi i8 [ 0, %92 ], [ 1, %88 ]
  %.179107 = phi i64 [ %.179, %92 ], [ %60, %88 ]
  %93 = trunc i64 %.179107 to i16
  %94 = getelementptr inbounds i8, ptr %0, i64 304
  %95 = load i8, ptr %6, align 1, !tbaa !5
  %96 = sext i8 %95 to i64
  %97 = getelementptr inbounds [32 x i16], ptr %94, i64 0, i64 %96
  store i16 %93, ptr %97, align 2, !tbaa !17
  %98 = icmp slt i64 %.179107, %11
  %99 = select i1 %98, ptr inttoptr (i64 -1 to ptr), ptr null
  br label %150

100:                                              ; preds = %.preheader, %141
  %.375 = phi i64 [ %.577, %141 ], [ %26, %.preheader ]
  %.3 = phi i64 [ %.5, %141 ], [ %25, %.preheader ]
  %101 = add nuw nsw i64 %.3, %.375
  %102 = lshr i64 %101, 1
  %103 = call ptr @page_node(ptr noundef %10, i64 noundef %102) #5
  %104 = call i64 @node_ks(ptr noundef %103) #5
  store i64 %104, ptr %37, align 8, !tbaa !34
  %105 = call ptr @node_key(ptr noundef %103) #5
  store ptr %105, ptr %4, align 8, !tbaa !36
  %106 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !25
  %107 = and i8 %106, 1
  %.not88 = icmp eq i8 %107, 0
  br i1 %.not88, label %121, label %108, !prof !15

108:                                              ; preds = %100
  %109 = load ptr, ptr %39, align 8, !tbaa !29
  %110 = getelementptr inbounds i8, ptr %109, i64 80
  %111 = load ptr, ptr %110, align 8, !tbaa !30
  %112 = getelementptr inbounds i8, ptr %111, i64 8
  %113 = load i32, ptr %112, align 8, !tbaa !37
  %114 = zext i32 %113 to i64
  %115 = add nsw i64 %114, %38
  %116 = inttoptr i64 %115 to ptr
  %117 = ptrtoint ptr %105 to i64
  %118 = add nsw i64 %104, %117
  %119 = inttoptr i64 %118 to ptr
  %.not89 = icmp ult ptr %116, %119
  br i1 %.not89, label %120, label %121, !prof !15

120:                                              ; preds = %108
  call void @mdbx_assert_fail(ptr noundef nonnull %111, ptr noundef nonnull @.str.46, ptr noundef nonnull @__func__.node_search, i32 noundef 347) #7
  unreachable

121:                                              ; preds = %108, %100
  %122 = call i32 %35(ptr noundef %1, ptr noundef nonnull %4) #6
  %123 = call zeroext i1 @is_leaf(ptr noundef %10) #5
  %124 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !10
  %125 = icmp ugt i8 %124, 4
  br i1 %123, label %126, label %129

126:                                              ; preds = %121
  br i1 %125, label %127, label %133, !prof !15

127:                                              ; preds = %126
  %128 = call ptr @mdbx_dump_val(ptr noundef nonnull %4, ptr noundef nonnull %3, i64 noundef 255) #6
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.node_search, i32 noundef 350, ptr noundef nonnull @.str.47, i64 noundef %102, ptr noundef %128, i32 noundef %122) #6
  br label %133

129:                                              ; preds = %121
  br i1 %125, label %130, label %133, !prof !15

130:                                              ; preds = %129
  %131 = call ptr @mdbx_dump_val(ptr noundef nonnull %4, ptr noundef nonnull %3, i64 noundef 255) #6
  %132 = call i32 @node_pgno(ptr noundef %103) #5
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.node_search, i32 noundef 352, ptr noundef nonnull @.str.48, i64 noundef %102, ptr noundef %131, i32 noundef %132, i32 noundef %122) #6
  br label %133

133:                                              ; preds = %129, %130, %126, %127
  %134 = icmp sgt i32 %122, 0
  br i1 %134, label %135, label %137

135:                                              ; preds = %133
  %136 = add nuw nsw i64 %102, 1
  br label %141

137:                                              ; preds = %133
  %138 = icmp slt i32 %122, 0
  br i1 %138, label %139, label %.thread109

139:                                              ; preds = %137
  %140 = add nsw i64 %102, -1
  br label %141

141:                                              ; preds = %135, %139
  %.381 = phi i64 [ %136, %135 ], [ %102, %139 ]
  %.577 = phi i64 [ %.375, %135 ], [ %140, %139 ]
  %.5 = phi i64 [ %136, %135 ], [ %.3, %139 ]
  %.not90 = icmp sgt i64 %.5, %.577
  br i1 %.not90, label %.thread109, label %100, !prof !46, !llvm.loop !49

.thread109:                                       ; preds = %137, %141
  %.sroa.4.3119 = phi i8 [ 0, %141 ], [ 1, %137 ]
  %.381118 = phi i64 [ %.381, %141 ], [ %102, %137 ]
  %142 = trunc i64 %.381118 to i16
  %143 = getelementptr inbounds i8, ptr %0, i64 304
  %144 = load i8, ptr %6, align 1, !tbaa !5
  %145 = sext i8 %144 to i64
  %146 = getelementptr inbounds [32 x i16], ptr %143, i64 0, i64 %145
  store i16 %142, ptr %146, align 2, !tbaa !17
  %147 = icmp slt i64 %.381118, %11
  br i1 %147, label %148, label %150

148:                                              ; preds = %.thread109
  %149 = call ptr @page_node(ptr noundef %10, i64 noundef %.381118) #5
  br label %150

150:                                              ; preds = %148, %.thread109, %.thread
  %.sroa.0.0 = phi ptr [ %99, %.thread ], [ %149, %148 ], [ null, %.thread109 ]
  %.sroa.4.4 = phi i8 [ %.sroa.4.1108, %.thread ], [ %.sroa.4.3119, %148 ], [ %.sroa.4.3119, %.thread109 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  br label %151

151:                                              ; preds = %150, %27
  %.sroa.0.1 = phi ptr [ null, %27 ], [ %.sroa.0.0, %150 ]
  %.sroa.4.5 = phi i8 [ 0, %27 ], [ %.sroa.4.4, %150 ]
  call void @llvm.lifetime.end.p0(i64 510, ptr nonnull %3) #6
  %.fca.0.insert = insertvalue { ptr, i8 } poison, ptr %.sroa.0.1, 0
  %.fca.1.insert = insertvalue { ptr, i8 } %.fca.0.insert, i8 %.sroa.4.5, 1
  ret { ptr, i8 } %.fca.1.insert
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { hot 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 willreturn memory(read) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !6, i64 26}
!11 = !{!"libmdbx_globals", !6, i64 0, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 25, !6, i64 26, !13, i64 27, !12, i64 28, !6, i64 32, !6, i64 40, !14, i64 80, !9, i64 88}
!12 = !{!"int", !6, i64 0}
!13 = !{!"_Bool", !6, i64 0}
!14 = !{!"long", !6, i64 0}
!15 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!16 = !{!12, !12, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !6, i64 0}
!19 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!20 = !{!21, !9, i64 32}
!21 = !{!"MDBX_cursor", !12, i64 0, !6, i64 4, !6, i64 6, !6, i64 7, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !9, i64 40, !6, i64 48, !6, i64 304, !9, i64 368, !9, i64 376}
!22 = !{!23, !9, i64 0}
!23 = !{!"clc2", !24, i64 0, !24, i64 24}
!24 = !{!"clc", !9, i64 0, !14, i64 8, !14, i64 16}
!25 = !{!11, !6, i64 25}
!26 = !{!21, !9, i64 24}
!27 = !{!28, !12, i64 4}
!28 = !{!"tree", !18, i64 0, !18, i64 2, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !14, i64 24, !14, i64 32, !14, i64 40}
!29 = !{!21, !9, i64 16}
!30 = !{!31, !9, i64 80}
!31 = !{!"MDBX_txn", !12, i64 0, !12, i64 4, !14, i64 8, !14, i64 16, !9, i64 24, !9, i64 32, !32, i64 40, !14, i64 64, !14, i64 72, !9, i64 80, !9, i64 88, !9, i64 96, !9, i64 104, !9, i64 112, !9, i64 120, !33, i64 128, !9, i64 160, !6, i64 168}
!32 = !{!"geo", !18, i64 0, !18, i64 2, !12, i64 4, !12, i64 8, !6, i64 12, !6, i64 16}
!33 = !{!"MDBX_canary", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!34 = !{!35, !14, i64 8}
!35 = !{!"iovec", !9, i64 0, !14, i64 8}
!36 = !{!35, !9, i64 0}
!37 = !{!38, !12, i64 8}
!38 = !{!"MDBX_env", !6, i64 0, !12, i64 4, !12, i64 8, !39, i64 16, !12, i64 56, !12, i64 60, !39, i64 64, !9, i64 104, !18, i64 112, !18, i64 114, !18, i64 116, !18, i64 118, !18, i64 120, !18, i64 122, !6, i64 124, !6, i64 128, !6, i64 129, !18, i64 130, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !40, i64 152, !9, i64 184, !9, i64 192, !9, i64 200, !9, i64 208, !9, i64 216, !12, i64 224, !12, i64 228, !12, i64 232, !9, i64 240, !9, i64 248, !14, i64 256, !41, i64 264, !43, i64 320, !13, i64 360, !9, i64 368, !9, i64 376, !9, i64 384, !44, i64 392, !6, i64 400, !12, i64 440, !12, i64 444, !9, i64 448, !45, i64 456, !6, i64 496, !6, i64 536}
!39 = !{!"osal_mmap", !6, i64 0, !12, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!40 = !{!"", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24}
!41 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !14, i64 16, !6, i64 24, !6, i64 25, !6, i64 26, !6, i64 27, !12, i64 28, !12, i64 32, !13, i64 36, !13, i64 37, !13, i64 38, !42, i64 40, !6, i64 48}
!42 = !{!"", !18, i64 0, !18, i64 2, !18, i64 4, !18, i64 6}
!43 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!44 = !{!"", !14, i64 0}
!45 = !{!"osal_ioring", !12, i64 0, !12, i64 4, !12, i64 8, !9, i64 16, !9, i64 24, !9, i64 32}
!46 = !{!"branch_weights", i32 745746216, i32 1401737432}
!47 = distinct !{!47, !48}
!48 = !{!"llvm.loop.mustprogress"}
!49 = distinct !{!49, !48}


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