; LLVM IR from erthink/libmdbx :: src (api-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 }
%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.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.meta_ptr = type { i64, %union.anon.24, i64 }
%union.anon.24 = type { ptr }
%struct.MDBX_env = type { %union.mdbx_atomic_uint32_t, i32, i32, %struct.osal_mmap, i32, i32, %struct.osal_mmap, ptr, i16, i16, i16, i16, i16, i16, %union.mdbx_atomic_uint32_t, i8, i8, i16, i32, i32, i32, i32, %struct.anon.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.MDBX_txn = type { i32, i32, i64, i64, ptr, ptr, %struct.geo, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, %struct.MDBX_canary, ptr, %union.anon.18 }
%struct.geo = type { i16, i16, i32, i32, %union.anon.12, %union.anon.13 }
%union.anon.12 = type { i32 }
%union.anon.13 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.18 = type { %struct.anon.20 }
%struct.anon.20 = type { %struct.troika, ptr, %struct.anon.21, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.22 }
%struct.anon.21 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.22 = type { %struct.anon.23 }
%struct.anon.23 = type { i64, ptr }
%struct.meta = type { [2 x i32], %union.anon.11, i16, i8, i8, %struct.geo, %union.anon.14, %struct.MDBX_canary, %union.anon.17, [2 x %union.mdbx_atomic_uint32_t], [2 x i32], %union.bin128, %union.bin128 }
%union.anon.11 = type { i64 }
%union.anon.14 = type { %struct.anon.15 }
%struct.anon.15 = type { %struct.tree, %struct.tree }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%union.anon.17 = type { i64 }
%struct.page = type <{ i64, i16, i16, %union.anon.25, i32, [0 x i16] }>
%union.anon.25 = type { i32 }

@globals = external global %struct.libmdbx_globals, align 8
@__func__.mdbx_env_open = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @log_if_error(i32 noundef, ptr noundef, i32 noundef) #1

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

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @check_env(ptr noundef, i1 noundef zeroext) #1

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @mdbx_env_open(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #5 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.troika, align 8
  %14 = alloca %struct.meta_ptr, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = call i32 @check_env(ptr noundef %16, i1 noundef zeroext false)
  store i32 %17, ptr %10, align 4, !tbaa !9
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = icmp ne i32 %18, 0
  %20 = xor i1 %19, true
  %21 = xor i1 %20, true
  %22 = zext i1 %21 to i32
  %23 = sext i32 %22 to i64
  %24 = call i64 @llvm.expect.i64(i64 %23, i64 0)
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %29

26:                                               ; preds = %4
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = call i32 @log_if_error(i32 noundef %27, ptr noundef @__func__.mdbx_env_open, i32 noundef 442)
  store i32 %28, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %400

29:                                               ; preds = %4
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = and i32 %30, -1342136321
  %32 = icmp ne i32 %31, 0
  %33 = xor i1 %32, true
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = call i64 @llvm.expect.i64(i64 %36, i64 0)
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %29
  %40 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_env_open, i32 noundef 445)
  store i32 %40, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %400

41:                                               ; preds = %29
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.MDBX_env, ptr %42, i32 0, i32 3
  %44 = getelementptr inbounds %struct.osal_mmap, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !11
  %46 = icmp ne i32 %45, -1
  br i1 %46, label %59, label %47

47:                                               ; preds = %41
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.MDBX_env, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !23
  %51 = and i32 %50, 536870912
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %59, label %53

53:                                               ; preds = %47
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.MDBX_env, ptr %54, i32 0, i32 3
  %56 = getelementptr inbounds %struct.osal_mmap, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !24
  %58 = icmp ne ptr %57, null
  br label %59

59:                                               ; preds = %53, %47, %41
  %60 = phi i1 [ true, %47 ], [ true, %41 ], [ %58, %53 ]
  %61 = xor i1 %60, true
  %62 = xor i1 %61, true
  %63 = zext i1 %62 to i32
  %64 = sext i32 %63 to i64
  %65 = call i64 @llvm.expect.i64(i64 %64, i64 0)
  %66 = icmp ne i64 %65, 0
  br i1 %66, label %67, label %69

67:                                               ; preds = %59
  %68 = call i32 @log_if_error(i32 noundef 1, ptr noundef @__func__.mdbx_env_open, i32 noundef 448)
  store i32 %68, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %400

69:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.MDBX_env, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !23
  store i32 %72, ptr %12, align 4, !tbaa !9
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = or i32 %73, 33554432
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.MDBX_env, ptr %75, i32 0, i32 1
  %77 = load i32, ptr %76, align 4, !tbaa !23
  %78 = call i32 @combine_durability_flags(i32 noundef %74, i32 noundef %77)
  store i32 %78, ptr %8, align 4, !tbaa !9
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = and i32 %79, 131072
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %85

82:                                               ; preds = %69
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = and i32 %83, -1193082881
  store i32 %84, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %86

85:                                               ; preds = %69
  br label %86

86:                                               ; preds = %85, %82
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = and i32 %87, 2147483647
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.MDBX_env, ptr %89, i32 0, i32 1
  store i32 %88, ptr %90, align 4, !tbaa !23
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = call i32 @env_handle_pathname(ptr noundef %91, ptr noundef %92, i32 noundef %93) #8
  store i32 %94, ptr %10, align 4, !tbaa !9
  %95 = load i32, ptr %10, align 4, !tbaa !9
  %96 = icmp ne i32 %95, 0
  %97 = xor i1 %96, true
  %98 = xor i1 %97, true
  %99 = zext i1 %98 to i32
  %100 = sext i32 %99 to i64
  %101 = call i64 @llvm.expect.i64(i64 %100, i64 0)
  %102 = icmp ne i64 %101, 0
  br i1 %102, label %103, label %104

103:                                              ; preds = %86
  br label %377

104:                                              ; preds = %86
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.MDBX_env, ptr %105, i32 0, i32 19
  %107 = load i32, ptr %106, align 8, !tbaa !25
  %108 = zext i32 %107 to i64
  %109 = call noalias ptr @calloc(i64 noundef %108, i64 noundef 64) #9
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.MDBX_env, ptr %110, i32 0, i32 25
  store ptr %109, ptr %111, align 8, !tbaa !26
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.MDBX_env, ptr %112, i32 0, i32 19
  %114 = load i32, ptr %113, align 8, !tbaa !25
  %115 = zext i32 %114 to i64
  %116 = call noalias ptr @calloc(i64 noundef %115, i64 noundef 1) #9
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.MDBX_env, ptr %117, i32 0, i32 26
  store ptr %116, ptr %118, align 8, !tbaa !27
  %119 = load ptr, ptr %6, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.MDBX_env, ptr %119, i32 0, i32 19
  %121 = load i32, ptr %120, align 8, !tbaa !25
  %122 = zext i32 %121 to i64
  %123 = call noalias ptr @calloc(i64 noundef %122, i64 noundef 4) #9
  %124 = load ptr, ptr %6, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.MDBX_env, ptr %124, i32 0, i32 27
  store ptr %123, ptr %125, align 8, !tbaa !28
  %126 = load ptr, ptr %6, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.MDBX_env, ptr %126, i32 0, i32 25
  %128 = load ptr, ptr %127, align 8, !tbaa !26
  %129 = icmp ne ptr %128, null
  br i1 %129, label %130, label %140

130:                                              ; preds = %104
  %131 = load ptr, ptr %6, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.MDBX_env, ptr %131, i32 0, i32 26
  %133 = load ptr, ptr %132, align 8, !tbaa !27
  %134 = icmp ne ptr %133, null
  br i1 %134, label %135, label %140

135:                                              ; preds = %130
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.MDBX_env, ptr %136, i32 0, i32 27
  %138 = load ptr, ptr %137, align 8, !tbaa !28
  %139 = icmp ne ptr %138, null
  br label %140

140:                                              ; preds = %135, %130, %104
  %141 = phi i1 [ false, %130 ], [ false, %104 ], [ %139, %135 ]
  %142 = xor i1 %141, true
  %143 = xor i1 %142, true
  %144 = xor i1 %143, true
  %145 = zext i1 %144 to i32
  %146 = sext i32 %145 to i64
  %147 = call i64 @llvm.expect.i64(i64 %146, i64 0)
  %148 = icmp ne i64 %147, 0
  br i1 %148, label %149, label %150

149:                                              ; preds = %140
  store i32 12, ptr %10, align 4, !tbaa !9
  br label %377

150:                                              ; preds = %140
  %151 = load i32, ptr %8, align 4, !tbaa !9
  %152 = and i32 %151, 131072
  %153 = icmp eq i32 %152, 0
  br i1 %153, label %154, label %181

154:                                              ; preds = %150
  %155 = load ptr, ptr %6, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.MDBX_env, ptr %155, i32 0, i32 19
  %157 = load i32, ptr %156, align 8, !tbaa !25
  %158 = zext i32 %157 to i64
  %159 = call ptr @txn_basal_create(i64 noundef %158)
  %160 = load ptr, ptr %6, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.MDBX_env, ptr %160, i32 0, i32 24
  store ptr %159, ptr %161, align 8, !tbaa !29
  %162 = load ptr, ptr %6, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.MDBX_env, ptr %162, i32 0, i32 24
  %164 = load ptr, ptr %163, align 8, !tbaa !29
  %165 = icmp ne ptr %164, null
  %166 = xor i1 %165, true
  %167 = xor i1 %166, true
  %168 = xor i1 %167, true
  %169 = zext i1 %168 to i32
  %170 = sext i32 %169 to i64
  %171 = call i64 @llvm.expect.i64(i64 %170, i64 0)
  %172 = icmp ne i64 %171, 0
  br i1 %172, label %173, label %174

173:                                              ; preds = %154
  store i32 12, ptr %10, align 4, !tbaa !9
  br label %377

174:                                              ; preds = %154
  %175 = load ptr, ptr %6, align 8, !tbaa !5
  %176 = load ptr, ptr %6, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.MDBX_env, ptr %176, i32 0, i32 24
  %178 = load ptr, ptr %177, align 8, !tbaa !29
  %179 = getelementptr inbounds %struct.MDBX_txn, ptr %178, i32 0, i32 9
  store ptr %175, ptr %179, align 8, !tbaa !30
  %180 = load ptr, ptr %6, align 8, !tbaa !5
  call void @env_options_adjust_defaults(ptr noundef %180)
  br label %181

181:                                              ; preds = %174, %150
  %182 = load ptr, ptr %6, align 8, !tbaa !5
  %183 = load i32, ptr %9, align 4, !tbaa !9
  %184 = call i32 @env_open(ptr noundef %182, i32 noundef %183)
  store i32 %184, ptr %10, align 4, !tbaa !9
  %185 = load i32, ptr %10, align 4, !tbaa !9
  %186 = icmp ne i32 %185, 0
  %187 = xor i1 %186, true
  %188 = xor i1 %187, true
  %189 = zext i1 %188 to i32
  %190 = sext i32 %189 to i64
  %191 = call i64 @llvm.expect.i64(i64 %190, i64 0)
  %192 = icmp ne i64 %191, 0
  br i1 %192, label %193, label %194

193:                                              ; preds = %181
  br label %377

194:                                              ; preds = %181
  %195 = load ptr, ptr %6, align 8, !tbaa !5
  call void @meta_tap(ptr dead_on_unwind writable sret(%struct.troika) align 8 %13, ptr noundef %195)
  %196 = load ptr, ptr %6, align 8, !tbaa !5
  call void @meta_recent(ptr dead_on_unwind writable sret(%struct.meta_ptr) align 8 %14, ptr noundef %196, ptr noundef %13)
  %197 = getelementptr inbounds %struct.meta_ptr, ptr %14, i32 0, i32 1
  %198 = load ptr, ptr %197, align 8, !tbaa !24
  %199 = getelementptr inbounds %struct.meta, ptr %198, i32 0, i32 6
  %200 = getelementptr inbounds %struct.anon.15, ptr %199, i32 0, i32 1
  store ptr %200, ptr %15, align 8, !tbaa !5
  br label %201

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

211:                                              ; preds = %201
  %212 = getelementptr inbounds %struct.meta_ptr, ptr %14, i32 0, i32 1
  %213 = load ptr, ptr %212, align 8, !tbaa !24
  %214 = getelementptr inbounds %struct.meta, ptr %213, i32 0, i32 0
  %215 = getelementptr inbounds [2 x i32], ptr %214, i64 0, i64 0
  %216 = call i64 @unaligned_peek_u64(i64 noundef 4, ptr noundef %215) #10
  %217 = trunc i64 %216 to i8
  %218 = zext i8 %217 to i32
  %219 = load ptr, ptr %6, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.MDBX_env, ptr %219, i32 0, i32 2
  %221 = load i32, ptr %220, align 8, !tbaa !36
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 510, ptr noundef @.str.3, i32 noundef %218, i32 noundef %221)
  br label %222

222:                                              ; preds = %211, %201
  br label %223

223:                                              ; preds = %222
  br label %224

224:                                              ; preds = %223
  br label %225

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

235:                                              ; preds = %225
  %236 = getelementptr inbounds %struct.meta_ptr, ptr %14, i32 0, i32 1
  %237 = load ptr, ptr %236, align 8, !tbaa !24
  %238 = call ptr @data_page(ptr noundef %237) #10
  %239 = getelementptr inbounds %struct.page, ptr %238, i32 0, i32 4
  %240 = load i32, ptr %239, align 1, !tbaa !9
  %241 = getelementptr inbounds %struct.meta_ptr, ptr %14, i32 0, i32 0
  %242 = load i64, ptr %241, align 8, !tbaa !37
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 511, ptr noundef @.str.4, i32 noundef %240, i64 noundef %242)
  br label %243

243:                                              ; preds = %235, %225
  br label %244

244:                                              ; preds = %243
  br label %245

245:                                              ; preds = %244
  br label %246

246:                                              ; preds = %245
  %247 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !34
  %248 = zext i8 %247 to i32
  %249 = icmp sle i32 5, %248
  %250 = xor i1 %249, true
  %251 = xor i1 %250, true
  %252 = zext i1 %251 to i32
  %253 = sext i32 %252 to i64
  %254 = call i64 @llvm.expect.i64(i64 %253, i64 0)
  %255 = icmp ne i64 %254, 0
  br i1 %255, label %256, label %261

256:                                              ; preds = %246
  %257 = load ptr, ptr %15, align 8, !tbaa !5
  %258 = getelementptr inbounds %struct.tree, ptr %257, i32 0, i32 1
  %259 = load i16, ptr %258, align 2, !tbaa !39
  %260 = zext i16 %259 to i32
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 512, ptr noundef @.str.5, i32 noundef %260)
  br label %261

261:                                              ; preds = %256, %246
  br label %262

262:                                              ; preds = %261
  br label %263

263:                                              ; preds = %262
  br label %264

264:                                              ; preds = %263
  %265 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !34
  %266 = zext i8 %265 to i32
  %267 = icmp sle i32 5, %266
  %268 = xor i1 %267, true
  %269 = xor i1 %268, true
  %270 = zext i1 %269 to i32
  %271 = sext i32 %270 to i64
  %272 = call i64 @llvm.expect.i64(i64 %271, i64 0)
  %273 = icmp ne i64 %272, 0
  br i1 %273, label %274, label %278

274:                                              ; preds = %264
  %275 = load ptr, ptr %15, align 8, !tbaa !5
  %276 = getelementptr inbounds %struct.tree, ptr %275, i32 0, i32 8
  %277 = load i64, ptr %276, align 4, !tbaa !41
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 513, ptr noundef @.str.6, i64 noundef %277)
  br label %278

