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

; 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::file_status" = type <{ i32, i16, [2 x i8] }>
%"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] }
%"class.std::error_code" = type { i32, ptr }
%"class.ghc::filesystem::directory_iterator" = type { %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i32, ptr } @_ZN3ghc10filesystem6detail15make_error_codeENS1_14portable_errorE(i32 noundef) #0

; 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 dso_local noundef zeroext i1 @_ZN3ghc10filesystem6detail18is_not_found_errorERSt10error_code(ptr noundef nonnull align 8 dereferenceable(16)) #0

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

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3ghc10filesystemeqERKNS0_4pathES3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3ghc10filesystem4pathC2IA2_cS1_EERKT_NS1_6formatE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 1 dereferenceable(2), i32 noundef) unnamed_addr #4 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3ghc10filesystem14symlink_statusERKNS0_4pathERSt10error_code(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::file_status") align 4, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3ghc10filesystem6existsENS0_11file_statusE(ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3ghc10filesystem12is_directoryENS0_11file_statusE(ptr noundef) #0

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN3ghc10filesystem10remove_allERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"class.ghc::filesystem::path", align 8
  %8 = alloca %"class.std::error_code", align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::error_code", align 8
  %11 = alloca %"class.ghc::filesystem::file_status", align 4
  %12 = alloca %"class.ghc::filesystem::file_status", align 4
  %13 = alloca %"class.ghc::filesystem::file_status", align 4
  %14 = alloca i1, align 1
  %15 = alloca %"class.ghc::filesystem::directory_iterator", align 8
  %16 = alloca %"class.ghc::filesystem::directory_iterator", align 8
  %17 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNSt10error_code5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #5
  invoke void @_ZN3ghc10filesystem4pathC2IA2_cS1_EERKT_NS1_6formatE(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 1 dereferenceable(2) @.str.3, i32 noundef 2)
          to label %20 unwind label %128

20:                                               ; preds = %2
  %21 = call noundef zeroext i1 @_ZN3ghc10filesystemeqERKNS0_4pathES3_(ptr noundef nonnull align 8 dereferenceable(32) %19, ptr noundef nonnull align 8 dereferenceable(32) %7) #5
  call void @_ZN3ghc10filesystem4pathD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #5
  br i1 %21, label %22, label %29

22:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %23 = call { i32, ptr } @_ZN3ghc10filesystem6detail15make_error_codeENS1_14portable_errorE(i32 noundef 3)
  %24 = getelementptr inbounds { i32, ptr }, ptr %8, i32 0, i32 0
  %25 = extractvalue { i32, ptr } %23, 0
  store i32 %25, ptr %24, align 8
  %26 = getelementptr inbounds { i32, ptr }, ptr %8, i32 0, i32 1
  %27 = extractvalue { i32, ptr } %23, 1
  store ptr %27, ptr %26, align 8
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %28, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %126

29:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #5
  call void @_ZNSt10error_codeC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3ghc10filesystem14symlink_statusERKNS0_4pathERSt10error_code(ptr dead_on_unwind writable sret(%"class.ghc::filesystem::file_status") align 4 %11, ptr noundef nonnull align 8 dereferenceable(32) %30, ptr noundef nonnull align 8 dereferenceable(16) %10) #5
  call void @_ZN3ghc10filesystem11file_statusC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(6) %12, ptr noundef nonnull align 4 dereferenceable(6) %11) #5
  %31 = call noundef zeroext i1 @_ZN3ghc10filesystem6existsENS0_11file_statusE(ptr noundef %12) #5
  store i1 false, ptr %14, align 1
  br i1 %31, label %32, label %34

32:                                               ; preds = %29
  call void @_ZN3ghc10filesystem11file_statusC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(6) %13, ptr noundef nonnull align 4 dereferenceable(6) %11) #5
  store i1 true, ptr %14, align 1
  %33 = call noundef zeroext i1 @_ZN3ghc10filesystem12is_directoryENS0_11file_statusE(ptr noundef %13) #5
  br label %34

34:                                               ; preds = %32, %29
  %35 = phi i1 [ false, %29 ], [ %33, %32 ]
  %36 = load i1, ptr %14, align 1
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  call void @_ZN3ghc10filesystem11file_statusD1Ev(ptr noundef nonnull align 4 dereferenceable(6) %13) #5
  br label %38

38:                                               ; preds = %37, %34
  call void @_ZN3ghc10filesystem11file_statusD1Ev(ptr noundef nonnull align 4 dereferenceable(6) %12) #5
  br i1 %35, label %39, label %108

39:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #5
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN3ghc10filesystem18directory_iteratorC1ERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(32) %40, ptr noundef nonnull align 8 dereferenceable(16) %41) #5
  br label %42

42:                                               ; preds = %102, %39
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #5
  call void @_ZN3ghc10filesystem18directory_iteratorC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %16) #5
  %43 = invoke noundef zeroext i1 @_ZNK3ghc10filesystem18directory_iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(16) %16)
          to label %44 unwind label %128

44:                                               ; preds = %42
  call void @_ZN3ghc10filesystem18directory_iteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %16) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #5
  br i1 %43, label %46, label %45

45:                                               ; preds = %44
  store i32 2, ptr %9, align 4
  br label %105

46:                                               ; preds = %44
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %47) #5
  br i1 %48, label %49, label %53

49:                                               ; preds = %46
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = call noundef zeroext i1 @_ZN3ghc10filesystem6detail18is_not_found_errorERSt10error_code(ptr noundef nonnull align 8 dereferenceable(16) %50)
  br i1 %51, label %53, label %52

52:                                               ; preds = %49
  store i32 2, ptr %9, align 4
  br label %105

53:                                               ; preds = %49, %46
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #5
  %54 = invoke noundef ptr @_ZNK3ghc10filesystem18directory_iteratorptEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
          to label %55 unwind label %128

55:                                               ; preds = %53
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call noundef zeroext i1 @_ZNK3ghc10filesystem15directory_entry10is_symlinkERSt10error_code(ptr noundef nonnull align 8 dereferenceable(72) %54, ptr noundef nonnull align 8 dereferenceable(16) %56) #5
  %58 = zext i1 %57 to i8
  store i8 %58, ptr %17, align 1, !tbaa !14
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %59) #5
  br i1 %60, label %61, label %62

61:                                               ; preds = %55
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %99

62:                                               ; preds = %55
  %63 = load i8, ptr %17, align 1, !tbaa !14, !range !16, !noundef !17
  %64 = trunc i8 %63 to i1
  br i1 %64, label %82, label %65

65:                                               ; preds = %62
  %66 = invoke noundef ptr @_ZNK3ghc10filesystem18directory_iteratorptEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
          to label %67 unwind label %128

67:                                               ; preds = %65
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = call noundef zeroext i1 @_ZNK3ghc10filesystem15directory_entry12is_directoryERSt10error_code(ptr noundef nonnull align 8 dereferenceable(72) %66, ptr noundef nonnull align 8 dereferenceable(16) %68) #5
  br i1 %69, label %70, label %82

70:                                               ; preds = %67
  %71 = invoke noundef ptr @_ZNK3ghc10filesystem18directory_iteratorptEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
          to label %72 unwind label %128

72:                                               ; preds = %70
  %73 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3ghc10filesystem15directory_entry4pathEv(ptr noundef nonnull align 8 dereferenceable(72) %71) #5
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = call noundef i64 @_ZN3ghc10filesystem10remove_allERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(32) %73, ptr noundef nonnull align 8 dereferenceable(16) %74) #5
  %76 = load i64, ptr %6, align 8, !tbaa !9
  %77 = add i64 %76, %75
  store i64 %77, ptr %6, align 8, !tbaa !9
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %78) #5
  br i1 %79, label %80, label %81

80:                                               ; preds = %72
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %99

81:                                               ; preds = %72
  br label %98

82:                                               ; preds = %67, %62
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %83) #5
  br i1 %84, label %91, label %85

85:                                               ; preds = %82
  %86 = invoke noundef ptr @_ZNK3ghc10filesystem18directory_iteratorptEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
          to label %87 unwind label %128

87:                                               ; preds = %85
  %88 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3ghc10filesystem15directory_entry4pathEv(ptr noundef nonnull align 8 dereferenceable(72) %86) #5
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = call noundef zeroext i1 @_ZN3ghc10filesystem6removeERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(32) %88, ptr noundef nonnull align 8 dereferenceable(16) %89) #5
  br label %91

91:                                               ; preds = %87, %82
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %92) #5
  br i1 %93, label %94, label %95

94:                                               ; preds = %91
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %99

95:                                               ; preds = %91
  %96 = load i64, ptr %6, align 8, !tbaa !9
  %97 = add i64 %96, 1
  store i64 %97, ptr %6, align 8, !tbaa !9
  br label %98

98:                                               ; preds = %95, %81
  store i32 0, ptr %9, align 4
  br label %99

99:                                               ; preds = %98, %94, %80, %61
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #5
  %100 = load i32, ptr %9, align 4
  switch i32 %100, label %105 [
    i32 0, label %101
  ]

101:                                              ; preds = %99
  br label %102

102:                                              ; preds = %101
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3ghc10filesystem18directory_iterator9incrementERSt10error_code(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(16) %103) #5
  br label %42, !llvm.loop !18

105:                                              ; preds = %99, %52, %45
  call void @_ZN3ghc10filesystem18directory_iteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %15) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #5
  %106 = load i32, ptr %9, align 4
  switch i32 %106, label %125 [
    i32 2, label %107
  ]

107:                                              ; preds = %105
  br label %108

108:                                              ; preds = %107, %38
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %109) #5
  br i1 %110, label %119, label %111

111:                                              ; preds = %108
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = call noundef zeroext i1 @_ZN3ghc10filesystem6removeERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(32) %112, ptr noundef nonnull align 8 dereferenceable(16) %113) #5
  br i1 %114, label %115, label %118

115:                                              ; preds = %111
  %116 = load i64, ptr %6, align 8, !tbaa !9
  %117 = add i64 %116, 1
  store i64 %117, ptr %6, align 8, !tbaa !9
  br label %118

118:                                              ; preds = %115, %111
  br label %119

119:                                              ; preds = %118, %108
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %120) #5
  br i1 %121, label %122, label %123

122:                                              ; preds = %119
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %125

123:                                              ; preds = %119
  %124 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %124, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %125

125:                                              ; preds = %123, %122, %105
  call void @_ZN3ghc10filesystem11file_statusD1Ev(ptr noundef nonnull align 4 dereferenceable(6) %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  br label %126

126:                                              ; preds = %125, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %127 = load i64, ptr %3, align 8
  ret i64 %127

128:                                              ; preds = %85, %70, %65, %53, %42, %2
  %129 = landingpad { ptr, i32 }
          catch ptr null
  %130 = extractvalue { ptr, i32 } %129, 0
  call void @__clang_call_terminate(ptr %130) #6
  unreachable
}

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

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

declare void @_ZN3ghc10filesystem4pathD1Ev(ptr)

declare void @_ZN3ghc10filesystem11file_statusC1ERKS1_(ptr, ptr)

declare void @_ZN3ghc10filesystem11file_statusD1Ev(ptr)

declare void @_ZN3ghc10filesystem18directory_iteratorC1Ev(ptr)

declare void @_ZN3ghc10filesystem18directory_iteratorC1ERKNS0_4pathERSt10error_code(ptr, ptr, ptr)

declare void @_ZN3ghc10filesystem18directory_iteratorD1Ev(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 = { noinline noreturn nounwind uwtable "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 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 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 = !{!"long", !7, i64 0}
!11 = !{i64 0, i64 4, !12, i64 8, i64 8, !5}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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::file_status" = type <{ i32, i16, [2 x i8] }>
%"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] }
%"class.std::error_code" = type { i32, ptr }
%"class.ghc::filesystem::directory_iterator" = type { %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i32, ptr } @_ZN3ghc10filesystem6detail15make_error_codeENS1_14portable_errorE(i32 noundef) local_unnamed_addr #0

; 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 dso_local noundef zeroext i1 @_ZN3ghc10filesystem6detail18is_not_found_errorERSt10error_code(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

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

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3ghc10filesystemeqERKNS0_4pathES3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3ghc10filesystem4pathC2IA2_cS1_EERKT_NS1_6formatE(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 1 dereferenceable(2), i32 noundef) unnamed_addr #3 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3ghc10filesystem14symlink_statusERKNS0_4pathERSt10error_code(ptr dead_on_unwind noalias writable sret(%"class.ghc::filesystem::file_status") align 4, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3ghc10filesystem6existsENS0_11file_statusE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3ghc10filesystem12is_directoryENS0_11file_statusE(ptr noundef) local_unnamed_addr #0

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN3ghc10filesystem10remove_allERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.ghc::filesystem::path", align 8
  %4 = alloca %"class.std::error_code", align 8
  %5 = alloca %"class.ghc::filesystem::file_status", align 4
  %6 = alloca %"class.ghc::filesystem::file_status", align 4
  %7 = alloca %"class.ghc::filesystem::file_status", align 4
  %8 = alloca %"class.ghc::filesystem::directory_iterator", align 8
  %9 = alloca %"class.ghc::filesystem::directory_iterator", align 8
  tail call void @_ZNSt10error_code5clearEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  invoke void @_ZN3ghc10filesystem4pathC2IA2_cS1_EERKT_NS1_6formatE(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 1 dereferenceable(2) @.str.3, i32 noundef 2)
          to label %10 unwind label %59

10:                                               ; preds = %2
  %11 = call noundef zeroext i1 @_ZN3ghc10filesystemeqERKNS0_4pathES3_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %3) #4
  call void @_ZN3ghc10filesystem4pathD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  br i1 %11, label %12, label %16

12:                                               ; preds = %10
  %13 = call { i32, ptr } @_ZN3ghc10filesystem6detail15make_error_codeENS1_14portable_errorE(i32 noundef 3)
  %14 = extractvalue { i32, ptr } %13, 0
  %15 = extractvalue { i32, ptr } %13, 1
  store i32 %14, ptr %1, align 8, !tbaa !5
  %.sroa.44.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %15, ptr %.sroa.44.0..sroa_idx, align 8, !tbaa !9
  br label %58

16:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @_ZNSt10error_codeC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @_ZN3ghc10filesystem14symlink_statusERKNS0_4pathERSt10error_code(ptr dead_on_unwind nonnull writable sret(%"class.ghc::filesystem::file_status") align 4 %5, ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  call void @_ZN3ghc10filesystem11file_statusC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(6) %6, ptr noundef nonnull align 4 dereferenceable(6) %5) #4
  %17 = call noundef zeroext i1 @_ZN3ghc10filesystem6existsENS0_11file_statusE(ptr noundef nonnull %6) #4
  br i1 %17, label %18, label %.thread42

.thread42:                                        ; preds = %16
  call void @_ZN3ghc10filesystem11file_statusD1Ev(ptr noundef nonnull align 4 dereferenceable(6) %6) #4
  br label %50

18:                                               ; preds = %16
  call void @_ZN3ghc10filesystem11file_statusC1ERKS1_(ptr noundef nonnull align 4 dereferenceable(6) %7, ptr noundef nonnull align 4 dereferenceable(6) %5) #4
  %19 = call noundef zeroext i1 @_ZN3ghc10filesystem12is_directoryENS0_11file_statusE(ptr noundef nonnull %7) #4
  call void @_ZN3ghc10filesystem11file_statusD1Ev(ptr noundef nonnull align 4 dereferenceable(6) %7) #4
  call void @_ZN3ghc10filesystem11file_statusD1Ev(ptr noundef nonnull align 4 dereferenceable(6) %6) #4
  br i1 %19, label %20, label %50

20:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #4
  call void @_ZN3ghc10filesystem18directory_iteratorC1ERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #4
  call void @_ZN3ghc10filesystem18directory_iteratorC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  %21 = call noundef zeroext i1 @_ZNK3ghc10filesystem18directory_iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %9)
  call void @_ZN3ghc10filesystem18directory_iteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  br i1 %21, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %20, %47
  %.03452 = phi i64 [ %.23646, %47 ], [ 0, %20 ]
  %22 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  br i1 %22, label %23, label %25

23:                                               ; preds = %.lr.ph
  %24 = call noundef zeroext i1 @_ZN3ghc10filesystem6detail18is_not_found_errorERSt10error_code(ptr noundef nonnull align 8 dereferenceable(16) %1)
  br i1 %24, label %25, label %._crit_edge

25:                                               ; preds = %23, %.lr.ph
  %26 = call noundef ptr @_ZNK3ghc10filesystem18directory_iteratorptEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %27 = call noundef zeroext i1 @_ZNK3ghc10filesystem15directory_entry10is_symlinkERSt10error_code(ptr noundef nonnull align 8 dereferenceable(72) %26, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  %28 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  br i1 %28, label %.thread47, label %29

29:                                               ; preds = %25
  br i1 %27, label %33, label %30

30:                                               ; preds = %29
  %31 = call noundef ptr @_ZNK3ghc10filesystem18directory_iteratorptEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %32 = call noundef zeroext i1 @_ZNK3ghc10filesystem15directory_entry12is_directoryERSt10error_code(ptr noundef nonnull align 8 dereferenceable(72) %31, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  br i1 %32, label %42, label %33

33:                                               ; preds = %30, %29
  %34 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  br i1 %34, label %39, label %35

35:                                               ; preds = %33
  %36 = call noundef ptr @_ZNK3ghc10filesystem18directory_iteratorptEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %37 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3ghc10filesystem15directory_entry4pathEv(ptr noundef nonnull align 8 dereferenceable(72) %36) #4
  %38 = call noundef zeroext i1 @_ZN3ghc10filesystem6removeERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(32) %37, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  br label %39

39:                                               ; preds = %35, %33
  %40 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  %not. = xor i1 %40, true
  %41 = zext i1 %not. to i64
  br i1 %40, label %.thread47, label %47

42:                                               ; preds = %30
  %43 = call noundef ptr @_ZNK3ghc10filesystem18directory_iteratorptEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %44 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK3ghc10filesystem15directory_entry4pathEv(ptr noundef nonnull align 8 dereferenceable(72) %43) #4
  %45 = call noundef i64 @_ZN3ghc10filesystem10remove_allERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(32) %44, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  %46 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  br i1 %46, label %.thread47, label %47

47:                                               ; preds = %39, %42
  %.pn = phi i64 [ %41, %39 ], [ %45, %42 ]
  %.23646 = add i64 %.pn, %.03452
  %48 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3ghc10filesystem18directory_iterator9incrementERSt10error_code(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #4
  call void @_ZN3ghc10filesystem18directory_iteratorC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  %49 = call noundef zeroext i1 @_ZNK3ghc10filesystem18directory_iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %9)
  call void @_ZN3ghc10filesystem18directory_iteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #4
  br i1 %49, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.thread47:                                        ; preds = %42, %39, %25
  call void @_ZN3ghc10filesystem18directory_iteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #4
  br label %57

._crit_edge:                                      ; preds = %47, %23, %20
  %.034.lcssa = phi i64 [ 0, %20 ], [ %.03452, %23 ], [ %.23646, %47 ]
  call void @_ZN3ghc10filesystem18directory_iteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #4
  br label %50

50:                                               ; preds = %._crit_edge, %.thread42, %18
  %.438 = phi i64 [ %.034.lcssa, %._crit_edge ], [ 0, %18 ], [ 0, %.thread42 ]
  %51 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  br i1 %51, label %55, label %52

52:                                               ; preds = %50
  %53 = call noundef zeroext i1 @_ZN3ghc10filesystem6removeERKNS0_4pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  %54 = zext i1 %53 to i64
  %spec.select = add i64 %.438, %54
  br label %55

55:                                               ; preds = %52, %50
  %.5 = phi i64 [ %.438, %50 ], [ %spec.select, %52 ]
  %56 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  %..5 = select i1 %56, i64 -1, i64 %.5
  br label %57

57:                                               ; preds = %.thread47, %55
  %.3 = phi i64 [ %..5, %55 ], [ -1, %.thread47 ]
  call void @_ZN3ghc10filesystem11file_statusD1Ev(ptr noundef nonnull align 4 dereferenceable(6) %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  br label %58

58:                                               ; preds = %57, %12
  %.4 = phi i64 [ -1, %12 ], [ %.3, %57 ]
  ret i64 %.4

59:                                               ; preds = %2
  %60 = landingpad { ptr, i32 }
          catch ptr null
  %61 = extractvalue { ptr, i32 } %60, 0
  call void @__clang_call_terminate(ptr %61) #5
  unreachable
}

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

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

declare void @_ZN3ghc10filesystem4pathD1Ev(ptr) local_unnamed_addr

declare void @_ZN3ghc10filesystem11file_statusC1ERKS1_(ptr, ptr) local_unnamed_addr

declare void @_ZN3ghc10filesystem11file_statusD1Ev(ptr) local_unnamed_addr

declare void @_ZN3ghc10filesystem18directory_iteratorC1Ev(ptr) local_unnamed_addr

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

declare void @_ZN3ghc10filesystem18directory_iteratorD1Ev(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 = { noinline noreturn nounwind uwtable "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 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 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 = !{!"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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass