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

%"class.juce::MD5Generator" = type { [64 x i8], [4 x i32], [2 x i32] }
%"class.juce::MD5" = type { [16 x i8] }

; 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
declare dso_local void @_ZN4juce12MD5GeneratorC2Ev(ptr noundef nonnull align 4 dereferenceable(88)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce12MD5Generator12processBlockEPKvm(ptr noundef nonnull align 4 dereferenceable(88), ptr noundef, i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce12MD5Generator6finishEPv(ptr noundef nonnull align 4 dereferenceable(88), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce3MD513processStreamERNS_11InputStreamEx(ptr noundef nonnull align 1 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"class.juce::MD5Generator", align 4
  %8 = alloca [512 x i8], align 16
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 88, ptr %7) #3
  call void @_ZN4juce12MD5GeneratorC2Ev(ptr noundef nonnull align 4 dereferenceable(88) %7) #3
  %12 = load i64, ptr %6, align 8, !tbaa !9
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %3
  %15 = call noundef i64 @_ZNSt14numeric_limitsIxE3maxEv() #3
  store i64 %15, ptr %6, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %14, %3
  br label %17

17:                                               ; preds = %43, %16
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = icmp sgt i64 %18, 0
  br i1 %19, label %20, label %44

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 512, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds [512 x i8], ptr %8, i64 0, i64 0
  %23 = load i64, ptr %6, align 8, !tbaa !9
  %24 = call noundef i64 @_ZN4juce4jminIxEET_S1_S1_(i64 noundef %23, i64 noundef 512)
  %25 = trunc i64 %24 to i32
  %26 = load ptr, ptr %21, align 8, !tbaa !11
  %27 = getelementptr inbounds ptr, ptr %26, i64 4
  %28 = load ptr, ptr %27, align 8
  %29 = call noundef i32 %28(ptr noundef nonnull align 8 dereferenceable(8) %21, ptr noundef %22, i32 noundef %25)
  store i32 %29, ptr %9, align 4, !tbaa !13
  %30 = load i32, ptr %9, align 4, !tbaa !13
  %31 = icmp sle i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %20
  store i32 3, ptr %10, align 4
  br label %41

33:                                               ; preds = %20
  %34 = load i32, ptr %9, align 4, !tbaa !13
  %35 = sext i32 %34 to i64
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = sub nsw i64 %36, %35
  store i64 %37, ptr %6, align 8, !tbaa !9
  %38 = getelementptr inbounds [512 x i8], ptr %8, i64 0, i64 0
  %39 = load i32, ptr %9, align 4, !tbaa !13
  %40 = sext i32 %39 to i64
  call void @_ZN4juce12MD5Generator12processBlockEPKvm(ptr noundef nonnull align 4 dereferenceable(88) %7, ptr noundef %38, i64 noundef %40) #3
  store i32 0, ptr %10, align 4
  br label %41

41:                                               ; preds = %33, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 512, ptr %8) #3
  %42 = load i32, ptr %10, align 4
  switch i32 %42, label %47 [
    i32 0, label %43
    i32 3, label %44
  ]

43:                                               ; preds = %41
  br label %17, !llvm.loop !15

44:                                               ; preds = %41, %17
  %45 = getelementptr inbounds %"class.juce::MD5", ptr %11, i32 0, i32 0
  %46 = getelementptr inbounds [16 x i8], ptr %45, i64 0, i64 0
  call void @_ZN4juce12MD5Generator6finishEPv(ptr noundef nonnull align 4 dereferenceable(88) %7, ptr noundef %46) #3
  call void @llvm.lifetime.end.p0(i64 88, ptr %7) #3
  ret void

47:                                               ; preds = %41
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNSt14numeric_limitsIxE3maxEv() #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4juce4jminIxEET_S1_S1_(i64 noundef, i64 noundef) #1

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 = { 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 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!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"

%"class.juce::MD5Generator" = type { [64 x i8], [4 x i32], [2 x i32] }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce12MD5GeneratorC2Ev(ptr noundef nonnull align 4 dereferenceable(88)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce12MD5Generator12processBlockEPKvm(ptr noundef nonnull align 4 dereferenceable(88), ptr noundef, i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce12MD5Generator6finishEPv(ptr noundef nonnull align 4 dereferenceable(88), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce3MD513processStreamERNS_11InputStreamEx(ptr noundef nonnull align 1 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %"class.juce::MD5Generator", align 4
  %5 = alloca [512 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %4) #3
  call void @_ZN4juce12MD5GeneratorC2Ev(ptr noundef nonnull align 4 dereferenceable(88) %4) #3
  %6 = icmp slt i64 %2, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = call noundef i64 @_ZNSt14numeric_limitsIxE3maxEv() #3
  br label %9

9:                                                ; preds = %7, %3
  %.09 = phi i64 [ %8, %7 ], [ %2, %3 ]
  %10 = icmp sgt i64 %.09, 0
  br i1 %10, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %9, %18
  %.115 = phi i64 [ %20, %18 ], [ %.09, %9 ]
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %5) #3
  %11 = call noundef i64 @_ZN4juce4jminIxEET_S1_S1_(i64 noundef %.115, i64 noundef 512)
  %12 = trunc i64 %11 to i32
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 32
  %15 = load ptr, ptr %14, align 8
  %16 = call noundef i32 %15(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %5, i32 noundef %12)
  %17 = icmp slt i32 %16, 1
  br i1 %17, label %.thread, label %18

.thread:                                          ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %5) #3
  br label %.loopexit

18:                                               ; preds = %.lr.ph
  %19 = zext nneg i32 %16 to i64
  %20 = sub nsw i64 %.115, %19
  call void @_ZN4juce12MD5Generator12processBlockEPKvm(ptr noundef nonnull align 4 dereferenceable(88) %4, ptr noundef nonnull %5, i64 noundef %19) #3
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %5) #3
  %21 = icmp sgt i64 %20, 0
  br i1 %21, label %.lr.ph, label %.loopexit

.loopexit:                                        ; preds = %18, %9, %.thread
  call void @_ZN4juce12MD5Generator6finishEPv(ptr noundef nonnull align 4 dereferenceable(88) %4, ptr noundef nonnull %0) #3
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %4) #3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNSt14numeric_limitsIxE3maxEv() local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4juce4jminIxEET_S1_S1_(i64 noundef, i64 noundef) local_unnamed_addr #1

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


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