; LLVM IR from dynexcoin/Dynex :: src/Common/StringView.ll (ZNK6Common10StringViewltES0_)

; 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.Common::StringView" = type { ptr, i64 }

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@__PRETTY_FUNCTION__._ZNK6Common10StringViewltES0_ = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK6Common10StringViewltES0_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  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
  %12 = getelementptr inbounds %"class.Common::StringView", ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp ne ptr %13, null
  br i1 %14, label %19, label %15

15:                                               ; preds = %2
  %16 = getelementptr inbounds %"class.Common::StringView", ptr %11, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !12
  %18 = icmp eq i64 %17, 0
  br label %19

19:                                               ; preds = %15, %2
  %20 = phi i1 [ true, %2 ], [ %18, %15 ]
  br i1 %20, label %21, label %22

21:                                               ; preds = %19
  br label %24

22:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.2, i32 noundef 150, ptr noundef @__PRETTY_FUNCTION__._ZNK6Common10StringViewltES0_) #3
  unreachable

23:                                               ; No predecessors!
  br label %24

24:                                               ; preds = %23, %21
  %25 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = icmp ne ptr %26, null
  br i1 %27, label %32, label %28

28:                                               ; preds = %24
  %29 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !12
  %31 = icmp eq i64 %30, 0
  br label %32

32:                                               ; preds = %28, %24
  %33 = phi i1 [ true, %24 ], [ %31, %28 ]
  br i1 %33, label %34, label %35

34:                                               ; preds = %32
  br label %37

35:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 151, ptr noundef @__PRETTY_FUNCTION__._ZNK6Common10StringViewltES0_) #3
  unreachable

36:                                               ; No predecessors!
  br label %37

37:                                               ; preds = %36, %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %38 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !12
  %40 = getelementptr inbounds %"class.Common::StringView", ptr %11, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !12
  %42 = icmp ult i64 %39, %41
  br i1 %42, label %43, label %46

43:                                               ; preds = %37
  %44 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !12
  br label %49

46:                                               ; preds = %37
  %47 = getelementptr inbounds %"class.Common::StringView", ptr %11, i32 0, i32 1
  %48 = load i64, ptr %47, align 8, !tbaa !12
  br label %49

49:                                               ; preds = %46, %43
  %50 = phi i64 [ %45, %43 ], [ %48, %46 ]
  store i64 %50, ptr %6, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !13
  br label %51

51:                                               ; preds = %84, %49
  %52 = load i64, ptr %7, align 8, !tbaa !13
  %53 = load i64, ptr %6, align 8, !tbaa !13
  %54 = icmp ult i64 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 2, ptr %8, align 4
  br label %87

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  %57 = getelementptr inbounds %"class.Common::StringView", ptr %11, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = load i64, ptr %7, align 8, !tbaa !13
  %60 = getelementptr inbounds i8, ptr %58, i64 %59
  %61 = load i8, ptr %60, align 1, !tbaa !14
  store i8 %61, ptr %9, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %62 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = load i64, ptr %7, align 8, !tbaa !13
  %65 = getelementptr inbounds i8, ptr %63, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !14
  store i8 %66, ptr %10, align 1, !tbaa !14
  %67 = load i8, ptr %9, align 1, !tbaa !14
  %68 = sext i8 %67 to i32
  %69 = load i8, ptr %10, align 1, !tbaa !14
  %70 = sext i8 %69 to i32
  %71 = icmp slt i32 %68, %70
  br i1 %71, label %72, label %73

72:                                               ; preds = %56
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %81

73:                                               ; preds = %56
  %74 = load i8, ptr %10, align 1, !tbaa !14
  %75 = sext i8 %74 to i32
  %76 = load i8, ptr %9, align 1, !tbaa !14
  %77 = sext i8 %76 to i32
  %78 = icmp slt i32 %75, %77
  br i1 %78, label %79, label %80

79:                                               ; preds = %73
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %81

80:                                               ; preds = %73
  store i32 0, ptr %8, align 4
  br label %81

