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

; 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_expand(ptr noundef nonnull) #1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_hash_insert(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.mln_hash_s, ptr %12, i32 0, i32 8
  %14 = load i8, ptr %13, align 8
  %15 = and i8 %14, 1
  %16 = zext i8 %15 to i32
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %28

18:                                               ; preds = %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mln_hash_s, ptr %19, i32 0, i32 6
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mln_hash_s, ptr %22, i32 0, i32 7
  %24 = load i32, ptr %23, align 4, !tbaa !13
  %25 = icmp ugt i32 %21, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %18
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mln_hash_expand(ptr noundef %27)
  br label %28

28:                                               ; preds = %26, %18, %3
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mln_hash_s, ptr %29, i32 0, i32 8
  %31 = load i8, ptr %30, align 8
  %32 = and i8 %31, 1
  %33 = zext i8 %32 to i32
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %46

35:                                               ; preds = %28
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mln_hash_s, ptr %36, i32 0, i32 6
  %38 = load i32, ptr %37, align 8, !tbaa !9
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.mln_hash_s, ptr %39, i32 0, i32 7
  %41 = load i32, ptr %40, align 4, !tbaa !13
  %42 = lshr i32 %41, 3
  %43 = icmp ule i32 %38, %42
  br i1 %43, label %44, label %46

44:                                               ; preds = %35
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mln_hash_reduce(ptr noundef %45)
  br label %46

46:                                               ; preds = %44, %35, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.mln_hash_s, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = call i64 %49(ptr noundef %50, ptr noundef %51)
  %53 = trunc i64 %52 to i32
  store i32 %53, ptr %8, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.mln_hash_s, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  %57 = load i32, ptr %8, align 4, !tbaa !15
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds %struct.mln_hash_mgr_s, ptr %56, i64 %58
  store ptr %59, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = call ptr @mln_hash_entry_new(ptr noundef %60, ptr noundef %61, ptr noundef %62, ptr noundef %63)
  store ptr %64, ptr %10, align 8, !tbaa !5
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %46
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %83

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

83:                                               ; preds = %68, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %84 = load i32, ptr %4, align 4
  ret i32 %84
}

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, !12, i64 48}
!10 = !{!"mln_hash_s", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 52}
!14 = !{!10, !6, i64 16}
!15 = !{!12, !12, i64 0}
!16 = !{!10, !6, 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"

%struct.mln_hash_mgr_s = type { ptr, ptr }

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @mln_hash_insert(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  %5 = load i8, ptr %4, align 8
  %6 = and i8 %5, 1
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %.thread, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 52
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %12 = icmp ugt i32 %9, %11
  br i1 %12, label %13, label %.thread30

13:                                               ; preds = %7
  tail call void @mln_hash_expand(ptr noundef %0)
  %.pre = load i8, ptr %4, align 8
  %.pre28 = and i8 %.pre, 1
  %14 = icmp eq i8 %.pre28, 0
  br i1 %14, label %.thread, label %.thread30

.thread30:                                        ; preds = %7, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  %16 = load i32, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 52
  %18 = load i32, ptr %17, align 4, !tbaa !12
  %19 = lshr i32 %18, 3
  %.not27 = icmp ugt i32 %16, %19
  br i1 %.not27, label %.thread, label %20

20:                                               ; preds = %.thread30
  tail call void @mln_hash_reduce(ptr noundef %0)
  br label %.thread

.thread:                                          ; preds = %3, %20, %.thread30, %13
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = tail call i64 %22(ptr noundef nonnull %0, ptr noundef nonnull %1) #2
  %24 = load ptr, ptr %0, align 8, !tbaa !14
  %25 = and i64 %23, 4294967295
  %26 = getelementptr inbounds %struct.mln_hash_mgr_s, ptr %24, i64 %25
  %27 = tail call ptr @mln_hash_entry_new(ptr noundef %0, ptr noundef %26, ptr noundef %1, ptr noundef %2)
  %28 = icmp eq ptr %27, null
  br i1 %28, label %36, label %29

29:                                               ; preds = %.thread
  %30 = getelementptr inbounds i8, ptr %26, i64 8
  tail call void @mln_hash_entry_chain_add(ptr noundef nonnull %26, ptr noundef nonnull %30, ptr noundef nonnull %27)
  %31 = getelementptr inbounds i8, ptr %0, i64 88
  %32 = getelementptr inbounds i8, ptr %0, i64 96
  tail call void @mln_hash_entry_iter_chain_add(ptr noundef nonnull %31, ptr noundef nonnull %32, ptr noundef nonnull %27)
  %33 = getelementptr inbounds i8, ptr %0, i64 48
  %34 = load i32, ptr %33, align 8, !tbaa !5
  %35 = add i32 %34, 1
  store i32 %35, ptr %33, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %.thread, %29
  %.0 = phi i32 [ 0, %29 ], [ -1, %.thread ]
  ret i32 %.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, !11, i64 48}
!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, !11, i64 52}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !7, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass