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

declare i32 @mln_prime_generate(i32 noundef) #0

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

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

; Function Attrs: nounwind uwtable
define dso_local ptr @mln_hash_new_fast(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4, i32 noundef %5, i32 noundef %6) #5 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store i64 %4, ptr %13, align 8, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !11
  store i32 %6, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %18 = call noalias ptr @malloc(i64 noundef 112) #7
  store ptr %18, ptr %16, align 8, !tbaa !5
  %19 = load ptr, ptr %16, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %7
  store ptr null, ptr %8, align 8
  store i32 1, ptr %17, align 4
  br label %135

22:                                               ; preds = %7
  %23 = load ptr, ptr %16, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mln_hash_s, ptr %23, i32 0, i32 9
  store ptr null, ptr %24, align 8, !tbaa !13
  %25 = load ptr, ptr %16, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mln_hash_s, ptr %25, i32 0, i32 10
  store ptr null, ptr %26, align 8, !tbaa !15
  %27 = load ptr, ptr %16, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.mln_hash_s, ptr %27, i32 0, i32 11
  store ptr null, ptr %28, align 8, !tbaa !16
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load ptr, ptr %16, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mln_hash_s, ptr %30, i32 0, i32 2
  store ptr %29, ptr %31, align 8, !tbaa !17
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = load ptr, ptr %16, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mln_hash_s, ptr %33, i32 0, i32 3
  store ptr %32, ptr %34, align 8, !tbaa !18
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = load ptr, ptr %16, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mln_hash_s, ptr %36, i32 0, i32 4
  store ptr %35, ptr %37, align 8, !tbaa !19
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = load ptr, ptr %16, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.mln_hash_s, ptr %39, i32 0, i32 5
  store ptr %38, ptr %40, align 8, !tbaa !20
  %41 = load i32, ptr %15, align 4, !tbaa !11
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %48

43:                                               ; preds = %22
  %44 = load i64, ptr %13, align 8, !tbaa !9
  %45 = trunc i64 %44 to i32
  %46 = call i32 @mln_prime_generate(i32 noundef %45)
  %47 = zext i32 %46 to i64
  br label %50

48:                                               ; preds = %22
  %49 = load i64, ptr %13, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %48, %43
  %51 = phi i64 [ %47, %43 ], [ %49, %48 ]
  %52 = load ptr, ptr %16, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.mln_hash_s, ptr %52, i32 0, i32 1
  store i64 %51, ptr %53, align 8, !tbaa !21
  %54 = load ptr, ptr %16, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.mln_hash_s, ptr %54, i32 0, i32 1
  %56 = load i64, ptr %55, align 8, !tbaa !21
  %57 = call noalias ptr @calloc(i64 noundef %56, i64 noundef 16) #8
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mln_hash_s, ptr %58, i32 0, i32 0
  store ptr %57, ptr %59, align 8, !tbaa !22
  %60 = load ptr, ptr %16, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.mln_hash_s, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !22
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %66

64:                                               ; preds = %50
  %65 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %65) #6
  store ptr null, ptr %8, align 8
  store i32 1, ptr %17, align 4
  br label %135

66:                                               ; preds = %50
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.mln_hash_s, ptr %67, i32 0, i32 6
  store i32 0, ptr %68, align 8, !tbaa !23
  %69 = load i32, ptr %15, align 4, !tbaa !11
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %79

71:                                               ; preds = %66
  %72 = load ptr, ptr %16, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mln_hash_s, ptr %72, i32 0, i32 1
  %74 = load i64, ptr %73, align 8, !tbaa !21
  %75 = shl i64 %74, 1
  %76 = trunc i64 %75 to i32
  %77 = call i32 @mln_prime_generate(i32 noundef %76)
  %78 = zext i32 %77 to i64
  br label %84

79:                                               ; preds = %66
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.mln_hash_s, ptr %80, i32 0, i32 1
  %82 = load i64, ptr %81, align 8, !tbaa !21
  %83 = shl i64 %82, 1
  br label %84

84:                                               ; preds = %79, %71
  %85 = phi i64 [ %78, %71 ], [ %83, %79 ]
  %86 = trunc i64 %85 to i32
  %87 = load ptr, ptr %16, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.mln_hash_s, ptr %87, i32 0, i32 7
  store i32 %86, ptr %88, align 4, !tbaa !24
  %89 = load i32, ptr %14, align 4, !tbaa !11
  %90 = load ptr, ptr %16, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.mln_hash_s, ptr %90, i32 0, i32 8
  %92 = trunc i32 %89 to i8
  %93 = load i8, ptr %91, align 8
  %94 = and i8 %92, 1
  %95 = and i8 %93, -2
  %96 = or i8 %95, %94
  store i8 %96, ptr %91, align 8
  %97 = zext i8 %94 to i32
  %98 = load i32, ptr %15, align 4, !tbaa !11
  %99 = load ptr, ptr %16, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.mln_hash_s, ptr %99, i32 0, i32 8
  %101 = trunc i32 %98 to i8
  %102 = load i8, ptr %100, align 8
  %103 = and i8 %101, 1
  %104 = shl i8 %103, 1
  %105 = and i8 %102, -3
  %106 = or i8 %105, %104
  store i8 %106, ptr %100, align 8
  %107 = zext i8 %103 to i32
  %108 = load ptr, ptr %16, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.mln_hash_s, ptr %108, i32 0, i32 1
  %110 = load i64, ptr %109, align 8, !tbaa !21
  %111 = icmp eq i64 %110, 0
  br i1 %111, label %122, label %112

