; LLVM IR from Water-Melon/Melon :: src (mln_hash)

; 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.mln_hash_s = type { ptr, i64, ptr, ptr, ptr, ptr, i32, i32, i8, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.mln_hash_mgr_s = type { ptr, ptr }
%struct.mln_hash_entry_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32 }

; 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: inlinehint nounwind uwtable
declare hidden void @mln_hash_entry_free(ptr noundef nonnull, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @mln_hash_remove(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.mln_hash_s, ptr %11, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call i64 %13(ptr noundef %14, ptr noundef %15)
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mln_hash_s, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds %struct.mln_hash_mgr_s, ptr %20, i64 %22
  store ptr %23, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mln_hash_mgr_s, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  store ptr %26, ptr %9, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %43, %3
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %47

30:                                               ; preds = %27
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mln_hash_s, ptr %31, i32 0, i32 3
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mln_hash_entry_s, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = call i32 %33(ptr noundef %34, ptr noundef %35, ptr noundef %38)
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %30
  br label %47

42:                                               ; preds = %30
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mln_hash_entry_s, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !20
  store ptr %46, ptr %9, align 8, !tbaa !5
  br label %27, !llvm.loop !21

47:                                               ; preds = %41, %27
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  store i32 1, ptr %10, align 4
  br label %84

51:                                               ; preds = %47
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.mln_hash_s, ptr %52, i32 0, i32 14
  %54 = load ptr, ptr %53, align 8, !tbaa !23
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = icmp eq ptr %54, %55
  br i1 %56, label %57, label %66

57:                                               ; preds = %51
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.mln_hash_entry_s, ptr %59, i32 0, i32 7
  store i32 %58, ptr %60, align 8, !tbaa !24
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.mln_hash_entry_s, ptr %61, i32 0, i32 8
  %63 = load i32, ptr %62, align 4
  %64 = and i32 %63, -2
  %65 = or i32 %64, 1
  store i32 %65, ptr %62, align 4
  store i32 1, ptr %10, align 4
  br label %84

66:                                               ; preds = %51
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.mln_hash_mgr_s, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.mln_hash_mgr_s, ptr %69, i32 0, i32 1
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  call void @mln_hash_entry_chain_del(ptr noundef %68, ptr noundef %70, ptr noundef %71)
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mln_hash_s, ptr %72, i32 0, i32 12
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.mln_hash_s, ptr %74, i32 0, i32 13
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  call void @mln_hash_entry_iter_chain_del(ptr noundef %73, ptr noundef %75, ptr noundef %76)
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.mln_hash_s, ptr %77, i32 0, i32 6
  %79 = load i32, ptr %78, align 8, !tbaa !25
  %80 = add i32 %79, -1
  store i32 %80, ptr %78, align 8, !tbaa !25
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = load i32, ptr %6, align 4, !tbaa !9
  call void @mln_hash_entry_free(ptr noundef %81, ptr noundef %82, i32 noundef %83)
  store i32 0, ptr %10, align 4
  br label %84

84:                                               ; preds = %66, %57, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %85 = load i32, ptr %10, align 4
  switch i32 %85, label %87 [
    i32 0, label %86
    i32 1, label %86
  ]

86:                                               ; preds = %84, %84
  ret void

87:                                               ; preds = %84
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_hash_entry_chain_del(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_hash_entry_iter_chain_del(ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { 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 = { 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 = { 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 = !{!12, !6, i64 16}
!12 = !{!"mln_hash_s", !6, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"mln_hash_mgr_s", !6, i64 0, !6, i64 8}
!17 = !{!12, !6, i64 24}
!18 = !{!19, !6, i64 24}
!19 = !{!"mln_hash_entry_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 60}
!20 = !{!19, !6, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!12, !6, i64 104}
!24 = !{!19, !10, i64 56}
!25 = !{!12, !10, i64 48}


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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_hash_entry_free(ptr noundef nonnull, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @mln_hash_remove(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call i64 %5(ptr noundef nonnull %0, ptr noundef nonnull %1) #2
  %7 = load ptr, ptr %0, align 8, !tbaa !12
  %8 = and i64 %6, 4294967295
  %9 = getelementptr inbounds %struct.mln_hash_mgr_s, ptr %7, i64 %8
  %.029 = load ptr, ptr %9, align 8, !tbaa !13
  %cond30 = icmp eq ptr %.029, null
  br i1 %cond30, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  br label %11

11:                                               ; preds = %.lr.ph, %16
  %.031 = phi ptr [ %.029, %.lr.ph ], [ %.0, %16 ]
  %12 = load ptr, ptr %10, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %.031, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = tail call i32 %12(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %14) #2
  %.not27 = icmp eq i32 %15, 0
  br i1 %.not27, label %16, label %18

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %.031, i64 8
  %.0 = load ptr, ptr %17, align 8, !tbaa !13
  %cond = icmp eq ptr %.0, null
  br i1 %cond, label %.loopexit, label %11, !llvm.loop !17

18:                                               ; preds = %11
  %19 = getelementptr inbounds i8, ptr %0, i64 104
  %20 = load ptr, ptr %19, align 8, !tbaa !19
  %21 = icmp eq ptr %20, %.031
  br i1 %21, label %22, label %27

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %.031, i64 56
  store i32 %2, ptr %23, align 8, !tbaa !20
  %24 = getelementptr inbounds i8, ptr %.031, i64 60
  %25 = load i32, ptr %24, align 4
  %26 = or i32 %25, 1
  store i32 %26, ptr %24, align 4
  br label %.loopexit

27:                                               ; preds = %18
  %28 = getelementptr inbounds i8, ptr %9, i64 8
  tail call void @mln_hash_entry_chain_del(ptr noundef nonnull %9, ptr noundef nonnull %28, ptr noundef nonnull %.031)
  %29 = getelementptr inbounds i8, ptr %0, i64 88
  %30 = getelementptr inbounds i8, ptr %0, i64 96
  tail call void @mln_hash_entry_iter_chain_del(ptr noundef nonnull %29, ptr noundef nonnull %30, ptr noundef nonnull %.031)
  %31 = getelementptr inbounds i8, ptr %0, i64 48
  %32 = load i32, ptr %31, align 8, !tbaa !21
  %33 = add i32 %32, -1
  store i32 %33, ptr %31, align 8, !tbaa !21
  tail call void @mln_hash_entry_free(ptr noundef %0, ptr noundef nonnull %.031, i32 noundef %2)
  br label %.loopexit

.loopexit:                                        ; preds = %16, %3, %27, %22
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_hash_entry_chain_del(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mln_hash_entry_iter_chain_del(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #1 = { 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, !7, i64 16}
!6 = !{!"mln_hash_s", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 24}
!15 = !{!16, !7, i64 24}
!16 = !{!"mln_hash_entry_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !11, i64 56, !11, i64 60, !11, i64 60}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !7, i64 104}
!20 = !{!16, !11, i64 56}
!21 = !{!6, !11, i64 48}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass