; 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.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }
%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 }
%struct.shared_lck = type { i64, i32, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, [2 x %union.mdbx_atomic_uint32_t], [16 x i8], %struct.pgops, [16 x i8], %union.pthread_mutex_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, i32, %struct.anon.19, %union.pthread_mutex_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, [16 x i8], [0 x %struct.reader_slot] }
%struct.pgops = type { %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %struct.anon.17 }
%struct.anon.17 = type { %struct.gc_prof_stat, %struct.gc_prof_stat, i32, i32, i32, i32, i32 }
%struct.gc_prof_stat = type { i64, i64, i32, i32, i32, i32, %struct.anon.18 }
%struct.anon.18 = type { i64, i64, i32 }
%struct.anon.19 = type { [4 x i32], [4 x i64] }
%struct.reader_slot = type { %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint64_t }

@globals = external global %struct.libmdbx_globals, align 8
@.str.16 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.env_open = external hidden unnamed_addr constant [9 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [5 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: noreturn
declare void @mdbx_assert_fail(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @atomic_load32(ptr noundef, i32 noundef) #3

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

declare i64 @osal_monotime() #4

declare i64 @recent_committed_txnid(ptr noundef) #4

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @env_open(ptr noundef %0, i32 noundef %1) #5 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca %struct.stat, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %19 = call i32 @osal_getpid()
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.MDBX_env, ptr %20, i32 0, i32 20
  store i32 %19, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.MDBX_env, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !23
  %25 = and i32 %24, 131072
  %26 = icmp ne i32 %25, 0
  %27 = zext i1 %26 to i64
  %28 = select i1 %26, i32 0, i32 1
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.MDBX_env, ptr %30, i32 0, i32 22
  %32 = getelementptr inbounds %struct.anon, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !24
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.MDBX_env, ptr %34, i32 0, i32 3
  %36 = getelementptr inbounds %struct.osal_mmap, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = call i32 @osal_openfile(i32 noundef %28, ptr noundef %29, ptr noundef %33, ptr noundef %36, i32 noundef %37)
  store i32 %38, ptr %6, align 4, !tbaa !9
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = icmp ne i32 %39, 0
  %41 = xor i1 %40, true
  %42 = xor i1 %41, true
  %43 = zext i1 %42 to i32
  %44 = sext i32 %43 to i64
  %45 = call i64 @llvm.expect.i64(i64 %44, i64 0)
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %2
  %48 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %48, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %549

49:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #9
  store i64 9223372034707292160, ptr %8, align 8, !tbaa !25
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MDBX_env, ptr %50, i32 0, i32 3
  %52 = getelementptr inbounds %struct.osal_mmap, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 8, !tbaa !26
  %54 = call i32 @osal_fseek(i32 noundef %53, i64 noundef 9223372034707292160)
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MDBX_env, ptr %55, i32 0, i32 3
  %57 = getelementptr inbounds %struct.osal_mmap, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !26
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.MDBX_env, ptr %59, i32 0, i32 5
  store i32 %58, ptr %60, align 4, !tbaa !27
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %85

63:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 144, ptr %9) #9
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.MDBX_env, ptr %64, i32 0, i32 3
  %66 = getelementptr inbounds %struct.osal_mmap, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 8, !tbaa !26
  %68 = call i32 @fstat64(i32 noundef %67, ptr noundef %9) #9
  %69 = icmp ne i32 %68, 0
  %70 = xor i1 %69, true
  %71 = xor i1 %70, true
  %72 = zext i1 %71 to i32
  %73 = sext i32 %72 to i64
  %74 = call i64 @llvm.expect.i64(i64 %73, i64 0)
  %75 = icmp ne i64 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %63
  %77 = call ptr @__errno_location() #10
  %78 = load i32, ptr %77, align 4, !tbaa !9
  store i32 %78, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %82

79:                                               ; preds = %63
  %80 = getelementptr inbounds %struct.stat, ptr %9, i32 0, i32 3
  %81 = load i32, ptr %80, align 8, !tbaa !28
  store i32 %81, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %7, align 4
  br label %82

82:                                               ; preds = %79, %76
  call void @llvm.lifetime.end.p0(i64 144, ptr %9) #9
  %83 = load i32, ptr %7, align 4
  switch i32 %83, label %548 [
    i32 0, label %84
  ]

84:                                               ; preds = %82
  br label %85

85:                                               ; preds = %84, %49
  %86 = load i32, ptr %5, align 4, !tbaa !9
  %87 = and i32 %86, 54
  %88 = or i32 %87, 256
  %89 = or i32 %88, 128
  %90 = load i32, ptr %5, align 4, !tbaa !9
  %91 = and i32 %90, 32
  %92 = icmp ne i32 %91, 0
  %93 = zext i1 %92 to i64
  %94 = select i1 %92, i32 16, i32 0
  %95 = or i32 %89, %94
  %96 = load i32, ptr %5, align 4, !tbaa !9
  %97 = and i32 %96, 4
  %98 = icmp ne i32 %97, 0
  %99 = zext i1 %98 to i64
  %100 = select i1 %98, i32 2, i32 0
  %101 = or i32 %95, %100
  store i32 %101, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #9
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = load i32, ptr %5, align 4, !tbaa !9
  %104 = call i32 @lck_setup(ptr noundef %102, i32 noundef %103)
  store i32 %104, ptr %10, align 4, !tbaa !9
  %105 = load i32, ptr %10, align 4, !tbaa !9
  %106 = icmp ne i32 %105, -1
  br i1 %106, label %107, label %110

107:                                              ; preds = %85
  %108 = load i32, ptr %10, align 4, !tbaa !9
  %109 = icmp ne i32 %108, 0
  br label %110

110:                                              ; preds = %107, %85
  %111 = phi i1 [ false, %85 ], [ %109, %107 ]
  %112 = xor i1 %111, true
  %113 = xor i1 %112, true
  %114 = zext i1 %113 to i32
  %115 = sext i32 %114 to i64
  %116 = call i64 @llvm.expect.i64(i64 %115, i64 0)
  %117 = icmp ne i64 %116, 0
  br i1 %117, label %118, label %120

118:                                              ; preds = %110
  %119 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %119, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %547

120:                                              ; preds = %110
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.MDBX_env, ptr %121, i32 0, i32 6
  %123 = getelementptr inbounds %struct.osal_mmap, ptr %122, i32 0, i32 1
  %124 = load i32, ptr %123, align 8, !tbaa !31
  %125 = icmp ne i32 %124, -1
  br i1 %125, label %126, label %132

126:                                              ; preds = %120
  %127 = load ptr, ptr %4, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.MDBX_env, ptr %127, i32 0, i32 6
  %129 = getelementptr inbounds %struct.osal_mmap, ptr %128, i32 0, i32 1
  %130 = load i32, ptr %129, align 8, !tbaa !31
  %131 = call i32 @osal_fseek(i32 noundef %130, i64 noundef 9223372034707292160)
  br label %132

132:                                              ; preds = %126, %120
  br label %133

133:                                              ; preds = %132
  %134 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !32
  %135 = zext i8 %134 to i32
  %136 = and i32 %135, 1
  %137 = icmp ne i32 %136, 0
  %138 = xor i1 %137, true
  %139 = xor i1 %138, true
  %140 = zext i1 %139 to i32
  %141 = sext i32 %140 to i64
  %142 = call i64 @llvm.expect.i64(i64 %141, i64 1)
  %143 = icmp ne i64 %142, 0
  br i1 %143, label %144, label %162

144:                                              ; preds = %133
  br label %145

145:                                              ; preds = %144
  %146 = load ptr, ptr %4, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.MDBX_env, ptr %146, i32 0, i32 4
  %148 = load i32, ptr %147, align 8, !tbaa !34
  %149 = icmp eq i32 %148, -1
  %150 = xor i1 %149, true
  %151 = xor i1 %150, true
  %152 = xor i1 %151, true
  %153 = zext i1 %152 to i32
  %154 = sext i32 %153 to i64
  %155 = call i64 @llvm.expect.i64(i64 %154, i64 0)
  %156 = icmp ne i64 %155, 0
  br i1 %156, label %157, label %159

157:                                              ; preds = %145
  %158 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %158, ptr noundef @.str.16, ptr noundef @__func__.env_open, i32 noundef 373) #11
  unreachable

159:                                              ; preds = %145
  br label %160

160:                                              ; preds = %159
  br label %161

161:                                              ; preds = %160
  br label %162

162:                                              ; preds = %161, %133
  br label %163

163:                                              ; preds = %162
  br label %164

164:                                              ; preds = %163
  %165 = load ptr, ptr %4, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.MDBX_env, ptr %165, i32 0, i32 1
  %167 = load i32, ptr %166, align 4, !tbaa !23
  %168 = and i32 %167, 1245184
  %169 = icmp ne i32 %168, 0
  br i1 %169, label %217, label %170

170:                                              ; preds = %164
  %171 = load ptr, ptr %4, align 8, !tbaa !5
  %172 = load ptr, ptr %4, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.MDBX_env, ptr %172, i32 0, i32 22
  %174 = getelementptr inbounds %struct.anon, ptr %173, i32 0, i32 1
  %175 = load ptr, ptr %174, align 8, !tbaa !24
  %176 = load ptr, ptr %4, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.MDBX_env, ptr %176, i32 0, i32 4
  %178 = call i32 @osal_openfile(i32 noundef 2, ptr noundef %171, ptr noundef %175, ptr noundef %177, i32 noundef 0)
  store i32 %178, ptr %6, align 4, !tbaa !9
  %179 = load i32, ptr %6, align 4, !tbaa !9
  %180 = icmp ne i32 %179, -1
  br i1 %180, label %181, label %184

181:                                              ; preds = %170
  %182 = load i32, ptr %6, align 4, !tbaa !9
  %183 = icmp ne i32 %182, 0
  br label %184

184:                                              ; preds = %181, %170
  %185 = phi i1 [ false, %170 ], [ %183, %181 ]
  %186 = xor i1 %185, true
  %187 = xor i1 %186, true
  %188 = zext i1 %187 to i32
  %189 = sext i32 %188 to i64
  %190 = call i64 @llvm.expect.i64(i64 %189, i64 0)
  %191 = icmp ne i64 %190, 0
  br i1 %191, label %192, label %194

192:                                              ; preds = %184
  %193 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %193, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %547

194:                                              ; preds = %184
  %195 = load ptr, ptr %4, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.MDBX_env, ptr %195, i32 0, i32 4
  %197 = load i32, ptr %196, align 8, !tbaa !34
  %198 = icmp ne i32 %197, -1
  br i1 %198, label %199, label %216

199:                                              ; preds = %194
  %200 = load ptr, ptr %4, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct.MDBX_env, ptr %200, i32 0, i32 1
  %202 = load i32, ptr %201, align 4, !tbaa !23
  %203 = and i32 %202, 262144
  %204 = icmp eq i32 %203, 0
  br i1 %204, label %205, label %211

205:                                              ; preds = %199
  %206 = load ptr, ptr %4, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.MDBX_env, ptr %206, i32 0, i32 4
  %208 = load i32, ptr %207, align 8, !tbaa !34
  %209 = load ptr, ptr %4, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.MDBX_env, ptr %209, i32 0, i32 5
  store i32 %208, ptr %210, align 4, !tbaa !27
  br label %211

211:                                              ; preds = %205, %199
  %212 = load ptr, ptr %4, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct.MDBX_env, ptr %212, i32 0, i32 4
  %214 = load i32, ptr %213, align 8, !tbaa !34
  %215 = call i32 @osal_fseek(i32 noundef %214, i64 noundef 9223372034707292160)
  br label %216

216:                                              ; preds = %211, %194
  br label %217

217:                                              ; preds = %216, %164
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  store i32 1376256, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  store i32 77529088, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #9
  %218 = load ptr, ptr %4, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.MDBX_env, ptr %218, i32 0, i32 6
  %220 = getelementptr inbounds %struct.osal_mmap, ptr %219, i32 0, i32 0
  %221 = load ptr, ptr %220, align 8, !tbaa !35
  store ptr %221, ptr %13, align 8, !tbaa !5
  %222 = load ptr, ptr %13, align 8, !tbaa !5
  %223 = icmp ne ptr %222, null
  br i1 %223, label %224, label %334

224:                                              ; preds = %217
  %225 = load i32, ptr %10, align 4, !tbaa !9
  %226 = icmp ne i32 %225, -1
  br i1 %226, label %227, label %334

227:                                              ; preds = %224
  %228 = load ptr, ptr %4, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.MDBX_env, ptr %228, i32 0, i32 1
  %230 = load i32, ptr %229, align 4, !tbaa !23
  %231 = and i32 %230, 131072
  %232 = icmp eq i32 %231, 0
  br i1 %232, label %233, label %334

233:                                              ; preds = %227
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  br label %234

234:                                              ; preds = %248, %233
  %235 = load ptr, ptr %13, align 8, !tbaa !5
  %236 = getelementptr inbounds %struct.shared_lck, ptr %235, i32 0, i32 2
  %237 = call i32 @atomic_load32(ptr noundef %236, i32 noundef 1)
  store i32 %237, ptr %14, align 4, !tbaa !9
  %238 = icmp eq i32 %237, 131072
  br i1 %238, label %239, label %249

239:                                              ; preds = %234
  %240 = load ptr, ptr %13, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.shared_lck, ptr %240, i32 0, i32 2
  %242 = load ptr, ptr %4, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.MDBX_env, ptr %242, i32 0, i32 1
  %244 = load i32, ptr %243, align 4, !tbaa !23
  %245 = and i32 %244, 77529088
  store i32 %245, ptr %14, align 4, !tbaa !9
  %246 = call zeroext i1 @atomic_cas32(ptr noundef %241, i32 noundef 131072, i32 noundef %245)
  br i1 %246, label %247, label %248

247:                                              ; preds = %239
  br label %249

248:                                              ; preds = %239
  call void @atomic_yield()
  br label %234, !llvm.loop !36

249:                                              ; preds = %247, %234
  %250 = load ptr, ptr %4, align 8, !tbaa !5
  %251 = getelementptr inbounds %struct.MDBX_env, ptr %250, i32 0, i32 1
  %252 = load i32, ptr %251, align 4, !tbaa !23
  %253 = and i32 %252, 1073741824
  %254 = icmp ne i32 %253, 0
  br i1 %254, label %255, label %295

255:                                              ; preds = %249
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  %256 = load i32, ptr %14, align 4, !tbaa !9
  %257 = load ptr, ptr %4, align 8, !tbaa !5
  %258 = getelementptr inbounds %struct.MDBX_env, ptr %257, i32 0, i32 1
  %259 = load i32, ptr %258, align 4, !tbaa !23
  %260 = xor i32 %256, %259
  %261 = load i32, ptr %14, align 4, !tbaa !9
  %262 = and i32 %261, 1376256
  %263 = icmp ne i32 %262, 0
  %264 = zext i1 %263 to i64
  %265 = select i1 %263, i32 77529088, i32 77004800
  %266 = and i32 %260, %265
  store i32 %266, ptr %15, align 4, !tbaa !9
  %267 = load i32, ptr %15, align 4, !tbaa !9
  %268 = load ptr, ptr %4, align 8, !tbaa !5
  %269 = getelementptr inbounds %struct.MDBX_env, ptr %268, i32 0, i32 1
  %270 = load i32, ptr %269, align 4, !tbaa !23
  %271 = xor i32 %270, %267
  store i32 %271, ptr %269, align 4, !tbaa !23
  br label %272

272:                                              ; preds = %255
  %273 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !38
  %274 = zext i8 %273 to i32
  %275 = icmp sle i32 3, %274
  %276 = xor i1 %275, true
  %277 = xor i1 %276, true
  %278 = zext i1 %277 to i32
  %279 = sext i32 %278 to i64
  %280 = call i64 @llvm.expect.i64(i64 %279, i64 0)
  %281 = icmp ne i64 %280, 0
  br i1 %281, label %282, label %292

282:                                              ; preds = %272
  %283 = load i32, ptr %15, align 4, !tbaa !9
  %284 = load ptr, ptr %4, align 8, !tbaa !5
  %285 = getelementptr inbounds %struct.MDBX_env, ptr %284, i32 0, i32 1
  %286 = load i32, ptr %285, align 4, !tbaa !23
  %287 = load i32, ptr %15, align 4, !tbaa !9
  %288 = xor i32 %286, %287
  %289 = load ptr, ptr %4, align 8, !tbaa !5
  %290 = getelementptr inbounds %struct.MDBX_env, ptr %289, i32 0, i32 1
  %291 = load i32, ptr %290, align 4, !tbaa !23
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef @__func__.env_open, i32 noundef 418, ptr noundef @.str.17, i32 noundef %283, i32 noundef %288, i32 noundef %291)
  br label %292

292:                                              ; preds = %282, %272
  br label %293

293:                                              ; preds = %292
  br label %294

294:                                              ; preds = %293
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  br label %295

295:                                              ; preds = %294, %249
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  %296 = load i32, ptr %14, align 4, !tbaa !9
  %297 = and i32 %296, 1376256
  %298 = icmp ne i32 %297, 0
  %299 = zext i1 %298 to i64
  %300 = select i1 %298, i32 1638400, i32 1114112
  store i32 %300, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  %301 = load i32, ptr %14, align 4, !tbaa !9
  %302 = load ptr, ptr %4, align 8, !tbaa !5
  %303 = getelementptr inbounds %struct.MDBX_env, ptr %302, i32 0, i32 1
  %304 = load i32, ptr %303, align 4, !tbaa !23
  %305 = xor i32 %301, %304
  %306 = load i32, ptr %16, align 4, !tbaa !9
  %307 = and i32 %305, %306
  store i32 %307, ptr %17, align 4, !tbaa !9
  %308 = load i32, ptr %17, align 4, !tbaa !9
  %309 = icmp ne i32 %308, 0
  br i1 %309, label %310, label %330

310:                                              ; preds = %295
  br label %311

311:                                              ; preds = %310
  %312 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !38
  %313 = zext i8 %312 to i32
  %314 = icmp sle i32 1, %313
  %315 = xor i1 %314, true
  %316 = xor i1 %315, true
  %317 = zext i1 %316 to i32
  %318 = sext i32 %317 to i64
  %319 = call i64 @llvm.expect.i64(i64 %318, i64 0)
  %320 = icmp ne i64 %319, 0
  br i1 %320, label %321, label %327

321:                                              ; preds = %311
  %322 = load ptr, ptr %4, align 8, !tbaa !5
  %323 = getelementptr inbounds %struct.MDBX_env, ptr %322, i32 0, i32 1
  %324 = load i32, ptr %323, align 4, !tbaa !23
  %325 = load i32, ptr %14, align 4, !tbaa !9
  %326 = load i32, ptr %17, align 4, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.env_open, i32 noundef 447, ptr noundef @.str.18, i32 noundef %324, i32 noundef %325, i32 noundef %326)
  br label %327

327:                                              ; preds = %321, %311
  br label %328

328:                                              ; preds = %327
  br label %329

329:                                              ; preds = %328
  store i32 -30784, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %331

330:                                              ; preds = %295
  store i32 0, ptr %7, align 4
  br label %331

331:                                              ; preds = %330, %329
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  %332 = load i32, ptr %7, align 4
  switch i32 %332, label %546 [
    i32 0, label %333
  ]

333:                                              ; preds = %331
  br label %334

334:                                              ; preds = %333, %227, %224, %217
  %335 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mincore_clean_cache(ptr noundef %335)
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #9
  %336 = load ptr, ptr %4, align 8, !tbaa !5
  %337 = load i32, ptr %10, align 4, !tbaa !9
  %338 = load i32, ptr %5, align 4, !tbaa !9
  %339 = call i32 @dxb_setup(ptr noundef %336, i32 noundef %337, i32 noundef %338)
  store i32 %339, ptr %18, align 4, !tbaa !9
  %340 = load i32, ptr %18, align 4, !tbaa !9
  %341 = icmp ne i32 %340, -1
  br i1 %341, label %342, label %347

342:                                              ; preds = %334
  %343 = load i32, ptr %18, align 4, !tbaa !9
  %344 = icmp ne i32 %343, 0
  br i1 %344, label %345, label %347

345:                                              ; preds = %342
  %346 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %346, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %545

347:                                              ; preds = %342, %334
  %348 = load ptr, ptr %4, align 8, !tbaa !5
  %349 = getelementptr inbounds %struct.MDBX_env, ptr %348, i32 0, i32 3
  %350 = getelementptr inbounds %struct.osal_mmap, ptr %349, i32 0, i32 1
  %351 = load i32, ptr %350, align 8, !tbaa !26
  %352 = call i32 @osal_check_fs_incore(i32 noundef %351)
  store i32 %352, ptr %6, align 4, !tbaa !9
  %353 = load ptr, ptr %4, align 8, !tbaa !5
  %354 = getelementptr inbounds %struct.MDBX_env, ptr %353, i32 0, i32 36
  store i8 0, ptr %354, align 8, !tbaa !39
  %355 = load i32, ptr %6, align 4, !tbaa !9
  %356 = icmp eq i32 %355, -1
  br i1 %356, label %357, label %374

357:                                              ; preds = %347
  %358 = load ptr, ptr %4, align 8, !tbaa !5
  %359 = getelementptr inbounds %struct.MDBX_env, ptr %358, i32 0, i32 36
  store i8 1, ptr %359, align 8, !tbaa !39
  br label %360

360:                                              ; preds = %357
  %361 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !38
  %362 = zext i8 %361 to i32
  %363 = icmp sle i32 3, %362
  %364 = xor i1 %363, true
  %365 = xor i1 %364, true
  %366 = zext i1 %365 to i32
  %367 = sext i32 %366 to i64
  %368 = call i64 @llvm.expect.i64(i64 %367, i64 0)
  %369 = icmp ne i64 %368, 0
  br i1 %369, label %370, label %371

370:                                              ; preds = %360
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef @__func__.env_open, i32 noundef 461, ptr noundef @.str.19, ptr noundef @.str.20)
  br label %371

371:                                              ; preds = %370, %360
  br label %372

372:                                              ; preds = %371
  br label %373

373:                                              ; preds = %372
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %401

374:                                              ; preds = %347
  %375 = load i32, ptr %6, align 4, !tbaa !9
  %376 = icmp ne i32 %375, 0
  %377 = xor i1 %376, true
  %378 = xor i1 %377, true
  %379 = zext i1 %378 to i32
  %380 = sext i32 %379 to i64
  %381 = call i64 @llvm.expect.i64(i64 %380, i64 0)
  %382 = icmp ne i64 %381, 0
  br i1 %382, label %383, label %400

383:                                              ; preds = %374
  br label %384

384:                                              ; preds = %383
  %385 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !38
  %386 = zext i8 %385 to i32
  %387 = icmp sle i32 1, %386
  %388 = xor i1 %387, true
  %389 = xor i1 %388, true
  %390 = zext i1 %389 to i32
  %391 = sext i32 %390 to i64
  %392 = call i64 @llvm.expect.i64(i64 %391, i64 0)
  %393 = icmp ne i64 %392, 0
  br i1 %393, label %394, label %396

394:                                              ; preds = %384
  %395 = load i32, ptr %6, align 4, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.env_open, i32 noundef 464, ptr noundef @.str.21, i32 noundef %395)
  br label %396

396:                                              ; preds = %394, %384
  br label %397

397:                                              ; preds = %396
  br label %398

398:                                              ; preds = %397
  %399 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %399, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %545

400:                                              ; preds = %374
  br label %401

401:                                              ; preds = %400, %373
  %402 = load ptr, ptr %4, align 8, !tbaa !5
  %403 = getelementptr inbounds %struct.MDBX_env, ptr %402, i32 0, i32 16
  %404 = load i8, ptr %403, align 1, !tbaa !40
  %405 = sext i8 %404 to i32
  %406 = icmp sge i32 %405, 0
  %407 = xor i1 %406, true
  %408 = xor i1 %407, true
  %409 = zext i1 %408 to i32
  %410 = sext i32 %409 to i64
  %411 = call i64 @llvm.expect.i64(i64 %410, i64 0)
  %412 = icmp ne i64 %411, 0
  br i1 %412, label %413, label %437

413:                                              ; preds = %401
  %414 = load i32, ptr %10, align 4, !tbaa !9
  %415 = icmp ne i32 %414, -1
  br i1 %415, label %422, label %416

416:                                              ; preds = %413
  %417 = load ptr, ptr %4, align 8, !tbaa !5
  %418 = getelementptr inbounds %struct.MDBX_env, ptr %417, i32 0, i32 1
  %419 = load i32, ptr %418, align 4, !tbaa !23
  %420 = and i32 %419, 4194304
  %421 = icmp eq i32 %420, 0
  br i1 %421, label %422, label %437

422:                                              ; preds = %416, %413
  br label %423

423:                                              ; preds = %422
  %424 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !38
  %425 = zext i8 %424 to i32
  %426 = icmp sle i32 1, %425
  %427 = xor i1 %426, true
  %428 = xor i1 %427, true
  %429 = zext i1 %428 to i32
  %430 = sext i32 %429 to i64
  %431 = call i64 @llvm.expect.i64(i64 %430, i64 0)
  %432 = icmp ne i64 %431, 0
  br i1 %432, label %433, label %434

433:                                              ; preds = %423
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.env_open, i32 noundef 470, ptr noundef @.str.19, ptr noundef @.str.22)
  br label %434

434:                                              ; preds = %433, %423
  br label %435

435:                                              ; preds = %434
  br label %436

436:                                              ; preds = %435
  store i32 -30778, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %545

437:                                              ; preds = %416, %401
  br label %438

438:                                              ; preds = %437
  %439 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !38
  %440 = zext i8 %439 to i32
  %441 = icmp sle i32 5, %440
  %442 = xor i1 %441, true
  %443 = xor i1 %442, true
  %444 = zext i1 %443 to i32
  %445 = sext i32 %444 to i64
  %446 = call i64 @llvm.expect.i64(i64 %445, i64 0)
  %447 = icmp ne i64 %446, 0
  br i1 %447, label %448, label %450

448:                                              ; preds = %438
  %449 = load ptr, ptr %4, align 8, !tbaa !5
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.env_open, i32 noundef 474, ptr noundef @.str.23, ptr noundef %449)
  br label %450

450:                                              ; preds = %448, %438
  br label %451

451:                                              ; preds = %450
  br label %452

452:                                              ; preds = %451
  %453 = load ptr, ptr %4, align 8, !tbaa !5
  %454 = getelementptr inbounds %struct.MDBX_env, ptr %453, i32 0, i32 1
  %455 = load i32, ptr %454, align 4, !tbaa !23
  %456 = or i32 %455, 536870912
  store i32 %456, ptr %454, align 4, !tbaa !23
  %457 = load ptr, ptr %13, align 8, !tbaa !5
  %458 = icmp ne ptr %457, null
  br i1 %458, label %459, label %462

459:                                              ; preds = %452
  %460 = load i32, ptr %10, align 4, !tbaa !9
  %461 = icmp eq i32 %460, -1
  br i1 %461, label %462, label %483

462:                                              ; preds = %459, %452
  %463 = load ptr, ptr %4, align 8, !tbaa !5
  %464 = getelementptr inbounds %struct.MDBX_env, ptr %463, i32 0, i32 1
  %465 = load i32, ptr %464, align 4, !tbaa !23
  %466 = and i32 %465, 77529088
  %467 = load ptr, ptr %4, align 8, !tbaa !5
  %468 = getelementptr inbounds %struct.MDBX_env, ptr %467, i32 0, i32 7
  %469 = load ptr, ptr %468, align 8, !tbaa !41
  %470 = getelementptr inbounds %struct.shared_lck, ptr %469, i32 0, i32 2
  store volatile i32 %466, ptr %470, align 4, !tbaa !35
  %471 = load ptr, ptr %4, align 8, !tbaa !5
  %472 = call i64 @recent_committed_txnid(ptr noundef %471)
  %473 = trunc i64 %472 to i32
  %474 = load ptr, ptr %4, align 8, !tbaa !5
  %475 = getelementptr inbounds %struct.MDBX_env, ptr %474, i32 0, i32 7
  %476 = load ptr, ptr %475, align 8, !tbaa !41
  %477 = getelementptr inbounds %struct.shared_lck, ptr %476, i32 0, i32 4
  store volatile i32 %473, ptr %477, align 4, !tbaa !35
  %478 = call i64 @osal_monotime()
  %479 = load ptr, ptr %4, align 8, !tbaa !5
  %480 = getelementptr inbounds %struct.MDBX_env, ptr %479, i32 0, i32 7
  %481 = load ptr, ptr %480, align 8, !tbaa !41
  %482 = getelementptr inbounds %struct.shared_lck, ptr %481, i32 0, i32 15
  store volatile i64 %478, ptr %482, align 64, !tbaa !35
  br label %483

483:                                              ; preds = %462, %459
  %484 = load ptr, ptr %13, align 8, !tbaa !5
  %485 = icmp ne ptr %484, null
  br i1 %485, label %486, label %531

486:                                              ; preds = %483
  %487 = load i32, ptr %10, align 4, !tbaa !9
  %488 = icmp eq i32 %487, -1
  br i1 %488, label %489, label %519

489:                                              ; preds = %486
  %490 = load ptr, ptr %4, align 8, !tbaa !5
  %491 = call i32 @lck_downgrade(ptr noundef %490)
  store i32 %491, ptr %6, align 4, !tbaa !9
  br label %492

492:                                              ; preds = %489
  %493 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !38
  %494 = zext i8 %493 to i32
  %495 = icmp sle i32 5, %494
  %496 = xor i1 %495, true
  %497 = xor i1 %496, true
  %498 = zext i1 %497 to i32
  %499 = sext i32 %498 to i64
  %500 = call i64 @llvm.expect.i64(i64 %499, i64 0)
  %501 = icmp ne i64 %500, 0
  br i1 %501, label %502, label %511

502:                                              ; preds = %492
  %503 = load ptr, ptr %4, align 8, !tbaa !5
  %504 = getelementptr inbounds %struct.MDBX_env, ptr %503, i32 0, i32 1
  %505 = load i32, ptr %504, align 4, !tbaa !23
  %506 = and i32 %505, 4194304
  %507 = icmp ne i32 %506, 0
  %508 = zext i1 %507 to i64
  %509 = select i1 %507, ptr @.str.25, ptr @.str.26
  %510 = load i32, ptr %6, align 4, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.env_open, i32 noundef 484, ptr noundef @.str.24, ptr noundef %509, i32 noundef %510)
  br label %511

511:                                              ; preds = %502, %492
  br label %512

512:                                              ; preds = %511
  br label %513

513:                                              ; preds = %512
  %514 = load i32, ptr %6, align 4, !tbaa !9
  %515 = icmp ne i32 %514, 0
  br i1 %515, label %516, label %518

516:                                              ; preds = %513
  %517 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %517, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %545

518:                                              ; preds = %513
  br label %530

519:                                              ; preds = %486
  %520 = load ptr, ptr %4, align 8, !tbaa !5
  %521 = call i32 @mvcc_cleanup_dead(ptr noundef %520, i32 noundef 0, ptr noundef null)
  store i32 %521, ptr %6, align 4, !tbaa !9
  %522 = load i32, ptr %6, align 4, !tbaa !9
  %523 = icmp ne i32 %522, -1
  br i1 %523, label %524, label %529

524:                                              ; preds = %519
  %525 = load i32, ptr %6, align 4, !tbaa !9
  %526 = icmp ne i32 %525, 0
  br i1 %526, label %527, label %529

527:                                              ; preds = %524
  %528 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %528, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %545

529:                                              ; preds = %524, %519
  br label %530

530:                                              ; preds = %529, %518
  br label %531

531:                                              ; preds = %530, %483
  %532 = load ptr, ptr %4, align 8, !tbaa !5
  %533 = getelementptr inbounds %struct.MDBX_env, ptr %532, i32 0, i32 1
  %534 = load i32, ptr %533, align 4, !tbaa !23
  %535 = and i32 %534, 131072
  %536 = icmp ne i32 %535, 0
  br i1 %536, label %537, label %538

537:                                              ; preds = %531
  br label %542

538:                                              ; preds = %531
  %539 = load ptr, ptr %4, align 8, !tbaa !5
  %540 = getelementptr inbounds %struct.MDBX_env, ptr %539, i32 0, i32 45
  %541 = call i32 @osal_ioring_create(ptr noundef %540)
  br label %542

542:                                              ; preds = %538, %537
  %543 = phi i32 [ 0, %537 ], [ %541, %538 ]
  store i32 %543, ptr %6, align 4, !tbaa !9
  %544 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %544, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %545

545:                                              ; preds = %542, %527, %516, %436, %398, %345
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  br label %546

546:                                              ; preds = %545, %331
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  br label %547

547:                                              ; preds = %546, %192, %118
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #9
  br label %548

548:                                              ; preds = %547, %82
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #9
  br label %549

549:                                              ; preds = %548, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  %550 = load i32, ptr %3, align 4
  ret i32 %550
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @osal_getpid() #6

declare i32 @osal_openfile(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #4

declare i32 @osal_fseek(i32 noundef, i64 noundef) #4

; Function Attrs: nounwind
declare i32 @fstat64(i32 noundef, ptr noundef) #7

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #8

declare i32 @lck_setup(ptr noundef, i32 noundef) #4

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @atomic_cas32(ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @atomic_yield() #3

declare void @mincore_clean_cache(ptr noundef) #4

declare i32 @dxb_setup(ptr noundef, i32 noundef, i32 noundef) #4

declare i32 @osal_check_fs_incore(i32 noundef) #4

declare i32 @lck_downgrade(ptr noundef) #4

declare i32 @mvcc_cleanup_dead(ptr noundef, i32 noundef, ptr noundef) #4

declare i32 @osal_ioring_create(ptr noundef) #4

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

!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 140}
!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 4}
!24 = !{!12, !6, i64 160}
!25 = !{!14, !14, i64 0}
!26 = !{!12, !10, i64 24}
!27 = !{!12, !10, i64 60}
!28 = !{!29, !10, i64 24}
!29 = !{!"stat", !14, i64 0, !14, i64 8, !14, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !30, i64 72, !30, i64 88, !30, i64 104, !7, i64 120}
!30 = !{!"timespec", !14, i64 0, !14, i64 8}
!31 = !{!12, !10, i64 72}
!32 = !{!33, !7, i64 25}
!33 = !{!"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}
!34 = !{!12, !10, i64 56}
!35 = !{!7, !7, i64 0}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!33, !7, i64 26}
!39 = !{!12, !18, i64 360}
!40 = !{!12, !7, i64 129}
!41 = !{!12, !6, i64 104}


; 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 }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.16 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.env_open = external hidden unnamed_addr constant [9 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

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

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

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

declare i64 @osal_monotime() local_unnamed_addr #3

declare i64 @recent_committed_txnid(ptr noundef) local_unnamed_addr #3

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @env_open(ptr noundef %0, i32 noundef %1) local_unnamed_addr #4 {
  %3 = alloca %struct.stat, align 8
  %4 = tail call i32 @osal_getpid()
  %5 = getelementptr inbounds i8, ptr %0, i64 140
  store i32 %4, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !21
  %8 = lshr i32 %7, 17
  %.lobit = and i32 %8, 1
  %9 = xor i32 %.lobit, 1
  %10 = getelementptr inbounds i8, ptr %0, i64 160
  %11 = load ptr, ptr %10, align 8, !tbaa !22
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = tail call i32 @osal_openfile(i32 noundef %9, ptr noundef %0, ptr noundef %11, ptr noundef nonnull %12, i32 noundef %1) #8
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %14, label %.thread152, !prof !23

14:                                               ; preds = %2
  %15 = load i32, ptr %12, align 8, !tbaa !24
  %16 = tail call i32 @osal_fseek(i32 noundef %15, i64 noundef 9223372034707292160) #8
  %17 = load i32, ptr %12, align 8, !tbaa !24
  %18 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 %17, ptr %18, align 4, !tbaa !25
  %19 = icmp eq i32 %1, 0
  br i1 %19, label %20, label %27

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %3) #8
  %21 = call i32 @fstat64(i32 noundef %17, ptr noundef nonnull %3) #8
  %.not131 = icmp eq i32 %21, 0
  br i1 %.not131, label %.thread, label %24, !prof !23

.thread:                                          ; preds = %20
  %22 = getelementptr inbounds i8, ptr %3, i64 24
  %23 = load i32, ptr %22, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %3) #8
  br label %27

24:                                               ; preds = %20
  %25 = tail call ptr @__errno_location() #9
  %26 = load i32, ptr %25, align 4, !tbaa !29
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %3) #8
  br label %.thread152

27:                                               ; preds = %.thread, %14
  %.1113 = phi i32 [ %1, %14 ], [ %23, %.thread ]
  %28 = and i32 %.1113, 54
  %29 = lshr i32 %.1113, 1
  %30 = and i32 %29, 18
  %31 = or i32 %28, %30
  %32 = or disjoint i32 %31, 384
  %33 = tail call i32 @lck_setup(ptr noundef nonnull %0, i32 noundef %32) #8
  %34 = icmp ne i32 %33, -1
  %35 = add i32 %33, -1
  %36 = icmp ult i32 %35, -2
  br i1 %36, label %.thread152, label %37, !prof !30

37:                                               ; preds = %27
  %38 = getelementptr inbounds i8, ptr %0, i64 64
  %39 = getelementptr inbounds i8, ptr %0, i64 72
  %40 = load i32, ptr %39, align 8, !tbaa !31
  %.not134 = icmp eq i32 %40, -1
  br i1 %.not134, label %43, label %41

41:                                               ; preds = %37
  %42 = tail call i32 @osal_fseek(i32 noundef %40, i64 noundef 9223372034707292160) #8
  br label %43

43:                                               ; preds = %37, %41
  %44 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !32
  %45 = and i8 %44, 1
  %.not135 = icmp eq i8 %45, 0
  br i1 %.not135, label %50, label %46, !prof !30

46:                                               ; preds = %43
  %47 = getelementptr inbounds i8, ptr %0, i64 56
  %48 = load i32, ptr %47, align 8, !tbaa !34
  %.not136 = icmp eq i32 %48, -1
  br i1 %.not136, label %50, label %49, !prof !23

49:                                               ; preds = %46
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.16, ptr noundef nonnull @__func__.env_open, i32 noundef 373) #10
  unreachable

50:                                               ; preds = %46, %43
  %51 = load i32, ptr %6, align 4, !tbaa !21
  %52 = and i32 %51, 1245184
  %.not137 = icmp eq i32 %52, 0
  br i1 %.not137, label %53, label %68

53:                                               ; preds = %50
  %54 = load ptr, ptr %10, align 8, !tbaa !22
  %55 = getelementptr inbounds i8, ptr %0, i64 56
  %56 = tail call i32 @osal_openfile(i32 noundef 2, ptr noundef nonnull %0, ptr noundef %54, ptr noundef nonnull %55, i32 noundef 0) #8
  %57 = add i32 %56, -1
  %58 = icmp ult i32 %57, -2
  br i1 %58, label %.thread152, label %59, !prof !30

59:                                               ; preds = %53
  %60 = load i32, ptr %55, align 8, !tbaa !34
  %.not138 = icmp eq i32 %60, -1
  br i1 %.not138, label %68, label %61

61:                                               ; preds = %59
  %62 = load i32, ptr %6, align 4, !tbaa !21
  %63 = and i32 %62, 262144
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %61
  store i32 %60, ptr %18, align 4, !tbaa !25
  br label %66

66:                                               ; preds = %65, %61
  %67 = tail call i32 @osal_fseek(i32 noundef %60, i64 noundef 9223372034707292160) #8
  br label %68

68:                                               ; preds = %59, %66, %50
  %69 = load ptr, ptr %38, align 8, !tbaa !35
  %70 = icmp ne ptr %69, null
  %or.cond = and i1 %34, %70
  br i1 %or.cond, label %71, label %103

71:                                               ; preds = %68
  %72 = load i32, ptr %6, align 4, !tbaa !21
  %73 = and i32 %72, 131072
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %.preheader, label %103

.preheader:                                       ; preds = %71
  %75 = getelementptr inbounds i8, ptr %69, i64 12
  %76 = tail call i32 @atomic_load32(ptr noundef nonnull %75, i32 noundef 1)
  %77 = icmp eq i32 %76, 131072
  br i1 %77, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %81
  %78 = load i32, ptr %6, align 4, !tbaa !21
  %79 = and i32 %78, 77529088
  %80 = tail call zeroext i1 @atomic_cas32(ptr noundef nonnull %75, i32 noundef 131072, i32 noundef %79)
  br i1 %80, label %._crit_edge, label %81

81:                                               ; preds = %.lr.ph
  tail call void @atomic_yield()
  %82 = tail call i32 @atomic_load32(ptr noundef nonnull %75, i32 noundef 1)
  %83 = icmp eq i32 %82, 131072
  br i1 %83, label %.lr.ph, label %._crit_edge, !llvm.loop !36

._crit_edge:                                      ; preds = %81, %.lr.ph, %.preheader
  %.0116 = phi i32 [ %76, %.preheader ], [ %79, %.lr.ph ], [ %82, %81 ]
  %84 = load i32, ptr %6, align 4, !tbaa !21
  %85 = and i32 %84, 1073741824
  %.not139 = icmp eq i32 %85, 0
  br i1 %.not139, label %._crit_edge._crit_edge, label %86

._crit_edge._crit_edge:                           ; preds = %._crit_edge
  %.pre158 = and i32 %.0116, 1376256
  br label %95

86:                                               ; preds = %._crit_edge
  %87 = xor i32 %84, %.0116
  %88 = and i32 %.0116, 1376256
  %.not140 = icmp eq i32 %88, 0
  %89 = select i1 %.not140, i32 77004800, i32 77529088
  %90 = and i32 %89, %87
  %91 = xor i32 %90, %84
  store i32 %91, ptr %6, align 4, !tbaa !21
  %92 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !38
  %93 = icmp ugt i8 %92, 2
  br i1 %93, label %94, label %95, !prof !30

94:                                               ; preds = %86
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef nonnull @__func__.env_open, i32 noundef 418, ptr noundef nonnull @.str.17, i32 noundef %90, i32 noundef %84, i32 noundef %91) #8
  %.pre = load i32, ptr %6, align 4, !tbaa !21
  br label %95

95:                                               ; preds = %._crit_edge._crit_edge, %86, %94
  %.pre-phi = phi i32 [ %.pre158, %._crit_edge._crit_edge ], [ %88, %86 ], [ %88, %94 ]
  %96 = phi i32 [ %84, %._crit_edge._crit_edge ], [ %91, %86 ], [ %.pre, %94 ]
  %.not141 = icmp eq i32 %.pre-phi, 0
  %97 = select i1 %.not141, i32 1114112, i32 1638400
  %98 = xor i32 %96, %.0116
  %99 = and i32 %98, %97
  %.not142 = icmp eq i32 %99, 0
  br i1 %.not142, label %103, label %100

100:                                              ; preds = %95
  %101 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !38
  %.not143 = icmp eq i8 %101, 0
  br i1 %.not143, label %.thread152, label %102, !prof !23

102:                                              ; preds = %100
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.env_open, i32 noundef 447, ptr noundef nonnull @.str.18, i32 noundef %96, i32 noundef %.0116, i32 noundef %99) #8
  br label %.thread152

103:                                              ; preds = %95, %71, %68
  tail call void @mincore_clean_cache(ptr noundef nonnull %0) #8
  %104 = tail call i32 @dxb_setup(ptr noundef nonnull %0, i32 noundef %33, i32 noundef %32) #8
  %105 = add i32 %104, -1
  %or.cond4 = icmp ult i32 %105, -2
  br i1 %or.cond4, label %.thread152, label %106

106:                                              ; preds = %103
  %107 = load i32, ptr %12, align 8, !tbaa !24
  %108 = tail call i32 @osal_check_fs_incore(i32 noundef %107) #8
  %109 = getelementptr inbounds i8, ptr %0, i64 360
  store i8 0, ptr %109, align 8, !tbaa !39
  switch i32 %108, label %114 [
    i32 -1, label %110
    i32 0, label %117
  ], !prof !40

110:                                              ; preds = %106
  store i8 1, ptr %109, align 8, !tbaa !39
  %111 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !38
  %112 = icmp ugt i8 %111, 2
  br i1 %112, label %113, label %117, !prof !30

113:                                              ; preds = %110
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef nonnull @__func__.env_open, i32 noundef 461, ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.20) #8
  br label %117

114:                                              ; preds = %106
  %115 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !38
  %.not145 = icmp eq i8 %115, 0
  br i1 %.not145, label %.thread152, label %116, !prof !23

116:                                              ; preds = %114
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.env_open, i32 noundef 464, ptr noundef nonnull @.str.21, i32 noundef %108) #8
  br label %.thread152

117:                                              ; preds = %106, %110, %113
  %118 = getelementptr inbounds i8, ptr %0, i64 129
  %119 = load i8, ptr %118, align 1, !tbaa !41
  %120 = icmp sgt i8 %119, -1
  br i1 %120, label %121, label %129, !prof !30

121:                                              ; preds = %117
  br i1 %34, label %126, label %122

122:                                              ; preds = %121
  %123 = load i32, ptr %6, align 4, !tbaa !21
  %124 = and i32 %123, 4194304
  %125 = icmp eq i32 %124, 0
  br i1 %125, label %126, label %129

126:                                              ; preds = %121, %122
  %127 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !38
  %.not149 = icmp eq i8 %127, 0
  br i1 %.not149, label %.thread152, label %128, !prof !23

128:                                              ; preds = %126
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.env_open, i32 noundef 470, ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.22) #8
  br label %.thread152

129:                                              ; preds = %117, %122
  %130 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !38
  %131 = icmp ugt i8 %130, 4
  br i1 %131, label %132, label %133, !prof !30

132:                                              ; preds = %129
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.env_open, i32 noundef 474, ptr noundef nonnull @.str.23, ptr noundef nonnull %0) #8
  br label %133

133:                                              ; preds = %132, %129
  %134 = load i32, ptr %6, align 4, !tbaa !21
  %135 = or i32 %134, 536870912
  store i32 %135, ptr %6, align 4, !tbaa !21
  %136 = icmp eq ptr %69, null
  %137 = icmp eq i32 %33, -1
  %or.cond6 = or i1 %137, %136
  br i1 %or.cond6, label %138, label %.thread155

138:                                              ; preds = %133
  %139 = and i32 %134, 77529088
  %140 = getelementptr inbounds i8, ptr %0, i64 104
  %141 = load ptr, ptr %140, align 8, !tbaa !42
  %142 = getelementptr inbounds i8, ptr %141, i64 12
  store volatile i32 %139, ptr %142, align 4, !tbaa !35
  %143 = tail call i64 @recent_committed_txnid(ptr noundef nonnull %0) #8
  %144 = trunc i64 %143 to i32
  %145 = load ptr, ptr %140, align 8, !tbaa !42
  %146 = getelementptr inbounds i8, ptr %145, i64 20
  store volatile i32 %144, ptr %146, align 4, !tbaa !35
  %147 = tail call i64 @osal_monotime() #8
  %148 = load ptr, ptr %140, align 8, !tbaa !42
  %149 = getelementptr inbounds i8, ptr %148, i64 384
  store volatile i64 %147, ptr %149, align 64, !tbaa !35
  br i1 %70, label %150, label %162

150:                                              ; preds = %138
  br i1 %137, label %151, label %.thread155

151:                                              ; preds = %150
  %152 = tail call i32 @lck_downgrade(ptr noundef nonnull %0) #8
  %153 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !38
  %154 = icmp ugt i8 %153, 4
  br i1 %154, label %155, label %159, !prof !30

155:                                              ; preds = %151
  %156 = load i32, ptr %6, align 4, !tbaa !21
  %157 = and i32 %156, 4194304
  %.not146 = icmp eq i32 %157, 0
  %158 = select i1 %.not146, ptr @.str.26, ptr @.str.25
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.env_open, i32 noundef 484, ptr noundef nonnull @.str.24, ptr noundef nonnull %158, i32 noundef %152) #8
  br label %159

159:                                              ; preds = %155, %151
  %.not147 = icmp eq i32 %152, 0
  br i1 %.not147, label %162, label %.thread152

.thread155:                                       ; preds = %133, %150
  %160 = tail call i32 @mvcc_cleanup_dead(ptr noundef nonnull %0, i32 noundef 0, ptr noundef null) #8
  %161 = add i32 %160, -1
  %or.cond8 = icmp ult i32 %161, -2
  br i1 %or.cond8, label %.thread152, label %162

162:                                              ; preds = %159, %.thread155, %138
  %163 = load i32, ptr %6, align 4, !tbaa !21
  %164 = and i32 %163, 131072
  %.not148 = icmp eq i32 %164, 0
  br i1 %.not148, label %165, label %.thread152

165:                                              ; preds = %162
  %166 = getelementptr inbounds i8, ptr %0, i64 456
  %167 = tail call i32 @osal_ioring_create(ptr noundef nonnull %166) #8
  br label %.thread152

.thread152:                                       ; preds = %102, %100, %24, %165, %162, %.thread155, %159, %126, %128, %114, %116, %103, %53, %27, %2
  %.7 = phi i32 [ %13, %2 ], [ %26, %24 ], [ %33, %27 ], [ %56, %53 ], [ %104, %103 ], [ %108, %116 ], [ %108, %114 ], [ -30778, %128 ], [ -30778, %126 ], [ %152, %159 ], [ %160, %.thread155 ], [ %167, %165 ], [ 0, %162 ], [ -30784, %100 ], [ -30784, %102 ]
  ret i32 %.7
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @osal_getpid() local_unnamed_addr #5

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

declare i32 @osal_fseek(i32 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fstat64(i32 noundef, ptr nocapture noundef) local_unnamed_addr #6

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #7

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @atomic_cas32(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @atomic_yield() local_unnamed_addr #2

declare void @mincore_clean_cache(ptr noundef) local_unnamed_addr #3

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

declare i32 @osal_check_fs_incore(i32 noundef) local_unnamed_addr #3

declare i32 @lck_downgrade(ptr noundef) local_unnamed_addr #3

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

declare i32 @osal_ioring_create(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { 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 #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 = { nofree nounwind "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 = { 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 #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { noreturn nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !9, i64 140}
!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, !9, i64 4}
!22 = !{!6, !12, i64 160}
!23 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!24 = !{!6, !9, i64 24}
!25 = !{!6, !9, i64 60}
!26 = !{!27, !9, i64 24}
!27 = !{!"stat", !11, i64 0, !11, i64 8, !11, i64 16, !9, i64 24, !9, i64 28, !9, i64 32, !9, i64 36, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !28, i64 72, !28, i64 88, !28, i64 104, !7, i64 120}
!28 = !{!"timespec", !11, i64 0, !11, i64 8}
!29 = !{!9, !9, i64 0}
!30 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!31 = !{!6, !9, i64 72}
!32 = !{!33, !7, i64 25}
!33 = !{!"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}
!34 = !{!6, !9, i64 56}
!35 = !{!7, !7, i64 0}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!33, !7, i64 26}
!39 = !{!6, !16, i64 360}
!40 = !{!"branch_weights", i32 1, i32 2001, i32 2000}
!41 = !{!6, !7, i64 129}
!42 = !{!6, !12, i64 104}


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