; LLVM IR from bqi343/cp-notebook :: Implementations/content/graphs (12)/Advanced (DMOJdynamicTreeTest)

; 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.snode = type <{ i32, i32, ptr, [5 x ptr], i8, [3 x i8], [2 x %struct.info], [2 x i32], [2 x i32], [4 x i8] }>
%struct.info = type { i32, i32, i32, i32 }

@N = external dso_local global i32, align 4
@LCT = external dso_local global [100001 x ptr], align 16
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [5 x i8], align 1

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4dumpNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @_ZN6output2psIA5_cJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEEvRKT_DpRKT0_(ptr noundef nonnull align 1 dereferenceable(5) @.str.12, ptr noundef nonnull align 8 dereferenceable(32) %0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %45, %1
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = load i32, ptr @N, align 4, !tbaa !9
  %10 = add nsw i32 %9, 1
  %11 = icmp slt i32 %8, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %7
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %48

13:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %41, %13
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 5
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %44

18:                                               ; preds = %14
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100001 x ptr], ptr @LCT, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.snode, ptr %22, i32 0, i32 3
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [5 x ptr], ptr %23, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %40

29:                                               ; preds = %18
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100001 x ptr], ptr @LCT, i64 0, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.snode, ptr %33, i32 0, i32 3
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [5 x ptr], ptr %34, i64 0, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.snode, ptr %38, i32 0, i32 0
  call void @_ZN6output2psIiJiiEEEvRKT_DpRKT0_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %39, ptr noundef nonnull align 4 dereferenceable(4) %5)
  br label %40

40:                                               ; preds = %29, %18
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %5, align 4, !tbaa !9
  br label %14, !llvm.loop !11

44:                                               ; preds = %17
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %3, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !13

48:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %61, %48
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = load i32, ptr @N, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  %53 = icmp slt i32 %50, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %49
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %64

55:                                               ; preds = %49
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100001 x ptr], ptr @LCT, i64 0, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.snode, ptr %59, i32 0, i32 4
  call void @_ZN6output2psIiJbEEEvRKT_DpRKT0_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 1 dereferenceable(1) %60)
  br label %61

61:                                               ; preds = %55
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %6, align 4, !tbaa !9
  br label %49, !llvm.loop !14

64:                                               ; preds = %54
  call void @_ZN6output2psIA5_cJEEEvRKT_DpRKT0_(ptr noundef nonnull align 1 dereferenceable(5) @.str.13)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6output2psIA5_cJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEEvRKT_DpRKT0_(ptr noundef nonnull align 1 dereferenceable(5), ptr noundef nonnull align 8 dereferenceable(32)) #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6output2psIA5_cJEEEvRKT_DpRKT0_(ptr noundef nonnull align 1 dereferenceable(5)) #1

attributes #0 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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"

@N = external dso_local local_unnamed_addr global i32, align 4
@LCT = external dso_local local_unnamed_addr global [100001 x ptr], align 16
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [5 x i8], align 1

; 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
define dso_local void @_Z4dumpNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  tail call void @_ZN6output2psIA5_cJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEEvRKT_DpRKT0_(ptr noundef nonnull align 1 dereferenceable(5) @.str.12, ptr noundef nonnull align 8 dereferenceable(32) %0)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #2
  store i32 1, ptr %2, align 4, !tbaa !5
  %5 = load i32, ptr @N, align 4, !tbaa !5
  %.not8 = icmp slt i32 %5, 1
  br i1 %.not8, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %1
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  br label %._crit_edge13

._crit_edge:                                      ; preds = %7
  %6 = icmp slt i32 %10, 1
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  store i32 1, ptr %4, align 4, !tbaa !5
  br i1 %6, label %._crit_edge13, label %.lr.ph12

.lr.ph:                                           ; preds = %1, %7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #2
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %11

7:                                                ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @N, align 4, !tbaa !5
  %.not.not = icmp slt i32 %8, %10
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

11:                                               ; preds = %.lr.ph, %21
  %storemerge57 = phi i32 [ 0, %.lr.ph ], [ %23, %21 ]
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [100001 x ptr], ptr @LCT, i64 0, i64 %13
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = sext i32 %storemerge57 to i64
  %18 = getelementptr inbounds [5 x ptr], ptr %16, i64 0, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %.not6 = icmp eq ptr %19, null
  br i1 %.not6, label %21, label %20

20:                                               ; preds = %11
  call void @_ZN6output2psIiJiiEEEvRKT_DpRKT0_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %11, %20
  %22 = phi i32 [ %storemerge57, %11 ], [ %.pre, %20 ]
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %3, align 4, !tbaa !5
  %24 = icmp slt i32 %22, 4
  br i1 %24, label %11, label %7, !llvm.loop !13

._crit_edge13:                                    ; preds = %.lr.ph12, %._crit_edge.thread, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  call void @_ZN6output2psIA5_cJEEEvRKT_DpRKT0_(ptr noundef nonnull align 1 dereferenceable(5) @.str.13)
  ret void

.lr.ph12:                                         ; preds = %._crit_edge, %.lr.ph12
  %storemerge310 = phi i32 [ %30, %.lr.ph12 ], [ 1, %._crit_edge ]
  %25 = sext i32 %storemerge310 to i64
  %26 = getelementptr inbounds [100001 x ptr], ptr @LCT, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %27, i64 56
  call void @_ZN6output2psIiJbEEEvRKT_DpRKT0_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 1 dereferenceable(1) %28)
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %4, align 4, !tbaa !5
  %31 = load i32, ptr @N, align 4, !tbaa !5
  %.not4.not = icmp slt i32 %29, %31
  br i1 %.not4.not, label %.lr.ph12, label %._crit_edge13, !llvm.loop !14
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6output2psIA5_cJNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEEvRKT_DpRKT0_(ptr noundef nonnull align 1 dereferenceable(5), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6output2psIA5_cJEEEvRKT_DpRKT0_(ptr noundef nonnull align 1 dereferenceable(5)) local_unnamed_addr #1

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass