; LLVM IR from tangjz/acm-icpc :: codeforces/complete (500E)

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

@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@l = external dso_local global [233333 x i32], align 16
@r = external dso_local global [233333 x i32], align 16
@fa = external dso_local global [233333 x i32], align 16
@que = external dso_local global [233333 x i32], align 16
@head = external dso_local global i32, align 4
@tail = external dso_local global i32, align 4
@sum = external dso_local global [233333 x i64], align 16
@ans = external dso_local global [233333 x i64], align 16
@query = external dso_local global [233333 x %struct.Node], 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 [7 x i8], align 1

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

8:                                                ; preds = %34, %0
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sle i32 %9, %10
  br i1 %11, label %13, label %12

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

13:                                               ; preds = %8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i32, ptr @l, i64 %15
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds i32, ptr @r, i64 %18
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %16, ptr noundef %19)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [233333 x i32], ptr @l, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [233333 x i32], ptr @r, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = add nsw i32 %28, %24
  store i32 %29, ptr %27, align 4, !tbaa !5
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [233333 x i32], ptr @fa, i64 0, i64 %32
  store i32 %30, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %13
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !9

37:                                               ; preds = %12
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %59, %37
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = load i32, ptr @q, align 4, !tbaa !5
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %44, label %43

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

44:                                               ; preds = %39
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.Node, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.Node, ptr %51, i32 0, i32 1
  %53 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %48, ptr noundef %52)
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %56
  %58 = getelementptr inbounds %struct.Node, ptr %57, i32 0, i32 2
  store i32 %54, ptr %58, align 4, !tbaa !11
  br label %59

59:                                               ; preds = %44
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %3, align 4, !tbaa !5
  br label %39, !llvm.loop !13

62:                                               ; preds = %43
  %63 = load i32, ptr @q, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds %struct.Node, ptr @query, i64 %64
  call void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef @query, ptr noundef %65)
  store i32 0, ptr @head, align 4, !tbaa !5
  store i32 -1, ptr @tail, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %66 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %66, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %201, %62
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %71, label %70

70:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %204

71:                                               ; preds = %67
  br label %72

72:                                               ; preds = %115, %71
  %73 = load i32, ptr @head, align 4, !tbaa !5
  %74 = load i32, ptr @tail, align 4, !tbaa !5
  %75 = icmp sle i32 %73, %74
  br i1 %75, label %76, label %89

76:                                               ; preds = %72
  %77 = load i32, ptr @tail, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [233333 x i32], ptr @que, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [233333 x i32], ptr @l, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [233333 x i32], ptr @r, i64 0, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = icmp sle i32 %83, %87
  br label %89

89:                                               ; preds = %76, %72
  %90 = phi i1 [ false, %72 ], [ %88, %76 ]
  br i1 %90, label %91, label %126

91:                                               ; preds = %89
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [233333 x i32], ptr @r, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = load i32, ptr @tail, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [233333 x i32], ptr @que, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [233333 x i32], ptr @r, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = icmp slt i32 %95, %102
  br i1 %103, label %104, label %115

104:                                              ; preds = %91
  %105 = load i32, ptr @tail, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [233333 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 [233333 x i32], ptr @r, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = load i32, ptr %4, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [233333 x i32], ptr @r, i64 0, i64 %113
  store i32 %111, ptr %114, align 4, !tbaa !5
  br label %115

115:                                              ; preds = %104, %91
  %116 = load i32, ptr %4, align 4, !tbaa !5
  %117 = load i32, ptr @tail, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [233333 x i32], ptr @que, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = call noundef i32 @_Z4findi(i32 noundef %120)
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [233333 x i32], ptr @fa, i64 0, i64 %122
  store i32 %116, ptr %123, align 4, !tbaa !5
  %124 = load i32, ptr @tail, align 4, !tbaa !5
  %125 = add nsw i32 %124, -1
  store i32 %125, ptr @tail, align 4, !tbaa !5
  br label %72, !llvm.loop !14

126:                                              ; preds = %89
  %127 = load i32, ptr @head, align 4, !tbaa !5
  %128 = load i32, ptr @tail, align 4, !tbaa !5
  %129 = icmp sle i32 %127, %128
  br i1 %129, label %130, label %156

130:                                              ; preds = %126
  %131 = load i32, ptr @tail, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [233333 x i32], ptr @que, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [233333 x i64], ptr @sum, i64 0, i64 %135
  %137 = load i64, ptr %136, align 8, !tbaa !15
  %138 = load i32, ptr @tail, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [233333 x i32], ptr @que, i64 0, i64 %139
  %141 = load i32, ptr %140, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [233333 x i32], ptr @l, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = add nsw i64 %137, %145
  %147 = load i32, ptr %4, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [233333 x i32], ptr @r, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = sub nsw i64 %146, %151
  %153 = load i32, ptr %4, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [233333 x i64], ptr @sum, i64 0, i64 %154
  store i64 %152, ptr %155, align 8, !tbaa !15
  br label %156

156:                                              ; preds = %130, %126
  br label %157

157:                                              ; preds = %171, %156
  %158 = load i32, ptr %5, align 4, !tbaa !5
  %159 = load i32, ptr @q, align 4, !tbaa !5
  %160 = icmp slt i32 %158, %159
  br i1 %160, label %161, label %169

161:                                              ; preds = %157
  %162 = load i32, ptr %5, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %163
  %165 = getelementptr inbounds %struct.Node, ptr %164, i32 0, i32 0
  %166 = load i32, ptr %165, align 4, !tbaa !17
  %167 = load i32, ptr %4, align 4, !tbaa !5
  %168 = icmp eq i32 %166, %167
  br label %169

169:                                              ; preds = %161, %157
  %170 = phi i1 [ false, %157 ], [ %168, %161 ]
  br i1 %170, label %171, label %195

171:                                              ; preds = %169
  %172 = load i32, ptr %4, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [233333 x i64], ptr @sum, i64 0, i64 %173
  %175 = load i64, ptr %174, align 8, !tbaa !15
  %176 = load i32, ptr %5, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %177
  %179 = getelementptr inbounds %struct.Node, ptr %178, i32 0, i32 1
  %180 = load i32, ptr %179, align 4, !tbaa !18
  %181 = call noundef i32 @_Z4findi(i32 noundef %180)
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [233333 x i64], ptr @sum, i64 0, i64 %182
  %184 = load i64, ptr %183, align 8, !tbaa !15
  %185 = sub nsw i64 %175, %184
  %186 = load i32, ptr %5, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %187
  %189 = getelementptr inbounds %struct.Node, ptr %188, i32 0, i32 2
  %190 = load i32, ptr %189, align 4, !tbaa !11
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [233333 x i64], ptr @ans, i64 0, i64 %191
  store i64 %185, ptr %192, align 8, !tbaa !15
  %193 = load i32, ptr %5, align 4, !tbaa !5
  %194 = add nsw i32 %193, 1
  store i32 %194, ptr %5, align 4, !tbaa !5
  br label %157, !llvm.loop !19

195:                                              ; preds = %169
  %196 = load i32, ptr %4, align 4, !tbaa !5
  %197 = load i32, ptr @tail, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr @tail, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [233333 x i32], ptr @que, i64 0, i64 %199
  store i32 %196, ptr %200, align 4, !tbaa !5
  br label %201

201:                                              ; preds = %195
  %202 = load i32, ptr %4, align 4, !tbaa !5
  %203 = add nsw i32 %202, -1
  store i32 %203, ptr %4, align 4, !tbaa !5
  br label %67, !llvm.loop !20

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

205:                                              ; preds = %216, %204
  %206 = load i32, ptr %6, align 4, !tbaa !5
  %207 = load i32, ptr @q, align 4, !tbaa !5
  %208 = icmp slt i32 %206, %207
  br i1 %208, label %210, label %209

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

210:                                              ; preds = %205
  %211 = load i32, ptr %6, align 4, !tbaa !5
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [233333 x i64], ptr @ans, i64 0, i64 %212
  %214 = load i64, ptr %213, align 8, !tbaa !15
  %215 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %214)
  br label %216

216:                                              ; preds = %210
  %217 = load i32, ptr %6, align 4, !tbaa !5
  %218 = add nsw i32 %217, 1
  store i32 %218, ptr %6, align 4, !tbaa !5
  br label %205, !llvm.loop !21

219:                                              ; preds = %209
  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 uwtable
declare dso_local void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef, ptr noundef) #4

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress 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 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 = { 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 = !{!12, !6, i64 8}
!12 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!12, !6, i64 0}
!18 = !{!12, !6, i64 4}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !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 { i32, i32, i32 }

@n = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@l = external dso_local global [233333 x i32], align 16
@r = external dso_local global [233333 x i32], align 16
@fa = external dso_local local_unnamed_addr global [233333 x i32], align 16
@que = external dso_local local_unnamed_addr global [233333 x i32], align 16
@head = external dso_local local_unnamed_addr global i32, align 4
@tail = external dso_local local_unnamed_addr global i32, align 4
@sum = external dso_local local_unnamed_addr global [233333 x i64], align 16
@ans = external dso_local local_unnamed_addr global [233333 x i64], align 16
@query = external dso_local global [233333 x %struct.Node], 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 [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4findi(i32 noundef) local_unnamed_addr #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
  %.not50 = icmp slt i32 %2, 1
  br i1 %.not50, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @q)
  %4 = load i32, ptr @q, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph54, label %._crit_edge.._crit_edge55_crit_edge

._crit_edge.._crit_edge55_crit_edge:              ; preds = %._crit_edge
  %.pre88 = sext i32 %4 to i64
  br label %._crit_edge55

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

._crit_edge55:                                    ; preds = %.lr.ph54, %._crit_edge.._crit_edge55_crit_edge
  %.pre-phi = phi i64 [ %.pre88, %._crit_edge.._crit_edge55_crit_edge ], [ %25, %.lr.ph54 ]
  %16 = getelementptr inbounds %struct.Node, ptr @query, i64 %.pre-phi
  tail call void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef nonnull @query, ptr noundef nonnull %16)
  store i32 0, ptr @head, align 4, !tbaa !5
  store i32 -1, ptr @tail, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %.not4463 = icmp eq i32 %17, 0
  br i1 %.not4463, label %._crit_edge55..preheader_crit_edge, label %.preheader48.preheader

._crit_edge55..preheader_crit_edge:               ; preds = %._crit_edge55
  %.pre87 = load i32, ptr @q, align 4, !tbaa !5
  br label %.preheader

.preheader48.preheader:                           ; preds = %._crit_edge55
  %18 = sext i32 %17 to i64
  br label %.preheader48

.lr.ph54:                                         ; preds = %._crit_edge, %.lr.ph54
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %.lr.ph54 ], [ 0, %._crit_edge ]
  %19 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %indvars.iv73
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  %21 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %19, ptr noundef nonnull %20)
  %22 = getelementptr inbounds i8, ptr %19, i64 8
  %23 = trunc nuw nsw i64 %indvars.iv73 to i32
  store i32 %23, ptr %22, align 4, !tbaa !11
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %24 = load i32, ptr @q, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next74, %25
  br i1 %26, label %.lr.ph54, label %._crit_edge55, !llvm.loop !13

.preheader48:                                     ; preds = %.preheader48.preheader, %.critedge2
  %27 = phi i32 [ -1, %.preheader48.preheader ], [ %93, %.critedge2 ]
  %indvars.iv79 = phi i64 [ %18, %.preheader48.preheader ], [ %indvars.iv.next80, %.critedge2 ]
  %.03565 = phi i32 [ 0, %.preheader48.preheader ], [ %.1.lcssa, %.critedge2 ]
  %28 = load i32, ptr @head, align 4, !tbaa !5
  %.not4556 = icmp sgt i32 %28, %27
  br i1 %.not4556, label %.critedge.thread, label %.lr.ph57

.lr.ph57:                                         ; preds = %.preheader48
  %29 = getelementptr inbounds [233333 x i32], ptr @r, i64 0, i64 %indvars.iv79
  %30 = trunc nsw i64 %indvars.iv79 to i32
  br label %33

.preheader:                                       ; preds = %.critedge2, %._crit_edge55..preheader_crit_edge
  %31 = phi i32 [ %.pre87, %._crit_edge55..preheader_crit_edge ], [ %91, %.critedge2 ]
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph67, label %._crit_edge68

33:                                               ; preds = %.lr.ph57, %47
  %34 = phi i32 [ %27, %.lr.ph57 ], [ %52, %47 ]
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [233333 x i32], ptr @que, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [233333 x i32], ptr @l, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = load i32, ptr %29, align 4, !tbaa !5
  %.not46 = icmp sgt i32 %40, %41
  br i1 %.not46, label %.critedge, label %42

42:                                               ; preds = %33
  %43 = getelementptr inbounds [233333 x i32], ptr @r, i64 0, i64 %38
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = icmp slt i32 %41, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  store i32 %44, ptr %29, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %46, %42
  %48 = tail call noundef i32 @_Z4findi(i32 noundef %37)
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [233333 x i32], ptr @fa, i64 0, i64 %49
  store i32 %30, ptr %50, align 4, !tbaa !5
  %51 = load i32, ptr @tail, align 4, !tbaa !5
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr @tail, align 4, !tbaa !5
  %53 = load i32, ptr @head, align 4, !tbaa !5
  %.not45.not = icmp slt i32 %53, %51
  br i1 %.not45.not, label %33, label %.critedge.thread, !llvm.loop !14

.critedge:                                        ; preds = %33
  %54 = getelementptr inbounds [233333 x i64], ptr @sum, i64 0, i64 %38
  %55 = load i64, ptr %54, align 8, !tbaa !15
  %56 = sext i32 %40 to i64
  %57 = add nsw i64 %55, %56
  %58 = sext i32 %41 to i64
  %59 = sub i64 %57, %58
  %60 = getelementptr inbounds [233333 x i64], ptr @sum, i64 0, i64 %indvars.iv79
  store i64 %59, ptr %60, align 8, !tbaa !15
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %47, %.preheader48, %.critedge
  %61 = phi i32 [ %27, %.preheader48 ], [ %34, %.critedge ], [ %52, %47 ]
  %62 = load i32, ptr @q, align 4, !tbaa !5
  %63 = icmp slt i32 %.03565, %62
  br i1 %63, label %.lr.ph59, label %.critedge.thread..critedge2_crit_edge

.critedge.thread..critedge2_crit_edge:            ; preds = %.critedge.thread
  %.pre89 = trunc nsw i64 %indvars.iv79 to i32
  br label %.critedge2

.lr.ph59:                                         ; preds = %.critedge.thread
  %64 = getelementptr inbounds [233333 x i64], ptr @sum, i64 0, i64 %indvars.iv79
  %65 = sext i32 %.03565 to i64
  %66 = trunc nsw i64 %indvars.iv79 to i32
  %67 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %65
  %68 = load i32, ptr %67, align 4, !tbaa !17
  %69 = icmp eq i32 %68, %66
  br i1 %69, label %.lr.ph113, label %.critedge2.loopexit

70:                                               ; preds = %.lr.ph113
  %71 = getelementptr inbounds [233333 x %struct.Node], ptr @query, i64 0, i64 %indvars.iv.next77
  %72 = load i32, ptr %71, align 4, !tbaa !17
  %73 = icmp eq i32 %72, %66
  br i1 %73, label %.lr.ph113, label %.critedge2.loopexit, !llvm.loop !18

.lr.ph113:                                        ; preds = %.lr.ph59, %70
  %74 = phi ptr [ %71, %70 ], [ %67, %.lr.ph59 ]
  %indvars.iv76112 = phi i64 [ %indvars.iv.next77, %70 ], [ %65, %.lr.ph59 ]
  %75 = load i64, ptr %64, align 8, !tbaa !15
  %76 = getelementptr inbounds i8, ptr %74, i64 4
  %77 = load i32, ptr %76, align 4, !tbaa !19
  %78 = tail call noundef i32 @_Z4findi(i32 noundef %77)
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [233333 x i64], ptr @sum, i64 0, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !15
  %82 = sub nsw i64 %75, %81
  %83 = getelementptr inbounds i8, ptr %74, i64 8
  %84 = load i32, ptr %83, align 4, !tbaa !11
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [233333 x i64], ptr @ans, i64 0, i64 %85
  store i64 %82, ptr %86, align 8, !tbaa !15
  %indvars.iv.next77 = add nsw i64 %indvars.iv76112, 1
  %87 = load i32, ptr @q, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = icmp slt i64 %indvars.iv.next77, %88
  br i1 %89, label %70, label %.critedge2.loopexit, !llvm.loop !18

.critedge2.loopexit:                              ; preds = %70, %.lr.ph113, %.lr.ph59
  %90 = phi i32 [ %62, %.lr.ph59 ], [ %87, %.lr.ph113 ], [ %87, %70 ]
  %.1.lcssa.ph.in = phi i64 [ %65, %.lr.ph59 ], [ %indvars.iv.next77, %.lr.ph113 ], [ %indvars.iv.next77, %70 ]
  %.1.lcssa.ph = trunc i64 %.1.lcssa.ph.in to i32
  %.pre = load i32, ptr @tail, align 4, !tbaa !5
  br label %.critedge2

.critedge2:                                       ; preds = %.critedge.thread..critedge2_crit_edge, %.critedge2.loopexit
  %.pre-phi90 = phi i32 [ %.pre89, %.critedge.thread..critedge2_crit_edge ], [ %66, %.critedge2.loopexit ]
  %91 = phi i32 [ %62, %.critedge.thread..critedge2_crit_edge ], [ %90, %.critedge2.loopexit ]
  %92 = phi i32 [ %61, %.critedge.thread..critedge2_crit_edge ], [ %.pre, %.critedge2.loopexit ]
  %.1.lcssa = phi i32 [ %.03565, %.critedge.thread..critedge2_crit_edge ], [ %.1.lcssa.ph, %.critedge2.loopexit ]
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr @tail, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [233333 x i32], ptr @que, i64 0, i64 %94
  store i32 %.pre-phi90, ptr %95, align 4, !tbaa !5
  %indvars.iv.next80 = add nsw i64 %indvars.iv79, -1
  %.not44 = icmp eq i64 %indvars.iv.next80, 0
  br i1 %.not44, label %.preheader, label %.preheader48, !llvm.loop !20

._crit_edge68:                                    ; preds = %.lr.ph67, %.preheader
  ret i32 0

.lr.ph67:                                         ; preds = %.preheader, %.lr.ph67
  %indvars.iv83 = phi i64 [ %indvars.iv.next84, %.lr.ph67 ], [ 0, %.preheader ]
  %96 = getelementptr inbounds [233333 x i64], ptr @ans, i64 0, i64 %indvars.iv83
  %97 = load i64, ptr %96, align 8, !tbaa !15
  %98 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %97)
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %99 = load i32, ptr @q, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = icmp slt i64 %indvars.iv.next84, %100
  br i1 %101, label %.lr.ph67, label %._crit_edge68, !llvm.loop !21
}

; 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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress 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 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!12, !6, i64 0}
!18 = distinct !{!18, !10}
!19 = !{!12, !6, i64 4}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}


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