; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数据结构/可持久化Treap.ll (ZN12shared_treap4findEPNS_4nodeEi)

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

%"struct.shared_treap::node" = type <{ %"struct.shared_treap::pointer", %"struct.shared_treap::pointer", i32, i32, i32, [4 x i8] }>
%"struct.shared_treap::pointer" = type { ptr }

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN12shared_treap4findEPNS_4nodeEi(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %31, %2
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %32

9:                                                ; preds = %6
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.shared_treap::node", ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = icmp eq i32 %10, %13
  br i1 %14, label %15, label %16

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

16:                                               ; preds = %9
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.shared_treap::node", ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !11
  %21 = icmp slt i32 %17, %20
  br i1 %21, label %22, label %26

22:                                               ; preds = %16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.shared_treap::node", ptr %23, i32 0, i32 0
  %25 = call noundef ptr @_ZNK12shared_treap7pointercvPNS_4nodeEEv(ptr noundef nonnull align 8 dereferenceable(8) %24)
  store ptr %25, ptr %4, align 8, !tbaa !5
  br label %30

26:                                               ; preds = %16
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.shared_treap::node", ptr %27, i32 0, i32 1
  %29 = call noundef ptr @_ZNK12shared_treap7pointercvPNS_4nodeEEv(ptr noundef nonnull align 8 dereferenceable(8) %28)
  store ptr %29, ptr %4, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %26, %22
  br label %31

31:                                               ; preds = %30
  br label %6, !llvm.loop !14

32:                                               ; preds = %6
  store i1 false, ptr %3, align 1
  br label %33

33:                                               ; preds = %32, %15
  %34 = load i1, ptr %3, align 1
  ret i1 %34
}

attributes #0 = { inlinehint 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 #1 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTSN12shared_treap4nodeE", !13, i64 0, !13, i64 8, !10, i64 16, !10, i64 20, !10, i64 24}
!13 = !{!"_ZTSN12shared_treap7pointerE", !6, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN12shared_treap4findEPNS_4nodeEi(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not10.not = icmp eq ptr %0, null
  br i1 %.not10.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %6
  %.0711 = phi ptr [ %8, %6 ], [ %0, %2 ]
  %3 = getelementptr inbounds i8, ptr %.0711, i64 16
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, %1
  br i1 %5, label %._crit_edge, label %6

6:                                                ; preds = %.lr.ph
  %7 = icmp sgt i32 %4, %1
  %.0711.sink.idx = select i1 %7, i64 0, i64 8
  %.0711.sink = getelementptr inbounds i8, ptr %.0711, i64 %.0711.sink.idx
  %8 = tail call noundef ptr @_ZNK12shared_treap7pointercvPNS_4nodeEEv(ptr noundef nonnull align 8 dereferenceable(8) %.0711.sink)
  %.not.not = icmp eq ptr %8, null
  br i1 %.not.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %6, %2
  %.not.lcssa = phi i1 [ false, %2 ], [ %5, %6 ], [ %5, %.lr.ph ]
  ret i1 %.not.lcssa
}

attributes #0 = { inlinehint 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 #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" }

!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, !11, i64 16}
!6 = !{!"_ZTSN12shared_treap4nodeE", !7, i64 0, !7, i64 8, !11, i64 16, !11, i64 20, !11, i64 24}
!7 = !{!"_ZTSN12shared_treap7pointerE", !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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