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

; 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.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.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.11, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.12, %struct.anon.16, i8, ptr, ptr, ptr, %struct.anon.17, %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.10, i32, i64, i64, i64 }
%union.anon.10 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.11 = type { ptr, ptr, ptr, ptr }
%struct.anon.12 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.13, %union.anon.14 }
%struct.anon.13 = type { i16, i16, i16, i16 }
%union.anon.14 = type { i32 }
%struct.anon.16 = type { i64, i64, i64, i64, i64 }
%struct.anon.17 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, 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 }
%union.mdbx_atomic_uint64_t = type { i64 }
%struct.page = type <{ i64, i16, i16, %union.anon.18, i32, [0 x i16] }>
%union.anon.18 = type { i32 }

@__func__.mdbx_is_dirty = external hidden unnamed_addr constant [14 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @log_if_error(i32 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: alwaysinline nounwind uwtable
declare hidden i32 @check_txn(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) #2

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

22:                                               ; preds = %2
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = call i32 @log_if_error(i32 noundef %23, ptr noundef @__func__.mdbx_is_dirty, i32 noundef 181)
  store i32 %24, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %132

25:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.MDBX_txn, ptr %26, i32 0, i32 9
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  store ptr %28, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = ptrtoint ptr %29 to i64
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.MDBX_env, ptr %31, i32 0, i32 3
  %33 = getelementptr inbounds %struct.osal_mmap, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = ptrtoint ptr %34 to i64
  %36 = sub nsw i64 %30, %35
  store i64 %36, ptr %9, align 8, !tbaa !18
  %37 = load i64, ptr %9, align 8, !tbaa !18
  %38 = icmp sge i64 %37, 0
  br i1 %38, label %39, label %120

39:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load i64, ptr %9, align 8, !tbaa !18
  %42 = call i32 @bytes2pgno(ptr noundef %40, i64 noundef %41) #7
  store i32 %42, ptr %10, align 4, !tbaa !9
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.MDBX_txn, ptr %44, i32 0, i32 6
  %46 = getelementptr inbounds %struct.geo, ptr %45, i32 0, i32 5
  %47 = load i32, ptr %46, align 8, !tbaa !17
  %48 = icmp ult i32 %43, %47
  %49 = xor i1 %48, true
  %50 = xor i1 %49, true
  %51 = zext i1 %50 to i32
  %52 = sext i32 %51 to i64
  %53 = call i64 @llvm.expect.i64(i64 %52, i64 1)
  %54 = icmp ne i64 %53, 0
  br i1 %54, label %55, label %98

55:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = call ptr @pgno2page(ptr noundef %56, i64 noundef %58) #7
  store ptr %59, ptr %11, align 8, !tbaa !5
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.page, ptr %60, i32 0, i32 4
  %62 = load i32, ptr %61, align 1, !tbaa !9
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = icmp ne i32 %62, %63
  br i1 %64, label %72, label %65

65:                                               ; preds = %55
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.page, ptr %66, i32 0, i32 2
  %68 = load i16, ptr %67, align 1, !tbaa !19
  %69 = zext i16 %68 to i32
  %70 = and i32 %69, 57304
  %71 = icmp ne i32 %70, 0
  br label %72

72:                                               ; preds = %65, %55
  %73 = phi i1 [ true, %55 ], [ %71, %65 ]
  %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 = %72
  %81 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_is_dirty, i32 noundef 192)
  store i32 %81, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %97

82:                                               ; preds = %72
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.MDBX_txn, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !20
  %86 = and i32 %85, 131072
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %93, label %88

88:                                               ; preds = %82
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = load ptr, ptr %11, align 8, !tbaa !5
  %91 = call zeroext i1 @is_modifable(ptr noundef %89, ptr noundef %90) #7
  %92 = xor i1 %91, true
  br label %93

93:                                               ; preds = %88, %82
  %94 = phi i1 [ true, %82 ], [ %92, %88 ]
  %95 = zext i1 %94 to i64
  %96 = select i1 %94, i32 0, i32 -1
  store i32 %96, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %97

97:                                               ; preds = %93, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %117

98:                                               ; preds = %39
  %99 = load i64, ptr %9, align 8, !tbaa !18
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.MDBX_env, ptr %100, i32 0, i32 3
  %102 = getelementptr inbounds %struct.osal_mmap, ptr %101, i32 0, i32 2
  %103 = load i64, ptr %102, align 8, !tbaa !21
  %104 = icmp ult i64 %99, %103
  br i1 %104, label %105, label %116

105:                                              ; preds = %98
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.MDBX_txn, ptr %106, i32 0, i32 1
  %108 = load i32, ptr %107, align 4, !tbaa !20
  %109 = and i32 %108, 131072
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %113

111:                                              ; preds = %105
  %112 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_is_dirty, i32 noundef 201)
  br label %114

113:                                              ; preds = %105
  br label %114

114:                                              ; preds = %113, %111
  %115 = phi i32 [ %112, %111 ], [ -1, %113 ]
  store i32 %115, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %117

116:                                              ; preds = %98
  store i32 0, ptr %7, align 4
  br label %117

117:                                              ; preds = %116, %114, %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %118 = load i32, ptr %7, align 4
  switch i32 %118, label %131 [
    i32 0, label %119
  ]

119:                                              ; preds = %117
  br label %120

120:                                              ; preds = %119, %25
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.MDBX_txn, ptr %121, i32 0, i32 1
  %123 = load i32, ptr %122, align 4, !tbaa !20
  %124 = and i32 %123, 655360
  %125 = icmp ne i32 %124, 0
  br i1 %125, label %126, label %128

126:                                              ; preds = %120
  %127 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_is_dirty, i32 noundef 211)
  br label %129

128:                                              ; preds = %120
  br label %129

129:                                              ; preds = %128, %126
  %130 = phi i32 [ %127, %126 ], [ -1, %128 ]
  store i32 %130, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %131

131:                                              ; preds = %129, %117
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %132

132:                                              ; preds = %131, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %133 = load i32, ptr %3, align 4
  ret i32 %133
}

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden i32 @bytes2pgno(ptr noundef, i64 noundef) #5

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden ptr @pgno2page(ptr noundef, i64 noundef) #5

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !14, 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, !16, i64 128, !6, i64 160, !7, i64 168}
!13 = !{!"long", !7, i64 0}
!14 = !{!"geo", !15, i64 0, !15, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!15 = !{!"short", !7, i64 0}
!16 = !{!"MDBX_canary", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!17 = !{!7, !7, i64 0}
!18 = !{!13, !13, i64 0}
!19 = !{!15, !15, i64 0}
!20 = !{!12, !10, i64 4}
!21 = !{!22, !13, i64 32}
!22 = !{!"MDBX_env", !7, i64 0, !10, i64 4, !10, i64 8, !23, i64 16, !10, i64 56, !10, i64 60, !23, 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, !24, 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, !13, i64 256, !25, i64 264, !28, i64 320, !26, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !29, i64 392, !7, i64 400, !10, i64 440, !10, i64 444, !6, i64 448, !30, i64 456, !7, i64 496, !7, i64 536}
!23 = !{!"osal_mmap", !7, i64 0, !10, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!24 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!25 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !10, i64 28, !10, i64 32, !26, i64 36, !26, i64 37, !26, i64 38, !27, i64 40, !7, i64 48}
!26 = !{!"_Bool", !7, i64 0}
!27 = !{!"", !15, i64 0, !15, i64 2, !15, i64 4, !15, i64 6}
!28 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!29 = !{!"", !13, i64 0}
!30 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, 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"

@__func__.mdbx_is_dirty = external hidden unnamed_addr constant [14 x i8], align 1

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read) uwtable
define dso_local i32 @mdbx_is_dirty(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = tail call i32 @check_txn(ptr noundef %0, i32 noundef 19)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %6, label %4, !prof !5

4:                                                ; preds = %2
  %5 = tail call i32 @log_if_error(i32 noundef %3, ptr noundef nonnull @__func__.mdbx_is_dirty, i32 noundef 181)
  br label %.thread

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = load ptr, ptr %7, align 8, !tbaa !6
  %9 = ptrtoint ptr %1 to i64
  %10 = getelementptr inbounds i8, ptr %8, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %12 = ptrtoint ptr %11 to i64
  %13 = sub nsw i64 %9, %12
  %14 = icmp sgt i64 %13, -1
  br i1 %14, label %15, label %47

15:                                               ; preds = %6
  %16 = tail call i32 @bytes2pgno(ptr noundef nonnull %8, i64 noundef %13) #4
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  %18 = load i32, ptr %17, align 8, !tbaa !16
  %19 = icmp ult i32 %16, %18
  br i1 %19, label %20, label %37, !prof !5

20:                                               ; preds = %15
  %21 = zext i32 %16 to i64
  %22 = tail call ptr @pgno2page(ptr noundef nonnull %8, i64 noundef %21) #4
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %24 = load i32, ptr %23, align 1, !tbaa !17
  %.not30 = icmp eq i32 %24, %16
  br i1 %.not30, label %25, label %.critedge, !prof !5

25:                                               ; preds = %20
  %26 = getelementptr inbounds i8, ptr %22, i64 10
  %27 = load i16, ptr %26, align 1, !tbaa !18
  %28 = and i16 %27, -8232
  %.not35 = icmp eq i16 %28, 0
  br i1 %.not35, label %30, label %.critedge, !prof !5

.critedge:                                        ; preds = %20, %25
  %29 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_is_dirty, i32 noundef 192)
  br label %.thread

30:                                               ; preds = %25
  %31 = getelementptr inbounds i8, ptr %0, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !19
  %33 = and i32 %32, 131072
  %.not31 = icmp eq i32 %33, 0
  br i1 %.not31, label %34, label %.thread

34:                                               ; preds = %30
  %35 = tail call zeroext i1 @is_modifable(ptr noundef nonnull %0, ptr noundef nonnull %22) #4
  %36 = sext i1 %35 to i32
  br label %.thread

37:                                               ; preds = %15
  %38 = getelementptr inbounds i8, ptr %8, i64 32
  %39 = load i64, ptr %38, align 8, !tbaa !20
  %40 = icmp ult i64 %13, %39
  br i1 %40, label %41, label %47

41:                                               ; preds = %37
  %42 = getelementptr inbounds i8, ptr %0, i64 4
  %43 = load i32, ptr %42, align 4, !tbaa !19
  %44 = and i32 %43, 131072
  %.not29 = icmp eq i32 %44, 0
  br i1 %.not29, label %.thread, label %45

45:                                               ; preds = %41
  %46 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_is_dirty, i32 noundef 201)
  br label %.thread

47:                                               ; preds = %37, %6
  %48 = getelementptr inbounds i8, ptr %0, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !19
  %50 = and i32 %49, 655360
  %.not32 = icmp eq i32 %50, 0
  br i1 %.not32, label %.thread, label %51

51:                                               ; preds = %47
  %52 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_is_dirty, i32 noundef 211)
  br label %.thread

.thread:                                          ; preds = %45, %41, %.critedge, %34, %30, %47, %51, %4
  %.3 = phi i32 [ %5, %4 ], [ %52, %51 ], [ -1, %47 ], [ -1, %41 ], [ %46, %45 ], [ %36, %34 ], [ 0, %30 ], [ %29, %.critedge ]
  ret i32 %.3
}

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden ptr @pgno2page(ptr noundef, i64 noundef) local_unnamed_addr #3

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

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


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