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

; 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
@perm = external dso_local global [4 x i32], align 16
@sx = external dso_local global i32, align 4
@sy = external dso_local global i32, align 4
@ex = external dso_local global i32, align 4
@ey = external dso_local global i32, align 4
@buf = external dso_local global [51 x [51 x i8]], align 16
@str = external dso_local global [101 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZL2dx = external hidden constant [4 x i32], align 16
@_ZL2dy = external hidden constant [4 x i32], align 16
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %15

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

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

20:                                               ; preds = %15
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %22
  %24 = getelementptr inbounds [51 x i8], ptr %23, i64 0, i64 0
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %24)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %59, %20
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = load i32, ptr @m, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %62

31:                                               ; preds = %26
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %33
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [51 x i8], ptr %34, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = sext i8 %38 to i32
  %40 = icmp eq i32 %39, 83
  br i1 %40, label %41, label %44

41:                                               ; preds = %31
  %42 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %42, ptr @sx, align 4, !tbaa !5
  %43 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %43, ptr @sy, align 4, !tbaa !5
  br label %58

44:                                               ; preds = %31
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %46
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [51 x i8], ptr %47, i64 0, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !9
  %52 = sext i8 %51 to i32
  %53 = icmp eq i32 %52, 69
  br i1 %53, label %54, label %57

54:                                               ; preds = %44
  %55 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %55, ptr @ex, align 4, !tbaa !5
  %56 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %56, ptr @ey, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %54, %44
  br label %58

58:                                               ; preds = %57, %41
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %4, align 4, !tbaa !5
  br label %26, !llvm.loop !10

62:                                               ; preds = %30
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !12

66:                                               ; preds = %19
  %67 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %77, %66
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = icmp slt i32 %69, 4
  br i1 %70, label %72, label %71

71:                                               ; preds = %68
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %80

72:                                               ; preds = %68
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [4 x i32], ptr @perm, i64 0, i64 %75
  store i32 %73, ptr %76, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %72
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %6, align 4, !tbaa !5
  br label %68, !llvm.loop !13

80:                                               ; preds = %71
  br label %81

81:                                               ; preds = %164, %80
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %82 = load i32, ptr @sx, align 4, !tbaa !5
  store i32 %82, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %83 = load i32, ptr @sy, align 4, !tbaa !5
  store i32 %83, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  store i8 0, ptr %9, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %154, %81
  %85 = load i32, ptr %10, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [101 x i8], ptr @str, i64 0, i64 %86
  %88 = load i8, ptr %87, align 1, !tbaa !9
  %89 = icmp ne i8 %88, 0
  br i1 %89, label %91, label %90

90:                                               ; preds = %84
  store i32 13, ptr %3, align 4
  br label %157

91:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %92 = load i32, ptr %10, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [101 x i8], ptr @str, i64 0, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !9
  %96 = sext i8 %95 to i32
  %97 = sub nsw i32 %96, 48
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [4 x i32], ptr @perm, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  store i32 %100, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = load i32, ptr %11, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [4 x i32], ptr @_ZL2dx, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = add nsw i32 %101, %105
  store i32 %106, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %107 = load i32, ptr %8, align 4, !tbaa !5
  %108 = load i32, ptr %11, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [4 x i32], ptr @_ZL2dy, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = add nsw i32 %107, %111
  store i32 %112, ptr %13, align 4, !tbaa !5
  %113 = load i32, ptr %12, align 4, !tbaa !5
  %114 = icmp slt i32 %113, 0
  br i1 %114, label %136, label %115

115:                                              ; preds = %91
  %116 = load i32, ptr %12, align 4, !tbaa !5
  %117 = load i32, ptr @n, align 4, !tbaa !5
  %118 = icmp sge i32 %116, %117
  br i1 %118, label %136, label %119

119:                                              ; preds = %115
  %120 = load i32, ptr %13, align 4, !tbaa !5
  %121 = icmp slt i32 %120, 0
  br i1 %121, label %136, label %122

122:                                              ; preds = %119
  %123 = load i32, ptr %13, align 4, !tbaa !5
  %124 = load i32, ptr @m, align 4, !tbaa !5
  %125 = icmp sge i32 %123, %124
  br i1 %125, label %136, label %126

126:                                              ; preds = %122
  %127 = load i32, ptr %12, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %128
  %130 = load i32, ptr %13, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [51 x i8], ptr %129, i64 0, i64 %131
  %133 = load i8, ptr %132, align 1, !tbaa !9
  %134 = sext i8 %133 to i32
  %135 = icmp eq i32 %134, 35
  br i1 %135, label %136, label %137

136:                                              ; preds = %126, %122, %119, %115, %91
  store i32 13, ptr %3, align 4
  br label %151

137:                                              ; preds = %126
  %138 = load i32, ptr %12, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %139
  %141 = load i32, ptr %13, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [51 x i8], ptr %140, i64 0, i64 %142
  %144 = load i8, ptr %143, align 1, !tbaa !9
  %145 = sext i8 %144 to i32
  %146 = icmp eq i32 %145, 69
  br i1 %146, label %147, label %148

147:                                              ; preds = %137
  store i8 1, ptr %9, align 1, !tbaa !14
  store i32 13, ptr %3, align 4
  br label %151

148:                                              ; preds = %137
  %149 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %149, ptr %7, align 4, !tbaa !5
  %150 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %150, ptr %8, align 4, !tbaa !5
  store i32 0, ptr %3, align 4
  br label %151

151:                                              ; preds = %148, %147, %136
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  %152 = load i32, ptr %3, align 4
  switch i32 %152, label %157 [
    i32 0, label %153
  ]

153:                                              ; preds = %151
  br label %154

154:                                              ; preds = %153
  %155 = load i32, ptr %10, align 4, !tbaa !5
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %10, align 4, !tbaa !5
  br label %84, !llvm.loop !16

157:                                              ; preds = %151, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %158

158:                                              ; preds = %157
  %159 = load i8, ptr %9, align 1, !tbaa !14, !range !17, !noundef !18
  %160 = trunc i8 %159 to i1
  %161 = zext i1 %160 to i32
  %162 = load i32, ptr %5, align 4, !tbaa !5
  %163 = add nsw i32 %162, %161
  store i32 %163, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %164

164:                                              ; preds = %158
  %165 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef @perm, ptr noundef getelementptr inbounds (i32, ptr @perm, i64 4))
  br i1 %165, label %81, label %166, !llvm.loop !19

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef, ptr noundef) #3

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph67, label %._crit_edge68

._crit_edge68:                                    ; preds = %._crit_edge, %0
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @str)
  store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, ptr @perm, align 16, !tbaa !5
  br label %.preheader

.lr.ph67:                                         ; preds = %0, %._crit_edge
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %._crit_edge ], [ 0, %0 ]
  %5 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %indvars.iv81
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %5)
  %7 = load i32, ptr @m, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.lr.ph67
  %wide.trip.count = zext nneg i32 %7 to i64
  %9 = trunc nuw nsw i64 %indvars.iv81 to i32
  %10 = trunc nuw nsw i64 %indvars.iv81 to i32
  %xtraiter = and i64 %wide.trip.count, 1
  %11 = icmp eq i32 %7, 1
  br i1 %11, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

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

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

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %12 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %indvars.iv81, i64 %indvars.iv.unr
  %13 = load i8, ptr %12, align 1, !tbaa !9
  switch i8 %13, label %._crit_edge [
    i8 83, label %15
    i8 69, label %14
  ]

14:                                               ; preds = %.lr.ph.epil
  store i32 %9, ptr @ex, align 4, !tbaa !5
  br label %.sink.split.epil

15:                                               ; preds = %.lr.ph.epil
  store i32 %10, ptr @sx, align 4, !tbaa !5
  br label %.sink.split.epil

.sink.split.epil:                                 ; preds = %15, %14
  %sy.sink.epil = phi ptr [ @sy, %15 ], [ @ey, %14 ]
  %16 = trunc nuw nsw i64 %indvars.iv.unr to i32
  store i32 %16, ptr %sy.sink.epil, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.sink.split.epil, %.lr.ph.epil, %.lr.ph67
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next82, %18
  br i1 %19, label %.lr.ph67, label %._crit_edge68, !llvm.loop !10

.lr.ph:                                           ; preds = %30, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %30 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %30 ]
  %20 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %indvars.iv81, i64 %indvars.iv
  %21 = load i8, ptr %20, align 1, !tbaa !9
  switch i8 %21, label %.lr.ph.1 [
    i8 83, label %22
    i8 69, label %23
  ]

22:                                               ; preds = %.lr.ph
  store i32 %10, ptr @sx, align 4, !tbaa !5
  br label %.sink.split

23:                                               ; preds = %.lr.ph
  store i32 %9, ptr @ex, align 4, !tbaa !5
  br label %.sink.split

.sink.split:                                      ; preds = %23, %22
  %sy.sink = phi ptr [ @sy, %22 ], [ @ey, %23 ]
  %24 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %24, ptr %sy.sink, align 4, !tbaa !5
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.sink.split, %.lr.ph
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %25 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %indvars.iv81, i64 %indvars.iv.next
  %26 = load i8, ptr %25, align 1, !tbaa !9
  switch i8 %26, label %30 [
    i8 83, label %28
    i8 69, label %27
  ]

27:                                               ; preds = %.lr.ph.1
  store i32 %9, ptr @ex, align 4, !tbaa !5
  br label %.sink.split.1

28:                                               ; preds = %.lr.ph.1
  store i32 %10, ptr @sx, align 4, !tbaa !5
  br label %.sink.split.1

.sink.split.1:                                    ; preds = %28, %27
  %sy.sink.1 = phi ptr [ @sy, %28 ], [ @ey, %27 ]
  %29 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %29, ptr %sy.sink.1, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %.sink.split.1, %.lr.ph.1
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !12

.preheader:                                       ; preds = %._crit_edge68, %.thread
  %.048 = phi i32 [ %61, %.thread ], [ 0, %._crit_edge68 ]
  %31 = load i8, ptr @str, align 16, !tbaa !9
  %.not70 = icmp eq i8 %31, 0
  br i1 %.not70, label %.thread, label %.lr.ph75

.lr.ph75:                                         ; preds = %.preheader
  %32 = load i32, ptr @sy, align 4, !tbaa !5
  %33 = load i32, ptr @sx, align 4, !tbaa !5
  %34 = load i32, ptr @n, align 4
  %35 = load i32, ptr @m, align 4
  br label %36

36:                                               ; preds = %.lr.ph75, %58
  %indvars.iv88 = phi i64 [ 0, %.lr.ph75 ], [ %indvars.iv.next89, %58 ]
  %37 = phi i8 [ %31, %.lr.ph75 ], [ %60, %58 ]
  %.04372 = phi i32 [ %32, %.lr.ph75 ], [ %48, %58 ]
  %.04571 = phi i32 [ %33, %.lr.ph75 ], [ %45, %58 ]
  %38 = sext i8 %37 to i64
  %39 = add nsw i64 %38, -48
  %40 = getelementptr inbounds [4 x i32], ptr @perm, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [4 x i32], ptr @_ZL2dx, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = add nsw i32 %44, %.04571
  %46 = getelementptr inbounds [4 x i32], ptr @_ZL2dy, i64 0, i64 %42
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = add nsw i32 %47, %.04372
  %49 = icmp slt i32 %45, 0
  br i1 %49, label %.thread.loopexit, label %50

50:                                               ; preds = %36
  %51 = icmp slt i32 %45, %34
  %52 = icmp sgt i32 %48, -1
  %or.cond.not63 = select i1 %51, i1 %52, i1 false
  %.not55 = icmp slt i32 %48, %35
  %or.cond56 = select i1 %or.cond.not63, i1 %.not55, i1 false
  br i1 %or.cond56, label %53, label %.thread.loopexit

53:                                               ; preds = %50
  %54 = zext nneg i32 %45 to i64
  %55 = zext nneg i32 %48 to i64
  %56 = getelementptr inbounds [51 x [51 x i8]], ptr @buf, i64 0, i64 %54, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !9
  switch i8 %57, label %58 [
    i8 35, label %.thread.loopexit
    i8 69, label %.thread
  ]

58:                                               ; preds = %53
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %59 = getelementptr inbounds [101 x i8], ptr @str, i64 0, i64 %indvars.iv.next89
  %60 = load i8, ptr %59, align 1, !tbaa !9
  %.not = icmp eq i8 %60, 0
  br i1 %.not, label %.thread.loopexit, label %36, !llvm.loop !13

.thread.loopexit:                                 ; preds = %36, %50, %53, %58
  br label %.thread

.thread:                                          ; preds = %53, %.thread.loopexit, %.preheader
  %.2 = phi i32 [ 0, %.preheader ], [ 0, %.thread.loopexit ], [ 1, %53 ]
  %61 = add nuw nsw i32 %.2, %.048
  %62 = tail call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull @perm, ptr noundef nonnull getelementptr inbounds (i8, ptr @perm, i64 16))
  br i1 %62, label %.preheader, label %63, !llvm.loop !14

63:                                               ; preds = %.thread
  %64 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %61)
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}


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