; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数据结构/TopTree.ll (Z7newnodei)

; 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.mark = type { i32, i32 }
%struct.info = type { i32, i32, i32, i32 }
%struct.node = type <{ [4 x ptr], ptr, %struct.info, %struct.info, %struct.info, %struct.info, %struct.mark, %struct.mark, i8, i8, [6 x i8] }>

@none = external dso_local global %struct.mark, align 4
@me = external dso_local global ptr, align 8
@ptr = external dso_local global ptr, align 8
@null = external dso_local global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z7newnodei(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca %struct.info, align 4
  %5 = alloca %struct.info, align 4
  %6 = alloca %struct.info, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %7 = load ptr, ptr @ptr, align 8, !tbaa !9
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %14

10:                                               ; preds = %1
  %11 = load ptr, ptr @ptr, align 8, !tbaa !9
  %12 = getelementptr inbounds ptr, ptr %11, i32 -1
  store ptr %12, ptr @ptr, align 8, !tbaa !9
  %13 = load ptr, ptr %11, align 8, !tbaa !9
  br label %17

14:                                               ; preds = %1
  %15 = load ptr, ptr @me, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.node, ptr %15, i32 1
  store ptr %16, ptr @me, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %14, %10
  %18 = phi ptr [ %13, %10 ], [ %15, %14 ]
  store ptr %18, ptr %3, align 8, !tbaa !9
  %19 = load ptr, ptr %3, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.node, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds [4 x ptr], ptr %20, i64 0, i64 0
  %22 = load ptr, ptr %3, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.node, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds [4 x ptr], ptr %23, i64 0, i64 0
  %25 = getelementptr inbounds ptr, ptr %24, i64 4
  %26 = load ptr, ptr @null, align 8, !tbaa !9
  %27 = load ptr, ptr %3, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.node, ptr %27, i32 0, i32 1
  store ptr %26, ptr %28, align 8, !tbaa !11
  call void @_ZSt4fillIPP4nodeS1_EvT_S3_RKT0_(ptr noundef %21, ptr noundef %25, ptr noundef nonnull align 8 dereferenceable(8) %28)
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #5
  call void @_ZN4infoC2Eiiii(ptr noundef nonnull align 4 dereferenceable(16) %4, i32 noundef 2147483647, i32 noundef -2147483647, i32 noundef 0, i32 noundef 0)
  %29 = load ptr, ptr %3, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.node, ptr %29, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %30, ptr align 4 %4, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #5
  %31 = load ptr, ptr %3, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.node, ptr %31, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %32, ptr align 4 @none, i64 8, i1 false), !tbaa.struct !17
  %33 = load ptr, ptr %3, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.node, ptr %33, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 4 %32, i64 8, i1 false), !tbaa.struct !17
  %35 = load ptr, ptr %3, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.node, ptr %35, i32 0, i32 8
  store i8 0, ptr %36, align 8, !tbaa !18
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 2147483647
  br i1 %38, label %39, label %48

39:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #5
  call void @_ZN4infoC2Eiiii(ptr noundef nonnull align 4 dereferenceable(16) %5, i32 noundef 2147483647, i32 noundef -2147483647, i32 noundef 0, i32 noundef 0)
  %40 = load ptr, ptr %3, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.node, ptr %40, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %41, ptr align 4 %5, i64 16, i1 false), !tbaa.struct !16
  %42 = load ptr, ptr %3, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.node, ptr %42, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %43, ptr align 4 %41, i64 16, i1 false), !tbaa.struct !16
  %44 = load ptr, ptr %3, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.node, ptr %44, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %45, ptr align 4 %43, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #5
  %46 = load ptr, ptr %3, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.node, ptr %46, i32 0, i32 9
  store i8 1, ptr %47, align 1, !tbaa !19
  br label %60

48:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = load i32, ptr %2, align 4, !tbaa !5
  call void @_ZN4infoC2Eiiii(ptr noundef nonnull align 4 dereferenceable(16) %6, i32 noundef %49, i32 noundef %50, i32 noundef %51, i32 noundef 1)
  %52 = load ptr, ptr %3, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.node, ptr %52, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %53, ptr align 4 %6, i64 16, i1 false), !tbaa.struct !16
  %54 = load ptr, ptr %3, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.node, ptr %54, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %55, ptr align 4 %53, i64 16, i1 false), !tbaa.struct !16
  %56 = load ptr, ptr %3, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.node, ptr %56, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %57, ptr align 4 %55, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  %58 = load ptr, ptr %3, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.node, ptr %58, i32 0, i32 9
  store i8 0, ptr %59, align 1, !tbaa !19
  br label %60

60:                                               ; preds = %48, %39
  %61 = load ptr, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret ptr %61
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4infoC2Eiiii(ptr noundef nonnull align 4 dereferenceable(16), i32 noundef, i32 noundef, i32 noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; 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 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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"_ZTS4node", !7, i64 0, !10, i64 32, !13, i64 40, !13, i64 56, !13, i64 72, !13, i64 88, !14, i64 104, !14, i64 112, !15, i64 120, !15, i64 121}
!13 = !{!"_ZTS4info", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!14 = !{!"_ZTS4mark", !6, i64 0, !6, i64 4}
!15 = !{!"bool", !7, i64 0}
!16 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5, i64 12, i64 4, !5}
!17 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}
!18 = !{!12, !15, i64 120}
!19 = !{!12, !15, i64 121}


; 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.mark = type { i32, i32 }
%struct.info = type { i32, i32, i32, i32 }

@none = external dso_local local_unnamed_addr global %struct.mark, align 4
@me = external dso_local local_unnamed_addr global ptr, align 8
@ptr = external dso_local local_unnamed_addr global ptr, align 8
@null = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z7newnodei(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.info, align 4
  %3 = alloca %struct.info, align 4
  %4 = alloca %struct.info, align 4
  %5 = load ptr, ptr @ptr, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %10, label %7

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %5, i64 -8
  store ptr %8, ptr @ptr, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  br label %13

10:                                               ; preds = %1
  %11 = load ptr, ptr @me, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 128
  store ptr %12, ptr @me, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %10, %7
  %14 = phi ptr [ %9, %7 ], [ %11, %10 ]
  %15 = getelementptr inbounds i8, ptr %14, i64 32
  %16 = load ptr, ptr @null, align 8, !tbaa !5
  store ptr %16, ptr %15, align 8, !tbaa !9
  tail call void @_ZSt4fillIPP4nodeS1_EvT_S3_RKT0_(ptr noundef %14, ptr noundef nonnull %15, ptr noundef nonnull align 8 dereferenceable(8) %15)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  call void @_ZN4infoC2Eiiii(ptr noundef nonnull align 4 dereferenceable(16) %2, i32 noundef 2147483647, i32 noundef -2147483647, i32 noundef 0, i32 noundef 0)
  %17 = getelementptr inbounds i8, ptr %14, i64 56
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 4 dereferenceable(16) %2, i64 16, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  %18 = getelementptr inbounds i8, ptr %14, i64 112
  %19 = load i64, ptr @none, align 4
  store i64 %19, ptr %18, align 8
  %20 = getelementptr inbounds i8, ptr %14, i64 104
  store i64 %19, ptr %20, align 8
  %21 = getelementptr inbounds i8, ptr %14, i64 120
  store i8 0, ptr %21, align 8, !tbaa !17
  %22 = icmp eq i32 %0, 2147483647
  %23 = getelementptr inbounds i8, ptr %14, i64 72
  %24 = getelementptr inbounds i8, ptr %14, i64 88
  %25 = getelementptr inbounds i8, ptr %14, i64 40
  br i1 %22, label %26, label %27

26:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  call void @_ZN4infoC2Eiiii(ptr noundef nonnull align 4 dereferenceable(16) %3, i32 noundef 2147483647, i32 noundef -2147483647, i32 noundef 0, i32 noundef 0)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 4 dereferenceable(16) %3, i64 16, i1 false), !tbaa.struct !15
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 4 dereferenceable(16) %3, i64 16, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 4 dereferenceable(16) %3, i64 16, i1 false)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  br label %28

27:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  call void @_ZN4infoC2Eiiii(ptr noundef nonnull align 4 dereferenceable(16) %4, i32 noundef %0, i32 noundef %0, i32 noundef %0, i32 noundef 1)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 4 dereferenceable(16) %4, i64 16, i1 false), !tbaa.struct !15
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 4 dereferenceable(16) %4, i64 16, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 4 dereferenceable(16) %4, i64 16, i1 false)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  br label %28

28:                                               ; preds = %27, %26
  %.sink = phi i8 [ 1, %26 ], [ 0, %27 ]
  %29 = getelementptr inbounds i8, ptr %14, i64 121
  store i8 %.sink, ptr %29, align 1
  ret ptr %14
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPP4nodeS1_EvT_S3_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4infoC2Eiiii(ptr noundef nonnull align 4 dereferenceable(16), i32 noundef, i32 noundef, i32 noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"_ZTS4node", !7, i64 0, !6, i64 32, !11, i64 40, !11, i64 56, !11, i64 72, !11, i64 88, !13, i64 104, !13, i64 112, !14, i64 120, !14, i64 121}
!11 = !{!"_ZTS4info", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS4mark", !12, i64 0, !12, i64 4}
!14 = !{!"bool", !7, i64 0}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 4, !16, i64 12, i64 4, !16}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !14, i64 120}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass