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

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden i64 @unaligned_peek_u64(i64 noundef, ptr noalias noundef) #2

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare hidden i32 @unaligned_peek_u32(i64 noundef, ptr noalias noundef) #2

; Function Attrs: alwaysinline nounwind willreturn memory(read) uwtable
declare hidden i32 @tail3le(ptr noundef, i64 noundef) #3

; Function Attrs: hot nounwind willreturn memory(read) uwtable
define dso_local zeroext i1 @eq_fast_slowpath(ptr noundef %0, ptr noundef %1, i64 noundef %2) #4 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %8 = load i64, ptr %7, align 8, !tbaa !9
  %9 = icmp ugt i64 %8, 3
  %10 = xor i1 %9, true
  %11 = xor i1 %10, true
  %12 = zext i1 %11 to i32
  %13 = sext i32 %12 to i64
  %14 = call i64 @llvm.expect.i64(i64 %13, i64 1)
  %15 = icmp ne i64 %14, 0
  br i1 %15, label %16, label %78

16:                                               ; preds = %3
  %17 = load i64, ptr %7, align 8, !tbaa !9
  %18 = icmp ult i64 %17, 9
  %19 = xor i1 %18, true
  %20 = xor i1 %19, true
  %21 = zext i1 %20 to i32
  %22 = sext i32 %21 to i64
  %23 = call i64 @llvm.expect.i64(i64 %22, i64 1)
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %44

25:                                               ; preds = %16
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call i32 @unaligned_peek_u32(i64 noundef 1, ptr noundef %26) #5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call i32 @unaligned_peek_u32(i64 noundef 1, ptr noundef %28) #5
  %30 = sub i32 %27, %29
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load i64, ptr %7, align 8, !tbaa !9
  %33 = getelementptr inbounds i8, ptr %31, i64 %32
  %34 = getelementptr inbounds i8, ptr %33, i64 -4
  %35 = call i32 @unaligned_peek_u32(i64 noundef 1, ptr noundef %34) #5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i64, ptr %7, align 8, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  %39 = getelementptr inbounds i8, ptr %38, i64 -4
  %40 = call i32 @unaligned_peek_u32(i64 noundef 1, ptr noundef %39) #5
  %41 = sub i32 %35, %40
  %42 = or i32 %30, %41
  %43 = icmp eq i32 %42, 0
  store i1 %43, ptr %4, align 1
  br label %96

44:                                               ; preds = %16
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = icmp ult i64 %45, 17
  %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 %72

53:                                               ; preds = %44
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = call i64 @unaligned_peek_u64(i64 noundef 1, ptr noundef %54) #5
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = call i64 @unaligned_peek_u64(i64 noundef 1, ptr noundef %56) #5
  %58 = sub i64 %55, %57
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load i64, ptr %7, align 8, !tbaa !9
  %61 = getelementptr inbounds i8, ptr %59, i64 %60
  %62 = getelementptr inbounds i8, ptr %61, i64 -8
  %63 = call i64 @unaligned_peek_u64(i64 noundef 1, ptr noundef %62) #5
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load i64, ptr %7, align 8, !tbaa !9
  %66 = getelementptr inbounds i8, ptr %64, i64 %65
  %67 = getelementptr inbounds i8, ptr %66, i64 -8
  %68 = call i64 @unaligned_peek_u64(i64 noundef 1, ptr noundef %67) #5
  %69 = sub i64 %63, %68
  %70 = or i64 %58, %69
  %71 = icmp eq i64 %70, 0
  store i1 %71, ptr %4, align 1
  br label %96

72:                                               ; preds = %44
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = load i64, ptr %7, align 8, !tbaa !9
  %76 = call i32 @memcmp(ptr noundef %73, ptr noundef %74, i64 noundef %75) #5
  %77 = icmp eq i32 %76, 0
  store i1 %77, ptr %4, align 1
  br label %96

78:                                               ; preds = %3
  %79 = load i64, ptr %7, align 8, !tbaa !9
  %80 = icmp ne i64 %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 %95

87:                                               ; preds = %78
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = load i64, ptr %7, align 8, !tbaa !9
  %90 = call i32 @tail3le(ptr noundef %88, i64 noundef %89) #5
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load i64, ptr %7, align 8, !tbaa !9
  %93 = call i32 @tail3le(ptr noundef %91, i64 noundef %92) #5
  %94 = icmp eq i32 %90, %93
  store i1 %94, ptr %4, align 1
  br label %96

95:                                               ; preds = %78
  store i1 true, ptr %4, align 1
  br label %96

96:                                               ; preds = %95, %87, %72, %53, %25
  %97 = load i1, ptr %4, align 1
  ret i1 %97
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #1 = { nounwind willreturn memory(read) "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 = { 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 #3 = { alwaysinline 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 = { hot 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 #5 = { nounwind willreturn memory(read) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, 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"

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden i64 @unaligned_peek_u64(i64 noundef, ptr noalias noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden i32 @unaligned_peek_u32(i64 noundef, ptr noalias noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline mustprogress nofree nounwind willreturn memory(read) uwtable
declare hidden i32 @tail3le(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: hot mustprogress nofree nounwind willreturn memory(read) uwtable
define dso_local zeroext i1 @eq_fast_slowpath(ptr noundef readonly %0, ptr noundef readonly %1, i64 noundef %2) local_unnamed_addr #2 {
  %4 = icmp ugt i64 %2, 3
  br i1 %4, label %5, label %35, !prof !5

5:                                                ; preds = %3
  %6 = icmp ult i64 %2, 9
  br i1 %6, label %7, label %19, !prof !5

7:                                                ; preds = %5
  %8 = tail call i32 @unaligned_peek_u32(i64 noundef 1, ptr noundef %0) #4
  %9 = tail call i32 @unaligned_peek_u32(i64 noundef 1, ptr noundef %1) #4
  %10 = getelementptr inbounds i8, ptr %0, i64 %2
  %11 = getelementptr inbounds i8, ptr %10, i64 -4
  %12 = tail call i32 @unaligned_peek_u32(i64 noundef 1, ptr noundef nonnull %11) #4
  %13 = getelementptr inbounds i8, ptr %1, i64 %2
  %14 = getelementptr inbounds i8, ptr %13, i64 -4
  %15 = tail call i32 @unaligned_peek_u32(i64 noundef 1, ptr noundef nonnull %14) #4
  %16 = icmp eq i32 %8, %9
  %17 = icmp eq i32 %12, %15
  %18 = and i1 %16, %17
  br label %40

19:                                               ; preds = %5
  %20 = icmp ult i64 %2, 17
  br i1 %20, label %21, label %33, !prof !5

21:                                               ; preds = %19
  %22 = tail call i64 @unaligned_peek_u64(i64 noundef 1, ptr noundef %0) #4
  %23 = tail call i64 @unaligned_peek_u64(i64 noundef 1, ptr noundef %1) #4
  %24 = getelementptr inbounds i8, ptr %0, i64 %2
  %25 = getelementptr inbounds i8, ptr %24, i64 -8
  %26 = tail call i64 @unaligned_peek_u64(i64 noundef 1, ptr noundef nonnull %25) #4
  %27 = getelementptr inbounds i8, ptr %1, i64 %2
  %28 = getelementptr inbounds i8, ptr %27, i64 -8
  %29 = tail call i64 @unaligned_peek_u64(i64 noundef 1, ptr noundef nonnull %28) #4
  %30 = icmp eq i64 %22, %23
  %31 = icmp eq i64 %26, %29
  %32 = and i1 %30, %31
  br label %40

33:                                               ; preds = %19
  %bcmp = tail call i32 @bcmp(ptr %0, ptr %1, i64 %2)
  %34 = icmp eq i32 %bcmp, 0
  br label %40

35:                                               ; preds = %3
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %40, label %36, !prof !6

36:                                               ; preds = %35
  %37 = tail call i32 @tail3le(ptr noundef %0, i64 noundef %2) #4
  %38 = tail call i32 @tail3le(ptr noundef %1, i64 noundef %2) #4
  %39 = icmp eq i32 %37, %38
  br label %40

40:                                               ; preds = %35, %36, %33, %21, %7
  %.0 = phi i1 [ %18, %7 ], [ %32, %21 ], [ %34, %33 ], [ %39, %36 ], [ true, %35 ]
  ret i1 %.0
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!6 = !{!"branch_weights", !"expected", i32 1, i32 2000}


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