; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/juce_audio_basics.ll (ZNK4juce7MPEZone12overlapsWithES0_)

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

%"struct.juce::MPEZone" = type { i32, i32, i32, i32 }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK4juce7MPEZone12overlapsWithES0_(ptr noundef nonnull align 4 dereferenceable(16) %0, i64 %1, i64 %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca %"struct.juce::MPEZone", align 4
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.juce::MPEZone", align 4
  %8 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 0
  store i64 %1, ptr %8, align 4
  %9 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 1
  store i64 %2, ptr %9, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %6, align 8
  %11 = getelementptr inbounds %"struct.juce::MPEZone", ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = getelementptr inbounds %"struct.juce::MPEZone", ptr %5, i32 0, i32 0
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = icmp eq i32 %12, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %3
  store i1 true, ptr %4, align 1
  br label %38

17:                                               ; preds = %3
  %18 = getelementptr inbounds %"struct.juce::MPEZone", ptr %10, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = getelementptr inbounds %"struct.juce::MPEZone", ptr %5, i32 0, i32 0
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = icmp sgt i32 %19, %21
  br i1 %22, label %23, label %29

23:                                               ; preds = %17
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 %10, i64 16, i1 false), !tbaa.struct !12
  %24 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %25 = load i64, ptr %24, align 4
  %26 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %27 = load i64, ptr %26, align 4
  %28 = call noundef zeroext i1 @_ZNK4juce7MPEZone12overlapsWithES0_(ptr noundef nonnull align 4 dereferenceable(16) %5, i64 %25, i64 %27) #2
  store i1 %28, ptr %4, align 1
  br label %38

29:                                               ; preds = %17
  %30 = getelementptr inbounds %"struct.juce::MPEZone", ptr %10, i32 0, i32 0
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = getelementptr inbounds %"struct.juce::MPEZone", ptr %10, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !14
  %34 = add nsw i32 %31, %33
  %35 = getelementptr inbounds %"struct.juce::MPEZone", ptr %5, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = icmp sge i32 %34, %36
  store i1 %37, ptr %4, align 1
  br label %38

38:                                               ; preds = %29, %23, %16
  %39 = load i1, ptr %4, align 1
  ret i1 %39
}

attributes #0 = { nocallback nofree 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 = { 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, !11, i64 0}
!10 = !{!"_ZTSN4juce7MPEZoneE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"int", !7, i64 0}
!12 = !{i64 0, i64 4, !13, i64 4, i64 4, !13, i64 8, i64 4, !13, i64 12, i64 4, !13}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 4}


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

%"struct.juce::MPEZone" = type { i32, i32, i32, i32 }

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @_ZNK4juce7MPEZone12overlapsWithES0_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0, i64 %1, i64 %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"struct.juce::MPEZone", align 8
  store i64 %1, ptr %4, align 8
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %2, ptr %5, align 8
  %6 = load i32, ptr %0, align 4, !tbaa !5
  %7 = trunc i64 %1 to i32
  %8 = icmp eq i32 %6, %7
  br i1 %8, label %18, label %9

9:                                                ; preds = %3
  %10 = icmp sgt i32 %6, %7
  br i1 %10, label %11, label %13

11:                                               ; preds = %9
  %.sroa.0.0.copyload = load i64, ptr %0, align 4
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.2.0.copyload = load i64, ptr %.sroa.2.0..sroa_idx, align 4
  %12 = call noundef zeroext i1 @_ZNK4juce7MPEZone12overlapsWithES0_(ptr noundef nonnull align 4 dereferenceable(16) %4, i64 %.sroa.0.0.copyload, i64 %.sroa.2.0.copyload) #1
  br label %18

13:                                               ; preds = %9
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !10
  %16 = add nsw i32 %15, %6
  %17 = icmp sge i32 %16, %7
  br label %18

18:                                               ; preds = %3, %13, %11
  %.0 = phi i1 [ %12, %11 ], [ %17, %13 ], [ true, %3 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(argmem: read) 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN4juce7MPEZoneE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass