; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/juce_gui_extra.ll (ZN4juce12CodeDocument8Position6moveByEi)

; 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::CodeDocument::Position" = type <{ ptr, i32, i32, i32, i8, [3 x i8] }>
%"class.juce::CodeDocument" = type { %"class.juce::OwnedArray", %"class.juce::Array.8", %"class.juce::UndoManager", i32, i32, i32, [4 x i8], %"class.juce::ListenerList.18", %"class.juce::String" }
%"class.juce::OwnedArray" = type { %"class.juce::ArrayAllocationBase.5", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.5" = type <{ %"class.juce::HeapBlock.6", i32, [4 x i8] }>
%"class.juce::HeapBlock.6" = type { ptr }
%"class.juce::Array.8" = type { %"class.juce::ArrayAllocationBase.9", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.9" = type <{ %"class.juce::HeapBlock.10", i32, [4 x i8] }>
%"class.juce::HeapBlock.10" = type { ptr }
%"class.juce::UndoManager" = type <{ %"class.juce::ChangeBroadcaster", %"class.juce::OwnedArray.13", %"class.juce::OwnedArray.13", %"class.juce::String", i32, i32, i32, i32, i8, i8, [6 x i8] }>
%"class.juce::ChangeBroadcaster" = type { ptr, %"class.juce::ChangeBroadcaster::ChangeBroadcasterCallback", %"class.juce::ListenerList" }
%"class.juce::ChangeBroadcaster::ChangeBroadcasterCallback" = type { %"class.juce::AsyncUpdater", ptr }
%"class.juce::AsyncUpdater" = type { ptr, %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ReferenceCountedObjectPtr" = type { ptr }
%"class.juce::ListenerList" = type { %"class.juce::Array" }
%"class.juce::Array" = type { %"class.juce::ArrayAllocationBase", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase" = type <{ %"class.juce::HeapBlock", i32, [4 x i8] }>
%"class.juce::HeapBlock" = type { ptr }
%"class.juce::OwnedArray.13" = type { %"class.juce::ArrayAllocationBase.14", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.14" = type <{ %"class.juce::HeapBlock.15", i32, [4 x i8] }>
%"class.juce::HeapBlock.15" = type { ptr }
%"class.juce::ListenerList.18" = type { %"class.juce::Array.19" }
%"class.juce::Array.19" = type { %"class.juce::ArrayAllocationBase.20", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.20" = type <{ %"class.juce::HeapBlock.21", i32, [4 x i8] }>
%"class.juce::HeapBlock.21" = type { ptr }
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::CodeDocumentLine" = type <{ %"class.juce::String", i32, i32, i32, [4 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce10OwnedArrayINS_16CodeDocumentLineENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20)) #1 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce10OwnedArrayINS_16CodeDocumentLineENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce12CodeDocument8Position6moveByEi(ptr noundef nonnull align 8 dereferenceable(21) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  br label %7

7:                                                ; preds = %2
  br label %8

8:                                                ; preds = %7
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %50

11:                                               ; preds = %8
  %12 = call noundef i32 @_ZNK4juce12CodeDocument8Position11getPositionEv(ptr noundef nonnull align 8 dereferenceable(21) %6) #4
  call void @_ZN4juce12CodeDocument8Position11setPositionEi(ptr noundef nonnull align 8 dereferenceable(21) %6, i32 noundef %12)
  %13 = getelementptr inbounds %"class.juce::CodeDocument::Position", ptr %6, i32 0, i32 2
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = getelementptr inbounds %"class.juce::CodeDocument::Position", ptr %6, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds %"class.juce::CodeDocument", ptr %16, i32 0, i32 0
  %18 = call noundef i32 @_ZNK4juce10OwnedArrayINS_16CodeDocumentLineENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %17) #4
  %19 = icmp slt i32 %14, %18
  br i1 %19, label %20, label %49

20:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %21 = getelementptr inbounds %"class.juce::CodeDocument::Position", ptr %6, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = getelementptr inbounds %"class.juce::CodeDocument", ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %"class.juce::CodeDocument::Position", ptr %6, i32 0, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = call noundef ptr @_ZNK4juce10OwnedArrayINS_16CodeDocumentLineENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %23, i32 noundef %25) #4
  store ptr %26, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.juce::CodeDocument::Position", ptr %6, i32 0, i32 3
  %28 = load i32, ptr %27, align 8, !tbaa !15
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = add nsw i32 %28, %29
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.juce::CodeDocumentLine", ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = icmp slt i32 %30, %33
  br i1 %34, label %35, label %48

35:                                               ; preds = %20
  %36 = getelementptr inbounds %"class.juce::CodeDocument::Position", ptr %6, i32 0, i32 3
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = add nsw i32 %37, %38
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"class.juce::CodeDocumentLine", ptr %40, i32 0, i32 3
  %42 = load i32, ptr %41, align 8, !tbaa !20
  %43 = add nsw i32 %42, 1
  %44 = icmp sge i32 %39, %43
  br i1 %44, label %45, label %48

45:                                               ; preds = %35
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %4, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %45, %35, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %49

49:                                               ; preds = %48, %11
  br label %50

50:                                               ; preds = %49, %8
  %51 = getelementptr inbounds %"class.juce::CodeDocument::Position", ptr %6, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !21
  %53 = load i32, ptr %4, align 4, !tbaa !9
  %54 = add nsw i32 %52, %53
  call void @_ZN4juce12CodeDocument8Position11setPositionEi(ptr noundef nonnull align 8 dereferenceable(21) %6, i32 noundef %54)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce12CodeDocument8Position11getPositionEv(ptr noundef nonnull align 8 dereferenceable(21)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { 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 #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, !10, i64 12}
!12 = !{!"_ZTSN4juce12CodeDocument8PositionE", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20}
!13 = !{!"bool", !7, i64 0}
!14 = !{!12, !6, i64 0}
!15 = !{!12, !10, i64 16}
!16 = !{!17, !10, i64 12}
!17 = !{!"_ZTSN4juce16CodeDocumentLineE", !18, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!18 = !{!"_ZTSN4juce6StringE", !19, i64 0}
!19 = !{!"_ZTSN4juce16CharPointer_UTF8E", !6, i64 0}
!20 = !{!17, !10, i64 16}
!21 = !{!12, !10, i64 8}


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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce10OwnedArrayINS_16CodeDocumentLineENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20)) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce10OwnedArrayINS_16CodeDocumentLineENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce12CodeDocument8Position6moveByEi(ptr noundef nonnull align 8 dereferenceable(21) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = icmp eq i32 %1, 1
  br i1 %3, label %4, label %24

4:                                                ; preds = %2
  %5 = tail call noundef i32 @_ZNK4juce12CodeDocument8Position11getPositionEv(ptr noundef nonnull align 8 dereferenceable(21) %0) #3
  tail call void @_ZN4juce12CodeDocument8Position11setPositionEi(ptr noundef nonnull align 8 dereferenceable(21) %0, i32 noundef %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = load ptr, ptr %0, align 8, !tbaa !12
  %9 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_16CodeDocumentLineENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %8) #3
  %10 = icmp slt i32 %7, %9
  br i1 %10, label %11, label %24

11:                                               ; preds = %4
  %12 = load ptr, ptr %0, align 8, !tbaa !12
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_16CodeDocumentLineENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %12, i32 noundef %13) #3
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = add nsw i32 %16, 1
  %18 = getelementptr inbounds i8, ptr %14, i64 12
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = icmp slt i32 %17, %19
  br i1 %20, label %21, label %24

21:                                               ; preds = %11
  %22 = getelementptr inbounds i8, ptr %14, i64 16
  %23 = load i32, ptr %22, align 8, !tbaa !18
  %.not = icmp slt i32 %16, %23
  %spec.select = select i1 %.not, i32 1, i32 2
  br label %24

24:                                               ; preds = %21, %11, %4, %2
  %.1 = phi i32 [ 1, %4 ], [ %1, %2 ], [ 1, %11 ], [ %spec.select, %21 ]
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load i32, ptr %25, align 8, !tbaa !19
  %27 = add nsw i32 %26, %.1
  tail call void @_ZN4juce12CodeDocument8Position11setPositionEi(ptr noundef nonnull align 8 dereferenceable(21) %0, i32 noundef %27)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce12CodeDocument8Position11getPositionEv(ptr noundef nonnull align 8 dereferenceable(21)) local_unnamed_addr #2 align 2

attributes #0 = { inlinehint 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 = { 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 = { 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, !10, i64 12}
!6 = !{!"_ZTSN4juce12CodeDocument8PositionE", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 16}
!14 = !{!15, !10, i64 12}
!15 = !{!"_ZTSN4juce16CodeDocumentLineE", !16, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!16 = !{!"_ZTSN4juce6StringE", !17, i64 0}
!17 = !{!"_ZTSN4juce16CharPointer_UTF8E", !7, i64 0}
!18 = !{!15, !10, i64 16}
!19 = !{!6, !10, i64 8}


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