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

; 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.MDBX_env = type { %union.mdbx_atomic_uint32_t, i32, i32, %struct.osal_mmap, i32, i32, %struct.osal_mmap, ptr, i16, i16, i16, i16, i16, i16, %union.mdbx_atomic_uint32_t, i8, i8, i16, i32, i32, i32, i32, %struct.anon.9, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.10, %struct.anon.14, i8, ptr, ptr, ptr, %struct.anon.15, %union.pthread_mutex_t, i32, i32, ptr, %struct.osal_ioring, %union.pthread_mutex_t, [71 x %union.mdbx_atomic_uint64_t] }
%struct.osal_mmap = type { %union.anon.8, i32, i64, i64, i64 }
%union.anon.8 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.9 = type { ptr, ptr, ptr, ptr }
%struct.anon.10 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.11, %union.anon.12 }
%struct.anon.11 = type { i16, i16, i16, i16 }
%union.anon.12 = type { i32 }
%struct.anon.14 = type { i64, i64, i64, i64, i64 }
%struct.anon.15 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, ptr }
%union.mdbx_atomic_uint64_t = type { i64 }
%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.2 }
%struct.geo = type { i16, i16, i32, i32, %union.anon, %union.anon.1 }
%union.anon = type { i32 }
%union.anon.1 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.2 = type { %struct.anon.4 }
%struct.anon.4 = type { %struct.troika, ptr, %struct.anon.5, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.6 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.5 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.6 = type { %struct.anon.7 }
%struct.anon.7 = type { i64, ptr }

@globals = external global %struct.libmdbx_globals, align 8
@.str.49 = external hidden unnamed_addr constant [12 x i8], align 1
@__func__.txn_alloc = external hidden unnamed_addr constant [10 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: nounwind uwtable
define dso_local ptr @txn_alloc(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  store ptr null, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.MDBX_env, ptr %11, i32 0, i32 19
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = zext i32 %13 to i64
  %15 = call i64 @ceil_powerof2(i64 noundef %14, i64 noundef 32) #8
  %16 = udiv i64 %15, 8
  store i64 %16, ptr %7, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = and i32 %17, 131072
  %19 = icmp ne i32 %18, 0
  %20 = zext i1 %19 to i64
  %21 = select i1 %19, i64 176, i64 544
  store i64 %21, ptr %8, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %22 = load i64, ptr %8, align 8, !tbaa !23
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = and i32 %23, 131072
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %34

26:                                               ; preds = %2
  %27 = load i64, ptr %7, align 8, !tbaa !23
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.MDBX_env, ptr %28, i32 0, i32 19
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = zext i32 %30 to i64
  %32 = mul i64 %31, 4
  %33 = add i64 %27, %32
  br label %35

34:                                               ; preds = %2
  br label %35

35:                                               ; preds = %34, %26
  %36 = phi i64 [ %33, %26 ], [ 0, %34 ]
  %37 = add i64 %22, %36
  %38 = load ptr, ptr %5, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.MDBX_env, ptr %38, i32 0, i32 19
  %40 = load i32, ptr %39, align 8, !tbaa !11
  %41 = zext i32 %40 to i64
  %42 = mul i64 %41, 57
  %43 = add i64 %37, %42
  store i64 %43, ptr %9, align 8, !tbaa !23
  %44 = load i64, ptr %9, align 8, !tbaa !23
  %45 = call noalias ptr @malloc(i64 noundef %44) #9
  store ptr %45, ptr %6, align 8, !tbaa !9
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  %47 = icmp ne ptr %46, null
  %48 = xor i1 %47, true
  %49 = xor i1 %48, true
  %50 = xor i1 %49, true
  %51 = zext i1 %50 to i32
  %52 = sext i32 %51 to i64
  %53 = call i64 @llvm.expect.i64(i64 %52, i64 0)
  %54 = icmp ne i64 %53, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %35
  %56 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %56, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %162

57:                                               ; preds = %35
  br label %58

58:                                               ; preds = %57
  %59 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !24
  %60 = zext i8 %59 to i32
  %61 = and i32 %60, 1
  %62 = icmp ne i32 %61, 0
  %63 = xor i1 %62, true
  %64 = xor i1 %63, true
  %65 = zext i1 %64 to i32
  %66 = sext i32 %65 to i64
  %67 = call i64 @llvm.expect.i64(i64 %66, i64 1)
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %69, label %85

69:                                               ; preds = %58
  br label %70

70:                                               ; preds = %69
  %71 = load i64, ptr %9, align 8, !tbaa !23
  %72 = load i64, ptr %8, align 8, !tbaa !23
  %73 = icmp ugt i64 %71, %72
  %74 = xor i1 %73, true
  %75 = xor i1 %74, true
  %76 = xor i1 %75, true
  %77 = zext i1 %76 to i32
  %78 = sext i32 %77 to i64
  %79 = call i64 @llvm.expect.i64(i64 %78, i64 0)
  %80 = icmp ne i64 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %70
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.49, ptr noundef @__func__.txn_alloc, i32 noundef 433) #10
  unreachable

82:                                               ; preds = %70
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83
  br label %85

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

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr %6, align 8, !tbaa !9
  %89 = load i64, ptr %8, align 8, !tbaa !23
  call void @llvm.memset.p0.i64(ptr align 8 %88, i8 0, i64 %89, i1 false)
  %90 = load ptr, ptr %6, align 8, !tbaa !9
  %91 = ptrtoint ptr %90 to i64
  %92 = load i64, ptr %8, align 8, !tbaa !23
  %93 = add nsw i64 %91, %92
  %94 = inttoptr i64 %93 to ptr
  %95 = load ptr, ptr %6, align 8, !tbaa !9
  %96 = getelementptr inbounds %struct.MDBX_txn, ptr %95, i32 0, i32 10
  store ptr %94, ptr %96, align 8, !tbaa !26
  %97 = load ptr, ptr %6, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.MDBX_txn, ptr %97, i32 0, i32 10
  %99 = load ptr, ptr %98, align 8, !tbaa !26
  %100 = ptrtoint ptr %99 to i64
  %101 = load ptr, ptr %5, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.MDBX_env, ptr %101, i32 0, i32 19
  %103 = load i32, ptr %102, align 8, !tbaa !11
  %104 = zext i32 %103 to i64
  %105 = mul i64 %104, 48
  %106 = add nsw i64 %100, %105
  %107 = inttoptr i64 %106 to ptr
  %108 = load ptr, ptr %6, align 8, !tbaa !9
  %109 = getelementptr inbounds %struct.MDBX_txn, ptr %108, i32 0, i32 14
  store ptr %107, ptr %109, align 8, !tbaa !30
  %110 = load ptr, ptr %6, align 8, !tbaa !9
  %111 = getelementptr inbounds %struct.MDBX_txn, ptr %110, i32 0, i32 14
  %112 = load ptr, ptr %111, align 8, !tbaa !30
  %113 = getelementptr inbounds ptr, ptr %112, i64 0
  store ptr null, ptr %113, align 8, !tbaa !9
  %114 = load ptr, ptr %6, align 8, !tbaa !9
  %115 = ptrtoint ptr %114 to i64
  %116 = load i64, ptr %9, align 8, !tbaa !23
  %117 = load ptr, ptr %5, align 8, !tbaa !9
  %118 = getelementptr inbounds %struct.MDBX_env, ptr %117, i32 0, i32 19
  %119 = load i32, ptr %118, align 8, !tbaa !11
  %120 = zext i32 %119 to i64
  %121 = mul i64 %120, 1
  %122 = sub i64 %116, %121
  %123 = add nsw i64 %115, %122
  %124 = inttoptr i64 %123 to ptr
  %125 = load ptr, ptr %6, align 8, !tbaa !9
  %126 = getelementptr inbounds %struct.MDBX_txn, ptr %125, i32 0, i32 12
  store ptr %124, ptr %126, align 8, !tbaa !31
  %127 = load i32, ptr %4, align 4, !tbaa !5
  %128 = load ptr, ptr %6, align 8, !tbaa !9
  %129 = getelementptr inbounds %struct.MDBX_txn, ptr %128, i32 0, i32 1
  store i32 %127, ptr %129, align 4, !tbaa !32
  %130 = load ptr, ptr %5, align 8, !tbaa !9
  %131 = load ptr, ptr %6, align 8, !tbaa !9
  %132 = getelementptr inbounds %struct.MDBX_txn, ptr %131, i32 0, i32 9
  store ptr %130, ptr %132, align 8, !tbaa !33
  %133 = load i32, ptr %4, align 4, !tbaa !5
  %134 = and i32 %133, 131072
  %135 = icmp ne i32 %134, 0
  br i1 %135, label %136, label %160

136:                                              ; preds = %87
  %137 = load ptr, ptr %6, align 8, !tbaa !9
  %138 = getelementptr inbounds %struct.MDBX_txn, ptr %137, i32 0, i32 14
  %139 = load ptr, ptr %138, align 8, !tbaa !30
  %140 = ptrtoint ptr %139 to i64
  %141 = load ptr, ptr %5, align 8, !tbaa !9
  %142 = getelementptr inbounds %struct.MDBX_env, ptr %141, i32 0, i32 19
  %143 = load i32, ptr %142, align 8, !tbaa !11
  %144 = zext i32 %143 to i64
  %145 = mul i64 %144, 8
  %146 = add nsw i64 %140, %145
  %147 = inttoptr i64 %146 to ptr
  %148 = load ptr, ptr %6, align 8, !tbaa !9
  %149 = getelementptr inbounds %struct.MDBX_txn, ptr %148, i32 0, i32 13
  store ptr %147, ptr %149, align 8, !tbaa !34
  %150 = load ptr, ptr %6, align 8, !tbaa !9
  %151 = getelementptr inbounds %struct.MDBX_txn, ptr %150, i32 0, i32 12
  %152 = load ptr, ptr %151, align 8, !tbaa !31
  %153 = ptrtoint ptr %152 to i64
  %154 = load i64, ptr %7, align 8, !tbaa !23
  %155 = sub nsw i64 0, %154
  %156 = add nsw i64 %153, %155
  %157 = inttoptr i64 %156 to ptr
  %158 = load ptr, ptr %6, align 8, !tbaa !9
  %159 = getelementptr inbounds %struct.MDBX_txn, ptr %158, i32 0, i32 11
  store ptr %157, ptr %159, align 8, !tbaa !35
  br label %160

160:                                              ; preds = %136, %87
  %161 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %161, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %162

162:                                              ; preds = %160, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  %163 = load ptr, ptr %3, align 8
  ret ptr %163
}

; Function Attrs: inlinehint nounwind willreturn memory(none) uwtable
declare hidden i64 @ceil_powerof2(i64 noundef, i64 noundef) #4

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

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 = { 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 willreturn memory(none) 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 allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { noreturn }

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

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


; 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.49 = external hidden unnamed_addr constant [12 x i8], align 1
@__func__.txn_alloc = external hidden unnamed_addr constant [10 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: nounwind uwtable
define dso_local noundef ptr @txn_alloc(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 136
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = zext i32 %4 to i64
  %6 = tail call i64 @ceil_powerof2(i64 noundef %5, i64 noundef 32) #5
  %7 = lshr i64 %6, 3
  %8 = and i32 %0, 131072
  %.not = icmp eq i32 %8, 0
  %9 = select i1 %.not, i64 544, i64 176
  %10 = shl nuw nsw i64 %5, 2
  %11 = add nuw nsw i64 %7, %10
  %12 = select i1 %.not, i64 0, i64 %11
  %13 = mul nuw nsw i64 %5, 57
  %14 = add nuw nsw i64 %13, %9
  %15 = add nuw nsw i64 %14, %12
  %16 = tail call noalias ptr @malloc(i64 noundef %15) #6
  %.not37 = icmp eq ptr %16, null
  br i1 %.not37, label %46, label %17, !prof !21

17:                                               ; preds = %2
  %18 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !22
  %19 = and i8 %18, 1
  %.not38 = icmp eq i8 %19, 0
  %.not39 = icmp ugt i64 %15, %9
  %or.cond = or i1 %.not39, %.not38
  br i1 %or.cond, label %21, label %20, !prof !24

20:                                               ; preds = %17
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.49, ptr noundef nonnull @__func__.txn_alloc, i32 noundef 433) #7
  unreachable

21:                                               ; preds = %17
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(176) %16, i8 0, i64 %9, i1 false)
  %22 = ptrtoint ptr %16 to i64
  %23 = add nsw i64 %9, %22
  %24 = inttoptr i64 %23 to ptr
  %25 = getelementptr inbounds i8, ptr %16, i64 88
  store ptr %24, ptr %25, align 8, !tbaa !25
  %26 = mul nuw nsw i64 %5, 48
  %27 = add nsw i64 %23, %26
  %28 = inttoptr i64 %27 to ptr
  %29 = getelementptr inbounds i8, ptr %16, i64 120
  store ptr %28, ptr %29, align 8, !tbaa !29
  store ptr null, ptr %28, align 8, !tbaa !30
  %30 = sub nsw i64 %15, %5
  %31 = add nsw i64 %30, %22
  %32 = inttoptr i64 %31 to ptr
  %33 = getelementptr inbounds i8, ptr %16, i64 104
  store ptr %32, ptr %33, align 8, !tbaa !31
  %34 = getelementptr inbounds i8, ptr %16, i64 4
  store i32 %0, ptr %34, align 4, !tbaa !32
  %35 = getelementptr inbounds i8, ptr %16, i64 80
  store ptr %1, ptr %35, align 8, !tbaa !33
  br i1 %.not, label %46, label %36

36:                                               ; preds = %21
  %37 = load ptr, ptr %29, align 8, !tbaa !29
  %38 = ptrtoint ptr %37 to i64
  %39 = shl nuw nsw i64 %5, 3
  %40 = add nsw i64 %39, %38
  %41 = inttoptr i64 %40 to ptr
  %42 = getelementptr inbounds i8, ptr %16, i64 112
  store ptr %41, ptr %42, align 8, !tbaa !34
  %43 = sub i64 %31, %7
  %44 = inttoptr i64 %43 to ptr
  %45 = getelementptr inbounds i8, ptr %16, i64 96
  store ptr %44, ptr %45, align 8, !tbaa !35
  br label %46

46:                                               ; preds = %21, %36, %2
  ret ptr %16
}

; Function Attrs: inlinehint mustprogress nofree nosync nounwind willreturn memory(none) uwtable
declare hidden i64 @ceil_powerof2(i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 = { 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 = { inlinehint mustprogress nofree nosync nounwind willreturn memory(none) 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind willreturn memory(none) }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { 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, !9, i64 136}
!6 = !{!"MDBX_env", !7, i64 0, !9, i64 4, !9, i64 8, !10, i64 16, !9, i64 56, !9, i64 60, !10, i64 64, !12, i64 104, !13, i64 112, !13, i64 114, !13, i64 116, !13, i64 118, !13, i64 120, !13, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !13, i64 130, !9, i64 132, !9, i64 136, !9, i64 140, !9, i64 144, !14, i64 152, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !9, i64 224, !9, i64 228, !9, i64 232, !12, i64 240, !12, i64 248, !11, i64 256, !15, i64 264, !18, i64 320, !16, i64 360, !12, i64 368, !12, i64 376, !12, i64 384, !19, i64 392, !7, i64 400, !9, i64 440, !9, i64 444, !12, i64 448, !20, i64 456, !7, i64 496, !7, i64 536}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"osal_mmap", !7, i64 0, !9, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!15 = !{!"", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !11, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !9, i64 28, !9, i64 32, !16, i64 36, !16, i64 37, !16, i64 38, !17, i64 40, !7, i64 48}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!"", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6}
!18 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!19 = !{!"", !11, i64 0}
!20 = !{!"osal_ioring", !9, i64 0, !9, i64 4, !9, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!21 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!22 = !{!23, !7, i64 25}
!23 = !{!"libmdbx_globals", !7, i64 0, !9, i64 16, !9, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !16, i64 27, !9, i64 28, !7, i64 32, !7, i64 40, !11, i64 80, !12, i64 88}
!24 = !{!"branch_weights", i32 4002001, i32 2000}
!25 = !{!26, !12, i64 88}
!26 = !{!"MDBX_txn", !9, i64 0, !9, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !27, 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, !28, i64 128, !12, i64 160, !7, i64 168}
!27 = !{!"geo", !13, i64 0, !13, i64 2, !9, i64 4, !9, i64 8, !7, i64 12, !7, i64 16}
!28 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!29 = !{!26, !12, i64 120}
!30 = !{!12, !12, i64 0}
!31 = !{!26, !12, i64 104}
!32 = !{!26, !9, i64 4}
!33 = !{!26, !12, i64 80}
!34 = !{!26, !12, i64 112}
!35 = !{!26, !12, i64 96}


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