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

@globals = external global %struct.libmdbx_globals, align 8
@.str.22 = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.cursor_eot = external hidden unnamed_addr constant [11 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [28 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @cursor_eot(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.MDBX_cursor, ptr %9, i32 0, i32 11
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.MDBX_cursor, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !12
  store i32 %14, ptr %6, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.MDBX_cursor, ptr %15, i32 0, i32 12
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  store ptr %17, ptr %7, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %2
  %19 = load i32, ptr %6, align 4, !tbaa !13
  %20 = icmp eq i32 %19, 2114311601
  br i1 %20, label %29, label %21

21:                                               ; preds = %18
  %22 = load i32, ptr %6, align 4, !tbaa !13
  %23 = icmp eq i32 %22, 283285415
  br i1 %23, label %24, label %27

24:                                               ; preds = %21
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br label %27

27:                                               ; preds = %24, %21
  %28 = phi i1 [ false, %21 ], [ %26, %24 ]
  br label %29

29:                                               ; preds = %27, %18
  %30 = phi i1 [ true, %18 ], [ %28, %27 ]
  %31 = xor i1 %30, true
  %32 = xor i1 %31, true
  %33 = xor i1 %32, true
  %34 = zext i1 %33 to i32
  %35 = sext i32 %34 to i64
  %36 = call i64 @llvm.expect.i64(i64 %35, i64 0)
  %37 = icmp ne i64 %36, 0
  br i1 %37, label %38, label %42

38:                                               ; preds = %29
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.MDBX_txn, ptr %39, i32 0, i32 9
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %41, ptr noundef @.str.22, ptr noundef @__func__.cursor_eot, i32 noundef 221) #8
  unreachable

42:                                               ; preds = %29
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !21
  %47 = zext i8 %46 to i32
  %48 = and i32 %47, 1
  %49 = icmp ne i32 %48, 0
  %50 = xor i1 %49, true
  %51 = xor i1 %50, true
  %52 = zext i1 %51 to i32
  %53 = sext i32 %52 to i64
  %54 = call i64 @llvm.expect.i64(i64 %53, i64 1)
  %55 = icmp ne i64 %54, 0
  br i1 %55, label %56, label %77

56:                                               ; preds = %45
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.MDBX_cursor, ptr %58, i32 0, i32 5
  %60 = load ptr, ptr %59, align 8, !tbaa !24
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = icmp eq ptr %60, %61
  %63 = xor i1 %62, true
  %64 = xor i1 %63, true
  %65 = xor i1 %64, true
  %66 = zext i1 %65 to i32
  %67 = sext i32 %66 to i64
  %68 = call i64 @llvm.expect.i64(i64 %67, i64 0)
  %69 = icmp ne i64 %68, 0
  br i1 %69, label %70, label %74

70:                                               ; preds = %57
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.MDBX_txn, ptr %71, i32 0, i32 9
  %73 = load ptr, ptr %72, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %73, ptr noundef @.str.23, ptr noundef @__func__.cursor_eot, i32 noundef 222) #8
  unreachable

74:                                               ; preds = %57
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76, %45
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %248

82:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.MDBX_cursor, ptr %83, i32 0, i32 8
  %85 = load ptr, ptr %84, align 8, !tbaa !25
  store ptr %85, ptr %8, align 8, !tbaa !5
  br label %86

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

97:                                               ; preds = %86
  br label %98

98:                                               ; preds = %97
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.MDBX_txn, ptr %99, i32 0, i32 4
  %101 = load ptr, ptr %100, align 8, !tbaa !26
  %102 = icmp ne ptr %101, null
  br i1 %102, label %103, label %111

103:                                              ; preds = %98
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.MDBX_cursor, ptr %104, i32 0, i32 5
  %106 = load ptr, ptr %105, align 8, !tbaa !24
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.MDBX_txn, ptr %107, i32 0, i32 4
  %109 = load ptr, ptr %108, align 8, !tbaa !26
  %110 = icmp eq ptr %106, %109
  br label %111

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

120:                                              ; preds = %111
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.MDBX_txn, ptr %121, i32 0, i32 9
  %123 = load ptr, ptr %122, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %123, ptr noundef @.str.24, ptr noundef @__func__.cursor_eot, i32 noundef 225) #8
  unreachable

124:                                              ; preds = %111
  br label %125

125:                                              ; preds = %124
  br label %126

126:                                              ; preds = %125
  br label %127

127:                                              ; preds = %126, %86
  br label %128

128:                                              ; preds = %127
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.MDBX_cursor, ptr %131, i32 0, i32 0
  %133 = load i32, ptr %132, align 8, !tbaa !12
  %134 = icmp eq i32 %133, 2114311601
  %135 = xor i1 %134, true
  %136 = xor i1 %135, true
  %137 = xor i1 %136, true
  %138 = zext i1 %137 to i32
  %139 = sext i32 %138 to i64
  %140 = call i64 @llvm.expect.i64(i64 %139, i64 0)
  %141 = icmp ne i64 %140, 0
  br i1 %141, label %142, label %146

142:                                              ; preds = %130
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.MDBX_txn, ptr %143, i32 0, i32 9
  %145 = load ptr, ptr %144, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %145, ptr noundef @.str.25, ptr noundef @__func__.cursor_eot, i32 noundef 228) #8
  unreachable

146:                                              ; preds = %130
  br label %147

147:                                              ; preds = %146
  br label %148

148:                                              ; preds = %147
  br label %149

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

160:                                              ; preds = %149
  br label %161

161:                                              ; preds = %160
  %162 = load ptr, ptr %8, align 8, !tbaa !5
  %163 = load ptr, ptr %7, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.MDBX_cursor, ptr %163, i32 0, i32 8
  %165 = load ptr, ptr %164, align 8, !tbaa !25
  %166 = icmp eq ptr %162, %165
  %167 = xor i1 %166, true
  %168 = xor i1 %167, true
  %169 = xor i1 %168, true
  %170 = zext i1 %169 to i32
  %171 = sext i32 %170 to i64
  %172 = call i64 @llvm.expect.i64(i64 %171, i64 0)
  %173 = icmp ne i64 %172, 0
  br i1 %173, label %174, label %178

174:                                              ; preds = %161
  %175 = load ptr, ptr %4, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.MDBX_txn, ptr %175, i32 0, i32 9
  %177 = load ptr, ptr %176, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %177, ptr noundef @.str.26, ptr noundef @__func__.cursor_eot, i32 noundef 229) #8
  unreachable

178:                                              ; preds = %161
  br label %179

179:                                              ; preds = %178
  br label %180

180:                                              ; preds = %179
  br label %181

181:                                              ; preds = %180, %149
  br label %182

182:                                              ; preds = %181
  br label %183

183:                                              ; preds = %182
  %184 = load ptr, ptr %4, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.MDBX_txn, ptr %184, i32 0, i32 1
  %186 = load i32, ptr %185, align 4, !tbaa !27
  %187 = and i32 %186, 2
  %188 = icmp eq i32 %187, 0
  br i1 %188, label %189, label %231

189:                                              ; preds = %183
  %190 = load ptr, ptr %7, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.MDBX_cursor, ptr %190, i32 0, i32 11
  %192 = load ptr, ptr %191, align 8, !tbaa !9
  %193 = load ptr, ptr %3, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.MDBX_cursor, ptr %193, i32 0, i32 11
  store ptr %192, ptr %194, align 8, !tbaa !9
  %195 = load ptr, ptr %7, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.MDBX_cursor, ptr %195, i32 0, i32 12
  %197 = load ptr, ptr %196, align 8, !tbaa !14
  %198 = load ptr, ptr %3, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.MDBX_cursor, ptr %198, i32 0, i32 12
  store ptr %197, ptr %199, align 8, !tbaa !14
  %200 = load ptr, ptr %7, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct.MDBX_cursor, ptr %200, i32 0, i32 5
  %202 = load ptr, ptr %201, align 8, !tbaa !24
  %203 = load ptr, ptr %3, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.MDBX_cursor, ptr %203, i32 0, i32 5
  store ptr %202, ptr %204, align 8, !tbaa !24
  %205 = load ptr, ptr %7, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.MDBX_cursor, ptr %205, i32 0, i32 6
  %207 = load ptr, ptr %206, align 8, !tbaa !28
  %208 = load ptr, ptr %3, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.MDBX_cursor, ptr %208, i32 0, i32 6
  store ptr %207, ptr %209, align 8, !tbaa !28
  %210 = load ptr, ptr %7, align 8, !tbaa !5
  %211 = getelementptr inbounds %struct.MDBX_cursor, ptr %210, i32 0, i32 4
  %212 = load ptr, ptr %211, align 8, !tbaa !29
  %213 = load ptr, ptr %3, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.MDBX_cursor, ptr %213, i32 0, i32 4
  store ptr %212, ptr %214, align 8, !tbaa !29
  %215 = load ptr, ptr %8, align 8, !tbaa !5
  %216 = icmp ne ptr %215, null
  br i1 %216, label %217, label %230

217:                                              ; preds = %189
  %218 = load ptr, ptr %7, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.MDBX_cursor, ptr %218, i32 0, i32 5
  %220 = load ptr, ptr %219, align 8, !tbaa !24
  %221 = load ptr, ptr %8, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.inner_cursor, ptr %221, i32 0, i32 0
  %223 = getelementptr inbounds %struct.MDBX_cursor, ptr %222, i32 0, i32 5
  store ptr %220, ptr %223, align 8, !tbaa !30
  %224 = load ptr, ptr %7, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct.MDBX_cursor, ptr %224, i32 0, i32 4
  %226 = load ptr, ptr %225, align 8, !tbaa !29
  %227 = load ptr, ptr %8, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.inner_cursor, ptr %227, i32 0, i32 0
  %229 = getelementptr inbounds %struct.MDBX_cursor, ptr %228, i32 0, i32 4
  store ptr %226, ptr %229, align 8, !tbaa !33
  br label %230

230:                                              ; preds = %217, %189
  br label %244

231:                                              ; preds = %183
  %232 = load ptr, ptr %3, align 8, !tbaa !5
  %233 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %232, ptr align 8 %233, i64 384, i1 false), !tbaa.struct !34
  %234 = load i32, ptr %6, align 4, !tbaa !13
  %235 = load ptr, ptr %3, align 8, !tbaa !5
  %236 = getelementptr inbounds %struct.MDBX_cursor, ptr %235, i32 0, i32 0
  store i32 %234, ptr %236, align 8, !tbaa !12
  %237 = load ptr, ptr %8, align 8, !tbaa !5
  %238 = icmp ne ptr %237, null
  br i1 %238, label %239, label %243

239:                                              ; preds = %231
  %240 = load ptr, ptr %8, align 8, !tbaa !5
  %241 = load ptr, ptr %7, align 8, !tbaa !5
  %242 = getelementptr inbounds %struct.MDBX_cursor, ptr %241, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %240, ptr align 8 %242, i64 432, i1 false), !tbaa.struct !36
  br label %243

243:                                              ; preds = %239, %231
  br label %244

244:                                              ; preds = %243, %230
  %245 = load ptr, ptr %7, align 8, !tbaa !5
  %246 = getelementptr inbounds %struct.MDBX_cursor, ptr %245, i32 0, i32 0
  store i32 0, ptr %246, align 8, !tbaa !12
  %247 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %247) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %274

248:                                              ; preds = %79
  br label %249

249:                                              ; preds = %248
  %250 = load i32, ptr %6, align 4, !tbaa !13
  %251 = icmp eq i32 %250, 2114311601
  %252 = xor i1 %251, true
  %253 = xor i1 %252, true
  %254 = xor i1 %253, true
  %255 = zext i1 %254 to i32
  %256 = sext i32 %255 to i64
  %257 = call i64 @llvm.expect.i64(i64 %256, i64 0)
  %258 = icmp ne i64 %257, 0
  br i1 %258, label %259, label %265

259:                                              ; preds = %249
  %260 = load ptr, ptr %3, align 8, !tbaa !5
  %261 = getelementptr inbounds %struct.MDBX_cursor, ptr %260, i32 0, i32 5
  %262 = load ptr, ptr %261, align 8, !tbaa !24
  %263 = getelementptr inbounds %struct.MDBX_txn, ptr %262, i32 0, i32 9
  %264 = load ptr, ptr %263, align 8, !tbaa !15
  call void @mdbx_assert_fail(ptr noundef %264, ptr noundef @.str.27, ptr noundef @__func__.cursor_eot, i32 noundef 251) #8
  unreachable

265:                                              ; preds = %249
  br label %266

266:                                              ; preds = %265
  br label %267

267:                                              ; preds = %266
  %268 = load ptr, ptr %3, align 8, !tbaa !5
  %269 = getelementptr inbounds %struct.MDBX_cursor, ptr %268, i32 0, i32 0
  store i32 672636999, ptr %269, align 8, !tbaa !12
  %270 = load ptr, ptr %3, align 8, !tbaa !5
  %271 = load ptr, ptr %3, align 8, !tbaa !5
  %272 = getelementptr inbounds %struct.MDBX_cursor, ptr %271, i32 0, i32 11
  store ptr %270, ptr %272, align 8, !tbaa !9
  %273 = load ptr, ptr %3, align 8, !tbaa !5
  call void @cursor_drown(ptr noundef %273)
  br label %274

274:                                              ; preds = %267, %244
  %275 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  ret ptr %275
}

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cursor_drown(ptr noundef) #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 "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 = { 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 #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, !6, i64 368}
!10 = !{!"MDBX_cursor", !11, 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}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 376}
!15 = !{!16, !6, i64 80}
!16 = !{!"MDBX_txn", !11, i64 0, !11, i64 4, !17, i64 8, !17, i64 16, !6, i64 24, !6, i64 32, !18, i64 40, !17, i64 64, !17, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !20, i64 128, !6, i64 160, !7, i64 168}
!17 = !{!"long", !7, i64 0}
!18 = !{!"geo", !19, i64 0, !19, i64 2, !11, i64 4, !11, i64 8, !7, i64 12, !7, i64 16}
!19 = !{!"short", !7, i64 0}
!20 = !{!"MDBX_canary", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24}
!21 = !{!22, !7, i64 25}
!22 = !{!"libmdbx_globals", !7, i64 0, !11, i64 16, !11, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !23, i64 27, !11, i64 28, !7, i64 32, !7, i64 40, !17, i64 80, !6, i64 88}
!23 = !{!"_Bool", !7, i64 0}
!24 = !{!10, !6, i64 16}
!25 = !{!10, !6, i64 40}
!26 = !{!16, !6, i64 24}
!27 = !{!16, !11, i64 4}
!28 = !{!10, !6, i64 24}
!29 = !{!10, !6, i64 8}
!30 = !{!31, !6, i64 16}
!31 = !{!"inner_cursor", !10, i64 0, !32, i64 384}
!32 = !{!"tree", !19, i64 0, !19, i64 2, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !17, i64 24, !17, i64 32, !17, i64 40}
!33 = !{!31, !6, i64 8}
!34 = !{i64 0, i64 4, !13, i64 4, i64 2, !35, i64 6, i64 1, !35, i64 7, i64 1, !35, 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, !35, i64 304, i64 64, !35, i64 368, i64 8, !5, i64 376, i64 8, !5}
!35 = !{!7, !7, i64 0}
!36 = !{i64 0, i64 4, !13, i64 4, i64 2, !35, i64 6, i64 1, !35, i64 7, i64 1, !35, 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, !35, i64 304, i64 64, !35, i64 368, i64 8, !5, i64 376, i64 8, !5, i64 384, i64 2, !37, i64 386, i64 2, !37, i64 388, i64 4, !13, i64 392, i64 4, !13, i64 396, i64 4, !13, i64 400, i64 4, !13, i64 404, i64 4, !13, i64 408, i64 8, !38, i64 416, i64 8, !38, i64 424, i64 8, !38}
!37 = !{!19, !19, i64 0}
!38 = !{!17, !17, i64 0}


; 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 }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@.str.22 = external hidden unnamed_addr constant [75 x i8], align 1
@__func__.cursor_eot = external hidden unnamed_addr constant [11 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [28 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 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) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @cursor_eot(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 368
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load i32, ptr %0, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 376
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %.not59 = icmp eq i32 %5, 2114311601
  br i1 %.not59, label %.critedge, label %8

8:                                                ; preds = %2
  %9 = icmp ne i32 %5, 283285415
  %10 = icmp eq ptr %7, null
  %.not56 = select i1 %9, i1 true, i1 %10
  br i1 %.not56, label %11, label %.critedge, !prof !13

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %1, i64 80
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  tail call void @mdbx_assert_fail(ptr noundef %13, ptr noundef nonnull @.str.22, ptr noundef nonnull @__func__.cursor_eot, i32 noundef 221) #5
  unreachable

.critedge:                                        ; preds = %2, %8
  %14 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !20
  %15 = and i8 %14, 1
  %.not = icmp eq i8 %15, 0
  br i1 %.not, label %22, label %16, !prof !13

16:                                               ; preds = %.critedge
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !23
  %.not57 = icmp eq ptr %18, %1
  br i1 %.not57, label %.thread, label %19, !prof !24

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %1, i64 80
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  tail call void @mdbx_assert_fail(ptr noundef %21, ptr noundef nonnull @.str.23, ptr noundef nonnull @__func__.cursor_eot, i32 noundef 222) #5
  unreachable

22:                                               ; preds = %.critedge
  %.not58 = icmp eq ptr %7, null
  br i1 %.not58, label %71, label %33

.thread:                                          ; preds = %16
  %.not5869 = icmp eq ptr %7, null
  br i1 %.not5869, label %71, label %23

23:                                               ; preds = %.thread
  %24 = getelementptr inbounds i8, ptr %0, i64 40
  %25 = load ptr, ptr %24, align 8, !tbaa !25
  %26 = getelementptr inbounds i8, ptr %1, i64 24
  %27 = load ptr, ptr %26, align 8, !tbaa !26
  %.not61 = icmp eq ptr %27, null
  br i1 %.not61, label %.critedge68, label %28, !prof !13

28:                                               ; preds = %23
  %29 = getelementptr inbounds i8, ptr %7, i64 16
  %30 = load ptr, ptr %29, align 8, !tbaa !23
  %.not74 = icmp eq ptr %30, %27
  br i1 %.not74, label %.thread71, label %.critedge68, !prof !24

.critedge68:                                      ; preds = %23, %28
  %31 = getelementptr inbounds i8, ptr %1, i64 80
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  tail call void @mdbx_assert_fail(ptr noundef %32, ptr noundef nonnull @.str.24, ptr noundef nonnull @__func__.cursor_eot, i32 noundef 225) #5
  unreachable

33:                                               ; preds = %22
  %34 = getelementptr inbounds i8, ptr %0, i64 40
  %35 = load ptr, ptr %34, align 8, !tbaa !25
  %36 = load i32, ptr %7, align 8, !tbaa !11
  %.not62 = icmp eq i32 %36, 2114311601
  br i1 %.not62, label %46, label %38, !prof !24

.thread71:                                        ; preds = %28
  %37 = load i32, ptr %7, align 8, !tbaa !11
  %.not6272 = icmp eq i32 %37, 2114311601
  br i1 %.not6272, label %.thread73, label %38, !prof !24

38:                                               ; preds = %.thread71, %33
  %39 = getelementptr inbounds i8, ptr %1, i64 80
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  tail call void @mdbx_assert_fail(ptr noundef %40, ptr noundef nonnull @.str.25, ptr noundef nonnull @__func__.cursor_eot, i32 noundef 228) #5
  unreachable

.thread73:                                        ; preds = %.thread71
  %41 = getelementptr inbounds i8, ptr %7, i64 40
  %42 = load ptr, ptr %41, align 8, !tbaa !25
  %.not64 = icmp eq ptr %25, %42
  br i1 %.not64, label %46, label %43, !prof !24

43:                                               ; preds = %.thread73
  %44 = getelementptr inbounds i8, ptr %1, i64 80
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  tail call void @mdbx_assert_fail(ptr noundef %45, ptr noundef nonnull @.str.26, ptr noundef nonnull @__func__.cursor_eot, i32 noundef 229) #5
  unreachable

46:                                               ; preds = %33, %.thread73
  %47 = phi ptr [ %25, %.thread73 ], [ %35, %33 ]
  %48 = getelementptr inbounds i8, ptr %1, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !27
  %50 = and i32 %49, 2
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %67

52:                                               ; preds = %46
  %53 = getelementptr inbounds i8, ptr %7, i64 368
  %54 = load <2 x ptr>, ptr %53, align 8, !tbaa !28
  store <2 x ptr> %54, ptr %3, align 8, !tbaa !28
  %55 = getelementptr inbounds i8, ptr %7, i64 16
  %56 = load ptr, ptr %55, align 8, !tbaa !23
  %57 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %56, ptr %57, align 8, !tbaa !23
  %58 = getelementptr inbounds i8, ptr %7, i64 24
  %59 = load ptr, ptr %58, align 8, !tbaa !29
  %60 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %59, ptr %60, align 8, !tbaa !29
  %61 = getelementptr inbounds i8, ptr %7, i64 8
  %62 = load ptr, ptr %61, align 8, !tbaa !30
  %63 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %62, ptr %63, align 8, !tbaa !30
  %.not66 = icmp eq ptr %47, null
  br i1 %.not66, label %70, label %64

64:                                               ; preds = %52
  %65 = getelementptr inbounds i8, ptr %47, i64 16
  store ptr %56, ptr %65, align 8, !tbaa !31
  %66 = getelementptr inbounds i8, ptr %47, i64 8
  store ptr %62, ptr %66, align 8, !tbaa !34
  br label %70

67:                                               ; preds = %46
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(384) %0, ptr noundef nonnull align 8 dereferenceable(384) %7, i64 384, i1 false), !tbaa.struct !35
  store i32 %5, ptr %0, align 8, !tbaa !11
  %.not65 = icmp eq ptr %47, null
  br i1 %.not65, label %70, label %68

68:                                               ; preds = %67
  %69 = getelementptr inbounds i8, ptr %7, i64 384
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(432) %47, ptr noundef nonnull align 8 dereferenceable(432) %69, i64 432, i1 false), !tbaa.struct !38
  br label %70

70:                                               ; preds = %67, %68, %52, %64
  tail call void @free(ptr noundef nonnull %7) #6
  br label %78

71:                                               ; preds = %.thread, %22
  br i1 %.not59, label %77, label %72, !prof !24

72:                                               ; preds = %71
  %73 = getelementptr inbounds i8, ptr %0, i64 16
  %74 = load ptr, ptr %73, align 8, !tbaa !23
  %75 = getelementptr inbounds i8, ptr %74, i64 80
  %76 = load ptr, ptr %75, align 8, !tbaa !14
  tail call void @mdbx_assert_fail(ptr noundef %76, ptr noundef nonnull @.str.27, ptr noundef nonnull @__func__.cursor_eot, i32 noundef 251) #5
  unreachable

77:                                               ; preds = %71
  store i32 672636999, ptr %0, align 8, !tbaa !11
  store ptr %0, ptr %3, align 8, !tbaa !5
  tail call void @cursor_drown(ptr noundef nonnull %0)
  br label %78

78:                                               ; preds = %77, %70
  ret ptr %4
}

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cursor_drown(ptr noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 nounwind willreturn allockind("free") memory(argmem: readwrite, 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 = { 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 #5 = { noreturn nounwind }
attributes #6 = { 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 368}
!6 = !{!"MDBX_cursor", !7, i64 0, !8, i64 4, !8, i64 6, !8, i64 7, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !8, i64 48, !8, i64 304, !10, i64 368, !10, i64 376}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 376}
!13 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!14 = !{!15, !10, i64 80}
!15 = !{!"MDBX_txn", !7, i64 0, !7, i64 4, !16, i64 8, !16, i64 16, !10, i64 24, !10, i64 32, !17, i64 40, !16, i64 64, !16, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !19, i64 128, !10, i64 160, !8, i64 168}
!16 = !{!"long", !8, i64 0}
!17 = !{!"geo", !18, i64 0, !18, i64 2, !7, i64 4, !7, i64 8, !8, i64 12, !8, i64 16}
!18 = !{!"short", !8, i64 0}
!19 = !{!"MDBX_canary", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24}
!20 = !{!21, !8, i64 25}
!21 = !{!"libmdbx_globals", !8, i64 0, !7, i64 16, !7, i64 20, !8, i64 24, !8, i64 25, !8, i64 26, !22, i64 27, !7, i64 28, !8, i64 32, !8, i64 40, !16, i64 80, !10, i64 88}
!22 = !{!"_Bool", !8, i64 0}
!23 = !{!6, !10, i64 16}
!24 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!25 = !{!6, !10, i64 40}
!26 = !{!15, !10, i64 24}
!27 = !{!15, !7, i64 4}
!28 = !{!10, !10, i64 0}
!29 = !{!6, !10, i64 24}
!30 = !{!6, !10, i64 8}
!31 = !{!32, !10, i64 16}
!32 = !{!"inner_cursor", !6, i64 0, !33, i64 384}
!33 = !{!"tree", !18, i64 0, !18, i64 2, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !16, i64 24, !16, i64 32, !16, i64 40}
!34 = !{!32, !10, i64 8}
!35 = !{i64 0, i64 4, !36, i64 4, i64 2, !37, i64 6, i64 1, !37, i64 7, i64 1, !37, i64 8, i64 8, !28, i64 16, i64 8, !28, i64 24, i64 8, !28, i64 32, i64 8, !28, i64 40, i64 8, !28, i64 48, i64 256, !37, i64 304, i64 64, !37, i64 368, i64 8, !28, i64 376, i64 8, !28}
!36 = !{!7, !7, i64 0}
!37 = !{!8, !8, i64 0}
!38 = !{i64 0, i64 4, !36, i64 4, i64 2, !37, i64 6, i64 1, !37, i64 7, i64 1, !37, i64 8, i64 8, !28, i64 16, i64 8, !28, i64 24, i64 8, !28, i64 32, i64 8, !28, i64 40, i64 8, !28, i64 48, i64 256, !37, i64 304, i64 64, !37, i64 368, i64 8, !28, i64 376, i64 8, !28, i64 384, i64 2, !39, i64 386, i64 2, !39, i64 388, i64 4, !36, i64 392, i64 4, !36, i64 396, i64 4, !36, i64 400, i64 4, !36, i64 404, i64 4, !36, i64 408, i64 8, !40, i64 416, i64 8, !40, i64 424, i64 8, !40}
!39 = !{!18, !18, i64 0}
!40 = !{!16, !16, i64 0}


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