; LLVM IR from scemama/slaterlib :: src (core)

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @get_holes(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = zext i32 %15 to i64
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = zext i32 %17 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %13, align 4, !tbaa !5
  store i32 1, ptr %11, align 4, !tbaa !5
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %78, %4
  %20 = load i32, ptr %10, align 4, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %23, label %81

23:                                               ; preds = %19
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = load i32, ptr %10, align 4, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds i64, ptr %24, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %7, align 8, !tbaa !9
  %30 = load i32, ptr %10, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds i64, ptr %29, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = xor i64 %28, %33
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = load i32, ptr %10, align 4, !tbaa !5
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds i64, ptr %35, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = and i64 %34, %39
  store i64 %40, ptr %12, align 8, !tbaa !11
  %41 = load ptr, ptr %6, align 8, !tbaa !9
  %42 = load i32, ptr %10, align 4, !tbaa !5
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds i64, ptr %41, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = load i32, ptr %10, align 4, !tbaa !5
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i64, ptr %46, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !11
  %51 = icmp ne i64 %45, %50
  br i1 %51, label %52, label %75

52:                                               ; preds = %23
  br label %53

53:                                               ; preds = %56, %52
  %54 = load i64, ptr %12, align 8, !tbaa !11
  %55 = icmp ne i64 %54, 0
  br i1 %55, label %56, label %74

56:                                               ; preds = %53
  %57 = load i64, ptr %12, align 8, !tbaa !11
  %58 = call i64 @llvm.cttz.i64(i64 %57, i1 true)
  %59 = trunc i64 %58 to i32
  store i32 %59, ptr %14, align 4, !tbaa !5
  %60 = load i32, ptr %14, align 4, !tbaa !5
  %61 = load i32, ptr %11, align 4, !tbaa !5
  %62 = add i32 %60, %61
  %63 = load ptr, ptr %8, align 8, !tbaa !9
  %64 = load i32, ptr %13, align 4, !tbaa !5
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr %63, i64 %65
  store i32 %62, ptr %66, align 4, !tbaa !5
  %67 = load i32, ptr %14, align 4, !tbaa !5
  %68 = zext i32 %67 to i64
  %69 = shl i64 1, %68
  %70 = load i64, ptr %12, align 8, !tbaa !11
  %71 = xor i64 %70, %69
  store i64 %71, ptr %12, align 8, !tbaa !11
  %72 = load i32, ptr %13, align 4, !tbaa !5
  %73 = add i32 %72, 1
  store i32 %73, ptr %13, align 4, !tbaa !5
  br label %53, !llvm.loop !13

74:                                               ; preds = %53
  br label %75

75:                                               ; preds = %74, %23
  %76 = load i32, ptr %11, align 4, !tbaa !5
  %77 = add i32 %76, 64
  store i32 %77, ptr %11, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %75
  %79 = load i32, ptr %10, align 4, !tbaa !5
  %80 = add i32 %79, 1
  store i32 %80, ptr %10, align 4, !tbaa !5
  br label %19, !llvm.loop !15

81:                                               ; preds = %19
  %82 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %82, ptr %9, align 4, !tbaa !5
  %83 = load i32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %83
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.cttz.i64(i64, i1 immarg) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local i32 @get_holes(i32 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %.not35 = icmp eq i32 %0, 0
  br i1 %.not35, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %wide.trip.count = zext i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.loopexit
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.loopexit ]
  %.02833 = phi i32 [ 0, %.lr.ph.preheader ], [ %.2, %.loopexit ]
  %.03032 = phi i32 [ 1, %.lr.ph.preheader ], [ %19, %.loopexit ]
  %5 = getelementptr inbounds i64, ptr %1, i64 %indvars.iv
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i64, ptr %2, i64 %indvars.iv
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = xor i64 %8, -1
  %10 = and i64 %6, %9
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %.preheader
  %.029 = phi i64 [ %17, %.preheader ], [ %10, %.lr.ph ]
  %.1 = phi i32 [ %18, %.preheader ], [ %.02833, %.lr.ph ]
  %11 = tail call range(i64 0, 65) i64 @llvm.cttz.i64(i64 %.029, i1 true)
  %12 = trunc nuw nsw i64 %11 to i32
  %13 = add i32 %.03032, %12
  %14 = zext i32 %.1 to i64
  %15 = getelementptr inbounds i32, ptr %3, i64 %14
  store i32 %13, ptr %15, align 4, !tbaa !9
  %16 = shl nuw i64 1, %11
  %17 = xor i64 %16, %.029
  %18 = add i32 %.1, 1
  %.old1.not = icmp eq i64 %.029, %16
  br i1 %.old1.not, label %.loopexit, label %.preheader

.loopexit:                                        ; preds = %.preheader, %.lr.ph
  %.2 = phi i32 [ %.02833, %.lr.ph ], [ %18, %.preheader ]
  %19 = add i32 %.03032, 64
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.loopexit, %4
  %.028.lcssa = phi i32 [ 0, %4 ], [ %.2, %.loopexit ]
  ret i32 %.028.lcssa
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.cttz.i64(i64, i1 immarg) #1

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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 speculatable willreturn memory(none) }

!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 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"}


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