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

; 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.5 }
%struct.anon.5 = 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.8, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.9, %struct.anon.13, i8, ptr, ptr, ptr, %struct.anon.14, %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.7, i32, i64, i64, i64 }
%union.anon.7 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.8 = type { ptr, ptr, ptr, ptr }
%struct.anon.9 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.10, %union.anon.11 }
%struct.anon.10 = type { i16, i16, i16, i16 }
%union.anon.11 = type { i32 }
%struct.anon.13 = type { i64, i64, i64, i64, i64 }
%struct.anon.14 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, ptr }
%union.mdbx_atomic_uint64_t = type { i64 }
%struct.meta = type { [2 x i32], %union.anon, i16, i8, i8, %struct.geo, %union.anon.2, %struct.MDBX_canary, %union.anon.4, [2 x %union.mdbx_atomic_uint32_t], [2 x i32], %union.bin128, %union.bin128 }
%union.anon = type { i64 }
%struct.geo = type { i16, i16, i32, i32, %union.anon.0, %union.anon.1 }
%union.anon.0 = type { i32 }
%union.anon.1 = type { i32 }
%union.anon.2 = type { %struct.anon }
%struct.anon = type { %struct.tree, %struct.tree }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.4 = type { i64 }
%struct.anon.3 = type { i16, i16, i32 }

@globals = external global %struct.libmdbx_globals, align 8
@__func__.dxb_read_header = external hidden unnamed_addr constant [16 x i8], align 1
@.str = external hidden unnamed_addr constant [54 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @dxb_read_header(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca [256 x i8], align 16
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca [256 x i8], align 16
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i8, align 1
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 4 %24, i8 0, i64 224, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.MDBX_env, ptr %25, i32 0, i32 3
  %27 = getelementptr inbounds %struct.osal_mmap, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.MDBX_env, ptr %29, i32 0, i32 3
  %31 = getelementptr inbounds %struct.osal_mmap, ptr %30, i32 0, i32 4
  %32 = call i32 @osal_filesize(i32 noundef %28, ptr noundef %31)
  store i32 %32, ptr %10, align 4, !tbaa !9
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = icmp ne i32 %33, 0
  %35 = xor i1 %34, true
  %36 = xor i1 %35, true
  %37 = zext i1 %36 to i32
  %38 = sext i32 %37 to i64
  %39 = call i64 @llvm.expect.i64(i64 %38, i64 0)
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %41, label %43

41:                                               ; preds = %4
  %42 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %42, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %386

43:                                               ; preds = %4
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.meta, ptr %44, i32 0, i32 8
  %46 = getelementptr inbounds [2 x i32], ptr %45, i64 0, i64 0
  call void @unaligned_poke_u64(i64 noundef 4, ptr noundef %46, i64 noundef 1)
  store i32 -30796, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  store i32 6, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  store i32 0, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %339, %43
  %48 = load i32, ptr %14, align 4, !tbaa !9
  %49 = load i32, ptr %12, align 4, !tbaa !9
  %50 = icmp ult i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  store i32 2, ptr %11, align 4
  br label %342

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  %53 = load i32, ptr %14, align 4, !tbaa !9
  %54 = urem i32 %53, 3
  store i32 %54, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %59

57:                                               ; preds = %52
  %58 = load i32, ptr %13, align 4, !tbaa !9
  br label %70

59:                                               ; preds = %52
  %60 = load i32, ptr %14, align 4, !tbaa !9
  %61 = icmp ugt i32 %60, 3
  br i1 %61, label %62, label %66

62:                                               ; preds = %59
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MDBX_env, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 8, !tbaa !23
  br label %68

66:                                               ; preds = %59
  %67 = load i32, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 1), align 8, !tbaa !24
  br label %68

68:                                               ; preds = %66, %62
  %69 = phi i32 [ %65, %62 ], [ %67, %66 ]
  br label %70

70:                                               ; preds = %68, %57
  %71 = phi i32 [ %58, %57 ], [ %69, %68 ]
  %72 = load i32, ptr %15, align 4, !tbaa !9
  %73 = mul i32 %71, %72
  store i32 %73, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 256, ptr %17) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #9
  store i32 42, ptr %18, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %220, %70
  br label %75

75:                                               ; preds = %74
  br label %76

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

86:                                               ; preds = %76
  %87 = load i32, ptr %15, align 4, !tbaa !9
  %88 = load i32, ptr %16, align 4, !tbaa !9
  %89 = load i32, ptr %18, align 4, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 6, ptr noundef @__func__.dxb_read_header, i32 noundef 29, ptr noundef @.str, i32 noundef %87, i32 noundef %88, i32 noundef 256, i32 noundef %89)
  br label %90

90:                                               ; preds = %86, %76
  br label %91

91:                                               ; preds = %90
  br label %92

92:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #9
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.MDBX_env, ptr %93, i32 0, i32 3
  %95 = getelementptr inbounds %struct.osal_mmap, ptr %94, i32 0, i32 1
  %96 = load i32, ptr %95, align 8, !tbaa !11
  %97 = getelementptr inbounds [256 x i8], ptr %17, i64 0, i64 0
  %98 = load i32, ptr %16, align 4, !tbaa !9
  %99 = zext i32 %98 to i64
  %100 = call i32 @osal_pread(i32 noundef %96, ptr noundef %97, i64 noundef 256, i64 noundef %99)
  store i32 %100, ptr %19, align 4, !tbaa !9
  %101 = load i32, ptr %19, align 4, !tbaa !9
  %102 = icmp eq i32 %101, 61
  br i1 %102, label %103, label %137

103:                                              ; preds = %92
  %104 = load i32, ptr %16, align 4, !tbaa !9
  %105 = icmp eq i32 %104, 0
  br i1 %105, label %106, label %137

106:                                              ; preds = %103
  %107 = load i32, ptr %14, align 4, !tbaa !9
  %108 = icmp eq i32 %107, 0
  br i1 %108, label %109, label %137

109:                                              ; preds = %106
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.MDBX_env, ptr %110, i32 0, i32 3
  %112 = getelementptr inbounds %struct.osal_mmap, ptr %111, i32 0, i32 4
  %113 = load i64, ptr %112, align 8, !tbaa !27
  %114 = icmp eq i64 %113, 0
  br i1 %114, label %115, label %137

115:                                              ; preds = %109
  %116 = load i32, ptr %9, align 4, !tbaa !9
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %118, label %137

118:                                              ; preds = %115
  br label %119

119:                                              ; preds = %118
  %120 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !26
  %121 = zext i8 %120 to i32
  %122 = icmp sle i32 3, %121
  %123 = xor i1 %122, true
  %124 = xor i1 %123, true
  %125 = zext i1 %124 to i32
  %126 = sext i32 %125 to i64
  %127 = call i64 @llvm.expect.i64(i64 %126, i64 0)
  %128 = icmp ne i64 %127, 0
  br i1 %128, label %129, label %133

129:                                              ; preds = %119
  %130 = load i32, ptr %19, align 4, !tbaa !9
  %131 = load i32, ptr %19, align 4, !tbaa !9
  %132 = call ptr @mdbx_strerror(i32 noundef %131)
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef @__func__.dxb_read_header, i32 noundef 33, ptr noundef @.str.1, i32 noundef %130, ptr noundef %132)
  br label %133

133:                                              ; preds = %129, %119
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134
  %136 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %136, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %218

137:                                              ; preds = %115, %109, %106, %103, %92
  %138 = load i32, ptr %19, align 4, !tbaa !9
  %139 = icmp ne i32 %138, 0
  br i1 %139, label %140, label %160

140:                                              ; preds = %137
  br label %141

141:                                              ; preds = %140
  %142 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !26
  %143 = zext i8 %142 to i32
  %144 = icmp sle i32 1, %143
  %145 = xor i1 %144, true
  %146 = xor i1 %145, true
  %147 = zext i1 %146 to i32
  %148 = sext i32 %147 to i64
  %149 = call i64 @llvm.expect.i64(i64 %148, i64 0)
  %150 = icmp ne i64 %149, 0
  br i1 %150, label %151, label %156

151:                                              ; preds = %141
  %152 = load i32, ptr %16, align 4, !tbaa !9
  %153 = load i32, ptr %19, align 4, !tbaa !9
  %154 = load i32, ptr %19, align 4, !tbaa !9
  %155 = call ptr @mdbx_strerror(i32 noundef %154)
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.dxb_read_header, i32 noundef 47, ptr noundef @.str.2, i32 noundef %152, i32 noundef 256, i32 noundef %153, ptr noundef %155)
  br label %156

156:                                              ; preds = %151, %141
  br label %157

157:                                              ; preds = %156
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %159, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %218

160:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 256, ptr %20) #9
  %161 = load ptr, ptr %6, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.MDBX_env, ptr %161, i32 0, i32 3
  %163 = getelementptr inbounds %struct.osal_mmap, ptr %162, i32 0, i32 1
  %164 = load i32, ptr %163, align 8, !tbaa !11
  %165 = getelementptr inbounds [256 x i8], ptr %20, i64 0, i64 0
  %166 = load i32, ptr %16, align 4, !tbaa !9
  %167 = zext i32 %166 to i64
  %168 = call i32 @osal_pread(i32 noundef %164, ptr noundef %165, i64 noundef 256, i64 noundef %167)
  store i32 %168, ptr %19, align 4, !tbaa !9
  %169 = load i32, ptr %19, align 4, !tbaa !9
  %170 = icmp ne i32 %169, 0
  br i1 %170, label %171, label %191

171:                                              ; preds = %160
  br label %172

172:                                              ; preds = %171
  %173 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !26
  %174 = zext i8 %173 to i32
  %175 = icmp sle i32 1, %174
  %176 = xor i1 %175, true
  %177 = xor i1 %176, true
  %178 = zext i1 %177 to i32
  %179 = sext i32 %178 to i64
  %180 = call i64 @llvm.expect.i64(i64 %179, i64 0)
  %181 = icmp ne i64 %180, 0
  br i1 %181, label %182, label %187

182:                                              ; preds = %172
  %183 = load i32, ptr %16, align 4, !tbaa !9
  %184 = load i32, ptr %19, align 4, !tbaa !9
  %185 = load i32, ptr %19, align 4, !tbaa !9
  %186 = call ptr @mdbx_strerror(i32 noundef %185)
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.dxb_read_header, i32 noundef 64, ptr noundef @.str.2, i32 noundef %183, i32 noundef 256, i32 noundef %184, ptr noundef %186)
  br label %187

187:                                              ; preds = %182, %172
  br label %188

188:                                              ; preds = %187
  br label %189

189:                                              ; preds = %188
  %190 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %190, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %217

191:                                              ; preds = %160
  %192 = getelementptr inbounds [256 x i8], ptr %17, i64 0, i64 0
  %193 = getelementptr inbounds [256 x i8], ptr %20, i64 0, i64 0
  %194 = call i32 @memcmp(ptr noundef %192, ptr noundef %193, i64 noundef 256) #10
  %195 = icmp eq i32 %194, 0
  br i1 %195, label %200, label %196

196:                                              ; preds = %191
  %197 = load i32, ptr %18, align 4, !tbaa !9
  %198 = add i32 %197, -1
  store i32 %198, ptr %18, align 4, !tbaa !9
  %199 = icmp eq i32 %198, 0
  br i1 %199, label %200, label %201

200:                                              ; preds = %196, %191
  store i32 6, ptr %11, align 4
  br label %217

201:                                              ; preds = %196
  br label %202

202:                                              ; preds = %201
  %203 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !26
  %204 = zext i8 %203 to i32
  %205 = icmp sle i32 4, %204
  %206 = xor i1 %205, true
  %207 = xor i1 %206, true
  %208 = zext i1 %207 to i32
  %209 = sext i32 %208 to i64
  %210 = call i64 @llvm.expect.i64(i64 %209, i64 0)
  %211 = icmp ne i64 %210, 0
  br i1 %211, label %212, label %214

212:                                              ; preds = %202
  %213 = load i32, ptr %15, align 4, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 4, ptr noundef @__func__.dxb_read_header, i32 noundef 71, ptr noundef @.str.3, i32 noundef %213)
  br label %214

214:                                              ; preds = %212, %202
  br label %215

215:                                              ; preds = %214
  br label %216

216:                                              ; preds = %215
  store i32 0, ptr %11, align 4
  br label %217

217:                                              ; preds = %216, %200, %189
  call void @llvm.lifetime.end.p0(i64 256, ptr %20) #9
  br label %218

218:                                              ; preds = %217, %158, %135
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #9
  %219 = load i32, ptr %11, align 4
  switch i32 %219, label %336 [
    i32 0, label %220
    i32 6, label %221
  ]

220:                                              ; preds = %218
  br label %74

221:                                              ; preds = %218
  %222 = load i32, ptr %18, align 4, !tbaa !9
  %223 = icmp ne i32 %222, 0
  br i1 %223, label %240, label %224

224:                                              ; preds = %221
  br label %225

225:                                              ; preds = %224
  %226 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !26
  %227 = zext i8 %226 to i32
  %228 = icmp sle i32 1, %227
  %229 = xor i1 %228, true
  %230 = xor i1 %229, true
  %231 = zext i1 %230 to i32
  %232 = sext i32 %231 to i64
  %233 = call i64 @llvm.expect.i64(i64 %232, i64 0)
  %234 = icmp ne i64 %233, 0
  br i1 %234, label %235, label %237

235:                                              ; preds = %225
  %236 = load i32, ptr %15, align 4, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.dxb_read_header, i32 noundef 75, ptr noundef @.str.4, i32 noundef %236)
  br label %237

237:                                              ; preds = %235, %225
  br label %238

238:                                              ; preds = %237
  br label %239

239:                                              ; preds = %238
  store i32 4, ptr %11, align 4
  br label %336

240:                                              ; preds = %221
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #9
  %241 = getelementptr inbounds [256 x i8], ptr %17, i64 0, i64 0
  store ptr %241, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #9
  %242 = load ptr, ptr %21, align 8, !tbaa !5
  %243 = call ptr @page_meta(ptr noundef %242) #10
  store ptr %243, ptr %22, align 8, !tbaa !5
  %244 = load ptr, ptr %6, align 8, !tbaa !5
  %245 = load ptr, ptr %22, align 8, !tbaa !5
  %246 = load ptr, ptr %21, align 8, !tbaa !5
  %247 = load i32, ptr %15, align 4, !tbaa !9
  %248 = call i32 @meta_validate(ptr noundef %244, ptr noundef %245, ptr noundef %246, i32 noundef %247, ptr noundef %13)
  store i32 %248, ptr %10, align 4, !tbaa !9
  %249 = load i32, ptr %10, align 4, !tbaa !9
  %250 = icmp ne i32 %249, 0
  br i1 %250, label %251, label %252

251:                                              ; preds = %240
  store i32 4, ptr %11, align 4
  br label %335

252:                                              ; preds = %240
  call void @llvm.lifetime.start.p0(i64 1, ptr %23) #9
  %253 = load ptr, ptr %6, align 8, !tbaa !5
  %254 = getelementptr inbounds %struct.MDBX_env, ptr %253, i32 0, i32 16
  %255 = load i8, ptr %254, align 1, !tbaa !28
  %256 = sext i8 %255 to i32
  %257 = icmp sge i32 %256, 0
  br i1 %257, label %258, label %266

258:                                              ; preds = %252
  %259 = load i32, ptr %15, align 4, !tbaa !9
  %260 = load ptr, ptr %6, align 8, !tbaa !5
  %261 = getelementptr inbounds %struct.MDBX_env, ptr %260, i32 0, i32 16
  %262 = load i8, ptr %261, align 1, !tbaa !28
  %263 = sext i8 %262 to i32
  %264 = icmp eq i32 %259, %263
  %265 = zext i1 %264 to i8
  store i8 %265, ptr %23, align 1, !tbaa !29
  br label %304

266:                                              ; preds = %252
  %267 = load ptr, ptr %22, align 8, !tbaa !5
  %268 = call zeroext i1 @meta_bootid_match(ptr noundef %267)
  br i1 %268, label %269, label %286

269:                                              ; preds = %266
  %270 = load ptr, ptr %22, align 8, !tbaa !5
  %271 = getelementptr inbounds %struct.meta, ptr %270, i32 0, i32 1
  %272 = load i64, ptr %271, align 4, !tbaa !30
  %273 = load ptr, ptr %22, align 8, !tbaa !5
  %274 = getelementptr inbounds %struct.meta, ptr %273, i32 0, i32 8
  %275 = load i64, ptr %274, align 4, !tbaa !30
  %276 = icmp ugt i64 %275, 1
  %277 = load ptr, ptr %7, align 8, !tbaa !5
  %278 = getelementptr inbounds %struct.meta, ptr %277, i32 0, i32 1
  %279 = load i64, ptr %278, align 4, !tbaa !30
  %280 = load ptr, ptr %7, align 8, !tbaa !5
  %281 = getelementptr inbounds %struct.meta, ptr %280, i32 0, i32 8
  %282 = load i64, ptr %281, align 4, !tbaa !30
  %283 = icmp ugt i64 %282, 1
  %284 = call zeroext i1 @meta_choice_recent(i64 noundef %272, i1 noundef zeroext %276, i64 noundef %279, i1 noundef zeroext %283)
  %285 = zext i1 %284 to i8
  store i8 %285, ptr %23, align 1, !tbaa !29
  br label %303

286:                                              ; preds = %266
  %287 = load ptr, ptr %22, align 8, !tbaa !5
  %288 = getelementptr inbounds %struct.meta, ptr %287, i32 0, i32 1
  %289 = load i64, ptr %288, align 4, !tbaa !30
  %290 = load ptr, ptr %22, align 8, !tbaa !5
  %291 = getelementptr inbounds %struct.meta, ptr %290, i32 0, i32 8
  %292 = load i64, ptr %291, align 4, !tbaa !30
  %293 = icmp ugt i64 %292, 1
  %294 = load ptr, ptr %7, align 8, !tbaa !5
  %295 = getelementptr inbounds %struct.meta, ptr %294, i32 0, i32 1
  %296 = load i64, ptr %295, align 4, !tbaa !30
  %297 = load ptr, ptr %7, align 8, !tbaa !5
  %298 = getelementptr inbounds %struct.meta, ptr %297, i32 0, i32 8
  %299 = load i64, ptr %298, align 4, !tbaa !30
  %300 = icmp ugt i64 %299, 1
  %301 = call zeroext i1 @meta_choice_steady(i64 noundef %289, i1 noundef zeroext %293, i64 noundef %296, i1 noundef zeroext %300)
  %302 = zext i1 %301 to i8
  store i8 %302, ptr %23, align 1, !tbaa !29
  br label %303

303:                                              ; preds = %286, %269
  br label %304

304:                                              ; preds = %303, %258
  %305 = load i8, ptr %23, align 1, !tbaa !29, !range !31, !noundef !32
  %306 = trunc i8 %305 to i1
  br i1 %306, label %307, label %334

307:                                              ; preds = %304
  %308 = load ptr, ptr %7, align 8, !tbaa !5
  %309 = load ptr, ptr %22, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %308, ptr align 4 %309, i64 224, i1 false), !tbaa.struct !33
  %310 = load i32, ptr %8, align 4, !tbaa !9
  %311 = icmp ne i32 %310, 0
  br i1 %311, label %318, label %312

312:                                              ; preds = %307
  %313 = load ptr, ptr %7, align 8, !tbaa !5
  %314 = call zeroext i1 @meta_is_steady(ptr noundef %313)
  br i1 %314, label %318, label %315

315:                                              ; preds = %312
  %316 = load i32, ptr %12, align 4, !tbaa !9
  %317 = add i32 %316, 1
  store i32 %317, ptr %12, align 4, !tbaa !9
  br label %318

318:                                              ; preds = %315, %312, %307
  br label %319

319:                                              ; preds = %318
  %320 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !26
  %321 = zext i8 %320 to i32
  %322 = icmp sle i32 4, %321
  %323 = xor i1 %322, true
  %324 = xor i1 %323, true
  %325 = zext i1 %324 to i32
  %326 = sext i32 %325 to i64
  %327 = call i64 @llvm.expect.i64(i64 %326, i64 0)
  %328 = icmp ne i64 %327, 0
  br i1 %328, label %329, label %331

329:                                              ; preds = %319
  %330 = load i32, ptr %15, align 4, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 4, ptr noundef @__func__.dxb_read_header, i32 noundef 98, ptr noundef @.str.5, i32 noundef %330)
  br label %331

331:                                              ; preds = %329, %319
  br label %332

332:                                              ; preds = %331
  br label %333

333:                                              ; preds = %332
  br label %334

334:                                              ; preds = %333, %304
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #9
  store i32 0, ptr %11, align 4
  br label %335

335:                                              ; preds = %334, %251
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #9
  br label %336

336:                                              ; preds = %335, %239, %218
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 256, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  %337 = load i32, ptr %11, align 4
  switch i32 %337, label %342 [
    i32 0, label %338
    i32 4, label %339
  ]

338:                                              ; preds = %336
  br label %339

339:                                              ; preds = %338, %336
  %340 = load i32, ptr %14, align 4, !tbaa !9
  %341 = add i32 %340, 1
  store i32 %341, ptr %14, align 4, !tbaa !9
  br label %47, !llvm.loop !36

342:                                              ; preds = %336, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  %343 = load i32, ptr %11, align 4
  switch i32 %343, label %385 [
    i32 2, label %344
  ]

344:                                              ; preds = %342
  %345 = load ptr, ptr %7, align 8, !tbaa !5
  %346 = getelementptr inbounds %struct.meta, ptr %345, i32 0, i32 6
  %347 = getelementptr inbounds %struct.anon.3, ptr %346, i32 0, i32 2
  %348 = load i32, ptr %347, align 4, !tbaa !30
  %349 = icmp eq i32 %348, 0
  br i1 %349, label %364, label %350

350:                                              ; preds = %344
  %351 = load ptr, ptr %6, align 8, !tbaa !5
  %352 = getelementptr inbounds %struct.MDBX_env, ptr %351, i32 0, i32 16
  %353 = load i8, ptr %352, align 1, !tbaa !28
  %354 = sext i8 %353 to i32
  %355 = icmp slt i32 %354, 0
  br i1 %355, label %356, label %384

356:                                              ; preds = %350
  %357 = load ptr, ptr %7, align 8, !tbaa !5
  %358 = call zeroext i1 @meta_is_steady(ptr noundef %357)
  br i1 %358, label %384, label %359

359:                                              ; preds = %356
  %360 = load ptr, ptr %6, align 8, !tbaa !5
  %361 = load ptr, ptr %7, align 8, !tbaa !5
  %362 = load i32, ptr %8, align 4, !tbaa !9
  %363 = call zeroext i1 @meta_weak_acceptable(ptr noundef %360, ptr noundef %361, i32 noundef %362)
  br i1 %363, label %384, label %364

364:                                              ; preds = %359, %344
  br label %365

365:                                              ; preds = %364
  %366 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !26
  %367 = zext i8 %366 to i32
  %368 = icmp sle i32 1, %367
  %369 = xor i1 %368, true
  %370 = xor i1 %369, true
  %371 = zext i1 %370 to i32
  %372 = sext i32 %371 to i64
  %373 = call i64 @llvm.expect.i64(i64 %372, i64 0)
  %374 = icmp ne i64 %373, 0
  br i1 %374, label %375, label %376

375:                                              ; preds = %365
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.dxb_read_header, i32 noundef 104, ptr noundef @.str.6, ptr noundef @.str.7)
  br label %376

376:                                              ; preds = %375, %365
  br label %377

377:                                              ; preds = %376
  br label %378

378:                                              ; preds = %377
  %379 = load i32, ptr %10, align 4, !tbaa !9
  %380 = icmp eq i32 %379, 0
  br i1 %380, label %381, label %382

381:                                              ; preds = %378
  store i32 -30796, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %385

382:                                              ; preds = %378
  %383 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %383, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %385

384:                                              ; preds = %359, %356, %350
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %385

385:                                              ; preds = %384, %382, %381, %342
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  br label %386

386:                                              ; preds = %385, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  %387 = load i32, ptr %5, align 4
  ret i32 %387
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

declare i32 @osal_filesize(i32 noundef, ptr noundef) #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @unaligned_poke_u64(i64 noundef, ptr noalias noundef, i64 noundef) #5

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

declare i32 @osal_pread(i32 noundef, ptr noundef, i64 noundef, i64 noundef) #3

declare ptr @mdbx_strerror(i32 noundef) #3

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

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

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

declare i32 @meta_validate(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_bootid_match(ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_choice_recent(i64 noundef, i1 noundef zeroext, i64 noundef, i1 noundef zeroext) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_choice_steady(i64 noundef, i1 noundef zeroext, i64 noundef, i1 noundef zeroext) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #8

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_is_steady(ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_weak_acceptable(ptr noundef, ptr noundef, i32 noundef) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #5 = { 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 #6 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { 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 #8 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #9 = { nounwind }
attributes #10 = { 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, !10, i64 24}
!12 = !{!"MDBX_env", !7, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !10, i64 56, !10, i64 60, !13, 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, !16, 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, !14, 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, !10, i64 440, !10, i64 444, !6, i64 448, !22, i64 456, !7, i64 496, !7, i64 536}
!13 = !{!"osal_mmap", !7, i64 0, !10, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!14 = !{!"long", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !14, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !10, i64 28, !10, 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 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!21 = !{!"", !14, i64 0}
!22 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!12, !10, i64 8}
!24 = !{!25, !10, i64 16}
!25 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !18, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !14, i64 80, !6, i64 88}
!26 = !{!25, !7, i64 26}
!27 = !{!12, !14, i64 48}
!28 = !{!12, !7, i64 129}
!29 = !{!18, !18, i64 0}
!30 = !{!7, !7, i64 0}
!31 = !{i8 0, i8 2}
!32 = !{}
!33 = !{i64 0, i64 8, !30, i64 8, i64 8, !30, i64 16, i64 2, !34, i64 18, i64 1, !30, i64 19, i64 1, !30, i64 20, i64 2, !34, i64 22, i64 2, !34, i64 24, i64 4, !9, i64 28, i64 4, !9, i64 32, i64 4, !30, i64 36, i64 4, !30, i64 40, i64 96, !30, i64 136, i64 8, !35, i64 144, i64 8, !35, i64 152, i64 8, !35, i64 160, i64 8, !35, i64 168, i64 8, !30, i64 176, i64 8, !30, i64 184, i64 8, !30, i64 192, i64 16, !30, i64 208, i64 16, !30}
!34 = !{!15, !15, i64 0}
!35 = !{!14, !14, i64 0}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


; 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.5 }
%struct.anon.5 = 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
@__func__.dxb_read_header = external hidden unnamed_addr constant [16 x i8], align 1
@.str = external hidden unnamed_addr constant [54 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @dxb_read_header(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca i32, align 4
  %6 = alloca [256 x i8], align 16
  %7 = alloca [256 x i8], align 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(224) %1, i8 0, i64 224, i1 false)
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = tail call i32 @osal_filesize(i32 noundef %9, ptr noundef nonnull %10) #8
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %117, !prof !21

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %1, i64 168
  tail call void @unaligned_poke_u64(i64 noundef 4, ptr noundef nonnull %13, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #8
  store i32 0, ptr %5, align 4, !tbaa !22
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = getelementptr inbounds i8, ptr %0, i64 129
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %.not118 = icmp eq i32 %2, 0
  br label %17

thread-pre-split:                                 ; preds = %99
  %.pr = load i32, ptr %5, align 4, !tbaa !22
  br label %17

17:                                               ; preds = %thread-pre-split, %12
  %18 = phi i32 [ %.pr, %thread-pre-split ], [ 0, %12 ]
  %.084173 = phi i32 [ %.185.ph, %thread-pre-split ], [ -30796, %12 ]
  %.096172 = phi i32 [ %.4100.ph, %thread-pre-split ], [ 6, %12 ]
  %.0101171 = phi i32 [ %100, %thread-pre-split ], [ 0, %12 ]
  %19 = urem i32 %.0101171, 3
  %.not110 = icmp eq i32 %18, 0
  br i1 %.not110, label %.sink.split, label %22

.sink.split:                                      ; preds = %17
  %20 = icmp ugt i32 %.0101171, 3
  %. = select i1 %20, ptr %14, ptr getelementptr inbounds (i8, ptr @globals, i64 16)
  %21 = load i32, ptr %., align 8, !tbaa !22
  br label %22

22:                                               ; preds = %.sink.split, %17
  %23 = phi i32 [ %18, %17 ], [ %21, %.sink.split ]
  %24 = mul i32 %23, %19
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %6) #8
  %25 = zext i32 %24 to i64
  %26 = icmp eq i32 %.0101171, 0
  %.pre185 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  br label %27

27:                                               ; preds = %65, %22
  %28 = phi i8 [ %.pre185, %22 ], [ %66, %65 ]
  %.087 = phi i32 [ 42, %22 ], [ %58, %65 ]
  %29 = icmp ugt i8 %28, 5
  br i1 %29, label %30, label %31, !prof !25

30:                                               ; preds = %27
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 6, ptr noundef nonnull @__func__.dxb_read_header, i32 noundef 29, ptr noundef nonnull @.str, i32 noundef %19, i32 noundef %24, i32 noundef 256, i32 noundef %.087) #8
  br label %31

31:                                               ; preds = %30, %27
  %32 = load i32, ptr %8, align 8, !tbaa !5
  %33 = call i32 @osal_pread(i32 noundef %32, ptr noundef nonnull %6, i64 noundef 256, i64 noundef %25) #8
  %34 = icmp eq i32 %33, 61
  %or.cond3 = and i1 %26, %34
  br i1 %or.cond3, label %35, label %44

35:                                               ; preds = %31
  %36 = load i64, ptr %10, align 8, !tbaa !26
  %37 = icmp eq i64 %36, 0
  %38 = icmp ne i32 %3, 0
  %or.cond5 = and i1 %38, %37
  br i1 %or.cond5, label %39, label %.thread

39:                                               ; preds = %35
  %40 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  %41 = icmp ugt i8 %40, 2
  br i1 %41, label %42, label %.thread122, !prof !25

42:                                               ; preds = %39
  %43 = call ptr @mdbx_strerror(i32 noundef 61) #8
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef nonnull @__func__.dxb_read_header, i32 noundef 33, ptr noundef nonnull @.str.1, i32 noundef 61, ptr noundef %43) #8
  br label %.thread122

44:                                               ; preds = %31
  %.not111 = icmp eq i32 %33, 0
  br i1 %.not111, label %48, label %.thread

.thread:                                          ; preds = %44, %35
  %45 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  %.not114 = icmp eq i8 %45, 0
  br i1 %.not114, label %.thread122, label %46, !prof !21

46:                                               ; preds = %.thread
  %47 = call ptr @mdbx_strerror(i32 noundef %33) #8
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.dxb_read_header, i32 noundef 47, ptr noundef nonnull @.str.2, i32 noundef %24, i32 noundef 256, i32 noundef %33, ptr noundef %47) #8
  br label %.thread122

48:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %7) #8
  %49 = load i32, ptr %8, align 8, !tbaa !5
  %50 = call i32 @osal_pread(i32 noundef %49, ptr noundef nonnull %7, i64 noundef 256, i64 noundef %25) #8
  %.not112 = icmp eq i32 %50, 0
  br i1 %.not112, label %55, label %51

51:                                               ; preds = %48
  %52 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  %.not113 = icmp eq i8 %52, 0
  br i1 %.not113, label %.thread128, label %53, !prof !21

53:                                               ; preds = %51
  %54 = call ptr @mdbx_strerror(i32 noundef %50) #8
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.dxb_read_header, i32 noundef 64, ptr noundef nonnull @.str.2, i32 noundef %24, i32 noundef 256, i32 noundef %50, ptr noundef %54) #8
  br label %.thread128

55:                                               ; preds = %48
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(256) %6, ptr noundef nonnull dereferenceable(256) %7, i64 256)
  %56 = icmp eq i32 %bcmp, 0
  br i1 %56, label %67, label %57

57:                                               ; preds = %55
  %58 = add nsw i32 %.087, -1
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %.thread139, label %61

.thread139:                                       ; preds = %57
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %7) #8
  %60 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  %.not116 = icmp eq i8 %60, 0
  br i1 %.not116, label %99, label %70, !prof !21

61:                                               ; preds = %57
  %62 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  %63 = icmp ugt i8 %62, 3
  br i1 %63, label %64, label %65, !prof !25

64:                                               ; preds = %61
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 4, ptr noundef nonnull @__func__.dxb_read_header, i32 noundef 71, ptr noundef nonnull @.str.3, i32 noundef %19) #8
  %.pre = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  br label %65

.thread128:                                       ; preds = %53, %51
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %7) #8
  br label %.thread122

65:                                               ; preds = %64, %61
  %66 = phi i8 [ %.pre, %64 ], [ %62, %61 ]
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %7) #8
  br label %27

67:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %7) #8
  %68 = call ptr @page_meta(ptr noundef nonnull %6) #9
  %69 = call i32 @meta_validate(ptr noundef nonnull %0, ptr noundef %68, ptr noundef nonnull %6, i32 noundef %19, ptr noundef nonnull %5) #8
  %.not117 = icmp eq i32 %69, 0
  br i1 %.not117, label %71, label %99

70:                                               ; preds = %.thread139
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.dxb_read_header, i32 noundef 75, ptr noundef nonnull @.str.4, i32 noundef %19) #8
  br label %99

71:                                               ; preds = %67
  %72 = load i8, ptr %15, align 1, !tbaa !27
  %73 = icmp sgt i8 %72, -1
  br i1 %73, label %74, label %77

74:                                               ; preds = %71
  %75 = zext nneg i8 %72 to i32
  %76 = icmp eq i32 %19, %75
  br i1 %76, label %91, label %99

77:                                               ; preds = %71
  %78 = call zeroext i1 @meta_bootid_match(ptr noundef %68)
  %79 = getelementptr inbounds i8, ptr %68, i64 8
  %80 = load i64, ptr %79, align 4, !tbaa !28
  %81 = getelementptr inbounds i8, ptr %68, i64 168
  %82 = load i64, ptr %81, align 4, !tbaa !28
  %83 = icmp ugt i64 %82, 1
  %84 = load i64, ptr %16, align 4, !tbaa !28
  %85 = load i64, ptr %13, align 4, !tbaa !28
  %86 = icmp ugt i64 %85, 1
  br i1 %78, label %87, label %89

87:                                               ; preds = %77
  %88 = call zeroext i1 @meta_choice_recent(i64 noundef %80, i1 noundef zeroext %83, i64 noundef %84, i1 noundef zeroext %86)
  br i1 %88, label %91, label %99

89:                                               ; preds = %77
  %90 = call zeroext i1 @meta_choice_steady(i64 noundef %80, i1 noundef zeroext %83, i64 noundef %84, i1 noundef zeroext %86)
  br i1 %90, label %91, label %99

91:                                               ; preds = %87, %74, %89
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(224) %1, ptr noundef nonnull align 4 dereferenceable(224) %68, i64 224, i1 false), !tbaa.struct !29
  br i1 %.not118, label %92, label %95

92:                                               ; preds = %91
  %93 = call zeroext i1 @meta_is_steady(ptr noundef nonnull %1)
  %not. = xor i1 %93, true
  %94 = zext i1 %not. to i32
  %spec.select = add i32 %.096172, %94
  br label %95

95:                                               ; preds = %92, %91
  %.197 = phi i32 [ %.096172, %91 ], [ %spec.select, %92 ]
  %96 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  %97 = icmp ugt i8 %96, 3
  br i1 %97, label %98, label %99, !prof !25

98:                                               ; preds = %95
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 4, ptr noundef nonnull @__func__.dxb_read_header, i32 noundef 98, ptr noundef nonnull @.str.5, i32 noundef %19) #8
  br label %99

99:                                               ; preds = %70, %.thread139, %67, %95, %98, %89, %74, %87
  %.4100.ph = phi i32 [ %.096172, %87 ], [ %.096172, %74 ], [ %.096172, %89 ], [ %.197, %95 ], [ %.197, %98 ], [ %.096172, %67 ], [ %.096172, %.thread139 ], [ %.096172, %70 ]
  %.185.ph = phi i32 [ 0, %87 ], [ 0, %74 ], [ 0, %89 ], [ 0, %95 ], [ 0, %98 ], [ %69, %67 ], [ %.084173, %.thread139 ], [ %.084173, %70 ]
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %6) #8
  %100 = add nuw i32 %.0101171, 1
  %.not119 = icmp ult i32 %100, %.4100.ph
  br i1 %.not119, label %thread-pre-split, label %.thread151, !llvm.loop !32

.thread122:                                       ; preds = %.thread, %46, %39, %42, %.thread128
  %.3126 = phi i32 [ %50, %.thread128 ], [ %33, %.thread ], [ %33, %46 ], [ 61, %39 ], [ 61, %42 ]
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %6) #8
  br label %116

.thread151:                                       ; preds = %99
  %101 = getelementptr inbounds i8, ptr %1, i64 44
  %102 = load i32, ptr %101, align 4, !tbaa !28
  %103 = icmp eq i32 %102, 0
  br i1 %103, label %111, label %104

104:                                              ; preds = %.thread151
  %105 = load i8, ptr %15, align 1, !tbaa !27
  %106 = icmp slt i8 %105, 0
  br i1 %106, label %107, label %116

107:                                              ; preds = %104
  %108 = call zeroext i1 @meta_is_steady(ptr noundef nonnull %1)
  br i1 %108, label %116, label %109

109:                                              ; preds = %107
  %110 = call zeroext i1 @meta_weak_acceptable(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %2)
  br i1 %110, label %116, label %111

111:                                              ; preds = %.thread151, %109
  %112 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !23
  %.not120 = icmp eq i8 %112, 0
  br i1 %.not120, label %114, label %113, !prof !21

113:                                              ; preds = %111
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.dxb_read_header, i32 noundef 104, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7) #8
  br label %114

114:                                              ; preds = %113, %111
  %115 = icmp eq i32 %.185.ph, 0
  %..286 = select i1 %115, i32 -30796, i32 %.185.ph
  br label %116

116:                                              ; preds = %.thread122, %104, %107, %109, %114
  %.5 = phi i32 [ %.3126, %.thread122 ], [ %..286, %114 ], [ 0, %109 ], [ 0, %107 ], [ 0, %104 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #8
  br label %117

117:                                              ; preds = %4, %116
  %.6 = phi i32 [ %.5, %116 ], [ %11, %4 ]
  ret i32 %.6
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

declare i32 @osal_filesize(i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @unaligned_poke_u64(i64 noundef, ptr noalias noundef, i64 noundef) local_unnamed_addr #4

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

declare i32 @osal_pread(i32 noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

declare ptr @mdbx_strerror(i32 noundef) local_unnamed_addr #3

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

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

declare i32 @meta_validate(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_bootid_match(ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_choice_recent(i64 noundef, i1 noundef zeroext, i64 noundef, i1 noundef zeroext) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_choice_steady(i64 noundef, i1 noundef zeroext, i64 noundef, i1 noundef zeroext) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_is_steady(ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @meta_weak_acceptable(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #7

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nofree nounwind willreturn memory(argmem: read) }
attributes #8 = { nounwind }
attributes #9 = { 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, !9, i64 24}
!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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!22 = !{!9, !9, i64 0}
!23 = !{!24, !7, i64 26}
!24 = !{!"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}
!25 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!26 = !{!6, !11, i64 48}
!27 = !{!6, !7, i64 129}
!28 = !{!7, !7, i64 0}
!29 = !{i64 0, i64 8, !28, i64 8, i64 8, !28, i64 16, i64 2, !30, i64 18, i64 1, !28, i64 19, i64 1, !28, i64 20, i64 2, !30, i64 22, i64 2, !30, i64 24, i64 4, !22, i64 28, i64 4, !22, i64 32, i64 4, !28, i64 36, i64 4, !28, i64 40, i64 96, !28, i64 136, i64 8, !31, i64 144, i64 8, !31, i64 152, i64 8, !31, i64 160, i64 8, !31, i64 168, i64 8, !28, i64 176, i64 8, !28, i64 184, i64 8, !28, i64 192, i64 16, !28, i64 208, i64 16, !28}
!30 = !{!13, !13, i64 0}
!31 = !{!11, !11, i64 0}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LowerExpectIntrinsicPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass