; LLVM IR from tangjz/acm-icpc :: codeforces/gym (100624K)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@out = external dso_local global [10 x i8], align 1
@tot = external dso_local global i32, align 4
@pre = external dso_local global [4040 x i32], align 16
@ans = external dso_local global i32, align 4
@que = external dso_local global [4040 x i32], align 16
@leaf = external dso_local global [4040 x i8], align 16
@vis = external dso_local global [4040 x i8], align 16
@.str.11 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3idxPc(ptr 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 void @_Z3idxi(i32 noundef) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z3dfsii(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z3pfsi(i32 noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca [10 x i8], align 1
  %3 = alloca [10 x i8], align 1
  %4 = alloca i8, align 1
  %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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 10, ptr %2) #7
  call void @llvm.lifetime.start.p0(i64 10, ptr %3) #7
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %11

11:                                               ; preds = %164, %0
  %12 = load i32, ptr @t, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr @t, align 4, !tbaa !5
  %14 = icmp ne i32 %12, 0
  br i1 %14, label %15, label %165

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #7
  store i8 1, ptr %4, align 1, !tbaa !9
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @vis, i8 0, i64 4040, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @pre, i8 -1, i64 16160, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @leaf, i8 0, i64 4040, i1 false)
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.11, ptr noundef @k, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %37, %15
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = load i32, ptr @k, align 4, !tbaa !5
  %20 = icmp sle i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %40

22:                                               ; preds = %17
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = load i32, ptr @k, align 4, !tbaa !5
  %25 = add nsw i32 %23, %24
  %26 = load i32, ptr @m, align 4, !tbaa !5
  %27 = add nsw i32 %25, %26
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = add nsw i32 %27, %28
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %30
  store i8 1, ptr %31, align 1, !tbaa !9
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = add nsw i32 %32, %33
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %35
  store i8 1, ptr %36, align 1, !tbaa !9
  br label %37

37:                                               ; preds = %22
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %5, align 4, !tbaa !5
  br label %17, !llvm.loop !11

40:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %56, %40
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = load i32, ptr @n, align 4, !tbaa !5
  %44 = load i32, ptr @k, align 4, !tbaa !5
  %45 = add nsw i32 %43, %44
  %46 = icmp slt i32 %42, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %59

48:                                               ; preds = %41
  %49 = getelementptr inbounds [10 x i8], ptr %2, i64 0, i64 0
  %50 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.12, ptr noundef %49, ptr noundef %50)
  %52 = getelementptr inbounds [10 x i8], ptr %2, i64 0, i64 0
  %53 = call noundef i32 @_Z3idxPc(ptr noundef %52)
  %54 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %55 = call noundef i32 @_Z3idxPc(ptr noundef %54)
  call void @_Z7addedgeii(i32 noundef %53, i32 noundef %55)
  br label %56

56:                                               ; preds = %48
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %6, align 4, !tbaa !5
  br label %41, !llvm.loop !13

59:                                               ; preds = %47
  %60 = call noundef zeroext i1 @_Z3dfsii(i32 noundef 1, i32 noundef -1)
  %61 = zext i1 %60 to i32
  %62 = load i8, ptr %4, align 1, !tbaa !9, !range !14, !noundef !15
  %63 = trunc i8 %62 to i1
  %64 = zext i1 %63 to i32
  %65 = and i32 %64, %61
  %66 = icmp ne i32 %65, 0
  %67 = zext i1 %66 to i8
  store i8 %67, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %83, %59
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = load i32, ptr @m, align 4, !tbaa !5
  %71 = load i32, ptr @k, align 4, !tbaa !5
  %72 = add nsw i32 %70, %71
  %73 = icmp slt i32 %69, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %86

75:                                               ; preds = %68
  %76 = getelementptr inbounds [10 x i8], ptr %2, i64 0, i64 0
  %77 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %78 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.12, ptr noundef %76, ptr noundef %77)
  %79 = getelementptr inbounds [10 x i8], ptr %2, i64 0, i64 0
  %80 = call noundef i32 @_Z3idxPc(ptr noundef %79)
  %81 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %82 = call noundef i32 @_Z3idxPc(ptr noundef %81)
  call void @_Z7addedgeii(i32 noundef %80, i32 noundef %82)
  br label %83

83:                                               ; preds = %75
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %7, align 4, !tbaa !5
  br label %68, !llvm.loop !16

86:                                               ; preds = %74
  %87 = load i8, ptr %4, align 1, !tbaa !9, !range !14, !noundef !15
  %88 = trunc i8 %87 to i1
  br i1 %88, label %89, label %102

89:                                               ; preds = %86
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = load i32, ptr @k, align 4, !tbaa !5
  %92 = add nsw i32 %90, %91
  %93 = add nsw i32 %92, 1
  %94 = call noundef zeroext i1 @_Z3dfsii(i32 noundef %93, i32 noundef -1)
  %95 = zext i1 %94 to i32
  %96 = load i8, ptr %4, align 1, !tbaa !9, !range !14, !noundef !15
  %97 = trunc i8 %96 to i1
  %98 = zext i1 %97 to i32
  %99 = and i32 %98, %95
  %100 = icmp ne i32 %99, 0
  %101 = zext i1 %100 to i8
  store i8 %101, ptr %4, align 1, !tbaa !9
  br label %102

102:                                              ; preds = %89, %86
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %116, %102
  %104 = load i32, ptr %8, align 4, !tbaa !5
  %105 = load i32, ptr @k, align 4, !tbaa !5
  %106 = icmp slt i32 %104, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %119

108:                                              ; preds = %103
  %109 = getelementptr inbounds [10 x i8], ptr %2, i64 0, i64 0
  %110 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %111 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.12, ptr noundef %109, ptr noundef %110)
  %112 = getelementptr inbounds [10 x i8], ptr %2, i64 0, i64 0
  %113 = call noundef i32 @_Z3idxPc(ptr noundef %112)
  %114 = getelementptr inbounds [10 x i8], ptr %3, i64 0, i64 0
  %115 = call noundef i32 @_Z3idxPc(ptr noundef %114)
  call void @_Z7addedgeii(i32 noundef %113, i32 noundef %115)
  br label %116

116:                                              ; preds = %108
  %117 = load i32, ptr %8, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %8, align 4, !tbaa !5
  br label %103, !llvm.loop !17

119:                                              ; preds = %107
  %120 = load i8, ptr %4, align 1, !tbaa !9, !range !14, !noundef !15
  %121 = trunc i8 %120 to i1
  br i1 %121, label %122, label %131

122:                                              ; preds = %119
  %123 = call noundef zeroext i1 @_Z3pfsi(i32 noundef 1)
  %124 = zext i1 %123 to i32
  %125 = load i8, ptr %4, align 1, !tbaa !9, !range !14, !noundef !15
  %126 = trunc i8 %125 to i1
  %127 = zext i1 %126 to i32
  %128 = and i32 %127, %124
  %129 = icmp ne i32 %128, 0
  %130 = zext i1 %129 to i8
  store i8 %130, ptr %4, align 1, !tbaa !9
  br label %131

131:                                              ; preds = %122, %119
  %132 = load i8, ptr %4, align 1, !tbaa !9, !range !14, !noundef !15
  %133 = trunc i8 %132 to i1
  br i1 %133, label %134, label %162

134:                                              ; preds = %131
  %135 = load i32, ptr @ans, align 4, !tbaa !5
  %136 = load i32, ptr @n, align 4, !tbaa !5
  %137 = load i32, ptr @k, align 4, !tbaa !5
  %138 = add nsw i32 %136, %137
  %139 = load i32, ptr @m, align 4, !tbaa !5
  %140 = add nsw i32 %138, %139
  %141 = load i32, ptr @k, align 4, !tbaa !5
  %142 = add nsw i32 %140, %141
  %143 = icmp eq i32 %135, %142
  br i1 %143, label %144, label %162

144:                                              ; preds = %134
  %145 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %146

146:                                              ; preds = %157, %144
  %147 = load i32, ptr %9, align 4, !tbaa !5
  %148 = load i32, ptr @ans, align 4, !tbaa !5
  %149 = icmp slt i32 %147, %148
  br i1 %149, label %151, label %150

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

151:                                              ; preds = %146
  %152 = load i32, ptr %9, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [4040 x i32], ptr @que, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  call void @_Z3idxi(i32 noundef %155)
  %156 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, ptr noundef @out)
  br label %157

157:                                              ; preds = %151
  %158 = load i32, ptr %9, align 4, !tbaa !5
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %9, align 4, !tbaa !5
  br label %146, !llvm.loop !18

160:                                              ; preds = %150
  %161 = call i32 @putchar(i32 noundef 10)
  br label %164

162:                                              ; preds = %134, %131
  %163 = call i32 @puts(ptr noundef @.str.15)
  br label %164

164:                                              ; preds = %162, %160
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #7
  br label %11, !llvm.loop !19

165:                                              ; preds = %11
  call void @llvm.lifetime.end.p0(i64 10, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 10, ptr %2) #7
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #6

