; LLVM IR from rcliftonharvey/dspfilters4juce :: DSPFilters4JUCEDemo/JuceLibraryCode (juce_cryptography)

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

%union.AlignedAccessHelper = type { [2 x i32] }

; 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: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK4juce8BlowFish5applyEPvmMS0_KDoFvRjS2_E(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1, i64 noundef %2, i64 %3, i64 %4) #1 align 2 {
  %6 = alloca i1, align 1
  %7 = alloca { i64, i64 }, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca { i64, i64 }, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  store i64 %3, ptr %15, align 8
  %16 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  store i64 %4, ptr %16, align 8
  %17 = load { i64, i64 }, ptr %7, align 8, !tbaa !5
  store ptr %0, ptr %8, align 8, !tbaa !8
  store ptr %1, ptr %9, align 8, !tbaa !8
  store i64 %2, ptr %10, align 8, !tbaa !10
  store { i64, i64 } %17, ptr %11, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8
  %19 = load i64, ptr %10, align 8, !tbaa !10
  %20 = urem i64 %19, 8
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %5
  store i1 false, ptr %6, align 1
  br label %60

23:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %24 = load i64, ptr %10, align 8, !tbaa !10
  %25 = udiv i64 %24, 8
  store i64 %25, ptr %12, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %26 = load ptr, ptr %9, align 8, !tbaa !8
  store ptr %26, ptr %13, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  store i64 0, ptr %14, align 8, !tbaa !10
  br label %27

27:                                               ; preds = %56, %23
  %28 = load i64, ptr %14, align 8, !tbaa !10
  %29 = load i64, ptr %12, align 8, !tbaa !10
  %30 = icmp ult i64 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  br label %59

32:                                               ; preds = %27
  %33 = load { i64, i64 }, ptr %11, align 8, !tbaa !5
  %34 = extractvalue { i64, i64 } %33, 1
  %35 = getelementptr inbounds i8, ptr %18, i64 %34
  %36 = extractvalue { i64, i64 } %33, 0
  %37 = and i64 %36, 1
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %32
  %40 = load ptr, ptr %35, align 8, !tbaa !12
  %41 = sub i64 %36, 1
  %42 = getelementptr i8, ptr %40, i64 %41, !nosanitize !14
  %43 = load ptr, ptr %42, align 8, !nosanitize !14
  br label %46

44:                                               ; preds = %32
  %45 = inttoptr i64 %36 to ptr
  br label %46

46:                                               ; preds = %44, %39
  %47 = phi ptr [ %43, %39 ], [ %45, %44 ]
  %48 = load ptr, ptr %13, align 8, !tbaa !8
  %49 = load i64, ptr %14, align 8, !tbaa !10
  %50 = getelementptr inbounds %union.AlignedAccessHelper, ptr %48, i64 %49
  %51 = getelementptr inbounds [2 x i32], ptr %50, i64 0, i64 0
  %52 = load ptr, ptr %13, align 8, !tbaa !8
  %53 = load i64, ptr %14, align 8, !tbaa !10
  %54 = getelementptr inbounds %union.AlignedAccessHelper, ptr %52, i64 %53
  %55 = getelementptr inbounds [2 x i32], ptr %54, i64 0, i64 1
  call void %47(ptr noundef nonnull align 8 dereferenceable(104) %35, ptr noundef nonnull align 4 dereferenceable(4) %51, ptr noundef nonnull align 4 dereferenceable(4) %55) #2
  br label %56

56:                                               ; preds = %46
  %57 = load i64, ptr %14, align 8, !tbaa !10
  %58 = add i64 %57, 1
  store i64 %58, ptr %14, align 8, !tbaa !10
  br label %27, !llvm.loop !15

59:                                               ; preds = %31
  store i1 true, ptr %6, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  br label %60

60:                                               ; preds = %59, %22
  %61 = load i1, ptr %6, align 1
  ret i1 %61
}

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

%union.AlignedAccessHelper = type { [2 x i32] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK4juce8BlowFish5applyEPvmMS0_KDoFvRjS2_E(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1, i64 noundef %2, i64 %3, i64 %4) local_unnamed_addr #0 align 2 {
  %6 = and i64 %2, 7
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %7, label %.loopexit

7:                                                ; preds = %5
  %8 = lshr exact i64 %2, 3
  %.not20 = icmp eq i64 %2, 0
  br i1 %.not20, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %7
  %9 = getelementptr inbounds i8, ptr %0, i64 %4
  %10 = and i64 %3, 1
  %.not18 = icmp eq i64 %10, 0
  %11 = inttoptr i64 %3 to ptr
  br i1 %.not18, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %.019.us = phi i64 [ %14, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %12 = getelementptr inbounds %union.AlignedAccessHelper, ptr %1, i64 %.019.us
  %13 = getelementptr inbounds i8, ptr %12, i64 4
  tail call void %11(ptr noundef nonnull align 8 dereferenceable(104) %9, ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13) #1
  %14 = add nuw nsw i64 %.019.us, 1
  %exitcond22.not = icmp eq i64 %14, %8
  br i1 %exitcond22.not, label %.loopexit, label %.lr.ph.split.us, !llvm.loop !5

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %.019 = phi i64 [ %21, %.lr.ph.split ], [ 0, %.lr.ph ]
  %15 = load ptr, ptr %9, align 8, !tbaa !7
  %16 = getelementptr i8, ptr %15, i64 %3
  %17 = getelementptr i8, ptr %16, i64 -1
  %18 = load ptr, ptr %17, align 8, !nosanitize !10
  %19 = getelementptr inbounds %union.AlignedAccessHelper, ptr %1, i64 %.019
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  tail call void %18(ptr noundef nonnull align 8 dereferenceable(104) %9, ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef nonnull align 4 dereferenceable(4) %20) #1
  %21 = add nuw nsw i64 %.019, 1
  %exitcond.not = icmp eq i64 %21, %8
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph.split, !llvm.loop !5

.loopexit:                                        ; preds = %.lr.ph.split, %.lr.ph.split.us, %7, %5
  ret i1 %.not
}

attributes #0 = { mustprogress 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 = { 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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"vtable pointer", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{}


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