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

; 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.16 }
%struct.anon.16 = 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 }
%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.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.2 }
%struct.geo = type { i16, i16, i32, i32, %union.anon.0, %union.anon.1 }
%union.anon.0 = type { i32 }
%union.anon.1 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.2 = type { %struct.anon.4 }
%struct.anon.4 = type { %struct.troika, ptr, %struct.anon.5, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.6 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.5 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.6 = type { %struct.anon.7 }
%struct.anon.7 = type { i64, ptr }
%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__.mdbx_cursor_get_batch = external hidden unnamed_addr constant [22 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [51 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cursor_check_ro(ptr noundef) #2

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

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

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

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

29:                                               ; preds = %5
  %30 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 599)
  store i32 %30, ptr %6, align 4
  br label %340

31:                                               ; preds = %5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 0, ptr %32, align 8, !tbaa !9
  %33 = load i64, ptr %10, align 8, !tbaa !9
  %34 = icmp ult i64 %33, 4
  br i1 %34, label %38, label %35

35:                                               ; preds = %31
  %36 = load i64, ptr %10, align 8, !tbaa !9
  %37 = icmp ugt i64 %36, 9223372036854775805
  br label %38

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

46:                                               ; preds = %38
  %47 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 603)
  store i32 %47, ptr %6, align 4
  br label %340

48:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = call i32 @cursor_check_ro(ptr noundef %49)
  store i32 %50, ptr %12, align 4, !tbaa !11
  %51 = load i32, ptr %12, align 4, !tbaa !11
  %52 = icmp ne i32 %51, 0
  %53 = xor i1 %52, true
  %54 = xor i1 %53, true
  %55 = zext i1 %54 to i32
  %56 = sext i32 %55 to i64
  %57 = call i64 @llvm.expect.i64(i64 %56, i64 0)
  %58 = icmp ne i64 %57, 0
  br i1 %58, label %59, label %62

59:                                               ; preds = %48
  %60 = load i32, ptr %12, align 4, !tbaa !11
  %61 = call i32 @log_if_error(i32 noundef %60, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 607)
  store i32 %61, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %339

62:                                               ; preds = %48
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MDBX_cursor, ptr %63, i32 0, i32 8
  %65 = load ptr, ptr %64, align 8, !tbaa !13
  %66 = icmp ne ptr %65, null
  %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 %75

73:                                               ; preds = %62
  %74 = call i32 @log_if_error(i32 noundef -30784, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 610)
  store i32 %74, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %339

75:                                               ; preds = %62
  %76 = load i32, ptr %11, align 4, !tbaa !11
  switch i32 %76, label %112 [
    i32 8, label %77
    i32 0, label %93
  ]

77:                                               ; preds = %75
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = call zeroext i1 @is_eof(ptr noundef %78) #9
  %80 = xor i1 %79, true
  %81 = xor i1 %80, true
  %82 = zext i1 %81 to i32
  %83 = sext i32 %82 to i64
  %84 = call i64 @llvm.expect.i64(i64 %83, i64 0)
  %85 = icmp ne i64 %84, 0
  br i1 %85, label %86, label %92

86:                                               ; preds = %77
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = call zeroext i1 @is_pointed(ptr noundef %87) #9
  %89 = zext i1 %88 to i64
  %90 = select i1 %88, i32 -30798, i32 61
  %91 = call i32 @log_if_error(i32 noundef %90, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 615)
  store i32 %91, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %339

92:                                               ; preds = %77
  br label %129

93:                                               ; preds = %75
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = call zeroext i1 @is_filled(ptr noundef %94) #9
  br i1 %95, label %111, label %96

96:                                               ; preds = %93
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = call i32 @outer_first(ptr noundef %97, ptr noundef null, ptr noundef null)
  store i32 %98, ptr %12, align 4, !tbaa !11
  %99 = load i32, ptr %12, align 4, !tbaa !11
  %100 = icmp ne i32 %99, 0
  %101 = xor i1 %100, true
  %102 = xor i1 %101, true
  %103 = zext i1 %102 to i32
  %104 = sext i32 %103 to i64
  %105 = call i64 @llvm.expect.i64(i64 %104, i64 0)
  %106 = icmp ne i64 %105, 0
  br i1 %106, label %107, label %110

107:                                              ; preds = %96
  %108 = load i32, ptr %12, align 4, !tbaa !11
  %109 = call i32 @log_if_error(i32 noundef %108, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 622)
  store i32 %109, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %339

110:                                              ; preds = %96
  br label %111

111:                                              ; preds = %110, %93
  br label %129

112:                                              ; preds = %75
  br label %113

113:                                              ; preds = %112
  %114 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !15
  %115 = zext i8 %114 to i32
  %116 = icmp sle i32 5, %115
  %117 = xor i1 %116, true
  %118 = xor i1 %117, true
  %119 = zext i1 %118 to i32
  %120 = sext i32 %119 to i64
  %121 = call i64 @llvm.expect.i64(i64 %120, i64 0)
  %122 = icmp ne i64 %121, 0
  br i1 %122, label %123, label %125

123:                                              ; preds = %113
  %124 = load i32, ptr %11, align 4, !tbaa !11
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 627, ptr noundef @.str.17, i32 noundef %124)
  br label %125

125:                                              ; preds = %123, %113
  br label %126

126:                                              ; preds = %125
  br label %127

127:                                              ; preds = %126
  %128 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 628)
  store i32 %128, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %339

129:                                              ; preds = %111, %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %130 = load ptr, ptr %7, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.MDBX_cursor, ptr %130, i32 0, i32 9
  %132 = load ptr, ptr %7, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.MDBX_cursor, ptr %132, i32 0, i32 1
  %134 = getelementptr inbounds %struct.anon, ptr %133, i32 0, i32 1
  %135 = load i8, ptr %134, align 1, !tbaa !18
  %136 = sext i8 %135 to i64
  %137 = getelementptr inbounds [32 x ptr], ptr %131, i64 0, i64 %136
  %138 = load ptr, ptr %137, align 8, !tbaa !5
  store ptr %138, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %139 = load ptr, ptr %14, align 8, !tbaa !5
  %140 = call i64 @page_numkeys(ptr noundef %139) #9
  store i64 %140, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %141 = load ptr, ptr %7, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.MDBX_cursor, ptr %141, i32 0, i32 10
  %143 = load ptr, ptr %7, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.MDBX_cursor, ptr %143, i32 0, i32 1
  %145 = getelementptr inbounds %struct.anon, ptr %144, i32 0, i32 1
  %146 = load i8, ptr %145, align 1, !tbaa !18
  %147 = sext i8 %146 to i64
  %148 = getelementptr inbounds [32 x i16], ptr %142, i64 0, i64 %147
  %149 = load i16, ptr %148, align 2, !tbaa !19
  %150 = zext i16 %149 to i64
  store i64 %150, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  store i64 0, ptr %17, align 8, !tbaa !9
  br label %151

151:                                              ; preds = %322, %129
  %152 = load i64, ptr %17, align 8, !tbaa !9
  %153 = add i64 %152, 2
  %154 = load i64, ptr %10, align 8, !tbaa !9
  %155 = icmp ule i64 %153, %154
  br i1 %155, label %156, label %323

156:                                              ; preds = %151
  br label %157

157:                                              ; preds = %156
  %158 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !21
  %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 %189

168:                                              ; preds = %157
  br label %169

169:                                              ; preds = %168
  %170 = load i64, ptr %16, align 8, !tbaa !9
  %171 = load i64, ptr %15, align 8, !tbaa !9
  %172 = icmp ult i64 %170, %171
  %173 = xor i1 %172, true
  %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 %186

180:                                              ; preds = %169
  %181 = load ptr, ptr %7, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.MDBX_cursor, ptr %181, i32 0, i32 5
  %183 = load ptr, ptr %182, align 8, !tbaa !22
  %184 = getelementptr inbounds %struct.MDBX_txn, ptr %183, i32 0, i32 9
  %185 = load ptr, ptr %184, align 8, !tbaa !23
  call void @mdbx_assert_fail(ptr noundef %185, ptr noundef @.str.18, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 636) #10
  unreachable

186:                                              ; preds = %169
  br label %187

187:                                              ; preds = %186
  br label %188

188:                                              ; preds = %187
  br label %189

189:                                              ; preds = %188, %157
  br label %190

190:                                              ; preds = %189
  br label %191

191:                                              ; preds = %190
  %192 = load i64, ptr %16, align 8, !tbaa !9
  %193 = load i64, ptr %15, align 8, !tbaa !9
  %194 = icmp uge i64 %192, %193
  %195 = xor i1 %194, true
  %196 = xor i1 %195, true
  %197 = zext i1 %196 to i32
  %198 = sext i32 %197 to i64
  %199 = call i64 @llvm.expect.i64(i64 %198, i64 0)
  %200 = icmp ne i64 %199, 0
  br i1 %200, label %201, label %202

201:                                              ; preds = %191
  br label %240

202:                                              ; preds = %191
  %203 = load ptr, ptr %14, align 8, !tbaa !5
  %204 = load i64, ptr %16, align 8, !tbaa !9
  %205 = call ptr @page_node(ptr noundef %203, i64 noundef %204) #9
  store ptr %205, ptr %18, align 8, !tbaa !5
  %206 = load ptr, ptr %9, align 8, !tbaa !5
  %207 = load i64, ptr %17, align 8, !tbaa !9
  %208 = getelementptr inbounds %struct.iovec, ptr %206, i64 %207
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #8
  %209 = load ptr, ptr %18, align 8, !tbaa !5
  %210 = call { ptr, i64 } @get_key(ptr noundef %209) #9
  %211 = getelementptr inbounds { ptr, i64 }, ptr %19, i32 0, i32 0
  %212 = extractvalue { ptr, i64 } %210, 0
  store ptr %212, ptr %211, align 8
  %213 = getelementptr inbounds { ptr, i64 }, ptr %19, i32 0, i32 1
  %214 = extractvalue { ptr, i64 } %210, 1
  store i64 %214, ptr %213, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %208, ptr align 8 %19, i64 16, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #8
  %215 = load ptr, ptr %7, align 8, !tbaa !5
  %216 = load ptr, ptr %18, align 8, !tbaa !5
  %217 = load ptr, ptr %9, align 8, !tbaa !5
  %218 = load i64, ptr %17, align 8, !tbaa !9
  %219 = add i64 %218, 1
  %220 = getelementptr inbounds %struct.iovec, ptr %217, i64 %219
  %221 = load ptr, ptr %14, align 8, !tbaa !5
  %222 = call i32 @node_read(ptr noundef %215, ptr noundef %216, ptr noundef %220, ptr noundef %221)
  store i32 %222, ptr %12, align 4, !tbaa !11
  %223 = load i32, ptr %12, align 4, !tbaa !11
  %224 = icmp ne i32 %223, 0
  %225 = xor i1 %224, true
  %226 = xor i1 %225, true
  %227 = zext i1 %226 to i32
  %228 = sext i32 %227 to i64
  %229 = call i64 @llvm.expect.i64(i64 %228, i64 0)
  %230 = icmp ne i64 %229, 0
  br i1 %230, label %231, label %232

231:                                              ; preds = %202
  br label %334

232:                                              ; preds = %202
  %233 = load i64, ptr %17, align 8, !tbaa !9
  %234 = add i64 %233, 2
  store i64 %234, ptr %17, align 8, !tbaa !9
  %235 = load i64, ptr %16, align 8, !tbaa !9
  %236 = add i64 %235, 1
  store i64 %236, ptr %16, align 8, !tbaa !9
  %237 = load i64, ptr %15, align 8, !tbaa !9
  %238 = icmp eq i64 %236, %237
  br i1 %238, label %239, label %322

239:                                              ; preds = %232
  br label %240

240:                                              ; preds = %239, %201
  %241 = load ptr, ptr %7, align 8, !tbaa !5
  %242 = call i32 @cursor_sibling_right(ptr noundef %241)
  store i32 %242, ptr %12, align 4, !tbaa !11
  %243 = load i32, ptr %12, align 4, !tbaa !11
  %244 = icmp ne i32 %243, 0
  br i1 %244, label %245, label %250

245:                                              ; preds = %240
  %246 = load i32, ptr %12, align 4, !tbaa !11
  %247 = icmp eq i32 %246, -30798
  br i1 %247, label %248, label %249

248:                                              ; preds = %245
  store i32 -1, ptr %12, align 4, !tbaa !11
  br label %249

249:                                              ; preds = %248, %245
  br label %334

250:                                              ; preds = %240
  %251 = load ptr, ptr %7, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.MDBX_cursor, ptr %251, i32 0, i32 9
  %253 = load ptr, ptr %7, align 8, !tbaa !5
  %254 = getelementptr inbounds %struct.MDBX_cursor, ptr %253, i32 0, i32 1
  %255 = getelementptr inbounds %struct.anon, ptr %254, i32 0, i32 1
  %256 = load i8, ptr %255, align 1, !tbaa !18
  %257 = sext i8 %256 to i64
  %258 = getelementptr inbounds [32 x ptr], ptr %252, i64 0, i64 %257
  %259 = load ptr, ptr %258, align 8, !tbaa !5
  store ptr %259, ptr %14, align 8, !tbaa !5
  br label %260

260:                                              ; preds = %250
  %261 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !15
  %262 = zext i8 %261 to i32
  %263 = icmp sle i32 5, %262
  %264 = xor i1 %263, true
  %265 = xor i1 %264, true
  %266 = zext i1 %265 to i32
  %267 = sext i32 %266 to i64
  %268 = call i64 @llvm.expect.i64(i64 %267, i64 0)
  %269 = icmp ne i64 %268, 0
  br i1 %269, label %270, label %284

270:                                              ; preds = %260
  %271 = load ptr, ptr %14, align 8, !tbaa !5
  %272 = getelementptr inbounds %struct.page, ptr %271, i32 0, i32 4
  %273 = load i32, ptr %272, align 1, !tbaa !11
  %274 = load ptr, ptr %7, align 8, !tbaa !5
  %275 = getelementptr inbounds %struct.MDBX_cursor, ptr %274, i32 0, i32 10
  %276 = load ptr, ptr %7, align 8, !tbaa !5
  %277 = getelementptr inbounds %struct.MDBX_cursor, ptr %276, i32 0, i32 1
  %278 = getelementptr inbounds %struct.anon, ptr %277, i32 0, i32 1
  %279 = load i8, ptr %278, align 1, !tbaa !18
  %280 = sext i8 %279 to i64
  %281 = getelementptr inbounds [32 x i16], ptr %275, i64 0, i64 %280
  %282 = load i16, ptr %281, align 2, !tbaa !19
  %283 = zext i16 %282 to i32
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 657, ptr noundef @.str.19, i32 noundef %273, i32 noundef %283)
  br label %284

284:                                              ; preds = %270, %260
  br label %285

285:                                              ; preds = %284
  br label %286

286:                                              ; preds = %285
  %287 = load ptr, ptr %7, align 8, !tbaa !5
  %288 = load ptr, ptr %14, align 8, !tbaa !5
  %289 = call zeroext i1 @check_leaf_type(ptr noundef %287, ptr noundef %288) #9
  %290 = xor i1 %289, true
  %291 = xor i1 %290, true
  %292 = xor i1 %291, true
  %293 = zext i1 %292 to i32
  %294 = sext i32 %293 to i64
  %295 = call i64 @llvm.expect.i64(i64 %294, i64 0)
  %296 = icmp ne i64 %295, 0
  br i1 %296, label %297, label %319

297:                                              ; preds = %286
  br label %298

298:                                              ; preds = %297
  %299 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !15
  %300 = zext i8 %299 to i32
  %301 = icmp sle i32 1, %300
  %302 = xor i1 %301, true
  %303 = xor i1 %302, true
  %304 = zext i1 %303 to i32
  %305 = sext i32 %304 to i64
  %306 = call i64 @llvm.expect.i64(i64 %305, i64 0)
  %307 = icmp ne i64 %306, 0
  br i1 %307, label %308, label %316

308:                                              ; preds = %298
  %309 = load ptr, ptr %14, align 8, !tbaa !5
  %310 = getelementptr inbounds %struct.page, ptr %309, i32 0, i32 4
  %311 = load i32, ptr %310, align 1, !tbaa !11
  %312 = load ptr, ptr %14, align 8, !tbaa !5
  %313 = getelementptr inbounds %struct.page, ptr %312, i32 0, i32 2
  %314 = load i16, ptr %313, align 1, !tbaa !19
  %315 = zext i16 %314 to i32
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 659, ptr noundef @.str.20, i32 noundef %311, i32 noundef %315)
  br label %316

316:                                              ; preds = %308, %298
  br label %317

317:                                              ; preds = %316
  br label %318

318:                                              ; preds = %317
  store i32 -30796, ptr %12, align 4, !tbaa !11
  br label %334

319:                                              ; preds = %286
  %320 = load ptr, ptr %14, align 8, !tbaa !5
  %321 = call i64 @page_numkeys(ptr noundef %320) #9
  store i64 %321, ptr %15, align 8, !tbaa !9
  store i64 0, ptr %16, align 8, !tbaa !9
  br label %322

322:                                              ; preds = %319, %232
  br label %151, !llvm.loop !28

323:                                              ; preds = %151
  %324 = load i64, ptr %16, align 8, !tbaa !9
  %325 = trunc i64 %324 to i16
  %326 = load ptr, ptr %7, align 8, !tbaa !5
  %327 = getelementptr inbounds %struct.MDBX_cursor, ptr %326, i32 0, i32 10
  %328 = load ptr, ptr %7, align 8, !tbaa !5
  %329 = getelementptr inbounds %struct.MDBX_cursor, ptr %328, i32 0, i32 1
  %330 = getelementptr inbounds %struct.anon, ptr %329, i32 0, i32 1
  %331 = load i8, ptr %330, align 1, !tbaa !18
  %332 = sext i8 %331 to i64
  %333 = getelementptr inbounds [32 x i16], ptr %327, i64 0, i64 %332
  store i16 %325, ptr %333, align 2, !tbaa !19
  br label %334

334:                                              ; preds = %323, %318, %249, %231
  %335 = load i64, ptr %17, align 8, !tbaa !9
  %336 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %335, ptr %336, align 8, !tbaa !9
  %337 = load i32, ptr %12, align 4, !tbaa !11
  %338 = call i32 @log_if_error(i32 noundef %337, ptr noundef @__func__.mdbx_cursor_get_batch, i32 noundef 671)
  store i32 %338, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  br label %339

339:                                              ; preds = %334, %127, %107, %86, %73, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %340

340:                                              ; preds = %339, %46, %29
  %341 = load i32, ptr %6, align 4
  ret i32 %341
}

declare i32 @outer_first(ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden { ptr, i64 } @get_key(ptr noundef) #6

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

declare i32 @cursor_sibling_right(ptr noundef) #4

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 40}
!14 = !{!"MDBX_cursor", !12, 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}
!15 = !{!16, !7, i64 26}
!16 = !{!"libmdbx_globals", !7, i64 0, !12, i64 16, !12, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !17, i64 27, !12, i64 28, !7, i64 32, !7, i64 40, !10, i64 80, !6, i64 88}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!16, !7, i64 25}
!22 = !{!14, !6, i64 16}
!23 = !{!24, !6, i64 80}
!24 = !{!"MDBX_txn", !12, i64 0, !12, i64 4, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !25, 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, !26, i64 128, !6, i64 160, !7, i64 168}
!25 = !{!"geo", !20, i64 0, !20, i64 2, !12, i64 4, !12, i64 8, !7, i64 12, !7, i64 16}
!26 = !{!"MDBX_canary", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!27 = !{i64 0, i64 8, !5, i64 8, i64 8, !9}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


; 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.16 }
%struct.anon.16 = 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
@__func__.mdbx_cursor_get_batch = external hidden unnamed_addr constant [22 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [51 x i8], align 1

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

; Function Attrs: 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_pointed(ptr noundef) local_unnamed_addr #3

; 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 nounwind uwtable
declare hidden i32 @cursor_check_ro(ptr noundef) local_unnamed_addr #0

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

; 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 zeroext i1 @is_eof(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_cursor_get_batch(ptr noundef %0, ptr noundef writeonly %1, ptr noundef %2, i64 noundef %3, i32 noundef %4) local_unnamed_addr #4 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %6, label %8, !prof !5

6:                                                ; preds = %5
  %7 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 599)
  br label %106

8:                                                ; preds = %5
  store i64 0, ptr %1, align 8, !tbaa !6
  %9 = add i64 %3, -9223372036854775806
  %10 = icmp ult i64 %9, -9223372036854775802
  br i1 %10, label %11, label %13, !prof !5

11:                                               ; preds = %8
  %12 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 603)
  br label %106

13:                                               ; preds = %8
  %14 = tail call i32 @cursor_check_ro(ptr noundef %0)
  %.not84 = icmp eq i32 %14, 0
  br i1 %.not84, label %17, label %15, !prof !10

15:                                               ; preds = %13
  %16 = tail call i32 @log_if_error(i32 noundef %14, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 607)
  br label %106

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %.not85 = icmp eq ptr %19, null
  br i1 %.not85, label %22, label %20, !prof !10

20:                                               ; preds = %17
  %21 = tail call i32 @log_if_error(i32 noundef -30784, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 610)
  br label %106

22:                                               ; preds = %17
  switch i32 %4, label %35 [
    i32 8, label %23
    i32 0, label %29
  ]

23:                                               ; preds = %22
  %24 = tail call zeroext i1 @is_eof(ptr noundef nonnull %0) #5
  br i1 %24, label %25, label %.lr.ph.preheader, !prof !5

25:                                               ; preds = %23
  %26 = tail call zeroext i1 @is_pointed(ptr noundef nonnull %0) #5
  %27 = select i1 %26, i32 -30798, i32 61
  %28 = tail call i32 @log_if_error(i32 noundef %27, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 615)
  br label %106

29:                                               ; preds = %22
  %30 = tail call zeroext i1 @is_filled(ptr noundef nonnull %0) #5
  br i1 %30, label %.lr.ph.preheader, label %31

31:                                               ; preds = %29
  %32 = tail call i32 @outer_first(ptr noundef nonnull %0, ptr noundef null, ptr noundef null) #6
  %.not86 = icmp eq i32 %32, 0
  br i1 %.not86, label %.lr.ph.preheader, label %33, !prof !10

33:                                               ; preds = %31
  %34 = tail call i32 @log_if_error(i32 noundef %32, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 622)
  br label %106

35:                                               ; preds = %22
  %36 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !15
  %37 = icmp ugt i8 %36, 4
  br i1 %37, label %38, label %39, !prof !5

38:                                               ; preds = %35
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 627, ptr noundef nonnull @.str.17, i32 noundef %4) #6
  br label %39

39:                                               ; preds = %38, %35
  %40 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 628)
  br label %106

.lr.ph.preheader:                                 ; preds = %23, %31, %29
  %41 = getelementptr inbounds i8, ptr %0, i64 48
  %42 = getelementptr inbounds i8, ptr %0, i64 5
  %43 = load i8, ptr %42, align 1, !tbaa !18
  %44 = sext i8 %43 to i64
  %45 = getelementptr inbounds i8, ptr %0, i64 304
  %46 = getelementptr inbounds [32 x i16], ptr %45, i64 0, i64 %44
  %47 = load i16, ptr %46, align 2, !tbaa !19
  %48 = zext i16 %47 to i64
  %49 = getelementptr inbounds [32 x ptr], ptr %41, i64 0, i64 %44
  %50 = load ptr, ptr %49, align 8, !tbaa !21
  %51 = tail call i64 @page_numkeys(ptr noundef %50) #5
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %101
  %52 = phi i64 [ %102, %101 ], [ 2, %.lr.ph.preheader ]
  %.063110 = phi i64 [ %.265, %101 ], [ 0, %.lr.ph.preheader ]
  %.067109 = phi i64 [ %.168, %101 ], [ %48, %.lr.ph.preheader ]
  %.069108 = phi i64 [ %.170, %101 ], [ %51, %.lr.ph.preheader ]
  %.071107 = phi ptr [ %.172, %101 ], [ %50, %.lr.ph.preheader ]
  %53 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !22
  %54 = and i8 %53, 1
  %.not88 = icmp eq i8 %54, 0
  %.not89 = icmp ult i64 %.067109, %.069108
  %or.cond = select i1 %.not88, i1 true, i1 %.not89
  br i1 %or.cond, label %60, label %55, !prof !23

55:                                               ; preds = %.lr.ph
  %56 = getelementptr inbounds i8, ptr %0, i64 16
  %57 = load ptr, ptr %56, align 8, !tbaa !24
  %58 = getelementptr inbounds i8, ptr %57, i64 80
  %59 = load ptr, ptr %58, align 8, !tbaa !25
  tail call void @mdbx_assert_fail(ptr noundef %59, ptr noundef nonnull @.str.18, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 636) #7
  unreachable

60:                                               ; preds = %.lr.ph
  br i1 %.not89, label %61, label %72, !prof !10

61:                                               ; preds = %60
  %62 = tail call ptr @page_node(ptr noundef %.071107, i64 noundef %.067109) #5
  %63 = getelementptr inbounds %struct.iovec, ptr %2, i64 %.063110
  %64 = tail call { ptr, i64 } @get_key(ptr noundef %62) #5
  %65 = extractvalue { ptr, i64 } %64, 0
  %66 = extractvalue { ptr, i64 } %64, 1
  store ptr %65, ptr %63, align 8, !tbaa !21
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %63, i64 8
  store i64 %66, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !6
  %67 = getelementptr i8, ptr %63, i64 16
  %68 = tail call i32 @node_read(ptr noundef %0, ptr noundef %62, ptr noundef %67, ptr noundef %.071107)
  %.not91 = icmp eq i32 %68, 0
  br i1 %.not91, label %69, label %.loopexit, !prof !10

69:                                               ; preds = %61
  %70 = add nuw i64 %.067109, 1
  %71 = icmp eq i64 %70, %.069108
  br i1 %71, label %72, label %101

72:                                               ; preds = %69, %60
  %.164 = phi i64 [ %.063110, %60 ], [ %52, %69 ]
  %73 = tail call i32 @cursor_sibling_right(ptr noundef %0) #6
  %.not92 = icmp eq i32 %73, 0
  br i1 %.not92, label %76, label %74

74:                                               ; preds = %72
  %75 = icmp eq i32 %73, -30798
  %spec.store.select = select i1 %75, i32 -1, i32 %73
  br label %.loopexit

76:                                               ; preds = %72
  %77 = load i8, ptr %42, align 1, !tbaa !18
  %78 = sext i8 %77 to i64
  %79 = getelementptr inbounds [32 x ptr], ptr %41, i64 0, i64 %78
  %80 = load ptr, ptr %79, align 8, !tbaa !21
  %81 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !15
  %82 = icmp ugt i8 %81, 4
  br i1 %82, label %83, label %89, !prof !5

83:                                               ; preds = %76
  %84 = getelementptr inbounds i8, ptr %80, i64 16
  %85 = load i32, ptr %84, align 1, !tbaa !29
  %86 = getelementptr inbounds [32 x i16], ptr %45, i64 0, i64 %78
  %87 = load i16, ptr %86, align 2, !tbaa !19
  %88 = zext i16 %87 to i32
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 657, ptr noundef nonnull @.str.19, i32 noundef %85, i32 noundef %88) #6
  br label %89

89:                                               ; preds = %83, %76
  %90 = tail call zeroext i1 @check_leaf_type(ptr noundef nonnull %0, ptr noundef %80) #5
  br i1 %90, label %99, label %91, !prof !10

91:                                               ; preds = %89
  %92 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !15
  %.not93 = icmp eq i8 %92, 0
  br i1 %.not93, label %.loopexit, label %93, !prof !10

93:                                               ; preds = %91
  %94 = getelementptr inbounds i8, ptr %80, i64 16
  %95 = load i32, ptr %94, align 1, !tbaa !29
  %96 = getelementptr inbounds i8, ptr %80, i64 10
  %97 = load i16, ptr %96, align 1, !tbaa !19
  %98 = zext i16 %97 to i32
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 659, ptr noundef nonnull @.str.20, i32 noundef %95, i32 noundef %98) #6
  br label %.loopexit

99:                                               ; preds = %89
  %100 = tail call i64 @page_numkeys(ptr noundef %80) #5
  br label %101

101:                                              ; preds = %99, %69
  %.172 = phi ptr [ %80, %99 ], [ %.071107, %69 ]
  %.170 = phi i64 [ %100, %99 ], [ %.069108, %69 ]
  %.168 = phi i64 [ 0, %99 ], [ %70, %69 ]
  %.265 = phi i64 [ %.164, %99 ], [ %52, %69 ]
  %102 = add i64 %.265, 2
  %.not87 = icmp ugt i64 %102, %3
  br i1 %.not87, label %._crit_edge, label %.lr.ph, !llvm.loop !30

._crit_edge:                                      ; preds = %101
  %.pre = load i8, ptr %42, align 1, !tbaa !18
  %.pre120 = sext i8 %.pre to i64
  %103 = trunc i64 %.168 to i16
  %104 = getelementptr inbounds [32 x i16], ptr %45, i64 0, i64 %.pre120
  store i16 %103, ptr %104, align 2, !tbaa !19
  br label %.loopexit

.loopexit:                                        ; preds = %61, %91, %93, %._crit_edge, %74
  %.366 = phi i64 [ %.164, %74 ], [ %.265, %._crit_edge ], [ %.164, %93 ], [ %.164, %91 ], [ %.063110, %61 ]
  %.3 = phi i32 [ %spec.store.select, %74 ], [ 0, %._crit_edge ], [ -30796, %93 ], [ -30796, %91 ], [ %68, %61 ]
  store i64 %.366, ptr %1, align 8, !tbaa !6
  %105 = tail call i32 @log_if_error(i32 noundef %.3, ptr noundef nonnull @__func__.mdbx_cursor_get_batch, i32 noundef 671)
  br label %106

106:                                              ; preds = %15, %20, %25, %33, %39, %.loopexit, %11, %6
  %.1 = phi i32 [ %7, %6 ], [ %12, %11 ], [ %16, %15 ], [ %21, %20 ], [ %40, %39 ], [ %105, %.loopexit ], [ %34, %33 ], [ %28, %25 ]
  ret i32 %.1
}

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

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

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

declare i32 @cursor_sibling_right(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 = { 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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !7, i64 0}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!11 = !{!12, !14, i64 40}
!12 = !{!"MDBX_cursor", !13, i64 0, !8, i64 4, !8, i64 6, !8, i64 7, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !8, i64 48, !8, i64 304, !14, i64 368, !14, i64 376}
!13 = !{!"int", !8, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!16, !8, i64 26}
!16 = !{!"libmdbx_globals", !8, i64 0, !13, i64 16, !13, i64 20, !8, i64 24, !8, i64 25, !8, i64 26, !17, i64 27, !13, i64 28, !8, i64 32, !8, i64 40, !7, i64 80, !14, i64 88}
!17 = !{!"_Bool", !8, i64 0}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !8, i64 0}
!21 = !{!14, !14, i64 0}
!22 = !{!16, !8, i64 25}
!23 = !{!"branch_weights", i32 4002001, i32 2000}
!24 = !{!12, !14, i64 16}
!25 = !{!26, !14, i64 80}
!26 = !{!"MDBX_txn", !13, i64 0, !13, i64 4, !7, i64 8, !7, i64 16, !14, i64 24, !14, i64 32, !27, i64 40, !7, i64 64, !7, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !28, i64 128, !14, i64 160, !8, i64 168}
!27 = !{!"geo", !20, i64 0, !20, i64 2, !13, i64 4, !13, i64 8, !8, i64 12, !8, i64 16}
!28 = !{!"MDBX_canary", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!29 = !{!13, !13, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


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