; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数据结构 (SplayTree)

; 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.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.3" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Tuple_impl.1", %"struct.std::_Head_base.2" }
%"struct.std::_Tuple_impl.1" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { i32 }
%"struct.std::_Head_base.2" = type { i32 }
%"struct.std::_Head_base.3" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10splay_tree4initEv() #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10splay_tree7extractEiii(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 4, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10splay_tree8traverseEi(i32 noundef) #2

declare i32 @printf(ptr noundef, ...) #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca [50 x i32], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"class.std::tuple", align 4
  store i32 0, ptr %1, align 4
  call void @_ZN10splay_tree4initEv()
  call void @llvm.lifetime.start.p0(i64 200, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %22, %0
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp sle i32 %7, 10
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %25

10:                                               ; preds = %6
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef %11)
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [50 x i32], ptr %2, i64 0, i64 %14
  store i32 %12, ptr %15, align 4, !tbaa !5
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [50 x i32], ptr %2, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %16, i32 noundef %20)
  store i32 %21, ptr %3, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %10
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %4, align 4, !tbaa !5
  br label %6, !llvm.loop !9

25:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #5
  %26 = load i32, ptr %3, align 4, !tbaa !5
  call void @_ZN10splay_tree7extractEiii(ptr dead_on_unwind writable sret(%"class.std::tuple") align 4 %5, i32 noundef %26, i32 noundef 3, i32 noundef 10)
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm1EJiiiEEONSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOS4_(ptr noundef nonnull align 4 dereferenceable(12) %5) #5
  %28 = load i32, ptr %27, align 4, !tbaa !5
  call void @_ZN10splay_tree8traverseEi(i32 noundef %28)
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #5
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 200, ptr %2) #5
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm1EJiiiEEONSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOS4_(ptr noundef nonnull align 4 dereferenceable(12)) #0

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 #4 = { mustprogress norecurse 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 #5 = { 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 = distinct !{!9, !10}
!10 = !{!"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"

%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.3" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Tuple_impl.1", %"struct.std::_Head_base.2" }
%"struct.std::_Tuple_impl.1" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { i32 }
%"struct.std::_Head_base.2" = type { i32 }
%"struct.std::_Head_base.3" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10splay_tree4initEv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10splay_tree7extractEiii(ptr dead_on_unwind noalias writable sret(%"class.std::tuple") align 4, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10splay_tree8traverseEi(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca %"class.std::tuple", align 4
  tail call void @_ZN10splay_tree4initEv()
  %2 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 1)
  %3 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef 0, i32 noundef %2)
  %4 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 2)
  %5 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %3, i32 noundef %4)
  %6 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 3)
  %7 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %5, i32 noundef %6)
  %8 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 4)
  %9 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %7, i32 noundef %8)
  %10 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 5)
  %11 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %9, i32 noundef %10)
  %12 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 6)
  %13 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %11, i32 noundef %12)
  %14 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 7)
  %15 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %13, i32 noundef %14)
  %16 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 8)
  %17 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %15, i32 noundef %16)
  %18 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 9)
  %19 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %17, i32 noundef %18)
  %20 = tail call noundef i32 @_ZN10splay_tree7newnodeEi(i32 noundef 10)
  %21 = tail call noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef %19, i32 noundef %20)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #5
  call void @_ZN10splay_tree7extractEiii(ptr dead_on_unwind nonnull writable sret(%"class.std::tuple") align 4 %1, i32 noundef %21, i32 noundef 3, i32 noundef 10)
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm1EJiiiEEONSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOS4_(ptr noundef nonnull align 4 dereferenceable(12) %1) #5
  %23 = load i32, ptr %22, align 4, !tbaa !5
  call void @_ZN10splay_tree8traverseEi(i32 noundef %23)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #5
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN10splay_tree5mergeIJEEEiiiDpT_(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm1EJiiiEEONSt13tuple_elementIXT_ESt5tupleIJDpT0_EEE4typeEOS4_(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nofree nounwind "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 #4 = { mustprogress norecurse 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 #5 = { 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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass