; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/modules/juce_audio_formats/codecs/flac/libFLAC/crc_2e0b869a_FLAC (block)

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

@FLAC__crc8_table = external dso_local constant [256 x i8], align 16

; Function Attrs: nounwind uwtable
define dso_local void @FLAC__crc8_update_block(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %11, %3
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = add i32 %8, -1
  store i32 %9, ptr %5, align 4, !tbaa !9
  %10 = icmp ne i32 %8, 0
  br i1 %10, label %11, label %24

11:                                               ; preds = %7
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = zext i8 %13 to i32
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i32 1
  store ptr %16, ptr %4, align 8, !tbaa !5
  %17 = load i8, ptr %15, align 1, !tbaa !11
  %18 = zext i8 %17 to i32
  %19 = xor i32 %14, %18
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [256 x i8], ptr @FLAC__crc8_table, i64 0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 %22, ptr %23, align 1, !tbaa !11
  br label %7, !llvm.loop !12

24:                                               ; preds = %7
  ret void
}

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

!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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@FLAC__crc8_table = external dso_local local_unnamed_addr constant [256 x i8], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @FLAC__crc8_update_block(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  %.not4 = icmp eq i32 %1, 0
  br i1 %.not4, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %.promoted = load i8, ptr %2, align 1, !tbaa !5
  %xtraiter = and i32 %1, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.preheader

.prol.preheader:                                  ; preds = %.lr.ph, %.prol.preheader
  %4 = phi i8 [ %11, %.prol.preheader ], [ %.promoted, %.lr.ph ]
  %.06.prol = phi ptr [ %6, %.prol.preheader ], [ %0, %.lr.ph ]
  %.035.prol = phi i32 [ %5, %.prol.preheader ], [ %1, %.lr.ph ]
  %prol.iter = phi i32 [ %prol.iter.next, %.prol.preheader ], [ 0, %.lr.ph ]
  %5 = add i32 %.035.prol, -1
  %6 = getelementptr inbounds i8, ptr %.06.prol, i64 1
  %7 = load i8, ptr %.06.prol, align 1, !tbaa !5
  %8 = xor i8 %7, %4
  %9 = zext i8 %8 to i64
  %10 = getelementptr inbounds [256 x i8], ptr @FLAC__crc8_table, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !5
  store i8 %11, ptr %2, align 1, !tbaa !5
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %.prol.preheader, !llvm.loop !8

.prol.loopexit:                                   ; preds = %.prol.preheader, %.lr.ph
  %.unr = phi i8 [ %.promoted, %.lr.ph ], [ %11, %.prol.preheader ]
  %.06.unr = phi ptr [ %0, %.lr.ph ], [ %6, %.prol.preheader ]
  %.035.unr = phi i32 [ %1, %.lr.ph ], [ %5, %.prol.preheader ]
  %12 = icmp ult i32 %1, 4
  br i1 %12, label %._crit_edge, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.prol.loopexit, %.lr.ph.new
  %13 = phi i8 [ %38, %.lr.ph.new ], [ %.unr, %.prol.loopexit ]
  %.06 = phi ptr [ %33, %.lr.ph.new ], [ %.06.unr, %.prol.loopexit ]
  %.035 = phi i32 [ %32, %.lr.ph.new ], [ %.035.unr, %.prol.loopexit ]
  %14 = getelementptr inbounds i8, ptr %.06, i64 1
  %15 = load i8, ptr %.06, align 1, !tbaa !5
  %16 = xor i8 %15, %13
  %17 = zext i8 %16 to i64
  %18 = getelementptr inbounds [256 x i8], ptr @FLAC__crc8_table, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !5
  store i8 %19, ptr %2, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %.06, i64 2
  %21 = load i8, ptr %14, align 1, !tbaa !5
  %22 = xor i8 %21, %19
  %23 = zext i8 %22 to i64
  %24 = getelementptr inbounds [256 x i8], ptr @FLAC__crc8_table, i64 0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !5
  store i8 %25, ptr %2, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %.06, i64 3
  %27 = load i8, ptr %20, align 1, !tbaa !5
  %28 = xor i8 %27, %25
  %29 = zext i8 %28 to i64
  %30 = getelementptr inbounds [256 x i8], ptr @FLAC__crc8_table, i64 0, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !5
  store i8 %31, ptr %2, align 1, !tbaa !5
  %32 = add i32 %.035, -4
  %33 = getelementptr inbounds i8, ptr %.06, i64 4
  %34 = load i8, ptr %26, align 1, !tbaa !5
  %35 = xor i8 %34, %31
  %36 = zext i8 %35 to i64
  %37 = getelementptr inbounds [256 x i8], ptr @FLAC__crc8_table, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !5
  store i8 %38, ptr %2, align 1, !tbaa !5
  %.not.3 = icmp eq i32 %32, 0
  br i1 %.not.3, label %._crit_edge, label %.lr.ph.new, !llvm.loop !10

._crit_edge:                                      ; preds = %.prol.loopexit, %.lr.ph.new, %3
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.unroll.disable"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass