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

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

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

; 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) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5touchP4node(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local { i64, i64 } @_ZN3sub5queryEP4node(ptr noundef %0) #2 {
  %2 = alloca %struct.info, 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 ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z5touchP4node(ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #3
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.node, ptr %8, i32 0, i32 2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.node, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds [4 x ptr], ptr %11, i64 0, i64 2
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.node, ptr %13, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 8 %14, i64 16, i1 false), !tbaa.struct !9
  %15 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 0
  %16 = load i64, ptr %15, align 4
  %17 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 1
  %18 = load i64, ptr %17, align 4
  %19 = call { i64, i64 } @_ZN4infoplES_(ptr noundef nonnull align 4 dereferenceable(16) %9, i64 %16, i64 %18)
  %20 = getelementptr inbounds { i64, i64 }, ptr %4, i32 0, i32 0
  %21 = extractvalue { i64, i64 } %19, 0
  store i64 %21, ptr %20, align 4
  %22 = getelementptr inbounds { i64, i64 }, ptr %4, i32 0, i32 1
  %23 = extractvalue { i64, i64 } %19, 1
  store i64 %23, ptr %22, align 4
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.node, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds [4 x ptr], ptr %25, i64 0, i64 3
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.node, ptr %27, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %28, i64 16, i1 false), !tbaa.struct !9
  %29 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 0
  %30 = load i64, ptr %29, align 4
  %31 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 1
  %32 = load i64, ptr %31, align 4
  %33 = call { i64, i64 } @_ZN4infoplES_(ptr noundef nonnull align 4 dereferenceable(16) %4, i64 %30, i64 %32)
  %34 = getelementptr inbounds { i64, i64 }, ptr %2, i32 0, i32 0
  %35 = extractvalue { i64, i64 } %33, 0
  store i64 %35, ptr %34, align 4
  %36 = getelementptr inbounds { i64, i64 }, ptr %2, i32 0, i32 1
  %37 = extractvalue { i64, i64 } %33, 1
  store i64 %37, ptr %36, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #3
  %38 = load { i64, i64 }, ptr %2, align 4
  ret { i64, i64 } %38
}

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZN4infoplES_(ptr noundef nonnull align 4 dereferenceable(16), i64, i64) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 = { 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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10, i64 12, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, 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"

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5touchP4node(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local { i64, i64 } @_ZN3sub5queryEP4node(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca %struct.info, align 8
  tail call void @_Z5touchP4node(ptr noundef %0)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #2
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 88
  %.sroa.01.0.copyload = load i64, ptr %6, align 8
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 96
  %.sroa.22.0.copyload = load i64, ptr %.sroa.22.0..sroa_idx, align 8
  %7 = tail call { i64, i64 } @_ZN4infoplES_(ptr noundef nonnull align 4 dereferenceable(16) %3, i64 %.sroa.01.0.copyload, i64 %.sroa.22.0.copyload)
  %8 = extractvalue { i64, i64 } %7, 0
  store i64 %8, ptr %2, align 8
  %9 = getelementptr inbounds i8, ptr %2, i64 8
  %10 = extractvalue { i64, i64 } %7, 1
  store i64 %10, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 88
  %.sroa.0.0.copyload = load i64, ptr %13, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %12, i64 96
  %.sroa.2.0.copyload = load i64, ptr %.sroa.2.0..sroa_idx, align 8
  %14 = call { i64, i64 } @_ZN4infoplES_(ptr noundef nonnull align 4 dereferenceable(16) %2, i64 %.sroa.0.0.copyload, i64 %.sroa.2.0.copyload)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #2
  ret { i64, i64 } %14
}

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_ZN4infoplES_(ptr noundef nonnull align 4 dereferenceable(16), i64, i64) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass