; LLVM IR from erthink/libmdbx :: src (api-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.16 }
%struct.anon.16 = 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.anon = type { i8, i8 }
%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
@__func__.mdbx_cursor_copy = external hidden unnamed_addr constant [17 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [22 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mdbx_cursor_bind(ptr noundef, ptr noundef, i32 noundef) #2

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

declare i32 @cursor_check(ptr noundef, i32 noundef) #4

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden i64 @cursor_dbi(ptr noundef) #5

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

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

19:                                               ; preds = %2
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = call i32 @log_if_error(i32 noundef %20, ptr noundef @__func__.mdbx_cursor_copy, i32 noundef 207)
  store i32 %21, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %236

22:                                               ; preds = %2
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.MDBX_cursor, ptr %23, i32 0, i32 5
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call i64 @cursor_dbi(ptr noundef %27) #9
  %29 = trunc i64 %28 to i32
  %30 = call i32 @mdbx_cursor_bind(ptr noundef %25, ptr noundef %26, i32 noundef %29)
  store i32 %30, ptr %6, align 4, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  %33 = xor i1 %32, true
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = call i64 @llvm.expect.i64(i64 %36, i64 0)
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %22
  %40 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %40, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %236

41:                                               ; preds = %22
  br label %42

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

53:                                               ; preds = %42
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MDBX_cursor, ptr %55, i32 0, i32 6
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.MDBX_cursor, ptr %58, i32 0, i32 6
  %60 = load ptr, ptr %59, align 8, !tbaa !17
  %61 = icmp eq ptr %57, %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 %70

69:                                               ; preds = %54
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.7, ptr noundef @__func__.mdbx_cursor_copy, i32 noundef 213) #10
  unreachable

70:                                               ; preds = %54
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72, %42
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74
  br label %76

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

87:                                               ; preds = %76
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = call i64 @cursor_dbi(ptr noundef %89) #9
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = call i64 @cursor_dbi(ptr noundef %91) #9
  %93 = icmp eq i64 %90, %92
  %94 = xor i1 %93, true
  %95 = xor i1 %94, true
  %96 = xor i1 %95, true
  %97 = zext i1 %96 to i32
  %98 = sext i32 %97 to i64
  %99 = call i64 @llvm.expect.i64(i64 %98, i64 0)
  %100 = icmp ne i64 %99, 0
  br i1 %100, label %101, label %102

101:                                              ; preds = %88
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.8, ptr noundef @__func__.mdbx_cursor_copy, i32 noundef 214) #10
  unreachable

102:                                              ; preds = %88
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  br label %105

105:                                              ; preds = %104, %76
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106
  br label %108

108:                                              ; preds = %218, %107
  br label %109

109:                                              ; preds = %108
  %110 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !13
  %111 = zext i8 %110 to i32
  %112 = and i32 %111, 1
  %113 = icmp ne i32 %112, 0
  %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 1)
  %119 = icmp ne i64 %118, 0
  br i1 %119, label %120, label %140

120:                                              ; preds = %109
  br label %121

121:                                              ; preds = %120
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.MDBX_cursor, ptr %122, i32 0, i32 7
  %124 = load ptr, ptr %123, align 8, !tbaa !18
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.MDBX_cursor, ptr %125, i32 0, i32 7
  %127 = load ptr, ptr %126, align 8, !tbaa !18
  %128 = icmp eq ptr %124, %127
  %129 = xor i1 %128, true
  %130 = xor i1 %129, true
  %131 = xor i1 %130, true
  %132 = zext i1 %131 to i32
  %133 = sext i32 %132 to i64
  %134 = call i64 @llvm.expect.i64(i64 %133, i64 0)
  %135 = icmp ne i64 %134, 0
  br i1 %135, label %136, label %137

136:                                              ; preds = %121
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.9, ptr noundef @__func__.mdbx_cursor_copy, i32 noundef 216) #10
  unreachable

137:                                              ; preds = %121
  br label %138

138:                                              ; preds = %137
  br label %139

139:                                              ; preds = %138
  br label %140

140:                                              ; preds = %139, %109
  br label %141

141:                                              ; preds = %140
  br label %142

142:                                              ; preds = %141
  br label %143

143:                                              ; preds = %142
  %144 = load i8, ptr getelementptr inbounds (%struct.libmdbx_globals, ptr @globals, i32 0, i32 4), align 1, !tbaa !13
  %145 = zext i8 %144 to i32
  %146 = and i32 %145, 1
  %147 = icmp ne i32 %146, 0
  %148 = xor i1 %147, true
  %149 = xor i1 %148, true
  %150 = zext i1 %149 to i32
  %151 = sext i32 %150 to i64
  %152 = call i64 @llvm.expect.i64(i64 %151, i64 1)
  %153 = icmp ne i64 %152, 0
  br i1 %153, label %154, label %174

154:                                              ; preds = %143
  br label %155

155:                                              ; preds = %154
  %156 = load ptr, ptr %5, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.MDBX_cursor, ptr %156, i32 0, i32 5
  %158 = load ptr, ptr %157, align 8, !tbaa !11
  %159 = load ptr, ptr %4, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.MDBX_cursor, ptr %159, i32 0, i32 5
  %161 = load ptr, ptr %160, align 8, !tbaa !11
  %162 = icmp eq ptr %158, %161
  %163 = xor i1 %162, true
  %164 = xor i1 %163, true
  %165 = xor i1 %164, true
  %166 = zext i1 %165 to i32
  %167 = sext i32 %166 to i64
  %168 = call i64 @llvm.expect.i64(i64 %167, i64 0)
  %169 = icmp ne i64 %168, 0
  br i1 %169, label %170, label %171

170:                                              ; preds = %155
  call void @mdbx_assert_fail(ptr noundef null, ptr noundef @.str.10, ptr noundef @__func__.mdbx_cursor_copy, i32 noundef 217) #10
  unreachable

171:                                              ; preds = %155
  br label %172

172:                                              ; preds = %171
  br label %173

173:                                              ; preds = %172
  br label %174

174:                                              ; preds = %173, %143
  br label %175

175:                                              ; preds = %174
  br label %176

176:                                              ; preds = %175
  %177 = load ptr, ptr %4, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.MDBX_cursor, ptr %177, i32 0, i32 1
  %179 = load i16, ptr %178, align 4, !tbaa !19
  %180 = load ptr, ptr %5, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.MDBX_cursor, ptr %180, i32 0, i32 1
  store i16 %179, ptr %181, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  store i64 0, ptr %8, align 8, !tbaa !20
  br label %182

182:                                              ; preds = %210, %176
  %183 = load i64, ptr %8, align 8, !tbaa !20
  %184 = load ptr, ptr %4, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.MDBX_cursor, ptr %184, i32 0, i32 1
  %186 = getelementptr inbounds %struct.anon, ptr %185, i32 0, i32 1
  %187 = load i8, ptr %186, align 1, !tbaa !19
  %188 = sext i8 %187 to i64
  %189 = icmp sle i64 %183, %188
  br i1 %189, label %191, label %190

190:                                              ; preds = %182
  store i32 19, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %213

191:                                              ; preds = %182
  %192 = load ptr, ptr %4, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.MDBX_cursor, ptr %192, i32 0, i32 10
  %194 = load i64, ptr %8, align 8, !tbaa !20
  %195 = getelementptr inbounds [32 x i16], ptr %193, i64 0, i64 %194
  %196 = load i16, ptr %195, align 2, !tbaa !21
  %197 = load ptr, ptr %5, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.MDBX_cursor, ptr %197, i32 0, i32 10
  %199 = load i64, ptr %8, align 8, !tbaa !20
  %200 = getelementptr inbounds [32 x i16], ptr %198, i64 0, i64 %199
  store i16 %196, ptr %200, align 2, !tbaa !21
  %201 = load ptr, ptr %4, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.MDBX_cursor, ptr %201, i32 0, i32 9
  %203 = load i64, ptr %8, align 8, !tbaa !20
  %204 = getelementptr inbounds [32 x ptr], ptr %202, i64 0, i64 %203
  %205 = load ptr, ptr %204, align 8, !tbaa !5
  %206 = load ptr, ptr %5, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.MDBX_cursor, ptr %206, i32 0, i32 9
  %208 = load i64, ptr %8, align 8, !tbaa !20
  %209 = getelementptr inbounds [32 x ptr], ptr %207, i64 0, i64 %208
  store ptr %205, ptr %209, align 8, !tbaa !5
  br label %210

