; LLVM IR from ponylang/ponyc :: src/libponyrt/ds (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.hashmap_t = type { i64, i64, ptr, ptr }
%struct.hashmap_entry_t = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@__func__.ponyint_hashmap_putindex = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @ponyint_hashmap_init(ptr noundef, i64 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @ponyint_hashmap_put(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @ponyint_hashmap_putindex(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i64 %4, ptr %10, align 8, !tbaa !9
  %17 = load i64, ptr %10, align 8, !tbaa !9
  %18 = icmp eq i64 %17, -1
  br i1 %18, label %19, label %25

19:                                               ; preds = %5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = load i64, ptr %8, align 8, !tbaa !9
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = call ptr @ponyint_hashmap_put(ptr noundef %20, ptr noundef %21, i64 noundef %22, ptr noundef %23)
  br label %136

25:                                               ; preds = %5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.hashmap_t, ptr %26, i32 0, i32 1
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %25
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ponyint_hashmap_init(ptr noundef %31, i64 noundef 4)
  br label %32

32:                                               ; preds = %30, %25
  %33 = load i64, ptr %10, align 8, !tbaa !9
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.hashmap_t, ptr %34, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !11
  %37 = icmp ult i64 %33, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %32
  br label %40

39:                                               ; preds = %32
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 344, ptr noundef @__func__.ponyint_hashmap_putindex)
  br label %40

40:                                               ; preds = %39, %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %41 = load i64, ptr %10, align 8, !tbaa !9
  %42 = lshr i64 %41, 6
  store i64 %42, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %43 = load i64, ptr %10, align 8, !tbaa !9
  %44 = and i64 %43, 63
  store i64 %44, ptr %12, align 8, !tbaa !9
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.hashmap_t, ptr %45, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load i64, ptr %11, align 8, !tbaa !9
  %49 = getelementptr inbounds i64, ptr %47, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = load i64, ptr %12, align 8, !tbaa !9
  %52 = shl i64 1, %51
  %53 = and i64 %50, %52
  %54 = icmp eq i64 %53, 0
  br i1 %54, label %55, label %95

55:                                               ; preds = %40
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.hashmap_t, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !14
  %60 = load i64, ptr %10, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.hashmap_entry_t, ptr %59, i64 %60
  %62 = getelementptr inbounds %struct.hashmap_entry_t, ptr %61, i32 0, i32 0
  store ptr %56, ptr %62, align 8, !tbaa !15
  %63 = load i64, ptr %8, align 8, !tbaa !9
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.hashmap_t, ptr %64, i32 0, i32 3
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = load i64, ptr %10, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.hashmap_entry_t, ptr %66, i64 %67
  %69 = getelementptr inbounds %struct.hashmap_entry_t, ptr %68, i32 0, i32 1
  store i64 %63, ptr %69, align 8, !tbaa !17
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.hashmap_t, ptr %70, i32 0, i32 0
  %72 = load i64, ptr %71, align 8, !tbaa !18
  %73 = add i64 %72, 1
  store i64 %73, ptr %71, align 8, !tbaa !18
  %74 = load i64, ptr %12, align 8, !tbaa !9
  %75 = shl i64 1, %74
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.hashmap_t, ptr %76, i32 0, i32 2
  %78 = load ptr, ptr %77, align 8, !tbaa !13
  %79 = load i64, ptr %11, align 8, !tbaa !9
  %80 = getelementptr inbounds i64, ptr %78, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !9
  %82 = or i64 %81, %75
  store i64 %82, ptr %80, align 8, !tbaa !9
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.hashmap_t, ptr %83, i32 0, i32 0
  %85 = load i64, ptr %84, align 8, !tbaa !18
  %86 = shl i64 %85, 1
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.hashmap_t, ptr %87, i32 0, i32 1
  %89 = load i64, ptr %88, align 8, !tbaa !11
  %90 = icmp ugt i64 %86, %89
  br i1 %90, label %91, label %94

91:                                               ; preds = %55
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  call void @resize(ptr noundef %92, ptr noundef %93)
  br label %94

94:                                               ; preds = %91, %55
  br label %135

95:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.hashmap_t, ptr %96, i32 0, i32 1
  %98 = load i64, ptr %97, align 8, !tbaa !11
  %99 = sub i64 %98, 1
  store i64 %99, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.hashmap_t, ptr %100, i32 0, i32 3
  %102 = load ptr, ptr %101, align 8, !tbaa !14
  %103 = load i64, ptr %10, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.hashmap_entry_t, ptr %102, i64 %103
  %105 = getelementptr inbounds %struct.hashmap_entry_t, ptr %104, i32 0, i32 1
  %106 = load i64, ptr %105, align 8, !tbaa !17
  store i64 %106, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = load i64, ptr %14, align 8, !tbaa !9
  %109 = load i64, ptr %10, align 8, !tbaa !9
  %110 = load i64, ptr %13, align 8, !tbaa !9
  %111 = call i64 @get_probe_length(ptr noundef %107, i64 noundef %108, i64 noundef %109, i64 noundef %110)
  store i64 %111, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = load i64, ptr %8, align 8, !tbaa !9
  %114 = load i64, ptr %10, align 8, !tbaa !9
  %115 = load i64, ptr %13, align 8, !tbaa !9
  %116 = call i64 @get_probe_length(ptr noundef %112, i64 noundef %113, i64 noundef %114, i64 noundef %115)
  store i64 %116, ptr %16, align 8, !tbaa !9
  %117 = load i64, ptr %16, align 8, !tbaa !9
  %118 = load i64, ptr %15, align 8, !tbaa !9
  %119 = icmp ugt i64 %117, %118
  br i1 %119, label %120, label %128

120:                                              ; preds = %95
  %121 = load ptr, ptr %6, align 8, !tbaa !5
  %122 = load ptr, ptr %7, align 8, !tbaa !5
  %123 = load i64, ptr %8, align 8, !tbaa !9
  %124 = load ptr, ptr %9, align 8, !tbaa !5
  %125 = load i64, ptr %10, align 8, !tbaa !9
  %126 = load i64, ptr %16, align 8, !tbaa !9
  %127 = load i64, ptr %15, align 8, !tbaa !9
  call void @shift_put(ptr noundef %121, ptr noundef %122, i64 noundef %123, ptr noundef %124, i64 noundef %125, i64 noundef %126, i64 noundef %127, ptr noundef null)
  br label %134

128:                                              ; preds = %95
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = load ptr, ptr %7, align 8, !tbaa !5
  %131 = load i64, ptr %8, align 8, !tbaa !9
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  %133 = call ptr @ponyint_hashmap_put(ptr noundef %129, ptr noundef %130, i64 noundef %131, ptr noundef %132)
  br label %134

134:                                              ; preds = %128, %120
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %135

135:                                              ; preds = %134, %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %136

136:                                              ; preds = %135, %19
  ret void
}

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

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

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

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 }

!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, !10, i64 8}
!12 = !{!"hashmap_t", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!12, !6, i64 16}
!14 = !{!12, !6, i64 24}
!15 = !{!16, !6, i64 0}
!16 = !{!"hashmap_entry_t", !6, i64 0, !10, i64 8}
!17 = !{!16, !10, i64 8}
!18 = !{!12, !10, 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.hashmap_entry_t = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1
@__func__.ponyint_hashmap_putindex = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @ponyint_hashmap_init(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ponyint_hashmap_put(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @ponyint_hashmap_putindex(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  %6 = icmp eq i64 %4, -1
  br i1 %6, label %7, label %9

7:                                                ; preds = %5
  %8 = tail call ptr @ponyint_hashmap_put(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3)
  br label %55

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %9
  tail call void @ponyint_hashmap_init(ptr noundef nonnull %0, i64 noundef 4)
  %.pre = load i64, ptr %10, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %13, %9
  %15 = phi i64 [ %.pre, %13 ], [ %11, %9 ]
  %16 = icmp ugt i64 %15, %4
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 344, ptr noundef nonnull @__func__.ponyint_hashmap_putindex) #2
  br label %18

18:                                               ; preds = %14, %17
  %19 = lshr i64 %4, 6
  %20 = and i64 %4, 63
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = getelementptr inbounds i64, ptr %22, i64 %19
  %24 = load i64, ptr %23, align 8, !tbaa !12
  %25 = shl nuw i64 1, %20
  %26 = and i64 %24, %25
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %28, label %42

28:                                               ; preds = %18
  %29 = getelementptr inbounds i8, ptr %0, i64 24
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = getelementptr inbounds %struct.hashmap_entry_t, ptr %30, i64 %4
  store ptr %1, ptr %31, align 8, !tbaa !14
  %32 = getelementptr inbounds %struct.hashmap_entry_t, ptr %30, i64 %4, i32 1
  store i64 %2, ptr %32, align 8, !tbaa !16
  %33 = load i64, ptr %0, align 8, !tbaa !17
  %34 = add i64 %33, 1
  store i64 %34, ptr %0, align 8, !tbaa !17
  %35 = load i64, ptr %23, align 8, !tbaa !12
  %36 = or i64 %35, %25
  store i64 %36, ptr %23, align 8, !tbaa !12
  %37 = load i64, ptr %0, align 8, !tbaa !17
  %38 = shl i64 %37, 1
  %39 = load i64, ptr %10, align 8, !tbaa !5
  %40 = icmp ugt i64 %38, %39
  br i1 %40, label %41, label %55

41:                                               ; preds = %28
  tail call void @resize(ptr noundef nonnull %0, ptr noundef %3)
  br label %55

42:                                               ; preds = %18
  %43 = load i64, ptr %10, align 8, !tbaa !5
  %44 = add i64 %43, -1
  %45 = getelementptr inbounds i8, ptr %0, i64 24
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = getelementptr inbounds %struct.hashmap_entry_t, ptr %46, i64 %4, i32 1
  %48 = load i64, ptr %47, align 8, !tbaa !16
  %49 = tail call i64 @get_probe_length(ptr noundef nonnull %0, i64 noundef %48, i64 noundef %4, i64 noundef %44)
  %50 = tail call i64 @get_probe_length(ptr noundef nonnull %0, i64 noundef %2, i64 noundef %4, i64 noundef %44)
  %51 = icmp ugt i64 %50, %49
  br i1 %51, label %52, label %53

52:                                               ; preds = %42
  tail call void @shift_put(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, i64 noundef %50, i64 noundef %49, ptr noundef null)
  br label %55

53:                                               ; preds = %42
  %54 = tail call ptr @ponyint_hashmap_put(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2, ptr noundef %3)
  br label %55

55:                                               ; preds = %41, %28, %53, %52, %7
  ret void
}

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden i64 @get_probe_length(ptr noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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 = { "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 8}
!6 = !{!"hashmap_t", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 24}
!14 = !{!15, !10, i64 0}
!15 = !{!"hashmap_entry_t", !10, i64 0, !7, i64 8}
!16 = !{!15, !7, i64 8}
!17 = !{!6, !7, i64 0}


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