81:                                               ; preds = %80, %79, %72
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  %82 = load i32, ptr %8, align 4
  switch i32 %82, label %87 [
    i32 0, label %83
  ]

83:                                               ; preds = %81
  br label %84

84:                                               ; preds = %83
  %85 = load i64, ptr %7, align 8, !tbaa !13
  %86 = add i64 %85, 1
  store i64 %86, ptr %7, align 8, !tbaa !13
  br label %51, !llvm.loop !15

87:                                               ; preds = %81, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %88 = load i32, ptr %8, align 4
  switch i32 %88, label %95 [
    i32 2, label %89
  ]

89:                                               ; preds = %87
  %90 = getelementptr inbounds %"class.Common::StringView", ptr %11, i32 0, i32 1
  %91 = load i64, ptr %90, align 8, !tbaa !12
  %92 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 1
  %93 = load i64, ptr %92, align 8, !tbaa !12
  %94 = icmp ult i64 %91, %93
  store i1 %94, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %95

95:                                               ; preds = %89, %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %96 = load i1, ptr %3, align 1
  ret i1 %96
}

attributes #0 = { noreturn 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 #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 = { noreturn nounwind }
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, !6, i64 0}
!10 = !{!"_ZTSN6Common10StringViewE", !6, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!11, !11, i64 0}
!14 = !{!7, !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"

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [41 x i8], align 1
@__PRETTY_FUNCTION__._ZNK6Common10StringViewltES0_ = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK6Common10StringViewltES0_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 align 2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp ne ptr %3, null
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8
  %6 = icmp eq i64 %5, 0
  %or.cond = select i1 %.not, i1 true, i1 %6
  br i1 %or.cond, label %.critedge, label %7

7:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, i32 noundef 150, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK6Common10StringViewltES0_) #3
  unreachable

.critedge:                                        ; preds = %2
  %8 = load ptr, ptr %1, align 8, !tbaa !5
  %.not22 = icmp eq ptr %8, null
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !11
  br i1 %.not22, label %11, label %.critedge3

11:                                               ; preds = %.critedge
  %12 = icmp eq i64 %10, 0
  br i1 %12, label %.critedge3, label %13

13:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 151, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK6Common10StringViewltES0_) #3
  unreachable

.critedge3:                                       ; preds = %.critedge, %11
  %14 = phi i64 [ 0, %11 ], [ %10, %.critedge ]
  %. = tail call i64 @llvm.umin.i64(i64 %14, i64 %5)
  %.not2331.not = icmp eq i64 %., 0
  br i1 %.not2331.not, label %._crit_edge, label %.lr.ph

15:                                               ; preds = %.lr.ph
  %16 = add nuw i64 %.01532, 1
  %exitcond.not = icmp eq i64 %16, %.
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

.lr.ph:                                           ; preds = %.critedge3, %15
  %.01532 = phi i64 [ %16, %15 ], [ 0, %.critedge3 ]
  %17 = getelementptr inbounds i8, ptr %3, i64 %.01532
  %18 = load i8, ptr %17, align 1, !tbaa !14
  %19 = getelementptr inbounds i8, ptr %8, i64 %.01532
  %20 = load i8, ptr %19, align 1, !tbaa !14
  %or.cond35.not = icmp eq i8 %20, %18
  br i1 %or.cond35.not, label %15, label %.thread29.loopexit

._crit_edge:                                      ; preds = %15, %.critedge3
  %21 = icmp ult i64 %5, %14
  br label %.thread29

.thread29.loopexit:                               ; preds = %.lr.ph
  %22 = icmp slt i8 %18, %20
  br label %.thread29

.thread29:                                        ; preds = %.thread29.loopexit, %._crit_edge
  %.3 = phi i1 [ %21, %._crit_edge ], [ %22, %.thread29.loopexit ]
  ret i1 %.3
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #2

attributes #0 = { noreturn 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { noreturn 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 = !{!"_ZTSN6Common10StringViewE", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!8, !8, i64 0}


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