; LLVM IR from begeekmyfriend/CuckooFilter :: cuckoo_filter (cuckoo_filter_get)

; 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.hash_table = type { ptr, ptr, i32, i32 }

@cuckoo_filter_get.value = external hidden global [12 x i8], align 1
@hash_table = external hidden global %struct.hash_table, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @cuckoo_filter_get(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = call i32 @cuckoo_hash_get(ptr noundef @hash_table, ptr noundef %7, ptr noundef %5)
  %9 = icmp ne i32 %8, 1
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %27

11:                                               ; preds = %1
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %23, %11
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 12
  br i1 %14, label %15, label %26

15:                                               ; preds = %12
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load volatile i8, ptr %16, align 1, !tbaa !11
  %18 = load i32, ptr %4, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [12 x i8], ptr @cuckoo_filter_get.value, i64 0, i64 %19
  store i8 %17, ptr %20, align 1, !tbaa !11
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i32 1
  store ptr %22, ptr %5, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %15
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %4, align 4, !tbaa !9
  br label %12, !llvm.loop !12

26:                                               ; preds = %12
  store ptr @cuckoo_filter_get.value, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %27

27:                                               ; preds = %26, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %28 = load ptr, ptr %2, align 8
  ret ptr %28
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @cuckoo_hash_get(ptr noundef, ptr noundef, ptr noundef) #0

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; 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.hash_table = type { ptr, ptr, i32, i32 }

@cuckoo_filter_get.value = external hidden global [12 x i8], align 1
@hash_table = external hidden global %struct.hash_table, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @cuckoo_filter_get(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #2
  %3 = call i32 @cuckoo_hash_get(ptr noundef nonnull @hash_table, ptr noundef %0, ptr noundef nonnull %2)
  %.not = icmp eq i32 %3, 1
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %1
  %.promoted = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load volatile i8, ptr %.promoted, align 1, !tbaa !9
  store i8 %4, ptr @cuckoo_filter_get.value, align 1, !tbaa !9
  %5 = getelementptr inbounds i8, ptr %.promoted, i64 1
  store ptr %5, ptr %2, align 8, !tbaa !5
  %6 = load volatile i8, ptr %5, align 1, !tbaa !9
  store i8 %6, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 1), align 1, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %.promoted, i64 2
  store ptr %7, ptr %2, align 8, !tbaa !5
  %8 = load volatile i8, ptr %7, align 1, !tbaa !9
  store i8 %8, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 2), align 1, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %.promoted, i64 3
  store ptr %9, ptr %2, align 8, !tbaa !5
  %10 = load volatile i8, ptr %9, align 1, !tbaa !9
  store i8 %10, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 3), align 1, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %.promoted, i64 4
  store ptr %11, ptr %2, align 8, !tbaa !5
  %12 = load volatile i8, ptr %11, align 1, !tbaa !9
  store i8 %12, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 4), align 1, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %.promoted, i64 5
  store ptr %13, ptr %2, align 8, !tbaa !5
  %14 = load volatile i8, ptr %13, align 1, !tbaa !9
  store i8 %14, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 5), align 1, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %.promoted, i64 6
  store ptr %15, ptr %2, align 8, !tbaa !5
  %16 = load volatile i8, ptr %15, align 1, !tbaa !9
  store i8 %16, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 6), align 1, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %.promoted, i64 7
  store ptr %17, ptr %2, align 8, !tbaa !5
  %18 = load volatile i8, ptr %17, align 1, !tbaa !9
  store i8 %18, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 7), align 1, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %.promoted, i64 8
  %20 = load volatile i8, ptr %19, align 1, !tbaa !9
  store i8 %20, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 8), align 1, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %.promoted, i64 9
  %22 = load volatile i8, ptr %21, align 1, !tbaa !9
  store i8 %22, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 9), align 1, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %.promoted, i64 10
  %24 = load volatile i8, ptr %23, align 1, !tbaa !9
  store i8 %24, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 10), align 1, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %.promoted, i64 11
  %26 = load volatile i8, ptr %25, align 1, !tbaa !9
  store i8 %26, ptr getelementptr inbounds (i8, ptr @cuckoo_filter_get.value, i64 11), align 1, !tbaa !9
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %1
  %.04 = phi ptr [ null, %1 ], [ @cuckoo_filter_get.value, %.preheader ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #2
  ret ptr %.04
}

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

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

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}


; Effective O3 passes: DSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass