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

; 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.12 }
%struct.anon.12 = 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.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.15, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.16, %struct.anon.20, i8, ptr, ptr, ptr, %struct.anon.21, %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.14, i32, i64, i64, i64 }
%union.anon.14 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.15 = type { ptr, ptr, ptr, ptr }
%struct.anon.16 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.17, %union.anon.18 }
%struct.anon.17 = type { i16, i16, i16, i16 }
%union.anon.18 = type { i32 }
%struct.anon.20 = type { i64, i64, i64, i64, i64 }
%struct.anon.21 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, ptr }
%union.mdbx_atomic_uint64_t = type { 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 }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }

@globals = external global %struct.libmdbx_globals, align 8
@__func__.mdbx_txn_begin_ex = external hidden unnamed_addr constant [18 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [99 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [159 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [47 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: alwaysinline nounwind uwtable
declare hidden i32 @check_txn(ptr noundef, i32 noundef) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @check_env(ptr noundef, i1 noundef zeroext) #3

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_txn_begin_ex(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #6 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %16 = load ptr, ptr %10, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  %18 = xor i1 %17, true
  %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 %27

25:                                               ; preds = %5
  %26 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 202)
  store i32 %26, ptr %6, align 4
  br label %486

27:                                               ; preds = %5
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr null, ptr %28, align 8, !tbaa !5
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = and i32 %29, -268763137
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %41

32:                                               ; preds = %27
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %39, label %35

35:                                               ; preds = %32
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = and i32 %36, -16908289
  %38 = icmp ne i32 %37, 0
  br label %39

39:                                               ; preds = %35, %32
  %40 = phi i1 [ true, %32 ], [ %38, %35 ]
  br label %41

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

49:                                               ; preds = %41
  %50 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 206)
  store i32 %50, ptr %6, align 4
  br label %486

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

62:                                               ; preds = %51
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = call i32 @log_if_error(i32 noundef %63, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 210)
  store i32 %64, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %485

65:                                               ; preds = %51
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.MDBX_env, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = and i32 %68, 131072
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = xor i32 %70, -1
  %72 = and i32 %69, %71
  %73 = icmp ne i32 %72, 0
  %74 = xor i1 %73, true
  %75 = xor i1 %74, true
  %76 = zext i1 %75 to i32
  %77 = sext i32 %76 to i64
  %78 = call i64 @llvm.expect.i64(i64 %77, i64 0)
  %79 = icmp ne i64 %78, 0
  br i1 %79, label %80, label %82

80:                                               ; preds = %65
  %81 = call i32 @log_if_error(i32 noundef 13, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 213)
  store i32 %81, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %485

82:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  store ptr null, ptr %14, align 8, !tbaa !5
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %240

85:                                               ; preds = %82
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = call i32 @check_txn(ptr noundef %86, i32 noundef 19)
  store i32 %87, ptr %12, align 4, !tbaa !9
  %88 = load i32, ptr %12, align 4, !tbaa !9
  %89 = icmp ne i32 %88, 0
  %90 = xor i1 %89, true
  %91 = xor i1 %90, true
  %92 = zext i1 %91 to i32
  %93 = sext i32 %92 to i64
  %94 = call i64 @llvm.expect.i64(i64 %93, i64 0)
  %95 = icmp ne i64 %94, 0
  br i1 %95, label %96, label %99

96:                                               ; preds = %85
  %97 = load i32, ptr %12, align 4, !tbaa !9
  %98 = call i32 @log_if_error(i32 noundef %97, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 222)
  store i32 %98, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %484

99:                                               ; preds = %85
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.MDBX_txn, ptr %100, i32 0, i32 1
  %102 = load i32, ptr %101, align 4, !tbaa !23
  %103 = and i32 %102, 655360
  %104 = icmp ne i32 %103, 0
  %105 = xor i1 %104, true
  %106 = xor i1 %105, true
  %107 = zext i1 %106 to i32
  %108 = sext i32 %107 to i64
  %109 = call i64 @llvm.expect.i64(i64 %108, i64 0)
  %110 = icmp ne i64 %109, 0
  br i1 %110, label %111, label %135

111:                                              ; preds = %99
  store i32 -30782, ptr %12, align 4, !tbaa !9
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.MDBX_txn, ptr %112, i32 0, i32 1
  %114 = load i32, ptr %113, align 4, !tbaa !23
  %115 = and i32 %114, 131072
  %116 = icmp eq i32 %115, 0
  br i1 %116, label %117, label %132

117:                                              ; preds = %111
  br label %118

118:                                              ; preds = %117
  %119 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !27
  %120 = zext i8 %119 to i32
  %121 = icmp sle i32 1, %120
  %122 = xor i1 %121, true
  %123 = xor i1 %122, true
  %124 = zext i1 %123 to i32
  %125 = sext i32 %124 to i64
  %126 = call i64 @llvm.expect.i64(i64 %125, i64 0)
  %127 = icmp ne i64 %126, 0
  br i1 %127, label %128, label %129

128:                                              ; preds = %118
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 227, ptr noundef @.str.6, ptr noundef @.str.7)
  br label %129

129:                                              ; preds = %128, %118
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  store i32 -30784, ptr %12, align 4, !tbaa !9
  br label %132

132:                                              ; preds = %131, %111
  %133 = load i32, ptr %12, align 4, !tbaa !9
  %134 = call i32 @log_if_error(i32 noundef %133, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 230)
  store i32 %134, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %484

135:                                              ; preds = %99
  %136 = load ptr, ptr %8, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.MDBX_txn, ptr %136, i32 0, i32 9
  %138 = load ptr, ptr %137, align 8, !tbaa !29
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = icmp ne ptr %138, %139
  %141 = xor i1 %140, true
  %142 = xor i1 %141, true
  %143 = zext i1 %142 to i32
  %144 = sext i32 %143 to i64
  %145 = call i64 @llvm.expect.i64(i64 %144, i64 0)
  %146 = icmp ne i64 %145, 0
  br i1 %146, label %147, label %149

147:                                              ; preds = %135
  %148 = call i32 @log_if_error(i32 noundef -30782, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 233)
  store i32 %148, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %484

149:                                              ; preds = %135
  %150 = load ptr, ptr %8, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.MDBX_txn, ptr %150, i32 0, i32 1
  %152 = load i32, ptr %151, align 4, !tbaa !23
  %153 = and i32 %152, 271384584
  %154 = load i32, ptr %9, align 4, !tbaa !9
  %155 = or i32 %154, %153
  store i32 %155, ptr %9, align 4, !tbaa !9
  %156 = load ptr, ptr %8, align 8, !tbaa !5
  %157 = load i32, ptr %9, align 4, !tbaa !9
  %158 = call i32 @txn_nested_create(ptr noundef %156, i32 noundef %157)
  store i32 %158, ptr %12, align 4, !tbaa !9
  %159 = load ptr, ptr %8, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.MDBX_txn, ptr %159, i32 0, i32 5
  %161 = load ptr, ptr %160, align 8, !tbaa !30
  store ptr %161, ptr %14, align 8, !tbaa !5
  %162 = load i32, ptr %12, align 4, !tbaa !9
  %163 = icmp ne i32 %162, 0
  %164 = xor i1 %163, true
  %165 = xor i1 %164, true
  %166 = zext i1 %165 to i32
  %167 = sext i32 %166 to i64
  %168 = call i64 @llvm.expect.i64(i64 %167, i64 0)
  %169 = icmp ne i64 %168, 0
  br i1 %169, label %170, label %181

170:                                              ; preds = %149
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %171 = load ptr, ptr %14, align 8, !tbaa !5
  %172 = call i32 @txn_end(ptr noundef %171, i32 noundef 5)
  store i32 %172, ptr %15, align 4, !tbaa !9
  %173 = load i32, ptr %15, align 4, !tbaa !9
  %174 = icmp ne i32 %173, 0
  br i1 %174, label %175, label %177

175:                                              ; preds = %170
  %176 = load i32, ptr %15, align 4, !tbaa !9
  br label %179

177:                                              ; preds = %170
  %178 = load i32, ptr %12, align 4, !tbaa !9
  br label %179

179:                                              ; preds = %177, %175
  %180 = phi i32 [ %176, %175 ], [ %178, %177 ]
  store i32 %180, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %484

181:                                              ; preds = %149
  %182 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !31
  %183 = zext i8 %182 to i32
  %184 = and i32 %183, 2
  %185 = icmp ne i32 %184, 0
  %186 = xor i1 %185, true
  %187 = xor i1 %186, true
  %188 = zext i1 %187 to i32
  %189 = sext i32 %188 to i64
  %190 = call i64 @llvm.expect.i64(i64 %189, i64 0)
  %191 = icmp ne i64 %190, 0
  br i1 %191, label %192, label %239

192:                                              ; preds = %181
  %193 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !31
  %194 = zext i8 %193 to i32
  %195 = and i32 %194, 1
  %196 = icmp ne i32 %195, 0
  %197 = xor i1 %196, true
  %198 = xor i1 %197, true
  %199 = zext i1 %198 to i32
  %200 = sext i32 %199 to i64
  %201 = call i64 @llvm.expect.i64(i64 %200, i64 1)
  %202 = icmp ne i64 %201, 0
  br i1 %202, label %203, label %239

203:                                              ; preds = %192
  %204 = load ptr, ptr %14, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.MDBX_txn, ptr %204, i32 0, i32 0
  store i32 332741169, ptr %205, align 8, !tbaa !32
  br label %206

206:                                              ; preds = %203
  %207 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !31
  %208 = zext i8 %207 to i32
  %209 = and i32 %208, 1
  %210 = icmp ne i32 %209, 0
  %211 = xor i1 %210, true
  %212 = xor i1 %211, true
  %213 = zext i1 %212 to i32
  %214 = sext i32 %213 to i64
  %215 = call i64 @llvm.expect.i64(i64 %214, i64 1)
  %216 = icmp ne i64 %215, 0
  br i1 %216, label %217, label %236

217:                                              ; preds = %206
  br label %218

218:                                              ; preds = %217
  %219 = load ptr, ptr %14, align 8, !tbaa !5
  %220 = call i32 @audit_ex(ptr noundef %219, i64 noundef 0, i1 noundef zeroext false)
  %221 = icmp eq i32 %220, 0
  %222 = xor i1 %221, true
  %223 = xor i1 %222, true
  %224 = xor i1 %223, true
  %225 = zext i1 %224 to i32
  %226 = sext i32 %225 to i64
  %227 = call i64 @llvm.expect.i64(i64 %226, i64 0)
  %228 = icmp ne i64 %227, 0
  br i1 %228, label %229, label %233

229:                                              ; preds = %218
  %230 = load ptr, ptr %14, align 8, !tbaa !5
  %231 = getelementptr inbounds %struct.MDBX_txn, ptr %230, i32 0, i32 9
  %232 = load ptr, ptr %231, align 8, !tbaa !29
  call void @mdbx_assert_fail(ptr noundef %232, ptr noundef @.str.8, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 244) #9
  unreachable

233:                                              ; preds = %218
  br label %234

234:                                              ; preds = %233
  br label %235

235:                                              ; preds = %234
  br label %236

236:                                              ; preds = %235, %206
  br label %237

237:                                              ; preds = %236
  br label %238

238:                                              ; preds = %237
  br label %239

239:                                              ; preds = %238, %192, %181
  br label %287

240:                                              ; preds = %82
  %241 = load ptr, ptr %7, align 8, !tbaa !5
  %242 = getelementptr inbounds %struct.MDBX_env, ptr %241, i32 0, i32 24
  %243 = load ptr, ptr %242, align 8, !tbaa !33
  store ptr %243, ptr %14, align 8, !tbaa !5
  %244 = load i32, ptr %9, align 4, !tbaa !9
  %245 = and i32 %244, 131072
  %246 = icmp ne i32 %245, 0
  br i1 %246, label %247, label %263

247:                                              ; preds = %240
  %248 = load i32, ptr %9, align 4, !tbaa !9
  %249 = load ptr, ptr %7, align 8, !tbaa !5
  %250 = call ptr @txn_alloc(i32 noundef %248, ptr noundef %249)
  store ptr %250, ptr %14, align 8, !tbaa !5
  %251 = load ptr, ptr %14, align 8, !tbaa !5
  %252 = icmp ne ptr %251, null
  %253 = xor i1 %252, true
  %254 = xor i1 %253, true
  %255 = xor i1 %254, true
  %256 = zext i1 %255 to i32
  %257 = sext i32 %256 to i64
  %258 = call i64 @llvm.expect.i64(i64 %257, i64 0)
  %259 = icmp ne i64 %258, 0
  br i1 %259, label %260, label %262

260:                                              ; preds = %247
  %261 = call i32 @log_if_error(i32 noundef 12, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 251)
  store i32 %261, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %484

262:                                              ; preds = %247
  br label %263

263:                                              ; preds = %262, %240
  %264 = load ptr, ptr %14, align 8, !tbaa !5
  %265 = load i32, ptr %9, align 4, !tbaa !9
  %266 = call i32 @txn_renew(ptr noundef %264, i32 noundef %265)
  store i32 %266, ptr %12, align 4, !tbaa !9
  %267 = load i32, ptr %12, align 4, !tbaa !9
  %268 = icmp ne i32 %267, 0
  %269 = xor i1 %268, true
  %270 = xor i1 %269, true
  %271 = zext i1 %270 to i32
  %272 = sext i32 %271 to i64
  %273 = call i64 @llvm.expect.i64(i64 %272, i64 0)
  %274 = icmp ne i64 %273, 0
  br i1 %274, label %275, label %286

275:                                              ; preds = %263
  %276 = load ptr, ptr %14, align 8, !tbaa !5
  %277 = load ptr, ptr %7, align 8, !tbaa !5
  %278 = getelementptr inbounds %struct.MDBX_env, ptr %277, i32 0, i32 24
  %279 = load ptr, ptr %278, align 8, !tbaa !33
  %280 = icmp ne ptr %276, %279
  br i1 %280, label %281, label %283

281:                                              ; preds = %275
  %282 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %282) #8
  br label %283

283:                                              ; preds = %281, %275
  %284 = load i32, ptr %12, align 4, !tbaa !9
  %285 = call i32 @log_if_error(i32 noundef %284, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 257)
  store i32 %285, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %484

286:                                              ; preds = %263
  br label %287

287:                                              ; preds = %286, %239
  %288 = load i32, ptr %9, align 4, !tbaa !9
  %289 = and i32 %288, 16777216
  %290 = icmp ne i32 %289, 0
  br i1 %290, label %291, label %324

291:                                              ; preds = %287
  br label %292

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

303:                                              ; preds = %292
  br label %304

304:                                              ; preds = %303
  %305 = load ptr, ptr %14, align 8, !tbaa !5
  %306 = getelementptr inbounds %struct.MDBX_txn, ptr %305, i32 0, i32 1
  %307 = load i32, ptr %306, align 4, !tbaa !23
  %308 = icmp eq i32 %307, 131073
  %309 = xor i1 %308, true
  %310 = xor i1 %309, true
  %311 = xor i1 %310, true
  %312 = zext i1 %311 to i32
  %313 = sext i32 %312 to i64
  %314 = call i64 @llvm.expect.i64(i64 %313, i64 0)
  %315 = icmp ne i64 %314, 0
  br i1 %315, label %316, label %318

316:                                              ; preds = %304
  %317 = load ptr, ptr %7, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %317, ptr noundef @.str.9, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 262) #9
  unreachable

318:                                              ; preds = %304
  br label %319

319:                                              ; preds = %318
  br label %320

320:                                              ; preds = %319
  br label %321

321:                                              ; preds = %320, %292
  br label %322

322:                                              ; preds = %321
  br label %323

323:                                              ; preds = %322
  br label %440

324:                                              ; preds = %287
  %325 = load i32, ptr %9, align 4, !tbaa !9
  %326 = and i32 %325, 131072
  %327 = icmp ne i32 %326, 0
  br i1 %327, label %328, label %362

328:                                              ; preds = %324
  br label %329

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

340:                                              ; preds = %329
  br label %341

341:                                              ; preds = %340
  %342 = load ptr, ptr %14, align 8, !tbaa !5
  %343 = getelementptr inbounds %struct.MDBX_txn, ptr %342, i32 0, i32 1
  %344 = load i32, ptr %343, align 4, !tbaa !23
  %345 = and i32 %344, -1076494337
  %346 = icmp eq i32 %345, 0
  %347 = xor i1 %346, true
  %348 = xor i1 %347, true
  %349 = xor i1 %348, true
  %350 = zext i1 %349 to i32
  %351 = sext i32 %350 to i64
  %352 = call i64 @llvm.expect.i64(i64 %351, i64 0)
  %353 = icmp ne i64 %352, 0
  br i1 %353, label %354, label %356

354:                                              ; preds = %341
  %355 = load ptr, ptr %7, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %355, ptr noundef @.str.10, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 265) #9
  unreachable

356:                                              ; preds = %341
  br label %357

357:                                              ; preds = %356
  br label %358

358:                                              ; preds = %357
  br label %359

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

360:                                              ; preds = %359
  br label %361

361:                                              ; preds = %360
  br label %439

362:                                              ; preds = %324
  br label %363

363:                                              ; preds = %362
  %364 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !31
  %365 = zext i8 %364 to i32
  %366 = and i32 %365, 1
  %367 = icmp ne i32 %366, 0
  %368 = xor i1 %367, true
  %369 = xor i1 %368, true
  %370 = zext i1 %369 to i32
  %371 = sext i32 %370 to i64
  %372 = call i64 @llvm.expect.i64(i64 %371, i64 1)
  %373 = icmp ne i64 %372, 0
  br i1 %373, label %374, label %393

374:                                              ; preds = %363
  br label %375

375:                                              ; preds = %374
  %376 = load ptr, ptr %14, align 8, !tbaa !5
  %377 = getelementptr inbounds %struct.MDBX_txn, ptr %376, i32 0, i32 1
  %378 = load i32, ptr %377, align 4, !tbaa !23
  %379 = and i32 %378, -1076691209
  %380 = icmp eq i32 %379, 0
  %381 = xor i1 %380, true
  %382 = xor i1 %381, true
  %383 = xor i1 %382, true
  %384 = zext i1 %383 to i32
  %385 = sext i32 %384 to i64
  %386 = call i64 @llvm.expect.i64(i64 %385, i64 0)
  %387 = icmp ne i64 %386, 0
  br i1 %387, label %388, label %390

388:                                              ; preds = %375
  %389 = load ptr, ptr %7, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %389, ptr noundef @.str.11, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 268) #9
  unreachable

390:                                              ; preds = %375
  br label %391

391:                                              ; preds = %390
  br label %392

392:                                              ; preds = %391
  br label %393

393:                                              ; preds = %392, %363
  br label %394

394:                                              ; preds = %393
  br label %395

395:                                              ; preds = %394
  br label %396

396:                                              ; preds = %395
  %397 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !31
  %398 = zext i8 %397 to i32
  %399 = and i32 %398, 1
  %400 = icmp ne i32 %399, 0
  %401 = xor i1 %400, true
  %402 = xor i1 %401, true
  %403 = zext i1 %402 to i32
  %404 = sext i32 %403 to i64
  %405 = call i64 @llvm.expect.i64(i64 %404, i64 1)
  %406 = icmp ne i64 %405, 0
  br i1 %406, label %407, label %436

407:                                              ; preds = %396
  br label %408

408:                                              ; preds = %407
  %409 = load ptr, ptr %14, align 8, !tbaa !5
  %410 = getelementptr inbounds %struct.MDBX_txn, ptr %409, i32 0, i32 17
  %411 = getelementptr inbounds %struct.anon.2, ptr %410, i32 0, i32 11
  %412 = getelementptr inbounds %struct.anon.5, ptr %411, i32 0, i32 1
  %413 = load ptr, ptr %412, align 8, !tbaa !34
  %414 = icmp ne ptr %413, null
  br i1 %414, label %423, label %415

415:                                              ; preds = %408
  %416 = load ptr, ptr %14, align 8, !tbaa !5
  %417 = getelementptr inbounds %struct.MDBX_txn, ptr %416, i32 0, i32 17
  %418 = getelementptr inbounds %struct.anon.2, ptr %417, i32 0, i32 11
  %419 = getelementptr inbounds %struct.anon.5, ptr %418, i32 0, i32 0
  %420 = load i64, ptr %419, align 8, !tbaa !34
  %421 = icmp ne i64 %420, 0
  %422 = xor i1 %421, true
  br label %423

423:                                              ; preds = %415, %408
  %424 = phi i1 [ false, %408 ], [ %422, %415 ]
  %425 = xor i1 %424, true
  %426 = xor i1 %425, true
  %427 = xor i1 %426, true
  %428 = zext i1 %427 to i32
  %429 = sext i32 %428 to i64
  %430 = call i64 @llvm.expect.i64(i64 %429, i64 0)
  %431 = icmp ne i64 %430, 0
  br i1 %431, label %432, label %433

432:                                              ; preds = %423
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.12, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 269) #9
  unreachable

433:                                              ; preds = %423
  br label %434

434:                                              ; preds = %433
  br label %435

435:                                              ; preds = %434
  br label %436

436:                                              ; preds = %435, %396
  br label %437

437:                                              ; preds = %436
  br label %438

438:                                              ; preds = %437
  br label %439

439:                                              ; preds = %438, %361
  br label %440

440:                                              ; preds = %439, %323
  %441 = load ptr, ptr %14, align 8, !tbaa !5
  %442 = getelementptr inbounds %struct.MDBX_txn, ptr %441, i32 0, i32 0
  store i32 332741169, ptr %442, align 8, !tbaa !32
  %443 = load ptr, ptr %11, align 8, !tbaa !5
  %444 = load ptr, ptr %14, align 8, !tbaa !5
  %445 = getelementptr inbounds %struct.MDBX_txn, ptr %444, i32 0, i32 16
  store ptr %443, ptr %445, align 8, !tbaa !35
  %446 = load ptr, ptr %14, align 8, !tbaa !5
  %447 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %446, ptr %447, align 8, !tbaa !5
  br label %448

448:                                              ; preds = %440
  %449 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !27
  %450 = zext i8 %449 to i32
  %451 = icmp sle i32 5, %450
  %452 = xor i1 %451, true
  %453 = xor i1 %452, true
  %454 = zext i1 %453 to i32
  %455 = sext i32 %454 to i64
  %456 = call i64 @llvm.expect.i64(i64 %455, i64 0)
  %457 = icmp ne i64 %456, 0
  br i1 %457, label %458, label %481

458:                                              ; preds = %448
  %459 = load ptr, ptr %14, align 8, !tbaa !5
  %460 = getelementptr inbounds %struct.MDBX_txn, ptr %459, i32 0, i32 7
  %461 = load i64, ptr %460, align 8, !tbaa !36
  %462 = load i32, ptr %9, align 4, !tbaa !9
  %463 = and i32 %462, 131072
  %464 = icmp ne i32 %463, 0
  %465 = zext i1 %464 to i64
  %466 = select i1 %464, i32 114, i32 119
  %467 = load ptr, ptr %14, align 8, !tbaa !5
  %468 = load ptr, ptr %7, align 8, !tbaa !5
  %469 = load ptr, ptr %14, align 8, !tbaa !5
  %470 = getelementptr inbounds %struct.MDBX_txn, ptr %469, i32 0, i32 10
  %471 = load ptr, ptr %470, align 8, !tbaa !37
  %472 = getelementptr inbounds %struct.tree, ptr %471, i64 1
  %473 = getelementptr inbounds %struct.tree, ptr %472, i32 0, i32 3
  %474 = load i32, ptr %473, align 4, !tbaa !38
  %475 = load ptr, ptr %14, align 8, !tbaa !5
  %476 = getelementptr inbounds %struct.MDBX_txn, ptr %475, i32 0, i32 10
  %477 = load ptr, ptr %476, align 8, !tbaa !37
  %478 = getelementptr inbounds %struct.tree, ptr %477, i64 0
  %479 = getelementptr inbounds %struct.tree, ptr %478, i32 0, i32 3
  %480 = load i32, ptr %479, align 4, !tbaa !38
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_txn_begin_ex, i32 noundef 276, ptr noundef @.str.13, i64 noundef %461, i32 noundef %466, ptr noundef %467, ptr noundef %468, i32 noundef %474, i32 noundef %480)
  br label %481

481:                                              ; preds = %458, %448
  br label %482

482:                                              ; preds = %481
  br label %483

483:                                              ; preds = %482
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %484

484:                                              ; preds = %483, %283, %260, %179, %147, %132, %96
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  br label %485

485:                                              ; preds = %484, %80, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %486

486:                                              ; preds = %485, %49, %25
  %487 = load i32, ptr %6, align 4
  ret i32 %487
}

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

declare i32 @audit_ex(ptr noundef, i64 noundef, i1 noundef zeroext) #5

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #7

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 #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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind "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 = { 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, !10, i64 4}
!12 = !{!"MDBX_env", !7, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !10, i64 56, !10, i64 60, !13, i64 64, !6, i64 104, !15, i64 112, !15, i64 114, !15, i64 116, !15, i64 118, !15, i64 120, !15, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !15, i64 130, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !16, 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, !14, i64 256, !17, i64 264, !20, i64 320, !18, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !21, i64 392, !7, i64 400, !10, i64 440, !10, i64 444, !6, i64 448, !22, i64 456, !7, i64 496, !7, i64 536}
!13 = !{!"osal_mmap", !7, i64 0, !10, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!14 = !{!"long", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !14, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !10, i64 28, !10, i64 32, !18, i64 36, !18, i64 37, !18, i64 38, !19, i64 40, !7, i64 48}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{!"", !15, i64 0, !15, i64 2, !15, i64 4, !15, i64 6}
!20 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!21 = !{!"", !14, i64 0}
!22 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!24, !10, i64 4}
!24 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !14, i64 8, !14, i64 16, !6, i64 24, !6, i64 32, !25, i64 40, !14, i64 64, !14, 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", !15, i64 0, !15, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!26 = !{!"MDBX_canary", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!27 = !{!28, !7, i64 26}
!28 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !18, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !14, i64 80, !6, i64 88}
!29 = !{!24, !6, i64 80}
!30 = !{!24, !6, i64 32}
!31 = !{!28, !7, i64 25}
!32 = !{!24, !10, i64 0}
!33 = !{!12, !6, i64 192}
!34 = !{!7, !7, i64 0}
!35 = !{!24, !6, i64 160}
!36 = !{!24, !14, i64 64}
!37 = !{!24, !6, i64 88}
!38 = !{!39, !10, i64 8}
!39 = !{!"tree", !15, i64 0, !15, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !14, i64 24, !14, i64 32, !14, i64 40}


; 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.12 }
%struct.anon.12 = 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 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@__func__.mdbx_txn_begin_ex = external hidden unnamed_addr constant [18 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [99 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [159 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [47 x i8], align 1

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

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_txn_begin_ex(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef writeonly %3, ptr noundef %4) local_unnamed_addr #4 {
  %.not = icmp eq ptr %3, 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_txn_begin_ex, i32 noundef 202)
  br label %131

8:                                                ; preds = %5
  store ptr null, ptr %3, align 8, !tbaa !6
  %9 = and i32 %2, -268763137
  %.not74 = icmp eq i32 %9, 0
  br i1 %.not74, label %.critedge, label %10

10:                                               ; preds = %8
  %11 = icmp ne ptr %1, null
  %12 = and i32 %2, -16908289
  %13 = icmp ne i32 %12, 0
  %14 = or i1 %11, %13
  br i1 %14, label %15, label %.critedge, !prof !5

15:                                               ; preds = %10
  %16 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 206)
  br label %131

.critedge:                                        ; preds = %8, %10
  %17 = tail call i32 @check_env(ptr noundef %0, i1 noundef zeroext true)
  %.not75 = icmp eq i32 %17, 0
  br i1 %.not75, label %20, label %18, !prof !10

18:                                               ; preds = %.critedge
  %19 = tail call i32 @log_if_error(i32 noundef %17, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 210)
  br label %131

20:                                               ; preds = %.critedge
  %21 = getelementptr inbounds i8, ptr %0, i64 4
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = and i32 %2, 131072
  %24 = xor i32 %23, 131072
  %25 = and i32 %24, %22
  %.not76 = icmp eq i32 %25, 0
  br i1 %.not76, label %28, label %26, !prof !10

26:                                               ; preds = %20
  %27 = tail call i32 @log_if_error(i32 noundef 13, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 213)
  br label %131

28:                                               ; preds = %20
  %.not77 = icmp eq ptr %1, null
  br i1 %.not77, label %72, label %29

29:                                               ; preds = %28
  %30 = tail call i32 @check_txn(ptr noundef nonnull %1, i32 noundef 19)
  %.not82 = icmp eq i32 %30, 0
  br i1 %.not82, label %33, label %31, !prof !10

31:                                               ; preds = %29
  %32 = tail call i32 @log_if_error(i32 noundef %30, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 222)
  br label %131

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %1, i64 4
  %35 = load i32, ptr %34, align 4, !tbaa !24
  %36 = and i32 %35, 655360
  %.not83 = icmp eq i32 %36, 0
  br i1 %.not83, label %45, label %37, !prof !10

37:                                               ; preds = %33
  %38 = and i32 %35, 131072
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !28
  %.not103 = icmp eq i8 %41, 0
  br i1 %.not103, label %43, label %42, !prof !10

42:                                               ; preds = %40
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 227, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7) #6
  br label %43

43:                                               ; preds = %40, %42, %37
  %.067 = phi i32 [ -30782, %37 ], [ -30784, %42 ], [ -30784, %40 ]
  %44 = tail call i32 @log_if_error(i32 noundef %.067, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 230)
  br label %131

45:                                               ; preds = %33
  %46 = getelementptr inbounds i8, ptr %1, i64 80
  %47 = load ptr, ptr %46, align 8, !tbaa !30
  %.not84 = icmp eq ptr %47, %0
  br i1 %.not84, label %50, label %48, !prof !10

48:                                               ; preds = %45
  %49 = tail call i32 @log_if_error(i32 noundef -30782, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 233)
  br label %131

50:                                               ; preds = %45
  %51 = and i32 %35, 270860296
  %52 = or i32 %51, %2
  %53 = tail call i32 @txn_nested_create(ptr noundef nonnull %1, i32 noundef %52) #6
  %54 = getelementptr inbounds i8, ptr %1, i64 32
  %55 = load ptr, ptr %54, align 8, !tbaa !31
  %.not85 = icmp eq i32 %53, 0
  br i1 %.not85, label %59, label %56, !prof !10

56:                                               ; preds = %50
  %57 = tail call i32 @txn_end(ptr noundef %55, i32 noundef 5) #6
  %.not102 = icmp eq i32 %57, 0
  %58 = select i1 %.not102, i32 %53, i32 %57
  br label %131

59:                                               ; preds = %50
  %60 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !32
  %61 = zext i8 %60 to i32
  %62 = and i32 %61, 2
  %.not86 = icmp eq i32 %62, 0
  br i1 %.not86, label %86, label %63, !prof !10

63:                                               ; preds = %59
  %64 = and i32 %61, 1
  %.not87 = icmp eq i32 %64, 0
  br i1 %.not87, label %86, label %65, !prof !5

65:                                               ; preds = %63
  store i32 332741169, ptr %55, align 8, !tbaa !33
  %66 = and i8 %60, 1
  %.not88 = icmp eq i8 %66, 0
  br i1 %.not88, label %86, label %67, !prof !5

67:                                               ; preds = %65
  %68 = tail call i32 @audit_ex(ptr noundef nonnull %55, i64 noundef 0, i1 noundef zeroext false) #6
  %.not89 = icmp eq i32 %68, 0
  br i1 %.not89, label %86, label %69, !prof !10

69:                                               ; preds = %67
  %70 = getelementptr inbounds i8, ptr %55, i64 80
  %71 = load ptr, ptr %70, align 8, !tbaa !30
  tail call void @mdbx_assert_fail(ptr noundef %71, ptr noundef nonnull @.str.8, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 244) #7
  unreachable

72:                                               ; preds = %28
  %73 = getelementptr inbounds i8, ptr %0, i64 192
  %74 = load ptr, ptr %73, align 8, !tbaa !34
  %.not78 = icmp eq i32 %23, 0
  br i1 %.not78, label %79, label %75

75:                                               ; preds = %72
  %76 = tail call ptr @txn_alloc(i32 noundef %2, ptr noundef nonnull %0) #6
  %.not79 = icmp eq ptr %76, null
  br i1 %.not79, label %77, label %79, !prof !5

77:                                               ; preds = %75
  %78 = tail call i32 @log_if_error(i32 noundef 12, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 251)
  br label %131

79:                                               ; preds = %75, %72
  %.065 = phi ptr [ %76, %75 ], [ %74, %72 ]
  %80 = tail call i32 @txn_renew(ptr noundef %.065, i32 noundef %2) #6
  %.not80 = icmp eq i32 %80, 0
  br i1 %.not80, label %86, label %81, !prof !10

81:                                               ; preds = %79
  %82 = load ptr, ptr %73, align 8, !tbaa !34
  %.not81 = icmp eq ptr %.065, %82
  br i1 %.not81, label %84, label %83

83:                                               ; preds = %81
  tail call void @free(ptr noundef %.065) #6
  br label %84

84:                                               ; preds = %83, %81
  %85 = tail call i32 @log_if_error(i32 noundef %80, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 257)
  br label %131

86:                                               ; preds = %79, %59, %63, %67, %65
  %.068 = phi i32 [ %52, %67 ], [ %52, %65 ], [ %52, %63 ], [ %52, %59 ], [ %2, %79 ]
  %.166 = phi ptr [ %55, %67 ], [ %55, %65 ], [ %55, %63 ], [ %55, %59 ], [ %.065, %79 ]
  %87 = and i32 %.068, 16777216
  %.not90 = icmp eq i32 %87, 0
  br i1 %.not90, label %95, label %88

88:                                               ; preds = %86
  %89 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !32
  %90 = and i8 %89, 1
  %.not99 = icmp eq i8 %90, 0
  br i1 %.not99, label %.thread, label %91, !prof !5

91:                                               ; preds = %88
  %92 = getelementptr inbounds i8, ptr %.166, i64 4
  %93 = load i32, ptr %92, align 4, !tbaa !24
  %.not100 = icmp eq i32 %93, 131073
  br i1 %.not100, label %.thread, label %94, !prof !10

94:                                               ; preds = %91
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.9, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 262) #7
  unreachable

95:                                               ; preds = %86
  %96 = and i32 %.068, 131072
  %.not91 = icmp eq i32 %96, 0
  %97 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !32
  %98 = and i8 %97, 1
  %.not92 = icmp eq i8 %98, 0
  br i1 %.not91, label %105, label %99

99:                                               ; preds = %95
  br i1 %.not92, label %.thread, label %100, !prof !5

100:                                              ; preds = %99
  %101 = getelementptr inbounds i8, ptr %.166, i64 4
  %102 = load i32, ptr %101, align 4, !tbaa !24
  %103 = and i32 %102, -1076494337
  %.not98 = icmp eq i32 %103, 0
  br i1 %.not98, label %.thread, label %104, !prof !10

104:                                              ; preds = %100
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.10, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 265) #7
  unreachable

105:                                              ; preds = %95
  br i1 %.not92, label %.thread, label %106, !prof !5

106:                                              ; preds = %105
  %107 = getelementptr inbounds i8, ptr %.166, i64 4
  %108 = load i32, ptr %107, align 4, !tbaa !24
  %109 = and i32 %108, -1076691209
  %.not93 = icmp eq i32 %109, 0
  br i1 %.not93, label %111, label %110, !prof !10

110:                                              ; preds = %106
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.11, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 268) #7
  unreachable

111:                                              ; preds = %106
  %112 = getelementptr inbounds i8, ptr %.166, i64 536
  %113 = load ptr, ptr %112, align 8, !tbaa !35
  %.not95 = icmp eq ptr %113, null
  br i1 %.not95, label %114, label %.critedge105, !prof !10

114:                                              ; preds = %111
  %115 = getelementptr inbounds i8, ptr %.166, i64 528
  %116 = load i64, ptr %115, align 8, !tbaa !35
  %.not96.not = icmp eq i64 %116, 0
  br i1 %.not96.not, label %.thread, label %.critedge105, !prof !10

.critedge105:                                     ; preds = %111, %114
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.12, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 269) #7
  unreachable

.thread:                                          ; preds = %105, %100, %99, %114, %88, %91
  store i32 332741169, ptr %.166, align 8, !tbaa !33
  %117 = getelementptr inbounds i8, ptr %.166, i64 160
  store ptr %4, ptr %117, align 8, !tbaa !36
  store ptr %.166, ptr %3, align 8, !tbaa !6
  %118 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !28
  %119 = icmp ugt i8 %118, 4
  br i1 %119, label %120, label %131, !prof !5

120:                                              ; preds = %.thread
  %121 = getelementptr inbounds i8, ptr %.166, i64 64
  %122 = load i64, ptr %121, align 8, !tbaa !37
  %123 = and i32 %.068, 131072
  %.not101 = icmp eq i32 %123, 0
  %124 = select i1 %.not101, i32 119, i32 114
  %125 = getelementptr inbounds i8, ptr %.166, i64 88
  %126 = load ptr, ptr %125, align 8, !tbaa !38
  %127 = getelementptr inbounds i8, ptr %126, i64 56
  %128 = load i32, ptr %127, align 4, !tbaa !39
  %129 = getelementptr inbounds i8, ptr %126, i64 8
  %130 = load i32, ptr %129, align 4, !tbaa !39
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_txn_begin_ex, i32 noundef 276, ptr noundef nonnull @.str.13, i64 noundef %122, i32 noundef %124, ptr noundef nonnull %.166, ptr noundef nonnull %0, i32 noundef %128, i32 noundef %130) #6
  br label %131

131:                                              ; preds = %18, %26, %.thread, %120, %84, %77, %56, %48, %43, %31, %15, %6
  %.2 = phi i32 [ %7, %6 ], [ %16, %15 ], [ %19, %18 ], [ %27, %26 ], [ %32, %31 ], [ %44, %43 ], [ %49, %48 ], [ %58, %56 ], [ %78, %77 ], [ %85, %84 ], [ 0, %120 ], [ 0, %.thread ]
  ret i32 %.2
}

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

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

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

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


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