; LLVM IR from DanEngelbrecht/longtail :: lib/blake3/ext (blake3_dispatch)

; 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: nounwind uwtable
declare hidden i32 @get_cpu_features() #1

; 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
declare dso_local void @blake3_compress_xof(ptr noundef, ptr noundef, i8 noundef zeroext, i64 noundef, i8 noundef zeroext, ptr noundef) #1

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

20:                                               ; preds = %7
  br label %58

21:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %22 = call i32 @get_cpu_features()
  store i32 %22, ptr %15, align 4, !tbaa !12
  %23 = load i32, ptr %15, align 4, !tbaa !12
  %24 = and i32 %23, 64
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %34

26:                                               ; preds = %21
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load i8, ptr %10, align 1, !tbaa !9
  %30 = load i64, ptr %11, align 8, !tbaa !10
  %31 = load i8, ptr %12, align 1, !tbaa !9
  %32 = load ptr, ptr %13, align 8, !tbaa !5
  %33 = load i64, ptr %14, align 8, !tbaa !10
  call void @blake3_xof_many_avx512(ptr noundef %27, ptr noundef %28, i8 noundef zeroext %29, i64 noundef %30, i8 noundef zeroext %31, ptr noundef %32, i64 noundef %33)
  store i32 1, ptr %16, align 4
  br label %56

34:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  store i64 0, ptr %17, align 8, !tbaa !10
  br label %35

35:                                               ; preds = %52, %34
  %36 = load i64, ptr %17, align 8, !tbaa !10
  %37 = load i64, ptr %14, align 8, !tbaa !10
  %38 = icmp ult i64 %36, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %35
  store i32 2, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %55

40:                                               ; preds = %35
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i8, ptr %10, align 1, !tbaa !9
  %44 = load i64, ptr %11, align 8, !tbaa !10
  %45 = load i64, ptr %17, align 8, !tbaa !10
  %46 = add i64 %44, %45
  %47 = load i8, ptr %12, align 1, !tbaa !9
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = load i64, ptr %17, align 8, !tbaa !10
  %50 = mul i64 64, %49
  %51 = getelementptr inbounds i8, ptr %48, i64 %50
  call void @blake3_compress_xof(ptr noundef %41, ptr noundef %42, i8 noundef zeroext %43, i64 noundef %46, i8 noundef zeroext %47, ptr noundef %51)
  br label %52

52:                                               ; preds = %40
  %53 = load i64, ptr %17, align 8, !tbaa !10
  %54 = add i64 %53, 1
  store i64 %54, ptr %17, align 8, !tbaa !10
  br label %35, !llvm.loop !14

55:                                               ; preds = %39
  store i32 0, ptr %16, align 4
  br label %56

56:                                               ; preds = %55, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  %57 = load i32, ptr %16, align 4
  switch i32 %57, label %59 [
    i32 0, label %58
    i32 1, label %58
  ]

58:                                               ; preds = %56, %56, %20
  ret void

59:                                               ; preds = %56
  unreachable
}

declare void @blake3_xof_many_avx512(ptr noundef, ptr noundef, i8 noundef zeroext, i64 noundef, i8 noundef zeroext, ptr noundef, i64 noundef) #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 = { "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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

; Function Attrs: nounwind uwtable
declare hidden i32 @get_cpu_features() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @blake3_xof_many(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i64 noundef %3, i8 noundef zeroext %4, ptr noundef %5, i64 noundef %6) local_unnamed_addr #0 {
  %8 = icmp eq i64 %6, 0
  br i1 %8, label %.loopexit, label %9

9:                                                ; preds = %7
  %10 = tail call i32 @get_cpu_features()
  %11 = and i32 %10, 64
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %.preheader, label %12

12:                                               ; preds = %9
  tail call void @blake3_xof_many_avx512(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i64 noundef %3, i8 noundef zeroext %4, ptr noundef %5, i64 noundef %6) #2
  br label %.loopexit

.preheader:                                       ; preds = %9, %.preheader
  %.020 = phi i64 [ %16, %.preheader ], [ 0, %9 ]
  %13 = add i64 %.020, %3
  %14 = shl i64 %.020, 6
  %15 = getelementptr inbounds i8, ptr %5, i64 %14
  tail call void @blake3_compress_xof(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i64 noundef %13, i8 noundef zeroext %4, ptr noundef %15)
  %16 = add nuw i64 %.020, 1
  %exitcond.not = icmp eq i64 %16, %6
  br i1 %exitcond.not, label %.loopexit, label %.preheader, !llvm.loop !5

.loopexit:                                        ; preds = %.preheader, %12, %7
  ret void
}

declare void @blake3_xof_many_avx512(ptr noundef, ptr noundef, i8 noundef zeroext, i64 noundef, i8 noundef zeroext, ptr noundef, i64 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 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass