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

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@que = external dso_local global [50001 x i32], align 16
@L = external dso_local global i32, align 4
@R = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@vis = external dso_local global [50001 x i8], align 16
@p = external dso_local global [50001 x %struct.Cow], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = 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
  store i32 0, ptr %1, align 4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %22, %0
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp slt i32 %8, %9
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %7
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %14
  %16 = getelementptr inbounds %struct.Cow, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.Cow, ptr %19, i32 0, i32 1
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %16, ptr noundef %20)
  br label %22

22:                                               ; preds = %12
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !5
  br label %7, !llvm.loop !9

25:                                               ; preds = %11
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds %struct.Cow, ptr @p, i64 %27
  call void @_ZSt4sortIP3CowEvT_S2_(ptr noundef @p, ptr noundef %28)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %117, %25
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %120

34:                                               ; preds = %29
  br label %35

35:                                               ; preds = %58, %34
  %36 = load i32, ptr @L, align 4, !tbaa !5
  %37 = load i32, ptr @R, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %56

39:                                               ; preds = %35
  %40 = load i32, ptr @L, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.Cow, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !11
  %48 = load i32, ptr @m, align 4, !tbaa !5
  %49 = add nsw i32 %47, %48
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.Cow, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !11
  %55 = icmp slt i32 %49, %54
  br label %56

56:                                               ; preds = %39, %35
  %57 = phi i1 [ false, %35 ], [ %55, %39 ]
  br i1 %57, label %58, label %61

58:                                               ; preds = %56
  %59 = load i32, ptr @L, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr @L, align 4, !tbaa !5
  br label %35, !llvm.loop !13

61:                                               ; preds = %56
  %62 = load i32, ptr @L, align 4, !tbaa !5
  %63 = load i32, ptr @R, align 4, !tbaa !5
  %64 = icmp eq i32 %62, %63
  br i1 %64, label %81, label %65

65:                                               ; preds = %61
  %66 = load i32, ptr @L, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.Cow, ptr %71, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !14
  %74 = load i32, ptr %3, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %75
  %77 = getelementptr inbounds %struct.Cow, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 4, !tbaa !14
  %79 = shl i32 %78, 1
  %80 = icmp slt i32 %73, %79
  br i1 %80, label %81, label %85

81:                                               ; preds = %65, %61
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %83
  store i8 1, ptr %84, align 1, !tbaa !15
  br label %85

85:                                               ; preds = %81, %65
  br label %86

86:                                               ; preds = %108, %85
  %87 = load i32, ptr @L, align 4, !tbaa !5
  %88 = load i32, ptr @R, align 4, !tbaa !5
  %89 = icmp slt i32 %87, %88
  br i1 %89, label %90, label %106

90:                                               ; preds = %86
  %91 = load i32, ptr @R, align 4, !tbaa !5
  %92 = sub nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %96
  %98 = getelementptr inbounds %struct.Cow, ptr %97, i32 0, i32 1
  %99 = load i32, ptr %98, align 4, !tbaa !14
  %100 = load i32, ptr %3, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %101
  %103 = getelementptr inbounds %struct.Cow, ptr %102, i32 0, i32 1
  %104 = load i32, ptr %103, align 4, !tbaa !14
  %105 = icmp sle i32 %99, %104
  br label %106

106:                                              ; preds = %90, %86
  %107 = phi i1 [ false, %86 ], [ %105, %90 ]
  br i1 %107, label %108, label %111

108:                                              ; preds = %106
  %109 = load i32, ptr @R, align 4, !tbaa !5
  %110 = add nsw i32 %109, -1
  store i32 %110, ptr @R, align 4, !tbaa !5
  br label %86, !llvm.loop !17

111:                                              ; preds = %106
  %112 = load i32, ptr %3, align 4, !tbaa !5
  %113 = load i32, ptr @R, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr @R, align 4, !tbaa !5
  %115 = sext i32 %113 to i64
  %116 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %115
  store i32 %112, ptr %116, align 4, !tbaa !5
  br label %117

117:                                              ; preds = %111
  %118 = load i32, ptr %3, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !18

120:                                              ; preds = %33
  store i32 0, ptr @R, align 4, !tbaa !5
  store i32 0, ptr @L, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %121 = load i32, ptr @n, align 4, !tbaa !5
  %122 = sub nsw i32 %121, 1
  store i32 %122, ptr %4, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %210, %120
  %124 = load i32, ptr %4, align 4, !tbaa !5
  %125 = icmp sge i32 %124, 0
  br i1 %125, label %127, label %126

126:                                              ; preds = %123
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %213

127:                                              ; preds = %123
  br label %128

128:                                              ; preds = %151, %127
  %129 = load i32, ptr @L, align 4, !tbaa !5
  %130 = load i32, ptr @R, align 4, !tbaa !5
  %131 = icmp slt i32 %129, %130
  br i1 %131, label %132, label %149

132:                                              ; preds = %128
  %133 = load i32, ptr @L, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %137
  %139 = getelementptr inbounds %struct.Cow, ptr %138, i32 0, i32 0
  %140 = load i32, ptr %139, align 8, !tbaa !11
  %141 = load i32, ptr @m, align 4, !tbaa !5
  %142 = sub nsw i32 %140, %141
  %143 = load i32, ptr %4, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %144
  %146 = getelementptr inbounds %struct.Cow, ptr %145, i32 0, i32 0
  %147 = load i32, ptr %146, align 8, !tbaa !11
  %148 = icmp sgt i32 %142, %147
  br label %149

149:                                              ; preds = %132, %128
  %150 = phi i1 [ false, %128 ], [ %148, %132 ]
  br i1 %150, label %151, label %154

151:                                              ; preds = %149
  %152 = load i32, ptr @L, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr @L, align 4, !tbaa !5
  br label %128, !llvm.loop !19

154:                                              ; preds = %149
  %155 = load i32, ptr @L, align 4, !tbaa !5
  %156 = load i32, ptr @R, align 4, !tbaa !5
  %157 = icmp eq i32 %155, %156
  br i1 %157, label %174, label %158

158:                                              ; preds = %154
  %159 = load i32, ptr @L, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %163
  %165 = getelementptr inbounds %struct.Cow, ptr %164, i32 0, i32 1
  %166 = load i32, ptr %165, align 4, !tbaa !14
  %167 = load i32, ptr %4, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %168
  %170 = getelementptr inbounds %struct.Cow, ptr %169, i32 0, i32 1
  %171 = load i32, ptr %170, align 4, !tbaa !14
  %172 = shl i32 %171, 1
  %173 = icmp slt i32 %166, %172
  br i1 %173, label %174, label %178

174:                                              ; preds = %158, %154
  %175 = load i32, ptr %4, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %176
  store i8 1, ptr %177, align 1, !tbaa !15
  br label %178

178:                                              ; preds = %174, %158
  br label %179

179:                                              ; preds = %201, %178
  %180 = load i32, ptr @L, align 4, !tbaa !5
  %181 = load i32, ptr @R, align 4, !tbaa !5
  %182 = icmp slt i32 %180, %181
  br i1 %182, label %183, label %199

183:                                              ; preds = %179
  %184 = load i32, ptr @R, align 4, !tbaa !5
  %185 = sub nsw i32 %184, 1
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %186
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %189
  %191 = getelementptr inbounds %struct.Cow, ptr %190, i32 0, i32 1
  %192 = load i32, ptr %191, align 4, !tbaa !14
  %193 = load i32, ptr %4, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %194
  %196 = getelementptr inbounds %struct.Cow, ptr %195, i32 0, i32 1
  %197 = load i32, ptr %196, align 4, !tbaa !14
  %198 = icmp sle i32 %192, %197
  br label %199

199:                                              ; preds = %183, %179
  %200 = phi i1 [ false, %179 ], [ %198, %183 ]
  br i1 %200, label %201, label %204

201:                                              ; preds = %199
  %202 = load i32, ptr @R, align 4, !tbaa !5
  %203 = add nsw i32 %202, -1
  store i32 %203, ptr @R, align 4, !tbaa !5
  br label %179, !llvm.loop !20

204:                                              ; preds = %199
  %205 = load i32, ptr %4, align 4, !tbaa !5
  %206 = load i32, ptr @R, align 4, !tbaa !5
  %207 = add nsw i32 %206, 1
  store i32 %207, ptr @R, align 4, !tbaa !5
  %208 = sext i32 %206 to i64
  %209 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %208
  store i32 %205, ptr %209, align 4, !tbaa !5
  br label %210

210:                                              ; preds = %204
  %211 = load i32, ptr %4, align 4, !tbaa !5
  %212 = add nsw i32 %211, -1
  store i32 %212, ptr %4, align 4, !tbaa !5
  br label %123, !llvm.loop !21

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

214:                                              ; preds = %229, %213
  %215 = load i32, ptr %5, align 4, !tbaa !5
  %216 = load i32, ptr @n, align 4, !tbaa !5
  %217 = icmp slt i32 %215, %216
  br i1 %217, label %219, label %218

218:                                              ; preds = %214
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %232

219:                                              ; preds = %214
  %220 = load i32, ptr %5, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %221
  %223 = load i8, ptr %222, align 1, !tbaa !15, !range !22, !noundef !23
  %224 = trunc i8 %223 to i1
  br i1 %224, label %228, label %225

225:                                              ; preds = %219
  %226 = load i32, ptr @ans, align 4, !tbaa !5
  %227 = add nsw i32 %226, 1
  store i32 %227, ptr @ans, align 4, !tbaa !5
  br label %228

228:                                              ; preds = %225, %219
  br label %229

229:                                              ; preds = %228
  %230 = load i32, ptr %5, align 4, !tbaa !5
  %231 = add nsw i32 %230, 1
  store i32 %231, ptr %5, align 4, !tbaa !5
  br label %214, !llvm.loop !24

232:                                              ; preds = %218
  %233 = load i32, ptr @ans, align 4, !tbaa !5
  %234 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %233)
  ret i32 0
}

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

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

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

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

declare i32 @printf(ptr noundef, ...) #1

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@que = external dso_local local_unnamed_addr global [50001 x i32], align 16
@L = external dso_local local_unnamed_addr global i32, align 4
@R = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@vis = external dso_local local_unnamed_addr global [50001 x i8], align 16
@p = external dso_local global [50001 x %struct.Cow], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = 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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = sext i32 %2 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %12, %.lr.ph ]
  %4 = getelementptr inbounds %struct.Cow, ptr @p, i64 %.pre-phi
  tail call void @_ZSt4sortIP3CowEvT_S2_(ptr noundef nonnull @p, ptr noundef nonnull %4)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.preheader39.lr.ph, label %.thread

.thread:                                          ; preds = %._crit_edge
  store i32 0, ptr @R, align 4, !tbaa !5
  store i32 0, ptr @L, align 4, !tbaa !5
  br label %.preheader.thread

.preheader39.lr.ph:                               ; preds = %._crit_edge
  %L.promoted61 = load i32, ptr @L, align 4, !tbaa !5
  %R.promoted59 = load i32, ptr @R, align 4, !tbaa !5
  %7 = load i32, ptr @m, align 4
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %.preheader39

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %8 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %indvars.iv
  %9 = getelementptr inbounds i8, ptr %8, i64 4
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = icmp slt i64 %indvars.iv.next, %12
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader39:                                     ; preds = %.preheader39.lr.ph, %.critedge2
  %indvars.iv108 = phi i64 [ 0, %.preheader39.lr.ph ], [ %indvars.iv.next109, %.critedge2 ]
  %R.promoted6068 = phi i32 [ %R.promoted59, %.preheader39.lr.ph ], [ %60, %.critedge2 ]
  %L.promoted6467 = phi i32 [ %L.promoted61, %.preheader39.lr.ph ], [ %L.promoted62128, %.critedge2 ]
  %14 = icmp slt i32 %L.promoted6467, %R.promoted6068
  br i1 %14, label %.lr.ph48, label %.critedge

.lr.ph48:                                         ; preds = %.preheader39
  %15 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %indvars.iv108
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = sext i32 %L.promoted6467 to i64
  %18 = sext i32 %R.promoted6068 to i64
  br label %22

19:                                               ; preds = %.critedge2
  store i32 0, ptr @R, align 4, !tbaa !5
  store i32 0, ptr @L, align 4, !tbaa !5
  br i1 %6, label %.preheader38.lr.ph, label %.preheader.thread

.preheader38.lr.ph:                               ; preds = %19
  %20 = load i32, ptr @m, align 4
  %21 = zext nneg i32 %5 to i64
  br label %.preheader38

22:                                               ; preds = %.lr.ph48, %30
  %indvars.iv102 = phi i64 [ %17, %.lr.ph48 ], [ %indvars.iv.next103, %30 ]
  %23 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %indvars.iv102
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %25
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = add nsw i32 %7, %27
  %29 = icmp slt i32 %28, %16
  br i1 %29, label %30, label %.critedge.loopexit

30:                                               ; preds = %22
  %indvars.iv.next103 = add nsw i64 %indvars.iv102, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next103, %18
  br i1 %exitcond.not, label %.critedge.thread, label %22, !llvm.loop !13

.critedge.loopexit:                               ; preds = %22
  %31 = trunc nsw i64 %indvars.iv102 to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.preheader39
  %L.promoted62 = phi i32 [ %L.promoted6467, %.preheader39 ], [ %31, %.critedge.loopexit ]
  %32 = icmp eq i32 %L.promoted62, %R.promoted6068
  br i1 %32, label %.critedge.thread, label %33

33:                                               ; preds = %.critedge
  %34 = sext i32 %L.promoted62 to i64
  %35 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %37, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !14
  %40 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %indvars.iv108, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !14
  %42 = shl i32 %41, 1
  %43 = icmp slt i32 %39, %42
  br i1 %43, label %.critedge.thread, label %45

.critedge.thread:                                 ; preds = %30, %33, %.critedge
  %L.promoted62129 = phi i32 [ %L.promoted62, %33 ], [ %L.promoted62, %.critedge ], [ %R.promoted6068, %30 ]
  %44 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %indvars.iv108
  store i8 1, ptr %44, align 1, !tbaa !15
  br label %45

45:                                               ; preds = %.critedge.thread, %33
  %L.promoted62128 = phi i32 [ %L.promoted62129, %.critedge.thread ], [ %L.promoted62, %33 ]
  %46 = icmp slt i32 %L.promoted62128, %R.promoted6068
  br i1 %46, label %.lr.ph55, label %.critedge2

.lr.ph55:                                         ; preds = %45
  %47 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %indvars.iv108, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !14
  %49 = sext i32 %R.promoted6068 to i64
  %50 = sext i32 %L.promoted62128 to i64
  br label %51

51:                                               ; preds = %.lr.ph55, %57
  %indvars.iv105 = phi i64 [ %49, %.lr.ph55 ], [ %indvars.iv.next106, %57 ]
  %indvars.iv.next106 = add nsw i64 %indvars.iv105, -1
  %52 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %indvars.iv.next106
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %54, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !14
  %.not37 = icmp sgt i32 %56, %48
  br i1 %.not37, label %.critedge2.loopexit.split.loop.exit140, label %57

57:                                               ; preds = %51
  %58 = icmp sgt i64 %indvars.iv.next106, %50
  br i1 %58, label %51, label %.critedge2, !llvm.loop !17

.critedge2.loopexit.split.loop.exit140:           ; preds = %51
  %59 = trunc nsw i64 %indvars.iv105 to i32
  br label %.critedge2

.critedge2:                                       ; preds = %57, %.critedge2.loopexit.split.loop.exit140, %45
  %.lcssa44 = phi i32 [ %R.promoted6068, %45 ], [ %59, %.critedge2.loopexit.split.loop.exit140 ], [ %L.promoted62128, %57 ]
  %60 = add nsw i32 %.lcssa44, 1
  %61 = sext i32 %.lcssa44 to i64
  %62 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %61
  %63 = trunc nuw nsw i64 %indvars.iv108 to i32
  store i32 %63, ptr %62, align 4, !tbaa !5
  %indvars.iv.next109 = add nuw nsw i64 %indvars.iv108, 1
  %exitcond111.not = icmp eq i64 %indvars.iv.next109, %wide.trip.count
  br i1 %exitcond111.not, label %19, label %.preheader39, !llvm.loop !18

.preheader38:                                     ; preds = %.preheader38.lr.ph, %.critedge6
  %indvars.iv119 = phi i64 [ %21, %.preheader38.lr.ph ], [ %indvars.iv.next120, %.critedge6 ]
  %R.promoted8593 = phi i32 [ 0, %.preheader38.lr.ph ], [ %109, %.critedge6 ]
  %L.promoted8992 = phi i32 [ 0, %.preheader38.lr.ph ], [ %L.promoted87132, %.critedge6 ]
  %indvars.iv.next120 = add nsw i64 %indvars.iv119, -1
  %64 = icmp slt i32 %L.promoted8992, %R.promoted8593
  br i1 %64, label %.lr.ph73, label %.critedge4

.lr.ph73:                                         ; preds = %.preheader38
  %65 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %indvars.iv.next120
  %66 = load i32, ptr %65, align 8, !tbaa !11
  %67 = sext i32 %L.promoted8992 to i64
  %68 = sext i32 %R.promoted8593 to i64
  br label %70

.preheader.thread:                                ; preds = %.thread, %19
  %ans.promoted130 = load i32, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge98

.preheader:                                       ; preds = %.critedge6
  store i32 %109, ptr @R, align 4, !tbaa !5
  %ans.promoted = load i32, ptr @ans, align 4, !tbaa !5
  br i1 %6, label %.lr.ph97.preheader, label %._crit_edge98

.lr.ph97.preheader:                               ; preds = %.preheader
  %xtraiter = and i64 %wide.trip.count, 3
  %69 = icmp ult i32 %5, 4
  br i1 %69, label %._crit_edge98.loopexit.unr-lcssa, label %.lr.ph97.preheader.new

.lr.ph97.preheader.new:                           ; preds = %.lr.ph97.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph97

70:                                               ; preds = %.lr.ph73, %78
  %indvars.iv112 = phi i64 [ %67, %.lr.ph73 ], [ %indvars.iv.next113, %78 ]
  %71 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %indvars.iv112
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %73
  %75 = load i32, ptr %74, align 8, !tbaa !11
  %76 = sub nsw i32 %75, %20
  %77 = icmp sgt i32 %76, %66
  br i1 %77, label %78, label %.critedge4.loopexit

78:                                               ; preds = %70
  %indvars.iv.next113 = add nsw i64 %indvars.iv112, 1
  %79 = trunc nsw i64 %indvars.iv.next113 to i32
  store i32 %79, ptr @L, align 4, !tbaa !5
  %exitcond115.not = icmp eq i64 %indvars.iv.next113, %68
  br i1 %exitcond115.not, label %.critedge4.thread, label %70, !llvm.loop !19

.critedge4.loopexit:                              ; preds = %70
  %80 = trunc nsw i64 %indvars.iv112 to i32
  br label %.critedge4

.critedge4:                                       ; preds = %.critedge4.loopexit, %.preheader38
  %L.promoted87 = phi i32 [ %L.promoted8992, %.preheader38 ], [ %80, %.critedge4.loopexit ]
  %81 = icmp eq i32 %L.promoted87, %R.promoted8593
  br i1 %81, label %.critedge4.thread, label %82

82:                                               ; preds = %.critedge4
  %83 = sext i32 %L.promoted87 to i64
  %84 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %86, i32 1
  %88 = load i32, ptr %87, align 4, !tbaa !14
  %89 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %indvars.iv.next120, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !14
  %91 = shl i32 %90, 1
  %92 = icmp slt i32 %88, %91
  br i1 %92, label %.critedge4.thread, label %94

.critedge4.thread:                                ; preds = %78, %82, %.critedge4
  %L.promoted87133 = phi i32 [ %L.promoted87, %82 ], [ %L.promoted87, %.critedge4 ], [ %R.promoted8593, %78 ]
  %93 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %indvars.iv.next120
  store i8 1, ptr %93, align 1, !tbaa !15
  br label %94

94:                                               ; preds = %.critedge4.thread, %82
  %L.promoted87132 = phi i32 [ %L.promoted87133, %.critedge4.thread ], [ %L.promoted87, %82 ]
  %95 = icmp slt i32 %L.promoted87132, %R.promoted8593
  br i1 %95, label %.lr.ph80, label %.critedge6

.lr.ph80:                                         ; preds = %94
  %96 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %indvars.iv.next120, i32 1
  %97 = load i32, ptr %96, align 4, !tbaa !14
  %98 = sext i32 %R.promoted8593 to i64
  %99 = sext i32 %L.promoted87132 to i64
  br label %100

100:                                              ; preds = %.lr.ph80, %106
  %indvars.iv116 = phi i64 [ %98, %.lr.ph80 ], [ %indvars.iv.next117, %106 ]
  %indvars.iv.next117 = add nsw i64 %indvars.iv116, -1
  %101 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %indvars.iv.next117
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [50001 x %struct.Cow], ptr @p, i64 0, i64 %103, i32 1
  %105 = load i32, ptr %104, align 4, !tbaa !14
  %.not = icmp sgt i32 %105, %97
  br i1 %.not, label %.critedge6.loopexit.split.loop.exit142, label %106

106:                                              ; preds = %100
  %107 = icmp sgt i64 %indvars.iv.next117, %99
  br i1 %107, label %100, label %.critedge6, !llvm.loop !20

.critedge6.loopexit.split.loop.exit142:           ; preds = %100
  %108 = trunc nsw i64 %indvars.iv116 to i32
  br label %.critedge6

.critedge6:                                       ; preds = %106, %.critedge6.loopexit.split.loop.exit142, %94
  %.lcssa41 = phi i32 [ %R.promoted8593, %94 ], [ %108, %.critedge6.loopexit.split.loop.exit142 ], [ %L.promoted87132, %106 ]
  %109 = add nsw i32 %.lcssa41, 1
  %110 = sext i32 %.lcssa41 to i64
  %111 = getelementptr inbounds [50001 x i32], ptr @que, i64 0, i64 %110
  %112 = trunc nuw nsw i64 %indvars.iv.next120 to i32
  store i32 %112, ptr %111, align 4, !tbaa !5
  %113 = icmp sgt i64 %indvars.iv119, 1
  br i1 %113, label %.preheader38, label %.preheader, !llvm.loop !21

._crit_edge98.loopexit.unr-lcssa:                 ; preds = %148, %.lr.ph97.preheader
  %.lcssa.ph = phi i32 [ poison, %.lr.ph97.preheader ], [ %149, %148 ]
  %indvars.iv122.unr = phi i64 [ 0, %.lr.ph97.preheader ], [ %indvars.iv.next123.3, %148 ]
  %.unr = phi i32 [ %ans.promoted, %.lr.ph97.preheader ], [ %149, %148 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge98, label %.lr.ph97.epil

.lr.ph97.epil:                                    ; preds = %._crit_edge98.loopexit.unr-lcssa, %120
  %indvars.iv122.epil = phi i64 [ %indvars.iv.next123.epil, %120 ], [ %indvars.iv122.unr, %._crit_edge98.loopexit.unr-lcssa ]
  %114 = phi i32 [ %121, %120 ], [ %.unr, %._crit_edge98.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %120 ], [ 0, %._crit_edge98.loopexit.unr-lcssa ]
  %115 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %indvars.iv122.epil
  %116 = load i8, ptr %115, align 1, !tbaa !15, !range !22, !noundef !23
  %117 = trunc nuw i8 %116 to i1
  br i1 %117, label %120, label %118

118:                                              ; preds = %.lr.ph97.epil
  %119 = add nsw i32 %114, 1
  store i32 %119, ptr @ans, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %118, %.lr.ph97.epil
  %121 = phi i32 [ %114, %.lr.ph97.epil ], [ %119, %118 ]
  %indvars.iv.next123.epil = add nuw nsw i64 %indvars.iv122.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge98, label %.lr.ph97.epil, !llvm.loop !24

._crit_edge98:                                    ; preds = %._crit_edge98.loopexit.unr-lcssa, %120, %.preheader.thread, %.preheader
  %122 = phi i32 [ %ans.promoted, %.preheader ], [ %ans.promoted130, %.preheader.thread ], [ %.lcssa.ph, %._crit_edge98.loopexit.unr-lcssa ], [ %121, %120 ]
  %123 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %122)
  ret i32 0

.lr.ph97:                                         ; preds = %148, %.lr.ph97.preheader.new
  %indvars.iv122 = phi i64 [ 0, %.lr.ph97.preheader.new ], [ %indvars.iv.next123.3, %148 ]
  %124 = phi i32 [ %ans.promoted, %.lr.ph97.preheader.new ], [ %149, %148 ]
  %niter = phi i64 [ 0, %.lr.ph97.preheader.new ], [ %niter.next.3, %148 ]
  %125 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %indvars.iv122
  %126 = load i8, ptr %125, align 4, !tbaa !15, !range !22, !noundef !23
  %127 = trunc nuw i8 %126 to i1
  br i1 %127, label %.lr.ph97.1, label %128

128:                                              ; preds = %.lr.ph97
  %129 = add nsw i32 %124, 1
  store i32 %129, ptr @ans, align 4, !tbaa !5
  br label %.lr.ph97.1

.lr.ph97.1:                                       ; preds = %.lr.ph97, %128
  %130 = phi i32 [ %124, %.lr.ph97 ], [ %129, %128 ]
  %indvars.iv.next123 = or disjoint i64 %indvars.iv122, 1
  %131 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %indvars.iv.next123
  %132 = load i8, ptr %131, align 1, !tbaa !15, !range !22, !noundef !23
  %133 = trunc nuw i8 %132 to i1
  br i1 %133, label %.lr.ph97.2, label %134

134:                                              ; preds = %.lr.ph97.1
  %135 = add nsw i32 %130, 1
  store i32 %135, ptr @ans, align 4, !tbaa !5
  br label %.lr.ph97.2

.lr.ph97.2:                                       ; preds = %134, %.lr.ph97.1
  %136 = phi i32 [ %130, %.lr.ph97.1 ], [ %135, %134 ]
  %indvars.iv.next123.1 = or disjoint i64 %indvars.iv122, 2
  %137 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %indvars.iv.next123.1
  %138 = load i8, ptr %137, align 2, !tbaa !15, !range !22, !noundef !23
  %139 = trunc nuw i8 %138 to i1
  br i1 %139, label %.lr.ph97.3, label %140

140:                                              ; preds = %.lr.ph97.2
  %141 = add nsw i32 %136, 1
  store i32 %141, ptr @ans, align 4, !tbaa !5
  br label %.lr.ph97.3

.lr.ph97.3:                                       ; preds = %140, %.lr.ph97.2
  %142 = phi i32 [ %136, %.lr.ph97.2 ], [ %141, %140 ]
  %indvars.iv.next123.2 = or disjoint i64 %indvars.iv122, 3
  %143 = getelementptr inbounds [50001 x i8], ptr @vis, i64 0, i64 %indvars.iv.next123.2
  %144 = load i8, ptr %143, align 1, !tbaa !15, !range !22, !noundef !23
  %145 = trunc nuw i8 %144 to i1
  br i1 %145, label %148, label %146

146:                                              ; preds = %.lr.ph97.3
  %147 = add nsw i32 %142, 1
  store i32 %147, ptr @ans, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %146, %.lr.ph97.3
  %149 = phi i32 [ %142, %.lr.ph97.3 ], [ %147, %146 ]
  %indvars.iv.next123.3 = add nuw nsw i64 %indvars.iv122, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge98.loopexit.unr-lcssa, label %.lr.ph97, !llvm.loop !26
}

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

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

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

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 = { 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 #2 = { 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" }

!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 = !{!"_ZTS3Cow", !6, i64 0, !6, i64 4}
!13 = distinct !{!13, !10}
!14 = !{!12, !6, i64 4}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.unroll.disable"}
!26 = distinct !{!26, !10}


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