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

; 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::File" = type { %"class.juce::String" }
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::GenericScopedLock" = type { ptr }
%"class.juce::StringRef" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::DirectoryContentsList" = type <{ %"class.juce::ChangeBroadcaster", %"class.juce::TimeSliceClient", %"class.juce::File", ptr, ptr, i32, [4 x i8], %"class.juce::CriticalSection", %"class.juce::OwnedArray.219", %"class.juce::ScopedPointer.224", i8, [7 x i8] }>
%"class.juce::ChangeBroadcaster" = type { ptr, %"class.juce::ChangeBroadcaster::ChangeBroadcasterCallback", %"class.juce::ListenerList.39" }
%"class.juce::ChangeBroadcaster::ChangeBroadcasterCallback" = type { %"class.juce::AsyncUpdater", ptr }
%"class.juce::AsyncUpdater" = type { ptr, %"class.juce::ReferenceCountedObjectPtr.15" }
%"class.juce::ReferenceCountedObjectPtr.15" = type { ptr }
%"class.juce::ListenerList.39" = type { %"class.juce::Array.40" }
%"class.juce::Array.40" = type { %"class.juce::ArrayAllocationBase.41", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.41" = type <{ %"class.juce::HeapBlock.42", i32, [4 x i8] }>
%"class.juce::HeapBlock.42" = type { ptr }
%"class.juce::TimeSliceClient" = type { ptr, %"class.juce::Time" }
%"class.juce::Time" = type { i64 }
%"class.juce::CriticalSection" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.juce::OwnedArray.219" = type { %"class.juce::ArrayAllocationBase.220", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.220" = type <{ %"class.juce::HeapBlock.221", i32, [4 x i8] }>
%"class.juce::HeapBlock.221" = type { ptr }
%"class.juce::ScopedPointer.224" = type { ptr }
%"struct.juce::DirectoryContentsList::FileInfo" = type <{ %"class.juce::String", i64, %"class.juce::Time", %"class.juce::Time", i8, i8, [6 x i8] }>

declare i32 @__gxx_personality_v0(...)

; 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: nounwind
declare void @_ZN4juce9StringRefC1ERKNS_6StringE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK4juce21DirectoryContentsList7getFileEi(ptr dead_on_unwind noalias writable sret(%"class.juce::File") align 8 %0, ptr noundef nonnull align 8 dereferenceable(177) %1, i32 noundef %2) #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.juce::GenericScopedLock", align 8
  %8 = alloca ptr, align 8
  %9 = alloca %"class.juce::StringRef", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %14 = getelementptr inbounds %"class.juce::DirectoryContentsList", ptr %13, i32 0, i32 7
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(40) %14) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %15 = getelementptr inbounds %"class.juce::DirectoryContentsList", ptr %13, i32 0, i32 8
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = call noundef ptr @_ZNK4juce10OwnedArrayINS_21DirectoryContentsList8FileInfoENS_20DummyCriticalSectionEEixEi(ptr noundef nonnull align 8 dereferenceable(20) %15, i32 noundef %16) #6
  store ptr %17, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %29

20:                                               ; preds = %3
  %21 = getelementptr inbounds %"class.juce::DirectoryContentsList", ptr %13, i32 0, i32 2
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.juce::DirectoryContentsList::FileInfo", ptr %22, i32 0, i32 0
  call void @_ZN4juce9StringRefC1ERKNS_6StringE(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %23) #6
  invoke void @_ZNK4juce4File12getChildFileENS_9StringRefE(ptr dead_on_unwind writable sret(%"class.juce::File") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %21, ptr noundef %9)
          to label %24 unwind label %25

24:                                               ; preds = %20
  store i32 1, ptr %12, align 4
  br label %30

25:                                               ; preds = %20
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %10, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %34

29:                                               ; preds = %3
  store i32 0, ptr %12, align 4
  br label %30

30:                                               ; preds = %29, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %31 = load i32, ptr %12, align 4
  switch i32 %31, label %33 [
    i32 0, label %32
  ]

32:                                               ; preds = %30
  call void @_ZN4juce4FileC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #6
  store i32 1, ptr %12, align 4
  br label %33

33:                                               ; preds = %32, %30
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret void

34:                                               ; preds = %25
  %35 = load ptr, ptr %10, align 8
  %36 = load i32, ptr %11, align 4
  %37 = insertvalue { ptr, i32 } poison, ptr %35, 0
  %38 = insertvalue { ptr, i32 } %37, i32 %36, 1
  resume { ptr, i32 } %38
}

declare void @_ZNK4juce4File12getChildFileENS_9StringRefE(ptr dead_on_unwind writable sret(%"class.juce::File") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5

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 = { 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 = { 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 #4 = { 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 #5 = { "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 #6 = { 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}


; 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::File" = type { %"class.juce::String" }
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }
%"class.juce::GenericScopedLock" = type { ptr }
%"class.juce::StringRef" = type { %"class.juce::CharPointer_UTF8" }

declare i32 @__gxx_personality_v0(...)

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

; 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 @_ZN4juce9StringRefC1ERKNS_6StringE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK4juce21DirectoryContentsList7getFileEi(ptr dead_on_unwind noalias writable sret(%"class.juce::File") align 8 %0, ptr noundef nonnull align 8 dereferenceable(177) %1, i32 noundef %2) local_unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.juce::GenericScopedLock", align 8
  %5 = alloca %"class.juce::StringRef", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %6 = getelementptr inbounds i8, ptr %1, i64 104
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(40) %6) #6
  %7 = getelementptr inbounds i8, ptr %1, i64 144
  %8 = call noundef ptr @_ZNK4juce10OwnedArrayINS_21DirectoryContentsList8FileInfoENS_20DummyCriticalSectionEEixEi(ptr noundef nonnull align 8 dereferenceable(20) %7, i32 noundef %2) #6
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %.critedge, label %9

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %1, i64 72
  call void @_ZN4juce9StringRefC1ERKNS_6StringE(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %8) #6
  invoke void @_ZNK4juce4File12getChildFileENS_9StringRefE(ptr dead_on_unwind writable sret(%"class.juce::File") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull %5)
          to label %13 unwind label %11

11:                                               ; preds = %9
  %12 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  resume { ptr, i32 } %12

.critedge:                                        ; preds = %3
  call void @_ZN4juce4FileC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #6
  br label %13

13:                                               ; preds = %9, %.critedge
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  ret void
}

declare void @_ZNK4juce4File12getChildFileENS_9StringRefE(ptr dead_on_unwind writable sret(%"class.juce::File") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #5

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 = { 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 = { 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 #4 = { 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 #5 = { "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 #6 = { 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)"}


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