; LLVM IR from erthink/libmdbx :: src (txn-ro)

; 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.6 }
%struct.anon.6 = 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.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.1 }
%struct.geo = type { i16, i16, i32, i32, %union.anon, %union.anon.0 }
%union.anon = type { i32 }
%union.anon.0 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.1 = type { %struct.anon.2 }
%struct.anon.2 = type { %struct.troika, ptr, %struct.anon.3, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.4 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.3 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.4 = type { %struct.anon.5 }
%struct.anon.5 = type { i64, ptr }
%struct.anon = type { ptr }
%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 }
%union.mdbx_atomic_uint32_t = type { i32 }
%union.mdbx_atomic_uint64_t = type { 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 }
%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 }
%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.18, %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.16 }
%struct.anon.16 = 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.17 }
%struct.anon.17 = type { i64, i64, i32 }
%struct.anon.18 = type { [4 x i32], [4 x i64] }

@globals = external global %struct.libmdbx_globals, align 8
@.str.15 = external hidden unnamed_addr constant [90 x i8], align 1
@__func__.txn_ro_park = external hidden unnamed_addr constant [12 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [59 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: noreturn
declare void @mdbx_assert_fail(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @txn_ro_park(ptr noundef %0, i1 noundef zeroext %1) #5 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  %11 = zext i1 %1 to i8
  store i8 %11, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.MDBX_txn, ptr %12, i32 0, i32 17
  %14 = getelementptr inbounds %struct.anon, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  store ptr %15, ptr %6, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %2
  %17 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !12
  %18 = zext i8 %17 to i32
  %19 = and i32 %18, 1
  %20 = icmp ne i32 %19, 0
  %21 = xor i1 %20, true
  %22 = xor i1 %21, true
  %23 = zext i1 %22 to i32
  %24 = sext i32 %23 to i64
  %25 = call i64 @llvm.expect.i64(i64 %24, i64 1)
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %48

27:                                               ; preds = %16
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.MDBX_txn, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = and i32 %31, 131105
  %33 = icmp eq i32 %32, 131072
  %34 = xor i1 %33, true
  %35 = xor i1 %34, true
  %36 = xor i1 %35, true
  %37 = zext i1 %36 to i32
  %38 = sext i32 %37 to i64
  %39 = call i64 @llvm.expect.i64(i64 %38, i64 0)
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %41, label %45

41:                                               ; preds = %28
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.MDBX_txn, ptr %42, i32 0, i32 9
  %44 = load ptr, ptr %43, align 8, !tbaa !21
  call void @mdbx_assert_fail(ptr noundef %44, ptr noundef @.str.15, ptr noundef @__func__.txn_ro_park, i32 noundef 217) #7
  unreachable

45:                                               ; preds = %28
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47, %16
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  %52 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !12
  %53 = zext i8 %52 to i32
  %54 = and i32 %53, 1
  %55 = icmp ne i32 %54, 0
  %56 = xor i1 %55, true
  %57 = xor i1 %56, true
  %58 = zext i1 %57 to i32
  %59 = sext i32 %58 to i64
  %60 = call i64 @llvm.expect.i64(i64 %59, i64 1)
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %62, label %85

62:                                               ; preds = %51
  br label %63

63:                                               ; preds = %62
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.MDBX_txn, ptr %64, i32 0, i32 17
  %66 = getelementptr inbounds %struct.anon, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !11
  %68 = getelementptr inbounds %struct.reader_slot, ptr %67, i32 0, i32 1
  %69 = load volatile i64, ptr %68, align 8, !tbaa !11
  %70 = icmp ult i64 %69, -2
  %71 = xor i1 %70, true
  %72 = xor i1 %71, true
  %73 = xor i1 %72, true
  %74 = zext i1 %73 to i32
  %75 = sext i32 %74 to i64
  %76 = call i64 @llvm.expect.i64(i64 %75, i64 0)
  %77 = icmp ne i64 %76, 0
  br i1 %77, label %78, label %82

78:                                               ; preds = %63
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.MDBX_txn, ptr %79, i32 0, i32 9
  %81 = load ptr, ptr %80, align 8, !tbaa !21
  call void @mdbx_assert_fail(ptr noundef %81, ptr noundef @.str.16, ptr noundef @__func__.txn_ro_park, i32 noundef 218) #7
  unreachable

82:                                               ; preds = %63
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83
  br label %85

85:                                               ; preds = %84, %51
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.MDBX_txn, ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !16
  %91 = and i32 %90, 131105
  %92 = icmp ne i32 %91, 131072
  %93 = xor i1 %92, true
  %94 = xor i1 %93, true
  %95 = zext i1 %94 to i32
  %96 = sext i32 %95 to i64
  %97 = call i64 @llvm.expect.i64(i64 %96, i64 0)
  %98 = icmp ne i64 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %87
  store i32 -30782, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %207

100:                                              ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.reader_slot, ptr %101, i32 0, i32 2
  %103 = call i32 @atomic_load32(ptr noundef %102, i32 noundef 0)
  store i32 %103, ptr %8, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.reader_slot, ptr %104, i32 0, i32 1
  %106 = call i64 @atomic_load64(ptr noundef %105, i32 noundef 0)
  store i64 %106, ptr %9, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.reader_slot, ptr %107, i32 0, i32 0
  %109 = call i64 @atomic_load64(ptr noundef %108, i32 noundef 0)
  store i64 %109, ptr %10, align 8, !tbaa !23
  %110 = load i32, ptr %8, align 4, !tbaa !22
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.MDBX_txn, ptr %111, i32 0, i32 9
  %113 = load ptr, ptr %112, align 8, !tbaa !21
  %114 = getelementptr inbounds %struct.MDBX_env, ptr %113, i32 0, i32 20
  %115 = load i32, ptr %114, align 4, !tbaa !24
  %116 = icmp ne i32 %110, %115
  %117 = xor i1 %116, true
  %118 = xor i1 %117, true
  %119 = zext i1 %118 to i32
  %120 = sext i32 %119 to i64
  %121 = call i64 @llvm.expect.i64(i64 %120, i64 0)
  %122 = icmp ne i64 %121, 0
  br i1 %122, label %123, label %144

123:                                              ; preds = %100
  br label %124

124:                                              ; preds = %123
  %125 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !33
  %126 = zext i8 %125 to i32
  %127 = icmp sle i32 1, %126
  %128 = xor i1 %127, true
  %129 = xor i1 %128, true
  %130 = zext i1 %129 to i32
  %131 = sext i32 %130 to i64
  %132 = call i64 @llvm.expect.i64(i64 %131, i64 0)
  %133 = icmp ne i64 %132, 0
  br i1 %133, label %134, label %141

134:                                              ; preds = %124
  %135 = load i32, ptr %8, align 4, !tbaa !22
  %136 = load ptr, ptr %4, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.MDBX_txn, ptr %136, i32 0, i32 9
  %138 = load ptr, ptr %137, align 8, !tbaa !21
  %139 = getelementptr inbounds %struct.MDBX_env, ptr %138, i32 0, i32 20
  %140 = load i32, ptr %139, align 4, !tbaa !24
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.txn_ro_park, i32 noundef 226, ptr noundef @.str.17, i32 noundef %135, ptr noundef @.str.18, i32 noundef %140)
  br label %141

141:                                              ; preds = %134, %124
  br label %142

142:                                              ; preds = %141
  br label %143

143:                                              ; preds = %142
  store i32 -30779, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %206

144:                                              ; preds = %100
  %145 = load i64, ptr %9, align 8, !tbaa !23
  %146 = load ptr, ptr %4, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.MDBX_txn, ptr %146, i32 0, i32 3
  %148 = load i64, ptr %147, align 8, !tbaa !34
  %149 = icmp ne i64 %145, %148
  br i1 %149, label %156, label %150

150:                                              ; preds = %144
  %151 = load i64, ptr %10, align 8, !tbaa !23
  %152 = load ptr, ptr %4, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.MDBX_txn, ptr %152, i32 0, i32 7
  %154 = load i64, ptr %153, align 8, !tbaa !35
  %155 = icmp ne i64 %151, %154
  br label %156

156:                                              ; preds = %150, %144
  %157 = phi i1 [ true, %144 ], [ %155, %150 ]
  %158 = xor i1 %157, true
  %159 = xor i1 %158, true
  %160 = zext i1 %159 to i32
  %161 = sext i32 %160 to i64
  %162 = call i64 @llvm.expect.i64(i64 %161, i64 0)
  %163 = icmp ne i64 %162, 0
  br i1 %163, label %164, label %187

164:                                              ; preds = %156
  br label %165

165:                                              ; preds = %164
  %166 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !33
  %167 = zext i8 %166 to i32
  %168 = icmp sle i32 1, %167
  %169 = xor i1 %168, true
  %170 = xor i1 %169, true
  %171 = zext i1 %170 to i32
  %172 = sext i32 %171 to i64
  %173 = call i64 @llvm.expect.i64(i64 %172, i64 0)
  %174 = icmp ne i64 %173, 0
  br i1 %174, label %175, label %184

175:                                              ; preds = %165
  %176 = load i64, ptr %9, align 8, !tbaa !23
  %177 = load ptr, ptr %4, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.MDBX_txn, ptr %177, i32 0, i32 3
  %179 = load i64, ptr %178, align 8, !tbaa !34
  %180 = load i64, ptr %10, align 8, !tbaa !23
  %181 = load ptr, ptr %4, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.MDBX_txn, ptr %181, i32 0, i32 7
  %183 = load i64, ptr %182, align 8, !tbaa !35
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef @__func__.txn_ro_park, i32 noundef 232, ptr noundef @.str.19, i64 noundef %176, ptr noundef @.str.18, i64 noundef %179, i64 noundef %180, ptr noundef @.str.18, i64 noundef %183)
  br label %184

184:                                              ; preds = %175, %165
  br label %185

185:                                              ; preds = %184
  br label %186

186:                                              ; preds = %185
  store i32 -30783, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %206

187:                                              ; preds = %156
  %188 = load ptr, ptr %6, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.reader_slot, ptr %188, i32 0, i32 1
  %190 = call i64 @atomic_store64(ptr noundef %189, i64 noundef -1, i32 noundef 1)
  %191 = load ptr, ptr %4, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.MDBX_txn, ptr %191, i32 0, i32 9
  %193 = load ptr, ptr %192, align 8, !tbaa !21
  %194 = getelementptr inbounds %struct.MDBX_env, ptr %193, i32 0, i32 7
  %195 = load ptr, ptr %194, align 8, !tbaa !36
  %196 = getelementptr inbounds %struct.shared_lck, ptr %195, i32 0, i32 21
  %197 = call i32 @atomic_store32(ptr noundef %196, i32 noundef 1, i32 noundef 0)
  %198 = load i8, ptr %5, align 1, !tbaa !9, !range !37, !noundef !38
  %199 = trunc i8 %198 to i1
  %200 = zext i1 %199 to i64
  %201 = select i1 %199, i32 96, i32 32
  %202 = load ptr, ptr %4, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.MDBX_txn, ptr %202, i32 0, i32 1
  %204 = load i32, ptr %203, align 4, !tbaa !16
  %205 = add i32 %204, %201
  store i32 %205, ptr %203, align 4, !tbaa !16
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %206

206:                                              ; preds = %187, %186, %143
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %207

207:                                              ; preds = %206, %99
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %208 = load i32, ptr %3, align 4
  ret i32 %208
}

; 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

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

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

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


; 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.6 }
%struct.anon.6 = 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 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.15 = external hidden unnamed_addr constant [90 x i8], align 1
@__func__.txn_ro_park = external hidden unnamed_addr constant [12 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [59 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -30783, 1) i32 @txn_ro_park(ptr nocapture noundef %0, i1 noundef zeroext %1) local_unnamed_addr #3 {
  %3 = getelementptr inbounds i8, ptr %0, i64 168
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !8
  %6 = and i8 %5, 1
  %.not = icmp eq i8 %6, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 4
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !14
  br i1 %.not, label %.thread, label %7, !prof !19

7:                                                ; preds = %2
  %8 = and i32 %.pre, 131105
  %.not27 = icmp eq i32 %8, 131072
  br i1 %.not27, label %12, label %9, !prof !20

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = load ptr, ptr %10, align 8, !tbaa !21
  tail call void @mdbx_assert_fail(ptr noundef %11, ptr noundef nonnull @.str.15, ptr noundef nonnull @__func__.txn_ro_park, i32 noundef 217) #4
  unreachable

12:                                               ; preds = %7
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  %14 = load volatile i64, ptr %13, align 8, !tbaa !5
  %15 = icmp ugt i64 %14, -3
  br i1 %15, label %16, label %.thread, !prof !19

16:                                               ; preds = %12
  %17 = getelementptr inbounds i8, ptr %0, i64 80
  %18 = load ptr, ptr %17, align 8, !tbaa !21
  tail call void @mdbx_assert_fail(ptr noundef %18, ptr noundef nonnull @.str.16, ptr noundef nonnull @__func__.txn_ro_park, i32 noundef 218) #4
  unreachable

.thread:                                          ; preds = %2, %12
  %19 = getelementptr inbounds i8, ptr %0, i64 4
  %20 = and i32 %.pre, 131105
  %.not29 = icmp eq i32 %20, 131072
  br i1 %.not29, label %21, label %54, !prof !20

21:                                               ; preds = %.thread
  %22 = getelementptr inbounds i8, ptr %4, i64 16
  %23 = tail call i32 @atomic_load32(ptr noundef nonnull %22, i32 noundef 0)
  %24 = getelementptr inbounds i8, ptr %4, i64 8
  %25 = tail call i64 @atomic_load64(ptr noundef nonnull %24, i32 noundef 0)
  %26 = tail call i64 @atomic_load64(ptr noundef %4, i32 noundef 0)
  %27 = getelementptr inbounds i8, ptr %0, i64 80
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %28, i64 140
  %30 = load i32, ptr %29, align 4, !tbaa !22
  %.not30 = icmp eq i32 %23, %30
  br i1 %.not30, label %34, label %31, !prof !20

31:                                               ; preds = %21
  %32 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !31
  %.not33 = icmp eq i8 %32, 0
  br i1 %.not33, label %54, label %33, !prof !20

33:                                               ; preds = %31
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.txn_ro_park, i32 noundef 226, ptr noundef nonnull @.str.17, i32 noundef %23, ptr noundef nonnull @.str.18, i32 noundef %30) #5
  br label %54

34:                                               ; preds = %21
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = load i64, ptr %35, align 8, !tbaa !32
  %.not31 = icmp eq i64 %25, %36
  br i1 %.not31, label %37, label %.critedge, !prof !20

37:                                               ; preds = %34
  %38 = getelementptr inbounds i8, ptr %0, i64 64
  %39 = load i64, ptr %38, align 8, !tbaa !33
  %.not34 = icmp eq i64 %26, %39
  br i1 %.not34, label %44, label %.critedge, !prof !20

.critedge:                                        ; preds = %34, %37
  %40 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !31
  %.not32 = icmp eq i8 %40, 0
  br i1 %.not32, label %54, label %41, !prof !20

41:                                               ; preds = %.critedge
  %42 = getelementptr inbounds i8, ptr %0, i64 64
  %43 = load i64, ptr %42, align 8, !tbaa !33
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 1, ptr noundef nonnull @__func__.txn_ro_park, i32 noundef 232, ptr noundef nonnull @.str.19, i64 noundef %25, ptr noundef nonnull @.str.18, i64 noundef %36, i64 noundef %26, ptr noundef nonnull @.str.18, i64 noundef %43) #5
  br label %54

44:                                               ; preds = %37
  %45 = tail call i64 @atomic_store64(ptr noundef nonnull %24, i64 noundef -1, i32 noundef 1)
  %46 = load ptr, ptr %27, align 8, !tbaa !21
  %47 = getelementptr inbounds i8, ptr %46, i64 104
  %48 = load ptr, ptr %47, align 8, !tbaa !34
  %49 = getelementptr inbounds i8, ptr %48, i64 492
  %50 = tail call i32 @atomic_store32(ptr noundef nonnull %49, i32 noundef 1, i32 noundef 0)
  %51 = select i1 %1, i32 96, i32 32
  %52 = load i32, ptr %19, align 4, !tbaa !14
  %53 = add i32 %52, %51
  store i32 %53, ptr %19, align 4, !tbaa !14
  br label %54

54:                                               ; preds = %44, %33, %31, %41, %.critedge, %.thread
  %.1 = phi i32 [ -30782, %.thread ], [ 0, %44 ], [ -30779, %33 ], [ -30779, %31 ], [ -30783, %41 ], [ -30783, %.critedge ]
  ret i32 %.1
}

; 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

attributes #0 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { "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 = { 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 = { noreturn nounwind }
attributes #5 = { nounwind }

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

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


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