112:                                              ; preds = %84
  %113 = load ptr, ptr %16, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.mln_hash_s, ptr %113, i32 0, i32 2
  %115 = load ptr, ptr %114, align 8, !tbaa !17
  %116 = icmp eq ptr %115, null
  br i1 %116, label %122, label %117

117:                                              ; preds = %112
  %118 = load ptr, ptr %16, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.mln_hash_s, ptr %118, i32 0, i32 3
  %120 = load ptr, ptr %119, align 8, !tbaa !18
  %121 = icmp eq ptr %120, null
  br i1 %121, label %122, label %127

122:                                              ; preds = %117, %112, %84
  %123 = load ptr, ptr %16, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.mln_hash_s, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !22
  call void @free(ptr noundef %125) #6
  %126 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %126) #6
  store ptr null, ptr %8, align 8
  store i32 1, ptr %17, align 4
  br label %135

127:                                              ; preds = %117
  %128 = load ptr, ptr %16, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.mln_hash_s, ptr %128, i32 0, i32 13
  store ptr null, ptr %129, align 8, !tbaa !25
  %130 = load ptr, ptr %16, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.mln_hash_s, ptr %130, i32 0, i32 12
  store ptr null, ptr %131, align 8, !tbaa !26
  %132 = load ptr, ptr %16, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.mln_hash_s, ptr %132, i32 0, i32 14
  store ptr null, ptr %133, align 8, !tbaa !27
  %134 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %134, ptr %8, align 8
  store i32 1, ptr %17, align 4
  br label %135

135:                                              ; preds = %127, %122, %64, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  %136 = load ptr, ptr %8, align 8
  ret ptr %136
}

attributes #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 allocsize(0,1) "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 "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind allocsize(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 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind allocsize(0,1) }

!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}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 64}
!14 = !{!"mln_hash_s", !6, i64 0, !10, 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}
!15 = !{!14, !6, i64 72}
!16 = !{!14, !6, i64 80}
!17 = !{!14, !6, i64 16}
!18 = !{!14, !6, i64 24}
!19 = !{!14, !6, i64 32}
!20 = !{!14, !6, i64 40}
!21 = !{!14, !10, i64 8}
!22 = !{!14, !6, i64 0}
!23 = !{!14, !12, i64 48}
!24 = !{!14, !12, i64 52}
!25 = !{!14, !6, i64 96}
!26 = !{!14, !6, i64 88}
!27 = !{!14, !6, i64 104}


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

declare i32 @mln_prime_generate(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @mln_hash_new_fast(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #4 {
  %8 = tail call noalias dereferenceable_or_null(112) ptr @malloc(i64 noundef 112) #6
  %9 = icmp eq ptr %8, null
  br i1 %9, label %47, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %8, i64 64
  %12 = getelementptr inbounds i8, ptr %8, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %11, i8 0, i64 24, i1 false)
  store ptr %0, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %8, i64 24
  store ptr %1, ptr %13, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %8, i64 32
  store ptr %2, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %8, i64 40
  store ptr %3, ptr %15, align 8, !tbaa !14
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %20, label %16

16:                                               ; preds = %10
  %17 = trunc i64 %4 to i32
  %18 = tail call i32 @mln_prime_generate(i32 noundef %17) #7
  %19 = zext i32 %18 to i64
  br label %20

20:                                               ; preds = %10, %16
  %21 = phi i64 [ %19, %16 ], [ %4, %10 ]
  %22 = getelementptr inbounds i8, ptr %8, i64 8
  store i64 %21, ptr %22, align 8, !tbaa !15
  %23 = tail call noalias ptr @calloc(i64 noundef %21, i64 noundef 16) #8
  store ptr %23, ptr %8, align 8, !tbaa !16
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  tail call void @free(ptr noundef nonnull %8) #7
  br label %47

26:                                               ; preds = %20
  %27 = getelementptr inbounds i8, ptr %8, i64 48
  store i32 0, ptr %27, align 8, !tbaa !17
  %.tr39 = trunc i64 %21 to i32
  %28 = shl i32 %.tr39, 1
  br i1 %.not, label %31, label %29

29:                                               ; preds = %26
  %30 = tail call i32 @mln_prime_generate(i32 noundef %28) #7
  br label %31

31:                                               ; preds = %26, %29
  %32 = phi i32 [ %30, %29 ], [ %28, %26 ]
  %33 = getelementptr inbounds i8, ptr %8, i64 52
  store i32 %32, ptr %33, align 4, !tbaa !18
  %34 = getelementptr inbounds i8, ptr %8, i64 56
  %35 = trunc i32 %5 to i8
  %36 = and i8 %35, 1
  %37 = trunc i32 %6 to i8
  %38 = shl i8 %37, 1
  %39 = and i8 %38, 2
  %40 = or disjoint i8 %39, %36
  store i8 %40, ptr %34, align 8
  %41 = icmp eq i64 %21, 0
  %42 = icmp eq ptr %0, null
  %or.cond = or i1 %42, %41
  %43 = icmp eq ptr %1, null
  %or.cond40 = or i1 %43, %or.cond
  br i1 %or.cond40, label %44, label %45

44:                                               ; preds = %31
  tail call void @free(ptr noundef nonnull %23) #7
  tail call void @free(ptr noundef nonnull %8) #7
  br label %47

45:                                               ; preds = %31
  %46 = getelementptr inbounds i8, ptr %8, i64 88
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %46, i8 0, i64 24, i1 false)
  br label %47

47:                                               ; preds = %7, %45, %44, %25
  %.0 = phi ptr [ null, %25 ], [ null, %44 ], [ %8, %45 ], [ null, %7 ]
  ret ptr %.0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }

!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 24}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !7, i64 40}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !11, i64 48}
!18 = !{!6, !11, i64 52}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass