; LLVM IR from vczh/herodb :: Kernel/Source/Vlpp.ll (ZNK2vl10filesystem8FilePath7GetNameEv)

; 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.vl::ObjectString" = type { %"class.vl::Object", ptr, ptr, i64, i64, i64 }
%"class.vl::Object" = type { ptr }
%"class.vl::collections::Pair" = type { i64, i64 }
%"class.vl::Locale" = type { %"class.vl::Object", %"class.vl::ObjectString" }
%"class.vl::filesystem::FilePath" = type { %"class.vl::Object", %"class.vl::ObjectString" }

@_ZN2vl10filesystem8FilePath9DelimiterE = external dso_local constant i32, align 4

; 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 noundef i64 @_ZNK2vl12ObjectStringIwE6LengthEv(ptr noundef nonnull align 8 dereferenceable(48)) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK2vl10filesystem8FilePath7GetNameEv(ptr dead_on_unwind noalias writable sret(%"class.vl::ObjectString") align 8 %0, ptr noundef nonnull align 8 dereferenceable(56) %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.vl::ObjectString", align 8
  %6 = alloca %"class.vl::collections::Pair", align 8
  %7 = alloca %"class.vl::Locale", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr %5) #3
  call void @_ZN2vl12ObjectStringIwEC2ERKw(ptr noundef nonnull align 8 dereferenceable(48) %5, ptr noundef nonnull align 4 dereferenceable(4) @_ZN2vl10filesystem8FilePath9DelimiterE)
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 56, ptr %7) #3
  invoke void @_ZN2vl6Locale9InvariantEv(ptr dead_on_unwind writable sret(%"class.vl::Locale") align 8 %7)
          to label %12 unwind label %21

12:                                               ; preds = %2
  %13 = getelementptr inbounds %"class.vl::filesystem::FilePath", ptr %11, i32 0, i32 1
  invoke void @_ZNK2vl6Locale8FindLastERKNS_12ObjectStringIwEES4_NS0_13NormalizationE(ptr dead_on_unwind writable sret(%"class.vl::collections::Pair") align 8 %6, ptr noundef nonnull align 8 dereferenceable(56) %7, ptr noundef nonnull align 8 dereferenceable(48) %13, ptr noundef nonnull align 8 dereferenceable(48) %5, i32 noundef 0)
          to label %14 unwind label %25

14:                                               ; preds = %12
  call void @_ZN2vl6LocaleD1Ev(ptr noundef nonnull align 8 dereferenceable(56) %7) #3
  call void @llvm.lifetime.end.p0(i64 56, ptr %7) #3
  %15 = getelementptr inbounds %"class.vl::collections::Pair", ptr %6, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = icmp eq i64 %16, -1
  br i1 %17, label %18, label %34

18:                                               ; preds = %14
  %19 = getelementptr inbounds %"class.vl::filesystem::FilePath", ptr %11, i32 0, i32 1
  invoke void @_ZN2vl12ObjectStringIwEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(48) %19)
          to label %20 unwind label %30

20:                                               ; preds = %18
  store i32 1, ptr %10, align 4
  br label %44

21:                                               ; preds = %2
  %22 = landingpad { ptr, i32 }
          cleanup
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %8, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %9, align 4
  br label %29

25:                                               ; preds = %12
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %8, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %9, align 4
  call void @_ZN2vl6LocaleD1Ev(ptr noundef nonnull align 8 dereferenceable(56) %7) #3
  br label %29

29:                                               ; preds = %25, %21
  call void @llvm.lifetime.end.p0(i64 56, ptr %7) #3
  br label %45

30:                                               ; preds = %38, %34, %18
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %8, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %9, align 4
  br label %45

34:                                               ; preds = %14
  %35 = getelementptr inbounds %"class.vl::filesystem::FilePath", ptr %11, i32 0, i32 1
  %36 = getelementptr inbounds %"class.vl::filesystem::FilePath", ptr %11, i32 0, i32 1
  %37 = invoke noundef i64 @_ZNK2vl12ObjectStringIwE6LengthEv(ptr noundef nonnull align 8 dereferenceable(48) %36)
          to label %38 unwind label %30

38:                                               ; preds = %34
  %39 = getelementptr inbounds %"class.vl::collections::Pair", ptr %6, i32 0, i32 0
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = sub nsw i64 %37, %40
  %42 = sub nsw i64 %41, 1
  invoke void @_ZNK2vl12ObjectStringIwE5RightEl(ptr dead_on_unwind writable sret(%"class.vl::ObjectString") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %35, i64 noundef %42)
          to label %43 unwind label %30

43:                                               ; preds = %38
  store i32 1, ptr %10, align 4
  br label %44

44:                                               ; preds = %43, %20
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  call void @_ZN2vl12ObjectStringIwED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %5) #3
  ret void

45:                                               ; preds = %30, %29
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  call void @_ZN2vl12ObjectStringIwED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %5) #3
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %8, align 8
  %48 = load i32, ptr %9, align 4
  %49 = insertvalue { ptr, i32 } poison, ptr %47, 0
  %50 = insertvalue { ptr, i32 } %49, i32 %48, 1
  resume { ptr, i32 } %50
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl12ObjectStringIwEC2ERKw(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl6Locale9InvariantEv(ptr dead_on_unwind noalias writable sret(%"class.vl::Locale") align 8) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK2vl6Locale8FindLastERKNS_12ObjectStringIwEES4_NS0_13NormalizationE(ptr dead_on_unwind noalias writable sret(%"class.vl::collections::Pair") align 8, ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK2vl12ObjectStringIwE5RightEl(ptr dead_on_unwind noalias writable sret(%"class.vl::ObjectString") align 8, ptr noundef nonnull align 8 dereferenceable(48), i64 noundef) #2 align 2

declare void @_ZN2vl6LocaleD1Ev(ptr)

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 = { 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 = { 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, !11, i64 0}
!10 = !{!"_ZTSN2vl11collections4PairIllEE", !11, i64 0, !11, i64 8}
!11 = !{!"long", !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.vl::ObjectString" = type { %"class.vl::Object", ptr, ptr, i64, i64, i64 }
%"class.vl::Object" = type { ptr }
%"class.vl::collections::Pair" = type { i64, i64 }
%"class.vl::Locale" = type { %"class.vl::Object", %"class.vl::ObjectString" }

@_ZN2vl10filesystem8FilePath9DelimiterE = external dso_local constant i32, align 4

; 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 noundef i64 @_ZNK2vl12ObjectStringIwE6LengthEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK2vl10filesystem8FilePath7GetNameEv(ptr dead_on_unwind noalias writable sret(%"class.vl::ObjectString") align 8 %0, ptr noundef nonnull align 8 dereferenceable(56) %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.vl::ObjectString", align 8
  %4 = alloca %"class.vl::collections::Pair", align 8
  %5 = alloca %"class.vl::Locale", align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %3) #3
  call void @_ZN2vl12ObjectStringIwEC2ERKw(ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 4 dereferenceable(4) @_ZN2vl10filesystem8FilePath9DelimiterE)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %5) #3
  invoke void @_ZN2vl6Locale9InvariantEv(ptr dead_on_unwind nonnull writable sret(%"class.vl::Locale") align 8 %5)
          to label %6 unwind label %12

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  invoke void @_ZNK2vl6Locale8FindLastERKNS_12ObjectStringIwEES4_NS0_13NormalizationE(ptr dead_on_unwind nonnull writable sret(%"class.vl::collections::Pair") align 8 %4, ptr noundef nonnull align 8 dereferenceable(56) %5, ptr noundef nonnull align 8 dereferenceable(48) %7, ptr noundef nonnull align 8 dereferenceable(48) %3, i32 noundef 0)
          to label %8 unwind label %14

8:                                                ; preds = %6
  call void @_ZN2vl6LocaleD1Ev(ptr noundef nonnull align 8 dereferenceable(56) %5) #3
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %5) #3
  %9 = load i64, ptr %4, align 8, !tbaa !5
  %10 = icmp eq i64 %9, -1
  br i1 %10, label %11, label %19

11:                                               ; preds = %8
  call void @_ZN2vl12ObjectStringIwEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(48) %7)
  br label %24

12:                                               ; preds = %2
  %13 = landingpad { ptr, i32 }
          cleanup
  br label %16

14:                                               ; preds = %6
  %15 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN2vl6LocaleD1Ev(ptr noundef nonnull align 8 dereferenceable(56) %5) #3
  br label %16

16:                                               ; preds = %14, %12
  %.pn = phi { ptr, i32 } [ %15, %14 ], [ %13, %12 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %5) #3
  br label %25

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

19:                                               ; preds = %8
  %20 = call noundef i64 @_ZNK2vl12ObjectStringIwE6LengthEv(ptr noundef nonnull align 8 dereferenceable(48) %7)
  %21 = load i64, ptr %4, align 8, !tbaa !5
  %22 = xor i64 %21, -1
  %23 = add i64 %20, %22
  invoke void @_ZNK2vl12ObjectStringIwE5RightEl(ptr dead_on_unwind writable sret(%"class.vl::ObjectString") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %7, i64 noundef %23)
          to label %24 unwind label %17

24:                                               ; preds = %19, %11
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  call void @_ZN2vl12ObjectStringIwED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #3
  ret void

25:                                               ; preds = %17, %16
  %.pn5 = phi { ptr, i32 } [ %18, %17 ], [ %.pn, %16 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  call void @_ZN2vl12ObjectStringIwED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #3
  resume { ptr, i32 } %.pn5
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl12ObjectStringIwEC2ERKw(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl6Locale9InvariantEv(ptr dead_on_unwind noalias writable sret(%"class.vl::Locale") align 8) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK2vl6Locale8FindLastERKNS_12ObjectStringIwEES4_NS0_13NormalizationE(ptr dead_on_unwind noalias writable sret(%"class.vl::collections::Pair") align 8, ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK2vl12ObjectStringIwE5RightEl(ptr dead_on_unwind noalias writable sret(%"class.vl::ObjectString") align 8, ptr noundef nonnull align 8 dereferenceable(48), i64 noundef) local_unnamed_addr #2 align 2

declare void @_ZN2vl6LocaleD1Ev(ptr) local_unnamed_addr

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 = { 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN2vl11collections4PairIllEE", !7, i64 0, !7, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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