; LLVM IR from thepowersgang/mrustc :: src/hir/path.ll (ZN3HIR10SimplePath13pop_componentEv)

; 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.RcString = type { ptr }
%class.ThinVector = type { ptr }
%"struct.HIR::SimplePath" = type { %class.ThinVector }

; 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 nounwind uwtable
declare dso_local void @_ZN10ThinVectorI8RcStringED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

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

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

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

; Function Attrs: nounwind
declare void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3HIR10SimplePath13pop_componentEv(ptr dead_on_unwind noalias writable sret(%class.RcString) align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1) #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %class.RcString, align 8
  %9 = alloca i1, align 1
  %10 = alloca i1, align 1
  %11 = alloca %class.ThinVector, align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8
  %13 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %12, i32 0, i32 0
  %14 = call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
  %15 = icmp ule i64 %14, 1
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  call void @_ZN8RcStringC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  br label %79

17:                                               ; preds = %2
  store i1 false, ptr %5, align 1
  %18 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %12, i32 0, i32 0
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10ThinVectorI8RcStringE4backEv(ptr noundef nonnull align 8 dereferenceable(8) %18)
  call void @_ZN8RcStringC2ERKS_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %20 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %12, i32 0, i32 0
  invoke void @_ZN10ThinVectorI8RcStringE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(8) %20)
          to label %21 unwind label %46

21:                                               ; preds = %17
  %22 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %12, i32 0, i32 0
  store i1 false, ptr %9, align 1
  store i1 false, ptr %10, align 1
  %23 = invoke noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %22)
          to label %24 unwind label %46

24:                                               ; preds = %21
  %25 = icmp eq i64 %23, 1
  br i1 %25, label %26, label %33

26:                                               ; preds = %24
  %27 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %12, i32 0, i32 0
  %28 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN10ThinVectorI8RcStringEixEm(ptr noundef nonnull align 8 dereferenceable(8) %27, i64 noundef 0)
          to label %29 unwind label %46

29:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i1 true, ptr %9, align 1
  invoke void @_ZN8RcStringC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %30 unwind label %50

30:                                               ; preds = %29
  store i1 true, ptr %10, align 1
  %31 = invoke noundef zeroext i1 @_ZNK8RcStringeqERKS_(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %32 unwind label %54

32:                                               ; preds = %30
  br label %33

33:                                               ; preds = %32, %24
  %34 = phi i1 [ false, %24 ], [ %31, %32 ]
  %35 = load i1, ptr %10, align 1
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  br label %37

37:                                               ; preds = %36, %33
  %38 = load i1, ptr %9, align 1
  br i1 %38, label %39, label %40

39:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %40

40:                                               ; preds = %39, %37
  br i1 %34, label %41, label %74

41:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  invoke void @_ZN10ThinVectorI8RcStringEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %42 unwind label %65

42:                                               ; preds = %41
  %43 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %12, i32 0, i32 0
  %44 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN10ThinVectorI8RcStringEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %45 unwind label %69

45:                                               ; preds = %42
  call void @_ZN10ThinVectorI8RcStringED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %74

46:                                               ; preds = %26, %21, %17
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %6, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %7, align 4
  br label %78

50:                                               ; preds = %29
  %51 = landingpad { ptr, i32 }
          cleanup
  %52 = extractvalue { ptr, i32 } %51, 0
  store ptr %52, ptr %6, align 8
  %53 = extractvalue { ptr, i32 } %51, 1
  store i32 %53, ptr %7, align 4
  br label %61

54:                                               ; preds = %30
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %6, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %7, align 4
  %58 = load i1, ptr %10, align 1
  br i1 %58, label %59, label %60

59:                                               ; preds = %54
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  br label %60

60:                                               ; preds = %59, %54
  br label %61

61:                                               ; preds = %60, %50
  %62 = load i1, ptr %9, align 1
  br i1 %62, label %63, label %64

63:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %64

64:                                               ; preds = %63, %61
  br label %78

65:                                               ; preds = %41
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %6, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %7, align 4
  br label %73

69:                                               ; preds = %42
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %6, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %7, align 4
  call void @_ZN10ThinVectorI8RcStringED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  br label %73

73:                                               ; preds = %69, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %78

74:                                               ; preds = %45, %40
  store i1 true, ptr %5, align 1
  %75 = load i1, ptr %5, align 1
  br i1 %75, label %77, label %76

76:                                               ; preds = %74
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  br label %77

77:                                               ; preds = %76, %74
  br label %79

78:                                               ; preds = %73, %64, %46
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  br label %80

79:                                               ; preds = %77, %16
  ret void

80:                                               ; preds = %78
  %81 = load ptr, ptr %6, align 8
  %82 = load i32, ptr %7, align 4
  %83 = insertvalue { ptr, i32 } poison, ptr %81, 0
  %84 = insertvalue { ptr, i32 } %83, i32 %82, 1
  resume { ptr, i32 } %84
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN10ThinVectorI8RcStringEixEm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #1 align 2

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

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

attributes #0 = { nocallback nofree nosync 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 "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 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.RcString = type { ptr }
%class.ThinVector = type { ptr }

; 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 nounwind uwtable
declare dso_local void @_ZN10ThinVectorI8RcStringED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

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

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

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

; Function Attrs: nounwind
declare void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3HIR10SimplePath13pop_componentEv(ptr dead_on_unwind noalias writable sret(%class.RcString) align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.RcString, align 8
  %4 = alloca %class.ThinVector, align 8
  %5 = tail call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %6 = icmp ult i64 %5, 2
  br i1 %6, label %7, label %8

7:                                                ; preds = %2
  tail call void @_ZN8RcStringC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  br label %.critedge.thread

8:                                                ; preds = %2
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10ThinVectorI8RcStringE4backEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  tail call void @_ZN8RcStringC2ERKS_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %9)
  invoke void @_ZN10ThinVectorI8RcStringE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
          to label %10 unwind label %18

10:                                               ; preds = %8
  %11 = tail call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %12 = icmp eq i64 %11, 1
  br i1 %12, label %13, label %.critedge.thread

13:                                               ; preds = %10
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10ThinVectorI8RcStringEixEm(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @_ZN8RcStringC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
  %15 = invoke noundef zeroext i1 @_ZNK8RcStringeqERKS_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %.critedge unwind label %20

.critedge:                                        ; preds = %13
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br i1 %15, label %16, label %.critedge.thread

16:                                               ; preds = %.critedge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZN10ThinVectorI8RcStringEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10ThinVectorI8RcStringEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @_ZN10ThinVectorI8RcStringED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %.critedge.thread

18:                                               ; preds = %8
  %19 = landingpad { ptr, i32 }
          cleanup
  br label %22

20:                                               ; preds = %13
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br label %22

22:                                               ; preds = %20, %18
  %.pn = phi { ptr, i32 } [ %21, %20 ], [ %19, %18 ]
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  resume { ptr, i32 } %.pn

.critedge.thread:                                 ; preds = %10, %.critedge, %16, %7
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ThinVectorI8RcStringE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN10ThinVectorI8RcStringEixEm(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #1 align 2

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

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

attributes #0 = { mustprogress nocallback nofree nosync 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 "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 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