; LLVM IR from PacktPublishing/CPP-Data-Structures-and-Algorithms :: Chapter05/Sublist_Search/Sublist_Search.ll (Z13SublistSearchP4NodeS0_)

; 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.Node = type { i32, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z25CompareAllMatchedElementsP4NodeS0_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z13SublistSearchP4NodeS0_(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %12

8:                                                ; preds = %2
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  store i1 true, ptr %3, align 1
  br label %45

12:                                               ; preds = %8, %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %12
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %24, label %18

18:                                               ; preds = %15, %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %25

21:                                               ; preds = %18
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %21, %15
  store i1 false, ptr %3, align 1
  br label %45

25:                                               ; preds = %21, %18
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.Node, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.Node, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !9
  %32 = icmp eq i32 %28, %31
  br i1 %32, label %33, label %39

33:                                               ; preds = %25
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call noundef zeroext i1 @_Z25CompareAllMatchedElementsP4NodeS0_(ptr noundef %34, ptr noundef %35)
  br i1 %36, label %37, label %38

37:                                               ; preds = %33
  store i1 true, ptr %3, align 1
  br label %45

38:                                               ; preds = %33
  br label %39

39:                                               ; preds = %38, %25
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.Node, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !12
  %44 = call noundef zeroext i1 @_Z13SublistSearchP4NodeS0_(ptr noundef %40, ptr noundef %43)
  store i1 %44, ptr %3, align 1
  br label %45

45:                                               ; preds = %39, %37, %24, %11
  %46 = load i1, ptr %3, align 1
  ret i1 %46
}

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

!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, !11, i64 0}
!10 = !{!"_ZTS4Node", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}


; 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 uwtable
declare dso_local noundef zeroext i1 @_Z25CompareAllMatchedElementsP4NodeS0_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z13SublistSearchP4NodeS0_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond20 = and i1 %3, %4
  br i1 %or.cond20, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %5 = icmp eq ptr %1, null
  br i1 %3, label %.lr.ph.split, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph
  br i1 %5, label %._crit_edge, label %.lr.ph28

.lr.ph28:                                         ; preds = %.lr.ph.split.us, %tailrecurse.us
  %.tr1921.us27 = phi ptr [ %12, %tailrecurse.us ], [ %1, %.lr.ph.split.us ]
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = load i32, ptr %.tr1921.us27, align 8, !tbaa !5
  %8 = icmp eq i32 %6, %7
  br i1 %8, label %9, label %tailrecurse.us

9:                                                ; preds = %.lr.ph28
  %10 = tail call noundef zeroext i1 @_Z25CompareAllMatchedElementsP4NodeS0_(ptr noundef nonnull %0, ptr noundef nonnull %.tr1921.us27)
  br i1 %10, label %._crit_edge, label %tailrecurse.us

tailrecurse.us:                                   ; preds = %9, %.lr.ph28
  %11 = getelementptr inbounds i8, ptr %.tr1921.us27, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %.not32 = icmp eq ptr %12, null
  br i1 %.not32, label %._crit_edge, label %.lr.ph28

.lr.ph.split:                                     ; preds = %.lr.ph
  br i1 %5, label %13, label %._crit_edge

13:                                               ; preds = %.lr.ph.split
  %14 = tail call noundef zeroext i1 @_Z25CompareAllMatchedElementsP4NodeS0_(ptr noundef nonnull null, ptr noundef nonnull null)
  br i1 %14, label %._crit_edge, label %tailrecurse

tailrecurse:                                      ; preds = %13
  %15 = load ptr, ptr inttoptr (i64 8 to ptr), align 8, !tbaa !11
  %16 = icmp eq ptr %15, null
  br label %._crit_edge

._crit_edge:                                      ; preds = %tailrecurse.us, %9, %tailrecurse, %.lr.ph.split, %13, %.lr.ph.split.us, %2
  %.0 = phi i1 [ true, %2 ], [ false, %.lr.ph.split.us ], [ false, %.lr.ph.split ], [ true, %13 ], [ %16, %tailrecurse ], [ true, %9 ], [ false, %tailrecurse.us ]
  ret i1 %.0
}

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

!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 = !{!"_ZTS4Node", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass