; LLVM IR from Tunghohin/Competitive_Coding :: Luogu/p2894.ll (Z6modifyiiii)

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

@tr = external dso_local global [2000040 x %struct.Node], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7push_upi(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 nounwind uwtable
declare dso_local void @_Z9push_downi(i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6modifyiiii(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 i32, align 4
  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
  %10 = load i32, ptr %5, align 4, !tbaa !5
  call void @_Z9push_downi(i32 noundef %10)
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %12
  %14 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = icmp sge i32 %15, %16
  br i1 %17, label %18, label %66

18:                                               ; preds = %4
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.Node, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp sle i32 %23, %24
  br i1 %25, label %26, label %66

26:                                               ; preds = %18
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.Node, ptr %30, i32 0, i32 6
  store i32 %27, ptr %31, align 4, !tbaa !12
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %34, label %47

34:                                               ; preds = %26
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.Node, ptr %37, i32 0, i32 5
  store i32 0, ptr %38, align 4, !tbaa !13
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %40
  %42 = getelementptr inbounds %struct.Node, ptr %41, i32 0, i32 4
  store i32 0, ptr %42, align 4, !tbaa !14
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.Node, ptr %45, i32 0, i32 3
  store i32 0, ptr %46, align 4, !tbaa !15
  br label %65

47:                                               ; preds = %26
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.Node, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !16
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %54
  %56 = getelementptr inbounds %struct.Node, ptr %55, i32 0, i32 5
  store i32 %52, ptr %56, align 4, !tbaa !13
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %58
  %60 = getelementptr inbounds %struct.Node, ptr %59, i32 0, i32 4
  store i32 %52, ptr %60, align 4, !tbaa !14
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %62
  %64 = getelementptr inbounds %struct.Node, ptr %63, i32 0, i32 3
  store i32 %52, ptr %64, align 4, !tbaa !15
  br label %65

65:                                               ; preds = %47, %34
  br label %101

66:                                               ; preds = %18, %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %68
  %70 = getelementptr inbounds %struct.Node, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %70, align 4, !tbaa !9
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %73
  %75 = getelementptr inbounds %struct.Node, ptr %74, i32 0, i32 1
  %76 = load i32, ptr %75, align 4, !tbaa !11
  %77 = add nsw i32 %71, %76
  %78 = ashr i32 %77, 1
  store i32 %78, ptr %9, align 4, !tbaa !5
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = icmp sle i32 %79, %80
  br i1 %81, label %82, label %88

82:                                               ; preds = %66
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = shl i32 %83, 1
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z6modifyiiii(i32 noundef %84, i32 noundef %85, i32 noundef %86, i32 noundef %87)
  br label %88

88:                                               ; preds = %82, %66
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = load i32, ptr %9, align 4, !tbaa !5
  %91 = icmp sgt i32 %89, %90
  br i1 %91, label %92, label %99

92:                                               ; preds = %88
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = shl i32 %93, 1
  %95 = or i32 %94, 1
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z6modifyiiii(i32 noundef %95, i32 noundef %96, i32 noundef %97, i32 noundef %98)
  br label %99

99:                                               ; preds = %92, %88
  %100 = load i32, ptr %5, align 4, !tbaa !5
  call void @_Z7push_upi(i32 noundef %100)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %101

101:                                              ; preds = %99, %65
  ret void
}

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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !6, i64 20}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 12}
!16 = !{!10, !6, i64 8}


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

@tr = external dso_local local_unnamed_addr global [2000040 x %struct.Node], align 16

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z9push_downi(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6modifyiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  tail call void @_Z9push_downi(i32 noundef %0)
  %5 = sext i32 %0 to i64
  %6 = getelementptr inbounds [2000040 x %struct.Node], ptr @tr, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %.not = icmp slt i32 %7, %1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %6, i64 4
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !10
  %.not31 = icmp sgt i32 %.pre, %2
  %or.cond = select i1 %.not, i1 true, i1 %.not31
  br i1 %or.cond, label %._crit_edge, label %8

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %6, i64 24
  store i32 %3, ptr %9, align 4, !tbaa !11
  %10 = icmp eq i32 %3, 1
  br i1 %10, label %11, label %15

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %6, i64 20
  store i32 0, ptr %12, align 4, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %6, i64 16
  store i32 0, ptr %13, align 4, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %6, i64 12
  store i32 0, ptr %14, align 4, !tbaa !14
  br label %31

15:                                               ; preds = %8
  %16 = getelementptr inbounds i8, ptr %6, i64 8
  %17 = load i32, ptr %16, align 4, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %6, i64 20
  store i32 %17, ptr %18, align 4, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %6, i64 16
  store i32 %17, ptr %19, align 4, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %6, i64 12
  store i32 %17, ptr %20, align 4, !tbaa !14
  br label %31

._crit_edge:                                      ; preds = %4
  %21 = add nsw i32 %.pre, %7
  %22 = ashr i32 %21, 1
  %.not32 = icmp slt i32 %22, %1
  br i1 %.not32, label %25, label %23

23:                                               ; preds = %._crit_edge
  %24 = shl i32 %0, 1
  tail call void @_Z6modifyiiii(i32 noundef %24, i32 noundef %1, i32 noundef %2, i32 noundef %3)
  br label %25

25:                                               ; preds = %23, %._crit_edge
  %26 = icmp slt i32 %22, %2
  br i1 %26, label %27, label %30

27:                                               ; preds = %25
  %28 = shl i32 %0, 1
  %29 = or disjoint i32 %28, 1
  tail call void @_Z6modifyiiii(i32 noundef %29, i32 noundef %1, i32 noundef %2, i32 noundef %3)
  br label %30

30:                                               ; preds = %27, %25
  tail call void @_Z7push_upi(i32 noundef %0)
  br label %31

31:                                               ; preds = %11, %15, %30
  ret void
}

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

!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, !7, i64 0}
!6 = !{!"_ZTS4Node", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 24}
!12 = !{!6, !7, i64 20}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !7, i64 12}
!15 = !{!6, !7, i64 8}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass