; LLVM IR from lzyrapx/Competitive-Programming :: hihocoder/1035(树形dp).ll (Z3addiiii)

; 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 { ptr, i32, i32, i32 }

@buf = external dso_local global [2000010 x %struct.node], align 16
@bufsize = external dso_local global i32, align 4
@head = external dso_local global [1000010 x ptr], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z3addiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %10 = load i32, ptr @bufsize, align 4, !tbaa !5
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr @bufsize, align 4, !tbaa !5
  %12 = sext i32 %10 to i64
  %13 = getelementptr inbounds %struct.node, ptr @buf, i64 %12
  store ptr %13, ptr %9, align 8, !tbaa !9
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = load ptr, ptr %9, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.node, ptr %15, i32 0, i32 3
  store i32 %14, ptr %16, align 8, !tbaa !11
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = load ptr, ptr %9, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.node, ptr %18, i32 0, i32 1
  store i32 %17, ptr %19, align 8, !tbaa !13
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = load ptr, ptr %9, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.node, ptr %21, i32 0, i32 2
  store i32 %20, ptr %22, align 4, !tbaa !14
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [1000010 x ptr], ptr @head, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = load ptr, ptr %9, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.node, ptr %27, i32 0, i32 0
  store ptr %26, ptr %28, align 8, !tbaa !15
  %29 = load ptr, ptr %9, align 8, !tbaa !9
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [1000010 x ptr], ptr @head, i64 0, i64 %31
  store ptr %29, ptr %32, align 8, !tbaa !9
  %33 = load i32, ptr @bufsize, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr @bufsize, align 4, !tbaa !5
  %35 = sext i32 %33 to i64
  %36 = getelementptr inbounds %struct.node, ptr @buf, i64 %35
  store ptr %36, ptr %9, align 8, !tbaa !9
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.node, ptr %38, i32 0, i32 3
  store i32 %37, ptr %39, align 8, !tbaa !11
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = load ptr, ptr %9, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.node, ptr %41, i32 0, i32 1
  store i32 %40, ptr %42, align 8, !tbaa !13
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = load ptr, ptr %9, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.node, ptr %44, i32 0, i32 2
  store i32 %43, ptr %45, align 4, !tbaa !14
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1000010 x ptr], ptr @head, i64 0, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.node, ptr %50, i32 0, i32 0
  store ptr %49, ptr %51, align 8, !tbaa !15
  %52 = load ptr, ptr %9, align 8, !tbaa !9
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1000010 x ptr], ptr @head, i64 0, i64 %54
  store ptr %52, ptr %55, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret i32 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

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 = { 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, !6, i64 16}
!12 = !{!"_ZTS4node", !10, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 12}
!15 = !{!12, !10, 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.node = type { ptr, i32, i32, i32 }

@buf = external dso_local global [2000010 x %struct.node], align 16
@bufsize = external dso_local local_unnamed_addr global i32, align 4
@head = external dso_local local_unnamed_addr global [1000010 x ptr], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef i32 @_Z3addiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = load i32, ptr @bufsize, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds %struct.node, ptr @buf, i64 %6
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 %1, ptr %8, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %2, ptr %9, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %7, i64 12
  store i32 %3, ptr %10, align 4, !tbaa !13
  %11 = sext i32 %0 to i64
  %12 = getelementptr inbounds [1000010 x ptr], ptr @head, i64 0, i64 %11
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  store ptr %13, ptr %7, align 8, !tbaa !15
  store ptr %7, ptr %12, align 8, !tbaa !14
  %14 = add nsw i32 %5, 2
  store i32 %14, ptr @bufsize, align 4, !tbaa !5
  %15 = sext i32 %5 to i64
  %16 = getelementptr %struct.node, ptr @buf, i64 %15
  %17 = getelementptr i8, ptr %16, i64 24
  %18 = getelementptr i8, ptr %16, i64 40
  store i32 %0, ptr %18, align 8, !tbaa !9
  %19 = getelementptr i8, ptr %16, i64 32
  store i32 %2, ptr %19, align 8, !tbaa !12
  %20 = getelementptr i8, ptr %16, i64 36
  store i32 %3, ptr %20, align 4, !tbaa !13
  %21 = sext i32 %1 to i64
  %22 = getelementptr inbounds [1000010 x ptr], ptr @head, i64 0, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  store ptr %23, ptr %17, align 8, !tbaa !15
  store ptr %17, ptr %22, align 8, !tbaa !14
  ret i32 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"_ZTS4node", !11, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 12}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass