; LLVM IR from tangjz/acm-icpc :: codeforces/complete (500B)

; 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"

@n = external dso_local global i32, align 4
@p = external dso_local global [666 x i32], align 16
@vis = external dso_local global [666 x i32], align 16
@l = external dso_local global i32, align 4
@r = external dso_local global i32, align 4
@que = external dso_local global [666 x i32], align 16
@val = external dso_local global [666 x i32], align 16
@g = external dso_local global [666 x [666 x i8]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 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 i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

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

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

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %18
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %19)
  br label %21

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

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

25:                                               ; preds = %36, %24
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %30, label %29

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

30:                                               ; preds = %25
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [666 x [666 x i8]], ptr @g, i64 0, i64 %32
  %34 = getelementptr inbounds [666 x i8], ptr %33, i64 0, i64 0
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %34)
  br label %36

36:                                               ; preds = %30
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %3, align 4, !tbaa !5
  br label %25, !llvm.loop !11

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

40:                                               ; preds = %147, %39
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %150

45:                                               ; preds = %40
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [666 x i32], ptr @vis, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %146, label %51

51:                                               ; preds = %45
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [666 x i32], ptr @vis, i64 0, i64 %53
  store i32 1, ptr %54, align 4, !tbaa !5
  store i32 0, ptr @r, align 4, !tbaa !5
  store i32 0, ptr @l, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = load i32, ptr @r, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %60
  store i32 %58, ptr %61, align 4, !tbaa !5
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = load i32, ptr @r, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr @r, align 4, !tbaa !5
  %65 = sext i32 %63 to i64
  %66 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %65
  store i32 %62, ptr %66, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %118, %51
  %68 = load i32, ptr @l, align 4, !tbaa !5
  %69 = load i32, ptr @r, align 4, !tbaa !5
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %71, label %119

71:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %72 = load i32, ptr @l, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr @l, align 4, !tbaa !5
  %74 = sext i32 %72 to i64
  %75 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  store i32 %76, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %115, %71
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = load i32, ptr @n, align 4, !tbaa !5
  %80 = icmp slt i32 %78, %79
  br i1 %80, label %82, label %81

81:                                               ; preds = %77
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %118

82:                                               ; preds = %77
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [666 x [666 x i8]], ptr @g, i64 0, i64 %84
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [666 x i8], ptr %85, i64 0, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !12
  %90 = sext i8 %89 to i32
  %91 = icmp eq i32 %90, 49
  br i1 %91, label %92, label %114

92:                                               ; preds = %82
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [666 x i32], ptr @vis, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %114, label %98

98:                                               ; preds = %92
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [666 x i32], ptr @vis, i64 0, i64 %100
  store i32 1, ptr %101, align 4, !tbaa !5
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = load i32, ptr @r, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %107
  store i32 %105, ptr %108, align 4, !tbaa !5
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = load i32, ptr @r, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr @r, align 4, !tbaa !5
  %112 = sext i32 %110 to i64
  %113 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %112
  store i32 %109, ptr %113, align 4, !tbaa !5
  br label %114

114:                                              ; preds = %98, %92, %82
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %7, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %7, align 4, !tbaa !5
  br label %77, !llvm.loop !13

118:                                              ; preds = %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %67, !llvm.loop !14

119:                                              ; preds = %67
  %120 = load i32, ptr @r, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr @que, i64 %121
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @que, ptr noundef %122)
  %123 = load i32, ptr @r, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds i32, ptr @val, i64 %124
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @val, ptr noundef %125)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %142, %119
  %127 = load i32, ptr %8, align 4, !tbaa !5
  %128 = load i32, ptr @r, align 4, !tbaa !5
  %129 = icmp slt i32 %127, %128
  br i1 %129, label %131, label %130

130:                                              ; preds = %126
  store i32 16, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %145

131:                                              ; preds = %126
  %132 = load i32, ptr %8, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = load i32, ptr %8, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %140
  store i32 %135, ptr %141, align 4, !tbaa !5
  br label %142

142:                                              ; preds = %131
  %143 = load i32, ptr %8, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %8, align 4, !tbaa !5
  br label %126, !llvm.loop !15

145:                                              ; preds = %130
  br label %146

146:                                              ; preds = %145, %45
  br label %147

147:                                              ; preds = %146
  %148 = load i32, ptr %4, align 4, !tbaa !5
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %4, align 4, !tbaa !5
  br label %40, !llvm.loop !16

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

151:                                              ; preds = %162, %150
  %152 = load i32, ptr %9, align 4, !tbaa !5
  %153 = load i32, ptr @n, align 4, !tbaa !5
  %154 = icmp slt i32 %152, %153
  br i1 %154, label %156, label %155

155:                                              ; preds = %151
  store i32 19, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %165

156:                                              ; preds = %151
  %157 = load i32, ptr %9, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %160)
  br label %162

162:                                              ; preds = %156
  %163 = load i32, ptr %9, align 4, !tbaa !5
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %9, align 4, !tbaa !5
  br label %151, !llvm.loop !17

165:                                              ; preds = %155
  %166 = call i32 @puts(ptr noundef @.str.3)
  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 @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #3

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

declare i32 @puts(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 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !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"

@n = external dso_local global i32, align 4
@p = external dso_local global [666 x i32], align 16
@vis = external dso_local local_unnamed_addr global [666 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
@que = external dso_local global [666 x i32], align 16
@val = external dso_local global [666 x i32], align 16
@g = external dso_local global [666 x [666 x i8]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 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)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge59

.preheader37:                                     ; preds = %.lr.ph
  %4 = icmp sgt i32 %7, 0
  br i1 %4, label %.lr.ph40, label %._crit_edge59

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

.preheader36:                                     ; preds = %.lr.ph40
  %10 = icmp sgt i32 %13, 0
  br i1 %10, label %.lr.ph56, label %._crit_edge59

.lr.ph40:                                         ; preds = %.preheader37, %.lr.ph40
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %.lr.ph40 ], [ 0, %.preheader37 ]
  %11 = getelementptr inbounds [666 x [666 x i8]], ptr @g, i64 0, i64 %indvars.iv63
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %11)
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = icmp slt i64 %indvars.iv.next64, %14
  br i1 %15, label %.lr.ph40, label %.preheader36, !llvm.loop !11

.preheader:                                       ; preds = %.loopexit35
  %16 = icmp sgt i32 %87, 0
  br i1 %16, label %.lr.ph58, label %._crit_edge59

.lr.ph56:                                         ; preds = %.preheader36, %.loopexit35
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %.loopexit35 ], [ 0, %.preheader36 ]
  %17 = phi i32 [ %87, %.loopexit35 ], [ %13, %.preheader36 ]
  %18 = getelementptr inbounds [666 x i32], ptr @vis, i64 0, i64 %indvars.iv77
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %.lr.ph49, label %.loopexit35

.lr.ph49:                                         ; preds = %.lr.ph56
  store i32 1, ptr %18, align 4, !tbaa !5
  %20 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %indvars.iv77
  %21 = load i32, ptr %20, align 4, !tbaa !5
  store i32 %21, ptr @val, align 16, !tbaa !5
  store i32 1, ptr @r, align 4, !tbaa !5
  %22 = trunc nuw nsw i64 %indvars.iv77 to i32
  store i32 %22, ptr @que, align 16, !tbaa !5
  %23 = icmp sgt i32 %17, 0
  br i1 %23, label %.lr.ph42.us.preheader, label %48

.lr.ph42.us.preheader:                            ; preds = %.lr.ph49
  %wide.trip.count = zext nneg i32 %17 to i64
  br label %.lr.ph42.us

.lr.ph42.us:                                      ; preds = %.lr.ph42.us.preheader, %..loopexit_crit_edge.us
  %indvars.iv69 = phi i64 [ 0, %.lr.ph42.us.preheader ], [ %indvars.iv.next70, %..loopexit_crit_edge.us ]
  %r.promoted4748.us = phi i32 [ 1, %.lr.ph42.us.preheader ], [ %r.promoted45.us, %..loopexit_crit_edge.us ]
  %24 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %indvars.iv69
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  br label %27

27:                                               ; preds = %.lr.ph42.us, %43
  %indvars.iv66 = phi i64 [ 0, %.lr.ph42.us ], [ %indvars.iv.next67, %43 ]
  %r.promoted46.us = phi i32 [ %r.promoted4748.us, %.lr.ph42.us ], [ %r.promoted45.us, %43 ]
  %28 = phi i32 [ %r.promoted4748.us, %.lr.ph42.us ], [ %44, %43 ]
  %29 = getelementptr inbounds [666 x [666 x i8]], ptr @g, i64 0, i64 %26, i64 %indvars.iv66
  %30 = load i8, ptr %29, align 1, !tbaa !12
  %31 = icmp eq i8 %30, 49
  br i1 %31, label %32, label %43

32:                                               ; preds = %27
  %33 = getelementptr inbounds [666 x i32], ptr @vis, i64 0, i64 %indvars.iv66
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %.not34.us = icmp eq i32 %34, 0
  br i1 %.not34.us, label %35, label %43

35:                                               ; preds = %32
  store i32 1, ptr %33, align 4, !tbaa !5
  %36 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %indvars.iv66
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %28 to i64
  %39 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %38
  store i32 %37, ptr %39, align 4, !tbaa !5
  %40 = add nsw i32 %28, 1
  store i32 %40, ptr @r, align 4, !tbaa !5
  %41 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %38
  %42 = trunc nuw nsw i64 %indvars.iv66 to i32
  store i32 %42, ptr %41, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %35, %32, %27
  %r.promoted45.us = phi i32 [ %r.promoted46.us, %27 ], [ %r.promoted46.us, %32 ], [ %40, %35 ]
  %44 = phi i32 [ %28, %27 ], [ %28, %32 ], [ %40, %35 ]
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next67, %wide.trip.count
  br i1 %exitcond.not, label %..loopexit_crit_edge.us, label %27, !llvm.loop !13

..loopexit_crit_edge.us:                          ; preds = %43
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %45 = sext i32 %r.promoted45.us to i64
  %46 = icmp slt i64 %indvars.iv.next70, %45
  br i1 %46, label %.lr.ph42.us, label %._crit_edge.loopexit, !llvm.loop !14

._crit_edge.loopexit:                             ; preds = %..loopexit_crit_edge.us
  %47 = trunc nuw nsw i64 %indvars.iv.next70 to i32
  br label %48

48:                                               ; preds = %._crit_edge.loopexit, %.lr.ph49
  %.us-phi = phi i32 [ %47, %._crit_edge.loopexit ], [ 1, %.lr.ph49 ]
  %.us-phi51 = phi i32 [ %r.promoted45.us, %._crit_edge.loopexit ], [ 1, %.lr.ph49 ]
  store i32 %.us-phi, ptr @l, align 4, !tbaa !5
  %49 = sext i32 %.us-phi51 to i64
  %50 = getelementptr inbounds i32, ptr @que, i64 %49
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @que, ptr noundef nonnull %50)
  %51 = load i32, ptr @r, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr @val, i64 %52
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @val, ptr noundef nonnull %53)
  %54 = load i32, ptr @r, align 4, !tbaa !5
  %55 = icmp sgt i32 %54, 0
  br i1 %55, label %.lr.ph54.preheader, label %.loopexit35

.lr.ph54.preheader:                               ; preds = %48
  %wide.trip.count75 = zext nneg i32 %54 to i64
  %xtraiter = and i64 %wide.trip.count75, 3
  %56 = icmp ult i32 %54, 4
  br i1 %56, label %.loopexit35.loopexit.unr-lcssa, label %.lr.ph54.preheader.new

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

.lr.ph54:                                         ; preds = %.lr.ph54, %.lr.ph54.preheader.new
  %indvars.iv72 = phi i64 [ 0, %.lr.ph54.preheader.new ], [ %indvars.iv.next73.3, %.lr.ph54 ]
  %niter = phi i64 [ 0, %.lr.ph54.preheader.new ], [ %niter.next.3, %.lr.ph54 ]
  %57 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %indvars.iv72
  %58 = load i32, ptr %57, align 16, !tbaa !5
  %59 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %indvars.iv72
  %60 = load i32, ptr %59, align 16, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %61
  store i32 %58, ptr %62, align 4, !tbaa !5
  %indvars.iv.next73 = or disjoint i64 %indvars.iv72, 1
  %63 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %indvars.iv.next73
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %indvars.iv.next73
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %67
  store i32 %64, ptr %68, align 4, !tbaa !5
  %indvars.iv.next73.1 = or disjoint i64 %indvars.iv72, 2
  %69 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %indvars.iv.next73.1
  %70 = load i32, ptr %69, align 8, !tbaa !5
  %71 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %indvars.iv.next73.1
  %72 = load i32, ptr %71, align 8, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %73
  store i32 %70, ptr %74, align 4, !tbaa !5
  %indvars.iv.next73.2 = or disjoint i64 %indvars.iv72, 3
  %75 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %indvars.iv.next73.2
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %indvars.iv.next73.2
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %79
  store i32 %76, ptr %80, align 4, !tbaa !5
  %indvars.iv.next73.3 = add nuw nsw i64 %indvars.iv72, 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 %.loopexit35.loopexit.unr-lcssa, label %.lr.ph54, !llvm.loop !15

.loopexit35.loopexit.unr-lcssa:                   ; preds = %.lr.ph54, %.lr.ph54.preheader
  %indvars.iv72.unr = phi i64 [ 0, %.lr.ph54.preheader ], [ %indvars.iv.next73.3, %.lr.ph54 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit35, label %.lr.ph54.epil

.lr.ph54.epil:                                    ; preds = %.loopexit35.loopexit.unr-lcssa, %.lr.ph54.epil
  %indvars.iv72.epil = phi i64 [ %indvars.iv.next73.epil, %.lr.ph54.epil ], [ %indvars.iv72.unr, %.loopexit35.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph54.epil ], [ 0, %.loopexit35.loopexit.unr-lcssa ]
  %81 = getelementptr inbounds [666 x i32], ptr @val, i64 0, i64 %indvars.iv72.epil
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = getelementptr inbounds [666 x i32], ptr @que, i64 0, i64 %indvars.iv72.epil
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %85
  store i32 %82, ptr %86, align 4, !tbaa !5
  %indvars.iv.next73.epil = add nuw nsw i64 %indvars.iv72.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 %.loopexit35, label %.lr.ph54.epil, !llvm.loop !16

.loopexit35:                                      ; preds = %.loopexit35.loopexit.unr-lcssa, %.lr.ph54.epil, %48, %.lr.ph56
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = icmp slt i64 %indvars.iv.next78, %88
  br i1 %89, label %.lr.ph56, label %.preheader, !llvm.loop !18

._crit_edge59:                                    ; preds = %.lr.ph58, %0, %.preheader37, %.preheader36, %.preheader
  %90 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  ret i32 0

.lr.ph58:                                         ; preds = %.preheader, %.lr.ph58
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %.lr.ph58 ], [ 0, %.preheader ]
  %91 = getelementptr inbounds [666 x i32], ptr @p, i64 0, i64 %indvars.iv80
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %92)
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %94 = load i32, ptr @n, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = icmp slt i64 %indvars.iv.next81, %95
  br i1 %96, label %.lr.ph58, label %._crit_edge59, !llvm.loop !19
}

; 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 @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(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 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


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