; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/1512（左偏树）.ll (Z5mergeii)

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

@ltree = external dso_local global [100005 x %struct.node], align 16
@par = external dso_local global [100005 x i32], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5mergeii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %2
  %12 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %12, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %106

13:                                               ; preds = %2
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %17, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %106

18:                                               ; preds = %13
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.node, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %25
  %27 = getelementptr inbounds %struct.node, ptr %26, i32 0, i32 3
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = icmp slt i32 %23, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %18
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5) #3
  br label %31

31:                                               ; preds = %30, %18
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %33
  %35 = getelementptr inbounds %struct.node, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = call noundef i32 @_Z5mergeii(i32 noundef %36, i32 noundef %37)
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %40
  %42 = getelementptr inbounds %struct.node, ptr %41, i32 0, i32 1
  store i32 %38, ptr %42, align 4, !tbaa !11
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.node, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 16, !tbaa !12
  store i32 %47, ptr %6, align 4, !tbaa !5
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.node, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !11
  store i32 %52, ptr %7, align 4, !tbaa !5
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100005 x i32], ptr @par, i64 0, i64 %55
  store i32 %53, ptr %56, align 4, !tbaa !5
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %58
  %60 = getelementptr inbounds %struct.node, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %60, align 8, !tbaa !13
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.node, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !13
  %67 = icmp slt i32 %61, %66
  br i1 %67, label %68, label %77

68:                                               ; preds = %31
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.node, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %74
  %76 = getelementptr inbounds %struct.node, ptr %75, i32 0, i32 1
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %72, ptr noundef nonnull align 4 dereferenceable(4) %76) #3
  br label %77

77:                                               ; preds = %68, %31
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.node, ptr %80, i32 0, i32 1
  %82 = load i32, ptr %81, align 4, !tbaa !11
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %84, label %89

84:                                               ; preds = %77
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %86
  %88 = getelementptr inbounds %struct.node, ptr %87, i32 0, i32 2
  store i32 0, ptr %88, align 8, !tbaa !13
  br label %104

89:                                               ; preds = %77
  %90 = load i32, ptr %4, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %91
  %93 = getelementptr inbounds %struct.node, ptr %92, i32 0, i32 1
  %94 = load i32, ptr %93, align 4, !tbaa !11
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.node, ptr %96, i32 0, i32 2
  %98 = load i32, ptr %97, align 8, !tbaa !13
  %99 = add nsw i32 %98, 1
  %100 = load i32, ptr %4, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %101
  %103 = getelementptr inbounds %struct.node, ptr %102, i32 0, i32 2
  store i32 %99, ptr %103, align 8, !tbaa !13
  br label %104

104:                                              ; preds = %89, %84
  %105 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %105, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %106

106:                                              ; preds = %104, %16, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %107 = load i32, ptr %3, align 4
  ret i32 %107
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 12}
!10 = !{!"_ZTS4node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 0}
!13 = !{!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"

%struct.node = type { i32, i32, i32, i32 }

@ltree = external dso_local global [100005 x %struct.node], align 16
@par = external dso_local local_unnamed_addr global [100005 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z5mergeii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = icmp eq i32 %0, 0
  br i1 %5, label %47, label %6

6:                                                ; preds = %2
  %7 = icmp eq i32 %1, 0
  br i1 %7, label %47, label %8

8:                                                ; preds = %6
  %9 = sext i32 %0 to i64
  %10 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %9, i32 3
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = sext i32 %1 to i64
  %13 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %12, i32 3
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = icmp slt i32 %11, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %8
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) #2
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  %.pre7 = load i32, ptr %4, align 4, !tbaa !5
  %.pre12 = sext i32 %.pre to i64
  br label %17

17:                                               ; preds = %16, %8
  %.pre-phi = phi i64 [ %.pre12, %16 ], [ %9, %8 ]
  %18 = phi i32 [ %.pre7, %16 ], [ %1, %8 ]
  %19 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %.pre-phi, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = call noundef i32 @_Z5mergeii(i32 noundef %20, i32 noundef %18)
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %23, i32 1
  store i32 %21, ptr %24, align 4, !tbaa !11
  %25 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %23
  %26 = load i32, ptr %25, align 16, !tbaa !12
  %27 = sext i32 %21 to i64
  %28 = getelementptr inbounds [100005 x i32], ptr @par, i64 0, i64 %27
  store i32 %22, ptr %28, align 4, !tbaa !5
  %29 = sext i32 %26 to i64
  %30 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %29, i32 2
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %27, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !13
  %34 = icmp slt i32 %31, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %17
  %36 = getelementptr inbounds i8, ptr %25, i64 4
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %25, ptr noundef nonnull align 4 dereferenceable(4) %36) #2
  %.pre8 = load i32, ptr %3, align 4, !tbaa !5
  %.phi.trans.insert = sext i32 %.pre8 to i64
  %.phi.trans.insert10 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %.phi.trans.insert, i32 1
  %.pre11 = load i32, ptr %.phi.trans.insert10, align 4, !tbaa !11
  br label %37

37:                                               ; preds = %35, %17
  %.pre-phi13 = phi i64 [ %.phi.trans.insert, %35 ], [ %23, %17 ]
  %38 = phi i32 [ %.pre11, %35 ], [ %21, %17 ]
  %39 = phi i32 [ %.pre8, %35 ], [ %22, %17 ]
  %40 = icmp eq i32 %38, 0
  br i1 %40, label %.sink.split, label %41

41:                                               ; preds = %37
  %42 = sext i32 %38 to i64
  %43 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %42, i32 2
  %44 = load i32, ptr %43, align 8, !tbaa !13
  %45 = add nsw i32 %44, 1
  br label %.sink.split

.sink.split:                                      ; preds = %37, %41
  %.sink = phi i32 [ %45, %41 ], [ 0, %37 ]
  %46 = getelementptr inbounds [100005 x %struct.node], ptr @ltree, i64 0, i64 %.pre-phi13, i32 2
  store i32 %.sink, ptr %46, align 8, !tbaa !13
  br label %47

47:                                               ; preds = %.sink.split, %6, %2
  %.0 = phi i32 [ %1, %2 ], [ %0, %6 ], [ %39, %.sink.split ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

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 = { 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 #2 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 12}
!10 = !{!"_ZTS4node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 0}
!13 = !{!10, !6, i64 8}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass