; LLVM IR from tangjz/acm-icpc :: self_training/2015-02-07 (J)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@fa = external dso_local global [100001 x i32], align 16
@u = external dso_local global [100001 x i32], align 16
@v = external dso_local global [100001 x i32], align 16
@query = external dso_local global [100001 x [3 x i32]], align 16
@ans = external dso_local global [100001 x i32], align 16
@vis = external dso_local global [100001 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = 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 [2 x i8], align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %25, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @m, align 4, !tbaa !5
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr @u, i64 %19
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr @v, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %20, ptr noundef %23)
  br label %25

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

28:                                               ; preds = %16
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %81, %28
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = load i32, ptr @t, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #4
  %36 = getelementptr inbounds [2 x i8], ptr %6, i64 0, i64 0
  %37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %36)
  %38 = getelementptr inbounds [2 x i8], ptr %6, i64 0, i64 0
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %40, 81
  br i1 %41, label %42, label %58

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

58:                                               ; preds = %35
  %59 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %61
  %63 = load i8, ptr %62, align 1, !tbaa !12, !range !14, !noundef !15
  %64 = trunc i8 %63 to i1
  br i1 %64, label %65, label %70

65:                                               ; preds = %58
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %67
  %69 = getelementptr inbounds [3 x i32], ptr %68, i64 0, i64 0
  store i32 2, ptr %69, align 4, !tbaa !5
  br label %79

70:                                               ; preds = %58
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %73
  %75 = getelementptr inbounds [3 x i32], ptr %74, i64 0, i64 1
  store i32 %71, ptr %75, align 4, !tbaa !5
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %77
  store i8 1, ptr %78, align 1, !tbaa !12
  br label %79

79:                                               ; preds = %70, %65
  br label %80

80:                                               ; preds = %79, %42
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %3, align 4, !tbaa !5
  br label %30, !llvm.loop !16

84:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %95, %84
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = icmp sle i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %98

90:                                               ; preds = %85
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = load i32, ptr %7, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %93
  store i32 %91, ptr %94, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %90
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %7, align 4, !tbaa !5
  br label %85, !llvm.loop !17

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

99:                                               ; preds = %124, %98
  %100 = load i32, ptr %8, align 4, !tbaa !5
  %101 = load i32, ptr @m, align 4, !tbaa !5
  %102 = icmp sle i32 %100, %101
  br i1 %102, label %104, label %103

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

104:                                              ; preds = %99
  %105 = load i32, ptr %8, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %106
  %108 = load i8, ptr %107, align 1, !tbaa !12, !range !14, !noundef !15
  %109 = trunc i8 %108 to i1
  br i1 %109, label %123, label %110

110:                                              ; preds = %104
  %111 = load i32, ptr %8, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = call noundef i32 @_Z4findi(i32 noundef %114)
  %116 = load i32, ptr %8, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [100001 x i32], ptr @u, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = call noundef i32 @_Z4findi(i32 noundef %119)
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %121
  store i32 %115, ptr %122, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %110, %104
  br label %124

124:                                              ; preds = %123
  %125 = load i32, ptr %8, align 4, !tbaa !5
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %8, align 4, !tbaa !5
  br label %99, !llvm.loop !18

127:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %128 = load i32, ptr @t, align 4, !tbaa !5
  store i32 %128, ptr %9, align 4, !tbaa !5
  br label %129

129:                                              ; preds = %188, %127
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = icmp sgt i32 %130, 0
  br i1 %131, label %133, label %132

132:                                              ; preds = %129
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %191

133:                                              ; preds = %129
  %134 = load i32, ptr %9, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %135
  %137 = getelementptr inbounds [3 x i32], ptr %136, i64 0, i64 0
  %138 = load i32, ptr %137, align 4, !tbaa !5
  %139 = icmp eq i32 %138, 1
  br i1 %139, label %140, label %158

140:                                              ; preds = %133
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %142
  %144 = getelementptr inbounds [3 x i32], ptr %143, i64 0, i64 1
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = call noundef i32 @_Z4findi(i32 noundef %145)
  %147 = load i32, ptr %9, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %148
  %150 = getelementptr inbounds [3 x i32], ptr %149, i64 0, i64 2
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = call noundef i32 @_Z4findi(i32 noundef %151)
  %153 = icmp eq i32 %146, %152
  %154 = zext i1 %153 to i32
  %155 = load i32, ptr %9, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %156
  store i32 %154, ptr %157, align 4, !tbaa !5
  br label %187

158:                                              ; preds = %133
  %159 = load i32, ptr %9, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %160
  %162 = getelementptr inbounds [3 x i32], ptr %161, i64 0, i64 0
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = icmp ne i32 %163, 0
  br i1 %164, label %186, label %165

165:                                              ; preds = %158
  %166 = load i32, ptr %9, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %167
  %169 = getelementptr inbounds [3 x i32], ptr %168, i64 0, i64 1
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %171
  %173 = load i32, ptr %172, align 4, !tbaa !5
  %174 = call noundef i32 @_Z4findi(i32 noundef %173)
  %175 = load i32, ptr %9, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %176
  %178 = getelementptr inbounds [3 x i32], ptr %177, i64 0, i64 1
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [100001 x i32], ptr @u, i64 0, i64 %180
  %182 = load i32, ptr %181, align 4, !tbaa !5
  %183 = call noundef i32 @_Z4findi(i32 noundef %182)
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %184
  store i32 %174, ptr %185, align 4, !tbaa !5
  br label %186

186:                                              ; preds = %165, %158
  br label %187

187:                                              ; preds = %186, %140
  br label %188

188:                                              ; preds = %187
  %189 = load i32, ptr %9, align 4, !tbaa !5
  %190 = add nsw i32 %189, -1
  store i32 %190, ptr %9, align 4, !tbaa !5
  br label %129, !llvm.loop !19

191:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %192

192:                                              ; preds = %211, %191
  %193 = load i32, ptr %10, align 4, !tbaa !5
  %194 = load i32, ptr @t, align 4, !tbaa !5
  %195 = icmp sle i32 %193, %194
  br i1 %195, label %197, label %196

196:                                              ; preds = %192
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %214

197:                                              ; preds = %192
  %198 = load i32, ptr %10, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %199
  %201 = getelementptr inbounds [3 x i32], ptr %200, i64 0, i64 0
  %202 = load i32, ptr %201, align 4, !tbaa !5
  %203 = icmp eq i32 %202, 1
  br i1 %203, label %204, label %210

204:                                              ; preds = %197
  %205 = load i32, ptr %10, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %206
  %208 = load i32, ptr %207, align 4, !tbaa !5
  %209 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %208)
  br label %210

210:                                              ; preds = %204, %197
  br label %211

211:                                              ; preds = %210
  %212 = load i32, ptr %10, align 4, !tbaa !5
  %213 = add nsw i32 %212, 1
  store i32 %213, ptr %10, align 4, !tbaa !5
  br label %192, !llvm.loop !20

214:                                              ; preds = %196
  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

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 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@t = external dso_local global i32, align 4
@fa = external dso_local local_unnamed_addr global [100001 x i32], align 16
@u = external dso_local global [100001 x i32], align 16
@v = external dso_local global [100001 x i32], align 16
@query = external dso_local local_unnamed_addr global [100001 x [3 x i32]], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i32], align 16
@vis = external dso_local local_unnamed_addr global [100001 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = 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 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [2 x i8], align 1
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %5 = load i32, ptr @m, align 4, !tbaa !5
  %.not46 = icmp slt i32 %5, 1
  br i1 %.not46, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @t)
  %7 = load i32, ptr @t, align 4, !tbaa !5
  %.not3948 = icmp slt i32 %7, 1
  br i1 %.not3948, label %.preheader45, label %.lr.ph51

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

.preheader45:                                     ; preds = %41, %._crit_edge
  %13 = phi i32 [ %7, %._crit_edge ], [ %42, %41 ]
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %.not4052 = icmp slt i32 %14, 1
  br i1 %.not4052, label %.preheader44, label %.lr.ph54.preheader

.lr.ph54.preheader:                               ; preds = %.preheader45
  %15 = add nuw i32 %14, 1
  %wide.trip.count = zext i32 %15 to i64
  %16 = zext nneg i32 %14 to i64
  %min.iters.check = icmp ult i32 %14, 8
  br i1 %min.iters.check, label %.lr.ph54.preheader87, label %vector.ph

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

vector.ph:                                        ; preds = %.lr.ph54.preheader
  %n.vec = and i64 %16, 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
  %17 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %offset.idx
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  store <4 x i32> %vec.ind, ptr %17, align 4, !tbaa !5
  store <4 x i32> %step.add, ptr %18, 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>
  %19 = icmp eq i64 %index.next, %n.vec
  br i1 %19, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %16
  br i1 %cmp.n, label %.preheader44, label %.lr.ph54.preheader87

.lr.ph51:                                         ; preds = %._crit_edge, %41
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %41 ], [ 1, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %3)
  %21 = load i8, ptr %3, align 1, !tbaa !14
  %22 = icmp eq i8 %21, 81
  br i1 %22, label %23, label %30

23:                                               ; preds = %.lr.ph51
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %25 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %indvars.iv67
  store i32 1, ptr %25, align 4, !tbaa !5
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %25, i64 4
  store i32 %26, ptr %27, align 4, !tbaa !5
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %25, i64 8
  store i32 %28, ptr %29, align 4, !tbaa !5
  br label %41

30:                                               ; preds = %.lr.ph51
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !15, !range !17, !noundef !18
  %36 = trunc nuw i8 %35 to i1
  br i1 %36, label %37, label %39

37:                                               ; preds = %30
  %38 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %indvars.iv67
  store i32 2, ptr %38, align 4, !tbaa !5
  br label %41

39:                                               ; preds = %30
  %40 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %indvars.iv67, i64 1
  store i32 %32, ptr %40, align 4, !tbaa !5
  store i8 1, ptr %34, align 1, !tbaa !15
  br label %41

41:                                               ; preds = %37, %39, %23
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %42 = load i32, ptr @t, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %.not39.not = icmp slt i64 %indvars.iv67, %43
  br i1 %.not39.not, label %.lr.ph51, label %.preheader45, !llvm.loop !19

.preheader44:                                     ; preds = %.lr.ph54, %middle.block, %.preheader45
  %44 = load i32, ptr @m, align 4, !tbaa !5
  %.not4155 = icmp slt i32 %44, 1
  br i1 %.not4155, label %._crit_edge58, label %.lr.ph57

.lr.ph54:                                         ; preds = %.lr.ph54.preheader87, %.lr.ph54
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %.lr.ph54 ], [ %indvars.iv70.ph, %.lr.ph54.preheader87 ]
  %45 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %indvars.iv70
  %46 = trunc nuw nsw i64 %indvars.iv70 to i32
  store i32 %46, ptr %45, align 4, !tbaa !5
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next71, %wide.trip.count
  br i1 %exitcond.not, label %.preheader44, label %.lr.ph54, !llvm.loop !20

._crit_edge58.loopexit:                           ; preds = %63
  %.pre82 = load i32, ptr @t, align 4, !tbaa !5
  br label %._crit_edge58

._crit_edge58:                                    ; preds = %._crit_edge58.loopexit, %.preheader44
  %47 = phi i32 [ %.pre82, %._crit_edge58.loopexit ], [ %13, %.preheader44 ]
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph61.preheader, label %._crit_edge65

.lr.ph61.preheader:                               ; preds = %._crit_edge58
  %49 = zext nneg i32 %47 to i64
  br label %.lr.ph61

.lr.ph57:                                         ; preds = %.preheader44, %63
  %50 = phi i32 [ %64, %63 ], [ %44, %.preheader44 ]
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %63 ], [ 1, %.preheader44 ]
  %51 = getelementptr inbounds [100001 x i8], ptr @vis, i64 0, i64 %indvars.iv73
  %52 = load i8, ptr %51, align 1, !tbaa !15, !range !17, !noundef !18
  %53 = trunc nuw i8 %52 to i1
  br i1 %53, label %63, label %54

54:                                               ; preds = %.lr.ph57
  %55 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %indvars.iv73
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = call noundef i32 @_Z4findi(i32 noundef %56)
  %58 = getelementptr inbounds [100001 x i32], ptr @u, i64 0, i64 %indvars.iv73
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = call noundef i32 @_Z4findi(i32 noundef %59)
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %61
  store i32 %57, ptr %62, align 4, !tbaa !5
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %.lr.ph57, %54
  %64 = phi i32 [ %50, %.lr.ph57 ], [ %.pre, %54 ]
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %65 = sext i32 %64 to i64
  %.not41.not = icmp slt i64 %indvars.iv73, %65
  br i1 %.not41.not, label %.lr.ph57, label %._crit_edge58.loopexit, !llvm.loop !21

.preheader:                                       ; preds = %92
  %.pre83 = load i32, ptr @t, align 4, !tbaa !5
  %.not4262 = icmp slt i32 %.pre83, 1
  br i1 %.not4262, label %._crit_edge65, label %.lr.ph64

.lr.ph61:                                         ; preds = %.lr.ph61.preheader, %92
  %indvars.iv76 = phi i64 [ %49, %.lr.ph61.preheader ], [ %indvars.iv.next77, %92 ]
  %66 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %indvars.iv76
  %67 = load i32, ptr %66, align 4, !tbaa !5
  switch i32 %67, label %92 [
    i32 1, label %68
    i32 0, label %78
  ]

68:                                               ; preds = %.lr.ph61
  %69 = getelementptr inbounds i8, ptr %66, i64 4
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = call noundef i32 @_Z4findi(i32 noundef %70)
  %72 = getelementptr inbounds i8, ptr %66, i64 8
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = call noundef i32 @_Z4findi(i32 noundef %73)
  %75 = icmp eq i32 %71, %74
  %76 = zext i1 %75 to i32
  %77 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %indvars.iv76
  store i32 %76, ptr %77, align 4, !tbaa !5
  br label %92

78:                                               ; preds = %.lr.ph61
  %79 = getelementptr inbounds i8, ptr %66, i64 4
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100001 x i32], ptr @v, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = call noundef i32 @_Z4findi(i32 noundef %83)
  %85 = load i32, ptr %79, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [100001 x i32], ptr @u, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = call noundef i32 @_Z4findi(i32 noundef %88)
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100001 x i32], ptr @fa, i64 0, i64 %90
  store i32 %84, ptr %91, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %.lr.ph61, %68, %78
  %indvars.iv.next77 = add nsw i64 %indvars.iv76, -1
  %93 = icmp sgt i64 %indvars.iv76, 1
  br i1 %93, label %.lr.ph61, label %.preheader, !llvm.loop !22

._crit_edge65:                                    ; preds = %102, %._crit_edge58, %.preheader
  ret i32 0

.lr.ph64:                                         ; preds = %.preheader, %102
  %94 = phi i32 [ %103, %102 ], [ %.pre83, %.preheader ]
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %102 ], [ 1, %.preheader ]
  %95 = getelementptr inbounds [100001 x [3 x i32]], ptr @query, i64 0, i64 %indvars.iv79
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = icmp eq i32 %96, 1
  br i1 %97, label %98, label %102

98:                                               ; preds = %.lr.ph64
  %99 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %indvars.iv79
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %100)
  %.pre84 = load i32, ptr @t, align 4, !tbaa !5
  br label %102

102:                                              ; preds = %.lr.ph64, %98
  %103 = phi i32 [ %94, %.lr.ph64 ], [ %.pre84, %98 ]
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %104 = sext i32 %103 to i64
  %.not42.not = icmp slt i64 %indvars.iv79, %104
  br i1 %.not42.not, label %.lr.ph64, label %._crit_edge65, !llvm.loop !23
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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 = !{!7, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10, !13, !12}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
!23 = distinct !{!23, !10}


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