; LLVM IR from erthink/libmdbx :: src (api-opts)

; 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_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.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.shared_lck = type { i64, i32, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, [2 x %union.mdbx_atomic_uint32_t], [16 x i8], %struct.pgops, [16 x i8], %union.pthread_mutex_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, i32, %struct.anon.10, %union.pthread_mutex_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, [16 x i8], [0 x %struct.reader_slot] }
%struct.pgops = type { %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %struct.anon.8 }
%struct.anon.8 = type { %struct.gc_prof_stat, %struct.gc_prof_stat, i32, i32, i32, i32, i32 }
%struct.gc_prof_stat = type { i64, i64, i32, i32, i32, i32, %struct.anon.9 }
%struct.anon.9 = type { i64, i64, i32 }
%struct.anon.10 = type { [4 x i32], [4 x i64] }
%struct.reader_slot = type { %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint64_t }

@__func__.mdbx_env_get_option = external hidden unnamed_addr constant [20 x i8], align 1

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

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

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

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

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

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

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

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

20:                                               ; preds = %3
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = call i32 @log_if_error(i32 noundef %21, ptr noundef @__func__.mdbx_env_get_option, i32 noundef 479)
  store i32 %22, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %228

23:                                               ; preds = %3
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  %26 = xor i1 %25, true
  %27 = xor i1 %26, true
  %28 = xor i1 %27, true
  %29 = zext i1 %28 to i32
  %30 = sext i32 %29 to i64
  %31 = call i64 @llvm.expect.i64(i64 %30, i64 0)
  %32 = icmp ne i64 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %23
  %34 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_env_get_option, i32 noundef 481)
  store i32 %34, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %228

35:                                               ; preds = %23
  %36 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %36, label %225 [
    i32 2, label %37
    i32 3, label %62
    i32 0, label %86
    i32 1, label %93
    i32 6, label %99
    i32 4, label %106
    i32 15, label %113
    i32 7, label %121
    i32 8, label %128
    i32 9, label %135
    i32 10, label %142
    i32 11, label %149
    i32 5, label %156
    i32 12, label %163
    i32 13, label %170
    i32 14, label %177
    i32 16, label %185
    i32 17, label %193
    i32 18, label %201
    i32 19, label %209
    i32 20, label %217
  ]

37:                                               ; preds = %35
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MDBX_env, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = and i32 %40, 536870912
  %42 = icmp ne i32 %41, 0
  %43 = xor i1 %42, true
  %44 = xor i1 %43, true
  %45 = xor i1 %44, true
  %46 = zext i1 %45 to i32
  %47 = sext i32 %46 to i64
  %48 = call i64 @llvm.expect.i64(i64 %47, i64 0)
  %49 = icmp ne i64 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %37
  %51 = call i32 @log_if_error(i32 noundef 1, ptr noundef @__func__.mdbx_env_get_option, i32 noundef 486)
  store i32 %51, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %228

52:                                               ; preds = %37
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.MDBX_env, ptr %54, i32 0, i32 7
  %56 = load ptr, ptr %55, align 8, !tbaa !23
  %57 = getelementptr inbounds %struct.shared_lck, ptr %56, i32 0, i32 3
  %58 = call i32 @atomic_load32(ptr noundef %57, i32 noundef 0)
  %59 = zext i32 %58 to i64
  %60 = call i64 @pgno2bytes(ptr noundef %53, i64 noundef %59) #8
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %60, ptr %61, align 8, !tbaa !24
  br label %227

62:                                               ; preds = %35
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MDBX_env, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !11
  %66 = and i32 %65, 536870912
  %67 = icmp ne i32 %66, 0
  %68 = xor i1 %67, true
  %69 = xor i1 %68, true
  %70 = xor i1 %69, true
  %71 = zext i1 %70 to i32
  %72 = sext i32 %71 to i64
  %73 = call i64 @llvm.expect.i64(i64 %72, i64 0)
  %74 = icmp ne i64 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %62
  %76 = call i32 @log_if_error(i32 noundef 1, ptr noundef @__func__.mdbx_env_get_option, i32 noundef 492)
  store i32 %76, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %228

77:                                               ; preds = %62
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.MDBX_env, ptr %78, i32 0, i32 7
  %80 = load ptr, ptr %79, align 8, !tbaa !23
  %81 = getelementptr inbounds %struct.shared_lck, ptr %80, i32 0, i32 5
  %82 = call i64 @atomic_load64(ptr noundef %81, i32 noundef 0)
  %83 = call i32 @osal_monotime_to_16dot16(i64 noundef %82)
  %84 = zext i32 %83 to i64
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %84, ptr %85, align 8, !tbaa !24
  br label %227

86:                                               ; preds = %35
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.MDBX_env, ptr %87, i32 0, i32 19
  %89 = load i32, ptr %88, align 8, !tbaa !25
  %90 = sub i32 %89, 2
  %91 = zext i32 %90 to i64
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %91, ptr %92, align 8, !tbaa !24
  br label %227

93:                                               ; preds = %35
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.MDBX_env, ptr %94, i32 0, i32 18
  %96 = load i32, ptr %95, align 4, !tbaa !26
  %97 = zext i32 %96 to i64
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %97, ptr %98, align 8, !tbaa !24
  br label %227

99:                                               ; preds = %35
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.MDBX_env, ptr %100, i32 0, i32 34
  %102 = getelementptr inbounds %struct.anon.2, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %102, align 8, !tbaa !27
  %104 = zext i32 %103 to i64
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %104, ptr %105, align 8, !tbaa !24
  br label %227

106:                                              ; preds = %35
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.MDBX_env, ptr %107, i32 0, i32 34
  %109 = getelementptr inbounds %struct.anon.2, ptr %108, i32 0, i32 1
  %110 = load i32, ptr %109, align 4, !tbaa !28
  %111 = zext i32 %110 to i64
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %111, ptr %112, align 8, !tbaa !24
  br label %227

113:                                              ; preds = %35
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.MDBX_env, ptr %114, i32 0, i32 34
  %116 = getelementptr inbounds %struct.anon.2, ptr %115, i32 0, i32 4
  %117 = load i64, ptr %116, align 8, !tbaa !29
  %118 = call i32 @osal_monotime_to_16dot16(i64 noundef %117)
  %119 = zext i32 %118 to i64
  %120 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %119, ptr %120, align 8, !tbaa !24
  br label %227

121:                                              ; preds = %35
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.MDBX_env, ptr %122, i32 0, i32 34
  %124 = getelementptr inbounds %struct.anon.2, ptr %123, i32 0, i32 2
  %125 = load i32, ptr %124, align 8, !tbaa !30
  %126 = zext i32 %125 to i64
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %126, ptr %127, align 8, !tbaa !24
  br label %227

128:                                              ; preds = %35
  %129 = load ptr, ptr %5, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.MDBX_env, ptr %129, i32 0, i32 34
  %131 = getelementptr inbounds %struct.anon.2, ptr %130, i32 0, i32 3
  %132 = load i32, ptr %131, align 4, !tbaa !31
  %133 = zext i32 %132 to i64
  %134 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %133, ptr %134, align 8, !tbaa !24
  br label %227

135:                                              ; preds = %35
  %136 = load ptr, ptr %5, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.MDBX_env, ptr %136, i32 0, i32 34
  %138 = getelementptr inbounds %struct.anon.2, ptr %137, i32 0, i32 6
  %139 = load i8, ptr %138, align 1, !tbaa !32
  %140 = zext i8 %139 to i64
  %141 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %140, ptr %141, align 8, !tbaa !24
  br label %227

142:                                              ; preds = %35
  %143 = load ptr, ptr %5, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.MDBX_env, ptr %143, i32 0, i32 34
  %145 = getelementptr inbounds %struct.anon.2, ptr %144, i32 0, i32 7
  %146 = load i8, ptr %145, align 2, !tbaa !33
  %147 = zext i8 %146 to i64
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %147, ptr %148, align 8, !tbaa !24
  br label %227

149:                                              ; preds = %35
  %150 = load ptr, ptr %5, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.MDBX_env, ptr %150, i32 0, i32 34
  %152 = getelementptr inbounds %struct.anon.2, ptr %151, i32 0, i32 8
  %153 = load i8, ptr %152, align 1, !tbaa !34
  %154 = zext i8 %153 to i64
  %155 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %154, ptr %155, align 8, !tbaa !24
  br label %227

156:                                              ; preds = %35
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.MDBX_env, ptr %157, i32 0, i32 34
  %159 = getelementptr inbounds %struct.anon.2, ptr %158, i32 0, i32 5
  %160 = load i8, ptr %159, align 8, !tbaa !35
  %161 = zext i8 %160 to i64
  %162 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %161, ptr %162, align 8, !tbaa !24
  br label %227

163:                                              ; preds = %35
  %164 = load ptr, ptr %5, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.MDBX_env, ptr %164, i32 0, i32 34
  %166 = getelementptr inbounds %struct.anon.2, ptr %165, i32 0, i32 9
  %167 = load i32, ptr %166, align 4, !tbaa !36
  %168 = zext i32 %167 to i64
  %169 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %168, ptr %169, align 8, !tbaa !24
  br label %227

170:                                              ; preds = %35
  %171 = load ptr, ptr %5, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.MDBX_env, ptr %171, i32 0, i32 34
  %173 = getelementptr inbounds %struct.anon.2, ptr %172, i32 0, i32 10
  %174 = load i32, ptr %173, align 8, !tbaa !37
  %175 = zext i32 %174 to i64
  %176 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %175, ptr %176, align 8, !tbaa !24
  br label %227

177:                                              ; preds = %35
  %178 = load ptr, ptr %5, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.MDBX_env, ptr %178, i32 0, i32 34
  %180 = getelementptr inbounds %struct.anon.2, ptr %179, i32 0, i32 11
  %181 = load i8, ptr %180, align 4, !tbaa !38, !range !39, !noundef !40
  %182 = trunc i8 %181 to i1
  %183 = zext i1 %182 to i64
  %184 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %183, ptr %184, align 8, !tbaa !24
  br label %227

185:                                              ; preds = %35
  %186 = load ptr, ptr %5, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.MDBX_env, ptr %186, i32 0, i32 34
  %188 = getelementptr inbounds %struct.anon.2, ptr %187, i32 0, i32 12
  %189 = load i8, ptr %188, align 1, !tbaa !41, !range !39, !noundef !40
  %190 = trunc i8 %189 to i1
  %191 = zext i1 %190 to i64
  %192 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %191, ptr %192, align 8, !tbaa !24
  br label %227

193:                                              ; preds = %35
  %194 = load ptr, ptr %5, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.MDBX_env, ptr %194, i32 0, i32 34
  %196 = getelementptr inbounds %struct.anon.2, ptr %195, i32 0, i32 14
  %197 = getelementptr inbounds %struct.anon.3, ptr %196, i32 0, i32 0
  %198 = load i16, ptr %197, align 8, !tbaa !42
  %199 = zext i16 %198 to i64
  %200 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %199, ptr %200, align 8, !tbaa !24
  br label %227

201:                                              ; preds = %35
  %202 = load ptr, ptr %5, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.MDBX_env, ptr %202, i32 0, i32 34
  %204 = getelementptr inbounds %struct.anon.2, ptr %203, i32 0, i32 14
  %205 = getelementptr inbounds %struct.anon.3, ptr %204, i32 0, i32 1
  %206 = load i16, ptr %205, align 2, !tbaa !43
  %207 = zext i16 %206 to i64
  %208 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %207, ptr %208, align 8, !tbaa !24
  br label %227

209:                                              ; preds = %35
  %210 = load ptr, ptr %5, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.MDBX_env, ptr %210, i32 0, i32 34
  %212 = getelementptr inbounds %struct.anon.2, ptr %211, i32 0, i32 14
  %213 = getelementptr inbounds %struct.anon.3, ptr %212, i32 0, i32 2
  %214 = load i16, ptr %213, align 4, !tbaa !44
  %215 = zext i16 %214 to i64
  %216 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %215, ptr %216, align 8, !tbaa !24
  br label %227

217:                                              ; preds = %35
  %218 = load ptr, ptr %5, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.MDBX_env, ptr %218, i32 0, i32 34
  %220 = getelementptr inbounds %struct.anon.2, ptr %219, i32 0, i32 14
  %221 = getelementptr inbounds %struct.anon.3, ptr %220, i32 0, i32 3
  %222 = load i16, ptr %221, align 2, !tbaa !45
  %223 = zext i16 %222 to i64
  %224 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %223, ptr %224, align 8, !tbaa !24
  br label %227

225:                                              ; preds = %35
  %226 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_env_get_option, i32 noundef 574)
  store i32 %226, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %228

227:                                              ; preds = %217, %209, %201, %193, %185, %177, %170, %163, %156, %149, %142, %135, %128, %121, %113, %106, %99, %93, %86, %77, %52
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %228

228:                                              ; preds = %227, %225, %75, %50, %33, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  %229 = load i32, ptr %4, align 4
  ret i32 %229
}

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

declare i32 @osal_monotime_to_16dot16(i64 noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #2 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { cold nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint nounwind willreturn memory(read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { "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 = { 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 4}
!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, !6, i64 104}
!24 = !{!14, !14, i64 0}
!25 = !{!12, !10, i64 136}
!26 = !{!12, !10, i64 132}
!27 = !{!12, !10, i64 264}
!28 = !{!12, !10, i64 268}
!29 = !{!12, !14, i64 280}
!30 = !{!12, !10, i64 272}
!31 = !{!12, !10, i64 276}
!32 = !{!12, !7, i64 289}
!33 = !{!12, !7, i64 290}
!34 = !{!12, !7, i64 291}
!35 = !{!12, !7, i64 288}
!36 = !{!12, !10, i64 292}
!37 = !{!12, !10, i64 296}
!38 = !{!12, !18, i64 300}
!39 = !{i8 0, i8 2}
!40 = !{}
!41 = !{!12, !18, i64 301}
!42 = !{!12, !15, i64 304}
!43 = !{!12, !15, i64 306}
!44 = !{!12, !15, i64 308}
!45 = !{!12, !15, i64 310}


; 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_get_option = external hidden unnamed_addr constant [20 x i8], align 1

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i64 @atomic_load64(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @mdbx_env_get_option(ptr noundef %0, i32 noundef %1, ptr noundef writeonly %2) local_unnamed_addr #2 {
  %4 = tail call i32 @check_env(ptr noundef %0, i1 noundef zeroext false)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %7, label %5, !prof !5

5:                                                ; preds = %3
  %6 = tail call i32 @log_if_error(i32 noundef %4, ptr noundef nonnull @__func__.mdbx_env_get_option, i32 noundef 479)
  br label %117

7:                                                ; preds = %3
  %.not51 = icmp eq ptr %2, null
  br i1 %.not51, label %8, label %10, !prof !6

8:                                                ; preds = %7
  %9 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_env_get_option, i32 noundef 481)
  br label %117

10:                                               ; preds = %7
  switch i32 %1, label %115 [
    i32 2, label %11
    i32 3, label %24
    i32 0, label %37
    i32 1, label %42
    i32 6, label %46
    i32 4, label %50
    i32 15, label %54
    i32 7, label %59
    i32 8, label %63
    i32 9, label %67
    i32 10, label %71
    i32 11, label %75
    i32 5, label %79
    i32 12, label %83
    i32 13, label %87
    i32 14, label %91
    i32 16, label %95
    i32 17, label %99
    i32 18, label %103
    i32 19, label %107
    i32 20, label %111
  ]

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !7
  %14 = and i32 %13, 536870912
  %.not53 = icmp eq i32 %14, 0
  br i1 %.not53, label %15, label %17, !prof !6

15:                                               ; preds = %11
  %16 = tail call i32 @log_if_error(i32 noundef 1, ptr noundef nonnull @__func__.mdbx_env_get_option, i32 noundef 486)
  br label %117

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %0, i64 104
  %19 = load ptr, ptr %18, align 8, !tbaa !23
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %21 = tail call i32 @atomic_load32(ptr noundef nonnull %20, i32 noundef 0)
  %22 = zext i32 %21 to i64
  %23 = tail call i64 @pgno2bytes(ptr noundef nonnull %0, i64 noundef %22) #5
  store i64 %23, ptr %2, align 8, !tbaa !24
  br label %117

24:                                               ; preds = %10
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !7
  %27 = and i32 %26, 536870912
  %.not52 = icmp eq i32 %27, 0
  br i1 %.not52, label %28, label %30, !prof !6

28:                                               ; preds = %24
  %29 = tail call i32 @log_if_error(i32 noundef 1, ptr noundef nonnull @__func__.mdbx_env_get_option, i32 noundef 492)
  br label %117

30:                                               ; preds = %24
  %31 = getelementptr inbounds i8, ptr %0, i64 104
  %32 = load ptr, ptr %31, align 8, !tbaa !23
  %33 = getelementptr inbounds i8, ptr %32, i64 24
  %34 = tail call i64 @atomic_load64(ptr noundef nonnull %33, i32 noundef 0)
  %35 = tail call i32 @osal_monotime_to_16dot16(i64 noundef %34) #6
  %36 = zext i32 %35 to i64
  store i64 %36, ptr %2, align 8, !tbaa !24
  br label %117

37:                                               ; preds = %10
  %38 = getelementptr inbounds i8, ptr %0, i64 136
  %39 = load i32, ptr %38, align 8, !tbaa !25
  %40 = add i32 %39, -2
  %41 = zext i32 %40 to i64
  store i64 %41, ptr %2, align 8, !tbaa !24
  br label %117

42:                                               ; preds = %10
  %43 = getelementptr inbounds i8, ptr %0, i64 132
  %44 = load i32, ptr %43, align 4, !tbaa !26
  %45 = zext i32 %44 to i64
  store i64 %45, ptr %2, align 8, !tbaa !24
  br label %117

46:                                               ; preds = %10
  %47 = getelementptr inbounds i8, ptr %0, i64 264
  %48 = load i32, ptr %47, align 8, !tbaa !27
  %49 = zext i32 %48 to i64
  store i64 %49, ptr %2, align 8, !tbaa !24
  br label %117

50:                                               ; preds = %10
  %51 = getelementptr inbounds i8, ptr %0, i64 268
  %52 = load i32, ptr %51, align 4, !tbaa !28
  %53 = zext i32 %52 to i64
  store i64 %53, ptr %2, align 8, !tbaa !24
  br label %117

54:                                               ; preds = %10
  %55 = getelementptr inbounds i8, ptr %0, i64 280
  %56 = load i64, ptr %55, align 8, !tbaa !29
  %57 = tail call i32 @osal_monotime_to_16dot16(i64 noundef %56) #6
  %58 = zext i32 %57 to i64
  store i64 %58, ptr %2, align 8, !tbaa !24
  br label %117

59:                                               ; preds = %10
  %60 = getelementptr inbounds i8, ptr %0, i64 272
  %61 = load i32, ptr %60, align 8, !tbaa !30
  %62 = zext i32 %61 to i64
  store i64 %62, ptr %2, align 8, !tbaa !24
  br label %117

63:                                               ; preds = %10
  %64 = getelementptr inbounds i8, ptr %0, i64 276
  %65 = load i32, ptr %64, align 4, !tbaa !31
  %66 = zext i32 %65 to i64
  store i64 %66, ptr %2, align 8, !tbaa !24
  br label %117

67:                                               ; preds = %10
  %68 = getelementptr inbounds i8, ptr %0, i64 289
  %69 = load i8, ptr %68, align 1, !tbaa !32
  %70 = zext i8 %69 to i64
  store i64 %70, ptr %2, align 8, !tbaa !24
  br label %117

71:                                               ; preds = %10
  %72 = getelementptr inbounds i8, ptr %0, i64 290
  %73 = load i8, ptr %72, align 2, !tbaa !33
  %74 = zext i8 %73 to i64
  store i64 %74, ptr %2, align 8, !tbaa !24
  br label %117

75:                                               ; preds = %10
  %76 = getelementptr inbounds i8, ptr %0, i64 291
  %77 = load i8, ptr %76, align 1, !tbaa !34
  %78 = zext i8 %77 to i64
  store i64 %78, ptr %2, align 8, !tbaa !24
  br label %117

79:                                               ; preds = %10
  %80 = getelementptr inbounds i8, ptr %0, i64 288
  %81 = load i8, ptr %80, align 8, !tbaa !35
  %82 = zext i8 %81 to i64
  store i64 %82, ptr %2, align 8, !tbaa !24
  br label %117

83:                                               ; preds = %10
  %84 = getelementptr inbounds i8, ptr %0, i64 292
  %85 = load i32, ptr %84, align 4, !tbaa !36
  %86 = zext i32 %85 to i64
  store i64 %86, ptr %2, align 8, !tbaa !24
  br label %117

87:                                               ; preds = %10
  %88 = getelementptr inbounds i8, ptr %0, i64 296
  %89 = load i32, ptr %88, align 8, !tbaa !37
  %90 = zext i32 %89 to i64
  store i64 %90, ptr %2, align 8, !tbaa !24
  br label %117

91:                                               ; preds = %10
  %92 = getelementptr inbounds i8, ptr %0, i64 300
  %93 = load i8, ptr %92, align 4, !tbaa !38, !range !39, !noundef !40
  %94 = zext nneg i8 %93 to i64
  store i64 %94, ptr %2, align 8, !tbaa !24
  br label %117

95:                                               ; preds = %10
  %96 = getelementptr inbounds i8, ptr %0, i64 301
  %97 = load i8, ptr %96, align 1, !tbaa !41, !range !39, !noundef !40
  %98 = zext nneg i8 %97 to i64
  store i64 %98, ptr %2, align 8, !tbaa !24
  br label %117

99:                                               ; preds = %10
  %100 = getelementptr inbounds i8, ptr %0, i64 304
  %101 = load i16, ptr %100, align 8, !tbaa !42
  %102 = zext i16 %101 to i64
  store i64 %102, ptr %2, align 8, !tbaa !24
  br label %117

103:                                              ; preds = %10
  %104 = getelementptr inbounds i8, ptr %0, i64 306
  %105 = load i16, ptr %104, align 2, !tbaa !43
  %106 = zext i16 %105 to i64
  store i64 %106, ptr %2, align 8, !tbaa !24
  br label %117

107:                                              ; preds = %10
  %108 = getelementptr inbounds i8, ptr %0, i64 308
  %109 = load i16, ptr %108, align 4, !tbaa !44
  %110 = zext i16 %109 to i64
  store i64 %110, ptr %2, align 8, !tbaa !24
  br label %117

111:                                              ; preds = %10
  %112 = getelementptr inbounds i8, ptr %0, i64 310
  %113 = load i16, ptr %112, align 2, !tbaa !45
  %114 = zext i16 %113 to i64
  store i64 %114, ptr %2, align 8, !tbaa !24
  br label %117

115:                                              ; preds = %10
  %116 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_env_get_option, i32 noundef 574)
  br label %117

117:                                              ; preds = %17, %30, %37, %42, %46, %50, %54, %59, %63, %67, %71, %75, %79, %83, %87, %91, %95, %99, %103, %107, %111, %115, %28, %15, %8, %5
  %.0 = phi i32 [ %6, %5 ], [ %9, %8 ], [ %116, %115 ], [ %29, %28 ], [ %16, %15 ], [ 0, %111 ], [ 0, %107 ], [ 0, %103 ], [ 0, %99 ], [ 0, %95 ], [ 0, %91 ], [ 0, %87 ], [ 0, %83 ], [ 0, %79 ], [ 0, %75 ], [ 0, %71 ], [ 0, %67 ], [ 0, %63 ], [ 0, %59 ], [ 0, %54 ], [ 0, %50 ], [ 0, %46 ], [ 0, %42 ], [ 0, %37 ], [ 0, %30 ], [ 0, %17 ]
  ret i32 %.0
}

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

declare i32 @osal_monotime_to_16dot16(i64 noundef) local_unnamed_addr #4

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!7 = !{!8, !11, i64 4}
!8 = !{!"MDBX_env", !9, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !11, i64 56, !11, i64 60, !12, i64 64, !14, i64 104, !15, i64 112, !15, i64 114, !15, i64 116, !15, i64 118, !15, i64 120, !15, i64 122, !9, i64 124, !9, i64 128, !9, i64 129, !15, i64 130, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !16, i64 152, !14, i64 184, !14, i64 192, !14, i64 200, !14, i64 208, !14, i64 216, !11, i64 224, !11, i64 228, !11, i64 232, !14, i64 240, !14, i64 248, !13, i64 256, !17, i64 264, !20, i64 320, !18, i64 360, !14, i64 368, !14, i64 376, !14, i64 384, !21, i64 392, !9, i64 400, !11, i64 440, !11, i64 444, !14, i64 448, !22, i64 456, !9, i64 496, !9, i64 536}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"osal_mmap", !9, i64 0, !11, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!13 = !{!"long", !9, i64 0}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"short", !9, i64 0}
!16 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!17 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !13, i64 16, !9, i64 24, !9, i64 25, !9, i64 26, !9, i64 27, !11, i64 28, !11, i64 32, !18, i64 36, !18, i64 37, !18, i64 38, !19, i64 40, !9, i64 48}
!18 = !{!"_Bool", !9, i64 0}
!19 = !{!"", !15, i64 0, !15, i64 2, !15, i64 4, !15, i64 6}
!20 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!21 = !{!"", !13, i64 0}
!22 = !{!"osal_ioring", !11, i64 0, !11, i64 4, !11, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!23 = !{!8, !14, i64 104}
!24 = !{!13, !13, i64 0}
!25 = !{!8, !11, i64 136}
!26 = !{!8, !11, i64 132}
!27 = !{!8, !11, i64 264}
!28 = !{!8, !11, i64 268}
!29 = !{!8, !13, i64 280}
!30 = !{!8, !11, i64 272}
!31 = !{!8, !11, i64 276}
!32 = !{!8, !9, i64 289}
!33 = !{!8, !9, i64 290}
!34 = !{!8, !9, i64 291}
!35 = !{!8, !9, i64 288}
!36 = !{!8, !11, i64 292}
!37 = !{!8, !11, i64 296}
!38 = !{!8, !18, i64 300}
!39 = !{i8 0, i8 2}
!40 = !{}
!41 = !{!8, !18, i64 301}
!42 = !{!8, !15, i64 304}
!43 = !{!8, !15, i64 306}
!44 = !{!8, !15, i64 308}
!45 = !{!8, !15, i64 310}


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