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

; 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
@a = external dso_local global [1001 x i32], align 16
@b = external dso_local global [1001 x i32], align 16
@c = external dso_local global [1001 x i32], align 16
@ord = external dso_local global [1001 x i32], align 16
@m = external dso_local global i32, align 4
@o = external dso_local global i32, align 4
@f = external dso_local global [2 x [10001 x i32]], align 16
@buf = external dso_local global [10001 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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 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 i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %10

10:                                               ; preds = %197, %0
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %204

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

14:                                               ; preds = %80, %13
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  store i32 4, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #9
  br label %83

19:                                               ; preds = %14
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @buf)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1001 x i32], ptr @b, i64 0, i64 %22
  store i32 0, ptr %23, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %25
  store i32 0, ptr %26, align 4, !tbaa !5
  %27 = call i64 @strlen(ptr noundef @buf) #10
  %28 = trunc i64 %27 to i32
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %30
  store i32 %28, ptr %31, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %72, %19
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10001 x i8], ptr @buf, i64 0, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !9
  %37 = icmp ne i8 %36, 0
  br i1 %37, label %39, label %38

38:                                               ; preds = %32
  store i32 7, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #9
  br label %75

39:                                               ; preds = %32
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [10001 x i8], ptr @buf, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !9
  %44 = sext i8 %43 to i32
  %45 = icmp eq i32 %44, 40
  br i1 %45, label %46, label %52

46:                                               ; preds = %39
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1001 x i32], ptr @b, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %49, align 4, !tbaa !5
  br label %71

52:                                               ; preds = %39
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1001 x i32], ptr @b, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %64

58:                                               ; preds = %52
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1001 x i32], ptr @b, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = add nsw i32 %62, -1
  store i32 %63, ptr %61, align 4, !tbaa !5
  br label %70

64:                                               ; preds = %52
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %67, align 4, !tbaa !5
  br label %70

70:                                               ; preds = %64, %58
  br label %71

71:                                               ; preds = %70, %46
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %4, align 4, !tbaa !5
  br label %32, !llvm.loop !10

75:                                               ; preds = %38
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %77 = load i32, ptr %2, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1001 x i32], ptr @ord, i64 0, i64 %78
  store i32 %76, ptr %79, align 4, !tbaa !5
  br label %80

80:                                               ; preds = %75
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !12

83:                                               ; preds = %18
  %84 = load i32, ptr @n, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr @ord, i64 %85
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @ord, ptr noundef %86, ptr noundef @_Z3cmpRKiS0_)
  %87 = load i32, ptr @o, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %88
  %90 = getelementptr inbounds [10001 x i32], ptr %89, i64 0, i64 0
  store i32 0, ptr %90, align 4, !tbaa !5
  store i32 0, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #9
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %194, %83
  %92 = load i32, ptr %5, align 4, !tbaa !5
  %93 = load i32, ptr @n, align 4, !tbaa !5
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #9
  br label %197

96:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1001 x i32], ptr @ord, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  store i32 %100, ptr %6, align 4, !tbaa !5
  %101 = load i32, ptr @o, align 4, !tbaa !5
  %102 = icmp ne i32 %101, 0
  %103 = xor i1 %102, true
  %104 = zext i1 %103 to i32
  store i32 %104, ptr @o, align 4, !tbaa !5
  %105 = load i32, ptr @o, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %106
  %108 = getelementptr inbounds [10001 x i32], ptr %107, i64 0, i64 0
  %109 = load i32, ptr @o, align 4, !tbaa !5
  %110 = icmp ne i32 %109, 0
  %111 = xor i1 %110, true
  %112 = zext i1 %111 to i64
  %113 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %112
  %114 = getelementptr inbounds [10001 x i32], ptr %113, i64 0, i64 0
  %115 = load i32, ptr @m, align 4, !tbaa !5
  %116 = add nsw i32 %115, 1
  %117 = sext i32 %116 to i64
  %118 = mul i64 %117, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %108, ptr align 4 %114, i64 %118, i1 false)
  %119 = load i32, ptr @m, align 4, !tbaa !5
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = icmp slt i32 %119, %123
  br i1 %124, label %125, label %126

125:                                              ; preds = %96
  store i32 12, ptr %3, align 4
  br label %191

126:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #9
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [1001 x i32], ptr @b, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = sub nsw i32 %130, %134
  store i32 %135, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  %136 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %136, ptr %8, align 4, !tbaa !5
  %137 = load i32, ptr %7, align 4, !tbaa !5
  %138 = icmp sgt i32 %137, 0
  br i1 %138, label %139, label %154

139:                                              ; preds = %126
  %140 = load i32, ptr %7, align 4, !tbaa !5
  %141 = load i32, ptr %8, align 4, !tbaa !5
  %142 = add nsw i32 %141, %140
  store i32 %142, ptr %8, align 4, !tbaa !5
  %143 = load i32, ptr @o, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %144
  %146 = getelementptr inbounds [10001 x i32], ptr %145, i64 0, i64 0
  %147 = load i32, ptr @m, align 4, !tbaa !5
  %148 = add nsw i32 %147, 1
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds i32, ptr %146, i64 %149
  %151 = load i32, ptr %7, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = mul i64 %152, 4
  call void @llvm.memset.p0.i64(ptr align 4 %150, i8 -1, i64 %153, i1 false)
  br label %154

154:                                              ; preds = %139, %126
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #9
  %155 = load i32, ptr %6, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  store i32 %158, ptr %9, align 4, !tbaa !5
  br label %159

159:                                              ; preds = %186, %154
  %160 = load i32, ptr %9, align 4, !tbaa !5
  %161 = load i32, ptr @m, align 4, !tbaa !5
  %162 = icmp sle i32 %160, %161
  br i1 %162, label %164, label %163

163:                                              ; preds = %159
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #9
  br label %189

164:                                              ; preds = %159
  %165 = load i32, ptr @o, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %166
  %168 = load i32, ptr %9, align 4, !tbaa !5
  %169 = load i32, ptr %7, align 4, !tbaa !5
  %170 = add nsw i32 %168, %169
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [10001 x i32], ptr %167, i64 0, i64 %171
  %173 = load i32, ptr @o, align 4, !tbaa !5
  %174 = icmp ne i32 %173, 0
  %175 = xor i1 %174, true
  %176 = zext i1 %175 to i64
  %177 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %176
  %178 = load i32, ptr %9, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [10001 x i32], ptr %177, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = load i32, ptr %6, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %183
  %185 = load i32, ptr %184, align 4, !tbaa !5
  call void @_Z3updRiii(ptr noundef nonnull align 4 dereferenceable(4) %172, i32 noundef %181, i32 noundef %185)
  br label %186

186:                                              ; preds = %164
  %187 = load i32, ptr %9, align 4, !tbaa !5
  %188 = add nsw i32 %187, 1
  store i32 %188, ptr %9, align 4, !tbaa !5
  br label %159, !llvm.loop !13

189:                                              ; preds = %163
  %190 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %190, ptr @m, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #9
  store i32 0, ptr %3, align 4
  br label %191

191:                                              ; preds = %189, %125
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  %192 = load i32, ptr %3, align 4
  switch i32 %192, label %205 [
    i32 0, label %193
    i32 12, label %194
  ]

193:                                              ; preds = %191
  br label %194

194:                                              ; preds = %193, %191
  %195 = load i32, ptr %5, align 4, !tbaa !5
  %196 = add nsw i32 %195, 1
  store i32 %196, ptr %5, align 4, !tbaa !5
  br label %91, !llvm.loop !14

197:                                              ; preds = %95
  %198 = load i32, ptr @o, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %199
  %201 = getelementptr inbounds [10001 x i32], ptr %200, i64 0, i64 0
  %202 = load i32, ptr %201, align 4, !tbaa !5
  %203 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %202)
  br label %10, !llvm.loop !15

204:                                              ; preds = %10
  ret i32 0

205:                                              ; preds = %191
  unreachable
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

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

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

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

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

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}


; 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
@a = external dso_local local_unnamed_addr global [1001 x i32], align 16
@b = external dso_local local_unnamed_addr global [1001 x i32], align 16
@c = external dso_local local_unnamed_addr global [1001 x i32], align 16
@ord = external dso_local global [1001 x i32], align 16
@m = external dso_local local_unnamed_addr global i32, align 4
@o = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local global [2 x [10001 x i32]], align 16
@buf = external dso_local global [10001 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %.preheader, label %._crit_edge55

.preheader:                                       ; preds = %0, %._crit_edge54
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.preheader.._crit_edge_crit_edge

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre73 = sext i32 %3 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %22, %.preheader.._crit_edge_crit_edge
  %.pre-phi74 = phi i64 [ %.pre73, %.preheader.._crit_edge_crit_edge ], [ %26, %22 ]
  %5 = getelementptr inbounds i32, ptr @ord, i64 %.pre-phi74
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @ord, ptr noundef nonnull %5, ptr noundef nonnull @_Z3cmpRKiS0_)
  %6 = load i32, ptr @o, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %7
  store i32 0, ptr %8, align 4, !tbaa !5
  store i32 0, ptr @m, align 4, !tbaa !5
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph53, label %._crit_edge54

.lr.ph:                                           ; preds = %.preheader, %22
  %indvars.iv58 = phi i64 [ %indvars.iv.next59, %22 ], [ 0, %.preheader ]
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @buf)
  %12 = getelementptr inbounds [1001 x i32], ptr @b, i64 0, i64 %indvars.iv58
  store i32 0, ptr %12, align 4, !tbaa !5
  %13 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %indvars.iv58
  store i32 0, ptr %13, align 4, !tbaa !5
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @buf) #8
  %15 = trunc i64 %14 to i32
  %16 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %indvars.iv58
  store i32 %15, ptr %16, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %35, %.lr.ph
  %18 = phi i32 [ %36, %35 ], [ 0, %.lr.ph ]
  %19 = phi i32 [ %37, %35 ], [ 0, %.lr.ph ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %35 ], [ 0, %.lr.ph ]
  %20 = getelementptr inbounds [10001 x i8], ptr @buf, i64 0, i64 %indvars.iv
  %21 = load i8, ptr %20, align 1, !tbaa !9
  switch i8 %21, label %30 [
    i8 0, label %22
    i8 40, label %28
  ]

22:                                               ; preds = %17
  %23 = getelementptr inbounds [1001 x i32], ptr @ord, i64 0, i64 %indvars.iv58
  %24 = trunc nuw nsw i64 %indvars.iv58 to i32
  store i32 %24, ptr %23, align 4, !tbaa !5
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = icmp slt i64 %indvars.iv.next59, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !10

28:                                               ; preds = %17
  %29 = add nsw i32 %19, 1
  store i32 %29, ptr %12, align 4, !tbaa !5
  br label %35

30:                                               ; preds = %17
  %.not44 = icmp eq i32 %19, 0
  br i1 %.not44, label %33, label %31

31:                                               ; preds = %30
  %32 = add nsw i32 %19, -1
  store i32 %32, ptr %12, align 4, !tbaa !5
  br label %35

33:                                               ; preds = %30
  %34 = add nsw i32 %18, 1
  store i32 %34, ptr %13, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %28, %33, %31
  %36 = phi i32 [ %18, %28 ], [ %34, %33 ], [ %18, %31 ]
  %37 = phi i32 [ %29, %28 ], [ 0, %33 ], [ %32, %31 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br label %17, !llvm.loop !12

._crit_edge54.loopexit:                           ; preds = %87
  %.pre67 = load i32, ptr @o, align 4, !tbaa !5
  %.phi.trans.insert = sext i32 %.pre67 to i64
  %.phi.trans.insert68 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %.phi.trans.insert
  %.pre69 = load i32, ptr %.phi.trans.insert68, align 4, !tbaa !5
  br label %._crit_edge54

._crit_edge54:                                    ; preds = %._crit_edge54.loopexit, %._crit_edge
  %38 = phi i32 [ %.pre69, %._crit_edge54.loopexit ], [ 0, %._crit_edge ]
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %38)
  %40 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %41 = icmp eq i32 %40, 1
  br i1 %41, label %.preheader, label %._crit_edge55, !llvm.loop !13

.lr.ph53:                                         ; preds = %._crit_edge, %87
  %42 = phi i32 [ %88, %87 ], [ %9, %._crit_edge ]
  %43 = phi i32 [ %89, %87 ], [ 0, %._crit_edge ]
  %indvars.iv64 = phi i64 [ %indvars.iv.next65, %87 ], [ 0, %._crit_edge ]
  %44 = getelementptr inbounds [1001 x i32], ptr @ord, i64 0, i64 %indvars.iv64
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr @o, align 4, !tbaa !5
  %47 = icmp ne i32 %46, 0
  %48 = xor i1 %47, true
  %49 = zext i1 %48 to i32
  store i32 %49, ptr @o, align 4, !tbaa !5
  %50 = zext i1 %48 to i64
  %51 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %50
  %52 = zext i1 %47 to i64
  %53 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %52
  %54 = add nsw i32 %43, 1
  %55 = sext i32 %54 to i64
  %56 = shl nsw i64 %55, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %51, ptr nonnull align 4 %53, i64 %56, i1 false)
  %57 = sext i32 %45 to i64
  %58 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = icmp slt i32 %43, %59
  br i1 %60, label %87, label %61

61:                                               ; preds = %.lr.ph53
  %62 = getelementptr inbounds [1001 x i32], ptr @b, i64 0, i64 %57
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = sub nsw i32 %63, %59
  %65 = icmp sgt i32 %64, 0
  br i1 %65, label %66, label %.lr.ph49

66:                                               ; preds = %61
  %67 = add nsw i32 %64, %43
  %68 = sext i32 %43 to i64
  %69 = getelementptr i32, ptr %51, i64 %68
  %70 = getelementptr i8, ptr %69, i64 4
  %71 = zext nneg i32 %64 to i64
  %72 = shl nuw nsw i64 %71, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %70, i8 -1, i64 %72, i1 false)
  br label %.lr.ph49

.lr.ph49:                                         ; preds = %61, %66
  %.032 = phi i32 [ %67, %66 ], [ %43, %61 ]
  %73 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %57
  %74 = sext i32 %59 to i64
  %75 = sext i32 %64 to i64
  br label %76

._crit_edge50:                                    ; preds = %76
  %.pre.pre = load i32, ptr @n, align 4, !tbaa !5
  store i32 %.032, ptr @m, align 4, !tbaa !5
  br label %87

76:                                               ; preds = %.lr.ph49, %76
  %indvars.iv61 = phi i64 [ %74, %.lr.ph49 ], [ %indvars.iv.next62, %76 ]
  %77 = load i32, ptr @o, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = add nsw i64 %indvars.iv61, %75
  %80 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %78, i64 %79
  %.not42 = icmp eq i32 %77, 0
  %81 = zext i1 %.not42 to i64
  %82 = getelementptr inbounds [2 x [10001 x i32]], ptr @f, i64 0, i64 %81, i64 %indvars.iv61
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %73, align 4, !tbaa !5
  tail call void @_Z3updRiii(ptr noundef nonnull align 4 dereferenceable(4) %80, i32 noundef %83, i32 noundef %84)
  %indvars.iv.next62 = add nsw i64 %indvars.iv61, 1
  %85 = load i32, ptr @m, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %.not.not = icmp slt i64 %indvars.iv61, %86
  br i1 %.not.not, label %76, label %._crit_edge50, !llvm.loop !14

87:                                               ; preds = %.lr.ph53, %._crit_edge50
  %88 = phi i32 [ %42, %.lr.ph53 ], [ %.pre.pre, %._crit_edge50 ]
  %89 = phi i32 [ %43, %.lr.ph53 ], [ %.032, %._crit_edge50 ]
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %90 = sext i32 %88 to i64
  %91 = icmp slt i64 %indvars.iv.next65, %90
  br i1 %91, label %.lr.ph53, label %._crit_edge54.loopexit, !llvm.loop !15

._crit_edge55:                                    ; preds = %._crit_edge54, %0
  ret i32 0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

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

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

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

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}


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