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

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

; 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
define dso_local noundef i32 @_ZNK7testing8internal6String7CompareERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %12 = call noundef ptr @_ZNK7testing8internal6String5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  store ptr %12, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call noundef ptr @_ZNK7testing8internal6String5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  store ptr %14, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %22

17:                                               ; preds = %2
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  %20 = zext i1 %19 to i64
  %21 = select i1 %19, i32 0, i32 -1
  store i32 %21, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %93

22:                                               ; preds = %2
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %93

26:                                               ; preds = %22
  br label %27

27:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %28 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %29)
  %31 = icmp ule i64 %28, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %27
  %33 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  br label %37

34:                                               ; preds = %27
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %35)
  br label %37

37:                                               ; preds = %34, %32
  %38 = phi i64 [ %33, %32 ], [ %36, %34 ]
  store i64 %38, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %72, %37
  %40 = load i64, ptr %10, align 8, !tbaa !9
  %41 = load i64, ptr %9, align 8, !tbaa !9
  %42 = icmp ne i64 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  store i32 2, ptr %8, align 4
  br label %75

44:                                               ; preds = %39
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i64, ptr %10, align 8, !tbaa !9
  %47 = getelementptr inbounds i8, ptr %45, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = sext i8 %48 to i32
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i64, ptr %10, align 8, !tbaa !9
  %52 = getelementptr inbounds i8, ptr %50, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = sext i8 %53 to i32
  %55 = icmp slt i32 %49, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %44
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %75

57:                                               ; preds = %44
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load i64, ptr %10, align 8, !tbaa !9
  %60 = getelementptr inbounds i8, ptr %58, i64 %59
  %61 = load i8, ptr %60, align 1, !tbaa !11
  %62 = sext i8 %61 to i32
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load i64, ptr %10, align 8, !tbaa !9
  %65 = getelementptr inbounds i8, ptr %63, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !11
  %67 = sext i8 %66 to i32
  %68 = icmp sgt i32 %62, %67
  br i1 %68, label %69, label %70

69:                                               ; preds = %57
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %75

70:                                               ; preds = %57
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  %73 = load i64, ptr %10, align 8, !tbaa !9
  %74 = add i64 %73, 1
  store i64 %74, ptr %10, align 8, !tbaa !9
  br label %39, !llvm.loop !12

75:                                               ; preds = %69, %56, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %76 = load i32, ptr %8, align 4
  switch i32 %76, label %92 [
    i32 2, label %77
  ]

77:                                               ; preds = %75
  %78 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %79)
  %81 = icmp ult i64 %78, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %77
  br label %90

83:                                               ; preds = %77
  %84 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %85)
  %87 = icmp ugt i64 %84, %86
  %88 = zext i1 %87 to i64
  %89 = select i1 %87, i32 1, i32 0
  br label %90

90:                                               ; preds = %83, %82
  %91 = phi i32 [ -1, %82 ], [ %89, %83 ]
  store i32 %91, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %92

92:                                               ; preds = %90, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %93

93:                                               ; preds = %92, %25, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %94 = load i32, ptr %3, align 4
  ret i32 %94
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16)) #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 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

; 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 nounwind uwtable
define dso_local noundef i32 @_ZNK7testing8internal6String7CompareERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef ptr @_ZNK7testing8internal6String5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %4 = tail call noundef ptr @_ZNK7testing8internal6String5c_strEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %5 = icmp eq ptr %3, null
  br i1 %5, label %6, label %9

6:                                                ; preds = %2
  %7 = icmp ne ptr %4, null
  %8 = sext i1 %7 to i32
  br label %.thread

9:                                                ; preds = %2
  %10 = icmp eq ptr %4, null
  br i1 %10, label %.thread, label %11

11:                                               ; preds = %9
  %12 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %13 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %.not = icmp ugt i64 %12, %13
  %. = select i1 %.not, ptr %1, ptr %0
  %14 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %.)
  %.not2729 = icmp eq i64 %14, 0
  br i1 %.not2729, label %._crit_edge, label %.lr.ph

15:                                               ; preds = %22
  %16 = add nuw i64 %.030, 1
  %.not27 = icmp eq i64 %16, %14
  br i1 %.not27, label %._crit_edge, label %.lr.ph, !llvm.loop !5

.lr.ph:                                           ; preds = %11, %15
  %.030 = phi i64 [ %16, %15 ], [ 0, %11 ]
  %17 = getelementptr inbounds i8, ptr %3, i64 %.030
  %18 = load i8, ptr %17, align 1, !tbaa !7
  %19 = getelementptr inbounds i8, ptr %4, i64 %.030
  %20 = load i8, ptr %19, align 1, !tbaa !7
  %21 = icmp slt i8 %18, %20
  br i1 %21, label %.thread, label %22

22:                                               ; preds = %.lr.ph
  %23 = icmp sgt i8 %18, %20
  br i1 %23, label %.thread, label %15

._crit_edge:                                      ; preds = %15, %11
  %24 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %25 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %26 = icmp ult i64 %24, %25
  br i1 %26, label %.thread, label %27

27:                                               ; preds = %._crit_edge
  %28 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %29 = tail call noundef i64 @_ZNK7testing8internal6String6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %30 = icmp ugt i64 %28, %29
  %31 = zext i1 %30 to i32
  br label %.thread

.thread:                                          ; preds = %.lr.ph, %22, %._crit_edge, %27, %9, %6
  %.2 = phi i32 [ %8, %6 ], [ 1, %9 ], [ %31, %27 ], [ -1, %._crit_edge ], [ -1, %.lr.ph ], [ 1, %22 ]
  ret i32 %.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

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

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass