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

; 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.Edge = type { i32, i32, i32 }
%struct.Query = type { i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@fa = external dso_local global [20001 x i32], align 16
@sz = external dso_local global [20001 x i32], align 16
@sum = external dso_local global i32, align 4
@ans = external dso_local global [5001 x i32], align 16
@e = external dso_local global [100001 x %struct.Edge], align 16
@que = external dso_local global [5001 x %struct.Query], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 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
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %11

11:                                               ; preds = %180, %0
  %12 = load i32, ptr @t, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr @t, align 4, !tbaa !5
  %14 = icmp ne i32 %12, 0
  br i1 %14, label %15, label %181

15:                                               ; preds = %11
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m, ptr noundef @q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %30, %15
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp sle i32 %18, %19
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [20001 x i32], ptr @fa, i64 0, i64 %25
  store i32 %23, ptr %26, align 4, !tbaa !5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %28
  store i32 1, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %22
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !9

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

34:                                               ; preds = %53, %33
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = load i32, ptr @m, align 4, !tbaa !5
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

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

39:                                               ; preds = %34
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.Edge, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.Edge, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.Edge, ptr %50, i32 0, i32 2
  %52 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %43, ptr noundef %47, ptr noundef %51)
  br label %53

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

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

57:                                               ; preds = %73, %56
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = load i32, ptr @q, align 4, !tbaa !5
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %76

62:                                               ; preds = %57
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [5001 x %struct.Query], ptr @que, i64 0, i64 %65
  %67 = getelementptr inbounds %struct.Query, ptr %66, i32 0, i32 0
  store i32 %63, ptr %67, align 8, !tbaa !12
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [5001 x %struct.Query], ptr @que, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.Query, ptr %70, i32 0, i32 1
  %72 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %71)
  br label %73

73:                                               ; preds = %62
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %4, align 4, !tbaa !5
  br label %57, !llvm.loop !14

76:                                               ; preds = %61
  %77 = load i32, ptr @m, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds %struct.Edge, ptr @e, i64 %78
  call void @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef @e, ptr noundef %79)
  %80 = load i32, ptr @q, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds %struct.Query, ptr @que, i64 %81
  call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef @que, ptr noundef %82)
  store i32 0, ptr @sum, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %161, %76
  %84 = load i32, ptr %5, align 4, !tbaa !5
  %85 = load i32, ptr @q, align 4, !tbaa !5
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %88, label %87

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

88:                                               ; preds = %83
  br label %89

89:                                               ; preds = %149, %88
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = load i32, ptr @m, align 4, !tbaa !5
  %92 = icmp slt i32 %90, %91
  br i1 %92, label %93, label %105

93:                                               ; preds = %89
  %94 = load i32, ptr %6, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.Edge, ptr %96, i32 0, i32 2
  %98 = load i32, ptr %97, align 4, !tbaa !15
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [5001 x %struct.Query], ptr @que, i64 0, i64 %100
  %102 = getelementptr inbounds %struct.Query, ptr %101, i32 0, i32 1
  %103 = load i32, ptr %102, align 4, !tbaa !17
  %104 = icmp sle i32 %98, %103
  br label %105

105:                                              ; preds = %93, %89
  %106 = phi i1 [ false, %89 ], [ %104, %93 ]
  br i1 %106, label %107, label %152

107:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %108 = load i32, ptr %6, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %109
  %111 = getelementptr inbounds %struct.Edge, ptr %110, i32 0, i32 0
  %112 = load i32, ptr %111, align 4, !tbaa !18
  store i32 %112, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %113 = load i32, ptr %6, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %114
  %116 = getelementptr inbounds %struct.Edge, ptr %115, i32 0, i32 1
  %117 = load i32, ptr %116, align 4, !tbaa !19
  store i32 %117, ptr %8, align 4, !tbaa !5
  %118 = load i32, ptr %7, align 4, !tbaa !5
  %119 = call noundef i32 @_Z4findi(i32 noundef %118)
  store i32 %119, ptr %7, align 4, !tbaa !5
  %120 = load i32, ptr %8, align 4, !tbaa !5
  %121 = call noundef i32 @_Z4findi(i32 noundef %120)
  store i32 %121, ptr %8, align 4, !tbaa !5
  %122 = icmp ne i32 %119, %121
  br i1 %122, label %123, label %148

123:                                              ; preds = %107
  %124 = load i32, ptr %7, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = load i32, ptr %8, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !5
  %132 = mul nsw i32 %127, %131
  %133 = load i32, ptr @sum, align 4, !tbaa !5
  %134 = add nsw i32 %133, %132
  store i32 %134, ptr @sum, align 4, !tbaa !5
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = load i32, ptr %7, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [20001 x i32], ptr @fa, i64 0, i64 %137
  store i32 %135, ptr %138, align 4, !tbaa !5
  %139 = load i32, ptr %7, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = load i32, ptr %8, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = add nsw i32 %146, %142
  store i32 %147, ptr %145, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %123, %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %149

149:                                              ; preds = %148
  %150 = load i32, ptr %6, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %6, align 4, !tbaa !5
  br label %89, !llvm.loop !20

152:                                              ; preds = %105
  %153 = load i32, ptr @sum, align 4, !tbaa !5
  %154 = load i32, ptr %5, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [5001 x %struct.Query], ptr @que, i64 0, i64 %155
  %157 = getelementptr inbounds %struct.Query, ptr %156, i32 0, i32 0
  %158 = load i32, ptr %157, align 8, !tbaa !12
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [5001 x i32], ptr @ans, i64 0, i64 %159
  store i32 %153, ptr %160, align 4, !tbaa !5
  br label %161

161:                                              ; preds = %152
  %162 = load i32, ptr %5, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %5, align 4, !tbaa !5
  br label %83, !llvm.loop !21

164:                                              ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %165

165:                                              ; preds = %177, %164
  %166 = load i32, ptr %9, align 4, !tbaa !5
  %167 = load i32, ptr @q, align 4, !tbaa !5
  %168 = icmp slt i32 %166, %167
  br i1 %168, label %170, label %169

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

170:                                              ; preds = %165
  %171 = load i32, ptr %9, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [5001 x i32], ptr @ans, i64 0, i64 %172
  %174 = load i32, ptr %173, align 4, !tbaa !5
  %175 = mul nsw i32 %174, 2
  %176 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %175)
  br label %177

177:                                              ; preds = %170
  %178 = load i32, ptr %9, align 4, !tbaa !5
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %9, align 4, !tbaa !5
  br label %165, !llvm.loop !22

180:                                              ; preds = %169
  br label %11, !llvm.loop !23

181:                                              ; preds = %11
  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 @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5QueryEvT_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 = distinct !{!11, !10}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4}
!14 = distinct !{!14, !10}
!15 = !{!16, !6, i64 8}
!16 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8}
!17 = !{!13, !6, i64 4}
!18 = !{!16, !6, i64 0}
!19 = !{!16, !6, i64 4}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !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.Edge = type { i32, i32, i32 }
%struct.Query = type { i32, i32 }

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@fa = external dso_local local_unnamed_addr global [20001 x i32], align 16
@sz = external dso_local local_unnamed_addr global [20001 x i32], align 16
@sum = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global [5001 x i32], align 16
@e = external dso_local global [100001 x %struct.Edge], align 16
@que = external dso_local global [5001 x %struct.Query], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 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 @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not62 = icmp eq i32 %2, 0
  br i1 %.not62, label %._crit_edge65, label %.lr.ph64

.loopexit:                                        ; preds = %.lr.ph61, %._crit_edge, %.preheader45
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge65, label %.lr.ph64, !llvm.loop !9

.lr.ph64:                                         ; preds = %0, %.loopexit
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @q)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not4248 = icmp slt i32 %7, 1
  br i1 %.not4248, label %.preheader47, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph64
  %8 = add nuw i32 %7, 1
  %wide.trip.count = zext i32 %8 to i64
  %9 = zext nneg i32 %7 to i64
  %min.iters.check = icmp ult i32 %7, 8
  br i1 %min.iters.check, label %.lr.ph.preheader97, label %vector.ph

.lr.ph.preheader97:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %9, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %offset.idx = or disjoint i64 %index, 1
  %10 = getelementptr inbounds [20001 x i32], ptr @fa, i64 0, i64 %offset.idx
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  store <4 x i32> %vec.ind, ptr %10, align 4, !tbaa !5
  store <4 x i32> %step.add, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %offset.idx
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %12, align 4, !tbaa !5
  store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %13, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %14 = icmp eq i64 %index.next, %n.vec
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %9
  br i1 %cmp.n, label %.preheader47, label %.lr.ph.preheader97

.preheader47:                                     ; preds = %.lr.ph, %middle.block, %.lr.ph64
  %15 = load i32, ptr @m, align 4, !tbaa !5
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph51, label %.preheader46

.lr.ph:                                           ; preds = %.lr.ph.preheader97, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader97 ]
  %17 = getelementptr inbounds [20001 x i32], ptr @fa, i64 0, i64 %indvars.iv
  %18 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %18, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %indvars.iv
  store i32 1, ptr %19, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader47, label %.lr.ph, !llvm.loop !14

.preheader46:                                     ; preds = %.lr.ph51, %.preheader47
  %20 = phi i32 [ %15, %.preheader47 ], [ %27, %.lr.ph51 ]
  %21 = load i32, ptr @q, align 4, !tbaa !5
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph53, label %._crit_edge

.lr.ph51:                                         ; preds = %.preheader47, %.lr.ph51
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %.lr.ph51 ], [ 0, %.preheader47 ]
  %23 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %indvars.iv67
  %24 = getelementptr inbounds i8, ptr %23, i64 4
  %25 = getelementptr inbounds i8, ptr %23, i64 8
  %26 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %23, ptr noundef nonnull %24, ptr noundef nonnull %25)
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %27 = load i32, ptr @m, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %indvars.iv.next68, %28
  br i1 %29, label %.lr.ph51, label %.preheader46, !llvm.loop !15

._crit_edge.loopexit:                             ; preds = %.lr.ph53
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader46
  %30 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %20, %.preheader46 ]
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct.Edge, ptr @e, i64 %31
  tail call void @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef nonnull @e, ptr noundef nonnull %32)
  %33 = load i32, ptr @q, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct.Query, ptr @que, i64 %34
  tail call void @_ZSt4sortIP5QueryEvT_S2_(ptr noundef nonnull @que, ptr noundef nonnull %35)
  store i32 0, ptr @sum, align 4, !tbaa !5
  %36 = load i32, ptr @q, align 4, !tbaa !5
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %._crit_edge
  %.pre84 = load i32, ptr @m, align 4, !tbaa !5
  br label %.preheader

.lr.ph53:                                         ; preds = %.preheader46, %.lr.ph53
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %.lr.ph53 ], [ 0, %.preheader46 ]
  %38 = getelementptr inbounds [5001 x %struct.Query], ptr @que, i64 0, i64 %indvars.iv70
  %39 = trunc nuw nsw i64 %indvars.iv70 to i32
  store i32 %39, ptr %38, align 8, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %38, i64 4
  %41 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %40)
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %42 = load i32, ptr @q, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = icmp slt i64 %indvars.iv.next71, %43
  br i1 %44, label %.lr.ph53, label %._crit_edge.loopexit, !llvm.loop !18

.preheader45:                                     ; preds = %.critedge
  %45 = icmp sgt i32 %84, 0
  br i1 %45, label %.lr.ph61, label %.loopexit

.preheader:                                       ; preds = %.preheader.preheader, %.critedge
  %46 = phi i32 [ %36, %.preheader.preheader ], [ %84, %.critedge ]
  %47 = phi i32 [ 0, %.preheader.preheader ], [ %85, %.critedge ]
  %48 = phi i32 [ %.pre84, %.preheader.preheader ], [ %86, %.critedge ]
  %indvars.iv76 = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next77, %.critedge ]
  %.03559 = phi i32 [ 0, %.preheader.preheader ], [ %.1.lcssa, %.critedge ]
  %49 = icmp slt i32 %.03559, %48
  br i1 %49, label %.lr.ph55, label %.critedge

.lr.ph55:                                         ; preds = %.preheader
  %50 = getelementptr inbounds [5001 x %struct.Query], ptr @que, i64 0, i64 %indvars.iv76, i32 1
  %51 = sext i32 %.03559 to i64
  %52 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %51
  %53 = getelementptr inbounds i8, ptr %52, i64 8
  %54 = load i32, ptr %53, align 4, !tbaa !19
  %55 = load i32, ptr %50, align 4, !tbaa !21
  %.not4389 = icmp sgt i32 %54, %55
  br i1 %.not4389, label %.critedge.loopexit, label %.lr.ph91

56:                                               ; preds = %79
  %57 = getelementptr inbounds [100001 x %struct.Edge], ptr @e, i64 0, i64 %indvars.iv.next74
  %58 = getelementptr inbounds i8, ptr %57, i64 8
  %59 = load i32, ptr %58, align 4, !tbaa !19
  %60 = load i32, ptr %50, align 4, !tbaa !21
  %.not43 = icmp sgt i32 %59, %60
  br i1 %.not43, label %.critedge.loopexit, label %.lr.ph91, !llvm.loop !22

.lr.ph91:                                         ; preds = %.lr.ph55, %56
  %61 = phi ptr [ %57, %56 ], [ %52, %.lr.ph55 ]
  %indvars.iv7390 = phi i64 [ %indvars.iv.next74, %56 ], [ %51, %.lr.ph55 ]
  %62 = load i32, ptr %61, align 4, !tbaa !23
  %63 = getelementptr inbounds i8, ptr %61, i64 4
  %64 = load i32, ptr %63, align 4, !tbaa !24
  %65 = tail call noundef i32 @_Z4findi(i32 noundef %62)
  %66 = tail call noundef i32 @_Z4findi(i32 noundef %64)
  %.not44 = icmp eq i32 %65, %66
  br i1 %.not44, label %79, label %67

67:                                               ; preds = %.lr.ph91
  %68 = sext i32 %65 to i64
  %69 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = sext i32 %66 to i64
  %72 = getelementptr inbounds [20001 x i32], ptr @sz, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = mul nsw i32 %73, %70
  %75 = load i32, ptr @sum, align 4, !tbaa !5
  %76 = add nsw i32 %75, %74
  store i32 %76, ptr @sum, align 4, !tbaa !5
  %77 = getelementptr inbounds [20001 x i32], ptr @fa, i64 0, i64 %68
  store i32 %66, ptr %77, align 4, !tbaa !5
  %78 = add nsw i32 %73, %70
  store i32 %78, ptr %72, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %67, %.lr.ph91
  %indvars.iv.next74 = add nsw i64 %indvars.iv7390, 1
  %80 = load i32, ptr @m, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = icmp slt i64 %indvars.iv.next74, %81
  br i1 %82, label %56, label %.critedge.loopexit, !llvm.loop !22

.critedge.loopexit:                               ; preds = %56, %79, %.lr.ph55
  %83 = phi i32 [ %48, %.lr.ph55 ], [ %80, %79 ], [ %80, %56 ]
  %.1.lcssa.ph.in = phi i64 [ %51, %.lr.ph55 ], [ %indvars.iv.next74, %79 ], [ %indvars.iv.next74, %56 ]
  %.1.lcssa.ph = trunc i64 %.1.lcssa.ph.in to i32
  %.pre85 = load i32, ptr @sum, align 4, !tbaa !5
  %.pre86 = load i32, ptr @q, align 4, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.preheader
  %84 = phi i32 [ %46, %.preheader ], [ %.pre86, %.critedge.loopexit ]
  %85 = phi i32 [ %47, %.preheader ], [ %.pre85, %.critedge.loopexit ]
  %86 = phi i32 [ %48, %.preheader ], [ %83, %.critedge.loopexit ]
  %.1.lcssa = phi i32 [ %.03559, %.preheader ], [ %.1.lcssa.ph, %.critedge.loopexit ]
  %87 = getelementptr inbounds [5001 x %struct.Query], ptr @que, i64 0, i64 %indvars.iv76
  %88 = load i32, ptr %87, align 8, !tbaa !16
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [5001 x i32], ptr @ans, i64 0, i64 %89
  store i32 %85, ptr %90, align 4, !tbaa !5
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %91 = sext i32 %84 to i64
  %92 = icmp slt i64 %indvars.iv.next77, %91
  br i1 %92, label %.preheader, label %.preheader45, !llvm.loop !25

.lr.ph61:                                         ; preds = %.preheader45, %.lr.ph61
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %.lr.ph61 ], [ 0, %.preheader45 ]
  %93 = getelementptr inbounds [5001 x i32], ptr @ans, i64 0, i64 %indvars.iv80
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = shl nsw i32 %94, 1
  %96 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %95)
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %97 = load i32, ptr @q, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = icmp slt i64 %indvars.iv.next81, %98
  br i1 %99, label %.lr.ph61, label %.loopexit, !llvm.loop !26

._crit_edge65:                                    ; preds = %.loopexit, %0
  ret i32 0
}

; 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 @_ZSt4sortIP4EdgeEvT_S2_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5QueryEvT_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 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10, !13, !12}
!15 = distinct !{!15, !10}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTS5Query", !6, i64 0, !6, i64 4}
!18 = distinct !{!18, !10}
!19 = !{!20, !6, i64 8}
!20 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8}
!21 = !{!17, !6, i64 4}
!22 = distinct !{!22, !10}
!23 = !{!20, !6, i64 0}
!24 = !{!20, !6, i64 4}
!25 = distinct !{!25, !10}
!26 = distinct !{!26, !10}


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