; LLVM IR from gulrak/filesystem :: test/impl_test.ll (ZNK3ghc10filesystem4path8filenameEv)

; 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.ghc::filesystem::path::iterator" = type { %"class.__gnu_cxx::__normal_iterator", %"class.__gnu_cxx::__normal_iterator", %"class.__gnu_cxx::__normal_iterator", %"class.__gnu_cxx::__normal_iterator", %"class.__gnu_cxx::__normal_iterator", %"class.ghc::filesystem::path" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.ghc::filesystem::path" = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3ghc10filesystem4path3endEv(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::path::iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3ghc10filesystem4path8iteratordeEv(ptr noundef nonnull align 8 dereferenceable(72)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3ghc10filesystem4path8filenameEv(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::path") align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.ghc::filesystem::path::iterator", align 8
  %6 = alloca i1, align 1
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = call noundef zeroext i1 @_ZNK3ghc10filesystem4path17has_relative_pathEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
  store i1 false, ptr %6, align 1
  store i1 false, ptr %7, align 1
  br i1 %11, label %13, label %12

12:                                               ; preds = %2
  call void @_ZN3ghc10filesystem4pathC1Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #4
  br label %19

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 72, ptr %5) #4
  store i1 true, ptr %6, align 1
  call void @_ZNK3ghc10filesystem4path3endEv(ptr dead_on_unwind writable sret(%"class.ghc::filesystem::path::iterator") align 8 %5, ptr noundef nonnull align 8 dereferenceable(32) %10)
  store i1 true, ptr %7, align 1
  %14 = invoke noundef nonnull align 8 dereferenceable(72) ptr @_ZN3ghc10filesystem4path8iteratormmEv(ptr noundef nonnull align 8 dereferenceable(72) %5)
          to label %15 unwind label %26

15:                                               ; preds = %13
  %16 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3ghc10filesystem4path8iteratordeEv(ptr noundef nonnull align 8 dereferenceable(72) %14)
          to label %17 unwind label %26

17:                                               ; preds = %15
  invoke void @_ZN3ghc10filesystem4pathC1ERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %16)
          to label %18 unwind label %26

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18, %12
  %20 = load i1, ptr %7, align 1
  br i1 %20, label %21, label %22

21:                                               ; preds = %19
  call void @_ZN3ghc10filesystem4path8iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %5) #4
  br label %22

22:                                               ; preds = %21, %19
  %23 = load i1, ptr %6, align 1
  br i1 %23, label %24, label %25

24:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 72, ptr %5) #4
  br label %25

25:                                               ; preds = %24, %22
  ret void

26:                                               ; preds = %17, %15, %13
  %27 = landingpad { ptr, i32 }
          cleanup
  %28 = extractvalue { ptr, i32 } %27, 0
  store ptr %28, ptr %8, align 8
  %29 = extractvalue { ptr, i32 } %27, 1
  store i32 %29, ptr %9, align 4
  %30 = load i1, ptr %7, align 1
  br i1 %30, label %31, label %32

31:                                               ; preds = %26
  call void @_ZN3ghc10filesystem4path8iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %5) #4
  br label %32

32:                                               ; preds = %31, %26
  %33 = load i1, ptr %6, align 1
  br i1 %33, label %34, label %35

34:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 72, ptr %5) #4
  br label %35

35:                                               ; preds = %34, %32
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %8, align 8
  %38 = load i32, ptr %9, align 4
  %39 = insertvalue { ptr, i32 } poison, ptr %37, 0
  %40 = insertvalue { ptr, i32 } %39, i32 %38, 1
  resume { ptr, i32 } %40
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3ghc10filesystem4path17has_relative_pathEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN3ghc10filesystem4path8iteratormmEv(ptr noundef nonnull align 8 dereferenceable(72)) #1 align 2

declare void @_ZN3ghc10filesystem4pathC1Ev(ptr)

declare void @_ZN3ghc10filesystem4pathC1ERKS1_(ptr, ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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"}


; 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.ghc::filesystem::path::iterator" = type { %"class.__gnu_cxx::__normal_iterator", %"class.__gnu_cxx::__normal_iterator", %"class.__gnu_cxx::__normal_iterator", %"class.__gnu_cxx::__normal_iterator", %"class.__gnu_cxx::__normal_iterator", %"class.ghc::filesystem::path" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.ghc::filesystem::path" = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3ghc10filesystem4path3endEv(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::path::iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3ghc10filesystem4path8iteratordeEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3ghc10filesystem4path8filenameEv(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::path") align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.ghc::filesystem::path::iterator", align 8
  %4 = tail call noundef zeroext i1 @_ZNK3ghc10filesystem4path17has_relative_pathEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  br i1 %4, label %5, label %9

5:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %3) #4
  call void @_ZNK3ghc10filesystem4path3endEv(ptr dead_on_unwind nonnull writable sret(%"class.ghc::filesystem::path::iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(32) %1)
  %6 = invoke noundef nonnull align 8 dereferenceable(72) ptr @_ZN3ghc10filesystem4path8iteratormmEv(ptr noundef nonnull align 8 dereferenceable(72) %3)
          to label %7 unwind label %11

7:                                                ; preds = %5
  %8 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3ghc10filesystem4path8iteratordeEv(ptr noundef nonnull align 8 dereferenceable(72) %6)
  invoke void @_ZN3ghc10filesystem4pathC1ERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %8)
          to label %10 unwind label %11

9:                                                ; preds = %2
  tail call void @_ZN3ghc10filesystem4pathC1Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #4
  br label %.critedge

10:                                               ; preds = %7
  call void @_ZN3ghc10filesystem4path8iteratorD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %3) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #4
  br label %.critedge

.critedge:                                        ; preds = %9, %10
  ret void

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3ghc10filesystem4path17has_relative_pathEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN3ghc10filesystem4path8iteratormmEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #1 align 2

declare void @_ZN3ghc10filesystem4pathC1Ev(ptr) local_unnamed_addr

declare void @_ZN3ghc10filesystem4pathC1ERKS1_(ptr, ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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)"}


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