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

; 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.dpl = type { i64, i64, i64, i64, [18 x %struct.dp] }
%struct.dp = type { ptr, i32, i32 }

@globals = external global %struct.libmdbx_globals, align 8
@.str = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.debug_dpl_find = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [40 x i8], align 1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @debug_dpl_find(ptr noundef %0, i32 noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  br label %10

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

21:                                               ; preds = %10
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.MDBX_txn, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !15
  %26 = and i32 %25, 131072
  %27 = icmp eq i32 %26, 0
  %28 = xor i1 %27, true
  %29 = xor i1 %28, true
  %30 = xor i1 %29, true
  %31 = zext i1 %30 to i32
  %32 = sext i32 %31 to i64
  %33 = call i64 @llvm.expect.i64(i64 %32, i64 0)
  %34 = icmp ne i64 %33, 0
  br i1 %34, label %35, label %39

35:                                               ; preds = %22
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.MDBX_txn, ptr %36, i32 0, i32 9
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  call void @mdbx_assert_fail(ptr noundef %38, ptr noundef @.str, ptr noundef @__func__.debug_dpl_find, i32 noundef 179) #5
  unreachable

39:                                               ; preds = %22
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40, %10
  br label %42

42:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.MDBX_txn, ptr %43, i32 0, i32 17
  %45 = getelementptr inbounds %struct.anon.2, ptr %44, i32 0, i32 7
  %46 = load ptr, ptr %45, align 8, !tbaa !21
  store ptr %46, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %208

49:                                               ; preds = %42
  br label %50

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

61:                                               ; preds = %50
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MDBX_txn, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !15
  %66 = and i32 %65, 524288
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %69, label %68

68:                                               ; preds = %62
  br label %69

69:                                               ; preds = %68, %62
  %70 = phi i1 [ true, %62 ], [ false, %68 ]
  %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 = %69
  %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 !20
  call void @mdbx_assert_fail(ptr noundef %81, ptr noundef @.str.1, ptr noundef @__func__.debug_dpl_find, i32 noundef 182) #5
  unreachable

82:                                               ; preds = %69
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83
  br label %85

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

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  %89 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %90 = zext i8 %89 to i32
  %91 = and i32 %90, 1
  %92 = icmp ne i32 %91, 0
  %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 1)
  %98 = icmp ne i64 %97, 0
  br i1 %98, label %99, label %131

99:                                               ; preds = %88
  br label %100

100:                                              ; preds = %99
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.dpl, ptr %101, i32 0, i32 4
  %103 = getelementptr inbounds [18 x %struct.dp], ptr %102, i64 0, i64 0
  %104 = getelementptr inbounds %struct.dp, ptr %103, i32 0, i32 1
  %105 = load i32, ptr %104, align 8, !tbaa !22
  %106 = icmp eq i32 %105, 0
  br i1 %106, label %107, label %118

107:                                              ; preds = %100
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.dpl, ptr %108, i32 0, i32 4
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.dpl, ptr %110, i32 0, i32 1
  %112 = load i64, ptr %111, align 8, !tbaa !24
  %113 = add i64 %112, 1
  %114 = getelementptr inbounds [18 x %struct.dp], ptr %109, i64 0, i64 %113
  %115 = getelementptr inbounds %struct.dp, ptr %114, i32 0, i32 1
  %116 = load i32, ptr %115, align 8, !tbaa !22
  %117 = icmp eq i32 %116, -1
  br label %118

118:                                              ; preds = %107, %100
  %119 = phi i1 [ false, %100 ], [ %117, %107 ]
  %120 = xor i1 %119, true
  %121 = xor i1 %120, true
  %122 = xor i1 %121, true
  %123 = zext i1 %122 to i32
  %124 = sext i32 %123 to i64
  %125 = call i64 @llvm.expect.i64(i64 %124, i64 0)
  %126 = icmp ne i64 %125, 0
  br i1 %126, label %127, label %128

127:                                              ; preds = %118
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.3, ptr noundef @__func__.debug_dpl_find, i32 noundef 183) #5
  unreachable

128:                                              ; preds = %118
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130, %88
  br label %132

132:                                              ; preds = %131
  br label %133

133:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %134 = load ptr, ptr %6, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.dpl, ptr %134, i32 0, i32 1
  %136 = load i64, ptr %135, align 8, !tbaa !24
  store i64 %136, ptr %7, align 8, !tbaa !26
  br label %137

137:                                              ; preds = %161, %133
  %138 = load i64, ptr %7, align 8, !tbaa !26
  %139 = load ptr, ptr %6, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.dpl, ptr %139, i32 0, i32 0
  %141 = load i64, ptr %140, align 8, !tbaa !27
  %142 = icmp ugt i64 %138, %141
  br i1 %142, label %144, label %143

143:                                              ; preds = %137
  store i32 14, ptr %8, align 4
  br label %164

144:                                              ; preds = %137
  %145 = load ptr, ptr %6, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.dpl, ptr %145, i32 0, i32 4
  %147 = load i64, ptr %7, align 8, !tbaa !26
  %148 = getelementptr inbounds [18 x %struct.dp], ptr %146, i64 0, i64 %147
  %149 = getelementptr inbounds %struct.dp, ptr %148, i32 0, i32 1
  %150 = load i32, ptr %149, align 8, !tbaa !22
  %151 = load i32, ptr %5, align 4, !tbaa !9
  %152 = icmp eq i32 %150, %151
  br i1 %152, label %153, label %160

153:                                              ; preds = %144
  %154 = load ptr, ptr %6, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.dpl, ptr %154, i32 0, i32 4
  %156 = load i64, ptr %7, align 8, !tbaa !26
  %157 = getelementptr inbounds [18 x %struct.dp], ptr %155, i64 0, i64 %156
  %158 = getelementptr inbounds %struct.dp, ptr %157, i32 0, i32 0
  %159 = load ptr, ptr %158, align 8, !tbaa !28
  store ptr %159, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %164

160:                                              ; preds = %144
  br label %161

161:                                              ; preds = %160
  %162 = load i64, ptr %7, align 8, !tbaa !26
  %163 = add i64 %162, -1
  store i64 %163, ptr %7, align 8, !tbaa !26
  br label %137, !llvm.loop !29

164:                                              ; preds = %153, %143
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %165 = load i32, ptr %8, align 4
  switch i32 %165, label %248 [
    i32 14, label %166
  ]

166:                                              ; preds = %164
  %167 = load ptr, ptr %6, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.dpl, ptr %167, i32 0, i32 0
  %169 = load i64, ptr %168, align 8, !tbaa !27
  %170 = icmp ne i64 %169, 0
  br i1 %170, label %171, label %207

171:                                              ; preds = %166
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %172 = load ptr, ptr %6, align 8, !tbaa !5
  %173 = getelementptr inbounds %struct.dpl, ptr %172, i32 0, i32 4
  %174 = getelementptr inbounds [18 x %struct.dp], ptr %173, i64 0, i64 0
  %175 = getelementptr inbounds %struct.dp, ptr %174, i64 1
  %176 = load ptr, ptr %6, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.dpl, ptr %176, i32 0, i32 0
  %178 = load i64, ptr %177, align 8, !tbaa !27
  %179 = load i32, ptr %5, align 4, !tbaa !9
  %180 = call ptr @dp_bsearch(ptr noundef %175, i64 noundef %178, i32 noundef %179)
  %181 = load ptr, ptr %6, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.dpl, ptr %181, i32 0, i32 4
  %183 = getelementptr inbounds [18 x %struct.dp], ptr %182, i64 0, i64 0
  %184 = ptrtoint ptr %180 to i64
  %185 = ptrtoint ptr %183 to i64
  %186 = sub i64 %184, %185
  %187 = sdiv exact i64 %186, 16
  store i64 %187, ptr %9, align 8, !tbaa !26
  %188 = load ptr, ptr %6, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.dpl, ptr %188, i32 0, i32 4
  %190 = load i64, ptr %9, align 8, !tbaa !26
  %191 = getelementptr inbounds [18 x %struct.dp], ptr %189, i64 0, i64 %190
  %192 = getelementptr inbounds %struct.dp, ptr %191, i32 0, i32 1
  %193 = load i32, ptr %192, align 8, !tbaa !22
  %194 = load i32, ptr %5, align 4, !tbaa !9
  %195 = icmp eq i32 %193, %194
  br i1 %195, label %196, label %203

196:                                              ; preds = %171
  %197 = load ptr, ptr %6, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.dpl, ptr %197, i32 0, i32 4
  %199 = load i64, ptr %9, align 8, !tbaa !26
  %200 = getelementptr inbounds [18 x %struct.dp], ptr %198, i64 0, i64 %199
  %201 = getelementptr inbounds %struct.dp, ptr %200, i32 0, i32 0
  %202 = load ptr, ptr %201, align 8, !tbaa !28
  store ptr %202, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %204

203:                                              ; preds = %171
  store i32 0, ptr %8, align 4
  br label %204

204:                                              ; preds = %203, %196
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %205 = load i32, ptr %8, align 4
  switch i32 %205, label %248 [
    i32 0, label %206
  ]

206:                                              ; preds = %204
  br label %207

207:                                              ; preds = %206, %166
  br label %247

208:                                              ; preds = %42
  br label %209

209:                                              ; preds = %208
  %210 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %211 = zext i8 %210 to i32
  %212 = and i32 %211, 1
  %213 = icmp ne i32 %212, 0
  %214 = xor i1 %213, true
  %215 = xor i1 %214, true
  %216 = zext i1 %215 to i32
  %217 = sext i32 %216 to i64
  %218 = call i64 @llvm.expect.i64(i64 %217, i64 1)
  %219 = icmp ne i64 %218, 0
  br i1 %219, label %220, label %244

220:                                              ; preds = %209
  br label %221

221:                                              ; preds = %220
  %222 = load ptr, ptr %4, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.MDBX_txn, ptr %222, i32 0, i32 1
  %224 = load i32, ptr %223, align 4, !tbaa !15
  %225 = and i32 %224, 524288
  %226 = icmp ne i32 %225, 0
  br i1 %226, label %227, label %228

227:                                              ; preds = %221
  br label %228

228:                                              ; preds = %227, %221
  %229 = phi i1 [ false, %221 ], [ true, %227 ]
  %230 = xor i1 %229, true
  %231 = xor i1 %230, true
  %232 = xor i1 %231, true
  %233 = zext i1 %232 to i32
  %234 = sext i32 %233 to i64
  %235 = call i64 @llvm.expect.i64(i64 %234, i64 0)
  %236 = icmp ne i64 %235, 0
  br i1 %236, label %237, label %241

237:                                              ; preds = %228
  %238 = load ptr, ptr %4, align 8, !tbaa !5
  %239 = getelementptr inbounds %struct.MDBX_txn, ptr %238, i32 0, i32 9
  %240 = load ptr, ptr %239, align 8, !tbaa !20
  call void @mdbx_assert_fail(ptr noundef %240, ptr noundef @.str.9, ptr noundef @__func__.debug_dpl_find, i32 noundef 194) #5
  unreachable

241:                                              ; preds = %228
  br label %242

242:                                              ; preds = %241
  br label %243

243:                                              ; preds = %242
  br label %244

244:                                              ; preds = %243, %209
  br label %245

245:                                              ; preds = %244
  br label %246

246:                                              ; preds = %245
  br label %247

247:                                              ; preds = %246, %207
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %248

248:                                              ; preds = %247, %204, %164
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %249 = load ptr, ptr %3, align 8
  ret ptr %249
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { noreturn }
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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 25}
!12 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !13, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !14, i64 80, !6, i64 88}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !10, i64 4}
!16 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !14, i64 8, !14, i64 16, !6, i64 24, !6, i64 32, !17, 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, !19, i64 128, !6, i64 160, !7, i64 168}
!17 = !{!"geo", !18, i64 0, !18, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!18 = !{!"short", !7, i64 0}
!19 = !{!"MDBX_canary", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!20 = !{!16, !6, i64 80}
!21 = !{!7, !7, i64 0}
!22 = !{!23, !10, i64 8}
!23 = !{!"dp", !6, i64 0, !10, i64 8, !10, i64 12}
!24 = !{!25, !14, i64 8}
!25 = !{!"dpl", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !7, i64 32}
!26 = !{!14, !14, i64 0}
!27 = !{!25, !14, i64 0}
!28 = !{!23, !6, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


; 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 }
%struct.dp = type { ptr, i32, i32 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [73 x i8], align 1
@__func__.debug_dpl_find = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [40 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 ptr @dp_bsearch(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @debug_dpl_find(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %4 = and i8 %3, 1
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %12, label %5, !prof !13

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !14
  %8 = and i32 %7, 131072
  %.not38 = icmp eq i32 %8, 0
  br i1 %.not38, label %.thread, label %9, !prof !19

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = load ptr, ptr %10, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %11, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.debug_dpl_find, i32 noundef 179) #3
  unreachable

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 496
  %14 = load ptr, ptr %13, align 8, !tbaa !21
  %.not39 = icmp eq ptr %14, null
  br i1 %.not39, label %61, label %._crit_edge62

._crit_edge62:                                    ; preds = %12
  %.phi.trans.insert = getelementptr inbounds i8, ptr %14, i64 8
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !22
  br label %33

.thread:                                          ; preds = %5
  %15 = getelementptr inbounds i8, ptr %0, i64 496
  %16 = load ptr, ptr %15, align 8, !tbaa !21
  %.not3948 = icmp eq ptr %16, null
  %17 = and i32 %7, 524288
  %.not41 = icmp eq i32 %17, 0
  br i1 %.not3948, label %56, label %18

18:                                               ; preds = %.thread
  br i1 %.not41, label %22, label %19, !prof !19

19:                                               ; preds = %18
  %20 = getelementptr inbounds i8, ptr %0, i64 80
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %21, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.debug_dpl_find, i32 noundef 182) #3
  unreachable

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %16, i64 40
  %24 = load i32, ptr %23, align 8, !tbaa !24
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %.critedge, !prof !19

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %16, i64 32
  %28 = getelementptr inbounds i8, ptr %16, i64 8
  %29 = load i64, ptr %28, align 8, !tbaa !22
  %30 = add i64 %29, 1
  %31 = getelementptr inbounds [18 x %struct.dp], ptr %27, i64 0, i64 %30, i32 1
  %32 = load i32, ptr %31, align 8, !tbaa !24
  %.not56 = icmp eq i32 %32, -1
  br i1 %.not56, label %33, label %.critedge, !prof !19

.critedge:                                        ; preds = %22, %26
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.3, ptr noundef nonnull @__func__.debug_dpl_find, i32 noundef 183) #3
  unreachable

33:                                               ; preds = %._crit_edge62, %26
  %34 = phi i64 [ %29, %26 ], [ %.pre, %._crit_edge62 ]
  %35 = phi ptr [ %16, %26 ], [ %14, %._crit_edge62 ]
  %36 = load i64, ptr %35, align 8, !tbaa !26
  %.not4559 = icmp ugt i64 %34, %36
  br i1 %.not4559, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %33
  %37 = getelementptr inbounds i8, ptr %35, i64 32
  br label %40

38:                                               ; preds = %40
  %39 = add i64 %.03560, -1
  %.not45 = icmp ugt i64 %39, %36
  br i1 %.not45, label %40, label %._crit_edge, !llvm.loop !27

40:                                               ; preds = %.lr.ph, %38
  %.03560 = phi i64 [ %34, %.lr.ph ], [ %39, %38 ]
  %41 = getelementptr inbounds [18 x %struct.dp], ptr %37, i64 0, i64 %.03560
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  %43 = load i32, ptr %42, align 8, !tbaa !24
  %44 = icmp eq i32 %43, %1
  br i1 %44, label %.sink.split, label %38

._crit_edge:                                      ; preds = %38, %33
  %.not46 = icmp eq i64 %36, 0
  br i1 %.not46, label %61, label %45

45:                                               ; preds = %._crit_edge
  %46 = getelementptr inbounds i8, ptr %35, i64 32
  %47 = getelementptr inbounds i8, ptr %35, i64 48
  %48 = tail call ptr @dp_bsearch(ptr noundef nonnull %47, i64 noundef %36, i32 noundef %1)
  %49 = ptrtoint ptr %48 to i64
  %50 = ptrtoint ptr %46 to i64
  %51 = sub i64 %49, %50
  %52 = ashr exact i64 %51, 4
  %53 = getelementptr inbounds [18 x %struct.dp], ptr %46, i64 0, i64 %52
  %54 = getelementptr inbounds i8, ptr %53, i64 8
  %55 = load i32, ptr %54, align 8, !tbaa !24
  %.not47 = icmp eq i32 %55, %1
  br i1 %.not47, label %.sink.split, label %61

56:                                               ; preds = %.thread
  br i1 %.not41, label %57, label %61, !prof !13

57:                                               ; preds = %56
  %58 = getelementptr inbounds i8, ptr %0, i64 80
  %59 = load ptr, ptr %58, align 8, !tbaa !20
  tail call void @mdbx_assert_fail(ptr noundef %59, ptr noundef nonnull @.str.9, ptr noundef nonnull @__func__.debug_dpl_find, i32 noundef 194) #3
  unreachable

.sink.split:                                      ; preds = %40, %45
  %.sink = phi ptr [ %53, %45 ], [ %41, %40 ]
  %60 = load ptr, ptr %.sink, align 8, !tbaa !29
  br label %61

61:                                               ; preds = %.sink.split, %._crit_edge, %56, %45, %12
  %.2 = phi ptr [ null, %12 ], [ null, %45 ], [ null, %56 ], [ null, %._crit_edge ], [ %60, %.sink.split ]
  ret ptr %.2
}

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 = { 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 = { noreturn 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, !7, i64 25}
!6 = !{!"libmdbx_globals", !7, i64 0, !9, i64 16, !9, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !10, i64 27, !9, i64 28, !7, i64 32, !7, i64 40, !11, i64 80, !12, i64 88}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!14 = !{!15, !9, i64 4}
!15 = !{!"MDBX_txn", !9, i64 0, !9, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !16, i64 40, !11, i64 64, !11, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !18, i64 128, !12, i64 160, !7, i64 168}
!16 = !{!"geo", !17, i64 0, !17, i64 2, !9, i64 4, !9, i64 8, !7, i64 12, !7, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!19 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!20 = !{!15, !12, i64 80}
!21 = !{!7, !7, i64 0}
!22 = !{!23, !11, i64 8}
!23 = !{!"dpl", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32}
!24 = !{!25, !9, i64 8}
!25 = !{!"dp", !12, i64 0, !9, i64 8, !9, i64 12}
!26 = !{!23, !11, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!25, !12, i64 0}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LowerExpectIntrinsicPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass