; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数据结构 (link-cut-tree（指针）)

; 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, [2 x ptr], i32, i32, i32, i32 }

@nodes = external dso_local global [400000 x %struct.node], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@w = external dso_local global i32, align 4
@eu = external dso_local global [400000 x i32], align 16
@ev = external dso_local global [400000 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z7newnodei(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4initv() #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8increaseP4nodei(ptr noundef, 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 uwtable
declare dso_local void @_Z5splayP4node(ptr noundef) #2

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  br label %8

8:                                                ; preds = %181, %0
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %10 = icmp ne i32 %9, -1
  br i1 %10, label %11, label %183

11:                                               ; preds = %8
  call void @_Z4initv()
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %25, %11
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %28

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [400000 x i32], ptr @eu, i64 0, i64 %19
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [400000 x i32], ptr @ev, i64 0, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %20, ptr noundef %23)
  br label %25

25:                                               ; preds = %17
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

28:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %38, %28
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = icmp sle i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %41

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %4)
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = call noundef ptr @_Z7newnodei(i32 noundef %36)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %38

38:                                               ; preds = %34
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !11

41:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %60, %41
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = load i32, ptr @n, align 4, !tbaa !5
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %63

47:                                               ; preds = %42
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [400000 x i32], ptr @eu, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.node, ptr @nodes, i64 %52
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [400000 x i32], ptr @ev, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.node, ptr @nodes, i64 %58
  call void @_Z4linkP4nodeS0_(ptr noundef %53, ptr noundef %59)
  br label %60

60:                                               ; preds = %47
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %5, align 4, !tbaa !5
  br label %42, !llvm.loop !12

63:                                               ; preds = %46
  %64 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %178, %63
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = load i32, ptr @m, align 4, !tbaa !5
  %68 = icmp sle i32 %66, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %181

70:                                               ; preds = %65
  %71 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x)
  %72 = load i32, ptr @x, align 4, !tbaa !5
  %73 = icmp eq i32 %72, 1
  br i1 %73, label %74, label %92

74:                                               ; preds = %70
  %75 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @x, ptr noundef @y)
  %76 = load i32, ptr @x, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %struct.node, ptr @nodes, i64 %77
  %79 = load i32, ptr @y, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds %struct.node, ptr @nodes, i64 %80
  %82 = call noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef %78, ptr noundef %81)
  br i1 %82, label %83, label %85

83:                                               ; preds = %74
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %178

85:                                               ; preds = %74
  %86 = load i32, ptr @x, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds %struct.node, ptr @nodes, i64 %87
  %89 = load i32, ptr @y, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds %struct.node, ptr @nodes, i64 %90
  call void @_Z4linkP4nodeS0_(ptr noundef %88, ptr noundef %91)
  br label %177

92:                                               ; preds = %70
  %93 = load i32, ptr @x, align 4, !tbaa !5
  %94 = icmp eq i32 %93, 2
  br i1 %94, label %95, label %117

95:                                               ; preds = %92
  %96 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @x, ptr noundef @y)
  %97 = load i32, ptr @x, align 4, !tbaa !5
  %98 = load i32, ptr @y, align 4, !tbaa !5
  %99 = icmp eq i32 %97, %98
  br i1 %99, label %108, label %100

100:                                              ; preds = %95
  %101 = load i32, ptr @x, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds %struct.node, ptr @nodes, i64 %102
  %104 = load i32, ptr @y, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.node, ptr @nodes, i64 %105
  %107 = call noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef %103, ptr noundef %106)
  br i1 %107, label %110, label %108

108:                                              ; preds = %100, %95
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %178

110:                                              ; preds = %100
  %111 = load i32, ptr @x, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds %struct.node, ptr @nodes, i64 %112
  call void @_Z10changerootP4node(ptr noundef %113)
  %114 = load i32, ptr @y, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds %struct.node, ptr @nodes, i64 %115
  call void @_Z3cutP4node(ptr noundef %116)
  br label %176

117:                                              ; preds = %92
  %118 = load i32, ptr @x, align 4, !tbaa !5
  %119 = icmp eq i32 %118, 3
  br i1 %119, label %120, label %147

120:                                              ; preds = %117
  %121 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef @w, ptr noundef @x, ptr noundef @y)
  %122 = load i32, ptr @x, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds %struct.node, ptr @nodes, i64 %123
  %125 = load i32, ptr @y, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds %struct.node, ptr @nodes, i64 %126
  %128 = call noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef %124, ptr noundef %127)
  br i1 %128, label %131, label %129

129:                                              ; preds = %120
  %130 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %178

131:                                              ; preds = %120
  %132 = load i32, ptr @x, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds %struct.node, ptr @nodes, i64 %133
  call void @_Z10changerootP4node(ptr noundef %134)
  %135 = load i32, ptr @y, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds %struct.node, ptr @nodes, i64 %136
  %138 = call noundef ptr @_Z6accessP4node(ptr noundef %137)
  %139 = load i32, ptr @y, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds %struct.node, ptr @nodes, i64 %140
  call void @_Z5splayP4node(ptr noundef %141)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %142 = load i32, ptr @y, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds %struct.node, ptr @nodes, i64 %143
  store ptr %144, ptr %7, align 8, !tbaa !13
  %145 = load ptr, ptr %7, align 8, !tbaa !13
  %146 = load i32, ptr @w, align 4, !tbaa !5
  call void @_Z8increaseP4nodei(ptr noundef %145, i32 noundef %146)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %175

147:                                              ; preds = %117
  %148 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @x, ptr noundef @y)
  %149 = load i32, ptr @x, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds %struct.node, ptr @nodes, i64 %150
  %152 = load i32, ptr @y, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds %struct.node, ptr @nodes, i64 %153
  %155 = call noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef %151, ptr noundef %154)
  br i1 %155, label %158, label %156

156:                                              ; preds = %147
  %157 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %178

158:                                              ; preds = %147
  %159 = load i32, ptr @x, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds %struct.node, ptr @nodes, i64 %160
  call void @_Z10changerootP4node(ptr noundef %161)
  %162 = load i32, ptr @y, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds %struct.node, ptr @nodes, i64 %163
  %165 = call noundef ptr @_Z6accessP4node(ptr noundef %164)
  %166 = load i32, ptr @y, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds %struct.node, ptr @nodes, i64 %167
  call void @_Z5splayP4node(ptr noundef %168)
  %169 = load i32, ptr @y, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds %struct.node, ptr @nodes, i64 %170
  %172 = getelementptr inbounds %struct.node, ptr %171, i32 0, i32 2
  %173 = load i32, ptr %172, align 8, !tbaa !15
  %174 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %173)
  br label %175

175:                                              ; preds = %158, %131
  br label %176

176:                                              ; preds = %175, %110
  br label %177

177:                                              ; preds = %176, %85
  br label %178

178:                                              ; preds = %177, %156, %129, %108, %83
  %179 = load i32, ptr %6, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %6, align 4, !tbaa !5
  br label %65, !llvm.loop !17

181:                                              ; preds = %69
  %182 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %8, !llvm.loop !18

183:                                              ; preds = %8
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

declare i32 @printf(ptr noundef, ...) #4

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 = { 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 norecurse 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 = { "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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !6, i64 24}
!16 = !{!"_ZTS4node", !14, i64 0, !7, i64 8, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


; 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, [2 x ptr], i32, i32, i32, i32 }

@nodes = external dso_local global [400000 x %struct.node], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@w = external dso_local global i32, align 4
@eu = external dso_local global [400000 x i32], align 16
@ev = external dso_local global [400000 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z7newnodei(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4initv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8increaseP4nodei(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z6accessP4node(ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not32 = icmp eq i32 %2, -1
  br i1 %.not32, label %._crit_edge35, label %.lr.ph34

.lr.ph34:                                         ; preds = %0, %._crit_edge31
  call void @_Z4initv()
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 1
  br i1 %4, label %.lr.ph, label %.preheader20

.preheader20:                                     ; preds = %.lr.ph, %.lr.ph34
  %5 = phi i32 [ %3, %.lr.ph34 ], [ %9, %.lr.ph ]
  %.not1822 = icmp slt i32 %5, 1
  br i1 %.not1822, label %._crit_edge, label %.lr.ph24

.lr.ph:                                           ; preds = %.lr.ph34, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph34 ]
  %6 = getelementptr inbounds [400000 x i32], ptr @eu, i64 0, i64 %indvars.iv
  %7 = getelementptr inbounds [400000 x i32], ptr @ev, i64 0, i64 %indvars.iv
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = icmp slt i64 %indvars.iv.next, %10
  br i1 %11, label %.lr.ph, label %.preheader20, !llvm.loop !9

.preheader:                                       ; preds = %.lr.ph24
  %12 = icmp sgt i32 %17, 1
  br i1 %12, label %.lr.ph26, label %._crit_edge

.lr.ph24:                                         ; preds = %.preheader20, %.lr.ph24
  %.01423 = phi i32 [ %16, %.lr.ph24 ], [ 1, %.preheader20 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = call noundef ptr @_Z7newnodei(i32 noundef %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %16 = add nuw nsw i32 %.01423, 1
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %.not18.not = icmp slt i32 %.01423, %17
  br i1 %.not18.not, label %.lr.ph24, label %.preheader, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph26, %.preheader20, %.preheader
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %.not1927 = icmp slt i32 %19, 1
  br i1 %.not1927, label %._crit_edge31, label %.lr.ph30

.lr.ph26:                                         ; preds = %.preheader, %.lr.ph26
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %.lr.ph26 ], [ 1, %.preheader ]
  %20 = getelementptr inbounds [400000 x i32], ptr @eu, i64 0, i64 %indvars.iv37
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds %struct.node, ptr @nodes, i64 %22
  %24 = getelementptr inbounds [400000 x i32], ptr @ev, i64 0, i64 %indvars.iv37
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds %struct.node, ptr @nodes, i64 %26
  call void @_Z4linkP4nodeS0_(ptr noundef nonnull %23, ptr noundef nonnull %27)
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next38, %29
  br i1 %30, label %.lr.ph26, label %._crit_edge, !llvm.loop !12

._crit_edge31:                                    ; preds = %126, %._crit_edge
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not = icmp eq i32 %32, -1
  br i1 %.not, label %._crit_edge35, label %.lr.ph34, !llvm.loop !13

.lr.ph30:                                         ; preds = %._crit_edge, %126
  %.01228 = phi i32 [ %127, %126 ], [ 1, %._crit_edge ]
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %34 = load i32, ptr @x, align 4, !tbaa !5
  switch i32 %34, label %99 [
    i32 1, label %35
    i32 2, label %53
    i32 3, label %73
  ]

35:                                               ; preds = %.lr.ph30
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %37 = load i32, ptr @x, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %struct.node, ptr @nodes, i64 %38
  %40 = load i32, ptr @y, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %struct.node, ptr @nodes, i64 %41
  %43 = call noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef nonnull %39, ptr noundef nonnull %42)
  br i1 %43, label %44, label %46

44:                                               ; preds = %35
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %126

46:                                               ; preds = %35
  %47 = load i32, ptr @x, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %struct.node, ptr @nodes, i64 %48
  %50 = load i32, ptr @y, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds %struct.node, ptr @nodes, i64 %51
  call void @_Z4linkP4nodeS0_(ptr noundef nonnull %49, ptr noundef nonnull %52)
  br label %126

53:                                               ; preds = %.lr.ph30
  %54 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %55 = load i32, ptr @x, align 4, !tbaa !5
  %56 = load i32, ptr @y, align 4, !tbaa !5
  %57 = icmp eq i32 %55, %56
  br i1 %57, label %64, label %58

58:                                               ; preds = %53
  %59 = sext i32 %55 to i64
  %60 = getelementptr inbounds %struct.node, ptr @nodes, i64 %59
  %61 = sext i32 %56 to i64
  %62 = getelementptr inbounds %struct.node, ptr @nodes, i64 %61
  %63 = call noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef nonnull %60, ptr noundef nonnull %62)
  br i1 %63, label %66, label %64

64:                                               ; preds = %58, %53
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %126

66:                                               ; preds = %58
  %67 = load i32, ptr @x, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds %struct.node, ptr @nodes, i64 %68
  call void @_Z10changerootP4node(ptr noundef nonnull %69)
  %70 = load i32, ptr @y, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds %struct.node, ptr @nodes, i64 %71
  call void @_Z3cutP4node(ptr noundef nonnull %72)
  br label %126

73:                                               ; preds = %.lr.ph30
  %74 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull @w, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %75 = load i32, ptr @x, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds %struct.node, ptr @nodes, i64 %76
  %78 = load i32, ptr @y, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %struct.node, ptr @nodes, i64 %79
  %81 = call noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef nonnull %77, ptr noundef nonnull %80)
  br i1 %81, label %84, label %82

82:                                               ; preds = %73
  %83 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %126

84:                                               ; preds = %73
  %85 = load i32, ptr @x, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds %struct.node, ptr @nodes, i64 %86
  call void @_Z10changerootP4node(ptr noundef nonnull %87)
  %88 = load i32, ptr @y, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds %struct.node, ptr @nodes, i64 %89
  %91 = call noundef ptr @_Z6accessP4node(ptr noundef nonnull %90)
  %92 = load i32, ptr @y, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds %struct.node, ptr @nodes, i64 %93
  call void @_Z5splayP4node(ptr noundef nonnull %94)
  %95 = load i32, ptr @y, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds %struct.node, ptr @nodes, i64 %96
  %98 = load i32, ptr @w, align 4, !tbaa !5
  call void @_Z8increaseP4nodei(ptr noundef nonnull %97, i32 noundef %98)
  br label %126

99:                                               ; preds = %.lr.ph30
  %100 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %101 = load i32, ptr @x, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds %struct.node, ptr @nodes, i64 %102
  %104 = load i32, ptr @y, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.node, ptr @nodes, i64 %105
  %107 = call noundef zeroext i1 @_Z8sametreeP4nodeS0_(ptr noundef nonnull %103, ptr noundef nonnull %106)
  br i1 %107, label %110, label %108

108:                                              ; preds = %99
  %109 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %126

110:                                              ; preds = %99
  %111 = load i32, ptr @x, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds %struct.node, ptr @nodes, i64 %112
  call void @_Z10changerootP4node(ptr noundef nonnull %113)
  %114 = load i32, ptr @y, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds %struct.node, ptr @nodes, i64 %115
  %117 = call noundef ptr @_Z6accessP4node(ptr noundef nonnull %116)
  %118 = load i32, ptr @y, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds %struct.node, ptr @nodes, i64 %119
  call void @_Z5splayP4node(ptr noundef nonnull %120)
  %121 = load i32, ptr @y, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds %struct.node, ptr @nodes, i64 %122, i32 2
  %124 = load i32, ptr %123, align 8, !tbaa !14
  %125 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %124)
  br label %126

126:                                              ; preds = %46, %84, %110, %66, %108, %82, %64, %44
  %127 = add nuw nsw i32 %.01228, 1
  %128 = load i32, ptr @m, align 4, !tbaa !5
  %.not19.not = icmp slt i32 %.01228, %128
  br i1 %.not19.not, label %.lr.ph30, label %._crit_edge31, !llvm.loop !17

._crit_edge35:                                    ; preds = %._crit_edge31, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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 = { mustprogress nocallback nofree nosync 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 = { mustprogress norecurse 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 = { nofree nounwind "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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = !{!15, !6, i64 24}
!15 = !{!"_ZTS4node", !16, i64 0, !7, i64 8, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36}
!16 = !{!"any pointer", !7, i64 0}
!17 = distinct !{!17, !10}


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