; LLVM IR from pictools/pica :: test/gtest/fused-src/gtest/gtest-all.ll (ZN7testing8internal8FilePath9NormalizeEv)

; 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.testing::internal::FilePath" = type { %"class.testing::internal::String" }
%"class.testing::internal::String" = type { ptr, i64 }

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

; 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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN7testing8internalL15IsPathSeparatorEc(i8 noundef signext) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7testing8internal8FilePath9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = getelementptr inbounds %"class.testing::internal::FilePath", ptr %6, i32 0, i32 0
  %8 = call noundef ptr @_ZNK7testing8internal6String5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %13

10:                                               ; preds = %1
  %11 = getelementptr inbounds %"class.testing::internal::FilePath", ptr %6, i32 0, i32 0
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7testing8internal6StringaSEPKc(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef @.str.13)
  br label %61

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %14 = getelementptr inbounds %"class.testing::internal::FilePath", ptr %6, i32 0, i32 0
  %15 = call noundef ptr @_ZNK7testing8internal6String5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %14)
  store ptr %15, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %16 = getelementptr inbounds %"class.testing::internal::FilePath", ptr %6, i32 0, i32 0
  %17 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %16)
  %18 = add i64 %17, 1
  %19 = call noalias noundef nonnull ptr @_Znam(i64 noundef %18) #7
  store ptr %19, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %20, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.testing::internal::FilePath", ptr %6, i32 0, i32 0
  %23 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %22)
  %24 = add i64 %23, 1
  call void @llvm.memset.p0.i64(ptr align 1 %21, i8 0, i64 %24, i1 false)
  br label %25

25:                                               ; preds = %49, %13
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %52

30:                                               ; preds = %25
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i8, ptr %31, align 1, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 %32, ptr %33, align 1, !tbaa !9
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %36 = call noundef zeroext i1 @_ZN7testing8internalL15IsPathSeparatorEc(i8 noundef signext %35)
  br i1 %36, label %40, label %37

37:                                               ; preds = %30
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %38, i32 1
  store ptr %39, ptr %3, align 8, !tbaa !5
  br label %49

40:                                               ; preds = %30
  br label %41

41:                                               ; preds = %45, %40
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load i8, ptr %42, align 1, !tbaa !9
  %44 = call noundef zeroext i1 @_ZN7testing8internalL15IsPathSeparatorEc(i8 noundef signext %43)
  br i1 %44, label %45, label %48

45:                                               ; preds = %41
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i32 1
  store ptr %47, ptr %3, align 8, !tbaa !5
  br label %41, !llvm.loop !10

48:                                               ; preds = %41
  br label %49

49:                                               ; preds = %48, %37
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i32 1
  store ptr %51, ptr %5, align 8, !tbaa !5
  br label %25, !llvm.loop !12

52:                                               ; preds = %25
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 0, ptr %53, align 1, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"class.testing::internal::FilePath", ptr %6, i32 0, i32 0
  %56 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7testing8internal6StringaSEPKc(ptr noundef nonnull align 8 dereferenceable(16) %55, ptr noundef %54)
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = icmp eq ptr %57, null
  br i1 %58, label %60, label %59

59:                                               ; preds = %52
  call void @_ZdaPv(ptr noundef %57) #8
  br label %60

60:                                               ; preds = %59, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %61

61:                                               ; preds = %60, %10
  ret void
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #5

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nobuiltin allocsize(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 = { nobuiltin 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; 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"

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZN7testing8internalL15IsPathSeparatorEc(i8 noundef signext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7testing8internal8FilePath9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0) local_unnamed_addr #1 align 2 {
  %2 = tail call noundef ptr @_ZNK7testing8internal6String5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %3 = icmp eq ptr %2, null
  br i1 %3, label %4, label %6

4:                                                ; preds = %1
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7testing8internal6StringaSEPKc(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull @.str.13)
  br label %25

6:                                                ; preds = %1
  %7 = tail call noundef ptr @_ZNK7testing8internal6String5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %8 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %9 = add i64 %8, 1
  %10 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %9) #5
  %11 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %12 = add i64 %11, 1
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %10, i8 0, i64 %12, i1 false)
  %13 = load i8, ptr %7, align 1, !tbaa !5
  %.not15 = icmp eq i8 %13, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6, %.loopexit
  %14 = phi i8 [ %23, %.loopexit ], [ %13, %6 ]
  %.017 = phi ptr [ %22, %.loopexit ], [ %10, %6 ]
  %.01416 = phi ptr [ %.2, %.loopexit ], [ %7, %6 ]
  store i8 %14, ptr %.017, align 1, !tbaa !5
  %15 = load i8, ptr %.01416, align 1, !tbaa !5
  %16 = tail call noundef zeroext i1 @_ZN7testing8internalL15IsPathSeparatorEc(i8 noundef signext %15)
  br i1 %16, label %.preheader, label %17

17:                                               ; preds = %.lr.ph
  %18 = getelementptr inbounds i8, ptr %.01416, i64 1
  br label %.loopexit

.preheader:                                       ; preds = %.lr.ph, %.preheader
  %.1 = phi ptr [ %21, %.preheader ], [ %.01416, %.lr.ph ]
  %19 = load i8, ptr %.1, align 1, !tbaa !5
  %20 = tail call noundef zeroext i1 @_ZN7testing8internalL15IsPathSeparatorEc(i8 noundef signext %19)
  %21 = getelementptr inbounds i8, ptr %.1, i64 1
  br i1 %20, label %.preheader, label %.loopexit, !llvm.loop !8

.loopexit:                                        ; preds = %.preheader, %17
  %.2 = phi ptr [ %18, %17 ], [ %.1, %.preheader ]
  %22 = getelementptr inbounds i8, ptr %.017, i64 1
  %23 = load i8, ptr %.2, align 1, !tbaa !5
  %.not = icmp eq i8 %23, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge:                                      ; preds = %.loopexit, %6
  %.0.lcssa = phi ptr [ %10, %6 ], [ %22, %.loopexit ]
  store i8 0, ptr %.0.lcssa, align 1, !tbaa !5
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN7testing8internal6StringaSEPKc(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %10)
  tail call void @_ZdaPv(ptr noundef nonnull %10) #6
  br label %25

25:                                               ; preds = %._crit_edge, %4
  ret void
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #4

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 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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nobuiltin allocsize(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 = { nobuiltin 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 #5 = { builtin allocsize(0) }
attributes #6 = { builtin 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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