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

; 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.fastIO::Output" = type { [1048577 x i8], ptr, ptr }
%struct.Node = type { i8, i32, i32, i32 }

@_ZN6fastIO3outE = external dso_local global %"struct.fastIO::Output", align 8
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [300001 x i32], align 16
@que = external dso_local global [300001 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8seg_initii(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 @_Z7seg_updiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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 ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @_ZN6fastIO7nextIntERi(ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @_ZN6fastIO7nextIntERi(ptr noundef nonnull align 4 dereferenceable(4) @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %12

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

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %29

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [300001 x i32], ptr @a, i64 0, i64 %19
  call void @_ZN6fastIO7nextIntERi(ptr noundef nonnull align 4 dereferenceable(4) %20)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [300001 x i32], ptr @a, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = srem i32 %24, 3
  store i32 %25, ptr %23, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %17
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

29:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = load i32, ptr @m, align 4, !tbaa !5
  %32 = add nsw i32 %30, %31
  store i32 %32, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %63, %29
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = load i32, ptr @m, align 4, !tbaa !5
  %36 = icmp sle i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %66

38:                                               ; preds = %33
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [300001 x %struct.Node], ptr @que, i64 0, i64 %40
  call void @_ZN4Node4readEv(ptr noundef nonnull align 4 dereferenceable(16) %41)
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [300001 x %struct.Node], ptr @que, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.Node, ptr %44, i32 0, i32 0
  %46 = load i8, ptr %45, align 16, !tbaa !11
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 81
  br i1 %48, label %49, label %62

49:                                               ; preds = %38
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [300001 x %struct.Node], ptr @que, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.Node, ptr %52, i32 0, i32 1
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %53)
  %55 = load i32, ptr %54, align 4, !tbaa !5
  store i32 %55, ptr %3, align 4, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [300001 x %struct.Node], ptr @que, i64 0, i64 %57
  %59 = getelementptr inbounds %struct.Node, ptr %58, i32 0, i32 2
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %59)
  %61 = load i32, ptr %60, align 4, !tbaa !5
  store i32 %61, ptr %4, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %49, %38
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %5, align 4, !tbaa !5
  br label %33, !llvm.loop !13

66:                                               ; preds = %37
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = icmp sgt i32 %67, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %66
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %215

71:                                               ; preds = %66
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z8seg_initii(i32 noundef %72, i32 noundef %73)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %211, %71
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = load i32, ptr @m, align 4, !tbaa !5
  %77 = icmp sle i32 %75, %76
  br i1 %77, label %79, label %78

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

79:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [300001 x %struct.Node], ptr @que, i64 0, i64 %81
  store ptr %82, ptr %8, align 8, !tbaa !14
  %83 = load ptr, ptr %8, align 8, !tbaa !14
  %84 = getelementptr inbounds %struct.Node, ptr %83, i32 0, i32 0
  %85 = load i8, ptr %84, align 4, !tbaa !11
  %86 = sext i8 %85 to i32
  %87 = icmp eq i32 %86, 81
  br i1 %87, label %88, label %104

88:                                               ; preds = %79
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = load i32, ptr %4, align 4, !tbaa !5
  %91 = load ptr, ptr %8, align 8, !tbaa !14
  %92 = getelementptr inbounds %struct.Node, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !16
  %94 = load ptr, ptr %8, align 8, !tbaa !14
  %95 = getelementptr inbounds %struct.Node, ptr %94, i32 0, i32 2
  %96 = load i32, ptr %95, align 4, !tbaa !17
  %97 = call noundef i32 @_Z7seg_queiiii(i32 noundef %89, i32 noundef %90, i32 noundef %93, i32 noundef %96)
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %88
  br label %101

100:                                              ; preds = %88
  br label %101

101:                                              ; preds = %100, %99
  %102 = phi ptr [ @.str, %99 ], [ @.str.2, %100 ]
  %103 = getelementptr inbounds [2 x i8], ptr %102, i64 0, i64 0
  call void @_ZN6fastIO6Output4putsEPKc(ptr noundef nonnull align 8 dereferenceable(1048600) @_ZN6fastIO3outE, ptr noundef %103)
  br label %202

104:                                              ; preds = %79
  %105 = load ptr, ptr %8, align 8, !tbaa !14
  %106 = getelementptr inbounds %struct.Node, ptr %105, i32 0, i32 0
  %107 = load i8, ptr %106, align 4, !tbaa !11
  %108 = sext i8 %107 to i32
  %109 = icmp eq i32 %108, 65
  br i1 %109, label %116, label %110

110:                                              ; preds = %104
  %111 = load ptr, ptr %8, align 8, !tbaa !14
  %112 = getelementptr inbounds %struct.Node, ptr %111, i32 0, i32 0
  %113 = load i8, ptr %112, align 4, !tbaa !11
  %114 = sext i8 %113 to i32
  %115 = icmp eq i32 %114, 66
  br i1 %115, label %116, label %156

116:                                              ; preds = %110, %104
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %117 = load ptr, ptr %8, align 8, !tbaa !14
  %118 = getelementptr inbounds %struct.Node, ptr %117, i32 0, i32 3
  %119 = load i32, ptr %118, align 4, !tbaa !18
  %120 = srem i32 %119, 3
  store i32 %120, ptr %9, align 4, !tbaa !5
  %121 = load i32, ptr %9, align 4, !tbaa !5
  %122 = icmp ne i32 %121, 0
  br i1 %122, label %123, label %132

123:                                              ; preds = %116
  %124 = load ptr, ptr %8, align 8, !tbaa !14
  %125 = getelementptr inbounds %struct.Node, ptr %124, i32 0, i32 0
  %126 = load i8, ptr %125, align 4, !tbaa !11
  %127 = sext i8 %126 to i32
  %128 = icmp eq i32 %127, 66
  br i1 %128, label %129, label %132

129:                                              ; preds = %123
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = sub nsw i32 3, %130
  store i32 %131, ptr %9, align 4, !tbaa !5
  br label %132

132:                                              ; preds = %129, %123, %116
  %133 = load i32, ptr %9, align 4, !tbaa !5
  %134 = icmp ne i32 %133, 0
  br i1 %134, label %135, label %155

135:                                              ; preds = %132
  %136 = load ptr, ptr %8, align 8, !tbaa !14
  %137 = getelementptr inbounds %struct.Node, ptr %136, i32 0, i32 1
  %138 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %137, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = load ptr, ptr %8, align 8, !tbaa !14
  %141 = getelementptr inbounds %struct.Node, ptr %140, i32 0, i32 2
  %142 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %141, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = icmp sle i32 %139, %143
  br i1 %144, label %145, label %155

145:                                              ; preds = %135
  %146 = load i32, ptr %3, align 4, !tbaa !5
  %147 = load i32, ptr %4, align 4, !tbaa !5
  %148 = load ptr, ptr %8, align 8, !tbaa !14
  %149 = getelementptr inbounds %struct.Node, ptr %148, i32 0, i32 1
  %150 = load i32, ptr %149, align 4, !tbaa !16
  %151 = load ptr, ptr %8, align 8, !tbaa !14
  %152 = getelementptr inbounds %struct.Node, ptr %151, i32 0, i32 2
  %153 = load i32, ptr %152, align 4, !tbaa !17
  %154 = load i32, ptr %9, align 4, !tbaa !5
  call void @_Z7seg_sftiiiii(i32 noundef %146, i32 noundef %147, i32 noundef %150, i32 noundef %153, i32 noundef %154)
  br label %155

155:                                              ; preds = %145, %135, %132
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %201

156:                                              ; preds = %110
  %157 = load ptr, ptr %8, align 8, !tbaa !14
  %158 = getelementptr inbounds %struct.Node, ptr %157, i32 0, i32 0
  %159 = load i8, ptr %158, align 4, !tbaa !11
  %160 = sext i8 %159 to i32
  %161 = icmp eq i32 %160, 67
  br i1 %161, label %168, label %162

162:                                              ; preds = %156
  %163 = load ptr, ptr %8, align 8, !tbaa !14
  %164 = getelementptr inbounds %struct.Node, ptr %163, i32 0, i32 0
  %165 = load i8, ptr %164, align 4, !tbaa !11
  %166 = sext i8 %165 to i32
  %167 = icmp eq i32 %166, 70
  br i1 %167, label %168, label %200

168:                                              ; preds = %162, %156
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %169 = load ptr, ptr %8, align 8, !tbaa !14
  %170 = getelementptr inbounds %struct.Node, ptr %169, i32 0, i32 0
  %171 = load i8, ptr %170, align 4, !tbaa !11
  %172 = sext i8 %171 to i32
  %173 = icmp eq i32 %172, 67
  br i1 %173, label %174, label %178

174:                                              ; preds = %168
  %175 = load ptr, ptr %8, align 8, !tbaa !14
  %176 = getelementptr inbounds %struct.Node, ptr %175, i32 0, i32 1
  %177 = load i32, ptr %176, align 4, !tbaa !16
  br label %181

178:                                              ; preds = %168
  %179 = load i32, ptr @n, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr @n, align 4, !tbaa !5
  br label %181

181:                                              ; preds = %178, %174
  %182 = phi i32 [ %177, %174 ], [ %180, %178 ]
  store i32 %182, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %183 = load ptr, ptr %8, align 8, !tbaa !14
  %184 = getelementptr inbounds %struct.Node, ptr %183, i32 0, i32 3
  %185 = load i32, ptr %184, align 4, !tbaa !18
  %186 = srem i32 %185, 3
  store i32 %186, ptr %11, align 4, !tbaa !5
  %187 = load i32, ptr %3, align 4, !tbaa !5
  %188 = load i32, ptr %10, align 4, !tbaa !5
  %189 = icmp sle i32 %187, %188
  br i1 %189, label %190, label %199

190:                                              ; preds = %181
  %191 = load i32, ptr %10, align 4, !tbaa !5
  %192 = load i32, ptr %4, align 4, !tbaa !5
  %193 = icmp sle i32 %191, %192
  br i1 %193, label %194, label %199

194:                                              ; preds = %190
  %195 = load i32, ptr %3, align 4, !tbaa !5
  %196 = load i32, ptr %4, align 4, !tbaa !5
  %197 = load i32, ptr %10, align 4, !tbaa !5
  %198 = load i32, ptr %11, align 4, !tbaa !5
  call void @_Z7seg_updiiii(i32 noundef %195, i32 noundef %196, i32 noundef %197, i32 noundef %198)
  br label %199

199:                                              ; preds = %194, %190, %181
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %200

200:                                              ; preds = %199, %162
  br label %201

201:                                              ; preds = %200, %155
  br label %202

202:                                              ; preds = %201, %101
  %203 = load ptr, ptr %8, align 8, !tbaa !14
  %204 = getelementptr inbounds %struct.Node, ptr %203, i32 0, i32 0
  %205 = load i8, ptr %204, align 4, !tbaa !11
  %206 = sext i8 %205 to i32
  %207 = icmp eq i32 %206, 71
  %208 = zext i1 %207 to i32
  %209 = load i32, ptr @n, align 4, !tbaa !5
  %210 = sub nsw i32 %209, %208
  store i32 %210, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %211

211:                                              ; preds = %202
  %212 = load i32, ptr %7, align 4, !tbaa !5
  %213 = add nsw i32 %212, 1
  store i32 %213, ptr %7, align 4, !tbaa !5
  br label %74, !llvm.loop !19

214:                                              ; preds = %78
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %215

215:                                              ; preds = %214, %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  %216 = load i32, ptr %1, align 4
  ret i32 %216
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Node4readEv(ptr noundef nonnull align 4 dereferenceable(16)) #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6fastIO6Output4putsEPKc(ptr noundef nonnull align 8 dereferenceable(1048600), ptr noundef) #0 align 2

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 = { 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 = { 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 #4 = { 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 #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 = !{!12, !7, i64 0}
!12 = !{!"_ZTS4Node", !7, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!12, !6, i64 4}
!17 = !{!12, !6, i64 8}
!18 = !{!12, !6, i64 12}
!19 = distinct !{!19, !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.fastIO::Output" = type { [1048577 x i8], ptr, ptr }
%struct.Node = type { i8, i32, i32, i32 }

@_ZN6fastIO3outE = external dso_local global %"struct.fastIO::Output", align 8
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [300001 x i32], align 16
@que = external dso_local global [300001 x %struct.Node], align 16
@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8seg_initii(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 @_Z7seg_updiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7seg_queiiii(i32 noundef, i32 noundef, 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
  tail call void @_ZN6fastIO7nextIntERi(ptr noundef nonnull align 4 dereferenceable(4) @n)
  tail call void @_ZN6fastIO7nextIntERi(ptr noundef nonnull align 4 dereferenceable(4) @m)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not62 = icmp slt i32 %3, 1
  br i1 %.not62, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i32 [ %3, %0 ], [ %9, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %4 = load i32, ptr @m, align 4, !tbaa !5
  %5 = add nsw i32 %4, %.lcssa
  store i32 %5, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  %.not4864 = icmp slt i32 %4, 1
  br i1 %.not4864, label %._crit_edge68, label %.lr.ph67

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %6 = getelementptr inbounds [300001 x i32], ptr @a, i64 0, i64 %indvars.iv
  tail call void @_ZN6fastIO7nextIntERi(ptr noundef nonnull align 4 dereferenceable(4) %6)
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = srem i32 %7, 3
  store i32 %8, ptr %6, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %.not.not = icmp slt i64 %indvars.iv, %10
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge68.loopexit:                           ; preds = %24
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  %.pre81 = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge68

._crit_edge68:                                    ; preds = %._crit_edge68.loopexit, %._crit_edge
  %11 = phi i32 [ %.pre81, %._crit_edge68.loopexit ], [ 0, %._crit_edge ]
  %12 = phi i32 [ %.pre, %._crit_edge68.loopexit ], [ %5, %._crit_edge ]
  %13 = icmp sgt i32 %12, %11
  br i1 %13, label %.loopexit, label %27

.lr.ph67:                                         ; preds = %._crit_edge, %24
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %24 ], [ 1, %._crit_edge ]
  %14 = getelementptr inbounds [300001 x %struct.Node], ptr @que, i64 0, i64 %indvars.iv75
  call void @_ZN4Node4readEv(ptr noundef nonnull align 4 dereferenceable(16) %14)
  %15 = load i8, ptr %14, align 16, !tbaa !11
  %16 = icmp eq i8 %15, 81
  br i1 %16, label %17, label %24

17:                                               ; preds = %.lr.ph67
  %18 = getelementptr inbounds i8, ptr %14, i64 4
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %20 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %20, ptr %1, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %14, i64 8
  %22 = 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) %21)
  %23 = load i32, ptr %22, align 4, !tbaa !5
  store i32 %23, ptr %2, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %.lr.ph67, %17
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %25 = load i32, ptr @m, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %.not48.not = icmp slt i64 %indvars.iv75, %26
  br i1 %.not48.not, label %.lr.ph67, label %._crit_edge68.loopexit, !llvm.loop !13

27:                                               ; preds = %._crit_edge68
  call void @_Z8seg_initii(i32 noundef %12, i32 noundef %11)
  %28 = load i32, ptr @m, align 4, !tbaa !5
  %.not4969 = icmp slt i32 %28, 1
  br i1 %.not4969, label %.loopexit, label %.lr.ph72

.lr.ph72:                                         ; preds = %27, %.thread
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.thread ], [ 1, %27 ]
  %29 = getelementptr inbounds [300001 x %struct.Node], ptr @que, i64 0, i64 %indvars.iv78
  %30 = load i8, ptr %29, align 16, !tbaa !11
  switch i8 %30, label %.thread [
    i8 81, label %31
    i8 65, label %39
    i8 66, label %39
    i8 67, label %56
    i8 70, label %59
  ]

31:                                               ; preds = %.lr.ph72
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %29, i64 4
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %36 = getelementptr inbounds i8, ptr %29, i64 8
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %38 = call noundef i32 @_Z7seg_queiiii(i32 noundef %32, i32 noundef %33, i32 noundef %35, i32 noundef %37)
  %.not55 = icmp eq i32 %38, 0
  %.str..str.2 = select i1 %.not55, ptr @.str.2, ptr @.str
  call void @_ZN6fastIO6Output4putsEPKc(ptr noundef nonnull align 8 dereferenceable(1048600) @_ZN6fastIO3outE, ptr noundef nonnull %.str..str.2)
  br label %.thread

39:                                               ; preds = %.lr.ph72, %.lr.ph72
  %40 = getelementptr inbounds i8, ptr %29, i64 12
  %41 = load i32, ptr %40, align 4, !tbaa !16
  %42 = srem i32 %41, 3
  %.not52 = icmp eq i32 %42, 0
  br i1 %.not52, label %.thread, label %.thread58

.thread58:                                        ; preds = %39
  %43 = getelementptr inbounds i8, ptr %29, i64 4
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %43, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %29, i64 8
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %46, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %.not54 = icmp sgt i32 %45, %48
  br i1 %.not54, label %.thread, label %49

49:                                               ; preds = %.thread58
  %50 = icmp eq i8 %30, 66
  %51 = sub nsw i32 3, %42
  %spec.select = select i1 %50, i32 %51, i32 %42
  %52 = load i32, ptr %1, align 4, !tbaa !5
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = load i32, ptr %43, align 4, !tbaa !14
  %55 = load i32, ptr %46, align 8, !tbaa !15
  call void @_Z7seg_sftiiiii(i32 noundef %52, i32 noundef %53, i32 noundef %54, i32 noundef %55, i32 noundef %spec.select)
  br label %.thread

56:                                               ; preds = %.lr.ph72
  %57 = getelementptr inbounds i8, ptr %29, i64 4
  %58 = load i32, ptr %57, align 4, !tbaa !14
  br label %62

59:                                               ; preds = %.lr.ph72
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr @n, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %59, %56
  %63 = phi i32 [ %58, %56 ], [ %61, %59 ]
  %64 = getelementptr inbounds i8, ptr %29, i64 12
  %65 = load i32, ptr %64, align 4, !tbaa !16
  %66 = srem i32 %65, 3
  %67 = load i32, ptr %1, align 4, !tbaa !5
  %.not50 = icmp sgt i32 %67, %63
  br i1 %.not50, label %.thread, label %68

68:                                               ; preds = %62
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %.not51 = icmp sgt i32 %63, %69
  br i1 %.not51, label %.thread, label %70

70:                                               ; preds = %68
  call void @_Z7seg_updiiii(i32 noundef %67, i32 noundef %69, i32 noundef %63, i32 noundef %66)
  br label %.thread

.thread:                                          ; preds = %.lr.ph72, %39, %62, %68, %70, %.thread58, %49, %31
  %71 = load i8, ptr %29, align 16, !tbaa !11
  %72 = icmp eq i8 %71, 71
  %.neg = sext i1 %72 to i32
  %73 = load i32, ptr @n, align 4, !tbaa !5
  %74 = add i32 %73, %.neg
  store i32 %74, ptr @n, align 4, !tbaa !5
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %75 = load i32, ptr @m, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %.not49.not = icmp slt i64 %indvars.iv78, %76
  br i1 %.not49.not, label %.lr.ph72, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %.thread, %27, %._crit_edge68
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Node4readEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #0 align 2

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

; 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 #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6fastIO6Output4putsEPKc(ptr noundef nonnull align 8 dereferenceable(1048600), ptr noundef) local_unnamed_addr #0 align 2

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 = { 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 #4 = { 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 #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 = !{!12, !7, i64 0}
!12 = !{!"_ZTS4Node", !7, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!13 = distinct !{!13, !10}
!14 = !{!12, !6, i64 4}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !6, i64 12}
!17 = distinct !{!17, !10}


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