; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode (juce_gui_basics)

; 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::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::Range" = type { i32, i32 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0

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

; 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 noundef i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce5RangeIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #2 align 2

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

16:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %79

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = sub nsw i32 %18, 512
  %20 = call noundef i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef 0, i32 noundef %19)
  store i32 %20, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN4juce5RangeIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %8, i32 noundef %21, i32 noundef %22) #4
  %23 = load ptr, ptr %13, align 8, !tbaa !11
  %24 = getelementptr inbounds ptr, ptr %23, i64 45
  %25 = load ptr, ptr %24, align 8
  call void %25(ptr dead_on_unwind writable sret(%"class.juce::String") align 8 %7, ptr noundef nonnull align 8 dereferenceable(600) %13, ptr noundef nonnull align 4 dereferenceable(8) %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = sub nsw i32 %26, %27
  store i32 %28, ptr %9, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %39, %17
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %32, label %37

32:                                               ; preds = %29
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = sub nsw i32 %33, 1
  %35 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef %34) #4
  %36 = call noundef zeroext i1 @_ZN4juce18CharacterFunctions12isWhitespaceEw(i32 noundef signext %35) #4
  br label %37

37:                                               ; preds = %32, %29
  %38 = phi i1 [ false, %29 ], [ %36, %32 ]
  br i1 %38, label %39, label %42

39:                                               ; preds = %37
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = add nsw i32 %40, -1
  store i32 %41, ptr %9, align 4, !tbaa !9
  br label %29, !llvm.loop !13

42:                                               ; preds = %37
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %45, label %72

45:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = sub nsw i32 %46, 1
  %48 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef %47) #4
  %49 = invoke noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext %48)
          to label %50 unwind label %67

50:                                               ; preds = %45
  store i32 %49, ptr %10, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %64, %50
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %54, label %62

54:                                               ; preds = %51
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = sub nsw i32 %56, 1
  %58 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef %57) #4
  %59 = invoke noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext %58)
          to label %60 unwind label %67

60:                                               ; preds = %54
  %61 = icmp eq i32 %55, %59
  br label %62

62:                                               ; preds = %60, %51
  %63 = phi i1 [ false, %51 ], [ %61, %60 ]
  br i1 %63, label %64, label %71

64:                                               ; preds = %62
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = add nsw i32 %65, -1
  store i32 %66, ptr %9, align 4, !tbaa !9
  br label %51, !llvm.loop !15

67:                                               ; preds = %54, %45
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %11, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %81

71:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %72

72:                                               ; preds = %71, %42
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %6, align 4, !tbaa !9
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = add nsw i32 %76, %77
  store i32 %78, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %79

79:                                               ; preds = %75, %16
  %80 = load i32, ptr %3, align 4
  ret i32 %80

81:                                               ; preds = %67
  %82 = load ptr, ptr %11, align 8
  %83 = load i32, ptr %12, align 4
  %84 = insertvalue { ptr, i32 } poison, ptr %82, 0
  %85 = insertvalue { ptr, i32 } %84, i32 %83, 1
  resume { ptr, i32 } %85
}

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZN4juce18CharacterFunctions12isWhitespaceEw(i32 noundef signext) #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::Range" = type { i32, i32 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0

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

; Function Attrs: mustprogress 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 noundef i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce5RangeIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK4juce10TextEditor19findWordBreakBeforeEi(ptr noundef nonnull align 8 dereferenceable(600) %0, i32 noundef %1) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.juce::String", align 8
  %4 = alloca %"class.juce::Range", align 4
  %5 = icmp slt i32 %1, 1
  br i1 %5, label %29, label %6

6:                                                ; preds = %2
  %7 = add nsw i32 %1, -512
  %8 = tail call noundef i32 @_ZN4juce4jmaxIiEET_S1_S1_(i32 noundef 0, i32 noundef %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZN4juce5RangeIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %4, i32 noundef %8, i32 noundef %1) #4
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 360
  %11 = load ptr, ptr %10, align 8
  call void %11(ptr dead_on_unwind nonnull writable sret(%"class.juce::String") align 8 %3, ptr noundef nonnull align 8 dereferenceable(600) %0, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %12 = sub nsw i32 %1, %8
  br label %13

13:                                               ; preds = %15, %6
  %.020 = phi i32 [ %12, %6 ], [ %16, %15 ]
  %14 = icmp sgt i32 %.020, 0
  br i1 %14, label %15, label %.critedge2

15:                                               ; preds = %13
  %16 = add nsw i32 %.020, -1
  %17 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %16) #4
  %18 = call noundef zeroext i1 @_ZN4juce18CharacterFunctions12isWhitespaceEw(i32 noundef signext %17) #4
  br i1 %18, label %13, label %.critedge, !llvm.loop !8

.critedge:                                        ; preds = %15
  %19 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %16) #4
  %20 = call noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext %19)
  br label %21

21:                                               ; preds = %23, %.critedge
  %.1 = phi i32 [ %.020, %.critedge ], [ %24, %23 ]
  %22 = icmp sgt i32 %.1, 0
  br i1 %22, label %23, label %.critedge2

23:                                               ; preds = %21
  %24 = add nsw i32 %.1, -1
  %25 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %24) #4
  %26 = call noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext %25)
  %27 = icmp eq i32 %20, %26
  br i1 %27, label %21, label %.critedge2, !llvm.loop !10

.critedge2:                                       ; preds = %13, %23, %21
  %.2 = phi i32 [ %.1, %23 ], [ 0, %21 ], [ %.020, %13 ]
  %28 = add nsw i32 %.2, %8
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br label %29

29:                                               ; preds = %2, %.critedge2
  %.0 = phi i32 [ %28, %.critedge2 ], [ 0, %2 ]
  ret i32 %.0
}

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZN4juce18CharacterFunctions12isWhitespaceEw(i32 noundef signext) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass