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

; 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.treap_old::node" = type { ptr, ptr, i32, i32, i32 }

@_ZN9treap_old3nilE = external dso_local global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9treap_old5mergeERPNS_4nodeES1_S1_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr @_ZN9treap_old3nilE, align 8, !tbaa !5
  %9 = icmp eq ptr %7, %8
  br i1 %9, label %10, label %13

10:                                               ; preds = %3
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %11, ptr %12, align 8, !tbaa !5
  br label %58

13:                                               ; preds = %3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr @_ZN9treap_old3nilE, align 8, !tbaa !5
  %16 = icmp eq ptr %14, %15
  br i1 %16, label %17, label %20

17:                                               ; preds = %13
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %18, ptr %19, align 8, !tbaa !5
  br label %57

20:                                               ; preds = %13
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.treap_old::node", ptr %21, i32 0, i32 2
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.treap_old::node", ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !9
  %27 = icmp sgt i32 %23, %26
  br i1 %27, label %28, label %42

28:                                               ; preds = %20
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %29, ptr %30, align 8, !tbaa !5
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  call void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32) %32)
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.treap_old::node", ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.treap_old::node", ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !12
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN9treap_old5mergeERPNS_4nodeES1_S1_(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef %38, ptr noundef %39)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  call void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32) %41)
  br label %56

42:                                               ; preds = %20
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %43, ptr %44, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  call void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32) %46)
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.treap_old::node", ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.treap_old::node", ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  call void @_ZN9treap_old5mergeERPNS_4nodeES1_S1_(ptr noundef nonnull align 8 dereferenceable(8) %49, ptr noundef %50, ptr noundef %53)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  call void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32) %55)
  br label %56

56:                                               ; preds = %42, %28
  br label %57

57:                                               ; preds = %56, %17
  br label %58

58:                                               ; preds = %57, %10
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

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


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

@_ZN9treap_old3nilE = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9treap_old5mergeERPNS_4nodeES1_S1_(ptr nocapture noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr @_ZN9treap_old3nilE, align 8, !tbaa !5
  %5 = icmp eq ptr %4, %1
  br i1 %5, label %6, label %7

6:                                                ; preds = %3
  store ptr %2, ptr %0, align 8, !tbaa !5
  br label %common.ret24

7:                                                ; preds = %3
  %8 = icmp eq ptr %4, %2
  br i1 %8, label %9, label %10

9:                                                ; preds = %7
  store ptr %1, ptr %0, align 8, !tbaa !5
  br label %common.ret24

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %2, i64 16
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp sgt i32 %12, %14
  br i1 %15, label %16, label %22

common.ret24:                                     ; preds = %9, %6, %22, %16
  ret void

16:                                               ; preds = %10
  store ptr %1, ptr %0, align 8, !tbaa !5
  tail call void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %17 = load ptr, ptr %0, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  tail call void @_ZN9treap_old5mergeERPNS_4nodeES1_S1_(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef %20, ptr noundef nonnull %2)
  %21 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32) %21)
  br label %common.ret24

22:                                               ; preds = %10
  store ptr %2, ptr %0, align 8, !tbaa !5
  tail call void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %23 = load ptr, ptr %0, align 8, !tbaa !5
  %24 = load ptr, ptr %2, align 8, !tbaa !13
  tail call void @_ZN9treap_old5mergeERPNS_4nodeES1_S1_(ptr noundef nonnull align 8 dereferenceable(8) %23, ptr noundef nonnull %1, ptr noundef %24)
  %25 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32) %25)
  br label %common.ret24
}

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

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

attributes #0 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"_ZTSN9treap_old4nodeE", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass