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

; 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 [800001 x i32], align 16
@ans = external dso_local global [800001 x i32], align 16
@p = external dso_local global [800001 x %struct.Oper], align 16
@.str = external hidden unnamed_addr constant [4 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 %struct.Oper, 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 i32, align 4
  %13 = 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
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str)
  br label %15

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

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

21:                                               ; preds = %18
  %22 = 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 %7) #6
  %23 = getelementptr inbounds %struct.Oper, ptr %7, i32 0, i32 0
  store i32 0, ptr %23, align 4, !tbaa !9
  %24 = getelementptr inbounds %struct.Oper, ptr %7, i32 0, i32 1
  %25 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %25, ptr %24, align 4, !tbaa !11
  %26 = getelementptr inbounds %struct.Oper, ptr %7, i32 0, i32 2
  %27 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %27, ptr %26, align 4, !tbaa !12
  %28 = getelementptr inbounds %struct.Oper, ptr %7, i32 0, i32 3
  %29 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %29, ptr %28, align 4, !tbaa !13
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr @n, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [800001 x %struct.Oper], ptr @p, i64 0, i64 %32
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %33, ptr align 4 %7, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = load i32, ptr @tot, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr @tot, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [800001 x i32], ptr @que, i64 0, i64 %37
  store i32 %34, ptr %38, align 4, !tbaa !5
  br label %106

39:                                               ; preds = %18
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = icmp eq i32 %40, 2
  br i1 %41, label %42, label %104

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

104:                                              ; preds = %39
  br label %107

105:                                              ; preds = %42
  br label %106

106:                                              ; preds = %105, %21
  br label %15, !llvm.loop !15

107:                                              ; preds = %104, %15
  %108 = load i32, ptr @tot, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds i32, ptr @que, i64 %109
  %111 = getelementptr inbounds i32, ptr %110, i64 1
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %111)
  %112 = load i32, ptr @tot, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds i32, ptr @que, i64 %113
  %115 = getelementptr inbounds i32, ptr %114, i64 1
  %116 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %115)
  %117 = ptrtoint ptr %116 to i64
  %118 = sub i64 %117, ptrtoint (ptr @que to i64)
  %119 = sdiv exact i64 %118, 4
  %120 = sub nsw i64 %119, 1
  %121 = trunc i64 %120 to i32
  store i32 %121, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %145, %107
  %123 = load i32, ptr %12, align 4, !tbaa !5
  %124 = load i32, ptr @n, align 4, !tbaa !5
  %125 = icmp sle i32 %123, %124
  br i1 %125, label %127, label %126

126:                                              ; preds = %122
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %148

127:                                              ; preds = %122
  %128 = load i32, ptr @tot, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i32, ptr @que, i64 %129
  %131 = getelementptr inbounds i32, ptr %130, i64 1
  %132 = load i32, ptr %12, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [800001 x %struct.Oper], ptr @p, i64 0, i64 %133
  %135 = getelementptr inbounds %struct.Oper, ptr %134, i32 0, i32 2
  %136 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef getelementptr inbounds (i32, ptr @que, i64 1), ptr noundef %131, ptr noundef nonnull align 4 dereferenceable(4) %135)
  %137 = ptrtoint ptr %136 to i64
  %138 = sub i64 %137, ptrtoint (ptr @que to i64)
  %139 = sdiv exact i64 %138, 4
  %140 = trunc i64 %139 to i32
  %141 = load i32, ptr %12, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [800001 x %struct.Oper], ptr @p, i64 0, i64 %142
  %144 = getelementptr inbounds %struct.Oper, ptr %143, i32 0, i32 2
  store i32 %140, ptr %144, align 8, !tbaa !12
  br label %145

145:                                              ; preds = %127
  %146 = load i32, ptr %12, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  store i32 %147, ptr %12, align 4, !tbaa !5
  br label %122, !llvm.loop !17

148:                                              ; preds = %126
  %149 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z5solveii(i32 noundef 1, i32 noundef %149)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 1, ptr %13, align 4, !tbaa !5
  br label %150

150:                                              ; preds = %161, %148
  %151 = load i32, ptr %13, align 4, !tbaa !5
  %152 = load i32, ptr @m, align 4, !tbaa !5
  %153 = icmp sle i32 %151, %152
  br i1 %153, label %155, label %154

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

155:                                              ; preds = %150
  %156 = load i32, ptr %13, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [800001 x i32], ptr @ans, i64 0, i64 %157
  %159 = load i32, ptr %158, align 4, !tbaa !5
  %160 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %159)
  br label %161

161:                                              ; preds = %155
  %162 = load i32, ptr %13, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %13, align 4, !tbaa !5
  br label %150, !llvm.loop !18

164:                                              ; preds = %154
  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 [800001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [800001 x i32], align 16
@p = external dso_local global [800001 x %struct.Oper], align 16
@.str = external hidden unnamed_addr constant [4 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
  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
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %.lr.ph, label %._crit_edge

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

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

21:                                               ; preds = %.lr.ph
  %22 = 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)
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, -1
  store i32 %24, ptr %2, align 4, !tbaa !5
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = add nsw i32 %25, -1
  store i32 %26, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr @m, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr @m, align 4, !tbaa !5
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [800001 x %struct.Oper], ptr @p, i64 0, i64 %33
  store i32 1, ptr %34, align 16, !tbaa !5
  %.sroa.416.0..sroa_idx = getelementptr inbounds i8, ptr %34, i64 4
  store i32 %29, ptr %.sroa.416.0..sroa_idx, align 4, !tbaa !5
  %.sroa.517.0..sroa_idx = getelementptr inbounds i8, ptr %34, i64 8
  store i32 %30, ptr %.sroa.517.0..sroa_idx, align 8, !tbaa !5
  %.sroa.618.0..sroa_idx = getelementptr inbounds i8, ptr %34, i64 12
  store i32 %28, ptr %.sroa.618.0..sroa_idx, align 4, !tbaa !5
  %35 = add nsw i32 %31, 2
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [800001 x %struct.Oper], ptr @p, i64 0, i64 %36
  store i32 -1, ptr %37, align 16, !tbaa !5
  %.sroa.412.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 4
  store i32 %24, ptr %.sroa.412.0..sroa_idx, align 4, !tbaa !5
  %.sroa.513.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 8
  store i32 %30, ptr %.sroa.513.0..sroa_idx, align 8, !tbaa !5
  %.sroa.614.0..sroa_idx = getelementptr inbounds i8, ptr %37, i64 12
  store i32 %28, ptr %.sroa.614.0..sroa_idx, align 4, !tbaa !5
  %38 = add nsw i32 %31, 3
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [800001 x %struct.Oper], ptr @p, i64 0, i64 %39
  store i32 -1, ptr %40, align 16, !tbaa !5
  %.sroa.48.0..sroa_idx = getelementptr inbounds i8, ptr %40, i64 4
  store i32 %29, ptr %.sroa.48.0..sroa_idx, align 4, !tbaa !5
  %.sroa.59.0..sroa_idx = getelementptr inbounds i8, ptr %40, i64 8
  store i32 %26, ptr %.sroa.59.0..sroa_idx, align 8, !tbaa !5
  %.sroa.610.0..sroa_idx = getelementptr inbounds i8, ptr %40, i64 12
  store i32 %28, ptr %.sroa.610.0..sroa_idx, align 4, !tbaa !5
  %41 = add nsw i32 %31, 4
  store i32 %41, ptr @n, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [800001 x %struct.Oper], ptr @p, i64 0, i64 %42
  store i32 1, ptr %43, align 16, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %43, i64 4
  store i32 %24, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %43, i64 8
  store i32 %26, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %43, i64 12
  store i32 %28, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !5
  %44 = load i32, ptr @tot, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [800001 x i32], ptr @que, i64 0, i64 %46
  store i32 %26, ptr %47, align 4, !tbaa !5
  %48 = add nsw i32 %44, 2
  br label %49

49:                                               ; preds = %21, %10
  %.sink47 = phi i32 [ %48, %21 ], [ %20, %10 ]
  %.sink = phi i32 [ %30, %21 ], [ %13, %10 ]
  store i32 %.sink47, ptr @tot, align 4, !tbaa !5
  %50 = sext i32 %.sink47 to i64
  %51 = getelementptr inbounds [800001 x i32], ptr @que, i64 0, i64 %50
  store i32 %.sink, ptr %51, align 4, !tbaa !5
  %52 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %49, %.lr.ph, %0
  %54 = load i32, ptr @tot, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr @que, i64 %55
  %57 = getelementptr inbounds i8, ptr %56, i64 4
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %57)
  %58 = load i32, ptr @tot, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr @que, i64 %59
  %61 = getelementptr inbounds i8, ptr %60, i64 4
  %62 = call noundef ptr @_ZSt6uniqueIPiET_S1_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @que, i64 4), ptr noundef nonnull %61)
  %63 = ptrtoint ptr %62 to i64
  %64 = sub i64 %63, ptrtoint (ptr @que to i64)
  %65 = lshr exact i64 %64, 2
  %66 = trunc i64 %65 to i32
  %67 = add i32 %66, -1
  store i32 %67, ptr @tot, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %.not28 = icmp slt i32 %68, 1
  br i1 %.not28, label %._crit_edge32, label %.lr.ph31

._crit_edge32:                                    ; preds = %.lr.ph31, %._crit_edge
  %.lcssa = phi i32 [ %68, %._crit_edge ], [ %78, %.lr.ph31 ]
  call void @_Z5solveii(i32 noundef 1, i32 noundef %.lcssa)
  %69 = load i32, ptr @m, align 4, !tbaa !5
  %.not2633 = icmp slt i32 %69, 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 ]
  %70 = load i32, ptr @tot, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @que, i64 4), i64 %71
  %72 = getelementptr inbounds [800001 x %struct.Oper], ptr @p, i64 0, i64 %indvars.iv, i32 2
  %73 = 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) %72)
  %74 = ptrtoint ptr %73 to i64
  %75 = sub i64 %74, ptrtoint (ptr @que to i64)
  %76 = lshr exact i64 %75, 2
  %77 = trunc i64 %76 to i32
  store i32 %77, ptr %72, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %78 = load i32, ptr @n, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %.not.not = icmp slt i64 %indvars.iv, %79
  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 %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 ]
  %80 = getelementptr inbounds [800001 x i32], ptr @ans, i64 0, i64 %indvars.iv40
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %81)
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %83 = load i32, ptr @m, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %.not26.not = icmp slt i64 %indvars.iv40, %84
  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,SROAPass,SimplifyCFGPass,TailCallElimPass