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

; 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 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x 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.2, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.3, %struct.anon.7, i8, ptr, ptr, ptr, %struct.anon.8, %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.1, i32, i64, i64, i64 }
%union.anon.1 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.2 = type { ptr, ptr, ptr, ptr }
%struct.anon.3 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.4, %union.anon.5 }
%struct.anon.4 = type { i16, i16, i16, i16 }
%union.anon.5 = type { i32 }
%struct.anon.7 = type { i64, i64, i64, i64, i64 }
%struct.anon.8 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, ptr }
%union.mdbx_atomic_uint64_t = type { i64 }
%struct.shared_lck = type { i64, i32, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, [2 x %union.mdbx_atomic_uint32_t], [16 x i8], %struct.pgops, [16 x i8], %union.pthread_mutex_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, i32, %struct.anon.11, %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.9 }
%struct.anon.9 = 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.10 }
%struct.anon.10 = type { i64, i64, i32 }
%struct.anon.11 = type { [4 x i32], [4 x i64] }
%struct.reader_slot = type { %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint64_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint32_t, %union.mdbx_atomic_uint64_t }
%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.14 }
%struct.geo = type { i16, i16, i32, i32, %union.anon.12, %union.anon.13 }
%union.anon.12 = type { i32 }
%union.anon.13 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.14 = type { %struct.anon.16 }
%struct.anon.16 = type { %struct.troika, ptr, %struct.anon.17, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.18 }
%struct.anon.17 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.18 = type { %struct.anon.19 }
%struct.anon.19 = type { i64, ptr }

@globals = external global %struct.libmdbx_globals, align 8

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

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

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

; Function Attrs: hot nounwind uwtable
declare dso_local void @meta_tap(ptr dead_on_unwind noalias writable sret(%struct.troika) align 8, ptr noundef) #2

; 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: cold nounwind optsize uwtable
define dso_local i32 @meta_wipe_steady(ptr noundef %0, i64 noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.troika, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #11
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load i64, ptr %4, align 8, !tbaa !9
  %10 = call i32 @meta_unsteady(ptr noundef %8, i64 noundef %9, i32 noundef 0)
  store i32 %10, ptr %5, align 4, !tbaa !11
  %11 = load i32, ptr %5, align 4, !tbaa !11
  %12 = icmp ne i32 %11, -1
  br i1 %12, label %13, label %16

13:                                               ; preds = %2
  %14 = load i32, ptr %5, align 4, !tbaa !11
  %15 = icmp ne i32 %14, 0
  br label %16

16:                                               ; preds = %13, %2
  %17 = phi i1 [ false, %2 ], [ %15, %13 ]
  %18 = xor i1 %17, true
  %19 = xor i1 %18, true
  %20 = xor i1 %19, true
  %21 = zext i1 %20 to i32
  %22 = sext i32 %21 to i64
  %23 = call i64 @llvm.expect.i64(i64 %22, i64 1)
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %29

25:                                               ; preds = %16
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load i64, ptr %4, align 8, !tbaa !9
  %28 = call i32 @meta_unsteady(ptr noundef %26, i64 noundef %27, i32 noundef 1)
  store i32 %28, ptr %5, align 4, !tbaa !11
  br label %29

29:                                               ; preds = %25, %16
  %30 = load i32, ptr %5, align 4, !tbaa !11
  %31 = icmp ne i32 %30, -1
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load i32, ptr %5, align 4, !tbaa !11
  %34 = icmp ne i32 %33, 0
  br label %35

35:                                               ; preds = %32, %29
  %36 = phi i1 [ false, %29 ], [ %34, %32 ]
  %37 = xor i1 %36, true
  %38 = xor i1 %37, true
  %39 = xor i1 %38, true
  %40 = zext i1 %39 to i32
  %41 = sext i32 %40 to i64
  %42 = call i64 @llvm.expect.i64(i64 %41, i64 1)
  %43 = icmp ne i64 %42, 0
  br i1 %43, label %44, label %48

44:                                               ; preds = %35
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = load i64, ptr %4, align 8, !tbaa !9
  %47 = call i32 @meta_unsteady(ptr noundef %45, i64 noundef %46, i32 noundef 2)
  store i32 %47, ptr %5, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %44, %35
  %49 = load i32, ptr %5, align 4, !tbaa !11
  %50 = icmp eq i32 %49, -1
  br i1 %50, label %51, label %94

51:                                               ; preds = %48
  store i32 0, ptr %5, align 4, !tbaa !11
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.MDBX_env, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !13
  %55 = and i32 %54, 524288
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %70

57:                                               ; preds = %51
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.MDBX_env, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = call i64 @pgno_align2os_bytes(ptr noundef %60, i64 noundef 3) #12
  %62 = call i32 @osal_msync(ptr noundef %59, i64 noundef 0, i64 noundef %61, i32 noundef 10)
  store i32 %62, ptr %5, align 4, !tbaa !11
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MDBX_env, ptr %63, i32 0, i32 7
  %65 = load ptr, ptr %64, align 8, !tbaa !24
  %66 = getelementptr inbounds %struct.shared_lck, ptr %65, i32 0, i32 9
  %67 = getelementptr inbounds %struct.pgops, ptr %66, i32 0, i32 8
  %68 = load volatile i64, ptr %67, align 64, !tbaa !25
  %69 = add i64 %68, 1
  store volatile i64 %69, ptr %67, align 64, !tbaa !25
  br label %93

70:                                               ; preds = %51
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.MDBX_env, ptr %71, i32 0, i32 5
  %73 = load i32, ptr %72, align 4, !tbaa !26
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.MDBX_env, ptr %74, i32 0, i32 3
  %76 = getelementptr inbounds %struct.osal_mmap, ptr %75, i32 0, i32 1
  %77 = load i32, ptr %76, align 8, !tbaa !27
  %78 = icmp eq i32 %73, %77
  br i1 %78, label %79, label %92

79:                                               ; preds = %70
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.MDBX_env, ptr %80, i32 0, i32 3
  %82 = getelementptr inbounds %struct.osal_mmap, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 8, !tbaa !27
  %84 = call i32 @osal_fsync(i32 noundef %83, i32 noundef 10)
  store i32 %84, ptr %5, align 4, !tbaa !11
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.MDBX_env, ptr %85, i32 0, i32 7
  %87 = load ptr, ptr %86, align 8, !tbaa !24
  %88 = getelementptr inbounds %struct.shared_lck, ptr %87, i32 0, i32 9
  %89 = getelementptr inbounds %struct.pgops, ptr %88, i32 0, i32 9
  %90 = load volatile i64, ptr %89, align 8, !tbaa !25
  %91 = add i64 %90, 1
  store volatile i64 %91, ptr %89, align 8, !tbaa !25
  br label %92

92:                                               ; preds = %79, %70
  br label %93

93:                                               ; preds = %92, %57
  br label %94

94:                                               ; preds = %93, %48
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.MDBX_env, ptr %95, i32 0, i32 3
  %97 = getelementptr inbounds %struct.osal_mmap, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8, !tbaa !25
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = call i64 @pgno2bytes(ptr noundef %99, i64 noundef 3) #12
  %101 = load i32, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 1), align 8, !tbaa !28
  %102 = zext i32 %101 to i64
  call void @osal_flush_incoherent_mmap(ptr noundef %98, i64 noundef %100, i64 noundef %102)
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.MDBX_env, ptr %103, i32 0, i32 7
  %105 = load ptr, ptr %104, align 8, !tbaa !24
  %106 = getelementptr inbounds %struct.shared_lck, ptr %105, i32 0, i32 21
  %107 = call i32 @atomic_store32(ptr noundef %106, i32 noundef 1, i32 noundef 0)
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.MDBX_env, ptr %108, i32 0, i32 24
  %110 = load ptr, ptr %109, align 8, !tbaa !30
  %111 = getelementptr inbounds %struct.MDBX_txn, ptr %110, i32 0, i32 17
  %112 = getelementptr inbounds %struct.anon.16, ptr %111, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #11
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  call void @meta_tap(ptr dead_on_unwind writable sret(%struct.troika) align 8 %6, ptr noundef %113) #13
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %112, ptr align 8 %6, i64 32, i1 false), !tbaa.struct !31
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #11
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.MDBX_env, ptr %114, i32 0, i32 24
  %116 = load ptr, ptr %115, align 8, !tbaa !30
  %117 = getelementptr inbounds %struct.MDBX_txn, ptr %116, i32 0, i32 5
  %118 = load ptr, ptr %117, align 8, !tbaa !32
  store ptr %118, ptr %7, align 8, !tbaa !5
  br label %119

119:                                              ; preds = %132, %94
  %120 = load ptr, ptr %7, align 8, !tbaa !5
  %121 = icmp ne ptr %120, null
  br i1 %121, label %123, label %122

122:                                              ; preds = %119
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #11
  br label %136

123:                                              ; preds = %119
  %124 = load ptr, ptr %7, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.MDBX_txn, ptr %124, i32 0, i32 17
  %126 = getelementptr inbounds %struct.anon.16, ptr %125, i32 0, i32 0
  %127 = load ptr, ptr %3, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.MDBX_env, ptr %127, i32 0, i32 24
  %129 = load ptr, ptr %128, align 8, !tbaa !30
  %130 = getelementptr inbounds %struct.MDBX_txn, ptr %129, i32 0, i32 17
  %131 = getelementptr inbounds %struct.anon.16, ptr %130, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %126, ptr align 8 %131, i64 32, i1 false), !tbaa.struct !31
  br label %132

132:                                              ; preds = %123
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.MDBX_txn, ptr %133, i32 0, i32 5
  %135 = load ptr, ptr %134, align 8, !tbaa !32
  store ptr %135, ptr %7, align 8, !tbaa !5
  br label %119, !llvm.loop !36

136:                                              ; preds = %122
  %137 = load i32, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #11
  ret i32 %137
}

; Function Attrs: nounwind uwtable
declare hidden i32 @meta_unsteady(ptr noundef, i64 noundef, i32 noundef) #5

declare i32 @osal_msync(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #6

; Function Attrs: nounwind willreturn memory(read)
declare i64 @pgno_align2os_bytes(ptr noundef, i64 noundef) #7

declare i32 @osal_fsync(i32 noundef, i32 noundef) #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @osal_flush_incoherent_mmap(ptr noundef, i64 noundef, i64 noundef) #8

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { cold nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind willreturn memory(read) "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 = { 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 #9 = { inlinehint nounwind willreturn memory(read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #10 = { 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 #11 = { nounwind }
attributes #12 = { nounwind willreturn memory(read) }
attributes #13 = { 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, !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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"MDBX_env", !7, i64 0, !12, i64 4, !12, i64 8, !15, i64 16, !12, i64 56, !12, i64 60, !15, i64 64, !6, i64 104, !16, i64 112, !16, i64 114, !16, i64 116, !16, i64 118, !16, i64 120, !16, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !16, i64 130, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !17, i64 152, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !12, i64 224, !12, i64 228, !12, i64 232, !6, i64 240, !6, i64 248, !10, i64 256, !18, i64 264, !21, i64 320, !19, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !22, i64 392, !7, i64 400, !12, i64 440, !12, i64 444, !6, i64 448, !23, i64 456, !7, i64 496, !7, i64 536}
!15 = !{!"osal_mmap", !7, i64 0, !12, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!16 = !{!"short", !7, i64 0}
!17 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !10, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !12, i64 28, !12, i64 32, !19, i64 36, !19, i64 37, !19, i64 38, !20, i64 40, !7, i64 48}
!19 = !{!"_Bool", !7, i64 0}
!20 = !{!"", !16, i64 0, !16, i64 2, !16, i64 4, !16, i64 6}
!21 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!22 = !{!"", !10, i64 0}
!23 = !{!"osal_ioring", !12, i64 0, !12, i64 4, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!24 = !{!14, !6, i64 104}
!25 = !{!7, !7, i64 0}
!26 = !{!14, !12, i64 60}
!27 = !{!14, !12, i64 24}
!28 = !{!29, !12, i64 16}
!29 = !{!"libmdbx_globals", !7, i64 0, !12, i64 16, !12, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !19, i64 27, !12, i64 28, !7, i64 32, !7, i64 40, !10, i64 80, !6, i64 88}
!30 = !{!14, !6, i64 192}
!31 = !{i64 0, i64 1, !25, i64 1, i64 1, !25, i64 2, i64 1, !25, i64 3, i64 1, !25, i64 4, i64 4, !11, i64 8, i64 24, !25}
!32 = !{!33, !6, i64 32}
!33 = !{!"MDBX_txn", !12, i64 0, !12, i64 4, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !34, i64 40, !10, i64 64, !10, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !35, i64 128, !6, i64 160, !7, i64 168}
!34 = !{!"geo", !16, i64 0, !16, i64 2, !12, i64 4, !12, i64 8, !7, i64 12, !7, i64 16}
!35 = !{!"MDBX_canary", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!36 = distinct !{!36, !37}
!37 = !{!"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 }
%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 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8

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

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

; Function Attrs: hot nounwind uwtable
declare dso_local void @meta_tap(ptr dead_on_unwind noalias writable sret(%struct.troika) align 8, ptr noundef) local_unnamed_addr #1

; 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) #2

; Function Attrs: cold nounwind optsize uwtable
define dso_local i32 @meta_wipe_steady(ptr noundef %0, i64 noundef %1) local_unnamed_addr #3 {
  %3 = alloca %struct.troika, align 8
  %4 = tail call i32 @meta_unsteady(ptr noundef %0, i64 noundef %1, i32 noundef 0)
  %5 = add i32 %4, 1
  %6 = icmp ult i32 %5, 2
  br i1 %6, label %7, label %.thread, !prof !5

7:                                                ; preds = %2
  %8 = tail call i32 @meta_unsteady(ptr noundef %0, i64 noundef %1, i32 noundef 1)
  %.pre = add i32 %8, 1
  %9 = icmp ult i32 %.pre, 2
  br i1 %9, label %10, label %.thread, !prof !6

10:                                               ; preds = %7
  %11 = tail call i32 @meta_unsteady(ptr noundef %0, i64 noundef %1, i32 noundef 2)
  %12 = icmp eq i32 %11, -1
  br i1 %12, label %13, label %.thread

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !7
  %16 = and i32 %15, 524288
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %26, label %17

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = tail call i64 @pgno_align2os_bytes(ptr noundef nonnull %0, i64 noundef 3) #10
  %20 = tail call i32 @osal_msync(ptr noundef nonnull %18, i64 noundef 0, i64 noundef %19, i32 noundef 10) #11
  %21 = getelementptr inbounds i8, ptr %0, i64 104
  %22 = load ptr, ptr %21, align 8, !tbaa !23
  %23 = getelementptr inbounds i8, ptr %22, i64 128
  %24 = load volatile i64, ptr %23, align 64, !tbaa !24
  %25 = add i64 %24, 1
  store volatile i64 %25, ptr %23, align 64, !tbaa !24
  br label %.thread

26:                                               ; preds = %13
  %27 = getelementptr inbounds i8, ptr %0, i64 60
  %28 = load i32, ptr %27, align 4, !tbaa !25
  %29 = getelementptr inbounds i8, ptr %0, i64 24
  %30 = load i32, ptr %29, align 8, !tbaa !26
  %31 = icmp eq i32 %28, %30
  br i1 %31, label %32, label %.thread

32:                                               ; preds = %26
  %33 = tail call i32 @osal_fsync(i32 noundef %28, i32 noundef 10) #11
  %34 = getelementptr inbounds i8, ptr %0, i64 104
  %35 = load ptr, ptr %34, align 8, !tbaa !23
  %36 = getelementptr inbounds i8, ptr %35, i64 136
  %37 = load volatile i64, ptr %36, align 8, !tbaa !24
  %38 = add i64 %37, 1
  store volatile i64 %38, ptr %36, align 8, !tbaa !24
  br label %.thread

.thread:                                          ; preds = %2, %7, %17, %32, %26, %10
  %.2 = phi i32 [ %20, %17 ], [ %33, %32 ], [ 0, %26 ], [ %11, %10 ], [ %8, %7 ], [ %4, %2 ]
  %39 = getelementptr inbounds i8, ptr %0, i64 16
  %40 = load ptr, ptr %39, align 8, !tbaa !24
  %41 = tail call i64 @pgno2bytes(ptr noundef %0, i64 noundef 3) #10
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @globals, i64 16), align 8, !tbaa !27
  %43 = zext i32 %42 to i64
  tail call void @osal_flush_incoherent_mmap(ptr noundef %40, i64 noundef %41, i64 noundef %43)
  %44 = getelementptr inbounds i8, ptr %0, i64 104
  %45 = load ptr, ptr %44, align 8, !tbaa !23
  %46 = getelementptr inbounds i8, ptr %45, i64 492
  %47 = tail call i32 @atomic_store32(ptr noundef nonnull %46, i32 noundef 1, i32 noundef 0)
  %48 = getelementptr inbounds i8, ptr %0, i64 192
  %49 = load ptr, ptr %48, align 8, !tbaa !29
  %50 = getelementptr inbounds i8, ptr %49, i64 168
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #11
  call void @meta_tap(ptr dead_on_unwind nonnull writable sret(%struct.troika) align 8 %3, ptr noundef %0) #12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %50, ptr noundef nonnull align 8 dereferenceable(32) %3, i64 32, i1 false), !tbaa.struct !30
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #11
  %51 = load ptr, ptr %48, align 8, !tbaa !29
  %.0.in33 = getelementptr inbounds i8, ptr %51, i64 32
  %.034 = load ptr, ptr %.0.in33, align 8, !tbaa !32
  %.not3135 = icmp eq ptr %.034, null
  br i1 %.not3135, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.thread
  ret i32 %.2

.lr.ph:                                           ; preds = %.thread, %.lr.ph
  %.036 = phi ptr [ %.0, %.lr.ph ], [ %.034, %.thread ]
  %52 = getelementptr inbounds i8, ptr %.036, i64 168
  %53 = load ptr, ptr %48, align 8, !tbaa !29
  %54 = getelementptr inbounds i8, ptr %53, i64 168
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %52, ptr noundef nonnull align 8 dereferenceable(32) %54, i64 32, i1 false), !tbaa.struct !30
  %.0.in = getelementptr inbounds i8, ptr %.036, i64 32
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !32
  %.not31 = icmp eq ptr %.0, null
  br i1 %.not31, label %._crit_edge, label %.lr.ph, !llvm.loop !36
}

; Function Attrs: nounwind uwtable
declare hidden i32 @meta_unsteady(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #4

declare i32 @osal_msync(ptr noundef, i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i64 @pgno_align2os_bytes(ptr noundef, i64 noundef) local_unnamed_addr #6

declare i32 @osal_fsync(i32 noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @osal_flush_incoherent_mmap(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #7

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { cold nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = { "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 = { mustprogress nofree nounwind willreturn memory(read) "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 = { 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 #8 = { inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #9 = { 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 #10 = { nounwind willreturn memory(read) }
attributes #11 = { nounwind }
attributes #12 = { 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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!"branch_weights", !"expected", i32 -2147483648, i32 0}
!7 = !{!8, !11, i64 4}
!8 = !{!"MDBX_env", !9, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !11, i64 56, !11, i64 60, !12, i64 64, !14, i64 104, !15, i64 112, !15, i64 114, !15, i64 116, !15, i64 118, !15, i64 120, !15, i64 122, !9, i64 124, !9, i64 128, !9, i64 129, !15, i64 130, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !16, i64 152, !14, i64 184, !14, i64 192, !14, i64 200, !14, i64 208, !14, i64 216, !11, i64 224, !11, i64 228, !11, i64 232, !14, i64 240, !14, i64 248, !13, i64 256, !17, i64 264, !20, i64 320, !18, i64 360, !14, i64 368, !14, i64 376, !14, i64 384, !21, i64 392, !9, i64 400, !11, i64 440, !11, i64 444, !14, i64 448, !22, i64 456, !9, i64 496, !9, i64 536}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"osal_mmap", !9, i64 0, !11, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!13 = !{!"long", !9, i64 0}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"short", !9, i64 0}
!16 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!17 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !13, i64 16, !9, i64 24, !9, i64 25, !9, i64 26, !9, i64 27, !11, i64 28, !11, i64 32, !18, i64 36, !18, i64 37, !18, i64 38, !19, i64 40, !9, i64 48}
!18 = !{!"_Bool", !9, i64 0}
!19 = !{!"", !15, i64 0, !15, i64 2, !15, i64 4, !15, i64 6}
!20 = !{!"", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!21 = !{!"", !13, i64 0}
!22 = !{!"osal_ioring", !11, i64 0, !11, i64 4, !11, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!23 = !{!8, !14, i64 104}
!24 = !{!9, !9, i64 0}
!25 = !{!8, !11, i64 60}
!26 = !{!8, !11, i64 24}
!27 = !{!28, !11, i64 16}
!28 = !{!"libmdbx_globals", !9, i64 0, !11, i64 16, !11, i64 20, !9, i64 24, !9, i64 25, !9, i64 26, !18, i64 27, !11, i64 28, !9, i64 32, !9, i64 40, !13, i64 80, !14, i64 88}
!29 = !{!8, !14, i64 192}
!30 = !{i64 0, i64 1, !24, i64 1, i64 1, !24, i64 2, i64 1, !24, i64 3, i64 1, !24, i64 4, i64 4, !31, i64 8, i64 24, !24}
!31 = !{!11, !11, i64 0}
!32 = !{!33, !14, i64 32}
!33 = !{!"MDBX_txn", !11, i64 0, !11, i64 4, !13, i64 8, !13, i64 16, !14, i64 24, !14, i64 32, !34, i64 40, !13, i64 64, !13, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !35, i64 128, !14, i64 160, !9, i64 168}
!34 = !{!"geo", !15, i64 0, !15, i64 2, !11, i64 4, !11, i64 8, !9, i64 12, !9, i64 16}
!35 = !{!"MDBX_canary", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


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