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

; 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.8 }
%struct.anon.8 = 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_cursor = type { i32, %union.anon, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon = type { i16 }
%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.0, %union.anon.1 }
%union.anon.0 = 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 }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%struct.inner_cursor = type { %struct.MDBX_cursor, %struct.tree }

@globals = external global %struct.libmdbx_globals, align 8
@.str.17 = external hidden unnamed_addr constant [40 x i8], align 1
@__func__.cursor_shadow = external hidden unnamed_addr constant [14 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 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: inlinehint nounwind willreturn memory(read) uwtable
declare hidden i64 @cursor_dbi(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @cursor_shadow(ptr noundef %0, ptr noundef %1, i64 noundef %2) #4 {
  %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 ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  br label %12

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

23:                                               ; preds = %12
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.MDBX_cursor, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !15
  %28 = icmp eq i32 %27, 2114311601
  %29 = xor i1 %28, true
  %30 = xor i1 %29, true
  %31 = xor i1 %30, true
  %32 = zext i1 %31 to i32
  %33 = sext i32 %32 to i64
  %34 = call i64 @llvm.expect.i64(i64 %33, i64 0)
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %36, label %40

36:                                               ; preds = %24
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.MDBX_txn, ptr %37, i32 0, i32 9
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  call void @mdbx_assert_fail(ptr noundef %39, ptr noundef @.str.17, ptr noundef @__func__.cursor_shadow, i32 noundef 188) #8
  unreachable

40:                                               ; preds = %24
  br label %41

41:                                               ; preds = %40
  br label %42

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

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %46 = zext i8 %45 to i32
  %47 = and i32 %46, 1
  %48 = icmp ne i32 %47, 0
  %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 1)
  %54 = icmp ne i64 %53, 0
  br i1 %54, label %55, label %75

55:                                               ; preds = %44
  br label %56

56:                                               ; preds = %55
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.MDBX_cursor, ptr %57, i32 0, i32 5
  %59 = load ptr, ptr %58, align 8, !tbaa !22
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = icmp ne ptr %59, %60
  %62 = xor i1 %61, true
  %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 %73

69:                                               ; preds = %56
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.MDBX_txn, ptr %70, i32 0, i32 9
  %72 = load ptr, ptr %71, align 8, !tbaa !17
  call void @mdbx_assert_fail(ptr noundef %72, ptr noundef @.str.18, ptr noundef @__func__.cursor_shadow, i32 noundef 189) #8
  unreachable

73:                                               ; preds = %56
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74, %44
  br label %76

76:                                               ; preds = %75
  br label %77

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

88:                                               ; preds = %77
  br label %89

89:                                               ; preds = %88
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.MDBX_cursor, ptr %90, i32 0, i32 5
  %92 = load ptr, ptr %91, align 8, !tbaa !22
  %93 = getelementptr inbounds %struct.MDBX_txn, ptr %92, i32 0, i32 1
  %94 = load i32, ptr %93, align 4, !tbaa !23
  %95 = and i32 %94, 256
  %96 = icmp ne i32 %95, 0
  %97 = xor i1 %96, true
  %98 = xor i1 %97, true
  %99 = xor i1 %98, true
  %100 = zext i1 %99 to i32
  %101 = sext i32 %100 to i64
  %102 = call i64 @llvm.expect.i64(i64 %101, i64 0)
  %103 = icmp ne i64 %102, 0
  br i1 %103, label %104, label %110

104:                                              ; preds = %89
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.MDBX_cursor, ptr %105, i32 0, i32 5
  %107 = load ptr, ptr %106, align 8, !tbaa !22
  %108 = getelementptr inbounds %struct.MDBX_txn, ptr %107, i32 0, i32 9
  %109 = load ptr, ptr %108, align 8, !tbaa !17
  call void @mdbx_assert_fail(ptr noundef %109, ptr noundef @.str.19, ptr noundef @__func__.cursor_shadow, i32 noundef 190) #8
  unreachable

110:                                              ; preds = %89
  br label %111

111:                                              ; preds = %110
  br label %112

112:                                              ; preds = %111, %77
  br label %113

113:                                              ; preds = %112
  br label %114

114:                                              ; preds = %113
  %115 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %116 = zext i8 %115 to i32
  %117 = and i32 %116, 1
  %118 = icmp ne i32 %117, 0
  %119 = xor i1 %118, true
  %120 = xor i1 %119, true
  %121 = zext i1 %120 to i32
  %122 = sext i32 %121 to i64
  %123 = call i64 @llvm.expect.i64(i64 %122, i64 1)
  %124 = icmp ne i64 %123, 0
  br i1 %124, label %125, label %146

125:                                              ; preds = %114
  br label %126

126:                                              ; preds = %125
  %127 = load i64, ptr %7, align 8, !tbaa !9
  %128 = load ptr, ptr %5, align 8, !tbaa !5
  %129 = call i64 @cursor_dbi(ptr noundef %128) #9
  %130 = icmp eq i64 %127, %129
  %131 = xor i1 %130, true
  %132 = xor i1 %131, true
  %133 = xor i1 %132, true
  %134 = zext i1 %133 to i32
  %135 = sext i32 %134 to i64
  %136 = call i64 @llvm.expect.i64(i64 %135, i64 0)
  %137 = icmp ne i64 %136, 0
  br i1 %137, label %138, label %144

138:                                              ; preds = %126
  %139 = load ptr, ptr %5, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.MDBX_cursor, ptr %139, i32 0, i32 5
  %141 = load ptr, ptr %140, align 8, !tbaa !22
  %142 = getelementptr inbounds %struct.MDBX_txn, ptr %141, i32 0, i32 9
  %143 = load ptr, ptr %142, align 8, !tbaa !17
  call void @mdbx_assert_fail(ptr noundef %143, ptr noundef @.str.20, ptr noundef @__func__.cursor_shadow, i32 noundef 191) #8
  unreachable

144:                                              ; preds = %126
  br label %145

145:                                              ; preds = %144
  br label %146

146:                                              ; preds = %145, %114
  br label %147

147:                                              ; preds = %146
  br label %148

148:                                              ; preds = %147
  %149 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !11
  %150 = zext i8 %149 to i32
  %151 = and i32 %150, 1
  %152 = icmp ne i32 %151, 0
  %153 = xor i1 %152, true
  %154 = xor i1 %153, true
  %155 = zext i1 %154 to i32
  %156 = sext i32 %155 to i64
  %157 = call i64 @llvm.expect.i64(i64 %156, i64 1)
  %158 = icmp ne i64 %157, 0
  br i1 %158, label %159, label %184

159:                                              ; preds = %148
  br label %160

160:                                              ; preds = %159
  %161 = load i64, ptr %7, align 8, !tbaa !9
  %162 = icmp ugt i64 %161, 0
  br i1 %162, label %163, label %169

163:                                              ; preds = %160
  %164 = load i64, ptr %7, align 8, !tbaa !9
  %165 = load ptr, ptr %6, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.MDBX_txn, ptr %165, i32 0, i32 2
  %167 = load i64, ptr %166, align 8, !tbaa !24
  %168 = icmp ult i64 %164, %167
  br label %169

169:                                              ; preds = %163, %160
  %170 = phi i1 [ false, %160 ], [ %168, %163 ]
  %171 = xor i1 %170, true
  %172 = xor i1 %171, true
  %173 = xor i1 %172, true
  %174 = zext i1 %173 to i32
  %175 = sext i32 %174 to i64
  %176 = call i64 @llvm.expect.i64(i64 %175, i64 0)
  %177 = icmp ne i64 %176, 0
  br i1 %177, label %178, label %182

178:                                              ; preds = %169
  %179 = load ptr, ptr %6, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.MDBX_txn, ptr %179, i32 0, i32 9
  %181 = load ptr, ptr %180, align 8, !tbaa !17
  call void @mdbx_assert_fail(ptr noundef %181, ptr noundef @.str.21, ptr noundef @__func__.cursor_shadow, i32 noundef 192) #8
  unreachable

182:                                              ; preds = %169
  br label %183

183:                                              ; preds = %182
  br label %184

184:                                              ; preds = %183, %148
  br label %185

185:                                              ; preds = %184
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #10
  %186 = load ptr, ptr %5, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.MDBX_cursor, ptr %186, i32 0, i32 8
  %188 = load ptr, ptr %187, align 8, !tbaa !25
  %189 = icmp ne ptr %188, null
  %190 = zext i1 %189 to i64
  %191 = select i1 %189, i64 816, i64 384
  store i64 %191, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #10
  %192 = load i64, ptr %8, align 8, !tbaa !9
  %193 = call noalias ptr @malloc(i64 noundef %192) #11
  store ptr %193, ptr %9, align 8, !tbaa !5
  %194 = load ptr, ptr %9, align 8, !tbaa !5
  %195 = icmp ne ptr %194, null
  %196 = xor i1 %195, true
  %197 = xor i1 %196, true
  %198 = xor i1 %197, true
  %199 = zext i1 %198 to i32
  %200 = sext i32 %199 to i64
  %201 = call i64 @llvm.expect.i64(i64 %200, i64 0)
  %202 = icmp ne i64 %201, 0
  br i1 %202, label %203, label %204

203:                                              ; preds = %185
  store i32 12, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %251

204:                                              ; preds = %185
  %205 = load ptr, ptr %9, align 8, !tbaa !5
  %206 = load i64, ptr %8, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 8 %205, i8 -51, i64 %206, i1 false)
  %207 = load ptr, ptr %9, align 8, !tbaa !5
  %208 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %207, ptr align 8 %208, i64 384, i1 false), !tbaa.struct !26
  %209 = load ptr, ptr %9, align 8, !tbaa !5
  %210 = load ptr, ptr %5, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.MDBX_cursor, ptr %210, i32 0, i32 12
  store ptr %209, ptr %211, align 8, !tbaa !29
  %212 = load ptr, ptr %6, align 8, !tbaa !5
  %213 = load ptr, ptr %5, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.MDBX_cursor, ptr %213, i32 0, i32 5
  store ptr %212, ptr %214, align 8, !tbaa !22
  %215 = load ptr, ptr %6, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.MDBX_txn, ptr %215, i32 0, i32 10
  %217 = load ptr, ptr %216, align 8, !tbaa !30
  %218 = load i64, ptr %7, align 8, !tbaa !9
  %219 = getelementptr inbounds %struct.tree, ptr %217, i64 %218
  %220 = load ptr, ptr %5, align 8, !tbaa !5
  %221 = getelementptr inbounds %struct.MDBX_cursor, ptr %220, i32 0, i32 6
  store ptr %219, ptr %221, align 8, !tbaa !31
  %222 = load ptr, ptr %6, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.MDBX_txn, ptr %222, i32 0, i32 12
  %224 = load ptr, ptr %223, align 8, !tbaa !32
  %225 = load i64, ptr %7, align 8, !tbaa !9
  %226 = getelementptr inbounds i8, ptr %224, i64 %225
  %227 = load ptr, ptr %5, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.MDBX_cursor, ptr %227, i32 0, i32 4
  store ptr %226, ptr %228, align 8, !tbaa !33
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #10
  %229 = load ptr, ptr %5, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.MDBX_cursor, ptr %229, i32 0, i32 8
  %231 = load ptr, ptr %230, align 8, !tbaa !25
  store ptr %231, ptr %11, align 8, !tbaa !5
  %232 = load ptr, ptr %11, align 8, !tbaa !5
  %233 = icmp ne ptr %232, null
  br i1 %233, label %234, label %250

234:                                              ; preds = %204
  %235 = load ptr, ptr %9, align 8, !tbaa !5
  %236 = getelementptr inbounds %struct.MDBX_cursor, ptr %235, i64 1
  %237 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %236, ptr align 8 %237, i64 432, i1 false), !tbaa.struct !34
  %238 = load ptr, ptr %6, align 8, !tbaa !5
  %239 = load ptr, ptr %11, align 8, !tbaa !5
  %240 = getelementptr inbounds %struct.inner_cursor, ptr %239, i32 0, i32 0
  %241 = getelementptr inbounds %struct.MDBX_cursor, ptr %240, i32 0, i32 5
  store ptr %238, ptr %241, align 8, !tbaa !36
  %242 = load ptr, ptr %6, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.MDBX_txn, ptr %242, i32 0, i32 12
  %244 = load ptr, ptr %243, align 8, !tbaa !32
  %245 = load i64, ptr %7, align 8, !tbaa !9
  %246 = getelementptr inbounds i8, ptr %244, i64 %245
  %247 = load ptr, ptr %11, align 8, !tbaa !5
  %248 = getelementptr inbounds %struct.inner_cursor, ptr %247, i32 0, i32 0
  %249 = getelementptr inbounds %struct.MDBX_cursor, ptr %248, i32 0, i32 4
  store ptr %246, ptr %249, align 8, !tbaa !39
  br label %250

250:                                              ; preds = %234, %204
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #10
  br label %251

251:                                              ; preds = %250, %203
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #10
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #10
  %252 = load i32, ptr %4, align 4
  ret i32 %252
}

; 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

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

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

!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, !7, i64 25}
!12 = !{!"libmdbx_globals", !7, i64 0, !13, i64 16, !13, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !14, i64 27, !13, i64 28, !7, i64 32, !7, i64 40, !10, i64 80, !6, i64 88}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !13, i64 0}
!16 = !{!"MDBX_cursor", !13, i64 0, !7, i64 4, !7, i64 6, !7, i64 7, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !7, i64 304, !6, i64 368, !6, i64 376}
!17 = !{!18, !6, i64 80}
!18 = !{!"MDBX_txn", !13, i64 0, !13, i64 4, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !19, 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, !21, i64 128, !6, i64 160, !7, i64 168}
!19 = !{!"geo", !20, i64 0, !20, i64 2, !13, i64 4, !13, i64 8, !7, i64 12, !7, i64 16}
!20 = !{!"short", !7, i64 0}
!21 = !{!"MDBX_canary", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!22 = !{!16, !6, i64 16}
!23 = !{!18, !13, i64 4}
!24 = !{!18, !10, i64 8}
!25 = !{!16, !6, i64 40}
!26 = !{i64 0, i64 4, !27, i64 4, i64 2, !28, i64 6, i64 1, !28, i64 7, i64 1, !28, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, i64 256, !28, i64 304, i64 64, !28, i64 368, i64 8, !5, i64 376, i64 8, !5}
!27 = !{!13, !13, i64 0}
!28 = !{!7, !7, i64 0}
!29 = !{!16, !6, i64 376}
!30 = !{!18, !6, i64 88}
!31 = !{!16, !6, i64 24}
!32 = !{!18, !6, i64 104}
!33 = !{!16, !6, i64 8}
!34 = !{i64 0, i64 4, !27, i64 4, i64 2, !28, i64 6, i64 1, !28, i64 7, i64 1, !28, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, i64 256, !28, i64 304, i64 64, !28, i64 368, i64 8, !5, i64 376, i64 8, !5, i64 384, i64 2, !35, i64 386, i64 2, !35, i64 388, i64 4, !27, i64 392, i64 4, !27, i64 396, i64 4, !27, i64 400, i64 4, !27, i64 404, i64 4, !27, i64 408, i64 8, !9, i64 416, i64 8, !9, i64 424, i64 8, !9}
!35 = !{!20, !20, i64 0}
!36 = !{!37, !6, i64 16}
!37 = !{!"inner_cursor", !16, i64 0, !38, i64 384}
!38 = !{!"tree", !20, i64 0, !20, i64 2, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !10, i64 24, !10, i64 32, !10, i64 40}
!39 = !{!37, !6, i64 8}


; 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.8 }
%struct.anon.8 = 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.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.17 = external hidden unnamed_addr constant [40 x i8], align 1
@__func__.cursor_shadow = external hidden unnamed_addr constant [14 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [31 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: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden i64 @cursor_dbi(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 13) i32 @cursor_shadow(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 {
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !5
  %5 = and i8 %4, 1
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %.thread56, label %6, !prof !13

6:                                                ; preds = %3
  %7 = load i32, ptr %0, align 8, !tbaa !14
  %.not42 = icmp eq i32 %7, 2114311601
  br i1 %.not42, label %11, label %8, !prof !16

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %1, i64 80
  %10 = load ptr, ptr %9, align 8, !tbaa !17
  tail call void @mdbx_assert_fail(ptr noundef %10, ptr noundef nonnull @.str.17, ptr noundef nonnull @__func__.cursor_shadow, i32 noundef 188) #6
  unreachable

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !22
  %.not44 = icmp eq ptr %13, %1
  br i1 %.not44, label %14, label %17, !prof !13

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %1, i64 80
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  tail call void @mdbx_assert_fail(ptr noundef %16, ptr noundef nonnull @.str.18, ptr noundef nonnull @__func__.cursor_shadow, i32 noundef 189) #6
  unreachable

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %13, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !23
  %20 = and i32 %19, 256
  %.not46 = icmp eq i32 %20, 0
  br i1 %.not46, label %21, label %24, !prof !13

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %13, i64 80
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  tail call void @mdbx_assert_fail(ptr noundef %23, ptr noundef nonnull @.str.19, ptr noundef nonnull @__func__.cursor_shadow, i32 noundef 190) #6
  unreachable

24:                                               ; preds = %17
  %25 = tail call i64 @cursor_dbi(ptr noundef nonnull %0) #7
  %.not48 = icmp eq i64 %25, %2
  br i1 %.not48, label %29, label %26, !prof !16

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %13, i64 80
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  tail call void @mdbx_assert_fail(ptr noundef %28, ptr noundef nonnull @.str.20, ptr noundef nonnull @__func__.cursor_shadow, i32 noundef 191) #6
  unreachable

29:                                               ; preds = %24
  %.not50 = icmp eq i64 %2, 0
  br i1 %.not50, label %.critedge, label %30, !prof !13

30:                                               ; preds = %29
  %31 = getelementptr inbounds i8, ptr %1, i64 8
  %32 = load i64, ptr %31, align 8, !tbaa !24
  %.not57 = icmp ugt i64 %32, %2
  br i1 %.not57, label %.thread56, label %.critedge, !prof !16

.critedge:                                        ; preds = %29, %30
  %33 = getelementptr inbounds i8, ptr %1, i64 80
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  tail call void @mdbx_assert_fail(ptr noundef %34, ptr noundef nonnull @.str.21, ptr noundef nonnull @__func__.cursor_shadow, i32 noundef 192) #6
  unreachable

.thread56:                                        ; preds = %3, %30
  %35 = getelementptr inbounds i8, ptr %0, i64 40
  %36 = load ptr, ptr %35, align 8, !tbaa !25
  %.not51 = icmp eq ptr %36, null
  %37 = select i1 %.not51, i64 384, i64 816
  %38 = tail call noalias ptr @malloc(i64 noundef %37) #8
  %.not52 = icmp eq ptr %38, null
  br i1 %.not52, label %56, label %39, !prof !13

39:                                               ; preds = %.thread56
  %40 = select i1 %.not51, i64 0, i64 432
  %41 = getelementptr i8, ptr %38, i64 384
  tail call void @llvm.memset.p0.i64(ptr align 8 %41, i8 -51, i64 %40, i1 false)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(384) %38, ptr noundef nonnull align 8 dereferenceable(384) %0, i64 384, i1 false), !tbaa.struct !26
  %42 = getelementptr inbounds i8, ptr %0, i64 376
  store ptr %38, ptr %42, align 8, !tbaa !30
  %43 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %1, ptr %43, align 8, !tbaa !22
  %44 = getelementptr inbounds i8, ptr %1, i64 88
  %45 = load ptr, ptr %44, align 8, !tbaa !31
  %46 = getelementptr inbounds %struct.tree, ptr %45, i64 %2
  %47 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %46, ptr %47, align 8, !tbaa !32
  %48 = getelementptr inbounds i8, ptr %1, i64 104
  %49 = load ptr, ptr %48, align 8, !tbaa !33
  %50 = getelementptr inbounds i8, ptr %49, i64 %2
  %51 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %50, ptr %51, align 8, !tbaa !34
  br i1 %.not51, label %56, label %52

52:                                               ; preds = %39
  %53 = getelementptr inbounds i8, ptr %38, i64 384
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(432) %53, ptr noundef nonnull align 8 dereferenceable(432) %36, i64 432, i1 false), !tbaa.struct !35
  %54 = getelementptr inbounds i8, ptr %36, i64 16
  store ptr %1, ptr %54, align 8, !tbaa !38
  %55 = getelementptr inbounds i8, ptr %36, i64 8
  store ptr %50, ptr %55, align 8, !tbaa !41
  br label %56

56:                                               ; preds = %39, %52, %.thread56
  %.0 = phi i32 [ 12, %.thread56 ], [ 0, %52 ], [ 0, %39 ]
  ret i32 %.0
}

; 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

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

attributes #0 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { noreturn nounwind }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { nounwind allocsize(0) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 25}
!6 = !{!"libmdbx_globals", !7, i64 0, !9, i64 16, !9, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !10, i64 27, !9, i64 28, !7, i64 32, !7, i64 40, !11, i64 80, !12, i64 88}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!14 = !{!15, !9, i64 0}
!15 = !{!"MDBX_cursor", !9, i64 0, !7, i64 4, !7, i64 6, !7, i64 7, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !7, i64 48, !7, i64 304, !12, i64 368, !12, i64 376}
!16 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!17 = !{!18, !12, i64 80}
!18 = !{!"MDBX_txn", !9, i64 0, !9, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !19, 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, !21, i64 128, !12, i64 160, !7, i64 168}
!19 = !{!"geo", !20, i64 0, !20, i64 2, !9, i64 4, !9, i64 8, !7, i64 12, !7, i64 16}
!20 = !{!"short", !7, i64 0}
!21 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!22 = !{!15, !12, i64 16}
!23 = !{!18, !9, i64 4}
!24 = !{!18, !11, i64 8}
!25 = !{!15, !12, i64 40}
!26 = !{i64 0, i64 4, !27, i64 4, i64 2, !28, i64 6, i64 1, !28, i64 7, i64 1, !28, i64 8, i64 8, !29, i64 16, i64 8, !29, i64 24, i64 8, !29, i64 32, i64 8, !29, i64 40, i64 8, !29, i64 48, i64 256, !28, i64 304, i64 64, !28, i64 368, i64 8, !29, i64 376, i64 8, !29}
!27 = !{!9, !9, i64 0}
!28 = !{!7, !7, i64 0}
!29 = !{!12, !12, i64 0}
!30 = !{!15, !12, i64 376}
!31 = !{!18, !12, i64 88}
!32 = !{!15, !12, i64 24}
!33 = !{!18, !12, i64 104}
!34 = !{!15, !12, i64 8}
!35 = !{i64 0, i64 4, !27, i64 4, i64 2, !28, i64 6, i64 1, !28, i64 7, i64 1, !28, i64 8, i64 8, !29, i64 16, i64 8, !29, i64 24, i64 8, !29, i64 32, i64 8, !29, i64 40, i64 8, !29, i64 48, i64 256, !28, i64 304, i64 64, !28, i64 368, i64 8, !29, i64 376, i64 8, !29, i64 384, i64 2, !36, i64 386, i64 2, !36, i64 388, i64 4, !27, i64 392, i64 4, !27, i64 396, i64 4, !27, i64 400, i64 4, !27, i64 404, i64 4, !27, i64 408, i64 8, !37, i64 416, i64 8, !37, i64 424, i64 8, !37}
!36 = !{!20, !20, i64 0}
!37 = !{!11, !11, i64 0}
!38 = !{!39, !12, i64 16}
!39 = !{!"inner_cursor", !15, i64 0, !40, i64 384}
!40 = !{!"tree", !20, i64 0, !20, i64 2, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20, !11, i64 24, !11, i64 32, !11, i64 40}
!41 = !{!39, !12, i64 8}


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