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

; 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.cursor_couple = type { %struct.MDBX_cursor, ptr, %struct.inner_cursor }
%struct.MDBX_cursor = type { i32, %union.anon, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon = type { i16 }
%struct.inner_cursor = type { %struct.MDBX_cursor, %struct.tree }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%struct.iovec = type { ptr, i64 }
%struct.cursor_set_result = type { i32, i8 }
%struct.MDBX_txn = type { i32, i32, i64, i64, ptr, ptr, %struct.geo, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, %struct.MDBX_canary, ptr, %union.anon.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.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.9, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.10, %struct.anon.14, i8, ptr, ptr, ptr, %struct.anon.15, %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.8, i32, i64, i64, i64 }
%union.anon.8 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.9 = type { ptr, ptr, ptr, ptr }
%struct.anon.10 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.11, %union.anon.12 }
%struct.anon.11 = type { i16, i16, i16, i16 }
%union.anon.12 = type { i32 }
%struct.anon.14 = type { i64, i64, i64, i64, i64 }
%struct.anon.15 = 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 }

@__func__.mdbx_drop = external hidden unnamed_addr constant [10 x i8], align 1
@globals = external global %struct.libmdbx_globals, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1

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

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @mdbx_drop(ptr noundef %0, i32 noundef %1, i1 noundef zeroext %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.cursor_couple, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %struct.iovec, align 8
  %14 = alloca %struct.cursor_set_result, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  %15 = zext i1 %2 to i8
  store i8 %15, ptr %7, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 @check_txn_rw(ptr noundef %16, i32 noundef 51)
  store i32 %17, ptr %8, align 4, !tbaa !9
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %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 %29

26:                                               ; preds = %3
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = call i32 @log_if_error(i32 noundef %27, ptr noundef @__func__.mdbx_drop, i32 noundef 40)
  store i32 %28, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %370

29:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 824, ptr %10) #7
  %30 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = zext i32 %32 to i64
  %34 = call i32 @cursor_init(ptr noundef %30, ptr noundef %31, i64 noundef %33)
  store i32 %34, ptr %8, align 4, !tbaa !9
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = icmp ne i32 %35, 0
  %37 = xor i1 %36, true
  %38 = xor i1 %37, true
  %39 = zext i1 %38 to i32
  %40 = sext i32 %39 to i64
  %41 = call i64 @llvm.expect.i64(i64 %40, i64 0)
  %42 = icmp ne i64 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %29
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = call i32 @log_if_error(i32 noundef %44, ptr noundef @__func__.mdbx_drop, i32 noundef 45)
  store i32 %45, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %369

46:                                               ; preds = %29
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.MDBX_txn, ptr %47, i32 0, i32 10
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds %struct.tree, ptr %49, i64 %51
  %53 = getelementptr inbounds %struct.tree, ptr %52, i32 0, i32 1
  %54 = load i16, ptr %53, align 2, !tbaa !19
  %55 = icmp ne i16 %54, 0
  br i1 %55, label %56, label %109

56:                                               ; preds = %46
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.MDBX_txn, ptr %57, i32 0, i32 14
  %59 = load ptr, ptr %58, align 8, !tbaa !21
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %59, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %65 = getelementptr inbounds %struct.MDBX_cursor, ptr %64, i32 0, i32 11
  store ptr %63, ptr %65, align 8, !tbaa !22
  %66 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.MDBX_txn, ptr %67, i32 0, i32 14
  %69 = load ptr, ptr %68, align 8, !tbaa !21
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  store ptr %66, ptr %72, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = icmp eq i32 %74, 1
  br i1 %75, label %85, label %76

76:                                               ; preds = %56
  %77 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %78 = getelementptr inbounds %struct.MDBX_cursor, ptr %77, i32 0, i32 6
  %79 = load ptr, ptr %78, align 8, !tbaa !26
  %80 = getelementptr inbounds %struct.tree, ptr %79, i32 0, i32 0
  %81 = load i16, ptr %80, align 4, !tbaa !27
  %82 = zext i16 %81 to i32
  %83 = and i32 %82, 4
  %84 = icmp ne i32 %83, 0
  br label %85

85:                                               ; preds = %76, %56
  %86 = phi i1 [ true, %56 ], [ %84, %76 ]
  %87 = call i32 @tree_drop(ptr noundef %73, i1 noundef zeroext %86)
  store i32 %87, ptr %8, align 4, !tbaa !9
  %88 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %89 = getelementptr inbounds %struct.MDBX_cursor, ptr %88, i32 0, i32 11
  %90 = load ptr, ptr %89, align 8, !tbaa !22
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.MDBX_txn, ptr %91, i32 0, i32 14
  %93 = load ptr, ptr %92, align 8, !tbaa !21
  %94 = load i32, ptr %6, align 4, !tbaa !9
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds ptr, ptr %93, i64 %95
  store ptr %90, ptr %96, align 8, !tbaa !5
  %97 = load i32, ptr %8, align 4, !tbaa !9
  %98 = icmp ne i32 %97, 0
  %99 = xor i1 %98, true
  %100 = xor i1 %99, true
  %101 = zext i1 %100 to i32
  %102 = sext i32 %101 to i64
  %103 = call i64 @llvm.expect.i64(i64 %102, i64 0)
  %104 = icmp ne i64 %103, 0
  br i1 %104, label %105, label %108

105:                                              ; preds = %85
  %106 = load i32, ptr %8, align 4, !tbaa !9
  %107 = call i32 @log_if_error(i32 noundef %106, ptr noundef @__func__.mdbx_drop, i32 noundef 53)
  store i32 %107, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %369

108:                                              ; preds = %85
  br label %109

109:                                              ; preds = %108, %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.MDBX_txn, ptr %110, i32 0, i32 14
  %112 = load ptr, ptr %111, align 8, !tbaa !21
  %113 = load i32, ptr %6, align 4, !tbaa !9
  %114 = zext i32 %113 to i64
  %115 = getelementptr inbounds ptr, ptr %112, i64 %114
  %116 = load ptr, ptr %115, align 8, !tbaa !5
  store ptr %116, ptr %11, align 8, !tbaa !5
  br label %117

117:                                              ; preds = %123, %109
  %118 = load ptr, ptr %11, align 8, !tbaa !5
  %119 = icmp ne ptr %118, null
  br i1 %119, label %121, label %120

120:                                              ; preds = %117
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %127

121:                                              ; preds = %117
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  call void @be_poor(ptr noundef %122)
  br label %123

123:                                              ; preds = %121
  %124 = load ptr, ptr %11, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.MDBX_cursor, ptr %124, i32 0, i32 11
  %126 = load ptr, ptr %125, align 8, !tbaa !28
  store ptr %126, ptr %11, align 8, !tbaa !5
  br label %117, !llvm.loop !29

127:                                              ; preds = %120
  %128 = load i8, ptr %7, align 1, !tbaa !11, !range !31, !noundef !32
  %129 = trunc i8 %128 to i1
  br i1 %129, label %130, label %133

130:                                              ; preds = %127
  %131 = load i32, ptr %6, align 4, !tbaa !9
  %132 = icmp ult i32 %131, 2
  br i1 %132, label %133, label %197

133:                                              ; preds = %130, %127
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.MDBX_txn, ptr %134, i32 0, i32 12
  %136 = load ptr, ptr %135, align 8, !tbaa !33
  %137 = load i32, ptr %6, align 4, !tbaa !9
  %138 = zext i32 %137 to i64
  %139 = getelementptr inbounds i8, ptr %136, i64 %138
  %140 = load i8, ptr %139, align 1, !tbaa !34
  %141 = zext i8 %140 to i32
  %142 = or i32 %141, 1
  %143 = trunc i32 %142 to i8
  store i8 %143, ptr %139, align 1, !tbaa !34
  %144 = load ptr, ptr %5, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.MDBX_txn, ptr %144, i32 0, i32 10
  %146 = load ptr, ptr %145, align 8, !tbaa !13
  %147 = load i32, ptr %6, align 4, !tbaa !9
  %148 = zext i32 %147 to i64
  %149 = getelementptr inbounds %struct.tree, ptr %146, i64 %148
  %150 = getelementptr inbounds %struct.tree, ptr %149, i32 0, i32 1
  store i16 0, ptr %150, align 2, !tbaa !19
  %151 = load ptr, ptr %5, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.MDBX_txn, ptr %151, i32 0, i32 10
  %153 = load ptr, ptr %152, align 8, !tbaa !13
  %154 = load i32, ptr %6, align 4, !tbaa !9
  %155 = zext i32 %154 to i64
  %156 = getelementptr inbounds %struct.tree, ptr %153, i64 %155
  %157 = getelementptr inbounds %struct.tree, ptr %156, i32 0, i32 4
  store i32 0, ptr %157, align 4, !tbaa !35
  %158 = load ptr, ptr %5, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.MDBX_txn, ptr %158, i32 0, i32 10
  %160 = load ptr, ptr %159, align 8, !tbaa !13
  %161 = load i32, ptr %6, align 4, !tbaa !9
  %162 = zext i32 %161 to i64
  %163 = getelementptr inbounds %struct.tree, ptr %160, i64 %162
  %164 = getelementptr inbounds %struct.tree, ptr %163, i32 0, i32 5
  store i32 0, ptr %164, align 4, !tbaa !36
  %165 = load ptr, ptr %5, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.MDBX_txn, ptr %165, i32 0, i32 10
  %167 = load ptr, ptr %166, align 8, !tbaa !13
  %168 = load i32, ptr %6, align 4, !tbaa !9
  %169 = zext i32 %168 to i64
  %170 = getelementptr inbounds %struct.tree, ptr %167, i64 %169
  %171 = getelementptr inbounds %struct.tree, ptr %170, i32 0, i32 6
  store i32 0, ptr %171, align 4, !tbaa !37
  %172 = load ptr, ptr %5, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.MDBX_txn, ptr %172, i32 0, i32 10
  %174 = load ptr, ptr %173, align 8, !tbaa !13
  %175 = load i32, ptr %6, align 4, !tbaa !9
  %176 = zext i32 %175 to i64
  %177 = getelementptr inbounds %struct.tree, ptr %174, i64 %176
  %178 = getelementptr inbounds %struct.tree, ptr %177, i32 0, i32 8
  store i64 0, ptr %178, align 4, !tbaa !38
  %179 = load ptr, ptr %5, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.MDBX_txn, ptr %179, i32 0, i32 10
  %181 = load ptr, ptr %180, align 8, !tbaa !13
  %182 = load i32, ptr %6, align 4, !tbaa !9
  %183 = zext i32 %182 to i64
  %184 = getelementptr inbounds %struct.tree, ptr %181, i64 %183
  %185 = getelementptr inbounds %struct.tree, ptr %184, i32 0, i32 3
  store i32 -1, ptr %185, align 4, !tbaa !39
  %186 = load ptr, ptr %5, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.MDBX_txn, ptr %186, i32 0, i32 10
  %188 = load ptr, ptr %187, align 8, !tbaa !13
  %189 = load i32, ptr %6, align 4, !tbaa !9
  %190 = zext i32 %189 to i64
  %191 = getelementptr inbounds %struct.tree, ptr %188, i64 %190
  %192 = getelementptr inbounds %struct.tree, ptr %191, i32 0, i32 7
  store i64 0, ptr %192, align 4, !tbaa !40
  %193 = load ptr, ptr %5, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.MDBX_txn, ptr %193, i32 0, i32 1
  %195 = load i32, ptr %194, align 4, !tbaa !41
  %196 = or i32 %195, 4
  store i32 %196, ptr %194, align 4, !tbaa !41
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %369

197:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %198 = load ptr, ptr %5, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.MDBX_txn, ptr %198, i32 0, i32 9
  %200 = load ptr, ptr %199, align 8, !tbaa !42
  store ptr %200, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #7
  %201 = load ptr, ptr %12, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.MDBX_env, ptr %201, i32 0, i32 25
  %203 = load ptr, ptr %202, align 8, !tbaa !43
  %204 = load i32, ptr %6, align 4, !tbaa !9
  %205 = zext i32 %204 to i64
  %206 = getelementptr inbounds %struct.kvx, ptr %203, i64 %205
  %207 = getelementptr inbounds %struct.kvx, ptr %206, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %207, i64 16, i1 false), !tbaa.struct !52
  %208 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %209 = load ptr, ptr %5, align 8, !tbaa !5
  %210 = call i32 @cursor_init(ptr noundef %208, ptr noundef %209, i64 noundef 1)
  store i32 %210, ptr %8, align 4, !tbaa !9
  %211 = load i32, ptr %8, align 4, !tbaa !9
  %212 = icmp eq i32 %211, 0
  %213 = xor i1 %212, true
  %214 = xor i1 %213, true
  %215 = zext i1 %214 to i32
  %216 = sext i32 %215 to i64
  %217 = call i64 @llvm.expect.i64(i64 %216, i64 1)
  %218 = icmp ne i64 %217, 0
  br i1 %218, label %219, label %361

219:                                              ; preds = %197
  %220 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %221 = call i64 @cursor_seek(ptr noundef %220, ptr noundef %13, ptr noundef null, i32 noundef 15)
  store i64 %221, ptr %14, align 4
  %222 = getelementptr inbounds %struct.cursor_set_result, ptr %14, i32 0, i32 0
  %223 = load i32, ptr %222, align 4, !tbaa !54
  store i32 %223, ptr %8, align 4, !tbaa !9
  %224 = load i32, ptr %8, align 4, !tbaa !9
  %225 = icmp eq i32 %224, 0
  %226 = xor i1 %225, true
  %227 = xor i1 %226, true
  %228 = zext i1 %227 to i32
  %229 = sext i32 %228 to i64
  %230 = call i64 @llvm.expect.i64(i64 %229, i64 1)
  %231 = icmp ne i64 %230, 0
  br i1 %231, label %232, label %360

232:                                              ; preds = %219
  %233 = load ptr, ptr %5, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.MDBX_txn, ptr %233, i32 0, i32 14
  %235 = load ptr, ptr %234, align 8, !tbaa !21
  %236 = getelementptr inbounds ptr, ptr %235, i64 1
  %237 = load ptr, ptr %236, align 8, !tbaa !5
  %238 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %239 = getelementptr inbounds %struct.MDBX_cursor, ptr %238, i32 0, i32 11
  store ptr %237, ptr %239, align 8, !tbaa !22
  %240 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %241 = load ptr, ptr %5, align 8, !tbaa !5
  %242 = getelementptr inbounds %struct.MDBX_txn, ptr %241, i32 0, i32 14
  %243 = load ptr, ptr %242, align 8, !tbaa !21
  %244 = getelementptr inbounds ptr, ptr %243, i64 1
  store ptr %240, ptr %244, align 8, !tbaa !5
  %245 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %246 = call i32 @cursor_del(ptr noundef %245, i32 noundef 2)
  store i32 %246, ptr %8, align 4, !tbaa !9
  %247 = getelementptr inbounds %struct.cursor_couple, ptr %10, i32 0, i32 0
  %248 = getelementptr inbounds %struct.MDBX_cursor, ptr %247, i32 0, i32 11
  %249 = load ptr, ptr %248, align 8, !tbaa !22
  %250 = load ptr, ptr %5, align 8, !tbaa !5
  %251 = getelementptr inbounds %struct.MDBX_txn, ptr %250, i32 0, i32 14
  %252 = load ptr, ptr %251, align 8, !tbaa !21
  %253 = getelementptr inbounds ptr, ptr %252, i64 1
  store ptr %249, ptr %253, align 8, !tbaa !5
  %254 = load i32, ptr %8, align 4, !tbaa !9
  %255 = icmp eq i32 %254, 0
  %256 = xor i1 %255, true
  %257 = xor i1 %256, true
  %258 = zext i1 %257 to i32
  %259 = sext i32 %258 to i64
  %260 = call i64 @llvm.expect.i64(i64 %259, i64 1)
  %261 = icmp ne i64 %260, 0
  br i1 %261, label %262, label %359

262:                                              ; preds = %232
  br label %263

263:                                              ; preds = %262
  %264 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !56
  %265 = zext i8 %264 to i32
  %266 = and i32 %265, 1
  %267 = icmp ne i32 %266, 0
  %268 = xor i1 %267, true
  %269 = xor i1 %268, true
  %270 = zext i1 %269 to i32
  %271 = sext i32 %270 to i64
  %272 = call i64 @llvm.expect.i64(i64 %271, i64 1)
  %273 = icmp ne i64 %272, 0
  br i1 %273, label %274, label %298

274:                                              ; preds = %263
  br label %275

275:                                              ; preds = %274
  %276 = load ptr, ptr %5, align 8, !tbaa !5
  %277 = getelementptr inbounds %struct.MDBX_txn, ptr %276, i32 0, i32 12
  %278 = load ptr, ptr %277, align 8, !tbaa !33
  %279 = getelementptr inbounds i8, ptr %278, i64 1
  %280 = load i8, ptr %279, align 1, !tbaa !34
  %281 = zext i8 %280 to i32
  %282 = and i32 %281, 1
  %283 = icmp ne i32 %282, 0
  %284 = xor i1 %283, true
  %285 = xor i1 %284, true
  %286 = xor i1 %285, true
  %287 = zext i1 %286 to i32
  %288 = sext i32 %287 to i64
  %289 = call i64 @llvm.expect.i64(i64 %288, i64 0)
  %290 = icmp ne i64 %289, 0
  br i1 %290, label %291, label %295

291:                                              ; preds = %275
  %292 = load ptr, ptr %5, align 8, !tbaa !5
  %293 = getelementptr inbounds %struct.MDBX_txn, ptr %292, i32 0, i32 9
  %294 = load ptr, ptr %293, align 8, !tbaa !42
  call void @mdbx_assert_fail(ptr noundef %294, ptr noundef @.str, ptr noundef @__func__.mdbx_drop, i32 noundef 86) #8
  unreachable

295:                                              ; preds = %275
  br label %296

296:                                              ; preds = %295
  br label %297

297:                                              ; preds = %296
  br label %298

298:                                              ; preds = %297, %263
  br label %299

299:                                              ; preds = %298
  br label %300

300:                                              ; preds = %299
  br label %301

301:                                              ; preds = %300
  %302 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !56
  %303 = zext i8 %302 to i32
  %304 = and i32 %303, 1
  %305 = icmp ne i32 %304, 0
  %306 = xor i1 %305, true
  %307 = xor i1 %306, true
  %308 = zext i1 %307 to i32
  %309 = sext i32 %308 to i64
  %310 = call i64 @llvm.expect.i64(i64 %309, i64 1)
  %311 = icmp ne i64 %310, 0
  br i1 %311, label %312, label %333

312:                                              ; preds = %301
  br label %313

313:                                              ; preds = %312
  %314 = load ptr, ptr %5, align 8, !tbaa !5
  %315 = getelementptr inbounds %struct.MDBX_txn, ptr %314, i32 0, i32 1
  %316 = load i32, ptr %315, align 4, !tbaa !41
  %317 = and i32 %316, 4
  %318 = icmp ne i32 %317, 0
  %319 = xor i1 %318, true
  %320 = xor i1 %319, true
  %321 = xor i1 %320, true
  %322 = zext i1 %321 to i32
  %323 = sext i32 %322 to i64
  %324 = call i64 @llvm.expect.i64(i64 %323, i64 0)
  %325 = icmp ne i64 %324, 0
  br i1 %325, label %326, label %330

326:                                              ; preds = %313
  %327 = load ptr, ptr %5, align 8, !tbaa !5
  %328 = getelementptr inbounds %struct.MDBX_txn, ptr %327, i32 0, i32 9
  %329 = load ptr, ptr %328, align 8, !tbaa !42
  call void @mdbx_assert_fail(ptr noundef %329, ptr noundef @.str.1, ptr noundef @__func__.mdbx_drop, i32 noundef 87) #8
  unreachable

330:                                              ; preds = %313
  br label %331

331:                                              ; preds = %330
  br label %332

332:                                              ; preds = %331
  br label %333

333:                                              ; preds = %332, %301
  br label %334

334:                                              ; preds = %333
  br label %335

335:                                              ; preds = %334
  %336 = load ptr, ptr %5, align 8, !tbaa !5
  %337 = getelementptr inbounds %struct.MDBX_txn, ptr %336, i32 0, i32 12
  %338 = load ptr, ptr %337, align 8, !tbaa !33
  %339 = load i32, ptr %6, align 4, !tbaa !9
  %340 = zext i32 %339 to i64
  %341 = getelementptr inbounds i8, ptr %338, i64 %340
  store i8 -64, ptr %341, align 1, !tbaa !34
  %342 = load ptr, ptr %12, align 8, !tbaa !5
  %343 = getelementptr inbounds %struct.MDBX_env, ptr %342, i32 0, i32 41
  %344 = call i32 @osal_fastmutex_acquire(ptr noundef %343)
  store i32 %344, ptr %8, align 4, !tbaa !9
  %345 = load i32, ptr %8, align 4, !tbaa !9
  %346 = icmp eq i32 %345, 0
  %347 = xor i1 %346, true
  %348 = xor i1 %347, true
  %349 = zext i1 %348 to i32
  %350 = sext i32 %349 to i64
  %351 = call i64 @llvm.expect.i64(i64 %350, i64 1)
  %352 = icmp ne i64 %351, 0
  br i1 %352, label %353, label %358

353:                                              ; preds = %335
  %354 = load ptr, ptr %12, align 8, !tbaa !5
  %355 = load i32, ptr %6, align 4, !tbaa !9
  %356 = call i32 @dbi_close_release(ptr noundef %354, i32 noundef %355)
  %357 = call i32 @log_if_error(i32 noundef %356, ptr noundef @__func__.mdbx_drop, i32 noundef 91)
  store i32 %357, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %368

358:                                              ; preds = %335
  br label %359

359:                                              ; preds = %358, %232
  br label %360

360:                                              ; preds = %359, %219
  br label %361

361:                                              ; preds = %360, %197
  %362 = load ptr, ptr %5, align 8, !tbaa !5
  %363 = getelementptr inbounds %struct.MDBX_txn, ptr %362, i32 0, i32 1
  %364 = load i32, ptr %363, align 4, !tbaa !41
  %365 = or i32 %364, 2
  store i32 %365, ptr %363, align 4, !tbaa !41
  %366 = load i32, ptr %8, align 4, !tbaa !9
  %367 = call i32 @log_if_error(i32 noundef %366, ptr noundef @__func__.mdbx_drop, i32 noundef 97)
  store i32 %367, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %368

368:                                              ; preds = %361, %353
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %369

369:                                              ; preds = %368, %133, %105, %43
  call void @llvm.lifetime.end.p0(i64 824, ptr %10) #7
  br label %370

370:                                              ; preds = %369, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  %371 = load i32, ptr %4, align 4
  ret i32 %371
}

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

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

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

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

declare i32 @tree_drop(ptr noundef, i1 noundef zeroext) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @be_poor(ptr noundef) #0

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

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

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

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

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

declare i32 @osal_fastmutex_acquire(ptr noundef) #4

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !6, i64 88}
!14 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !15, i64 8, !15, i64 16, !6, i64 24, !6, i64 32, !16, i64 40, !15, i64 64, !15, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !18, i64 128, !6, i64 160, !7, i64 168}
!15 = !{!"long", !7, i64 0}
!16 = !{!"geo", !17, i64 0, !17, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!"MDBX_canary", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24}
!19 = !{!20, !17, i64 2}
!20 = !{!"tree", !17, i64 0, !17, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !15, i64 24, !15, i64 32, !15, i64 40}
!21 = !{!14, !6, i64 120}
!22 = !{!23, !6, i64 368}
!23 = !{!"cursor_couple", !24, i64 0, !6, i64 384, !25, i64 392}
!24 = !{!"MDBX_cursor", !10, i64 0, !7, i64 4, !7, i64 6, !7, i64 7, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !7, i64 304, !6, i64 368, !6, i64 376}
!25 = !{!"inner_cursor", !24, i64 0, !20, i64 384}
!26 = !{!23, !6, i64 24}
!27 = !{!20, !17, i64 0}
!28 = !{!24, !6, i64 368}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{i8 0, i8 2}
!32 = !{}
!33 = !{!14, !6, i64 104}
!34 = !{!7, !7, i64 0}
!35 = !{!20, !10, i64 12}
!36 = !{!20, !10, i64 16}
!37 = !{!20, !10, i64 20}
!38 = !{!20, !15, i64 32}
!39 = !{!20, !10, i64 8}
!40 = !{!20, !15, i64 24}
!41 = !{!14, !10, i64 4}
!42 = !{!14, !6, i64 80}
!43 = !{!44, !6, i64 200}
!44 = !{!"MDBX_env", !7, i64 0, !10, i64 4, !10, i64 8, !45, i64 16, !10, i64 56, !10, i64 60, !45, i64 64, !6, i64 104, !17, i64 112, !17, i64 114, !17, i64 116, !17, i64 118, !17, i64 120, !17, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !17, i64 130, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !46, i64 152, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !10, i64 228, !10, i64 232, !6, i64 240, !6, i64 248, !15, i64 256, !47, i64 264, !49, i64 320, !12, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !50, i64 392, !7, i64 400, !10, i64 440, !10, i64 444, !6, i64 448, !51, i64 456, !7, i64 496, !7, i64 536}
!45 = !{!"osal_mmap", !7, i64 0, !10, i64 8, !15, i64 16, !15, i64 24, !15, i64 32}
!46 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!47 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !15, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !10, i64 28, !10, i64 32, !12, i64 36, !12, i64 37, !12, i64 38, !48, i64 40, !7, i64 48}
!48 = !{!"", !17, i64 0, !17, i64 2, !17, i64 4, !17, i64 6}
!49 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32}
!50 = !{!"", !15, i64 0}
!51 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!52 = !{i64 0, i64 8, !5, i64 8, i64 8, !53}
!53 = !{!15, !15, i64 0}
!54 = !{!55, !10, i64 0}
!55 = !{!"cursor_set_result", !10, i64 0, !12, i64 4}
!56 = !{!57, !7, i64 25}
!57 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !12, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !15, i64 80, !6, i64 88}


; 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.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 }

@__func__.mdbx_drop = external hidden unnamed_addr constant [10 x i8], align 1
@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 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: cold nounwind optsize uwtable
define dso_local i32 @mdbx_drop(ptr noundef %0, i32 noundef %1, i1 noundef zeroext %2) local_unnamed_addr #1 {
  %4 = alloca %struct.cursor_couple, align 8
  %5 = alloca %struct.iovec, align 8
  %6 = tail call i32 @check_txn_rw(ptr noundef %0, i32 noundef 51)
  %.not74 = icmp eq i32 %6, 0
  br i1 %.not74, label %9, label %7, !prof !5

7:                                                ; preds = %3
  %8 = tail call i32 @log_if_error(i32 noundef %6, ptr noundef nonnull @__func__.mdbx_drop, i32 noundef 40)
  br label %113

9:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 824, ptr nonnull %4) #6
  %10 = zext i32 %1 to i64
  %11 = call i32 @cursor_init(ptr noundef nonnull %4, ptr noundef %0, i64 noundef %10) #6
  %.not75 = icmp eq i32 %11, 0
  br i1 %.not75, label %14, label %12, !prof !5

12:                                               ; preds = %9
  %13 = call i32 @log_if_error(i32 noundef %11, ptr noundef nonnull @__func__.mdbx_drop, i32 noundef 45)
  br label %112

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %0, i64 88
  %16 = load ptr, ptr %15, align 8, !tbaa !6
  %17 = getelementptr inbounds %struct.tree, ptr %16, i64 %10, i32 1
  %18 = load i16, ptr %17, align 2, !tbaa !16
  %.not76 = icmp eq i16 %18, 0
  br i1 %.not76, label %40, label %19

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %0, i64 120
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = getelementptr inbounds ptr, ptr %21, i64 %10
  %23 = load ptr, ptr %22, align 8, !tbaa !19
  %24 = getelementptr inbounds i8, ptr %4, i64 368
  store ptr %23, ptr %24, align 8, !tbaa !20
  store ptr %4, ptr %22, align 8, !tbaa !19
  %25 = icmp eq i32 %1, 1
  br i1 %25, label %32, label %26

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %4, i64 24
  %28 = load ptr, ptr %27, align 8, !tbaa !24
  %29 = load i16, ptr %28, align 4, !tbaa !25
  %30 = and i16 %29, 4
  %31 = icmp ne i16 %30, 0
  br label %32

32:                                               ; preds = %26, %19
  %33 = phi i1 [ true, %19 ], [ %31, %26 ]
  %34 = call i32 @tree_drop(ptr noundef nonnull %4, i1 noundef zeroext %33) #6
  %35 = load ptr, ptr %24, align 8, !tbaa !20
  %36 = load ptr, ptr %20, align 8, !tbaa !18
  %37 = getelementptr inbounds ptr, ptr %36, i64 %10
  store ptr %35, ptr %37, align 8, !tbaa !19
  %.not77 = icmp eq i32 %34, 0
  br i1 %.not77, label %40, label %38, !prof !5

38:                                               ; preds = %32
  %39 = call i32 @log_if_error(i32 noundef %34, ptr noundef nonnull @__func__.mdbx_drop, i32 noundef 53)
  br label %112

40:                                               ; preds = %32, %14
  %41 = getelementptr inbounds i8, ptr %0, i64 120
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = getelementptr inbounds ptr, ptr %42, i64 %10
  %.06683 = load ptr, ptr %43, align 8, !tbaa !19
  %.not7884 = icmp eq ptr %.06683, null
  br i1 %.not7884, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %40
  %44 = icmp ugt i32 %1, 1
  %or.cond.not = and i1 %44, %2
  br i1 %or.cond.not, label %63, label %46

.lr.ph:                                           ; preds = %40, %.lr.ph
  %.06685 = phi ptr [ %.066, %.lr.ph ], [ %.06683, %40 ]
  call void @be_poor(ptr noundef nonnull %.06685)
  %45 = getelementptr inbounds i8, ptr %.06685, i64 368
  %.066 = load ptr, ptr %45, align 8, !tbaa !19
  %.not78 = icmp eq ptr %.066, null
  br i1 %.not78, label %._crit_edge, label %.lr.ph, !llvm.loop !26

46:                                               ; preds = %._crit_edge
  %47 = getelementptr inbounds i8, ptr %0, i64 104
  %48 = load ptr, ptr %47, align 8, !tbaa !28
  %49 = getelementptr inbounds i8, ptr %48, i64 %10
  %50 = load i8, ptr %49, align 1, !tbaa !29
  %51 = or i8 %50, 1
  store i8 %51, ptr %49, align 1, !tbaa !29
  %52 = load ptr, ptr %15, align 8, !tbaa !6
  %53 = getelementptr inbounds %struct.tree, ptr %52, i64 %10, i32 1
  store i16 0, ptr %53, align 2, !tbaa !16
  %54 = getelementptr inbounds %struct.tree, ptr %52, i64 %10, i32 4
  store i32 0, ptr %54, align 4, !tbaa !30
  %55 = getelementptr inbounds %struct.tree, ptr %52, i64 %10, i32 5
  store i32 0, ptr %55, align 4, !tbaa !31
  %56 = getelementptr inbounds %struct.tree, ptr %52, i64 %10, i32 6
  store i32 0, ptr %56, align 4, !tbaa !32
  %57 = getelementptr inbounds %struct.tree, ptr %52, i64 %10, i32 8
  store i64 0, ptr %57, align 4, !tbaa !33
  %58 = getelementptr inbounds %struct.tree, ptr %52, i64 %10, i32 3
  store i32 -1, ptr %58, align 4, !tbaa !34
  %59 = getelementptr inbounds %struct.tree, ptr %52, i64 %10, i32 7
  store i64 0, ptr %59, align 4, !tbaa !35
  %60 = getelementptr inbounds i8, ptr %0, i64 4
  %61 = load i32, ptr %60, align 4, !tbaa !36
  %62 = or i32 %61, 4
  store i32 %62, ptr %60, align 4, !tbaa !36
  br label %112

63:                                               ; preds = %._crit_edge
  %64 = getelementptr inbounds i8, ptr %0, i64 80
  %65 = load ptr, ptr %64, align 8, !tbaa !37
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  %66 = getelementptr inbounds i8, ptr %65, i64 200
  %67 = load ptr, ptr %66, align 8, !tbaa !38
  %68 = getelementptr inbounds %struct.kvx, ptr %67, i64 %10, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %68, i64 16, i1 false), !tbaa.struct !48
  %69 = call i32 @cursor_init(ptr noundef nonnull %4, ptr noundef %0, i64 noundef 1) #6
  %70 = icmp eq i32 %69, 0
  br i1 %70, label %71, label %106, !prof !5

71:                                               ; preds = %63
  %72 = call i64 @cursor_seek(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef null, i32 noundef 15) #6
  %.sroa.0.0.extract.trunc = trunc i64 %72 to i32
  %73 = icmp eq i32 %.sroa.0.0.extract.trunc, 0
  br i1 %73, label %74, label %106, !prof !5

74:                                               ; preds = %71
  %75 = load ptr, ptr %41, align 8, !tbaa !18
  %76 = getelementptr inbounds i8, ptr %75, i64 8
  %77 = load ptr, ptr %76, align 8, !tbaa !19
  %78 = getelementptr inbounds i8, ptr %4, i64 368
  store ptr %77, ptr %78, align 8, !tbaa !20
  store ptr %4, ptr %76, align 8, !tbaa !19
  %79 = call i32 @cursor_del(ptr noundef nonnull %4, i32 noundef 2) #6
  %80 = load ptr, ptr %78, align 8, !tbaa !20
  %81 = load ptr, ptr %41, align 8, !tbaa !18
  %82 = getelementptr inbounds i8, ptr %81, i64 8
  store ptr %80, ptr %82, align 8, !tbaa !19
  %83 = icmp eq i32 %79, 0
  br i1 %83, label %84, label %106, !prof !5

84:                                               ; preds = %74
  %85 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !50
  %86 = and i8 %85, 1
  %.not = icmp eq i8 %86, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 104
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !28
  br i1 %.not, label %.thread, label %87, !prof !52

87:                                               ; preds = %84
  %88 = getelementptr inbounds i8, ptr %.pre, i64 1
  %89 = load i8, ptr %88, align 1, !tbaa !29
  %90 = and i8 %89, 1
  %.not80 = icmp eq i8 %90, 0
  br i1 %.not80, label %91, label %93, !prof !52

91:                                               ; preds = %87
  %92 = load ptr, ptr %64, align 8, !tbaa !37
  call void @mdbx_assert_fail(ptr noundef %92, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.mdbx_drop, i32 noundef 86) #7
  unreachable

93:                                               ; preds = %87
  %94 = getelementptr inbounds i8, ptr %0, i64 4
  %95 = load i32, ptr %94, align 4, !tbaa !36
  %96 = and i32 %95, 4
  %.not82 = icmp eq i32 %96, 0
  br i1 %.not82, label %97, label %.thread, !prof !52

97:                                               ; preds = %93
  %98 = load ptr, ptr %64, align 8, !tbaa !37
  call void @mdbx_assert_fail(ptr noundef %98, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.mdbx_drop, i32 noundef 87) #7
  unreachable

.thread:                                          ; preds = %84, %93
  %99 = getelementptr inbounds i8, ptr %.pre, i64 %10
  store i8 -64, ptr %99, align 1, !tbaa !29
  %100 = getelementptr inbounds i8, ptr %65, i64 400
  %101 = call i32 @osal_fastmutex_acquire(ptr noundef nonnull %100) #6
  %102 = icmp eq i32 %101, 0
  br i1 %102, label %103, label %106, !prof !5

103:                                              ; preds = %.thread
  %104 = call i32 @dbi_close_release(ptr noundef nonnull %65, i32 noundef %1) #6
  %105 = call i32 @log_if_error(i32 noundef %104, ptr noundef nonnull @__func__.mdbx_drop, i32 noundef 91)
  br label %111

106:                                              ; preds = %71, %.thread, %74, %63
  %.065 = phi i32 [ %101, %.thread ], [ %79, %74 ], [ %.sroa.0.0.extract.trunc, %71 ], [ %69, %63 ]
  %107 = getelementptr inbounds i8, ptr %0, i64 4
  %108 = load i32, ptr %107, align 4, !tbaa !36
  %109 = or i32 %108, 2
  store i32 %109, ptr %107, align 4, !tbaa !36
  %110 = call i32 @log_if_error(i32 noundef %.065, ptr noundef nonnull @__func__.mdbx_drop, i32 noundef 97)
  br label %111

111:                                              ; preds = %106, %103
  %.0 = phi i32 [ %105, %103 ], [ %110, %106 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  br label %112

112:                                              ; preds = %111, %46, %38, %12
  %.1 = phi i32 [ %13, %12 ], [ %39, %38 ], [ 0, %46 ], [ %.0, %111 ]
  call void @llvm.lifetime.end.p0(i64 824, ptr nonnull %4) #6
  br label %113

113:                                              ; preds = %112, %7
  %.2 = phi i32 [ %8, %7 ], [ %.1, %112 ]
  ret i32 %.2
}

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

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

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

declare i32 @tree_drop(ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @be_poor(ptr noundef) local_unnamed_addr #0

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

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

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

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

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

declare i32 @osal_fastmutex_acquire(ptr noundef) local_unnamed_addr #3

declare i32 @dbi_close_release(ptr noundef, i32 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 = { cold nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
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 2000, i32 1}
!6 = !{!7, !12, i64 88}
!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, !14, i64 2}
!17 = !{!"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}
!18 = !{!7, !12, i64 120}
!19 = !{!12, !12, i64 0}
!20 = !{!21, !12, i64 368}
!21 = !{!"cursor_couple", !22, i64 0, !12, i64 384, !23, i64 392}
!22 = !{!"MDBX_cursor", !8, i64 0, !9, i64 4, !9, i64 6, !9, i64 7, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !9, i64 48, !9, i64 304, !12, i64 368, !12, i64 376}
!23 = !{!"inner_cursor", !22, i64 0, !17, i64 384}
!24 = !{!21, !12, i64 24}
!25 = !{!17, !14, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!7, !12, i64 104}
!29 = !{!9, !9, i64 0}
!30 = !{!17, !8, i64 12}
!31 = !{!17, !8, i64 16}
!32 = !{!17, !8, i64 20}
!33 = !{!17, !11, i64 32}
!34 = !{!17, !8, i64 8}
!35 = !{!17, !11, i64 24}
!36 = !{!7, !8, i64 4}
!37 = !{!7, !12, i64 80}
!38 = !{!39, !12, i64 200}
!39 = !{!"MDBX_env", !9, i64 0, !8, i64 4, !8, i64 8, !40, i64 16, !8, i64 56, !8, i64 60, !40, 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, !41, 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, !42, i64 264, !45, i64 320, !43, i64 360, !12, i64 368, !12, i64 376, !12, i64 384, !46, i64 392, !9, i64 400, !8, i64 440, !8, i64 444, !12, i64 448, !47, i64 456, !9, i64 496, !9, i64 536}
!40 = !{!"osal_mmap", !9, i64 0, !8, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!41 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!42 = !{!"", !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, !43, i64 36, !43, i64 37, !43, i64 38, !44, i64 40, !9, i64 48}
!43 = !{!"_Bool", !9, i64 0}
!44 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6}
!45 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!46 = !{!"", !11, i64 0}
!47 = !{!"osal_ioring", !8, i64 0, !8, i64 4, !8, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!48 = !{i64 0, i64 8, !19, i64 8, i64 8, !49}
!49 = !{!11, !11, i64 0}
!50 = !{!51, !9, i64 25}
!51 = !{!"libmdbx_globals", !9, i64 0, !8, i64 16, !8, i64 20, !9, i64 24, !9, i64 25, !9, i64 26, !43, i64 27, !8, i64 28, !9, i64 32, !9, i64 40, !11, i64 80, !12, i64 88}
!52 = !{!"branch_weights", !"expected", i32 1, i32 2000}


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