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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; 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)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3HIR10SimplePath11starts_withERKS0_b(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i1 noundef zeroext %2) #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca %class.RcString, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  %13 = zext i1 %2 to i8
  store i8 %13, ptr %7, align 1, !tbaa !9
  %14 = load ptr, ptr %5, align 8
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %15, i32 0, i32 0
  %17 = call noundef zeroext i1 @_ZNK10ThinVectorI8RcStringE5emptyEv(ptr noundef nonnull align 8 dereferenceable(8) %16)
  br i1 %17, label %18, label %26

18:                                               ; preds = %3
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3HIR10SimplePath10crate_nameEv(ptr noundef nonnull align 8 dereferenceable(8) %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @_ZN8RcStringC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8)
  %20 = invoke noundef zeroext i1 @_ZNK8RcStringeqERKS_(ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %21 unwind label %22

21:                                               ; preds = %18
  store i1 %20, ptr %4, align 1
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %71

22:                                               ; preds = %18
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %9, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %10, align 4
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %73

26:                                               ; preds = %3
  %27 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %14, i32 0, i32 0
  %28 = call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %27)
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %29, i32 0, i32 0
  %31 = call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %30)
  %32 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %33 = trunc i8 %32 to i1
  %34 = zext i1 %33 to i64
  %35 = select i1 %33, i32 1, i32 0
  %36 = sext i32 %35 to i64
  %37 = sub i64 %31, %36
  %38 = icmp ult i64 %28, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %26
  store i1 false, ptr %4, align 1
  br label %71

40:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !13
  br label %41

41:                                               ; preds = %65, %40
  %42 = load i64, ptr %11, align 8, !tbaa !13
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %43, i32 0, i32 0
  %45 = call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %44)
  %46 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %47 = trunc i8 %46 to i1
  %48 = zext i1 %47 to i64
  %49 = select i1 %47, i32 1, i32 0
  %50 = sext i32 %49 to i64
  %51 = sub i64 %45, %50
  %52 = icmp ult i64 %42, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %41
  store i32 2, ptr %12, align 4
  br label %68

54:                                               ; preds = %41
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %55, i32 0, i32 0
  %57 = load i64, ptr %11, align 8, !tbaa !13
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK10ThinVectorI8RcStringEixEm(ptr noundef nonnull align 8 dereferenceable(8) %56, i64 noundef %57)
  %59 = getelementptr inbounds %"struct.HIR::SimplePath", ptr %14, i32 0, i32 0
  %60 = load i64, ptr %11, align 8, !tbaa !13
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK10ThinVectorI8RcStringEixEm(ptr noundef nonnull align 8 dereferenceable(8) %59, i64 noundef %60)
  %62 = call noundef zeroext i1 @_ZNK8RcStringneERKS_(ptr noundef nonnull align 8 dereferenceable(8) %58, ptr noundef nonnull align 8 dereferenceable(8) %61)
  br i1 %62, label %63, label %64

63:                                               ; preds = %54
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %68

64:                                               ; preds = %54
  br label %65

65:                                               ; preds = %64
  %66 = load i64, ptr %11, align 8, !tbaa !13
  %67 = add i64 %66, 1
  store i64 %67, ptr %11, align 8, !tbaa !13
  br label %41, !llvm.loop !15

68:                                               ; preds = %63, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %69 = load i32, ptr %12, align 4
  switch i32 %69, label %78 [
    i32 2, label %70
    i32 1, label %71
  ]

70:                                               ; preds = %68
  store i1 true, ptr %4, align 1
  br label %71

71:                                               ; preds = %70, %68, %39, %21
  %72 = load i1, ptr %4, align 1
  ret i1 %72

73:                                               ; preds = %22
  %74 = load ptr, ptr %9, align 8
  %75 = load i32, ptr %10, align 4
  %76 = insertvalue { ptr, i32 } poison, ptr %74, 0
  %77 = insertvalue { ptr, i32 } %76, i32 %75, 1
  resume { ptr, i32 } %77

78:                                               ; preds = %68
  unreachable
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%class.RcString = type { ptr }

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; 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 #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3HIR10SimplePath11starts_withERKS0_b(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.RcString, align 8
  %5 = tail call noundef zeroext i1 @_ZNK10ThinVectorI8RcStringE5emptyEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  br i1 %5, label %6, label %12

6:                                                ; preds = %3
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3HIR10SimplePath10crate_nameEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZN8RcStringC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %8 = invoke noundef zeroext i1 @_ZNK8RcStringeqERKS_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %9 unwind label %10

9:                                                ; preds = %6
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %.loopexit

10:                                               ; preds = %6
  %11 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN8RcStringD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  resume { ptr, i32 } %11

12:                                               ; preds = %3
  %13 = tail call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %14 = tail call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %15 = zext i1 %2 to i64
  %16 = sub i64 %14, %15
  %17 = icmp ult i64 %13, %16
  br i1 %17, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %12
  %18 = tail call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %19 = icmp eq i64 %18, %15
  br i1 %19, label %.loopexit, label %.lr.ph

20:                                               ; preds = %.lr.ph
  %21 = add nuw i64 %.01416, 1
  %22 = tail call noundef i64 @_ZNK10ThinVectorI8RcStringE4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %23 = sub i64 %22, %15
  %.not = icmp ult i64 %21, %23
  br i1 %.not, label %.lr.ph, label %.loopexit.loopexit, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader, %20
  %.01416 = phi i64 [ %21, %20 ], [ 0, %.preheader ]
  %24 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK10ThinVectorI8RcStringEixEm(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %.01416)
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK10ThinVectorI8RcStringEixEm(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 noundef %.01416)
  %26 = tail call noundef zeroext i1 @_ZNK8RcStringneERKS_(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull align 8 dereferenceable(8) %25)
  br i1 %26, label %.loopexit.loopexit, label %20

.loopexit.loopexit:                               ; preds = %20, %.lr.ph
  %.1.ph = xor i1 %26, true
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader, %12, %9
  %.1 = phi i1 [ %8, %9 ], [ false, %12 ], [ true, %.preheader ], [ %.1.ph, %.loopexit.loopexit ]
  ret i1 %.1
}

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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