210:                                              ; preds = %191
  %211 = load i64, ptr %8, align 8, !tbaa !20
  %212 = add nsw i64 %211, 1
  store i64 %212, ptr %8, align 8, !tbaa !20
  br label %182, !llvm.loop !23

213:                                              ; preds = %190
  %214 = load ptr, ptr %4, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.MDBX_cursor, ptr %214, i32 0, i32 8
  %216 = load ptr, ptr %215, align 8, !tbaa !25
  %217 = icmp ne ptr %216, null
  br i1 %217, label %218, label %235

218:                                              ; preds = %213
  %219 = load ptr, ptr %5, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.MDBX_cursor, ptr %219, i32 0, i32 8
  %221 = load ptr, ptr %220, align 8, !tbaa !25
  %222 = getelementptr inbounds %struct.inner_cursor, ptr %221, i32 0, i32 1
  %223 = load ptr, ptr %4, align 8, !tbaa !5
  %224 = getelementptr inbounds %struct.MDBX_cursor, ptr %223, i32 0, i32 8
  %225 = load ptr, ptr %224, align 8, !tbaa !25
  %226 = getelementptr inbounds %struct.inner_cursor, ptr %225, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %222, ptr align 8 %226, i64 48, i1 false), !tbaa.struct !26
  %227 = load ptr, ptr %4, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.MDBX_cursor, ptr %227, i32 0, i32 8
  %229 = load ptr, ptr %228, align 8, !tbaa !25
  %230 = getelementptr inbounds %struct.inner_cursor, ptr %229, i32 0, i32 0
  store ptr %230, ptr %4, align 8, !tbaa !5
  %231 = load ptr, ptr %5, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.MDBX_cursor, ptr %231, i32 0, i32 8
  %233 = load ptr, ptr %232, align 8, !tbaa !25
  %234 = getelementptr inbounds %struct.inner_cursor, ptr %233, i32 0, i32 0
  store ptr %234, ptr %5, align 8, !tbaa !5
  br label %108

235:                                              ; preds = %213
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %236

236:                                              ; preds = %235, %39, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #8
  %237 = load i32, ptr %3, align 4
  ret i32 %237
}

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"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}
!13 = !{!14, !7, i64 25}
!14 = !{!"libmdbx_globals", !7, i64 0, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 25, !7, i64 26, !15, i64 27, !10, i64 28, !7, i64 32, !7, i64 40, !16, i64 80, !6, i64 88}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !6, i64 32}
!19 = !{!7, !7, i64 0}
!20 = !{!16, !16, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"short", !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!12, !6, i64 40}
!26 = !{i64 0, i64 2, !21, i64 2, i64 2, !21, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9, i64 20, i64 4, !9, i64 24, i64 8, !20, i64 32, i64 8, !20, i64 40, i64 8, !20}


; 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.16 }
%struct.anon.16 = type { i64, i64 }
%union.logger_union = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@globals = external local_unnamed_addr global %struct.libmdbx_globals, align 8
@__func__.mdbx_cursor_copy = external hidden unnamed_addr constant [17 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mdbx_cursor_bind(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

declare i32 @cursor_check(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden i64 @cursor_dbi(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mdbx_cursor_copy(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @cursor_check(ptr noundef %0, i32 noundef 17) #6
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %6, label %4, !prof !5

4:                                                ; preds = %2
  %5 = tail call i32 @log_if_error(i32 noundef %3, ptr noundef nonnull @__func__.mdbx_cursor_copy, i32 noundef 207)
  br label %.loopexit

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !6
  %9 = tail call i64 @cursor_dbi(ptr noundef %0) #7
  %10 = trunc i64 %9 to i32
  %11 = tail call i32 @mdbx_cursor_bind(ptr noundef %8, ptr noundef %1, i32 noundef %10)
  %.not40 = icmp eq i32 %11, 0
  br i1 %.not40, label %12, label %.loopexit, !prof !5

12:                                               ; preds = %6
  %13 = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !12
  %14 = and i8 %13, 1
  %.not41 = icmp eq i8 %14, 0
  br i1 %.not41, label %.thread.preheader, label %15, !prof !16

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %1, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load ptr, ptr %18, align 8, !tbaa !17
  %.not42 = icmp eq ptr %17, %19
  br i1 %.not42, label %21, label %20, !prof !5

20:                                               ; preds = %15
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.7, ptr noundef nonnull @__func__.mdbx_cursor_copy, i32 noundef 213) #8
  unreachable

21:                                               ; preds = %15
  %22 = tail call i64 @cursor_dbi(ptr noundef nonnull %1) #7
  %23 = tail call i64 @cursor_dbi(ptr noundef nonnull %0) #7
  %.not44 = icmp eq i64 %22, %23
  br i1 %.not44, label %.thread.preheader, label %24, !prof !5

.thread.preheader:                                ; preds = %12, %21
  br label %.thread

24:                                               ; preds = %21
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.8, ptr noundef nonnull @__func__.mdbx_cursor_copy, i32 noundef 214) #8
  unreachable

.thread:                                          ; preds = %.thread.preheader, %60
  %25 = phi i8 [ %.pre, %60 ], [ %13, %.thread.preheader ]
  %.035 = phi ptr [ %65, %60 ], [ %0, %.thread.preheader ]
  %.034 = phi ptr [ %66, %60 ], [ %1, %.thread.preheader ]
  %26 = and i8 %25, 1
  %.not45 = icmp eq i8 %26, 0
  br i1 %.not45, label %.thread51, label %27, !prof !16

27:                                               ; preds = %.thread
  %28 = getelementptr inbounds i8, ptr %.034, i64 32
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %30 = getelementptr inbounds i8, ptr %.035, i64 32
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  %.not46 = icmp eq ptr %29, %31
  br i1 %.not46, label %33, label %32, !prof !5

32:                                               ; preds = %27
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.9, ptr noundef nonnull @__func__.mdbx_cursor_copy, i32 noundef 216) #8
  unreachable

33:                                               ; preds = %27
  %34 = getelementptr inbounds i8, ptr %.034, i64 16
  %35 = load ptr, ptr %34, align 8, !tbaa !6
  %36 = getelementptr inbounds i8, ptr %.035, i64 16
  %37 = load ptr, ptr %36, align 8, !tbaa !6
  %.not48 = icmp eq ptr %35, %37
  br i1 %.not48, label %.thread51, label %38, !prof !5

38:                                               ; preds = %33
  tail call void @mdbx_assert_fail(ptr noundef null, ptr noundef nonnull @.str.10, ptr noundef nonnull @__func__.mdbx_cursor_copy, i32 noundef 217) #8
  unreachable

.thread51:                                        ; preds = %.thread, %33
  %39 = getelementptr inbounds i8, ptr %.035, i64 4
  %40 = load i16, ptr %39, align 4, !tbaa !19
  %41 = getelementptr inbounds i8, ptr %.034, i64 4
  store i16 %40, ptr %41, align 4, !tbaa !19
  %42 = getelementptr inbounds i8, ptr %.035, i64 5
  %43 = load i8, ptr %42, align 1, !tbaa !19
  %.not4952 = icmp slt i8 %43, 0
  br i1 %.not4952, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.thread51
  %44 = getelementptr inbounds i8, ptr %.035, i64 304
  %45 = getelementptr inbounds i8, ptr %.034, i64 304
  %46 = getelementptr inbounds i8, ptr %.035, i64 48
  %47 = getelementptr inbounds i8, ptr %.034, i64 48
  br label %50

._crit_edge:                                      ; preds = %50, %.thread51
  %48 = getelementptr inbounds i8, ptr %.035, i64 40
  %49 = load ptr, ptr %48, align 8, !tbaa !20
  %.not50 = icmp eq ptr %49, null
  br i1 %.not50, label %.loopexit, label %60

50:                                               ; preds = %.lr.ph, %50
  %.053 = phi i64 [ 0, %.lr.ph ], [ %57, %50 ]
  %51 = getelementptr inbounds [32 x i16], ptr %44, i64 0, i64 %.053
  %52 = load i16, ptr %51, align 2, !tbaa !21
  %53 = getelementptr inbounds [32 x i16], ptr %45, i64 0, i64 %.053
  store i16 %52, ptr %53, align 2, !tbaa !21
  %54 = getelementptr inbounds [32 x ptr], ptr %46, i64 0, i64 %.053
  %55 = load ptr, ptr %54, align 8, !tbaa !23
  %56 = getelementptr inbounds [32 x ptr], ptr %47, i64 0, i64 %.053
  store ptr %55, ptr %56, align 8, !tbaa !23
  %57 = add nuw nsw i64 %.053, 1
  %58 = load i8, ptr %42, align 1, !tbaa !19
  %59 = sext i8 %58 to i64
  %.not49.not = icmp slt i64 %.053, %59
  br i1 %.not49.not, label %50, label %._crit_edge, !llvm.loop !24

60:                                               ; preds = %._crit_edge
  %61 = getelementptr inbounds i8, ptr %.034, i64 40
  %62 = load ptr, ptr %61, align 8, !tbaa !20
  %63 = getelementptr inbounds i8, ptr %62, i64 384
  %64 = getelementptr inbounds i8, ptr %49, i64 384
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %63, ptr noundef nonnull align 8 dereferenceable(48) %64, i64 48, i1 false), !tbaa.struct !26
  %65 = load ptr, ptr %48, align 8, !tbaa !20
  %66 = load ptr, ptr %61, align 8, !tbaa !20
  %.pre = load i8, ptr getelementptr inbounds (i8, ptr @globals, i64 25), align 1, !tbaa !12
  br label %.thread

.loopexit:                                        ; preds = %._crit_edge, %6, %4
  %.036 = phi i32 [ %5, %4 ], [ %11, %6 ], [ 0, %._crit_edge ]
  ret i32 %.036
}

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!7, !11, i64 16}
!7 = !{!"MDBX_cursor", !8, i64 0, !9, i64 4, !9, i64 6, !9, i64 7, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !9, i64 48, !9, i64 304, !11, i64 368, !11, i64 376}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!13, !9, i64 25}
!13 = !{!"libmdbx_globals", !9, i64 0, !8, i64 16, !8, i64 20, !9, i64 24, !9, i64 25, !9, i64 26, !14, i64 27, !8, i64 28, !9, i64 32, !9, i64 40, !15, i64 80, !11, i64 88}
!14 = !{!"_Bool", !9, i64 0}
!15 = !{!"long", !9, i64 0}
!16 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!17 = !{!7, !11, i64 24}
!18 = !{!7, !11, i64 32}
!19 = !{!9, !9, i64 0}
!20 = !{!7, !11, i64 40}
!21 = !{!22, !22, i64 0}
!22 = !{!"short", !9, i64 0}
!23 = !{!11, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{i64 0, i64 2, !21, i64 2, i64 2, !21, i64 4, i64 4, !27, i64 8, i64 4, !27, i64 12, i64 4, !27, i64 16, i64 4, !27, i64 20, i64 4, !27, i64 24, i64 8, !28, i64 32, i64 8, !28, i64 40, i64 8, !28}
!27 = !{!8, !8, i64 0}
!28 = !{!15, !15, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass