; LLVM IR from ShahjalalShohag/code-library :: Data Structures (MOs Algorithm)

; 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 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@Q = external dso_local global [1000009 x %struct.query], align 16
@a = external dso_local global [1000009 x i32], align 16
@sum = external dso_local global i64, align 8
@ans = external dso_local global [1000009 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %12 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %13 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %15
  %17 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !8
  br label %20

20:                                               ; preds = %30, %0
  %21 = load i32, ptr %4, align 4, !tbaa !8
  %22 = load i32, ptr %2, align 4, !tbaa !8
  %23 = icmp sle i32 %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %33

25:                                               ; preds = %20
  %26 = load i32, ptr %4, align 4, !tbaa !8
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1000009 x i32], ptr @a, i64 0, i64 %27
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %28)
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %4, align 4, !tbaa !8
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !8
  br label %20, !llvm.loop !11

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

34:                                               ; preds = %55, %33
  %35 = load i32, ptr %5, align 4, !tbaa !8
  %36 = load i32, ptr %3, align 4, !tbaa !8
  %37 = icmp sle i32 %35, %36
  br i1 %37, label %39, label %38

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

39:                                               ; preds = %34
  %40 = load i32, ptr %5, align 4, !tbaa !8
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [1000009 x %struct.query], ptr @Q, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.query, ptr %42, i32 0, i32 0
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %43)
  %45 = load i32, ptr %5, align 4, !tbaa !8
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1000009 x %struct.query], ptr @Q, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.query, ptr %47, i32 0, i32 1
  %49 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef nonnull align 4 dereferenceable(4) %48)
  %50 = load i32, ptr %5, align 4, !tbaa !8
  %51 = load i32, ptr %5, align 4, !tbaa !8
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1000009 x %struct.query], ptr @Q, i64 0, i64 %52
  %54 = getelementptr inbounds %struct.query, ptr %53, i32 0, i32 2
  store i32 %50, ptr %54, align 4, !tbaa !13
  br label %55

55:                                               ; preds = %39
  %56 = load i32, ptr %5, align 4, !tbaa !8
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %5, align 4, !tbaa !8
  br label %34, !llvm.loop !15

58:                                               ; preds = %38
  %59 = load i32, ptr %3, align 4, !tbaa !8
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %struct.query, ptr @Q, i64 %60
  %62 = getelementptr inbounds %struct.query, ptr %61, i64 1
  call void @_ZSt4sortIP5queryEvT_S2_(ptr noundef getelementptr inbounds (%struct.query, ptr @Q, i64 1), ptr noundef %62)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !8
  br label %63

63:                                               ; preds = %157, %58
  %64 = load i32, ptr %8, align 4, !tbaa !8
  %65 = load i32, ptr %3, align 4, !tbaa !8
  %66 = icmp sle i32 %64, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %160

68:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %69 = load i32, ptr %8, align 4, !tbaa !8
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1000009 x %struct.query], ptr @Q, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.query, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %72, align 4, !tbaa !16
  store i32 %73, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %74 = load i32, ptr %8, align 4, !tbaa !8
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1000009 x %struct.query], ptr @Q, i64 0, i64 %75
  %77 = getelementptr inbounds %struct.query, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 4, !tbaa !17
  store i32 %78, ptr %10, align 4, !tbaa !8
  %79 = load i32, ptr %10, align 4, !tbaa !8
  %80 = load i32, ptr %6, align 4, !tbaa !8
  %81 = icmp slt i32 %79, %80
  br i1 %81, label %82, label %115

82:                                               ; preds = %68
  br label %83

83:                                               ; preds = %87, %82
  %84 = load i32, ptr %6, align 4, !tbaa !8
  %85 = load i32, ptr %9, align 4, !tbaa !8
  %86 = icmp sgt i32 %84, %85
  br i1 %86, label %87, label %90

87:                                               ; preds = %83
  %88 = load i32, ptr %6, align 4, !tbaa !8
  %89 = add nsw i32 %88, -1
  store i32 %89, ptr %6, align 4, !tbaa !8
  call void @_Z8add_lefti(i32 noundef %89)
  br label %83, !llvm.loop !18

90:                                               ; preds = %83
  br label %91

91:                                               ; preds = %95, %90
  %92 = load i32, ptr %6, align 4, !tbaa !8
  %93 = load i32, ptr %9, align 4, !tbaa !8
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %95, label %98

95:                                               ; preds = %91
  %96 = load i32, ptr %6, align 4, !tbaa !8
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %6, align 4, !tbaa !8
  call void @_Z8rem_lefti(i32 noundef %96)
  br label %91, !llvm.loop !19

98:                                               ; preds = %91
  br label %99

99:                                               ; preds = %103, %98
  %100 = load i32, ptr %7, align 4, !tbaa !8
  %101 = load i32, ptr %10, align 4, !tbaa !8
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %103, label %106

103:                                              ; preds = %99
  %104 = load i32, ptr %7, align 4, !tbaa !8
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %7, align 4, !tbaa !8
  call void @_Z9add_righti(i32 noundef %105)
  br label %99, !llvm.loop !20

106:                                              ; preds = %99
  br label %107

107:                                              ; preds = %111, %106
  %108 = load i32, ptr %7, align 4, !tbaa !8
  %109 = load i32, ptr %10, align 4, !tbaa !8
  %110 = icmp sgt i32 %108, %109
  br i1 %110, label %111, label %114

111:                                              ; preds = %107
  %112 = load i32, ptr %7, align 4, !tbaa !8
  %113 = add nsw i32 %112, -1
  store i32 %113, ptr %7, align 4, !tbaa !8
  call void @_Z9rem_righti(i32 noundef %112)
  br label %107, !llvm.loop !21

114:                                              ; preds = %107
  br label %148

115:                                              ; preds = %68
  br label %116

116:                                              ; preds = %120, %115
  %117 = load i32, ptr %7, align 4, !tbaa !8
  %118 = load i32, ptr %10, align 4, !tbaa !8
  %119 = icmp slt i32 %117, %118
  br i1 %119, label %120, label %123

120:                                              ; preds = %116
  %121 = load i32, ptr %7, align 4, !tbaa !8
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %7, align 4, !tbaa !8
  call void @_Z9add_righti(i32 noundef %122)
  br label %116, !llvm.loop !22

123:                                              ; preds = %116
  br label %124

124:                                              ; preds = %128, %123
  %125 = load i32, ptr %7, align 4, !tbaa !8
  %126 = load i32, ptr %10, align 4, !tbaa !8
  %127 = icmp sgt i32 %125, %126
  br i1 %127, label %128, label %131

128:                                              ; preds = %124
  %129 = load i32, ptr %7, align 4, !tbaa !8
  %130 = add nsw i32 %129, -1
  store i32 %130, ptr %7, align 4, !tbaa !8
  call void @_Z9rem_righti(i32 noundef %129)
  br label %124, !llvm.loop !23

131:                                              ; preds = %124
  br label %132

132:                                              ; preds = %136, %131
  %133 = load i32, ptr %6, align 4, !tbaa !8
  %134 = load i32, ptr %9, align 4, !tbaa !8
  %135 = icmp sgt i32 %133, %134
  br i1 %135, label %136, label %139

136:                                              ; preds = %132
  %137 = load i32, ptr %6, align 4, !tbaa !8
  %138 = add nsw i32 %137, -1
  store i32 %138, ptr %6, align 4, !tbaa !8
  call void @_Z8add_lefti(i32 noundef %138)
  br label %132, !llvm.loop !24

139:                                              ; preds = %132
  br label %140

140:                                              ; preds = %144, %139
  %141 = load i32, ptr %6, align 4, !tbaa !8
  %142 = load i32, ptr %9, align 4, !tbaa !8
  %143 = icmp slt i32 %141, %142
  br i1 %143, label %144, label %147

144:                                              ; preds = %140
  %145 = load i32, ptr %6, align 4, !tbaa !8
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %6, align 4, !tbaa !8
  call void @_Z8rem_lefti(i32 noundef %145)
  br label %140, !llvm.loop !25

147:                                              ; preds = %140
  br label %148

148:                                              ; preds = %147, %114
  %149 = load i64, ptr @sum, align 8, !tbaa !26
  %150 = load i32, ptr %8, align 4, !tbaa !8
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [1000009 x %struct.query], ptr @Q, i64 0, i64 %151
  %153 = getelementptr inbounds %struct.query, ptr %152, i32 0, i32 2
  %154 = load i32, ptr %153, align 4, !tbaa !13
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [1000009 x i64], ptr @ans, i64 0, i64 %155
  store i64 %149, ptr %156, align 8, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %157

157:                                              ; preds = %148
  %158 = load i32, ptr %8, align 4, !tbaa !8
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %8, align 4, !tbaa !8
  br label %63, !llvm.loop !28

160:                                              ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 1, ptr %11, align 4, !tbaa !8
  br label %161

161:                                              ; preds = %173, %160
  %162 = load i32, ptr %11, align 4, !tbaa !8
  %163 = load i32, ptr %3, align 4, !tbaa !8
  %164 = icmp sle i32 %162, %163
  br i1 %164, label %166, label %165

165:                                              ; preds = %161
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %176

166:                                              ; preds = %161
  %167 = load i32, ptr %11, align 4, !tbaa !8
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [1000009 x i64], ptr @ans, i64 0, i64 %168
  %170 = load i64, ptr %169, align 8, !tbaa !26
  %171 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %170)
  %172 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %171, i8 noundef signext 10)
  br label %173

173:                                              ; preds = %166
  %174 = load i32, ptr %11, align 4, !tbaa !8
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %11, align 4, !tbaa !8
  br label %161, !llvm.loop !29

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 2

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z8add_lefti(i32 noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z8rem_lefti(i32 noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z9add_righti(i32 noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z9rem_righti(i32 noundef) #5

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #6 align 2

attributes #0 = { 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 #1 = { "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 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint 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 #6 = { 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 #7 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !9, i64 8}
!14 = !{!"_ZTS5query", !9, i64 0, !9, i64 4, !9, i64 8}
!15 = distinct !{!15, !12}
!16 = !{!14, !9, i64 0}
!17 = !{!14, !9, i64 4}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !12}
!26 = !{!27, !27, i64 0}
!27 = !{!"long long", !10, i64 0}
!28 = distinct !{!28, !12}
!29 = distinct !{!29, !12}


; 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 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@Q = external dso_local global [1000009 x %struct.query], align 16
@a = external dso_local global [1000009 x i32], align 16
@sum = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global [1000009 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %4 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %6
  %8 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %7, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %11 = load i32, ptr %1, align 4, !tbaa !8
  %.not67 = icmp slt i32 %11, 1
  br i1 %.not67, label %.preheader66, label %.lr.ph

.preheader66:                                     ; preds = %.lr.ph, %0
  %12 = load i32, ptr %2, align 4, !tbaa !8
  %.not5469 = icmp slt i32 %12, 1
  br i1 %.not5469, label %.preheader66.._crit_edge_crit_edge, label %.lr.ph71

.preheader66.._crit_edge_crit_edge:               ; preds = %.preheader66
  %.pre = sext i32 %12 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %13 = getelementptr inbounds [1000009 x i32], ptr @a, i64 0, i64 %indvars.iv
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr %1, align 4, !tbaa !8
  %16 = sext i32 %15 to i64
  %.not.not = icmp slt i64 %indvars.iv, %16
  br i1 %.not.not, label %.lr.ph, label %.preheader66, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph71, %.preheader66.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.preheader66.._crit_edge_crit_edge ], [ %27, %.lr.ph71 ]
  %17 = getelementptr inbounds %struct.query, ptr @Q, i64 %.pre-phi
  %18 = getelementptr inbounds i8, ptr %17, i64 12
  call void @_ZSt4sortIP5queryEvT_S2_(ptr noundef nonnull getelementptr inbounds (i8, ptr @Q, i64 12), ptr noundef nonnull %18)
  %19 = load i32, ptr %2, align 4, !tbaa !8
  %.not5596 = icmp slt i32 %19, 1
  br i1 %.not5596, label %._crit_edge105, label %.lr.ph101

.lr.ph71:                                         ; preds = %.preheader66, %.lr.ph71
  %indvars.iv117 = phi i64 [ %indvars.iv.next118, %.lr.ph71 ], [ 1, %.preheader66 ]
  %20 = getelementptr inbounds [1000009 x %struct.query], ptr @Q, i64 0, i64 %indvars.iv117
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %20)
  %22 = getelementptr inbounds i8, ptr %20, i64 4
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 4 dereferenceable(4) %22)
  %24 = getelementptr inbounds i8, ptr %20, i64 8
  %25 = trunc nuw nsw i64 %indvars.iv117 to i32
  store i32 %25, ptr %24, align 4, !tbaa !13
  %indvars.iv.next118 = add nuw nsw i64 %indvars.iv117, 1
  %26 = load i32, ptr %2, align 4, !tbaa !8
  %27 = sext i32 %26 to i64
  %.not54.not = icmp slt i64 %indvars.iv117, %27
  br i1 %.not54.not, label %.lr.ph71, label %._crit_edge, !llvm.loop !15

.preheader:                                       ; preds = %.loopexit
  %28 = icmp slt i32 %59, 1
  br i1 %28, label %._crit_edge105, label %.lr.ph104

.lr.ph101:                                        ; preds = %._crit_edge, %.loopexit
  %indvars.iv123 = phi i64 [ %indvars.iv.next124, %.loopexit ], [ 1, %._crit_edge ]
  %.04698 = phi i32 [ %.5, %.loopexit ], [ 0, %._crit_edge ]
  %.04797 = phi i32 [ %.552, %.loopexit ], [ 1, %._crit_edge ]
  %29 = getelementptr inbounds [1000009 x %struct.query], ptr @Q, i64 0, i64 %indvars.iv123
  %30 = load i32, ptr %29, align 4, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %29, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = icmp slt i32 %32, %.04797
  br i1 %33, label %.preheader60, label %.preheader65

.preheader65:                                     ; preds = %.lr.ph101
  %34 = icmp slt i32 %.04698, %32
  br i1 %34, label %.lr.ph73, label %.preheader64

.preheader60:                                     ; preds = %.lr.ph101
  %35 = icmp sgt i32 %.04797, %30
  br i1 %35, label %.lr.ph85, label %.preheader59

.preheader59:                                     ; preds = %.preheader60
  %36 = icmp slt i32 %.04797, %30
  br i1 %36, label %.lr.ph88, label %.preheader58

.lr.ph85:                                         ; preds = %.preheader60, %.lr.ph85
  %.14884 = phi i32 [ %37, %.lr.ph85 ], [ %.04797, %.preheader60 ]
  %37 = add nsw i32 %.14884, -1
  call void @_Z8add_lefti(i32 noundef %37)
  %38 = icmp sgt i32 %37, %30
  br i1 %38, label %.lr.ph85, label %.preheader58, !llvm.loop !18

.preheader58:                                     ; preds = %.lr.ph88, %.lr.ph85, %.preheader59
  %.249.lcssa = phi i32 [ %.04797, %.preheader59 ], [ %30, %.lr.ph85 ], [ %30, %.lr.ph88 ]
  %39 = icmp slt i32 %.04698, %32
  br i1 %39, label %.lr.ph91, label %.preheader57

.lr.ph88:                                         ; preds = %.preheader59, %.lr.ph88
  %.24987 = phi i32 [ %40, %.lr.ph88 ], [ %.04797, %.preheader59 ]
  %40 = add i32 %.24987, 1
  call void @_Z8rem_lefti(i32 noundef %.24987)
  %exitcond121.not = icmp eq i32 %40, %30
  br i1 %exitcond121.not, label %.preheader58, label %.lr.ph88, !llvm.loop !19

.preheader57:                                     ; preds = %.preheader58
  %41 = icmp sgt i32 %.04698, %32
  br i1 %41, label %.lr.ph94, label %.loopexit

.lr.ph91:                                         ; preds = %.preheader58, %.lr.ph91
  %.190 = phi i32 [ %42, %.lr.ph91 ], [ %.04698, %.preheader58 ]
  %42 = add nsw i32 %.190, 1
  call void @_Z9add_righti(i32 noundef %42)
  %exitcond122.not = icmp eq i32 %42, %32
  br i1 %exitcond122.not, label %.loopexit, label %.lr.ph91, !llvm.loop !20

.lr.ph94:                                         ; preds = %.preheader57, %.lr.ph94
  %.293 = phi i32 [ %43, %.lr.ph94 ], [ %.04698, %.preheader57 ]
  %43 = add nsw i32 %.293, -1
  call void @_Z9rem_righti(i32 noundef %.293)
  %44 = icmp sgt i32 %43, %32
  br i1 %44, label %.lr.ph94, label %.loopexit, !llvm.loop !21

.preheader64:                                     ; preds = %.preheader65
  %45 = icmp sgt i32 %.04698, %32
  br i1 %45, label %.lr.ph76, label %.preheader63

.lr.ph73:                                         ; preds = %.preheader65, %.lr.ph73
  %.372 = phi i32 [ %46, %.lr.ph73 ], [ %.04698, %.preheader65 ]
  %46 = add nsw i32 %.372, 1
  call void @_Z9add_righti(i32 noundef %46)
  %exitcond.not = icmp eq i32 %46, %32
  br i1 %exitcond.not, label %.preheader63, label %.lr.ph73, !llvm.loop !22

.preheader63:                                     ; preds = %.lr.ph76, %.lr.ph73, %.preheader64
  %.4.lcssa = phi i32 [ %.04698, %.preheader64 ], [ %32, %.lr.ph73 ], [ %32, %.lr.ph76 ]
  %47 = icmp sgt i32 %.04797, %30
  br i1 %47, label %.lr.ph79, label %.preheader61

.lr.ph76:                                         ; preds = %.preheader64, %.lr.ph76
  %.475 = phi i32 [ %48, %.lr.ph76 ], [ %.04698, %.preheader64 ]
  %48 = add nsw i32 %.475, -1
  call void @_Z9rem_righti(i32 noundef %.475)
  %49 = icmp sgt i32 %48, %32
  br i1 %49, label %.lr.ph76, label %.preheader63, !llvm.loop !23

.preheader61:                                     ; preds = %.preheader63
  %50 = icmp slt i32 %.04797, %30
  br i1 %50, label %.lr.ph82, label %.loopexit

.lr.ph79:                                         ; preds = %.preheader63, %.lr.ph79
  %.35078 = phi i32 [ %51, %.lr.ph79 ], [ %.04797, %.preheader63 ]
  %51 = add nsw i32 %.35078, -1
  call void @_Z8add_lefti(i32 noundef %51)
  %52 = icmp sgt i32 %51, %30
  br i1 %52, label %.lr.ph79, label %.loopexit, !llvm.loop !24

.lr.ph82:                                         ; preds = %.preheader61, %.lr.ph82
  %.45181 = phi i32 [ %53, %.lr.ph82 ], [ %.04797, %.preheader61 ]
  %53 = add i32 %.45181, 1
  call void @_Z8rem_lefti(i32 noundef %.45181)
  %exitcond120.not = icmp eq i32 %53, %30
  br i1 %exitcond120.not, label %.loopexit, label %.lr.ph82, !llvm.loop !25

.loopexit:                                        ; preds = %.lr.ph82, %.lr.ph79, %.lr.ph94, %.lr.ph91, %.preheader61, %.preheader57
  %.552 = phi i32 [ %.249.lcssa, %.preheader57 ], [ %.04797, %.preheader61 ], [ %.249.lcssa, %.lr.ph91 ], [ %.249.lcssa, %.lr.ph94 ], [ %30, %.lr.ph79 ], [ %30, %.lr.ph82 ]
  %.5 = phi i32 [ %.04698, %.preheader57 ], [ %.4.lcssa, %.preheader61 ], [ %32, %.lr.ph91 ], [ %32, %.lr.ph94 ], [ %.4.lcssa, %.lr.ph79 ], [ %.4.lcssa, %.lr.ph82 ]
  %54 = load i64, ptr @sum, align 8, !tbaa !26
  %55 = getelementptr inbounds i8, ptr %29, i64 8
  %56 = load i32, ptr %55, align 4, !tbaa !13
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [1000009 x i64], ptr @ans, i64 0, i64 %57
  store i64 %54, ptr %58, align 8, !tbaa !26
  %indvars.iv.next124 = add nuw nsw i64 %indvars.iv123, 1
  %59 = load i32, ptr %2, align 4, !tbaa !8
  %60 = sext i32 %59 to i64
  %.not55.not = icmp slt i64 %indvars.iv123, %60
  br i1 %.not55.not, label %.lr.ph101, label %.preheader, !llvm.loop !28

._crit_edge105:                                   ; preds = %.lr.ph104, %._crit_edge, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0

.lr.ph104:                                        ; preds = %.preheader, %.lr.ph104
  %indvars.iv126 = phi i64 [ %indvars.iv.next127, %.lr.ph104 ], [ 1, %.preheader ]
  %61 = getelementptr inbounds [1000009 x i64], ptr @ans, i64 0, i64 %indvars.iv126
  %62 = load i64, ptr %61, align 8, !tbaa !26
  %63 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %62)
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %63, i8 noundef signext 10)
  %indvars.iv.next127 = add nuw nsw i64 %indvars.iv126, 1
  %65 = load i32, ptr %2, align 4, !tbaa !8
  %66 = sext i32 %65 to i64
  %.not56.not = icmp slt i64 %indvars.iv126, %66
  br i1 %.not56.not, label %.lr.ph104, label %._crit_edge105, !llvm.loop !29
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #2 align 2

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z8add_lefti(i32 noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z8rem_lefti(i32 noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z9add_righti(i32 noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z9rem_righti(i32 noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #6 align 2

attributes #0 = { 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 #1 = { "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 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 #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 = { inlinehint 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 #6 = { 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 #7 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !9, i64 8}
!14 = !{!"_ZTS5query", !9, i64 0, !9, i64 4, !9, i64 8}
!15 = distinct !{!15, !12}
!16 = !{!14, !9, i64 0}
!17 = !{!14, !9, i64 4}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}
!25 = distinct !{!25, !12}
!26 = !{!27, !27, i64 0}
!27 = !{!"long long", !10, i64 0}
!28 = distinct !{!28, !12}
!29 = distinct !{!29, !12}


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