; LLVM IR from tangjz/acm-icpc :: luogu (1248)

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

@n = external dso_local global i32, align 4
@que = external dso_local global [2001 x i32], align 16
@t1 = external dso_local global i32, align 4
@t2 = external dso_local global i32, align 4
@work = external dso_local global [2001 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRK4NodeS1_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %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 i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %10

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

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %30

15:                                               ; preds = %10
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %17
  %19 = getelementptr inbounds %struct.Node, ptr %18, i32 0, i32 0
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %19)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.Node, ptr %25, i32 0, i32 3
  store i32 %22, ptr %26, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %15
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !11

30:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %56, %30
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %59

36:                                               ; preds = %31
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %38
  %40 = getelementptr inbounds %struct.Node, ptr %39, i32 0, i32 1
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %40)
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.Node, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %47
  %49 = getelementptr inbounds %struct.Node, ptr %48, i32 0, i32 1
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %45, ptr noundef nonnull align 4 dereferenceable(4) %49)
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.Node, ptr %54, i32 0, i32 2
  store i32 %51, ptr %55, align 8, !tbaa !13
  br label %56

56:                                               ; preds = %36
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !14

59:                                               ; preds = %35
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds %struct.Node, ptr @work, i64 %61
  call void @_ZSt4sortIP4NodePFbRKS0_S3_EEvT_S6_T0_(ptr noundef @work, ptr noundef %62, ptr noundef @_Z3cmpRK4NodeS1_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = sub nsw i32 %63, 1
  store i32 %64, ptr %6, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %95, %59
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = load i32, ptr @n, align 4, !tbaa !5
  %68 = icmp slt i32 %66, %67
  br i1 %68, label %70, label %69

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

70:                                               ; preds = %65
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %72
  %74 = getelementptr inbounds %struct.Node, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !13
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.Node, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 16, !tbaa !15
  %81 = icmp eq i32 %75, %80
  br i1 %81, label %82, label %88

82:                                               ; preds = %70
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = load i32, ptr %5, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %5, align 4, !tbaa !5
  %86 = sext i32 %84 to i64
  %87 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %86
  store i32 %83, ptr %87, align 4, !tbaa !5
  br label %94

88:                                               ; preds = %70
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = add nsw i32 %90, -1
  store i32 %91, ptr %6, align 4, !tbaa !5
  %92 = sext i32 %90 to i64
  %93 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %92
  store i32 %89, ptr %93, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %88, %82
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %4, align 4, !tbaa !5
  br label %65, !llvm.loop !16

98:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %126, %98
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = load i32, ptr @n, align 4, !tbaa !5
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %104, label %103

103:                                              ; preds = %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %129

104:                                              ; preds = %99
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %109
  %111 = getelementptr inbounds %struct.Node, ptr %110, i32 0, i32 0
  %112 = load i32, ptr %111, align 16, !tbaa !15
  %113 = load i32, ptr @t1, align 4, !tbaa !5
  %114 = add nsw i32 %113, %112
  store i32 %114, ptr @t1, align 4, !tbaa !5
  %115 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @t1, ptr noundef nonnull align 4 dereferenceable(4) @t2)
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = load i32, ptr %7, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %121
  %123 = getelementptr inbounds %struct.Node, ptr %122, i32 0, i32 1
  %124 = load i32, ptr %123, align 4, !tbaa !17
  %125 = add nsw i32 %116, %124
  store i32 %125, ptr @t2, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %104
  %127 = load i32, ptr %7, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %7, align 4, !tbaa !5
  br label %99, !llvm.loop !18

129:                                              ; preds = %103
  %130 = load i32, ptr @t2, align 4, !tbaa !5
  %131 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %130)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %132

132:                                              ; preds = %148, %129
  %133 = load i32, ptr %8, align 4, !tbaa !5
  %134 = load i32, ptr @n, align 4, !tbaa !5
  %135 = sub nsw i32 %134, 1
  %136 = icmp slt i32 %133, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %132
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %151

138:                                              ; preds = %132
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %143
  %145 = getelementptr inbounds %struct.Node, ptr %144, i32 0, i32 3
  %146 = load i32, ptr %145, align 4, !tbaa !9
  %147 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %146)
  br label %148

148:                                              ; preds = %138
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = add nsw i32 %149, 1
  store i32 %150, ptr %8, align 4, !tbaa !5
  br label %132, !llvm.loop !19

151:                                              ; preds = %137
  %152 = load i32, ptr @n, align 4, !tbaa !5
  %153 = sub nsw i32 %152, 1
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %157
  %159 = getelementptr inbounds %struct.Node, ptr %158, i32 0, i32 3
  %160 = load i32, ptr %159, align 4, !tbaa !9
  %161 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %160)
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP4NodePFbRKS0_S3_EEvT_S6_T0_(ptr noundef, ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

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 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 #2 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 #5 = { inlinehint 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 #6 = { 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 12}
!10 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !6, i64 8}
!14 = distinct !{!14, !12}
!15 = !{!10, !6, i64 0}
!16 = distinct !{!16, !12}
!17 = !{!10, !6, i64 4}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !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"

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

@n = external dso_local global i32, align 4
@que = external dso_local local_unnamed_addr global [2001 x i32], align 16
@t1 = external dso_local global i32, align 4
@t2 = external dso_local global i32, align 4
@work = external dso_local global [2001 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRK4NodeS1_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.preheader35.._crit_edge_crit_edge

.preheader35:                                     ; preds = %.lr.ph
  %4 = icmp sgt i32 %10, 0
  br i1 %4, label %.lr.ph39, label %.preheader35.._crit_edge_crit_edge

.preheader35.._crit_edge_crit_edge:               ; preds = %0, %.preheader35
  %5 = phi i32 [ %10, %.preheader35 ], [ %2, %0 ]
  %.pre68 = sext i32 %5 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %6 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %indvars.iv
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %6)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %8 = getelementptr inbounds i8, ptr %6, i64 12
  %9 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %9, ptr %8, align 4, !tbaa !9
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = icmp slt i64 %indvars.iv.next, %11
  br i1 %12, label %.lr.ph, label %.preheader35, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph39, %.preheader35.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre68, %.preheader35.._crit_edge_crit_edge ], [ %24, %.lr.ph39 ]
  %13 = getelementptr inbounds %struct.Node, ptr @work, i64 %.pre-phi
  tail call void @_ZSt4sortIP4NodePFbRKS0_S3_EEvT_S6_T0_(ptr noundef nonnull @work, ptr noundef nonnull %13, ptr noundef nonnull @_Z3cmpRK4NodeS1_)
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph44.preheader, label %.preheader.._crit_edge47_crit_edge

.lr.ph44.preheader:                               ; preds = %._crit_edge
  %16 = add nsw i32 %14, -1
  %wide.trip.count = zext nneg i32 %14 to i64
  br label %.lr.ph44

.lr.ph39:                                         ; preds = %.preheader35, %.lr.ph39
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %.lr.ph39 ], [ 0, %.preheader35 ]
  %17 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %indvars.iv56
  %18 = getelementptr inbounds i8, ptr %17, i64 4
  %19 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %18)
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %17, i64 8
  store i32 %21, ptr %22, align 8, !tbaa !13
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next57, %24
  br i1 %25, label %.lr.ph39, label %._crit_edge, !llvm.loop !14

.preheader:                                       ; preds = %.lr.ph44
  br i1 %15, label %.lr.ph46, label %.preheader.._crit_edge47_crit_edge

.preheader.._crit_edge47_crit_edge:               ; preds = %._crit_edge, %.preheader
  %.pre = load i32, ptr @t2, align 4, !tbaa !5
  br label %._crit_edge47

.lr.ph44:                                         ; preds = %.lr.ph44.preheader, %.lr.ph44
  %indvars.iv59 = phi i64 [ 0, %.lr.ph44.preheader ], [ %indvars.iv.next60, %.lr.ph44 ]
  %.02742 = phi i32 [ %16, %.lr.ph44.preheader ], [ %.1, %.lr.ph44 ]
  %.02841 = phi i32 [ 0, %.lr.ph44.preheader ], [ %.129, %.lr.ph44 ]
  %26 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %indvars.iv59
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = load i32, ptr %26, align 16, !tbaa !15
  %30 = icmp eq i32 %28, %29
  %31 = trunc nuw nsw i64 %indvars.iv59 to i32
  %.02841.sink = select i1 %30, i32 %.02841, i32 %.02742
  %32 = zext i1 %30 to i32
  %.129 = add nuw nsw i32 %.02841, %32
  %not. = xor i1 %30, true
  %33 = sext i1 %not. to i32
  %.1 = add nsw i32 %.02742, %33
  %34 = sext i32 %.02841.sink to i64
  %35 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %34
  store i32 %31, ptr %35, align 4, !tbaa !5
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next60, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph44, !llvm.loop !16

._crit_edge47:                                    ; preds = %.lr.ph46, %.preheader.._crit_edge47_crit_edge
  %36 = phi i32 [ %.pre, %.preheader.._crit_edge47_crit_edge ], [ %54, %.lr.ph46 ]
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %36)
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp sgt i32 %38, 1
  br i1 %39, label %.lr.ph50, label %._crit_edge47.._crit_edge51_crit_edge

._crit_edge47.._crit_edge51_crit_edge:            ; preds = %._crit_edge47
  %40 = add nsw i32 %38, -1
  %.pre69 = sext i32 %40 to i64
  br label %._crit_edge51

.lr.ph46:                                         ; preds = %.preheader, %.lr.ph46
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %.lr.ph46 ], [ 0, %.preheader ]
  %41 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %indvars.iv62
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %43
  %45 = load i32, ptr %44, align 16, !tbaa !15
  %46 = load i32, ptr @t1, align 4, !tbaa !5
  %47 = add nsw i32 %46, %45
  store i32 %47, ptr @t1, align 4, !tbaa !5
  %48 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @t1, ptr noundef nonnull align 4 dereferenceable(4) @t2)
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = load i32, ptr %41, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %51, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !17
  %54 = add nsw i32 %53, %49
  store i32 %54, ptr @t2, align 4, !tbaa !5
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = icmp slt i64 %indvars.iv.next63, %56
  br i1 %57, label %.lr.ph46, label %._crit_edge47, !llvm.loop !18

._crit_edge51:                                    ; preds = %.lr.ph50, %._crit_edge47.._crit_edge51_crit_edge
  %.pre-phi70 = phi i64 [ %.pre69, %._crit_edge47.._crit_edge51_crit_edge ], [ %72, %.lr.ph50 ]
  %58 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %.pre-phi70
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %60, i32 3
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %62)
  ret i32 0

.lr.ph50:                                         ; preds = %._crit_edge47, %.lr.ph50
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %.lr.ph50 ], [ 0, %._crit_edge47 ]
  %64 = getelementptr inbounds [2001 x i32], ptr @que, i64 0, i64 %indvars.iv65
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [2001 x %struct.Node], ptr @work, i64 0, i64 %66, i32 3
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %68)
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = add nsw i32 %70, -1
  %72 = sext i32 %71 to i64
  %73 = icmp slt i64 %indvars.iv.next66, %72
  br i1 %73, label %.lr.ph50, label %._crit_edge51, !llvm.loop !19
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP4NodePFbRKS0_S3_EEvT_S6_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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 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 #2 = { 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 #3 = { inlinehint 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 #4 = { inlinehint 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" }

!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 12}
!10 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !6, i64 8}
!14 = distinct !{!14, !12}
!15 = !{!10, !6, i64 0}
!16 = distinct !{!16, !12}
!17 = !{!10, !6, i64 4}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}


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