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

; 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: nounwind uwtable
define dso_local void @blake3_hash_many_portable(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, i1 noundef zeroext %5, i8 noundef zeroext %6, i8 noundef zeroext %7, i8 noundef zeroext %8, ptr noundef %9) #0 {
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i8, align 1
  %17 = alloca i8, align 1
  %18 = alloca i8, align 1
  %19 = alloca i8, align 1
  %20 = alloca ptr, align 8
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i64 %1, ptr %12, align 8, !tbaa !9
  store i64 %2, ptr %13, align 8, !tbaa !9
  store ptr %3, ptr %14, align 8, !tbaa !5
  store i64 %4, ptr %15, align 8, !tbaa !9
  %21 = zext i1 %5 to i8
  store i8 %21, ptr %16, align 1, !tbaa !11
  store i8 %6, ptr %17, align 1, !tbaa !13
  store i8 %7, ptr %18, align 1, !tbaa !13
  store i8 %8, ptr %19, align 1, !tbaa !13
  store ptr %9, ptr %20, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %41, %10
  %23 = load i64, ptr %12, align 8, !tbaa !9
  %24 = icmp ugt i64 %23, 0
  br i1 %24, label %25, label %48

25:                                               ; preds = %22
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = getelementptr inbounds ptr, ptr %26, i64 0
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = load i64, ptr %13, align 8, !tbaa !9
  %30 = load ptr, ptr %14, align 8, !tbaa !5
  %31 = load i64, ptr %15, align 8, !tbaa !9
  %32 = load i8, ptr %17, align 1, !tbaa !13
  %33 = load i8, ptr %18, align 1, !tbaa !13
  %34 = load i8, ptr %19, align 1, !tbaa !13
  %35 = load ptr, ptr %20, align 8, !tbaa !5
  call void @hash_one_portable(ptr noundef %28, i64 noundef %29, ptr noundef %30, i64 noundef %31, i8 noundef zeroext %32, i8 noundef zeroext %33, i8 noundef zeroext %34, ptr noundef %35)
  %36 = load i8, ptr %16, align 1, !tbaa !11, !range !14, !noundef !15
  %37 = trunc i8 %36 to i1
  br i1 %37, label %38, label %41

38:                                               ; preds = %25
  %39 = load i64, ptr %15, align 8, !tbaa !9
  %40 = add i64 %39, 1
  store i64 %40, ptr %15, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %38, %25
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds ptr, ptr %42, i64 1
  store ptr %43, ptr %11, align 8, !tbaa !5
  %44 = load i64, ptr %12, align 8, !tbaa !9
  %45 = sub i64 %44, 1
  store i64 %45, ptr %12, align 8, !tbaa !9
  %46 = load ptr, ptr %20, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 32
  store ptr %47, ptr %20, align 8, !tbaa !5
  br label %22, !llvm.loop !16

48:                                               ; preds = %22
  ret void
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @hash_one_portable(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, ptr noundef) #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 = { alwaysinline 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" }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"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
define dso_local void @blake3_hash_many_portable(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, i1 noundef zeroext %5, i8 noundef zeroext %6, i8 noundef zeroext %7, i8 noundef zeroext %8, ptr noundef %9) local_unnamed_addr #0 {
  %.not16 = icmp eq i64 %1, 0
  br i1 %.not16, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %11 = zext i1 %5 to i64
  br label %12

12:                                               ; preds = %.lr.ph, %12
  %.020 = phi ptr [ %9, %.lr.ph ], [ %16, %12 ]
  %.01319 = phi ptr [ %0, %.lr.ph ], [ %14, %12 ]
  %.01418 = phi i64 [ %1, %.lr.ph ], [ %15, %12 ]
  %.01517 = phi i64 [ %4, %.lr.ph ], [ %spec.select, %12 ]
  %13 = load ptr, ptr %.01319, align 8, !tbaa !5
  tail call void @hash_one_portable(ptr noundef %13, i64 noundef %2, ptr noundef %3, i64 noundef %.01517, i8 noundef zeroext %6, i8 noundef zeroext %7, i8 noundef zeroext %8, ptr noundef %.020)
  %spec.select = add i64 %.01517, %11
  %14 = getelementptr inbounds i8, ptr %.01319, i64 8
  %15 = add i64 %.01418, -1
  %16 = getelementptr inbounds i8, ptr %.020, i64 32
  %.not = icmp eq i64 %15, 0
  br i1 %.not, label %._crit_edge, label %12, !llvm.loop !9

._crit_edge:                                      ; preds = %12, %10
  ret void
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @hash_one_portable(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, 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 = { alwaysinline 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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass