; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/340 Division 2/Problem E (E)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [100100 x i32], align 16
@s = external dso_local global [100100 x i32], align 16
@res = external dso_local global [100100 x i64], align 16
@ans = external dso_local global i64, align 8
@q = external dso_local global [100100 x %struct.query], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addi(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6removei(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4add2i(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7remove2i(i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.query, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m, ptr noundef @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %13

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

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

18:                                               ; preds = %13
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %20
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %21)
  br label %23

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %13, !llvm.loop !9

26:                                               ; preds = %17
  %27 = load i32, ptr getelementptr inbounds ([100100 x i32], ptr @a, i64 0, i64 1), align 4, !tbaa !5
  store i32 %27, ptr getelementptr inbounds ([100100 x i32], ptr @s, i64 0, i64 1), align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %47, %26
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp sle i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %50

33:                                               ; preds = %28
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sub nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = xor i32 %38, %42
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %45
  store i32 %43, ptr %46, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %33
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !11

50:                                               ; preds = %32
  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
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %67, %50
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = load i32, ptr @m, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %70

56:                                               ; preds = %51
  %57 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %4, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #6
  %58 = getelementptr inbounds %struct.query, ptr %7, i32 0, i32 0
  %59 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %59, ptr %58, align 4, !tbaa !12
  %60 = getelementptr inbounds %struct.query, ptr %7, i32 0, i32 1
  %61 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %61, ptr %60, align 4, !tbaa !14
  %62 = getelementptr inbounds %struct.query, ptr %7, i32 0, i32 2
  %63 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %63, ptr %62, align 4, !tbaa !15
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100100 x %struct.query], ptr @q, i64 0, i64 %65
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %66, ptr align 4 %7, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #6
  br label %67

67:                                               ; preds = %56
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %6, align 4, !tbaa !5
  br label %51, !llvm.loop !17

70:                                               ; preds = %55
  %71 = load i32, ptr @m, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.query, ptr @q, i64 %72
  call void @_ZSt4sortIP5queryEvT_S2_(ptr noundef @q, ptr noundef %73)
  %74 = load i32, ptr @q, align 16, !tbaa !12
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %4, align 4, !tbaa !5
  %76 = load i32, ptr @q, align 16, !tbaa !12
  %77 = sub nsw i32 %76, 1
  store i32 %77, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %134, %70
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = load i32, ptr @m, align 4, !tbaa !5
  %81 = icmp slt i32 %79, %80
  br i1 %81, label %83, label %82

82:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %137

83:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %84 = load i32, ptr %8, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100100 x %struct.query], ptr @q, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.query, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 4, !tbaa !12
  store i32 %88, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %89 = load i32, ptr %8, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [100100 x %struct.query], ptr @q, i64 0, i64 %90
  %92 = getelementptr inbounds %struct.query, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !14
  store i32 %93, ptr %10, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %98, %83
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = load i32, ptr %9, align 4, !tbaa !5
  %97 = icmp slt i32 %95, %96
  br i1 %97, label %98, label %101

98:                                               ; preds = %94
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %4, align 4, !tbaa !5
  call void @_Z7remove2i(i32 noundef %99)
  br label %94, !llvm.loop !18

101:                                              ; preds = %94
  br label %102

102:                                              ; preds = %106, %101
  %103 = load i32, ptr %4, align 4, !tbaa !5
  %104 = load i32, ptr %9, align 4, !tbaa !5
  %105 = icmp sgt i32 %103, %104
  br i1 %105, label %106, label %109

106:                                              ; preds = %102
  %107 = load i32, ptr %4, align 4, !tbaa !5
  %108 = add nsw i32 %107, -1
  store i32 %108, ptr %4, align 4, !tbaa !5
  call void @_Z4add2i(i32 noundef %108)
  br label %102, !llvm.loop !19

109:                                              ; preds = %102
  br label %110

110:                                              ; preds = %114, %109
  %111 = load i32, ptr %5, align 4, !tbaa !5
  %112 = load i32, ptr %10, align 4, !tbaa !5
  %113 = icmp slt i32 %111, %112
  br i1 %113, label %114, label %117

114:                                              ; preds = %110
  %115 = load i32, ptr %5, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %5, align 4, !tbaa !5
  call void @_Z3addi(i32 noundef %116)
  br label %110, !llvm.loop !20

117:                                              ; preds = %110
  br label %118

118:                                              ; preds = %122, %117
  %119 = load i32, ptr %5, align 4, !tbaa !5
  %120 = load i32, ptr %10, align 4, !tbaa !5
  %121 = icmp sgt i32 %119, %120
  br i1 %121, label %122, label %125

122:                                              ; preds = %118
  %123 = load i32, ptr %5, align 4, !tbaa !5
  %124 = add nsw i32 %123, -1
  store i32 %124, ptr %5, align 4, !tbaa !5
  call void @_Z6removei(i32 noundef %123)
  br label %118, !llvm.loop !21

125:                                              ; preds = %118
  %126 = load i64, ptr @ans, align 8, !tbaa !22
  %127 = load i32, ptr %8, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [100100 x %struct.query], ptr @q, i64 0, i64 %128
  %130 = getelementptr inbounds %struct.query, ptr %129, i32 0, i32 2
  %131 = load i32, ptr %130, align 4, !tbaa !15
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [100100 x i64], ptr @res, i64 0, i64 %132
  store i64 %126, ptr %133, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %134

134:                                              ; preds = %125
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %8, align 4, !tbaa !5
  br label %78, !llvm.loop !24

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

138:                                              ; preds = %149, %137
  %139 = load i32, ptr %11, align 4, !tbaa !5
  %140 = load i32, ptr @m, align 4, !tbaa !5
  %141 = icmp slt i32 %139, %140
  br i1 %141, label %143, label %142

142:                                              ; preds = %138
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %152

143:                                              ; preds = %138
  %144 = load i32, ptr %11, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [100100 x i64], ptr @res, i64 0, i64 %145
  %147 = load i64, ptr %146, align 8, !tbaa !22
  %148 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %147)
  br label %149

149:                                              ; preds = %143
  %150 = load i32, ptr %11, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %11, align 4, !tbaa !5
  br label %138, !llvm.loop !25

152:                                              ; preds = %142
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  ret i32 0
}

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

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

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

; Function Attrs: 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) #4

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

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

attributes #0 = { mustprogress nounwind 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTS5query", !6, i64 0, !6, i64 4, !6, i64 8}
!14 = !{!13, !6, i64 4}
!15 = !{!13, !6, i64 8}
!16 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = !{!23, !23, i64 0}
!23 = !{!"long long", !7, i64 0}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.query = type { i32, i32, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [100100 x i32], align 16
@s = external dso_local local_unnamed_addr global [100100 x i32], align 16
@res = external dso_local local_unnamed_addr global [100100 x i64], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@q = external dso_local global [100100 x %struct.query], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6removei(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4add2i(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7remove2i(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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @k)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not38 = icmp slt i32 %4, 1
  br i1 %.not38, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %0
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  store i32 %5, ptr getelementptr inbounds (i8, ptr @s, i64 4), align 4, !tbaa !5
  br label %._crit_edge44

._crit_edge:                                      ; preds = %.lr.ph
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  store i32 %6, ptr getelementptr inbounds (i8, ptr @s, i64 4), align 4, !tbaa !5
  %.not3340 = icmp slt i32 %13, 2
  br i1 %.not3340, label %._crit_edge44, label %.lr.ph43.preheader

.lr.ph43.preheader:                               ; preds = %._crit_edge
  %7 = add nuw i32 %13, 1
  %wide.trip.count = zext i32 %7 to i64
  %8 = add nsw i64 %wide.trip.count, -2
  %9 = add nsw i64 %wide.trip.count, -3
  %xtraiter = and i64 %8, 3
  %10 = icmp ult i64 %9, 3
  br i1 %10, label %._crit_edge44.loopexit.unr-lcssa, label %.lr.ph43.preheader.new

.lr.ph43.preheader.new:                           ; preds = %.lr.ph43.preheader
  %unroll_iter = and i64 %8, -4
  br label %.lr.ph43

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

._crit_edge44.loopexit.unr-lcssa:                 ; preds = %.lr.ph43, %.lr.ph43.preheader
  %.unr = phi i32 [ %6, %.lr.ph43.preheader ], [ %37, %.lr.ph43 ]
  %indvars.iv65.unr = phi i64 [ 2, %.lr.ph43.preheader ], [ %indvars.iv.next66.3, %.lr.ph43 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge44, label %.lr.ph43.epil

.lr.ph43.epil:                                    ; preds = %._crit_edge44.loopexit.unr-lcssa, %.lr.ph43.epil
  %15 = phi i32 [ %18, %.lr.ph43.epil ], [ %.unr, %._crit_edge44.loopexit.unr-lcssa ]
  %indvars.iv65.epil = phi i64 [ %indvars.iv.next66.epil, %.lr.ph43.epil ], [ %indvars.iv65.unr, %._crit_edge44.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph43.epil ], [ 0, %._crit_edge44.loopexit.unr-lcssa ]
  %16 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %indvars.iv65.epil
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = xor i32 %17, %15
  %19 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %indvars.iv65.epil
  store i32 %18, ptr %19, align 4, !tbaa !5
  %indvars.iv.next66.epil = add nuw nsw i64 %indvars.iv65.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge44, label %.lr.ph43.epil, !llvm.loop !11

._crit_edge44:                                    ; preds = %._crit_edge44.loopexit.unr-lcssa, %.lr.ph43.epil, %._crit_edge.thread, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %20 = load i32, ptr @m, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph47, label %._crit_edge44.._crit_edge48_crit_edge

._crit_edge44.._crit_edge48_crit_edge:            ; preds = %._crit_edge44
  %.pre = sext i32 %20 to i64
  br label %._crit_edge48

.lr.ph43:                                         ; preds = %.lr.ph43, %.lr.ph43.preheader.new
  %22 = phi i32 [ %6, %.lr.ph43.preheader.new ], [ %37, %.lr.ph43 ]
  %indvars.iv65 = phi i64 [ 2, %.lr.ph43.preheader.new ], [ %indvars.iv.next66.3, %.lr.ph43 ]
  %niter = phi i64 [ 0, %.lr.ph43.preheader.new ], [ %niter.next.3, %.lr.ph43 ]
  %23 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %indvars.iv65
  %24 = load i32, ptr %23, align 8, !tbaa !5
  %25 = xor i32 %24, %22
  %26 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %indvars.iv65
  store i32 %25, ptr %26, align 8, !tbaa !5
  %indvars.iv.next66 = or disjoint i64 %indvars.iv65, 1
  %27 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %indvars.iv.next66
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = xor i32 %28, %25
  %30 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %indvars.iv.next66
  store i32 %29, ptr %30, align 4, !tbaa !5
  %indvars.iv.next66.1 = add nuw nsw i64 %indvars.iv65, 2
  %31 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %indvars.iv.next66.1
  %32 = load i32, ptr %31, align 8, !tbaa !5
  %33 = xor i32 %32, %29
  %34 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %indvars.iv.next66.1
  store i32 %33, ptr %34, align 8, !tbaa !5
  %indvars.iv.next66.2 = add nuw nsw i64 %indvars.iv65, 3
  %35 = getelementptr inbounds [100100 x i32], ptr @a, i64 0, i64 %indvars.iv.next66.2
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = xor i32 %36, %33
  %38 = getelementptr inbounds [100100 x i32], ptr @s, i64 0, i64 %indvars.iv.next66.2
  store i32 %37, ptr %38, align 4, !tbaa !5
  %indvars.iv.next66.3 = add nuw nsw i64 %indvars.iv65, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge44.loopexit.unr-lcssa, label %.lr.ph43, !llvm.loop !13

._crit_edge48:                                    ; preds = %.lr.ph47, %._crit_edge44.._crit_edge48_crit_edge
  %.pre-phi = phi i64 [ %.pre, %._crit_edge44.._crit_edge48_crit_edge ], [ %51, %.lr.ph47 ]
  %39 = getelementptr inbounds %struct.query, ptr @q, i64 %.pre-phi
  call void @_ZSt4sortIP5queryEvT_S2_(ptr noundef nonnull @q, ptr noundef nonnull %39)
  %40 = load i32, ptr @q, align 16, !tbaa !14
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %1, align 4, !tbaa !5
  %42 = add nsw i32 %40, -1
  store i32 %42, ptr %2, align 4, !tbaa !5
  %43 = load i32, ptr @m, align 4, !tbaa !5
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %.lr.ph58, label %._crit_edge61

.lr.ph47:                                         ; preds = %._crit_edge44, %.lr.ph47
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.lr.ph47 ], [ 0, %._crit_edge44 ]
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %46 = load i32, ptr %1, align 4, !tbaa !5
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = getelementptr inbounds [100100 x %struct.query], ptr @q, i64 0, i64 %indvars.iv68
  store i32 %46, ptr %48, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %48, i64 4
  store i32 %47, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %48, i64 8
  %49 = trunc nuw nsw i64 %indvars.iv68 to i32
  store i32 %49, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %50 = load i32, ptr @m, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = icmp slt i64 %indvars.iv.next69, %51
  br i1 %52, label %.lr.ph47, label %._crit_edge48, !llvm.loop !16

.preheader:                                       ; preds = %._crit_edge55
  %53 = icmp sgt i32 %87, 0
  br i1 %53, label %.lr.ph60, label %._crit_edge61

.lr.ph58:                                         ; preds = %._crit_edge48, %._crit_edge55
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %._crit_edge55 ], [ 0, %._crit_edge48 ]
  %54 = getelementptr inbounds [100100 x %struct.query], ptr @q, i64 0, i64 %indvars.iv71
  %55 = load i32, ptr %54, align 4, !tbaa !14
  %56 = getelementptr inbounds i8, ptr %54, i64 4
  %57 = load i32, ptr %56, align 4, !tbaa !17
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = icmp slt i32 %58, %55
  br i1 %59, label %.lr.ph51, label %.preheader36

.preheader36:                                     ; preds = %.lr.ph51, %.lr.ph58
  %60 = phi i32 [ %58, %.lr.ph58 ], [ %64, %.lr.ph51 ]
  %61 = icmp sgt i32 %60, %55
  br i1 %61, label %.lr.ph52, label %.preheader35

.lr.ph51:                                         ; preds = %.lr.ph58, %.lr.ph51
  %62 = phi i32 [ %64, %.lr.ph51 ], [ %58, %.lr.ph58 ]
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %1, align 4, !tbaa !5
  call void @_Z7remove2i(i32 noundef %62)
  %64 = load i32, ptr %1, align 4, !tbaa !5
  %65 = icmp slt i32 %64, %55
  br i1 %65, label %.lr.ph51, label %.preheader36, !llvm.loop !18

.preheader35:                                     ; preds = %.lr.ph52, %.preheader36
  %66 = load i32, ptr %2, align 4, !tbaa !5
  %67 = icmp slt i32 %66, %57
  br i1 %67, label %.lr.ph53, label %.preheader34

.lr.ph52:                                         ; preds = %.preheader36, %.lr.ph52
  %68 = phi i32 [ %70, %.lr.ph52 ], [ %60, %.preheader36 ]
  %69 = add nsw i32 %68, -1
  store i32 %69, ptr %1, align 4, !tbaa !5
  call void @_Z4add2i(i32 noundef %69)
  %70 = load i32, ptr %1, align 4, !tbaa !5
  %71 = icmp sgt i32 %70, %55
  br i1 %71, label %.lr.ph52, label %.preheader35, !llvm.loop !19

.preheader34:                                     ; preds = %.lr.ph53, %.preheader35
  %72 = phi i32 [ %66, %.preheader35 ], [ %76, %.lr.ph53 ]
  %73 = icmp sgt i32 %72, %57
  br i1 %73, label %.lr.ph54, label %._crit_edge55

.lr.ph53:                                         ; preds = %.preheader35, %.lr.ph53
  %74 = phi i32 [ %76, %.lr.ph53 ], [ %66, %.preheader35 ]
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %2, align 4, !tbaa !5
  call void @_Z3addi(i32 noundef %75)
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %77 = icmp slt i32 %76, %57
  br i1 %77, label %.lr.ph53, label %.preheader34, !llvm.loop !20

.lr.ph54:                                         ; preds = %.preheader34, %.lr.ph54
  %78 = phi i32 [ %80, %.lr.ph54 ], [ %72, %.preheader34 ]
  %79 = add nsw i32 %78, -1
  store i32 %79, ptr %2, align 4, !tbaa !5
  call void @_Z6removei(i32 noundef %78)
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = icmp sgt i32 %80, %57
  br i1 %81, label %.lr.ph54, label %._crit_edge55, !llvm.loop !21

._crit_edge55:                                    ; preds = %.lr.ph54, %.preheader34
  %82 = load i64, ptr @ans, align 8, !tbaa !22
  %83 = getelementptr inbounds i8, ptr %54, i64 8
  %84 = load i32, ptr %83, align 4, !tbaa !24
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100100 x i64], ptr @res, i64 0, i64 %85
  store i64 %82, ptr %86, align 8, !tbaa !22
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %87 = load i32, ptr @m, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = icmp slt i64 %indvars.iv.next72, %88
  br i1 %89, label %.lr.ph58, label %.preheader, !llvm.loop !25

._crit_edge61:                                    ; preds = %.lr.ph60, %._crit_edge48, %.preheader
  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.ph60:                                         ; preds = %.preheader, %.lr.ph60
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %.lr.ph60 ], [ 0, %.preheader ]
  %90 = getelementptr inbounds [100100 x i64], ptr @res, i64 0, i64 %indvars.iv74
  %91 = load i64, ptr %90, align 8, !tbaa !22
  %92 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %91)
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %93 = load i32, ptr @m, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = icmp slt i64 %indvars.iv.next75, %94
  br i1 %95, label %.lr.ph60, label %._crit_edge61, !llvm.loop !26
}

; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5queryEvT_S2_(ptr noundef, ptr noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress nounwind 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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

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

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


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