; LLVM IR from Water-Melon/Melon :: t (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_attr = type { ptr, ptr, ptr, ptr, i64, i8, ptr, ptr, ptr }
%struct.mln_hash_test_s = type { i32, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.mln_hash_attr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 72, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %11 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 6
  store ptr null, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 7
  store ptr null, ptr %12, align 8, !tbaa !14
  %13 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 8
  store ptr null, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 0
  store ptr @calc_handler, ptr %14, align 8, !tbaa !16
  %15 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 1
  store ptr @cmp_handler, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 2
  store ptr null, ptr %16, align 8, !tbaa !18
  %17 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 3
  store ptr @free_handler, ptr %17, align 8, !tbaa !19
  %18 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 4
  store i64 97, ptr %18, align 8, !tbaa !20
  %19 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 5
  %20 = load i8, ptr %19, align 8
  %21 = and i8 %20, -2
  %22 = or i8 %21, 0
  store i8 %22, ptr %19, align 8
  %23 = getelementptr inbounds %struct.mln_hash_attr, ptr %7, i32 0, i32 5
  %24 = load i8, ptr %23, align 8
  %25 = and i8 %24, -3
  %26 = or i8 %25, 0
  store i8 %26, ptr %23, align 8
  %27 = call ptr @mln_hash_new(ptr noundef %7)
  store ptr %27, ptr %6, align 8, !tbaa !9
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %32

29:                                               ; preds = %2
  %30 = load ptr, ptr @stderr, align 8, !tbaa !9
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str) #5
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %62

32:                                               ; preds = %2
  %33 = call noalias ptr @malloc(i64 noundef 8) #6
  store ptr %33, ptr %8, align 8, !tbaa !9
  %34 = load ptr, ptr %8, align 8, !tbaa !9
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %39

36:                                               ; preds = %32
  %37 = load ptr, ptr @stderr, align 8, !tbaa !9
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.1) #5
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %62

39:                                               ; preds = %32
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.mln_hash_test_s, ptr %40, i32 0, i32 0
  store i32 1, ptr %41, align 4, !tbaa !21
  %42 = load ptr, ptr %8, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.mln_hash_test_s, ptr %42, i32 0, i32 1
  store i32 10, ptr %43, align 4, !tbaa !23
  %44 = load ptr, ptr %6, align 8, !tbaa !9
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.mln_hash_test_s, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %8, align 8, !tbaa !9
  %48 = call i32 @mln_hash_insert(ptr noundef %44, ptr noundef %46, ptr noundef %47)
  %49 = icmp slt i32 %48, 0
  br i1 %49, label %50, label %53

50:                                               ; preds = %39
  %51 = load ptr, ptr @stderr, align 8, !tbaa !9
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef @.str.2) #5
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %62

53:                                               ; preds = %39
  %54 = load ptr, ptr %6, align 8, !tbaa !9
  %55 = load ptr, ptr %8, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.mln_hash_test_s, ptr %55, i32 0, i32 0
  %57 = call ptr @mln_hash_search(ptr noundef %54, ptr noundef %56)
  store ptr %57, ptr %9, align 8, !tbaa !9
  %58 = load ptr, ptr %9, align 8, !tbaa !9
  %59 = load ptr, ptr %8, align 8, !tbaa !9
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, ptr noundef %58, ptr noundef %59)
  %61 = load ptr, ptr %6, align 8, !tbaa !9
  call void @mln_hash_free(ptr noundef %61, i32 noundef 1)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %62

62:                                               ; preds = %53, %50, %36, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 72, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %63 = load i32, ptr %3, align 4
  ret i32 %63
}

; 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 i64 @calc_handler(ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare hidden void @free_handler(ptr noundef) #0

declare ptr @mln_hash_new(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

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

declare i32 @mln_hash_insert(ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @mln_hash_search(ptr noundef, ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #2

declare void @mln_hash_free(ptr noundef, i32 noundef) #2

; 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 = { "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 "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 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 }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 48}
!12 = !{!"mln_hash_attr", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !13, i64 32, !6, i64 40, !6, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !10, i64 56}
!15 = !{!12, !10, i64 64}
!16 = !{!12, !10, i64 0}
!17 = !{!12, !10, i64 8}
!18 = !{!12, !10, i64 16}
!19 = !{!12, !10, i64 24}
!20 = !{!12, !13, i64 32}
!21 = !{!22, !6, i64 0}
!22 = !{!"mln_hash_test_s", !6, i64 0, !6, i64 4}
!23 = !{!22, !6, i64 4}


; 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_attr = type { ptr, ptr, ptr, ptr, i64, i8, ptr, ptr, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.mln_hash_attr, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %3) #6
  %4 = getelementptr inbounds i8, ptr %3, i64 48
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, i8 0, i64 24, i1 false)
  store ptr @calc_handler, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr @cmp_handler, ptr %5, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr null, ptr %6, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr @free_handler, ptr %7, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %3, i64 32
  store i64 97, ptr %8, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %3, i64 40
  store i8 0, ptr %9, align 8
  %10 = call ptr @mln_hash_new(ptr noundef nonnull %3) #6
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %15

12:                                               ; preds = %2
  %13 = load ptr, ptr @stderr, align 8, !tbaa !16
  %14 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str) #7
  br label %31

15:                                               ; preds = %2
  %16 = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #8
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  %19 = load ptr, ptr @stderr, align 8, !tbaa !16
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.1) #7
  br label %31

21:                                               ; preds = %15
  store i32 1, ptr %16, align 4, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %16, i64 4
  store i32 10, ptr %22, align 4, !tbaa !19
  %23 = call i32 @mln_hash_insert(ptr noundef nonnull %10, ptr noundef nonnull %16, ptr noundef nonnull %16) #6
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %21
  %26 = load ptr, ptr @stderr, align 8, !tbaa !16
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.2) #7
  br label %31

28:                                               ; preds = %21
  %29 = call ptr @mln_hash_search(ptr noundef nonnull %10, ptr noundef nonnull %16) #6
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef %29, ptr noundef nonnull %16)
  call void @mln_hash_free(ptr noundef nonnull %10, i32 noundef 1) #6
  br label %31

31:                                               ; preds = %28, %25, %18, %12
  %.0 = phi i32 [ -1, %12 ], [ -1, %18 ], [ -1, %25 ], [ 0, %28 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #6
  ret i32 %.0
}

; 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 i64 @calc_handler(ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare hidden void @free_handler(ptr noundef) #0

declare ptr @mln_hash_new(ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

declare i32 @mln_hash_insert(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @mln_hash_search(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare void @mln_hash_free(ptr noundef, i32 noundef) local_unnamed_addr #2

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

; 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 = { 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 = { "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 = { nofree 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 #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 0}
!6 = !{!"mln_hash_attr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !11, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!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 8}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !10, i64 32}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !11, i64 0}
!18 = !{!"mln_hash_test_s", !11, i64 0, !11, i64 4}
!19 = !{!18, !11, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass