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

; 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.dbi_rename_result = type { ptr, i32 }
%struct.iovec = type { ptr, i64 }
%struct.cursor_couple = type { %struct.MDBX_cursor, ptr, %struct.inner_cursor }
%struct.MDBX_cursor = type { i32, %union.anon.16, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon.16 = type { i16 }
%struct.inner_cursor = type { %struct.MDBX_cursor, %struct.tree }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%struct.cursor_set_result = type { i32, i8 }
%struct.MDBX_txn = type { i32, i32, i64, i64, ptr, ptr, %struct.geo, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, %struct.MDBX_canary, ptr, %union.anon.2 }
%struct.geo = type { i16, i16, i32, i32, %union.anon, %union.anon.1 }
%union.anon = type { i32 }
%union.anon.1 = type { i32 }
%struct.MDBX_canary = type { i64, i64, i64, i64 }
%union.anon.2 = type { %struct.anon.4 }
%struct.anon.4 = type { %struct.troika, ptr, %struct.anon.5, i8, i32, i32, i64, ptr, ptr, ptr, i64, %union.anon.6 }
%struct.troika = type { i8, i8, i8, i8, i32, [3 x i64] }
%struct.anon.5 = type { %struct.MDBX_rkl, i64, %struct.MDBX_rkl }
%struct.MDBX_rkl = type { i64, i64, i32, i32, ptr, [12 x i64] }
%union.anon.6 = type { %struct.anon.7 }
%struct.anon.7 = type { i64, ptr }
%struct.MDBX_env = type { %union.mdbx_atomic_uint32_t, i32, i32, %struct.osal_mmap, i32, i32, %struct.osal_mmap, ptr, i16, i16, i16, i16, i16, i16, %union.mdbx_atomic_uint32_t, i8, i8, i16, i32, i32, i32, i32, %struct.anon.9, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i64, %struct.anon.10, %struct.anon.14, i8, ptr, ptr, ptr, %struct.anon.15, %union.pthread_mutex_t, i32, i32, ptr, %struct.osal_ioring, %union.pthread_mutex_t, [71 x %union.mdbx_atomic_uint64_t] }
%struct.osal_mmap = type { %union.anon.8, i32, i64, i64, i64 }
%union.anon.8 = type { ptr }
%union.mdbx_atomic_uint32_t = type { i32 }
%struct.anon.9 = type { ptr, ptr, ptr, ptr }
%struct.anon.10 = type { i32, i32, i32, i32, i64, i8, i8, i8, i8, i32, i32, i8, i8, i8, %struct.anon.11, %union.anon.12 }
%struct.anon.11 = type { i16, i16, i16, i16 }
%union.anon.12 = type { i32 }
%struct.anon.14 = type { i64, i64, i64, i64, i64 }
%struct.anon.15 = type { i64 }
%struct.osal_ioring = type { i32, i32, i32, ptr, ptr, ptr }
%union.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 }
%union.mdbx_atomic_uint64_t = type { i64 }
%struct.kvx = type { %struct.clc2, %struct.iovec }
%struct.clc2 = type { %struct.clc, %struct.clc }
%struct.clc = type { ptr, i64, i64 }

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @dbi_check(ptr noundef, i64 noundef) #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: cold nounwind optsize uwtable
define dso_local { ptr, i32 } @dbi_rename_locked(ptr noundef %0, i32 noundef %1, ptr %2, i64 %3) #4 {
  %5 = alloca %struct.dbi_rename_result, align 8
  %6 = alloca %struct.iovec, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %struct.iovec, align 8
  %11 = alloca i32, align 4
  %12 = alloca %struct.cursor_couple, align 8
  %13 = alloca %struct.cursor_set_result, align 4
  %14 = alloca %struct.iovec, align 8
  %15 = alloca %struct.cursor_set_result, align 4
  %16 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 0
  store ptr %2, ptr %16, align 8
  %17 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 1
  store i64 %3, ptr %17, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  %18 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 0
  store ptr null, ptr %18, align 8, !tbaa !11
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = call i32 @dbi_check(ptr noundef %19, i64 noundef %21)
  %23 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  store i32 %22, ptr %23, align 8, !tbaa !13
  %24 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !13
  %26 = icmp ne i32 %25, 0
  %27 = xor i1 %26, true
  %28 = xor i1 %27, true
  %29 = zext i1 %28 to i32
  %30 = sext i32 %29 to i64
  %31 = call i64 @llvm.expect.i64(i64 %30, i64 0)
  %32 = icmp ne i64 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %4
  br label %221

34:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.MDBX_txn, ptr %35, i32 0, i32 9
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  store ptr %37, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #7
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MDBX_env, ptr %38, i32 0, i32 25
  %40 = load ptr, ptr %39, align 8, !tbaa !20
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds %struct.kvx, ptr %40, i64 %42
  %44 = getelementptr inbounds %struct.kvx, ptr %43, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %44, i64 16, i1 false), !tbaa.struct !30
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.MDBX_env, ptr %45, i32 0, i32 25
  %47 = load ptr, ptr %46, align 8, !tbaa !20
  %48 = getelementptr inbounds %struct.kvx, ptr %47, i64 1
  %49 = getelementptr inbounds %struct.kvx, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.clc2, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds %struct.clc, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !32
  %53 = call i32 %52(ptr noundef %6, ptr noundef %10)
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %34
  br i1 false, label %56, label %57

56:                                               ; preds = %55
  store i32 1, ptr %11, align 4
  br label %220

57:                                               ; preds = %55, %34
  call void @llvm.lifetime.start.p0(i64 824, ptr %12) #7
  %58 = getelementptr inbounds %struct.cursor_couple, ptr %12, i32 0, i32 0
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = call i32 @cursor_init(ptr noundef %58, ptr noundef %59, i64 noundef 1)
  %61 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  store i32 %60, ptr %61, align 8, !tbaa !13
  %62 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  %63 = load i32, ptr %62, align 8, !tbaa !13
  %64 = icmp ne i32 %63, 0
  %65 = xor i1 %64, true
  %66 = xor i1 %65, true
  %67 = zext i1 %66 to i32
  %68 = sext i32 %67 to i64
  %69 = call i64 @llvm.expect.i64(i64 %68, i64 0)
  %70 = icmp ne i64 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %57
  store i32 1, ptr %11, align 4
  br label %219

72:                                               ; preds = %57
  %73 = getelementptr inbounds %struct.cursor_couple, ptr %12, i32 0, i32 0
  %74 = call i64 @cursor_seek(ptr noundef %73, ptr noundef %6, ptr noundef null, i32 noundef 15)
  store i64 %74, ptr %13, align 4
  %75 = getelementptr inbounds %struct.cursor_set_result, ptr %13, i32 0, i32 0
  %76 = load i32, ptr %75, align 4, !tbaa !37
  %77 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  store i32 %76, ptr %77, align 8, !tbaa !13
  %78 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  %79 = load i32, ptr %78, align 8, !tbaa !13
  %80 = icmp ne i32 %79, -30798
  %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 0)
  %86 = icmp ne i64 %85, 0
  br i1 %86, label %87, label %98

87:                                               ; preds = %72
  %88 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  %89 = load i32, ptr %88, align 8, !tbaa !13
  %90 = icmp eq i32 %89, 0
  br i1 %90, label %91, label %92

91:                                               ; preds = %87
  br label %95

92:                                               ; preds = %87
  %93 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  %94 = load i32, ptr %93, align 8, !tbaa !13
  br label %95

95:                                               ; preds = %92, %91
  %96 = phi i32 [ -30799, %91 ], [ %94, %92 ]
  %97 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  store i32 %96, ptr %97, align 8, !tbaa !13
  store i32 1, ptr %11, align 4
  br label %219

98:                                               ; preds = %72
  %99 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8
  %101 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 1
  %102 = load i64, ptr %101, align 8
  %103 = call i64 @dbi_namelen(ptr %100, i64 %102)
  %104 = call noalias ptr @malloc(i64 noundef %103) #8
  %105 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 0
  store ptr %104, ptr %105, align 8, !tbaa !11
  %106 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !11
  %108 = icmp ne ptr %107, null
  %109 = xor i1 %108, true
  %110 = xor i1 %109, true
  %111 = xor i1 %110, true
  %112 = zext i1 %111 to i32
  %113 = sext i32 %112 to i64
  %114 = call i64 @llvm.expect.i64(i64 %113, i64 0)
  %115 = icmp ne i64 %114, 0
  br i1 %115, label %116, label %118

116:                                              ; preds = %98
  %117 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  store i32 12, ptr %117, align 8, !tbaa !13
  store i32 1, ptr %11, align 4
  br label %219

118:                                              ; preds = %98
  %119 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 0
  %120 = load ptr, ptr %119, align 8, !tbaa !11
  %121 = getelementptr inbounds %struct.iovec, ptr %6, i32 0, i32 0
  %122 = load ptr, ptr %121, align 8, !tbaa !39
  %123 = getelementptr inbounds %struct.iovec, ptr %6, i32 0, i32 1
  %124 = load i64, ptr %123, align 8, !tbaa !40
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %120, ptr align 1 %122, i64 %124, i1 false)
  %125 = getelementptr inbounds %struct.iovec, ptr %6, i32 0, i32 0
  store ptr %120, ptr %125, align 8, !tbaa !39
  %126 = load ptr, ptr %7, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.MDBX_txn, ptr %126, i32 0, i32 14
  %128 = load ptr, ptr %127, align 8, !tbaa !41
  %129 = getelementptr inbounds ptr, ptr %128, i64 1
  %130 = load ptr, ptr %129, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.cursor_couple, ptr %12, i32 0, i32 0
  %132 = getelementptr inbounds %struct.MDBX_cursor, ptr %131, i32 0, i32 11
  store ptr %130, ptr %132, align 8, !tbaa !42
  %133 = getelementptr inbounds %struct.cursor_couple, ptr %12, i32 0, i32 0
  %134 = load ptr, ptr %7, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.MDBX_txn, ptr %134, i32 0, i32 14
  %136 = load ptr, ptr %135, align 8, !tbaa !41
  %137 = getelementptr inbounds ptr, ptr %136, i64 1
  store ptr %133, ptr %137, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #7
  %138 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 0
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.MDBX_txn, ptr %139, i32 0, i32 10
  %141 = load ptr, ptr %140, align 8, !tbaa !47
  %142 = load i32, ptr %8, align 4, !tbaa !9
  %143 = zext i32 %142 to i64
  %144 = getelementptr inbounds %struct.tree, ptr %141, i64 %143
  store ptr %144, ptr %138, align 8, !tbaa !39
  %145 = getelementptr inbounds %struct.iovec, ptr %14, i32 0, i32 1
  store i64 48, ptr %145, align 8, !tbaa !40
  %146 = getelementptr inbounds %struct.cursor_couple, ptr %12, i32 0, i32 0
  %147 = call i32 @cursor_put_checklen(ptr noundef %146, ptr noundef %6, ptr noundef %14, i32 noundef 18)
  %148 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  store i32 %147, ptr %148, align 8, !tbaa !13
  %149 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  %150 = load i32, ptr %149, align 8, !tbaa !13
  %151 = icmp eq i32 %150, 0
  %152 = xor i1 %151, true
  %153 = xor i1 %152, true
  %154 = zext i1 %153 to i32
  %155 = sext i32 %154 to i64
  %156 = call i64 @llvm.expect.i64(i64 %155, i64 1)
  %157 = icmp ne i64 %156, 0
  br i1 %157, label %158, label %211

158:                                              ; preds = %118
  %159 = getelementptr inbounds %struct.cursor_couple, ptr %12, i32 0, i32 0
  %160 = call i64 @cursor_seek(ptr noundef %159, ptr noundef %10, ptr noundef null, i32 noundef 15)
  store i64 %160, ptr %15, align 4
  %161 = getelementptr inbounds %struct.cursor_set_result, ptr %15, i32 0, i32 0
  %162 = load i32, ptr %161, align 4, !tbaa !37
  %163 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  store i32 %162, ptr %163, align 8, !tbaa !13
  %164 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  %165 = load i32, ptr %164, align 8, !tbaa !13
  %166 = icmp eq i32 %165, 0
  %167 = xor i1 %166, true
  %168 = xor i1 %167, true
  %169 = zext i1 %168 to i32
  %170 = sext i32 %169 to i64
  %171 = call i64 @llvm.expect.i64(i64 %170, i64 1)
  %172 = icmp ne i64 %171, 0
  br i1 %172, label %173, label %177

173:                                              ; preds = %158
  %174 = getelementptr inbounds %struct.cursor_couple, ptr %12, i32 0, i32 0
  %175 = call i32 @cursor_del(ptr noundef %174, i32 noundef 2)
  %176 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  store i32 %175, ptr %176, align 8, !tbaa !13
  br label %177

177:                                              ; preds = %173, %158
  %178 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 1
  %179 = load i32, ptr %178, align 8, !tbaa !13
  %180 = icmp eq i32 %179, 0
  %181 = xor i1 %180, true
  %182 = xor i1 %181, true
  %183 = zext i1 %182 to i32
  %184 = sext i32 %183 to i64
  %185 = call i64 @llvm.expect.i64(i64 %184, i64 1)
  %186 = icmp ne i64 %185, 0
  br i1 %186, label %187, label %205

187:                                              ; preds = %177
  %188 = load ptr, ptr %9, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.MDBX_env, ptr %188, i32 0, i32 25
  %190 = load ptr, ptr %189, align 8, !tbaa !20
  %191 = load i32, ptr %8, align 4, !tbaa !9
  %192 = zext i32 %191 to i64
  %193 = getelementptr inbounds %struct.kvx, ptr %190, i64 %192
  %194 = getelementptr inbounds %struct.kvx, ptr %193, i32 0, i32 1
  %195 = getelementptr inbounds %struct.iovec, ptr %194, i32 0, i32 0
  %196 = load ptr, ptr %195, align 8, !tbaa !48
  %197 = getelementptr inbounds %struct.dbi_rename_result, ptr %5, i32 0, i32 0
  store ptr %196, ptr %197, align 8, !tbaa !11
  %198 = load ptr, ptr %9, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.MDBX_env, ptr %198, i32 0, i32 25
  %200 = load ptr, ptr %199, align 8, !tbaa !20
  %201 = load i32, ptr %8, align 4, !tbaa !9
  %202 = zext i32 %201 to i64
  %203 = getelementptr inbounds %struct.kvx, ptr %200, i64 %202
  %204 = getelementptr inbounds %struct.kvx, ptr %203, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %204, ptr align 8 %6, i64 16, i1 false), !tbaa.struct !30
  br label %210

205:                                              ; preds = %177
  %206 = load ptr, ptr %7, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.MDBX_txn, ptr %206, i32 0, i32 1
  %208 = load i32, ptr %207, align 4, !tbaa !49
  %209 = or i32 %208, 2
  store i32 %209, ptr %207, align 4, !tbaa !49
  br label %210

210:                                              ; preds = %205, %187
  br label %211

211:                                              ; preds = %210, %118
  %212 = getelementptr inbounds %struct.cursor_couple, ptr %12, i32 0, i32 0
  %213 = getelementptr inbounds %struct.MDBX_cursor, ptr %212, i32 0, i32 11
  %214 = load ptr, ptr %213, align 8, !tbaa !42
  %215 = load ptr, ptr %7, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.MDBX_txn, ptr %215, i32 0, i32 14
  %217 = load ptr, ptr %216, align 8, !tbaa !41
  %218 = getelementptr inbounds ptr, ptr %217, i64 1
  store ptr %214, ptr %218, align 8, !tbaa !5
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #7
  br label %219

219:                                              ; preds = %211, %116, %95, %71
  call void @llvm.lifetime.end.p0(i64 824, ptr %12) #7
  br label %220

220:                                              ; preds = %219, %56
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %221

221:                                              ; preds = %220, %33
  %222 = load { ptr, i32 }, ptr %5, align 8
  ret { ptr, i32 } %222
}

declare i32 @cursor_init(ptr noundef, ptr noundef, i64 noundef) #5

declare i64 @cursor_seek(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #5

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @dbi_namelen(ptr, i64) #2

declare i32 @cursor_put_checklen(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #5

declare i32 @cursor_del(ptr noundef, i32 noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { cold nounwind optsize 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 = { "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 = { 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 #7 = { nounwind }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"dbi_rename_result", !6, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = !{!15, !6, i64 80}
!15 = !{!"MDBX_txn", !10, i64 0, !10, i64 4, !16, i64 8, !16, i64 16, !6, i64 24, !6, i64 32, !17, i64 40, !16, i64 64, !16, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !19, i64 128, !6, i64 160, !7, i64 168}
!16 = !{!"long", !7, i64 0}
!17 = !{!"geo", !18, i64 0, !18, i64 2, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 16}
!18 = !{!"short", !7, i64 0}
!19 = !{!"MDBX_canary", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24}
!20 = !{!21, !6, i64 200}
!21 = !{!"MDBX_env", !7, i64 0, !10, i64 4, !10, i64 8, !22, i64 16, !10, i64 56, !10, i64 60, !22, i64 64, !6, i64 104, !18, i64 112, !18, i64 114, !18, i64 116, !18, i64 118, !18, i64 120, !18, i64 122, !7, i64 124, !7, i64 128, !7, i64 129, !18, i64 130, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !23, i64 152, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !10, i64 228, !10, i64 232, !6, i64 240, !6, i64 248, !16, i64 256, !24, i64 264, !27, i64 320, !25, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !28, i64 392, !7, i64 400, !10, i64 440, !10, i64 444, !6, i64 448, !29, i64 456, !7, i64 496, !7, i64 536}
!22 = !{!"osal_mmap", !7, i64 0, !10, i64 8, !16, i64 16, !16, i64 24, !16, i64 32}
!23 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!24 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !16, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !10, i64 28, !10, i64 32, !25, i64 36, !25, i64 37, !25, i64 38, !26, i64 40, !7, i64 48}
!25 = !{!"_Bool", !7, i64 0}
!26 = !{!"", !18, i64 0, !18, i64 2, !18, i64 4, !18, i64 6}
!27 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32}
!28 = !{!"", !16, i64 0}
!29 = !{!"osal_ioring", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!30 = !{i64 0, i64 8, !5, i64 8, i64 8, !31}
!31 = !{!16, !16, i64 0}
!32 = !{!33, !6, i64 0}
!33 = !{!"kvx", !34, i64 0, !36, i64 48}
!34 = !{!"clc2", !35, i64 0, !35, i64 24}
!35 = !{!"clc", !6, i64 0, !16, i64 8, !16, i64 16}
!36 = !{!"iovec", !6, i64 0, !16, i64 8}
!37 = !{!38, !10, i64 0}
!38 = !{!"cursor_set_result", !10, i64 0, !25, i64 4}
!39 = !{!36, !6, i64 0}
!40 = !{!36, !16, i64 8}
!41 = !{!15, !6, i64 120}
!42 = !{!43, !6, i64 368}
!43 = !{!"cursor_couple", !44, i64 0, !6, i64 384, !45, i64 392}
!44 = !{!"MDBX_cursor", !10, 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}
!45 = !{!"inner_cursor", !44, i64 0, !46, i64 384}
!46 = !{!"tree", !18, i64 0, !18, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !16, i64 24, !16, i64 32, !16, i64 40}
!47 = !{!15, !6, i64 88}
!48 = !{!33, !6, i64 48}
!49 = !{!15, !10, i64 4}


; 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.iovec = type { ptr, i64 }
%struct.cursor_couple = type { %struct.MDBX_cursor, ptr, %struct.inner_cursor }
%struct.MDBX_cursor = type { i32, %union.anon.16, i8, i8, ptr, ptr, ptr, ptr, ptr, [32 x ptr], [32 x i16], ptr, ptr }
%union.anon.16 = type { i16 }
%struct.inner_cursor = type { %struct.MDBX_cursor, %struct.tree }
%struct.tree = type { i16, i16, i32, i32, i32, i32, i32, i64, i64, i64 }
%struct.kvx = type { %struct.clc2, %struct.iovec }
%struct.clc2 = type { %struct.clc, %struct.clc }
%struct.clc = type { ptr, i64, i64 }

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

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

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

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

; Function Attrs: cold nounwind optsize uwtable
define dso_local { ptr, i32 } @dbi_rename_locked(ptr noundef %0, i32 noundef %1, ptr %2, i64 %3) local_unnamed_addr #3 {
  %5 = alloca %struct.iovec, align 8
  %6 = alloca %struct.iovec, align 8
  %7 = alloca %struct.cursor_couple, align 8
  %8 = alloca %struct.iovec, align 8
  store ptr %2, ptr %5, align 8
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  store i64 %3, ptr %9, align 8
  %10 = zext i32 %1 to i64
  %11 = tail call i32 @dbi_check(ptr noundef %0, i64 noundef %10)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %64, !prof !5

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %0, i64 80
  %14 = load ptr, ptr %13, align 8, !tbaa !6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  %15 = getelementptr inbounds i8, ptr %14, i64 200
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = getelementptr inbounds %struct.kvx, ptr %16, i64 %10, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %17, i64 16, i1 false), !tbaa.struct !26
  %18 = getelementptr inbounds i8, ptr %16, i64 64
  %19 = load ptr, ptr %18, align 8, !tbaa !29
  %20 = call i32 %19(ptr noundef nonnull %5, ptr noundef nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 824, ptr nonnull %7) #6
  %21 = call i32 @cursor_init(ptr noundef nonnull %7, ptr noundef %0, i64 noundef 1) #6
  %.not30 = icmp eq i32 %21, 0
  br i1 %.not30, label %22, label %63, !prof !5

22:                                               ; preds = %12
  %23 = call i64 @cursor_seek(ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef null, i32 noundef 15) #6
  %.sroa.01.0.extract.trunc = trunc i64 %23 to i32
  %.not31 = icmp eq i32 %.sroa.01.0.extract.trunc, -30798
  br i1 %.not31, label %27, label %24, !prof !5

24:                                               ; preds = %22
  %25 = icmp eq i32 %.sroa.01.0.extract.trunc, 0
  %26 = select i1 %25, i32 -30799, i32 %.sroa.01.0.extract.trunc
  br label %63

27:                                               ; preds = %22
  %28 = load ptr, ptr %5, align 8
  %29 = load i64, ptr %9, align 8
  %30 = call i64 @dbi_namelen(ptr %28, i64 %29)
  %31 = call noalias ptr @malloc(i64 noundef %30) #7
  %.not32 = icmp eq ptr %31, null
  br i1 %.not32, label %63, label %32, !prof !34

32:                                               ; preds = %27
  %33 = load ptr, ptr %5, align 8, !tbaa !35
  %34 = load i64, ptr %9, align 8, !tbaa !36
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %31, ptr align 1 %33, i64 %34, i1 false)
  store ptr %31, ptr %5, align 8, !tbaa !35
  %35 = getelementptr inbounds i8, ptr %0, i64 120
  %36 = load ptr, ptr %35, align 8, !tbaa !37
  %37 = getelementptr inbounds i8, ptr %36, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !27
  %39 = getelementptr inbounds i8, ptr %7, i64 368
  store ptr %38, ptr %39, align 8, !tbaa !38
  store ptr %7, ptr %37, align 8, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #6
  %40 = getelementptr inbounds i8, ptr %0, i64 88
  %41 = load ptr, ptr %40, align 8, !tbaa !43
  %42 = getelementptr inbounds %struct.tree, ptr %41, i64 %10
  store ptr %42, ptr %8, align 8, !tbaa !35
  %43 = getelementptr inbounds i8, ptr %8, i64 8
  store i64 48, ptr %43, align 8, !tbaa !36
  %44 = call i32 @cursor_put_checklen(ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef nonnull %8, i32 noundef 18) #6
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %59, !prof !5

46:                                               ; preds = %32
  %47 = call i64 @cursor_seek(ptr noundef nonnull %7, ptr noundef nonnull %6, ptr noundef null, i32 noundef 15) #6
  %.sroa.0.0.extract.trunc = trunc i64 %47 to i32
  %48 = icmp eq i32 %.sroa.0.0.extract.trunc, 0
  br i1 %48, label %49, label %.thread, !prof !5

49:                                               ; preds = %46
  %50 = call i32 @cursor_del(ptr noundef nonnull %7, i32 noundef 2) #6
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %.thread, !prof !44

52:                                               ; preds = %49
  %53 = load ptr, ptr %15, align 8, !tbaa !16
  %54 = getelementptr inbounds %struct.kvx, ptr %53, i64 %10, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !45
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %54, ptr noundef nonnull align 8 dereferenceable(16) %5, i64 16, i1 false), !tbaa.struct !26
  br label %59

.thread:                                          ; preds = %46, %49
  %.sroa.6.034 = phi i32 [ %50, %49 ], [ %.sroa.0.0.extract.trunc, %46 ]
  %56 = getelementptr inbounds i8, ptr %0, i64 4
  %57 = load i32, ptr %56, align 4, !tbaa !46
  %58 = or i32 %57, 2
  store i32 %58, ptr %56, align 4, !tbaa !46
  br label %59

59:                                               ; preds = %52, %.thread, %32
  %.sroa.018.0 = phi ptr [ %55, %52 ], [ %31, %.thread ], [ %31, %32 ]
  %.sroa.6.1 = phi i32 [ 0, %52 ], [ %.sroa.6.034, %.thread ], [ %44, %32 ]
  %60 = load ptr, ptr %39, align 8, !tbaa !38
  %61 = load ptr, ptr %35, align 8, !tbaa !37
  %62 = getelementptr inbounds i8, ptr %61, i64 8
  store ptr %60, ptr %62, align 8, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #6
  br label %63

63:                                               ; preds = %27, %12, %59, %24
  %.sroa.018.1 = phi ptr [ null, %24 ], [ %.sroa.018.0, %59 ], [ null, %12 ], [ null, %27 ]
  %.sroa.6.2 = phi i32 [ %26, %24 ], [ %.sroa.6.1, %59 ], [ %21, %12 ], [ 12, %27 ]
  call void @llvm.lifetime.end.p0(i64 824, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  br label %64

64:                                               ; preds = %4, %63
  %.sroa.018.2 = phi ptr [ null, %4 ], [ %.sroa.018.1, %63 ]
  %.sroa.6.3 = phi i32 [ %11, %4 ], [ %.sroa.6.2, %63 ]
  %.fca.0.insert = insertvalue { ptr, i32 } poison, ptr %.sroa.018.2, 0
  %.fca.1.insert = insertvalue { ptr, i32 } %.fca.0.insert, i32 %.sroa.6.3, 1
  ret { ptr, i32 } %.fca.1.insert
}

declare i32 @cursor_init(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare i64 @cursor_seek(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { cold nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!7, !12, i64 80}
!7 = !{!"MDBX_txn", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !13, i64 40, !11, i64 64, !11, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !15, i64 128, !12, i64 160, !9, i64 168}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"geo", !14, i64 0, !14, i64 2, !8, i64 4, !8, i64 8, !9, i64 12, !9, i64 16}
!14 = !{!"short", !9, i64 0}
!15 = !{!"MDBX_canary", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!16 = !{!17, !12, i64 200}
!17 = !{!"MDBX_env", !9, i64 0, !8, i64 4, !8, i64 8, !18, i64 16, !8, i64 56, !8, i64 60, !18, i64 64, !12, i64 104, !14, i64 112, !14, i64 114, !14, i64 116, !14, i64 118, !14, i64 120, !14, i64 122, !9, i64 124, !9, i64 128, !9, i64 129, !14, i64 130, !8, i64 132, !8, i64 136, !8, i64 140, !8, i64 144, !19, i64 152, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !8, i64 224, !8, i64 228, !8, i64 232, !12, i64 240, !12, i64 248, !11, i64 256, !20, i64 264, !23, i64 320, !21, i64 360, !12, i64 368, !12, i64 376, !12, i64 384, !24, i64 392, !9, i64 400, !8, i64 440, !8, i64 444, !12, i64 448, !25, i64 456, !9, i64 496, !9, i64 536}
!18 = !{!"osal_mmap", !9, i64 0, !8, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!19 = !{!"", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!20 = !{!"", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !11, i64 16, !9, i64 24, !9, i64 25, !9, i64 26, !9, i64 27, !8, i64 28, !8, i64 32, !21, i64 36, !21, i64 37, !21, i64 38, !22, i64 40, !9, i64 48}
!21 = !{!"_Bool", !9, i64 0}
!22 = !{!"", !14, i64 0, !14, i64 2, !14, i64 4, !14, i64 6}
!23 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!24 = !{!"", !11, i64 0}
!25 = !{!"osal_ioring", !8, i64 0, !8, i64 4, !8, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!26 = !{i64 0, i64 8, !27, i64 8, i64 8, !28}
!27 = !{!12, !12, i64 0}
!28 = !{!11, !11, i64 0}
!29 = !{!30, !12, i64 0}
!30 = !{!"kvx", !31, i64 0, !33, i64 48}
!31 = !{!"clc2", !32, i64 0, !32, i64 24}
!32 = !{!"clc", !12, i64 0, !11, i64 8, !11, i64 16}
!33 = !{!"iovec", !12, i64 0, !11, i64 8}
!34 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!35 = !{!33, !12, i64 0}
!36 = !{!33, !11, i64 8}
!37 = !{!7, !12, i64 120}
!38 = !{!39, !12, i64 368}
!39 = !{!"cursor_couple", !40, i64 0, !12, i64 384, !41, i64 392}
!40 = !{!"MDBX_cursor", !8, i64 0, !9, i64 4, !9, i64 6, !9, i64 7, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !9, i64 48, !9, i64 304, !12, i64 368, !12, i64 376}
!41 = !{!"inner_cursor", !40, i64 0, !42, i64 384}
!42 = !{!"tree", !14, i64 0, !14, i64 2, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !11, i64 24, !11, i64 32, !11, i64 40}
!43 = !{!7, !12, i64 88}
!44 = !{!"branch_weights", !"expected", i32 -2147483648, i32 0}
!45 = !{!30, !12, i64 48}
!46 = !{!7, !8, i64 4}


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