; LLVM IR from DionysiosB/CodeForces :: 1921A-Square (main)

; 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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

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

12:                                               ; preds = %97, %0
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = add nsw i64 %13, -1
  store i64 %14, ptr %2, align 8, !tbaa !5
  %15 = icmp ne i64 %13, 0
  br i1 %15, label %16, label %100

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %29, %16
  %18 = load i64, ptr %5, align 8, !tbaa !5
  %19 = icmp slt i64 %18, 4
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %32

21:                                               ; preds = %17
  %22 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 0
  %23 = load i64, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds i64, ptr %22, i64 %23
  %25 = getelementptr inbounds [4 x i64], ptr %4, i64 0, i64 0
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds i64, ptr %25, i64 %26
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %24, ptr noundef %27)
  br label %29

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

32:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 1, ptr %8, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %57, %32
  %34 = load i64, ptr %6, align 8, !tbaa !5
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %39, label %36

36:                                               ; preds = %33
  %37 = load i64, ptr %8, align 8, !tbaa !5
  %38 = icmp slt i64 %37, 4
  br label %39

39:                                               ; preds = %36, %33
  %40 = phi i1 [ false, %33 ], [ %38, %36 ]
  br i1 %40, label %42, label %41

41:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %60

42:                                               ; preds = %39
  %43 = load i64, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 0
  %47 = load i64, ptr %46, align 16, !tbaa !5
  %48 = icmp eq i64 %45, %47
  br i1 %48, label %49, label %56

49:                                               ; preds = %42
  %50 = load i64, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds [4 x i64], ptr %4, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !5
  %53 = getelementptr inbounds [4 x i64], ptr %4, i64 0, i64 0
  %54 = load i64, ptr %53, align 16, !tbaa !5
  %55 = sub nsw i64 %52, %54
  store i64 %55, ptr %6, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %49, %42
  br label %57

57:                                               ; preds = %56
  %58 = load i64, ptr %8, align 8, !tbaa !5
  %59 = add nsw i64 %58, 1
  store i64 %59, ptr %8, align 8, !tbaa !5
  br label %33, !llvm.loop !11

60:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 1, ptr %9, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %85, %60
  %62 = load i64, ptr %7, align 8, !tbaa !5
  %63 = icmp ne i64 %62, 0
  br i1 %63, label %67, label %64

64:                                               ; preds = %61
  %65 = load i64, ptr %9, align 8, !tbaa !5
  %66 = icmp slt i64 %65, 4
  br label %67

67:                                               ; preds = %64, %61
  %68 = phi i1 [ false, %61 ], [ %66, %64 ]
  br i1 %68, label %70, label %69

69:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %88

70:                                               ; preds = %67
  %71 = load i64, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds [4 x i64], ptr %4, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !5
  %74 = getelementptr inbounds [4 x i64], ptr %4, i64 0, i64 0
  %75 = load i64, ptr %74, align 16, !tbaa !5
  %76 = icmp eq i64 %73, %75
  br i1 %76, label %77, label %84

77:                                               ; preds = %70
  %78 = load i64, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 %78
  %80 = load i64, ptr %79, align 8, !tbaa !5
  %81 = getelementptr inbounds [4 x i64], ptr %3, i64 0, i64 0
  %82 = load i64, ptr %81, align 16, !tbaa !5
  %83 = sub nsw i64 %80, %82
  store i64 %83, ptr %7, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %77, %70
  br label %85

85:                                               ; preds = %84
  %86 = load i64, ptr %9, align 8, !tbaa !5
  %87 = add nsw i64 %86, 1
  store i64 %87, ptr %9, align 8, !tbaa !5
  br label %61, !llvm.loop !12

88:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %89 = load i64, ptr %6, align 8, !tbaa !5
  %90 = load i64, ptr %7, align 8, !tbaa !5
  %91 = mul nsw i64 %89, %90
  store i64 %91, ptr %10, align 8, !tbaa !5
  %92 = load i64, ptr %10, align 8, !tbaa !5
  %93 = icmp slt i64 %92, 0
  br i1 %93, label %94, label %97

94:                                               ; preds = %88
  %95 = load i64, ptr %10, align 8, !tbaa !5
  %96 = mul nsw i64 %95, -1
  store i64 %96, ptr %10, align 8, !tbaa !5
  br label %97

97:                                               ; preds = %94, %88
  %98 = load i64, ptr %10, align 8, !tbaa !5
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %98)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #3
  br label %12, !llvm.loop !13

100:                                              ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %101 = load i32, ptr %1, align 4
  ret i32 %101
}

; 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

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

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 = { "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 = { 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 = !{!"long", !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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca [4 x i64], align 16
  %3 = alloca [4 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = add nsw i64 %5, -1
  store i64 %6, ptr %1, align 8, !tbaa !5
  %.not34 = icmp eq i64 %5, 0
  br i1 %.not34, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = getelementptr inbounds i8, ptr %2, i64 16
  %10 = getelementptr inbounds i8, ptr %3, i64 16
  %11 = getelementptr inbounds i8, ptr %2, i64 24
  %12 = getelementptr inbounds i8, ptr %3, i64 24
  %13 = getelementptr inbounds i8, ptr %2, i64 8
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  %15 = getelementptr inbounds i8, ptr %2, i64 16
  %16 = getelementptr inbounds i8, ptr %3, i64 16
  %17 = getelementptr inbounds i8, ptr %2, i64 24
  %18 = getelementptr inbounds i8, ptr %3, i64 24
  %19 = getelementptr inbounds i8, ptr %3, i64 8
  %20 = getelementptr inbounds i8, ptr %2, i64 8
  %21 = getelementptr inbounds i8, ptr %3, i64 16
  %22 = getelementptr inbounds i8, ptr %2, i64 16
  %23 = getelementptr inbounds i8, ptr %3, i64 24
  %24 = getelementptr inbounds i8, ptr %2, i64 24
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %45
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %27 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %9, ptr noundef nonnull %10)
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %11, ptr noundef nonnull %12)
  %29 = load i64, ptr %2, align 16
  %30 = load i64, ptr %3, align 16
  %31 = load i64, ptr %13, align 8, !tbaa !5
  %32 = icmp eq i64 %31, %29
  %33 = load i64, ptr %14, align 8
  %34 = sub nsw i64 %33, %30
  %.124 = select i1 %32, i64 %34, i64 0
  %.not28 = icmp eq i64 %.124, 0
  br i1 %.not28, label %35, label %.preheader, !llvm.loop !9

35:                                               ; preds = %.lr.ph
  %36 = load i64, ptr %15, align 16, !tbaa !5
  %37 = icmp eq i64 %36, %29
  %38 = load i64, ptr %16, align 16
  %39 = sub nsw i64 %38, %30
  %.124.1 = select i1 %37, i64 %39, i64 0
  %.not28.1 = icmp eq i64 %.124.1, 0
  br i1 %.not28.1, label %40, label %.preheader, !llvm.loop !9

40:                                               ; preds = %35
  %41 = load i64, ptr %17, align 8, !tbaa !5
  %42 = icmp eq i64 %41, %29
  %43 = load i64, ptr %18, align 8
  %44 = sub nsw i64 %43, %30
  %.124.2 = select i1 %42, i64 %44, i64 0
  br label %.preheader

45:                                               ; preds = %.preheader.2, %.preheader.1, %.preheader
  %.1.lcssa = phi i64 [ %.1, %.preheader ], [ %.1.1, %.preheader.1 ], [ %.1.2, %.preheader.2 ]
  %46 = mul nsw i64 %.1.lcssa, %.124.lcssa
  %spec.select = call i64 @llvm.abs.i64(i64 %46, i1 true)
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %spec.select)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #4
  %48 = load i64, ptr %1, align 8, !tbaa !5
  %49 = add nsw i64 %48, -1
  store i64 %49, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %48, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph, %35, %40
  %.124.lcssa = phi i64 [ %.124, %.lr.ph ], [ %.124.1, %35 ], [ %.124.2, %40 ]
  %50 = load i64, ptr %19, align 8, !tbaa !5
  %51 = icmp eq i64 %50, %30
  %52 = load i64, ptr %20, align 8
  %53 = sub nsw i64 %52, %29
  %.1 = select i1 %51, i64 %53, i64 0
  %.not29 = icmp eq i64 %.1, 0
  br i1 %.not29, label %.preheader.1, label %45, !llvm.loop !12

.preheader.1:                                     ; preds = %.preheader
  %54 = load i64, ptr %21, align 16, !tbaa !5
  %55 = icmp eq i64 %54, %30
  %56 = load i64, ptr %22, align 16
  %57 = sub nsw i64 %56, %29
  %.1.1 = select i1 %55, i64 %57, i64 0
  %.not29.1 = icmp eq i64 %.1.1, 0
  br i1 %.not29.1, label %.preheader.2, label %45, !llvm.loop !12

.preheader.2:                                     ; preds = %.preheader.1
  %58 = load i64, ptr %23, align 8, !tbaa !5
  %59 = icmp eq i64 %58, %30
  %60 = load i64, ptr %24, align 8
  %61 = sub nsw i64 %60, %29
  %.1.2 = select i1 %59, i64 %61, i64 0
  br label %45

._crit_edge:                                      ; preds = %45, %0
  call void @llvm.lifetime.end.p0(i64 8, 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: 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long", !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}


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