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

; 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.14 }
%struct.anon.14 = 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, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.0, %struct.anon.4, i8, ptr, ptr, ptr, %struct.anon.5, %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, i32, i64, i64, i64 }
%union.anon = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon = type { ptr, ptr, ptr, ptr }
%struct.anon.0 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.1, %union.anon.2 }
%struct.anon.1 = type { i16, i16, i16, i16 }
%union.anon.2 = type { i32 }
%struct.anon.4 = type { i64, i64, i64, i64, i64 }
%struct.anon.5 = 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 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.env_setup_pagesize = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [224 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [42 x i8], align 1

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

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

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

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

8:                                                ; preds = %2
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = call zeroext i1 @is_powerof2(i64 noundef %9) #8
  %11 = xor i1 %10, true
  %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 0)
  %17 = icmp ne i64 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %8
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %19, ptr noundef @.str, ptr noundef @__func__.env_setup_pagesize, i32 noundef 30) #9
  unreachable

20:                                               ; preds = %8
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  %23 = load i64, ptr %4, align 8, !tbaa !9
  %24 = icmp uge i64 %23, 256
  %25 = xor i1 %24, true
  %26 = xor i1 %25, true
  %27 = xor i1 %26, true
  %28 = zext i1 %27 to i32
  %29 = sext i32 %28 to i64
  %30 = call i64 @llvm.expect.i64(i64 %29, i64 0)
  %31 = icmp ne i64 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %22
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %33, ptr noundef @.str.1, ptr noundef @__func__.env_setup_pagesize, i32 noundef 31) #9
  unreachable

34:                                               ; preds = %22
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load i64, ptr %4, align 8, !tbaa !9
  %38 = icmp ule i64 %37, 65536
  %39 = xor i1 %38, true
  %40 = xor i1 %39, true
  %41 = xor i1 %40, true
  %42 = zext i1 %41 to i32
  %43 = sext i32 %42 to i64
  %44 = call i64 @llvm.expect.i64(i64 %43, i64 0)
  %45 = icmp ne i64 %44, 0
  br i1 %45, label %46, label %48

46:                                               ; preds = %36
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %47, ptr noundef @.str.2, ptr noundef @__func__.env_setup_pagesize, i32 noundef 32) #9
  unreachable

48:                                               ; preds = %36
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.MDBX_env, ptr %51, i32 0, i32 23
  %53 = load ptr, ptr %52, align 8, !tbaa !11
  %54 = icmp ne ptr %53, null
  br i1 %54, label %62, label %55

55:                                               ; preds = %50
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.MDBX_env, ptr %56, i32 0, i32 2
  %58 = load i32, ptr %57, align 8, !tbaa !23
  %59 = zext i32 %58 to i64
  %60 = load i64, ptr %4, align 8, !tbaa !9
  %61 = icmp ne i64 %59, %60
  br label %62

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

71:                                               ; preds = %62
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %72, ptr noundef @.str.3, ptr noundef @__func__.env_setup_pagesize, i32 noundef 33) #9
  unreachable

73:                                               ; preds = %62
  br label %74

74:                                               ; preds = %73
  %75 = load i64, ptr %4, align 8, !tbaa !9
  %76 = trunc i64 %75 to i32
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.MDBX_env, ptr %77, i32 0, i32 2
  store i32 %76, ptr %78, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #10
  %79 = load i64, ptr %4, align 8, !tbaa !9
  %80 = sub i64 %79, 20
  %81 = udiv i64 %80, 4
  %82 = sub i64 %81, 1
  store i64 %82, ptr %5, align 8, !tbaa !9
  br label %83

83:                                               ; preds = %74
  %84 = load i64, ptr %5, align 8, !tbaa !9
  %85 = icmp sgt i64 %84, 42
  br i1 %85, label %86, label %89

86:                                               ; preds = %83
  %87 = load i64, ptr %5, align 8, !tbaa !9
  %88 = icmp slt i64 %87, 536870911
  br label %89

89:                                               ; preds = %86, %83
  %90 = phi i1 [ false, %83 ], [ %88, %86 ]
  %91 = xor i1 %90, true
  %92 = xor i1 %91, true
  %93 = xor i1 %92, true
  %94 = zext i1 %93 to i32
  %95 = sext i32 %94 to i64
  %96 = call i64 @llvm.expect.i64(i64 %95, i64 0)
  %97 = icmp ne i64 %96, 0
  br i1 %97, label %98, label %100

98:                                               ; preds = %89
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %99, ptr noundef @.str.4, ptr noundef @__func__.env_setup_pagesize, i32 noundef 39) #9
  unreachable

100:                                              ; preds = %89
  br label %101

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101
  %103 = load i64, ptr %5, align 8, !tbaa !9
  %104 = trunc i64 %103 to i32
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.MDBX_env, ptr %105, i32 0, i32 28
  store i32 %104, ptr %106, align 8, !tbaa !24
  %107 = load i64, ptr %4, align 8, !tbaa !9
  %108 = sub i64 %107, 20
  %109 = udiv i64 %108, 18
  %110 = trunc i64 %109 to i32
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.MDBX_env, ptr %111, i32 0, i32 29
  store i32 %110, ptr %112, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #10
  %113 = load i64, ptr %4, align 8, !tbaa !9
  %114 = sub i64 %113, 20
  %115 = sub i64 %114, 2
  %116 = sub i64 %115, 8
  %117 = udiv i64 %116, 2
  %118 = sub i64 %117, 2
  %119 = and i64 %118, -2
  store i64 %119, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #10
  %120 = load i64, ptr %4, align 8, !tbaa !9
  %121 = sub i64 %120, 20
  %122 = udiv i64 %121, 2
  %123 = and i64 %122, -2
  %124 = sub i64 %123, 2
  store i64 %124, ptr %7, align 8, !tbaa !9
  br label %125

125:                                              ; preds = %102
  %126 = load i64, ptr %6, align 8, !tbaa !9
  %127 = icmp sgt i64 %126, 50
  br i1 %127, label %128, label %146

128:                                              ; preds = %125
  %129 = load i64, ptr %6, align 8, !tbaa !9
  %130 = srem i64 %129, 2
  %131 = icmp eq i64 %130, 0
  br i1 %131, label %132, label %146

132:                                              ; preds = %128
  %133 = load i64, ptr %7, align 8, !tbaa !9
  %134 = icmp sgt i64 %133, 98
  br i1 %134, label %135, label %146

135:                                              ; preds = %132
  %136 = load i64, ptr %7, align 8, !tbaa !9
  %137 = load i64, ptr %6, align 8, !tbaa !9
  %138 = icmp sge i64 %136, %137
  br i1 %138, label %139, label %146

139:                                              ; preds = %135
  %140 = load i64, ptr %7, align 8, !tbaa !9
  %141 = icmp slt i64 %140, 65535
  br i1 %141, label %142, label %146

142:                                              ; preds = %139
  %143 = load i64, ptr %7, align 8, !tbaa !9
  %144 = srem i64 %143, 2
  %145 = icmp eq i64 %144, 0
  br label %146

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

155:                                              ; preds = %146
  %156 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %156, ptr noundef @.str.5, ptr noundef @__func__.env_setup_pagesize, i32 noundef 52) #9
  unreachable

157:                                              ; preds = %146
  br label %158

158:                                              ; preds = %157
  br label %159

159:                                              ; preds = %158
  %160 = load i64, ptr %7, align 8, !tbaa !9
  %161 = trunc i64 %160 to i16
  %162 = load ptr, ptr %3, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.MDBX_env, ptr %162, i32 0, i32 8
  store i16 %161, ptr %163, align 8, !tbaa !26
  %164 = load i64, ptr %6, align 8, !tbaa !9
  %165 = trunc i64 %164 to i16
  %166 = load ptr, ptr %3, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.MDBX_env, ptr %166, i32 0, i32 9
  store i16 %165, ptr %167, align 2, !tbaa !27
  %168 = load i64, ptr %4, align 8, !tbaa !9
  %169 = call i32 @log2n_powerof2(i64 noundef %168) #8
  %170 = trunc i32 %169 to i8
  %171 = load ptr, ptr %3, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.MDBX_env, ptr %171, i32 0, i32 15
  store i8 %170, ptr %172, align 8, !tbaa !28
  br label %173

173:                                              ; preds = %159
  %174 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !29
  %175 = zext i8 %174 to i32
  %176 = and i32 %175, 1
  %177 = icmp ne i32 %176, 0
  %178 = xor i1 %177, true
  %179 = xor i1 %178, true
  %180 = zext i1 %179 to i32
  %181 = sext i32 %180 to i64
  %182 = call i64 @llvm.expect.i64(i64 %181, i64 1)
  %183 = icmp ne i64 %182, 0
  br i1 %183, label %184, label %202

184:                                              ; preds = %173
  br label %185

185:                                              ; preds = %184
  %186 = load ptr, ptr %3, align 8, !tbaa !5
  %187 = call i64 @pgno2bytes(ptr noundef %186, i64 noundef 1) #11
  %188 = load i64, ptr %4, align 8, !tbaa !9
  %189 = icmp eq i64 %187, %188
  %190 = xor i1 %189, true
  %191 = xor i1 %190, true
  %192 = xor i1 %191, true
  %193 = zext i1 %192 to i32
  %194 = sext i32 %193 to i64
  %195 = call i64 @llvm.expect.i64(i64 %194, i64 0)
  %196 = icmp ne i64 %195, 0
  br i1 %196, label %197, label %199

197:                                              ; preds = %185
  %198 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %198, ptr noundef @.str.6, ptr noundef @__func__.env_setup_pagesize, i32 noundef 56) #9
  unreachable

199:                                              ; preds = %185
  br label %200

200:                                              ; preds = %199
  br label %201

201:                                              ; preds = %200
  br label %202

202:                                              ; preds = %201, %173
  br label %203

203:                                              ; preds = %202
  br label %204

204:                                              ; preds = %203
  br label %205

205:                                              ; preds = %204
  %206 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !29
  %207 = zext i8 %206 to i32
  %208 = and i32 %207, 1
  %209 = icmp ne i32 %208, 0
  %210 = xor i1 %209, true
  %211 = xor i1 %210, true
  %212 = zext i1 %211 to i32
  %213 = sext i32 %212 to i64
  %214 = call i64 @llvm.expect.i64(i64 %213, i64 1)
  %215 = icmp ne i64 %214, 0
  br i1 %215, label %216, label %236

216:                                              ; preds = %205
  br label %217

217:                                              ; preds = %216
  %218 = load ptr, ptr %3, align 8, !tbaa !5
  %219 = load i64, ptr %4, align 8, !tbaa !9
  %220 = load i64, ptr %4, align 8, !tbaa !9
  %221 = add i64 %219, %220
  %222 = call i32 @bytes2pgno(ptr noundef %218, i64 noundef %221) #11
  %223 = icmp eq i32 %222, 2
  %224 = xor i1 %223, true
  %225 = xor i1 %224, true
  %226 = xor i1 %225, true
  %227 = zext i1 %226 to i32
  %228 = sext i32 %227 to i64
  %229 = call i64 @llvm.expect.i64(i64 %228, i64 0)
  %230 = icmp ne i64 %229, 0
  br i1 %230, label %231, label %233

231:                                              ; preds = %217
  %232 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %232, ptr noundef @.str.7, ptr noundef @__func__.env_setup_pagesize, i32 noundef 57) #9
  unreachable

233:                                              ; preds = %217
  br label %234

234:                                              ; preds = %233
  br label %235

235:                                              ; preds = %234
  br label %236

236:                                              ; preds = %235, %205
  br label %237

237:                                              ; preds = %236
  br label %238

238:                                              ; preds = %237
  %239 = load ptr, ptr %3, align 8, !tbaa !5
  call void @recalculate_merge_thresholds(ptr noundef %239)
  %240 = load ptr, ptr %3, align 8, !tbaa !5
  call void @recalculate_subpage_thresholds(ptr noundef %240)
  %241 = load ptr, ptr %3, align 8, !tbaa !5
  call void @env_options_adjust_dp_limit(ptr noundef %241)
  %242 = load ptr, ptr %3, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.MDBX_env, ptr %242, i32 0, i32 2
  %244 = load i32, ptr %243, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #10
  ret i32 %244
}

; Function Attrs: inlinehint nounwind willreturn memory(none) uwtable
declare hidden zeroext i1 @is_powerof2(i64 noundef) #3

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

; Function Attrs: nounwind willreturn memory(none)
declare i32 @log2n_powerof2(i64 noundef) #5

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

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

declare void @recalculate_merge_thresholds(ptr noundef) #7

declare void @recalculate_subpage_thresholds(ptr noundef) #7

declare void @env_options_adjust_dp_limit(ptr noundef) #7

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 184}
!12 = !{!"MDBX_env", !7, i64 0, !13, i64 4, !13, i64 8, !14, i64 16, !13, i64 56, !13, i64 60, !14, 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, !13, i64 132, !13, i64 136, !13, i64 140, !13, i64 144, !16, i64 152, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !13, i64 224, !13, i64 228, !13, i64 232, !6, i64 240, !6, i64 248, !10, i64 256, !17, i64 264, !20, i64 320, !18, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !21, i64 392, !7, i64 400, !13, i64 440, !13, i64 444, !6, i64 448, !22, i64 456, !7, i64 496, !7, i64 536}
!13 = !{!"int", !7, i64 0}
!14 = !{!"osal_mmap", !7, i64 0, !13, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!15 = !{!"short", !7, i64 0}
!16 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !10, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !13, i64 28, !13, i64 32, !18, i64 36, !18, i64 37, !18, i64 38, !19, i64 40, !7, i64 48}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{!"", !15, i64 0, !15, i64 2, !15, i64 4, !15, i64 6}
!20 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!21 = !{!"", !10, i64 0}
!22 = !{!"osal_ioring", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!12, !13, i64 8}
!24 = !{!12, !13, i64 224}
!25 = !{!12, !13, i64 228}
!26 = !{!12, !15, i64 112}
!27 = !{!12, !15, i64 114}
!28 = !{!12, !7, i64 128}
!29 = !{!30, !7, i64 25}
!30 = !{!"libmdbx_globals", !7, i64 0, !13, i64 16, !13, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !18, i64 27, !13, i64 28, !7, i64 32, !7, i64 40, !10, i64 80, !6, i64 88}


; 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.14 }
%struct.anon.14 = 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 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.env_setup_pagesize = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [224 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @env_setup_pagesize(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i1 @is_powerof2(i64 noundef %1) #6
  br i1 %3, label %5, label %4, !prof !5

4:                                                ; preds = %2
  tail call void @mdbx_assert_fail(ptr noundef %0, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.env_setup_pagesize, i32 noundef 30) #7
  unreachable

5:                                                ; preds = %2
  %6 = icmp ult i64 %1, 256
  br i1 %6, label %7, label %8, !prof !6

7:                                                ; preds = %5
  tail call void @mdbx_assert_fail(ptr noundef %0, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.env_setup_pagesize, i32 noundef 31) #7
  unreachable

8:                                                ; preds = %5
  %9 = icmp ugt i64 %1, 65536
  br i1 %9, label %10, label %11, !prof !6

10:                                               ; preds = %8
  tail call void @mdbx_assert_fail(ptr noundef %0, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__.env_setup_pagesize, i32 noundef 32) #7
  unreachable

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 184
  %13 = load ptr, ptr %12, align 8, !tbaa !7
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %14, label %.critedge, !prof !5

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !23
  %17 = zext i32 %16 to i64
  %18 = icmp eq i64 %17, %1
  br i1 %18, label %.critedge, label %19, !prof !6

.critedge:                                        ; preds = %11, %14
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.3, ptr noundef nonnull @__func__.env_setup_pagesize, i32 noundef 33) #7
  unreachable

19:                                               ; preds = %14
  %20 = trunc nuw i64 %1 to i32
  store i32 %20, ptr %15, align 8, !tbaa !23
  %21 = add nsw i64 %1, -20
  %22 = lshr i64 %21, 2
  %23 = trunc i64 %22 to i32
  %24 = add nsw i32 %23, -1
  %25 = getelementptr inbounds i8, ptr %0, i64 224
  store i32 %24, ptr %25, align 8, !tbaa !24
  %.lhs.trunc = trunc i64 %21 to i16
  %26 = udiv i16 %.lhs.trunc, 18
  %27 = zext nneg i16 %26 to i32
  %28 = getelementptr inbounds i8, ptr %0, i64 228
  store i32 %27, ptr %28, align 4, !tbaa !25
  %29 = add nsw i64 %1, -30
  %30 = lshr i64 %29, 1
  %31 = and i64 %30, 9223372036854775806
  %32 = lshr i64 %21, 1
  %33 = and i64 %32, 9223372036854775806
  %34 = icmp ult i64 %31, 53
  %35 = icmp ult i64 %33, 101
  %.not60 = icmp ult i64 %33, %31
  %36 = or i1 %35, %.not60
  %or.cond56 = select i1 %34, i1 true, i1 %36
  br i1 %or.cond56, label %.critedge55, label %37, !prof !26

.critedge55:                                      ; preds = %19
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.5, ptr noundef nonnull @__func__.env_setup_pagesize, i32 noundef 52) #7
  unreachable

37:                                               ; preds = %19
  %38 = trunc i64 %33 to i16
  %39 = add nsw i16 %38, -2
  %40 = getelementptr inbounds i8, ptr %0, i64 112
  store i16 %39, ptr %40, align 8, !tbaa !27
  %41 = trunc i64 %31 to i16
  %42 = add nsw i16 %41, -2
  %43 = getelementptr inbounds i8, ptr %0, i64 114
  store i16 %42, ptr %43, align 2, !tbaa !28
  %44 = tail call i32 @log2n_powerof2(i64 noundef %1) #6
  %45 = trunc i32 %44 to i8
  %46 = getelementptr inbounds i8, ptr %0, i64 128
  store i8 %45, ptr %46, align 8, !tbaa !29
  %47 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !30
  %48 = and i8 %47, 1
  %.not50 = icmp eq i8 %48, 0
  br i1 %.not50, label %.thread, label %49, !prof !6

49:                                               ; preds = %37
  %50 = tail call i64 @pgno2bytes(ptr noundef nonnull %0, i64 noundef 1) #8
  %.not51 = icmp eq i64 %50, %1
  br i1 %.not51, label %52, label %51, !prof !5

51:                                               ; preds = %49
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.6, ptr noundef nonnull @__func__.env_setup_pagesize, i32 noundef 56) #7
  unreachable

52:                                               ; preds = %49
  %53 = shl nuw nsw i64 %1, 1
  %54 = tail call i32 @bytes2pgno(ptr noundef nonnull %0, i64 noundef %53) #8
  %.not53 = icmp eq i32 %54, 2
  br i1 %.not53, label %.thread, label %55, !prof !5

55:                                               ; preds = %52
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.7, ptr noundef nonnull @__func__.env_setup_pagesize, i32 noundef 57) #7
  unreachable

.thread:                                          ; preds = %37, %52
  tail call void @recalculate_merge_thresholds(ptr noundef nonnull %0) #9
  tail call void @recalculate_subpage_thresholds(ptr noundef nonnull %0) #9
  tail call void @env_options_adjust_dp_limit(ptr noundef nonnull %0) #9
  %56 = load i32, ptr %15, align 8, !tbaa !23
  ret i32 %56
}

; Function Attrs: inlinehint mustprogress nofree nosync nounwind willreturn memory(none) uwtable
declare hidden zeroext i1 @is_powerof2(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare i32 @log2n_powerof2(i64 noundef) local_unnamed_addr #3

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

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

declare void @recalculate_merge_thresholds(ptr noundef) local_unnamed_addr #5

declare void @recalculate_subpage_thresholds(ptr noundef) local_unnamed_addr #5

declare void @env_options_adjust_dp_limit(ptr noundef) local_unnamed_addr #5

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


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