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

; 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, i32 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@num = external dso_local global [100001 x i32], align 16
@f1 = external dso_local global [101 x [101 x i32]], align 16
@f2 = external dso_local global [10001 x i32], align 16
@ans = external dso_local global [100001 x i32], align 16
@Q = external dso_local global [200002 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; 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 %struct.Node, align 4
  %10 = alloca %struct.Node, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %34, %0
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %19
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr @num, i64 %26
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %27)
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100001 x i32], ptr @num, i64 0, i64 %30
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %31)
  %33 = load i32, ptr %32, align 4, !tbaa !5
  store i32 %33, ptr %2, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %24
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %3, align 4, !tbaa !5
  br label %19, !llvm.loop !9

37:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  br label %38

38:                                               ; preds = %73, %37
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = load i32, ptr @m, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %38
  %44 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 20, ptr %9) #6
  %45 = getelementptr inbounds %struct.Node, ptr %9, i32 0, i32 0
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = sub nsw i32 %46, 1
  store i32 %47, ptr %45, align 4, !tbaa !11
  %48 = getelementptr inbounds %struct.Node, ptr %9, i32 0, i32 1
  store i32 -1, ptr %48, align 4, !tbaa !13
  %49 = getelementptr inbounds %struct.Node, ptr %9, i32 0, i32 2
  %50 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %50, ptr %49, align 4, !tbaa !14
  %51 = getelementptr inbounds %struct.Node, ptr %9, i32 0, i32 3
  %52 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %52, ptr %51, align 4, !tbaa !15
  %53 = getelementptr inbounds %struct.Node, ptr %9, i32 0, i32 4
  %54 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %54, ptr %53, align 4, !tbaa !16
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = shl i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %57
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %58, ptr align 4 %9, i64 20, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 20, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 20, ptr %10) #6
  %59 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 0
  %60 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %60, ptr %59, align 4, !tbaa !11
  %61 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 1
  store i32 1, ptr %61, align 4, !tbaa !13
  %62 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 2
  %63 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %63, ptr %62, align 4, !tbaa !14
  %64 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 3
  %65 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %65, ptr %64, align 4, !tbaa !15
  %66 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 4
  %67 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %67, ptr %66, align 4, !tbaa !16
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = shl i32 %68, 1
  %70 = add nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %71
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %72, ptr align 4 %10, i64 20, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 20, ptr %10) #6
  br label %73

73:                                               ; preds = %43
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %4, align 4, !tbaa !5
  br label %38, !llvm.loop !18

76:                                               ; preds = %42
  %77 = load i32, ptr @m, align 4, !tbaa !5
  %78 = shl i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %struct.Node, ptr @Q, i64 %79
  call void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef @Q, ptr noundef %80)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %81 = load i32, ptr @m, align 4, !tbaa !5
  %82 = shl i32 %81, 1
  store i32 %82, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %209, %76
  %84 = load i32, ptr %11, align 4, !tbaa !5
  %85 = load i32, ptr %12, align 4, !tbaa !5
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %212

88:                                               ; preds = %83
  br label %89

89:                                               ; preds = %121, %88
  %90 = load i32, ptr %13, align 4, !tbaa !5
  %91 = load i32, ptr %11, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.Node, ptr %93, i32 0, i32 0
  %95 = load i32, ptr %94, align 4, !tbaa !11
  %96 = icmp slt i32 %90, %95
  br i1 %96, label %97, label %130

97:                                               ; preds = %89
  %98 = load i32, ptr %13, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 1, ptr %15, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %118, %97
  %101 = load i32, ptr %15, align 4, !tbaa !5
  %102 = icmp sle i32 %101, 100
  br i1 %102, label %104, label %103

103:                                              ; preds = %100
  store i32 13, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %121

104:                                              ; preds = %100
  %105 = load i32, ptr %15, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [101 x [101 x i32]], ptr @f1, i64 0, i64 %106
  %108 = load i32, ptr %13, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100001 x i32], ptr @num, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = load i32, ptr %15, align 4, !tbaa !5
  %113 = srem i32 %111, %112
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [101 x i32], ptr %107, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %115, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %104
  %119 = load i32, ptr %15, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %15, align 4, !tbaa !5
  br label %100, !llvm.loop !19

121:                                              ; preds = %103
  %122 = load i32, ptr %13, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [100001 x i32], ptr @num, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [10001 x i32], ptr @f2, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %127, align 4, !tbaa !5
  br label %89, !llvm.loop !20

130:                                              ; preds = %89
  %131 = load i32, ptr %11, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %132
  %134 = getelementptr inbounds %struct.Node, ptr %133, i32 0, i32 2
  %135 = load i32, ptr %134, align 4, !tbaa !14
  %136 = icmp sle i32 %135, 100
  br i1 %136, label %137, label %168

137:                                              ; preds = %130
  %138 = load i32, ptr %11, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %139
  %141 = getelementptr inbounds %struct.Node, ptr %140, i32 0, i32 1
  %142 = load i32, ptr %141, align 4, !tbaa !13
  %143 = load i32, ptr %11, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %144
  %146 = getelementptr inbounds %struct.Node, ptr %145, i32 0, i32 2
  %147 = load i32, ptr %146, align 4, !tbaa !14
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [101 x [101 x i32]], ptr @f1, i64 0, i64 %148
  %150 = load i32, ptr %11, align 4, !tbaa !5
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %151
  %153 = getelementptr inbounds %struct.Node, ptr %152, i32 0, i32 3
  %154 = load i32, ptr %153, align 4, !tbaa !15
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [101 x i32], ptr %149, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = mul nsw i32 %142, %157
  %159 = load i32, ptr %11, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %160
  %162 = getelementptr inbounds %struct.Node, ptr %161, i32 0, i32 4
  %163 = load i32, ptr %162, align 4, !tbaa !16
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %164
  %166 = load i32, ptr %165, align 4, !tbaa !5
  %167 = add nsw i32 %166, %158
  store i32 %167, ptr %165, align 4, !tbaa !5
  br label %208

168:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %169 = load i32, ptr %11, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %170
  %172 = getelementptr inbounds %struct.Node, ptr %171, i32 0, i32 3
  %173 = load i32, ptr %172, align 4, !tbaa !15
  store i32 %173, ptr %16, align 4, !tbaa !5
  br label %174

174:                                              ; preds = %199, %168
  %175 = load i32, ptr %16, align 4, !tbaa !5
  %176 = load i32, ptr %2, align 4, !tbaa !5
  %177 = icmp sle i32 %175, %176
  br i1 %177, label %179, label %178

178:                                              ; preds = %174
  store i32 16, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %207

179:                                              ; preds = %174
  %180 = load i32, ptr %11, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %181
  %183 = getelementptr inbounds %struct.Node, ptr %182, i32 0, i32 1
  %184 = load i32, ptr %183, align 4, !tbaa !13
  %185 = load i32, ptr %16, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [10001 x i32], ptr @f2, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = mul nsw i32 %184, %188
  %190 = load i32, ptr %11, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %191
  %193 = getelementptr inbounds %struct.Node, ptr %192, i32 0, i32 4
  %194 = load i32, ptr %193, align 4, !tbaa !16
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %195
  %197 = load i32, ptr %196, align 4, !tbaa !5
  %198 = add nsw i32 %197, %189
  store i32 %198, ptr %196, align 4, !tbaa !5
  br label %199

199:                                              ; preds = %179
  %200 = load i32, ptr %11, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %201
  %203 = getelementptr inbounds %struct.Node, ptr %202, i32 0, i32 2
  %204 = load i32, ptr %203, align 4, !tbaa !14
  %205 = load i32, ptr %16, align 4, !tbaa !5
  %206 = add nsw i32 %205, %204
  store i32 %206, ptr %16, align 4, !tbaa !5
  br label %174, !llvm.loop !21

207:                                              ; preds = %178
  br label %208

208:                                              ; preds = %207, %137
  br label %209

209:                                              ; preds = %208
  %210 = load i32, ptr %11, align 4, !tbaa !5
  %211 = add nsw i32 %210, 1
  store i32 %211, ptr %11, align 4, !tbaa !5
  br label %83, !llvm.loop !22

212:                                              ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %213

213:                                              ; preds = %224, %212
  %214 = load i32, ptr %17, align 4, !tbaa !5
  %215 = load i32, ptr @m, align 4, !tbaa !5
  %216 = icmp slt i32 %214, %215
  br i1 %216, label %218, label %217

217:                                              ; preds = %213
  store i32 19, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %227

218:                                              ; preds = %213
  %219 = load i32, ptr %17, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %220
  %222 = load i32, ptr %221, align 4, !tbaa !5
  %223 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %222)
  br label %224

224:                                              ; preds = %218
  %225 = load i32, ptr %17, align 4, !tbaa !5
  %226 = add nsw i32 %225, 1
  store i32 %226, ptr %17, align 4, !tbaa !5
  br label %213, !llvm.loop !23

227:                                              ; preds = %217
  store i32 0, ptr %1, align 4
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %228 = load i32, ptr %1, align 4
  ret i32 %228
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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) #4

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

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

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

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


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

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@num = external dso_local global [100001 x i32], align 16
@f1 = external dso_local local_unnamed_addr global [101 x [101 x i32]], align 16
@f2 = external dso_local local_unnamed_addr global [10001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i32], align 16
@Q = external dso_local global [200002 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; 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 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not53 = icmp slt i32 %7, 1
  br i1 %.not53, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %8 = load i32, ptr @m, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph57, label %._crit_edge58

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

._crit_edge58:                                    ; preds = %.lr.ph57, %._crit_edge
  %.lcssa52 = phi i32 [ %8, %._crit_edge ], [ %37, %.lr.ph57 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %16 = shl i32 %.lcssa52, 1
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds %struct.Node, ptr @Q, i64 %17
  call void @_ZSt4sortIP4NodeEvT_S2_(ptr noundef nonnull @Q, ptr noundef nonnull %18)
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = shl i32 %19, 1
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.preheader51.lr.ph, label %.preheader

.preheader51.lr.ph:                               ; preds = %._crit_edge58
  %22 = load i32, ptr %1, align 4
  %23 = sext i32 %22 to i64
  %wide.trip.count = zext nneg i32 %20 to i64
  br label %.preheader51

.lr.ph57:                                         ; preds = %._crit_edge, %.lr.ph57
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %.lr.ph57 ], [ 0, %._crit_edge ]
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, -1
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %sext = shl i64 %indvars.iv76, 33
  %29 = ashr exact i64 %sext, 32
  %30 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %29
  store i32 %26, ptr %30, align 8, !tbaa !5
  %.sroa.428.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 4
  store i32 -1, ptr %.sroa.428.0..sroa_idx, align 4, !tbaa !5
  %.sroa.529.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 8
  store i32 %27, ptr %.sroa.529.0..sroa_idx, align 8, !tbaa !5
  %.sroa.630.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 12
  store i32 %28, ptr %.sroa.630.0..sroa_idx, align 4, !tbaa !5
  %.sroa.731.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 16
  %31 = trunc nuw nsw i64 %indvars.iv76 to i32
  store i32 %31, ptr %.sroa.731.0..sroa_idx, align 8, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %indvars.iv76.tr = trunc i64 %indvars.iv76 to i32
  %33 = shl i32 %indvars.iv76.tr, 1
  %34 = or disjoint i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %35
  store i32 %32, ptr %36, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %36, i64 4
  store i32 1, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %36, i64 8
  store i32 %27, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %36, i64 12
  store i32 %28, ptr %.sroa.6.0..sroa_idx, align 8, !tbaa !5
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %36, i64 16
  store i32 %31, ptr %.sroa.7.0..sroa_idx, align 4, !tbaa !5
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %37 = load i32, ptr @m, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = icmp slt i64 %indvars.iv.next77, %38
  br i1 %39, label %.lr.ph57, label %._crit_edge58, !llvm.loop !11

.preheader51:                                     ; preds = %.preheader51.lr.ph, %.loopexit
  %indvars.iv89 = phi i64 [ 0, %.preheader51.lr.ph ], [ %indvars.iv.next90, %.loopexit ]
  %.04570 = phi i32 [ 0, %.preheader51.lr.ph ], [ %.1.lcssa, %.loopexit ]
  %40 = getelementptr inbounds [200002 x %struct.Node], ptr @Q, i64 0, i64 %indvars.iv89
  %41 = load i32, ptr %40, align 4, !tbaa !12
  %42 = icmp slt i32 %.04570, %41
  br i1 %42, label %.lr.ph61.preheader, label %._crit_edge62

.lr.ph61.preheader:                               ; preds = %.preheader51
  %43 = sext i32 %.04570 to i64
  %44 = sext i32 %41 to i64
  br label %.lr.ph61

.preheader:                                       ; preds = %.loopexit, %._crit_edge58
  %45 = icmp sgt i32 %19, 0
  br i1 %45, label %.lr.ph72, label %._crit_edge73

.lr.ph61:                                         ; preds = %.lr.ph61.preheader, %48
  %indvars.iv82 = phi i64 [ %43, %.lr.ph61.preheader ], [ %indvars.iv.next83, %48 ]
  %indvars.iv.next83 = add nsw i64 %indvars.iv82, 1
  %46 = getelementptr inbounds [100001 x i32], ptr @num, i64 0, i64 %indvars.iv.next83
  %47 = load i32, ptr %46, align 4, !tbaa !5
  br label %53

48:                                               ; preds = %53
  %49 = sext i32 %47 to i64
  %50 = getelementptr inbounds [10001 x i32], ptr @f2, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %50, align 4, !tbaa !5
  %exitcond85.not = icmp eq i64 %indvars.iv.next83, %44
  br i1 %exitcond85.not, label %._crit_edge62, label %.lr.ph61, !llvm.loop !14

53:                                               ; preds = %53, %.lr.ph61
  %indvars.iv79 = phi i64 [ 1, %.lr.ph61 ], [ %indvars.iv.next80.1, %53 ]
  %54 = trunc nuw nsw i64 %indvars.iv79 to i32
  %55 = srem i32 %47, %54
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [101 x [101 x i32]], ptr @f1, i64 0, i64 %indvars.iv79, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %57, align 4, !tbaa !5
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %60 = trunc nuw nsw i64 %indvars.iv.next80 to i32
  %61 = srem i32 %47, %60
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [101 x [101 x i32]], ptr @f1, i64 0, i64 %indvars.iv.next80, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %63, align 4, !tbaa !5
  %indvars.iv.next80.1 = add nuw nsw i64 %indvars.iv79, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next80.1, 101
  br i1 %exitcond.not.1, label %48, label %53, !llvm.loop !15

._crit_edge62:                                    ; preds = %48, %.preheader51
  %.1.lcssa = phi i32 [ %.04570, %.preheader51 ], [ %41, %48 ]
  %66 = getelementptr inbounds i8, ptr %40, i64 8
  %67 = load i32, ptr %66, align 4, !tbaa !16
  %68 = icmp slt i32 %67, 101
  br i1 %68, label %69, label %85

69:                                               ; preds = %._crit_edge62
  %70 = getelementptr inbounds i8, ptr %40, i64 4
  %71 = load i32, ptr %70, align 4, !tbaa !17
  %72 = sext i32 %67 to i64
  %73 = getelementptr inbounds i8, ptr %40, i64 12
  %74 = load i32, ptr %73, align 4, !tbaa !18
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [101 x [101 x i32]], ptr @f1, i64 0, i64 %72, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = mul nsw i32 %77, %71
  %79 = getelementptr inbounds i8, ptr %40, i64 16
  %80 = load i32, ptr %79, align 4, !tbaa !19
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nsw i32 %83, %78
  store i32 %84, ptr %82, align 4, !tbaa !5
  br label %.loopexit

85:                                               ; preds = %._crit_edge62
  %86 = getelementptr inbounds i8, ptr %40, i64 12
  %87 = load i32, ptr %86, align 4, !tbaa !18
  %.not5065 = icmp sgt i32 %87, %22
  br i1 %.not5065, label %.loopexit, label %.lr.ph68

.lr.ph68:                                         ; preds = %85
  %88 = getelementptr inbounds i8, ptr %40, i64 4
  %89 = getelementptr inbounds i8, ptr %40, i64 16
  %90 = sext i32 %87 to i64
  %91 = zext nneg i32 %67 to i64
  %.pre = load i32, ptr %88, align 4, !tbaa !17
  %.pre96 = load i32, ptr %89, align 4, !tbaa !19
  %.phi.trans.insert = sext i32 %.pre96 to i64
  %.phi.trans.insert97 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %.phi.trans.insert
  %.pre98 = load i32, ptr %.phi.trans.insert97, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %.lr.ph68, %92
  %93 = phi i32 [ %.pre98, %.lr.ph68 ], [ %97, %92 ]
  %indvars.iv86 = phi i64 [ %90, %.lr.ph68 ], [ %indvars.iv.next87, %92 ]
  %94 = getelementptr inbounds [10001 x i32], ptr @f2, i64 0, i64 %indvars.iv86
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = mul nsw i32 %95, %.pre
  %97 = add nsw i32 %93, %96
  %indvars.iv.next87 = add nsw i64 %indvars.iv86, %91
  %.not50 = icmp sgt i64 %indvars.iv.next87, %23
  br i1 %.not50, label %.loopexit.loopexit, label %92, !llvm.loop !20

.loopexit.loopexit:                               ; preds = %92
  store i32 %97, ptr %.phi.trans.insert97, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %85, %69
  %indvars.iv.next90 = add nuw nsw i64 %indvars.iv89, 1
  %exitcond92.not = icmp eq i64 %indvars.iv.next90, %wide.trip.count
  br i1 %exitcond92.not, label %.preheader, label %.preheader51, !llvm.loop !22

._crit_edge73:                                    ; preds = %.lr.ph72, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0

.lr.ph72:                                         ; preds = %.preheader, %.lr.ph72
  %indvars.iv93 = phi i64 [ %indvars.iv.next94, %.lr.ph72 ], [ 0, %.preheader ]
  %98 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %indvars.iv93
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %99)
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %101 = load i32, ptr @m, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = icmp slt i64 %indvars.iv.next94, %102
  br i1 %103, label %.lr.ph72, label %._crit_edge73, !llvm.loop !23
}

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

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

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

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

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

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

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

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

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


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