; 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.14 = external hidden unnamed_addr constant [43 x i8], align 1
@__func__.page_touch_modifable = external hidden unnamed_addr constant [21 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [86 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

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

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

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

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

7:                                                ; preds = %2
  %8 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %9 = zext i8 %8 to i32
  %10 = and i32 %9, 1
  %11 = icmp ne i32 %10, 0
  %12 = xor i1 %11, true
  %13 = xor i1 %12, true
  %14 = zext i1 %13 to i32
  %15 = sext i32 %14 to i64
  %16 = call i64 @llvm.expect.i64(i64 %15, i64 1)
  %17 = icmp ne i64 %16, 0
  br i1 %17, label %18, label %44

18:                                               ; preds = %7
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = call zeroext i1 @is_modifable(ptr noundef %20, ptr noundef %21) #6
  br i1 %22, label %23, label %29

23:                                               ; preds = %19
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.MDBX_txn, ptr %24, i32 0, i32 17
  %26 = getelementptr inbounds %struct.anon.6, ptr %25, i32 0, i32 7
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = icmp ne ptr %27, null
  br label %29

29:                                               ; preds = %23, %19
  %30 = phi i1 [ false, %19 ], [ %28, %23 ]
  %31 = xor i1 %30, true
  %32 = xor i1 %31, true
  %33 = xor i1 %32, true
  %34 = zext i1 %33 to i32
  %35 = sext i32 %34 to i64
  %36 = call i64 @llvm.expect.i64(i64 %35, i64 0)
  %37 = icmp ne i64 %36, 0
  br i1 %37, label %38, label %42

38:                                               ; preds = %29
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.MDBX_txn, ptr %39, i32 0, i32 9
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %41, ptr noundef @.str.14, ptr noundef @__func__.page_touch_modifable, i32 noundef 147) #7
  unreachable

42:                                               ; preds = %29
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43, %7
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %48 = zext i8 %47 to i32
  %49 = and i32 %48, 1
  %50 = icmp ne i32 %49, 0
  %51 = xor i1 %50, true
  %52 = xor i1 %51, true
  %53 = zext i1 %52 to i32
  %54 = sext i32 %53 to i64
  %55 = call i64 @llvm.expect.i64(i64 %54, i64 1)
  %56 = icmp ne i64 %55, 0
  br i1 %56, label %57, label %80

57:                                               ; preds = %46
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = call zeroext i1 @is_largepage(ptr noundef %59) #6
  br i1 %60, label %65, label %61

61:                                               ; preds = %58
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = call zeroext i1 @is_subpage(ptr noundef %62) #6
  %64 = xor i1 %63, true
  br label %65

65:                                               ; preds = %61, %58
  %66 = phi i1 [ false, %58 ], [ %64, %61 ]
  %67 = xor i1 %66, true
  %68 = xor i1 %67, true
  %69 = xor i1 %68, true
  %70 = zext i1 %69 to i32
  %71 = sext i32 %70 to i64
  %72 = call i64 @llvm.expect.i64(i64 %71, i64 0)
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %78

74:                                               ; preds = %65
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.MDBX_txn, ptr %75, i32 0, i32 9
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %77, ptr noundef @.str.15, ptr noundef @__func__.page_touch_modifable, i32 noundef 148) #7
  unreachable

78:                                               ; preds = %65
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79, %46
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81
  %83 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %84 = zext i8 %83 to i32
  %85 = and i32 %84, 1
  %86 = icmp ne i32 %85, 0
  %87 = xor i1 %86, true
  %88 = xor i1 %87, true
  %89 = zext i1 %88 to i32
  %90 = sext i32 %89 to i64
  %91 = call i64 @llvm.expect.i64(i64 %90, i64 1)
  %92 = icmp ne i64 %91, 0
  br i1 %92, label %93, label %116

93:                                               ; preds = %82
  br label %94

94:                                               ; preds = %93
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.MDBX_txn, ptr %95, i32 0, i32 1
  %97 = load i32, ptr %96, align 4, !tbaa !20
  %98 = and i32 %97, 524288
  %99 = icmp eq i32 %98, 0
  br i1 %99, label %101, label %100

100:                                              ; preds = %94
  br label %101

101:                                              ; preds = %100, %94
  %102 = phi i1 [ true, %94 ], [ false, %100 ]
  %103 = xor i1 %102, true
  %104 = xor i1 %103, true
  %105 = xor i1 %104, true
  %106 = zext i1 %105 to i32
  %107 = sext i32 %106 to i64
  %108 = call i64 @llvm.expect.i64(i64 %107, i64 0)
  %109 = icmp ne i64 %108, 0
  br i1 %109, label %110, label %114

110:                                              ; preds = %101
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.MDBX_txn, ptr %111, i32 0, i32 9
  %113 = load ptr, ptr %112, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %113, ptr noundef @.str.16, ptr noundef @__func__.page_touch_modifable, i32 noundef 149) #7
  unreachable

114:                                              ; preds = %101
  br label %115

115:                                              ; preds = %114
  br label %116

116:                                              ; preds = %115, %82
  br label %117

117:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #8
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.page, ptr %119, i32 0, i32 4
  %121 = load i32, ptr %120, align 1, !tbaa !21
  %122 = call i64 @dpl_search(ptr noundef %118, i32 noundef %121) #6
  store i64 %122, ptr %5, align 8, !tbaa !22
  br label %123

123:                                              ; preds = %117
  %124 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %125 = zext i8 %124 to i32
  %126 = and i32 %125, 1
  %127 = icmp ne i32 %126, 0
  %128 = xor i1 %127, true
  %129 = xor i1 %128, true
  %130 = zext i1 %129 to i32
  %131 = sext i32 %130 to i64
  %132 = call i64 @llvm.expect.i64(i64 %131, i64 1)
  %133 = icmp ne i64 %132, 0
  br i1 %133, label %134, label %163

134:                                              ; preds = %123
  br label %135

135:                                              ; preds = %134
  %136 = load i64, ptr %5, align 8, !tbaa !22
  %137 = icmp ugt i64 %136, 0
  br i1 %137, label %138, label %147

138:                                              ; preds = %135
  %139 = load i64, ptr %5, align 8, !tbaa !22
  %140 = load ptr, ptr %3, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.MDBX_txn, ptr %140, i32 0, i32 17
  %142 = getelementptr inbounds %struct.anon.6, ptr %141, i32 0, i32 7
  %143 = load ptr, ptr %142, align 8, !tbaa !14
  %144 = getelementptr inbounds %struct.dpl, ptr %143, i32 0, i32 1
  %145 = load i64, ptr %144, align 8, !tbaa !23
  %146 = icmp ule i64 %139, %145
  br label %147

147:                                              ; preds = %138, %135
  %148 = phi i1 [ false, %135 ], [ %146, %138 ]
  %149 = xor i1 %148, true
  %150 = xor i1 %149, true
  %151 = xor i1 %150, true
  %152 = zext i1 %151 to i32
  %153 = sext i32 %152 to i64
  %154 = call i64 @llvm.expect.i64(i64 %153, i64 0)
  %155 = icmp ne i64 %154, 0
  br i1 %155, label %156, label %160

156:                                              ; preds = %147
  %157 = load ptr, ptr %3, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.MDBX_txn, ptr %157, i32 0, i32 9
  %159 = load ptr, ptr %158, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %159, ptr noundef @.str.17, ptr noundef @__func__.page_touch_modifable, i32 noundef 162) #7
  unreachable

160:                                              ; preds = %147
  br label %161

161:                                              ; preds = %160
  br label %162

162:                                              ; preds = %161
  br label %163

163:                                              ; preds = %162, %123
  br label %164

164:                                              ; preds = %163
  br label %165

165:                                              ; preds = %164
  br label %166

166:                                              ; preds = %165
  %167 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %168 = zext i8 %167 to i32
  %169 = and i32 %168, 1
  %170 = icmp ne i32 %169, 0
  %171 = xor i1 %170, true
  %172 = xor i1 %171, true
  %173 = zext i1 %172 to i32
  %174 = sext i32 %173 to i64
  %175 = call i64 @llvm.expect.i64(i64 %174, i64 1)
  %176 = icmp ne i64 %175, 0
  br i1 %176, label %177, label %220

177:                                              ; preds = %166
  br label %178

178:                                              ; preds = %177
  %179 = load ptr, ptr %3, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.MDBX_txn, ptr %179, i32 0, i32 17
  %181 = getelementptr inbounds %struct.anon.6, ptr %180, i32 0, i32 7
  %182 = load ptr, ptr %181, align 8, !tbaa !14
  %183 = getelementptr inbounds %struct.dpl, ptr %182, i32 0, i32 4
  %184 = load i64, ptr %5, align 8, !tbaa !22
  %185 = getelementptr inbounds [18 x %struct.dp], ptr %183, i64 0, i64 %184
  %186 = getelementptr inbounds %struct.dp, ptr %185, i32 0, i32 1
  %187 = load i32, ptr %186, align 8, !tbaa !25
  %188 = load ptr, ptr %4, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.page, ptr %188, i32 0, i32 4
  %190 = load i32, ptr %189, align 1, !tbaa !21
  %191 = icmp eq i32 %187, %190
  br i1 %191, label %192, label %204

192:                                              ; preds = %178
  %193 = load ptr, ptr %3, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.MDBX_txn, ptr %193, i32 0, i32 17
  %195 = getelementptr inbounds %struct.anon.6, ptr %194, i32 0, i32 7
  %196 = load ptr, ptr %195, align 8, !tbaa !14
  %197 = getelementptr inbounds %struct.dpl, ptr %196, i32 0, i32 4
  %198 = load i64, ptr %5, align 8, !tbaa !22
  %199 = getelementptr inbounds [18 x %struct.dp], ptr %197, i64 0, i64 %198
  %200 = getelementptr inbounds %struct.dp, ptr %199, i32 0, i32 0
  %201 = load ptr, ptr %200, align 8, !tbaa !27
  %202 = load ptr, ptr %4, align 8, !tbaa !5
  %203 = icmp eq ptr %201, %202
  br label %204

204:                                              ; preds = %192, %178
  %205 = phi i1 [ false, %178 ], [ %203, %192 ]
  %206 = xor i1 %205, true
  %207 = xor i1 %206, true
  %208 = xor i1 %207, true
  %209 = zext i1 %208 to i32
  %210 = sext i32 %209 to i64
  %211 = call i64 @llvm.expect.i64(i64 %210, i64 0)
  %212 = icmp ne i64 %211, 0
  br i1 %212, label %213, label %217

213:                                              ; preds = %204
  %214 = load ptr, ptr %3, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.MDBX_txn, ptr %214, i32 0, i32 9
  %216 = load ptr, ptr %215, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %216, ptr noundef @.str.18, ptr noundef @__func__.page_touch_modifable, i32 noundef 163) #7
  unreachable

217:                                              ; preds = %204
  br label %218

218:                                              ; preds = %217
  br label %219

219:                                              ; preds = %218
  br label %220

220:                                              ; preds = %219, %166
  br label %221

221:                                              ; preds = %220
  br label %222

222:                                              ; preds = %221
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %223 = load ptr, ptr %3, align 8, !tbaa !5
  %224 = getelementptr inbounds %struct.MDBX_txn, ptr %223, i32 0, i32 17
  %225 = getelementptr inbounds %struct.anon.6, ptr %224, i32 0, i32 7
  %226 = load ptr, ptr %225, align 8, !tbaa !14
  %227 = getelementptr inbounds %struct.dpl, ptr %226, i32 0, i32 4
  %228 = load i64, ptr %5, align 8, !tbaa !22
  %229 = getelementptr inbounds [18 x %struct.dp], ptr %227, i64 0, i64 %228
  %230 = getelementptr inbounds %struct.dp, ptr %229, i32 0, i32 0
  %231 = load ptr, ptr %230, align 8, !tbaa !27
  %232 = ptrtoint ptr %231 to i64
  %233 = add nsw i64 %232, -8
  %234 = inttoptr i64 %233 to ptr
  store ptr %234, ptr %6, align 8, !tbaa !5
  %235 = load ptr, ptr %3, align 8, !tbaa !5
  %236 = getelementptr inbounds %struct.MDBX_txn, ptr %235, i32 0, i32 17
  %237 = getelementptr inbounds %struct.anon.6, ptr %236, i32 0, i32 5
  %238 = load i32, ptr %237, align 8, !tbaa !14
  %239 = zext i32 %238 to i64
  %240 = load ptr, ptr %6, align 8, !tbaa !5
  store i64 %239, ptr %240, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #8
  ret i32 0
}

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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint nounwind willreturn memory(read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 willreturn memory(read) }
attributes #7 = { noreturn }
attributes #8 = { 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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 25}
!10 = !{!"libmdbx_globals", !7, i64 0, !11, i64 16, !11, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !12, i64 27, !11, i64 28, !7, i64 32, !7, i64 40, !13, i64 80, !6, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !6, i64 80}
!16 = !{!"MDBX_txn", !11, i64 0, !11, i64 4, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !17, i64 40, !13, i64 64, !13, 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, !11, i64 4, !11, i64 8, !7, i64 12, !7, i64 16}
!18 = !{!"short", !7, i64 0}
!19 = !{!"MDBX_canary", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!20 = !{!16, !11, i64 4}
!21 = !{!11, !11, i64 0}
!22 = !{!13, !13, i64 0}
!23 = !{!24, !13, i64 8}
!24 = !{!"dpl", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !7, i64 32}
!25 = !{!26, !11, i64 8}
!26 = !{!"dp", !6, i64 0, !11, i64 8, !11, i64 12}
!27 = !{!26, !6, i64 0}


; 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.14 = external hidden unnamed_addr constant [43 x i8], align 1
@__func__.page_touch_modifable = external hidden unnamed_addr constant [21 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [86 x i8], align 1

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

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

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

.thread39:                                        ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load i32, ptr %5, align 1, !tbaa !14
  %7 = tail call i64 @dpl_search(ptr noundef %0, i32 noundef %6) #4
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 496
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !15
  %.phi.trans.insert41 = getelementptr inbounds i8, ptr %.pre, i64 32
  %.phi.trans.insert42 = getelementptr inbounds [18 x %struct.dp], ptr %.phi.trans.insert41, i64 0, i64 %7
  %.pre43 = load ptr, ptr %.phi.trans.insert42, align 8, !tbaa !16
  br label %49

8:                                                ; preds = %2
  %9 = tail call zeroext i1 @is_modifable(ptr noundef %0, ptr noundef %1) #4
  br i1 %9, label %10, label %.critedge, !prof !18

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %0, i64 496
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = icmp eq ptr %12, null
  br i1 %13, label %.critedge, label %16, !prof !13

.critedge:                                        ; preds = %8, %10
  %14 = getelementptr inbounds i8, ptr %0, i64 80
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  tail call void @mdbx_assert_fail(ptr noundef %15, ptr noundef nonnull @.str.14, ptr noundef nonnull @__func__.page_touch_modifable, i32 noundef 147) #5
  unreachable

16:                                               ; preds = %10
  %17 = tail call zeroext i1 @is_largepage(ptr noundef %1) #4
  br i1 %17, label %.critedge32, label %18, !prof !13

18:                                               ; preds = %16
  %19 = tail call zeroext i1 @is_subpage(ptr noundef %1) #4
  br i1 %19, label %.critedge32, label %22, !prof !13

.critedge32:                                      ; preds = %16, %18
  %20 = getelementptr inbounds i8, ptr %0, i64 80
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  tail call void @mdbx_assert_fail(ptr noundef %21, ptr noundef nonnull @.str.15, ptr noundef nonnull @__func__.page_touch_modifable, i32 noundef 148) #5
  unreachable

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !24
  %25 = and i32 %24, 524288
  %.not27 = icmp eq i32 %25, 0
  br i1 %.not27, label %29, label %26, !prof !18

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %0, i64 80
  %28 = load ptr, ptr %27, align 8, !tbaa !19
  tail call void @mdbx_assert_fail(ptr noundef %28, ptr noundef nonnull @.str.16, ptr noundef nonnull @__func__.page_touch_modifable, i32 noundef 149) #5
  unreachable

29:                                               ; preds = %22
  %30 = getelementptr inbounds i8, ptr %1, i64 16
  %31 = load i32, ptr %30, align 1, !tbaa !14
  %32 = tail call i64 @dpl_search(ptr noundef nonnull %0, i32 noundef %31) #4
  %.not29 = icmp eq i64 %32, 0
  br i1 %.not29, label %.critedge34, label %33, !prof !13

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %12, i64 8
  %35 = load i64, ptr %34, align 8, !tbaa !25
  %36 = icmp ugt i64 %32, %35
  br i1 %36, label %.critedge34, label %39, !prof !13

.critedge34:                                      ; preds = %29, %33
  %37 = getelementptr inbounds i8, ptr %0, i64 80
  %38 = load ptr, ptr %37, align 8, !tbaa !19
  tail call void @mdbx_assert_fail(ptr noundef %38, ptr noundef nonnull @.str.17, ptr noundef nonnull @__func__.page_touch_modifable, i32 noundef 162) #5
  unreachable

39:                                               ; preds = %33
  %40 = getelementptr inbounds i8, ptr %12, i64 32
  %41 = getelementptr inbounds [18 x %struct.dp], ptr %40, i64 0, i64 %32
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  %43 = load i32, ptr %42, align 8, !tbaa !27
  %44 = icmp eq i32 %43, %31
  br i1 %44, label %45, label %.critedge36, !prof !18

45:                                               ; preds = %39
  %46 = load ptr, ptr %41, align 8, !tbaa !16
  %.not40 = icmp eq ptr %46, %1
  br i1 %.not40, label %49, label %.critedge36, !prof !18

.critedge36:                                      ; preds = %39, %45
  %47 = getelementptr inbounds i8, ptr %0, i64 80
  %48 = load ptr, ptr %47, align 8, !tbaa !19
  tail call void @mdbx_assert_fail(ptr noundef %48, ptr noundef nonnull @.str.18, ptr noundef nonnull @__func__.page_touch_modifable, i32 noundef 163) #5
  unreachable

49:                                               ; preds = %.thread39, %45
  %50 = phi ptr [ %.pre43, %.thread39 ], [ %1, %45 ]
  %51 = ptrtoint ptr %50 to i64
  %52 = add nsw i64 %51, -8
  %53 = inttoptr i64 %52 to ptr
  %54 = getelementptr inbounds i8, ptr %0, i64 480
  %55 = load i32, ptr %54, align 8, !tbaa !15
  %56 = zext i32 %55 to i64
  store i64 %56, ptr %53, align 8, !tbaa !28
  ret i32 0
}

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

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

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

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 = { inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 willreturn memory(read) }
attributes #5 = { 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 = !{!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 = !{!9, !9, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !12, i64 0}
!17 = !{!"dp", !12, i64 0, !9, i64 8, !9, i64 12}
!18 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!19 = !{!20, !12, i64 80}
!20 = !{!"MDBX_txn", !9, i64 0, !9, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !21, 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, !23, i64 128, !12, i64 160, !7, i64 168}
!21 = !{!"geo", !22, i64 0, !22, i64 2, !9, i64 4, !9, i64 8, !7, i64 12, !7, i64 16}
!22 = !{!"short", !7, i64 0}
!23 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!24 = !{!20, !9, i64 4}
!25 = !{!26, !11, i64 8}
!26 = !{!"dpl", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32}
!27 = !{!17, !9, i64 8}
!28 = !{!11, !11, i64 0}


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