; LLVM IR from tangjz/acm-icpc :: Summer_Training/2016-07-17/upsolved (G - King Arthur's Knights - tjz)

; 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
@m = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@seq = external dso_local global [151 x i32], align 16
@vis = external dso_local global [151 x i8], align 16
@e = external dso_local global [151 x [151 x i8]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 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 ptr, align 8
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %8

8:                                                ; preds = %177, %0
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %11, label %178

11:                                               ; preds = %8
  store i32 0, ptr @tot, align 4, !tbaa !5
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = mul i64 %13, 1
  call void @llvm.memset.p0.i64(ptr align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %14, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %29, %11
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp sle i32 %16, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %15
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %22
  %24 = getelementptr inbounds [151 x i8], ptr %23, i64 0, i64 0
  %25 = getelementptr inbounds i8, ptr %24, i64 1
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = mul i64 %27, 1
  call void @llvm.memset.p0.i64(ptr align 1 %25, i8 0, i64 %28, i1 false)
  br label %29

29:                                               ; preds = %20
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !9

32:                                               ; preds = %19
  br label %33

33:                                               ; preds = %37, %32
  %34 = load i32, ptr @m, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr @m, align 4, !tbaa !5
  %36 = icmp ne i32 %34, 0
  br i1 %36, label %37, label %51

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3, ptr noundef %4)
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %40
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [151 x i8], ptr %41, i64 0, i64 %43
  store i8 1, ptr %44, align 1, !tbaa !11
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %46
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [151 x i8], ptr %47, i64 0, i64 %49
  store i8 1, ptr %50, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %33, !llvm.loop !13

51:                                               ; preds = %33
  store i32 0, ptr @tot, align 4, !tbaa !5
  store i8 1, ptr getelementptr inbounds ([151 x i8], ptr @vis, i64 0, i64 1), align 1, !tbaa !11
  %52 = load i32, ptr @tot, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr @tot, align 4, !tbaa !5
  %54 = sext i32 %52 to i64
  %55 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %54
  store i32 1, ptr %55, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %146, %110, %51
  %57 = load i32, ptr @tot, align 4, !tbaa !5
  %58 = icmp sge i32 %57, 0
  br i1 %58, label %59, label %147

59:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %60 = load i32, ptr @tot, align 4, !tbaa !5
  %61 = sub nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  store i32 %64, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %65 = load i32, ptr @tot, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [151 x i32], ptr @seq, 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
  store ptr %67, ptr %6, align 8, !tbaa !14
  br label %70

70:                                               ; preds = %99, %59
  %71 = load ptr, ptr %6, align 8, !tbaa !14
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = load i32, ptr @n, align 4, !tbaa !5
  %74 = icmp sle i32 %72, %73
  br i1 %74, label %75, label %95

75:                                               ; preds = %70
  %76 = load ptr, ptr %6, align 8, !tbaa !14
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [151 x i8], ptr @vis, i64 0, i64 %78
  %80 = load i8, ptr %79, align 1, !tbaa !11, !range !16, !noundef !17
  %81 = trunc i8 %80 to i1
  br i1 %81, label %92, label %82

82:                                               ; preds = %75
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %84
  %86 = load ptr, ptr %6, align 8, !tbaa !14
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [151 x i8], ptr %85, i64 0, i64 %88
  %90 = load i8, ptr %89, align 1, !tbaa !11, !range !16, !noundef !17
  %91 = trunc i8 %90 to i1
  br label %92

92:                                               ; preds = %82, %75
  %93 = phi i1 [ false, %75 ], [ %91, %82 ]
  %94 = xor i1 %93, true
  br label %95

95:                                               ; preds = %92, %70
  %96 = phi i1 [ false, %70 ], [ %94, %92 ]
  br i1 %96, label %98, label %97

97:                                               ; preds = %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %103

98:                                               ; preds = %95
  br label %99

99:                                               ; preds = %98
  %100 = load ptr, ptr %6, align 8, !tbaa !14
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %100, align 4, !tbaa !5
  br label %70, !llvm.loop !18

103:                                              ; preds = %97
  %104 = load i32, ptr @tot, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = load i32, ptr @n, align 4, !tbaa !5
  %109 = icmp sgt i32 %107, %108
  br i1 %109, label %110, label %121

110:                                              ; preds = %103
  %111 = load i32, ptr @tot, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %112
  store i32 0, ptr %113, align 4, !tbaa !5
  %114 = load i32, ptr @tot, align 4, !tbaa !5
  %115 = add nsw i32 %114, -1
  store i32 %115, ptr @tot, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [151 x i8], ptr @vis, i64 0, i64 %119
  store i8 0, ptr %120, align 1, !tbaa !11
  br label %56, !llvm.loop !19

121:                                              ; preds = %103
  %122 = load i32, ptr @tot, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr @tot, align 4, !tbaa !5
  %124 = sext i32 %122 to i64
  %125 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [151 x i8], ptr @vis, i64 0, i64 %127
  store i8 1, ptr %128, align 1, !tbaa !11
  %129 = load i32, ptr @tot, align 4, !tbaa !5
  %130 = load i32, ptr @n, align 4, !tbaa !5
  %131 = icmp eq i32 %129, %130
  br i1 %131, label %132, label %146

132:                                              ; preds = %121
  %133 = load i32, ptr @tot, align 4, !tbaa !5
  %134 = sub nsw i32 %133, 1
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %138
  %140 = load i32, ptr @seq, align 16, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [151 x i8], ptr %139, i64 0, i64 %141
  %143 = load i8, ptr %142, align 1, !tbaa !11, !range !16, !noundef !17
  %144 = trunc i8 %143 to i1
  br i1 %144, label %145, label %146

145:                                              ; preds = %132
  br label %147

146:                                              ; preds = %132, %121
  br label %56, !llvm.loop !19

147:                                              ; preds = %145, %56
  %148 = load i32, ptr @tot, align 4, !tbaa !5
  %149 = load i32, ptr @n, align 4, !tbaa !5
  %150 = icmp slt i32 %148, %149
  br i1 %150, label %151, label %153

151:                                              ; preds = %147
  %152 = call i32 @puts(ptr noundef @.str.1)
  br label %177

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

154:                                              ; preds = %173, %153
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = load i32, ptr @n, align 4, !tbaa !5
  %157 = icmp slt i32 %155, %156
  br i1 %157, label %159, label %158

158:                                              ; preds = %154
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %176

159:                                              ; preds = %154
  %160 = load i32, ptr %7, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = load i32, ptr %7, align 4, !tbaa !5
  %165 = load i32, ptr @n, align 4, !tbaa !5
  %166 = sub nsw i32 %165, 1
  %167 = icmp eq i32 %164, %166
  %168 = zext i1 %167 to i64
  %169 = getelementptr inbounds [3 x i8], ptr @.str.3, i64 0, i64 %168
  %170 = load i8, ptr %169, align 1, !tbaa !20
  %171 = sext i8 %170 to i32
  %172 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %163, i32 noundef %171)
  br label %173

173:                                              ; preds = %159
  %174 = load i32, ptr %7, align 4, !tbaa !5
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %7, align 4, !tbaa !5
  br label %154, !llvm.loop !21

176:                                              ; preds = %158
  br label %177

177:                                              ; preds = %176, %151
  br label %8, !llvm.loop !22

178:                                              ; preds = %8
  ret i32 0
}

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

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

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

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

declare i32 @puts(ptr noundef) #1

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

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !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
@m = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@seq = external dso_local local_unnamed_addr global [151 x i32], align 16
@vis = external dso_local local_unnamed_addr global [151 x i8], align 16
@e = external dso_local local_unnamed_addr global [151 x [151 x i8]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %4 = icmp eq i32 %3, 2
  br i1 %4, label %.lr.ph39, label %._crit_edge40

.lr.ph39:                                         ; preds = %0, %.loopexit
  store i32 0, ptr @tot, align 4, !tbaa !5
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 1 getelementptr inbounds (i8, ptr @vis, i64 1), i8 0, i64 %6, i1 false)
  %.not22 = icmp slt i32 %5, 1
  br i1 %.not22, label %.preheader21, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph39
  %7 = zext nneg i32 %5 to i64
  %xtraiter = and i64 %7, 7
  %8 = icmp ult i32 %5, 8
  br i1 %8, label %.preheader21.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %7, 2147483640
  br label %.lr.ph

.preheader21.loopexit.unr-lcssa:                  ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.7, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader21, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader21.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.preheader21.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader21.loopexit.unr-lcssa ]
  %9 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv.epil, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %9, i8 0, i64 %6, i1 false)
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.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 %.preheader21, label %.lr.ph.epil, !llvm.loop !9

.preheader21:                                     ; preds = %.preheader21.loopexit.unr-lcssa, %.lr.ph.epil, %.lr.ph39
  %10 = load i32, ptr @m, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr @m, align 4, !tbaa !5
  %.not1724 = icmp eq i32 %10, 0
  br i1 %.not1724, label %._crit_edge, label %.lr.ph25

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.7, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  %12 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %12, i8 0, i64 %6, i1 false)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv.next, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %13, i8 0, i64 %6, i1 false)
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %14 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv.next.1, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %14, i8 0, i64 %6, i1 false)
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %15 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv.next.2, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %15, i8 0, i64 %6, i1 false)
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %16 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv.next.3, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %16, i8 0, i64 %6, i1 false)
  %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
  %17 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv.next.4, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %17, i8 0, i64 %6, i1 false)
  %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv, 6
  %18 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv.next.5, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %18, i8 0, i64 %6, i1 false)
  %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv, 7
  %19 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %indvars.iv.next.6, i64 1
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %19, i8 0, i64 %6, i1 false)
  %indvars.iv.next.7 = add nuw nsw i64 %indvars.iv, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.preheader21.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

.lr.ph25:                                         ; preds = %.preheader21, %.lr.ph25
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %22, i64 %24
  store i8 1, ptr %25, align 1, !tbaa !13
  %26 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %24, i64 %22
  store i8 1, ptr %26, align 1, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %27 = load i32, ptr @m, align 4, !tbaa !5
  %28 = add nsw i32 %27, -1
  store i32 %28, ptr @m, align 4, !tbaa !5
  %.not17 = icmp eq i32 %27, 0
  br i1 %.not17, label %._crit_edge.loopexit, label %.lr.ph25, !llvm.loop !15

._crit_edge.loopexit:                             ; preds = %.lr.ph25
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader21
  %29 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %5, %.preheader21 ]
  store i8 1, ptr getelementptr inbounds (i8, ptr @vis, i64 1), align 1, !tbaa !13
  store i32 1, ptr @seq, align 16, !tbaa !5
  %30 = add i32 %29, 1
  br label %31

31:                                               ; preds = %._crit_edge, %.backedge
  %32 = phi i32 [ 1, %._crit_edge ], [ %56, %.backedge ]
  %33 = add nsw i32 %32, -1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %34
  %36 = zext nneg i32 %32 to i64
  %37 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %36
  %.promoted = load i32, ptr %37, align 4, !tbaa !5
  %storemerge27 = add nsw i32 %.promoted, 1
  %.not18.not28 = icmp slt i32 %.promoted, %29
  br i1 %.not18.not28, label %.lr.ph31, label %.critedge

.lr.ph31:                                         ; preds = %31
  %38 = load i32, ptr %35, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = sext i32 %.promoted to i64
  %41 = add nsw i64 %40, 1
  br label %42

42:                                               ; preds = %.lr.ph31, %.critedge20
  %indvars.iv42 = phi i64 [ %41, %.lr.ph31 ], [ %indvars.iv.next43, %.critedge20 ]
  %43 = getelementptr inbounds [151 x i8], ptr @vis, i64 0, i64 %indvars.iv42
  %44 = load i8, ptr %43, align 1, !tbaa !13, !range !16, !noundef !17
  %45 = trunc nuw i8 %44 to i1
  br i1 %45, label %.critedge20, label %46

46:                                               ; preds = %42
  %47 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %39, i64 %indvars.iv42
  %48 = load i8, ptr %47, align 1, !tbaa !13, !range !16, !noundef !17
  %49 = trunc nuw i8 %48 to i1
  br i1 %49, label %.critedge.loopexit.split.loop.exit49, label %.critedge20

.critedge.loopexit.split.loop.exit49:             ; preds = %46
  %50 = trunc nsw i64 %indvars.iv42 to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge20, %.critedge.loopexit.split.loop.exit49, %31
  %storemerge.lcssa = phi i32 [ %storemerge27, %31 ], [ %50, %.critedge.loopexit.split.loop.exit49 ], [ %30, %.critedge20 ]
  store i32 %storemerge.lcssa, ptr %37, align 4, !tbaa !5
  %51 = icmp sgt i32 %storemerge.lcssa, %29
  br i1 %51, label %52, label %58

.critedge20:                                      ; preds = %42, %46
  %indvars.iv.next43 = add nsw i64 %indvars.iv42, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next43 to i32
  %exitcond45.not = icmp eq i32 %30, %lftr.wideiv
  br i1 %exitcond45.not, label %.critedge, label %42, !llvm.loop !18

52:                                               ; preds = %.critedge
  store i32 0, ptr %37, align 4, !tbaa !5
  store i32 %33, ptr @tot, align 4, !tbaa !5
  %53 = load i32, ptr %35, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [151 x i8], ptr @vis, i64 0, i64 %54
  store i8 0, ptr %55, align 1, !tbaa !13
  br label %.backedge

.backedge:                                        ; preds = %58, %63, %52
  %56 = phi i32 [ %33, %52 ], [ %29, %63 ], [ %59, %58 ]
  %57 = icmp sgt i32 %56, -1
  br i1 %57, label %31, label %69, !llvm.loop !19

58:                                               ; preds = %.critedge
  %59 = add nuw nsw i32 %32, 1
  store i32 %59, ptr @tot, align 4, !tbaa !5
  %60 = sext i32 %storemerge.lcssa to i64
  %61 = getelementptr inbounds [151 x i8], ptr @vis, i64 0, i64 %60
  store i8 1, ptr %61, align 1, !tbaa !13
  %62 = icmp eq i32 %59, %29
  br i1 %62, label %63, label %.backedge

63:                                               ; preds = %58
  %64 = load i32, ptr @seq, align 16, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [151 x [151 x i8]], ptr @e, i64 0, i64 %60, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !13, !range !16, !noundef !17
  %68 = trunc nuw i8 %67 to i1
  br i1 %68, label %.preheader, label %.backedge

69:                                               ; preds = %.backedge
  %70 = icmp slt i32 %56, %29
  br i1 %70, label %72, label %.loopexit

.preheader:                                       ; preds = %63
  %71 = icmp sgt i32 %29, 0
  br i1 %71, label %.lr.ph37, label %.loopexit

72:                                               ; preds = %69
  %73 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %.loopexit

.lr.ph37:                                         ; preds = %.preheader, %.lr.ph37
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %.lr.ph37 ], [ 0, %.preheader ]
  %74 = phi i32 [ %85, %.lr.ph37 ], [ %29, %.preheader ]
  %75 = getelementptr inbounds [151 x i32], ptr @seq, i64 0, i64 %indvars.iv46
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = add nsw i32 %74, -1
  %78 = zext i32 %77 to i64
  %79 = icmp eq i64 %indvars.iv46, %78
  %80 = zext i1 %79 to i64
  %81 = getelementptr inbounds [3 x i8], ptr @.str.3, i64 0, i64 %80
  %82 = load i8, ptr %81, align 1, !tbaa !20
  %83 = sext i8 %82 to i32
  %84 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %76, i32 noundef %83)
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %85 = load i32, ptr @n, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = icmp slt i64 %indvars.iv.next47, %86
  br i1 %87, label %.lr.ph37, label %.loopexit, !llvm.loop !21

.loopexit:                                        ; preds = %.lr.ph37, %69, %.preheader, %72
  %88 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %89 = icmp eq i32 %88, 2
  br i1 %89, label %.lr.ph39, label %._crit_edge40, !llvm.loop !22

._crit_edge40:                                    ; preds = %.loopexit, %0
  ret i32 0
}

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

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

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

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

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

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

attributes #0 = { mustprogress nofree norecurse 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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}


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