; LLVM IR from pavlosdais/Abstract-Data-Types :: modules/HashTable/SeparateChaining (hash_table)

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

@.str.1 = external hidden unnamed_addr constant [112 x i8], align 1
@hash_sizes = external hidden global [57 x i64], align 16
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__.hash_insert = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @hash_insert(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca i1, align 1
  %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 i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call zeroext i1 @hash_search(ptr noundef %10, ptr noundef %11, ptr noundef %6)
  br i1 %12, label %13, label %24

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.hash_table, ptr %14, i32 0, i32 5
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %23

18:                                               ; preds = %13
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.hash_table, ptr %19, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  call void %21(ptr noundef %22)
  br label %23

23:                                               ; preds = %18, %13
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %94

24:                                               ; preds = %2
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.hash_table, ptr %25, i32 0, i32 2
  %27 = load i64, ptr %26, align 8, !tbaa !14
  %28 = uitofp i64 %27 to float
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.hash_table, ptr %29, i32 0, i32 1
  %31 = load i8, ptr %30, align 8, !tbaa !15
  %32 = zext i8 %31 to i64
  %33 = getelementptr inbounds [57 x i64], ptr @hash_sizes, i64 0, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !16
  %35 = uitofp i64 %34 to float
  %36 = fdiv float %28, %35
  %37 = fpext float %36 to double
  %38 = fcmp ogt double %37, 8.000000e-01
  br i1 %38, label %39, label %51

39:                                               ; preds = %24
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.hash_table, ptr %40, i32 0, i32 1
  %42 = load i8, ptr %41, align 8, !tbaa !15
  %43 = zext i8 %42 to i64
  %44 = getelementptr inbounds [57 x i64], ptr @hash_sizes, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !16
  %46 = load i64, ptr getelementptr inbounds ([57 x i64], ptr @hash_sizes, i64 0, i64 56), align 16, !tbaa !16
  %47 = icmp ne i64 %45, %46
  br i1 %47, label %48, label %50

48:                                               ; preds = %39
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  call void @rehash(ptr noundef %49)
  br label %50

50:                                               ; preds = %48, %39
  br label %51

51:                                               ; preds = %50, %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %52 = call noalias ptr @malloc(i64 noundef 24) #6
  store ptr %52, ptr %8, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %56

55:                                               ; preds = %51
  br label %57

56:                                               ; preds = %51
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 93, ptr noundef @__PRETTY_FUNCTION__.hash_insert) #7
  unreachable

57:                                               ; preds = %55
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.node, ptr %59, i32 0, i32 0
  store ptr %58, ptr %60, align 8, !tbaa !17
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.node, ptr %62, i32 0, i32 1
  store i32 %61, ptr %63, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = zext i32 %64 to i64
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.hash_table, ptr %66, i32 0, i32 1
  %68 = load i8, ptr %67, align 8, !tbaa !15
  %69 = zext i8 %68 to i64
  %70 = getelementptr inbounds [57 x i64], ptr @hash_sizes, i64 0, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !16
  %72 = urem i64 %65, %71
  %73 = trunc i64 %72 to i32
  store i32 %73, ptr %9, align 4, !tbaa !9
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.hash_table, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !20
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds ptr, ptr %76, i64 %78
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.node, ptr %81, i32 0, i32 2
  store ptr %80, ptr %82, align 8, !tbaa !21
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.hash_table, ptr %84, i32 0, i32 0
  %86 = load ptr, ptr %85, align 8, !tbaa !20
  %87 = load i32, ptr %9, align 4, !tbaa !9
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds ptr, ptr %86, i64 %88
  store ptr %83, ptr %89, align 8, !tbaa !5
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.hash_table, ptr %90, i32 0, i32 2
  %92 = load i64, ptr %91, align 8, !tbaa !14
  %93 = add i64 %92, 1
  store i64 %93, ptr %91, align 8, !tbaa !14
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %94

94:                                               ; preds = %57, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %95 = load i1, ptr %3, align 1
  ret i1 %95
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @hash_search(ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @rehash(ptr noundef) #4

attributes #0 = { noreturn 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { noreturn 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 40}
!12 = !{!"hash_table", !6, i64 0, !7, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 16}
!15 = !{!12, !7, i64 8}
!16 = !{!13, !13, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"node", !6, i64 0, !10, i64 8, !6, i64 16}
!19 = !{!18, !10, i64 8}
!20 = !{!12, !6, i64 0}
!21 = !{!18, !6, i64 16}


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

@.str.1 = external hidden unnamed_addr constant [112 x i8], align 1
@hash_sizes = external hidden local_unnamed_addr global [57 x i64], align 16
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__.hash_insert = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 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: nounwind uwtable
define dso_local noundef zeroext i1 @hash_insert(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  %4 = call zeroext i1 @hash_search(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %3)
  br i1 %4, label %5, label %9

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %.not24 = icmp eq ptr %7, null
  br i1 %.not24, label %42, label %8

8:                                                ; preds = %5
  call void %7(ptr noundef %1) #5
  br label %42

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load i64, ptr %10, align 8, !tbaa !13
  %12 = uitofp i64 %11 to float
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i8, ptr %13, align 8, !tbaa !14
  %15 = zext i8 %14 to i64
  %16 = getelementptr inbounds [57 x i64], ptr @hash_sizes, i64 0, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = uitofp i64 %17 to float
  %19 = fdiv float %12, %18
  %20 = fpext float %19 to double
  %21 = fcmp ule double %20, 8.000000e-01
  %22 = load i64, ptr getelementptr inbounds (i8, ptr @hash_sizes, i64 448), align 16
  %.not = icmp eq i64 %17, %22
  %or.cond = select i1 %21, i1 true, i1 %.not
  br i1 %or.cond, label %24, label %23

23:                                               ; preds = %9
  call void @rehash(ptr noundef nonnull %0)
  br label %24

24:                                               ; preds = %23, %9
  %25 = call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #6
  %.not23 = icmp eq ptr %25, null
  br i1 %.not23, label %26, label %27

26:                                               ; preds = %24
  call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 93, ptr noundef nonnull @__PRETTY_FUNCTION__.hash_insert) #7
  unreachable

27:                                               ; preds = %24
  store ptr %1, ptr %25, align 8, !tbaa !16
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %25, i64 8
  store i32 %28, ptr %29, align 8, !tbaa !18
  %30 = zext i32 %28 to i64
  %31 = load i8, ptr %13, align 8, !tbaa !14
  %32 = zext i8 %31 to i64
  %33 = getelementptr inbounds [57 x i64], ptr @hash_sizes, i64 0, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !15
  %35 = urem i64 %30, %34
  %36 = load ptr, ptr %0, align 8, !tbaa !19
  %37 = getelementptr inbounds ptr, ptr %36, i64 %35
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = getelementptr inbounds i8, ptr %25, i64 16
  store ptr %38, ptr %39, align 8, !tbaa !21
  store ptr %25, ptr %37, align 8, !tbaa !20
  %40 = load i64, ptr %10, align 8, !tbaa !13
  %41 = add i64 %40, 1
  store i64 %41, ptr %10, align 8, !tbaa !13
  br label %42

42:                                               ; preds = %5, %8, %27
  %.0 = xor i1 %4, true
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  ret i1 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @hash_search(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @rehash(ptr noundef) local_unnamed_addr #4

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 40}
!10 = !{!"hash_table", !11, i64 0, !7, i64 8, !12, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 16}
!14 = !{!10, !7, i64 8}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !11, i64 0}
!17 = !{!"node", !11, i64 0, !6, i64 8, !11, i64 16}
!18 = !{!17, !6, i64 8}
!19 = !{!10, !11, i64 0}
!20 = !{!11, !11, i64 0}
!21 = !{!17, !11, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass