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

; 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.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] }
%"class.ghc::filesystem::path" = type { %"class.std::__cxx11::basic_string" }
%"class.std::error_code" = type { i32, ptr }

@_ZTIN3ghc10filesystem16filesystem_errorE = external dso_local constant { ptr, ptr, ptr }, align 8

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

; 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: 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) #2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt10error_code5valueEv(ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3ghc10filesystem6detail15systemErrorTextIiEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i32 noundef) #3

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

declare void @__cxa_throw(ptr, ptr, ptr)

declare void @__cxa_free_exception(ptr)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3ghc10filesystem12current_pathERSt10error_code(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::path") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3ghc10filesystem12current_pathEv(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::path") align 8 %0) #3 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.std::error_code", align 8
  %4 = alloca i1, align 1
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %"class.std::error_code", align 8
  %9 = alloca i1, align 1
  store ptr %0, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #5
  call void @_ZNSt10error_codeC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #5
  store i1 false, ptr %4, align 1
  call void @_ZN3ghc10filesystem12current_pathERSt10error_code(ptr dead_on_unwind writable sret(%"class.ghc::filesystem::path") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %3)
  %10 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %3) #5
  br i1 %10, label %11, label %32

11:                                               ; preds = %1
  store i1 true, ptr %9, align 1
  %12 = call ptr @__cxa_allocate_exception(i64 144) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #5
  %13 = call noundef i32 @_ZNKSt10error_code5valueEv(ptr noundef nonnull align 8 dereferenceable(16) %3) #5
  invoke void @_ZN3ghc10filesystem6detail15systemErrorTextIiEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %5, i32 noundef %13)
          to label %14 unwind label %20

14:                                               ; preds = %11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %3, i64 16, i1 false), !tbaa.struct !5
  %15 = getelementptr inbounds { i32, ptr }, ptr %8, i32 0, i32 0
  %16 = load i32, ptr %15, align 8
  %17 = getelementptr inbounds { i32, ptr }, ptr %8, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8
  invoke void @_ZN3ghc10filesystem16filesystem_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10error_code(ptr noundef nonnull align 8 dereferenceable(144) %12, ptr noundef nonnull align 8 dereferenceable(32) %5, i32 %16, ptr %18)
          to label %19 unwind label %24

19:                                               ; preds = %14
  store i1 false, ptr %9, align 1
  invoke void @__cxa_throw(ptr %12, ptr @_ZTIN3ghc10filesystem16filesystem_errorE, ptr @_ZN3ghc10filesystem16filesystem_errorD2Ev) #6
          to label %41 unwind label %24

20:                                               ; preds = %11
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %6, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %7, align 4
  br label %28

24:                                               ; preds = %19, %14
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %6, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %7, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #5
  br label %28

28:                                               ; preds = %24, %20
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #5
  %29 = load i1, ptr %9, align 1
  br i1 %29, label %30, label %31

30:                                               ; preds = %28
  call void @__cxa_free_exception(ptr %12) #5
  br label %31

31:                                               ; preds = %30, %28
  call void @_ZN3ghc10filesystem4pathD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #5
  br label %36

32:                                               ; preds = %1
  store i1 true, ptr %4, align 1
  %33 = load i1, ptr %4, align 1
  br i1 %33, label %35, label %34

34:                                               ; preds = %32
  call void @_ZN3ghc10filesystem4pathD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #5
  br label %35

35:                                               ; preds = %34, %32
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #5
  ret void

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

41:                                               ; preds = %19
  unreachable
}

declare void @_ZN3ghc10filesystem4pathD1Ev(ptr)

declare void @_ZN3ghc10filesystem16filesystem_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10error_code(ptr, ptr, i32, ptr)

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

!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 = !{i64 0, i64 4, !6, i64 8, i64 8, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, 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.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] }
%"class.ghc::filesystem::path" = type { %"class.std::__cxx11::basic_string" }
%"class.std::error_code" = type { i32, ptr }

@_ZTIN3ghc10filesystem16filesystem_errorE = external dso_local constant { ptr, ptr, ptr }, align 8

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

; 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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3ghc10filesystem6detail15systemErrorTextIiEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, i32 noundef) local_unnamed_addr #2

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

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

declare void @__cxa_free_exception(ptr) local_unnamed_addr

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3ghc10filesystem12current_pathEv(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::path") align 8 %0) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.std::error_code", align 8
  %3 = alloca %"class.std::__cxx11::basic_string", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  call void @_ZNSt10error_codeC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  call void @_ZN3ghc10filesystem12current_pathERSt10error_code(ptr dead_on_unwind writable sret(%"class.ghc::filesystem::path") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %4 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  br i1 %4, label %5, label %16

5:                                                ; preds = %1
  %6 = call ptr @__cxa_allocate_exception(i64 144) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  %7 = call noundef i32 @_ZNKSt10error_code5valueEv(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  invoke void @_ZN3ghc10filesystem6detail15systemErrorTextIiEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEET_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %3, i32 noundef %7)
          to label %8 unwind label %.thread

8:                                                ; preds = %5
  %.sroa.0.0.copyload = load i32, ptr %2, align 8, !tbaa !5
  %.sroa.21.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.21.0.copyload = load ptr, ptr %.sroa.21.0..sroa_idx, align 8, !tbaa !9
  invoke void @_ZN3ghc10filesystem16filesystem_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10error_code(ptr noundef nonnull align 8 dereferenceable(144) %6, ptr noundef nonnull align 8 dereferenceable(32) %3, i32 %.sroa.0.0.copyload, ptr %.sroa.21.0.copyload)
          to label %10 unwind label %.thread11

.thread11:                                        ; preds = %8
  %9 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  br label %14

10:                                               ; preds = %8
  invoke void @__cxa_throw(ptr %6, ptr nonnull @_ZTIN3ghc10filesystem16filesystem_errorE, ptr nonnull @_ZN3ghc10filesystem16filesystem_errorD2Ev) #5
          to label %17 unwind label %12

.thread:                                          ; preds = %5
  %11 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  br label %14

12:                                               ; preds = %10
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  br label %15

14:                                               ; preds = %.thread11, %.thread
  %.pn10 = phi { ptr, i32 } [ %11, %.thread ], [ %9, %.thread11 ]
  call void @__cxa_free_exception(ptr %6) #4
  br label %15

15:                                               ; preds = %12, %14
  %.pn9 = phi { ptr, i32 } [ %.pn10, %14 ], [ %13, %12 ]
  call void @_ZN3ghc10filesystem4pathD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  resume { ptr, i32 } %.pn9

16:                                               ; preds = %1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  ret void

17:                                               ; preds = %10
  unreachable
}

declare void @_ZN3ghc10filesystem4pathD1Ev(ptr) local_unnamed_addr

declare void @_ZN3ghc10filesystem16filesystem_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10error_code(ptr, ptr, i32, ptr) local_unnamed_addr

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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