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

; 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.6 }
%struct.anon.6 = 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.8, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon.8 = 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.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.1 }
%struct.geo = type { i16, i16, i32, i32, %union.anon, %union.anon.0 }
%union.anon = type { i32 }
%union.anon.0 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.1 = type { %struct.anon.2 }
%struct.anon.2 = type { %struct.troika, ptr, %struct.anon.3, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.4 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.3 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.4 = type { %struct.anon.5 }
%struct.anon.5 = type { i64, ptr }

@__func__.mdbx_dbi_sequence = external hidden unnamed_addr constant [18 x i8], align 1
@globals = external global %struct.libmdbx_globals, align 8
@.str = external hidden unnamed_addr constant [20 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: inlinehint nounwind uwtable
declare hidden i32 @log_if_error(i32 noundef, ptr noundef, i32 noundef) #2

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

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

25:                                               ; preds = %4
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = call i32 @log_if_error(i32 noundef %26, ptr noundef @__func__.mdbx_dbi_sequence, i32 noundef 33)
  store i32 %27, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %261

28:                                               ; preds = %4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = call i32 @dbi_check(ptr noundef %29, i64 noundef %31)
  store i32 %32, ptr %10, align 4, !tbaa !9
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = icmp ne i32 %33, 0
  %35 = xor i1 %34, true
  %36 = xor i1 %35, true
  %37 = zext i1 %36 to i32
  %38 = sext i32 %37 to i64
  %39 = call i64 @llvm.expect.i64(i64 %38, i64 0)
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %41, label %44

41:                                               ; preds = %28
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = call i32 @log_if_error(i32 noundef %42, ptr noundef @__func__.mdbx_dbi_sequence, i32 noundef 37)
  store i32 %43, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %261

44:                                               ; preds = %28
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.MDBX_txn, ptr %45, i32 0, i32 12
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %47, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !18
  %52 = zext i8 %51 to i32
  %53 = and i32 %52, 2
  %54 = icmp ne i32 %53, 0
  %55 = xor i1 %54, true
  %56 = xor i1 %55, true
  %57 = zext i1 %56 to i32
  %58 = sext i32 %57 to i64
  %59 = call i64 @llvm.expect.i64(i64 %58, i64 0)
  %60 = icmp ne i64 %59, 0
  br i1 %60, label %61, label %78

61:                                               ; preds = %44
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = call i32 @tbl_fetch(ptr noundef %62, i64 noundef %64)
  store i32 %65, ptr %10, align 4, !tbaa !9
  %66 = load i32, ptr %10, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 0
  %68 = xor i1 %67, true
  %69 = xor i1 %68, true
  %70 = zext i1 %69 to i32
  %71 = sext i32 %70 to i64
  %72 = call i64 @llvm.expect.i64(i64 %71, i64 0)
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %77

74:                                               ; preds = %61
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = call i32 @log_if_error(i32 noundef %75, ptr noundef @__func__.mdbx_dbi_sequence, i32 noundef 42)
  store i32 %76, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %261

77:                                               ; preds = %61
  br label %78

78:                                               ; preds = %77, %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.MDBX_txn, ptr %79, i32 0, i32 10
  %81 = load ptr, ptr %80, align 8, !tbaa !19
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds %struct.tree, ptr %81, i64 %83
  store ptr %84, ptr %12, align 8, !tbaa !5
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = icmp ne ptr %85, null
  %87 = xor i1 %86, true
  %88 = xor i1 %87, true
  %89 = zext i1 %88 to i32
  %90 = sext i32 %89 to i64
  %91 = call i64 @llvm.expect.i64(i64 %90, i64 1)
  %92 = icmp ne i64 %91, 0
  br i1 %92, label %93, label %98

93:                                               ; preds = %78
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.tree, ptr %94, i32 0, i32 7
  %96 = load i64, ptr %95, align 4, !tbaa !20
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %96, ptr %97, align 8, !tbaa !11
  br label %98

98:                                               ; preds = %93, %78
  %99 = load i64, ptr %9, align 8, !tbaa !11
  %100 = icmp ugt i64 %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 1)
  %106 = icmp ne i64 %105, 0
  br i1 %106, label %107, label %259

107:                                              ; preds = %98
  %108 = load i32, ptr %7, align 4, !tbaa !9
  %109 = icmp eq i32 %108, 0
  br i1 %109, label %116, label %110

110:                                              ; preds = %107
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.MDBX_txn, ptr %111, i32 0, i32 1
  %113 = load i32, ptr %112, align 4, !tbaa !22
  %114 = and i32 %113, 131072
  %115 = icmp ne i32 %114, 0
  br label %116

116:                                              ; preds = %110, %107
  %117 = phi i1 [ true, %107 ], [ %115, %110 ]
  %118 = xor i1 %117, true
  %119 = xor i1 %118, true
  %120 = zext i1 %119 to i32
  %121 = sext i32 %120 to i64
  %122 = call i64 @llvm.expect.i64(i64 %121, i64 0)
  %123 = icmp ne i64 %122, 0
  br i1 %123, label %124, label %125

124:                                              ; preds = %116
  store i32 13, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %260

125:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %126 = load ptr, ptr %12, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.tree, ptr %126, i32 0, i32 7
  %128 = load i64, ptr %127, align 4, !tbaa !20
  %129 = load i64, ptr %9, align 8, !tbaa !11
  %130 = add i64 %128, %129
  store i64 %130, ptr %13, align 8, !tbaa !11
  %131 = load i64, ptr %13, align 8, !tbaa !11
  %132 = load i64, ptr %9, align 8, !tbaa !11
  %133 = icmp ult i64 %131, %132
  %134 = xor i1 %133, true
  %135 = xor i1 %134, true
  %136 = zext i1 %135 to i32
  %137 = sext i32 %136 to i64
  %138 = call i64 @llvm.expect.i64(i64 %137, i64 0)
  %139 = icmp ne i64 %138, 0
  br i1 %139, label %140, label %141

140:                                              ; preds = %125
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %256

141:                                              ; preds = %125
  br label %142

142:                                              ; preds = %141
  %143 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !23
  %144 = zext i8 %143 to i32
  %145 = and i32 %144, 1
  %146 = icmp ne i32 %145, 0
  %147 = xor i1 %146, true
  %148 = xor i1 %147, true
  %149 = zext i1 %148 to i32
  %150 = sext i32 %149 to i64
  %151 = call i64 @llvm.expect.i64(i64 %150, i64 1)
  %152 = icmp ne i64 %151, 0
  br i1 %152, label %153, label %174

153:                                              ; preds = %142
  br label %154

154:                                              ; preds = %153
  %155 = load i64, ptr %13, align 8, !tbaa !11
  %156 = load ptr, ptr %12, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.tree, ptr %156, i32 0, i32 7
  %158 = load i64, ptr %157, align 4, !tbaa !20
  %159 = icmp ugt i64 %155, %158
  %160 = xor i1 %159, true
  %161 = xor i1 %160, true
  %162 = xor i1 %161, true
  %163 = zext i1 %162 to i32
  %164 = sext i32 %163 to i64
  %165 = call i64 @llvm.expect.i64(i64 %164, i64 0)
  %166 = icmp ne i64 %165, 0
  br i1 %166, label %167, label %171

167:                                              ; preds = %154
  %168 = load ptr, ptr %6, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.MDBX_txn, ptr %168, i32 0, i32 9
  %170 = load ptr, ptr %169, align 8, !tbaa !26
  call void @mdbx_assert_fail(ptr noundef %170, ptr noundef @.str, ptr noundef @__func__.mdbx_dbi_sequence, i32 noundef 57) #8
  unreachable

171:                                              ; preds = %154
  br label %172

172:                                              ; preds = %171
  br label %173

173:                                              ; preds = %172
  br label %174

174:                                              ; preds = %173, %142
  br label %175

175:                                              ; preds = %174
  br label %176

176:                                              ; preds = %175
  %177 = load ptr, ptr %6, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.MDBX_txn, ptr %177, i32 0, i32 12
  %179 = load ptr, ptr %178, align 8, !tbaa !13
  %180 = load i32, ptr %7, align 4, !tbaa !9
  %181 = zext i32 %180 to i64
  %182 = getelementptr inbounds i8, ptr %179, i64 %181
  %183 = load i8, ptr %182, align 1, !tbaa !18
  %184 = zext i8 %183 to i32
  %185 = and i32 %184, 1
  %186 = icmp eq i32 %185, 0
  br i1 %186, label %187, label %252

187:                                              ; preds = %176
  %188 = load ptr, ptr %6, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.MDBX_txn, ptr %188, i32 0, i32 1
  %190 = load i32, ptr %189, align 4, !tbaa !22
  %191 = or i32 %190, 4
  store i32 %191, ptr %189, align 4, !tbaa !22
  %192 = load ptr, ptr %6, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.MDBX_txn, ptr %192, i32 0, i32 12
  %194 = load ptr, ptr %193, align 8, !tbaa !13
  %195 = load i32, ptr %7, align 4, !tbaa !9
  %196 = zext i32 %195 to i64
  %197 = getelementptr inbounds i8, ptr %194, i64 %196
  %198 = load i8, ptr %197, align 1, !tbaa !18
  %199 = zext i8 %198 to i32
  %200 = or i32 %199, 1
  %201 = trunc i32 %200 to i8
  store i8 %201, ptr %197, align 1, !tbaa !18
  %202 = load i32, ptr %7, align 4, !tbaa !9
  %203 = icmp eq i32 %202, 1
  %204 = xor i1 %203, true
  %205 = xor i1 %204, true
  %206 = zext i1 %205 to i32
  %207 = sext i32 %206 to i64
  %208 = call i64 @llvm.expect.i64(i64 %207, i64 0)
  %209 = icmp ne i64 %208, 0
  br i1 %209, label %210, label %251

210:                                              ; preds = %187
  %211 = load ptr, ptr %6, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.MDBX_txn, ptr %211, i32 0, i32 10
  %213 = load ptr, ptr %212, align 8, !tbaa !19
  %214 = getelementptr inbounds %struct.tree, ptr %213, i64 1
  %215 = getelementptr inbounds %struct.tree, ptr %214, i32 0, i32 3
  %216 = load i32, ptr %215, align 4, !tbaa !27
  %217 = icmp ne i32 %216, -1
  br i1 %217, label %218, label %251

218:                                              ; preds = %210
  call void @llvm.lifetime.start.p0(i64 824, ptr %14) #7
  %219 = getelementptr inbounds %struct.cursor_couple, ptr %14, i32 0, i32 0
  %220 = load ptr, ptr %6, align 8, !tbaa !5
  %221 = call i32 @cursor_init(ptr noundef %219, ptr noundef %220, i64 noundef 1)
  store i32 %221, ptr %10, align 4, !tbaa !9
  %222 = load i32, ptr %10, align 4, !tbaa !9
  %223 = icmp ne i32 %222, 0
  %224 = xor i1 %223, true
  %225 = xor i1 %224, true
  %226 = zext i1 %225 to i32
  %227 = sext i32 %226 to i64
  %228 = call i64 @llvm.expect.i64(i64 %227, i64 0)
  %229 = icmp ne i64 %228, 0
  br i1 %229, label %230, label %233

230:                                              ; preds = %218
  %231 = load i32, ptr %10, align 4, !tbaa !9
  %232 = call i32 @log_if_error(i32 noundef %231, ptr noundef @__func__.mdbx_dbi_sequence, i32 noundef 93)
  store i32 %232, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %248

233:                                              ; preds = %218
  %234 = getelementptr inbounds %struct.cursor_couple, ptr %14, i32 0, i32 0
  %235 = call i32 @tree_search(ptr noundef %234, ptr noundef null, i32 noundef 3)
  store i32 %235, ptr %10, align 4, !tbaa !9
  %236 = load i32, ptr %10, align 4, !tbaa !9
  %237 = icmp ne i32 %236, 0
  %238 = xor i1 %237, true
  %239 = xor i1 %238, true
  %240 = zext i1 %239 to i32
  %241 = sext i32 %240 to i64
  %242 = call i64 @llvm.expect.i64(i64 %241, i64 0)
  %243 = icmp ne i64 %242, 0
  br i1 %243, label %244, label %247

244:                                              ; preds = %233
  %245 = load i32, ptr %10, align 4, !tbaa !9
  %246 = call i32 @log_if_error(i32 noundef %245, ptr noundef @__func__.mdbx_dbi_sequence, i32 noundef 96)
  store i32 %246, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %248

247:                                              ; preds = %233
  store i32 0, ptr %11, align 4
  br label %248

248:                                              ; preds = %247, %244, %230
  call void @llvm.lifetime.end.p0(i64 824, ptr %14) #7
  %249 = load i32, ptr %11, align 4
  switch i32 %249, label %256 [
    i32 0, label %250
  ]

250:                                              ; preds = %248
  br label %251

251:                                              ; preds = %250, %210, %187
  br label %252

252:                                              ; preds = %251, %176
  %253 = load i64, ptr %13, align 8, !tbaa !11
  %254 = load ptr, ptr %12, align 8, !tbaa !5
  %255 = getelementptr inbounds %struct.tree, ptr %254, i32 0, i32 7
  store i64 %253, ptr %255, align 4, !tbaa !20
  store i32 0, ptr %11, align 4
  br label %256

256:                                              ; preds = %252, %248, %140
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  %257 = load i32, ptr %11, align 4
  switch i32 %257, label %260 [
    i32 0, label %258
  ]

258:                                              ; preds = %256
  br label %259

259:                                              ; preds = %258, %98
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %260

260:                                              ; preds = %259, %256, %124
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %261

261:                                              ; preds = %260, %74, %41, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  %262 = load i32, ptr %5, align 4
  ret i32 %262
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @check_txn(ptr noundef, i32 noundef) #4

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

declare i32 @tbl_fetch(ptr noundef, i64 noundef) #5

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

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

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

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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { alwaysinline 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 = { "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 = { 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 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 104}
!14 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !12, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !15, i64 40, !12, i64 64, !12, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !17, i64 128, !6, i64 160, !7, i64 168}
!15 = !{!"geo", !16, i64 0, !16, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!16 = !{!"short", !7, i64 0}
!17 = !{!"MDBX_canary", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!18 = !{!7, !7, i64 0}
!19 = !{!14, !6, i64 88}
!20 = !{!21, !12, i64 24}
!21 = !{!"tree", !16, i64 0, !16, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !12, i64 24, !12, i64 32, !12, i64 40}
!22 = !{!14, !10, i64 4}
!23 = !{!24, !7, i64 25}
!24 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !25, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !12, i64 80, !6, i64 88}
!25 = !{!"_Bool", !7, i64 0}
!26 = !{!14, !6, i64 80}
!27 = !{!21, !10, i64 8}


; 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.6 }
%struct.anon.6 = 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.8, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon.8 = type { i16 }
%struct.inner_cursor = type { %struct.MDBX_cursor, %struct.tree }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }

@__func__.mdbx_dbi_sequence = external hidden unnamed_addr constant [18 x i8], align 1
@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str = external hidden unnamed_addr constant [20 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_dbi_sequence(ptr noundef %0, i32 noundef %1, ptr noundef writeonly %2, i64 noundef %3) local_unnamed_addr #2 {
  %5 = alloca %struct.cursor_couple, align 8
  %6 = tail call i32 @check_txn(ptr noundef %0, i32 noundef 51)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %9, label %7, !prof !5

7:                                                ; preds = %4
  %8 = tail call i32 @log_if_error(i32 noundef %6, ptr noundef nonnull @__func__.mdbx_dbi_sequence, i32 noundef 33)
  br label %.critedge

9:                                                ; preds = %4
  %10 = zext i32 %1 to i64
  %11 = tail call i32 @dbi_check(ptr noundef %0, i64 noundef %10)
  %.not55 = icmp eq i32 %11, 0
  br i1 %.not55, label %14, label %12, !prof !5

12:                                               ; preds = %9
  %13 = tail call i32 @log_if_error(i32 noundef %11, ptr noundef nonnull @__func__.mdbx_dbi_sequence, i32 noundef 37)
  br label %.critedge

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %0, i64 104
  %16 = load ptr, ptr %15, align 8, !tbaa !6
  %17 = getelementptr inbounds i8, ptr %16, i64 %10
  %18 = load i8, ptr %17, align 1, !tbaa !16
  %19 = and i8 %18, 2
  %.not56 = icmp eq i8 %19, 0
  br i1 %.not56, label %24, label %20, !prof !5

20:                                               ; preds = %14
  %21 = tail call i32 @tbl_fetch(ptr noundef nonnull %0, i64 noundef %10) #6
  %.not57 = icmp eq i32 %21, 0
  br i1 %.not57, label %24, label %22, !prof !5

22:                                               ; preds = %20
  %23 = tail call i32 @log_if_error(i32 noundef %21, ptr noundef nonnull @__func__.mdbx_dbi_sequence, i32 noundef 42)
  br label %.critedge

24:                                               ; preds = %20, %14
  %25 = getelementptr inbounds i8, ptr %0, i64 88
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = getelementptr inbounds %struct.tree, ptr %26, i64 %10
  %.not58 = icmp eq ptr %2, null
  br i1 %.not58, label %31, label %28, !prof !18

28:                                               ; preds = %24
  %29 = getelementptr inbounds i8, ptr %27, i64 24
  %30 = load i64, ptr %29, align 4, !tbaa !19
  store i64 %30, ptr %2, align 8, !tbaa !21
  br label %31

31:                                               ; preds = %28, %24
  %.not59 = icmp eq i64 %3, 0
  br i1 %.not59, label %.critedge, label %32, !prof !18

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

34:                                               ; preds = %32
  %35 = getelementptr inbounds i8, ptr %0, i64 4
  %36 = load i32, ptr %35, align 4, !tbaa !22
  %37 = and i32 %36, 131072
  %.not71 = icmp eq i32 %37, 0
  br i1 %.not71, label %38, label %.critedge, !prof !5

38:                                               ; preds = %34
  %39 = getelementptr inbounds i8, ptr %27, i64 24
  %40 = load i64, ptr %39, align 4, !tbaa !19
  %41 = add i64 %40, %3
  %42 = icmp ult i64 %41, %3
  br i1 %42, label %.critedge, label %43, !prof !18

43:                                               ; preds = %38
  %44 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !23
  %45 = and i8 %44, 1
  %.not60 = icmp eq i8 %45, 0
  %.not61 = icmp ugt i64 %41, %40
  %or.cond = or i1 %.not61, %.not60
  br i1 %or.cond, label %49, label %46, !prof !26

46:                                               ; preds = %43
  %47 = getelementptr inbounds i8, ptr %0, i64 80
  %48 = load ptr, ptr %47, align 8, !tbaa !27
  tail call void @mdbx_assert_fail(ptr noundef %48, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.mdbx_dbi_sequence, i32 noundef 57) #7
  unreachable

49:                                               ; preds = %43
  %50 = load ptr, ptr %15, align 8, !tbaa !6
  %51 = getelementptr inbounds i8, ptr %50, i64 %10
  %52 = load i8, ptr %51, align 1, !tbaa !16
  %53 = and i8 %52, 1
  %54 = icmp eq i8 %53, 0
  br i1 %54, label %55, label %73

55:                                               ; preds = %49
  %56 = or i32 %36, 4
  store i32 %56, ptr %35, align 4, !tbaa !22
  %57 = load i8, ptr %51, align 1, !tbaa !16
  %58 = or i8 %57, 1
  store i8 %58, ptr %51, align 1, !tbaa !16
  %59 = icmp eq i32 %1, 1
  br i1 %59, label %60, label %73, !prof !18

60:                                               ; preds = %55
  %61 = load ptr, ptr %25, align 8, !tbaa !17
  %62 = getelementptr inbounds i8, ptr %61, i64 56
  %63 = load i32, ptr %62, align 4, !tbaa !28
  %.not62 = icmp eq i32 %63, -1
  br i1 %.not62, label %73, label %64

64:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 824, ptr nonnull %5) #6
  %65 = call i32 @cursor_init(ptr noundef nonnull %5, ptr noundef nonnull %0, i64 noundef 1) #6
  %.not63 = icmp eq i32 %65, 0
  br i1 %.not63, label %68, label %66, !prof !5

66:                                               ; preds = %64
  %67 = call i32 @log_if_error(i32 noundef %65, ptr noundef nonnull @__func__.mdbx_dbi_sequence, i32 noundef 93)
  br label %.thread

68:                                               ; preds = %64
  %69 = call i32 @tree_search(ptr noundef nonnull %5, ptr noundef null, i32 noundef 3) #6
  %.not64 = icmp eq i32 %69, 0
  br i1 %.not64, label %72, label %70, !prof !5

70:                                               ; preds = %68
  %71 = call i32 @log_if_error(i32 noundef %69, ptr noundef nonnull @__func__.mdbx_dbi_sequence, i32 noundef 96)
  br label %.thread

.thread:                                          ; preds = %66, %70
  %.0.ph = phi i32 [ %71, %70 ], [ %67, %66 ]
  call void @llvm.lifetime.end.p0(i64 824, ptr nonnull %5) #6
  br label %.critedge

72:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 824, ptr nonnull %5) #6
  br label %73

73:                                               ; preds = %49, %60, %55, %72
  store i64 %41, ptr %39, align 4, !tbaa !19
  br label %.critedge

.critedge:                                        ; preds = %.thread, %38, %31, %73, %32, %34, %22, %12, %7
  %.4 = phi i32 [ %8, %7 ], [ %13, %12 ], [ %23, %22 ], [ 13, %34 ], [ 13, %32 ], [ 0, %73 ], [ 0, %31 ], [ %.0.ph, %.thread ], [ -1, %38 ]
  ret i32 %.4
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @check_txn(ptr noundef, i32 noundef) local_unnamed_addr #3

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

declare i32 @tbl_fetch(ptr noundef, i64 noundef) local_unnamed_addr #4

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "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 = { 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 104}
!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 = !{!9, !9, i64 0}
!17 = !{!7, !12, i64 88}
!18 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!19 = !{!20, !11, i64 24}
!20 = !{!"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}
!21 = !{!11, !11, i64 0}
!22 = !{!7, !8, i64 4}
!23 = !{!24, !9, i64 25}
!24 = !{!"libmdbx_globals", !9, i64 0, !8, i64 16, !8, i64 20, !9, i64 24, !9, i64 25, !9, i64 26, !25, i64 27, !8, i64 28, !9, i64 32, !9, i64 40, !11, i64 80, !12, i64 88}
!25 = !{!"_Bool", !9, i64 0}
!26 = !{!"branch_weights", i32 4002001, i32 2000}
!27 = !{!7, !12, i64 80}
!28 = !{!20, !8, i64 8}


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