; LLVM IR from themisvaltinos/Partitioned-Hash-Join :: tests (test_optimizer)

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

@.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.37 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [41 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 @testDistinctCount() #0 {
  %1 = alloca [6 x i64], align 16
  %2 = alloca [100000 x i64], align 16
  %3 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr %1) #4
  %4 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 0
  store i64 1, ptr %4, align 16, !tbaa !5
  %5 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 1
  store i64 1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 2
  store i64 55, ptr %6, align 16, !tbaa !5
  %7 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 3
  store i64 77, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 4
  store i64 12, ptr %8, align 16, !tbaa !5
  %9 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 5
  store i64 155, ptr %9, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %0
  %11 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 0
  %12 = call i32 @distinctCount(ptr noundef %11, i64 noundef 6)
  %13 = icmp eq i32 5, %12
  %14 = zext i1 %13 to i32
  %15 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %14, ptr noundef @.str.36, i32 noundef 31, ptr noundef @.str.5, ptr noundef @.str.37)
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %10
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  %21 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 0
  store i64 1, ptr %21, align 16, !tbaa !5
  %22 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 1
  store i64 1, ptr %22, align 8, !tbaa !5
  %23 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 2
  store i64 2, ptr %23, align 16, !tbaa !5
  %24 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 3
  store i64 3, ptr %24, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %20
  %26 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 0
  %27 = call i32 @distinctCount(ptr noundef %26, i64 noundef 4)
  %28 = icmp eq i32 3, %27
  %29 = zext i1 %28 to i32
  %30 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %29, ptr noundef @.str.36, i32 noundef 37, ptr noundef @.str.5, ptr noundef @.str.38)
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %25
  call void @acutest_abort_() #5
  unreachable

33:                                               ; preds = %25
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 0
  store i64 1, ptr %36, align 16, !tbaa !5
  %37 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 1
  store i64 2, ptr %37, align 8, !tbaa !5
  %38 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 2
  store i64 1, ptr %38, align 16, !tbaa !5
  %39 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 3
  store i64 1, ptr %39, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %35
  %41 = getelementptr inbounds [6 x i64], ptr %1, i64 0, i64 0
  %42 = call i32 @distinctCount(ptr noundef %41, i64 noundef 4)
  %43 = icmp eq i32 2, %42
  %44 = zext i1 %43 to i32
  %45 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %44, ptr noundef @.str.36, i32 noundef 43, ptr noundef @.str.5, ptr noundef @.str.39)
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %48, label %47

47:                                               ; preds = %40
  call void @acutest_abort_() #5
  unreachable

48:                                               ; preds = %40
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 800000, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %58, %50
  %52 = load i64, ptr %3, align 8, !tbaa !5
  %53 = icmp ult i64 %52, 100000
  br i1 %53, label %55, label %54

54:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %61

55:                                               ; preds = %51
  %56 = load i64, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds [100000 x i64], ptr %2, i64 0, i64 %56
  store i64 8829, ptr %57, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %55
  %59 = load i64, ptr %3, align 8, !tbaa !5
  %60 = add i64 %59, 1
  store i64 %60, ptr %3, align 8, !tbaa !5
  br label %51, !llvm.loop !9

61:                                               ; preds = %54
  br label %62

62:                                               ; preds = %61
  %63 = getelementptr inbounds [100000 x i64], ptr %2, i64 0, i64 0
  %64 = call i32 @distinctCount(ptr noundef %63, i64 noundef 100000)
  %65 = icmp eq i32 1, %64
  %66 = zext i1 %65 to i32
  %67 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %66, ptr noundef @.str.36, i32 noundef 49, ptr noundef @.str.5, ptr noundef @.str.40)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %70, label %69

69:                                               ; preds = %62
  call void @acutest_abort_() #5
  unreachable

70:                                               ; preds = %62
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  call void @llvm.lifetime.end.p0(i64 800000, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr %1) #4
  ret void
}

declare i32 @distinctCount(ptr noundef, i64 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; 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.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [41 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 @testDistinctCount() local_unnamed_addr #0 {
  %1 = alloca [6 x i64], align 16
  %2 = alloca [100000 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %1) #4
  store i64 1, ptr %1, align 16, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 1, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 55, ptr %4, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  store i64 77, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  store i64 12, ptr %6, align 16, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 40
  store i64 155, ptr %7, align 8, !tbaa !5
  %8 = call i32 @distinctCount(ptr noundef nonnull %1, i64 noundef 6) #4
  %9 = icmp eq i32 %8, 5
  %10 = zext i1 %9 to i32
  %11 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %10, ptr noundef nonnull @.str.36, i32 noundef 31, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.37)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %13

12:                                               ; preds = %0
  call void @acutest_abort_() #5
  unreachable

13:                                               ; preds = %0
  store i64 1, ptr %1, align 16, !tbaa !5
  store i64 1, ptr %3, align 8, !tbaa !5
  store i64 2, ptr %4, align 16, !tbaa !5
  store i64 3, ptr %5, align 8, !tbaa !5
  %14 = call i32 @distinctCount(ptr noundef nonnull %1, i64 noundef 4) #4
  %15 = icmp eq i32 %14, 3
  %16 = zext i1 %15 to i32
  %17 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %16, ptr noundef nonnull @.str.36, i32 noundef 37, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.38)
  %.not3 = icmp eq i32 %17, 0
  br i1 %.not3, label %18, label %19

18:                                               ; preds = %13
  call void @acutest_abort_() #5
  unreachable

19:                                               ; preds = %13
  store i64 1, ptr %1, align 16, !tbaa !5
  store i64 2, ptr %3, align 8, !tbaa !5
  store i64 1, ptr %4, align 16, !tbaa !5
  store i64 1, ptr %5, align 8, !tbaa !5
  %20 = call i32 @distinctCount(ptr noundef nonnull %1, i64 noundef 4) #4
  %21 = icmp eq i32 %20, 2
  %22 = zext i1 %21 to i32
  %23 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %22, ptr noundef nonnull @.str.36, i32 noundef 43, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.39)
  %.not4 = icmp eq i32 %23, 0
  br i1 %.not4, label %24, label %vector.ph

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

vector.ph:                                        ; preds = %19
  call void @llvm.lifetime.start.p0(i64 800000, ptr nonnull %2) #4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.4, %vector.body ]
  %25 = getelementptr inbounds [100000 x i64], ptr %2, i64 0, i64 %index
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  store <2 x i64> <i64 8829, i64 8829>, ptr %25, align 16, !tbaa !5
  store <2 x i64> <i64 8829, i64 8829>, ptr %26, align 16, !tbaa !5
  %index.next = add nuw nsw i64 %index, 4
  %27 = getelementptr inbounds [100000 x i64], ptr %2, i64 0, i64 %index.next
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  store <2 x i64> <i64 8829, i64 8829>, ptr %27, align 16, !tbaa !5
  store <2 x i64> <i64 8829, i64 8829>, ptr %28, align 16, !tbaa !5
  %index.next.1 = add nuw nsw i64 %index, 8
  %29 = getelementptr inbounds [100000 x i64], ptr %2, i64 0, i64 %index.next.1
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  store <2 x i64> <i64 8829, i64 8829>, ptr %29, align 16, !tbaa !5
  store <2 x i64> <i64 8829, i64 8829>, ptr %30, align 16, !tbaa !5
  %index.next.2 = add nuw nsw i64 %index, 12
  %31 = getelementptr inbounds [100000 x i64], ptr %2, i64 0, i64 %index.next.2
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  store <2 x i64> <i64 8829, i64 8829>, ptr %31, align 16, !tbaa !5
  store <2 x i64> <i64 8829, i64 8829>, ptr %32, align 16, !tbaa !5
  %index.next.3 = add nuw nsw i64 %index, 16
  %33 = getelementptr inbounds [100000 x i64], ptr %2, i64 0, i64 %index.next.3
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  store <2 x i64> <i64 8829, i64 8829>, ptr %33, align 16, !tbaa !5
  store <2 x i64> <i64 8829, i64 8829>, ptr %34, align 16, !tbaa !5
  %index.next.4 = add nuw nsw i64 %index, 20
  %35 = icmp eq i64 %index.next.4, 100000
  br i1 %35, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %36 = call i32 @distinctCount(ptr noundef nonnull %2, i64 noundef 100000) #4
  %37 = icmp eq i32 %36, 1
  %38 = zext i1 %37 to i32
  %39 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %38, ptr noundef nonnull @.str.36, i32 noundef 49, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.40)
  %.not5 = icmp eq i32 %39, 0
  br i1 %.not5, label %40, label %41

40:                                               ; preds = %middle.block
  call void @acutest_abort_() #5
  unreachable

41:                                               ; preds = %middle.block
  call void @llvm.lifetime.end.p0(i64 800000, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %1) #4
  ret void
}

declare i32 @distinctCount(ptr noundef, i64 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, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass