; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (1028（dp）)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [122 x [122 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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 59536, ptr %2) #4
  call void @llvm.memset.p0.i64(ptr align 16 %2, i8 0, i64 59536, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %29, %0
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 121
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %8
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 %14
  %16 = getelementptr inbounds [122 x i32], ptr %15, i64 0, i64 0
  store i32 1, ptr %16, align 8, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 %18
  %20 = getelementptr inbounds [122 x i32], ptr %19, i64 0, i64 1
  store i32 1, ptr %20, align 4, !tbaa !5
  %21 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 0
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [122 x i32], ptr %21, i64 0, i64 %23
  store i32 1, ptr %24, align 4, !tbaa !5
  %25 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 1
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [122 x i32], ptr %25, i64 0, i64 %27
  store i32 1, ptr %28, align 4, !tbaa !5
  br label %29

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

32:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 2, ptr %5, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %90, %32
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = icmp slt i32 %34, 121
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %93

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 2, ptr %7, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %86, %37
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = icmp slt i32 %39, 121
  br i1 %40, label %42, label %41

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

42:                                               ; preds = %38
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = icmp sge i32 %43, %44
  br i1 %45, label %46, label %71

46:                                               ; preds = %42
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 %48
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [122 x i32], ptr %49, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = sub nsw i32 %55, %56
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 %58
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [122 x i32], ptr %59, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = add nsw i32 %54, %63
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 %66
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [122 x i32], ptr %67, i64 0, i64 %69
  store i32 %64, ptr %70, align 4, !tbaa !5
  br label %85

71:                                               ; preds = %42
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 %73
  %75 = load i32, ptr %5, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [122 x i32], ptr %74, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 %80
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [122 x i32], ptr %81, i64 0, i64 %83
  store i32 %78, ptr %84, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %71, %46
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %7, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %7, align 4, !tbaa !5
  br label %38, !llvm.loop !11

89:                                               ; preds = %41
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %5, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %5, align 4, !tbaa !5
  br label %33, !llvm.loop !12

93:                                               ; preds = %36
  br label %94

94:                                               ; preds = %97, %93
  %95 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  %96 = icmp eq i32 %95, 1
  br i1 %96, label %97, label %106

97:                                               ; preds = %94
  %98 = load i32, ptr %3, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [122 x [122 x i32]], ptr %2, i64 0, i64 %99
  %101 = load i32, ptr %3, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [122 x i32], ptr %100, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %104)
  br label %94, !llvm.loop !13

106:                                              ; preds = %94
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 59536, ptr %2) #4
  %107 = load i32, ptr %1, align 4
  ret i32 %107
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

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

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

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [122 x [122 x i32]], align 16
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 59536, ptr nonnull %1) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(59536) %1, i8 0, i64 59536, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = getelementptr inbounds i8, ptr %1, i64 488
  br label %4

4:                                                ; preds = %9, %0
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next.1, %9 ]
  %5 = getelementptr inbounds [122 x [122 x i32]], ptr %1, i64 0, i64 %indvars.iv
  store i32 1, ptr %5, align 16, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 1, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds [122 x i32], ptr %1, i64 0, i64 %indvars.iv
  store i32 1, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds [122 x i32], ptr %3, i64 0, i64 %indvars.iv
  store i32 1, ptr %8, align 8, !tbaa !5
  %exitcond.not = icmp eq i64 %indvars.iv, 120
  br i1 %exitcond.not, label %.preheader26, label %9, !llvm.loop !9

9:                                                ; preds = %4
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %10 = getelementptr inbounds [122 x [122 x i32]], ptr %1, i64 0, i64 %indvars.iv.next
  store i32 1, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 4
  store i32 1, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds [122 x i32], ptr %1, i64 0, i64 %indvars.iv.next
  store i32 1, ptr %12, align 4, !tbaa !5
  %13 = getelementptr inbounds [122 x i32], ptr %3, i64 0, i64 %indvars.iv.next
  store i32 1, ptr %13, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %4

.preheader26:                                     ; preds = %4, %17
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %17 ], [ 2, %4 ]
  %14 = getelementptr inbounds [122 x [122 x i32]], ptr %1, i64 0, i64 %indvars.iv36, i64 %indvars.iv36
  br label %18

.preheader:                                       ; preds = %17
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %.lr.ph, label %._crit_edge

17:                                               ; preds = %29
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %exitcond39.not = icmp eq i64 %indvars.iv.next37, 121
  br i1 %exitcond39.not, label %.preheader, label %.preheader26, !llvm.loop !11

18:                                               ; preds = %.preheader26, %29
  %indvars.iv32 = phi i64 [ 2, %.preheader26 ], [ %indvars.iv.next33, %29 ]
  %.not = icmp ult i64 %indvars.iv36, %indvars.iv32
  br i1 %.not, label %27, label %19

19:                                               ; preds = %18
  %20 = add nsw i64 %indvars.iv32, -1
  %21 = getelementptr inbounds [122 x [122 x i32]], ptr %1, i64 0, i64 %indvars.iv36, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = sub nsw i64 %indvars.iv36, %indvars.iv32
  %24 = getelementptr inbounds [122 x [122 x i32]], ptr %1, i64 0, i64 %23, i64 %indvars.iv32
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = add nsw i32 %25, %22
  br label %29

27:                                               ; preds = %18
  %28 = load i32, ptr %14, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %19, %27
  %.sink = phi i32 [ %28, %27 ], [ %26, %19 ]
  %30 = getelementptr inbounds [122 x [122 x i32]], ptr %1, i64 0, i64 %indvars.iv36, i64 %indvars.iv32
  store i32 %.sink, ptr %30, align 4
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %exitcond35.not = icmp eq i64 %indvars.iv.next33, 121
  br i1 %exitcond35.not, label %17, label %18, !llvm.loop !12

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [122 x [122 x i32]], ptr %1, i64 0, i64 %32, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %34)
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %37 = icmp eq i32 %36, 1
  br i1 %37, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 59536, ptr nonnull %1) #4
  ret i32 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

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

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

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass