; LLVM IR from erthink/libmdbx :: src (api-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.12 }
%struct.anon.12 = 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.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }

@globals = external global %struct.libmdbx_globals, align 8
@__func__.mdbx_txn_renew = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 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: alwaysinline nounwind uwtable
declare hidden i32 @check_txn(ptr noundef, i32 noundef) #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @check_env(ptr noundef, i1 noundef zeroext) #3

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mdbx_txn_reset(ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @osal_thread_self() #3

declare i32 @txn_renew(ptr noundef, i32 noundef) #6

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_txn_renew(ptr noundef %0) #5 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = call i32 @check_txn(ptr noundef %6, i32 noundef 0)
  store i32 %7, ptr %4, align 4, !tbaa !9
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp ne i32 %8, 0
  %10 = xor i1 %9, true
  %11 = xor i1 %10, true
  %12 = zext i1 %11 to i32
  %13 = sext i32 %12 to i64
  %14 = call i64 @llvm.expect.i64(i64 %13, i64 0)
  %15 = icmp ne i64 %14, 0
  br i1 %15, label %16, label %19

16:                                               ; preds = %1
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = call i32 @log_if_error(i32 noundef %17, ptr noundef @__func__.mdbx_txn_renew, i32 noundef 164)
  store i32 %18, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %177

19:                                               ; preds = %1
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.MDBX_txn, ptr %20, i32 0, i32 9
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = call i32 @check_env(ptr noundef %22, i1 noundef zeroext true)
  store i32 %23, ptr %4, align 4, !tbaa !9
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  %26 = xor i1 %25, true
  %27 = xor i1 %26, true
  %28 = zext i1 %27 to i32
  %29 = sext i32 %28 to i64
  %30 = call i64 @llvm.expect.i64(i64 %29, i64 0)
  %31 = icmp ne i64 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %19
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = call i32 @log_if_error(i32 noundef %33, ptr noundef @__func__.mdbx_txn_renew, i32 noundef 168)
  store i32 %34, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %177

35:                                               ; preds = %19
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.MDBX_txn, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !17
  %39 = and i32 %38, 131072
  %40 = icmp eq 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 0)
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %35
  %48 = call i32 @log_if_error(i32 noundef 22, ptr noundef @__func__.mdbx_txn_renew, i32 noundef 171)
  store i32 %48, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %177

49:                                               ; preds = %35
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MDBX_txn, ptr %50, i32 0, i32 3
  %52 = load i64, ptr %51, align 8, !tbaa !18
  %53 = icmp ne i64 %52, 0
  br i1 %53, label %61, label %54

54:                                               ; preds = %49
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MDBX_txn, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !17
  %58 = and i32 %57, 1
  %59 = icmp ne i32 %58, 0
  %60 = xor i1 %59, true
  br label %61

61:                                               ; preds = %54, %49
  %62 = phi i1 [ true, %49 ], [ %60, %54 ]
  %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 0)
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %69, label %83

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

80:                                               ; preds = %69
  %81 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %81, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %177

82:                                               ; preds = %69
  br label %83

83:                                               ; preds = %82, %61
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = call i32 @txn_renew(ptr noundef %84, i32 noundef 131072)
  store i32 %85, ptr %4, align 4, !tbaa !9
  %86 = load i32, ptr %4, align 4, !tbaa !9
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %88, label %174

88:                                               ; preds = %83
  br label %89

89:                                               ; preds = %88
  %90 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !19
  %91 = zext i8 %90 to i32
  %92 = and i32 %91, 1
  %93 = icmp ne i32 %92, 0
  %94 = xor i1 %93, true
  %95 = xor i1 %94, true
  %96 = zext i1 %95 to i32
  %97 = sext i32 %96 to i64
  %98 = call i64 @llvm.expect.i64(i64 %97, i64 1)
  %99 = icmp ne i64 %98, 0
  br i1 %99, label %100, label %131

100:                                              ; preds = %89
  br label %101

101:                                              ; preds = %100
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.MDBX_txn, ptr %102, i32 0, i32 3
  %104 = load i64, ptr %103, align 8, !tbaa !18
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.MDBX_txn, ptr %105, i32 0, i32 1
  %107 = load i32, ptr %106, align 4, !tbaa !17
  %108 = and i32 %107, 2097152
  %109 = zext i32 %108 to i64
  %110 = icmp eq i64 %104, %109
  br i1 %110, label %111, label %112

111:                                              ; preds = %101
  br label %114

112:                                              ; preds = %101
  %113 = call i64 @osal_thread_self()
  br label %114

114:                                              ; preds = %112, %111
  %115 = phi i64 [ 0, %111 ], [ %113, %112 ]
  %116 = icmp ne i64 %115, 0
  %117 = xor i1 %116, true
  %118 = xor i1 %117, true
  %119 = xor i1 %118, true
  %120 = zext i1 %119 to i32
  %121 = sext i32 %120 to i64
  %122 = call i64 @llvm.expect.i64(i64 %121, i64 0)
  %123 = icmp ne i64 %122, 0
  br i1 %123, label %124, label %128

124:                                              ; preds = %114
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.MDBX_txn, ptr %125, i32 0, i32 9
  %127 = load ptr, ptr %126, align 8, !tbaa !11
  call void @mdbx_assert_fail(ptr noundef %127, ptr noundef @.str.4, ptr noundef @__func__.mdbx_txn_renew, i32 noundef 181) #8
  unreachable

128:                                              ; preds = %114
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  br label %131

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

132:                                              ; preds = %131
  br label %133

133:                                              ; preds = %132
  br label %134

134:                                              ; preds = %133
  %135 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 5), align 2, !tbaa !22
  %136 = zext i8 %135 to i32
  %137 = icmp sle i32 5, %136
  %138 = xor i1 %137, true
  %139 = xor i1 %138, true
  %140 = zext i1 %139 to i32
  %141 = sext i32 %140 to i64
  %142 = call i64 @llvm.expect.i64(i64 %141, i64 0)
  %143 = icmp ne i64 %142, 0
  br i1 %143, label %144, label %171

144:                                              ; preds = %134
  %145 = load ptr, ptr %3, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.MDBX_txn, ptr %145, i32 0, i32 7
  %147 = load i64, ptr %146, align 8, !tbaa !23
  %148 = load ptr, ptr %3, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.MDBX_txn, ptr %148, i32 0, i32 1
  %150 = load i32, ptr %149, align 4, !tbaa !17
  %151 = and i32 %150, 131072
  %152 = icmp ne i32 %151, 0
  %153 = zext i1 %152 to i64
  %154 = select i1 %152, i32 114, i32 119
  %155 = load ptr, ptr %3, align 8, !tbaa !5
  %156 = load ptr, ptr %3, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.MDBX_txn, ptr %156, i32 0, i32 9
  %158 = load ptr, ptr %157, align 8, !tbaa !11
  %159 = load ptr, ptr %3, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.MDBX_txn, ptr %159, i32 0, i32 10
  %161 = load ptr, ptr %160, align 8, !tbaa !24
  %162 = getelementptr inbounds %struct.tree, ptr %161, i64 1
  %163 = getelementptr inbounds %struct.tree, ptr %162, i32 0, i32 3
  %164 = load i32, ptr %163, align 4, !tbaa !25
  %165 = load ptr, ptr %3, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.MDBX_txn, ptr %165, i32 0, i32 10
  %167 = load ptr, ptr %166, align 8, !tbaa !24
  %168 = getelementptr inbounds %struct.tree, ptr %167, i64 0
  %169 = getelementptr inbounds %struct.tree, ptr %168, i32 0, i32 3
  %170 = load i32, ptr %169, align 4, !tbaa !25
  call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef @__func__.mdbx_txn_renew, i32 noundef 184, ptr noundef @.str.5, i64 noundef %147, i32 noundef %154, ptr noundef %155, ptr noundef %158, i32 noundef %164, i32 noundef %170)
  br label %171

171:                                              ; preds = %144, %134
  br label %172

172:                                              ; preds = %171
  br label %173

173:                                              ; preds = %172
  br label %174

174:                                              ; preds = %173, %83
  %175 = load i32, ptr %4, align 4, !tbaa !9
  %176 = call i32 @log_if_error(i32 noundef %175, ptr noundef @__func__.mdbx_txn_renew, i32 noundef 186)
  store i32 %176, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %177

177:                                              ; preds = %174, %80, %47, %32, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  %178 = load i32, ptr %2, align 4
  ret i32 %178
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 #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 }
attributes #8 = { noreturn }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !13, i64 64, !13, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !16, i64 128, !6, i64 160, !7, i64 168}
!13 = !{!"long", !7, i64 0}
!14 = !{!"geo", !15, i64 0, !15, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!15 = !{!"short", !7, i64 0}
!16 = !{!"MDBX_canary", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!17 = !{!12, !10, i64 4}
!18 = !{!12, !13, i64 16}
!19 = !{!20, !7, i64 25}
!20 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !21, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !13, i64 80, !6, i64 88}
!21 = !{!"_Bool", !7, i64 0}
!22 = !{!20, !7, i64 26}
!23 = !{!12, !13, i64 64}
!24 = !{!12, !6, i64 88}
!25 = !{!26, !10, i64 8}
!26 = !{!"tree", !15, i64 0, !15, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !13, i64 24, !13, i64 32, !13, i64 40}


; 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.12 }
%struct.anon.12 = 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
@__func__.mdbx_txn_renew = external hidden unnamed_addr constant [15 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @check_env(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mdbx_txn_reset(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @osal_thread_self() local_unnamed_addr #1

declare i32 @txn_renew(ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_txn_renew(ptr noundef %0) local_unnamed_addr #3 {
  %2 = tail call i32 @check_txn(ptr noundef %0, i32 noundef 0)
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %5, label %3, !prof !5

3:                                                ; preds = %1
  %4 = tail call i32 @log_if_error(i32 noundef %2, ptr noundef nonnull @__func__.mdbx_txn_renew, i32 noundef 164)
  br label %59

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  %7 = load ptr, ptr %6, align 8, !tbaa !6
  %8 = tail call i32 @check_env(ptr noundef %7, i1 noundef zeroext true)
  %.not27 = icmp eq i32 %8, 0
  br i1 %.not27, label %11, label %9, !prof !5

9:                                                ; preds = %5
  %10 = tail call i32 @log_if_error(i32 noundef %8, ptr noundef nonnull @__func__.mdbx_txn_renew, i32 noundef 168)
  br label %59

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !16
  %14 = and i32 %13, 131072
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18, !prof !17

16:                                               ; preds = %11
  %17 = tail call i32 @log_if_error(i32 noundef 22, ptr noundef nonnull @__func__.mdbx_txn_renew, i32 noundef 171)
  br label %59

18:                                               ; preds = %11
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load i64, ptr %19, align 8, !tbaa !18
  %.not28 = icmp ne i64 %20, 0
  %21 = and i32 %13, 1
  %.not29 = icmp eq i32 %21, 0
  %22 = or i1 %.not29, %.not28
  br i1 %22, label %23, label %25, !prof !17

23:                                               ; preds = %18
  %24 = tail call i32 @mdbx_txn_reset(ptr noundef nonnull %0)
  %.not30 = icmp eq i32 %24, 0
  br i1 %.not30, label %25, label %59, !prof !5

25:                                               ; preds = %23, %18
  %26 = tail call i32 @txn_renew(ptr noundef nonnull %0, i32 noundef 131072) #5
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %57

28:                                               ; preds = %25
  %29 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !19
  %30 = and i8 %29, 1
  %.not31 = icmp eq i8 %30, 0
  br i1 %.not31, label %41, label %31, !prof !17

31:                                               ; preds = %28
  %32 = load i64, ptr %19, align 8, !tbaa !18
  %33 = load i32, ptr %12, align 4, !tbaa !16
  %34 = and i32 %33, 2097152
  %35 = zext nneg i32 %34 to i64
  %36 = icmp eq i64 %32, %35
  br i1 %36, label %.critedge, label %37

37:                                               ; preds = %31
  %38 = tail call i64 @osal_thread_self()
  %39 = icmp eq i64 %38, 0
  br i1 %39, label %.critedge, label %41, !prof !17

.critedge:                                        ; preds = %31, %37
  %40 = load ptr, ptr %6, align 8, !tbaa !6
  tail call void @mdbx_assert_fail(ptr noundef %40, ptr noundef nonnull @.str.4, ptr noundef nonnull @__func__.mdbx_txn_renew, i32 noundef 181) #6
  unreachable

41:                                               ; preds = %28, %37
  %42 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 26), align 2, !tbaa !22
  %43 = icmp ugt i8 %42, 4
  br i1 %43, label %44, label %57, !prof !17

44:                                               ; preds = %41
  %45 = getelementptr inbounds i8, ptr %0, i64 64
  %46 = load i64, ptr %45, align 8, !tbaa !23
  %47 = load i32, ptr %12, align 4, !tbaa !16
  %48 = and i32 %47, 131072
  %.not33 = icmp eq i32 %48, 0
  %49 = select i1 %.not33, i32 119, i32 114
  %50 = load ptr, ptr %6, align 8, !tbaa !6
  %51 = getelementptr inbounds i8, ptr %0, i64 88
  %52 = load ptr, ptr %51, align 8, !tbaa !24
  %53 = getelementptr inbounds i8, ptr %52, i64 56
  %54 = load i32, ptr %53, align 4, !tbaa !25
  %55 = getelementptr inbounds i8, ptr %52, i64 8
  %56 = load i32, ptr %55, align 4, !tbaa !25
  tail call void (i32, ptr, i32, ptr, ...) @debug_log(i32 noundef 5, ptr noundef nonnull @__func__.mdbx_txn_renew, i32 noundef 184, ptr noundef nonnull @.str.5, i64 noundef %46, i32 noundef %49, ptr noundef nonnull %0, ptr noundef %50, i32 noundef %54, i32 noundef %56) #5
  br label %57

57:                                               ; preds = %41, %44, %25
  %58 = tail call i32 @log_if_error(i32 noundef %26, ptr noundef nonnull @__func__.mdbx_txn_renew, i32 noundef 186)
  br label %59

59:                                               ; preds = %23, %57, %16, %9, %3
  %.0 = phi i32 [ %4, %3 ], [ %10, %9 ], [ %17, %16 ], [ %58, %57 ], [ %24, %23 ]
  ret i32 %.0
}

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

attributes #0 = { 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 #1 = { 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 #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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { 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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!7, !12, i64 80}
!7 = !{!"MDBX_txn", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !13, 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, !15, i64 128, !12, i64 160, !9, i64 168}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"geo", !14, i64 0, !14, i64 2, !8, i64 4, !8, i64 8, !9, i64 12, !9, i64 16}
!14 = !{!"short", !9, i64 0}
!15 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!16 = !{!7, !8, i64 4}
!17 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!18 = !{!7, !11, i64 16}
!19 = !{!20, !9, i64 25}
!20 = !{!"libmdbx_globals", !9, i64 0, !8, i64 16, !8, i64 20, !9, i64 24, !9, i64 25, !9, i64 26, !21, i64 27, !8, i64 28, !9, i64 32, !9, i64 40, !11, i64 80, !12, i64 88}
!21 = !{!"_Bool", !9, i64 0}
!22 = !{!20, !9, i64 26}
!23 = !{!7, !11, i64 64}
!24 = !{!7, !12, i64 88}
!25 = !{!26, !8, i64 8}
!26 = !{!"tree", !14, i64 0, !14, i64 2, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !11, i64 24, !11, i64 32, !11, i64 40}


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