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

; 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__._ZNK6Common10StringView8containsES0_ = 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 @_ZNK6Common10StringView8containsES0_(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 i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = getelementptr inbounds %"class.Common::StringView", ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = icmp ne ptr %12, null
  br i1 %13, label %18, label %14

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

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

20:                                               ; preds = %18
  br label %23

21:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.2, i32 noundef 219, ptr noundef @__PRETTY_FUNCTION__._ZNK6Common10StringView8containsES0_) #3
  unreachable

22:                                               ; No predecessors!
  br label %23

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

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

31:                                               ; preds = %27, %23
  %32 = phi i1 [ true, %23 ], [ %30, %27 ]
  br i1 %32, label %33, label %34

33:                                               ; preds = %31
  br label %36

34:                                               ; preds = %31
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 220, ptr noundef @__PRETTY_FUNCTION__._ZNK6Common10StringView8containsES0_) #3
  unreachable

35:                                               ; No predecessors!
  br label %36

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

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

48:                                               ; preds = %85, %42
  %49 = load i64, ptr %6, align 8, !tbaa !13
  %50 = load i64, ptr %7, align 8, !tbaa !13
  %51 = icmp ult i64 %49, %50
  %52 = xor i1 %51, true
  br i1 %52, label %54, label %53

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

54:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !13
  br label %55

55:                                               ; preds = %79, %54
  %56 = load i64, ptr %9, align 8, !tbaa !13
  %57 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 1
  %58 = load i64, ptr %57, align 8, !tbaa !12
  %59 = icmp eq i64 %56, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %82

61:                                               ; preds = %55
  %62 = getelementptr inbounds %"class.Common::StringView", ptr %10, 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 i64, ptr %9, align 8, !tbaa !13
  %67 = getelementptr inbounds i8, ptr %65, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !14
  %69 = sext i8 %68 to i32
  %70 = getelementptr inbounds %"class.Common::StringView", ptr %1, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !9
  %72 = load i64, ptr %9, align 8, !tbaa !13
  %73 = getelementptr inbounds i8, ptr %71, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !14
  %75 = sext i8 %74 to i32
  %76 = icmp eq i32 %69, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %61
  store i32 5, ptr %8, align 4
  br label %82

78:                                               ; preds = %61
  br label %79

79:                                               ; preds = %78
  %80 = load i64, ptr %9, align 8, !tbaa !13
  %81 = add i64 %80, 1
  store i64 %81, ptr %9, align 8, !tbaa !13
  br label %55, !llvm.loop !15

82:                                               ; preds = %77, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  %83 = load i32, ptr %8, align 4
  switch i32 %83, label %88 [
    i32 5, label %84
  ]

84:                                               ; preds = %82
  br label %85

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

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

90:                                               ; preds = %88
  store i32 0, ptr %8, align 4
  br label %91

91:                                               ; preds = %90, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %92 = load i32, ptr %8, align 4
  switch i32 %92, label %97 [
    i32 0, label %93
    i32 1, label %95
  ]

93:                                               ; preds = %91
  br label %94

94:                                               ; preds = %93, %36
  store i1 false, ptr %3, align 1
  br label %95

95:                                               ; preds = %94, %91
  %96 = load i1, ptr %3, align 1
  ret i1 %96

97:                                               ; preds = %91
  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"}
!17 = distinct !{!17, !16}


; 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__._ZNK6Common10StringView8containsES0_ = 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 @_ZNK6Common10StringView8containsES0_(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 219, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK6Common10StringView8containsES0_) #2
  unreachable

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

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

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

.critedge3:                                       ; preds = %.critedge
  %.not22 = icmp ult i64 %5, %10
  br i1 %.not22, label %.thread28, label %14

14:                                               ; preds = %.critedge3
  %15 = sub i64 %5, %10
  %.not2433 = icmp eq i64 %10, 0
  br i1 %.not2433, label %.thread28, label %.preheader

.preheader:                                       ; preds = %14, %25
  %.01635 = phi i64 [ %26, %25 ], [ 0, %14 ]
  %16 = getelementptr inbounds i8, ptr %3, i64 %.01635
  br label %19

17:                                               ; preds = %19
  %18 = add nuw i64 %.034, 1
  %.not24 = icmp eq i64 %18, %10
  br i1 %.not24, label %.thread28, label %19, !llvm.loop !12

19:                                               ; preds = %.preheader, %17
  %.034 = phi i64 [ 0, %.preheader ], [ %18, %17 ]
  %20 = getelementptr inbounds i8, ptr %16, i64 %.034
  %21 = load i8, ptr %20, align 1, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %8, i64 %.034
  %23 = load i8, ptr %22, align 1, !tbaa !14
  %24 = icmp eq i8 %21, %23
  br i1 %24, label %17, label %25

25:                                               ; preds = %19
  %26 = add i64 %.01635, 1
  %.not23 = icmp ult i64 %15, %26
  br i1 %.not23, label %.thread28, label %.preheader, !llvm.loop !15

.thread28:                                        ; preds = %25, %17, %11, %14, %.critedge3
  %.3 = phi i1 [ false, %.critedge3 ], [ true, %14 ], [ true, %11 ], [ true, %17 ], [ false, %25 ]
  ret i1 %.3
}

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


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass