; LLVM IR from facebook/redex :: libresource/String8.ll (ZNK7android7String88walkPathEPS0_)

; 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.android::String8" = type { ptr }

@.str = 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7android7String88walkPathEPS0_(ptr dead_on_unwind noalias writable sret(%"class.android::String8") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %2) #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i1, align 1
  %11 = alloca %"class.android::String8", align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i1, align 1
  %16 = alloca %"class.android::String8", align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %18 = getelementptr inbounds %"class.android::String8", ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %20, ptr %9, align 8, !tbaa !5
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = call noundef ptr @strchr(ptr noundef %21, i32 noundef 47) #5
  store ptr %22, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = icmp eq ptr %23, %24
  br i1 %25, label %26, label %31

26:                                               ; preds = %3
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 1
  store ptr %28, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = call noundef ptr @strchr(ptr noundef %29, i32 noundef 47) #5
  store ptr %30, ptr %7, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %26, %3
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %62

34:                                               ; preds = %31
  store i1 false, ptr %10, align 1
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = icmp ne ptr %35, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %34
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN7android7String8C1EPKc(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %39)
  br label %41

40:                                               ; preds = %34
  call void @_ZN7android7String8C1ERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %17)
  br label %41

41:                                               ; preds = %40, %38
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %58

44:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  invoke void @_ZN7android7String8C1EPKc(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef @.str)
          to label %45 unwind label %49

45:                                               ; preds = %44
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7android7String8aSERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %46, ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %48 unwind label %53

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

49:                                               ; preds = %44
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %12, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %13, align 4
  br label %57

53:                                               ; preds = %45
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %12, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %13, align 4
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  br label %57

57:                                               ; preds = %53, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  br label %92

58:                                               ; preds = %48, %41
  store i1 true, ptr %10, align 1
  store i32 1, ptr %14, align 4
  %59 = load i1, ptr %10, align 1
  br i1 %59, label %61, label %60

60:                                               ; preds = %58
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  br label %61

61:                                               ; preds = %60, %58
  br label %91

62:                                               ; preds = %31
  store i1 false, ptr %15, align 1
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = ptrtoint ptr %64 to i64
  %67 = ptrtoint ptr %65 to i64
  %68 = sub i64 %66, %67
  call void @_ZN7android7String8C1EPKcm(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %63, i64 noundef %68)
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %87

71:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i64 1
  invoke void @_ZN7android7String8C1EPKc(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef %73)
          to label %74 unwind label %78

74:                                               ; preds = %71
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7android7String8aSERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %75, ptr noundef nonnull align 8 dereferenceable(8) %16)
          to label %77 unwind label %82

77:                                               ; preds = %74
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br label %87

78:                                               ; preds = %71
  %79 = landingpad { ptr, i32 }
          cleanup
  %80 = extractvalue { ptr, i32 } %79, 0
  store ptr %80, ptr %12, align 8
  %81 = extractvalue { ptr, i32 } %79, 1
  store i32 %81, ptr %13, align 4
  br label %86

82:                                               ; preds = %74
  %83 = landingpad { ptr, i32 }
          cleanup
  %84 = extractvalue { ptr, i32 } %83, 0
  store ptr %84, ptr %12, align 8
  %85 = extractvalue { ptr, i32 } %83, 1
  store i32 %85, ptr %13, align 4
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %16) #4
  br label %86

86:                                               ; preds = %82, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  br label %92

87:                                               ; preds = %77, %62
  store i1 true, ptr %15, align 1
  store i32 1, ptr %14, align 4
  %88 = load i1, ptr %15, align 1
  br i1 %88, label %90, label %89

89:                                               ; preds = %87
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #4
  br label %90

90:                                               ; preds = %89, %87
  br label %91

91:                                               ; preds = %90, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void

92:                                               ; preds = %86, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %93

93:                                               ; preds = %92
  %94 = load ptr, ptr %12, align 8
  %95 = load i32, ptr %13, align 4
  %96 = insertvalue { ptr, i32 } poison, ptr %94, 0
  %97 = insertvalue { ptr, i32 } %96, i32 %95, 1
  resume { ptr, i32 } %97
}

; Function Attrs: nounwind willreturn memory(read)
declare noundef ptr @strchr(ptr noundef, i32 noundef) #2

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

declare void @_ZN7android7String8C1ERKS0_(ptr, ptr)

declare void @_ZN7android7String8C1EPKc(ptr, ptr)

declare void @_ZN7android7String8C1EPKcm(ptr, ptr, i64)

declare void @_ZN7android7String8D1Ev(ptr)

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

!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, !6, i64 0}
!10 = !{!"_ZTSN7android7String8E", !6, 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.android::String8" = type { ptr }

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

; 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 uwtable
define dso_local void @_ZNK7android7String88walkPathEPS0_(ptr dead_on_unwind noalias writable sret(%"class.android::String8") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %2) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.android::String8", align 8
  %5 = alloca %"class.android::String8", align 8
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = tail call noundef ptr @strchr(ptr noundef nonnull dereferenceable(1) %6, i32 noundef 47) #4
  %8 = icmp eq ptr %7, %6
  br i1 %8, label %9, label %12

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %6, i64 1
  %11 = tail call noundef ptr @strchr(ptr noundef nonnull dereferenceable(1) %10, i32 noundef 47) #4
  br label %12

12:                                               ; preds = %9, %3
  %.026 = phi ptr [ %11, %9 ], [ %7, %3 ]
  %.025 = phi ptr [ %10, %9 ], [ %6, %3 ]
  %13 = icmp eq ptr %.026, null
  br i1 %13, label %14, label %27

14:                                               ; preds = %12
  %.not33 = icmp eq ptr %.025, %6
  br i1 %.not33, label %16, label %15

15:                                               ; preds = %14
  tail call void @_ZN7android7String8C1EPKc(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %.025)
  br label %17

16:                                               ; preds = %14
  tail call void @_ZN7android7String8C1ERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %1)
  br label %17

17:                                               ; preds = %16, %15
  %.not34 = icmp eq ptr %2, null
  br i1 %.not34, label %41, label %18

18:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  invoke void @_ZN7android7String8C1EPKc(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull @.str)
          to label %19 unwind label %22

19:                                               ; preds = %18
  %20 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7android7String8aSERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %21 unwind label %24

21:                                               ; preds = %19
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %41

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

24:                                               ; preds = %19
  %25 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  br label %26

26:                                               ; preds = %24, %22
  %.pn35 = phi { ptr, i32 } [ %25, %24 ], [ %23, %22 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %42

27:                                               ; preds = %12
  %28 = ptrtoint ptr %.026 to i64
  %29 = ptrtoint ptr %.025 to i64
  %30 = sub i64 %28, %29
  tail call void @_ZN7android7String8C1EPKcm(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %.025, i64 noundef %30)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %41, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %32 = getelementptr inbounds i8, ptr %.026, i64 1
  invoke void @_ZN7android7String8C1EPKc(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull %32)
          to label %33 unwind label %36

33:                                               ; preds = %31
  %34 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZN7android7String8aSERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %5)
          to label %35 unwind label %38

35:                                               ; preds = %33
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br label %41

36:                                               ; preds = %31
  %37 = landingpad { ptr, i32 }
          cleanup
  br label %40

38:                                               ; preds = %33
  %39 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  br label %40

40:                                               ; preds = %38, %36
  %.pn = phi { ptr, i32 } [ %39, %38 ], [ %37, %36 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br label %42

41:                                               ; preds = %27, %35, %17, %21
  ret void

42:                                               ; preds = %40, %26
  %.pn35.pn = phi { ptr, i32 } [ %.pn35, %26 ], [ %.pn, %40 ]
  call void @_ZN7android7String8D1Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  resume { ptr, i32 } %.pn35.pn
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare noundef ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare void @_ZN7android7String8C1ERKS0_(ptr, ptr) local_unnamed_addr

declare void @_ZN7android7String8C1EPKc(ptr, ptr) local_unnamed_addr

declare void @_ZN7android7String8C1EPKcm(ptr, ptr, i64) local_unnamed_addr

declare void @_ZN7android7String8D1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }
attributes #5 = { 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 = !{!"_ZTSN7android7String8E", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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