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

; 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 }
%struct.anon = 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.node_search_result = type { ptr, 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.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.11, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.12, %struct.anon.16, i8, ptr, ptr, ptr, %struct.anon.17, %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.10, i32, i64, i64, i64 }
%union.anon.10 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.11 = type { ptr, ptr, ptr, ptr }
%struct.anon.12 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.13, %union.anon.14 }
%struct.anon.13 = type { i16, i16, i16, i16 }
%union.anon.14 = type { i32 }
%struct.anon.16 = type { i64, i64, i64, i64, i64 }
%struct.anon.17 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, ptr }
%union.mdbx_atomic_uint64_t = type { i64 }
%struct.kvx = type { %struct.clc2, %struct.iovec }
%struct.clc2 = type { %struct.clc, %struct.clc }
%struct.clc = type { ptr, i64, i64 }
%struct.anon.1 = type { i8, i8 }
%struct.page = type <{ i64, i16, i16, %union.anon.18, i32, [0 x i16] }>
%union.anon.18 = type { i32 }

@globals = external global %struct.libmdbx_globals, align 8
@__func__.tbl_fetch = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [39 x i8], align 1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @tbl_fetch(ptr noundef %0, i64 noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca %struct.cursor_couple, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %struct.iovec, align 8
  %11 = alloca %struct.node_search_result, align 8
  %12 = alloca i16, align 2
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 824, ptr %6) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  %15 = getelementptr inbounds %struct.cursor_couple, ptr %6, i32 0, i32 0
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call i32 @cursor_init(ptr noundef %15, ptr noundef %16, i64 noundef 1)
  store i32 %17, ptr %7, align 4, !tbaa !11
  %18 = load i32, ptr %7, align 4, !tbaa !11
  %19 = icmp ne i32 %18, 0
  %20 = xor i1 %19, true
  %21 = xor i1 %20, true
  %22 = zext i1 %21 to i32
  %23 = sext i32 %22 to i64
  %24 = call i64 @llvm.expect.i64(i64 %23, i64 0)
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %2
  %27 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %27, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %388

28:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.MDBX_txn, ptr %29, i32 0, i32 9
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds %struct.MDBX_env, ptr %31, i32 0, i32 25
  %33 = load ptr, ptr %32, align 8, !tbaa !18
  %34 = load i64, ptr %5, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.kvx, ptr %33, i64 %34
  store ptr %35, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.cursor_couple, ptr %6, i32 0, i32 0
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.kvx, ptr %37, i32 0, i32 1
  %39 = call i32 @tree_search(ptr noundef %36, ptr noundef %38, i32 noundef 0)
  store i32 %39, ptr %7, align 4, !tbaa !11
  %40 = load i32, ptr %7, align 4, !tbaa !11
  %41 = icmp ne i32 %40, 0
  %42 = xor i1 %41, true
  %43 = xor i1 %42, true
  %44 = zext i1 %43 to i32
  %45 = sext i32 %44 to i64
  %46 = call i64 @llvm.expect.i64(i64 %45, i64 0)
  %47 = icmp ne i64 %46, 0
  br i1 %47, label %48, label %85

48:                                               ; preds = %28
  br label %49

49:                                               ; preds = %104, %48
  br label %50

50:                                               ; preds = %49
  %51 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !28
  %52 = zext i8 %51 to i32
  %53 = icmp sle i32 3, %52
  %54 = xor i1 %53, true
  %55 = xor i1 %54, true
  %56 = zext i1 %55 to i32
  %57 = sext i32 %56 to i64
  %58 = call i64 @llvm.expect.i64(i64 %57, i64 0)
  %59 = icmp ne i64 %58, 0
  br i1 %59, label %60, label %75

60:                                               ; preds = %50
  %61 = load i64, ptr %5, align 8, !tbaa !9
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.kvx, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.iovec, ptr %63, i32 0, i32 1
  %65 = load i64, ptr %64, align 8, !tbaa !30
  %66 = trunc i64 %65 to i32
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.kvx, ptr %67, i32 0, i32 1
  %69 = getelementptr inbounds %struct.iovec, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !35
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.MDBX_txn, ptr %71, i32 0, i32 7
  %73 = load i64, ptr %72, align 8, !tbaa !36
  %74 = load i32, ptr %7, align 4, !tbaa !11
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef @__func__.tbl_fetch, i32 noundef 51, ptr noundef @.str.4, i64 noundef %61, i32 noundef %66, ptr noundef %70, i64 noundef %73, i32 noundef %74)
  br label %75

75:                                               ; preds = %60, %50
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %7, align 4, !tbaa !11
  %79 = icmp eq i32 %78, -30798
  br i1 %79, label %80, label %81

80:                                               ; preds = %77
  br label %83

81:                                               ; preds = %77
  %82 = load i32, ptr %7, align 4, !tbaa !11
  br label %83

83:                                               ; preds = %81, %80
  %84 = phi i32 [ -30780, %80 ], [ %82, %81 ]
  store i32 %84, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

85:                                               ; preds = %28
  %86 = getelementptr inbounds %struct.cursor_couple, ptr %6, i32 0, i32 0
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.kvx, ptr %87, i32 0, i32 1
  %89 = call { ptr, i8 } @node_search(ptr noundef %86, ptr noundef %88)
  %90 = getelementptr inbounds { ptr, i8 }, ptr %11, i32 0, i32 0
  %91 = extractvalue { ptr, i8 } %89, 0
  store ptr %91, ptr %90, align 8
  %92 = getelementptr inbounds { ptr, i8 }, ptr %11, i32 0, i32 1
  %93 = extractvalue { ptr, i8 } %89, 1
  store i8 %93, ptr %92, align 8
  %94 = getelementptr inbounds %struct.node_search_result, ptr %11, i32 0, i32 1
  %95 = load i8, ptr %94, align 8, !tbaa !37, !range !39, !noundef !40
  %96 = trunc i8 %95 to i1
  %97 = xor i1 %96, true
  %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 %105

104:                                              ; preds = %85
  store i32 -30798, ptr %7, align 4, !tbaa !11
  br label %49

105:                                              ; preds = %85
  %106 = getelementptr inbounds %struct.node_search_result, ptr %11, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !41
  %108 = call zeroext i8 @node_flags(ptr noundef %107) #9
  %109 = zext i8 %108 to i32
  %110 = and i32 %109, 6
  %111 = icmp ne i32 %110, 2
  %112 = xor i1 %111, true
  %113 = xor i1 %112, true
  %114 = zext i1 %113 to i32
  %115 = sext i32 %114 to i64
  %116 = call i64 @llvm.expect.i64(i64 %115, i64 0)
  %117 = icmp ne i64 %116, 0
  br i1 %117, label %118, label %146

118:                                              ; preds = %105
  br label %119

119:                                              ; preds = %118
  %120 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !28
  %121 = zext i8 %120 to i32
  %122 = icmp sle i32 3, %121
  %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 %143

129:                                              ; preds = %119
  %130 = load i64, ptr %5, align 8, !tbaa !9
  %131 = load ptr, ptr %9, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.kvx, ptr %131, i32 0, i32 1
  %133 = getelementptr inbounds %struct.iovec, ptr %132, i32 0, i32 1
  %134 = load i64, ptr %133, align 8, !tbaa !30
  %135 = trunc i64 %134 to i32
  %136 = load ptr, ptr %9, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.kvx, ptr %136, i32 0, i32 1
  %138 = getelementptr inbounds %struct.iovec, ptr %137, i32 0, i32 0
  %139 = load ptr, ptr %138, align 8, !tbaa !35
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.MDBX_txn, ptr %140, i32 0, i32 7
  %142 = load i64, ptr %141, align 8, !tbaa !36
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef @__func__.tbl_fetch, i32 noundef 63, ptr noundef @.str.5, i64 noundef %130, i32 noundef %135, ptr noundef %139, i64 noundef %142, ptr noundef @.str.6)
  br label %143

143:                                              ; preds = %129, %119
  br label %144

144:                                              ; preds = %143
  br label %145

145:                                              ; preds = %144
  store i32 -30784, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

146:                                              ; preds = %105
  %147 = getelementptr inbounds %struct.cursor_couple, ptr %6, i32 0, i32 0
  %148 = getelementptr inbounds %struct.node_search_result, ptr %11, i32 0, i32 0
  %149 = load ptr, ptr %148, align 8, !tbaa !41
  %150 = getelementptr inbounds %struct.cursor_couple, ptr %6, i32 0, i32 0
  %151 = getelementptr inbounds %struct.MDBX_cursor, ptr %150, i32 0, i32 9
  %152 = getelementptr inbounds %struct.cursor_couple, ptr %6, i32 0, i32 0
  %153 = getelementptr inbounds %struct.MDBX_cursor, ptr %152, i32 0, i32 1
  %154 = getelementptr inbounds %struct.anon.1, ptr %153, i32 0, i32 1
  %155 = load i8, ptr %154, align 1, !tbaa !42
  %156 = sext i8 %155 to i64
  %157 = getelementptr inbounds [32 x ptr], ptr %151, i64 0, i64 %156
  %158 = load ptr, ptr %157, align 8, !tbaa !5
  %159 = call i32 @node_read(ptr noundef %147, ptr noundef %149, ptr noundef %10, ptr noundef %158)
  store i32 %159, ptr %7, align 4, !tbaa !11
  %160 = load i32, ptr %7, align 4, !tbaa !11
  %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 0)
  %167 = icmp ne i64 %166, 0
  br i1 %167, label %168, label %170

168:                                              ; preds = %146
  %169 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %169, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

170:                                              ; preds = %146
  %171 = getelementptr inbounds %struct.iovec, ptr %10, i32 0, i32 1
  %172 = load i64, ptr %171, align 8, !tbaa !43
  %173 = icmp ne i64 %172, 48
  %174 = xor i1 %173, true
  %175 = xor i1 %174, true
  %176 = zext i1 %175 to i32
  %177 = sext i32 %176 to i64
  %178 = call i64 @llvm.expect.i64(i64 %177, i64 0)
  %179 = icmp ne i64 %178, 0
  br i1 %179, label %180, label %208

180:                                              ; preds = %170
  br label %181

181:                                              ; preds = %180
  %182 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !28
  %183 = zext i8 %182 to i32
  %184 = icmp sle i32 3, %183
  %185 = xor i1 %184, true
  %186 = xor i1 %185, true
  %187 = zext i1 %186 to i32
  %188 = sext i32 %187 to i64
  %189 = call i64 @llvm.expect.i64(i64 %188, i64 0)
  %190 = icmp ne i64 %189, 0
  br i1 %190, label %191, label %205

191:                                              ; preds = %181
  %192 = load i64, ptr %5, align 8, !tbaa !9
  %193 = load ptr, ptr %9, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.kvx, ptr %193, i32 0, i32 1
  %195 = getelementptr inbounds %struct.iovec, ptr %194, i32 0, i32 1
  %196 = load i64, ptr %195, align 8, !tbaa !30
  %197 = trunc i64 %196 to i32
  %198 = load ptr, ptr %9, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.kvx, ptr %198, i32 0, i32 1
  %200 = getelementptr inbounds %struct.iovec, ptr %199, i32 0, i32 0
  %201 = load ptr, ptr %200, align 8, !tbaa !35
  %202 = load ptr, ptr %4, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.MDBX_txn, ptr %202, i32 0, i32 7
  %204 = load i64, ptr %203, align 8, !tbaa !36
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef @__func__.tbl_fetch, i32 noundef 73, ptr noundef @.str.5, i64 noundef %192, i32 noundef %197, ptr noundef %201, i64 noundef %204, ptr noundef @.str.7)
  br label %205

205:                                              ; preds = %191, %181
  br label %206

206:                                              ; preds = %205
  br label %207

207:                                              ; preds = %206
  store i32 -30784, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

208:                                              ; preds = %170
  %209 = getelementptr inbounds %struct.iovec, ptr %10, i32 0, i32 0
  %210 = load ptr, ptr %209, align 8, !tbaa !44
  %211 = ptrtoint ptr %210 to i64
  %212 = add nsw i64 %211, 0
  %213 = inttoptr i64 %212 to ptr
  %214 = call zeroext i16 @unaligned_peek_u16(i64 noundef 1, ptr noundef %213) #9
  store i16 %214, ptr %12, align 2, !tbaa !45
  %215 = load ptr, ptr %4, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.MDBX_txn, ptr %215, i32 0, i32 10
  %217 = load ptr, ptr %216, align 8, !tbaa !46
  %218 = load i64, ptr %5, align 8, !tbaa !9
  %219 = getelementptr inbounds %struct.tree, ptr %217, i64 %218
  store ptr %219, ptr %13, align 8, !tbaa !5
  %220 = load ptr, ptr %13, align 8, !tbaa !5
  %221 = getelementptr inbounds %struct.tree, ptr %220, i32 0, i32 0
  %222 = load i16, ptr %221, align 4, !tbaa !47
  %223 = zext i16 %222 to i32
  %224 = and i32 %223, 126
  %225 = load i16, ptr %12, align 2, !tbaa !45
  %226 = zext i16 %225 to i32
  %227 = icmp ne i32 %224, %226
  %228 = xor i1 %227, true
  %229 = xor i1 %228, true
  %230 = zext i1 %229 to i32
  %231 = sext i32 %230 to i64
  %232 = call i64 @llvm.expect.i64(i64 %231, i64 0)
  %233 = icmp ne i64 %232, 0
  br i1 %233, label %234, label %269

234:                                              ; preds = %208
  br label %235

235:                                              ; preds = %234
  %236 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !28
  %237 = zext i8 %236 to i32
  %238 = icmp sle i32 3, %237
  %239 = xor i1 %238, true
  %240 = xor i1 %239, true
  %241 = zext i1 %240 to i32
  %242 = sext i32 %241 to i64
  %243 = call i64 @llvm.expect.i64(i64 %242, i64 0)
  %244 = icmp ne i64 %243, 0
  br i1 %244, label %245, label %266

245:                                              ; preds = %235
  %246 = load i64, ptr %5, align 8, !tbaa !9
  %247 = load ptr, ptr %9, align 8, !tbaa !5
  %248 = getelementptr inbounds %struct.kvx, ptr %247, i32 0, i32 1
  %249 = getelementptr inbounds %struct.iovec, ptr %248, i32 0, i32 1
  %250 = load i64, ptr %249, align 8, !tbaa !30
  %251 = trunc i64 %250 to i32
  %252 = load ptr, ptr %9, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.kvx, ptr %252, i32 0, i32 1
  %254 = getelementptr inbounds %struct.iovec, ptr %253, i32 0, i32 0
  %255 = load ptr, ptr %254, align 8, !tbaa !35
  %256 = load ptr, ptr %4, align 8, !tbaa !5
  %257 = getelementptr inbounds %struct.MDBX_txn, ptr %256, i32 0, i32 7
  %258 = load i64, ptr %257, align 8, !tbaa !36
  %259 = load ptr, ptr %13, align 8, !tbaa !5
  %260 = getelementptr inbounds %struct.tree, ptr %259, i32 0, i32 0
  %261 = load i16, ptr %260, align 4, !tbaa !47
  %262 = zext i16 %261 to i32
  %263 = and i32 %262, 126
  %264 = load i16, ptr %12, align 2, !tbaa !45
  %265 = zext i16 %264 to i32
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef @__func__.tbl_fetch, i32 noundef 85, ptr noundef @.str.8, i64 noundef %246, i32 noundef %251, ptr noundef %255, i64 noundef %258, i32 noundef %263, i32 noundef %265)
  br label %266

266:                                              ; preds = %245, %235
  br label %267

267:                                              ; preds = %266
  br label %268

268:                                              ; preds = %267
  store i32 -30784, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

269:                                              ; preds = %208
  %270 = load ptr, ptr %13, align 8, !tbaa !5
  %271 = getelementptr inbounds %struct.iovec, ptr %10, i32 0, i32 0
  %272 = load ptr, ptr %271, align 8, !tbaa !44
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %270, ptr align 1 %272, i64 48, i1 false)
  %273 = getelementptr inbounds %struct.cursor_couple, ptr %6, i32 0, i32 0
  %274 = getelementptr inbounds %struct.MDBX_cursor, ptr %273, i32 0, i32 9
  %275 = getelementptr inbounds %struct.cursor_couple, ptr %6, i32 0, i32 0
  %276 = getelementptr inbounds %struct.MDBX_cursor, ptr %275, i32 0, i32 1
  %277 = getelementptr inbounds %struct.anon.1, ptr %276, i32 0, i32 1
  %278 = load i8, ptr %277, align 1, !tbaa !42
  %279 = sext i8 %278 to i64
  %280 = getelementptr inbounds [32 x ptr], ptr %274, i64 0, i64 %279
  %281 = load ptr, ptr %280, align 8, !tbaa !5
  %282 = getelementptr inbounds %struct.page, ptr %281, i32 0, i32 0
  %283 = load i64, ptr %282, align 1, !tbaa !9
  store i64 %283, ptr %14, align 8, !tbaa !9
  br label %284

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

295:                                              ; preds = %284
  br label %296

296:                                              ; preds = %295
  %297 = load ptr, ptr %4, align 8, !tbaa !5
  %298 = getelementptr inbounds %struct.MDBX_txn, ptr %297, i32 0, i32 8
  %299 = load i64, ptr %298, align 8, !tbaa !50
  %300 = load i64, ptr %14, align 8, !tbaa !9
  %301 = icmp uge i64 %299, %300
  %302 = xor i1 %301, true
  %303 = xor i1 %302, true
  %304 = xor i1 %303, true
  %305 = zext i1 %304 to i32
  %306 = sext i32 %305 to i64
  %307 = call i64 @llvm.expect.i64(i64 %306, i64 0)
  %308 = icmp ne i64 %307, 0
  br i1 %308, label %309, label %313

309:                                              ; preds = %296
  %310 = load ptr, ptr %4, align 8, !tbaa !5
  %311 = getelementptr inbounds %struct.MDBX_txn, ptr %310, i32 0, i32 9
  %312 = load ptr, ptr %311, align 8, !tbaa !13
  call void @mdbx_assert_fail(ptr noundef %312, ptr noundef @.str.9, ptr noundef @__func__.tbl_fetch, i32 noundef 92) #10
  unreachable

313:                                              ; preds = %296
  br label %314

314:                                              ; preds = %313
  br label %315

315:                                              ; preds = %314
  br label %316

316:                                              ; preds = %315, %284
  br label %317

317:                                              ; preds = %316
  br label %318

318:                                              ; preds = %317
  %319 = load ptr, ptr %13, align 8, !tbaa !5
  %320 = getelementptr inbounds %struct.tree, ptr %319, i32 0, i32 9
  %321 = load i64, ptr %320, align 4, !tbaa !51
  %322 = load i64, ptr %14, align 8, !tbaa !9
  %323 = icmp ugt i64 %321, %322
  %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 %349

330:                                              ; preds = %318
  br label %331

331:                                              ; preds = %330
  %332 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !28
  %333 = zext i8 %332 to i32
  %334 = icmp sle i32 1, %333
  %335 = xor i1 %334, true
  %336 = xor i1 %335, true
  %337 = zext i1 %336 to i32
  %338 = sext i32 %337 to i64
  %339 = call i64 @llvm.expect.i64(i64 %338, i64 0)
  %340 = icmp ne i64 %339, 0
  br i1 %340, label %341, label %346

341:                                              ; preds = %331
  %342 = load ptr, ptr %13, align 8, !tbaa !5
  %343 = getelementptr inbounds %struct.tree, ptr %342, i32 0, i32 9
  %344 = load i64, ptr %343, align 4, !tbaa !51
  %345 = load i64, ptr %14, align 8, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.tbl_fetch, i32 noundef 94, ptr noundef @.str.10, i64 noundef %344, i64 noundef %345)
  br label %346

346:                                              ; preds = %341, %331
  br label %347

347:                                              ; preds = %346
  br label %348

348:                                              ; preds = %347
  store i32 -30796, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

349:                                              ; preds = %318
  %350 = load ptr, ptr %4, align 8, !tbaa !5
  %351 = getelementptr inbounds %struct.MDBX_txn, ptr %350, i32 0, i32 9
  %352 = load ptr, ptr %351, align 8, !tbaa !13
  %353 = load ptr, ptr %9, align 8, !tbaa !5
  %354 = load ptr, ptr %13, align 8, !tbaa !5
  %355 = call i32 @tbl_setup_ifneed(ptr noundef %352, ptr noundef %353, ptr noundef %354)
  store i32 %355, ptr %7, align 4, !tbaa !11
  %356 = load i32, ptr %7, align 4, !tbaa !11
  %357 = icmp ne i32 %356, 0
  %358 = xor i1 %357, true
  %359 = xor i1 %358, true
  %360 = zext i1 %359 to i32
  %361 = sext i32 %360 to i64
  %362 = call i64 @llvm.expect.i64(i64 %361, i64 0)
  %363 = icmp ne i64 %362, 0
  br i1 %363, label %364, label %366

364:                                              ; preds = %349
  %365 = load i32, ptr %7, align 4, !tbaa !11
  store i32 %365, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

366:                                              ; preds = %349
  %367 = load ptr, ptr %4, align 8, !tbaa !5
  %368 = load i64, ptr %5, align 8, !tbaa !9
  %369 = call zeroext i1 @dbi_changed(ptr noundef %367, i64 noundef %368)
  %370 = xor i1 %369, true
  %371 = xor i1 %370, true
  %372 = zext i1 %371 to i32
  %373 = sext i32 %372 to i64
  %374 = call i64 @llvm.expect.i64(i64 %373, i64 0)
  %375 = icmp ne i64 %374, 0
  br i1 %375, label %376, label %377

376:                                              ; preds = %366
  store i32 -30780, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

377:                                              ; preds = %366
  %378 = load ptr, ptr %4, align 8, !tbaa !5
  %379 = getelementptr inbounds %struct.MDBX_txn, ptr %378, i32 0, i32 12
  %380 = load ptr, ptr %379, align 8, !tbaa !52
  %381 = load i64, ptr %5, align 8, !tbaa !9
  %382 = getelementptr inbounds i8, ptr %380, i64 %381
  %383 = load i8, ptr %382, align 1, !tbaa !42
  %384 = zext i8 %383 to i32
  %385 = and i32 %384, -3
  %386 = trunc i32 %385 to i8
  store i8 %386, ptr %382, align 1, !tbaa !42
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %387

387:                                              ; preds = %377, %376, %364, %348, %268, %207, %168, %145, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  br label %388

388:                                              ; preds = %387, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 824, ptr %6) #8
  %389 = load i32, ptr %3, align 4
  ret i32 %389
}

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

declare i32 @tree_search(ptr noundef, ptr noundef, i32 noundef) #1

declare { ptr, i8 } @node_search(ptr noundef, ptr noundef) #1

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

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden zeroext i16 @unaligned_peek_u16(i64 noundef, ptr noundef) #5

; 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) #7

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @dbi_changed(ptr noundef, i64 noundef) #6

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


; 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 }
%struct.anon = 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.kvx = type { %struct.clc2, %struct.iovec }
%struct.clc2 = type { %struct.clc, %struct.clc }
%struct.clc = type { ptr, i64, i64 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@__func__.tbl_fetch = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [39 x i8], align 1

declare void @debug_log(i32 noundef, ptr noundef, i32 noundef, ptr 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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @tbl_fetch(ptr noundef %0, i64 noundef %1) local_unnamed_addr #3 {
  %3 = alloca %struct.cursor_couple, align 8
  %4 = alloca %struct.iovec, align 8
  call void @llvm.lifetime.start.p0(i64 824, ptr nonnull %3) #7
  %5 = call i32 @cursor_init(ptr noundef nonnull %3, ptr noundef %0, i64 noundef 1) #7
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %117, !prof !5

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = load ptr, ptr %7, align 8, !tbaa !6
  %9 = getelementptr inbounds i8, ptr %8, i64 200
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  %11 = getelementptr inbounds %struct.kvx, ptr %10, i64 %1
  %12 = getelementptr inbounds i8, ptr %11, i64 48
  %13 = call i32 @tree_search(ptr noundef nonnull %3, ptr noundef nonnull %12, i32 noundef 0) #7
  %.not62 = icmp eq i32 %13, 0
  br i1 %.not62, label %27, label %14, !prof !5

14:                                               ; preds = %27, %6
  %.053 = phi i32 [ %13, %6 ], [ -30798, %27 ]
  %15 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !26
  %16 = icmp ugt i8 %15, 2
  br i1 %16, label %17, label %24, !prof !28

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %11, i64 56
  %19 = load i64, ptr %18, align 8, !tbaa !29
  %20 = trunc i64 %19 to i32
  %21 = load ptr, ptr %12, align 8, !tbaa !34
  %22 = getelementptr inbounds i8, ptr %0, i64 64
  %23 = load i64, ptr %22, align 8, !tbaa !35
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef nonnull @__func__.tbl_fetch, i32 noundef 51, ptr noundef nonnull @.str.4, i64 noundef %1, i32 noundef %20, ptr noundef %21, i64 noundef %23, i32 noundef %.053) #7
  br label %24

24:                                               ; preds = %17, %14
  %25 = icmp eq i32 %.053, -30798
  %26 = select i1 %25, i32 -30780, i32 %.053
  br label %117

27:                                               ; preds = %6
  %28 = call { ptr, i8 } @node_search(ptr noundef nonnull %3, ptr noundef nonnull %12) #7
  %29 = extractvalue { ptr, i8 } %28, 0
  %30 = extractvalue { ptr, i8 } %28, 1
  %31 = trunc i8 %30 to i1
  br i1 %31, label %32, label %14, !prof !5

32:                                               ; preds = %27
  %33 = call zeroext i8 @node_flags(ptr noundef %29) #8
  %34 = and i8 %33, 6
  %.not63 = icmp eq i8 %34, 2
  br i1 %.not63, label %45, label %35, !prof !5

35:                                               ; preds = %32
  %36 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !26
  %37 = icmp ugt i8 %36, 2
  br i1 %37, label %38, label %117, !prof !28

38:                                               ; preds = %35
  %39 = getelementptr inbounds i8, ptr %11, i64 56
  %40 = load i64, ptr %39, align 8, !tbaa !29
  %41 = trunc i64 %40 to i32
  %42 = load ptr, ptr %12, align 8, !tbaa !34
  %43 = getelementptr inbounds i8, ptr %0, i64 64
  %44 = load i64, ptr %43, align 8, !tbaa !35
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef nonnull @__func__.tbl_fetch, i32 noundef 63, ptr noundef nonnull @.str.5, i64 noundef %1, i32 noundef %41, ptr noundef %42, i64 noundef %44, ptr noundef nonnull @.str.6) #7
  br label %117

45:                                               ; preds = %32
  %46 = getelementptr inbounds i8, ptr %3, i64 48
  %47 = getelementptr inbounds i8, ptr %3, i64 5
  %48 = load i8, ptr %47, align 1, !tbaa !36
  %49 = sext i8 %48 to i64
  %50 = getelementptr inbounds [32 x ptr], ptr %46, i64 0, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !37
  %52 = call i32 @node_read(ptr noundef nonnull %3, ptr noundef %29, ptr noundef nonnull %4, ptr noundef %51)
  %.not64 = icmp eq i32 %52, 0
  br i1 %.not64, label %53, label %117, !prof !5

53:                                               ; preds = %45
  %54 = getelementptr inbounds i8, ptr %4, i64 8
  %55 = load i64, ptr %54, align 8, !tbaa !38
  %.not65 = icmp eq i64 %55, 48
  br i1 %.not65, label %66, label %56, !prof !5

56:                                               ; preds = %53
  %57 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !26
  %58 = icmp ugt i8 %57, 2
  br i1 %58, label %59, label %117, !prof !28

59:                                               ; preds = %56
  %60 = getelementptr inbounds i8, ptr %11, i64 56
  %61 = load i64, ptr %60, align 8, !tbaa !29
  %62 = trunc i64 %61 to i32
  %63 = load ptr, ptr %12, align 8, !tbaa !34
  %64 = getelementptr inbounds i8, ptr %0, i64 64
  %65 = load i64, ptr %64, align 8, !tbaa !35
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef nonnull @__func__.tbl_fetch, i32 noundef 73, ptr noundef nonnull @.str.5, i64 noundef %1, i32 noundef %62, ptr noundef %63, i64 noundef %65, ptr noundef nonnull @.str.7) #7
  br label %117

66:                                               ; preds = %53
  %67 = load ptr, ptr %4, align 8, !tbaa !39
  %68 = call zeroext i16 @unaligned_peek_u16(i64 noundef 1, ptr noundef %67) #8
  %69 = getelementptr inbounds i8, ptr %0, i64 88
  %70 = load ptr, ptr %69, align 8, !tbaa !40
  %71 = getelementptr inbounds %struct.tree, ptr %70, i64 %1
  %72 = load i16, ptr %71, align 4, !tbaa !41
  %73 = and i16 %72, 126
  %74 = zext nneg i16 %73 to i32
  %75 = zext i16 %68 to i32
  %.not66 = icmp eq i16 %73, %68
  br i1 %.not66, label %86, label %76, !prof !5

76:                                               ; preds = %66
  %77 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !26
  %78 = icmp ugt i8 %77, 2
  br i1 %78, label %79, label %117, !prof !28

79:                                               ; preds = %76
  %80 = getelementptr inbounds i8, ptr %11, i64 56
  %81 = load i64, ptr %80, align 8, !tbaa !29
  %82 = trunc i64 %81 to i32
  %83 = load ptr, ptr %12, align 8, !tbaa !34
  %84 = getelementptr inbounds i8, ptr %0, i64 64
  %85 = load i64, ptr %84, align 8, !tbaa !35
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef nonnull @__func__.tbl_fetch, i32 noundef 85, ptr noundef nonnull @.str.8, i64 noundef %1, i32 noundef %82, ptr noundef %83, i64 noundef %85, i32 noundef %74, i32 noundef %75) #7
  br label %117

86:                                               ; preds = %66
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(48) %71, ptr noundef nonnull align 1 dereferenceable(48) %67, i64 48, i1 false)
  %87 = load i8, ptr %47, align 1, !tbaa !36
  %88 = sext i8 %87 to i64
  %89 = getelementptr inbounds [32 x ptr], ptr %46, i64 0, i64 %88
  %90 = load ptr, ptr %89, align 8, !tbaa !37
  %91 = load i64, ptr %90, align 1, !tbaa !43
  %92 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !44
  %93 = and i8 %92, 1
  %.not67 = icmp eq i8 %93, 0
  br i1 %.not67, label %99, label %94, !prof !28

94:                                               ; preds = %86
  %95 = getelementptr inbounds i8, ptr %0, i64 72
  %96 = load i64, ptr %95, align 8, !tbaa !45
  %.not68 = icmp ult i64 %96, %91
  br i1 %.not68, label %97, label %99, !prof !28

97:                                               ; preds = %94
  %98 = load ptr, ptr %7, align 8, !tbaa !6
  call void @mdbx_assert_fail(ptr noundef %98, ptr noundef nonnull @.str.9, ptr noundef nonnull @__func__.tbl_fetch, i32 noundef 92) #9
  unreachable

99:                                               ; preds = %94, %86
  %100 = getelementptr inbounds i8, ptr %71, i64 40
  %101 = load i64, ptr %100, align 4, !tbaa !46
  %102 = icmp ugt i64 %101, %91
  br i1 %102, label %103, label %106, !prof !28

103:                                              ; preds = %99
  %104 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !26
  %.not70 = icmp eq i8 %104, 0
  br i1 %.not70, label %117, label %105, !prof !5

105:                                              ; preds = %103
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.tbl_fetch, i32 noundef 94, ptr noundef nonnull @.str.10, i64 noundef %101, i64 noundef %91) #7
  br label %117

106:                                              ; preds = %99
  %107 = load ptr, ptr %7, align 8, !tbaa !6
  %108 = call i32 @tbl_setup_ifneed(ptr noundef %107, ptr noundef %11, ptr noundef nonnull %71)
  %.not69 = icmp eq i32 %108, 0
  br i1 %.not69, label %109, label %117, !prof !5

109:                                              ; preds = %106
  %110 = call zeroext i1 @dbi_changed(ptr noundef nonnull %0, i64 noundef %1)
  br i1 %110, label %117, label %111, !prof !28

111:                                              ; preds = %109
  %112 = getelementptr inbounds i8, ptr %0, i64 104
  %113 = load ptr, ptr %112, align 8, !tbaa !47
  %114 = getelementptr inbounds i8, ptr %113, i64 %1
  %115 = load i8, ptr %114, align 1, !tbaa !36
  %116 = and i8 %115, -3
  store i8 %116, ptr %114, align 1, !tbaa !36
  br label %117

117:                                              ; preds = %24, %111, %38, %35, %45, %59, %56, %79, %76, %105, %103, %106, %109, %2
  %.1 = phi i32 [ %5, %2 ], [ %26, %24 ], [ 0, %111 ], [ -30784, %38 ], [ -30784, %35 ], [ %52, %45 ], [ -30784, %59 ], [ -30784, %56 ], [ -30784, %79 ], [ -30784, %76 ], [ -30796, %105 ], [ -30796, %103 ], [ %108, %106 ], [ -30780, %109 ]
  call void @llvm.lifetime.end.p0(i64 824, ptr nonnull %3) #7
  ret i32 %.1
}

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

declare i32 @tree_search(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare { ptr, i8 } @node_search(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden zeroext i16 @unaligned_peek_u16(i64 noundef, ptr noundef) local_unnamed_addr #4

; 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) #6

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @dbi_changed(ptr noundef, i64 noundef) local_unnamed_addr #5

attributes #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 = { 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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #5 = { 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { 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 2000, i32 1}
!6 = !{!7, !12, i64 80}
!7 = !{!"MDBX_txn", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !13, i64 40, !11, i64 64, !11, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !15, i64 128, !12, i64 160, !9, i64 168}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"geo", !14, i64 0, !14, i64 2, !8, i64 4, !8, i64 8, !9, i64 12, !9, i64 16}
!14 = !{!"short", !9, i64 0}
!15 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!16 = !{!17, !12, i64 200}
!17 = !{!"MDBX_env", !9, i64 0, !8, i64 4, !8, i64 8, !18, i64 16, !8, i64 56, !8, i64 60, !18, i64 64, !12, i64 104, !14, i64 112, !14, i64 114, !14, i64 116, !14, i64 118, !14, i64 120, !14, i64 122, !9, i64 124, !9, i64 128, !9, i64 129, !14, i64 130, !8, i64 132, !8, i64 136, !8, i64 140, !8, i64 144, !19, i64 152, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !8, i64 224, !8, i64 228, !8, i64 232, !12, i64 240, !12, i64 248, !11, i64 256, !20, i64 264, !23, i64 320, !21, i64 360, !12, i64 368, !12, i64 376, !12, i64 384, !24, i64 392, !9, i64 400, !8, i64 440, !8, i64 444, !12, i64 448, !25, i64 456, !9, i64 496, !9, i64 536}
!18 = !{!"osal_mmap", !9, i64 0, !8, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!19 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!20 = !{!"", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !11, i64 16, !9, i64 24, !9, i64 25, !9, i64 26, !9, i64 27, !8, i64 28, !8, i64 32, !21, i64 36, !21, i64 37, !21, i64 38, !22, i64 40, !9, i64 48}
!21 = !{!"_Bool", !9, i64 0}
!22 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6}
!23 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!24 = !{!"", !11, i64 0}
!25 = !{!"osal_ioring", !8, i64 0, !8, i64 4, !8, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!26 = !{!27, !9, i64 26}
!27 = !{!"libmdbx_globals", !9, i64 0, !8, i64 16, !8, i64 20, !9, i64 24, !9, i64 25, !9, i64 26, !21, i64 27, !8, i64 28, !9, i64 32, !9, i64 40, !11, i64 80, !12, i64 88}
!28 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!29 = !{!30, !11, i64 56}
!30 = !{!"kvx", !31, i64 0, !33, i64 48}
!31 = !{!"clc2", !32, i64 0, !32, i64 24}
!32 = !{!"clc", !12, i64 0, !11, i64 8, !11, i64 16}
!33 = !{!"iovec", !12, i64 0, !11, i64 8}
!34 = !{!30, !12, i64 48}
!35 = !{!7, !11, i64 64}
!36 = !{!9, !9, i64 0}
!37 = !{!12, !12, i64 0}
!38 = !{!33, !11, i64 8}
!39 = !{!33, !12, i64 0}
!40 = !{!7, !12, i64 88}
!41 = !{!42, !14, i64 0}
!42 = !{!"tree", !14, i64 0, !14, i64 2, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !11, i64 24, !11, i64 32, !11, i64 40}
!43 = !{!11, !11, i64 0}
!44 = !{!27, !9, i64 25}
!45 = !{!7, !11, i64 72}
!46 = !{!42, !11, i64 40}
!47 = !{!7, !12, i64 104}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass