; LLVM IR from tangjz/acm-icpc :: lydsy/1039.ll (Z4initv)

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

@a = external dso_local global [1650050 x %struct.Node], align 16
@que = external dso_local global [1650050 x %struct.Node], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@fir = external dso_local global [400020 x i32], align 16
@q_tot = external dso_local global i32, align 4
@len = external dso_local global i32, align 4
@seq = external dso_local global [1650050 x i32], align 16
@ans = external dso_local global [200010 x i32], align 16
@rk = external dso_local global [1650050 x i32], align 16
@ht = external dso_local global [1650050 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkii(i32 noundef, i32 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6insertiiPiS_(i32 noundef, i32 noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca %struct.Node, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.Node, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.Node, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  store ptr @rk, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store ptr @ht, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #6
  %13 = getelementptr inbounds %struct.Node, ptr %3, i32 0, i32 0
  store i32 0, ptr %13, align 4, !tbaa !9
  %14 = getelementptr inbounds %struct.Node, ptr %3, i32 0, i32 1
  store i32 0, ptr %14, align 4, !tbaa !12
  %15 = getelementptr inbounds %struct.Node, ptr %3, i32 0, i32 2
  store i32 0, ptr %15, align 4, !tbaa !13
  %16 = getelementptr inbounds %struct.Node, ptr %3, i32 0, i32 3
  store i32 0, ptr %16, align 4, !tbaa !14
  %17 = load i32, ptr @q_tot, align 4, !tbaa !15
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr @q_tot, align 4, !tbaa !15
  %19 = sext i32 %17 to i64
  %20 = getelementptr inbounds [1650050 x %struct.Node], ptr @que, i64 0, i64 %19
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %20, ptr align 4 %3, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !15
  br label %21

21:                                               ; preds = %123, %0
  %22 = load i32, ptr %4, align 4, !tbaa !15
  %23 = load i32, ptr @m, align 4, !tbaa !15
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %126

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !15
  br label %28

28:                                               ; preds = %43, %26
  %29 = load i32, ptr %7, align 4, !tbaa !15
  %30 = load i32, ptr %6, align 4, !tbaa !15
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %46

33:                                               ; preds = %28
  %34 = load ptr, ptr %1, align 8, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !15
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr %34, i64 %36
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !15
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %37, ptr noundef %41)
  br label %43

43:                                               ; preds = %33
  %44 = load i32, ptr %7, align 4, !tbaa !15
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %7, align 4, !tbaa !15
  br label %28, !llvm.loop !17

46:                                               ; preds = %32
  %47 = load i32, ptr %6, align 4, !tbaa !15
  %48 = load i32, ptr @n, align 4, !tbaa !15
  %49 = icmp sgt i32 %47, %48
  br i1 %49, label %53, label %50

50:                                               ; preds = %46
  %51 = load i32, ptr %6, align 4, !tbaa !15
  %52 = icmp sle i32 %51, 2
  br i1 %52, label %53, label %66

53:                                               ; preds = %50, %46
  %54 = load i32, ptr %6, align 4, !tbaa !15
  %55 = load i32, ptr @n, align 4, !tbaa !15
  %56 = icmp sle i32 %54, %55
  br i1 %56, label %57, label %65

57:                                               ; preds = %53
  %58 = load i32, ptr @n, align 4, !tbaa !15
  %59 = load i32, ptr %6, align 4, !tbaa !15
  %60 = sub nsw i32 %58, %59
  %61 = add nsw i32 %60, 1
  %62 = load i32, ptr %4, align 4, !tbaa !15
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200010 x i32], ptr @ans, i64 0, i64 %63
  store i32 %61, ptr %64, align 4, !tbaa !15
  br label %65

65:                                               ; preds = %57, %53
  store i32 4, ptr %5, align 4
  br label %120

66:                                               ; preds = %50
  %67 = load i32, ptr %4, align 4, !tbaa !15
  %68 = load i32, ptr %6, align 4, !tbaa !15
  %69 = load ptr, ptr %1, align 8, !tbaa !5
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_Z6insertiiPiS_(i32 noundef %67, i32 noundef %68, ptr noundef %69, ptr noundef %70)
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  %71 = getelementptr inbounds %struct.Node, ptr %8, i32 0, i32 0
  store i32 0, ptr %71, align 4, !tbaa !9
  %72 = getelementptr inbounds %struct.Node, ptr %8, i32 0, i32 1
  store i32 0, ptr %72, align 4, !tbaa !12
  %73 = getelementptr inbounds %struct.Node, ptr %8, i32 0, i32 2
  store i32 0, ptr %73, align 4, !tbaa !13
  %74 = getelementptr inbounds %struct.Node, ptr %8, i32 0, i32 3
  store i32 0, ptr %74, align 4, !tbaa !14
  %75 = load i32, ptr @len, align 4, !tbaa !15
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr @len, align 4, !tbaa !15
  %77 = sext i32 %75 to i64
  %78 = getelementptr inbounds [1650050 x %struct.Node], ptr @a, i64 0, i64 %77
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %78, ptr align 4 %8, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  %79 = load i32, ptr @tot, align 4, !tbaa !15
  %80 = sub nsw i32 %79, 1
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [400020 x i32], ptr @fir, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !15
  %84 = load i32, ptr @len, align 4, !tbaa !15
  %85 = call noundef zeroext i1 @_Z5checkii(i32 noundef %83, i32 noundef %84)
  br i1 %85, label %86, label %119

86:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !15
  br label %87

87:                                               ; preds = %103, %86
  %88 = load i32, ptr %9, align 4, !tbaa !15
  %89 = load i32, ptr %6, align 4, !tbaa !15
  %90 = icmp slt i32 %88, %89
  br i1 %90, label %92, label %91

91:                                               ; preds = %87
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %106

92:                                               ; preds = %87
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = load i32, ptr %9, align 4, !tbaa !15
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i32, ptr %93, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !15
  %98 = sub nsw i32 0, %97
  %99 = load ptr, ptr %2, align 8, !tbaa !5
  %100 = load i32, ptr %9, align 4, !tbaa !15
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds i32, ptr %99, i64 %101
  store i32 %98, ptr %102, align 4, !tbaa !15
  br label %103

103:                                              ; preds = %92
  %104 = load i32, ptr %9, align 4, !tbaa !15
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %9, align 4, !tbaa !15
  br label %87, !llvm.loop !19

106:                                              ; preds = %91
  %107 = load i32, ptr %4, align 4, !tbaa !15
  %108 = load i32, ptr %6, align 4, !tbaa !15
  %109 = load ptr, ptr %1, align 8, !tbaa !5
  %110 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_Z6insertiiPiS_(i32 noundef %107, i32 noundef %108, ptr noundef %109, ptr noundef %110)
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  %111 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 0
  store i32 0, ptr %111, align 4, !tbaa !9
  %112 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 1
  store i32 0, ptr %112, align 4, !tbaa !12
  %113 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 2
  store i32 0, ptr %113, align 4, !tbaa !13
  %114 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 3
  store i32 0, ptr %114, align 4, !tbaa !14
  %115 = load i32, ptr @len, align 4, !tbaa !15
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr @len, align 4, !tbaa !15
  %117 = sext i32 %115 to i64
  %118 = getelementptr inbounds [1650050 x %struct.Node], ptr @a, i64 0, i64 %117
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %118, ptr align 4 %10, i64 16, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  br label %119

119:                                              ; preds = %106, %66
  store i32 0, ptr %5, align 4
  br label %120

120:                                              ; preds = %119, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %121 = load i32, ptr %5, align 4
  switch i32 %121, label %190 [
    i32 0, label %122
    i32 4, label %123
  ]

122:                                              ; preds = %120
  br label %123

123:                                              ; preds = %122, %120
  %124 = load i32, ptr %4, align 4, !tbaa !15
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %4, align 4, !tbaa !15
  br label %21, !llvm.loop !20

126:                                              ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !15
  br label %127

127:                                              ; preds = %142, %126
  %128 = load i32, ptr %11, align 4, !tbaa !15
  %129 = load i32, ptr @n, align 4, !tbaa !15
  %130 = icmp slt i32 %128, %129
  br i1 %130, label %132, label %131

131:                                              ; preds = %127
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %145

132:                                              ; preds = %127
  %133 = load ptr, ptr %1, align 8, !tbaa !5
  %134 = load i32, ptr %11, align 4, !tbaa !15
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds i32, ptr %133, i64 %135
  %137 = load ptr, ptr %2, align 8, !tbaa !5
  %138 = load i32, ptr %11, align 4, !tbaa !15
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds i32, ptr %137, i64 %139
  %141 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %136, ptr noundef %140)
  br label %142

142:                                              ; preds = %132
  %143 = load i32, ptr %11, align 4, !tbaa !15
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %11, align 4, !tbaa !15
  br label %127, !llvm.loop !21

145:                                              ; preds = %131
  %146 = load i32, ptr @m, align 4, !tbaa !15
  %147 = load i32, ptr @n, align 4, !tbaa !15
  %148 = load ptr, ptr %1, align 8, !tbaa !5
  %149 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_Z6insertiiPiS_(i32 noundef %146, i32 noundef %147, ptr noundef %148, ptr noundef %149)
  %150 = load i32, ptr @tot, align 4, !tbaa !15
  %151 = add nsw i32 %150, -1
  store i32 %151, ptr @tot, align 4, !tbaa !15
  %152 = load i32, ptr @q_tot, align 4, !tbaa !15
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds %struct.Node, ptr @que, i64 %153
  call void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef @que, ptr noundef %154)
  %155 = load i32, ptr @q_tot, align 4, !tbaa !15
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds %struct.Node, ptr @que, i64 %156
  %158 = call noundef ptr @_ZSt6uniqueIP4NodeET_S2_S2_(ptr noundef @que, ptr noundef %157)
  %159 = ptrtoint ptr %158 to i64
  %160 = sub i64 %159, ptrtoint (ptr @que to i64)
  %161 = sdiv exact i64 %160, 16
  %162 = trunc i64 %161 to i32
  store i32 %162, ptr @q_tot, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !15
  br label %163

163:                                              ; preds = %183, %145
  %164 = load i32, ptr %12, align 4, !tbaa !15
  %165 = load i32, ptr @len, align 4, !tbaa !15
  %166 = icmp slt i32 %164, %165
  br i1 %166, label %168, label %167

167:                                              ; preds = %163
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %186

168:                                              ; preds = %163
  %169 = load i32, ptr @q_tot, align 4, !tbaa !15
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds %struct.Node, ptr @que, i64 %170
  %172 = load i32, ptr %12, align 4, !tbaa !15
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [1650050 x %struct.Node], ptr @a, i64 0, i64 %173
  %175 = call noundef ptr @_ZSt11lower_boundIP4NodeS0_ET_S2_S2_RKT0_(ptr noundef @que, ptr noundef %171, ptr noundef nonnull align 4 dereferenceable(16) %174)
  %176 = ptrtoint ptr %175 to i64
  %177 = sub i64 %176, ptrtoint (ptr @que to i64)
  %178 = sdiv exact i64 %177, 16
  %179 = trunc i64 %178 to i32
  %180 = load i32, ptr %12, align 4, !tbaa !15
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [1650050 x i32], ptr @seq, i64 0, i64 %181
  store i32 %179, ptr %182, align 4, !tbaa !15
  br label %183

183:                                              ; preds = %168
  %184 = load i32, ptr %12, align 4, !tbaa !15
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %12, align 4, !tbaa !15
  br label %163, !llvm.loop !22

186:                                              ; preds = %167
  %187 = load i32, ptr @len, align 4, !tbaa !15
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [1650050 x i32], ptr @seq, i64 0, i64 %188
  store i32 -1, ptr %189, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  ret void

190:                                              ; preds = %120
  unreachable
}

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

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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

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

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


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

@a = external dso_local global [1650050 x %struct.Node], align 16
@que = external dso_local global [1650050 x %struct.Node], align 16
@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@fir = external dso_local local_unnamed_addr global [400020 x i32], align 16
@q_tot = external dso_local local_unnamed_addr global i32, align 4
@len = external dso_local local_unnamed_addr global i32, align 4
@seq = external dso_local local_unnamed_addr global [1650050 x i32], align 16
@ans = external dso_local local_unnamed_addr global [200010 x i32], align 16
@rk = external dso_local global [1650050 x i32], align 16
@ht = external dso_local global [1650050 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkii(i32 noundef, i32 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 void @_Z6insertiiPiS_(i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = load i32, ptr @q_tot, align 4, !tbaa !5
  %3 = add nsw i32 %2, 1
  store i32 %3, ptr @q_tot, align 4, !tbaa !5
  %4 = sext i32 %2 to i64
  %5 = getelementptr inbounds [1650050 x %struct.Node], ptr @que, i64 0, i64 %4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  %6 = load i32, ptr @m, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph61, label %.preheader

.preheader:                                       ; preds = %56, %0
  %8 = phi i32 [ %6, %0 ], [ %57, %56 ]
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph63, label %._crit_edge64

.lr.ph61:                                         ; preds = %0, %56
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %56 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %12 = load i32, ptr %1, align 4
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %.lr.ph61
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp sgt i32 %12, %14
  br i1 %15, label %56, label %26

._crit_edge:                                      ; preds = %.lr.ph
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = icmp sgt i32 %22, %16
  %18 = icmp slt i32 %22, 3
  %or.cond = or i1 %18, %17
  br i1 %or.cond, label %25, label %30

.lr.ph:                                           ; preds = %.lr.ph61, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph61 ]
  %19 = getelementptr inbounds i32, ptr @rk, i64 %indvars.iv
  %20 = getelementptr inbounds i32, ptr @ht, i64 %indvars.iv
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %19, ptr noundef nonnull %20)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = load i32, ptr %1, align 4
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv.next, %23
  br i1 %24, label %.lr.ph, label %._crit_edge, !llvm.loop !9

25:                                               ; preds = %._crit_edge
  br i1 %17, label %56, label %26

26:                                               ; preds = %._crit_edge.thread, %25
  %.lcssa529091 = phi i32 [ %12, %._crit_edge.thread ], [ %22, %25 ]
  %27 = phi i32 [ %14, %._crit_edge.thread ], [ %16, %25 ]
  %reass.sub = sub i32 %27, %.lcssa529091
  %28 = add i32 %reass.sub, 1
  %29 = getelementptr inbounds [200010 x i32], ptr @ans, i64 0, i64 %indvars.iv78
  store i32 %28, ptr %29, align 4, !tbaa !5
  br label %56

30:                                               ; preds = %._crit_edge
  %31 = trunc nuw nsw i64 %indvars.iv78 to i32
  call void @_Z6insertiiPiS_(i32 noundef %31, i32 noundef %22, ptr noundef nonnull @rk, ptr noundef nonnull @ht)
  %32 = load i32, ptr @len, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr @len, align 4, !tbaa !5
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds [1650050 x %struct.Node], ptr @a, i64 0, i64 %34
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %35, i8 0, i64 16, i1 false)
  %36 = load i32, ptr @tot, align 4, !tbaa !5
  %37 = add nsw i32 %36, -1
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [400020 x i32], ptr @fir, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = call noundef zeroext i1 @_Z5checkii(i32 noundef %40, i32 noundef %33)
  br i1 %41, label %.preheader50, label %56

.preheader50:                                     ; preds = %30
  %42 = load i32, ptr %1, align 4, !tbaa !5
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %.lr.ph56.preheader, label %._crit_edge57

.lr.ph56.preheader:                               ; preds = %.preheader50
  %wide.trip.count = zext nneg i32 %42 to i64
  %min.iters.check = icmp ult i32 %42, 8
  br i1 %min.iters.check, label %.lr.ph56.preheader100, label %vector.ph

.lr.ph56.preheader100:                            ; preds = %middle.block, %.lr.ph56.preheader
  %indvars.iv75.ph = phi i64 [ 0, %.lr.ph56.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph56

vector.ph:                                        ; preds = %.lr.ph56.preheader
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %44 = getelementptr inbounds i32, ptr @ht, i64 %index
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  %wide.load = load <4 x i32>, ptr %44, align 16, !tbaa !5
  %wide.load98 = load <4 x i32>, ptr %45, align 16, !tbaa !5
  %46 = sub nsw <4 x i32> zeroinitializer, %wide.load
  %47 = sub nsw <4 x i32> zeroinitializer, %wide.load98
  store <4 x i32> %46, ptr %44, align 16, !tbaa !5
  store <4 x i32> %47, ptr %45, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %48 = icmp eq i64 %index.next, %n.vec
  br i1 %48, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge57, label %.lr.ph56.preheader100

._crit_edge57:                                    ; preds = %.lr.ph56, %middle.block, %.preheader50
  call void @_Z6insertiiPiS_(i32 noundef %31, i32 noundef %42, ptr noundef nonnull @rk, ptr noundef nonnull @ht)
  %49 = load i32, ptr @len, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr @len, align 4, !tbaa !5
  %51 = sext i32 %49 to i64
  %52 = getelementptr inbounds [1650050 x %struct.Node], ptr @a, i64 0, i64 %51
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %52, i8 0, i64 16, i1 false)
  br label %56

.lr.ph56:                                         ; preds = %.lr.ph56.preheader100, %.lr.ph56
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %.lr.ph56 ], [ %indvars.iv75.ph, %.lr.ph56.preheader100 ]
  %53 = getelementptr inbounds i32, ptr @ht, i64 %indvars.iv75
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = sub nsw i32 0, %54
  store i32 %55, ptr %53, align 4, !tbaa !5
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next76, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge57, label %.lr.ph56, !llvm.loop !14

56:                                               ; preds = %._crit_edge.thread, %30, %._crit_edge57, %25, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %57 = load i32, ptr @m, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = icmp slt i64 %indvars.iv.next79, %58
  br i1 %59, label %.lr.ph61, label %.preheader, !llvm.loop !15

._crit_edge64.loopexit:                           ; preds = %.lr.ph63
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %._crit_edge64

._crit_edge64:                                    ; preds = %._crit_edge64.loopexit, %.preheader
  %60 = phi i32 [ %8, %.preheader ], [ %.pre, %._crit_edge64.loopexit ]
  %.lcssa51 = phi i32 [ %9, %.preheader ], [ %79, %._crit_edge64.loopexit ]
  call void @_Z6insertiiPiS_(i32 noundef %60, i32 noundef %.lcssa51, ptr noundef nonnull @rk, ptr noundef nonnull @ht)
  %61 = load i32, ptr @tot, align 4, !tbaa !5
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr @tot, align 4, !tbaa !5
  %63 = load i32, ptr @q_tot, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds %struct.Node, ptr @que, i64 %64
  call void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef nonnull @que, ptr noundef nonnull %65)
  %66 = load i32, ptr @q_tot, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds %struct.Node, ptr @que, i64 %67
  %69 = call noundef ptr @_ZSt6uniqueIP4NodeET_S2_S2_(ptr noundef nonnull @que, ptr noundef nonnull %68)
  %70 = ptrtoint ptr %69 to i64
  %71 = sub i64 %70, ptrtoint (ptr @que to i64)
  %72 = lshr exact i64 %71, 4
  %73 = trunc i64 %72 to i32
  store i32 %73, ptr @q_tot, align 4, !tbaa !5
  %74 = load i32, ptr @len, align 4, !tbaa !5
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %.lr.ph68, label %._crit_edge64.._crit_edge69_crit_edge

._crit_edge64.._crit_edge69_crit_edge:            ; preds = %._crit_edge64
  %.pre87 = sext i32 %74 to i64
  br label %._crit_edge69

.lr.ph63:                                         ; preds = %.preheader, %.lr.ph63
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %.lr.ph63 ], [ 0, %.preheader ]
  %76 = getelementptr inbounds i32, ptr @rk, i64 %indvars.iv81
  %77 = getelementptr inbounds i32, ptr @ht, i64 %indvars.iv81
  %78 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %76, ptr noundef nonnull %77)
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = icmp slt i64 %indvars.iv.next82, %80
  br i1 %81, label %.lr.ph63, label %._crit_edge64.loopexit, !llvm.loop !16

._crit_edge69:                                    ; preds = %.lr.ph68, %._crit_edge64.._crit_edge69_crit_edge
  %.pre-phi = phi i64 [ %.pre87, %._crit_edge64.._crit_edge69_crit_edge ], [ %94, %.lr.ph68 ]
  %82 = getelementptr inbounds [1650050 x i32], ptr @seq, i64 0, i64 %.pre-phi
  store i32 -1, ptr %82, align 4, !tbaa !5
  ret void

.lr.ph68:                                         ; preds = %._crit_edge64, %.lr.ph68
  %indvars.iv84 = phi i64 [ %indvars.iv.next85, %.lr.ph68 ], [ 0, %._crit_edge64 ]
  %83 = load i32, ptr @q_tot, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds %struct.Node, ptr @que, i64 %84
  %86 = getelementptr inbounds [1650050 x %struct.Node], ptr @a, i64 0, i64 %indvars.iv84
  %87 = call noundef ptr @_ZSt11lower_boundIP4NodeS0_ET_S2_S2_RKT0_(ptr noundef nonnull @que, ptr noundef nonnull %85, ptr noundef nonnull align 4 dereferenceable(16) %86)
  %88 = ptrtoint ptr %87 to i64
  %89 = sub i64 %88, ptrtoint (ptr @que to i64)
  %90 = lshr exact i64 %89, 4
  %91 = trunc i64 %90 to i32
  %92 = getelementptr inbounds [1650050 x i32], ptr @seq, i64 0, i64 %indvars.iv84
  store i32 %91, ptr %92, align 4, !tbaa !5
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %93 = load i32, ptr @len, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = icmp slt i64 %indvars.iv.next85, %94
  br i1 %95, label %.lr.ph68, label %._crit_edge69, !llvm.loop !17
}

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

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

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

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

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10, !13, !12}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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