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

; 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
@q = external dso_local global i32, align 4
@a = external dso_local global [4001 x i32], align 16
@b = external dso_local global [4001 x i32], align 16
@cur = external dso_local global i32, align 4
@pre = external dso_local global i32, align 4
@f = external dso_local global [4001 x [4001 x i16]], align 16
@g = external dso_local global [4001 x [4001 x i16]], align 16
@h = external dso_local global [2 x [4001 x i16]], align 16
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4initiiPiPA4001_s(i32 noundef, i32 noundef, ptr noundef, ptr noundef) #0

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %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 i16, align 2
  %8 = alloca i16, align 2
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m, ptr noundef @q)
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = load i32, ptr @q, align 4, !tbaa !5
  call void @_Z4initiiPiPA4001_s(i32 noundef %10, i32 noundef %11, ptr noundef @a, ptr noundef @f)
  %12 = load i32, ptr @m, align 4, !tbaa !5
  %13 = load i32, ptr @q, align 4, !tbaa !5
  call void @_Z4initiiPiPA4001_s(i32 noundef %12, i32 noundef %13, ptr noundef @b, ptr noundef @g)
  %14 = load i32, ptr @cur, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %15
  %17 = getelementptr inbounds [4001 x i16], ptr %16, i64 0, i64 0
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = mul i64 %20, 2
  call void @llvm.memset.p0.i64(ptr align 2 %17, i8 -1, i64 %21, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %41, %0
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = load i32, ptr @q, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %44

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [4001 x i16], ptr @g, i64 0, i64 %29
  %31 = load i16, ptr %30, align 2, !tbaa !9
  %32 = load i32, ptr @cur, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %33
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [4001 x i16], ptr @f, i64 0, i64 %36
  %38 = load i16, ptr %37, align 2, !tbaa !9
  %39 = sext i16 %38 to i64
  %40 = getelementptr inbounds [4001 x i16], ptr %34, i64 0, i64 %39
  store i16 %31, ptr %40, align 2, !tbaa !9
  br label %41

41:                                               ; preds = %27
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %2, align 4, !tbaa !5
  br label %22, !llvm.loop !11

44:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %163, %44
  %46 = load i32, ptr @cur, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %47
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [4001 x i16], ptr %48, i64 0, i64 %50
  %52 = load i16, ptr %51, align 2, !tbaa !9
  %53 = sext i16 %52 to i32
  %54 = load i32, ptr @m, align 4, !tbaa !5
  %55 = icmp eq i32 %53, %54
  br i1 %55, label %56, label %59

56:                                               ; preds = %45
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %57)
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %166