declare i32 @puts(ptr noundef) #4

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@out = external dso_local global [10 x i8], align 1
@tot = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global [4040 x i32], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@que = external dso_local local_unnamed_addr global [4040 x i32], align 16
@leaf = external dso_local local_unnamed_addr global [4040 x i8], align 16
@vis = external dso_local local_unnamed_addr global [4040 x i8], align 16
@.str.11 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3idxPc(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: 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 void @_Z3idxi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z7addedgeii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z3dfsii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z3pfsi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca [10 x i8], align 1
  %2 = alloca [10 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %2) #7
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %.not44 = icmp eq i32 %4, 0
  br i1 %.not44, label %._crit_edge47, label %.lr.ph46

.lr.ph46:                                         ; preds = %0, %135
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @tot, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4040) @vis, i8 0, i64 4040, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16160) @pre, i8 -1, i64 16160, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4040) @leaf, i8 0, i64 4040, i1 false)
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.11, ptr noundef nonnull @k, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %7 = load i32, ptr @k, align 4, !tbaa !5
  %.not2628 = icmp slt i32 %7, 1
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br i1 %.not2628, label %.preheader, label %iter.check

iter.check:                                       ; preds = %.lr.ph46
  %8 = load i32, ptr @m, align 4, !tbaa !5
  %9 = sext i32 %.pre to i64
  %10 = add nuw i32 %7, 1
  %wide.trip.count = zext i32 %10 to i64
  %11 = zext nneg i32 %7 to i64
  %min.iters.check = icmp ult i32 %7, 8
  br i1 %min.iters.check, label %vec.epilog.scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %iter.check
  %12 = add nsw i64 %wide.trip.count, -2
  %13 = add i32 %.pre, 1
  %14 = add i32 %13, %8
  %15 = add i32 %14, %7
  %16 = trunc i64 %12 to i32
  %17 = add i32 %15, %16
  %18 = icmp slt i32 %17, %15
  %19 = icmp ugt i64 %12, 4294967295
  %20 = or i1 %18, %19
  br i1 %20, label %vec.epilog.scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %vector.scevcheck
  %21 = add nsw i64 %9, 1
  %22 = add i32 %.pre, 1
  %23 = add i32 %22, %8
  %24 = add i32 %23, %7
  %25 = sext i32 %24 to i64
  %26 = sub nsw i64 %21, %25
  %diff.check = icmp ult i64 %26, 32
  br i1 %diff.check, label %vec.epilog.scalar.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %vector.memcheck
  %min.iters.check56 = icmp ult i32 %7, 32
  br i1 %min.iters.check56, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %11, 2147483616
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %27 = trunc i64 %index to i32
  %28 = or disjoint i32 %27, 1
  %29 = add i32 %7, %28
  %30 = add i32 %29, %.pre
  %31 = add i32 %30, %8
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %32
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  store <16 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, ptr %33, align 1, !tbaa !9
  store <16 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, ptr %34, align 1, !tbaa !9
  %35 = add nsw i64 %offset.idx, %9
  %36 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %35
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  store <16 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, ptr %36, align 1, !tbaa !9
  store <16 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, ptr %37, align 1, !tbaa !9
  %index.next = add nuw i64 %index, 32
  %38 = icmp eq i64 %index.next, %n.vec
  br i1 %38, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %11
  br i1 %cmp.n, label %.preheader, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end60 = or disjoint i64 %n.vec, 1
  %n.vec.remaining = and i64 %11, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %vec.epilog.scalar.ph.preheader, label %vec.epilog.ph

vec.epilog.scalar.ph.preheader:                   ; preds = %vec.epilog.middle.block, %vector.memcheck, %vector.scevcheck, %iter.check, %vec.epilog.iter.check
  %indvars.iv.ph = phi i64 [ 1, %iter.check ], [ 1, %vector.memcheck ], [ 1, %vector.scevcheck ], [ %ind.end60, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  %39 = zext nneg i32 %7 to i64
  %40 = and i32 %7, 1
  %lcmp.mod.not = icmp eq i32 %40, 0
  br i1 %lcmp.mod.not, label %vec.epilog.scalar.ph.prol.loopexit, label %vec.epilog.scalar.ph.prol

vec.epilog.scalar.ph.prol:                        ; preds = %vec.epilog.scalar.ph.preheader
  %41 = trunc i64 %indvars.iv.ph to i32
  %42 = add i32 %7, %41
  %43 = add i32 %42, %.pre
  %44 = add i32 %43, %8
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %45
  store i8 1, ptr %46, align 1, !tbaa !9
  %47 = add nsw i64 %indvars.iv.ph, %9
  %48 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %47
  store i8 1, ptr %48, align 1, !tbaa !9
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.ph, 1
  br label %vec.epilog.scalar.ph.prol.loopexit

vec.epilog.scalar.ph.prol.loopexit:               ; preds = %vec.epilog.scalar.ph.prol, %vec.epilog.scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %vec.epilog.scalar.ph.preheader ], [ %indvars.iv.next.prol, %vec.epilog.scalar.ph.prol ]
  %49 = icmp eq i64 %indvars.iv.ph, %39
  br i1 %49, label %.preheader, label %vec.epilog.scalar.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec59 = and i64 %11, 2147483640
  %ind.end = or disjoint i64 %n.vec59, 1
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index61 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next64, %vec.epilog.vector.body ]
  %offset.idx62 = or disjoint i64 %index61, 1
  %50 = trunc i64 %index61 to i32
  %51 = or disjoint i32 %50, 1
  %52 = add i32 %7, %51
  %53 = add i32 %52, %.pre
  %54 = add i32 %53, %8
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %55
  store <8 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, ptr %56, align 1, !tbaa !9
  %57 = add nsw i64 %offset.idx62, %9
  %58 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %57
  store <8 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, ptr %58, align 1, !tbaa !9
  %index.next64 = add nuw i64 %index61, 8
  %59 = icmp eq i64 %index.next64, %n.vec59
  br i1 %59, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !15

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n65 = icmp eq i64 %n.vec59, %11
  br i1 %cmp.n65, label %.preheader, label %vec.epilog.scalar.ph.preheader

.preheader:                                       ; preds = %vec.epilog.scalar.ph.prol.loopexit, %vec.epilog.scalar.ph, %middle.block, %vec.epilog.middle.block, %.lr.ph46
  %60 = add nsw i32 %7, %.pre
  %61 = icmp sgt i32 %60, 1
  br i1 %61, label %.lr.ph31, label %._crit_edge

vec.epilog.scalar.ph:                             ; preds = %vec.epilog.scalar.ph.prol.loopexit, %vec.epilog.scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %vec.epilog.scalar.ph ], [ %indvars.iv.unr, %vec.epilog.scalar.ph.prol.loopexit ]
  %62 = trunc i64 %indvars.iv to i32
  %63 = add i32 %7, %62
  %64 = add i32 %63, %.pre
  %65 = add i32 %64, %8
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %66
  store i8 1, ptr %67, align 1, !tbaa !9
  %68 = add nsw i64 %indvars.iv, %9
  %69 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %68
  store i8 1, ptr %69, align 1, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %70 = trunc i64 %indvars.iv.next to i32
  %71 = add i32 %7, %70
  %72 = add i32 %71, %.pre
  %73 = add i32 %72, %8
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %74
  store i8 1, ptr %75, align 1, !tbaa !9
  %76 = add nsw i64 %indvars.iv.next, %9
  %77 = getelementptr inbounds [4040 x i8], ptr @leaf, i64 0, i64 %76
  store i8 1, ptr %77, align 1, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %.preheader, label %vec.epilog.scalar.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph31, %.preheader
  %78 = call noundef zeroext i1 @_Z3dfsii(i32 noundef 1, i32 noundef -1)
  %79 = load i32, ptr @m, align 4, !tbaa !5
  %80 = load i32, ptr @k, align 4, !tbaa !5
  %81 = add nsw i32 %80, %79
  %82 = icmp sgt i32 %81, 1
  br i1 %82, label %.lr.ph34, label %._crit_edge35

.lr.ph31:                                         ; preds = %.preheader, %.lr.ph31
  %.02130 = phi i32 [ %86, %.lr.ph31 ], [ 1, %.preheader ]
  %83 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.12, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %84 = call noundef i32 @_Z3idxPc(ptr noundef nonnull %1)
  %85 = call noundef i32 @_Z3idxPc(ptr noundef nonnull %2)
  call void @_Z7addedgeii(i32 noundef %84, i32 noundef %85)
  %86 = add nuw nsw i32 %.02130, 1
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = load i32, ptr @k, align 4, !tbaa !5
  %89 = add nsw i32 %88, %87
  %90 = icmp slt i32 %86, %89
  br i1 %90, label %.lr.ph31, label %._crit_edge, !llvm.loop !17

._crit_edge35:                                    ; preds = %.lr.ph34, %._crit_edge
  %.lcssa = phi i32 [ %80, %._crit_edge ], [ %96, %.lr.ph34 ]
  br i1 %78, label %99, label %104

.lr.ph34:                                         ; preds = %._crit_edge, %.lr.ph34
  %.02032 = phi i32 [ %94, %.lr.ph34 ], [ 1, %._crit_edge ]
  %91 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.12, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %92 = call noundef i32 @_Z3idxPc(ptr noundef nonnull %1)
  %93 = call noundef i32 @_Z3idxPc(ptr noundef nonnull %2)
  call void @_Z7addedgeii(i32 noundef %92, i32 noundef %93)
  %94 = add nuw nsw i32 %.02032, 1
  %95 = load i32, ptr @m, align 4, !tbaa !5
  %96 = load i32, ptr @k, align 4, !tbaa !5
  %97 = add nsw i32 %96, %95
  %98 = icmp slt i32 %94, %97
  br i1 %98, label %.lr.ph34, label %._crit_edge35, !llvm.loop !18

99:                                               ; preds = %._crit_edge35
  %100 = load i32, ptr @n, align 4, !tbaa !5
  %101 = add i32 %.lcssa, 1
  %102 = add i32 %101, %100
  %103 = call noundef zeroext i1 @_Z3dfsii(i32 noundef %102, i32 noundef -1)
  %.pre53 = load i32, ptr @k, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %99, %._crit_edge35
  %105 = phi i32 [ %.pre53, %99 ], [ %.lcssa, %._crit_edge35 ]
  %.023.in = phi i1 [ %103, %99 ], [ false, %._crit_edge35 ]
  %106 = icmp sgt i32 %105, 0
  br i1 %106, label %.lr.ph38, label %._crit_edge39

._crit_edge39:                                    ; preds = %.lr.ph38, %104
  br i1 %.023.in, label %113, label %.thread

.lr.ph38:                                         ; preds = %104, %.lr.ph38
  %.01936 = phi i32 [ %110, %.lr.ph38 ], [ 0, %104 ]
  %107 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.12, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %108 = call noundef i32 @_Z3idxPc(ptr noundef nonnull %1)
  %109 = call noundef i32 @_Z3idxPc(ptr noundef nonnull %2)
  call void @_Z7addedgeii(i32 noundef %108, i32 noundef %109)
  %110 = add nuw nsw i32 %.01936, 1
  %111 = load i32, ptr @k, align 4, !tbaa !5
  %112 = icmp slt i32 %110, %111
  br i1 %112, label %.lr.ph38, label %._crit_edge39, !llvm.loop !19

113:                                              ; preds = %._crit_edge39
  %114 = call noundef zeroext i1 @_Z3pfsi(i32 noundef 1)
  br i1 %114, label %115, label %.thread

115:                                              ; preds = %113
  %116 = load i32, ptr @ans, align 4, !tbaa !5
  %117 = load i32, ptr @n, align 4, !tbaa !5
  %118 = load i32, ptr @k, align 4, !tbaa !5
  %119 = load i32, ptr @m, align 4, !tbaa !5
  %factor = shl i32 %118, 1
  %120 = add i32 %119, %117
  %121 = add i32 %120, %factor
  %122 = icmp eq i32 %116, %121
  br i1 %122, label %123, label %.thread

123:                                              ; preds = %115
  %124 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %125 = load i32, ptr @ans, align 4, !tbaa !5
  %126 = icmp sgt i32 %125, 0
  br i1 %126, label %.lr.ph42, label %._crit_edge43

._crit_edge43:                                    ; preds = %.lr.ph42, %123
  %127 = call i32 @putchar(i32 noundef 10)
  br label %135

.lr.ph42:                                         ; preds = %123, %.lr.ph42
  %indvars.iv50 = phi i64 [ %indvars.iv.next51, %.lr.ph42 ], [ 0, %123 ]
  %128 = getelementptr inbounds [4040 x i32], ptr @que, i64 0, i64 %indvars.iv50
  %129 = load i32, ptr %128, align 4, !tbaa !5
  call void @_Z3idxi(i32 noundef %129)
  %130 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, ptr noundef nonnull @out)
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %131 = load i32, ptr @ans, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = icmp slt i64 %indvars.iv.next51, %132
  br i1 %133, label %.lr.ph42, label %._crit_edge43, !llvm.loop !20

.thread:                                          ; preds = %._crit_edge39, %115, %113
  %134 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.15)
  br label %135

135:                                              ; preds = %.thread, %._crit_edge43
  %136 = load i32, ptr @t, align 4, !tbaa !5
  %137 = add nsw i32 %136, -1
  store i32 %137, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %136, 0
  br i1 %.not, label %._crit_edge47, label %.lr.ph46, !llvm.loop !21

._crit_edge47:                                    ; preds = %135, %0
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %1) #7
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6

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

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 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 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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { inlinehint mustprogress nofree 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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !13, !14}
!16 = distinct !{!16, !12, !13}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}


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