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

; 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_rkl_iter = type { ptr, i32, i32 }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }

@globals = external global %struct.libmdbx_globals, align 8
@.str.10 = external hidden unnamed_addr constant [41 x i8], align 1
@__func__.rkl_turn = external hidden unnamed_addr constant [9 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [16 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(argmem: readwrite)
declare void @llvm.lifetime.end.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: nounwind willreturn memory(read) uwtable
declare dso_local i64 @rkl_len(ptr noundef) #3

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

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

21:                                               ; preds = %10
  br label %22

22:                                               ; preds = %21
  %23 = load i8, ptr %5, align 1, !tbaa !9, !range !15, !noundef !16
  %24 = trunc i8 %23 to i1
  %25 = zext i1 %24 to i32
  %26 = load i8, ptr %5, align 1, !tbaa !9, !range !15, !noundef !16
  %27 = trunc i8 %26 to i1
  %28 = xor i1 %27, true
  %29 = xor i1 %28, true
  %30 = zext i1 %29 to i32
  %31 = icmp eq i32 %25, %30
  %32 = xor i1 %31, true
  %33 = xor i1 %32, true
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = call i64 @llvm.expect.i64(i64 %36, i64 0)
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %22
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.10, ptr noundef @__func__.rkl_turn, i32 noundef 427) #5
  unreachable

40:                                               ; preds = %22
  br label %41

41:                                               ; preds = %40
  br label %42

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

43:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 8, !tbaa !17
  %47 = load i8, ptr %5, align 1, !tbaa !9, !range !15, !noundef !16
  %48 = trunc i8 %47 to i1
  %49 = zext i1 %48 to i32
  %50 = sub i32 %46, %49
  %51 = zext i32 %50 to i64
  store i64 %51, ptr %6, align 8, !tbaa !19
  %52 = load i64, ptr %6, align 8, !tbaa !19
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = call i64 @rkl_len(ptr noundef %55) #7
  %57 = icmp uge i64 %52, %56
  %58 = xor i1 %57, true
  %59 = xor i1 %58, true
  %60 = zext i1 %59 to i32
  %61 = sext i32 %60 to i64
  %62 = call i64 @llvm.expect.i64(i64 %61, i64 0)
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %43
  store i64 0, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %217

65:                                               ; preds = %43
  %66 = load i64, ptr %6, align 8, !tbaa !19
  %67 = load i8, ptr %5, align 1, !tbaa !9, !range !15, !noundef !16
  %68 = trunc i8 %67 to i1
  %69 = xor i1 %68, true
  %70 = zext i1 %69 to i32
  %71 = sext i32 %70 to i64
  %72 = add i64 %66, %71
  %73 = trunc i64 %72 to i32
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %74, i32 0, i32 1
  store i32 %73, ptr %75, align 8, !tbaa !17
  br label %76

76:                                               ; preds = %65
  %77 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %78 = zext i8 %77 to i32
  %79 = and i32 %78, 1
  %80 = icmp ne i32 %79, 0
  %81 = xor i1 %80, true
  %82 = xor i1 %81, true
  %83 = zext i1 %82 to i32
  %84 = sext i32 %83 to i64
  %85 = call i64 @llvm.expect.i64(i64 %84, i64 1)
  %86 = icmp ne i64 %85, 0
  br i1 %86, label %87, label %109

87:                                               ; preds = %76
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %89, i32 0, i32 1
  %91 = load i32, ptr %90, align 8, !tbaa !17
  %92 = zext i32 %91 to i64
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !20
  %96 = call i64 @rkl_len(ptr noundef %95) #7
  %97 = icmp ule i64 %92, %96
  %98 = xor i1 %97, true
  %99 = xor i1 %98, true
  %100 = xor i1 %99, true
  %101 = zext i1 %100 to i32
  %102 = sext i32 %101 to i64
  %103 = call i64 @llvm.expect.i64(i64 %102, i64 0)
  %104 = icmp ne i64 %103, 0
  br i1 %104, label %105, label %106

105:                                              ; preds = %88
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.11, ptr noundef @__func__.rkl_turn, i32 noundef 433) #5
  unreachable

106:                                              ; preds = %88
  br label %107

107:                                              ; preds = %106
  br label %108

108:                                              ; preds = %107
  br label %109

109:                                              ; preds = %108, %76
  br label %110

110:                                              ; preds = %109
  br label %111

111:                                              ; preds = %110
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %112, i32 0, i32 0
  %114 = load ptr, ptr %113, align 8, !tbaa !20
  %115 = getelementptr inbounds %struct.MDBX_rkl, ptr %114, i32 0, i32 1
  %116 = load i64, ptr %115, align 8, !tbaa !21
  %117 = load ptr, ptr %4, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %117, i32 0, i32 0
  %119 = load ptr, ptr %118, align 8, !tbaa !20
  %120 = getelementptr inbounds %struct.MDBX_rkl, ptr %119, i32 0, i32 0
  %121 = load i64, ptr %120, align 8, !tbaa !23
  %122 = sub i64 %116, %121
  store i64 %122, ptr %8, align 8, !tbaa !19
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !20
  %126 = getelementptr inbounds %struct.MDBX_rkl, ptr %125, i32 0, i32 2
  %127 = load i32, ptr %126, align 8, !tbaa !24
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %178

129:                                              ; preds = %111
  %130 = load i64, ptr %6, align 8, !tbaa !19
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %131, i32 0, i32 2
  %133 = load i32, ptr %132, align 4, !tbaa !25
  %134 = zext i32 %133 to i64
  %135 = icmp ult i64 %130, %134
  br i1 %135, label %136, label %145

136:                                              ; preds = %129
  %137 = load ptr, ptr %4, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %137, i32 0, i32 0
  %139 = load ptr, ptr %138, align 8, !tbaa !20
  %140 = getelementptr inbounds %struct.MDBX_rkl, ptr %139, i32 0, i32 4
  %141 = load ptr, ptr %140, align 8, !tbaa !26
  %142 = load i64, ptr %6, align 8, !tbaa !19
  %143 = getelementptr inbounds i64, ptr %141, i64 %142
  %144 = load i64, ptr %143, align 8, !tbaa !19
  store i64 %144, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %216

145:                                              ; preds = %129
  %146 = load i64, ptr %6, align 8, !tbaa !19
  %147 = load ptr, ptr %4, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %147, i32 0, i32 2
  %149 = load i32, ptr %148, align 4, !tbaa !25
  %150 = zext i32 %149 to i64
  %151 = load i64, ptr %8, align 8, !tbaa !19
  %152 = add i64 %150, %151
  %153 = icmp ult i64 %146, %152
  br i1 %153, label %154, label %167

154:                                              ; preds = %145
  %155 = load ptr, ptr %4, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %155, i32 0, i32 0
  %157 = load ptr, ptr %156, align 8, !tbaa !20
  %158 = getelementptr inbounds %struct.MDBX_rkl, ptr %157, i32 0, i32 0
  %159 = load i64, ptr %158, align 8, !tbaa !23
  %160 = load i64, ptr %6, align 8, !tbaa !19
  %161 = add i64 %159, %160
  %162 = load ptr, ptr %4, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %162, i32 0, i32 2
  %164 = load i32, ptr %163, align 4, !tbaa !25
  %165 = zext i32 %164 to i64
  %166 = sub i64 %161, %165
  store i64 %166, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %216

167:                                              ; preds = %145
  %168 = load ptr, ptr %4, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %168, i32 0, i32 0
  %170 = load ptr, ptr %169, align 8, !tbaa !20
  %171 = getelementptr inbounds %struct.MDBX_rkl, ptr %170, i32 0, i32 4
  %172 = load ptr, ptr %171, align 8, !tbaa !26
  %173 = load i64, ptr %6, align 8, !tbaa !19
  %174 = load i64, ptr %8, align 8, !tbaa !19
  %175 = sub i64 %173, %174
  %176 = getelementptr inbounds i64, ptr %172, i64 %175
  %177 = load i64, ptr %176, align 8, !tbaa !19
  store i64 %177, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %216

178:                                              ; preds = %111
  br label %179

179:                                              ; preds = %178
  %180 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %181 = zext i8 %180 to i32
  %182 = and i32 %181, 1
  %183 = icmp ne i32 %182, 0
  %184 = xor i1 %183, true
  %185 = xor i1 %184, true
  %186 = zext i1 %185 to i32
  %187 = sext i32 %186 to i64
  %188 = call i64 @llvm.expect.i64(i64 %187, i64 1)
  %189 = icmp ne i64 %188, 0
  br i1 %189, label %190, label %206

190:                                              ; preds = %179
  br label %191

191:                                              ; preds = %190
  %192 = load i64, ptr %6, align 8, !tbaa !19
  %193 = load i64, ptr %8, align 8, !tbaa !19
  %194 = icmp ult i64 %192, %193
  %195 = xor i1 %194, true
  %196 = xor i1 %195, true
  %197 = xor i1 %196, true
  %198 = zext i1 %197 to i32
  %199 = sext i32 %198 to i64
  %200 = call i64 @llvm.expect.i64(i64 %199, i64 0)
  %201 = icmp ne i64 %200, 0
  br i1 %201, label %202, label %203

202:                                              ; preds = %191
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.12, ptr noundef @__func__.rkl_turn, i32 noundef 445) #5
  unreachable

203:                                              ; preds = %191
  br label %204

204:                                              ; preds = %203
  br label %205

205:                                              ; preds = %204
  br label %206

206:                                              ; preds = %205, %179
  br label %207

207:                                              ; preds = %206
  br label %208

208:                                              ; preds = %207
  %209 = load ptr, ptr %4, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.MDBX_rkl_iter, ptr %209, i32 0, i32 0
  %211 = load ptr, ptr %210, align 8, !tbaa !20
  %212 = getelementptr inbounds %struct.MDBX_rkl, ptr %211, i32 0, i32 0
  %213 = load i64, ptr %212, align 8, !tbaa !23
  %214 = load i64, ptr %6, align 8, !tbaa !19
  %215 = add i64 %213, %214
  store i64 %215, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %216

216:                                              ; preds = %208, %167, %154, %136
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %217

217:                                              ; preds = %216, %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %218 = load i64, ptr %3, align 8
  ret i64 %218
}

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 = { 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 #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { noreturn }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !7, i64 25}
!12 = !{!"libmdbx_globals", !7, i64 0, !13, i64 16, !13, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !10, i64 27, !13, i64 28, !7, i64 32, !7, i64 40, !14, i64 80, !6, i64 88}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !13, i64 8}
!18 = !{!"MDBX_rkl_iter", !6, i64 0, !13, i64 8, !13, i64 12}
!19 = !{!14, !14, i64 0}
!20 = !{!18, !6, i64 0}
!21 = !{!22, !14, i64 8}
!22 = !{!"MDBX_rkl", !14, i64 0, !14, i64 8, !13, i64 16, !13, i64 20, !6, i64 24, !7, i64 32}
!23 = !{!22, !14, i64 0}
!24 = !{!22, !13, i64 16}
!25 = !{!18, !13, i64 12}
!26 = !{!22, !6, i64 24}


; 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
@__func__.rkl_turn = external hidden unnamed_addr constant [9 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [16 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 nofree nounwind willreturn memory(read) uwtable
declare dso_local i64 @rkl_len(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @rkl_turn(ptr nocapture noundef %0, i1 noundef zeroext %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.neg = sext i1 %1 to i32
  %5 = add i32 %4, %.neg
  %6 = zext i32 %5 to i64
  %7 = load ptr, ptr %0, align 8, !tbaa !11
  %8 = tail call i64 @rkl_len(ptr noundef %7) #3
  %.not33 = icmp ugt i64 %8, %6
  br i1 %.not33, label %9, label %52, !prof !12

9:                                                ; preds = %2
  %10 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !13
  %11 = and i8 %10, 1
  %12 = xor i1 %1, true
  %13 = zext i1 %12 to i32
  %14 = add i32 %5, %13
  store i32 %14, ptr %3, align 8, !tbaa !5
  %.not34 = icmp eq i8 %11, 0
  br i1 %.not34, label %19, label %15, !prof !17

15:                                               ; preds = %9
  %16 = zext i32 %14 to i64
  %17 = tail call i64 @rkl_len(ptr noundef %7) #3
  %.not35 = icmp ult i64 %17, %16
  br i1 %.not35, label %18, label %19, !prof !17

18:                                               ; preds = %15
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.11, ptr noundef nonnull @__func__.rkl_turn, i32 noundef 433) #4
  unreachable

19:                                               ; preds = %15, %9
  %20 = getelementptr inbounds i8, ptr %7, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !18
  %22 = load i64, ptr %7, align 8, !tbaa !20
  %23 = sub i64 %21, %22
  %24 = getelementptr inbounds i8, ptr %7, i64 16
  %25 = load i32, ptr %24, align 8, !tbaa !21
  %.not36 = icmp eq i32 %25, 0
  br i1 %.not36, label %48, label %26

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  %28 = load i32, ptr %27, align 4, !tbaa !22
  %29 = zext i32 %28 to i64
  %30 = icmp ult i32 %5, %28
  br i1 %30, label %31, label %36

31:                                               ; preds = %26
  %32 = getelementptr inbounds i8, ptr %7, i64 24
  %33 = load ptr, ptr %32, align 8, !tbaa !23
  %34 = getelementptr inbounds i64, ptr %33, i64 %6
  %35 = load i64, ptr %34, align 8, !tbaa !24
  br label %52

36:                                               ; preds = %26
  %37 = add i64 %23, %29
  %38 = icmp ugt i64 %37, %6
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = add i64 %22, %6
  %41 = sub i64 %40, %29
  br label %52

42:                                               ; preds = %36
  %43 = getelementptr inbounds i8, ptr %7, i64 24
  %44 = load ptr, ptr %43, align 8, !tbaa !23
  %45 = sub i64 %6, %23
  %46 = getelementptr inbounds i64, ptr %44, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !24
  br label %52

48:                                               ; preds = %19
  %.not38 = icmp ugt i64 %23, %6
  %or.cond = select i1 %.not34, i1 true, i1 %.not38
  br i1 %or.cond, label %50, label %49, !prof !25

49:                                               ; preds = %48
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.12, ptr noundef nonnull @__func__.rkl_turn, i32 noundef 445) #4
  unreachable

50:                                               ; preds = %48
  %51 = add i64 %22, %6
  br label %52

52:                                               ; preds = %31, %39, %42, %50, %2
  %.1 = phi i64 [ 0, %2 ], [ %35, %31 ], [ %41, %39 ], [ %47, %42 ], [ %51, %50 ]
  ret i64 %.1
}

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


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