59:                                               ; preds = %45
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @cur, ptr noundef nonnull align 4 dereferenceable(4) @pre) #6
  %60 = load i32, ptr @cur, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %61
  %63 = getelementptr inbounds [4001 x i16], ptr %62, i64 0, i64 0
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = mul i64 %66, 2
  call void @llvm.memset.p0.i64(ptr align 2 %63, i8 -1, i64 %67, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %159, %59
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = icmp sle i32 %69, %70
  br i1 %71, label %73, label %72

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

73:                                               ; preds = %68
  %74 = load i32, ptr @pre, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %75
  %77 = load i32, ptr %5, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [4001 x i16], ptr %76, i64 0, i64 %78
  %80 = load i16, ptr %79, align 2, !tbaa !9
  %81 = sext i16 %80 to i32
  %82 = icmp eq i32 %81, -1
  br i1 %82, label %83, label %84

83:                                               ; preds = %73
  br label %159

84:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %155, %84
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = load i32, ptr @q, align 4, !tbaa !5
  %88 = icmp slt i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %158

90:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #6
  %91 = load i32, ptr %5, align 4, !tbaa !5
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %94, label %104

94:                                               ; preds = %90
  %95 = load i32, ptr %5, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [4001 x [4001 x i16]], ptr @f, i64 0, i64 %97
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [4001 x i16], ptr %98, i64 0, i64 %100
  %102 = load i16, ptr %101, align 2, !tbaa !9
  %103 = sext i16 %102 to i32
  br label %106

104:                                              ; preds = %90
  %105 = load i32, ptr @n, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %104, %94
  %107 = phi i32 [ %103, %94 ], [ %105, %104 ]
  %108 = trunc i32 %107 to i16
  store i16 %108, ptr %7, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #6
  %109 = load i32, ptr @pre, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %110
  %112 = load i32, ptr %5, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [4001 x i16], ptr %111, i64 0, i64 %113
  %115 = load i16, ptr %114, align 2, !tbaa !9
  %116 = sext i16 %115 to i32
  %117 = load i32, ptr @m, align 4, !tbaa !5
  %118 = icmp slt i32 %116, %117
  br i1 %118, label %119, label %136

119:                                              ; preds = %106
  %120 = load i32, ptr @pre, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %121
  %123 = load i32, ptr %5, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [4001 x i16], ptr %122, i64 0, i64 %124
  %126 = load i16, ptr %125, align 2, !tbaa !9
  %127 = sext i16 %126 to i32
  %128 = add nsw i32 %127, 1
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [4001 x [4001 x i16]], ptr @g, i64 0, i64 %129
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [4001 x i16], ptr %130, i64 0, i64 %132
  %134 = load i16, ptr %133, align 2, !tbaa !9
  %135 = sext i16 %134 to i32
  br label %138

136:                                              ; preds = %106
  %137 = load i32, ptr @m, align 4, !tbaa !5
  br label %138

138:                                              ; preds = %136, %119
  %139 = phi i32 [ %135, %119 ], [ %137, %136 ]
  %140 = trunc i32 %139 to i16
  store i16 %140, ptr %8, align 2, !tbaa !9
  %141 = load i32, ptr @cur, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %142
  %144 = load i16, ptr %7, align 2, !tbaa !9
  %145 = sext i16 %144 to i64
  %146 = getelementptr inbounds [4001 x i16], ptr %143, i64 0, i64 %145
  %147 = call noundef nonnull align 2 dereferenceable(2) ptr @_ZSt3maxIsERKT_S2_S2_(ptr noundef nonnull align 2 dereferenceable(2) %146, ptr noundef nonnull align 2 dereferenceable(2) %8)
  %148 = load i16, ptr %147, align 2, !tbaa !9
  %149 = load i32, ptr @cur, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %150
  %152 = load i16, ptr %7, align 2, !tbaa !9
  %153 = sext i16 %152 to i64
  %154 = getelementptr inbounds [4001 x i16], ptr %151, i64 0, i64 %153
  store i16 %148, ptr %154, align 2, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #6
  br label %155

155:                                              ; preds = %138
  %156 = load i32, ptr %6, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %6, align 4, !tbaa !5
  br label %85, !llvm.loop !13

158:                                              ; preds = %89
  br label %159

159:                                              ; preds = %158, %83
  %160 = load i32, ptr %5, align 4, !tbaa !5
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %5, align 4, !tbaa !5
  br label %68, !llvm.loop !14

162:                                              ; preds = %72
  br label %163

163:                                              ; preds = %162
  %164 = load i32, ptr %3, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %3, align 4, !tbaa !5
  br label %45, !llvm.loop !15

166:                                              ; preds = %56
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 2 dereferenceable(2) ptr @_ZSt3maxIsERKT_S2_S2_(ptr noundef nonnull align 2 dereferenceable(2), ptr noundef nonnull align 2 dereferenceable(2)) #5

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


; 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
@q = external dso_local global i32, align 4
@a = external dso_local global [4001 x i32], align 16
@b = external dso_local global [4001 x i32], align 16
@cur = external dso_local global i32, align 4
@pre = external dso_local global i32, align 4
@f = external dso_local global [4001 x [4001 x i16]], align 16
@g = external dso_local global [4001 x [4001 x i16]], align 16
@h = external dso_local global [2 x [4001 x i16]], align 16
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4initiiPiPA4001_s(i32 noundef, i32 noundef, ptr noundef, ptr 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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i16, align 2
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @q)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = load i32, ptr @q, align 4, !tbaa !5
  tail call void @_Z4initiiPiPA4001_s(i32 noundef %3, i32 noundef %4, ptr noundef nonnull @a, ptr noundef nonnull @f)
  %5 = load i32, ptr @m, align 4, !tbaa !5
  %6 = load i32, ptr @q, align 4, !tbaa !5
  tail call void @_Z4initiiPiPA4001_s(i32 noundef %5, i32 noundef %6, ptr noundef nonnull @b, ptr noundef nonnull @g)
  %7 = load i32, ptr @cur, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %8
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = add nsw i32 %10, 1
  %12 = sext i32 %11 to i64
  %13 = shl nsw i64 %12, 1
  tail call void @llvm.memset.p0.i64(ptr nonnull align 2 %9, i8 -1, i64 %13, i1 false)
  %14 = load i32, ptr @q, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph.preheader, label %.preheader25

.lr.ph.preheader:                                 ; preds = %0
  %wide.trip.count = zext nneg i32 %14 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %16 = icmp ult i32 %14, 4
  br i1 %16, label %.preheader25.loopexit.unr-lcssa, label %.lr.ph.preheader.new

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

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

.lr.ph.epil:                                      ; preds = %.preheader25.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.preheader25.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader25.loopexit.unr-lcssa ]
  %17 = getelementptr inbounds [4001 x i16], ptr @g, i64 0, i64 %indvars.iv.epil
  %18 = load i16, ptr %17, align 2, !tbaa !9
  %19 = getelementptr inbounds [4001 x i16], ptr @f, i64 0, i64 %indvars.iv.epil
  %20 = load i16, ptr %19, align 2, !tbaa !9
  %21 = sext i16 %20 to i64
  %22 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %8, i64 %21
  store i16 %18, ptr %22, align 2, !tbaa !9
  %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 %.preheader25, label %.lr.ph.epil, !llvm.loop !11

.preheader25:                                     ; preds = %.preheader25.loopexit.unr-lcssa, %.lr.ph.epil, %0
  %23 = sext i32 %10 to i64
  %24 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %8, i64 %23
  %25 = load i16, ptr %24, align 2, !tbaa !9
  %26 = sext i16 %25 to i32
  %27 = load i32, ptr @m, align 4, !tbaa !5
  %28 = icmp eq i32 %27, %26
  br i1 %28, label %._crit_edge35, label %.lr.ph34

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %29 = getelementptr inbounds [4001 x i16], ptr @g, i64 0, i64 %indvars.iv
  %30 = load i16, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds [4001 x i16], ptr @f, i64 0, i64 %indvars.iv
  %32 = load i16, ptr %31, align 8, !tbaa !9
  %33 = sext i16 %32 to i64
  %34 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %8, i64 %33
  store i16 %30, ptr %34, align 2, !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %35 = getelementptr inbounds [4001 x i16], ptr @g, i64 0, i64 %indvars.iv.next
  %36 = load i16, ptr %35, align 2, !tbaa !9
  %37 = getelementptr inbounds [4001 x i16], ptr @f, i64 0, i64 %indvars.iv.next
  %38 = load i16, ptr %37, align 2, !tbaa !9
  %39 = sext i16 %38 to i64
  %40 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %8, i64 %39
  store i16 %36, ptr %40, align 2, !tbaa !9
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %41 = getelementptr inbounds [4001 x i16], ptr @g, i64 0, i64 %indvars.iv.next.1
  %42 = load i16, ptr %41, align 4, !tbaa !9
  %43 = getelementptr inbounds [4001 x i16], ptr @f, i64 0, i64 %indvars.iv.next.1
  %44 = load i16, ptr %43, align 4, !tbaa !9
  %45 = sext i16 %44 to i64
  %46 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %8, i64 %45
  store i16 %42, ptr %46, align 2, !tbaa !9
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %47 = getelementptr inbounds [4001 x i16], ptr @g, i64 0, i64 %indvars.iv.next.2
  %48 = load i16, ptr %47, align 2, !tbaa !9
  %49 = getelementptr inbounds [4001 x i16], ptr @f, i64 0, i64 %indvars.iv.next.2
  %50 = load i16, ptr %49, align 2, !tbaa !9
  %51 = sext i16 %50 to i64
  %52 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %8, i64 %51
  store i16 %48, ptr %52, align 2, !tbaa !9
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader25.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !13

._crit_edge35:                                    ; preds = %._crit_edge, %.preheader25
  %.021.lcssa = phi i32 [ 1, %.preheader25 ], [ %61, %._crit_edge ]
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.021.lcssa)
  ret i32 0

.lr.ph34:                                         ; preds = %.preheader25, %._crit_edge
  %.02133 = phi i32 [ %61, %._crit_edge ], [ 1, %.preheader25 ]
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @cur, ptr noundef nonnull align 4 dereferenceable(4) @pre) #6
  %54 = load i32, ptr @cur, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %55
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  %59 = sext i32 %58 to i64
  %60 = shl nsw i64 %59, 1
  call void @llvm.memset.p0.i64(ptr nonnull align 2 %56, i8 -1, i64 %60, i1 false)
  %.not29 = icmp slt i32 %57, 0
  br i1 %.not29, label %.lr.ph34.._crit_edge_crit_edge, label %.lr.ph32.preheader

.lr.ph34.._crit_edge_crit_edge:                   ; preds = %.lr.ph34
  %.pre46 = sext i32 %57 to i64
  br label %._crit_edge

.lr.ph32.preheader:                               ; preds = %.lr.ph34
  %.pre = load i32, ptr @q, align 4
  br label %.lr.ph32

._crit_edge.loopexit:                             ; preds = %.loopexit
  %.pre45 = sext i32 %116 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph34.._crit_edge_crit_edge, %._crit_edge.loopexit
  %.pre-phi47 = phi i64 [ %.pre46, %.lr.ph34.._crit_edge_crit_edge ], [ %118, %._crit_edge.loopexit ]
  %.pre-phi = phi i64 [ %55, %.lr.ph34.._crit_edge_crit_edge ], [ %.pre45, %._crit_edge.loopexit ]
  %61 = add nuw nsw i32 %.02133, 1
  %62 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %.pre-phi, i64 %.pre-phi47
  %63 = load i16, ptr %62, align 2, !tbaa !9
  %64 = sext i16 %63 to i32
  %65 = load i32, ptr @m, align 4, !tbaa !5
  %66 = icmp eq i32 %65, %64
  br i1 %66, label %._crit_edge35, label %.lr.ph34, !llvm.loop !15

.lr.ph32:                                         ; preds = %.lr.ph32.preheader, %.loopexit
  %67 = phi i32 [ %57, %.lr.ph32.preheader ], [ %115, %.loopexit ]
  %68 = phi i32 [ %54, %.lr.ph32.preheader ], [ %116, %.loopexit ]
  %69 = phi i32 [ %.pre, %.lr.ph32.preheader ], [ %117, %.loopexit ]
  %indvars.iv41 = phi i64 [ 0, %.lr.ph32.preheader ], [ %76, %.loopexit ]
  %70 = load i32, ptr @pre, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %71, i64 %indvars.iv41
  %73 = load i16, ptr %72, align 2, !tbaa !9
  %74 = icmp ne i16 %73, -1
  %75 = icmp sgt i32 %69, 0
  %or.cond = select i1 %74, i1 %75, i1 false
  %76 = add nuw nsw i64 %indvars.iv41, 1
  br i1 %or.cond, label %.lr.ph28, label %.loopexit

.lr.ph28:                                         ; preds = %.lr.ph32, %101
  %77 = phi i32 [ %109, %101 ], [ %68, %.lr.ph32 ]
  %indvars.iv38 = phi i64 [ %indvars.iv.next39, %101 ], [ 0, %.lr.ph32 ]
  %78 = load i32, ptr @n, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = icmp slt i64 %indvars.iv41, %79
  br i1 %80, label %81, label %85

81:                                               ; preds = %.lr.ph28
  %82 = getelementptr inbounds [4001 x [4001 x i16]], ptr @f, i64 0, i64 %76, i64 %indvars.iv38
  %83 = load i16, ptr %82, align 2, !tbaa !9
  %84 = zext i16 %83 to i32
  br label %85

85:                                               ; preds = %.lr.ph28, %81
  %86 = phi i32 [ %84, %81 ], [ %78, %.lr.ph28 ]
  %87 = zext i32 %86 to i64
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %1) #6
  %88 = load i32, ptr @pre, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %89, i64 %indvars.iv41
  %91 = load i16, ptr %90, align 2, !tbaa !9
  %92 = sext i16 %91 to i32
  %93 = load i32, ptr @m, align 4, !tbaa !5
  %94 = icmp sgt i32 %93, %92
  br i1 %94, label %95, label %101

95:                                               ; preds = %85
  %96 = add nsw i32 %92, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [4001 x [4001 x i16]], ptr @g, i64 0, i64 %97, i64 %indvars.iv38
  %99 = load i16, ptr %98, align 2, !tbaa !9
  %100 = zext i16 %99 to i32
  br label %101

101:                                              ; preds = %85, %95
  %102 = phi i32 [ %100, %95 ], [ %93, %85 ]
  %103 = trunc i32 %102 to i16
  store i16 %103, ptr %1, align 2, !tbaa !9
  %104 = sext i32 %77 to i64
  %sext = shl i64 %87, 48
  %105 = ashr exact i64 %sext, 48
  %106 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %104, i64 %105
  %107 = call noundef nonnull align 2 dereferenceable(2) ptr @_ZSt3maxIsERKT_S2_S2_(ptr noundef nonnull align 2 dereferenceable(2) %106, ptr noundef nonnull align 2 dereferenceable(2) %1)
  %108 = load i16, ptr %107, align 2, !tbaa !9
  %109 = load i32, ptr @cur, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [2 x [4001 x i16]], ptr @h, i64 0, i64 %110, i64 %105
  store i16 %108, ptr %111, align 2, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %1) #6
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %112 = load i32, ptr @q, align 4
  %113 = sext i32 %112 to i64
  %114 = icmp slt i64 %indvars.iv.next39, %113
  br i1 %114, label %.lr.ph28, label %.loopexit.loopexit, !llvm.loop !16

.loopexit.loopexit:                               ; preds = %101
  %.pre44 = load i32, ptr @n, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph32, %.loopexit.loopexit
  %115 = phi i32 [ %.pre44, %.loopexit.loopexit ], [ %67, %.lr.ph32 ]
  %116 = phi i32 [ %109, %.loopexit.loopexit ], [ %68, %.lr.ph32 ]
  %117 = phi i32 [ %112, %.loopexit.loopexit ], [ %69, %.lr.ph32 ]
  %118 = sext i32 %115 to i64
  %.not.not = icmp slt i64 %indvars.iv41, %118
  br i1 %.not.not, label %.lr.ph32, label %._crit_edge.loopexit, !llvm.loop !17
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 2 dereferenceable(2) ptr @_ZSt3maxIsERKT_S2_S2_(ptr noundef nonnull align 2 dereferenceable(2), ptr noundef nonnull align 2 dereferenceable(2)) local_unnamed_addr #5

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


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