; LLVM IR from themisvaltinos/Partitioned-Hash-Join :: tests/test_hopscotch.ll (testBasicInsert)

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

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [24 x i8], align 1

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

; Function Attrs: noreturn nounwind uwtable
declare dso_local void @acutest_abort_() #2

; Function Attrs: nounwind uwtable
define dso_local void @_testBasicInsert(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %struct.tuple, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %38, %2
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = icmp ult i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %41

13:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %14 = getelementptr inbounds %struct.tuple, ptr %6, i32 0, i32 0
  %15 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %15, ptr %14, align 4, !tbaa !11
  %16 = getelementptr inbounds %struct.tuple, ptr %6, i32 0, i32 1
  %17 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %17, ptr %16, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = call i32 @insert(ptr noundef %18, ptr noundef %6)
  store i32 %19, ptr %7, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %13
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hash_table, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds %struct.bucket, ptr %23, i64 %25
  %27 = getelementptr inbounds %struct.bucket, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = icmp eq i32 %28, %29
  %31 = zext i1 %30 to i32
  %32 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %31, ptr noundef @.str.36, i32 noundef 46, ptr noundef @.str.5, ptr noundef @.str.49)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %35, label %34

34:                                               ; preds = %20
  call void @acutest_abort_() #5
  unreachable

35:                                               ; preds = %20
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = add i32 %39, 1
  store i32 %40, ptr %5, align 4, !tbaa !9
  br label %8, !llvm.loop !19

41:                                               ; preds = %12
  br label %42

42:                                               ; preds = %41
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.hash_table, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !21
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = icmp eq i32 %45, %46
  %48 = zext i1 %47 to i32
  %49 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %48, ptr noundef @.str.36, i32 noundef 49, ptr noundef @.str.5, ptr noundef @.str.50)
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %52, label %51

51:                                               ; preds = %42
  call void @acutest_abort_() #5
  unreachable

52:                                               ; preds = %42
  br label %53

53:                                               ; preds = %52
  ret void
}

declare i32 @insert(ptr noundef, ptr noundef) #3

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 = { noreturn 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 = { "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 }
attributes #5 = { noreturn }

!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, !10, i64 0}
!12 = !{!"tuple", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = !{!15, !6, i64 0}
!15 = !{!"hash_table", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!16 = !{!17, !10, i64 4}
!17 = !{!"bucket", !10, i64 0, !10, i64 4, !18, i64 8, !6, i64 16}
!18 = !{!"long", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!15, !10, i64 8}


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

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [24 x i8], align 1

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

; Function Attrs: noreturn nounwind uwtable
declare dso_local void @acutest_abort_() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @_testBasicInsert(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.tuple, align 4
  %.not13 = icmp eq i32 %1, 0
  br i1 %.not13, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = getelementptr inbounds i8, ptr %3, i64 4
  br label %10

._crit_edge:                                      ; preds = %20, %2
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp eq i32 %6, %1
  %8 = zext i1 %7 to i32
  %9 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %8, ptr noundef nonnull @.str.36, i32 noundef 49, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.50)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %22, label %23

10:                                               ; preds = %.lr.ph, %20
  %.012 = phi i32 [ 0, %.lr.ph ], [ %21, %20 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store i32 %.012, ptr %3, align 4, !tbaa !11
  store i32 %.012, ptr %4, align 4, !tbaa !13
  %11 = call i32 @insert(ptr noundef %0, ptr noundef nonnull %3) #4
  %12 = load ptr, ptr %0, align 8, !tbaa !14
  %13 = zext i32 %11 to i64
  %14 = getelementptr inbounds %struct.bucket, ptr %12, i64 %13, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !15
  %16 = icmp eq i32 %15, %.012
  %17 = zext i1 %16 to i32
  %18 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %17, ptr noundef nonnull @.str.36, i32 noundef 46, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.49)
  %.not11 = icmp eq i32 %18, 0
  br i1 %.not11, label %19, label %20

19:                                               ; preds = %10
  call void @acutest_abort_() #5
  unreachable

20:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %21 = add nuw i32 %.012, 1
  %exitcond.not = icmp eq i32 %21, %1
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !18

22:                                               ; preds = %._crit_edge
  call void @acutest_abort_() #5
  unreachable

23:                                               ; preds = %._crit_edge
  ret void
}

declare i32 @insert(ptr noundef, ptr noundef) local_unnamed_addr #3

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 = { noreturn 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 = { "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 }
attributes #5 = { noreturn }

!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, !10, i64 8}
!6 = !{!"hash_table", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"tuple", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !10, i64 4}
!16 = !{!"bucket", !10, i64 0, !10, i64 4, !17, i64 8, !7, i64 16}
!17 = !{!"long", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass