; LLVM IR from pranjalwalia/Competitive-programming :: spoj (dquery)

; 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.fo = type { i32, i32 }
%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" }
%struct.nodost = type { i32 }

@a = external dso_local global [1000000 x i32], align 16
@n = external dso_local global i32, align 4
@b = external dso_local global [1000000 x %struct.fo], align 16
@querys = external dso_local global [1000006 x %struct.query], align 16
@ant = external dso_local global [1000006 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7buildstiix(i32 noundef, i32 noundef, i64 noundef) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_Z6getsumxiiii(i64 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

; 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 %struct.fo, 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 ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.query, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %struct.nodost, align 4
  %19 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %20 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %21 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %22 = getelementptr i8, ptr %21, i64 -24
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %23
  %25 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %24, ptr noundef null)
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #9
  store i32 1, ptr %3, align 4, !tbaa !8
  br label %27

27:                                               ; preds = %49, %0
  %28 = load i32, ptr %3, align 4, !tbaa !8
  %29 = load i32, ptr @n, align 4, !tbaa !8
  %30 = add nsw i32 %29, 1
  %31 = icmp slt i32 %28, %30
  br i1 %31, label %33, label %32

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

33:                                               ; preds = %27
  %34 = 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)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #9
  %35 = getelementptr inbounds %struct.fo, ptr %4, i32 0, i32 0
  %36 = load i32, ptr %2, align 4, !tbaa !8
  store i32 %36, ptr %35, align 4, !tbaa !11
  %37 = getelementptr inbounds %struct.fo, ptr %4, i32 0, i32 1
  %38 = load i32, ptr %2, align 4, !tbaa !8
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1000006 x i32], ptr @ant, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !8
  store i32 %41, ptr %37, align 4, !tbaa !13
  %42 = load i32, ptr %3, align 4, !tbaa !8
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1000000 x %struct.fo], ptr @b, i64 0, i64 %43
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %44, ptr align 4 %4, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #9
  %45 = load i32, ptr %3, align 4, !tbaa !8
  %46 = load i32, ptr %2, align 4, !tbaa !8
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1000006 x i32], ptr @ant, i64 0, i64 %47
  store i32 %45, ptr %48, align 4, !tbaa !8
  br label %49

49:                                               ; preds = %33
  %50 = load i32, ptr %3, align 4, !tbaa !8
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %3, align 4, !tbaa !8
  br label %27, !llvm.loop !15

52:                                               ; preds = %32
  call void @llvm.memset.p0.i64(ptr align 16 @ant, i8 -1, i64 4000024, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #9
  %53 = load i32, ptr @n, align 4, !tbaa !8
  store i32 %53, ptr %5, align 4, !tbaa !8
  br label %54

54:                                               ; preds = %84, %52
  %55 = load i32, ptr %5, align 4, !tbaa !8
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #9
  br label %87

58:                                               ; preds = %54
  %59 = load i32, ptr %5, align 4, !tbaa !8
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1000000 x %struct.fo], ptr @b, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.fo, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [1000006 x i32], ptr @ant, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !8
  %67 = icmp eq i32 %66, -1
  br i1 %67, label %68, label %79

68:                                               ; preds = %58
  %69 = load i32, ptr %5, align 4, !tbaa !8
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [1000000 x i32], ptr @a, i64 0, i64 %70
  store i32 1, ptr %71, align 4, !tbaa !8
  %72 = load i32, ptr %5, align 4, !tbaa !8
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1000000 x %struct.fo], ptr @b, i64 0, i64 %73
  %75 = getelementptr inbounds %struct.fo, ptr %74, i32 0, i32 0
  %76 = load i32, ptr %75, align 8, !tbaa !11
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1000006 x i32], ptr @ant, i64 0, i64 %77
  store i32 1, ptr %78, align 4, !tbaa !8
  br label %83

79:                                               ; preds = %58
  %80 = load i32, ptr %5, align 4, !tbaa !8
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1000000 x i32], ptr @a, i64 0, i64 %81
  store i32 0, ptr %82, align 4, !tbaa !8
  br label %83

83:                                               ; preds = %79, %68
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %5, align 4, !tbaa !8
  %86 = add nsw i32 %85, -1
  store i32 %86, ptr %5, align 4, !tbaa !8
  br label %54, !llvm.loop !17

87:                                               ; preds = %57
  %88 = load i32, ptr @n, align 4, !tbaa !8
  call void @_Z7buildstiix(i32 noundef 1, i32 noundef %88, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  %89 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  %90 = load i32, ptr @n, align 4, !tbaa !8
  store i32 %90, ptr %9, align 4, !tbaa !8
  %91 = load i32, ptr %6, align 4, !tbaa !8
  %92 = zext i32 %91 to i64
  %93 = call ptr @llvm.stacksave.p0()
  store ptr %93, ptr %10, align 8
  %94 = alloca i32, i64 %92, align 16
  store i64 %92, ptr %11, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  store i32 0, ptr %12, align 4, !tbaa !8
  br label %95

95:                                               ; preds = %112, %87
  %96 = load i32, ptr %12, align 4, !tbaa !8
  %97 = load i32, ptr %6, align 4, !tbaa !8
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  br label %115

100:                                              ; preds = %95
  %101 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %102 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %101, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #9
  %103 = getelementptr inbounds %struct.query, ptr %13, i32 0, i32 0
  %104 = load i32, ptr %7, align 4, !tbaa !8
  store i32 %104, ptr %103, align 4, !tbaa !18
  %105 = getelementptr inbounds %struct.query, ptr %13, i32 0, i32 1
  %106 = load i32, ptr %8, align 4, !tbaa !8
  store i32 %106, ptr %105, align 4, !tbaa !20
  %107 = getelementptr inbounds %struct.query, ptr %13, i32 0, i32 2
  %108 = load i32, ptr %12, align 4, !tbaa !8
  store i32 %108, ptr %107, align 4, !tbaa !21
  %109 = load i32, ptr %12, align 4, !tbaa !8
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [1000006 x %struct.query], ptr @querys, i64 0, i64 %110
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %111, ptr align 4 %13, i64 12, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #9
  br label %112

112:                                              ; preds = %100
  %113 = load i32, ptr %12, align 4, !tbaa !8
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %12, align 4, !tbaa !8
  br label %95, !llvm.loop !23

115:                                              ; preds = %99
  %116 = load i32, ptr %6, align 4, !tbaa !8
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds %struct.query, ptr @querys, i64 %117
  call void @_ZSt4sortIP5queryEvT_S2_(ptr noundef @querys, ptr noundef %118)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  %119 = load i32, ptr %6, align 4, !tbaa !8
  %120 = sub nsw i32 %119, 1
  store i32 %120, ptr %14, align 4, !tbaa !8
  br label %121

121:                                              ; preds = %159, %115
  %122 = load i32, ptr %14, align 4, !tbaa !8
  %123 = icmp sgt i32 %122, -1
  br i1 %123, label %125, label %124

124:                                              ; preds = %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  br label %162

125:                                              ; preds = %121
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  %126 = load i32, ptr %14, align 4, !tbaa !8
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1000006 x %struct.query], ptr @querys, i64 0, i64 %127
  %129 = getelementptr inbounds %struct.query, ptr %128, i32 0, i32 1
  %130 = load i32, ptr %129, align 4, !tbaa !20
  store i32 %130, ptr %15, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  %131 = load i32, ptr %14, align 4, !tbaa !8
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [1000006 x %struct.query], ptr @querys, i64 0, i64 %132
  %134 = getelementptr inbounds %struct.query, ptr %133, i32 0, i32 0
  %135 = load i32, ptr %134, align 4, !tbaa !18
  store i32 %135, ptr %16, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  %136 = load i32, ptr %14, align 4, !tbaa !8
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [1000006 x %struct.query], ptr @querys, i64 0, i64 %137
  %139 = getelementptr inbounds %struct.query, ptr %138, i32 0, i32 2
  %140 = load i32, ptr %139, align 4, !tbaa !21
  store i32 %140, ptr %17, align 4, !tbaa !8
  %141 = load i32, ptr %15, 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 = %125
  %145 = load i32, ptr %15, align 4, !tbaa !8
  %146 = load i32, ptr %9, align 4, !tbaa !8
  call void @_Z3fixii(i32 noundef %145, i32 noundef %146)
  br label %147

147:                                              ; preds = %144, %125
  %148 = load i32, ptr %15, align 4, !tbaa !8
  store i32 %148, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #9
  %149 = load i32, ptr @n, align 4, !tbaa !8
  %150 = load i32, ptr %16, align 4, !tbaa !8
  %151 = load i32, ptr %15, align 4, !tbaa !8
  %152 = call i32 @_Z6getsumxiiii(i64 noundef 1, i32 noundef 1, i32 noundef %149, i32 noundef %150, i32 noundef %151)
  %153 = getelementptr inbounds %struct.nodost, ptr %18, i32 0, i32 0
  store i32 %152, ptr %153, align 4
  %154 = getelementptr inbounds %struct.nodost, ptr %18, i32 0, i32 0
  %155 = load i32, ptr %154, align 4, !tbaa !24
  %156 = load i32, ptr %17, align 4, !tbaa !8
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds i32, ptr %94, i64 %157
  store i32 %155, ptr %158, align 4, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  br label %159

159:                                              ; preds = %147
  %160 = load i32, ptr %14, align 4, !tbaa !8
  %161 = add nsw i32 %160, -1
  store i32 %161, ptr %14, align 4, !tbaa !8
  br label %121, !llvm.loop !26

162:                                              ; preds = %124
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #9
  store i32 0, ptr %19, align 4, !tbaa !8
  br label %163

163:                                              ; preds = %175, %162
  %164 = load i32, ptr %19, align 4, !tbaa !8
  %165 = load i32, ptr %6, align 4, !tbaa !8
  %166 = icmp slt i32 %164, %165
  br i1 %166, label %168, label %167

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

168:                                              ; preds = %163
  %169 = load i32, ptr %19, align 4, !tbaa !8
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds i32, ptr %94, i64 %170
  %172 = load i32, ptr %171, align 4, !tbaa !8
  %173 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %172)
  %174 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %173, ptr noundef @.str)
  br label %175

175:                                              ; preds = %168
  %176 = load i32, ptr %19, align 4, !tbaa !8
  %177 = add nsw i32 %176, 1
  store i32 %177, ptr %19, align 4, !tbaa !8
  br label %163, !llvm.loop !27

178:                                              ; preds = %167
  store i32 0, ptr %1, align 4
  %179 = load ptr, ptr %10, align 8
  call void @llvm.stackrestore.p0(ptr %179)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  %180 = load i32, ptr %1, align 4
  ret i32 %180
}

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #7

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #8

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #7

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nocallback nofree nosync nounwind willreturn }
attributes #8 = { 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 #9 = { 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 = !{!12, !9, i64 0}
!12 = !{!"_ZTS2fo", !9, i64 0, !9, i64 4}
!13 = !{!12, !9, i64 4}
!14 = !{i64 0, i64 4, !8, i64 4, i64 4, !8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!19, !9, i64 0}
!19 = !{!"_ZTS5query", !9, i64 0, !9, i64 4, !9, i64 8}
!20 = !{!19, !9, i64 4}
!21 = !{!19, !9, i64 8}
!22 = !{i64 0, i64 4, !8, i64 4, i64 4, !8, i64 8, i64 4, !8}
!23 = distinct !{!23, !16}
!24 = !{!25, !9, i64 0}
!25 = !{!"_ZTS6nodost", !9, i64 0}
!26 = distinct !{!26, !16}
!27 = distinct !{!27, !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.fo = type { i32, i32 }
%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" }

@a = external dso_local local_unnamed_addr global [1000000 x i32], align 16
@n = external dso_local global i32, align 4
@b = external dso_local local_unnamed_addr global [1000000 x %struct.fo], align 16
@querys = external dso_local global [1000006 x %struct.query], align 16
@ant = external dso_local local_unnamed_addr global [1000006 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7buildstiix(i32 noundef, i32 noundef, i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_Z6getsumxiiii(i64 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; 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 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %6 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i64, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %8
  %10 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %9, ptr noundef null)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %12 = load i32, ptr @n, align 4, !tbaa !8
  %.not42 = icmp slt i32 %12, 1
  br i1 %.not42, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %0
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4000024) @ant, i8 -1, i64 4000024, i1 false)
  br label %._crit_edge47

._crit_edge:                                      ; preds = %.lr.ph
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4000024) @ant, i8 -1, i64 4000024, i1 false)
  %13 = icmp sgt i32 %31, 0
  br i1 %13, label %.lr.ph46.preheader, label %._crit_edge47

.lr.ph46.preheader:                               ; preds = %._crit_edge
  %14 = zext nneg i32 %31 to i64
  %xtraiter = and i64 %14, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph46.prol.loopexit, label %.lr.ph46.prol

.lr.ph46.prol:                                    ; preds = %.lr.ph46.preheader
  %15 = getelementptr inbounds [1000000 x %struct.fo], ptr @b, i64 0, i64 %14
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1000006 x i32], ptr @ant, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !8
  %20 = icmp eq i32 %19, -1
  br i1 %20, label %21, label %.lr.ph46.prol.loopexit.unr-lcssa

21:                                               ; preds = %.lr.ph46.prol
  store i32 1, ptr %18, align 4, !tbaa !8
  br label %.lr.ph46.prol.loopexit.unr-lcssa

.lr.ph46.prol.loopexit.unr-lcssa:                 ; preds = %21, %.lr.ph46.prol
  %.sink.prol = phi i32 [ 1, %21 ], [ 0, %.lr.ph46.prol ]
  %22 = getelementptr inbounds [1000000 x i32], ptr @a, i64 0, i64 %14
  store i32 %.sink.prol, ptr %22, align 4
  %indvars.iv.next65.prol = add nsw i64 %14, -1
  br label %.lr.ph46.prol.loopexit

.lr.ph46.prol.loopexit:                           ; preds = %.lr.ph46.prol.loopexit.unr-lcssa, %.lr.ph46.preheader
  %indvars.iv64.unr = phi i64 [ %14, %.lr.ph46.preheader ], [ %indvars.iv.next65.prol, %.lr.ph46.prol.loopexit.unr-lcssa ]
  %23 = icmp eq i32 %31, 1
  br i1 %23, label %._crit_edge47, label %.lr.ph46

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %24 = 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)
  %25 = load i32, ptr %1, align 4, !tbaa !8
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1000006 x i32], ptr @ant, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !8
  %29 = getelementptr inbounds [1000000 x %struct.fo], ptr @b, i64 0, i64 %indvars.iv
  store i32 %25, ptr %29, align 8, !tbaa !8
  %.sroa.428.0..sroa_idx = getelementptr inbounds i8, ptr %29, i64 4
  store i32 %28, ptr %.sroa.428.0..sroa_idx, align 4, !tbaa !8
  %30 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %30, ptr %27, align 4, !tbaa !8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %31 = load i32, ptr @n, align 4, !tbaa !8
  %32 = sext i32 %31 to i64
  %.not.not = icmp slt i64 %indvars.iv, %32
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge47:                                    ; preds = %.lr.ph46.prol.loopexit, %56, %._crit_edge.thread, %._crit_edge
  %.lcssa4178 = phi i32 [ %12, %._crit_edge.thread ], [ %31, %._crit_edge ], [ %31, %56 ], [ %31, %.lr.ph46.prol.loopexit ]
  call void @_Z7buildstiix(i32 noundef 1, i32 noundef %.lcssa4178, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #8
  %33 = 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)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #8
  %34 = load i32, ptr @n, align 4, !tbaa !8
  %35 = load i32, ptr %2, align 4, !tbaa !8
  %36 = zext i32 %35 to i64
  %37 = call ptr @llvm.stacksave.p0()
  %38 = alloca i32, i64 %36, align 16
  %39 = load i32, ptr %2, align 4, !tbaa !8
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %.lr.ph50, label %._crit_edge47.._crit_edge51_crit_edge

._crit_edge47.._crit_edge51_crit_edge:            ; preds = %._crit_edge47
  %.pre76 = sext i32 %39 to i64
  br label %._crit_edge51

.lr.ph46:                                         ; preds = %.lr.ph46.prol.loopexit, %56
  %indvars.iv64 = phi i64 [ %indvars.iv.next65.1, %56 ], [ %indvars.iv64.unr, %.lr.ph46.prol.loopexit ]
  %41 = getelementptr inbounds [1000000 x %struct.fo], ptr @b, i64 0, i64 %indvars.iv64
  %42 = load i32, ptr %41, align 8, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1000006 x i32], ptr @ant, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !8
  %46 = icmp eq i32 %45, -1
  br i1 %46, label %47, label %.lr.ph46.1

47:                                               ; preds = %.lr.ph46
  store i32 1, ptr %44, align 4, !tbaa !8
  br label %.lr.ph46.1

.lr.ph46.1:                                       ; preds = %.lr.ph46, %47
  %.sink = phi i32 [ 1, %47 ], [ 0, %.lr.ph46 ]
  %48 = getelementptr inbounds [1000000 x i32], ptr @a, i64 0, i64 %indvars.iv64
  store i32 %.sink, ptr %48, align 4
  %indvars.iv.next65 = add nsw i64 %indvars.iv64, -1
  %49 = getelementptr inbounds [1000000 x %struct.fo], ptr @b, i64 0, i64 %indvars.iv.next65
  %50 = load i32, ptr %49, align 8, !tbaa !11
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [1000006 x i32], ptr @ant, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !8
  %54 = icmp eq i32 %53, -1
  br i1 %54, label %55, label %56

55:                                               ; preds = %.lr.ph46.1
  store i32 1, ptr %52, align 4, !tbaa !8
  br label %56

56:                                               ; preds = %55, %.lr.ph46.1
  %.sink.1 = phi i32 [ 1, %55 ], [ 0, %.lr.ph46.1 ]
  %57 = getelementptr inbounds [1000000 x i32], ptr @a, i64 0, i64 %indvars.iv.next65
  store i32 %.sink.1, ptr %57, align 4
  %indvars.iv.next65.1 = add nsw i64 %indvars.iv64, -2
  %58 = icmp sgt i64 %indvars.iv64, 2
  br i1 %58, label %.lr.ph46, label %._crit_edge47, !llvm.loop !15

._crit_edge51:                                    ; preds = %.lr.ph50, %._crit_edge47.._crit_edge51_crit_edge
  %.pre-phi = phi i64 [ %.pre76, %._crit_edge47.._crit_edge51_crit_edge ], [ %70, %.lr.ph50 ]
  %59 = getelementptr inbounds %struct.query, ptr @querys, i64 %.pre-phi
  call void @_ZSt4sortIP5queryEvT_S2_(ptr noundef nonnull @querys, ptr noundef nonnull %59)
  %60 = load i32, ptr %2, align 4, !tbaa !8
  %61 = icmp sgt i32 %60, 0
  br i1 %61, label %.lr.ph57.preheader, label %._crit_edge60

.lr.ph57.preheader:                               ; preds = %._crit_edge51
  %62 = zext nneg i32 %60 to i64
  br label %.lr.ph57

.lr.ph50:                                         ; preds = %._crit_edge47, %.lr.ph50
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %.lr.ph50 ], [ 0, %._crit_edge47 ]
  %63 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %64 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %63, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %65 = load i32, ptr %3, align 4, !tbaa !8
  %66 = load i32, ptr %4, align 4, !tbaa !8
  %67 = getelementptr inbounds [1000006 x %struct.query], ptr @querys, i64 0, i64 %indvars.iv67
  store i32 %65, ptr %67, align 4, !tbaa !8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %67, i64 4
  store i32 %66, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !8
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %67, i64 8
  %68 = trunc nuw nsw i64 %indvars.iv67 to i32
  store i32 %68, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !8
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %69 = load i32, ptr %2, align 4, !tbaa !8
  %70 = sext i32 %69 to i64
  %71 = icmp slt i64 %indvars.iv.next68, %70
  br i1 %71, label %.lr.ph50, label %._crit_edge51, !llvm.loop !16

.preheader:                                       ; preds = %81
  %.pre = load i32, ptr %2, align 4, !tbaa !8
  %72 = icmp sgt i32 %.pre, 0
  br i1 %72, label %.lr.ph59, label %._crit_edge60

.lr.ph57:                                         ; preds = %.lr.ph57.preheader, %81
  %indvars.iv70 = phi i64 [ %62, %.lr.ph57.preheader ], [ %indvars.iv.next71, %81 ]
  %.03654 = phi i32 [ %34, %.lr.ph57.preheader ], [ %75, %81 ]
  %indvars.iv.next71 = add nsw i64 %indvars.iv70, -1
  %73 = getelementptr inbounds [1000006 x %struct.query], ptr @querys, i64 0, i64 %indvars.iv.next71
  %74 = getelementptr inbounds i8, ptr %73, i64 4
  %75 = load i32, ptr %74, align 4, !tbaa !17
  %76 = load i32, ptr %73, align 4, !tbaa !19
  %77 = getelementptr inbounds i8, ptr %73, i64 8
  %78 = load i32, ptr %77, align 4, !tbaa !20
  %79 = icmp slt i32 %75, %.03654
  br i1 %79, label %80, label %81

80:                                               ; preds = %.lr.ph57
  call void @_Z3fixii(i32 noundef %75, i32 noundef %.03654)
  br label %81

81:                                               ; preds = %80, %.lr.ph57
  %82 = load i32, ptr @n, align 4, !tbaa !8
  %83 = call i32 @_Z6getsumxiiii(i64 noundef 1, i32 noundef 1, i32 noundef %82, i32 noundef %76, i32 noundef %75)
  %84 = sext i32 %78 to i64
  %85 = getelementptr inbounds i32, ptr %38, i64 %84
  store i32 %83, ptr %85, align 4, !tbaa !8
  %86 = icmp ugt i64 %indvars.iv70, 1
  br i1 %86, label %.lr.ph57, label %.preheader, !llvm.loop !21

._crit_edge60:                                    ; preds = %.lr.ph59, %._crit_edge51, %.preheader
  call void @llvm.stackrestore.p0(ptr %37)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  ret i32 0

.lr.ph59:                                         ; preds = %.preheader, %.lr.ph59
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %.lr.ph59 ], [ 0, %.preheader ]
  %87 = getelementptr inbounds i32, ptr %38, i64 %indvars.iv73
  %88 = load i32, ptr %87, align 4, !tbaa !8
  %89 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %88)
  %90 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %89, ptr noundef nonnull @.str)
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %91 = load i32, ptr %2, align 4, !tbaa !8
  %92 = sext i32 %91 to i64
  %93 = icmp slt i64 %indvars.iv.next74, %92
  br i1 %93, label %.lr.ph59, label %._crit_edge60, !llvm.loop !22
}

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

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

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 #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #6

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #7

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #6

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #7 = { 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 #8 = { 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 = !{!12, !9, i64 0}
!12 = !{!"_ZTS2fo", !9, i64 0, !9, i64 4}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = !{!18, !9, i64 4}
!18 = !{!"_ZTS5query", !9, i64 0, !9, i64 4, !9, i64 8}
!19 = !{!18, !9, i64 0}
!20 = !{!18, !9, i64 8}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}


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