; LLVM IR from erthink/libmdbx :: src (node)

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

@globals = external global %struct.libmdbx_globals, align 8
@.str.33 = external hidden unnamed_addr constant [60 x i8], align 1
@__func__.node_read_bigdata = external hidden unnamed_addr constant [18 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [49 x i8], align 1

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

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

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

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

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden zeroext i8 @page_type(ptr noundef) #4

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden ptr @page_data(ptr noundef) #4

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden zeroext i8 @node_flags(ptr noalias noundef) #4

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden i64 @node_ds(ptr noalias noundef) #4

; Function Attrs: noinline nounwind uwtable
define dso_local i32 @node_read_bigdata(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #5 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.page_get_result, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  br label %15

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

26:                                               ; preds = %15
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = call zeroext i8 @node_flags(ptr noundef %28) #6
  %30 = zext i8 %29 to i32
  %31 = icmp eq i32 %30, 1
  br i1 %31, label %32, label %39

32:                                               ; preds = %27
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.iovec, ptr %33, i32 0, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !14
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call i64 @node_ds(ptr noundef %36) #6
  %38 = icmp eq i64 %35, %37
  br label %39

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

48:                                               ; preds = %39
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.MDBX_cursor, ptr %49, i32 0, i32 5
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = getelementptr inbounds %struct.MDBX_txn, ptr %51, i32 0, i32 9
  %53 = load ptr, ptr %52, align 8, !tbaa !18
  call void @mdbx_assert_fail(ptr noundef %53, ptr noundef @.str.33, ptr noundef @__func__.node_read_bigdata, i32 noundef 227) #7
  unreachable

54:                                               ; preds = %39
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55, %15
  br label %57

57:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #8
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = call i32 @node_largedata_pgno(ptr noundef %59) #6
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.page, ptr %61, i32 0, i32 0
  %63 = load i64, ptr %62, align 1, !tbaa !23
  %64 = call { ptr, i32 } @page_get_large(ptr noundef %58, i32 noundef %60, i64 noundef %63)
  %65 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 0
  %66 = extractvalue { ptr, i32 } %64, 0
  store ptr %66, ptr %65, align 8
  %67 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 1
  %68 = extractvalue { ptr, i32 } %64, 1
  store i32 %68, ptr %67, align 8
  %69 = getelementptr inbounds %struct.page_get_result, ptr %10, i32 0, i32 1
  %70 = load i32, ptr %69, align 8, !tbaa !24
  %71 = icmp ne i32 %70, 0
  %72 = xor i1 %71, true
  %73 = xor i1 %72, true
  %74 = zext i1 %73 to i32
  %75 = sext i32 %74 to i64
  %76 = call i64 @llvm.expect.i64(i64 %75, i64 0)
  %77 = icmp ne i64 %76, 0
  br i1 %77, label %78, label %97

78:                                               ; preds = %57
  br label %79

79:                                               ; preds = %78
  %80 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !26
  %81 = zext i8 %80 to i32
  %82 = icmp sle i32 5, %81
  %83 = xor i1 %82, true
  %84 = xor i1 %83, true
  %85 = zext i1 %84 to i32
  %86 = sext i32 %85 to i64
  %87 = call i64 @llvm.expect.i64(i64 %86, i64 0)
  %88 = icmp ne i64 %87, 0
  br i1 %88, label %89, label %92

89:                                               ; preds = %79
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = call i32 @node_largedata_pgno(ptr noundef %90) #6
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.node_read_bigdata, i32 noundef 231, ptr noundef @.str.34, i32 noundef %91)
  br label %92

92:                                               ; preds = %89, %79
  br label %93

93:                                               ; preds = %92
  br label %94

94:                                               ; preds = %93
  %95 = getelementptr inbounds %struct.page_get_result, ptr %10, i32 0, i32 1
  %96 = load i32, ptr %95, align 8, !tbaa !24
  store i32 %96, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %176

97:                                               ; preds = %57
  br label %98

98:                                               ; preds = %97
  %99 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %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 %132

109:                                              ; preds = %98
  br label %110

110:                                              ; preds = %109
  %111 = getelementptr inbounds %struct.page_get_result, ptr %10, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8, !tbaa !27
  %113 = call zeroext i8 @page_type(ptr noundef %112) #6
  %114 = zext i8 %113 to i32
  %115 = icmp eq i32 %114, 4
  %116 = xor i1 %115, true
  %117 = xor i1 %116, true
  %118 = xor i1 %117, true
  %119 = zext i1 %118 to i32
  %120 = sext i32 %119 to i64
  %121 = call i64 @llvm.expect.i64(i64 %120, i64 0)
  %122 = icmp ne i64 %121, 0
  br i1 %122, label %123, label %129

123:                                              ; preds = %110
  %124 = load ptr, ptr %6, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.MDBX_cursor, ptr %124, i32 0, i32 5
  %126 = load ptr, ptr %125, align 8, !tbaa !16
  %127 = getelementptr inbounds %struct.MDBX_txn, ptr %126, i32 0, i32 9
  %128 = load ptr, ptr %127, align 8, !tbaa !18
  call void @mdbx_assert_fail(ptr noundef %128, ptr noundef @.str.35, ptr noundef @__func__.node_read_bigdata, i32 noundef 235) #7
  unreachable

129:                                              ; preds = %110
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  br label %132

132:                                              ; preds = %131, %98
  br label %133

133:                                              ; preds = %132
  br label %134

134:                                              ; preds = %133
  %135 = getelementptr inbounds %struct.page_get_result, ptr %10, i32 0, i32 0
  %136 = load ptr, ptr %135, align 8, !tbaa !27
  %137 = call ptr @page_data(ptr noundef %136) #6
  %138 = load ptr, ptr %8, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.iovec, ptr %138, i32 0, i32 0
  store ptr %137, ptr %139, align 8, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  %140 = load ptr, ptr %6, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.MDBX_cursor, ptr %140, i32 0, i32 5
  %142 = load ptr, ptr %141, align 8, !tbaa !16
  %143 = getelementptr inbounds %struct.MDBX_txn, ptr %142, i32 0, i32 9
  %144 = load ptr, ptr %143, align 8, !tbaa !18
  store ptr %144, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %145 = load ptr, ptr %8, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.iovec, ptr %145, i32 0, i32 1
  %147 = load i64, ptr %146, align 8, !tbaa !14
  store i64 %147, ptr %13, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %148 = load ptr, ptr %12, align 8, !tbaa !5
  %149 = load i64, ptr %13, align 8, !tbaa !23
  %150 = call i32 @largechunk_npages(ptr noundef %148, i64 noundef %149) #6
  store i32 %150, ptr %14, align 4, !tbaa !29
  %151 = getelementptr inbounds %struct.page_get_result, ptr %10, i32 0, i32 0
  %152 = load ptr, ptr %151, align 8, !tbaa !27
  %153 = getelementptr inbounds %struct.page, ptr %152, i32 0, i32 3
  %154 = load i32, ptr %153, align 1, !tbaa !30
  %155 = load i32, ptr %14, align 4, !tbaa !29
  %156 = icmp ult i32 %154, %155
  %157 = xor i1 %156, true
  %158 = xor i1 %157, true
  %159 = zext i1 %158 to i32
  %160 = sext i32 %159 to i64
  %161 = call i64 @llvm.expect.i64(i64 %160, i64 0)
  %162 = icmp ne i64 %161, 0
  br i1 %162, label %163, label %172

163:                                              ; preds = %134
  %164 = getelementptr inbounds %struct.page_get_result, ptr %10, i32 0, i32 0
  %165 = load ptr, ptr %164, align 8, !tbaa !27
  %166 = getelementptr inbounds %struct.page_get_result, ptr %10, i32 0, i32 0
  %167 = load ptr, ptr %166, align 8, !tbaa !27
  %168 = getelementptr inbounds %struct.page, ptr %167, i32 0, i32 3
  %169 = load i32, ptr %168, align 1, !tbaa !30
  %170 = load i64, ptr %13, align 8, !tbaa !23
  %171 = call i32 (ptr, ptr, ...) @bad_page(ptr noundef %165, ptr noundef @.str.36, i32 noundef %169, i64 noundef %170)
  store i32 %171, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %173

172:                                              ; preds = %134
  store i32 0, ptr %11, align 4
  br label %173

173:                                              ; preds = %172, %163
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  %174 = load i32, ptr %11, align 4
  switch i32 %174, label %176 [
    i32 0, label %175
  ]

175:                                              ; preds = %173
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %176

176:                                              ; preds = %175, %173, %94
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #8
  %177 = load i32, ptr %5, align 4
  ret i32 %177
}

declare { ptr, i32 } @page_get_large(ptr noundef, i32 noundef, i64 noundef) #3

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden i32 @node_largedata_pgno(ptr noalias noundef) #4

declare i32 @bad_page(ptr noundef, ptr noundef, ...) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #2 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #5 = { noinline 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 = { 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 = !{!15, !13, i64 8}
!15 = !{!"iovec", !6, i64 0, !13, i64 8}
!16 = !{!17, !6, i64 16}
!17 = !{!"MDBX_cursor", !11, i64 0, !7, i64 4, !7, i64 6, !7, i64 7, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !7, i64 304, !6, i64 368, !6, i64 376}
!18 = !{!19, !6, i64 80}
!19 = !{!"MDBX_txn", !11, i64 0, !11, i64 4, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !20, 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, !22, i64 128, !6, i64 160, !7, i64 168}
!20 = !{!"geo", !21, i64 0, !21, i64 2, !11, i64 4, !11, i64 8, !7, i64 12, !7, i64 16}
!21 = !{!"short", !7, i64 0}
!22 = !{!"MDBX_canary", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!23 = !{!13, !13, i64 0}
!24 = !{!25, !11, i64 8}
!25 = !{!"page_get_result", !6, i64 0, !11, i64 8}
!26 = !{!10, !7, i64 26}
!27 = !{!25, !6, i64 0}
!28 = !{!15, !6, i64 0}
!29 = !{!11, !11, i64 0}
!30 = !{!7, !7, 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.0 }
%struct.anon.0 = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.33 = external hidden unnamed_addr constant [60 x i8], align 1
@__func__.node_read_bigdata = external hidden unnamed_addr constant [18 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [49 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: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden zeroext i8 @page_type(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden ptr @page_data(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden zeroext i8 @node_flags(ptr noalias noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden i64 @node_ds(ptr noalias noundef) local_unnamed_addr #2

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

7:                                                ; preds = %4
  %8 = tail call zeroext i8 @node_flags(ptr noundef %1) #4
  %9 = icmp eq i8 %8, 1
  br i1 %9, label %10, label %.critedge, !prof !14

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %2, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !15
  %13 = tail call i64 @node_ds(ptr noundef %1) #4
  %.not29 = icmp eq i64 %12, %13
  br i1 %.not29, label %18, label %.critedge, !prof !14

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

18:                                               ; preds = %4, %10
  %19 = tail call i32 @node_largedata_pgno(ptr noundef %1) #4
  %20 = load i64, ptr %3, align 1, !tbaa !24
  %21 = tail call { ptr, i32 } @page_get_large(ptr noundef %0, i32 noundef %19, i64 noundef %20) #6
  %22 = extractvalue { ptr, i32 } %21, 0
  %23 = extractvalue { ptr, i32 } %21, 1
  %.not25 = icmp eq i32 %23, 0
  br i1 %.not25, label %29, label %24, !prof !14

24:                                               ; preds = %18
  %25 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !25
  %26 = icmp ugt i8 %25, 4
  br i1 %26, label %27, label %52, !prof !13

27:                                               ; preds = %24
  %28 = tail call i32 @node_largedata_pgno(ptr noundef %1) #4
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.node_read_bigdata, i32 noundef 231, ptr noundef nonnull @.str.34, i32 noundef %28) #6
  br label %52

29:                                               ; preds = %18
  %30 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %31 = and i8 %30, 1
  %.not26 = icmp eq i8 %31, 0
  br i1 %.not26, label %39, label %32, !prof !13

32:                                               ; preds = %29
  %33 = tail call zeroext i8 @page_type(ptr noundef %22) #4
  %.not27 = icmp eq i8 %33, 4
  br i1 %.not27, label %39, label %34, !prof !14

34:                                               ; preds = %32
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %37 = getelementptr inbounds i8, ptr %36, i64 80
  %38 = load ptr, ptr %37, align 8, !tbaa !19
  tail call void @mdbx_assert_fail(ptr noundef %38, ptr noundef nonnull @.str.35, ptr noundef nonnull @__func__.node_read_bigdata, i32 noundef 235) #5
  unreachable

39:                                               ; preds = %32, %29
  %40 = tail call ptr @page_data(ptr noundef %22) #4
  store ptr %40, ptr %2, align 8, !tbaa !26
  %41 = getelementptr inbounds i8, ptr %0, i64 16
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %42, i64 80
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = getelementptr inbounds i8, ptr %2, i64 8
  %46 = load i64, ptr %45, align 8, !tbaa !15
  %47 = tail call i32 @largechunk_npages(ptr noundef %44, i64 noundef %46) #4
  %48 = getelementptr inbounds i8, ptr %22, i64 12
  %49 = load i32, ptr %48, align 1, !tbaa !27
  %.not28 = icmp ult i32 %49, %47
  br i1 %.not28, label %50, label %52, !prof !13

50:                                               ; preds = %39
  %51 = tail call i32 (ptr, ptr, ...) @bad_page(ptr noundef nonnull %22, ptr noundef nonnull @.str.36, i32 noundef %49, i64 noundef %46) #6
  br label %52

52:                                               ; preds = %50, %39, %24, %27
  %.1 = phi i32 [ %23, %27 ], [ %23, %24 ], [ %51, %50 ], [ 0, %39 ]
  ret i32 %.1
}

declare { ptr, i32 } @page_get_large(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden i32 @node_largedata_pgno(ptr noalias noundef) local_unnamed_addr #2

declare i32 @bad_page(ptr noundef, ptr 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 = { 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 #3 = { noinline 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) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!15 = !{!16, !11, i64 8}
!16 = !{!"iovec", !12, i64 0, !11, i64 8}
!17 = !{!18, !12, i64 16}
!18 = !{!"MDBX_cursor", !9, i64 0, !7, i64 4, !7, i64 6, !7, i64 7, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !7, i64 48, !7, i64 304, !12, i64 368, !12, i64 376}
!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 = !{!11, !11, i64 0}
!25 = !{!6, !7, i64 26}
!26 = !{!16, !12, i64 0}
!27 = !{!7, !7, i64 0}


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