; 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::BigInteger" = type <{ %"class.juce::HeapBlock", [4 x i32], i64, i32, i8, [3 x i8] }>
%"class.juce::HeapBlock" = type { ptr }

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

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) #0

; Function Attrs: nounwind
declare void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37)) unnamed_addr #1

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce10BigInteger13getHighestBitEv(ptr noundef nonnull align 8 dereferenceable(37)) #1

declare void @_ZN4juce10BigIntegerC1Ei(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce6Primes15isProbablyPrimeERKNS_10BigIntegerEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %1) #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"class.juce::BigInteger", align 8
  %10 = alloca %"class.juce::BigInteger", align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"class.juce::BigInteger", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call noundef zeroext i1 @_ZNK4juce10BigIntegerixEi(ptr noundef nonnull align 8 dereferenceable(37) %14, i32 noundef 0) #4
  br i1 %15, label %17, label %16

16:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %61

17:                                               ; preds = %2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noundef i32 @_ZNK4juce10BigInteger13getHighestBitEv(ptr noundef nonnull align 8 dereferenceable(37) %18) #4
  %20 = icmp sle i32 %19, 10
  br i1 %20, label %21, label %42

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call noundef i32 @_ZNK4juce10BigInteger16getBitRangeAsIntEii(ptr noundef nonnull align 8 dereferenceable(37) %22, i32 noundef 0, i32 noundef 10) #4
  store i32 %23, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = udiv i32 %24, 2
  store i32 %25, ptr %7, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %37, %21
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = add i32 %27, -1
  store i32 %28, ptr %7, align 4, !tbaa !9
  %29 = icmp ugt i32 %28, 1
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %8, align 4
  br label %38

31:                                               ; preds = %26
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = urem i32 %32, %33
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %38

37:                                               ; preds = %31
  br label %26, !llvm.loop !11

38:                                               ; preds = %36, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %39 = load i32, ptr %8, align 4
  switch i32 %39, label %41 [
    i32 2, label %40
  ]

40:                                               ; preds = %38
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %41

41:                                               ; preds = %40, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %61

42:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #4
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN4juce10BigIntegerC1Ei(ptr noundef nonnull align 8 dereferenceable(37) %10, i32 noundef 223092870)
  invoke void @_ZNK4juce10BigInteger25findGreatestCommonDivisorES0_(ptr dead_on_unwind writable sret(%"class.juce::BigInteger") align 8 %9, ptr noundef nonnull align 8 dereferenceable(37) %43, ptr noundef %10)
          to label %44 unwind label %48

44:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 40, ptr %13) #4
  invoke void @_ZN4juce10BigIntegerC1Ei(ptr noundef nonnull align 8 dereferenceable(37) %13, i32 noundef 1)
          to label %45 unwind label %52

45:                                               ; preds = %44
  %46 = call noundef zeroext i1 @_ZNK4juce10BigIntegerneERKS0_(ptr noundef nonnull align 8 dereferenceable(37) %9, ptr noundef nonnull align 8 dereferenceable(37) %13) #4
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %13) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %13) #4
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %9) #4
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %10) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #4
  br i1 %46, label %47, label %57

47:                                               ; preds = %45
  store i1 false, ptr %3, align 1
  br label %61

48:                                               ; preds = %42
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %11, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %12, align 4
  br label %56

52:                                               ; preds = %44
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %11, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 40, ptr %13) #4
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %9) #4
  br label %56

56:                                               ; preds = %52, %48
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %10) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #4
  br label %63

57:                                               ; preds = %45
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = call noundef zeroext i1 @_ZN4juce13PrimesHelpersL17passesMillerRabinERKNS_10BigIntegerEi(ptr noundef nonnull align 8 dereferenceable(37) %58, i32 noundef %59)
  store i1 %60, ptr %3, align 1
  br label %61

61:                                               ; preds = %57, %47, %41, %16
  %62 = load i1, ptr %3, align 1
  ret i1 %62

63:                                               ; preds = %56
  %64 = load ptr, ptr %11, align 8
  %65 = load i32, ptr %12, align 4
  %66 = insertvalue { ptr, i32 } poison, ptr %64, 0
  %67 = insertvalue { ptr, i32 } %66, i32 %65, 1
  resume { ptr, i32 } %67
}

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZNK4juce10BigIntegerixEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) #1

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce10BigInteger16getBitRangeAsIntEii(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef, i32 noundef) #1

declare void @_ZNK4juce10BigInteger25findGreatestCommonDivisorES0_(ptr dead_on_unwind writable sret(%"class.juce::BigInteger") align 8, ptr noundef nonnull align 8 dereferenceable(37), ptr noundef) #2

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZNK4juce10BigIntegerneERKS0_(ptr noundef nonnull align 8 dereferenceable(37), ptr noundef nonnull align 8 dereferenceable(37)) #1

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN4juce13PrimesHelpersL17passesMillerRabinERKNS_10BigIntegerEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { "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 = { 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 #4 = { 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::BigInteger" = type <{ %"class.juce::HeapBlock", [4 x i32], i64, i32, i8, [3 x i8] }>
%"class.juce::HeapBlock" = type { ptr }

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37)) unnamed_addr #1

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce10BigInteger13getHighestBitEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #1

declare void @_ZN4juce10BigIntegerC1Ei(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce6Primes15isProbablyPrimeERKNS_10BigIntegerEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %1) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.juce::BigInteger", align 8
  %4 = alloca %"class.juce::BigInteger", align 8
  %5 = alloca %"class.juce::BigInteger", align 8
  %6 = tail call noundef zeroext i1 @_ZNK4juce10BigIntegerixEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef 0) #4
  br i1 %6, label %7, label %.critedge

7:                                                ; preds = %2
  %8 = tail call noundef i32 @_ZNK4juce10BigInteger13getHighestBitEv(ptr noundef nonnull align 8 dereferenceable(37) %0) #4
  %9 = icmp slt i32 %8, 11
  br i1 %9, label %10, label %19

10:                                               ; preds = %7
  %11 = tail call noundef i32 @_ZNK4juce10BigInteger16getBitRangeAsIntEii(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef 0, i32 noundef 10) #4
  %12 = lshr i32 %11, 1
  br label %13

13:                                               ; preds = %16, %10
  %.015 = phi i32 [ %12, %10 ], [ %14, %16 ]
  %14 = add i32 %.015, -1
  %15 = icmp ult i32 %14, 2
  br i1 %15, label %.critedge, label %16

16:                                               ; preds = %13
  %17 = urem i32 %11, %14
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %.critedge, label %13, !llvm.loop !5

19:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #4
  call void @_ZN4juce10BigIntegerC1Ei(ptr noundef nonnull align 8 dereferenceable(37) %4, i32 noundef 223092870)
  invoke void @_ZNK4juce10BigInteger25findGreatestCommonDivisorES0_(ptr dead_on_unwind nonnull writable sret(%"class.juce::BigInteger") align 8 %3, ptr noundef nonnull align 8 dereferenceable(37) %0, ptr noundef nonnull %4)
          to label %20 unwind label %23

20:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #4
  invoke void @_ZN4juce10BigIntegerC1Ei(ptr noundef nonnull align 8 dereferenceable(37) %5, i32 noundef 1)
          to label %21 unwind label %25

21:                                               ; preds = %20
  %22 = call noundef zeroext i1 @_ZNK4juce10BigIntegerneERKS0_(ptr noundef nonnull align 8 dereferenceable(37) %3, ptr noundef nonnull align 8 dereferenceable(37) %5) #4
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %5) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #4
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %3) #4
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %4) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #4
  br i1 %22, label %.critedge, label %28

23:                                               ; preds = %19
  %24 = landingpad { ptr, i32 }
          cleanup
  br label %27

25:                                               ; preds = %20
  %26 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #4
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %3) #4
  br label %27

27:                                               ; preds = %25, %23
  %.pn = phi { ptr, i32 } [ %26, %25 ], [ %24, %23 ]
  call void @_ZN4juce10BigIntegerD1Ev(ptr noundef nonnull align 8 dereferenceable(37) %4) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #4
  resume { ptr, i32 } %.pn

28:                                               ; preds = %21
  %29 = call noundef zeroext i1 @_ZN4juce13PrimesHelpersL17passesMillerRabinERKNS_10BigIntegerEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %1)
  br label %.critedge

.critedge:                                        ; preds = %13, %16, %21, %2, %28
  %.2 = phi i1 [ %29, %28 ], [ false, %2 ], [ false, %21 ], [ %15, %16 ], [ %15, %13 ]
  ret i1 %.2
}

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZNK4juce10BigIntegerixEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare noundef i32 @_ZNK4juce10BigInteger16getBitRangeAsIntEii(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef, i32 noundef) local_unnamed_addr #1

declare void @_ZNK4juce10BigInteger25findGreatestCommonDivisorES0_(ptr dead_on_unwind writable sret(%"class.juce::BigInteger") align 8, ptr noundef nonnull align 8 dereferenceable(37), ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZNK4juce10BigIntegerneERKS0_(ptr noundef nonnull align 8 dereferenceable(37), ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN4juce13PrimesHelpersL17passesMillerRabinERKNS_10BigIntegerEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { "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 = { 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 #4 = { 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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass