; LLVM IR from erthink/libmdbx :: src (page-ops)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon }
%struct.anon = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.MDBX_txn = type { i32, i32, i64, i64, ptr, ptr, %struct.geo, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, %struct.MDBX_canary, ptr, %union.anon.4 }
%struct.geo = type { i16, i16, i32, i32, %union.anon.2, %union.anon.3 }
%union.anon.2 = type { i32 }
%union.anon.3 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.4 = type { %struct.anon.6 }
%struct.anon.6 = type { %struct.troika, ptr, %struct.anon.7, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.8 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.7 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.8 = type { %struct.anon.9 }
%struct.anon.9 = type { i64, ptr }
%struct.page = type <{ i64, i16, i16, %union.anon.10, i32, [0 x i16] }>
%union.anon.10 = type { i32 }
%struct.dpl = type { i64, i64, i64, i64, [18 x %struct.dp] }
%struct.dp = type { ptr, i32, i32 }

@globals = external global %struct.libmdbx_globals, align 8
@.str.16 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.51 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [36 x i8], align 1
@__func__.page_dirty = external hidden unnamed_addr constant [11 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.70 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [39 x i8], align 1

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

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

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

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

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

; Function Attrs: hot nounwind uwtable
define dso_local i32 @page_dirty(ptr noundef %0, ptr noundef %1, i64 noundef %2) #4 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %3
  %13 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %14 = zext i8 %13 to i32
  %15 = and i32 %14, 1
  %16 = icmp ne i32 %15, 0
  %17 = xor i1 %16, true
  %18 = xor i1 %17, true
  %19 = zext i1 %18 to i32
  %20 = sext i32 %19 to i64
  %21 = call i64 @llvm.expect.i64(i64 %20, i64 1)
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %23, label %43

23:                                               ; preds = %12
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.MDBX_txn, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !15
  %28 = and i32 %27, 131072
  %29 = icmp eq i32 %28, 0
  %30 = xor i1 %29, true
  %31 = xor i1 %30, true
  %32 = xor i1 %31, true
  %33 = zext i1 %32 to i32
  %34 = sext i32 %33 to i64
  %35 = call i64 @llvm.expect.i64(i64 %34, i64 0)
  %36 = icmp ne i64 %35, 0
  br i1 %36, label %37, label %41

37:                                               ; preds = %24
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MDBX_txn, ptr %38, i32 0, i32 9
  %40 = load ptr, ptr %39, align 8, !tbaa !20
  call void @mdbx_assert_fail(ptr noundef %40, ptr noundef @.str.67, ptr noundef @__func__.page_dirty, i32 noundef 661) #8
  unreachable

41:                                               ; preds = %24
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42, %12
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.MDBX_txn, ptr %45, i32 0, i32 8
  %47 = load i64, ptr %46, align 8, !tbaa !21
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.page, ptr %48, i32 0, i32 0
  store i64 %47, ptr %49, align 1, !tbaa !9
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MDBX_txn, ptr %50, i32 0, i32 17
  %52 = getelementptr inbounds %struct.anon.6, ptr %51, i32 0, i32 7
  %53 = load ptr, ptr %52, align 8, !tbaa !22
  %54 = icmp ne ptr %53, null
  br i1 %54, label %132, label %55

55:                                               ; preds = %44
  br label %56

56:                                               ; preds = %55
  %57 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %58 = zext i8 %57 to i32
  %59 = and i32 %58, 1
  %60 = icmp ne i32 %59, 0
  %61 = xor i1 %60, true
  %62 = xor i1 %61, true
  %63 = zext i1 %62 to i32
  %64 = sext i32 %63 to i64
  %65 = call i64 @llvm.expect.i64(i64 %64, i64 1)
  %66 = icmp ne i64 %65, 0
  br i1 %66, label %67, label %90

67:                                               ; preds = %56
  br label %68

68:                                               ; preds = %67
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.MDBX_txn, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !15
  %72 = and i32 %71, 524288
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %68
  br label %75

75:                                               ; preds = %74, %68
  %76 = phi i1 [ false, %68 ], [ true, %74 ]
  %77 = xor i1 %76, true
  %78 = xor i1 %77, true
  %79 = xor i1 %78, true
  %80 = zext i1 %79 to i32
  %81 = sext i32 %80 to i64
  %82 = call i64 @llvm.expect.i64(i64 %81, i64 0)
  %83 = icmp ne i64 %82, 0
  br i1 %83, label %84, label %88

84:                                               ; preds = %75
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.MDBX_txn, ptr %85, i32 0, i32 9
  %87 = load ptr, ptr %86, align 8, !tbaa !20
  call void @mdbx_assert_fail(ptr noundef %87, ptr noundef @.str.68, ptr noundef @__func__.page_dirty, i32 noundef 664) #8
  unreachable

88:                                               ; preds = %75
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89, %56
  br label %91

91:                                               ; preds = %90
  %92 = load i64, ptr %7, align 8, !tbaa !9
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.MDBX_txn, ptr %93, i32 0, i32 17
  %95 = getelementptr inbounds %struct.anon.6, ptr %94, i32 0, i32 11
  %96 = load i64, ptr %95, align 8, !tbaa !22
  %97 = add i64 %96, %92
  store i64 %97, ptr %95, align 8, !tbaa !22
  br label %98

98:                                               ; preds = %91
  %99 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %100 = zext i8 %99 to i32
  %101 = and i32 %100, 1
  %102 = icmp ne i32 %101, 0
  %103 = xor i1 %102, true
  %104 = xor i1 %103, true
  %105 = zext i1 %104 to i32
  %106 = sext i32 %105 to i64
  %107 = call i64 @llvm.expect.i64(i64 %106, i64 1)
  %108 = icmp ne i64 %107, 0
  br i1 %108, label %109, label %130

109:                                              ; preds = %98
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.MDBX_txn, ptr %111, i32 0, i32 17
  %113 = getelementptr inbounds %struct.anon.6, ptr %112, i32 0, i32 11
  %114 = getelementptr inbounds %struct.anon.9, ptr %113, i32 0, i32 1
  %115 = load ptr, ptr %114, align 8, !tbaa !22
  %116 = icmp eq ptr %115, null
  %117 = xor i1 %116, true
  %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 %128

124:                                              ; preds = %110
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.MDBX_txn, ptr %125, i32 0, i32 9
  %127 = load ptr, ptr %126, align 8, !tbaa !20
  call void @mdbx_assert_fail(ptr noundef %127, ptr noundef @.str.69, ptr noundef @__func__.page_dirty, i32 noundef 666) #8
  unreachable

128:                                              ; preds = %110
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129, %98
  br label %131

131:                                              ; preds = %130
  store i32 0, ptr %4, align 4
  br label %418

132:                                              ; preds = %44
  br label %133

133:                                              ; preds = %132
  %134 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %135 = zext i8 %134 to i32
  %136 = and i32 %135, 1
  %137 = icmp ne i32 %136, 0
  %138 = xor i1 %137, true
  %139 = xor i1 %138, true
  %140 = zext i1 %139 to i32
  %141 = sext i32 %140 to i64
  %142 = call i64 @llvm.expect.i64(i64 %141, i64 1)
  %143 = icmp ne i64 %142, 0
  br i1 %143, label %144, label %167

144:                                              ; preds = %133
  br label %145

145:                                              ; preds = %144
  %146 = load ptr, ptr %5, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.MDBX_txn, ptr %146, i32 0, i32 1
  %148 = load i32, ptr %147, align 4, !tbaa !15
  %149 = and i32 %148, 524288
  %150 = icmp eq i32 %149, 0
  br i1 %150, label %152, label %151

151:                                              ; preds = %145
  br label %152

152:                                              ; preds = %151, %145
  %153 = phi i1 [ true, %145 ], [ false, %151 ]
  %154 = xor i1 %153, true
  %155 = xor i1 %154, true
  %156 = xor i1 %155, true
  %157 = zext i1 %156 to i32
  %158 = sext i32 %157 to i64
  %159 = call i64 @llvm.expect.i64(i64 %158, i64 0)
  %160 = icmp ne i64 %159, 0
  br i1 %160, label %161, label %165

161:                                              ; preds = %152
  %162 = load ptr, ptr %5, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.MDBX_txn, ptr %162, i32 0, i32 9
  %164 = load ptr, ptr %163, align 8, !tbaa !20
  call void @mdbx_assert_fail(ptr noundef %164, ptr noundef @.str.16, ptr noundef @__func__.page_dirty, i32 noundef 669) #8
  unreachable

165:                                              ; preds = %152
  br label %166

166:                                              ; preds = %165
  br label %167

167:                                              ; preds = %166, %133
  br label %168

168:                                              ; preds = %167
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  %169 = load ptr, ptr %5, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.MDBX_txn, ptr %169, i32 0, i32 17
  %171 = getelementptr inbounds %struct.anon.6, ptr %170, i32 0, i32 6
  %172 = load i64, ptr %171, align 8, !tbaa !22
  %173 = icmp eq i64 %172, 0
  %174 = xor i1 %173, true
  %175 = xor i1 %174, true
  %176 = zext i1 %175 to i32
  %177 = sext i32 %176 to i64
  %178 = call i64 @llvm.expect.i64(i64 %177, i64 0)
  %179 = icmp ne i64 %178, 0
  br i1 %179, label %180, label %356

180:                                              ; preds = %168
  %181 = load ptr, ptr %5, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.MDBX_txn, ptr %181, i32 0, i32 17
  %183 = getelementptr inbounds %struct.anon.6, ptr %182, i32 0, i32 10
  %184 = load i64, ptr %183, align 8, !tbaa !22
  %185 = icmp ne i64 %184, 0
  br i1 %185, label %186, label %329

186:                                              ; preds = %180
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #9
  %187 = load ptr, ptr %5, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.MDBX_txn, ptr %187, i32 0, i32 17
  %189 = getelementptr inbounds %struct.anon.6, ptr %188, i32 0, i32 9
  %190 = load ptr, ptr %189, align 8, !tbaa !22
  store ptr %190, ptr %9, align 8, !tbaa !5
  br label %191

191:                                              ; preds = %186
  %192 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !23
  %193 = zext i8 %192 to i32
  %194 = icmp sle i32 5, %193
  %195 = xor i1 %194, true
  %196 = xor i1 %195, true
  %197 = zext i1 %196 to i32
  %198 = sext i32 %197 to i64
  %199 = call i64 @llvm.expect.i64(i64 %198, i64 0)
  %200 = icmp ne i64 %199, 0
  br i1 %200, label %201, label %205

201:                                              ; preds = %191
  %202 = load ptr, ptr %9, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.page, ptr %202, i32 0, i32 4
  %204 = load i32, ptr %203, align 1, !tbaa !24
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.page_dirty, i32 noundef 681, ptr noundef @.str.70, i32 noundef %204)
  br label %205

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

206:                                              ; preds = %205
  br label %207

207:                                              ; preds = %206
  %208 = load ptr, ptr %5, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.MDBX_txn, ptr %208, i32 0, i32 17
  %210 = getelementptr inbounds %struct.anon.6, ptr %209, i32 0, i32 1
  %211 = load ptr, ptr %9, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.page, ptr %211, i32 0, i32 4
  %213 = load i32, ptr %212, align 1, !tbaa !24
  %214 = call i32 @pnl_insert_span(ptr noundef %210, i32 noundef %213, i64 noundef 1)
  store i32 %214, ptr %8, align 4, !tbaa !24
  %215 = load i32, ptr %8, align 4, !tbaa !24
  %216 = icmp ne i32 %215, 0
  %217 = xor i1 %216, true
  %218 = xor i1 %217, true
  %219 = zext i1 %218 to i32
  %220 = sext i32 %219 to i64
  %221 = call i64 @llvm.expect.i64(i64 %220, i64 0)
  %222 = icmp ne i64 %221, 0
  br i1 %222, label %223, label %224

223:                                              ; preds = %207
  store i32 20, ptr %11, align 4
  br label %326

224:                                              ; preds = %207
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  %225 = load ptr, ptr %5, align 8, !tbaa !5
  %226 = load ptr, ptr %9, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.page, ptr %226, i32 0, i32 4
  %228 = load i32, ptr %227, align 1, !tbaa !24
  %229 = call i64 @dpl_search(ptr noundef %225, i32 noundef %228) #10
  store i64 %229, ptr %10, align 8, !tbaa !9
  br label %230

230:                                              ; preds = %224
  %231 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %232 = zext i8 %231 to i32
  %233 = and i32 %232, 1
  %234 = icmp ne i32 %233, 0
  %235 = xor i1 %234, true
  %236 = xor i1 %235, true
  %237 = zext i1 %236 to i32
  %238 = sext i32 %237 to i64
  %239 = call i64 @llvm.expect.i64(i64 %238, i64 1)
  %240 = icmp ne i64 %239, 0
  br i1 %240, label %241, label %268

241:                                              ; preds = %230
  br label %242

242:                                              ; preds = %241
  %243 = load ptr, ptr %5, align 8, !tbaa !5
  %244 = getelementptr inbounds %struct.MDBX_txn, ptr %243, i32 0, i32 17
  %245 = getelementptr inbounds %struct.anon.6, ptr %244, i32 0, i32 7
  %246 = load ptr, ptr %245, align 8, !tbaa !22
  %247 = getelementptr inbounds %struct.dpl, ptr %246, i32 0, i32 4
  %248 = load i64, ptr %10, align 8, !tbaa !9
  %249 = getelementptr inbounds [18 x %struct.dp], ptr %247, i64 0, i64 %248
  %250 = getelementptr inbounds %struct.dp, ptr %249, i32 0, i32 0
  %251 = load ptr, ptr %250, align 8, !tbaa !25
  %252 = load ptr, ptr %9, align 8, !tbaa !5
  %253 = icmp eq ptr %251, %252
  %254 = xor i1 %253, true
  %255 = xor i1 %254, true
  %256 = xor i1 %255, true
  %257 = zext i1 %256 to i32
  %258 = sext i32 %257 to i64
  %259 = call i64 @llvm.expect.i64(i64 %258, i64 0)
  %260 = icmp ne i64 %259, 0
  br i1 %260, label %261, label %265

261:                                              ; preds = %242
  %262 = load ptr, ptr %5, align 8, !tbaa !5
  %263 = getelementptr inbounds %struct.MDBX_txn, ptr %262, i32 0, i32 9
  %264 = load ptr, ptr %263, align 8, !tbaa !20
  call void @mdbx_assert_fail(ptr noundef %264, ptr noundef @.str.71, ptr noundef @__func__.page_dirty, i32 noundef 686) #8
  unreachable

265:                                              ; preds = %242
  br label %266

266:                                              ; preds = %265
  br label %267

267:                                              ; preds = %266
  br label %268

268:                                              ; preds = %267, %230
  br label %269

269:                                              ; preds = %268
  br label %270

270:                                              ; preds = %269
  %271 = load ptr, ptr %5, align 8, !tbaa !5
  %272 = load i64, ptr %10, align 8, !tbaa !9
  call void @dpl_remove(ptr noundef %271, i64 noundef %272)
  br label %273

273:                                              ; preds = %270
  br label %274

274:                                              ; preds = %273
  %275 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !23
  %276 = zext i8 %275 to i32
  %277 = icmp sle i32 6, %276
  %278 = xor i1 %277, true
  %279 = xor i1 %278, true
  %280 = zext i1 %279 to i32
  %281 = sext i32 %280 to i64
  %282 = call i64 @llvm.expect.i64(i64 %281, i64 0)
  %283 = icmp ne i64 %282, 0
  br i1 %283, label %284, label %291

284:                                              ; preds = %274
  %285 = load ptr, ptr %9, align 8, !tbaa !5
  %286 = getelementptr inbounds %struct.page, ptr %285, i32 0, i32 5
  %287 = getelementptr inbounds [0 x i16], ptr %286, i64 0, i64 0
  %288 = ptrtoint ptr %287 to i64
  %289 = add nsw i64 %288, 4
  %290 = inttoptr i64 %289 to ptr
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 6, ptr noundef @__func__.page_dirty, i32 noundef 688, ptr noundef @.str.29, ptr noundef %290, i64 noundef 8, i32 noundef 688)
  br label %291

291:                                              ; preds = %284, %274
  br label %292

292:                                              ; preds = %291
  br label %293

293:                                              ; preds = %292
  %294 = load ptr, ptr %9, align 8, !tbaa !5
  %295 = getelementptr inbounds %struct.page, ptr %294, i32 0, i32 5
  %296 = getelementptr inbounds [0 x i16], ptr %295, i64 0, i64 0
  %297 = ptrtoint ptr %296 to i64
  %298 = add nsw i64 %297, 4
  %299 = inttoptr i64 %298 to ptr
  br label %300

300:                                              ; preds = %293
  br label %301

301:                                              ; preds = %300
  %302 = load ptr, ptr %9, align 8, !tbaa !5
  %303 = getelementptr inbounds %struct.page, ptr %302, i32 0, i32 5
  %304 = getelementptr inbounds [0 x i16], ptr %303, i64 0, i64 0
  %305 = ptrtoint ptr %304 to i64
  %306 = add nsw i64 %305, 4
  %307 = inttoptr i64 %306 to ptr
  %308 = load ptr, ptr %307, align 8, !tbaa !5
  %309 = load ptr, ptr %5, align 8, !tbaa !5
  %310 = getelementptr inbounds %struct.MDBX_txn, ptr %309, i32 0, i32 17
  %311 = getelementptr inbounds %struct.anon.6, ptr %310, i32 0, i32 9
  store ptr %308, ptr %311, align 8, !tbaa !22
  %312 = load ptr, ptr %5, align 8, !tbaa !5
  %313 = getelementptr inbounds %struct.MDBX_txn, ptr %312, i32 0, i32 17
  %314 = getelementptr inbounds %struct.anon.6, ptr %313, i32 0, i32 10
  %315 = load i64, ptr %314, align 8, !tbaa !22
  %316 = add i64 %315, -1
  store i64 %316, ptr %314, align 8, !tbaa !22
  %317 = load ptr, ptr %5, align 8, !tbaa !5
  %318 = getelementptr inbounds %struct.MDBX_txn, ptr %317, i32 0, i32 17
  %319 = getelementptr inbounds %struct.anon.6, ptr %318, i32 0, i32 6
  %320 = load i64, ptr %319, align 8, !tbaa !22
  %321 = add i64 %320, 1
  store i64 %321, ptr %319, align 8, !tbaa !22
  %322 = load ptr, ptr %5, align 8, !tbaa !5
  %323 = getelementptr inbounds %struct.MDBX_txn, ptr %322, i32 0, i32 9
  %324 = load ptr, ptr %323, align 8, !tbaa !20
  %325 = load ptr, ptr %9, align 8, !tbaa !5
  call void @page_shadow_release(ptr noundef %324, ptr noundef %325, i64 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  store i32 0, ptr %11, align 4
  br label %326

326:                                              ; preds = %301, %223
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  %327 = load i32, ptr %11, align 4
  switch i32 %327, label %417 [
    i32 0, label %328
    i32 20, label %373
  ]

328:                                              ; preds = %326
  br label %355

329:                                              ; preds = %180
  br label %330

330:                                              ; preds = %329
  %331 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !23
  %332 = zext i8 %331 to i32
  %333 = icmp sle i32 1, %332
  %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 0)
  %339 = icmp ne i64 %338, 0
  br i1 %339, label %340, label %347

340:                                              ; preds = %330
  %341 = load ptr, ptr %5, align 8, !tbaa !5
  %342 = getelementptr inbounds %struct.MDBX_txn, ptr %341, i32 0, i32 17
  %343 = getelementptr inbounds %struct.anon.6, ptr %342, i32 0, i32 7
  %344 = load ptr, ptr %343, align 8, !tbaa !22
  %345 = getelementptr inbounds %struct.dpl, ptr %344, i32 0, i32 1
  %346 = load i64, ptr %345, align 8, !tbaa !27
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.page_dirty, i32 noundef 696, ptr noundef @.str.72, i64 noundef %346)
  br label %347

347:                                              ; preds = %340, %330
  br label %348

348:                                              ; preds = %347
  br label %349

349:                                              ; preds = %348
  %350 = load ptr, ptr %5, align 8, !tbaa !5
  %351 = getelementptr inbounds %struct.MDBX_txn, ptr %350, i32 0, i32 9
  %352 = load ptr, ptr %351, align 8, !tbaa !20
  %353 = load ptr, ptr %6, align 8, !tbaa !5
  %354 = load i64, ptr %7, align 8, !tbaa !9
  call void @page_shadow_release(ptr noundef %352, ptr noundef %353, i64 noundef %354)
  store i32 -30788, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %417

355:                                              ; preds = %328
  br label %356

356:                                              ; preds = %355, %168
  %357 = load ptr, ptr %5, align 8, !tbaa !5
  %358 = load ptr, ptr %6, align 8, !tbaa !5
  %359 = getelementptr inbounds %struct.page, ptr %358, i32 0, i32 4
  %360 = load i32, ptr %359, align 1, !tbaa !24
  %361 = load ptr, ptr %6, align 8, !tbaa !5
  %362 = load i64, ptr %7, align 8, !tbaa !9
  %363 = call i32 @dpl_append(ptr noundef %357, i32 noundef %360, ptr noundef %361, i64 noundef %362)
  store i32 %363, ptr %8, align 4, !tbaa !24
  %364 = load i32, ptr %8, align 4, !tbaa !24
  %365 = icmp ne i32 %364, 0
  %366 = xor i1 %365, true
  %367 = xor i1 %366, true
  %368 = zext i1 %367 to i32
  %369 = sext i32 %368 to i64
  %370 = call i64 @llvm.expect.i64(i64 %369, i64 0)
  %371 = icmp ne i64 %370, 0
  br i1 %371, label %372, label %379

372:                                              ; preds = %356
  br label %373

373:                                              ; preds = %372, %326
  %374 = load ptr, ptr %5, align 8, !tbaa !5
  %375 = getelementptr inbounds %struct.MDBX_txn, ptr %374, i32 0, i32 1
  %376 = load i32, ptr %375, align 4, !tbaa !15
  %377 = or i32 %376, 2
  store i32 %377, ptr %375, align 4, !tbaa !15
  %378 = load i32, ptr %8, align 4, !tbaa !24
  store i32 %378, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %417

379:                                              ; preds = %356
  %380 = load ptr, ptr %5, align 8, !tbaa !5
  %381 = getelementptr inbounds %struct.MDBX_txn, ptr %380, i32 0, i32 17
  %382 = getelementptr inbounds %struct.anon.6, ptr %381, i32 0, i32 6
  %383 = load i64, ptr %382, align 8, !tbaa !22
  %384 = add i64 %383, -1
  store i64 %384, ptr %382, align 8, !tbaa !22
  br label %385

385:                                              ; preds = %379
  %386 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %387 = zext i8 %386 to i32
  %388 = and i32 %387, 1
  %389 = icmp ne i32 %388, 0
  %390 = xor i1 %389, true
  %391 = xor i1 %390, true
  %392 = zext i1 %391 to i32
  %393 = sext i32 %392 to i64
  %394 = call i64 @llvm.expect.i64(i64 %393, i64 1)
  %395 = icmp ne i64 %394, 0
  br i1 %395, label %396, label %414

396:                                              ; preds = %385
  br label %397

397:                                              ; preds = %396
  %398 = load ptr, ptr %5, align 8, !tbaa !5
  %399 = call zeroext i1 @dpl_check(ptr noundef %398)
  %400 = xor i1 %399, true
  %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 0)
  %406 = icmp ne i64 %405, 0
  br i1 %406, label %407, label %411

407:                                              ; preds = %397
  %408 = load ptr, ptr %5, align 8, !tbaa !5
  %409 = getelementptr inbounds %struct.MDBX_txn, ptr %408, i32 0, i32 9
  %410 = load ptr, ptr %409, align 8, !tbaa !20
  call void @mdbx_assert_fail(ptr noundef %410, ptr noundef @.str.51, ptr noundef @__func__.page_dirty, i32 noundef 710) #8
  unreachable

411:                                              ; preds = %397
  br label %412

412:                                              ; preds = %411
  br label %413

413:                                              ; preds = %412
  br label %414

414:                                              ; preds = %413, %385
  br label %415

415:                                              ; preds = %414
  br label %416

416:                                              ; preds = %415
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %417

417:                                              ; preds = %416, %373, %349, %326
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  br label %418

418:                                              ; preds = %417, %131
  %419 = load i32, ptr %4, align 4
  ret i32 %419
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @dpl_search(ptr noundef, i32 noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @page_shadow_release(ptr noundef, ptr noundef, i64 noundef) #6

declare zeroext i1 @dpl_check(ptr noundef) #2

declare i32 @pnl_insert_span(ptr noundef, i32 noundef, i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @dpl_remove(ptr noundef, i64 noundef) #7

declare i32 @dpl_append(ptr noundef, i32 noundef, ptr noundef, i64 noundef) #2

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

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon }
%struct.anon = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.dp = type { ptr, i32, i32 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.16 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.51 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.67 = external hidden unnamed_addr constant [36 x i8], align 1
@__func__.page_dirty = external hidden unnamed_addr constant [11 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.69 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.70 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.71 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.72 = external hidden unnamed_addr constant [39 x i8], align 1

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

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

; Function Attrs: hot nounwind uwtable
define dso_local i32 @page_dirty(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 {
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %5 = and i8 %4, 1
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %13, label %6, !prof !13

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !14
  %9 = and i32 %8, 131072
  %.not54 = icmp eq i32 %9, 0
  br i1 %.not54, label %.thread, label %10, !prof !19

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = load ptr, ptr %11, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %12, ptr noundef nonnull @.str.67, ptr noundef nonnull @__func__.page_dirty, i32 noundef 661) #6
  unreachable

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %0, i64 72
  %15 = load i64, ptr %14, align 8, !tbaa !21
  store i64 %15, ptr %1, align 1, !tbaa !22
  %16 = getelementptr inbounds i8, ptr %0, i64 496
  %17 = load ptr, ptr %16, align 8, !tbaa !23
  %.not55 = icmp eq ptr %17, null
  br i1 %.not55, label %27, label %44

.thread:                                          ; preds = %6
  %18 = getelementptr inbounds i8, ptr %0, i64 72
  %19 = load i64, ptr %18, align 8, !tbaa !21
  store i64 %19, ptr %1, align 1, !tbaa !22
  %20 = getelementptr inbounds i8, ptr %0, i64 496
  %21 = load ptr, ptr %20, align 8, !tbaa !23
  %.not5569 = icmp eq ptr %21, null
  %22 = and i32 %8, 524288
  %.not57 = icmp eq i32 %22, 0
  br i1 %.not5569, label %23, label %40

23:                                               ; preds = %.thread
  br i1 %.not57, label %24, label %31, !prof !13

24:                                               ; preds = %23
  %25 = getelementptr inbounds i8, ptr %0, i64 80
  %26 = load ptr, ptr %25, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %26, ptr noundef nonnull @.str.68, ptr noundef nonnull @__func__.page_dirty, i32 noundef 664) #6
  unreachable

27:                                               ; preds = %13
  %28 = getelementptr inbounds i8, ptr %0, i64 528
  %29 = load i64, ptr %28, align 8, !tbaa !23
  %30 = add i64 %29, %2
  store i64 %30, ptr %28, align 8, !tbaa !23
  br label %124

31:                                               ; preds = %23
  %32 = getelementptr inbounds i8, ptr %0, i64 528
  %33 = load i64, ptr %32, align 8, !tbaa !23
  %34 = add i64 %33, %2
  store i64 %34, ptr %32, align 8, !tbaa !23
  %35 = getelementptr inbounds i8, ptr %0, i64 536
  %36 = load ptr, ptr %35, align 8, !tbaa !23
  %.not59 = icmp eq ptr %36, null
  br i1 %.not59, label %124, label %37, !prof !19

37:                                               ; preds = %31
  %38 = getelementptr inbounds i8, ptr %0, i64 80
  %39 = load ptr, ptr %38, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %39, ptr noundef nonnull @.str.69, ptr noundef nonnull @__func__.page_dirty, i32 noundef 666) #6
  unreachable

40:                                               ; preds = %.thread
  br i1 %.not57, label %44, label %41, !prof !19

41:                                               ; preds = %40
  %42 = getelementptr inbounds i8, ptr %0, i64 80
  %43 = load ptr, ptr %42, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %43, ptr noundef nonnull @.str.16, ptr noundef nonnull @__func__.page_dirty, i32 noundef 669) #6
  unreachable

44:                                               ; preds = %13, %40
  %45 = phi ptr [ %20, %40 ], [ %16, %13 ]
  %46 = phi ptr [ %21, %40 ], [ %17, %13 ]
  %47 = getelementptr inbounds i8, ptr %0, i64 488
  %48 = load i64, ptr %47, align 8, !tbaa !23
  %49 = icmp eq i64 %48, 0
  br i1 %49, label %50, label %106, !prof !13

50:                                               ; preds = %44
  %51 = getelementptr inbounds i8, ptr %0, i64 520
  %52 = load i64, ptr %51, align 8, !tbaa !23
  %.not62 = icmp eq i64 %52, 0
  br i1 %.not62, label %98, label %53

53:                                               ; preds = %50
  %54 = getelementptr inbounds i8, ptr %0, i64 512
  %55 = load ptr, ptr %54, align 8, !tbaa !23
  %56 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !24
  %57 = icmp ugt i8 %56, 4
  br i1 %57, label %58, label %61, !prof !13

58:                                               ; preds = %53
  %59 = getelementptr inbounds i8, ptr %55, i64 16
  %60 = load i32, ptr %59, align 1, !tbaa !25
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.page_dirty, i32 noundef 681, ptr noundef nonnull @.str.70, i32 noundef %60) #7
  br label %61

61:                                               ; preds = %58, %53
  %62 = getelementptr inbounds i8, ptr %0, i64 200
  %63 = getelementptr inbounds i8, ptr %55, i64 16
  %64 = load i32, ptr %63, align 1, !tbaa !25
  %65 = tail call i32 @pnl_insert_span(ptr noundef nonnull %62, i32 noundef %64, i64 noundef 1) #7
  %.not64 = icmp eq i32 %65, 0
  br i1 %.not64, label %66, label %110, !prof !19

66:                                               ; preds = %61
  %67 = load i32, ptr %63, align 1, !tbaa !25
  %68 = tail call i64 @dpl_search(ptr noundef nonnull %0, i32 noundef %67) #8
  %69 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %70 = and i8 %69, 1
  %.not65 = icmp eq i8 %70, 0
  br i1 %.not65, label %79, label %71, !prof !13

71:                                               ; preds = %66
  %72 = load ptr, ptr %45, align 8, !tbaa !23
  %73 = getelementptr inbounds i8, ptr %72, i64 32
  %74 = getelementptr inbounds [18 x %struct.dp], ptr %73, i64 0, i64 %68
  %75 = load ptr, ptr %74, align 8, !tbaa !26
  %.not66 = icmp eq ptr %75, %55
  br i1 %.not66, label %79, label %76, !prof !19

76:                                               ; preds = %71
  %77 = getelementptr inbounds i8, ptr %0, i64 80
  %78 = load ptr, ptr %77, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %78, ptr noundef nonnull @.str.71, ptr noundef nonnull @__func__.page_dirty, i32 noundef 686) #6
  unreachable

79:                                               ; preds = %71, %66
  tail call void @dpl_remove(ptr noundef nonnull %0, i64 noundef %68)
  %80 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !24
  %81 = icmp ugt i8 %80, 5
  br i1 %81, label %82, label %.thread73, !prof !13

82:                                               ; preds = %79
  %83 = getelementptr inbounds i8, ptr %55, i64 20
  %84 = ptrtoint ptr %83 to i64
  %85 = add nsw i64 %84, 4
  %86 = inttoptr i64 %85 to ptr
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 6, ptr noundef nonnull @__func__.page_dirty, i32 noundef 688, ptr noundef nonnull @.str.29, ptr noundef %86, i64 noundef 8, i32 noundef 688) #7
  br label %.thread73

.thread73:                                        ; preds = %79, %82
  %87 = getelementptr inbounds i8, ptr %55, i64 20
  %88 = ptrtoint ptr %87 to i64
  %89 = add nsw i64 %88, 4
  %90 = inttoptr i64 %89 to ptr
  %91 = load ptr, ptr %90, align 8, !tbaa !28
  store ptr %91, ptr %54, align 8, !tbaa !23
  %92 = load i64, ptr %51, align 8, !tbaa !23
  %93 = add i64 %92, -1
  store i64 %93, ptr %51, align 8, !tbaa !23
  %94 = load i64, ptr %47, align 8, !tbaa !23
  %95 = add i64 %94, 1
  store i64 %95, ptr %47, align 8, !tbaa !23
  %96 = getelementptr inbounds i8, ptr %0, i64 80
  %97 = load ptr, ptr %96, align 8, !tbaa !20
  tail call void @page_shadow_release(ptr noundef %97, ptr noundef nonnull %55, i64 noundef 1)
  br label %106

98:                                               ; preds = %50
  %99 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !24
  %.not63 = icmp eq i8 %99, 0
  br i1 %.not63, label %103, label %100, !prof !19

100:                                              ; preds = %98
  %101 = getelementptr inbounds i8, ptr %46, i64 8
  %102 = load i64, ptr %101, align 8, !tbaa !29
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.page_dirty, i32 noundef 696, ptr noundef nonnull @.str.72, i64 noundef %102) #7
  br label %103

103:                                              ; preds = %100, %98
  %104 = getelementptr inbounds i8, ptr %0, i64 80
  %105 = load ptr, ptr %104, align 8, !tbaa !20
  tail call void @page_shadow_release(ptr noundef %105, ptr noundef nonnull %1, i64 noundef %2)
  br label %124

106:                                              ; preds = %.thread73, %44
  %107 = getelementptr inbounds i8, ptr %1, i64 16
  %108 = load i32, ptr %107, align 1, !tbaa !25
  %109 = tail call i32 @dpl_append(ptr noundef nonnull %0, i32 noundef %108, ptr noundef nonnull %1, i64 noundef %2) #7
  %.not67 = icmp eq i32 %109, 0
  br i1 %.not67, label %114, label %110, !prof !19

110:                                              ; preds = %61, %106
  %.052 = phi i32 [ %109, %106 ], [ %65, %61 ]
  %111 = getelementptr inbounds i8, ptr %0, i64 4
  %112 = load i32, ptr %111, align 4, !tbaa !14
  %113 = or i32 %112, 2
  store i32 %113, ptr %111, align 4, !tbaa !14
  br label %124

114:                                              ; preds = %106
  %115 = load i64, ptr %47, align 8, !tbaa !23
  %116 = add i64 %115, -1
  store i64 %116, ptr %47, align 8, !tbaa !23
  %117 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %118 = and i8 %117, 1
  %.not68 = icmp eq i8 %118, 0
  br i1 %.not68, label %124, label %119, !prof !13

119:                                              ; preds = %114
  %120 = tail call zeroext i1 @dpl_check(ptr noundef nonnull %0) #7
  br i1 %120, label %124, label %121, !prof !19

121:                                              ; preds = %119
  %122 = getelementptr inbounds i8, ptr %0, i64 80
  %123 = load ptr, ptr %122, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %123, ptr noundef nonnull @.str.51, ptr noundef nonnull @__func__.page_dirty, i32 noundef 710) #6
  unreachable

124:                                              ; preds = %27, %103, %110, %119, %114, %31
  %.1 = phi i32 [ 0, %27 ], [ 0, %31 ], [ %.052, %110 ], [ -30788, %103 ], [ 0, %119 ], [ 0, %114 ]
  ret i32 %.1
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i64 @dpl_search(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @page_shadow_release(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare zeroext i1 @dpl_check(ptr noundef) local_unnamed_addr #1

declare i32 @pnl_insert_span(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @dpl_remove(ptr noundef, i64 noundef) local_unnamed_addr #5

declare i32 @dpl_append(ptr noundef, i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

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

!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, !7, i64 25}
!6 = !{!"libmdbx_globals", !7, i64 0, !9, i64 16, !9, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !10, i64 27, !9, i64 28, !7, i64 32, !7, i64 40, !11, i64 80, !12, i64 88}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!14 = !{!15, !9, i64 4}
!15 = !{!"MDBX_txn", !9, i64 0, !9, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !16, 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, !18, i64 128, !12, i64 160, !7, i64 168}
!16 = !{!"geo", !17, i64 0, !17, i64 2, !9, i64 4, !9, i64 8, !7, i64 12, !7, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!19 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!20 = !{!15, !12, i64 80}
!21 = !{!15, !11, i64 72}
!22 = !{!11, !11, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!6, !7, i64 26}
!25 = !{!9, !9, i64 0}
!26 = !{!27, !12, i64 0}
!27 = !{!"dp", !12, i64 0, !9, i64 8, !9, i64 12}
!28 = !{!12, !12, i64 0}
!29 = !{!30, !11, i64 8}
!30 = !{!"dpl", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32}


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