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

@globals = external global %struct.libmdbx_globals, align 8
@.str.73 = external hidden unnamed_addr constant [45 x i8], align 1
@__func__.recalculate_subpage_thresholds = external hidden unnamed_addr constant [31 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [88 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: nounwind uwtable
define dso_local void @recalculate_subpage_thresholds(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.MDBX_env, ptr %4, i32 0, i32 8
  %6 = load i16, ptr %5, align 8, !tbaa !9
  %7 = zext i16 %6 to i32
  %8 = sub i32 %7, 8
  %9 = zext i32 %8 to i64
  store i64 %9, ptr %3, align 8, !tbaa !22
  %10 = load i64, ptr %3, align 8, !tbaa !22
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.MDBX_env, ptr %11, i32 0, i32 34
  %13 = getelementptr inbounds %struct.anon.14, ptr %12, i32 0, i32 14
  %14 = getelementptr inbounds %struct.anon.15, ptr %13, i32 0, i32 0
  %15 = load i16, ptr %14, align 8, !tbaa !23
  %16 = zext i16 %15 to i64
  %17 = mul i64 %10, %16
  %18 = add i64 %17, 32767
  %19 = lshr i64 %18, 16
  %20 = trunc i64 %19 to i16
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.MDBX_env, ptr %21, i32 0, i32 10
  store i16 %20, ptr %22, align 4, !tbaa !24
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.MDBX_env, ptr %23, i32 0, i32 10
  %25 = load i16, ptr %24, align 4, !tbaa !24
  %26 = zext i16 %25 to i64
  store i64 %26, ptr %3, align 8, !tbaa !22
  %27 = load i64, ptr %3, align 8, !tbaa !22
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.MDBX_env, ptr %28, i32 0, i32 34
  %30 = getelementptr inbounds %struct.anon.14, ptr %29, i32 0, i32 14
  %31 = getelementptr inbounds %struct.anon.15, ptr %30, i32 0, i32 3
  %32 = load i16, ptr %31, align 2, !tbaa !25
  %33 = zext i16 %32 to i64
  %34 = mul i64 %27, %33
  %35 = add i64 %34, 32767
  %36 = lshr i64 %35, 16
  %37 = trunc i64 %36 to i16
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MDBX_env, ptr %38, i32 0, i32 13
  store i16 %37, ptr %39, align 2, !tbaa !26
  br label %40

40:                                               ; preds = %1
  %41 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !27
  %42 = zext i8 %41 to i32
  %43 = and i32 %42, 1
  %44 = icmp ne i32 %43, 0
  %45 = xor i1 %44, true
  %46 = xor i1 %45, true
  %47 = zext i1 %46 to i32
  %48 = sext i32 %47 to i64
  %49 = call i64 @llvm.expect.i64(i64 %48, i64 1)
  %50 = icmp ne i64 %49, 0
  br i1 %50, label %51, label %75

51:                                               ; preds = %40
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.MDBX_env, ptr %53, i32 0, i32 8
  %55 = load i16, ptr %54, align 8, !tbaa !9
  %56 = zext i16 %55 to i32
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.MDBX_env, ptr %57, i32 0, i32 10
  %59 = load i16, ptr %58, align 4, !tbaa !24
  %60 = zext i16 %59 to i32
  %61 = add i32 %60, 8
  %62 = icmp uge i32 %56, %61
  %63 = xor i1 %62, true
  %64 = xor i1 %63, true
  %65 = xor i1 %64, true
  %66 = zext i1 %65 to i32
  %67 = sext i32 %66 to i64
  %68 = call i64 @llvm.expect.i64(i64 %67, i64 0)
  %69 = icmp ne i64 %68, 0
  br i1 %69, label %70, label %72

70:                                               ; preds = %52
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %71, ptr noundef @.str.73, ptr noundef @__func__.recalculate_subpage_thresholds, i32 noundef 719) #6
  unreachable

72:                                               ; preds = %52
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74, %40
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  %79 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !27
  %80 = zext i8 %79 to i32
  %81 = and i32 %80, 1
  %82 = icmp ne i32 %81, 0
  %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 1)
  %88 = icmp ne i64 %87, 0
  br i1 %88, label %89, label %112

89:                                               ; preds = %78
  br label %90

90:                                               ; preds = %89
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.MDBX_env, ptr %91, i32 0, i32 10
  %93 = load i16, ptr %92, align 4, !tbaa !24
  %94 = zext i16 %93 to i32
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.MDBX_env, ptr %95, i32 0, i32 13
  %97 = load i16, ptr %96, align 2, !tbaa !26
  %98 = zext i16 %97 to i32
  %99 = icmp sge i32 %94, %98
  %100 = xor i1 %99, true
  %101 = xor i1 %100, true
  %102 = xor i1 %101, true
  %103 = zext i1 %102 to i32
  %104 = sext i32 %103 to i64
  %105 = call i64 @llvm.expect.i64(i64 %104, i64 0)
  %106 = icmp ne i64 %105, 0
  br i1 %106, label %107, label %109

107:                                              ; preds = %90
  %108 = load ptr, ptr %2, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %108, ptr noundef @.str.74, ptr noundef @__func__.recalculate_subpage_thresholds, i32 noundef 720) #6
  unreachable

109:                                              ; preds = %90
  br label %110

110:                                              ; preds = %109
  br label %111

111:                                              ; preds = %110
  br label %112

112:                                              ; preds = %111, %78
  br label %113

113:                                              ; preds = %112
  br label %114

114:                                              ; preds = %113
  %115 = load ptr, ptr %2, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.MDBX_env, ptr %115, i32 0, i32 8
  %117 = load i16, ptr %116, align 8, !tbaa !9
  %118 = zext i16 %117 to i64
  store i64 %118, ptr %3, align 8, !tbaa !22
  %119 = load i64, ptr %3, align 8, !tbaa !22
  %120 = load ptr, ptr %2, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.MDBX_env, ptr %120, i32 0, i32 34
  %122 = getelementptr inbounds %struct.anon.14, ptr %121, i32 0, i32 14
  %123 = getelementptr inbounds %struct.anon.15, ptr %122, i32 0, i32 1
  %124 = load i16, ptr %123, align 2, !tbaa !29
  %125 = zext i16 %124 to i64
  %126 = mul i64 %119, %125
  %127 = add i64 %126, 32767
  %128 = lshr i64 %127, 16
  %129 = trunc i64 %128 to i16
  %130 = load ptr, ptr %2, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.MDBX_env, ptr %130, i32 0, i32 11
  store i16 %129, ptr %131, align 2, !tbaa !30
  %132 = load i64, ptr %3, align 8, !tbaa !22
  %133 = load ptr, ptr %2, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.MDBX_env, ptr %133, i32 0, i32 34
  %135 = getelementptr inbounds %struct.anon.14, ptr %134, i32 0, i32 14
  %136 = getelementptr inbounds %struct.anon.15, ptr %135, i32 0, i32 2
  %137 = load i16, ptr %136, align 4, !tbaa !31
  %138 = zext i16 %137 to i64
  %139 = mul i64 %132, %138
  %140 = add i64 %139, 32767
  %141 = lshr i64 %140, 16
  %142 = trunc i64 %141 to i16
  %143 = load ptr, ptr %2, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.MDBX_env, ptr %143, i32 0, i32 12
  store i16 %142, ptr %144, align 8, !tbaa !32
  %145 = load ptr, ptr %2, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.MDBX_env, ptr %145, i32 0, i32 11
  %147 = load i16, ptr %146, align 2, !tbaa !30
  %148 = zext i16 %147 to i32
  %149 = load ptr, ptr %2, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.MDBX_env, ptr %149, i32 0, i32 13
  %151 = load i16, ptr %150, align 2, !tbaa !26
  %152 = zext i16 %151 to i32
  %153 = add nsw i32 %148, %152
  %154 = sext i32 %153 to i64
  %155 = load ptr, ptr %2, align 8, !tbaa !5
  %156 = call i64 @page_space(ptr noundef %155) #7
  %157 = icmp sgt i64 %154, %156
  br i1 %157, label %158, label %164

158:                                              ; preds = %114
  %159 = load ptr, ptr %2, align 8, !tbaa !5
  %160 = call i64 @page_space(ptr noundef %159) #7
  %161 = trunc i64 %160 to i16
  %162 = load ptr, ptr %2, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.MDBX_env, ptr %162, i32 0, i32 12
  store i16 %161, ptr %163, align 8, !tbaa !32
  br label %193

164:                                              ; preds = %114
  %165 = load ptr, ptr %2, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.MDBX_env, ptr %165, i32 0, i32 12
  %167 = load i16, ptr %166, align 8, !tbaa !32
  %168 = zext i16 %167 to i32
  %169 = load ptr, ptr %2, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.MDBX_env, ptr %169, i32 0, i32 11
  %171 = load i16, ptr %170, align 2, !tbaa !30
  %172 = zext i16 %171 to i32
  %173 = load ptr, ptr %2, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.MDBX_env, ptr %173, i32 0, i32 13
  %175 = load i16, ptr %174, align 2, !tbaa !26
  %176 = zext i16 %175 to i32
  %177 = add nsw i32 %172, %176
  %178 = icmp slt i32 %168, %177
  br i1 %178, label %179, label %192

179:                                              ; preds = %164
  %180 = load ptr, ptr %2, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.MDBX_env, ptr %180, i32 0, i32 11
  %182 = load i16, ptr %181, align 2, !tbaa !30
  %183 = zext i16 %182 to i32
  %184 = load ptr, ptr %2, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.MDBX_env, ptr %184, i32 0, i32 13
  %186 = load i16, ptr %185, align 2, !tbaa !26
  %187 = zext i16 %186 to i32
  %188 = add nsw i32 %183, %187
  %189 = trunc i32 %188 to i16
  %190 = load ptr, ptr %2, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.MDBX_env, ptr %190, i32 0, i32 12
  store i16 %189, ptr %191, align 8, !tbaa !32
  br label %192

192:                                              ; preds = %179, %164
  br label %193

193:                                              ; preds = %192, %158
  br label %194

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

205:                                              ; preds = %194
  br label %206

206:                                              ; preds = %205
  %207 = load ptr, ptr %2, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.MDBX_env, ptr %207, i32 0, i32 12
  %209 = load i16, ptr %208, align 8, !tbaa !32
  %210 = zext i16 %209 to i32
  %211 = load ptr, ptr %2, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.MDBX_env, ptr %211, i32 0, i32 11
  %213 = load i16, ptr %212, align 2, !tbaa !30
  %214 = zext i16 %213 to i32
  %215 = load ptr, ptr %2, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.MDBX_env, ptr %215, i32 0, i32 13
  %217 = load i16, ptr %216, align 2, !tbaa !26
  %218 = zext i16 %217 to i32
  %219 = add nsw i32 %214, %218
  %220 = icmp sge i32 %210, %219
  %221 = xor i1 %220, true
  %222 = xor i1 %221, true
  %223 = xor i1 %222, true
  %224 = zext i1 %223 to i32
  %225 = sext i32 %224 to i64
  %226 = call i64 @llvm.expect.i64(i64 %225, i64 0)
  %227 = icmp ne i64 %226, 0
  br i1 %227, label %228, label %230

228:                                              ; preds = %206
  %229 = load ptr, ptr %2, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %229, ptr noundef @.str.75, ptr noundef @__func__.recalculate_subpage_thresholds, i32 noundef 729) #6
  unreachable

230:                                              ; preds = %206
  br label %231

231:                                              ; preds = %230
  br label %232

232:                                              ; preds = %231
  br label %233

233:                                              ; preds = %232, %194
  br label %234

234:                                              ; preds = %233
  br label %235

235:                                              ; preds = %234
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

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

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 = { 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 = { 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 = { nounwind }
attributes #6 = { noreturn }
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, !14, i64 112}
!10 = !{!"MDBX_env", !7, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !11, i64 56, !11, i64 60, !12, i64 64, !6, i64 104, !14, i64 112, !14, i64 114, !14, i64 116, !14, i64 118, !14, i64 120, !14, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !14, i64 130, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !15, i64 152, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !11, i64 224, !11, i64 228, !11, i64 232, !6, i64 240, !6, i64 248, !13, i64 256, !16, i64 264, !19, i64 320, !17, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !20, i64 392, !7, i64 400, !11, i64 440, !11, i64 444, !6, i64 448, !21, i64 456, !7, i64 496, !7, i64 536}
!11 = !{!"int", !7, i64 0}
!12 = !{!"osal_mmap", !7, i64 0, !11, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !13, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !11, i64 28, !11, i64 32, !17, i64 36, !17, i64 37, !17, i64 38, !18, i64 40, !7, i64 48}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6}
!19 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!20 = !{!"", !13, i64 0}
!21 = !{!"osal_ioring", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!22 = !{!13, !13, i64 0}
!23 = !{!10, !14, i64 304}
!24 = !{!10, !14, i64 116}
!25 = !{!10, !14, i64 310}
!26 = !{!10, !14, i64 122}
!27 = !{!28, !7, i64 25}
!28 = !{!"libmdbx_globals", !7, i64 0, !11, i64 16, !11, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !17, i64 27, !11, i64 28, !7, i64 32, !7, i64 40, !13, i64 80, !6, i64 88}
!29 = !{!10, !14, i64 306}
!30 = !{!10, !14, i64 118}
!31 = !{!10, !14, i64 308}
!32 = !{!10, !14, i64 120}


; 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 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.73 = external hidden unnamed_addr constant [45 x i8], align 1
@__func__.recalculate_subpage_thresholds = external hidden unnamed_addr constant [31 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [88 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: nounwind uwtable
define dso_local void @recalculate_subpage_thresholds(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 112
  %3 = load i16, ptr %2, align 8, !tbaa !5
  %4 = zext i16 %3 to i64
  %5 = add nuw nsw i64 %4, 4294967288
  %6 = getelementptr inbounds i8, ptr %0, i64 304
  %7 = load i16, ptr %6, align 8, !tbaa !21
  %8 = zext i16 %7 to i64
  %9 = mul nuw nsw i64 %5, %8
  %10 = add nuw nsw i64 %9, 32767
  %11 = lshr i64 %10, 16
  %12 = trunc i64 %11 to i16
  %13 = getelementptr inbounds i8, ptr %0, i64 116
  store i16 %12, ptr %13, align 4, !tbaa !22
  %14 = and i64 %11, 65535
  %15 = getelementptr inbounds i8, ptr %0, i64 310
  %16 = load i16, ptr %15, align 2, !tbaa !23
  %17 = zext i16 %16 to i64
  %18 = mul nuw nsw i64 %14, %17
  %19 = add nuw nsw i64 %18, 32767
  %20 = lshr i64 %19, 16
  %21 = trunc nuw i64 %20 to i16
  %22 = getelementptr inbounds i8, ptr %0, i64 122
  store i16 %21, ptr %22, align 2, !tbaa !24
  %23 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !25
  %24 = and i8 %23, 1
  %.not = icmp ne i8 %24, 0
  br i1 %.not, label %25, label %.thread, !prof !27

25:                                               ; preds = %1
  %26 = zext i16 %3 to i32
  %27 = trunc nuw i64 %11 to i32
  %28 = and i32 %27, 65535
  %29 = add nuw nsw i32 %28, 8
  %.not36 = icmp ugt i32 %29, %26
  br i1 %.not36, label %30, label %31, !prof !28

30:                                               ; preds = %25
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.73, ptr noundef nonnull @__func__.recalculate_subpage_thresholds, i32 noundef 719) #3
  unreachable

31:                                               ; preds = %25
  %.not38 = icmp ult i16 %12, %21
  br i1 %.not38, label %32, label %.thread, !prof !28

32:                                               ; preds = %31
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.74, ptr noundef nonnull @__func__.recalculate_subpage_thresholds, i32 noundef 720) #3
  unreachable

.thread:                                          ; preds = %1, %31
  %33 = getelementptr inbounds i8, ptr %0, i64 306
  %34 = load i16, ptr %33, align 2, !tbaa !29
  %35 = zext i16 %34 to i64
  %36 = mul nuw nsw i64 %35, %4
  %37 = add nuw nsw i64 %36, 32767
  %38 = lshr i64 %37, 16
  %39 = trunc nuw i64 %38 to i16
  %40 = getelementptr inbounds i8, ptr %0, i64 118
  store i16 %39, ptr %40, align 2, !tbaa !30
  %41 = getelementptr inbounds i8, ptr %0, i64 308
  %42 = load i16, ptr %41, align 4, !tbaa !31
  %43 = zext i16 %42 to i64
  %44 = mul nuw nsw i64 %43, %4
  %45 = add nuw nsw i64 %44, 32767
  %46 = lshr i64 %45, 16
  %47 = trunc nuw i64 %46 to i16
  %48 = getelementptr inbounds i8, ptr %0, i64 120
  store i16 %47, ptr %48, align 8, !tbaa !32
  %49 = trunc nuw nsw i64 %38 to i32
  %50 = trunc nuw nsw i64 %20 to i32
  %51 = add nuw nsw i32 %49, %50
  %52 = zext nneg i32 %51 to i64
  %53 = tail call i64 @page_space(ptr noundef nonnull %0) #4
  %54 = icmp slt i64 %53, %52
  br i1 %54, label %55, label %57

55:                                               ; preds = %.thread
  %56 = trunc i64 %53 to i16
  br label %.sink.split

57:                                               ; preds = %.thread
  %58 = trunc nuw nsw i64 %46 to i32
  %59 = icmp ugt i32 %51, %58
  br i1 %59, label %60, label %62

60:                                               ; preds = %57
  %61 = trunc i32 %51 to i16
  br label %.sink.split

.sink.split:                                      ; preds = %60, %55
  %.sink = phi i16 [ %56, %55 ], [ %61, %60 ]
  store i16 %.sink, ptr %48, align 8, !tbaa !32
  br label %62

62:                                               ; preds = %.sink.split, %57
  %63 = phi i16 [ %47, %57 ], [ %.sink, %.sink.split ]
  %64 = zext i16 %63 to i32
  %.not40 = icmp ugt i32 %51, %64
  %or.cond = select i1 %.not, i1 %.not40, i1 false
  br i1 %or.cond, label %65, label %66, !prof !33

65:                                               ; preds = %62
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.75, ptr noundef nonnull @__func__.recalculate_subpage_thresholds, i32 noundef 729) #3
  unreachable

66:                                               ; preds = %62
  ret void
}

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

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 = { 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 = { 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 = { noreturn nounwind }
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 = !{!6, !13, i64 112}
!6 = !{!"MDBX_env", !7, i64 0, !9, i64 4, !9, i64 8, !10, i64 16, !9, i64 56, !9, i64 60, !10, i64 64, !12, i64 104, !13, i64 112, !13, i64 114, !13, i64 116, !13, i64 118, !13, i64 120, !13, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !13, i64 130, !9, i64 132, !9, i64 136, !9, i64 140, !9, i64 144, !14, i64 152, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !9, i64 224, !9, i64 228, !9, i64 232, !12, i64 240, !12, i64 248, !11, i64 256, !15, i64 264, !18, i64 320, !16, i64 360, !12, i64 368, !12, i64 376, !12, i64 384, !19, i64 392, !7, i64 400, !9, i64 440, !9, i64 444, !12, i64 448, !20, i64 456, !7, i64 496, !7, i64 536}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"osal_mmap", !7, i64 0, !9, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!15 = !{!"", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !11, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !9, i64 28, !9, i64 32, !16, i64 36, !16, i64 37, !16, i64 38, !17, i64 40, !7, i64 48}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!"", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6}
!18 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!19 = !{!"", !11, i64 0}
!20 = !{!"osal_ioring", !9, i64 0, !9, i64 4, !9, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!21 = !{!6, !13, i64 304}
!22 = !{!6, !13, i64 116}
!23 = !{!6, !13, i64 310}
!24 = !{!6, !13, i64 122}
!25 = !{!26, !7, i64 25}
!26 = !{!"libmdbx_globals", !7, i64 0, !9, i64 16, !9, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !16, i64 27, !9, i64 28, !7, i64 32, !7, i64 40, !11, i64 80, !12, i64 88}
!27 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!28 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!29 = !{!6, !13, i64 306}
!30 = !{!6, !13, i64 118}
!31 = !{!6, !13, i64 308}
!32 = !{!6, !13, i64 120}
!33 = !{!"branch_weights", i32 2000, i32 4002001}


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