; LLVM IR from erthink/libmdbx :: src (lck-posix)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon }
%struct.anon = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.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.1, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.2, %struct.anon.6, i8, ptr, ptr, ptr, %struct.anon.7, %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.1 = type { ptr, ptr, ptr, ptr }
%struct.anon.2 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.3, %union.anon.4 }
%struct.anon.3 = type { i16, i16, i16, i16 }
%union.anon.4 = type { i32 }
%struct.anon.6 = type { i64, i64, i64, i64, i64 }
%struct.anon.7 = 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.10, %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.8 }
%struct.anon.8 = 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.9 }
%struct.anon.9 = type { i64, i64, i32 }
%struct.anon.10 = 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 }

@op_setlk = external hidden global i32, align 4
@globals = external global %struct.libmdbx_globals, align 8
@.str.15 = external hidden unnamed_addr constant [29 x i8], align 1
@__func__.lck_destroy = external hidden unnamed_addr constant [12 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [38 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @lck_op(i32 noundef, i32 noundef, i32 noundef, i64 noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @lck_rpid_set(ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @lck_ipclock_destroy(ptr noundef) #1

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

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

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

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @lck_destroy(ptr noundef %0, ptr noundef %1, i32 noundef %2) #6 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.stat, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  br label %11

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

22:                                               ; preds = %11
  br label %23

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

34:                                               ; preds = %23
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %35, ptr noundef @.str.15, ptr noundef @__func__.lck_destroy, i32 noundef 430) #9
  unreachable

36:                                               ; preds = %23
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37, %11
  br label %39

39:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #10
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 144, ptr %8) #10
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #10
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.MDBX_env, ptr %40, i32 0, i32 7
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  store ptr %42, ptr %9, align 8, !tbaa !5
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %212

45:                                               ; preds = %39
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.MDBX_env, ptr %47, i32 0, i32 6
  %49 = getelementptr inbounds %struct.osal_mmap, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !25
  %51 = icmp eq ptr %46, %50
  br i1 %51, label %52, label %212

52:                                               ; preds = %45
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %212, label %55

55:                                               ; preds = %52
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.MDBX_env, ptr %56, i32 0, i32 6
  %58 = getelementptr inbounds %struct.osal_mmap, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 8, !tbaa !26
  %60 = load i32, ptr @op_setlk, align 4, !tbaa !9
  %61 = call i32 @lck_op(i32 noundef %59, i32 noundef %60, i32 noundef 1, i64 noundef 0, i64 noundef 9223372036853727232)
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %212

63:                                               ; preds = %55
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.MDBX_env, ptr %64, i32 0, i32 6
  %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 %8) #10
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %212

70:                                               ; preds = %63
  %71 = getelementptr inbounds %struct.stat, ptr %8, i32 0, i32 2
  %72 = load i64, ptr %71, align 8, !tbaa !27
  %73 = icmp ugt i64 %72, 0
  br i1 %73, label %74, label %212

74:                                               ; preds = %70
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.MDBX_env, ptr %75, i32 0, i32 3
  %77 = getelementptr inbounds %struct.osal_mmap, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 8, !tbaa !30
  %79 = load i32, ptr @op_setlk, align 4, !tbaa !9
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.MDBX_env, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !31
  %83 = and i32 %82, 131072
  %84 = icmp ne i32 %83, 0
  %85 = zext i1 %84 to i64
  %86 = select i1 %84, i32 0, i32 1
  %87 = call i32 @lck_op(i32 noundef %78, i32 noundef %79, i32 noundef %86, i64 noundef 0, i64 noundef 9223372036853727232)
  %88 = icmp eq i32 %87, 0
  br i1 %88, label %89, label %212

89:                                               ; preds = %74
  br label %90

90:                                               ; preds = %89
  %91 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !32
  %92 = zext i8 %91 to i32
  %93 = icmp sle i32 4, %92
  %94 = xor i1 %93, true
  %95 = xor i1 %94, true
  %96 = zext i1 %95 to i32
  %97 = sext i32 %96 to i64
  %98 = call i64 @llvm.expect.i64(i64 %97, i64 0)
  %99 = icmp ne i64 %98, 0
  br i1 %99, label %100, label %102

100:                                              ; preds = %90
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 4, ptr noundef @__func__.lck_destroy, i32 noundef 441, ptr noundef @.str.16, ptr noundef %101)
  br label %102

102:                                              ; preds = %100, %90
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  br label %105

105:                                              ; preds = %104
  %106 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %107 = zext i8 %106 to i32
  %108 = and i32 %107, 1
  %109 = icmp ne i32 %108, 0
  %110 = xor i1 %109, true
  %111 = xor i1 %110, true
  %112 = zext i1 %111 to i32
  %113 = sext i32 %112 to i64
  %114 = call i64 @llvm.expect.i64(i64 %113, i64 1)
  %115 = icmp ne i64 %114, 0
  br i1 %115, label %116, label %135

116:                                              ; preds = %105
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %6, align 4, !tbaa !9
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.MDBX_env, ptr %119, i32 0, i32 20
  %121 = load i32, ptr %120, align 4, !tbaa !33
  %122 = icmp eq i32 %118, %121
  %123 = xor i1 %122, true
  %124 = xor i1 %123, true
  %125 = xor i1 %124, true
  %126 = zext i1 %125 to i32
  %127 = sext i32 %126 to i64
  %128 = call i64 @llvm.expect.i64(i64 %127, i64 0)
  %129 = icmp ne i64 %128, 0
  br i1 %129, label %130, label %132

130:                                              ; preds = %117
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %131, ptr noundef @.str.17, ptr noundef @__func__.lck_destroy, i32 noundef 442) #9
  unreachable

132:                                              ; preds = %117
  br label %133

133:                                              ; preds = %132
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134, %105
  br label %136

136:                                              ; preds = %135
  br label %137

137:                                              ; preds = %136
  %138 = load ptr, ptr %9, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.shared_lck, ptr %138, i32 0, i32 19
  %140 = call i32 @lck_ipclock_destroy(ptr noundef %139)
  store i32 %140, ptr %7, align 4, !tbaa !9
  %141 = load i32, ptr %7, align 4, !tbaa !9
  %142 = icmp eq i32 %141, 0
  br i1 %142, label %143, label %147

143:                                              ; preds = %137
  %144 = load ptr, ptr %9, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.shared_lck, ptr %144, i32 0, i32 11
  %146 = call i32 @lck_ipclock_destroy(ptr noundef %145)
  store i32 %146, ptr %7, align 4, !tbaa !9
  br label %147

147:                                              ; preds = %143, %137
  br label %148

148:                                              ; preds = %147
  %149 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %150 = zext i8 %149 to i32
  %151 = and i32 %150, 1
  %152 = icmp ne i32 %151, 0
  %153 = xor i1 %152, true
  %154 = xor i1 %153, true
  %155 = zext i1 %154 to i32
  %156 = sext i32 %155 to i64
  %157 = call i64 @llvm.expect.i64(i64 %156, i64 1)
  %158 = icmp ne i64 %157, 0
  br i1 %158, label %159, label %175

159:                                              ; preds = %148
  br label %160

160:                                              ; preds = %159
  %161 = load i32, ptr %7, align 4, !tbaa !9
  %162 = icmp eq i32 %161, 0
  %163 = xor i1 %162, true
  %164 = xor i1 %163, true
  %165 = xor i1 %164, true
  %166 = zext i1 %165 to i32
  %167 = sext i32 %166 to i64
  %168 = call i64 @llvm.expect.i64(i64 %167, i64 0)
  %169 = icmp ne i64 %168, 0
  br i1 %169, label %170, label %172

170:                                              ; preds = %160
  %171 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %171, ptr noundef @.str.18, ptr noundef @__func__.lck_destroy, i32 noundef 452) #9
  unreachable

172:                                              ; preds = %160
  br label %173

173:                                              ; preds = %172
  br label %174

174:                                              ; preds = %173
  br label %175

175:                                              ; preds = %174, %148
  br label %176

176:                                              ; preds = %175
  br label %177

177:                                              ; preds = %176
  %178 = load i32, ptr %7, align 4, !tbaa !9
  %179 = icmp eq i32 %178, 0
  br i1 %179, label %180, label %211

180:                                              ; preds = %177
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #10
  %181 = load ptr, ptr %9, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.shared_lck, ptr %181, i32 0, i32 14
  %183 = load volatile i64, ptr %182, align 8, !tbaa !25
  %184 = icmp eq i64 %183, 0
  %185 = zext i1 %184 to i8
  store i8 %185, ptr %10, align 1, !tbaa !34
  %186 = load ptr, ptr %4, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.MDBX_env, ptr %186, i32 0, i32 6
  %188 = call i32 @osal_munmap(ptr noundef %187)
  %189 = load i8, ptr %10, align 1, !tbaa !34, !range !35, !noundef !36
  %190 = trunc i8 %189 to i1
  br i1 %190, label %191, label %210

191:                                              ; preds = %180
  %192 = load ptr, ptr %4, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.MDBX_env, ptr %192, i32 0, i32 6
  %194 = getelementptr inbounds %struct.osal_mmap, ptr %193, i32 0, i32 1
  %195 = load i32, ptr %194, align 8, !tbaa !26
  %196 = icmp ne i32 %195, -1
  br i1 %196, label %197, label %210

197:                                              ; preds = %191
  %198 = load ptr, ptr %4, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.MDBX_env, ptr %198, i32 0, i32 6
  %200 = getelementptr inbounds %struct.osal_mmap, ptr %199, i32 0, i32 1
  %201 = load i32, ptr %200, align 8, !tbaa !26
  %202 = call i32 @ftruncate64(i32 noundef %201, i64 noundef 0) #10
  %203 = icmp ne i32 %202, 0
  br i1 %203, label %204, label %207

204:                                              ; preds = %197
  %205 = call ptr @__errno_location() #11
  %206 = load i32, ptr %205, align 4, !tbaa !9
  br label %208

207:                                              ; preds = %197
  br label %208

208:                                              ; preds = %207, %204
  %209 = phi i32 [ %206, %204 ], [ 0, %207 ]
  store i32 %209, ptr %7, align 4, !tbaa !9
  br label %210

210:                                              ; preds = %208, %191, %180
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #10
  br label %211

211:                                              ; preds = %210, %177
  call void @jitter4testing(i1 noundef zeroext false)
  br label %212

212:                                              ; preds = %211, %74, %70, %63, %55, %52, %45, %39
  %213 = load i32, ptr %6, align 4, !tbaa !9
  %214 = load ptr, ptr %4, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.MDBX_env, ptr %214, i32 0, i32 20
  %216 = load i32, ptr %215, align 4, !tbaa !33
  %217 = icmp ne i32 %213, %216
  br i1 %217, label %218, label %270

218:                                              ; preds = %212
  br label %219

219:                                              ; preds = %218
  %220 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %221 = zext i8 %220 to i32
  %222 = and i32 %221, 1
  %223 = icmp ne i32 %222, 0
  %224 = xor i1 %223, true
  %225 = xor i1 %224, true
  %226 = zext i1 %225 to i32
  %227 = sext i32 %226 to i64
  %228 = call i64 @llvm.expect.i64(i64 %227, i64 1)
  %229 = icmp ne i64 %228, 0
  br i1 %229, label %230, label %247

230:                                              ; preds = %219
  br label %231

231:                                              ; preds = %230
  %232 = load ptr, ptr %5, align 8, !tbaa !5
  %233 = icmp ne ptr %232, null
  %234 = xor i1 %233, true
  %235 = xor i1 %234, true
  %236 = xor i1 %235, true
  %237 = xor i1 %236, true
  %238 = zext i1 %237 to i32
  %239 = sext i32 %238 to i64
  %240 = call i64 @llvm.expect.i64(i64 %239, i64 0)
  %241 = icmp ne i64 %240, 0
  br i1 %241, label %242, label %244

242:                                              ; preds = %231
  %243 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mdbx_assert_fail(ptr noundef %243, ptr noundef @.str.19, ptr noundef @__func__.lck_destroy, i32 noundef 464) #9
  unreachable

244:                                              ; preds = %231
  br label %245

245:                                              ; preds = %244
  br label %246

246:                                              ; preds = %245
  br label %247

247:                                              ; preds = %246, %219
  br label %248

248:                                              ; preds = %247
  br label %249

249:                                              ; preds = %248
  br label %250

250:                                              ; preds = %249
  %251 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !32
  %252 = zext i8 %251 to i32
  %253 = icmp sle i32 3, %252
  %254 = xor i1 %253, true
  %255 = xor i1 %254, true
  %256 = zext i1 %255 to i32
  %257 = sext i32 %256 to i64
  %258 = call i64 @llvm.expect.i64(i64 %257, i64 0)
  %259 = icmp ne i64 %258, 0
  br i1 %259, label %260, label %267

260:                                              ; preds = %250
  %261 = load ptr, ptr %4, align 8, !tbaa !5
  %262 = call ptr @__Wpedantic_format_voidptr(ptr noundef %261)
  %263 = load ptr, ptr %4, align 8, !tbaa !5
  %264 = getelementptr inbounds %struct.MDBX_env, ptr %263, i32 0, i32 20
  %265 = load i32, ptr %264, align 4, !tbaa !33
  %266 = load i32, ptr %6, align 4, !tbaa !9
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef @__func__.lck_destroy, i32 noundef 465, ptr noundef @.str.20, ptr noundef %262, i32 noundef %265, i32 noundef %266)
  br label %267

267:                                              ; preds = %260, %250
  br label %268

268:                                              ; preds = %267
  br label %269

269:                                              ; preds = %268
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %270

270:                                              ; preds = %269, %212
  %271 = load ptr, ptr %4, align 8, !tbaa !5
  %272 = getelementptr inbounds %struct.MDBX_env, ptr %271, i32 0, i32 4
  %273 = load i32, ptr %272, align 8, !tbaa !37
  %274 = icmp ne i32 %273, -1
  br i1 %274, label %275, label %296

275:                                              ; preds = %270
  %276 = load ptr, ptr %4, align 8, !tbaa !5
  %277 = getelementptr inbounds %struct.MDBX_env, ptr %276, i32 0, i32 4
  %278 = load i32, ptr %277, align 8, !tbaa !37
  %279 = call i32 @close(i32 noundef %278)
  %280 = icmp ne i32 %279, 0
  %281 = xor i1 %280, true
  %282 = xor i1 %281, true
  %283 = zext i1 %282 to i32
  %284 = sext i32 %283 to i64
  %285 = call i64 @llvm.expect.i64(i64 %284, i64 0)
  %286 = icmp ne i64 %285, 0
  br i1 %286, label %287, label %293

287:                                              ; preds = %275
  %288 = load i32, ptr %7, align 4, !tbaa !9
  %289 = icmp eq i32 %288, 0
  br i1 %289, label %290, label %293

290:                                              ; preds = %287
  %291 = call ptr @__errno_location() #11
  %292 = load i32, ptr %291, align 4, !tbaa !9
  store i32 %292, ptr %7, align 4, !tbaa !9
  br label %293

293:                                              ; preds = %290, %287, %275
  %294 = load ptr, ptr %4, align 8, !tbaa !5
  %295 = getelementptr inbounds %struct.MDBX_env, ptr %294, i32 0, i32 4
  store i32 -1, ptr %295, align 8, !tbaa !37
  br label %296

296:                                              ; preds = %293, %270
  %297 = load ptr, ptr %4, align 8, !tbaa !5
  %298 = getelementptr inbounds %struct.MDBX_env, ptr %297, i32 0, i32 3
  %299 = getelementptr inbounds %struct.osal_mmap, ptr %298, i32 0, i32 1
  %300 = load i32, ptr %299, align 8, !tbaa !30
  %301 = icmp ne i32 %300, -1
  br i1 %301, label %302, label %367

302:                                              ; preds = %296
  %303 = load ptr, ptr %4, align 8, !tbaa !5
  %304 = getelementptr inbounds %struct.MDBX_env, ptr %303, i32 0, i32 3
  %305 = getelementptr inbounds %struct.osal_mmap, ptr %304, i32 0, i32 1
  %306 = load i32, ptr %305, align 8, !tbaa !30
  %307 = call i32 @close(i32 noundef %306)
  %308 = icmp ne i32 %307, 0
  %309 = xor i1 %308, true
  %310 = xor i1 %309, true
  %311 = zext i1 %310 to i32
  %312 = sext i32 %311 to i64
  %313 = call i64 @llvm.expect.i64(i64 %312, i64 0)
  %314 = icmp ne i64 %313, 0
  br i1 %314, label %315, label %321

315:                                              ; preds = %302
  %316 = load i32, ptr %7, align 4, !tbaa !9
  %317 = icmp eq i32 %316, 0
  br i1 %317, label %318, label %321

318:                                              ; preds = %315
  %319 = call ptr @__errno_location() #11
  %320 = load i32, ptr %319, align 4, !tbaa !9
  store i32 %320, ptr %7, align 4, !tbaa !9
  br label %321

321:                                              ; preds = %318, %315, %302
  %322 = load ptr, ptr %4, align 8, !tbaa !5
  %323 = getelementptr inbounds %struct.MDBX_env, ptr %322, i32 0, i32 3
  %324 = getelementptr inbounds %struct.osal_mmap, ptr %323, i32 0, i32 1
  store i32 -1, ptr %324, align 8, !tbaa !30
  %325 = load i32, ptr @op_setlk, align 4, !tbaa !9
  %326 = icmp eq i32 %325, 6
  br i1 %326, label %327, label %366

327:                                              ; preds = %321
  %328 = load ptr, ptr %5, align 8, !tbaa !5
  %329 = icmp ne ptr %328, null
  br i1 %329, label %330, label %366

330:                                              ; preds = %327
  %331 = load i32, ptr %7, align 4, !tbaa !9
  %332 = icmp eq i32 %331, 0
  br i1 %332, label %333, label %366

333:                                              ; preds = %330
  %334 = load ptr, ptr %5, align 8, !tbaa !5
  %335 = getelementptr inbounds %struct.MDBX_env, ptr %334, i32 0, i32 3
  %336 = getelementptr inbounds %struct.osal_mmap, ptr %335, i32 0, i32 1
  %337 = load i32, ptr %336, align 8, !tbaa !30
  %338 = load ptr, ptr %5, align 8, !tbaa !5
  %339 = getelementptr inbounds %struct.MDBX_env, ptr %338, i32 0, i32 1
  %340 = load i32, ptr %339, align 4, !tbaa !31
  %341 = and i32 %340, 131072
  %342 = icmp ne i32 %341, 0
  %343 = zext i1 %342 to i64
  %344 = select i1 %342, i32 0, i32 1
  %345 = load ptr, ptr %5, align 8, !tbaa !5
  %346 = getelementptr inbounds %struct.MDBX_env, ptr %345, i32 0, i32 1
  %347 = load i32, ptr %346, align 4, !tbaa !31
  %348 = and i32 %347, 4194304
  %349 = icmp ne i32 %348, 0
  br i1 %349, label %350, label %351

350:                                              ; preds = %333
  br label %355

351:                                              ; preds = %333
  %352 = load ptr, ptr %5, align 8, !tbaa !5
  %353 = getelementptr inbounds %struct.MDBX_env, ptr %352, i32 0, i32 20
  %354 = load i32, ptr %353, align 4, !tbaa !33
  br label %355

355:                                              ; preds = %351, %350
  %356 = phi i32 [ 0, %350 ], [ %354, %351 ]
  %357 = zext i32 %356 to i64
  %358 = load ptr, ptr %5, align 8, !tbaa !5
  %359 = getelementptr inbounds %struct.MDBX_env, ptr %358, i32 0, i32 1
  %360 = load i32, ptr %359, align 4, !tbaa !31
  %361 = and i32 %360, 4194304
  %362 = icmp ne i32 %361, 0
  %363 = zext i1 %362 to i64
  %364 = select i1 %362, i64 9223372036853727232, i64 1
  %365 = call i32 @lck_op(i32 noundef %337, i32 noundef 7, i32 noundef %344, i64 noundef %357, i64 noundef %364)
  store i32 %365, ptr %7, align 4, !tbaa !9
  br label %366

366:                                              ; preds = %355, %330, %327, %321
  br label %367

367:                                              ; preds = %366, %296
  %368 = load ptr, ptr %4, align 8, !tbaa !5
  %369 = getelementptr inbounds %struct.MDBX_env, ptr %368, i32 0, i32 6
  %370 = getelementptr inbounds %struct.osal_mmap, ptr %369, i32 0, i32 1
  %371 = load i32, ptr %370, align 8, !tbaa !26
  %372 = icmp ne i32 %371, -1
  br i1 %372, label %373, label %422

373:                                              ; preds = %367
  %374 = load ptr, ptr %4, align 8, !tbaa !5
  %375 = getelementptr inbounds %struct.MDBX_env, ptr %374, i32 0, i32 6
  %376 = getelementptr inbounds %struct.osal_mmap, ptr %375, i32 0, i32 1
  %377 = load i32, ptr %376, align 8, !tbaa !26
  %378 = call i32 @close(i32 noundef %377)
  %379 = icmp ne i32 %378, 0
  %380 = xor i1 %379, true
  %381 = xor i1 %380, true
  %382 = zext i1 %381 to i32
  %383 = sext i32 %382 to i64
  %384 = call i64 @llvm.expect.i64(i64 %383, i64 0)
  %385 = icmp ne i64 %384, 0
  br i1 %385, label %386, label %392

386:                                              ; preds = %373
  %387 = load i32, ptr %7, align 4, !tbaa !9
  %388 = icmp eq i32 %387, 0
  br i1 %388, label %389, label %392

389:                                              ; preds = %386
  %390 = call ptr @__errno_location() #11
  %391 = load i32, ptr %390, align 4, !tbaa !9
  store i32 %391, ptr %7, align 4, !tbaa !9
  br label %392

392:                                              ; preds = %389, %386, %373
  %393 = load ptr, ptr %4, align 8, !tbaa !5
  %394 = getelementptr inbounds %struct.MDBX_env, ptr %393, i32 0, i32 6
  %395 = getelementptr inbounds %struct.osal_mmap, ptr %394, i32 0, i32 1
  store i32 -1, ptr %395, align 8, !tbaa !26
  %396 = load i32, ptr @op_setlk, align 4, !tbaa !9
  %397 = icmp eq i32 %396, 6
  br i1 %397, label %398, label %421

398:                                              ; preds = %392
  %399 = load ptr, ptr %5, align 8, !tbaa !5
  %400 = icmp ne ptr %399, null
  br i1 %400, label %401, label %421

401:                                              ; preds = %398
  %402 = load i32, ptr %7, align 4, !tbaa !9
  %403 = icmp eq i32 %402, 0
  br i1 %403, label %404, label %421

404:                                              ; preds = %401
  %405 = load ptr, ptr %5, align 8, !tbaa !5
  %406 = getelementptr inbounds %struct.MDBX_env, ptr %405, i32 0, i32 6
  %407 = getelementptr inbounds %struct.osal_mmap, ptr %406, i32 0, i32 1
  %408 = load i32, ptr %407, align 8, !tbaa !26
  %409 = call i32 @lck_op(i32 noundef %408, i32 noundef 7, i32 noundef 0, i64 noundef 0, i64 noundef 1)
  store i32 %409, ptr %7, align 4, !tbaa !9
  %410 = load i32, ptr %7, align 4, !tbaa !9
  %411 = icmp eq i32 %410, 0
  br i1 %411, label %412, label %420

412:                                              ; preds = %404
  %413 = load ptr, ptr %5, align 8, !tbaa !5
  %414 = getelementptr inbounds %struct.MDBX_env, ptr %413, i32 0, i32 30
  %415 = load i32, ptr %414, align 8, !tbaa !38
  %416 = icmp ne i32 %415, 0
  br i1 %416, label %417, label %420

417:                                              ; preds = %412
  %418 = load ptr, ptr %5, align 8, !tbaa !5
  %419 = call i32 @lck_rpid_set(ptr noundef %418)
  store i32 %419, ptr %7, align 4, !tbaa !9
  br label %420

420:                                              ; preds = %417, %412, %404
  br label %421

421:                                              ; preds = %420, %401, %398, %392
  br label %422

422:                                              ; preds = %421, %367
  %423 = load ptr, ptr %5, align 8, !tbaa !5
  %424 = icmp ne ptr %423, null
  br i1 %424, label %425, label %433

425:                                              ; preds = %422
  %426 = load i32, ptr %7, align 4, !tbaa !9
  %427 = icmp ne i32 %426, 0
  br i1 %427, label %428, label %433

428:                                              ; preds = %425
  %429 = load ptr, ptr %5, align 8, !tbaa !5
  %430 = getelementptr inbounds %struct.MDBX_env, ptr %429, i32 0, i32 1
  %431 = load i32, ptr %430, align 4, !tbaa !31
  %432 = or i32 %431, -2147483648
  store i32 %432, ptr %430, align 4, !tbaa !31
  br label %433

433:                                              ; preds = %428, %425, %422
  %434 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #10
  call void @llvm.lifetime.end.p0(i64 144, ptr %8) #10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #10
  ret i32 %434
}

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

declare i32 @osal_munmap(ptr noundef) #5

; Function Attrs: nounwind
declare i32 @ftruncate64(i32 noundef, i64 noundef) #7

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @jitter4testing(i1 noundef zeroext) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @__Wpedantic_format_voidptr(ptr noundef) #3

declare i32 @close(i32 noundef) #5

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

!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, !7, i64 25}
!12 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !13, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !14, i64 80, !6, i64 88}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !6, i64 104}
!16 = !{!"MDBX_env", !7, i64 0, !10, i64 4, !10, i64 8, !17, i64 16, !10, i64 56, !10, i64 60, !17, i64 64, !6, i64 104, !18, i64 112, !18, i64 114, !18, i64 116, !18, i64 118, !18, i64 120, !18, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !18, i64 130, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !19, 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, !20, i64 264, !22, i64 320, !13, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !23, i64 392, !7, i64 400, !10, i64 440, !10, i64 444, !6, i64 448, !24, i64 456, !7, i64 496, !7, i64 536}
!17 = !{!"osal_mmap", !7, i64 0, !10, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!18 = !{!"short", !7, i64 0}
!19 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"", !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, !13, i64 36, !13, i64 37, !13, i64 38, !21, i64 40, !7, i64 48}
!21 = !{!"", !18, i64 0, !18, i64 2, !18, i64 4, !18, i64 6}
!22 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!23 = !{!"", !14, i64 0}
!24 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!25 = !{!7, !7, i64 0}
!26 = !{!16, !10, i64 72}
!27 = !{!28, !14, i64 16}
!28 = !{!"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, !29, i64 72, !29, i64 88, !29, i64 104, !7, i64 120}
!29 = !{!"timespec", !14, i64 0, !14, i64 8}
!30 = !{!16, !10, i64 24}
!31 = !{!16, !10, i64 4}
!32 = !{!12, !7, i64 26}
!33 = !{!16, !10, i64 140}
!34 = !{!13, !13, i64 0}
!35 = !{i8 0, i8 2}
!36 = !{}
!37 = !{!16, !10, i64 56}
!38 = !{!16, !10, i64 232}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon }
%struct.anon = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%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 }

@op_setlk = external hidden local_unnamed_addr global i32, align 4
@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.15 = external hidden unnamed_addr constant [29 x i8], align 1
@__func__.lck_destroy = external hidden unnamed_addr constant [12 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden i32 @lck_op(i32 noundef, i32 noundef, i32 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @lck_rpid_set(ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @lck_ipclock_destroy(ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @lck_destroy(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #5 {
  %4 = alloca %struct.stat, align 8
  %5 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %6 = and i8 %5, 1
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %10, label %7, !prof !13

7:                                                ; preds = %3
  %8 = tail call i32 @osal_getpid()
  %.not85 = icmp eq i32 %8, %2
  br i1 %.not85, label %10, label %9, !prof !14

9:                                                ; preds = %7
  tail call void @mdbx_assert_fail(ptr noundef %0, ptr noundef nonnull @.str.15, ptr noundef nonnull @__func__.lck_destroy, i32 noundef 430) #9
  unreachable

10:                                               ; preds = %3, %7
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %4) #10
  %11 = getelementptr inbounds i8, ptr %0, i64 104
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %.not86 = icmp eq ptr %12, null
  br i1 %.not86, label %77, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  %15 = load ptr, ptr %14, align 8, !tbaa !25
  %16 = icmp ne ptr %12, %15
  %17 = icmp ne ptr %1, null
  %or.cond = or i1 %17, %16
  br i1 %or.cond, label %77, label %18

18:                                               ; preds = %13
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  %20 = load i32, ptr %19, align 8, !tbaa !26
  %21 = load i32, ptr @op_setlk, align 4, !tbaa !27
  %22 = tail call i32 @lck_op(i32 noundef %20, i32 noundef %21, i32 noundef 1, i64 noundef 0, i64 noundef 9223372036853727232)
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %77

24:                                               ; preds = %18
  %25 = load i32, ptr %19, align 8, !tbaa !26
  %26 = call i32 @fstat64(i32 noundef %25, ptr noundef nonnull %4) #10
  %27 = icmp eq i32 %26, 0
  %28 = getelementptr inbounds i8, ptr %4, i64 16
  %29 = load i64, ptr %28, align 8
  %30 = icmp ne i64 %29, 0
  %or.cond4 = select i1 %27, i1 %30, i1 false
  br i1 %or.cond4, label %31, label %77

31:                                               ; preds = %24
  %32 = getelementptr inbounds i8, ptr %0, i64 24
  %33 = load i32, ptr %32, align 8, !tbaa !28
  %34 = load i32, ptr @op_setlk, align 4, !tbaa !27
  %35 = getelementptr inbounds i8, ptr %0, i64 4
  %36 = load i32, ptr %35, align 4, !tbaa !29
  %37 = lshr i32 %36, 17
  %.lobit = and i32 %37, 1
  %38 = xor i32 %.lobit, 1
  %39 = tail call i32 @lck_op(i32 noundef %33, i32 noundef %34, i32 noundef %38, i64 noundef 0, i64 noundef 9223372036853727232)
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %77

41:                                               ; preds = %31
  %42 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !30
  %43 = icmp ugt i8 %42, 3
  br i1 %43, label %44, label %45, !prof !13

44:                                               ; preds = %41
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 4, ptr noundef nonnull @__func__.lck_destroy, i32 noundef 441, ptr noundef nonnull @.str.16, ptr noundef nonnull %0) #10
  br label %45

45:                                               ; preds = %41, %44
  %46 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %47 = and i8 %46, 1
  %.not88 = icmp eq i8 %47, 0
  br i1 %.not88, label %52, label %48, !prof !13

48:                                               ; preds = %45
  %49 = getelementptr inbounds i8, ptr %0, i64 140
  %50 = load i32, ptr %49, align 4, !tbaa !31
  %.not89 = icmp eq i32 %50, %2
  br i1 %.not89, label %52, label %51, !prof !14

51:                                               ; preds = %48
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.17, ptr noundef nonnull @__func__.lck_destroy, i32 noundef 442) #9
  unreachable

52:                                               ; preds = %48, %45
  %53 = getelementptr inbounds i8, ptr %12, i64 448
  %54 = tail call i32 @lck_ipclock_destroy(ptr noundef nonnull %53)
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %59

56:                                               ; preds = %52
  %57 = getelementptr inbounds i8, ptr %12, i64 320
  %58 = tail call i32 @lck_ipclock_destroy(ptr noundef nonnull %57)
  br label %59

59:                                               ; preds = %52, %56
  %.075 = phi i32 [ %58, %56 ], [ %54, %52 ]
  %60 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %61 = and i8 %60, 1
  %.not90 = icmp eq i8 %61, 0
  %.not91 = icmp eq i32 %.075, 0
  %or.cond108 = select i1 %.not90, i1 true, i1 %.not91
  br i1 %or.cond108, label %63, label %62, !prof !32

62:                                               ; preds = %59
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.18, ptr noundef nonnull @__func__.lck_destroy, i32 noundef 452) #9
  unreachable

63:                                               ; preds = %59
  br i1 %.not91, label %64, label %76

64:                                               ; preds = %63
  %65 = getelementptr inbounds i8, ptr %12, i64 376
  %66 = load volatile i64, ptr %65, align 8, !tbaa !25
  %67 = icmp eq i64 %66, 0
  %68 = tail call i32 @osal_munmap(ptr noundef nonnull %14) #10
  br i1 %67, label %69, label %76

69:                                               ; preds = %64
  %70 = load i32, ptr %19, align 8, !tbaa !26
  %.not92 = icmp eq i32 %70, -1
  br i1 %.not92, label %76, label %71

71:                                               ; preds = %69
  %72 = tail call i32 @ftruncate64(i32 noundef %70, i64 noundef 0) #10
  %.not93 = icmp eq i32 %72, 0
  br i1 %.not93, label %76, label %73

73:                                               ; preds = %71
  %74 = tail call ptr @__errno_location() #11
  %75 = load i32, ptr %74, align 4, !tbaa !27
  br label %76

76:                                               ; preds = %64, %69, %71, %73, %63
  %.2 = phi i32 [ %.075, %63 ], [ 0, %69 ], [ 0, %64 ], [ %75, %73 ], [ 0, %71 ]
  tail call void @jitter4testing(i1 noundef zeroext false)
  br label %77

77:                                               ; preds = %76, %31, %24, %18, %13, %10
  %.3 = phi i32 [ 0, %13 ], [ %.2, %76 ], [ 0, %31 ], [ 0, %24 ], [ 0, %18 ], [ 0, %10 ]
  %78 = getelementptr inbounds i8, ptr %0, i64 140
  %79 = load i32, ptr %78, align 4, !tbaa !31
  %.not94 = icmp eq i32 %79, %2
  br i1 %.not94, label %90, label %80

80:                                               ; preds = %77
  %81 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %82 = and i8 %81, 1
  %.not95 = icmp eq i8 %82, 0
  %.not96 = icmp eq ptr %1, null
  %or.cond109 = or i1 %.not96, %.not95
  br i1 %or.cond109, label %84, label %83, !prof !32

83:                                               ; preds = %80
  tail call void @mdbx_assert_fail(ptr noundef nonnull %0, ptr noundef nonnull @.str.19, ptr noundef nonnull @__func__.lck_destroy, i32 noundef 464) #9
  unreachable

84:                                               ; preds = %80
  %85 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !30
  %86 = icmp ugt i8 %85, 2
  br i1 %86, label %87, label %90, !prof !13

87:                                               ; preds = %84
  %88 = tail call ptr @__Wpedantic_format_voidptr(ptr noundef nonnull %0)
  %89 = load i32, ptr %78, align 4, !tbaa !31
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 3, ptr noundef nonnull @__func__.lck_destroy, i32 noundef 465, ptr noundef nonnull @.str.20, ptr noundef %88, i32 noundef %89, i32 noundef %2) #10
  br label %90

90:                                               ; preds = %84, %87, %77
  %.0 = phi ptr [ %1, %77 ], [ null, %87 ], [ null, %84 ]
  %91 = getelementptr inbounds i8, ptr %0, i64 56
  %92 = load i32, ptr %91, align 8, !tbaa !33
  %.not97 = icmp eq i32 %92, -1
  br i1 %.not97, label %101, label %93

93:                                               ; preds = %90
  %94 = tail call i32 @close(i32 noundef %92) #10
  %.not98 = icmp eq i32 %94, 0
  br i1 %.not98, label %100, label %95, !prof !14

95:                                               ; preds = %93
  %96 = icmp eq i32 %.3, 0
  br i1 %96, label %97, label %100

97:                                               ; preds = %95
  %98 = tail call ptr @__errno_location() #11
  %99 = load i32, ptr %98, align 4, !tbaa !27
  br label %100

100:                                              ; preds = %97, %95, %93
  %.4 = phi i32 [ %99, %97 ], [ %.3, %95 ], [ %.3, %93 ]
  store i32 -1, ptr %91, align 8, !tbaa !33
  br label %101

101:                                              ; preds = %100, %90
  %.5 = phi i32 [ %.4, %100 ], [ %.3, %90 ]
  %102 = getelementptr inbounds i8, ptr %0, i64 24
  %103 = load i32, ptr %102, align 8, !tbaa !28
  %.not99 = icmp eq i32 %103, -1
  br i1 %.not99, label %132, label %104

104:                                              ; preds = %101
  %105 = tail call i32 @close(i32 noundef %103) #10
  %.not100 = icmp eq i32 %105, 0
  br i1 %.not100, label %111, label %106, !prof !14

106:                                              ; preds = %104
  %107 = icmp eq i32 %.5, 0
  br i1 %107, label %108, label %111

108:                                              ; preds = %106
  %109 = tail call ptr @__errno_location() #11
  %110 = load i32, ptr %109, align 4, !tbaa !27
  br label %111

111:                                              ; preds = %108, %106, %104
  %.6 = phi i32 [ %110, %108 ], [ %.5, %106 ], [ %.5, %104 ]
  store i32 -1, ptr %102, align 8, !tbaa !28
  %112 = load i32, ptr @op_setlk, align 4, !tbaa !27
  %113 = icmp eq i32 %112, 6
  %114 = icmp ne ptr %.0, null
  %or.cond6 = and i1 %114, %113
  %115 = icmp eq i32 %.6, 0
  %or.cond8 = select i1 %or.cond6, i1 %115, i1 false
  br i1 %or.cond8, label %116, label %132

116:                                              ; preds = %111
  %117 = getelementptr inbounds i8, ptr %.0, i64 24
  %118 = load i32, ptr %117, align 8, !tbaa !28
  %119 = getelementptr inbounds i8, ptr %.0, i64 4
  %120 = load i32, ptr %119, align 4, !tbaa !29
  %121 = lshr i32 %120, 17
  %.lobit102 = and i32 %121, 1
  %122 = xor i32 %.lobit102, 1
  %123 = and i32 %120, 4194304
  %.not103 = icmp eq i32 %123, 0
  br i1 %.not103, label %124, label %128

124:                                              ; preds = %116
  %125 = getelementptr inbounds i8, ptr %.0, i64 140
  %126 = load i32, ptr %125, align 4, !tbaa !31
  %127 = zext i32 %126 to i64
  br label %128

128:                                              ; preds = %116, %124
  %129 = phi i64 [ 1, %124 ], [ 9223372036853727232, %116 ]
  %130 = phi i64 [ %127, %124 ], [ 0, %116 ]
  %131 = tail call i32 @lck_op(i32 noundef %118, i32 noundef 7, i32 noundef %122, i64 noundef %130, i64 noundef %129)
  br label %132

132:                                              ; preds = %111, %128, %101
  %.7 = phi i32 [ %131, %128 ], [ %.6, %111 ], [ %.5, %101 ]
  %133 = getelementptr inbounds i8, ptr %0, i64 72
  %134 = load i32, ptr %133, align 8, !tbaa !26
  %.not105 = icmp eq i32 %134, -1
  br i1 %.not105, label %157, label %135

135:                                              ; preds = %132
  %136 = tail call i32 @close(i32 noundef %134) #10
  %.not106 = icmp eq i32 %136, 0
  br i1 %.not106, label %142, label %137, !prof !14

137:                                              ; preds = %135
  %138 = icmp eq i32 %.7, 0
  br i1 %138, label %139, label %142

139:                                              ; preds = %137
  %140 = tail call ptr @__errno_location() #11
  %141 = load i32, ptr %140, align 4, !tbaa !27
  br label %142

142:                                              ; preds = %139, %137, %135
  %.8 = phi i32 [ %141, %139 ], [ %.7, %137 ], [ %.7, %135 ]
  store i32 -1, ptr %133, align 8, !tbaa !26
  %143 = load i32, ptr @op_setlk, align 4, !tbaa !27
  %144 = icmp eq i32 %143, 6
  %145 = icmp ne ptr %.0, null
  %or.cond10 = and i1 %145, %144
  %146 = icmp eq i32 %.8, 0
  %or.cond12 = select i1 %or.cond10, i1 %146, i1 false
  br i1 %or.cond12, label %147, label %157

147:                                              ; preds = %142
  %148 = getelementptr inbounds i8, ptr %.0, i64 72
  %149 = load i32, ptr %148, align 8, !tbaa !26
  %150 = tail call i32 @lck_op(i32 noundef %149, i32 noundef 7, i32 noundef 0, i64 noundef 0, i64 noundef 1)
  %151 = icmp eq i32 %150, 0
  br i1 %151, label %152, label %157

152:                                              ; preds = %147
  %153 = getelementptr inbounds i8, ptr %.0, i64 232
  %154 = load i32, ptr %153, align 8, !tbaa !34
  %.not107 = icmp eq i32 %154, 0
  br i1 %.not107, label %.thread, label %155

155:                                              ; preds = %152
  %156 = tail call i32 @lck_rpid_set(ptr noundef nonnull %.0)
  br label %157

157:                                              ; preds = %142, %155, %147, %132
  %.9 = phi i32 [ %156, %155 ], [ %150, %147 ], [ %.8, %142 ], [ %.7, %132 ]
  %158 = icmp ne ptr %.0, null
  %159 = icmp ne i32 %.9, 0
  %or.cond14 = select i1 %158, i1 %159, i1 false
  br i1 %or.cond14, label %160, label %.thread

160:                                              ; preds = %157
  %161 = getelementptr inbounds i8, ptr %.0, i64 4
  %162 = load i32, ptr %161, align 4, !tbaa !29
  %163 = or i32 %162, -2147483648
  store i32 %163, ptr %161, align 4, !tbaa !29
  br label %.thread

.thread:                                          ; preds = %152, %160, %157
  %.9112 = phi i32 [ %.9, %160 ], [ %.9, %157 ], [ 0, %152 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %4) #10
  ret i32 %.9112
}

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

declare i32 @osal_munmap(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare i32 @ftruncate64(i32 noundef, i64 noundef) local_unnamed_addr #7

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @jitter4testing(i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @__Wpedantic_format_voidptr(ptr noundef) local_unnamed_addr #2

declare i32 @close(i32 noundef) local_unnamed_addr #4

attributes #0 = { 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 #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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = { 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 #9 = { noreturn nounwind }
attributes #10 = { nounwind }
attributes #11 = { nounwind willreturn memory(none) }

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

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


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