; LLVM IR from tangjz/acm-icpc :: hdu (5259)

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

@pos = external dso_local global [24 x [4 x i32]], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@seq = external dso_local global [5010 x [4 x [2 x i32]]], align 16
@f = external dso_local global [5010 x [24 x i32]], align 16
@ans = external dso_local global i32, align 4
@__const.main.tmp = external hidden unnamed_addr constant [4 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 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 @_Z5validii(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 nounwind uwtable
declare dso_local noundef i32 @_Z4costiii(i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca [4 x i32], align 16
  %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
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.main.tmp, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %43, %0
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 24
  br i1 %17, label %19, label %18

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

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

20:                                               ; preds = %35, %19
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 4
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %20
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [24 x [4 x i32]], ptr @pos, i64 0, i64 %30
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [4 x i32], ptr %31, i64 0, i64 %33
  store i32 %28, ptr %34, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %24
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %5, align 4, !tbaa !5
  br label %20, !llvm.loop !9

38:                                               ; preds = %23
  %39 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 0
  %40 = getelementptr inbounds [4 x i32], ptr %2, i64 0, i64 0
  %41 = getelementptr inbounds i32, ptr %40, i64 4
  %42 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef %39, ptr noundef %41)
  br label %43

43:                                               ; preds = %38
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !5
  br label %15, !llvm.loop !11

46:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #7
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %190, %46
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = load i32, ptr @t, align 4, !tbaa !5
  %51 = icmp sle i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %193

53:                                               ; preds = %48
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %54)
  %56 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %68, %53
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = icmp slt i32 %58, 4
  br i1 %59, label %61, label %60

60:                                               ; preds = %57
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %71

61:                                               ; preds = %57
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [4 x [2 x i32]], ptr @seq, i64 0, i64 %65
  %67 = getelementptr inbounds [2 x i32], ptr %66, i64 0, i64 1
  store i32 %63, ptr %67, align 4, !tbaa !5
  br label %68

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

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

72:                                               ; preds = %162, %71
  %73 = load i32, ptr %8, align 4, !tbaa !5
  %74 = load i32, ptr @n, align 4, !tbaa !5
  %75 = icmp sle i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %165

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

78:                                               ; preds = %102, %77
  %79 = load i32, ptr %9, align 4, !tbaa !5
  %80 = icmp slt i32 %79, 4
  br i1 %80, label %82, label %81

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

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

83:                                               ; preds = %98, %82
  %84 = load i32, ptr %10, align 4, !tbaa !5
  %85 = icmp slt i32 %84, 2
  br i1 %85, label %87, label %86

86:                                               ; preds = %83
  store i32 20, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %101

87:                                               ; preds = %83
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %89
  %91 = load i32, ptr %9, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [4 x [2 x i32]], ptr %90, i64 0, i64 %92
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2 x i32], ptr %93, i64 0, i64 %95
  %97 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %96)
  br label %98

98:                                               ; preds = %87
  %99 = load i32, ptr %10, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %10, align 4, !tbaa !5
  br label %83, !llvm.loop !13

101:                                              ; preds = %86
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %9, align 4, !tbaa !5
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %9, align 4, !tbaa !5
  br label %78, !llvm.loop !14

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

106:                                              ; preds = %158, %105
  %107 = load i32, ptr %11, align 4, !tbaa !5
  %108 = icmp slt i32 %107, 24
  br i1 %108, label %110, label %109

109:                                              ; preds = %106
  store i32 23, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %161

110:                                              ; preds = %106
  %111 = load i32, ptr %8, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [5010 x [24 x i32]], ptr @f, i64 0, i64 %112
  %114 = load i32, ptr %11, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [24 x i32], ptr %113, i64 0, i64 %115
  store i32 1061109567, ptr %116, align 4, !tbaa !5
  %117 = load i32, ptr %8, align 4, !tbaa !5
  %118 = load i32, ptr %11, align 4, !tbaa !5
  %119 = call noundef zeroext i1 @_Z5validii(i32 noundef %117, i32 noundef %118)
  br i1 %119, label %121, label %120

120:                                              ; preds = %110
  br label %158

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

122:                                              ; preds = %154, %121
  %123 = load i32, ptr %12, align 4, !tbaa !5
  %124 = icmp slt i32 %123, 24
  br i1 %124, label %126, label %125

125:                                              ; preds = %122
  store i32 26, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %157

126:                                              ; preds = %122
  %127 = load i32, ptr %8, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [5010 x [24 x i32]], ptr @f, i64 0, i64 %128
  %130 = load i32, ptr %11, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [24 x i32], ptr %129, i64 0, i64 %131
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %133 = load i32, ptr %8, align 4, !tbaa !5
  %134 = sub nsw i32 %133, 1
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [5010 x [24 x i32]], ptr @f, i64 0, i64 %135
  %137 = load i32, ptr %12, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [24 x i32], ptr %136, i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load i32, ptr %8, align 4, !tbaa !5
  %142 = load i32, ptr %11, align 4, !tbaa !5
  %143 = load i32, ptr %12, align 4, !tbaa !5
  %144 = call noundef i32 @_Z4costiii(i32 noundef %141, i32 noundef %142, i32 noundef %143)
  %145 = add nsw i32 %140, %144
  store i32 %145, ptr %13, align 4, !tbaa !5
  %146 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %132, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = load i32, ptr %8, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [5010 x [24 x i32]], ptr @f, i64 0, i64 %149
  %151 = load i32, ptr %11, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [24 x i32], ptr %150, i64 0, i64 %152
  store i32 %147, ptr %153, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %154

154:                                              ; preds = %126
  %155 = load i32, ptr %12, align 4, !tbaa !5
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %12, align 4, !tbaa !5
  br label %122, !llvm.loop !15

157:                                              ; preds = %125
  br label %158

158:                                              ; preds = %157, %120
  %159 = load i32, ptr %11, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %11, align 4, !tbaa !5
  br label %106, !llvm.loop !16

161:                                              ; preds = %109
  br label %162

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

165:                                              ; preds = %76
  store i32 1061109567, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %166

166:                                              ; preds = %184, %165
  %167 = load i32, ptr %14, align 4, !tbaa !5
  %168 = icmp slt i32 %167, 24
  br i1 %168, label %170, label %169

169:                                              ; preds = %166
  store i32 29, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %187

170:                                              ; preds = %166
  %171 = load i32, ptr @n, align 4, !tbaa !5
  %172 = load i32, ptr %14, align 4, !tbaa !5
  %173 = call noundef zeroext i1 @_Z5validii(i32 noundef %171, i32 noundef %172)
  br i1 %173, label %174, label %183

174:                                              ; preds = %170
  %175 = load i32, ptr @n, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [5010 x [24 x i32]], ptr @f, i64 0, i64 %176
  %178 = load i32, ptr %14, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [24 x i32], ptr %177, i64 0, i64 %179
  %181 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %180)
  %182 = load i32, ptr %181, align 4, !tbaa !5
  store i32 %182, ptr @ans, align 4, !tbaa !5
  br label %183

183:                                              ; preds = %174, %170
  br label %184

184:                                              ; preds = %183
  %185 = load i32, ptr %14, align 4, !tbaa !5
  %186 = add nsw i32 %185, 1
  store i32 %186, ptr %14, align 4, !tbaa !5
  br label %166, !llvm.loop !18

187:                                              ; preds = %169
  %188 = load i32, ptr @ans, align 4, !tbaa !5
  %189 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %188)
  br label %190

190:                                              ; preds = %187
  %191 = load i32, ptr %6, align 4, !tbaa !5
  %192 = add nsw i32 %191, 1
  store i32 %192, ptr %6, align 4, !tbaa !5
  br label %48, !llvm.loop !19

193:                                              ; preds = %52
  ret i32 0
}

; 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) #3

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

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

declare i32 @printf(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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

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

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

@pos = external dso_local local_unnamed_addr global [24 x [4 x i32]], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@seq = external dso_local global [5010 x [4 x [2 x i32]]], align 16
@f = external dso_local global [5010 x [24 x i32]], align 16
@ans = external dso_local global i32, align 4
@__const.main.tmp = external hidden unnamed_addr constant [4 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 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 @_Z5validii(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 nounwind uwtable
declare dso_local noundef i32 @_Z4costiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
.preheader58:
  %0 = alloca [4 x i32], align 16
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %0) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %0, ptr noundef nonnull align 16 dereferenceable(16) @__const.main.tmp, i64 16, i1 false)
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) @pos, ptr noundef nonnull align 16 dereferenceable(16) @__const.main.tmp, i64 16, i1 false)
  %3 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 16), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %4 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 32), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %5 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 48), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %6 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 64), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %7 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 80), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %8 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 96), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %9 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 112), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %10 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 128), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %11 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 144), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %12 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 160), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %13 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 176), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %14 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 192), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %15 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 208), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %16 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 224), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %17 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 240), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %18 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 256), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %19 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 272), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %20 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 288), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %21 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 304), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %22 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 320), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %23 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 336), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %24 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 352), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %25 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pos, i64 368), ptr noundef nonnull align 16 dereferenceable(16) %0, i64 16, i1 false), !tbaa !5
  %26 = call noundef zeroext i1 @_ZSt16next_permutationIPiEbT_S1_(ptr noundef nonnull %0, ptr noundef nonnull %2)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %0) #7
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %28 = load i32, ptr @t, align 4, !tbaa !5
  %.not69 = icmp slt i32 %28, 1
  br i1 %.not69, label %._crit_edge72, label %.lr.ph

._crit_edge72:                                    ; preds = %64, %.preheader58
  ret i32 0

.lr.ph:                                           ; preds = %.preheader58, %64
  %.05070 = phi i32 [ %67, %64 ], [ 1, %.preheader58 ]
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.05070)
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  store i32 1, ptr getelementptr inbounds (i8, ptr @seq, i64 4), align 4, !tbaa !5
  store i32 2, ptr getelementptr inbounds (i8, ptr @seq, i64 12), align 4, !tbaa !5
  store i32 3, ptr getelementptr inbounds (i8, ptr @seq, i64 20), align 4, !tbaa !5
  store i32 4, ptr getelementptr inbounds (i8, ptr @seq, i64 28), align 4, !tbaa !5
  %31 = load i32, ptr @n, align 4, !tbaa !5
  %.not5366 = icmp slt i32 %31, 1
  br i1 %.not5366, label %._crit_edge, label %.preheader56

.preheader56:                                     ; preds = %.lr.ph, %50
  %indvars.iv83 = phi i64 [ %indvars.iv.next84, %50 ], [ 1, %.lr.ph ]
  %32 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %indvars.iv83, i64 0, i64 0
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %32)
  %34 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %indvars.iv83, i64 0, i64 1
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %34)
  %36 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %indvars.iv83, i64 1, i64 0
  %37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %36)
  %38 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %indvars.iv83, i64 1, i64 1
  %39 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %38)
  %40 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %indvars.iv83, i64 2, i64 0
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %40)
  %42 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %indvars.iv83, i64 2, i64 1
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %42)
  %44 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %indvars.iv83, i64 3, i64 0
  %45 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %44)
  %46 = getelementptr inbounds [5010 x [4 x [2 x i32]]], ptr @seq, i64 0, i64 %indvars.iv83, i64 3, i64 1
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %46)
  %48 = add nsw i64 %indvars.iv83, -1
  %49 = trunc nuw nsw i64 %indvars.iv83 to i32
  br label %53

._crit_edge:                                      ; preds = %50, %.lr.ph
  store i32 1061109567, ptr @ans, align 4, !tbaa !5
  br label %69

50:                                               ; preds = %.loopexit
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %51 = load i32, ptr @n, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %.not53.not = icmp slt i64 %indvars.iv83, %52
  br i1 %.not53.not, label %.preheader56, label %._crit_edge, !llvm.loop !9

53:                                               ; preds = %.preheader56, %.loopexit
  %indvars.iv79 = phi i64 [ 0, %.preheader56 ], [ %indvars.iv.next80, %.loopexit ]
  %54 = getelementptr inbounds [5010 x [24 x i32]], ptr @f, i64 0, i64 %indvars.iv83, i64 %indvars.iv79
  store i32 1061109567, ptr %54, align 4, !tbaa !5
  %55 = trunc nuw nsw i64 %indvars.iv79 to i32
  %56 = call noundef zeroext i1 @_Z5validii(i32 noundef %49, i32 noundef %55)
  br i1 %56, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %53, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 0, %53 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %57 = getelementptr inbounds [5010 x [24 x i32]], ptr @f, i64 0, i64 %48, i64 %indvars.iv
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = trunc nuw nsw i64 %indvars.iv to i32
  %60 = call noundef i32 @_Z4costiii(i32 noundef %49, i32 noundef %55, i32 noundef %59)
  %61 = add nsw i32 %60, %58
  store i32 %61, ptr %1, align 4, !tbaa !5
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %54, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %63 = load i32, ptr %62, align 4, !tbaa !5
  store i32 %63, ptr %54, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 24
  br i1 %exitcond.not, label %.loopexit, label %.preheader, !llvm.loop !11

.loopexit:                                        ; preds = %.preheader, %53
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %exitcond82.not = icmp eq i64 %indvars.iv.next80, 24
  br i1 %exitcond82.not, label %50, label %53, !llvm.loop !12

64:                                               ; preds = %79
  %65 = load i32, ptr @ans, align 4, !tbaa !5
  %66 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %65)
  %67 = add nuw nsw i32 %.05070, 1
  %68 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.05070, %68
  br i1 %.not.not, label %.lr.ph, label %._crit_edge72, !llvm.loop !13

69:                                               ; preds = %._crit_edge, %79
  %indvars.iv86 = phi i64 [ 0, %._crit_edge ], [ %indvars.iv.next87, %79 ]
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = trunc nuw nsw i64 %indvars.iv86 to i32
  %72 = call noundef zeroext i1 @_Z5validii(i32 noundef %70, i32 noundef %71)
  br i1 %72, label %73, label %79

73:                                               ; preds = %69
  %74 = load i32, ptr @n, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [5010 x [24 x i32]], ptr @f, i64 0, i64 %75, i64 %indvars.iv86
  %77 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @ans, ptr noundef nonnull align 4 dereferenceable(4) %76)
  %78 = load i32, ptr %77, align 4, !tbaa !5
  store i32 %78, ptr @ans, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %69, %73
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %exitcond89.not = icmp eq i64 %indvars.iv.next87, 24
  br i1 %exitcond89.not, label %64, label %69, !llvm.loop !14
}

; 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) #3

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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

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 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: readwrite) }
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 = { 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 #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 }

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass