; LLVM IR from tangjz/acm-icpc :: usaco/Training/Chapter 1 Getting started (milk2)

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

@farmer = external dso_local global [5001 x %struct.Node], align 16
@max_work = external dso_local global i32, align 4
@max_relax = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1

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

12:                                               ; preds = %26, %0
  %13 = load i32, ptr %2, align 4, !tbaa !9
  %14 = load i32, ptr @n, align 4, !tbaa !9
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %16, label %29

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

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

29:                                               ; preds = %12
  %30 = load i32, ptr @n, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct.Node, ptr @farmer, i64 %31
  %33 = getelementptr inbounds %struct.Node, ptr %32, i64 1
  call void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef getelementptr inbounds (%struct.Node, ptr @farmer, i64 1), ptr noundef %33)
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %106, %29
  %35 = load i32, ptr %2, align 4, !tbaa !9
  %36 = load i32, ptr @n, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %38, label %109

38:                                               ; preds = %34
  %39 = load i32, ptr %2, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %40
  %42 = getelementptr inbounds %struct.Node, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 8, !tbaa !13
  %44 = icmp sge i32 %43, 0
  br i1 %44, label %45, label %105

45:                                               ; preds = %38
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %101, %45
  %47 = load i32, ptr %2, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.Node, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !15
  %52 = load i32, ptr %2, align 4, !tbaa !9
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = add nsw i32 %52, %53
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %55
  %57 = getelementptr inbounds %struct.Node, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !13
  %59 = icmp sge i32 %51, %58
  br i1 %59, label %60, label %66

60:                                               ; preds = %46
  %61 = load i32, ptr %2, align 4, !tbaa !9
  %62 = load i32, ptr %3, align 4, !tbaa !9
  %63 = add nsw i32 %61, %62
  %64 = load i32, ptr @n, align 4, !tbaa !9
  %65 = icmp sle i32 %63, %64
  br label %66

66:                                               ; preds = %60, %46
  %67 = phi i1 [ false, %46 ], [ %65, %60 ]
  br i1 %67, label %68, label %104

68:                                               ; preds = %66
  %69 = load i32, ptr %2, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.Node, ptr %71, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !15
  %74 = load i32, ptr %2, align 4, !tbaa !9
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = add nsw i32 %74, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.Node, ptr %78, i32 0, i32 1
  %80 = load i32, ptr %79, align 4, !tbaa !15
  %81 = icmp slt i32 %73, %80
  br i1 %81, label %82, label %94

82:                                               ; preds = %68
  %83 = load i32, ptr %2, align 4, !tbaa !9
  %84 = load i32, ptr %3, align 4, !tbaa !9
  %85 = add nsw i32 %83, %84
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %86
  %88 = getelementptr inbounds %struct.Node, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !15
  %90 = load i32, ptr %2, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %91
  %93 = getelementptr inbounds %struct.Node, ptr %92, i32 0, i32 1
  store i32 %89, ptr %93, align 4, !tbaa !15
  br label %94

94:                                               ; preds = %82, %68
  %95 = load i32, ptr %2, align 4, !tbaa !9
  %96 = load i32, ptr %3, align 4, !tbaa !9
  %97 = add nsw i32 %95, %96
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %98
  %100 = getelementptr inbounds %struct.Node, ptr %99, i32 0, i32 0
  store i32 -1, ptr %100, align 8, !tbaa !13
  br label %101

101:                                              ; preds = %94
  %102 = load i32, ptr %3, align 4, !tbaa !9
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %3, align 4, !tbaa !9
  br label %46, !llvm.loop !16

104:                                              ; preds = %66
  br label %105

105:                                              ; preds = %104, %38
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %2, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %2, align 4, !tbaa !9
  br label %34, !llvm.loop !17

109:                                              ; preds = %34
  %110 = load i32, ptr getelementptr inbounds ([5001 x %struct.Node], ptr @farmer, i64 0, i64 1), align 8, !tbaa !13
  store i32 %110, ptr %4, align 4, !tbaa !9
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %159, %109
  %112 = load i32, ptr %2, align 4, !tbaa !9
  %113 = load i32, ptr @n, align 4, !tbaa !9
  %114 = icmp sle i32 %112, %113
  br i1 %114, label %115, label %162

115:                                              ; preds = %111
  %116 = load i32, ptr %2, align 4, !tbaa !9
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %117
  %119 = getelementptr inbounds %struct.Node, ptr %118, i32 0, i32 0
  %120 = load i32, ptr %119, align 8, !tbaa !13
  %121 = icmp sge i32 %120, 0
  br i1 %121, label %122, label %158

122:                                              ; preds = %115
  %123 = load i32, ptr %2, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %124
  %126 = getelementptr inbounds %struct.Node, ptr %125, i32 0, i32 0
  %127 = load i32, ptr %126, align 8, !tbaa !13
  %128 = load i32, ptr %4, align 4, !tbaa !9
  %129 = sub nsw i32 %127, %128
  store i32 %129, ptr %5, align 4, !tbaa !9
  %130 = load i32, ptr %5, align 4, !tbaa !9
  %131 = load i32, ptr @max_relax, align 4, !tbaa !9
  %132 = icmp sgt i32 %130, %131
  br i1 %132, label %133, label %135

133:                                              ; preds = %122
  %134 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %134, ptr @max_relax, align 4, !tbaa !9
  br label %135

135:                                              ; preds = %133, %122
  %136 = load i32, ptr %2, align 4, !tbaa !9
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %137
  %139 = getelementptr inbounds %struct.Node, ptr %138, i32 0, i32 1
  %140 = load i32, ptr %139, align 4, !tbaa !15
  %141 = load i32, ptr %2, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %142
  %144 = getelementptr inbounds %struct.Node, ptr %143, i32 0, i32 0
  %145 = load i32, ptr %144, align 8, !tbaa !13
  %146 = sub nsw i32 %140, %145
  store i32 %146, ptr %6, align 4, !tbaa !9
  %147 = load i32, ptr %6, align 4, !tbaa !9
  %148 = load i32, ptr @max_work, align 4, !tbaa !9
  %149 = icmp sgt i32 %147, %148
  br i1 %149, label %150, label %152

150:                                              ; preds = %135
  %151 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %151, ptr @max_work, align 4, !tbaa !9
  br label %152

152:                                              ; preds = %150, %135
  %153 = load i32, ptr %2, align 4, !tbaa !9
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %154
  %156 = getelementptr inbounds %struct.Node, ptr %155, i32 0, i32 1
  %157 = load i32, ptr %156, align 4, !tbaa !15
  store i32 %157, ptr %4, align 4, !tbaa !9
  br label %158

158:                                              ; preds = %152, %115
  br label %159

159:                                              ; preds = %158
  %160 = load i32, ptr %2, align 4, !tbaa !9
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %2, align 4, !tbaa !9
  br label %111, !llvm.loop !18

162:                                              ; preds = %111
  %163 = load i32, ptr @max_work, align 4, !tbaa !9
  %164 = load i32, ptr @max_relax, align 4, !tbaa !9
  %165 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %163, i32 noundef %164)
  %166 = load ptr, ptr @stdin, align 8, !tbaa !5
  %167 = call i32 @fclose(ptr noundef %166)
  %168 = load ptr, ptr @stdout, align 8, !tbaa !5
  %169 = call i32 @fclose(ptr noundef %168)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #1

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

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

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

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

declare i32 @fclose(ptr noundef) #1

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

attributes #0 = { 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 #1 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!14, !10, i64 0}
!14 = !{!"_ZTS4Node", !10, i64 0, !10, i64 4}
!15 = !{!14, !10, i64 4}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !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 }

@farmer = external dso_local global [5001 x %struct.Node], align 16
@max_work = external dso_local local_unnamed_addr global i32, align 4
@max_relax = external dso_local local_unnamed_addr global i32, align 4
@n = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1

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

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = sext i32 %6 to i64
  br label %._crit_edge

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

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %11, %.lr.ph ]
  %12 = getelementptr inbounds %struct.Node, ptr @farmer, i64 %.pre-phi
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  tail call void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef nonnull getelementptr inbounds (i8, ptr @farmer, i64 8), ptr noundef nonnull %13)
  %14 = load i32, ptr @n, align 4
  %15 = icmp sgt i32 %14, 1
  br i1 %15, label %.lr.ph56.preheader, label %._crit_edge57

.lr.ph56.preheader:                               ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %14 to i64
  br label %.lr.ph56

.lr.ph56:                                         ; preds = %.lr.ph56.preheader, %.critedge
  %indvars.iv69 = phi i64 [ 1, %.lr.ph56.preheader ], [ %indvars.iv.next70.pre-phi, %.critedge ]
  %16 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %indvars.iv69
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = icmp sgt i32 %17, -1
  br i1 %18, label %.preheader, label %.lr.ph56..critedge_crit_edge

.lr.ph56..critedge_crit_edge:                     ; preds = %.lr.ph56
  %.pre77 = add nuw nsw i64 %indvars.iv69, 1
  br label %.critedge

.preheader:                                       ; preds = %.lr.ph56
  %19 = getelementptr inbounds i8, ptr %16, i64 4
  %.promoted = load i32, ptr %19, align 4, !tbaa !15
  %20 = add nuw nsw i64 %indvars.iv69, 1
  %21 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %20
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %.not4348 = icmp slt i32 %.promoted, %22
  br i1 %.not4348, label %.critedge, label %.lr.ph52

.lr.ph52:                                         ; preds = %.preheader, %29
  %indvars.iv66 = phi i64 [ %indvars.iv.next67, %29 ], [ 1, %.preheader ]
  %23 = phi ptr [ %32, %29 ], [ %21, %.preheader ]
  %24 = phi i32 [ %30, %29 ], [ %.promoted, %.preheader ]
  %25 = getelementptr inbounds i8, ptr %23, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %.lr.ph52
  store i32 %26, ptr %19, align 4, !tbaa !15
  br label %29

29:                                               ; preds = %28, %.lr.ph52
  %30 = phi i32 [ %26, %28 ], [ %24, %.lr.ph52 ]
  store i32 -1, ptr %23, align 8, !tbaa !13
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %31 = add nuw nsw i64 %indvars.iv.next67, %indvars.iv69
  %32 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %31
  %33 = load i32, ptr %32, align 8, !tbaa !13
  %.not43 = icmp slt i32 %30, %33
  %34 = trunc nuw i64 %31 to i32
  %.not44 = icmp slt i32 %14, %34
  %or.cond = or i1 %.not44, %.not43
  br i1 %or.cond, label %.critedge, label %.lr.ph52, !llvm.loop !16

.critedge:                                        ; preds = %29, %.lr.ph56..critedge_crit_edge, %.preheader
  %indvars.iv.next70.pre-phi = phi i64 [ %.pre77, %.lr.ph56..critedge_crit_edge ], [ %20, %.preheader ], [ %20, %29 ]
  %exitcond.not = icmp eq i64 %indvars.iv.next70.pre-phi, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge57, label %.lr.ph56, !llvm.loop !17

._crit_edge57:                                    ; preds = %.critedge, %._crit_edge
  %max_relax.promoted = load i32, ptr @max_relax, align 4, !tbaa !9
  %max_work.promoted = load i32, ptr @max_work, align 4, !tbaa !9
  %.not4259 = icmp slt i32 %14, 1
  br i1 %.not4259, label %._crit_edge64, label %.lr.ph63.preheader

.lr.ph63.preheader:                               ; preds = %._crit_edge57
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @farmer, i64 8), align 8, !tbaa !13
  %36 = add nuw i32 %14, 1
  %wide.trip.count75 = zext i32 %36 to i64
  br label %.lr.ph63

.lr.ph63:                                         ; preds = %.lr.ph63.preheader, %53
  %indvars.iv72 = phi i64 [ 1, %.lr.ph63.preheader ], [ %indvars.iv.next73, %53 ]
  %.03460 = phi i32 [ %35, %.lr.ph63.preheader ], [ %.135, %53 ]
  %37 = phi i32 [ %max_relax.promoted, %.lr.ph63.preheader ], [ %55, %53 ]
  %38 = phi i32 [ %max_work.promoted, %.lr.ph63.preheader ], [ %54, %53 ]
  %39 = getelementptr inbounds [5001 x %struct.Node], ptr @farmer, i64 0, i64 %indvars.iv72
  %40 = load i32, ptr %39, align 8, !tbaa !13
  %41 = icmp sgt i32 %40, -1
  br i1 %41, label %42, label %53

42:                                               ; preds = %.lr.ph63
  %43 = sub nsw i32 %40, %.03460
  %44 = icmp sgt i32 %43, %37
  br i1 %44, label %45, label %46

45:                                               ; preds = %42
  store i32 %43, ptr @max_relax, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %45, %42
  %47 = phi i32 [ %43, %45 ], [ %37, %42 ]
  %48 = getelementptr inbounds i8, ptr %39, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !15
  %50 = sub nsw i32 %49, %40
  %51 = icmp sgt i32 %50, %38
  br i1 %51, label %52, label %53

52:                                               ; preds = %46
  store i32 %50, ptr @max_work, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %46, %52, %.lr.ph63
  %54 = phi i32 [ %38, %.lr.ph63 ], [ %50, %52 ], [ %38, %46 ]
  %55 = phi i32 [ %37, %.lr.ph63 ], [ %47, %52 ], [ %47, %46 ]
  %.135 = phi i32 [ %.03460, %.lr.ph63 ], [ %49, %52 ], [ %49, %46 ]
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %exitcond76.not = icmp eq i64 %indvars.iv.next73, %wide.trip.count75
  br i1 %exitcond76.not, label %._crit_edge64, label %.lr.ph63, !llvm.loop !18

._crit_edge64:                                    ; preds = %53, %._crit_edge57
  %56 = phi i32 [ %max_relax.promoted, %._crit_edge57 ], [ %55, %53 ]
  %57 = phi i32 [ %max_work.promoted, %._crit_edge57 ], [ %54, %53 ]
  %58 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %57, i32 noundef %56)
  %59 = load ptr, ptr @stdin, align 8, !tbaa !5
  %60 = tail call i32 @fclose(ptr noundef %59)
  %61 = load ptr, ptr @stdout, align 8, !tbaa !5
  %62 = tail call i32 @fclose(ptr noundef %61)
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { "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 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 = !{!"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 = !{!14, !10, i64 0}
!14 = !{!"_ZTS4Node", !10, i64 0, !10, i64 4}
!15 = !{!14, !10, i64 4}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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