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

; 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__._ZNK6Common10StringView8endsWithES0_ = external hidden unnamed_addr constant [52 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 @_ZNK6Common10StringView8endsWithES0_(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
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  %10 = getelementptr inbounds %"class.Common::StringView", ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = icmp ne ptr %11, null
  br i1 %12, label %17, label %13

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

17:                                               ; preds = %13, %2
  %18 = phi i1 [ true, %2 ], [ %16, %13 ]
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  br label %22

20:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.2, i32 noundef 249, ptr noundef @__PRETTY_FUNCTION__._ZNK6Common10StringView8endsWithES0_) #3
  unreachable

21:                                               ; No predecessors!
  br label %22

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

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

30:                                               ; preds = %26, %22
  %31 = phi i1 [ true, %22 ], [ %29, %26 ]
  br i1 %31, label %32, label %33

32:                                               ; preds = %30
  br label %35

33:                                               ; preds = %30
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 250, ptr noundef @__PRETTY_FUNCTION__._ZNK6Common10StringView8endsWithES0_) #3
  unreachable

34:                                               ; No predecessors!
  br label %35

35:                                               ; preds = %34, %32
  %36 = getelementptr inbounds %"class.Common::StringView", ptr %9, i32 0, i32 1
  %37 = load i64, ptr %36, align 8, !tbaa !12
  %38 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !12
  %40 = icmp uge i64 %37, %39
  br i1 %40, label %41, label %80

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %42 = getelementptr inbounds %"class.Common::StringView", ptr %9, i32 0, i32 1
  %43 = load i64, ptr %42, align 8, !tbaa !12
  %44 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 1
  %45 = load i64, ptr %44, align 8, !tbaa !12
  %46 = sub i64 %43, %45
  store i64 %46, 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 %47

47:                                               ; preds = %71, %41
  %48 = load i64, ptr %7, align 8, !tbaa !13
  %49 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !12
  %51 = icmp eq i64 %48, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %47
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %74

53:                                               ; preds = %47
  %54 = getelementptr inbounds %"class.Common::StringView", ptr %9, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  %56 = load i64, ptr %6, align 8, !tbaa !13
  %57 = getelementptr inbounds i8, ptr %55, i64 %56
  %58 = load i64, ptr %7, align 8, !tbaa !13
  %59 = getelementptr inbounds i8, ptr %57, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !14
  %61 = sext i8 %60 to i32
  %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
  %67 = sext i8 %66 to i32
  %68 = icmp eq i32 %61, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %53
  store i32 2, ptr %8, align 4
  br label %74

70:                                               ; preds = %53
  br label %71

71:                                               ; preds = %70
  %72 = load i64, ptr %7, align 8, !tbaa !13
  %73 = add i64 %72, 1
  store i64 %73, ptr %7, align 8, !tbaa !13
  br label %47, !llvm.loop !15

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

76:                                               ; preds = %74
  store i32 0, ptr %8, align 4
  br label %77

77:                                               ; preds = %76, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %78 = load i32, ptr %8, align 4
  switch i32 %78, label %83 [
    i32 0, label %79
    i32 1, label %81
  ]

79:                                               ; preds = %77
  br label %80

80:                                               ; preds = %79, %35
  store i1 false, ptr %3, align 1
  br label %81

81:                                               ; preds = %80, %77
  %82 = load i1, ptr %3, align 1
  ret i1 %82

83:                                               ; preds = %77
  unreachable
}

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__._ZNK6Common10StringView8endsWithES0_ = external hidden unnamed_addr constant [52 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 @_ZNK6Common10StringView8endsWithES0_(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 249, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK6Common10StringView8endsWithES0_) #2
  unreachable

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

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

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

.critedge2:                                       ; preds = %.critedge
  %.not15 = icmp ult i64 %5, %10
  br i1 %.not15, label %.thread, label %14

14:                                               ; preds = %.critedge2
  %15 = sub i64 %5, %10
  %16 = getelementptr inbounds i8, ptr %3, i64 %15
  %.not1620 = icmp eq i64 %10, 0
  br i1 %.not1620, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %14, %.lr.ph
  %.01021 = phi i64 [ %22, %.lr.ph ], [ 0, %14 ]
  %17 = getelementptr inbounds i8, ptr %16, i64 %.01021
  %18 = load i8, ptr %17, align 1, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %8, i64 %.01021
  %20 = load i8, ptr %19, align 1, !tbaa !12
  %21 = icmp eq i8 %18, %20
  %22 = add nuw i64 %.01021, 1
  %.not16 = icmp ne i64 %22, %10
  %or.cond28.not = select i1 %21, i1 %.not16, i1 false
  br i1 %or.cond28.not, label %.lr.ph, label %.thread, !llvm.loop !13

.thread:                                          ; preds = %.lr.ph, %11, %14, %.critedge2
  %.1 = phi i1 [ false, %.critedge2 ], [ true, %14 ], [ true, %11 ], [ %21, %.lr.ph ]
  ret i1 %.1
}

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 = { 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 = !{!8, !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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