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

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

%"class.juce::BlowFish" = type { [18 x i32], [4 x %"class.juce::HeapBlock"] }
%"class.juce::HeapBlock" = type { ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce9HeapBlockIjLb0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce9HeapBlockIjLb0EE6mallocEmm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i64 noundef) #2 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce9HeapBlockIjLb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce8BlowFishC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 8 dereferenceable(104) %1) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  %9 = getelementptr inbounds %"class.juce::BlowFish", ptr %8, i32 0, i32 1
  %10 = getelementptr inbounds [4 x %"class.juce::HeapBlock"], ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %"class.juce::HeapBlock", ptr %10, i64 4
  br label %12

12:                                               ; preds = %12, %2
  %13 = phi ptr [ %10, %2 ], [ %14, %12 ]
  call void @_ZN4juce9HeapBlockIjLb0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %13) #3
  %14 = getelementptr inbounds %"class.juce::HeapBlock", ptr %13, i64 1
  %15 = icmp eq ptr %14, %11
  br i1 %15, label %16, label %12

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 4, ptr %5, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %27, %16
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = add nsw i32 %18, -1
  store i32 %19, ptr %5, align 4, !tbaa !9
  %20 = icmp sge i32 %19, 0
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %34

22:                                               ; preds = %17
  %23 = getelementptr inbounds %"class.juce::BlowFish", ptr %8, i32 0, i32 1
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [4 x %"class.juce::HeapBlock"], ptr %23, i64 0, i64 %25
  invoke void @_ZN4juce9HeapBlockIjLb0EE6mallocEmm(ptr noundef nonnull align 8 dereferenceable(8) %26, i64 noundef 256, i64 noundef 4)
          to label %27 unwind label %28

27:                                               ; preds = %22
  br label %17, !llvm.loop !11

28:                                               ; preds = %22
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %6, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  %32 = getelementptr inbounds [4 x %"class.juce::HeapBlock"], ptr %9, i32 0, i32 0
  %33 = getelementptr inbounds %"class.juce::HeapBlock", ptr %32, i64 4
  br label %37

34:                                               ; preds = %21
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call noundef nonnull align 8 dereferenceable(104) ptr @_ZN4juce8BlowFishaSERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %8, ptr noundef nonnull align 8 dereferenceable(104) %35) #3
  ret void

37:                                               ; preds = %37, %28
  %38 = phi ptr [ %33, %28 ], [ %39, %37 ]
  %39 = getelementptr inbounds %"class.juce::HeapBlock", ptr %38, i64 -1
  call void @_ZN4juce9HeapBlockIjLb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %39) #3
  %40 = icmp eq ptr %39, %32
  br i1 %40, label %41, label %37

41:                                               ; preds = %37
  br label %42

42:                                               ; preds = %41
  %43 = load ptr, ptr %6, align 8
  %44 = load i32, ptr %7, align 4
  %45 = insertvalue { ptr, i32 } poison, ptr %43, 0
  %46 = insertvalue { ptr, i32 } %45, i32 %44, 1
  resume { ptr, i32 } %46
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(104) ptr @_ZN4juce8BlowFishaSERKS0_(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 8 dereferenceable(104)) #0 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%"class.juce::HeapBlock" = type { ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce9HeapBlockIjLb0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce9HeapBlockIjLb0EE6mallocEmm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, i64 noundef) local_unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce9HeapBlockIjLb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce8BlowFishC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 8 dereferenceable(104) %1) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
.preheader.preheader:
  %.ptr = getelementptr inbounds i8, ptr %0, i64 72
  tail call void @_ZN4juce9HeapBlockIjLb0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr) #2
  %.ptr.1 = getelementptr inbounds i8, ptr %0, i64 80
  tail call void @_ZN4juce9HeapBlockIjLb0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr.1) #2
  %.ptr.2 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @_ZN4juce9HeapBlockIjLb0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr.2) #2
  %.ptr.3 = getelementptr inbounds i8, ptr %0, i64 96
  tail call void @_ZN4juce9HeapBlockIjLb0EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr.3) #2
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %4
  %indvars.iv = phi i64 [ 4, %.preheader.preheader ], [ %indvars.iv.next, %4 ]
  %.not = icmp eq i64 %indvars.iv, 0
  br i1 %.not, label %2, label %4

2:                                                ; preds = %.preheader
  %3 = tail call noundef nonnull align 8 dereferenceable(104) ptr @_ZN4juce8BlowFishaSERKS0_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 8 dereferenceable(104) %1) #2
  ret void

4:                                                ; preds = %.preheader
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %5 = getelementptr inbounds [4 x %"class.juce::HeapBlock"], ptr %.ptr, i64 0, i64 %indvars.iv.next
  invoke void @_ZN4juce9HeapBlockIjLb0EE6mallocEmm(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef 256, i64 noundef 4)
          to label %.preheader unwind label %6, !llvm.loop !5

6:                                                ; preds = %4
  %7 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN4juce9HeapBlockIjLb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr.3) #2
  tail call void @_ZN4juce9HeapBlockIjLb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr.2) #2
  tail call void @_ZN4juce9HeapBlockIjLb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr.1) #2
  tail call void @_ZN4juce9HeapBlockIjLb0EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %.ptr) #2
  resume { ptr, i32 } %7
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(104) ptr @_ZN4juce8BlowFishaSERKS0_(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #0 align 2

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass