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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon }
%struct.anon = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@globals = external global %struct.libmdbx_globals, align 8
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [42 x i8], align 1
@__func__.pnl_merge = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [21 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: hot noinline nounwind uwtable
declare dso_local zeroext i1 @pnl_check(ptr noundef, i64 noundef) #4

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

9:                                                ; preds = %2
  %10 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %11 = zext i8 %10 to i32
  %12 = and i32 %11, 1
  %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 1)
  %19 = icmp ne i64 %18, 0
  br i1 %19, label %20, label %34

20:                                               ; preds = %9
  br label %21

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

31:                                               ; preds = %21
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.8, ptr noundef @__func__.pnl_merge, i32 noundef 190) #8
  unreachable

32:                                               ; preds = %21
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33, %9
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %38 = zext i8 %37 to i32
  %39 = and i32 %38, 1
  %40 = icmp ne i32 %39, 0
  %41 = xor i1 %40, true
  %42 = xor i1 %41, true
  %43 = zext i1 %42 to i32
  %44 = sext i32 %43 to i64
  %45 = call i64 @llvm.expect.i64(i64 %44, i64 1)
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %61

47:                                               ; preds = %36
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = call zeroext i1 @pnl_check(ptr noundef %49, i64 noundef 2147483648) #9
  %51 = xor i1 %50, true
  %52 = xor i1 %51, true
  %53 = xor i1 %52, true
  %54 = zext i1 %53 to i32
  %55 = sext i32 %54 to i64
  %56 = call i64 @llvm.expect.i64(i64 %55, i64 0)
  %57 = icmp ne i64 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %48
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.9, ptr noundef @__func__.pnl_merge, i32 noundef 191) #8
  unreachable

59:                                               ; preds = %48
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60, %36
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #10
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds i32, ptr %63, i64 0
  %65 = load i32, ptr %64, align 4, !tbaa !14
  %66 = zext i32 %65 to i64
  store i64 %66, ptr %5, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #10
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds i32, ptr %67, i64 0
  %69 = load i32, ptr %68, align 4, !tbaa !14
  %70 = zext i32 %69 to i64
  store i64 %70, ptr %6, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #10
  %71 = load i64, ptr %6, align 8, !tbaa !15
  store i64 %71, ptr %7, align 8, !tbaa !15
  br label %72

72:                                               ; preds = %62
  %73 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %74 = zext i8 %73 to i32
  %75 = and i32 %74, 1
  %76 = icmp ne i32 %75, 0
  %77 = xor i1 %76, true
  %78 = xor i1 %77, true
  %79 = zext i1 %78 to i32
  %80 = sext i32 %79 to i64
  %81 = call i64 @llvm.expect.i64(i64 %80, i64 1)
  %82 = icmp ne i64 %81, 0
  br i1 %82, label %83, label %102

83:                                               ; preds = %72
  br label %84

84:                                               ; preds = %83
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds i32, ptr %85, i64 -1
  %87 = load i32, ptr %86, align 4, !tbaa !14
  %88 = zext i32 %87 to i64
  %89 = load i64, ptr %7, align 8, !tbaa !15
  %90 = icmp uge i64 %88, %89
  %91 = xor i1 %90, true
  %92 = xor i1 %91, true
  %93 = xor i1 %92, true
  %94 = zext i1 %93 to i32
  %95 = sext i32 %94 to i64
  %96 = call i64 @llvm.expect.i64(i64 %95, i64 0)
  %97 = icmp ne i64 %96, 0
  br i1 %97, label %98, label %99

98:                                               ; preds = %84
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.10, ptr noundef @__func__.pnl_merge, i32 noundef 195) #8
  unreachable

99:                                               ; preds = %84
  br label %100

100:                                              ; preds = %99
  br label %101

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101, %72
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  %105 = load i64, ptr %5, align 8, !tbaa !15
  %106 = icmp ugt i64 %105, 0
  %107 = xor i1 %106, true
  %108 = xor i1 %107, true
  %109 = zext i1 %108 to i32
  %110 = sext i32 %109 to i64
  %111 = call i64 @llvm.expect.i64(i64 %110, i64 1)
  %112 = icmp ne i64 %111, 0
  br i1 %112, label %113, label %223

113:                                              ; preds = %104
  %114 = load i64, ptr %5, align 8, !tbaa !15
  %115 = load i64, ptr %7, align 8, !tbaa !15
  %116 = add i64 %115, %114
  store i64 %116, ptr %7, align 8, !tbaa !15
  %117 = load i64, ptr %6, align 8, !tbaa !15
  %118 = icmp eq i64 %117, 0
  br i1 %118, label %131, label %119

119:                                              ; preds = %113
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = getelementptr inbounds i32, ptr %121, i64 0
  %123 = load i32, ptr %122, align 4, !tbaa !14
  %124 = zext i32 %123 to i64
  %125 = getelementptr inbounds i32, ptr %120, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !14
  %127 = load ptr, ptr %4, align 8, !tbaa !5
  %128 = getelementptr inbounds i32, ptr %127, i64 1
  %129 = load i32, ptr %128, align 4, !tbaa !14
  %130 = icmp ugt i32 %126, %129
  br i1 %130, label %131, label %143

131:                                              ; preds = %119, %113
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  %133 = load ptr, ptr %3, align 8, !tbaa !5
  %134 = getelementptr inbounds i32, ptr %133, i64 0
  %135 = load i32, ptr %134, align 4, !tbaa !14
  %136 = zext i32 %135 to i64
  %137 = add i64 %136, 1
  %138 = getelementptr inbounds i32, ptr %132, i64 %137
  %139 = load ptr, ptr %4, align 8, !tbaa !5
  %140 = getelementptr inbounds i32, ptr %139, i64 1
  %141 = load i64, ptr %5, align 8, !tbaa !15
  %142 = mul i64 %141, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %138, ptr align 4 %140, i64 %142, i1 false)
  br label %185

143:                                              ; preds = %119
  %144 = load ptr, ptr %4, align 8, !tbaa !5
  %145 = load ptr, ptr %4, align 8, !tbaa !5
  %146 = getelementptr inbounds i32, ptr %145, i64 0
  %147 = load i32, ptr %146, align 4, !tbaa !14
  %148 = zext i32 %147 to i64
  %149 = getelementptr inbounds i32, ptr %144, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !14
  %151 = load ptr, ptr %3, align 8, !tbaa !5
  %152 = getelementptr inbounds i32, ptr %151, i64 1
  %153 = load i32, ptr %152, align 4, !tbaa !14
  %154 = icmp ugt i32 %150, %153
  br i1 %154, label %155, label %170

155:                                              ; preds = %143
  %156 = load ptr, ptr %3, align 8, !tbaa !5
  %157 = getelementptr inbounds i32, ptr %156, i64 1
  %158 = load i64, ptr %5, align 8, !tbaa !15
  %159 = getelementptr inbounds i32, ptr %157, i64 %158
  %160 = load ptr, ptr %3, align 8, !tbaa !5
  %161 = getelementptr inbounds i32, ptr %160, i64 1
  %162 = load i64, ptr %6, align 8, !tbaa !15
  %163 = mul i64 %162, 4
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %159, ptr align 4 %161, i64 %163, i1 false)
  %164 = load ptr, ptr %3, align 8, !tbaa !5
  %165 = getelementptr inbounds i32, ptr %164, i64 1
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = getelementptr inbounds i32, ptr %166, i64 1
  %168 = load i64, ptr %5, align 8, !tbaa !15
  %169 = mul i64 %168, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %165, ptr align 4 %167, i64 %169, i1 false)
  br label %184

170:                                              ; preds = %143
  br label %171

171:                                              ; preds = %170
  %172 = load ptr, ptr %3, align 8, !tbaa !5
  %173 = getelementptr inbounds i32, ptr %172, i64 0
  store i32 -1, ptr %173, align 4, !tbaa !14
  %174 = load ptr, ptr %3, align 8, !tbaa !5
  %175 = load i64, ptr %7, align 8, !tbaa !15
  %176 = getelementptr inbounds i32, ptr %174, i64 %175
  %177 = load ptr, ptr %3, align 8, !tbaa !5
  %178 = load i64, ptr %6, align 8, !tbaa !15
  %179 = getelementptr inbounds i32, ptr %177, i64 %178
  %180 = load ptr, ptr %4, align 8, !tbaa !5
  %181 = load i64, ptr %5, align 8, !tbaa !15
  %182 = getelementptr inbounds i32, ptr %180, i64 %181
  %183 = load ptr, ptr %4, align 8, !tbaa !5
  call void @pnl_merge_inner(ptr noundef %176, ptr noundef %179, ptr noundef %182, ptr noundef %183)
  br label %184

184:                                              ; preds = %171, %155
  br label %185

185:                                              ; preds = %184, %131
  br label %186

186:                                              ; preds = %185
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #10
  %187 = load i64, ptr %7, align 8, !tbaa !15
  store i64 %187, ptr %8, align 8, !tbaa !15
  br label %188

188:                                              ; preds = %186
  %189 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !9
  %190 = zext i8 %189 to i32
  %191 = and i32 %190, 1
  %192 = icmp ne i32 %191, 0
  %193 = xor i1 %192, true
  %194 = xor i1 %193, true
  %195 = zext i1 %194 to i32
  %196 = sext i32 %195 to i64
  %197 = call i64 @llvm.expect.i64(i64 %196, i64 1)
  %198 = icmp ne i64 %197, 0
  br i1 %198, label %199, label %214

199:                                              ; preds = %188
  br label %200

200:                                              ; preds = %199
  %201 = load i64, ptr %8, align 8, !tbaa !15
  %202 = icmp ult i64 %201, 2147483647
  %203 = xor i1 %202, true
  %204 = xor i1 %203, true
  %205 = xor i1 %204, true
  %206 = zext i1 %205 to i32
  %207 = sext i32 %206 to i64
  %208 = call i64 @llvm.expect.i64(i64 %207, i64 0)
  %209 = icmp ne i64 %208, 0
  br i1 %209, label %210, label %211

210:                                              ; preds = %200
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.6, ptr noundef @__func__.pnl_merge, i32 noundef 210) #8
  unreachable

211:                                              ; preds = %200
  br label %212

212:                                              ; preds = %211
  br label %213

213:                                              ; preds = %212
  br label %214

214:                                              ; preds = %213, %188
  br label %215

215:                                              ; preds = %214
  br label %216

216:                                              ; preds = %215
  %217 = load i64, ptr %8, align 8, !tbaa !15
  %218 = trunc i64 %217 to i32
  %219 = load ptr, ptr %3, align 8, !tbaa !5
  %220 = getelementptr inbounds i32, ptr %219, i64 0
  store i32 %218, ptr %220, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #10
  br label %221

221:                                              ; preds = %216
  br label %222

222:                                              ; preds = %221
  br label %223

223:                                              ; preds = %222, %104
  br label %224

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

235:                                              ; preds = %224
  br label %236

236:                                              ; preds = %235
  %237 = load ptr, ptr %3, align 8, !tbaa !5
  %238 = call zeroext i1 @pnl_check_allocated(ptr noundef %237, i64 noundef 2147483648)
  %239 = xor i1 %238, true
  %240 = xor i1 %239, true
  %241 = xor i1 %240, true
  %242 = zext i1 %241 to i32
  %243 = sext i32 %242 to i64
  %244 = call i64 @llvm.expect.i64(i64 %243, i64 0)
  %245 = icmp ne i64 %244, 0
  br i1 %245, label %246, label %247

246:                                              ; preds = %236
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.8, ptr noundef @__func__.pnl_merge, i32 noundef 212) #8
  unreachable

247:                                              ; preds = %236
  br label %248

248:                                              ; preds = %247
  br label %249

249:                                              ; preds = %248
  br label %250

250:                                              ; preds = %249, %224
  br label %251

251:                                              ; preds = %250
  br label %252

252:                                              ; preds = %251
  %253 = load i64, ptr %7, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #10
  ret i64 %253
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @pnl_check_allocated(ptr noundef, i64 noundef) #6

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @pnl_merge_inner(ptr noalias noundef, ptr noalias noundef, ptr noalias noundef, ptr noalias noundef) #7

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { hot noinline 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 = { hot 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 = { 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 #7 = { 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 #8 = { noreturn }
attributes #9 = { hot }
attributes #10 = { 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, !7, i64 25}
!10 = !{!"libmdbx_globals", !7, i64 0, !11, i64 16, !11, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !12, i64 27, !11, i64 28, !7, i64 32, !7, i64 40, !13, i64 80, !6, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!13, !13, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.libmdbx_globals = type { %union.bin128, i32, i32, i8, i8, i8, i8, i32, %union.logger_union, %union.pthread_mutex_t, i64, ptr }
%union.bin128 = type { %struct.anon }
%struct.anon = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [42 x i8], align 1
@__func__.pnl_merge = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [21 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: hot noinline nounwind uwtable
declare dso_local zeroext i1 @pnl_check(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: hot nounwind uwtable
define dso_local range(i64 0, 8589934591) i64 @pnl_merge(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %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 %.thread57, label %5, !prof !13

5:                                                ; preds = %2
  %6 = tail call zeroext i1 @pnl_check_allocated(ptr noundef %0, i64 noundef 2147483648)
  br i1 %6, label %8, label %7, !prof !14

7:                                                ; preds = %5
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.8, ptr noundef nonnull @__func__.pnl_merge, i32 noundef 190) #6
  unreachable

8:                                                ; preds = %5
  %.pre = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %.pre51 = and i8 %.pre, 1
  %.not43 = icmp eq i8 %.pre51, 0
  br i1 %.not43, label %.thread57, label %9, !prof !15

9:                                                ; preds = %8
  %10 = tail call zeroext i1 @pnl_check(ptr noundef %1, i64 noundef 2147483648) #7
  br i1 %10, label %14, label %11, !prof !14

11:                                               ; preds = %9
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.9, ptr noundef nonnull @__func__.pnl_merge, i32 noundef 191) #6
  unreachable

.thread57:                                        ; preds = %8, %2
  %12 = load i32, ptr %1, align 4, !tbaa !16
  %13 = load i32, ptr %0, align 4, !tbaa !16
  br label %21

14:                                               ; preds = %9
  %.pre50 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %.pre52 = and i8 %.pre50, 1
  %15 = load i32, ptr %1, align 4, !tbaa !16
  %16 = load i32, ptr %0, align 4, !tbaa !16
  %.not44 = icmp eq i8 %.pre52, 0
  br i1 %.not44, label %21, label %17, !prof !15

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 -4
  %19 = load i32, ptr %18, align 4, !tbaa !16
  %.not45 = icmp ult i32 %19, %16
  br i1 %.not45, label %20, label %21, !prof !13

20:                                               ; preds = %17
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.10, ptr noundef nonnull @__func__.pnl_merge, i32 noundef 195) #6
  unreachable

21:                                               ; preds = %.thread57, %17, %14
  %22 = phi i32 [ %13, %.thread57 ], [ %16, %17 ], [ %16, %14 ]
  %23 = phi i32 [ %12, %.thread57 ], [ %15, %17 ], [ %15, %14 ]
  %.pre-phi5360 = phi i8 [ 0, %.thread57 ], [ 1, %17 ], [ 0, %14 ]
  %24 = zext i32 %23 to i64
  %25 = zext i32 %22 to i64
  %.not46 = icmp eq i32 %23, 0
  br i1 %.not46, label %59, label %26, !prof !13

26:                                               ; preds = %21
  %27 = add nuw nsw i64 %25, %24
  %28 = icmp eq i32 %22, 0
  br i1 %28, label %35, label %29

29:                                               ; preds = %26
  %30 = getelementptr inbounds i32, ptr %0, i64 %25
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = getelementptr inbounds i8, ptr %1, i64 4
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = icmp ugt i32 %31, %33
  br i1 %34, label %35, label %40

35:                                               ; preds = %29, %26
  %36 = getelementptr inbounds i32, ptr %0, i64 %25
  %37 = getelementptr inbounds i8, ptr %36, i64 4
  %38 = getelementptr inbounds i8, ptr %1, i64 4
  %39 = shl nuw nsw i64 %24, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %37, ptr nonnull align 4 %38, i64 %39, i1 false)
  br label %52

40:                                               ; preds = %29
  %41 = getelementptr inbounds i32, ptr %1, i64 %24
  %42 = load i32, ptr %41, align 4, !tbaa !16
  %43 = getelementptr inbounds i8, ptr %0, i64 4
  %44 = load i32, ptr %43, align 4, !tbaa !16
  %45 = icmp ugt i32 %42, %44
  br i1 %45, label %46, label %50

46:                                               ; preds = %40
  %47 = getelementptr inbounds i32, ptr %43, i64 %24
  %48 = shl nuw nsw i64 %25, 2
  tail call void @llvm.memmove.p0.p0.i64(ptr nonnull align 4 %47, ptr nonnull align 4 %43, i64 %48, i1 false)
  %49 = shl nuw nsw i64 %24, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %43, ptr nonnull align 4 %32, i64 %49, i1 false)
  br label %52

50:                                               ; preds = %40
  store i32 -1, ptr %0, align 4, !tbaa !16
  %51 = getelementptr inbounds i32, ptr %0, i64 %27
  tail call void @pnl_merge_inner(ptr noundef nonnull %51, ptr noundef nonnull %30, ptr noundef nonnull %41, ptr noundef nonnull %1)
  br label %52

52:                                               ; preds = %35, %50, %46
  %53 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %54 = and i8 %53, 1
  %.not47 = icmp ne i8 %54, 0
  %55 = icmp ugt i64 %27, 2147483646
  %or.cond = select i1 %.not47, i1 %55, i1 false
  br i1 %or.cond, label %56, label %57, !prof !17

56:                                               ; preds = %52
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.6, ptr noundef nonnull @__func__.pnl_merge, i32 noundef 210) #6
  unreachable

57:                                               ; preds = %52
  %58 = trunc i64 %27 to i32
  store i32 %58, ptr %0, align 4, !tbaa !16
  br label %59

59:                                               ; preds = %21, %57
  %.pre-phi54 = phi i8 [ %.pre-phi5360, %21 ], [ %54, %57 ]
  %.0 = phi i64 [ %25, %21 ], [ %27, %57 ]
  %.not48 = icmp eq i8 %.pre-phi54, 0
  br i1 %.not48, label %63, label %60, !prof !13

60:                                               ; preds = %59
  %61 = tail call zeroext i1 @pnl_check_allocated(ptr noundef nonnull %0, i64 noundef 2147483648)
  br i1 %61, label %63, label %62, !prof !14

62:                                               ; preds = %60
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.8, ptr noundef nonnull @__func__.pnl_merge, i32 noundef 212) #6
  unreachable

63:                                               ; preds = %60, %59
  ret i64 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @pnl_check_allocated(ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @pnl_merge_inner(ptr noalias noundef, ptr noalias noundef, ptr noalias noundef, ptr noalias noundef) local_unnamed_addr #5

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { hot noinline 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 = { hot 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 = { 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 #5 = { 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 #6 = { noreturn nounwind }
attributes #7 = { hot }

!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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!15 = !{!"branch_weights", !"expected", i32 0, i32 -2147483648}
!16 = !{!9, !9, i64 0}
!17 = !{!"branch_weights", i32 2000, i32 4002001}


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