; LLVM IR from themisvaltinos/Partitioned-Hash-Join :: modules/hopscotch (hopscotch)

; 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 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [100 x i8], align 1
@__PRETTY_FUNCTION__.emptySpace = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @emptySpace(i64 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = zext i32 %8 to i64
  %10 = shl i64 1, %9
  %11 = sub i64 %10, 1
  %12 = load i64, ptr %4, align 8, !tbaa !5
  %13 = icmp eq i64 %11, %12
  br i1 %13, label %14, label %16

14:                                               ; preds = %2
  %15 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %15, ptr %3, align 4
  br label %41

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %17 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %17, ptr %6, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %35, %16
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp ugt i32 %19, 0
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  store i32 2, ptr %7, align 4
  br label %38

22:                                               ; preds = %18
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = sub i32 %24, 1
  %26 = zext i32 %25 to i64
  %27 = lshr i64 %23, %26
  %28 = and i64 %27, 1
  %29 = icmp ne i64 %28, 0
  br i1 %29, label %34, label %30

30:                                               ; preds = %22
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sub i32 %31, %32
  store i32 %33, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %38

34:                                               ; preds = %22
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = add i32 %36, -1
  store i32 %37, ptr %6, align 4, !tbaa !9
  br label %18, !llvm.loop !11

38:                                               ; preds = %30, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %39 = load i32, ptr %7, align 4
  switch i32 %39, label %43 [
    i32 2, label %40
    i32 1, label %41
  ]

40:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 45, ptr noundef @__PRETTY_FUNCTION__.emptySpace) #4
  unreachable

41:                                               ; preds = %38, %14
  %42 = load i32, ptr %3, align 4
  ret i32 %42

43:                                               ; preds = %38
  unreachable
}

; 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
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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 "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 }
attributes #4 = { 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 = !{!"long", !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 = distinct !{!11, !12}
!12 = !{!"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 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [100 x i8], align 1
@__PRETTY_FUNCTION__.emptySpace = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @emptySpace(i64 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = zext i32 %1 to i64
  %notmask = shl nsw i64 -1, %3
  %4 = xor i64 %notmask, %0
  %5 = icmp eq i64 %4, -1
  br i1 %5, label %14, label %.preheader

.preheader:                                       ; preds = %2, %6
  %indvars.iv = phi i64 [ %7, %6 ], [ %3, %2 ]
  %.not = icmp eq i64 %indvars.iv, 0
  br i1 %.not, label %13, label %6

6:                                                ; preds = %.preheader
  %7 = add nsw i64 %indvars.iv, -1
  %8 = shl nuw i64 1, %7
  %9 = and i64 %8, %0
  %.not15 = icmp eq i64 %9, 0
  br i1 %.not15, label %10, label %.preheader, !llvm.loop !5

10:                                               ; preds = %6
  %11 = trunc nuw i64 %indvars.iv to i32
  %12 = sub i32 %1, %11
  br label %14

13:                                               ; preds = %.preheader
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 45, ptr noundef nonnull @__PRETTY_FUNCTION__.emptySpace) #2
  unreachable

14:                                               ; preds = %10, %2
  %.1 = phi i32 [ %12, %10 ], [ %1, %2 ]
  ret i32 %.1
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 = { 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 #2 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass