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

; 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.std::pair" = type { i32, i32 }

@n = external dso_local global i32, align 4
@mx = external dso_local global i32, align 4
@dt = external dso_local global i32, align 4
@e = external dso_local global [51 x [51 x i32]], align 16
@buf = external dso_local global [51 x i8], align 16
@vis = external dso_local global [103 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

; Function Attrs: mustprogress 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 [2 x [4 x i32]], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.std::pair", align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 1, ptr @n, align 4, !tbaa !5
  store i32 9, ptr @mx, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @e, i8 -1, i64 10404, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %68, %0
  %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 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %71

19:                                               ; preds = %14
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @buf)
  %21 = call i64 @strlen(ptr noundef @buf) #8
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr @n, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %64, %19
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %67

28:                                               ; preds = %23
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [51 x i8], ptr @buf, i64 0, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !9
  %33 = sext i8 %32 to i32
  %34 = icmp eq i32 %33, 45
  br i1 %34, label %35, label %42

35:                                               ; preds = %28
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [51 x [51 x i32]], ptr @e, i64 0, i64 %37
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [51 x i32], ptr %38, i64 0, i64 %40
  store i32 -1, ptr %41, align 4, !tbaa !5
  br label %63

42:                                               ; preds = %28
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [51 x i8], ptr @buf, i64 0, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = sext i8 %46 to i32
  %48 = sub nsw i32 %47, 48
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [51 x [51 x i32]], ptr @e, i64 0, i64 %50
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [51 x i32], ptr %51, i64 0, i64 %53
  store i32 %48, ptr %54, align 4, !tbaa !5
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [51 x [51 x i32]], ptr @e, i64 0, i64 %56
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [51 x i32], ptr %57, i64 0, i64 %59
  %61 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mx, ptr noundef nonnull align 4 dereferenceable(4) %60)
  %62 = load i32, ptr %61, align 4, !tbaa !5
  store i32 %62, ptr @mx, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %42, %35
  br label %64

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

67:                                               ; preds = %27
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !12

71:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !5
  store i32 0, ptr @dt, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %160, %71
  %73 = load i32, ptr @dt, align 4, !tbaa !5
  %74 = load i32, ptr @mx, align 4, !tbaa !5
  %75 = icmp sle i32 %73, %74
  br i1 %75, label %76, label %163

76:                                               ; preds = %72
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 103, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #7
  call void @llvm.memset.p0.i64(ptr align 16 %6, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !5
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [2 x [4 x i32]], ptr %6, i64 0, i64 %78
  %80 = getelementptr inbounds [4 x i32], ptr %79, i64 0, i64 0
  store i32 1, ptr %80, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %151, %76
  %82 = load i32, ptr %9, align 4, !tbaa !5
  %83 = load i32, ptr @n, align 4, !tbaa !5
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %86, label %85

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

86:                                               ; preds = %81
  %87 = load i32, ptr %9, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [103 x i8], ptr @vis, i64 0, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !13, !range !15, !noundef !16
  %91 = trunc i8 %90 to i1
  br i1 %91, label %92, label %93

92:                                               ; preds = %86
  br label %151

93:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %94 = load i32, ptr %9, align 4, !tbaa !5
  %95 = call i64 @_Z3dfsiii(i32 noundef %94, i32 noundef 1, i32 noundef 0)
  store i64 %95, ptr %10, align 4
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8) #7
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [2 x [4 x i32]], ptr %6, i64 0, i64 %97
  %99 = getelementptr inbounds [4 x i32], ptr %98, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %99, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %100 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %101 = load i32, ptr %100, align 4, !tbaa !17
  %102 = sub nsw i32 0, %101
  store i32 %102, ptr %11, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %147, %93
  %104 = load i32, ptr %11, align 4, !tbaa !5
  %105 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 1
  %106 = load i32, ptr %105, align 4, !tbaa !19
  %107 = icmp sle i32 %104, %106
  br i1 %107, label %109, label %108

108:                                              ; preds = %103
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %150

109:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %110 = load i32, ptr %11, align 4, !tbaa !5
  %111 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %112 = load i32, ptr %111, align 4, !tbaa !17
  %113 = sub nsw i32 0, %112
  %114 = icmp eq i32 %110, %113
  %115 = zext i1 %114 to i32
  %116 = shl i32 %115, 1
  %117 = load i32, ptr %11, align 4, !tbaa !5
  %118 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 1
  %119 = load i32, ptr %118, align 4, !tbaa !19
  %120 = icmp eq i32 %117, %119
  %121 = zext i1 %120 to i32
  %122 = or i32 %116, %121
  store i32 %122, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %143, %109
  %124 = load i32, ptr %13, align 4, !tbaa !5
  %125 = icmp slt i32 %124, 4
  br i1 %125, label %127, label %126

126:                                              ; preds = %123
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %146

127:                                              ; preds = %123
  %128 = load i32, ptr %7, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [2 x [4 x i32]], ptr %6, i64 0, i64 %129
  %131 = load i32, ptr %12, align 4, !tbaa !5
  %132 = load i32, ptr %13, align 4, !tbaa !5
  %133 = or i32 %131, %132
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [4 x i32], ptr %130, i64 0, i64 %134
  %136 = load i32, ptr %8, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [2 x [4 x i32]], ptr %6, i64 0, i64 %137
  %139 = load i32, ptr %13, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [4 x i32], ptr %138, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %135, i32 noundef %142)
  br label %143

143:                                              ; preds = %127
  %144 = load i32, ptr %13, align 4, !tbaa !5
  %145 = add nsw i32 %144, 1
  store i32 %145, ptr %13, align 4, !tbaa !5
  br label %123, !llvm.loop !20

146:                                              ; preds = %126
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %147

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

150:                                              ; preds = %108
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %151

151:                                              ; preds = %150, %92
  %152 = load i32, ptr %9, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %9, align 4, !tbaa !5
  br label %81, !llvm.loop !22

154:                                              ; preds = %85
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [2 x [4 x i32]], ptr %6, i64 0, i64 %156
  %158 = getelementptr inbounds [4 x i32], ptr %157, i64 0, i64 3
  %159 = load i32, ptr %158, align 4, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef %159)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #7
  br label %160

160:                                              ; preds = %154
  %161 = load i32, ptr @dt, align 4, !tbaa !5
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr @dt, align 4, !tbaa !5
  br label %72, !llvm.loop !23

163:                                              ; preds = %72
  %164 = load i32, ptr %5, align 4, !tbaa !5
  %165 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %164)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  %166 = load i32, ptr %1, align 4
  ret i32 %166
}

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

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

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

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

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

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind 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 #6 = { 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 #7 = { nounwind }
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 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !6, i64 0}
!18 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!19 = !{!18, !6, i64 4}
!20 = distinct !{!20, !11}
!21 = distinct !{!21, !11}
!22 = distinct !{!22, !11}
!23 = distinct !{!23, !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 local_unnamed_addr global i32, align 4
@mx = external dso_local global i32, align 4
@dt = external dso_local local_unnamed_addr global i32, align 4
@e = external dso_local global [51 x [51 x i32]], align 16
@buf = external dso_local global [51 x i8], align 16
@vis = external dso_local local_unnamed_addr global [103 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
.lr.ph37.preheader:
  %0 = alloca i32, align 4
  %1 = alloca [2 x [4 x i32]], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 1, ptr @n, align 4, !tbaa !5
  store i32 9, ptr @mx, align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(10404) @e, i8 -1, i64 10404, i1 false)
  br label %.lr.ph37

._crit_edge38:                                    ; preds = %._crit_edge
  %.pre63 = load i32, ptr @mx, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #7
  store i32 0, ptr %0, align 4, !tbaa !5
  store i32 0, ptr @dt, align 4, !tbaa !5
  %.not48 = icmp slt i32 %.pre63, 0
  br i1 %.not48, label %._crit_edge51, label %.lr.ph50

.lr.ph37:                                         ; preds = %.lr.ph37.preheader, %._crit_edge
  %indvars.iv53 = phi i64 [ 0, %.lr.ph37.preheader ], [ %indvars.iv.next54, %._crit_edge ]
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @buf)
  %5 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @buf) #8
  %6 = trunc i64 %5 to i32
  store i32 %6, ptr @n, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %.lr.ph37.._crit_edge_crit_edge

.lr.ph37.._crit_edge_crit_edge:                   ; preds = %.lr.ph37
  %sext = shl i64 %5, 32
  %.pre66 = ashr exact i64 %sext, 32
  br label %._crit_edge

._crit_edge:                                      ; preds = %21, %.lr.ph37.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre66, %.lr.ph37.._crit_edge_crit_edge ], [ %23, %21 ]
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %8 = icmp slt i64 %indvars.iv.next54, %.pre-phi
  br i1 %8, label %.lr.ph37, label %._crit_edge38, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph37, %21
  %9 = phi i32 [ %22, %21 ], [ %6, %.lr.ph37 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %21 ], [ 0, %.lr.ph37 ]
  %10 = getelementptr inbounds [51 x i8], ptr @buf, i64 0, i64 %indvars.iv
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = icmp eq i8 %11, 45
  br i1 %12, label %13, label %15

13:                                               ; preds = %.lr.ph
  %14 = getelementptr inbounds [51 x [51 x i32]], ptr @e, i64 0, i64 %indvars.iv53, i64 %indvars.iv
  store i32 -1, ptr %14, align 4, !tbaa !5
  br label %21

15:                                               ; preds = %.lr.ph
  %16 = sext i8 %11 to i32
  %17 = add nsw i32 %16, -48
  %18 = getelementptr inbounds [51 x [51 x i32]], ptr @e, i64 0, i64 %indvars.iv53, i64 %indvars.iv
  store i32 %17, ptr %18, align 4, !tbaa !5
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mx, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %20 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %20, ptr @mx, align 4, !tbaa !5
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %13, %15
  %22 = phi i32 [ %9, %13 ], [ %.pre, %15 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv.next, %23
  br i1 %24, label %.lr.ph, label %._crit_edge, !llvm.loop !12

.lr.ph50:                                         ; preds = %._crit_edge38, %._crit_edge47
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(103) @vis, i8 0, i64 103, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %1, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  store i32 1, ptr %3, align 4, !tbaa !5
  store i32 1, ptr %1, align 16, !tbaa !5
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %.lr.ph46, label %._crit_edge47

._crit_edge47.loopexit:                           ; preds = %.loopexit
  %.pre64 = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge47

._crit_edge47:                                    ; preds = %._crit_edge47.loopexit, %.lr.ph50
  %27 = phi i32 [ %.pre64, %._crit_edge47.loopexit ], [ 0, %.lr.ph50 ]
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %28, i64 3
  %30 = load i32, ptr %29, align 4, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %0, i32 noundef %30)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #7
  %31 = load i32, ptr @dt, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr @dt, align 4, !tbaa !5
  %33 = load i32, ptr @mx, align 4, !tbaa !5
  %.not.not = icmp slt i32 %31, %33
  br i1 %.not.not, label %.lr.ph50, label %._crit_edge51.loopexit, !llvm.loop !13

.lr.ph46:                                         ; preds = %.lr.ph50, %.loopexit
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %.loopexit ], [ 0, %.lr.ph50 ]
  %34 = getelementptr inbounds [103 x i8], ptr @vis, i64 0, i64 %indvars.iv60
  %35 = load i8, ptr %34, align 1, !tbaa !14, !range !16, !noundef !17
  %36 = trunc nuw i8 %35 to i1
  br i1 %36, label %.loopexit, label %37

37:                                               ; preds = %.lr.ph46
  %38 = trunc nuw nsw i64 %indvars.iv60 to i32
  %39 = call i64 @_Z3dfsiii(i32 noundef %38, i32 noundef 1, i32 noundef 0)
  %.sroa.0.0.extract.trunc = trunc i64 %39 to i32
  %.sroa.5.0.extract.shift = lshr i64 %39, 32
  %.sroa.5.0.extract.trunc = trunc nuw i64 %.sroa.5.0.extract.shift to i32
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3) #7
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %41
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %42, i8 0, i64 16, i1 false)
  %43 = sub nsw i32 0, %.sroa.0.0.extract.trunc
  %.not3340 = icmp sgt i32 %43, %.sroa.5.0.extract.trunc
  br i1 %.not3340, label %.loopexit, label %.lr.ph43.preheader

.lr.ph43.preheader:                               ; preds = %37
  %44 = add i32 %.sroa.5.0.extract.trunc, 1
  %45 = icmp eq i32 %43, %.sroa.5.0.extract.trunc
  %46 = zext i1 %45 to i64
  %47 = or disjoint i64 %46, 2
  %48 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %41, i64 %47
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %50, i64 0
  %52 = load i32, ptr %51, align 16, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %48, i32 noundef %52)
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %54, i64 3
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %57, i64 1
  %59 = load i32, ptr %58, align 4, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %55, i32 noundef %59)
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %61, i64 %47
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %64, i64 2
  %66 = load i32, ptr %65, align 8, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %62, i32 noundef %66)
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %68, i64 3
  %70 = load i32, ptr %3, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %71, i64 3
  %73 = load i32, ptr %72, align 4, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %69, i32 noundef %73)
  %74 = sub i32 1, %.sroa.0.0.extract.trunc
  %exitcond.peel.not = icmp eq i32 %74, %44
  br i1 %exitcond.peel.not, label %.loopexit, label %.lr.ph43

.lr.ph43:                                         ; preds = %.lr.ph43.preheader, %.lr.ph43
  %.02841 = phi i32 [ %113, %.lr.ph43 ], [ %74, %.lr.ph43.preheader ]
  %75 = icmp eq i32 %.02841, %43
  %76 = select i1 %75, i32 2, i32 0
  %77 = icmp eq i32 %.02841, %.sroa.5.0.extract.trunc
  %78 = zext i1 %77 to i32
  %79 = or disjoint i32 %76, %78
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = zext nneg i32 %79 to i64
  %83 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %81, i64 %82
  %84 = load i32, ptr %3, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %85, i64 0
  %87 = load i32, ptr %86, align 16, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %83, i32 noundef %87)
  %88 = load i32, ptr %2, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = or disjoint i32 %76, 1
  %91 = zext nneg i32 %90 to i64
  %92 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %89, i64 %91
  %93 = load i32, ptr %3, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %94, i64 1
  %96 = load i32, ptr %95, align 4, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %92, i32 noundef %96)
  %97 = load i32, ptr %2, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = or disjoint i32 %78, 2
  %100 = zext nneg i32 %99 to i64
  %101 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %98, i64 %100
  %102 = load i32, ptr %3, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %103, i64 2
  %105 = load i32, ptr %104, align 8, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %101, i32 noundef %105)
  %106 = load i32, ptr %2, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %107, i64 3
  %109 = load i32, ptr %3, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2 x [4 x i32]], ptr %1, i64 0, i64 %110, i64 3
  %112 = load i32, ptr %111, align 4, !tbaa !5
  call void @_Z7upd_addRii(ptr noundef nonnull align 4 dereferenceable(4) %108, i32 noundef %112)
  %113 = add i32 %.02841, 1
  %exitcond.not = icmp eq i32 %.02841, %.sroa.5.0.extract.trunc
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph43, !llvm.loop !18

.loopexit:                                        ; preds = %.lr.ph43, %.lr.ph43.preheader, %37, %.lr.ph46
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %114 = load i32, ptr @n, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = icmp slt i64 %indvars.iv.next61, %115
  br i1 %116, label %.lr.ph46, label %._crit_edge47.loopexit, !llvm.loop !20

._crit_edge51.loopexit:                           ; preds = %._crit_edge47
  %.pre65 = load i32, ptr %0, align 4, !tbaa !5
  br label %._crit_edge51

._crit_edge51:                                    ; preds = %._crit_edge51.loopexit, %._crit_edge38
  %117 = phi i32 [ %.pre65, %._crit_edge51.loopexit ], [ 0, %._crit_edge38 ]
  %118 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %117)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #7
  ret i32 0
}

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

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

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

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

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

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

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

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


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