278:                                              ; preds = %274, %264
  br label %279

279:                                              ; preds = %278
  br label %280

280:                                              ; preds = %279
  br label %281

281:                                              ; preds = %280
  %282 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !34
  %283 = zext i8 %282 to i32
  %284 = icmp sle i32 5, %283
  %285 = xor i1 %284, true
  %286 = xor i1 %285, true
  %287 = zext i1 %286 to i32
  %288 = sext i32 %287 to i64
  %289 = call i64 @llvm.expect.i64(i64 %288, i64 0)
  %290 = icmp ne i64 %289, 0
  br i1 %290, label %291, label %295

291:                                              ; preds = %281
  %292 = load ptr, ptr %15, align 8, !tbaa !5
  %293 = getelementptr inbounds %struct.tree, ptr %292, i32 0, i32 4
  %294 = load i32, ptr %293, align 4, !tbaa !42
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 514, ptr noundef @.str.7, i32 noundef %294)
  br label %295

295:                                              ; preds = %291, %281
  br label %296

296:                                              ; preds = %295
  br label %297

297:                                              ; preds = %296
  br label %298

298:                                              ; preds = %297
  %299 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !34
  %300 = zext i8 %299 to i32
  %301 = icmp sle i32 5, %300
  %302 = xor i1 %301, true
  %303 = xor i1 %302, true
  %304 = zext i1 %303 to i32
  %305 = sext i32 %304 to i64
  %306 = call i64 @llvm.expect.i64(i64 %305, i64 0)
  %307 = icmp ne i64 %306, 0
  br i1 %307, label %308, label %312

308:                                              ; preds = %298
  %309 = load ptr, ptr %15, align 8, !tbaa !5
  %310 = getelementptr inbounds %struct.tree, ptr %309, i32 0, i32 5
  %311 = load i32, ptr %310, align 4, !tbaa !43
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 515, ptr noundef @.str.8, i32 noundef %311)
  br label %312

312:                                              ; preds = %308, %298
  br label %313

313:                                              ; preds = %312
  br label %314

314:                                              ; preds = %313
  br label %315

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

325:                                              ; preds = %315
  %326 = load ptr, ptr %15, align 8, !tbaa !5
  %327 = getelementptr inbounds %struct.tree, ptr %326, i32 0, i32 6
  %328 = load i32, ptr %327, align 4, !tbaa !44
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 516, ptr noundef @.str.9, i32 noundef %328)
  br label %329

329:                                              ; preds = %325, %315
  br label %330

330:                                              ; preds = %329
  br label %331

331:                                              ; preds = %330
  br label %332

332:                                              ; preds = %331
  %333 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !34
  %334 = zext i8 %333 to i32
  %335 = icmp sle i32 5, %334
  %336 = xor i1 %335, true
  %337 = xor i1 %336, true
  %338 = zext i1 %337 to i32
  %339 = sext i32 %338 to i64
  %340 = call i64 @llvm.expect.i64(i64 %339, i64 0)
  %341 = icmp ne i64 %340, 0
  br i1 %341, label %342, label %346

342:                                              ; preds = %332
  %343 = load ptr, ptr %15, align 8, !tbaa !5
  %344 = getelementptr inbounds %struct.tree, ptr %343, i32 0, i32 3
  %345 = load i32, ptr %344, align 4, !tbaa !45
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 517, ptr noundef @.str.10, i32 noundef %345)
  br label %346

346:                                              ; preds = %342, %332
  br label %347

347:                                              ; preds = %346
  br label %348

348:                                              ; preds = %347
  br label %349

349:                                              ; preds = %348
  %350 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !34
  %351 = zext i8 %350 to i32
  %352 = icmp sle i32 5, %351
  %353 = xor i1 %352, true
  %354 = xor i1 %353, true
  %355 = zext i1 %354 to i32
  %356 = sext i32 %355 to i64
  %357 = call i64 @llvm.expect.i64(i64 %356, i64 0)
  %358 = icmp ne i64 %357, 0
  br i1 %358, label %359, label %363

359:                                              ; preds = %349
  %360 = load ptr, ptr %15, align 8, !tbaa !5
  %361 = getelementptr inbounds %struct.tree, ptr %360, i32 0, i32 9
  %362 = load i64, ptr %361, align 4, !tbaa !46
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_env_open, i32 noundef 518, ptr noundef @.str.11, i64 noundef %362)
  br label %363

363:                                              ; preds = %359, %349
  br label %364

364:                                              ; preds = %363
  br label %365

365:                                              ; preds = %364
  %366 = load i32, ptr %10, align 4, !tbaa !9
  %367 = icmp eq i32 %366, 0
  %368 = xor i1 %367, true
  %369 = xor i1 %368, true
  %370 = zext i1 %369 to i32
  %371 = sext i32 %370 to i64
  %372 = call i64 @llvm.expect.i64(i64 %371, i64 1)
  %373 = icmp ne i64 %372, 0
  br i1 %373, label %374, label %376

374:                                              ; preds = %365
  %375 = load ptr, ptr %6, align 8, !tbaa !5
  call void @dxb_sanitize_tail(ptr noundef %375, ptr noundef null)
  br label %397

376:                                              ; preds = %365
  br label %377

377:                                              ; preds = %376, %193, %173, %149, %103
  %378 = load ptr, ptr %6, align 8, !tbaa !5
  %379 = call i32 @env_close(ptr noundef %378, i1 noundef zeroext false)
  %380 = icmp eq i32 %379, 0
  %381 = xor i1 %380, true
  %382 = xor i1 %381, true
  %383 = zext i1 %382 to i32
  %384 = sext i32 %383 to i64
  %385 = call i64 @llvm.expect.i64(i64 %384, i64 1)
  %386 = icmp ne i64 %385, 0
  br i1 %386, label %387, label %391

387:                                              ; preds = %377
  %388 = load i32, ptr %12, align 4, !tbaa !9
  %389 = load ptr, ptr %6, align 8, !tbaa !5
  %390 = getelementptr inbounds %struct.MDBX_env, ptr %389, i32 0, i32 1
  store i32 %388, ptr %390, align 4, !tbaa !23
  br label %396

391:                                              ; preds = %377
  store i32 -30795, ptr %10, align 4, !tbaa !9
  %392 = load i32, ptr %12, align 4, !tbaa !9
  %393 = or i32 %392, -2147483648
  %394 = load ptr, ptr %6, align 8, !tbaa !5
  %395 = getelementptr inbounds %struct.MDBX_env, ptr %394, i32 0, i32 1
  store i32 %393, ptr %395, align 4, !tbaa !23
  br label %396

396:                                              ; preds = %391, %387
  br label %397

397:                                              ; preds = %396, %374
  %398 = load i32, ptr %10, align 4, !tbaa !9
  %399 = call i32 @log_if_error(i32 noundef %398, ptr noundef @__func__.mdbx_env_open, i32 noundef 532)
  store i32 %399, ptr %5, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %400

400:                                              ; preds = %397, %67, %39, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  %401 = load i32, ptr %5, align 4
  ret i32 %401
}

; Function Attrs: cold nounwind optsize uwtable
declare hidden i32 @env_handle_pathname(ptr noundef, ptr noundef, i32 noundef) #5

declare i32 @combine_durability_flags(i32 noundef, i32 noundef) #2

declare ptr @txn_basal_create(i64 noundef) #2

declare void @env_options_adjust_defaults(ptr noundef) #2

declare i32 @env_open(ptr noundef, i32 noundef) #2

declare void @meta_tap(ptr dead_on_unwind writable sret(%struct.troika) align 8, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @meta_recent(ptr dead_on_unwind noalias writable sret(%struct.meta_ptr) align 8, ptr noundef, ptr noundef) #1

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @dxb_sanitize_tail(ptr noundef, ptr noundef) #1

declare i32 @env_close(ptr noundef, i1 noundef zeroext) #2

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

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

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


; 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.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.meta_ptr = type { i64, %union.anon.24, i64 }
%union.anon.24 = type { ptr }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@__func__.mdbx_env_open = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @log_if_error(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @mdbx_env_open(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = alloca %struct.troika, align 8
  %6 = alloca %struct.meta_ptr, align 8
  %7 = tail call i32 @check_env(ptr noundef %0, i1 noundef zeroext false)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %10, label %8, !prof !5

8:                                                ; preds = %4
  %9 = tail call i32 @log_if_error(i32 noundef %7, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 442)
  br label %105

10:                                               ; preds = %4
  %11 = and i32 %2, -1342136321
  %.not62 = icmp eq i32 %11, 0
  br i1 %.not62, label %14, label %12, !prof !5

12:                                               ; preds = %10
  %13 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 445)
  br label %105

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = load i32, ptr %16, align 8, !tbaa !6
  %.not63 = icmp eq i32 %17, -1
  br i1 %.not63, label %18, label %.critedge, !prof !5

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %0, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !22
  %21 = and i32 %20, 536870912
  %.not64 = icmp eq i32 %21, 0
  br i1 %.not64, label %22, label %.critedge, !prof !5

22:                                               ; preds = %18
  %23 = load ptr, ptr %15, align 8, !tbaa !23
  %.not103 = icmp eq ptr %23, null
  br i1 %.not103, label %25, label %.critedge, !prof !5

.critedge:                                        ; preds = %18, %14, %22
  %24 = tail call i32 @log_if_error(i32 noundef 1, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 448)
  br label %105

25:                                               ; preds = %22
  %26 = or i32 %2, 33554432
  %27 = tail call i32 @combine_durability_flags(i32 noundef %26, i32 noundef %20) #5
  %28 = and i32 %27, 131072
  %.not65 = icmp eq i32 %28, 0
  %29 = and i32 %27, -1193082881
  %spec.select = select i1 %.not65, i32 %3, i32 0
  %spec.select71 = select i1 %.not65, i32 %27, i32 %29
  %30 = and i32 %spec.select71, 2147483647
  store i32 %30, ptr %19, align 4, !tbaa !22
  %31 = tail call i32 @env_handle_pathname(ptr noundef nonnull %0, ptr noundef %1, i32 noundef %spec.select) #6
  %.not66 = icmp eq i32 %31, 0
  br i1 %.not66, label %32, label %.critedge74, !prof !5

32:                                               ; preds = %25
  %33 = getelementptr inbounds i8, ptr %0, i64 136
  %34 = load i32, ptr %33, align 8, !tbaa !24
  %35 = zext i32 %34 to i64
  %36 = tail call noalias ptr @calloc(i64 noundef %35, i64 noundef 64) #7
  %37 = getelementptr inbounds i8, ptr %0, i64 200
  store ptr %36, ptr %37, align 8, !tbaa !25
  %38 = tail call noalias ptr @calloc(i64 noundef %35, i64 noundef 1) #7
  %39 = getelementptr inbounds i8, ptr %0, i64 208
  store ptr %38, ptr %39, align 8, !tbaa !26
  %40 = tail call noalias ptr @calloc(i64 noundef %35, i64 noundef 4) #7
  %41 = getelementptr inbounds i8, ptr %0, i64 216
  store ptr %40, ptr %41, align 8, !tbaa !27
  %.not67 = icmp eq ptr %36, null
  br i1 %.not67, label %.critedge74, label %42, !prof !28

42:                                               ; preds = %32
  %.not68 = icmp ne ptr %38, null
  %43 = icmp ne ptr %40, null
  %spec.select72 = and i1 %.not68, %43
  br i1 %spec.select72, label %44, label %.critedge74, !prof !5

44:                                               ; preds = %42
  %45 = and i32 %spec.select71, 131072
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %52

47:                                               ; preds = %44
  %48 = tail call ptr @txn_basal_create(i64 noundef %35) #5
  %49 = getelementptr inbounds i8, ptr %0, i64 192
  store ptr %48, ptr %49, align 8, !tbaa !29
  %.not69 = icmp eq ptr %48, null
  br i1 %.not69, label %.critedge74, label %50, !prof !28

50:                                               ; preds = %47
  %51 = getelementptr inbounds i8, ptr %48, i64 80
  store ptr %0, ptr %51, align 8, !tbaa !30
  tail call void @env_options_adjust_defaults(ptr noundef nonnull %0) #5
  br label %52

52:                                               ; preds = %50, %44
  %53 = tail call i32 @env_open(ptr noundef nonnull %0, i32 noundef %spec.select) #5
  %.not70 = icmp eq i32 %53, 0
  br i1 %.not70, label %54, label %.critedge74, !prof !5

54:                                               ; preds = %52
  call void @meta_tap(ptr dead_on_unwind nonnull writable sret(%struct.troika) align 8 %5, ptr noundef nonnull %0) #5
  call void @meta_recent(ptr dead_on_unwind nonnull writable sret(%struct.meta_ptr) align 8 %6, ptr noundef nonnull %0, ptr noundef nonnull %5)
  %55 = getelementptr inbounds i8, ptr %6, i64 8
  %56 = load ptr, ptr %55, align 8, !tbaa !23
  %57 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %58 = icmp ugt i8 %57, 4
  br i1 %58, label %59, label %.thread93, !prof !28

59:                                               ; preds = %54
  %60 = call i64 @unaligned_peek_u64(i64 noundef 4, ptr noundef %56) #8
  %61 = trunc i64 %60 to i32
  %62 = and i32 %61, 255
  %63 = getelementptr inbounds i8, ptr %0, i64 8
  %64 = load i32, ptr %63, align 8, !tbaa !36
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 510, ptr noundef nonnull @.str.3, i32 noundef %62, i32 noundef %64) #5
  %.pr = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %65 = icmp ugt i8 %.pr, 4
  br i1 %65, label %66, label %.thread93, !prof !37

66:                                               ; preds = %59
  %67 = load ptr, ptr %55, align 8, !tbaa !23
  %68 = call ptr @data_page(ptr noundef %67) #8
  %69 = getelementptr inbounds i8, ptr %68, i64 16
  %70 = load i32, ptr %69, align 1, !tbaa !38
  %71 = load i64, ptr %6, align 8, !tbaa !39
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 511, ptr noundef nonnull @.str.4, i32 noundef %70, i64 noundef %71) #5
  %.pr75 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %72 = icmp ugt i8 %.pr75, 4
  br i1 %72, label %.thread76, label %.thread93, !prof !37

.thread76:                                        ; preds = %66
  %73 = getelementptr inbounds i8, ptr %56, i64 90
  %74 = load i16, ptr %73, align 2, !tbaa !41
  %75 = zext i16 %74 to i32
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 512, ptr noundef nonnull @.str.5, i32 noundef %75) #5
  %.pr77.pr = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %76 = icmp ugt i8 %.pr77.pr, 4
  br i1 %76, label %77, label %.thread93, !prof !43

77:                                               ; preds = %.thread76
  %78 = getelementptr inbounds i8, ptr %56, i64 120
  %79 = load i64, ptr %78, align 4, !tbaa !44
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 513, ptr noundef nonnull @.str.6, i64 noundef %79) #5
  %.pr79 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %80 = icmp ugt i8 %.pr79, 4
  br i1 %80, label %.thread81, label %.thread93, !prof !37

.thread81:                                        ; preds = %77
  %81 = getelementptr inbounds i8, ptr %56, i64 100
  %82 = load i32, ptr %81, align 4, !tbaa !45
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 514, ptr noundef nonnull @.str.7, i32 noundef %82) #5
  %.pr83.pr.pr = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %83 = icmp ugt i8 %.pr83.pr.pr, 4
  br i1 %83, label %84, label %.thread93, !prof !46

84:                                               ; preds = %.thread81
  %85 = getelementptr inbounds i8, ptr %56, i64 104
  %86 = load i32, ptr %85, align 4, !tbaa !47
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 515, ptr noundef nonnull @.str.8, i32 noundef %86) #5
  %.pr85 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %87 = icmp ugt i8 %.pr85, 4
  br i1 %87, label %.thread87, label %.thread93, !prof !37

.thread87:                                        ; preds = %84
  %88 = getelementptr inbounds i8, ptr %56, i64 108
  %89 = load i32, ptr %88, align 4, !tbaa !48
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 516, ptr noundef nonnull @.str.9, i32 noundef %89) #5
  %.pr89.pr.pr = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %90 = icmp ugt i8 %.pr89.pr.pr, 4
  br i1 %90, label %91, label %.thread93, !prof !37

91:                                               ; preds = %.thread87
  %92 = getelementptr inbounds i8, ptr %56, i64 96
  %93 = load i32, ptr %92, align 4, !tbaa !49
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 517, ptr noundef nonnull @.str.10, i32 noundef %93) #5
  %.pr91 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !34
  %94 = icmp ugt i8 %.pr91, 4
  br i1 %94, label %95, label %.thread93, !prof !37

95:                                               ; preds = %91
  %96 = getelementptr inbounds i8, ptr %56, i64 128
  %97 = load i64, ptr %96, align 4, !tbaa !50
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 518, ptr noundef nonnull @.str.11, i64 noundef %97) #5
  br label %.thread93

.thread93:                                        ; preds = %66, %.thread76, %54, %59, %.thread81, %77, %84, %.thread87, %91, %95
  call void @dxb_sanitize_tail(ptr noundef nonnull %0, ptr noundef null)
  br label %103

.critedge74:                                      ; preds = %32, %47, %42, %52, %25
  %.056 = phi i32 [ %31, %25 ], [ %53, %52 ], [ 12, %42 ], [ 12, %47 ], [ 12, %32 ]
  %98 = tail call i32 @env_close(ptr noundef nonnull %0, i1 noundef zeroext false) #5
  %99 = icmp eq i32 %98, 0
  br i1 %99, label %100, label %101, !prof !5

100:                                              ; preds = %.critedge74
  store i32 %20, ptr %19, align 4, !tbaa !22
  br label %103

101:                                              ; preds = %.critedge74
  %102 = or i32 %20, -2147483648
  store i32 %102, ptr %19, align 4, !tbaa !22
  br label %103

103:                                              ; preds = %100, %101, %.thread93
  %.1 = phi i32 [ %.056, %100 ], [ -30795, %101 ], [ 0, %.thread93 ]
  %104 = call i32 @log_if_error(i32 noundef %.1, ptr noundef nonnull @__func__.mdbx_env_open, i32 noundef 532)
  br label %105

105:                                              ; preds = %103, %.critedge, %12, %8
  %.0 = phi i32 [ %9, %8 ], [ %13, %12 ], [ %24, %.critedge ], [ %104, %103 ]
  ret i32 %.0
}

; Function Attrs: cold nounwind optsize uwtable
declare hidden i32 @env_handle_pathname(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @combine_durability_flags(i32 noundef, i32 noundef) local_unnamed_addr #1

declare ptr @txn_basal_create(i64 noundef) local_unnamed_addr #1

declare void @env_options_adjust_defaults(ptr noundef) local_unnamed_addr #1

declare i32 @env_open(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @meta_tap(ptr dead_on_unwind writable sret(%struct.troika) align 8, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @meta_recent(ptr dead_on_unwind noalias writable sret(%struct.meta_ptr) align 8, ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @dxb_sanitize_tail(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @env_close(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #4 = { inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { cold }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { nounwind willreturn memory(read) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!7, !10, i64 24}
!7 = !{!"MDBX_env", !8, i64 0, !10, i64 4, !10, i64 8, !11, i64 16, !10, i64 56, !10, i64 60, !11, i64 64, !13, i64 104, !14, i64 112, !14, i64 114, !14, i64 116, !14, i64 118, !14, i64 120, !14, i64 122, !8, i64 124, !8, i64 128, !8, i64 129, !14, i64 130, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !15, i64 152, !13, i64 184, !13, i64 192, !13, i64 200, !13, i64 208, !13, i64 216, !10, i64 224, !10, i64 228, !10, i64 232, !13, i64 240, !13, i64 248, !12, i64 256, !16, i64 264, !19, i64 320, !17, i64 360, !13, i64 368, !13, i64 376, !13, i64 384, !20, i64 392, !8, i64 400, !10, i64 440, !10, i64 444, !13, i64 448, !21, i64 456, !8, i64 496, !8, i64 536}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"osal_mmap", !8, i64 0, !10, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!12 = !{!"long", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"short", !8, i64 0}
!15 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!16 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !12, i64 16, !8, i64 24, !8, i64 25, !8, i64 26, !8, i64 27, !10, i64 28, !10, i64 32, !17, i64 36, !17, i64 37, !17, i64 38, !18, i64 40, !8, i64 48}
!17 = !{!"_Bool", !8, i64 0}
!18 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6}
!19 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!20 = !{!"", !12, i64 0}
!21 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!22 = !{!7, !10, i64 4}
!23 = !{!8, !8, i64 0}
!24 = !{!7, !10, i64 136}
!25 = !{!7, !13, i64 200}
!26 = !{!7, !13, i64 208}
!27 = !{!7, !13, i64 216}
!28 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!29 = !{!7, !13, i64 192}
!30 = !{!31, !13, i64 80}
!31 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !12, i64 8, !12, i64 16, !13, i64 24, !13, i64 32, !32, i64 40, !12, i64 64, !12, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !33, i64 128, !13, i64 160, !8, i64 168}
!32 = !{!"geo", !14, i64 0, !14, i64 2, !10, i64 4, !10, i64 8, !8, i64 12, !8, i64 16}
!33 = !{!"MDBX_canary", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!34 = !{!35, !8, i64 26}
!35 = !{!"libmdbx_globals", !8, i64 0, !10, i64 16, !10, i64 20, !8, i64 24, !8, i64 25, !8, i64 26, !17, i64 27, !10, i64 28, !8, i64 32, !8, i64 40, !12, i64 80, !13, i64 88}
!36 = !{!7, !10, i64 8}
!37 = !{!"branch_weights", !"expected", i32 -2147483648, i32 0}
!38 = !{!10, !10, i64 0}
!39 = !{!40, !12, i64 0}
!40 = !{!"meta_ptr", !12, i64 0, !8, i64 8, !12, i64 16}
!41 = !{!42, !14, i64 2}
!42 = !{!"tree", !14, i64 0, !14, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !12, i64 24, !12, i64 32, !12, i64 40}
!43 = !{!"branch_weights", !"expected", i32 2147481647, i32 2001}
!44 = !{!42, !12, i64 32}
!45 = !{!42, !10, i64 12}
!46 = !{!"branch_weights", !"expected", i32 2147481646, i32 2002}
!47 = !{!42, !10, i64 16}
!48 = !{!42, !10, i64 20}
!49 = !{!42, !10, i64 8}
!50 = !{!42, !12, i64 40}


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