; LLVM IR from tangjz/acm-icpc :: lydsy (1176)

; 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.Oper = type { i32, i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@que = external dso_local global [200001 x i32], align 16
@ans = external dso_local global [10001 x i32], align 16
@p = external dso_local global [200001 x %struct.Oper], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solveii(i32 noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 %struct.Oper, align 4
  %9 = alloca %struct.Oper, align 4
  %10 = alloca %struct.Oper, align 4
  %11 = alloca %struct.Oper, align 4
  %12 = alloca %struct.Oper, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %7)
  br label %16

16:                                               ; preds = %119, %0
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2)
  %18 = icmp eq i32 %17, 1
  br i1 %18, label %19, label %120

19:                                               ; preds = %16
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 1
  br i1 %21, label %22, label %40

22:                                               ; preds = %19
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  %24 = getelementptr inbounds %struct.Oper, ptr %8, i32 0, i32 0
  store i32 0, ptr %24, align 4, !tbaa !9
  %25 = getelementptr inbounds %struct.Oper, ptr %8, i32 0, i32 1
  %26 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %26, ptr %25, align 4, !tbaa !11
  %27 = getelementptr inbounds %struct.Oper, ptr %8, i32 0, i32 2
  %28 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %28, ptr %27, align 4, !tbaa !12
  %29 = getelementptr inbounds %struct.Oper, ptr %8, i32 0, i32 3
  %30 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %30, ptr %29, align 4, !tbaa !13
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr @n, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %34, ptr align 4 %8, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = load i32, ptr @tot, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr @tot, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [200001 x i32], ptr @que, i64 0, i64 %38
  store i32 %35, ptr %39, align 4, !tbaa !5
  br label %119

40:                                               ; preds = %19
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = icmp eq i32 %41, 2
  br i1 %42, label %43, label %117

43:                                               ; preds = %40
  %44 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6)
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr %3, align 4, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr %4, align 4, !tbaa !5
  %49 = load i32, ptr @m, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  %51 = getelementptr inbounds %struct.Oper, ptr %9, i32 0, i32 0
  store i32 1, ptr %51, align 4, !tbaa !9
  %52 = getelementptr inbounds %struct.Oper, ptr %9, i32 0, i32 1
  %53 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %53, ptr %52, align 4, !tbaa !11
  %54 = getelementptr inbounds %struct.Oper, ptr %9, i32 0, i32 2
  %55 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %55, ptr %54, align 4, !tbaa !12
  %56 = getelementptr inbounds %struct.Oper, ptr %9, i32 0, i32 3
  %57 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %57, ptr %56, align 4, !tbaa !13
  %58 = load i32, ptr @n, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr @n, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %60
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %61, ptr align 4 %9, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  %62 = getelementptr inbounds %struct.Oper, ptr %10, i32 0, i32 0
  store i32 -1, ptr %62, align 4, !tbaa !9
  %63 = getelementptr inbounds %struct.Oper, ptr %10, i32 0, i32 1
  %64 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %64, ptr %63, align 4, !tbaa !11
  %65 = getelementptr inbounds %struct.Oper, ptr %10, i32 0, i32 2
  %66 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %66, ptr %65, align 4, !tbaa !12
  %67 = getelementptr inbounds %struct.Oper, ptr %10, i32 0, i32 3
  %68 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %68, ptr %67, align 4, !tbaa !13
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr @n, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %71
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %72, ptr align 4 %10, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #6
  %73 = getelementptr inbounds %struct.Oper, ptr %11, i32 0, i32 0
  store i32 -1, ptr %73, align 4, !tbaa !9
  %74 = getelementptr inbounds %struct.Oper, ptr %11, i32 0, i32 1
  %75 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %75, ptr %74, align 4, !tbaa !11
  %76 = getelementptr inbounds %struct.Oper, ptr %11, i32 0, i32 2
  %77 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %77, ptr %76, align 4, !tbaa !12
  %78 = getelementptr inbounds %struct.Oper, ptr %11, i32 0, i32 3
  %79 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %79, ptr %78, align 4, !tbaa !13
  %80 = load i32, ptr @n, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr @n, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %82
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %83, ptr align 4 %11, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #6
  %84 = getelementptr inbounds %struct.Oper, ptr %12, i32 0, i32 0
  store i32 1, ptr %84, align 4, !tbaa !9
  %85 = getelementptr inbounds %struct.Oper, ptr %12, i32 0, i32 1
  %86 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %86, ptr %85, align 4, !tbaa !11
  %87 = getelementptr inbounds %struct.Oper, ptr %12, i32 0, i32 2
  %88 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %88, ptr %87, align 4, !tbaa !12
  %89 = getelementptr inbounds %struct.Oper, ptr %12, i32 0, i32 3
  %90 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %90, ptr %89, align 4, !tbaa !13
  %91 = load i32, ptr @n, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr @n, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %93
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %94, ptr align 4 %12, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #6
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = load i32, ptr @tot, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr @tot, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [200001 x i32], ptr @que, i64 0, i64 %98
  store i32 %95, ptr %99, align 4, !tbaa !5
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = load i32, ptr @tot, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr @tot, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [200001 x i32], ptr @que, i64 0, i64 %103
  store i32 %100, ptr %104, align 4, !tbaa !5
  %105 = load i32, ptr %5, align 4, !tbaa !5
  %106 = load i32, ptr %3, align 4, !tbaa !5
  %107 = sub nsw i32 %105, %106
  %108 = load i32, ptr %6, align 4, !tbaa !5
  %109 = load i32, ptr %4, align 4, !tbaa !5
  %110 = sub nsw i32 %108, %109
  %111 = mul nsw i32 %107, %110
  %112 = load i32, ptr %7, align 4, !tbaa !5
  %113 = mul nsw i32 %111, %112
  %114 = load i32, ptr @m, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [10001 x i32], ptr @ans, i64 0, i64 %115
  store i32 %113, ptr %116, align 4, !tbaa !5
  br label %118

117:                                              ; preds = %40
  br label %120

118:                                              ; preds = %43
  br label %119

119:                                              ; preds = %118, %22
  br label %16, !llvm.loop !15

120:                                              ; preds = %117, %16
  %121 = load i32, ptr @tot, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds i32, ptr @que, i64 %122
  %124 = getelementptr inbounds i32, ptr %123, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %124)
  %125 = load i32, ptr @tot, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds i32, ptr @que, i64 %126
  %128 = getelementptr inbounds i32, ptr %127, i64 1
  %129 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %128)
  %130 = ptrtoint ptr %129 to i64
  %131 = sub i64 %130, ptrtoint (ptr @que to i64)
  %132 = sdiv exact i64 %131, 4
  %133 = sub nsw i64 %132, 1
  %134 = trunc i64 %133 to i32
  store i32 %134, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %158, %120
  %136 = load i32, ptr %13, align 4, !tbaa !5
  %137 = load i32, ptr @n, align 4, !tbaa !5
  %138 = icmp sle i32 %136, %137
  br i1 %138, label %140, label %139

139:                                              ; preds = %135
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %161

140:                                              ; preds = %135
  %141 = load i32, ptr @tot, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds i32, ptr @que, i64 %142
  %144 = getelementptr inbounds i32, ptr %143, i64 1
  %145 = load i32, ptr %13, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %146
  %148 = getelementptr inbounds %struct.Oper, ptr %147, i32 0, i32 2
  %149 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %144, ptr noundef nonnull align 4 dereferenceable(4) %148)
  %150 = ptrtoint ptr %149 to i64
  %151 = sub i64 %150, ptrtoint (ptr @que to i64)
  %152 = sdiv exact i64 %151, 4
  %153 = trunc i64 %152 to i32
  %154 = load i32, ptr %13, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %155
  %157 = getelementptr inbounds %struct.Oper, ptr %156, i32 0, i32 2
  store i32 %153, ptr %157, align 8, !tbaa !12
  br label %158

158:                                              ; preds = %140
  %159 = load i32, ptr %13, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %13, align 4, !tbaa !5
  br label %135, !llvm.loop !17

161:                                              ; preds = %139
  %162 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z5solveii(i32 noundef 1, i32 noundef %162)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 1, ptr %14, align 4, !tbaa !5
  br label %163

163:                                              ; preds = %174, %161
  %164 = load i32, ptr %14, align 4, !tbaa !5
  %165 = load i32, ptr @m, align 4, !tbaa !5
  %166 = icmp sle i32 %164, %165
  br i1 %166, label %168, label %167

167:                                              ; preds = %163
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %177

168:                                              ; preds = %163
  %169 = load i32, ptr %14, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [10001 x i32], ptr @ans, i64 0, i64 %170
  %172 = load i32, ptr %171, align 4, !tbaa !5
  %173 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %172)
  br label %174

174:                                              ; preds = %168
  %175 = load i32, ptr %14, align 4, !tbaa !5
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %14, align 4, !tbaa !5
  br label %163, !llvm.loop !18

177:                                              ; preds = %167
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  ret i32 0
}

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

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { 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 #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Oper", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 12}
!14 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5, i64 12, i64 4, !5}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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.Oper = type { i32, i32, i32, i32 }

@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local global [200001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [10001 x i32], align 16
@p = external dso_local global [200001 x %struct.Oper], align 16
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solveii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %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
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %6)
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %9 = icmp eq i32 %8, 1
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %61
  %10 = load i32, ptr %1, align 4, !tbaa !5
  switch i32 %10, label %._crit_edge [
    i32 1, label %11
    i32 2, label %24
  ]

11:                                               ; preds = %.lr.ph
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr @n, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %18
  store i32 0, ptr %19, align 16, !tbaa !5
  %.sroa.420.0..sroa_idx = getelementptr inbounds i8, ptr %19, i64 4
  store i32 %13, ptr %.sroa.420.0..sroa_idx, align 4, !tbaa !5
  %.sroa.521.0..sroa_idx = getelementptr inbounds i8, ptr %19, i64 8
  store i32 %14, ptr %.sroa.521.0..sroa_idx, align 8, !tbaa !5
  %.sroa.622.0..sroa_idx = getelementptr inbounds i8, ptr %19, i64 12
  store i32 %15, ptr %.sroa.622.0..sroa_idx, align 4, !tbaa !5
  %20 = load i32, ptr @tot, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr @tot, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [200001 x i32], ptr @que, i64 0, i64 %22
  store i32 %14, ptr %23, align 4, !tbaa !5
  br label %61

24:                                               ; preds = %.lr.ph
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr %2, align 4, !tbaa !5
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = add nsw i32 %28, -1
  store i32 %29, ptr %3, align 4, !tbaa !5
  %30 = load i32, ptr @m, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @m, align 4, !tbaa !5
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %36
  store i32 1, ptr %37, align 16, !tbaa !5
  %.sroa.416.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 4
  store i32 %32, ptr %.sroa.416.0..sroa_idx, align 4, !tbaa !5
  %.sroa.517.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 8
  store i32 %33, ptr %.sroa.517.0..sroa_idx, align 8, !tbaa !5
  %.sroa.618.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 12
  store i32 %31, ptr %.sroa.618.0..sroa_idx, align 4, !tbaa !5
  %38 = add nsw i32 %34, 2
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %39
  store i32 -1, ptr %40, align 16, !tbaa !5
  %.sroa.412.0..sroa_idx = getelementptr inbounds i8, ptr %40, i64 4
  store i32 %27, ptr %.sroa.412.0..sroa_idx, align 4, !tbaa !5
  %.sroa.513.0..sroa_idx = getelementptr inbounds i8, ptr %40, i64 8
  store i32 %33, ptr %.sroa.513.0..sroa_idx, align 8, !tbaa !5
  %.sroa.614.0..sroa_idx = getelementptr inbounds i8, ptr %40, i64 12
  store i32 %31, ptr %.sroa.614.0..sroa_idx, align 4, !tbaa !5
  %41 = add nsw i32 %34, 3
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %42
  store i32 -1, ptr %43, align 16, !tbaa !5
  %.sroa.48.0..sroa_idx = getelementptr inbounds i8, ptr %43, i64 4
  store i32 %32, ptr %.sroa.48.0..sroa_idx, align 4, !tbaa !5
  %.sroa.59.0..sroa_idx = getelementptr inbounds i8, ptr %43, i64 8
  store i32 %29, ptr %.sroa.59.0..sroa_idx, align 8, !tbaa !5
  %.sroa.610.0..sroa_idx = getelementptr inbounds i8, ptr %43, i64 12
  store i32 %31, ptr %.sroa.610.0..sroa_idx, align 4, !tbaa !5
  %44 = add nsw i32 %34, 4
  store i32 %44, ptr @n, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %45
  store i32 1, ptr %46, align 16, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %46, i64 4
  store i32 %27, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %46, i64 8
  store i32 %29, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %46, i64 12
  store i32 %31, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !5
  %47 = load i32, ptr @tot, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [200001 x i32], ptr @que, i64 0, i64 %49
  store i32 %29, ptr %50, align 4, !tbaa !5
  %51 = add nsw i32 %47, 2
  store i32 %51, ptr @tot, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [200001 x i32], ptr @que, i64 0, i64 %52
  store i32 %33, ptr %53, align 4, !tbaa !5
  %54 = sub nsw i32 %32, %27
  %55 = sub nsw i32 %33, %29
  %56 = mul nsw i32 %55, %54
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = mul nsw i32 %56, %57
  %59 = sext i32 %31 to i64
  %60 = getelementptr inbounds [10001 x i32], ptr @ans, i64 0, i64 %59
  store i32 %58, ptr %60, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %24, %11
  %62 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %63 = icmp eq i32 %62, 1
  br i1 %63, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %61, %.lr.ph, %0
  %64 = load i32, ptr @tot, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr @que, i64 %65
  %67 = getelementptr inbounds i8, ptr %66, i64 4
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %67)
  %68 = load i32, ptr @tot, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr @que, i64 %69
  %71 = getelementptr inbounds i8, ptr %70, i64 4
  %72 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %71)
  %73 = ptrtoint ptr %72 to i64
  %74 = sub i64 %73, ptrtoint (ptr @que to i64)
  %75 = lshr exact i64 %74, 2
  %76 = trunc i64 %75 to i32
  %77 = add i32 %76, -1
  store i32 %77, ptr @tot, align 4, !tbaa !5
  %78 = load i32, ptr @n, align 4, !tbaa !5
  %.not28 = icmp slt i32 %78, 1
  br i1 %.not28, label %._crit_edge32, label %.lr.ph31

._crit_edge32:                                    ; preds = %.lr.ph31, %._crit_edge
  %.lcssa = phi i32 [ %78, %._crit_edge ], [ %88, %.lr.ph31 ]
  call void @_Z5solveii(i32 noundef 1, i32 noundef %.lcssa)
  %79 = load i32, ptr @m, align 4, !tbaa !5
  %.not2633 = icmp slt i32 %79, 1
  br i1 %.not2633, label %._crit_edge37, label %.lr.ph36

.lr.ph31:                                         ; preds = %._crit_edge, %.lr.ph31
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph31 ], [ 1, %._crit_edge ]
  %80 = load i32, ptr @tot, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @que, i64 4), i64 %81
  %82 = getelementptr inbounds [200001 x %struct.Oper], ptr @p, i64 0, i64 %indvars.iv, i32 2
  %83 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %gep, ptr noundef nonnull align 4 dereferenceable(4) %82)
  %84 = ptrtoint ptr %83 to i64
  %85 = sub i64 %84, ptrtoint (ptr @que to i64)
  %86 = lshr exact i64 %85, 2
  %87 = trunc i64 %86 to i32
  store i32 %87, ptr %82, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %88 = load i32, ptr @n, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %.not.not = icmp slt i64 %indvars.iv, %89
  br i1 %.not.not, label %.lr.ph31, label %._crit_edge32, !llvm.loop !13

._crit_edge37:                                    ; preds = %.lr.ph36, %._crit_edge32
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0

.lr.ph36:                                         ; preds = %._crit_edge32, %.lr.ph36
  %indvars.iv40 = phi i64 [ %indvars.iv.next41, %.lr.ph36 ], [ 1, %._crit_edge32 ]
  %90 = getelementptr inbounds [10001 x i32], ptr @ans, i64 0, i64 %indvars.iv40
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %91)
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %93 = load i32, ptr @m, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %.not26.not = icmp slt i64 %indvars.iv40, %94
  br i1 %.not26.not, label %.lr.ph36, label %._crit_edge37, !llvm.loop !14
}

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

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #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 = !{!"_ZTS4Oper", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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