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

; 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: nounwind
declare noundef i32 @_ZNK4juce6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(8)) #0

; 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 @_ZNK4juce10TextEditor18findWordBreakAfterEi(ptr noundef nonnull align 8 dereferenceable(600) %0, i32 noundef %1) #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.juce::String", align 8
  %6 = alloca %"class.juce::Range", align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = add nsw i32 %14, 512
  call void @_ZN4juce5RangeIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %6, i32 noundef %13, i32 noundef %15) #4
  %16 = load ptr, ptr %12, align 8, !tbaa !11
  %17 = getelementptr inbounds ptr, ptr %16, i64 45
  %18 = load ptr, ptr %17, align 8
  call void %18(ptr dead_on_unwind writable sret(%"class.juce::String") align 8 %5, ptr noundef nonnull align 8 dereferenceable(600) %12, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %19 = call noundef i32 @_ZNK4juce6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  store i32 %19, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %30, %2
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %28

24:                                               ; preds = %20
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %25) #4
  %27 = call noundef zeroext i1 @_ZN4juce18CharacterFunctions12isWhitespaceEw(i32 noundef signext %26) #4
  br label %28

28:                                               ; preds = %24, %20
  %29 = phi i1 [ false, %20 ], [ %27, %24 ]
  br i1 %29, label %30, label %33

30:                                               ; preds = %28
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %8, align 4, !tbaa !9
  br label %20, !llvm.loop !13

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %34) #4
  %36 = invoke noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext %35)
          to label %37 unwind label %54

37:                                               ; preds = %33
  store i32 %36, ptr %9, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %51, %37
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %42, label %49

42:                                               ; preds = %38
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %44) #4
  %46 = invoke noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext %45)
          to label %47 unwind label %54

47:                                               ; preds = %42
  %48 = icmp eq i32 %43, %46
  br label %49

49:                                               ; preds = %47, %38
  %50 = phi i1 [ false, %38 ], [ %48, %47 ]
  br i1 %50, label %51, label %58

51:                                               ; preds = %49
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %8, align 4, !tbaa !9
  br label %38, !llvm.loop !15

54:                                               ; preds = %42, %33
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %10, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %76

58:                                               ; preds = %49
  br label %59

59:                                               ; preds = %69, %58
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %63, label %67

63:                                               ; preds = %59
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef %64) #4
  %66 = call noundef zeroext i1 @_ZN4juce18CharacterFunctions12isWhitespaceEw(i32 noundef signext %65) #4
  br label %67

67:                                               ; preds = %63, %59
  %68 = phi i1 [ false, %59 ], [ %66, %63 ]
  br i1 %68, label %69, label %72

69:                                               ; preds = %67
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %8, align 4, !tbaa !9
  br label %59, !llvm.loop !16

72:                                               ; preds = %67
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = add nsw i32 %73, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret i32 %75

76:                                               ; preds = %54
  %77 = load ptr, ptr %10, align 8
  %78 = load i32, ptr %11, align 4
  %79 = insertvalue { ptr, i32 } poison, ptr %77, 0
  %80 = insertvalue { ptr, i32 } %79, i32 %78, 1
  resume { ptr, i32 } %80
}

; 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}
!16 = distinct !{!16, !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: nounwind
declare noundef i32 @_ZNK4juce6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

; 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 @_ZNK4juce10TextEditor18findWordBreakAfterEi(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
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %5 = add nsw i32 %1, 512
  call void @_ZN4juce5RangeIiEC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %4, i32 noundef %1, i32 noundef %5) #4
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 360
  %8 = load ptr, ptr %7, align 8
  call void %8(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
  %9 = call noundef i32 @_ZNK4juce6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2, %13
  %.022 = phi i32 [ %14, %13 ], [ 0, %2 ]
  %11 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %.022) #4
  %12 = call noundef zeroext i1 @_ZN4juce18CharacterFunctions12isWhitespaceEw(i32 noundef signext %11) #4
  br i1 %12, label %13, label %.critedge

13:                                               ; preds = %.lr.ph
  %14 = add nuw nsw i32 %.022, 1
  %exitcond.not = icmp eq i32 %14, %9
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !8

.critedge:                                        ; preds = %.lr.ph, %13, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %9, %13 ], [ %.022, %.lr.ph ]
  %15 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %.0.lcssa) #4
  %16 = call noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext %15)
  %17 = icmp slt i32 %.0.lcssa, %9
  br i1 %17, label %.lr.ph26, label %.critedge2

.lr.ph26:                                         ; preds = %.critedge, %21
  %.125 = phi i32 [ %22, %21 ], [ %.0.lcssa, %.critedge ]
  %18 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %.125) #4
  %19 = call noundef i32 @_ZN4juce14TextEditorDefsL20getCharacterCategoryEw(i32 noundef signext %18)
  %20 = icmp eq i32 %16, %19
  br i1 %20, label %21, label %.critedge2

21:                                               ; preds = %.lr.ph26
  %22 = add i32 %.125, 1
  %exitcond35.not = icmp eq i32 %22, %9
  br i1 %exitcond35.not, label %.critedge4, label %.lr.ph26, !llvm.loop !10

.critedge2:                                       ; preds = %.lr.ph26, %.critedge
  %.1.lcssa = phi i32 [ %.0.lcssa, %.critedge ], [ %.125, %.lr.ph26 ]
  %23 = icmp slt i32 %.1.lcssa, %9
  br i1 %23, label %.lr.ph31, label %.critedge4

.lr.ph31:                                         ; preds = %.critedge2, %26
  %.230 = phi i32 [ %27, %26 ], [ %.1.lcssa, %.critedge2 ]
  %24 = call noundef signext i32 @_ZNK4juce6StringixEi(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %.230) #4
  %25 = call noundef zeroext i1 @_ZN4juce18CharacterFunctions12isWhitespaceEw(i32 noundef signext %24) #4
  br i1 %25, label %26, label %.critedge4

26:                                               ; preds = %.lr.ph31
  %27 = add i32 %.230, 1
  %exitcond36.not = icmp eq i32 %27, %9
  br i1 %exitcond36.not, label %.critedge4, label %.lr.ph31, !llvm.loop !11

.critedge4:                                       ; preds = %21, %.lr.ph31, %26, %.critedge2
  %.2.lcssa = phi i32 [ %.1.lcssa, %.critedge2 ], [ %9, %26 ], [ %.230, %.lr.ph31 ], [ %9, %21 ]
  %28 = add nsw i32 %.2.lcssa, %1
  call void @_ZN4juce6StringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret i32 %28
}

; 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}
!11 = distinct !{!11, !9}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass