; LLVM IR from tangjz/acm-icpc :: hdu (6012)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@que = external dso_local global [100003 x i32], align 16
@s = external dso_local global [100003 x i64], align 16
@p = external dso_local global [50001 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = 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 i64, align 8
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %9

9:                                                ; preds = %197, %0
  %10 = load i32, ptr @t, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr @t, align 4, !tbaa !5
  %12 = icmp ne i32 %10, 0
  br i1 %12, label %13, label %200

13:                                               ; preds = %9
  store i32 0, ptr @tot, align 4, !tbaa !5
  %14 = load i32, ptr @tot, align 4, !tbaa !5
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr @tot, align 4, !tbaa !5
  %16 = sext i32 %14 to i64
  %17 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %16
  store i32 0, ptr %17, align 4, !tbaa !5
  %18 = load i32, ptr @tot, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr @tot, align 4, !tbaa !5
  %20 = sext i32 %18 to i64
  %21 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %20
  store i32 2000000010, ptr %21, align 4, !tbaa !5
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %71, %13
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %23
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.Node, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.Node, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %38
  %40 = getelementptr inbounds %struct.Node, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.Node, ptr %43, i32 0, i32 3
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.Node, ptr %47, i32 0, i32 4
  %49 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %32, ptr noundef %36, ptr noundef %40, ptr noundef %44, ptr noundef %48)
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.Node, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = shl i32 %54, 1
  %56 = load i32, ptr @tot, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr @tot, align 4, !tbaa !5
  %58 = sext i32 %56 to i64
  %59 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %58
  store i32 %55, ptr %59, align 4, !tbaa !5
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.Node, ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !11
  %65 = shl i32 %64, 1
  %66 = or i32 %65, 1
  %67 = load i32, ptr @tot, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr @tot, align 4, !tbaa !5
  %69 = sext i32 %67 to i64
  %70 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %69
  store i32 %66, ptr %70, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %28
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %2, align 4, !tbaa !5
  br label %23, !llvm.loop !12

74:                                               ; preds = %27
  %75 = load i32, ptr @tot, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i32, ptr @que, i64 %76
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %77)
  %78 = load i32, ptr @tot, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i32, ptr @que, i64 %79
  %81 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef @que, ptr noundef %80)
  %82 = ptrtoint ptr %81 to i64
  %83 = sub i64 %82, ptrtoint (ptr @que to i64)
  %84 = sdiv exact i64 %83, 4
  %85 = trunc i64 %84 to i32
  store i32 %85, ptr @tot, align 4, !tbaa !5
  %86 = load i32, ptr @tot, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = mul i64 %87, 8
  call void @llvm.memset.p0.i64(ptr align 16 @s, i8 0, i64 %88, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %160, %74
  %90 = load i32, ptr %3, align 4, !tbaa !5
  %91 = load i32, ptr @n, align 4, !tbaa !5
  %92 = icmp slt i32 %90, %91
  br i1 %92, label %94, label %93

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

94:                                               ; preds = %89
  %95 = load i32, ptr %3, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %96
  %98 = getelementptr inbounds %struct.Node, ptr %97, i32 0, i32 4
  %99 = load i32, ptr %98, align 4, !tbaa !14
  %100 = sext i32 %99 to i64
  %101 = load i64, ptr @s, align 16, !tbaa !15
  %102 = add nsw i64 %101, %100
  store i64 %102, ptr @s, align 16, !tbaa !15
  %103 = load i32, ptr %3, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %104
  %106 = getelementptr inbounds %struct.Node, ptr %105, i32 0, i32 2
  %107 = load i32, ptr %106, align 4, !tbaa !17
  %108 = load i32, ptr %3, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %109
  %111 = getelementptr inbounds %struct.Node, ptr %110, i32 0, i32 4
  %112 = load i32, ptr %111, align 4, !tbaa !14
  %113 = sub nsw i32 %107, %112
  %114 = sext i32 %113 to i64
  %115 = load i32, ptr @tot, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds i32, ptr @que, i64 %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %118 = load i32, ptr %3, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %119
  %121 = getelementptr inbounds %struct.Node, ptr %120, i32 0, i32 0
  %122 = load i32, ptr %121, align 4, !tbaa !9
  %123 = shl i32 %122, 1
  store i32 %123, ptr %4, align 4, !tbaa !5
  %124 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %117, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %125 = ptrtoint ptr %124 to i64
  %126 = sub i64 %125, ptrtoint (ptr @que to i64)
  %127 = sdiv exact i64 %126, 4
  %128 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %127
  %129 = load i64, ptr %128, align 8, !tbaa !15
  %130 = add nsw i64 %129, %114
  store i64 %130, ptr %128, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %131 = load i32, ptr %3, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %132
  %134 = getelementptr inbounds %struct.Node, ptr %133, i32 0, i32 3
  %135 = load i32, ptr %134, align 4, !tbaa !18
  %136 = load i32, ptr %3, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %137
  %139 = getelementptr inbounds %struct.Node, ptr %138, i32 0, i32 2
  %140 = load i32, ptr %139, align 4, !tbaa !17
  %141 = sub nsw i32 %135, %140
  %142 = sext i32 %141 to i64
  %143 = load i32, ptr @tot, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds i32, ptr @que, i64 %144
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %146 = load i32, ptr %3, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %147
  %149 = getelementptr inbounds %struct.Node, ptr %148, i32 0, i32 1
  %150 = load i32, ptr %149, align 4, !tbaa !11
  %151 = shl i32 %150, 1
  %152 = or i32 %151, 1
  store i32 %152, ptr %5, align 4, !tbaa !5
  %153 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef @que, ptr noundef %145, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %154 = ptrtoint ptr %153 to i64
  %155 = sub i64 %154, ptrtoint (ptr @que to i64)
  %156 = sdiv exact i64 %155, 4
  %157 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %156
  %158 = load i64, ptr %157, align 8, !tbaa !15
  %159 = add nsw i64 %158, %142
  store i64 %159, ptr %157, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %160

160:                                              ; preds = %94
  %161 = load i32, ptr %3, align 4, !tbaa !5
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %3, align 4, !tbaa !5
  br label %89, !llvm.loop !19

163:                                              ; preds = %93
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %164 = load i64, ptr @s, align 16, !tbaa !15
  store i64 %164, ptr %6, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %165

165:                                              ; preds = %194, %163
  %166 = load i32, ptr %7, align 4, !tbaa !5
  %167 = load i32, ptr @tot, align 4, !tbaa !5
  %168 = sub nsw i32 %167, 1
  %169 = icmp slt i32 %166, %168
  br i1 %169, label %171, label %170

170:                                              ; preds = %165
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %197

171:                                              ; preds = %165
  %172 = load i32, ptr %7, align 4, !tbaa !5
  %173 = sub nsw i32 %172, 1
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %174
  %176 = load i64, ptr %175, align 8, !tbaa !15
  %177 = load i32, ptr %7, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %178
  %180 = load i64, ptr %179, align 8, !tbaa !15
  %181 = add nsw i64 %180, %176
  store i64 %181, ptr %179, align 8, !tbaa !15
  %182 = load i64, ptr %6, align 8, !tbaa !15
  %183 = load i32, ptr %7, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %184
  %186 = load i64, ptr %185, align 8, !tbaa !15
  %187 = icmp slt i64 %182, %186
  br i1 %187, label %188, label %193

188:                                              ; preds = %171
  %189 = load i32, ptr %7, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %190
  %192 = load i64, ptr %191, align 8, !tbaa !15
  store i64 %192, ptr %6, align 8, !tbaa !15
  br label %193

193:                                              ; preds = %188, %171
  br label %194

194:                                              ; preds = %193
  %195 = load i32, ptr %7, align 4, !tbaa !5
  %196 = add nsw i32 %195, 1
  store i32 %196, ptr %7, align 4, !tbaa !5
  br label %165, !llvm.loop !20

197:                                              ; preds = %170
  %198 = load i64, ptr %6, align 8, !tbaa !15
  %199 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %198)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %9, !llvm.loop !21

200:                                              ; preds = %9
  ret i32 0
}

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

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

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


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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [100003 x i32], align 16
@s = external dso_local local_unnamed_addr global [100003 x i64], align 16
@p = external dso_local global [50001 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = 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 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %.not40 = icmp eq i32 %4, 0
  br i1 %.not40, label %._crit_edge43, label %.lr.ph42

.lr.ph42:                                         ; preds = %0, %._crit_edge39
  store i32 0, ptr @que, align 16, !tbaa !5
  store i32 2, ptr @tot, align 4, !tbaa !5
  store i32 2000000010, ptr getelementptr inbounds (i8, ptr @que, i64 4), align 4, !tbaa !5
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %.lr.ph42.._crit_edge_crit_edge

.lr.ph42.._crit_edge_crit_edge:                   ; preds = %.lr.ph42
  %.pre = load i32, ptr @tot, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph42.._crit_edge_crit_edge
  %9 = phi i32 [ %.pre, %.lr.ph42.._crit_edge_crit_edge ], [ %39, %.lr.ph ]
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds i32, ptr @que, i64 %10
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %11)
  %12 = load i32, ptr @tot, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds i32, ptr @que, i64 %13
  %15 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull @que, ptr noundef nonnull %14)
  %16 = ptrtoint ptr %15 to i64
  %17 = sub i64 %16, ptrtoint (ptr @que to i64)
  %18 = lshr exact i64 %17, 2
  %19 = trunc i64 %18 to i32
  store i32 %19, ptr @tot, align 4, !tbaa !5
  %sext = shl i64 %17, 30
  %20 = ashr exact i64 %sext, 29
  %21 = and i64 %20, -8
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @s, i8 0, i64 %21, i1 false)
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph33, label %._crit_edge34

.lr.ph:                                           ; preds = %.lr.ph42, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph42 ]
  %24 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %indvars.iv
  %25 = getelementptr inbounds i8, ptr %24, i64 4
  %26 = getelementptr inbounds i8, ptr %24, i64 8
  %27 = getelementptr inbounds i8, ptr %24, i64 12
  %28 = getelementptr inbounds i8, ptr %24, i64 16
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %24, ptr noundef nonnull %25, ptr noundef nonnull %26, ptr noundef nonnull %27, ptr noundef nonnull %28)
  %30 = load i32, ptr %24, align 4, !tbaa !9
  %31 = shl i32 %30, 1
  %32 = load i32, ptr @tot, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %34
  store i32 %31, ptr %35, align 4, !tbaa !5
  %36 = load i32, ptr %25, align 4, !tbaa !11
  %37 = shl i32 %36, 1
  %38 = or disjoint i32 %37, 1
  %39 = add nsw i32 %32, 2
  store i32 %39, ptr @tot, align 4, !tbaa !5
  %40 = sext i32 %33 to i64
  %41 = getelementptr inbounds [100003 x i32], ptr @que, i64 0, i64 %40
  store i32 %38, ptr %41, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = icmp slt i64 %indvars.iv.next, %43
  br i1 %44, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge34.loopexit:                           ; preds = %.lr.ph33
  %.pre51 = load i32, ptr @tot, align 4, !tbaa !5
  br label %._crit_edge34

._crit_edge34:                                    ; preds = %._crit_edge34.loopexit, %._crit_edge
  %45 = phi i32 [ %.pre51, %._crit_edge34.loopexit ], [ %19, %._crit_edge ]
  %46 = load i64, ptr @s, align 16, !tbaa !14
  %47 = icmp sgt i32 %45, 2
  br i1 %47, label %.lr.ph38.preheader, label %._crit_edge39

.lr.ph38.preheader:                               ; preds = %._crit_edge34
  %48 = zext nneg i32 %45 to i64
  %xtraiter = and i64 %48, 1
  %49 = icmp eq i32 %45, 3
  br i1 %49, label %._crit_edge39.loopexit.unr-lcssa, label %.lr.ph38.preheader.new

.lr.ph38.preheader.new:                           ; preds = %.lr.ph38.preheader
  %50 = and i64 %48, 2147483646
  %51 = add nsw i64 %50, -4
  br label %.lr.ph38

.lr.ph33:                                         ; preds = %._crit_edge, %.lr.ph33
  %indvars.iv45 = phi i64 [ %indvars.iv.next46, %.lr.ph33 ], [ 0, %._crit_edge ]
  %52 = getelementptr inbounds [50001 x %struct.Node], ptr @p, i64 0, i64 %indvars.iv45
  %53 = getelementptr inbounds i8, ptr %52, i64 16
  %54 = load i32, ptr %53, align 4, !tbaa !16
  %55 = sext i32 %54 to i64
  %56 = load i64, ptr @s, align 16, !tbaa !14
  %57 = add nsw i64 %56, %55
  store i64 %57, ptr @s, align 16, !tbaa !14
  %58 = getelementptr inbounds i8, ptr %52, i64 8
  %59 = load i32, ptr %58, align 4, !tbaa !17
  %60 = sub nsw i32 %59, %54
  %61 = sext i32 %60 to i64
  %62 = load i32, ptr @tot, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds i32, ptr @que, i64 %63
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %65 = load i32, ptr %52, align 4, !tbaa !9
  %66 = shl i32 %65, 1
  store i32 %66, ptr %1, align 4, !tbaa !5
  %67 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %64, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %68 = ptrtoint ptr %67 to i64
  %69 = sub i64 %68, ptrtoint (ptr @que to i64)
  %70 = ashr exact i64 %69, 2
  %71 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !14
  %73 = add nsw i64 %72, %61
  store i64 %73, ptr %71, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %74 = getelementptr inbounds i8, ptr %52, i64 12
  %75 = load i32, ptr %74, align 4, !tbaa !18
  %76 = load i32, ptr %58, align 4, !tbaa !17
  %77 = sub nsw i32 %75, %76
  %78 = sext i32 %77 to i64
  %79 = load i32, ptr @tot, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds i32, ptr @que, i64 %80
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %82 = getelementptr inbounds i8, ptr %52, i64 4
  %83 = load i32, ptr %82, align 4, !tbaa !11
  %84 = shl i32 %83, 1
  %85 = or disjoint i32 %84, 1
  store i32 %85, ptr %2, align 4, !tbaa !5
  %86 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %81, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %87 = ptrtoint ptr %86 to i64
  %88 = sub i64 %87, ptrtoint (ptr @que to i64)
  %89 = ashr exact i64 %88, 2
  %90 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !14
  %92 = add nsw i64 %91, %78
  store i64 %92, ptr %90, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %93 = load i32, ptr @n, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = icmp slt i64 %indvars.iv.next46, %94
  br i1 %95, label %.lr.ph33, label %._crit_edge34.loopexit, !llvm.loop !19

._crit_edge39.loopexit.unr-lcssa:                 ; preds = %.lr.ph38, %.lr.ph38.preheader
  %spec.select.lcssa.ph = phi i64 [ poison, %.lr.ph38.preheader ], [ %spec.select.1, %.lr.ph38 ]
  %.unr = phi i64 [ %46, %.lr.ph38.preheader ], [ %108, %.lr.ph38 ]
  %indvars.iv48.unr = phi i64 [ 1, %.lr.ph38.preheader ], [ %indvars.iv.next49.1, %.lr.ph38 ]
  %.02635.unr = phi i64 [ %46, %.lr.ph38.preheader ], [ %spec.select.1, %.lr.ph38 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge39, label %.lr.ph38.epil

.lr.ph38.epil:                                    ; preds = %._crit_edge39.loopexit.unr-lcssa
  %96 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %indvars.iv48.unr
  %97 = load i64, ptr %96, align 8, !tbaa !14
  %98 = add nsw i64 %97, %.unr
  store i64 %98, ptr %96, align 8, !tbaa !14
  %spec.select.epil = call i64 @llvm.smax.i64(i64 %.02635.unr, i64 %98)
  br label %._crit_edge39

._crit_edge39:                                    ; preds = %.lr.ph38.epil, %._crit_edge39.loopexit.unr-lcssa, %._crit_edge34
  %.026.lcssa = phi i64 [ %46, %._crit_edge34 ], [ %spec.select.lcssa.ph, %._crit_edge39.loopexit.unr-lcssa ], [ %spec.select.epil, %.lr.ph38.epil ]
  %99 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.026.lcssa)
  %100 = load i32, ptr @t, align 4, !tbaa !5
  %101 = add nsw i32 %100, -1
  store i32 %101, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %100, 0
  br i1 %.not, label %._crit_edge43, label %.lr.ph42, !llvm.loop !20

.lr.ph38:                                         ; preds = %.lr.ph38, %.lr.ph38.preheader.new
  %102 = phi i64 [ %46, %.lr.ph38.preheader.new ], [ %108, %.lr.ph38 ]
  %indvars.iv48 = phi i64 [ 1, %.lr.ph38.preheader.new ], [ %indvars.iv.next49.1, %.lr.ph38 ]
  %.02635 = phi i64 [ %46, %.lr.ph38.preheader.new ], [ %spec.select.1, %.lr.ph38 ]
  %niter = phi i64 [ 0, %.lr.ph38.preheader.new ], [ %niter.next.1, %.lr.ph38 ]
  %103 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %indvars.iv48
  %104 = load i64, ptr %103, align 8, !tbaa !14
  %105 = add nsw i64 %104, %102
  store i64 %105, ptr %103, align 8, !tbaa !14
  %spec.select = call i64 @llvm.smax.i64(i64 %.02635, i64 %105)
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %106 = getelementptr inbounds [100003 x i64], ptr @s, i64 0, i64 %indvars.iv.next49
  %107 = load i64, ptr %106, align 8, !tbaa !14
  %108 = add nsw i64 %107, %105
  store i64 %108, ptr %106, align 8, !tbaa !14
  %spec.select.1 = call i64 @llvm.smax.i64(i64 %spec.select, i64 %108)
  %indvars.iv.next49.1 = add nuw nsw i64 %indvars.iv48, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter, %51
  br i1 %niter.ncmp.1, label %._crit_edge39.loopexit.unr-lcssa, label %.lr.ph38, !llvm.loop !21

._crit_edge43:                                    ; preds = %._crit_edge39, %0
  ret i32 0
}

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

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, 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 #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #5

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


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