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

; 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.MDBX_chk_context = type { ptr, ptr, ptr, ptr, i8, %struct.anon.7 }
%struct.anon.7 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr }
%struct.MDBX_chk_internal = type { ptr, ptr, i64, ptr, i8, i8, i8, i8, %struct.MDBX_chk_table, %struct.MDBX_chk_table, ptr, ptr, ptr, [12 x %struct.MDBX_chk_scope], [32767 x ptr], %struct.MDBX_envinfo, %struct.troika, %struct.iovec }
%struct.MDBX_chk_table = type { ptr, %struct.iovec, i32, i32, i64, i64, %struct.anon, %struct.anon.0 }
%struct.anon = type { i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.anon.0 = type { %struct.MDBX_chk_histogram, %struct.MDBX_chk_histogram, %struct.MDBX_chk_histogram, %struct.MDBX_chk_histogram, %struct.MDBX_chk_histogram, %struct.MDBX_chk_histogram }
%struct.MDBX_chk_histogram = type { i64, i64, i64, i64, [9 x %struct.anon.1] }
%struct.anon.1 = type { i64, i64, i64, i64 }
%struct.MDBX_chk_scope = type { ptr, ptr, ptr, i32, i32, i64, %union.anon, %union.anon, %union.anon }
%union.anon = type { ptr }
%struct.MDBX_envinfo = type { %struct.anon.2, i64, i64, i64, i64, i64, [3 x i64], [3 x i64], i32, i32, i32, i32, %struct.anon.3, i64, i64, i32, i32, i32, i32, %struct.anon.5, %struct.anon.6 }
%struct.anon.2 = type { i64, i64, i64, i64, i64 }
%struct.anon.3 = type { %struct.anon.4, [3 x %struct.anon.4] }
%struct.anon.4 = type { i64, i64 }
%struct.anon.5 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.anon.6 = type { i64, i64 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.iovec = type { ptr, 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.9, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.10, %struct.anon.14, i8, ptr, ptr, ptr, %struct.anon.15, %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.8, i32, i64, i64, i64 }
%union.anon.8 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.9 = type { ptr, ptr, ptr, ptr }
%struct.anon.10 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.11, %union.anon.12 }
%struct.anon.11 = type { i16, i16, i16, i16 }
%union.anon.12 = type { i32 }
%struct.anon.14 = type { i64, i64, i64, i64, i64 }
%struct.anon.15 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, 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 }
%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.16, %union.anon.17 }
%union.anon.16 = type { i32 }
%union.anon.17 = 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.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }

@__func__.mdbx_env_chk = external hidden unnamed_addr constant [13 x i8], align 1
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1

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

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

29:                                               ; preds = %6
  %30 = load i32, ptr %15, align 4, !tbaa !9
  %31 = call i32 @log_if_error(i32 noundef %30, ptr noundef @__func__.mdbx_env_chk, i32 noundef 1747)
  store i32 %31, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %338

32:                                               ; preds = %6
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %43

35:                                               ; preds = %32
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %43

38:                                               ; preds = %35
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.MDBX_chk_context, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = icmp ne ptr %41, null
  br label %43

43:                                               ; preds = %38, %35, %32
  %44 = phi i1 [ true, %35 ], [ true, %32 ], [ %42, %38 ]
  %45 = xor i1 %44, true
  %46 = xor i1 %45, true
  %47 = zext i1 %46 to i32
  %48 = sext i32 %47 to i64
  %49 = call i64 @llvm.expect.i64(i64 %48, i64 0)
  %50 = icmp ne i64 %49, 0
  br i1 %50, label %51, label %53

51:                                               ; preds = %43
  %52 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_env_chk, i32 noundef 1749)
  store i32 %52, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %338

53:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %54 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 267432) #7
  store ptr %54, ptr %17, align 8, !tbaa !5
  %55 = load ptr, ptr %17, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  %57 = xor i1 %56, true
  %58 = xor i1 %57, true
  %59 = xor i1 %58, true
  %60 = zext i1 %59 to i32
  %61 = sext i32 %60 to i64
  %62 = call i64 @llvm.expect.i64(i64 %61, i64 0)
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %53
  %65 = call i32 @log_if_error(i32 noundef 12, ptr noundef @__func__.mdbx_env_chk, i32 noundef 1753)
  store i32 %65, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %337

66:                                               ; preds = %53
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load ptr, ptr %17, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %68, i32 0, i32 1
  store ptr %67, ptr %69, align 8, !tbaa !15
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %71, i32 0, i32 0
  store ptr %70, ptr %72, align 8, !tbaa !29
  %73 = load ptr, ptr %17, align 8, !tbaa !5
  %74 = load ptr, ptr %17, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !29
  %77 = getelementptr inbounds %struct.MDBX_chk_context, ptr %76, i32 0, i32 0
  store ptr %73, ptr %77, align 8, !tbaa !11
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !29
  %82 = getelementptr inbounds %struct.MDBX_chk_context, ptr %81, i32 0, i32 1
  store ptr %78, ptr %82, align 8, !tbaa !30
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = trunc i32 %83 to i8
  %85 = load ptr, ptr %17, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %85, i32 0, i32 4
  store i8 %84, ptr %86, align 8, !tbaa !31
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %87, i32 0, i32 8
  %89 = getelementptr inbounds %struct.MDBX_chk_table, ptr %88, i32 0, i32 3
  store i32 -1, ptr %89, align 4, !tbaa !32
  %90 = load ptr, ptr %17, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %90, i32 0, i32 8
  %92 = getelementptr inbounds %struct.MDBX_chk_table, ptr %91, i32 0, i32 1
  %93 = getelementptr inbounds %struct.iovec, ptr %92, i32 0, i32 0
  store ptr inttoptr (i64 -1 to ptr), ptr %93, align 8, !tbaa !33
  %94 = load ptr, ptr %17, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %94, i32 0, i32 8
  %96 = load ptr, ptr %17, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %96, i32 0, i32 14
  %98 = getelementptr inbounds [32767 x ptr], ptr %97, i64 0, i64 0
  store ptr %95, ptr %98, align 8, !tbaa !5
  %99 = load ptr, ptr %17, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %99, i32 0, i32 9
  %101 = getelementptr inbounds %struct.MDBX_chk_table, ptr %100, i32 0, i32 3
  store i32 -1, ptr %101, align 4, !tbaa !34
  %102 = load ptr, ptr %17, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %102, i32 0, i32 9
  %104 = getelementptr inbounds %struct.MDBX_chk_table, ptr %103, i32 0, i32 1
  %105 = getelementptr inbounds %struct.iovec, ptr %104, i32 0, i32 0
  store ptr null, ptr %105, align 8, !tbaa !35
  %106 = load ptr, ptr %17, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %106, i32 0, i32 9
  %108 = load ptr, ptr %17, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %108, i32 0, i32 14
  %110 = getelementptr inbounds [32767 x ptr], ptr %109, i64 0, i64 1
  store ptr %107, ptr %110, align 8, !tbaa !5
  %111 = load i32, ptr %13, align 4, !tbaa !9
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %113, label %118

113:                                              ; preds = %66
  %114 = load i32, ptr %13, align 4, !tbaa !9
  %115 = call i64 @osal_16dot16_to_monotime(i32 noundef %114)
  %116 = call i64 @osal_monotime()
  %117 = add i64 %115, %116
  br label %119

118:                                              ; preds = %66
  br label %119

119:                                              ; preds = %118, %113
  %120 = phi i64 [ %117, %113 ], [ 0, %118 ]
  %121 = load ptr, ptr %17, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %121, i32 0, i32 2
  store i64 %120, ptr %122, align 8, !tbaa !36
  %123 = load ptr, ptr %17, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !29
  %126 = getelementptr inbounds %struct.MDBX_chk_context, ptr %125, i32 0, i32 4
  store i8 0, ptr %126, align 8, !tbaa !37
  %127 = load ptr, ptr %17, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %127, i32 0, i32 14
  %129 = load ptr, ptr %17, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !29
  %132 = getelementptr inbounds %struct.MDBX_chk_context, ptr %131, i32 0, i32 5
  %133 = getelementptr inbounds %struct.anon.7, ptr %132, i32 0, i32 19
  store ptr %128, ptr %133, align 8, !tbaa !38
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %134 = load ptr, ptr %17, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %134, i32 0, i32 13
  %136 = getelementptr inbounds [12 x %struct.MDBX_chk_scope], ptr %135, i64 0, i64 0
  store ptr %136, ptr %18, align 8, !tbaa !5
  %137 = load i32, ptr %12, align 4, !tbaa !9
  %138 = load ptr, ptr %18, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.MDBX_chk_scope, ptr %138, i32 0, i32 4
  store i32 %137, ptr %139, align 4, !tbaa !39
  %140 = load ptr, ptr %17, align 8, !tbaa !5
  %141 = load ptr, ptr %18, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.MDBX_chk_scope, ptr %141, i32 0, i32 1
  store ptr %140, ptr %142, align 8, !tbaa !41
  %143 = load ptr, ptr %17, align 8, !tbaa !5
  %144 = load ptr, ptr %17, align 8, !tbaa !5
  %145 = call i32 (ptr, i32, i32, ptr, ptr, ptr, ...) @chk_scope_begin(ptr noundef %144, i32 noundef 0, i32 noundef 1, ptr noundef null, ptr noundef null, ptr noundef null) #8
  %146 = call i32 @chk_scope_end(ptr noundef %143, i32 noundef %145) #8
  store i32 %146, ptr %15, align 4, !tbaa !9
  %147 = load i32, ptr %15, align 4, !tbaa !9
  %148 = icmp ne i32 %147, 0
  %149 = xor i1 %148, true
  %150 = xor i1 %149, true
  %151 = xor i1 %150, true
  %152 = zext i1 %151 to i32
  %153 = sext i32 %152 to i64
  %154 = call i64 @llvm.expect.i64(i64 %153, i64 1)
  %155 = icmp ne i64 %154, 0
  br i1 %155, label %156, label %166

156:                                              ; preds = %119
  %157 = load ptr, ptr %17, align 8, !tbaa !5
  %158 = load ptr, ptr %8, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.MDBX_env, ptr %158, i32 0, i32 1
  %160 = load i32, ptr %159, align 4, !tbaa !42
  %161 = and i32 %160, 4325376
  %162 = icmp ne i32 %161, 0
  %163 = zext i1 %162 to i64
  %164 = select i1 %162, ptr @.str.1, ptr @.str.2
  %165 = call i32 (ptr, i32, i32, ptr, ptr, ptr, ...) @chk_scope_begin(ptr noundef %157, i32 noundef 0, i32 noundef 2, ptr noundef null, ptr noundef null, ptr noundef @.str, ptr noundef %164) #8
  store i32 %165, ptr %15, align 4, !tbaa !9
  br label %166

166:                                              ; preds = %156, %119
  %167 = load i32, ptr %15, align 4, !tbaa !9
  %168 = icmp ne i32 %167, 0
  %169 = xor i1 %168, true
  %170 = xor i1 %169, true
  %171 = xor i1 %170, true
  %172 = zext i1 %171 to i32
  %173 = sext i32 %172 to i64
  %174 = call i64 @llvm.expect.i64(i64 %173, i64 1)
  %175 = icmp ne i64 %174, 0
  br i1 %175, label %176, label %207

176:                                              ; preds = %166
  %177 = load ptr, ptr %8, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.MDBX_env, ptr %177, i32 0, i32 1
  %179 = load i32, ptr %178, align 4, !tbaa !42
  %180 = and i32 %179, 4325376
  %181 = icmp eq i32 %180, 0
  br i1 %181, label %182, label %207

182:                                              ; preds = %176
  %183 = load i32, ptr %11, align 4, !tbaa !9
  %184 = and i32 %183, 1
  %185 = icmp ne i32 %184, 0
  br i1 %185, label %186, label %207

186:                                              ; preds = %182
  %187 = load ptr, ptr %8, align 8, !tbaa !5
  %188 = call i32 @mdbx_txn_lock(ptr noundef %187, i1 noundef zeroext false)
  store i32 %188, ptr %15, align 4, !tbaa !9
  %189 = load i32, ptr %15, align 4, !tbaa !9
  %190 = icmp ne i32 %189, 0
  %191 = xor i1 %190, true
  %192 = xor i1 %191, true
  %193 = zext i1 %192 to i32
  %194 = sext i32 %193 to i64
  %195 = call i64 @llvm.expect.i64(i64 %194, i64 0)
  %196 = icmp ne i64 %195, 0
  br i1 %196, label %197, label %203

197:                                              ; preds = %186
  %198 = load ptr, ptr %10, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.MDBX_chk_context, ptr %198, i32 0, i32 3
  %200 = load ptr, ptr %199, align 8, !tbaa !51
  %201 = load i32, ptr %15, align 4, !tbaa !9
  %202 = call i32 @chk_error_rc(ptr noundef %200, i32 noundef %201, ptr noundef @.str.3) #8
  br label %206

203:                                              ; preds = %186
  %204 = load ptr, ptr %17, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %204, i32 0, i32 6
  store i8 1, ptr %205, align 2, !tbaa !52
  br label %206

206:                                              ; preds = %203, %197
  br label %207

207:                                              ; preds = %206, %182, %176, %166
  %208 = load i32, ptr %15, align 4, !tbaa !9
  %209 = icmp ne i32 %208, 0
  %210 = xor i1 %209, true
  %211 = xor i1 %210, true
  %212 = xor i1 %211, true
  %213 = zext i1 %212 to i32
  %214 = sext i32 %213 to i64
  %215 = call i64 @llvm.expect.i64(i64 %214, i64 1)
  %216 = icmp ne i64 %215, 0
  br i1 %216, label %217, label %237

217:                                              ; preds = %207
  %218 = load ptr, ptr %8, align 8, !tbaa !5
  %219 = load ptr, ptr %10, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.MDBX_chk_context, ptr %219, i32 0, i32 2
  %221 = call i32 @mdbx_txn_begin(ptr noundef %218, ptr noundef null, i32 noundef 131072, ptr noundef %220)
  store i32 %221, ptr %15, align 4, !tbaa !9
  %222 = load i32, ptr %15, align 4, !tbaa !9
  %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 0)
  %229 = icmp ne i64 %228, 0
  br i1 %229, label %230, label %236

230:                                              ; preds = %217
  %231 = load ptr, ptr %10, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.MDBX_chk_context, ptr %231, i32 0, i32 3
  %233 = load ptr, ptr %232, align 8, !tbaa !51
  %234 = load i32, ptr %15, align 4, !tbaa !9
  %235 = call i32 @chk_error_rc(ptr noundef %233, i32 noundef %234, ptr noundef @.str.4) #8
  br label %236

236:                                              ; preds = %230, %217
  br label %237

237:                                              ; preds = %236, %207
  %238 = load ptr, ptr %17, align 8, !tbaa !5
  %239 = load i32, ptr %15, align 4, !tbaa !9
  %240 = call i32 @chk_scope_end(ptr noundef %238, i32 noundef %239) #8
  %241 = load i32, ptr %15, align 4, !tbaa !9
  %242 = icmp ne i32 %241, 0
  %243 = xor i1 %242, true
  %244 = xor i1 %243, true
  %245 = xor i1 %244, true
  %246 = zext i1 %245 to i32
  %247 = sext i32 %246 to i64
  %248 = call i64 @llvm.expect.i64(i64 %247, i64 1)
  %249 = icmp ne i64 %248, 0
  br i1 %249, label %250, label %277

250:                                              ; preds = %237
  %251 = load ptr, ptr %10, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.MDBX_chk_context, ptr %251, i32 0, i32 2
  %253 = load ptr, ptr %252, align 8, !tbaa !53
  %254 = getelementptr inbounds %struct.MDBX_txn, ptr %253, i32 0, i32 10
  %255 = load ptr, ptr %254, align 8, !tbaa !54
  %256 = getelementptr inbounds %struct.tree, ptr %255, i64 0
  %257 = getelementptr inbounds %struct.tree, ptr %256, i32 0, i32 0
  %258 = load i16, ptr %257, align 4, !tbaa !58
  %259 = zext i16 %258 to i32
  %260 = load ptr, ptr %17, align 8, !tbaa !5
  %261 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %260, i32 0, i32 8
  %262 = getelementptr inbounds %struct.MDBX_chk_table, ptr %261, i32 0, i32 2
  store i32 %259, ptr %262, align 8, !tbaa !60
  %263 = load ptr, ptr %10, align 8, !tbaa !5
  %264 = getelementptr inbounds %struct.MDBX_chk_context, ptr %263, i32 0, i32 2
  %265 = load ptr, ptr %264, align 8, !tbaa !53
  %266 = getelementptr inbounds %struct.MDBX_txn, ptr %265, i32 0, i32 10
  %267 = load ptr, ptr %266, align 8, !tbaa !54
  %268 = getelementptr inbounds %struct.tree, ptr %267, i64 1
  %269 = getelementptr inbounds %struct.tree, ptr %268, i32 0, i32 0
  %270 = load i16, ptr %269, align 4, !tbaa !58
  %271 = zext i16 %270 to i32
  %272 = load ptr, ptr %17, align 8, !tbaa !5
  %273 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %272, i32 0, i32 9
  %274 = getelementptr inbounds %struct.MDBX_chk_table, ptr %273, i32 0, i32 2
  store i32 %271, ptr %274, align 8, !tbaa !61
  %275 = load ptr, ptr %18, align 8, !tbaa !5
  %276 = call i32 @env_chk(ptr noundef %275) #8
  store i32 %276, ptr %15, align 4, !tbaa !9
  br label %277

277:                                              ; preds = %250, %237
  %278 = load ptr, ptr %10, align 8, !tbaa !5
  %279 = getelementptr inbounds %struct.MDBX_chk_context, ptr %278, i32 0, i32 2
  %280 = load ptr, ptr %279, align 8, !tbaa !53
  %281 = icmp ne ptr %280, null
  br i1 %281, label %287, label %282

282:                                              ; preds = %277
  %283 = load ptr, ptr %17, align 8, !tbaa !5
  %284 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %283, i32 0, i32 6
  %285 = load i8, ptr %284, align 2, !tbaa !52, !range !62, !noundef !63
  %286 = trunc i8 %285 to i1
  br i1 %286, label %287, label %321

287:                                              ; preds = %282, %277
  %288 = load ptr, ptr %17, align 8, !tbaa !5
  %289 = call i32 (ptr, i32, i32, ptr, ptr, ptr, ...) @chk_scope_begin(ptr noundef %288, i32 noundef 0, i32 noundef 10, ptr noundef null, ptr noundef null, ptr noundef null) #8
  %290 = load ptr, ptr %10, align 8, !tbaa !5
  %291 = getelementptr inbounds %struct.MDBX_chk_context, ptr %290, i32 0, i32 2
  %292 = load ptr, ptr %291, align 8, !tbaa !53
  %293 = icmp ne ptr %292, null
  br i1 %293, label %294, label %309

294:                                              ; preds = %287
  %295 = load ptr, ptr %10, align 8, !tbaa !5
  %296 = getelementptr inbounds %struct.MDBX_chk_context, ptr %295, i32 0, i32 2
  %297 = load ptr, ptr %296, align 8, !tbaa !53
  %298 = call i32 @mdbx_txn_abort(ptr noundef %297)
  store i32 %298, ptr %14, align 4, !tbaa !9
  %299 = load i32, ptr %14, align 4, !tbaa !9
  %300 = icmp ne i32 %299, 0
  br i1 %300, label %301, label %306

301:                                              ; preds = %294
  %302 = load i32, ptr %15, align 4, !tbaa !9
  %303 = icmp ne i32 %302, 0
  br i1 %303, label %306, label %304

304:                                              ; preds = %301
  %305 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %305, ptr %15, align 4, !tbaa !9
  br label %306

306:                                              ; preds = %304, %301, %294
  %307 = load ptr, ptr %10, align 8, !tbaa !5
  %308 = getelementptr inbounds %struct.MDBX_chk_context, ptr %307, i32 0, i32 2
  store ptr null, ptr %308, align 8, !tbaa !53
  br label %309

309:                                              ; preds = %306, %287
  %310 = load ptr, ptr %17, align 8, !tbaa !5
  %311 = getelementptr inbounds %struct.MDBX_chk_internal, ptr %310, i32 0, i32 6
  %312 = load i8, ptr %311, align 2, !tbaa !52, !range !62, !noundef !63
  %313 = trunc i8 %312 to i1
  br i1 %313, label %314, label %317

314:                                              ; preds = %309
  %315 = load ptr, ptr %8, align 8, !tbaa !5
  %316 = call i32 @mdbx_txn_unlock(ptr noundef %315)
  br label %317

317:                                              ; preds = %314, %309
  %318 = load ptr, ptr %17, align 8, !tbaa !5
  %319 = load i32, ptr %15, align 4, !tbaa !9
  %320 = call i32 @chk_scope_end(ptr noundef %318, i32 noundef %319) #8
  store i32 %320, ptr %15, align 4, !tbaa !9
  br label %321

321:                                              ; preds = %317, %282
  %322 = load ptr, ptr %17, align 8, !tbaa !5
  %323 = call i32 (ptr, i32, i32, ptr, ptr, ptr, ...) @chk_scope_begin(ptr noundef %322, i32 noundef 0, i32 noundef 11, ptr noundef null, ptr noundef null, ptr noundef null) #8
  store i32 %323, ptr %14, align 4, !tbaa !9
  %324 = load ptr, ptr %17, align 8, !tbaa !5
  %325 = load i32, ptr %14, align 4, !tbaa !9
  %326 = icmp ne i32 %325, 0
  br i1 %326, label %327, label %329

327:                                              ; preds = %321
  %328 = load i32, ptr %14, align 4, !tbaa !9
  br label %331

329:                                              ; preds = %321
  %330 = load i32, ptr %15, align 4, !tbaa !9
  br label %331

331:                                              ; preds = %329, %327
  %332 = phi i32 [ %328, %327 ], [ %330, %329 ]
  %333 = call i32 @chk_scope_end(ptr noundef %324, i32 noundef %332) #8
  store i32 %333, ptr %15, align 4, !tbaa !9
  %334 = load ptr, ptr %17, align 8, !tbaa !5
  call void @chk_dispose(ptr noundef %334) #8
  %335 = load i32, ptr %15, align 4, !tbaa !9
  %336 = call i32 @log_if_error(i32 noundef %335, ptr noundef @__func__.mdbx_env_chk, i32 noundef 1824)
  store i32 %336, ptr %7, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %337

337:                                              ; preds = %331, %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %338

338:                                              ; preds = %337, %51, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  %339 = load i32, ptr %7, align 4
  ret i32 %339
}

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

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

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

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

declare i64 @osal_16dot16_to_monotime(i32 noundef) #5

declare i64 @osal_monotime() #5

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

; Function Attrs: cold nounwind optsize uwtable
declare hidden i32 @chk_scope_begin(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ...) #1

declare i32 @mdbx_txn_lock(ptr noundef, i1 noundef zeroext) #5

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

declare i32 @mdbx_txn_begin(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

; Function Attrs: cold nounwind optsize uwtable
declare hidden i32 @env_chk(ptr noundef) #1

declare i32 @mdbx_txn_abort(ptr noundef) #5

declare i32 @mdbx_txn_unlock(ptr noundef) #5

; Function Attrs: cold nounwind optsize uwtable
declare hidden void @chk_dispose(ptr noundef) #1

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

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

!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, !6, i64 0}
!12 = !{!"MDBX_chk_context", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !13, i64 40}
!13 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !6, i64 152}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"MDBX_chk_internal", !6, i64 0, !6, i64 8, !14, i64 16, !6, i64 24, !7, i64 32, !17, i64 33, !17, i64 34, !7, i64 35, !18, i64 40, !18, i64 2072, !6, i64 4104, !6, i64 4112, !6, i64 4120, !7, i64 4128, !7, i64 4896, !23, i64 267032, !28, i64 267384, !19, i64 267416}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{!"MDBX_chk_table", !6, i64 0, !19, i64 8, !10, i64 24, !10, i64 28, !14, i64 32, !14, i64 40, !20, i64 48, !21, i64 112}
!19 = !{!"iovec", !6, i64 0, !14, i64 8}
!20 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56}
!21 = !{!"", !22, i64 0, !22, i64 320, !22, i64 640, !22, i64 960, !22, i64 1280, !22, i64 1600}
!22 = !{!"MDBX_chk_histogram", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !7, i64 32}
!23 = !{!"MDBX_envinfo", !24, i64 0, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !7, i64 80, !7, i64 104, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !25, i64 144, !14, i64 208, !14, i64 216, !10, i64 224, !10, i64 228, !10, i64 232, !10, i64 236, !27, i64 240, !26, i64 336}
!24 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!25 = !{!"", !26, i64 0, !7, i64 16}
!26 = !{!"", !14, i64 0, !14, i64 8}
!27 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88}
!28 = !{!"troika", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !10, i64 4, !7, i64 8}
!29 = !{!16, !6, i64 0}
!30 = !{!12, !6, i64 8}
!31 = !{!16, !7, i64 32}
!32 = !{!16, !10, i64 68}
!33 = !{!16, !6, i64 48}
!34 = !{!16, !10, i64 2100}
!35 = !{!16, !6, i64 2080}
!36 = !{!16, !14, i64 16}
!37 = !{!12, !7, i64 32}
!38 = !{!12, !6, i64 192}
!39 = !{!40, !10, i64 28}
!40 = !{!"MDBX_chk_scope", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !14, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!41 = !{!40, !6, i64 8}
!42 = !{!43, !10, i64 4}
!43 = !{!"MDBX_env", !7, i64 0, !10, i64 4, !10, i64 8, !44, i64 16, !10, i64 56, !10, i64 60, !44, i64 64, !6, i64 104, !45, i64 112, !45, i64 114, !45, i64 116, !45, i64 118, !45, i64 120, !45, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !45, i64 130, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !46, 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, !47, i64 264, !24, i64 320, !17, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !49, i64 392, !7, i64 400, !10, i64 440, !10, i64 444, !6, i64 448, !50, i64 456, !7, i64 496, !7, i64 536}
!44 = !{!"osal_mmap", !7, i64 0, !10, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!45 = !{!"short", !7, i64 0}
!46 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!47 = !{!"", !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, !17, i64 36, !17, i64 37, !17, i64 38, !48, i64 40, !7, i64 48}
!48 = !{!"", !45, i64 0, !45, i64 2, !45, i64 4, !45, i64 6}
!49 = !{!"", !14, i64 0}
!50 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!51 = !{!12, !6, i64 24}
!52 = !{!16, !17, i64 34}
!53 = !{!12, !6, i64 16}
!54 = !{!55, !6, i64 88}
!55 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !14, i64 8, !14, i64 16, !6, i64 24, !6, i64 32, !56, 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, !57, i64 128, !6, i64 160, !7, i64 168}
!56 = !{!"geo", !45, i64 0, !45, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!57 = !{!"MDBX_canary", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!58 = !{!59, !45, i64 0}
!59 = !{!"tree", !45, i64 0, !45, 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}
!60 = !{!16, !10, i64 64}
!61 = !{!16, !10, i64 2096}
!62 = !{i8 0, i8 2}
!63 = !{}


; 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"

@__func__.mdbx_env_chk = external hidden unnamed_addr constant [13 x i8], align 1
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @mdbx_env_chk(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %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 = %6
  %9 = tail call i32 @log_if_error(i32 noundef %7, ptr noundef nonnull @__func__.mdbx_env_chk, i32 noundef 1747)
  br label %114

10:                                               ; preds = %6
  %11 = icmp ne ptr %1, null
  %12 = icmp ne ptr %2, null
  %or.cond = and i1 %11, %12
  br i1 %or.cond, label %13, label %.critedge, !prof !6

13:                                               ; preds = %10
  %14 = load ptr, ptr %2, align 8, !tbaa !7
  %.not120 = icmp eq ptr %14, null
  br i1 %.not120, label %16, label %.critedge, !prof !5

.critedge:                                        ; preds = %10, %13
  %15 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_env_chk, i32 noundef 1749)
  br label %114

16:                                               ; preds = %13
  %17 = tail call noalias dereferenceable_or_null(267432) ptr @calloc(i64 noundef 1, i64 noundef 267432) #4
  %.not97 = icmp eq ptr %17, null
  br i1 %.not97, label %18, label %20, !prof !14

18:                                               ; preds = %16
  %19 = tail call i32 @log_if_error(i32 noundef 12, ptr noundef nonnull @__func__.mdbx_env_chk, i32 noundef 1753)
  br label %114

20:                                               ; preds = %16
  %21 = getelementptr inbounds i8, ptr %17, i64 8
  store ptr %1, ptr %21, align 8, !tbaa !15
  store ptr %2, ptr %17, align 8, !tbaa !30
  store ptr %17, ptr %2, align 8, !tbaa !7
  %22 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %0, ptr %22, align 8, !tbaa !31
  %23 = trunc i32 %3 to i8
  %24 = getelementptr inbounds i8, ptr %17, i64 32
  store i8 %23, ptr %24, align 8, !tbaa !32
  %25 = getelementptr inbounds i8, ptr %17, i64 40
  %26 = getelementptr inbounds i8, ptr %17, i64 68
  store i32 -1, ptr %26, align 4, !tbaa !33
  %27 = getelementptr inbounds i8, ptr %17, i64 48
  store ptr inttoptr (i64 -1 to ptr), ptr %27, align 8, !tbaa !34
  %28 = getelementptr inbounds i8, ptr %17, i64 4896
  store ptr %25, ptr %28, align 8, !tbaa !35
  %29 = getelementptr inbounds i8, ptr %17, i64 2072
  %30 = getelementptr inbounds i8, ptr %17, i64 2100
  store i32 -1, ptr %30, align 4, !tbaa !36
  %31 = getelementptr inbounds i8, ptr %17, i64 4904
  store ptr %29, ptr %31, align 8, !tbaa !35
  %.not98 = icmp eq i32 %5, 0
  br i1 %.not98, label %36, label %32

32:                                               ; preds = %20
  %33 = tail call i64 @osal_16dot16_to_monotime(i32 noundef %5) #5
  %34 = tail call i64 @osal_monotime() #5
  %35 = add i64 %34, %33
  %.pre = load ptr, ptr %17, align 8, !tbaa !30
  br label %36

36:                                               ; preds = %20, %32
  %37 = phi ptr [ %.pre, %32 ], [ %2, %20 ]
  %38 = phi i64 [ %35, %32 ], [ 0, %20 ]
  %39 = getelementptr inbounds i8, ptr %17, i64 16
  store i64 %38, ptr %39, align 8, !tbaa !37
  %40 = getelementptr inbounds i8, ptr %37, i64 32
  store i8 0, ptr %40, align 8, !tbaa !38
  %41 = getelementptr inbounds i8, ptr %37, i64 192
  store ptr %28, ptr %41, align 8, !tbaa !39
  %42 = getelementptr inbounds i8, ptr %17, i64 4128
  %43 = getelementptr inbounds i8, ptr %17, i64 4156
  store i32 %4, ptr %43, align 4, !tbaa !40
  %44 = getelementptr inbounds i8, ptr %17, i64 4136
  store ptr %17, ptr %44, align 8, !tbaa !42
  %45 = tail call i32 (ptr, i32, i32, ptr, ptr, ptr, ...) @chk_scope_begin(ptr noundef nonnull %17, i32 noundef 0, i32 noundef 1, ptr noundef null, ptr noundef null, ptr noundef null) #6
  %46 = tail call i32 @chk_scope_end(ptr noundef nonnull %17, i32 noundef %45) #6
  %.not99 = icmp eq i32 %46, 0
  br i1 %.not99, label %47, label %.thread117, !prof !5

47:                                               ; preds = %36
  %48 = getelementptr inbounds i8, ptr %0, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !43
  %50 = and i32 %49, 4325376
  %.not100 = icmp eq i32 %50, 0
  %51 = select i1 %.not100, ptr @.str.2, ptr @.str.1
  %52 = tail call i32 (ptr, i32, i32, ptr, ptr, ptr, ...) @chk_scope_begin(ptr noundef nonnull %17, i32 noundef 0, i32 noundef 2, ptr noundef null, ptr noundef null, ptr noundef nonnull @.str, ptr noundef nonnull %51) #6
  %.not101 = icmp eq i32 %52, 0
  br i1 %.not101, label %53, label %.thread117, !prof !52

53:                                               ; preds = %47
  %54 = load i32, ptr %48, align 4, !tbaa !43
  %55 = and i32 %54, 4325376
  %56 = icmp ne i32 %55, 0
  %57 = and i32 %3, 1
  %.not102 = icmp eq i32 %57, 0
  %or.cond110 = or i1 %.not102, %56
  br i1 %or.cond110, label %66, label %58

58:                                               ; preds = %53
  %59 = tail call i32 @mdbx_txn_lock(ptr noundef nonnull %0, i1 noundef zeroext false) #5
  %.not103 = icmp eq i32 %59, 0
  br i1 %.not103, label %64, label %60, !prof !5

60:                                               ; preds = %58
  %61 = getelementptr inbounds i8, ptr %2, i64 24
  %62 = load ptr, ptr %61, align 8, !tbaa !53
  %63 = tail call i32 @chk_error_rc(ptr noundef %62, i32 noundef %59, ptr noundef nonnull @.str.3) #6
  br label %.thread117

64:                                               ; preds = %58
  %65 = getelementptr inbounds i8, ptr %17, i64 34
  store i8 1, ptr %65, align 2, !tbaa !54
  br label %66

66:                                               ; preds = %53, %64
  %67 = getelementptr inbounds i8, ptr %2, i64 16
  %68 = tail call i32 @mdbx_txn_begin(ptr noundef nonnull %0, ptr noundef null, i32 noundef 131072, ptr noundef nonnull %67) #5
  %.not105 = icmp eq i32 %68, 0
  br i1 %.not105, label %74, label %69, !prof !5

69:                                               ; preds = %66
  %70 = getelementptr inbounds i8, ptr %2, i64 24
  %71 = load ptr, ptr %70, align 8, !tbaa !53
  %72 = tail call i32 @chk_error_rc(ptr noundef %71, i32 noundef %68, ptr noundef nonnull @.str.4) #6
  br label %.thread117

.thread117:                                       ; preds = %69, %60, %47, %36
  %.2.ph = phi i32 [ %68, %69 ], [ %52, %47 ], [ %59, %60 ], [ %46, %36 ]
  %73 = tail call i32 @chk_scope_end(ptr noundef nonnull %17, i32 noundef %.2.ph) #6
  br label %87

74:                                               ; preds = %66
  %75 = tail call i32 @chk_scope_end(ptr noundef nonnull %17, i32 noundef 0) #6
  %76 = load ptr, ptr %67, align 8, !tbaa !55
  %77 = getelementptr inbounds i8, ptr %76, i64 88
  %78 = load ptr, ptr %77, align 8, !tbaa !56
  %79 = load i16, ptr %78, align 4, !tbaa !60
  %80 = zext i16 %79 to i32
  %81 = getelementptr inbounds i8, ptr %17, i64 64
  store i32 %80, ptr %81, align 8, !tbaa !62
  %82 = getelementptr inbounds i8, ptr %78, i64 48
  %83 = load i16, ptr %82, align 4, !tbaa !60
  %84 = zext i16 %83 to i32
  %85 = getelementptr inbounds i8, ptr %17, i64 2096
  store i32 %84, ptr %85, align 8, !tbaa !63
  %86 = tail call i32 @env_chk(ptr noundef nonnull %42) #6
  br label %87

87:                                               ; preds = %.thread117, %74
  %.3 = phi i32 [ %86, %74 ], [ %.2.ph, %.thread117 ]
  %88 = getelementptr inbounds i8, ptr %2, i64 16
  %89 = load ptr, ptr %88, align 8, !tbaa !55
  %.not107 = icmp eq ptr %89, null
  br i1 %.not107, label %90, label %94

90:                                               ; preds = %87
  %91 = getelementptr inbounds i8, ptr %17, i64 34
  %92 = load i8, ptr %91, align 2, !tbaa !54, !range !64, !noundef !65
  %93 = trunc nuw i8 %92 to i1
  br i1 %93, label %94, label %109

94:                                               ; preds = %90, %87
  %95 = tail call i32 (ptr, i32, i32, ptr, ptr, ptr, ...) @chk_scope_begin(ptr noundef nonnull %17, i32 noundef 0, i32 noundef 10, ptr noundef null, ptr noundef null, ptr noundef null) #6
  %96 = load ptr, ptr %88, align 8, !tbaa !55
  %.not108 = icmp eq ptr %96, null
  br i1 %.not108, label %101, label %97

97:                                               ; preds = %94
  %98 = tail call i32 @mdbx_txn_abort(ptr noundef nonnull %96) #5
  %99 = icmp eq i32 %98, 0
  %100 = icmp ne i32 %.3, 0
  %or.cond3 = select i1 %99, i1 true, i1 %100
  %spec.select = select i1 %or.cond3, i32 %.3, i32 %98
  store ptr null, ptr %88, align 8, !tbaa !55
  br label %101

101:                                              ; preds = %97, %94
  %.5 = phi i32 [ %spec.select, %97 ], [ %.3, %94 ]
  %102 = getelementptr inbounds i8, ptr %17, i64 34
  %103 = load i8, ptr %102, align 2, !tbaa !54, !range !64, !noundef !65
  %104 = trunc nuw i8 %103 to i1
  br i1 %104, label %105, label %107

105:                                              ; preds = %101
  %106 = tail call i32 @mdbx_txn_unlock(ptr noundef %0) #5
  br label %107

107:                                              ; preds = %105, %101
  %108 = tail call i32 @chk_scope_end(ptr noundef nonnull %17, i32 noundef %.5) #6
  br label %109

109:                                              ; preds = %107, %90
  %.6 = phi i32 [ %108, %107 ], [ %.3, %90 ]
  %110 = tail call i32 (ptr, i32, i32, ptr, ptr, ptr, ...) @chk_scope_begin(ptr noundef nonnull %17, i32 noundef 0, i32 noundef 11, ptr noundef null, ptr noundef null, ptr noundef null) #6
  %.not109 = icmp eq i32 %110, 0
  %111 = select i1 %.not109, i32 %.6, i32 %110
  %112 = tail call i32 @chk_scope_end(ptr noundef nonnull %17, i32 noundef %111) #6
  tail call void @chk_dispose(ptr noundef nonnull %17) #6
  %113 = tail call i32 @log_if_error(i32 noundef %112, ptr noundef nonnull @__func__.mdbx_env_chk, i32 noundef 1824)
  br label %114

114:                                              ; preds = %18, %109, %.critedge, %8
  %.1 = phi i32 [ %9, %8 ], [ %15, %.critedge ], [ %19, %18 ], [ %113, %109 ]
  ret i32 %.1
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @log_if_error(i32 noundef, ptr noundef, i32 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

declare i64 @osal_16dot16_to_monotime(i32 noundef) local_unnamed_addr #3

declare i64 @osal_monotime() local_unnamed_addr #3

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

; Function Attrs: cold nounwind optsize uwtable
declare hidden i32 @chk_scope_begin(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

declare i32 @mdbx_txn_lock(ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

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

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

; Function Attrs: cold nounwind optsize uwtable
declare hidden i32 @env_chk(ptr noundef) local_unnamed_addr #0

declare i32 @mdbx_txn_abort(ptr noundef) local_unnamed_addr #3

declare i32 @mdbx_txn_unlock(ptr noundef) local_unnamed_addr #3

; Function Attrs: cold nounwind optsize uwtable
declare hidden void @chk_dispose(ptr noundef) local_unnamed_addr #0

attributes #0 = { cold nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { inlinehint 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 = { 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 = { "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 = { nounwind allocsize(0,1) }
attributes #5 = { nounwind }
attributes #6 = { cold }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!"branch_weights", i32 4000000, i32 4001}
!7 = !{!8, !9, i64 0}
!8 = !{!"MDBX_chk_context", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !10, i64 32, !12, i64 40}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !9, i64 152}
!13 = !{!"long", !10, i64 0}
!14 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!15 = !{!16, !9, i64 8}
!16 = !{!"MDBX_chk_internal", !9, i64 0, !9, i64 8, !13, i64 16, !9, i64 24, !10, i64 32, !17, i64 33, !17, i64 34, !10, i64 35, !18, i64 40, !18, i64 2072, !9, i64 4104, !9, i64 4112, !9, i64 4120, !10, i64 4128, !10, i64 4896, !24, i64 267032, !29, i64 267384, !19, i64 267416}
!17 = !{!"_Bool", !10, i64 0}
!18 = !{!"MDBX_chk_table", !9, i64 0, !19, i64 8, !20, i64 24, !20, i64 28, !13, i64 32, !13, i64 40, !21, i64 48, !22, i64 112}
!19 = !{!"iovec", !9, i64 0, !13, i64 8}
!20 = !{!"int", !10, i64 0}
!21 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56}
!22 = !{!"", !23, i64 0, !23, i64 320, !23, i64 640, !23, i64 960, !23, i64 1280, !23, i64 1600}
!23 = !{!"MDBX_chk_histogram", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !10, i64 32}
!24 = !{!"MDBX_envinfo", !25, i64 0, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !10, i64 80, !10, i64 104, !20, i64 128, !20, i64 132, !20, i64 136, !20, i64 140, !26, i64 144, !13, i64 208, !13, i64 216, !20, i64 224, !20, i64 228, !20, i64 232, !20, i64 236, !28, i64 240, !27, i64 336}
!25 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!26 = !{!"", !27, i64 0, !10, i64 16}
!27 = !{!"", !13, i64 0, !13, i64 8}
!28 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88}
!29 = !{!"troika", !10, i64 0, !10, i64 1, !10, i64 2, !10, i64 3, !20, i64 4, !10, i64 8}
!30 = !{!16, !9, i64 0}
!31 = !{!8, !9, i64 8}
!32 = !{!16, !10, i64 32}
!33 = !{!16, !20, i64 68}
!34 = !{!16, !9, i64 48}
!35 = !{!9, !9, i64 0}
!36 = !{!16, !20, i64 2100}
!37 = !{!16, !13, i64 16}
!38 = !{!8, !10, i64 32}
!39 = !{!8, !9, i64 192}
!40 = !{!41, !20, i64 28}
!41 = !{!"MDBX_chk_scope", !9, i64 0, !9, i64 8, !9, i64 16, !20, i64 24, !20, i64 28, !13, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!42 = !{!41, !9, i64 8}
!43 = !{!44, !20, i64 4}
!44 = !{!"MDBX_env", !10, i64 0, !20, i64 4, !20, i64 8, !45, i64 16, !20, i64 56, !20, i64 60, !45, i64 64, !9, i64 104, !46, i64 112, !46, i64 114, !46, i64 116, !46, i64 118, !46, i64 120, !46, i64 122, !10, i64 124, !10, i64 128, !10, i64 129, !46, i64 130, !20, i64 132, !20, i64 136, !20, i64 140, !20, i64 144, !47, i64 152, !9, i64 184, !9, i64 192, !9, i64 200, !9, i64 208, !9, i64 216, !20, i64 224, !20, i64 228, !20, i64 232, !9, i64 240, !9, i64 248, !13, i64 256, !48, i64 264, !25, i64 320, !17, i64 360, !9, i64 368, !9, i64 376, !9, i64 384, !50, i64 392, !10, i64 400, !20, i64 440, !20, i64 444, !9, i64 448, !51, i64 456, !10, i64 496, !10, i64 536}
!45 = !{!"osal_mmap", !10, i64 0, !20, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!46 = !{!"short", !10, i64 0}
!47 = !{!"", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24}
!48 = !{!"", !20, i64 0, !20, i64 4, !20, i64 8, !20, i64 12, !13, i64 16, !10, i64 24, !10, i64 25, !10, i64 26, !10, i64 27, !20, i64 28, !20, i64 32, !17, i64 36, !17, i64 37, !17, i64 38, !49, i64 40, !10, i64 48}
!49 = !{!"", !46, i64 0, !46, i64 2, !46, i64 4, !46, i64 6}
!50 = !{!"", !13, i64 0}
!51 = !{!"osal_ioring", !20, i64 0, !20, i64 4, !20, i64 8, !9, i64 16, !9, i64 24, !9, i64 32}
!52 = !{!"branch_weights", !"expected", i32 -2147483648, i32 0}
!53 = !{!8, !9, i64 24}
!54 = !{!16, !17, i64 34}
!55 = !{!8, !9, i64 16}
!56 = !{!57, !9, i64 88}
!57 = !{!"MDBX_txn", !20, i64 0, !20, i64 4, !13, i64 8, !13, i64 16, !9, i64 24, !9, i64 32, !58, i64 40, !13, i64 64, !13, i64 72, !9, i64 80, !9, i64 88, !9, i64 96, !9, i64 104, !9, i64 112, !9, i64 120, !59, i64 128, !9, i64 160, !10, i64 168}
!58 = !{!"geo", !46, i64 0, !46, i64 2, !20, i64 4, !20, i64 8, !10, i64 12, !10, i64 16}
!59 = !{!"MDBX_canary", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!60 = !{!61, !46, i64 0}
!61 = !{!"tree", !46, i64 0, !46, i64 2, !20, i64 4, !20, i64 8, !20, i64 12, !20, i64 16, !20, i64 20, !13, i64 24, !13, i64 32, !13, i64 40}
!62 = !{!16, !20, i64 64}
!63 = !{!16, !20, i64 2096}
!64 = !{i8 0, i8 2}
!65 = !{}


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