; LLVM IR from JessonYue/LeetCodeLearning :: Array/zhanchengguo/homework/hashMap/LinkedListHash.ll (Z14hash_deleteKeyP11_hash_tablei)

; 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 { [6 x ptr] }
%struct._hash_node = type { i32, ptr }

; 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(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z14hash_deleteKeyP11_hash_tablei(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %72

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._hash_table, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = srem i32 %15, 6
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [6 x ptr], ptr %14, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %12
  store i1 false, ptr %3, align 1
  br label %72

22:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._hash_table, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = srem i32 %25, 6
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [6 x ptr], ptr %24, i64 0, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  store ptr %29, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %40, %22
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %45

33:                                               ; preds = %30
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._hash_node, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !11
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %33
  br label %45

40:                                               ; preds = %33
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %41, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._hash_node, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  store ptr %44, ptr %6, align 8, !tbaa !5
  br label %30, !llvm.loop !14

45:                                               ; preds = %39, %30
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = icmp eq ptr %46, null
  br i1 %47, label %48, label %58

48:                                               ; preds = %45
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._hash_node, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._hash_table, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = srem i32 %54, 6
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [6 x ptr], ptr %53, i64 0, i64 %56
  store ptr %51, ptr %57, align 8, !tbaa !5
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %71

58:                                               ; preds = %45
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %70

61:                                               ; preds = %58
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %70

64:                                               ; preds = %61
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._hash_node, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._hash_node, ptr %68, i32 0, i32 1
  store ptr %67, ptr %69, align 8, !tbaa !13
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %71

70:                                               ; preds = %61, %58
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %71

71:                                               ; preds = %70, %64, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %72

72:                                               ; preds = %71, %21, %11
  %73 = load i1, ptr %3, align 1
  ret i1 %73
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS10_hash_node", !10, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z14hash_deleteKeyP11_hash_tablei(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %.loopexit, label %4

4:                                                ; preds = %2
  %5 = srem i32 %1, 6
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [6 x ptr], ptr %0, i64 0, i64 %6
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %4
  %10 = load i32, ptr %8, align 8, !tbaa !9
  %11 = icmp eq i32 %10, %1
  br i1 %11, label %.thread, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  %12 = load i32, ptr %15, align 8, !tbaa !9
  %13 = icmp eq i32 %12, %1
  br i1 %13, label %.thread, label %.lr.ph, !llvm.loop !12

.lr.ph:                                           ; preds = %.preheader.preheader, %.preheader
  %.0192736 = phi ptr [ %15, %.preheader ], [ %8, %.preheader.preheader ]
  %14 = getelementptr inbounds i8, ptr %.0192736, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %.loopexit, label %.preheader, !llvm.loop !12

.thread:                                          ; preds = %.preheader, %.preheader.preheader
  %.028.lcssa = phi ptr [ null, %.preheader.preheader ], [ %.0192736, %.preheader ]
  %.01927.lcssa = phi ptr [ %8, %.preheader.preheader ], [ %15, %.preheader ]
  %16 = icmp eq ptr %.028.lcssa, null
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.01927.lcssa, i64 8
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %.028.lcssa, i64 8
  %.sink = select i1 %16, ptr %7, ptr %17
  store ptr %.pre, ptr %.sink, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.thread, %4, %2
  %.1 = phi i1 [ false, %2 ], [ false, %4 ], [ true, %.thread ], [ false, %.lr.ph ]
  ret i1 %.1
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS10_hash_node", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 8}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass