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

; 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 nounwind uwtable
declare dso_local void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

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

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

11:                                               ; preds = %4
  %12 = load ptr, ptr @_ZN9treap_old3nilE, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %12, ptr %13, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %14, ptr %15, align 8, !tbaa !5
  br label %72

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

22:                                               ; preds = %16
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %23, ptr %24, align 8, !tbaa !5
  %25 = load ptr, ptr @_ZN9treap_old3nilE, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %25, ptr %26, align 8, !tbaa !5
  br label %71

27:                                               ; preds = %16
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.treap_old::node", ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = getelementptr inbounds %"struct.treap_old::node", ptr %30, i32 0, i32 4
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = icmp sge i32 %32, %33
  br i1 %34, label %35, label %49

35:                                               ; preds = %27
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32) %36)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %37, ptr %38, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.treap_old::node", ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.treap_old::node", ptr %44, i32 0, i32 0
  %46 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN9treap_old5splitEPNS_4nodeERS1_S2_i(ptr noundef %41, ptr noundef nonnull align 8 dereferenceable(8) %42, ptr noundef nonnull align 8 dereferenceable(8) %45, i32 noundef %46)
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  call void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32) %48)
  br label %70

49:                                               ; preds = %27
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32) %50)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %51, ptr %52, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.treap_old::node", ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = load ptr, ptr %56, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.treap_old::node", ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.treap_old::node", ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !13
  %64 = getelementptr inbounds %"struct.treap_old::node", ptr %63, i32 0, i32 4
  %65 = load i32, ptr %64, align 8, !tbaa !11
  %66 = sub nsw i32 %60, %65
  %67 = sub nsw i32 %66, 1
  call void @_ZN9treap_old5splitEPNS_4nodeERS1_S2_i(ptr noundef %55, ptr noundef nonnull align 8 dereferenceable(8) %58, ptr noundef nonnull align 8 dereferenceable(8) %59, i32 noundef %67)
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  call void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32) %69)
  br label %70

70:                                               ; preds = %49, %35
  br label %71

71:                                               ; preds = %70, %22
  br label %72

72:                                               ; preds = %71, %11
  ret void
}

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" }
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 24}
!12 = !{!"_ZTSN9treap_old4nodeE", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !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"

@_ZN9treap_old3nilE = external dso_local local_unnamed_addr global ptr, align 8

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9treap_old5splitEPNS_4nodeERS1_S2_i(ptr noundef %0, ptr nocapture noundef nonnull align 8 dereferenceable(8) %1, ptr nocapture noundef nonnull align 8 dereferenceable(8) %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq i32 %3, 0
  br i1 %5, label %6, label %8

6:                                                ; preds = %4
  %7 = load ptr, ptr @_ZN9treap_old3nilE, align 8, !tbaa !5
  store ptr %7, ptr %1, align 8, !tbaa !5
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %common.ret28

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load i32, ptr %9, align 8, !tbaa !9
  %.not = icmp sgt i32 %10, %3
  br i1 %.not, label %13, label %11

11:                                               ; preds = %8
  store ptr %0, ptr %1, align 8, !tbaa !5
  %12 = load ptr, ptr @_ZN9treap_old3nilE, align 8, !tbaa !5
  store ptr %12, ptr %2, align 8, !tbaa !5
  br label %common.ret28

13:                                               ; preds = %8
  %14 = load ptr, ptr %0, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %14, i64 24
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %.not27 = icmp slt i32 %16, %3
  tail call void @_ZN9treap_old4node4downEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  br i1 %.not27, label %20, label %17

common.ret28:                                     ; preds = %11, %6, %20, %17
  ret void

17:                                               ; preds = %13
  store ptr %0, ptr %2, align 8, !tbaa !5
  %18 = load ptr, ptr %0, align 8, !tbaa !12
  tail call void @_ZN9treap_old5splitEPNS_4nodeERS1_S2_i(ptr noundef %18, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %3)
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32) %19)
  br label %common.ret28

20:                                               ; preds = %13
  store ptr %0, ptr %1, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load ptr, ptr %0, align 8, !tbaa !12
  %24 = getelementptr inbounds i8, ptr %23, i64 24
  %25 = load i32, ptr %24, align 8, !tbaa !9
  %26 = xor i32 %25, -1
  %27 = add i32 %26, %3
  tail call void @_ZN9treap_old5splitEPNS_4nodeERS1_S2_i(ptr noundef %22, ptr noundef nonnull align 8 dereferenceable(8) %21, ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef %27)
  %28 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @_ZN9treap_old4node2upEv(ptr noundef nonnull align 8 dereferenceable(32) %28)
  br label %common.ret28
}

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 24}
!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 0}
!13 = !{!10, !6, i64 8}


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